@salutejs/plasma-new-hope 0.193.0 → 0.194.0-canary.1558.11852073996.0
Sign up to get free protection for your applications and to get access to all the features.
- package/cjs/components/Modal/Modal.css +6 -0
- package/cjs/components/Modal/Modal.js +27 -13
- package/cjs/components/Modal/Modal.js.map +1 -1
- package/cjs/components/Modal/Modal.styles.js +27 -0
- package/cjs/components/Modal/Modal.styles.js.map +1 -0
- package/cjs/components/Modal/Modal.styles_tqsxxy.css +3 -0
- package/cjs/components/Modal/Modal.tokens.js +7 -1
- package/cjs/components/Modal/Modal.tokens.js.map +1 -1
- package/cjs/index.css +4 -0
- package/emotion/cjs/components/Modal/Modal.js +26 -12
- package/emotion/cjs/components/Modal/Modal.styles.js +27 -0
- package/emotion/cjs/components/Modal/Modal.template-doc.mdx +47 -0
- package/emotion/cjs/components/Modal/Modal.tokens.js +7 -1
- package/emotion/cjs/examples/plasma_b2c/components/Modal/Modal.config.js +1 -1
- package/emotion/cjs/examples/plasma_b2c/components/Modal/Modal.stories.tsx +90 -1
- package/emotion/cjs/examples/plasma_web/components/Modal/Modal.config.js +1 -1
- package/emotion/cjs/examples/plasma_web/components/Modal/Modal.stories.tsx +90 -1
- package/emotion/es/components/Modal/Modal.js +26 -12
- package/emotion/es/components/Modal/Modal.styles.js +20 -0
- package/emotion/es/components/Modal/Modal.template-doc.mdx +47 -0
- package/emotion/es/components/Modal/Modal.tokens.js +7 -1
- package/emotion/es/examples/plasma_b2c/components/Modal/Modal.config.js +1 -1
- package/emotion/es/examples/plasma_b2c/components/Modal/Modal.stories.tsx +90 -1
- package/emotion/es/examples/plasma_web/components/Modal/Modal.config.js +1 -1
- package/emotion/es/examples/plasma_web/components/Modal/Modal.stories.tsx +90 -1
- package/es/components/Modal/Modal.css +6 -0
- package/es/components/Modal/Modal.js +27 -13
- package/es/components/Modal/Modal.js.map +1 -1
- package/es/components/Modal/Modal.styles.js +21 -0
- package/es/components/Modal/Modal.styles.js.map +1 -0
- package/es/components/Modal/Modal.styles_tqsxxy.css +3 -0
- package/es/components/Modal/Modal.tokens.js +7 -1
- package/es/components/Modal/Modal.tokens.js.map +1 -1
- package/es/index.css +4 -0
- package/package.json +2 -2
- package/styled-components/cjs/components/Modal/Modal.js +26 -12
- package/styled-components/cjs/components/Modal/Modal.styles.js +24 -0
- package/styled-components/cjs/components/Modal/Modal.template-doc.mdx +47 -0
- package/styled-components/cjs/components/Modal/Modal.tokens.js +7 -1
- package/styled-components/cjs/examples/plasma_b2c/components/Modal/Modal.config.js +1 -1
- package/styled-components/cjs/examples/plasma_b2c/components/Modal/Modal.stories.tsx +90 -1
- package/styled-components/cjs/examples/plasma_web/components/Modal/Modal.config.js +1 -1
- package/styled-components/cjs/examples/plasma_web/components/Modal/Modal.stories.tsx +90 -1
- package/styled-components/es/components/Modal/Modal.js +26 -12
- package/styled-components/es/components/Modal/Modal.styles.js +17 -0
- package/styled-components/es/components/Modal/Modal.template-doc.mdx +47 -0
- package/styled-components/es/components/Modal/Modal.tokens.js +7 -1
- package/styled-components/es/examples/plasma_b2c/components/Modal/Modal.config.js +1 -1
- package/styled-components/es/examples/plasma_b2c/components/Modal/Modal.stories.tsx +90 -1
- package/styled-components/es/examples/plasma_web/components/Modal/Modal.config.js +1 -1
- package/styled-components/es/examples/plasma_web/components/Modal/Modal.stories.tsx +90 -1
- package/types/components/Modal/Modal.d.ts.map +1 -1
- package/types/components/Modal/Modal.styles.d.ts +5 -0
- package/types/components/Modal/Modal.styles.d.ts.map +1 -0
- package/types/components/Modal/Modal.tokens.d.ts +6 -0
- package/types/components/Modal/Modal.tokens.d.ts.map +1 -1
- package/types/components/Modal/Modal.types.d.ts +21 -1
- package/types/components/Modal/Modal.types.d.ts.map +1 -1
- package/types/components/Modal/index.d.ts +1 -1
- package/types/components/Modal/index.d.ts.map +1 -1
- package/types/examples/plasma_b2c/components/Modal/Modal.config.d.ts.map +1 -1
- package/types/examples/plasma_b2c/components/Modal/Modal.d.ts +7 -1
- package/types/examples/plasma_b2c/components/Modal/Modal.d.ts.map +1 -1
- package/types/examples/plasma_web/components/Modal/Modal.config.d.ts.map +1 -1
- package/types/examples/plasma_web/components/Modal/Modal.d.ts +7 -1
- package/types/examples/plasma_web/components/Modal/Modal.d.ts.map +1 -1
@@ -2,17 +2,20 @@ import { objectWithoutProperties as _objectWithoutProperties, extends as _extend
|
|
2
2
|
import React, { forwardRef, useMemo, useCallback } from 'react';
|
3
3
|
import { useForkRef, safeUseId } from '@salutejs/plasma-core';
|
4
4
|
import { DEFAULT_Z_INDEX } from '../Popup/utils/index.js';
|
5
|
+
import { IconClose } from '../_Icon/Icons/IconClose.js';
|
5
6
|
import { classes, tokens } from './Modal.tokens.js';
|
6
7
|
import { base } from './variations/_view/base.js';
|
7
8
|
import { getIdLastModal } from './ModalContext.js';
|
9
|
+
import { ModalBody, ModalContent, CloseButton } from './Modal.styles.js';
|
8
10
|
import { useFocusTrap } from '../../hooks/useFocusTrap.js';
|
9
11
|
import { usePopupContext } from '../Popup/PopupContext.js';
|
10
12
|
import { useModal } from './hooks/useModal.js';
|
11
|
-
import { Overlay } from '../Overlay/Overlay.js';
|
12
13
|
import { component } from '../../engines/common.js';
|
13
14
|
import { popupConfig } from '../Popup/Popup.js';
|
15
|
+
import { Overlay } from '../Overlay/Overlay.js';
|
14
16
|
|
15
|
-
var
|
17
|
+
var _IconClose;
|
18
|
+
var _excluded = ["id", "withAnimation", "onClose", "onOverlayClick", "onEscKeyDown", "closeOnEsc", "closeOnOverlayClick", "withBlur", "initialFocusRef", "focusAfterRef", "zIndex", "popupInfo", "children", "view", "opened", "isOpen", "hasBody", "hasClose"];
|
16
19
|
|
17
20
|
// issue #823
|
18
21
|
var Popup = /*#__PURE__*/component(popupConfig);
|
@@ -41,8 +44,11 @@ var modalRoot = function modalRoot(Root) {
|
|
41
44
|
view = _ref.view,
|
42
45
|
opened = _ref.opened,
|
43
46
|
isOpen = _ref.isOpen,
|
47
|
+
hasBody = _ref.hasBody,
|
48
|
+
hasClose = _ref.hasClose,
|
44
49
|
rest = _objectWithoutProperties(_ref, _excluded);
|
45
50
|
var innerIsOpen = Boolean(isOpen || opened);
|
51
|
+
var innerHasClose = hasClose === undefined && hasBody || hasClose;
|
46
52
|
var trapRef = useFocusTrap(true, initialFocusRef, focusAfterRef, true);
|
47
53
|
var popupController = usePopupContext();
|
48
54
|
var innerRef = useForkRef(trapRef, outerRootRef);
|
@@ -70,6 +76,15 @@ var modalRoot = function modalRoot(Root) {
|
|
70
76
|
onClose();
|
71
77
|
}
|
72
78
|
}, [closeOnOverlayClick, onOverlayClick, onClose]);
|
79
|
+
var overlayNode = /*#__PURE__*/React.createElement(Overlay, {
|
80
|
+
className: classes.overlay,
|
81
|
+
zIndex: zIndex || DEFAULT_Z_INDEX,
|
82
|
+
backgroundColorProperty: overlayBackgroundToken,
|
83
|
+
withBlur: withBlur,
|
84
|
+
transparent: transparent,
|
85
|
+
isClickable: closeOnOverlayClick,
|
86
|
+
onOverlayClick: onModalOverlayKeyDown
|
87
|
+
});
|
73
88
|
return /*#__PURE__*/React.createElement(Popup, _extends({
|
74
89
|
id: innerId,
|
75
90
|
opened: innerIsOpen,
|
@@ -77,18 +92,17 @@ var modalRoot = function modalRoot(Root) {
|
|
77
92
|
popupInfo: modalInfo,
|
78
93
|
withAnimation: withAnimation,
|
79
94
|
zIndex: zIndex,
|
80
|
-
overlay: /*#__PURE__*/React.createElement(Root, {
|
95
|
+
overlay: hasBody ? overlayNode : /*#__PURE__*/React.createElement(Root, {
|
81
96
|
view: view
|
82
|
-
},
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
}, rest), children);
|
97
|
+
}, overlayNode)
|
98
|
+
}, rest), hasBody ? /*#__PURE__*/React.createElement(Root, {
|
99
|
+
view: view
|
100
|
+
}, /*#__PURE__*/React.createElement(ModalBody, null, /*#__PURE__*/React.createElement(ModalContent, null, innerHasClose && /*#__PURE__*/React.createElement(CloseButton, {
|
101
|
+
onClick: onClose,
|
102
|
+
"data-test": "modal-close"
|
103
|
+
}, _IconClose || (_IconClose = /*#__PURE__*/React.createElement(IconClose, {
|
104
|
+
size: "s"
|
105
|
+
}))), children))) : /*#__PURE__*/React.createElement(React.Fragment, null, children));
|
92
106
|
});
|
93
107
|
};
|
94
108
|
var modalConfig = {
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"Modal.js","sources":["../../../src/components/Modal/Modal.tsx"],"sourcesContent":["import React, { forwardRef, useCallback, useMemo } from 'react';\nimport { useForkRef, safeUseId } from '@salutejs/plasma-core';\n\nimport { RootProps, component } from '../../engines';\nimport { popupConfig, usePopupContext } from '../Popup';\nimport { Overlay } from '../Overlay';\nimport { DEFAULT_Z_INDEX } from '../Popup/utils';\nimport { useFocusTrap } from '../../hooks';\n\nimport { classes, tokens } from './Modal.tokens';\nimport { ModalProps } from './Modal.types';\nimport { useModal } from './hooks';\nimport { base as viewCSS } from './variations/_view/base';\nimport { getIdLastModal } from './ModalContext';\n\n// issue #823\nconst Popup = component(popupConfig);\n\n/**\n * Modal.\n * Управляет показом/скрытием, подложкой и анимацией визуальной части модального окна.\n */\nexport const modalRoot = (Root: RootProps<HTMLDivElement, ModalProps>) =>\n forwardRef<HTMLDivElement, ModalProps>(\n (\n {\n id,\n withAnimation,\n onClose,\n onOverlayClick,\n onEscKeyDown,\n closeOnEsc = true,\n closeOnOverlayClick = true,\n withBlur,\n initialFocusRef,\n focusAfterRef,\n zIndex,\n popupInfo,\n children,\n view,\n opened,\n isOpen,\n ...rest\n },\n outerRootRef,\n ) => {\n const innerIsOpen = Boolean(isOpen || opened);\n const trapRef = useFocusTrap(true, initialFocusRef, focusAfterRef, true);\n const popupController = usePopupContext();\n\n const innerRef = useForkRef<HTMLDivElement>(trapRef, outerRootRef);\n\n const uniqId = safeUseId();\n const innerId = id || uniqId;\n const overlayBackgroundToken = withBlur\n ? `var(${tokens.modalOverlayWithBlurColor})`\n : `var(${tokens.modalOverlayColor})`;\n\n const { modalInfo } = useModal({\n id: innerId,\n isOpen: innerIsOpen,\n closeOnEsc,\n onEscKeyDown,\n onClose,\n popupInfo,\n });\n\n const transparent = useMemo(() => getIdLastModal(popupController.items) !== innerId, [\n innerId,\n popupController.items,\n ]);\n\n const onModalOverlayKeyDown = useCallback(\n (event: React.MouseEvent<HTMLDivElement>) => {\n if (onOverlayClick) {\n onOverlayClick(event);\n return;\n }\n\n if (onClose) {\n onClose();\n }\n },\n [closeOnOverlayClick, onOverlayClick, onClose],\n );\n\n return (\n <Popup\n id={innerId}\n opened={innerIsOpen}\n ref={innerRef}\n popupInfo={modalInfo}\n withAnimation={withAnimation}\n zIndex={zIndex}\n overlay={\n <Root view={view}>\n <Overlay\n className={classes.overlay}\n zIndex={zIndex || DEFAULT_Z_INDEX}\n backgroundColorProperty={overlayBackgroundToken}\n withBlur={withBlur}\n transparent={transparent}\n isClickable={closeOnOverlayClick}\n onOverlayClick={onModalOverlayKeyDown}\n />\n </Root>\n }\n {...rest}\n >\n {children}\n </Popup>\n );\n },\n );\n\nexport const modalConfig = {\n name: 'Modal',\n tag: 'div',\n layout: modalRoot,\n base: '',\n variations: {\n view: {\n css: viewCSS,\n },\n },\n defaults: {\n view: 'default',\n },\n};\n"],"names":["Popup","component","popupConfig","modalRoot","Root","forwardRef","_ref","outerRootRef","id","withAnimation","onClose","onOverlayClick","onEscKeyDown","_ref$closeOnEsc","closeOnEsc","_ref$closeOnOverlayCl","closeOnOverlayClick","withBlur","initialFocusRef","focusAfterRef","zIndex","popupInfo","children","view","opened","isOpen","rest","_objectWithoutProperties","_excluded","innerIsOpen","Boolean","trapRef","useFocusTrap","popupController","usePopupContext","innerRef","useForkRef","uniqId","safeUseId","innerId","overlayBackgroundToken","concat","tokens","modalOverlayWithBlurColor","modalOverlayColor","_useModal","useModal","modalInfo","transparent","useMemo","getIdLastModal","items","onModalOverlayKeyDown","useCallback","event","React","createElement","_extends","ref","overlay","Overlay","className","classes","DEFAULT_Z_INDEX","backgroundColorProperty","isClickable","mod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;;"}
|
1
|
+
{"version":3,"file":"Modal.js","sources":["../../../src/components/Modal/Modal.tsx"],"sourcesContent":["import React, { forwardRef, useCallback, useMemo } from 'react';\nimport { useForkRef, safeUseId } from '@salutejs/plasma-core';\n\nimport { RootProps, component } from '../../engines';\nimport { popupConfig, usePopupContext } from '../Popup';\nimport { Overlay } from '../Overlay';\nimport { DEFAULT_Z_INDEX } from '../Popup/utils';\nimport { useFocusTrap } from '../../hooks';\nimport { IconClose } from '../_Icon/Icons/IconClose';\n\nimport { classes, tokens } from './Modal.tokens';\nimport { ModalProps } from './Modal.types';\nimport { useModal } from './hooks';\nimport { base as viewCSS } from './variations/_view/base';\nimport { getIdLastModal } from './ModalContext';\nimport { CloseButton, ModalBody, ModalContent } from './Modal.styles';\n\n// issue #823\nconst Popup = component(popupConfig);\n\n/**\n * Modal.\n * Управляет показом/скрытием, подложкой и анимацией визуальной части модального окна.\n */\nexport const modalRoot = (Root: RootProps<HTMLDivElement, ModalProps>) =>\n forwardRef<HTMLDivElement, ModalProps>(\n (\n {\n id,\n withAnimation,\n onClose,\n onOverlayClick,\n onEscKeyDown,\n closeOnEsc = true,\n closeOnOverlayClick = true,\n withBlur,\n initialFocusRef,\n focusAfterRef,\n zIndex,\n popupInfo,\n children,\n view,\n opened,\n isOpen,\n hasBody,\n hasClose,\n ...rest\n },\n outerRootRef,\n ) => {\n const innerIsOpen = Boolean(isOpen || opened);\n const innerHasClose = (hasClose === undefined && hasBody) || hasClose;\n const trapRef = useFocusTrap(true, initialFocusRef, focusAfterRef, true);\n const popupController = usePopupContext();\n\n const innerRef = useForkRef<HTMLDivElement>(trapRef, outerRootRef);\n\n const uniqId = safeUseId();\n const innerId = id || uniqId;\n const overlayBackgroundToken = withBlur\n ? `var(${tokens.modalOverlayWithBlurColor})`\n : `var(${tokens.modalOverlayColor})`;\n\n const { modalInfo } = useModal({\n id: innerId,\n isOpen: innerIsOpen,\n closeOnEsc,\n onEscKeyDown,\n onClose,\n popupInfo,\n });\n\n const transparent = useMemo(() => getIdLastModal(popupController.items) !== innerId, [\n innerId,\n popupController.items,\n ]);\n\n const onModalOverlayKeyDown = useCallback(\n (event: React.MouseEvent<HTMLDivElement>) => {\n if (onOverlayClick) {\n onOverlayClick(event);\n return;\n }\n\n if (onClose) {\n onClose();\n }\n },\n [closeOnOverlayClick, onOverlayClick, onClose],\n );\n\n const overlayNode = (\n <Overlay\n className={classes.overlay}\n zIndex={zIndex || DEFAULT_Z_INDEX}\n backgroundColorProperty={overlayBackgroundToken}\n withBlur={withBlur}\n transparent={transparent}\n isClickable={closeOnOverlayClick}\n onOverlayClick={onModalOverlayKeyDown}\n />\n );\n\n return (\n <Popup\n id={innerId}\n opened={innerIsOpen}\n ref={innerRef}\n popupInfo={modalInfo}\n withAnimation={withAnimation}\n zIndex={zIndex}\n overlay={hasBody ? overlayNode : <Root view={view}>{overlayNode}</Root>}\n {...rest}\n >\n {hasBody ? (\n <Root view={view}>\n <ModalBody>\n <ModalContent>\n {innerHasClose && (\n <CloseButton onClick={onClose} data-test=\"modal-close\">\n <IconClose size=\"s\" />\n </CloseButton>\n )}\n {children}\n </ModalContent>\n </ModalBody>\n </Root>\n ) : (\n <>{children}</>\n )}\n </Popup>\n );\n },\n );\n\nexport const modalConfig = {\n name: 'Modal',\n tag: 'div',\n layout: modalRoot,\n base: '',\n variations: {\n view: {\n css: viewCSS,\n },\n },\n defaults: {\n view: 'default',\n },\n};\n"],"names":["Popup","component","popupConfig","modalRoot","Root","forwardRef","_ref","outerRootRef","id","withAnimation","onClose","onOverlayClick","onEscKeyDown","_ref$closeOnEsc","closeOnEsc","_ref$closeOnOverlayCl","closeOnOverlayClick","withBlur","initialFocusRef","focusAfterRef","zIndex","popupInfo","children","view","opened","isOpen","hasBody","hasClose","rest","_objectWithoutProperties","_excluded","innerIsOpen","Boolean","innerHasClose","undefined","trapRef","useFocusTrap","popupController","usePopupContext","innerRef","useForkRef","uniqId","safeUseId","innerId","overlayBackgroundToken","concat","tokens","modalOverlayWithBlurColor","modalOverlayColor","_useModal","useModal","modalInfo","transparent","useMemo","getIdLastModal","items","onModalOverlayKeyDown","useCallback","event","overlayNode","React","createElement","Overlay","className","classes","overlay","DEFAULT_Z_INDEX","backgroundColorProperty","isClickable","_extends","ref","ModalBody","ModalContent","CloseButton","onClick","_IconClose","IconClose","size","Fragment","modalConfig","name","tag","layout","base","variations","css","viewCSS","defaults"],"mappings":";;;;;;;;;;;;;;;;;;;AAiBA;AACA,IAAMA,KAAK,gBAAGC,SAAS,CAACC,WAAW,CAAC,CAAA;;AAEpC;AACA;AACA;AACA;IACaC,SAAS,GAAG,SAAZA,SAASA,CAAIC,IAA2C,EAAA;AAAA,EAAA,oBACjEC,UAAU,CACN,UAAAC,IAAA,EAsBIC,YAAY,EACX;AAAA,IAAA,IArBGC,EAAE,GAAAF,IAAA,CAAFE,EAAE;MACFC,aAAa,GAAAH,IAAA,CAAbG,aAAa;MACbC,OAAO,GAAAJ,IAAA,CAAPI,OAAO;MACPC,cAAc,GAAAL,IAAA,CAAdK,cAAc;MACdC,YAAY,GAAAN,IAAA,CAAZM,YAAY;MAAAC,eAAA,GAAAP,IAAA,CACZQ,UAAU;AAAVA,MAAAA,UAAU,GAAAD,eAAA,KAAG,KAAA,CAAA,GAAA,IAAI,GAAAA,eAAA;MAAAE,qBAAA,GAAAT,IAAA,CACjBU,mBAAmB;AAAnBA,MAAAA,mBAAmB,GAAAD,qBAAA,KAAG,KAAA,CAAA,GAAA,IAAI,GAAAA,qBAAA;MAC1BE,QAAQ,GAAAX,IAAA,CAARW,QAAQ;MACRC,eAAe,GAAAZ,IAAA,CAAfY,eAAe;MACfC,aAAa,GAAAb,IAAA,CAAba,aAAa;MACbC,MAAM,GAAAd,IAAA,CAANc,MAAM;MACNC,SAAS,GAAAf,IAAA,CAATe,SAAS;MACTC,QAAQ,GAAAhB,IAAA,CAARgB,QAAQ;MACRC,IAAI,GAAAjB,IAAA,CAAJiB,IAAI;MACJC,MAAM,GAAAlB,IAAA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K,OAAA,EAAEoC,WAAkB,CAAA;KAClE/B,EAAAA,IAAI,GAEPF,OAAO,gBACJkC,KAAA,CAAAC,aAAA,CAACzD,IAAI,EAAA;AAACmB,MAAAA,IAAI,EAAEA,IAAAA;AAAK,KAAA,eACbqC,KAAA,CAAAC,aAAA,CAACU,SAAS,EAAA,IAAA,eACNX,KAAA,CAAAC,aAAA,CAACW,YAAY,QACRvC,aAAa,iBACV2B,KAAA,CAAAC,aAAA,CAACY,WAAW,EAAA;AAACC,MAAAA,OAAO,EAAEhE,OAAQ;MAAC,WAAU,EAAA,aAAA;KAAaiE,EAAAA,UAAA,KAAAA,UAAA,gBAClDf,KAAA,CAAAC,aAAA,CAACe,SAAS,EAAA;AAACC,MAAAA,IAAI,EAAC,GAAA;AAAG,KAAE,CAAC,CACb,CAChB,EACAvD,QACS,CACP,CACT,CAAC,gBAEPsC,KAAA,CAAAC,aAAA,CAAAD,KAAA,CAAAkB,QAAA,EAAGxD,IAAAA,EAAAA,QAAW,CAEf,CAAC,CAAA;AAEhB,GACJ,CAAC,CAAA;AAAA,EAAA;AAEE,IAAMyD,WAAW,GAAG;AACvBC,EAAAA,IAAI,EAAE,OAAO;AACbC,EAAAA,GAAG,EAAE,KAAK;AACVC,EAAAA,MAAM,EAAE/E,SAAS;AACjBgF,EAAAA,IAAI,EAAE,EAAE;AACRC,EAAAA,UAAU,EAAE;AACR7D,IAAAA,IAAI,EAAE;AACF8D,MAAAA,GAAG,EAAEC,IAAAA;AACT,KAAA;GACH;AACDC,EAAAA,QAAQ,EAAE;AACNhE,IAAAA,IAAI,EAAE,SAAA;AACV,GAAA;AACJ;;;;"}
|
@@ -0,0 +1,21 @@
|
|
1
|
+
import './Modal.styles_tqsxxy.css';
|
2
|
+
import { styled } from '@linaria/react';
|
3
|
+
|
4
|
+
var ModalBody = /*#__PURE__*/styled('div')({
|
5
|
+
name: "ModalBody",
|
6
|
+
"class": "m7npn1w",
|
7
|
+
propsAsIs: false
|
8
|
+
});
|
9
|
+
var ModalContent = /*#__PURE__*/styled('div')({
|
10
|
+
name: "ModalContent",
|
11
|
+
"class": "m16phoaz",
|
12
|
+
propsAsIs: false
|
13
|
+
});
|
14
|
+
var CloseButton = /*#__PURE__*/styled('button')({
|
15
|
+
name: "CloseButton",
|
16
|
+
"class": "c5bx5hr",
|
17
|
+
propsAsIs: false
|
18
|
+
});
|
19
|
+
|
20
|
+
export { CloseButton, ModalBody, ModalContent };
|
21
|
+
//# sourceMappingURL=Modal.styles.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"Modal.styles.js","sources":["../../../src/components/Modal/Modal.styles.ts"],"sourcesContent":["import { styled } from '@linaria/react';\n\nimport { addFocus } from '../../mixins';\n\nimport { tokens } from './Modal.tokens';\n\nexport const ModalBody = styled.div`\n border-radius: var(${tokens.modalBodyBorderRadius});\n padding: var(${tokens.modalBodyPadding});\n background: var(${tokens.modalBodyBackground});\n box-shadow: var(--shadow-down-soft-l);\n`;\n\nexport const ModalContent = styled.div`\n position: relative;\n padding: var(${tokens.modalContentPadding});\n`;\n\nexport const CloseButton = styled.button`\n top: 0;\n right: 0;\n\n width: 1.5rem;\n height: 1.5rem;\n\n display: flex;\n align-items: center;\n justify-content: center;\n\n border: none;\n border-radius: var(${tokens.modalCloseButtonRadius});\n\n padding: 0;\n margin: 0;\n outline: none;\n\n cursor: pointer;\n\n background: transparent;\n\n ${addFocus({\n outlineSize: '0.063rem',\n outlineOffset: '-0.125rem',\n outlineColor: `var(${tokens.modalOutlineFocusColor})`,\n outlineRadius: `calc(var(${tokens.modalCloseButtonRadius}) + 0.063rem)`,\n })};\n\n position: absolute;\n`;\n"],"names":["ModalBody","styled","name","class","propsAsIs","ModalContent","CloseButton"],"mappings":";;AAMO,IAAMA,SAAS,gBAAGC,MAAM,CAAA,KAAA,CAAA,CAAA;AAAAC,EAAAA,IAAA,EAAA,WAAA;AAAAC,EAAAA,OAAAA,EAAA,SAAA;AAAAC,EAAAA,SAAA,EAAA,KAAA;AAAA,CAK9B,EAAA;AAEM,IAAMC,YAAY,gBAAGJ,MAAM,CAAA,KAAA,CAAA,CAAA;AAAAC,EAAAA,IAAA,EAAA,cAAA;AAAAC,EAAAA,OAAAA,EAAA,UAAA;AAAAC,EAAAA,SAAA,EAAA,KAAA;AAAA,CAGjC,EAAA;AAEM,IAAME,WAAW,gBAAGL,MAAM,CAAA,QAAA,CAAA,CAAA;AAAAC,EAAAA,IAAA,EAAA,aAAA;AAAAC,EAAAA,OAAAA,EAAA,SAAA;AAAAC,EAAAA,SAAA,EAAA,KAAA;AAAA,CA8BhC;;;;"}
|
@@ -0,0 +1,3 @@
|
|
1
|
+
.m7npn1w{border-radius:var(--plasma-modal-body-border-radius);padding:var(--plasma-modal-body-padding);background:var(--plasma-modal-body-background);box-shadow:var(--shadow-down-soft-l);}
|
2
|
+
.m16phoaz{position:relative;padding:var(--plasma-modal-content-padding);}
|
3
|
+
.c5bx5hr{top:0;right:0;width:1.5rem;height:1.5rem;display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;-webkit-align-items:center;-webkit-box-align:center;-ms-flex-align:center;align-items:center;-webkit-box-pack:center;-webkit-justify-content:center;-ms-flex-pack:center;justify-content:center;border:none;border-radius:var(--plasma-modal-close-button-radius);padding:0;margin:0;outline:none;cursor:pointer;background:transparent;position:relative;position:absolute;}.c5bx5hr::before{content:'';position:absolute;top:-0.125rem;left:-0.125rem;right:-0.125rem;bottom:-0.125rem;z-index:1;display:block;box-sizing:content-box;border:0.063rem solid transparent;border-radius:calc(var(--plasma-modal-close-button-radius) + 0.063rem);-webkit-transition:box-shadow 0.2s ease-in-out;transition:box-shadow 0.2s ease-in-out;pointer-events:none;}.c5bx5hr.focus-visible:focus::before,.c5bx5hr[data-focus-visible-added]::before{outline:none;box-shadow:0 0 0 0.063rem var(--plasma-modal-outline-focus-color);}
|
@@ -6,7 +6,13 @@ var classes = {
|
|
6
6
|
};
|
7
7
|
var tokens = {
|
8
8
|
modalOverlayWithBlurColor: '--plasma-modal-overlay-with-blur-color',
|
9
|
-
modalOverlayColor: '--plasma-modal-overlay-color'
|
9
|
+
modalOverlayColor: '--plasma-modal-overlay-color',
|
10
|
+
modalBodyBackground: '--plasma-modal-body-background',
|
11
|
+
modalBodyBorderRadius: '--plasma-modal-body-border-radius',
|
12
|
+
modalBodyPadding: '--plasma-modal-body-padding',
|
13
|
+
modalContentPadding: '--plasma-modal-content-padding',
|
14
|
+
modalOutlineFocusColor: '--plasma-modal-outline-focus-color',
|
15
|
+
modalCloseButtonRadius: '--plasma-modal-close-button-radius'
|
10
16
|
};
|
11
17
|
|
12
18
|
export { classes, tokens };
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"Modal.tokens.js","sources":["../../../src/components/Modal/Modal.tokens.ts"],"sourcesContent":["export const classes = {\n /*\n * Класс компонента ModalOverlay\n */\n overlay: 'modal-overlay',\n};\n\nexport const tokens = {\n modalOverlayWithBlurColor: '--plasma-modal-overlay-with-blur-color',\n modalOverlayColor: '--plasma-modal-overlay-color',\n};\n"],"names":["classes","overlay","tokens","modalOverlayWithBlurColor","modalOverlayColor"],"mappings":"AAAO,IAAMA,OAAO,GAAG;AACnB;AACJ;AACA;AACIC,EAAAA,OAAO,EAAE,eAAA;AACb,EAAC;AAEM,IAAMC,MAAM,GAAG;AAClBC,EAAAA,yBAAyB,EAAE,wCAAwC;AACnEC,EAAAA,iBAAiB,EAAE,
|
1
|
+
{"version":3,"file":"Modal.tokens.js","sources":["../../../src/components/Modal/Modal.tokens.ts"],"sourcesContent":["export const classes = {\n /*\n * Класс компонента ModalOverlay\n */\n overlay: 'modal-overlay',\n};\n\nexport const tokens = {\n modalOverlayWithBlurColor: '--plasma-modal-overlay-with-blur-color',\n modalOverlayColor: '--plasma-modal-overlay-color',\n modalBodyBackground: '--plasma-modal-body-background',\n modalBodyBorderRadius: '--plasma-modal-body-border-radius',\n modalBodyPadding: '--plasma-modal-body-padding',\n modalContentPadding: '--plasma-modal-content-padding',\n modalOutlineFocusColor: '--plasma-modal-outline-focus-color',\n modalCloseButtonRadius: '--plasma-modal-close-button-radius',\n};\n"],"names":["classes","overlay","tokens","modalOverlayWithBlurColor","modalOverlayColor","modalBodyBackground","modalBodyBorderRadius","modalBodyPadding","modalContentPadding","modalOutlineFocusColor","modalCloseButtonRadius"],"mappings":"AAAO,IAAMA,OAAO,GAAG;AACnB;AACJ;AACA;AACIC,EAAAA,OAAO,EAAE,eAAA;AACb,EAAC;AAEM,IAAMC,MAAM,GAAG;AAClBC,EAAAA,yBAAyB,EAAE,wCAAwC;AACnEC,EAAAA,iBAAiB,EAAE,8BAA8B;AACjDC,EAAAA,mBAAmB,EAAE,gCAAgC;AACrDC,EAAAA,qBAAqB,EAAE,mCAAmC;AAC1DC,EAAAA,gBAAgB,EAAE,6BAA6B;AAC/CC,EAAAA,mBAAmB,EAAE,gCAAgC;AACrDC,EAAAA,sBAAsB,EAAE,oCAAoC;AAC5DC,EAAAA,sBAAsB,EAAE,oCAAA;AAC5B;;;;"}
|
package/es/index.css
CHANGED
@@ -336,6 +336,10 @@
|
|
336
336
|
.Popup_styles_gq4luz_p5u7tqa__bb610b96{position:relative;max-width:100%;pointer-events:all;}
|
337
337
|
.Popup_styles_gq4luz_p1f40oul__bb610b96{position:var(--p1f40oul-0);z-index:var(--p1f40oul-1);left:var(--p1f40oul-2);right:var(--p1f40oul-3);top:var(--p1f40oul-4);bottom:var(--p1f40oul-5);-webkit-transform:var(--p1f40oul-6);-ms-transform:var(--p1f40oul-6);transform:var(--p1f40oul-6);}
|
338
338
|
|
339
|
+
.Modal_styles_tqsxxy_m7npn1w__53552e6a{border-radius:var(--plasma-modal-body-border-radius);padding:var(--plasma-modal-body-padding);background:var(--plasma-modal-body-background);box-shadow:var(--shadow-down-soft-l);}
|
340
|
+
.Modal_styles_tqsxxy_m16phoaz__53552e6a{position:relative;padding:var(--plasma-modal-content-padding);}
|
341
|
+
.Modal_styles_tqsxxy_c5bx5hr__53552e6a{top:0;right:0;width:1.5rem;height:1.5rem;display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;-webkit-align-items:center;-webkit-box-align:center;-ms-flex-align:center;align-items:center;-webkit-box-pack:center;-webkit-justify-content:center;-ms-flex-pack:center;justify-content:center;border:none;border-radius:var(--plasma-modal-close-button-radius);padding:0;margin:0;outline:none;cursor:pointer;background:transparent;position:relative;position:absolute;}.Modal_styles_tqsxxy_c5bx5hr__53552e6a::before{content:'';position:absolute;top:-0.125rem;left:-0.125rem;right:-0.125rem;bottom:-0.125rem;z-index:1;display:block;box-sizing:content-box;border:0.063rem solid transparent;border-radius:calc(var(--plasma-modal-close-button-radius) + 0.063rem);-webkit-transition:box-shadow 0.2s ease-in-out;transition:box-shadow 0.2s ease-in-out;pointer-events:none;}.Modal_styles_tqsxxy_c5bx5hr__53552e6a.Modal_styles_tqsxxy_focusVisible__53552e6a:focus::before,.Modal_styles_tqsxxy_c5bx5hr__53552e6a[data-focus-visible-added]::before{outline:none;box-shadow:0 0 0 0.063rem var(--plasma-modal-outline-focus-color);}
|
342
|
+
|
339
343
|
.NotificationsPortal_6417q6_s19gbs9t__4166aeb6 > .NotificationsPortal_6417q6_popupBaseRoot__4166aeb6{overflow:hidden;}
|
340
344
|
|
341
345
|
.base_qkc3i4_bg3tssa__4791b7ea .base_qkc3i4_notificationWrapper__4791b7ea{width:var(--plasma-notification-width);padding:var(--plasma-notification-padding);}.base_qkc3i4_bg3tssa__4791b7ea .base_qkc3i4_notificationWrapper__4791b7ea.base_qkc3i4_notificationLayoutHorizontal__4791b7ea{padding:var(--plasma-notification-horizontal-layout-padding);}.base_qkc3i4_bg3tssa__4791b7ea .base_qkc3i4_notificationWrapper__4791b7ea.base_qkc3i4_notificationLayoutHorizontal__4791b7ea.base_qkc3i4_notificationWithoutCloseIcon__4791b7ea{padding-right:var(--plasma-notification-horizontal-layout-right-padding-without-close-icon);}.base_qkc3i4_bg3tssa__4791b7ea .base_qkc3i4_notificationWrapper__4791b7ea.base_qkc3i4_notificationLayoutHorizontal__4791b7ea.base_qkc3i4_notificationOneLineTextbox__4791b7ea{padding:var(--plasma-notification-padding-one-line-textbox);}
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@salutejs/plasma-new-hope",
|
3
|
-
"version": "0.
|
3
|
+
"version": "0.194.0-canary.1558.11852073996.0",
|
4
4
|
"description": "Salute Design System blueprint",
|
5
5
|
"main": "cjs/index.js",
|
6
6
|
"module": "es/index.js",
|
@@ -128,5 +128,5 @@
|
|
128
128
|
"sideEffects": [
|
129
129
|
"*.css"
|
130
130
|
],
|
131
|
-
"gitHead": "
|
131
|
+
"gitHead": "77b65a5bff681c71979e6960ad0a173d0c0f36cb"
|
132
132
|
}
|
@@ -12,11 +12,14 @@ var _Popup = /*#__PURE__*/require("../Popup");
|
|
12
12
|
var _Overlay = /*#__PURE__*/require("../Overlay");
|
13
13
|
var _utils = /*#__PURE__*/require("../Popup/utils");
|
14
14
|
var _hooks = /*#__PURE__*/require("../../hooks");
|
15
|
+
var _IconClose2 = /*#__PURE__*/require("../_Icon/Icons/IconClose");
|
15
16
|
var _Modal = /*#__PURE__*/require("./Modal.tokens");
|
16
17
|
var _hooks2 = /*#__PURE__*/require("./hooks");
|
17
18
|
var _base = /*#__PURE__*/require("./variations/_view/base");
|
18
19
|
var _ModalContext = /*#__PURE__*/require("./ModalContext");
|
19
|
-
var
|
20
|
+
var _Modal2 = /*#__PURE__*/require("./Modal.styles");
|
21
|
+
var _IconClose;
|
22
|
+
var _excluded = ["id", "withAnimation", "onClose", "onOverlayClick", "onEscKeyDown", "closeOnEsc", "closeOnOverlayClick", "withBlur", "initialFocusRef", "focusAfterRef", "zIndex", "popupInfo", "children", "view", "opened", "isOpen", "hasBody", "hasClose"];
|
20
23
|
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
|
21
24
|
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != _typeof(e) && "function" != typeof e) return { "default": e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n["default"] = e, t && t.set(e, n), n; }
|
22
25
|
function _extends() { _extends = Object.assign ? Object.assign.bind() : 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); }
|
@@ -49,8 +52,11 @@ var modalRoot = exports.modalRoot = function modalRoot(Root) {
|
|
49
52
|
view = _ref.view,
|
50
53
|
opened = _ref.opened,
|
51
54
|
isOpen = _ref.isOpen,
|
55
|
+
hasBody = _ref.hasBody,
|
56
|
+
hasClose = _ref.hasClose,
|
52
57
|
rest = _objectWithoutProperties(_ref, _excluded);
|
53
58
|
var innerIsOpen = Boolean(isOpen || opened);
|
59
|
+
var innerHasClose = hasClose === undefined && hasBody || hasClose;
|
54
60
|
var trapRef = (0, _hooks.useFocusTrap)(true, initialFocusRef, focusAfterRef, true);
|
55
61
|
var popupController = (0, _Popup.usePopupContext)();
|
56
62
|
var innerRef = (0, _plasmaCore.useForkRef)(trapRef, outerRootRef);
|
@@ -78,6 +84,15 @@ var modalRoot = exports.modalRoot = function modalRoot(Root) {
|
|
78
84
|
onClose();
|
79
85
|
}
|
80
86
|
}, [closeOnOverlayClick, onOverlayClick, onClose]);
|
87
|
+
var overlayNode = /*#__PURE__*/_react["default"].createElement(_Overlay.Overlay, {
|
88
|
+
className: _Modal.classes.overlay,
|
89
|
+
zIndex: zIndex || _utils.DEFAULT_Z_INDEX,
|
90
|
+
backgroundColorProperty: overlayBackgroundToken,
|
91
|
+
withBlur: withBlur,
|
92
|
+
transparent: transparent,
|
93
|
+
isClickable: closeOnOverlayClick,
|
94
|
+
onOverlayClick: onModalOverlayKeyDown
|
95
|
+
});
|
81
96
|
return /*#__PURE__*/_react["default"].createElement(Popup, _extends({
|
82
97
|
id: innerId,
|
83
98
|
opened: innerIsOpen,
|
@@ -85,18 +100,17 @@ var modalRoot = exports.modalRoot = function modalRoot(Root) {
|
|
85
100
|
popupInfo: modalInfo,
|
86
101
|
withAnimation: withAnimation,
|
87
102
|
zIndex: zIndex,
|
88
|
-
overlay: /*#__PURE__*/_react["default"].createElement(Root, {
|
103
|
+
overlay: hasBody ? overlayNode : /*#__PURE__*/_react["default"].createElement(Root, {
|
89
104
|
view: view
|
90
|
-
},
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
}, rest), children);
|
105
|
+
}, overlayNode)
|
106
|
+
}, rest), hasBody ? /*#__PURE__*/_react["default"].createElement(Root, {
|
107
|
+
view: view
|
108
|
+
}, /*#__PURE__*/_react["default"].createElement(_Modal2.ModalBody, null, /*#__PURE__*/_react["default"].createElement(_Modal2.ModalContent, null, innerHasClose && /*#__PURE__*/_react["default"].createElement(_Modal2.CloseButton, {
|
109
|
+
onClick: onClose,
|
110
|
+
"data-test": "modal-close"
|
111
|
+
}, _IconClose || (_IconClose = /*#__PURE__*/_react["default"].createElement(_IconClose2.IconClose, {
|
112
|
+
size: "s"
|
113
|
+
}))), children))) : /*#__PURE__*/_react["default"].createElement(_react["default"].Fragment, null, children));
|
100
114
|
});
|
101
115
|
};
|
102
116
|
var modalConfig = exports.modalConfig = {
|
@@ -0,0 +1,24 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
4
|
+
value: true
|
5
|
+
});
|
6
|
+
exports.ModalContent = exports.ModalBody = exports.CloseButton = void 0;
|
7
|
+
var _styledComponents = /*#__PURE__*/_interopRequireDefault( /*#__PURE__*/require("styled-components"));
|
8
|
+
var _mixins = /*#__PURE__*/require("../../mixins");
|
9
|
+
var _Modal = /*#__PURE__*/require("./Modal.tokens");
|
10
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
11
|
+
var ModalBody = exports.ModalBody = /*#__PURE__*/_styledComponents["default"].div.withConfig({
|
12
|
+
componentId: "plasma-new-hope__sc-yxf3fb-0"
|
13
|
+
})(["border-radius:var(", ");padding:var(", ");background:var(", ");box-shadow:var(--shadow-down-soft-l);"], _Modal.tokens.modalBodyBorderRadius, _Modal.tokens.modalBodyPadding, _Modal.tokens.modalBodyBackground);
|
14
|
+
var ModalContent = exports.ModalContent = /*#__PURE__*/_styledComponents["default"].div.withConfig({
|
15
|
+
componentId: "plasma-new-hope__sc-yxf3fb-1"
|
16
|
+
})(["position:relative;padding:var(", ");"], _Modal.tokens.modalContentPadding);
|
17
|
+
var CloseButton = exports.CloseButton = /*#__PURE__*/_styledComponents["default"].button.withConfig({
|
18
|
+
componentId: "plasma-new-hope__sc-yxf3fb-2"
|
19
|
+
})(["top:0;right:0;width:1.5rem;height:1.5rem;display:flex;align-items:center;justify-content:center;border:none;border-radius:var(", ");padding:0;margin:0;outline:none;cursor:pointer;background:transparent;", ";position:absolute;"], _Modal.tokens.modalCloseButtonRadius, /*#__PURE__*/(0, _mixins.addFocus)({
|
20
|
+
outlineSize: '0.063rem',
|
21
|
+
outlineOffset: '-0.125rem',
|
22
|
+
outlineColor: /*#__PURE__*/"var(".concat(_Modal.tokens.modalOutlineFocusColor, ")"),
|
23
|
+
outlineRadius: /*#__PURE__*/"calc(var(".concat(_Modal.tokens.modalCloseButtonRadius, ") + 0.063rem)")
|
24
|
+
}));
|
@@ -62,6 +62,53 @@ export function App() {
|
|
62
62
|
}
|
63
63
|
```
|
64
64
|
|
65
|
+
## Использование стилизованной обертки
|
66
|
+
|
67
|
+
Для использования стилизованного мобального окна с отступами и крестиком для закрытия, добавьте свойство `hasBody`.
|
68
|
+
```tsx live
|
69
|
+
import React, { useState } from 'react';
|
70
|
+
import { SSRProvider, Button, Modal, PopupProvider } from '@salutejs/{{ package }}';
|
71
|
+
|
72
|
+
export function App() {
|
73
|
+
const [isOpenA, setIsOpenA] = useState(false);
|
74
|
+
const [isOpenB, setIsOpenB] = useState(false);
|
75
|
+
|
76
|
+
return (
|
77
|
+
<SSRProvider>
|
78
|
+
<PopupProvider>
|
79
|
+
<div style=\{{ height: "300px" }}>
|
80
|
+
<div style=\{{ display: 'flex', flexDirection: 'column' }}>
|
81
|
+
<Button text="Открыть A" onClick={() => setIsOpenA(true)} />
|
82
|
+
</div>
|
83
|
+
<Modal
|
84
|
+
id="modalA"
|
85
|
+
onClose={() => setIsOpenA(false)}
|
86
|
+
opened={isOpenA}
|
87
|
+
placement="center"
|
88
|
+
offset={[0, 0]}
|
89
|
+
hasBody
|
90
|
+
>
|
91
|
+
<Button onClick={() => setIsOpenA(false)}>Close</Button>
|
92
|
+
<Button text="Открыть B" onClick={() => setIsOpenB(true)} />
|
93
|
+
Content
|
94
|
+
<Modal
|
95
|
+
id="modalB"
|
96
|
+
onClose={() => setIsOpenB(false)}
|
97
|
+
opened={isOpenB}
|
98
|
+
placement="right"
|
99
|
+
offset={[0, 0]}
|
100
|
+
>
|
101
|
+
<Button onClick={() => setIsOpenB(false)}>Close</Button>
|
102
|
+
Content
|
103
|
+
</Modal>
|
104
|
+
</Modal>
|
105
|
+
</div>
|
106
|
+
</PopupProvider>
|
107
|
+
</SSRProvider>
|
108
|
+
);
|
109
|
+
}
|
110
|
+
```
|
111
|
+
|
65
112
|
## Подключение анимации
|
66
113
|
Подключение анимации аналогично тому, как это происходит в `Popup` - через свойство `withAnimation`(управление через `popupClasses`, `modalClasses`).
|
67
114
|
Для добавления анимации в оверлей необходимо использовать класс `.modal-overlay` через переменную `modalClasses.overlay` из пакета.
|
@@ -12,5 +12,11 @@ var classes = exports.classes = {
|
|
12
12
|
};
|
13
13
|
var tokens = exports.tokens = {
|
14
14
|
modalOverlayWithBlurColor: '--plasma-modal-overlay-with-blur-color',
|
15
|
-
modalOverlayColor: '--plasma-modal-overlay-color'
|
15
|
+
modalOverlayColor: '--plasma-modal-overlay-color',
|
16
|
+
modalBodyBackground: '--plasma-modal-body-background',
|
17
|
+
modalBodyBorderRadius: '--plasma-modal-body-border-radius',
|
18
|
+
modalBodyPadding: '--plasma-modal-body-padding',
|
19
|
+
modalContentPadding: '--plasma-modal-content-padding',
|
20
|
+
modalOutlineFocusColor: '--plasma-modal-outline-focus-color',
|
21
|
+
modalCloseButtonRadius: '--plasma-modal-close-button-radius'
|
16
22
|
};
|
@@ -12,7 +12,7 @@ var config = exports.config = {
|
|
12
12
|
},
|
13
13
|
variations: {
|
14
14
|
view: {
|
15
|
-
"default": /*#__PURE__*/(0, _styledComponents.css)(["", ":var(--overlay-blur);", ":var(--overlay-soft);"], _Modal.modalTokens.modalOverlayWithBlurColor, _Modal.modalTokens.modalOverlayColor)
|
15
|
+
"default": /*#__PURE__*/(0, _styledComponents.css)(["", ":var(--overlay-blur);", ":var(--overlay-soft);", ":var(--surface-solid-card);", ":1.25rem;", ":2rem;", ":0.625rem;", ":0.375rem;", ":var(--surface-accent);"], _Modal.modalTokens.modalOverlayWithBlurColor, _Modal.modalTokens.modalOverlayColor, _Modal.modalTokens.modalBodyBackground, _Modal.modalTokens.modalBodyBorderRadius, _Modal.modalTokens.modalBodyPadding, _Modal.modalTokens.modalContentPadding, _Modal.modalTokens.modalCloseButtonRadius, _Modal.modalTokens.modalOutlineFocusColor)
|
16
16
|
}
|
17
17
|
}
|
18
18
|
};
|
@@ -3,6 +3,7 @@ import styled from 'styled-components';
|
|
3
3
|
import type { ComponentProps } from 'react';
|
4
4
|
import type { StoryObj, Meta } from '@storybook/react';
|
5
5
|
import { SSRProvider } from '@salutejs/plasma-core';
|
6
|
+
import { disableProps } from '@salutejs/plasma-sb-utils';
|
6
7
|
|
7
8
|
import { PopupProvider, popupClasses } from '../Popup/Popup';
|
8
9
|
import { Button } from '../Button/Button';
|
@@ -18,6 +19,7 @@ export default {
|
|
18
19
|
docs: { story: { inline: false, iframeHeight: '30rem' } },
|
19
20
|
},
|
20
21
|
argTypes: {
|
22
|
+
...disableProps(['hasBody']),
|
21
23
|
placement: {
|
22
24
|
options: [
|
23
25
|
'center',
|
@@ -75,6 +77,7 @@ type StoryModalProps = ComponentProps<typeof Modal> & {
|
|
75
77
|
closeOnEsc: boolean;
|
76
78
|
closeOnOverlayClick: boolean;
|
77
79
|
withBlur: boolean;
|
80
|
+
hasClose?: boolean;
|
78
81
|
};
|
79
82
|
|
80
83
|
const StyledButton = styled(Button)`
|
@@ -135,6 +138,72 @@ const StoryModalDemo = ({ placement, offsetX, offsetY, ...rest }: StoryModalProp
|
|
135
138
|
const [isOpenB, setIsOpenB] = useState(false);
|
136
139
|
const [isOpenC, setIsOpenC] = useState(false);
|
137
140
|
|
141
|
+
return (
|
142
|
+
<SSRProvider>
|
143
|
+
<StyledWrapper>
|
144
|
+
<PopupProvider>
|
145
|
+
<ButtonWrapper>
|
146
|
+
<StyledButton text="Открыть A" onClick={() => setIsOpenA(true)} />
|
147
|
+
</ButtonWrapper>
|
148
|
+
<StyledModal
|
149
|
+
id="modalA"
|
150
|
+
frame="theme-root"
|
151
|
+
withAnimation
|
152
|
+
onClose={() => setIsOpenA(false)}
|
153
|
+
opened={isOpenA}
|
154
|
+
placement={placement}
|
155
|
+
offset={[offsetX, offsetY]}
|
156
|
+
hasBody
|
157
|
+
{...rest}
|
158
|
+
>
|
159
|
+
<Button onClick={() => setIsOpenA(false)}>Close</Button>
|
160
|
+
<ButtonWrapper>
|
161
|
+
<StyledButton text="Открыть B" onClick={() => setIsOpenB(true)} />
|
162
|
+
</ButtonWrapper>
|
163
|
+
<Modal
|
164
|
+
id="modalB"
|
165
|
+
frame="theme-root"
|
166
|
+
onClose={() => setIsOpenB(false)}
|
167
|
+
opened={isOpenB}
|
168
|
+
placement="left"
|
169
|
+
offset={[offsetX, offsetY]}
|
170
|
+
hasBody
|
171
|
+
{...rest}
|
172
|
+
>
|
173
|
+
<Button style={{ marginRight: '1rem' }} onClick={() => setIsOpenB(false)}>
|
174
|
+
Close
|
175
|
+
</Button>
|
176
|
+
<ButtonWrapper>
|
177
|
+
<StyledButton text="Открыть C" onClick={() => setIsOpenC(true)} />
|
178
|
+
</ButtonWrapper>
|
179
|
+
<Modal
|
180
|
+
id="modalC"
|
181
|
+
frame="theme-root"
|
182
|
+
onClose={() => setIsOpenC(false)}
|
183
|
+
opened={isOpenC}
|
184
|
+
placement="top"
|
185
|
+
offset={[offsetX, offsetY]}
|
186
|
+
hasBody
|
187
|
+
{...rest}
|
188
|
+
>
|
189
|
+
<Button style={{ marginRight: '1rem' }} onClick={() => setIsOpenC(false)}>
|
190
|
+
Close
|
191
|
+
</Button>
|
192
|
+
<>Content</>
|
193
|
+
</Modal>
|
194
|
+
</Modal>
|
195
|
+
</StyledModal>
|
196
|
+
</PopupProvider>
|
197
|
+
</StyledWrapper>
|
198
|
+
</SSRProvider>
|
199
|
+
);
|
200
|
+
};
|
201
|
+
|
202
|
+
const StoryCustomModalDemo = ({ placement, offsetX, offsetY, ...rest }: StoryModalProps) => {
|
203
|
+
const [isOpenA, setIsOpenA] = useState(false);
|
204
|
+
const [isOpenB, setIsOpenB] = useState(false);
|
205
|
+
const [isOpenC, setIsOpenC] = useState(false);
|
206
|
+
|
138
207
|
return (
|
139
208
|
<SSRProvider>
|
140
209
|
<StyledWrapper>
|
@@ -199,7 +268,7 @@ const StoryModalDemo = ({ placement, offsetX, offsetY, ...rest }: StoryModalProp
|
|
199
268
|
);
|
200
269
|
};
|
201
270
|
|
202
|
-
export const
|
271
|
+
export const Default: StoryObj<StoryModalProps> = {
|
203
272
|
args: {
|
204
273
|
placement: 'center',
|
205
274
|
withBlur: false,
|
@@ -207,10 +276,30 @@ export const ModalDemo: StoryObj<StoryModalProps> = {
|
|
207
276
|
closeOnOverlayClick: true,
|
208
277
|
offsetX: 0,
|
209
278
|
offsetY: 0,
|
279
|
+
hasClose: true,
|
280
|
+
},
|
281
|
+
argTypes: {
|
282
|
+
hasClose: {
|
283
|
+
control: {
|
284
|
+
type: 'boolean',
|
285
|
+
},
|
286
|
+
},
|
210
287
|
},
|
211
288
|
render: (args) => <StoryModalDemo {...args} />,
|
212
289
|
};
|
213
290
|
|
291
|
+
export const CustomModalDemo: StoryObj<StoryModalProps> = {
|
292
|
+
args: {
|
293
|
+
placement: 'center',
|
294
|
+
withBlur: false,
|
295
|
+
closeOnEsc: true,
|
296
|
+
closeOnOverlayClick: true,
|
297
|
+
offsetX: 0,
|
298
|
+
offsetY: 0,
|
299
|
+
},
|
300
|
+
render: (args) => <StoryCustomModalDemo {...args} />,
|
301
|
+
};
|
302
|
+
|
214
303
|
const StyledModalAnimation = styled(Modal)`
|
215
304
|
/* stylelint-disable */
|
216
305
|
&& .${popupClasses.root} {
|
@@ -12,7 +12,7 @@ var config = exports.config = {
|
|
12
12
|
},
|
13
13
|
variations: {
|
14
14
|
view: {
|
15
|
-
"default": /*#__PURE__*/(0, _styledComponents.css)(["", ":var(--overlay-blur);", ":var(--overlay-soft);"], _Modal.modalTokens.modalOverlayWithBlurColor, _Modal.modalTokens.modalOverlayColor)
|
15
|
+
"default": /*#__PURE__*/(0, _styledComponents.css)(["", ":var(--overlay-blur);", ":var(--overlay-soft);", ":var(--surface-solid-card);", ":1.25rem;", ":2rem;", ":0.625rem;", ":0.375rem;", ":var(--surface-accent);"], _Modal.modalTokens.modalOverlayWithBlurColor, _Modal.modalTokens.modalOverlayColor, _Modal.modalTokens.modalBodyBackground, _Modal.modalTokens.modalBodyBorderRadius, _Modal.modalTokens.modalBodyPadding, _Modal.modalTokens.modalContentPadding, _Modal.modalTokens.modalCloseButtonRadius, _Modal.modalTokens.modalOutlineFocusColor)
|
16
16
|
}
|
17
17
|
}
|
18
18
|
};
|