@salutejs/plasma-new-hope 0.146.1-canary.1412.10900761739.0 → 0.146.1-canary.1412.10901451694.0
Sign up to get free protection for your applications and to get access to all the features.
- package/cjs/components/Popup/Popup.js +0 -130
- package/cjs/components/Popup/Popup.js.map +1 -1
- package/emotion/cjs/components/Popup/Popup.js +0 -130
- package/emotion/cjs/examples/plasma_b2c/components/Drawer/Drawer.stories.tsx +1 -1
- package/emotion/cjs/examples/plasma_b2c/components/Modal/Modal.stories.tsx +1 -1
- package/emotion/cjs/examples/plasma_b2c/components/Popup/Popup.stories.tsx +1 -1
- package/emotion/cjs/examples/plasma_web/components/Modal/Modal.stories.tsx +1 -1
- package/emotion/cjs/examples/plasma_web/components/Popup/Popup.stories.tsx +1 -1
- package/emotion/es/components/Popup/Popup.js +0 -130
- package/emotion/es/examples/plasma_b2c/components/Drawer/Drawer.stories.tsx +1 -1
- package/emotion/es/examples/plasma_b2c/components/Modal/Modal.stories.tsx +1 -1
- package/emotion/es/examples/plasma_b2c/components/Popup/Popup.stories.tsx +1 -1
- package/emotion/es/examples/plasma_web/components/Modal/Modal.stories.tsx +1 -1
- package/emotion/es/examples/plasma_web/components/Popup/Popup.stories.tsx +1 -1
- package/es/components/Popup/Popup.js +0 -130
- package/es/components/Popup/Popup.js.map +1 -1
- package/package.json +3 -3
- package/styled-components/cjs/components/Popup/Popup.js +0 -130
- package/styled-components/cjs/examples/plasma_b2c/components/Drawer/Drawer.stories.tsx +1 -1
- package/styled-components/cjs/examples/plasma_b2c/components/Modal/Modal.stories.tsx +1 -1
- package/styled-components/cjs/examples/plasma_b2c/components/Popup/Popup.stories.tsx +1 -1
- package/styled-components/cjs/examples/plasma_web/components/Modal/Modal.stories.tsx +1 -1
- package/styled-components/cjs/examples/plasma_web/components/Popup/Popup.stories.tsx +1 -1
- package/styled-components/es/components/Popup/Popup.js +0 -130
- package/styled-components/es/examples/plasma_b2c/components/Drawer/Drawer.stories.tsx +1 -1
- package/styled-components/es/examples/plasma_b2c/components/Modal/Modal.stories.tsx +1 -1
- package/styled-components/es/examples/plasma_b2c/components/Popup/Popup.stories.tsx +1 -1
- package/styled-components/es/examples/plasma_web/components/Modal/Modal.stories.tsx +1 -1
- package/styled-components/es/examples/plasma_web/components/Popup/Popup.stories.tsx +1 -1
- package/types/components/Popup/Popup.d.ts.map +1 -1
@@ -70,136 +70,6 @@ var handlePosition = function handlePosition(placement, offset) {
|
|
70
70
|
transform: transform
|
71
71
|
};
|
72
72
|
};
|
73
|
-
/*
|
74
|
-
const getPortalParent = (frame: 'document' | string | React.RefObject<HTMLElement>, portalRef) => {
|
75
|
-
if (typeof frame !== 'string' && frame && frame.current) {
|
76
|
-
portalRef.current = frame.current;
|
77
|
-
return;
|
78
|
-
}
|
79
|
-
|
80
|
-
if (typeof frame === 'string' && frame !== 'document') {
|
81
|
-
const element = document.getElementById(frame);
|
82
|
-
if (element) {
|
83
|
-
const portal = document.createElement('div');
|
84
|
-
portal.className = 'frame-portal';
|
85
|
-
portal.style.position = 'relative';
|
86
|
-
portal.style.width = '0';
|
87
|
-
|
88
|
-
element.appendChild(portal);
|
89
|
-
portalRef.current = portal;
|
90
|
-
|
91
|
-
return;
|
92
|
-
//
|
93
|
-
// const portal = document?.querySelector('.frame-portal');
|
94
|
-
// if (!portal) {
|
95
|
-
// portal = document.createElement('div');
|
96
|
-
// document.getElementById(frame)?.appendChild(portal);
|
97
|
-
// }
|
98
|
-
// return portal;
|
99
|
-
}
|
100
|
-
}
|
101
|
-
|
102
|
-
const portal = document.getElementById(POPUP_PORTAL_ID);
|
103
|
-
|
104
|
-
if (!portal) {
|
105
|
-
ReactDOM.createPortal(<StyledPortal id={POPUP_PORTAL_ID} ref={portalRef} />, document.body);
|
106
|
-
}
|
107
|
-
|
108
|
-
portalRef.current = portal;
|
109
|
-
|
110
|
-
let portal;
|
111
|
-
|
112
|
-
const hasFrame = typeof frame !== 'string' && frame && frame.current;
|
113
|
-
if (hasFrame) {
|
114
|
-
portal = frame.current;
|
115
|
-
} else {
|
116
|
-
// ReactDOM.createPortal(<StyledPortal id={POPUP_PORTAL_ID} ref={portalRef} />, document.body);
|
117
|
-
|
118
|
-
portal = document.getElementById(POPUP_PORTAL_ID);
|
119
|
-
|
120
|
-
if (!portal) {
|
121
|
-
if (typeof frame === 'string' && frame !== 'document') {
|
122
|
-
portal = document.createElement('div');
|
123
|
-
document.getElementById(frame)?.appendChild(portal);
|
124
|
-
} else {
|
125
|
-
portal.className('frame-portal');
|
126
|
-
document.body.appendChild(portal);
|
127
|
-
// ReactDOM.createPortal(<StyledPortal id={POPUP_PORTAL_ID} ref={portalRef} />, document.body);
|
128
|
-
}
|
129
|
-
}
|
130
|
-
}
|
131
|
-
|
132
|
-
};
|
133
|
-
|
134
|
-
const usePortalContainer = (frame: 'document' | string | React.RefObject<HTMLElement>) => {
|
135
|
-
const portalRef = useRef<HTMLDivElement | null>(null);
|
136
|
-
|
137
|
-
if (typeof frame !== 'string' && frame && frame.current) {
|
138
|
-
return frame.current;
|
139
|
-
}
|
140
|
-
|
141
|
-
if (typeof frame === 'string' && frame !== 'document') {
|
142
|
-
const element = document.getElementById(frame);
|
143
|
-
|
144
|
-
const portal = document?.querySelector('.frame-portal');
|
145
|
-
|
146
|
-
if (portal) {
|
147
|
-
return portal;
|
148
|
-
}
|
149
|
-
|
150
|
-
if (element) {
|
151
|
-
const portal = document.createElement('div');
|
152
|
-
portal.className = 'frame-portal';
|
153
|
-
portal.style.position = 'relative';
|
154
|
-
// portal.style.width = '0';
|
155
|
-
|
156
|
-
element.appendChild(portal);
|
157
|
-
return portal;
|
158
|
-
//
|
159
|
-
// const portal = document?.querySelector('.frame-portal');
|
160
|
-
// if (!portal) {
|
161
|
-
// portal = document.createElement('div');
|
162
|
-
// document.getElementById(frame)?.appendChild(portal);
|
163
|
-
// }
|
164
|
-
// return portal;
|
165
|
-
}
|
166
|
-
}
|
167
|
-
|
168
|
-
const portal = document.getElementById(POPUP_PORTAL_ID);
|
169
|
-
|
170
|
-
if (!portal) {
|
171
|
-
const res = ReactDOM.createPortal(<StyledPortal id={POPUP_PORTAL_ID} ref={portalRef} />, document.body);
|
172
|
-
|
173
|
-
console.log('!!! res', res);
|
174
|
-
}
|
175
|
-
|
176
|
-
console.log('!!!! portalRef.current', portalRef.current, document.getElementById(POPUP_PORTAL_ID));
|
177
|
-
return portalRef.current;
|
178
|
-
|
179
|
-
let portal;
|
180
|
-
|
181
|
-
const hasFrame = typeof frame !== 'string' && frame && frame.current;
|
182
|
-
if (hasFrame) {
|
183
|
-
portal = frame.current;
|
184
|
-
} else {
|
185
|
-
// ReactDOM.createPortal(<StyledPortal id={POPUP_PORTAL_ID} ref={portalRef} />, document.body);
|
186
|
-
|
187
|
-
portal = document.getElementById(POPUP_PORTAL_ID);
|
188
|
-
|
189
|
-
if (!portal) {
|
190
|
-
if (typeof frame === 'string' && frame !== 'document') {
|
191
|
-
portal = document.createElement('div');
|
192
|
-
document.getElementById(frame)?.appendChild(portal);
|
193
|
-
} else {
|
194
|
-
portal.className('frame-portal');
|
195
|
-
document.body.appendChild(portal);
|
196
|
-
// ReactDOM.createPortal(<StyledPortal id={POPUP_PORTAL_ID} ref={portalRef} />, document.body);
|
197
|
-
}
|
198
|
-
}
|
199
|
-
}
|
200
|
-
|
201
|
-
};
|
202
|
-
*/
|
203
73
|
|
204
74
|
/**
|
205
75
|
* Базовый компонент Popup.
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"Popup.js","sources":["../../../src/components/Popup/Popup.tsx"],"sourcesContent":["import React, { forwardRef, useRef } from 'react';\nimport ReactDOM from 'react-dom';\nimport { useForkRef, safeUseId } from '@salutejs/plasma-core';\n\nimport { RootProps } from '../../engines/types';\nimport { cx } from '../../utils';\nimport { Portal } from '../Portal';\n\nimport type { PopupPlacementBasic, PopupPlacement, PopupPositionType, PopupProps } from './Popup.types';\nimport { POPUP_PORTAL_ID } from './PopupContext';\nimport { PopupRoot } from './PopupRoot';\nimport { usePopup } from './hooks';\nimport { classes } from './Popup.tokens';\nimport { StyledPortalContainer } from './Popup.styles';\n\nexport const handlePosition = (\n placement: PopupPlacement,\n offset: [number, number] | [string, string],\n): PopupPositionType => {\n let x = '0rem';\n let y = '0rem';\n\n if (offset) {\n const [_x, _y] = offset;\n x = typeof _x === 'number' ? `${_x}rem` : _x;\n y = typeof _y === 'number' ? `${_y}rem` : _y;\n }\n\n if (!placement || placement === 'center') {\n return {\n left: `calc(50% + ${x})`,\n top: `calc(50% - ${y})`,\n transform: 'translate(-50%, -50%)',\n };\n }\n\n let left;\n let right;\n let top;\n let bottom;\n let transform;\n const placements = placement.split('-') as PopupPlacementBasic[];\n\n placements.forEach((placementValue: PopupPlacementBasic) => {\n switch (placementValue) {\n case 'left':\n left = x;\n break;\n case 'right':\n right = x;\n break;\n case 'top':\n top = y;\n break;\n case 'bottom':\n bottom = y;\n break;\n default:\n break;\n }\n });\n\n const isCenteredX = left === undefined && right === undefined;\n const isCenteredY = top === undefined && bottom === undefined;\n\n if (isCenteredX) {\n transform = 'translateX(-50%)';\n }\n\n if (isCenteredY) {\n transform = 'translateY(-50%)';\n }\n\n return {\n left: isCenteredX ? `calc(50% + ${x})` : left,\n right,\n top: isCenteredY ? `calc(50% - ${y})` : top,\n bottom,\n transform,\n };\n};\n/*\nconst getPortalParent = (frame: 'document' | string | React.RefObject<HTMLElement>, portalRef) => {\n if (typeof frame !== 'string' && frame && frame.current) {\n portalRef.current = frame.current;\n return;\n }\n\n if (typeof frame === 'string' && frame !== 'document') {\n const element = document.getElementById(frame);\n if (element) {\n const portal = document.createElement('div');\n portal.className = 'frame-portal';\n portal.style.position = 'relative';\n portal.style.width = '0';\n\n element.appendChild(portal);\n portalRef.current = portal;\n\n return;\n //\n // const portal = document?.querySelector('.frame-portal');\n // if (!portal) {\n // portal = document.createElement('div');\n // document.getElementById(frame)?.appendChild(portal);\n // }\n // return portal;\n }\n }\n\n const portal = document.getElementById(POPUP_PORTAL_ID);\n\n if (!portal) {\n ReactDOM.createPortal(<StyledPortal id={POPUP_PORTAL_ID} ref={portalRef} />, document.body);\n }\n\n portalRef.current = portal;\n\n let portal;\n\n const hasFrame = typeof frame !== 'string' && frame && frame.current;\n if (hasFrame) {\n portal = frame.current;\n } else {\n // ReactDOM.createPortal(<StyledPortal id={POPUP_PORTAL_ID} ref={portalRef} />, document.body);\n\n portal = document.getElementById(POPUP_PORTAL_ID);\n\n if (!portal) {\n if (typeof frame === 'string' && frame !== 'document') {\n portal = document.createElement('div');\n document.getElementById(frame)?.appendChild(portal);\n } else {\n portal.className('frame-portal');\n document.body.appendChild(portal);\n // ReactDOM.createPortal(<StyledPortal id={POPUP_PORTAL_ID} ref={portalRef} />, document.body);\n }\n }\n }\n\n};\n\nconst usePortalContainer = (frame: 'document' | string | React.RefObject<HTMLElement>) => {\n const portalRef = useRef<HTMLDivElement | null>(null);\n\n if (typeof frame !== 'string' && frame && frame.current) {\n return frame.current;\n }\n\n if (typeof frame === 'string' && frame !== 'document') {\n const element = document.getElementById(frame);\n\n const portal = document?.querySelector('.frame-portal');\n\n if (portal) {\n return portal;\n }\n\n if (element) {\n const portal = document.createElement('div');\n portal.className = 'frame-portal';\n portal.style.position = 'relative';\n // portal.style.width = '0';\n\n element.appendChild(portal);\n return portal;\n //\n // const portal = document?.querySelector('.frame-portal');\n // if (!portal) {\n // portal = document.createElement('div');\n // document.getElementById(frame)?.appendChild(portal);\n // }\n // return portal;\n }\n }\n\n const portal = document.getElementById(POPUP_PORTAL_ID);\n\n if (!portal) {\n const res = ReactDOM.createPortal(<StyledPortal id={POPUP_PORTAL_ID} ref={portalRef} />, document.body);\n\n console.log('!!! res', res);\n }\n\n console.log('!!!! portalRef.current', portalRef.current, document.getElementById(POPUP_PORTAL_ID));\n return portalRef.current;\n\n let portal;\n\n const hasFrame = typeof frame !== 'string' && frame && frame.current;\n if (hasFrame) {\n portal = frame.current;\n } else {\n // ReactDOM.createPortal(<StyledPortal id={POPUP_PORTAL_ID} ref={portalRef} />, document.body);\n\n portal = document.getElementById(POPUP_PORTAL_ID);\n\n if (!portal) {\n if (typeof frame === 'string' && frame !== 'document') {\n portal = document.createElement('div');\n document.getElementById(frame)?.appendChild(portal);\n } else {\n portal.className('frame-portal');\n document.body.appendChild(portal);\n // ReactDOM.createPortal(<StyledPortal id={POPUP_PORTAL_ID} ref={portalRef} />, document.body);\n }\n }\n }\n\n};\n*/\n\n/**\n * Базовый компонент Popup.\n */\nexport const popupRoot = (Root: RootProps<HTMLDivElement, PopupProps>) =>\n forwardRef<HTMLDivElement, PopupProps>(\n (\n {\n id,\n isOpen = false,\n opened = false,\n placement = 'center',\n offset = [0, 0],\n frame = 'document',\n children,\n overlay,\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n role,\n zIndex,\n popupInfo,\n withAnimation = false,\n className,\n ...rest\n },\n outerRootRef,\n ) => {\n const innerIsOpen = isOpen || opened;\n\n const uniqId = safeUseId();\n const innerId = id || uniqId;\n\n const { isVisible, animationInfo, setVisible } = usePopup({\n isOpen: innerIsOpen,\n id: innerId,\n popupInfo,\n withAnimation,\n });\n\n const portalRef = useRef<HTMLDivElement | null>(null);\n const contentRef = useRef<HTMLDivElement | null>(null);\n\n const innerRef = useForkRef<HTMLDivElement>(contentRef, outerRootRef);\n\n if (!isVisible && !innerIsOpen) {\n return null;\n }\n\n const cls = cx(\n className,\n animationInfo?.endAnimation ? classes.endAnimation : '',\n animationInfo?.endTransition ? classes.endTransition : '',\n );\n\n const rootNode = (\n <Root className={cls} {...rest}>\n {overlay}\n <PopupRoot\n id={innerId}\n ref={innerRef}\n position={handlePosition(placement, offset)}\n frame={frame}\n zIndex={zIndex}\n animationInfo={animationInfo}\n setVisible={setVisible}\n >\n {children}\n </PopupRoot>\n </Root>\n );\n\n if (typeof frame !== 'string' && frame && frame.current) {\n return <Portal container={frame.current}>{rootNode}</Portal>;\n }\n\n const withFrameId = typeof frame === 'string' && frame !== 'document';\n const containerElement = withFrameId && document.getElementById(frame as string);\n\n if (containerElement) {\n return (\n <>\n {ReactDOM.createPortal(\n <StyledPortalContainer ref={portalRef}>\n {portalRef.current && <Portal container={portalRef.current}>{rootNode}</Portal>}\n </StyledPortalContainer>,\n containerElement,\n )}\n </>\n );\n }\n\n const globalPortal = typeof document !== 'undefined' && document.getElementById(POPUP_PORTAL_ID);\n\n return <>{globalPortal && <Portal container={globalPortal}>{rootNode}</Portal>}</>;\n },\n );\n\nexport const popupConfig = {\n name: 'Popup',\n tag: 'div',\n layout: popupRoot,\n base: '',\n variations: {},\n defaults: {},\n};\n"],"names":["handlePosition","placement","offset","x","y","_offset","_slicedToArray","_x","_y","concat","left","top","transform","right","bottom","placements","split","forEach","placementValue","isCenteredX","undefined","isCenteredY","popupRoot","Root","forwardRef","_ref","outerRootRef","id","_ref$isOpen","isOpen","_ref$opened","opened","_ref$placement","_ref$offset","_ref$frame","frame","children","overlay","zIndex","popupInfo","_ref$withAnimation","withAnimation","className","rest","_objectWithoutProperties","_excluded","innerIsOpen","uniqId","safeUseId","innerId","_usePopup","usePopup","isVisible","animationInfo","setVisible","portalRef","useRef","contentRef","innerRef","useForkRef","cls","cx","endAnimation","classes","endTransition","rootNode","React","createElement","_extends","PopupRoot","ref","position","current","Portal","container","withFrameId","containerElement","document","getElementById","Fragment","ReactDOM","createPortal","StyledPortalContainer","globalPortal","POPUP_PORTAL_ID","popupConfig","name","tag","layout","base","variations","defaults"],"mappings":";;;;;;;;;;;;;;;;;AAeO,IAAMA,cAAc,GAAG,SAAjBA,cAAcA,CACvBC,SAAyB,EACzBC,MAA2C,EACvB;EACpB,IAAIC,CAAC,GAAG,MAAM,CAAA;EACd,IAAIC,CAAC,GAAG,MAAM,CAAA;AAEd,EAAA,IAAIF,MAAM,EAAE;AACR,IAAA,IAAAG,OAAA,GAAAC,uCAAA,CAAiBJ,MAAM,EAAA,CAAA,CAAA;AAAhBK,MAAAA,EAAE,GAAAF,OAAA,CAAA,CAAA,CAAA;AAAEG,MAAAA,EAAE,GAAAH,OAAA,CAAA,CAAA,CAAA,CAAA;IACbF,CAAC,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AK,KAAKO,SAAS,CAAA;EAC7D,IAAMC,WAAW,GAAGV,GAAG,KAAKS,SAAS,IAAIN,MAAM,KAAKM,SAAS,CAAA;AAE7D,EAAA,IAAID,WAAW,EAAE;AACbP,IAAAA,SAAS,GAAG,kBAAkB,CAAA;AAClC,GAAA;AAEA,EAAA,IAAIS,WAAW,EAAE;AACbT,IAAAA,SAAS,GAAG,kBAAkB,CAAA;AAClC,GAAA;EAEA,OAAO;AACHF,IAAAA,IAAI,EAAES,WAAW,GAAA,aAAA,CAAAV,MAAA,CAAiBN,CAAC,SAAMO,IAAI;AAC7CG,IAAAA,KAAK,EAALA,KAAK;AACLF,IAAAA,GAAG,EAAEU,WAAW,GAAA,aAAA,CAAAZ,MAAA,CAAiBL,CAAC,SAAMO,GAAG;AAC3CG,IAAAA,MAAM,EAANA,MAAM;AACNF,IAAAA,SAAS,EAATA,SAAAA;GACH,CAAA;AACL,EAAC;AACD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;IACaU,SAAS,GAAG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KAAA;AAEA,IAAA,IAAMO,YAAY,GAAG,OAAON,QAAQ,KAAK,WAAW,IAAIA,QAAQ,CAACC,cAAc,CAACM,4BAAe,CAAC,CAAA;AAEhG,IAAA,oBAAOlB,KAAA,CAAAC,aAAA,CAAAD,KAAA,CAAAa,QAAA,EAAGI,IAAAA,EAAAA,YAAY,iBAAIjB,KAAA,CAAAC,aAAA,CAACM,aAAM,EAAA;AAACC,MAAAA,SAAS,EAAES,YAAAA;KAAelB,EAAAA,QAAiB,CAAI,CAAC,CAAA;AACtF,GACJ,CAAC,CAAA;AAAA,EAAA;AAEE,IAAMoB,WAAW,GAAG;AACvBC,EAAAA,IAAI,EAAE,OAAO;AACbC,EAAAA,GAAG,EAAE,KAAK;AACVC,EAAAA,MAAM,EAAElE,SAAS;AACjBmE,EAAAA,IAAI,EAAE,EAAE;EACRC,UAAU,EAAE,EAAE;AACdC,EAAAA,QAAQ,EAAE,EAAC;AACf;;;;;;"}
|
1
|
+
{"version":3,"file":"Popup.js","sources":["../../../src/components/Popup/Popup.tsx"],"sourcesContent":["import React, { forwardRef, useRef } from 'react';\nimport ReactDOM from 'react-dom';\nimport { useForkRef, safeUseId } from '@salutejs/plasma-core';\n\nimport { RootProps } from '../../engines/types';\nimport { cx } from '../../utils';\nimport { Portal } from '../Portal';\n\nimport type { PopupPlacementBasic, PopupPlacement, PopupPositionType, PopupProps } from './Popup.types';\nimport { POPUP_PORTAL_ID } from './PopupContext';\nimport { PopupRoot } from './PopupRoot';\nimport { usePopup } from './hooks';\nimport { classes } from './Popup.tokens';\nimport { StyledPortalContainer } from './Popup.styles';\n\nexport const handlePosition = (\n placement: PopupPlacement,\n offset: [number, number] | [string, string],\n): PopupPositionType => {\n let x = '0rem';\n let y = '0rem';\n\n if (offset) {\n const [_x, _y] = offset;\n x = typeof _x === 'number' ? `${_x}rem` : _x;\n y = typeof _y === 'number' ? `${_y}rem` : _y;\n }\n\n if (!placement || placement === 'center') {\n return {\n left: `calc(50% + ${x})`,\n top: `calc(50% - ${y})`,\n transform: 'translate(-50%, -50%)',\n };\n }\n\n let left;\n let right;\n let top;\n let bottom;\n let transform;\n const placements = placement.split('-') as PopupPlacementBasic[];\n\n placements.forEach((placementValue: PopupPlacementBasic) => {\n switch (placementValue) {\n case 'left':\n left = x;\n break;\n case 'right':\n right = x;\n break;\n case 'top':\n top = y;\n break;\n case 'bottom':\n bottom = y;\n break;\n default:\n break;\n }\n });\n\n const isCenteredX = left === undefined && right === undefined;\n const isCenteredY = top === undefined && bottom === undefined;\n\n if (isCenteredX) {\n transform = 'translateX(-50%)';\n }\n\n if (isCenteredY) {\n transform = 'translateY(-50%)';\n }\n\n return {\n left: isCenteredX ? `calc(50% + ${x})` : left,\n right,\n top: isCenteredY ? `calc(50% - ${y})` : top,\n bottom,\n transform,\n };\n};\n\n/**\n * Базовый компонент Popup.\n */\nexport const popupRoot = (Root: RootProps<HTMLDivElement, PopupProps>) =>\n forwardRef<HTMLDivElement, PopupProps>(\n (\n {\n id,\n isOpen = false,\n opened = false,\n placement = 'center',\n offset = [0, 0],\n frame = 'document',\n children,\n overlay,\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n role,\n zIndex,\n popupInfo,\n withAnimation = false,\n className,\n ...rest\n },\n outerRootRef,\n ) => {\n const innerIsOpen = isOpen || opened;\n\n const uniqId = safeUseId();\n const innerId = id || uniqId;\n\n const { isVisible, animationInfo, setVisible } = usePopup({\n isOpen: innerIsOpen,\n id: innerId,\n popupInfo,\n withAnimation,\n });\n\n const portalRef = useRef<HTMLDivElement | null>(null);\n const contentRef = useRef<HTMLDivElement | null>(null);\n\n const innerRef = useForkRef<HTMLDivElement>(contentRef, outerRootRef);\n\n if (!isVisible && !innerIsOpen) {\n return null;\n }\n\n const cls = cx(\n className,\n animationInfo?.endAnimation ? classes.endAnimation : '',\n animationInfo?.endTransition ? classes.endTransition : '',\n );\n\n const rootNode = (\n <Root className={cls} {...rest}>\n {overlay}\n <PopupRoot\n id={innerId}\n ref={innerRef}\n position={handlePosition(placement, offset)}\n frame={frame}\n zIndex={zIndex}\n animationInfo={animationInfo}\n setVisible={setVisible}\n >\n {children}\n </PopupRoot>\n </Root>\n );\n\n if (typeof frame !== 'string' && frame && frame.current) {\n return <Portal container={frame.current}>{rootNode}</Portal>;\n }\n\n const withFrameId = typeof frame === 'string' && frame !== 'document';\n const containerElement = withFrameId && document.getElementById(frame as string);\n\n if (containerElement) {\n return (\n <>\n {ReactDOM.createPortal(\n <StyledPortalContainer ref={portalRef}>\n {portalRef.current && <Portal container={portalRef.current}>{rootNode}</Portal>}\n </StyledPortalContainer>,\n containerElement,\n )}\n </>\n );\n }\n\n const globalPortal = typeof document !== 'undefined' && document.getElementById(POPUP_PORTAL_ID);\n\n return <>{globalPortal && <Portal container={globalPortal}>{rootNode}</Portal>}</>;\n },\n );\n\nexport const popupConfig = {\n name: 'Popup',\n tag: 'div',\n layout: popupRoot,\n base: '',\n variations: {},\n defaults: {},\n};\n"],"names":["handlePosition","placement","offset","x","y","_offset","_slicedToArray","_x","_y","concat","left","top","transform","right","bottom","placements","split","forEach","placementValue","isCenteredX","undefined","isCenteredY","popupRoot","Root","forwardRef","_ref","outerRootRef","id","_ref$isOpen","isOpen","_ref$opened","opened","_ref$placement","_ref$offset","_ref$frame","frame","children","overlay","zIndex","popupInfo","_ref$withAnimation","withAnimation","className","rest","_objectWithoutProperties","_excluded","innerIsOpen","uniqId","safeUseId","innerId","_usePopup","usePopup","isVisible","animationInfo","setVisible","portalRef","useRef","contentRef","innerRef","useForkRef","cls","cx","endAnimation","classes","endTransition","rootNode","React","createElement","_extends","PopupRoot","ref","position","current","Portal","container","withFrameId","containerElement","document","getElementById","Fragment","ReactDOM","createPortal","StyledPortalContainer","globalPortal","POPUP_PORTAL_ID","popupConfig","name","tag","layout","base","variations","defaults"],"mappings":";;;;;;;;;;;;;;;;;AAeO,IAAMA,cAAc,GAAG,SAAjBA,cAAcA,CACvBC,SAAyB,EACzBC,MAA2C,EACvB;EACpB,IAA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ACJ,CAAC,CAAA;AAAA,EAAA;AAEE,IAAMoB,WAAW,GAAG;AACvBC,EAAAA,IAAI,EAAE,OAAO;AACbC,EAAAA,GAAG,EAAE,KAAK;AACVC,EAAAA,MAAM,EAAElE,SAAS;AACjBmE,EAAAA,IAAI,EAAE,EAAE;EACRC,UAAU,EAAE,EAAE;AACdC,EAAAA,QAAQ,EAAE,EAAC;AACf;;;;;;"}
|
@@ -85,136 +85,6 @@ var handlePosition = exports.handlePosition = function handlePosition(placement,
|
|
85
85
|
transform: transform
|
86
86
|
};
|
87
87
|
};
|
88
|
-
/*
|
89
|
-
const getPortalParent = (frame: 'document' | string | React.RefObject<HTMLElement>, portalRef) => {
|
90
|
-
if (typeof frame !== 'string' && frame && frame.current) {
|
91
|
-
portalRef.current = frame.current;
|
92
|
-
return;
|
93
|
-
}
|
94
|
-
|
95
|
-
if (typeof frame === 'string' && frame !== 'document') {
|
96
|
-
const element = document.getElementById(frame);
|
97
|
-
if (element) {
|
98
|
-
const portal = document.createElement('div');
|
99
|
-
portal.className = 'frame-portal';
|
100
|
-
portal.style.position = 'relative';
|
101
|
-
portal.style.width = '0';
|
102
|
-
|
103
|
-
element.appendChild(portal);
|
104
|
-
portalRef.current = portal;
|
105
|
-
|
106
|
-
return;
|
107
|
-
//
|
108
|
-
// const portal = document?.querySelector('.frame-portal');
|
109
|
-
// if (!portal) {
|
110
|
-
// portal = document.createElement('div');
|
111
|
-
// document.getElementById(frame)?.appendChild(portal);
|
112
|
-
// }
|
113
|
-
// return portal;
|
114
|
-
}
|
115
|
-
}
|
116
|
-
|
117
|
-
const portal = document.getElementById(POPUP_PORTAL_ID);
|
118
|
-
|
119
|
-
if (!portal) {
|
120
|
-
ReactDOM.createPortal(<StyledPortal id={POPUP_PORTAL_ID} ref={portalRef} />, document.body);
|
121
|
-
}
|
122
|
-
|
123
|
-
portalRef.current = portal;
|
124
|
-
|
125
|
-
let portal;
|
126
|
-
|
127
|
-
const hasFrame = typeof frame !== 'string' && frame && frame.current;
|
128
|
-
if (hasFrame) {
|
129
|
-
portal = frame.current;
|
130
|
-
} else {
|
131
|
-
// ReactDOM.createPortal(<StyledPortal id={POPUP_PORTAL_ID} ref={portalRef} />, document.body);
|
132
|
-
|
133
|
-
portal = document.getElementById(POPUP_PORTAL_ID);
|
134
|
-
|
135
|
-
if (!portal) {
|
136
|
-
if (typeof frame === 'string' && frame !== 'document') {
|
137
|
-
portal = document.createElement('div');
|
138
|
-
document.getElementById(frame)?.appendChild(portal);
|
139
|
-
} else {
|
140
|
-
portal.className('frame-portal');
|
141
|
-
document.body.appendChild(portal);
|
142
|
-
// ReactDOM.createPortal(<StyledPortal id={POPUP_PORTAL_ID} ref={portalRef} />, document.body);
|
143
|
-
}
|
144
|
-
}
|
145
|
-
}
|
146
|
-
|
147
|
-
};
|
148
|
-
|
149
|
-
const usePortalContainer = (frame: 'document' | string | React.RefObject<HTMLElement>) => {
|
150
|
-
const portalRef = useRef<HTMLDivElement | null>(null);
|
151
|
-
|
152
|
-
if (typeof frame !== 'string' && frame && frame.current) {
|
153
|
-
return frame.current;
|
154
|
-
}
|
155
|
-
|
156
|
-
if (typeof frame === 'string' && frame !== 'document') {
|
157
|
-
const element = document.getElementById(frame);
|
158
|
-
|
159
|
-
const portal = document?.querySelector('.frame-portal');
|
160
|
-
|
161
|
-
if (portal) {
|
162
|
-
return portal;
|
163
|
-
}
|
164
|
-
|
165
|
-
if (element) {
|
166
|
-
const portal = document.createElement('div');
|
167
|
-
portal.className = 'frame-portal';
|
168
|
-
portal.style.position = 'relative';
|
169
|
-
// portal.style.width = '0';
|
170
|
-
|
171
|
-
element.appendChild(portal);
|
172
|
-
return portal;
|
173
|
-
//
|
174
|
-
// const portal = document?.querySelector('.frame-portal');
|
175
|
-
// if (!portal) {
|
176
|
-
// portal = document.createElement('div');
|
177
|
-
// document.getElementById(frame)?.appendChild(portal);
|
178
|
-
// }
|
179
|
-
// return portal;
|
180
|
-
}
|
181
|
-
}
|
182
|
-
|
183
|
-
const portal = document.getElementById(POPUP_PORTAL_ID);
|
184
|
-
|
185
|
-
if (!portal) {
|
186
|
-
const res = ReactDOM.createPortal(<StyledPortal id={POPUP_PORTAL_ID} ref={portalRef} />, document.body);
|
187
|
-
|
188
|
-
console.log('!!! res', res);
|
189
|
-
}
|
190
|
-
|
191
|
-
console.log('!!!! portalRef.current', portalRef.current, document.getElementById(POPUP_PORTAL_ID));
|
192
|
-
return portalRef.current;
|
193
|
-
|
194
|
-
let portal;
|
195
|
-
|
196
|
-
const hasFrame = typeof frame !== 'string' && frame && frame.current;
|
197
|
-
if (hasFrame) {
|
198
|
-
portal = frame.current;
|
199
|
-
} else {
|
200
|
-
// ReactDOM.createPortal(<StyledPortal id={POPUP_PORTAL_ID} ref={portalRef} />, document.body);
|
201
|
-
|
202
|
-
portal = document.getElementById(POPUP_PORTAL_ID);
|
203
|
-
|
204
|
-
if (!portal) {
|
205
|
-
if (typeof frame === 'string' && frame !== 'document') {
|
206
|
-
portal = document.createElement('div');
|
207
|
-
document.getElementById(frame)?.appendChild(portal);
|
208
|
-
} else {
|
209
|
-
portal.className('frame-portal');
|
210
|
-
document.body.appendChild(portal);
|
211
|
-
// ReactDOM.createPortal(<StyledPortal id={POPUP_PORTAL_ID} ref={portalRef} />, document.body);
|
212
|
-
}
|
213
|
-
}
|
214
|
-
}
|
215
|
-
|
216
|
-
};
|
217
|
-
*/
|
218
88
|
|
219
89
|
/**
|
220
90
|
* Базовый компонент Popup.
|
@@ -75,136 +75,6 @@ export var handlePosition = function handlePosition(placement, offset) {
|
|
75
75
|
transform: transform
|
76
76
|
};
|
77
77
|
};
|
78
|
-
/*
|
79
|
-
const getPortalParent = (frame: 'document' | string | React.RefObject<HTMLElement>, portalRef) => {
|
80
|
-
if (typeof frame !== 'string' && frame && frame.current) {
|
81
|
-
portalRef.current = frame.current;
|
82
|
-
return;
|
83
|
-
}
|
84
|
-
|
85
|
-
if (typeof frame === 'string' && frame !== 'document') {
|
86
|
-
const element = document.getElementById(frame);
|
87
|
-
if (element) {
|
88
|
-
const portal = document.createElement('div');
|
89
|
-
portal.className = 'frame-portal';
|
90
|
-
portal.style.position = 'relative';
|
91
|
-
portal.style.width = '0';
|
92
|
-
|
93
|
-
element.appendChild(portal);
|
94
|
-
portalRef.current = portal;
|
95
|
-
|
96
|
-
return;
|
97
|
-
//
|
98
|
-
// const portal = document?.querySelector('.frame-portal');
|
99
|
-
// if (!portal) {
|
100
|
-
// portal = document.createElement('div');
|
101
|
-
// document.getElementById(frame)?.appendChild(portal);
|
102
|
-
// }
|
103
|
-
// return portal;
|
104
|
-
}
|
105
|
-
}
|
106
|
-
|
107
|
-
const portal = document.getElementById(POPUP_PORTAL_ID);
|
108
|
-
|
109
|
-
if (!portal) {
|
110
|
-
ReactDOM.createPortal(<StyledPortal id={POPUP_PORTAL_ID} ref={portalRef} />, document.body);
|
111
|
-
}
|
112
|
-
|
113
|
-
portalRef.current = portal;
|
114
|
-
|
115
|
-
let portal;
|
116
|
-
|
117
|
-
const hasFrame = typeof frame !== 'string' && frame && frame.current;
|
118
|
-
if (hasFrame) {
|
119
|
-
portal = frame.current;
|
120
|
-
} else {
|
121
|
-
// ReactDOM.createPortal(<StyledPortal id={POPUP_PORTAL_ID} ref={portalRef} />, document.body);
|
122
|
-
|
123
|
-
portal = document.getElementById(POPUP_PORTAL_ID);
|
124
|
-
|
125
|
-
if (!portal) {
|
126
|
-
if (typeof frame === 'string' && frame !== 'document') {
|
127
|
-
portal = document.createElement('div');
|
128
|
-
document.getElementById(frame)?.appendChild(portal);
|
129
|
-
} else {
|
130
|
-
portal.className('frame-portal');
|
131
|
-
document.body.appendChild(portal);
|
132
|
-
// ReactDOM.createPortal(<StyledPortal id={POPUP_PORTAL_ID} ref={portalRef} />, document.body);
|
133
|
-
}
|
134
|
-
}
|
135
|
-
}
|
136
|
-
|
137
|
-
};
|
138
|
-
|
139
|
-
const usePortalContainer = (frame: 'document' | string | React.RefObject<HTMLElement>) => {
|
140
|
-
const portalRef = useRef<HTMLDivElement | null>(null);
|
141
|
-
|
142
|
-
if (typeof frame !== 'string' && frame && frame.current) {
|
143
|
-
return frame.current;
|
144
|
-
}
|
145
|
-
|
146
|
-
if (typeof frame === 'string' && frame !== 'document') {
|
147
|
-
const element = document.getElementById(frame);
|
148
|
-
|
149
|
-
const portal = document?.querySelector('.frame-portal');
|
150
|
-
|
151
|
-
if (portal) {
|
152
|
-
return portal;
|
153
|
-
}
|
154
|
-
|
155
|
-
if (element) {
|
156
|
-
const portal = document.createElement('div');
|
157
|
-
portal.className = 'frame-portal';
|
158
|
-
portal.style.position = 'relative';
|
159
|
-
// portal.style.width = '0';
|
160
|
-
|
161
|
-
element.appendChild(portal);
|
162
|
-
return portal;
|
163
|
-
//
|
164
|
-
// const portal = document?.querySelector('.frame-portal');
|
165
|
-
// if (!portal) {
|
166
|
-
// portal = document.createElement('div');
|
167
|
-
// document.getElementById(frame)?.appendChild(portal);
|
168
|
-
// }
|
169
|
-
// return portal;
|
170
|
-
}
|
171
|
-
}
|
172
|
-
|
173
|
-
const portal = document.getElementById(POPUP_PORTAL_ID);
|
174
|
-
|
175
|
-
if (!portal) {
|
176
|
-
const res = ReactDOM.createPortal(<StyledPortal id={POPUP_PORTAL_ID} ref={portalRef} />, document.body);
|
177
|
-
|
178
|
-
console.log('!!! res', res);
|
179
|
-
}
|
180
|
-
|
181
|
-
console.log('!!!! portalRef.current', portalRef.current, document.getElementById(POPUP_PORTAL_ID));
|
182
|
-
return portalRef.current;
|
183
|
-
|
184
|
-
let portal;
|
185
|
-
|
186
|
-
const hasFrame = typeof frame !== 'string' && frame && frame.current;
|
187
|
-
if (hasFrame) {
|
188
|
-
portal = frame.current;
|
189
|
-
} else {
|
190
|
-
// ReactDOM.createPortal(<StyledPortal id={POPUP_PORTAL_ID} ref={portalRef} />, document.body);
|
191
|
-
|
192
|
-
portal = document.getElementById(POPUP_PORTAL_ID);
|
193
|
-
|
194
|
-
if (!portal) {
|
195
|
-
if (typeof frame === 'string' && frame !== 'document') {
|
196
|
-
portal = document.createElement('div');
|
197
|
-
document.getElementById(frame)?.appendChild(portal);
|
198
|
-
} else {
|
199
|
-
portal.className('frame-portal');
|
200
|
-
document.body.appendChild(portal);
|
201
|
-
// ReactDOM.createPortal(<StyledPortal id={POPUP_PORTAL_ID} ref={portalRef} />, document.body);
|
202
|
-
}
|
203
|
-
}
|
204
|
-
}
|
205
|
-
|
206
|
-
};
|
207
|
-
*/
|
208
78
|
|
209
79
|
/**
|
210
80
|
* Базовый компонент Popup.
|
@@ -66,136 +66,6 @@ var handlePosition = function handlePosition(placement, offset) {
|
|
66
66
|
transform: transform
|
67
67
|
};
|
68
68
|
};
|
69
|
-
/*
|
70
|
-
const getPortalParent = (frame: 'document' | string | React.RefObject<HTMLElement>, portalRef) => {
|
71
|
-
if (typeof frame !== 'string' && frame && frame.current) {
|
72
|
-
portalRef.current = frame.current;
|
73
|
-
return;
|
74
|
-
}
|
75
|
-
|
76
|
-
if (typeof frame === 'string' && frame !== 'document') {
|
77
|
-
const element = document.getElementById(frame);
|
78
|
-
if (element) {
|
79
|
-
const portal = document.createElement('div');
|
80
|
-
portal.className = 'frame-portal';
|
81
|
-
portal.style.position = 'relative';
|
82
|
-
portal.style.width = '0';
|
83
|
-
|
84
|
-
element.appendChild(portal);
|
85
|
-
portalRef.current = portal;
|
86
|
-
|
87
|
-
return;
|
88
|
-
//
|
89
|
-
// const portal = document?.querySelector('.frame-portal');
|
90
|
-
// if (!portal) {
|
91
|
-
// portal = document.createElement('div');
|
92
|
-
// document.getElementById(frame)?.appendChild(portal);
|
93
|
-
// }
|
94
|
-
// return portal;
|
95
|
-
}
|
96
|
-
}
|
97
|
-
|
98
|
-
const portal = document.getElementById(POPUP_PORTAL_ID);
|
99
|
-
|
100
|
-
if (!portal) {
|
101
|
-
ReactDOM.createPortal(<StyledPortal id={POPUP_PORTAL_ID} ref={portalRef} />, document.body);
|
102
|
-
}
|
103
|
-
|
104
|
-
portalRef.current = portal;
|
105
|
-
|
106
|
-
let portal;
|
107
|
-
|
108
|
-
const hasFrame = typeof frame !== 'string' && frame && frame.current;
|
109
|
-
if (hasFrame) {
|
110
|
-
portal = frame.current;
|
111
|
-
} else {
|
112
|
-
// ReactDOM.createPortal(<StyledPortal id={POPUP_PORTAL_ID} ref={portalRef} />, document.body);
|
113
|
-
|
114
|
-
portal = document.getElementById(POPUP_PORTAL_ID);
|
115
|
-
|
116
|
-
if (!portal) {
|
117
|
-
if (typeof frame === 'string' && frame !== 'document') {
|
118
|
-
portal = document.createElement('div');
|
119
|
-
document.getElementById(frame)?.appendChild(portal);
|
120
|
-
} else {
|
121
|
-
portal.className('frame-portal');
|
122
|
-
document.body.appendChild(portal);
|
123
|
-
// ReactDOM.createPortal(<StyledPortal id={POPUP_PORTAL_ID} ref={portalRef} />, document.body);
|
124
|
-
}
|
125
|
-
}
|
126
|
-
}
|
127
|
-
|
128
|
-
};
|
129
|
-
|
130
|
-
const usePortalContainer = (frame: 'document' | string | React.RefObject<HTMLElement>) => {
|
131
|
-
const portalRef = useRef<HTMLDivElement | null>(null);
|
132
|
-
|
133
|
-
if (typeof frame !== 'string' && frame && frame.current) {
|
134
|
-
return frame.current;
|
135
|
-
}
|
136
|
-
|
137
|
-
if (typeof frame === 'string' && frame !== 'document') {
|
138
|
-
const element = document.getElementById(frame);
|
139
|
-
|
140
|
-
const portal = document?.querySelector('.frame-portal');
|
141
|
-
|
142
|
-
if (portal) {
|
143
|
-
return portal;
|
144
|
-
}
|
145
|
-
|
146
|
-
if (element) {
|
147
|
-
const portal = document.createElement('div');
|
148
|
-
portal.className = 'frame-portal';
|
149
|
-
portal.style.position = 'relative';
|
150
|
-
// portal.style.width = '0';
|
151
|
-
|
152
|
-
element.appendChild(portal);
|
153
|
-
return portal;
|
154
|
-
//
|
155
|
-
// const portal = document?.querySelector('.frame-portal');
|
156
|
-
// if (!portal) {
|
157
|
-
// portal = document.createElement('div');
|
158
|
-
// document.getElementById(frame)?.appendChild(portal);
|
159
|
-
// }
|
160
|
-
// return portal;
|
161
|
-
}
|
162
|
-
}
|
163
|
-
|
164
|
-
const portal = document.getElementById(POPUP_PORTAL_ID);
|
165
|
-
|
166
|
-
if (!portal) {
|
167
|
-
const res = ReactDOM.createPortal(<StyledPortal id={POPUP_PORTAL_ID} ref={portalRef} />, document.body);
|
168
|
-
|
169
|
-
console.log('!!! res', res);
|
170
|
-
}
|
171
|
-
|
172
|
-
console.log('!!!! portalRef.current', portalRef.current, document.getElementById(POPUP_PORTAL_ID));
|
173
|
-
return portalRef.current;
|
174
|
-
|
175
|
-
let portal;
|
176
|
-
|
177
|
-
const hasFrame = typeof frame !== 'string' && frame && frame.current;
|
178
|
-
if (hasFrame) {
|
179
|
-
portal = frame.current;
|
180
|
-
} else {
|
181
|
-
// ReactDOM.createPortal(<StyledPortal id={POPUP_PORTAL_ID} ref={portalRef} />, document.body);
|
182
|
-
|
183
|
-
portal = document.getElementById(POPUP_PORTAL_ID);
|
184
|
-
|
185
|
-
if (!portal) {
|
186
|
-
if (typeof frame === 'string' && frame !== 'document') {
|
187
|
-
portal = document.createElement('div');
|
188
|
-
document.getElementById(frame)?.appendChild(portal);
|
189
|
-
} else {
|
190
|
-
portal.className('frame-portal');
|
191
|
-
document.body.appendChild(portal);
|
192
|
-
// ReactDOM.createPortal(<StyledPortal id={POPUP_PORTAL_ID} ref={portalRef} />, document.body);
|
193
|
-
}
|
194
|
-
}
|
195
|
-
}
|
196
|
-
|
197
|
-
};
|
198
|
-
*/
|
199
69
|
|
200
70
|
/**
|
201
71
|
* Базовый компонент Popup.
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"Popup.js","sources":["../../../src/components/Popup/Popup.tsx"],"sourcesContent":["import React, { forwardRef, useRef } from 'react';\nimport ReactDOM from 'react-dom';\nimport { useForkRef, safeUseId } from '@salutejs/plasma-core';\n\nimport { RootProps } from '../../engines/types';\nimport { cx } from '../../utils';\nimport { Portal } from '../Portal';\n\nimport type { PopupPlacementBasic, PopupPlacement, PopupPositionType, PopupProps } from './Popup.types';\nimport { POPUP_PORTAL_ID } from './PopupContext';\nimport { PopupRoot } from './PopupRoot';\nimport { usePopup } from './hooks';\nimport { classes } from './Popup.tokens';\nimport { StyledPortalContainer } from './Popup.styles';\n\nexport const handlePosition = (\n placement: PopupPlacement,\n offset: [number, number] | [string, string],\n): PopupPositionType => {\n let x = '0rem';\n let y = '0rem';\n\n if (offset) {\n const [_x, _y] = offset;\n x = typeof _x === 'number' ? `${_x}rem` : _x;\n y = typeof _y === 'number' ? `${_y}rem` : _y;\n }\n\n if (!placement || placement === 'center') {\n return {\n left: `calc(50% + ${x})`,\n top: `calc(50% - ${y})`,\n transform: 'translate(-50%, -50%)',\n };\n }\n\n let left;\n let right;\n let top;\n let bottom;\n let transform;\n const placements = placement.split('-') as PopupPlacementBasic[];\n\n placements.forEach((placementValue: PopupPlacementBasic) => {\n switch (placementValue) {\n case 'left':\n left = x;\n break;\n case 'right':\n right = x;\n break;\n case 'top':\n top = y;\n break;\n case 'bottom':\n bottom = y;\n break;\n default:\n break;\n }\n });\n\n const isCenteredX = left === undefined && right === undefined;\n const isCenteredY = top === undefined && bottom === undefined;\n\n if (isCenteredX) {\n transform = 'translateX(-50%)';\n }\n\n if (isCenteredY) {\n transform = 'translateY(-50%)';\n }\n\n return {\n left: isCenteredX ? `calc(50% + ${x})` : left,\n right,\n top: isCenteredY ? `calc(50% - ${y})` : top,\n bottom,\n transform,\n };\n};\n/*\nconst getPortalParent = (frame: 'document' | string | React.RefObject<HTMLElement>, portalRef) => {\n if (typeof frame !== 'string' && frame && frame.current) {\n portalRef.current = frame.current;\n return;\n }\n\n if (typeof frame === 'string' && frame !== 'document') {\n const element = document.getElementById(frame);\n if (element) {\n const portal = document.createElement('div');\n portal.className = 'frame-portal';\n portal.style.position = 'relative';\n portal.style.width = '0';\n\n element.appendChild(portal);\n portalRef.current = portal;\n\n return;\n //\n // const portal = document?.querySelector('.frame-portal');\n // if (!portal) {\n // portal = document.createElement('div');\n // document.getElementById(frame)?.appendChild(portal);\n // }\n // return portal;\n }\n }\n\n const portal = document.getElementById(POPUP_PORTAL_ID);\n\n if (!portal) {\n ReactDOM.createPortal(<StyledPortal id={POPUP_PORTAL_ID} ref={portalRef} />, document.body);\n }\n\n portalRef.current = portal;\n\n let portal;\n\n const hasFrame = typeof frame !== 'string' && frame && frame.current;\n if (hasFrame) {\n portal = frame.current;\n } else {\n // ReactDOM.createPortal(<StyledPortal id={POPUP_PORTAL_ID} ref={portalRef} />, document.body);\n\n portal = document.getElementById(POPUP_PORTAL_ID);\n\n if (!portal) {\n if (typeof frame === 'string' && frame !== 'document') {\n portal = document.createElement('div');\n document.getElementById(frame)?.appendChild(portal);\n } else {\n portal.className('frame-portal');\n document.body.appendChild(portal);\n // ReactDOM.createPortal(<StyledPortal id={POPUP_PORTAL_ID} ref={portalRef} />, document.body);\n }\n }\n }\n\n};\n\nconst usePortalContainer = (frame: 'document' | string | React.RefObject<HTMLElement>) => {\n const portalRef = useRef<HTMLDivElement | null>(null);\n\n if (typeof frame !== 'string' && frame && frame.current) {\n return frame.current;\n }\n\n if (typeof frame === 'string' && frame !== 'document') {\n const element = document.getElementById(frame);\n\n const portal = document?.querySelector('.frame-portal');\n\n if (portal) {\n return portal;\n }\n\n if (element) {\n const portal = document.createElement('div');\n portal.className = 'frame-portal';\n portal.style.position = 'relative';\n // portal.style.width = '0';\n\n element.appendChild(portal);\n return portal;\n //\n // const portal = document?.querySelector('.frame-portal');\n // if (!portal) {\n // portal = document.createElement('div');\n // document.getElementById(frame)?.appendChild(portal);\n // }\n // return portal;\n }\n }\n\n const portal = document.getElementById(POPUP_PORTAL_ID);\n\n if (!portal) {\n const res = ReactDOM.createPortal(<StyledPortal id={POPUP_PORTAL_ID} ref={portalRef} />, document.body);\n\n console.log('!!! res', res);\n }\n\n console.log('!!!! portalRef.current', portalRef.current, document.getElementById(POPUP_PORTAL_ID));\n return portalRef.current;\n\n let portal;\n\n const hasFrame = typeof frame !== 'string' && frame && frame.current;\n if (hasFrame) {\n portal = frame.current;\n } else {\n // ReactDOM.createPortal(<StyledPortal id={POPUP_PORTAL_ID} ref={portalRef} />, document.body);\n\n portal = document.getElementById(POPUP_PORTAL_ID);\n\n if (!portal) {\n if (typeof frame === 'string' && frame !== 'document') {\n portal = document.createElement('div');\n document.getElementById(frame)?.appendChild(portal);\n } else {\n portal.className('frame-portal');\n document.body.appendChild(portal);\n // ReactDOM.createPortal(<StyledPortal id={POPUP_PORTAL_ID} ref={portalRef} />, document.body);\n }\n }\n }\n\n};\n*/\n\n/**\n * Базовый компонент Popup.\n */\nexport const popupRoot = (Root: RootProps<HTMLDivElement, PopupProps>) =>\n forwardRef<HTMLDivElement, PopupProps>(\n (\n {\n id,\n isOpen = false,\n opened = false,\n placement = 'center',\n offset = [0, 0],\n frame = 'document',\n children,\n overlay,\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n role,\n zIndex,\n popupInfo,\n withAnimation = false,\n className,\n ...rest\n },\n outerRootRef,\n ) => {\n const innerIsOpen = isOpen || opened;\n\n const uniqId = safeUseId();\n const innerId = id || uniqId;\n\n const { isVisible, animationInfo, setVisible } = usePopup({\n isOpen: innerIsOpen,\n id: innerId,\n popupInfo,\n withAnimation,\n });\n\n const portalRef = useRef<HTMLDivElement | null>(null);\n const contentRef = useRef<HTMLDivElement | null>(null);\n\n const innerRef = useForkRef<HTMLDivElement>(contentRef, outerRootRef);\n\n if (!isVisible && !innerIsOpen) {\n return null;\n }\n\n const cls = cx(\n className,\n animationInfo?.endAnimation ? classes.endAnimation : '',\n animationInfo?.endTransition ? classes.endTransition : '',\n );\n\n const rootNode = (\n <Root className={cls} {...rest}>\n {overlay}\n <PopupRoot\n id={innerId}\n ref={innerRef}\n position={handlePosition(placement, offset)}\n frame={frame}\n zIndex={zIndex}\n animationInfo={animationInfo}\n setVisible={setVisible}\n >\n {children}\n </PopupRoot>\n </Root>\n );\n\n if (typeof frame !== 'string' && frame && frame.current) {\n return <Portal container={frame.current}>{rootNode}</Portal>;\n }\n\n const withFrameId = typeof frame === 'string' && frame !== 'document';\n const containerElement = withFrameId && document.getElementById(frame as string);\n\n if (containerElement) {\n return (\n <>\n {ReactDOM.createPortal(\n <StyledPortalContainer ref={portalRef}>\n {portalRef.current && <Portal container={portalRef.current}>{rootNode}</Portal>}\n </StyledPortalContainer>,\n containerElement,\n )}\n </>\n );\n }\n\n const globalPortal = typeof document !== 'undefined' && document.getElementById(POPUP_PORTAL_ID);\n\n return <>{globalPortal && <Portal container={globalPortal}>{rootNode}</Portal>}</>;\n },\n );\n\nexport const popupConfig = {\n name: 'Popup',\n tag: 'div',\n layout: popupRoot,\n base: '',\n variations: {},\n defaults: {},\n};\n"],"names":["handlePosition","placement","offset","x","y","_offset","_slicedToArray","_x","_y","concat","left","top","transform","right","bottom","placements","split","forEach","placementValue","isCenteredX","undefined","isCenteredY","popupRoot","Root","forwardRef","_ref","outerRootRef","id","_ref$isOpen","isOpen","_ref$opened","opened","_ref$placement","_ref$offset","_ref$frame","frame","children","overlay","zIndex","popupInfo","_ref$withAnimation","withAnimation","className","rest","_objectWithoutProperties","_excluded","innerIsOpen","uniqId","safeUseId","innerId","_usePopup","usePopup","isVisible","animationInfo","setVisible","portalRef","useRef","contentRef","innerRef","useForkRef","cls","cx","endAnimation","classes","endTransition","rootNode","React","createElement","_extends","PopupRoot","ref","position","current","Portal","container","withFrameId","containerElement","document","getElementById","Fragment","ReactDOM","createPortal","StyledPortalContainer","globalPortal","POPUP_PORTAL_ID","popupConfig","name","tag","layout","base","variations","defaults"],"mappings":";;;;;;;;;;;;;AAeO,IAAMA,cAAc,GAAG,SAAjBA,cAAcA,CACvBC,SAAyB,EACzBC,MAA2C,EACvB;EACpB,IAAIC,CAAC,GAAG,MAAM,CAAA;EACd,IAAIC,CAAC,GAAG,MAAM,CAAA;AAEd,EAAA,IAAIF,MAAM,EAAE;AACR,IAAA,IAAAG,OAAA,GAAAC,cAAA,CAAiBJ,MAAM,EAAA,CAAA,CA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AAGV,CAAC,CAAA;AACV,QAAA,MAAA;AAGR,KAAA;AACJ,GAAC,CAAC,CAAA;EAEF,IAAMe,WAAW,GAAGT,IAAI,KAAKU,SAAS,IAAIP,KAAK,KAAKO,SAAS,CAAA;EAC7D,IAAMC,WAAW,GAAGV,GAAG,KAAKS,SAAS,IAAIN,MAAM,KAAKM,SAAS,CAAA;AAE7D,EAAA,IAAID,WAAW,EAAE;AACbP,IAAAA,SAAS,GAAG,kBAAkB,CAAA;AAClC,GAAA;AAEA,EAAA,IAAIS,WAAW,EAAE;AACbT,IAAAA,SAAS,GAAG,kBAAkB,CAAA;AAClC,GAAA;EAEA,OAAO;AACHF,IAAAA,IAAI,EAAES,WAAW,GAAA,aAAA,CAAAV,MAAA,CAAiBN,CAAC,SAAMO,IAAI;AAC7CG,IAAAA,KAAK,EAALA,KAAK;AACLF,IAAAA,GAAG,EAAEU,WAAW,GAAA,aAAA,CAAAZ,MAAA,CAAiBL,CAAC,SAAMO,GAAG;AAC3CG,IAAAA,MAAM,EAANA,MAAM;AACNF,IAAAA,SAAS,EAATA,SAAAA;GACH,CAAA;AACL,EAAC;AACD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA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ACC,SAAS,EAAEnB,SAAS,CAACiB,OAAAA;AAAQ,OAAA,EAAEP,QAAiB,CAC3D,CAAC,EACxBW,gBACJ,CACF,CAAC,CAAA;AAEX,KAAA;AAEA,IAAA,IAAMO,YAAY,GAAG,OAAON,QAAQ,KAAK,WAAW,IAAIA,QAAQ,CAACC,cAAc,CAACM,eAAe,CAAC,CAAA;AAEhG,IAAA,oBAAOlB,KAAA,CAAAC,aAAA,CAAAD,KAAA,CAAAa,QAAA,EAAGI,IAAAA,EAAAA,YAAY,iBAAIjB,KAAA,CAAAC,aAAA,CAACM,MAAM,EAAA;AAACC,MAAAA,SAAS,EAAES,YAAAA;KAAelB,EAAAA,QAAiB,CAAI,CAAC,CAAA;AACtF,GACJ,CAAC,CAAA;AAAA,EAAA;AAEE,IAAMoB,WAAW,GAAG;AACvBC,EAAAA,IAAI,EAAE,OAAO;AACbC,EAAAA,GAAG,EAAE,KAAK;AACVC,EAAAA,MAAM,EAAElE,SAAS;AACjBmE,EAAAA,IAAI,EAAE,EAAE;EACRC,UAAU,EAAE,EAAE;AACdC,EAAAA,QAAQ,EAAE,EAAC;AACf;;;;"}
|
1
|
+
{"version":3,"file":"Popup.js","sources":["../../../src/components/Popup/Popup.tsx"],"sourcesContent":["import React, { forwardRef, useRef } from 'react';\nimport ReactDOM from 'react-dom';\nimport { useForkRef, safeUseId } from '@salutejs/plasma-core';\n\nimport { RootProps } from '../../engines/types';\nimport { cx } from '../../utils';\nimport { Portal } from '../Portal';\n\nimport type { PopupPlacementBasic, PopupPlacement, PopupPositionType, PopupProps } from './Popup.types';\nimport { POPUP_PORTAL_ID } from './PopupContext';\nimport { PopupRoot } from './PopupRoot';\nimport { usePopup } from './hooks';\nimport { classes } from './Popup.tokens';\nimport { StyledPortalContainer } from './Popup.styles';\n\nexport const handlePosition = (\n placement: PopupPlacement,\n offset: [number, number] | [string, string],\n): PopupPositionType => {\n let x = '0rem';\n let y = '0rem';\n\n if (offset) {\n const [_x, _y] = offset;\n x = typeof _x === 'number' ? `${_x}rem` : _x;\n y = typeof _y === 'number' ? `${_y}rem` : _y;\n }\n\n if (!placement || placement === 'center') {\n return {\n left: `calc(50% + ${x})`,\n top: `calc(50% - ${y})`,\n transform: 'translate(-50%, -50%)',\n };\n }\n\n let left;\n let right;\n let top;\n let bottom;\n let transform;\n const placements = placement.split('-') as PopupPlacementBasic[];\n\n placements.forEach((placementValue: PopupPlacementBasic) => {\n switch (placementValue) {\n case 'left':\n left = x;\n break;\n case 'right':\n right = x;\n break;\n case 'top':\n top = y;\n break;\n case 'bottom':\n bottom = y;\n break;\n default:\n break;\n }\n });\n\n const isCenteredX = left === undefined && right === undefined;\n const isCenteredY = top === undefined && bottom === undefined;\n\n if (isCenteredX) {\n transform = 'translateX(-50%)';\n }\n\n if (isCenteredY) {\n transform = 'translateY(-50%)';\n }\n\n return {\n left: isCenteredX ? `calc(50% + ${x})` : left,\n right,\n top: isCenteredY ? `calc(50% - ${y})` : top,\n bottom,\n transform,\n };\n};\n\n/**\n * Базовый компонент Popup.\n */\nexport const popupRoot = (Root: RootProps<HTMLDivElement, PopupProps>) =>\n forwardRef<HTMLDivElement, PopupProps>(\n (\n {\n id,\n isOpen = false,\n opened = false,\n placement = 'center',\n offset = [0, 0],\n frame = 'document',\n children,\n overlay,\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n role,\n zIndex,\n popupInfo,\n withAnimation = false,\n className,\n ...rest\n },\n outerRootRef,\n ) => {\n const innerIsOpen = isOpen || opened;\n\n const uniqId = safeUseId();\n const innerId = id || uniqId;\n\n const { isVisible, animationInfo, setVisible } = usePopup({\n isOpen: innerIsOpen,\n id: innerId,\n popupInfo,\n withAnimation,\n });\n\n const portalRef = useRef<HTMLDivElement | null>(null);\n const contentRef = useRef<HTMLDivElement | null>(null);\n\n const innerRef = useForkRef<HTMLDivElement>(contentRef, outerRootRef);\n\n if (!isVisible && !innerIsOpen) {\n return null;\n }\n\n const cls = cx(\n className,\n animationInfo?.endAnimation ? classes.endAnimation : '',\n animationInfo?.endTransition ? classes.endTransition : '',\n );\n\n const rootNode = (\n <Root className={cls} {...rest}>\n {overlay}\n <PopupRoot\n id={innerId}\n ref={innerRef}\n position={handlePosition(placement, offset)}\n frame={frame}\n zIndex={zIndex}\n animationInfo={animationInfo}\n setVisible={setVisible}\n >\n {children}\n </PopupRoot>\n </Root>\n );\n\n if (typeof frame !== 'string' && frame && frame.current) {\n return <Portal container={frame.current}>{rootNode}</Portal>;\n }\n\n const withFrameId = typeof frame === 'string' && frame !== 'document';\n const containerElement = withFrameId && document.getElementById(frame as string);\n\n if (containerElement) {\n return (\n <>\n {ReactDOM.createPortal(\n <StyledPortalContainer ref={portalRef}>\n {portalRef.current && <Portal container={portalRef.current}>{rootNode}</Portal>}\n </StyledPortalContainer>,\n containerElement,\n )}\n </>\n );\n }\n\n const globalPortal = typeof document !== 'undefined' && document.getElementById(POPUP_PORTAL_ID);\n\n return <>{globalPortal && <Portal container={globalPortal}>{rootNode}</Portal>}</>;\n },\n );\n\nexport const popupConfig = {\n name: 'Popup',\n tag: 'div',\n layout: popupRoot,\n base: '',\n variations: {},\n defaults: {},\n};\n"],"names":["handlePosition","placement","offset","x","y","_offset","_slicedToArray","_x","_y","concat","left","top","transform","right","bottom","placements","split","forEach","placementValue","isCenteredX","undefined","isCenteredY","popupRoot","Root","forwardRef","_ref","outerRootRef","id","_ref$isOpen","isOpen","_ref$opened","opened","_ref$placement","_ref$offset","_ref$frame","frame","children","overlay","zIndex","popupInfo","_ref$withAnimation","withAnimation","className","rest","_objectWithoutProperties","_excluded","innerIsOpen","uniqId","safeUseId","innerId","_usePopup","usePopup","isVisible","animationInfo","setVisible","portalRef","useRef","contentRef","innerRef","useForkRef","cls","cx","endAnimation","classes","endTransition","rootNode","React","createElement","_extends","PopupRoot","ref","position","current","Portal","container","withFrameId","containerElement","document","getElementById","Fragment","ReactDOM","createPortal","StyledPortalContainer","globalPortal","POPUP_PORTAL_ID","popupConfig","name","tag","layout","base","variations","defaults"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AACM,MAAM,EAAA;AAACC,MAAAA,SAAS,EAAES,YAAAA;KAAelB,EAAAA,QAAiB,CAAI,CAAC,CAAA;AACtF,GACJ,CAAC,CAAA;AAAA,EAAA;AAEE,IAAMoB,WAAW,GAAG;AACvBC,EAAAA,IAAI,EAAE,OAAO;AACbC,EAAAA,GAAG,EAAE,KAAK;AACVC,EAAAA,MAAM,EAAElE,SAAS;AACjBmE,EAAAA,IAAI,EAAE,EAAE;EACRC,UAAU,EAAE,EAAE;AACdC,EAAAA,QAAQ,EAAE,EAAC;AACf;;;;"}
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@salutejs/plasma-new-hope",
|
3
|
-
"version": "0.146.1-canary.1412.
|
3
|
+
"version": "0.146.1-canary.1412.10901451694.0",
|
4
4
|
"description": "Salute Design System blueprint",
|
5
5
|
"main": "cjs/index.js",
|
6
6
|
"module": "es/index.js",
|
@@ -80,7 +80,7 @@
|
|
80
80
|
"@rollup/plugin-babel": "^6.0.4",
|
81
81
|
"@rollup/plugin-commonjs": "^25.0.4",
|
82
82
|
"@rollup/plugin-node-resolve": "^15.1.0",
|
83
|
-
"@salutejs/plasma-sb-utils": "0.177.
|
83
|
+
"@salutejs/plasma-sb-utils": "0.177.0",
|
84
84
|
"@storybook/addon-docs": "^7.6.17",
|
85
85
|
"@storybook/addon-essentials": "^7.6.17",
|
86
86
|
"@storybook/addons": "^7.6.17",
|
@@ -121,5 +121,5 @@
|
|
121
121
|
"react-popper": "2.3.0",
|
122
122
|
"storeon": "3.1.5"
|
123
123
|
},
|
124
|
-
"gitHead": "
|
124
|
+
"gitHead": "d434ee69cb3a5af60bcad52e0c8b48b14e2ee5d4"
|
125
125
|
}
|
@@ -85,136 +85,6 @@ var handlePosition = exports.handlePosition = function handlePosition(placement,
|
|
85
85
|
transform: transform
|
86
86
|
};
|
87
87
|
};
|
88
|
-
/*
|
89
|
-
const getPortalParent = (frame: 'document' | string | React.RefObject<HTMLElement>, portalRef) => {
|
90
|
-
if (typeof frame !== 'string' && frame && frame.current) {
|
91
|
-
portalRef.current = frame.current;
|
92
|
-
return;
|
93
|
-
}
|
94
|
-
|
95
|
-
if (typeof frame === 'string' && frame !== 'document') {
|
96
|
-
const element = document.getElementById(frame);
|
97
|
-
if (element) {
|
98
|
-
const portal = document.createElement('div');
|
99
|
-
portal.className = 'frame-portal';
|
100
|
-
portal.style.position = 'relative';
|
101
|
-
portal.style.width = '0';
|
102
|
-
|
103
|
-
element.appendChild(portal);
|
104
|
-
portalRef.current = portal;
|
105
|
-
|
106
|
-
return;
|
107
|
-
//
|
108
|
-
// const portal = document?.querySelector('.frame-portal');
|
109
|
-
// if (!portal) {
|
110
|
-
// portal = document.createElement('div');
|
111
|
-
// document.getElementById(frame)?.appendChild(portal);
|
112
|
-
// }
|
113
|
-
// return portal;
|
114
|
-
}
|
115
|
-
}
|
116
|
-
|
117
|
-
const portal = document.getElementById(POPUP_PORTAL_ID);
|
118
|
-
|
119
|
-
if (!portal) {
|
120
|
-
ReactDOM.createPortal(<StyledPortal id={POPUP_PORTAL_ID} ref={portalRef} />, document.body);
|
121
|
-
}
|
122
|
-
|
123
|
-
portalRef.current = portal;
|
124
|
-
|
125
|
-
let portal;
|
126
|
-
|
127
|
-
const hasFrame = typeof frame !== 'string' && frame && frame.current;
|
128
|
-
if (hasFrame) {
|
129
|
-
portal = frame.current;
|
130
|
-
} else {
|
131
|
-
// ReactDOM.createPortal(<StyledPortal id={POPUP_PORTAL_ID} ref={portalRef} />, document.body);
|
132
|
-
|
133
|
-
portal = document.getElementById(POPUP_PORTAL_ID);
|
134
|
-
|
135
|
-
if (!portal) {
|
136
|
-
if (typeof frame === 'string' && frame !== 'document') {
|
137
|
-
portal = document.createElement('div');
|
138
|
-
document.getElementById(frame)?.appendChild(portal);
|
139
|
-
} else {
|
140
|
-
portal.className('frame-portal');
|
141
|
-
document.body.appendChild(portal);
|
142
|
-
// ReactDOM.createPortal(<StyledPortal id={POPUP_PORTAL_ID} ref={portalRef} />, document.body);
|
143
|
-
}
|
144
|
-
}
|
145
|
-
}
|
146
|
-
|
147
|
-
};
|
148
|
-
|
149
|
-
const usePortalContainer = (frame: 'document' | string | React.RefObject<HTMLElement>) => {
|
150
|
-
const portalRef = useRef<HTMLDivElement | null>(null);
|
151
|
-
|
152
|
-
if (typeof frame !== 'string' && frame && frame.current) {
|
153
|
-
return frame.current;
|
154
|
-
}
|
155
|
-
|
156
|
-
if (typeof frame === 'string' && frame !== 'document') {
|
157
|
-
const element = document.getElementById(frame);
|
158
|
-
|
159
|
-
const portal = document?.querySelector('.frame-portal');
|
160
|
-
|
161
|
-
if (portal) {
|
162
|
-
return portal;
|
163
|
-
}
|
164
|
-
|
165
|
-
if (element) {
|
166
|
-
const portal = document.createElement('div');
|
167
|
-
portal.className = 'frame-portal';
|
168
|
-
portal.style.position = 'relative';
|
169
|
-
// portal.style.width = '0';
|
170
|
-
|
171
|
-
element.appendChild(portal);
|
172
|
-
return portal;
|
173
|
-
//
|
174
|
-
// const portal = document?.querySelector('.frame-portal');
|
175
|
-
// if (!portal) {
|
176
|
-
// portal = document.createElement('div');
|
177
|
-
// document.getElementById(frame)?.appendChild(portal);
|
178
|
-
// }
|
179
|
-
// return portal;
|
180
|
-
}
|
181
|
-
}
|
182
|
-
|
183
|
-
const portal = document.getElementById(POPUP_PORTAL_ID);
|
184
|
-
|
185
|
-
if (!portal) {
|
186
|
-
const res = ReactDOM.createPortal(<StyledPortal id={POPUP_PORTAL_ID} ref={portalRef} />, document.body);
|
187
|
-
|
188
|
-
console.log('!!! res', res);
|
189
|
-
}
|
190
|
-
|
191
|
-
console.log('!!!! portalRef.current', portalRef.current, document.getElementById(POPUP_PORTAL_ID));
|
192
|
-
return portalRef.current;
|
193
|
-
|
194
|
-
let portal;
|
195
|
-
|
196
|
-
const hasFrame = typeof frame !== 'string' && frame && frame.current;
|
197
|
-
if (hasFrame) {
|
198
|
-
portal = frame.current;
|
199
|
-
} else {
|
200
|
-
// ReactDOM.createPortal(<StyledPortal id={POPUP_PORTAL_ID} ref={portalRef} />, document.body);
|
201
|
-
|
202
|
-
portal = document.getElementById(POPUP_PORTAL_ID);
|
203
|
-
|
204
|
-
if (!portal) {
|
205
|
-
if (typeof frame === 'string' && frame !== 'document') {
|
206
|
-
portal = document.createElement('div');
|
207
|
-
document.getElementById(frame)?.appendChild(portal);
|
208
|
-
} else {
|
209
|
-
portal.className('frame-portal');
|
210
|
-
document.body.appendChild(portal);
|
211
|
-
// ReactDOM.createPortal(<StyledPortal id={POPUP_PORTAL_ID} ref={portalRef} />, document.body);
|
212
|
-
}
|
213
|
-
}
|
214
|
-
}
|
215
|
-
|
216
|
-
};
|
217
|
-
*/
|
218
88
|
|
219
89
|
/**
|
220
90
|
* Базовый компонент Popup.
|
@@ -75,136 +75,6 @@ export var handlePosition = function handlePosition(placement, offset) {
|
|
75
75
|
transform: transform
|
76
76
|
};
|
77
77
|
};
|
78
|
-
/*
|
79
|
-
const getPortalParent = (frame: 'document' | string | React.RefObject<HTMLElement>, portalRef) => {
|
80
|
-
if (typeof frame !== 'string' && frame && frame.current) {
|
81
|
-
portalRef.current = frame.current;
|
82
|
-
return;
|
83
|
-
}
|
84
|
-
|
85
|
-
if (typeof frame === 'string' && frame !== 'document') {
|
86
|
-
const element = document.getElementById(frame);
|
87
|
-
if (element) {
|
88
|
-
const portal = document.createElement('div');
|
89
|
-
portal.className = 'frame-portal';
|
90
|
-
portal.style.position = 'relative';
|
91
|
-
portal.style.width = '0';
|
92
|
-
|
93
|
-
element.appendChild(portal);
|
94
|
-
portalRef.current = portal;
|
95
|
-
|
96
|
-
return;
|
97
|
-
//
|
98
|
-
// const portal = document?.querySelector('.frame-portal');
|
99
|
-
// if (!portal) {
|
100
|
-
// portal = document.createElement('div');
|
101
|
-
// document.getElementById(frame)?.appendChild(portal);
|
102
|
-
// }
|
103
|
-
// return portal;
|
104
|
-
}
|
105
|
-
}
|
106
|
-
|
107
|
-
const portal = document.getElementById(POPUP_PORTAL_ID);
|
108
|
-
|
109
|
-
if (!portal) {
|
110
|
-
ReactDOM.createPortal(<StyledPortal id={POPUP_PORTAL_ID} ref={portalRef} />, document.body);
|
111
|
-
}
|
112
|
-
|
113
|
-
portalRef.current = portal;
|
114
|
-
|
115
|
-
let portal;
|
116
|
-
|
117
|
-
const hasFrame = typeof frame !== 'string' && frame && frame.current;
|
118
|
-
if (hasFrame) {
|
119
|
-
portal = frame.current;
|
120
|
-
} else {
|
121
|
-
// ReactDOM.createPortal(<StyledPortal id={POPUP_PORTAL_ID} ref={portalRef} />, document.body);
|
122
|
-
|
123
|
-
portal = document.getElementById(POPUP_PORTAL_ID);
|
124
|
-
|
125
|
-
if (!portal) {
|
126
|
-
if (typeof frame === 'string' && frame !== 'document') {
|
127
|
-
portal = document.createElement('div');
|
128
|
-
document.getElementById(frame)?.appendChild(portal);
|
129
|
-
} else {
|
130
|
-
portal.className('frame-portal');
|
131
|
-
document.body.appendChild(portal);
|
132
|
-
// ReactDOM.createPortal(<StyledPortal id={POPUP_PORTAL_ID} ref={portalRef} />, document.body);
|
133
|
-
}
|
134
|
-
}
|
135
|
-
}
|
136
|
-
|
137
|
-
};
|
138
|
-
|
139
|
-
const usePortalContainer = (frame: 'document' | string | React.RefObject<HTMLElement>) => {
|
140
|
-
const portalRef = useRef<HTMLDivElement | null>(null);
|
141
|
-
|
142
|
-
if (typeof frame !== 'string' && frame && frame.current) {
|
143
|
-
return frame.current;
|
144
|
-
}
|
145
|
-
|
146
|
-
if (typeof frame === 'string' && frame !== 'document') {
|
147
|
-
const element = document.getElementById(frame);
|
148
|
-
|
149
|
-
const portal = document?.querySelector('.frame-portal');
|
150
|
-
|
151
|
-
if (portal) {
|
152
|
-
return portal;
|
153
|
-
}
|
154
|
-
|
155
|
-
if (element) {
|
156
|
-
const portal = document.createElement('div');
|
157
|
-
portal.className = 'frame-portal';
|
158
|
-
portal.style.position = 'relative';
|
159
|
-
// portal.style.width = '0';
|
160
|
-
|
161
|
-
element.appendChild(portal);
|
162
|
-
return portal;
|
163
|
-
//
|
164
|
-
// const portal = document?.querySelector('.frame-portal');
|
165
|
-
// if (!portal) {
|
166
|
-
// portal = document.createElement('div');
|
167
|
-
// document.getElementById(frame)?.appendChild(portal);
|
168
|
-
// }
|
169
|
-
// return portal;
|
170
|
-
}
|
171
|
-
}
|
172
|
-
|
173
|
-
const portal = document.getElementById(POPUP_PORTAL_ID);
|
174
|
-
|
175
|
-
if (!portal) {
|
176
|
-
const res = ReactDOM.createPortal(<StyledPortal id={POPUP_PORTAL_ID} ref={portalRef} />, document.body);
|
177
|
-
|
178
|
-
console.log('!!! res', res);
|
179
|
-
}
|
180
|
-
|
181
|
-
console.log('!!!! portalRef.current', portalRef.current, document.getElementById(POPUP_PORTAL_ID));
|
182
|
-
return portalRef.current;
|
183
|
-
|
184
|
-
let portal;
|
185
|
-
|
186
|
-
const hasFrame = typeof frame !== 'string' && frame && frame.current;
|
187
|
-
if (hasFrame) {
|
188
|
-
portal = frame.current;
|
189
|
-
} else {
|
190
|
-
// ReactDOM.createPortal(<StyledPortal id={POPUP_PORTAL_ID} ref={portalRef} />, document.body);
|
191
|
-
|
192
|
-
portal = document.getElementById(POPUP_PORTAL_ID);
|
193
|
-
|
194
|
-
if (!portal) {
|
195
|
-
if (typeof frame === 'string' && frame !== 'document') {
|
196
|
-
portal = document.createElement('div');
|
197
|
-
document.getElementById(frame)?.appendChild(portal);
|
198
|
-
} else {
|
199
|
-
portal.className('frame-portal');
|
200
|
-
document.body.appendChild(portal);
|
201
|
-
// ReactDOM.createPortal(<StyledPortal id={POPUP_PORTAL_ID} ref={portalRef} />, document.body);
|
202
|
-
}
|
203
|
-
}
|
204
|
-
}
|
205
|
-
|
206
|
-
};
|
207
|
-
*/
|
208
78
|
|
209
79
|
/**
|
210
80
|
* Базовый компонент Popup.
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"Popup.d.ts","sourceRoot":"","sources":["../../../src/components/Popup/Popup.tsx"],"names":[],"mappings":"AAAA,OAAO,KAA6B,MAAM,OAAO,CAAC;AAIlD,OAAO,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAIhD,OAAO,KAAK,EAAuB,cAAc,EAAE,iBAAiB,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAOxG,eAAO,MAAM,cAAc,cACZ,cAAc,UACjB,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,KAC5C,iBA8DF,CAAC;
|
1
|
+
{"version":3,"file":"Popup.d.ts","sourceRoot":"","sources":["../../../src/components/Popup/Popup.tsx"],"names":[],"mappings":"AAAA,OAAO,KAA6B,MAAM,OAAO,CAAC;AAIlD,OAAO,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAIhD,OAAO,KAAK,EAAuB,cAAc,EAAE,iBAAiB,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAOxG,eAAO,MAAM,cAAc,cACZ,cAAc,UACjB,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,KAC5C,iBA8DF,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,SAAS,SAAU,UAAU,cAAc,EAAE,UAAU,CAAC,sFA0FhE,CAAC;AAEN,eAAO,MAAM,WAAW;;;mBA5FQ,UAAU,cAAc,EAAE,UAAU,CAAC;;;;CAmGpE,CAAC"}
|