@salutejs/plasma-new-hope 0.94.0-canary.1272.9717304400.0 → 0.94.0-canary.1274.9714331676.0
Sign up to get free protection for your applications and to get access to all the features.
- package/cjs/components/Combobox/Combobox.js +1 -1
- package/cjs/components/Combobox/ui/ComboboxDivider/ComboboxDivider.js +1 -1
- package/cjs/components/Combobox/ui/ComboboxFooter/ComboboxFooter.js +1 -1
- package/cjs/components/Combobox/ui/ComboboxGroup/ComboboxGroup.js +1 -1
- package/cjs/components/Combobox/ui/ComboboxHeader/ComboboxHeader.js +1 -1
- package/cjs/components/Drawer/Drawer.js +1 -1
- package/cjs/components/Drawer/hooks/useDrawer.js +1 -3
- package/cjs/components/Drawer/hooks/useDrawer.js.map +1 -1
- package/cjs/components/Dropdown/Dropdown.js +1 -1
- package/cjs/components/Dropdown/ui/DropdownInner/DropdownInner.js +1 -1
- package/cjs/components/Modal/hooks/useModal.js +1 -3
- package/cjs/components/Modal/hooks/useModal.js.map +1 -1
- package/cjs/components/Pagination/ui/PaginationSelectPerPage/PaginationSelectPerPage.styles.js +1 -1
- package/cjs/components/Popover/Popover.js +3 -9
- package/cjs/components/Popover/Popover.js.map +1 -1
- package/cjs/components/Popup/Popup.js +3 -9
- package/cjs/components/Popup/Popup.js.map +1 -1
- package/cjs/components/Select/Select.js +1 -1
- package/cjs/components/Select/ui/SelectDivider/SelectDivider.js +1 -1
- package/cjs/components/Select/ui/SelectFooter/SelectFooter.js +1 -1
- package/cjs/components/Select/ui/SelectGroup/SelectGroup.js +1 -1
- package/cjs/components/Select/ui/SelectHeader/SelectHeader.js +1 -1
- package/cjs/components/Select/ui/SelectItem/SelectItem.js +1 -1
- package/cjs/components/Select/ui/SelectItem/SelectItem.styles.js +1 -1
- package/cjs/index.js +0 -3
- package/cjs/index.js.map +1 -1
- package/es/components/Combobox/Combobox.js +1 -1
- package/es/components/Combobox/ui/ComboboxDivider/ComboboxDivider.js +1 -1
- package/es/components/Combobox/ui/ComboboxFooter/ComboboxFooter.js +1 -1
- package/es/components/Combobox/ui/ComboboxGroup/ComboboxGroup.js +1 -1
- package/es/components/Combobox/ui/ComboboxHeader/ComboboxHeader.js +1 -1
- package/es/components/Drawer/Drawer.js +1 -1
- package/es/components/Drawer/hooks/useDrawer.js +1 -3
- package/es/components/Drawer/hooks/useDrawer.js.map +1 -1
- package/es/components/Dropdown/Dropdown.js +1 -1
- package/es/components/Dropdown/ui/DropdownInner/DropdownInner.js +1 -1
- package/es/components/Modal/hooks/useModal.js +1 -3
- package/es/components/Modal/hooks/useModal.js.map +1 -1
- package/es/components/Pagination/ui/PaginationSelectPerPage/PaginationSelectPerPage.styles.js +1 -1
- package/es/components/Popover/Popover.js +3 -9
- package/es/components/Popover/Popover.js.map +1 -1
- package/es/components/Popup/Popup.js +3 -9
- package/es/components/Popup/Popup.js.map +1 -1
- package/es/components/Select/Select.js +1 -1
- package/es/components/Select/ui/SelectDivider/SelectDivider.js +1 -1
- package/es/components/Select/ui/SelectFooter/SelectFooter.js +1 -1
- package/es/components/Select/ui/SelectGroup/SelectGroup.js +1 -1
- package/es/components/Select/ui/SelectHeader/SelectHeader.js +1 -1
- package/es/components/Select/ui/SelectItem/SelectItem.js +1 -1
- package/es/components/Select/ui/SelectItem/SelectItem.styles.js +1 -1
- package/es/index.js +0 -1
- package/es/index.js.map +1 -1
- package/package.json +4 -4
- package/styled-components/cjs/components/Popover/Popover.js +4 -8
- package/styled-components/cjs/components/Popup/Popup.js +4 -8
- package/styled-components/cjs/index.js +0 -11
- package/styled-components/es/components/Popover/Popover.js +3 -8
- package/styled-components/es/components/Popup/Popup.js +3 -8
- package/styled-components/es/index.js +1 -2
- package/types/components/Popover/Popover.d.ts.map +1 -1
- package/types/components/Popup/Popup.d.ts.map +1 -1
- package/types/index.d.ts +0 -1
- package/types/index.d.ts.map +1 -1
- package/cjs/components/Portal/Portal.js +0 -36
- package/cjs/components/Portal/Portal.js.map +0 -1
- package/es/components/Portal/Portal.js +0 -31
- package/es/components/Portal/Portal.js.map +0 -1
- package/styled-components/cjs/components/Portal/Portal.js +0 -37
- package/styled-components/cjs/components/Portal/Portal.template-doc.mdx +0 -66
- package/styled-components/cjs/components/Portal/Portal.types.js +0 -5
- package/styled-components/cjs/components/Portal/index.js +0 -18
- package/styled-components/cjs/examples/plasma_b2c/components/Portal/Portal.js +0 -10
- package/styled-components/cjs/examples/plasma_b2c/components/Portal/Portal.stories.tsx +0 -57
- package/styled-components/cjs/examples/plasma_web/components/Portal/Portal.js +0 -10
- package/styled-components/cjs/examples/plasma_web/components/Portal/Portal.stories.tsx +0 -57
- package/styled-components/es/components/Portal/Portal.js +0 -27
- package/styled-components/es/components/Portal/Portal.template-doc.mdx +0 -66
- package/styled-components/es/components/Portal/Portal.types.js +0 -1
- package/styled-components/es/components/Portal/index.js +0 -1
- package/styled-components/es/examples/plasma_b2c/components/Portal/Portal.js +0 -4
- package/styled-components/es/examples/plasma_b2c/components/Portal/Portal.stories.tsx +0 -57
- package/styled-components/es/examples/plasma_web/components/Portal/Portal.js +0 -4
- package/styled-components/es/examples/plasma_web/components/Portal/Portal.stories.tsx +0 -57
- package/types/components/Portal/Portal.d.ts +0 -13
- package/types/components/Portal/Portal.d.ts.map +0 -1
- package/types/components/Portal/Portal.types.d.ts +0 -18
- package/types/components/Portal/Portal.types.d.ts.map +0 -1
- package/types/components/Portal/index.d.ts +0 -3
- package/types/components/Portal/index.d.ts.map +0 -1
- package/types/examples/plasma_b2c/components/Portal/Portal.d.ts +0 -3
- package/types/examples/plasma_b2c/components/Portal/Portal.d.ts.map +0 -1
- package/types/examples/plasma_web/components/Portal/Portal.d.ts +0 -3
- package/types/examples/plasma_web/components/Portal/Portal.d.ts.map +0 -1
@@ -6,15 +6,15 @@ Object.defineProperty(exports, "__esModule", {
|
|
6
6
|
});
|
7
7
|
exports.popupRoot = exports.popupConfig = exports.handlePosition = void 0;
|
8
8
|
var _react = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("react"));
|
9
|
+
var _reactDom = /*#__PURE__*/_interopRequireDefault( /*#__PURE__*/require("react-dom"));
|
9
10
|
var _plasmaCore = /*#__PURE__*/require("@salutejs/plasma-core");
|
10
11
|
var _utils = /*#__PURE__*/require("../../utils");
|
11
|
-
var _Portal = /*#__PURE__*/require("../Portal");
|
12
|
-
var _engines = /*#__PURE__*/require("../../engines");
|
13
12
|
var _PopupContext = /*#__PURE__*/require("./PopupContext");
|
14
13
|
var _PopupRoot = /*#__PURE__*/require("./PopupRoot");
|
15
14
|
var _hooks = /*#__PURE__*/require("./hooks");
|
16
15
|
var _Popup = /*#__PURE__*/require("./Popup.tokens");
|
17
16
|
var _excluded = ["id", "isOpen", "placement", "offset", "frame", "children", "overlay", "role", "zIndex", "popupInfo", "withAnimation", "className"];
|
17
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
18
18
|
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); }
|
19
19
|
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; }
|
20
20
|
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); }
|
@@ -83,8 +83,6 @@ var handlePosition = exports.handlePosition = function handlePosition(placement,
|
|
83
83
|
transform: transform
|
84
84
|
};
|
85
85
|
};
|
86
|
-
var mergedPortalConfig = /*#__PURE__*/(0, _engines.mergeConfig)(_Portal.portalConfig);
|
87
|
-
var Portal = /*#__PURE__*/(0, _engines.component)(mergedPortalConfig);
|
88
86
|
|
89
87
|
/**
|
90
88
|
* Базовый копмонент Popup.
|
@@ -158,9 +156,7 @@ var popupRoot = exports.popupRoot = function popupRoot(Root) {
|
|
158
156
|
return null;
|
159
157
|
}
|
160
158
|
var cls = (0, _utils.cx)(className, animationInfo !== null && animationInfo !== void 0 && animationInfo.endAnimation ? _Popup.classes.endAnimation : '', animationInfo !== null && animationInfo !== void 0 && animationInfo.endTransition ? _Popup.classes.endTransition : '');
|
161
|
-
return /*#__PURE__*/_react["default"].createElement(_react["default"].Fragment, null, portalRef.current && /*#__PURE__*/_react["default"].createElement(
|
162
|
-
container: portalRef.current
|
163
|
-
}, /*#__PURE__*/_react["default"].createElement(Root, _extends({
|
159
|
+
return /*#__PURE__*/_react["default"].createElement(_react["default"].Fragment, null, portalRef.current && /*#__PURE__*/_reactDom["default"].createPortal( /*#__PURE__*/_react["default"].createElement(Root, _extends({
|
164
160
|
className: cls
|
165
161
|
}, rest), overlay, /*#__PURE__*/_react["default"].createElement(_PopupRoot.PopupRoot, {
|
166
162
|
id: innerId,
|
@@ -170,7 +166,7 @@ var popupRoot = exports.popupRoot = function popupRoot(Root) {
|
|
170
166
|
zIndex: zIndex,
|
171
167
|
animationInfo: animationInfo,
|
172
168
|
setVisible: setVisible
|
173
|
-
}, children))));
|
169
|
+
}, children)), portalRef.current));
|
174
170
|
});
|
175
171
|
};
|
176
172
|
var popupConfig = exports.popupConfig = {
|
@@ -552,15 +552,4 @@ Object.keys(_Accordion).forEach(function (key) {
|
|
552
552
|
return _Accordion[key];
|
553
553
|
}
|
554
554
|
});
|
555
|
-
});
|
556
|
-
var _Portal = /*#__PURE__*/require("./components/Portal");
|
557
|
-
Object.keys(_Portal).forEach(function (key) {
|
558
|
-
if (key === "default" || key === "__esModule") return;
|
559
|
-
if (key in exports && exports[key] === _Portal[key]) return;
|
560
|
-
Object.defineProperty(exports, key, {
|
561
|
-
enumerable: true,
|
562
|
-
get: function get() {
|
563
|
-
return _Portal[key];
|
564
|
-
}
|
565
|
-
});
|
566
555
|
});
|
@@ -15,18 +15,15 @@ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
15
15
|
function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
|
16
16
|
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
|
17
17
|
import React, { useRef, useCallback, useEffect, useState, forwardRef } from 'react';
|
18
|
+
import ReactDOM from 'react-dom';
|
18
19
|
import { usePopper } from 'react-popper';
|
19
20
|
import { useFocusTrap, useForkRef } from '@salutejs/plasma-core';
|
20
|
-
import { component, mergeConfig } from '../../engines';
|
21
21
|
import { cx } from '../../utils';
|
22
|
-
import { portalConfig } from '../Portal';
|
23
22
|
import { base as viewCSS } from './variations/_view/base';
|
24
23
|
import { StyledArrow, StyledPopover, StyledRoot, StyledWrapper } from './Popover.styles';
|
25
24
|
import { classes } from './Popover.tokens';
|
26
25
|
export var ESCAPE_KEYCODE = 27;
|
27
26
|
export var POPOVER_PORTAL_ID = 'plasma-popover-root';
|
28
|
-
var mergedPortalConfig = /*#__PURE__*/mergeConfig(portalConfig);
|
29
|
-
var Portal = /*#__PURE__*/component(mergedPortalConfig);
|
30
27
|
|
31
28
|
/**
|
32
29
|
* Всплывающее окно с возможностью позиционирования
|
@@ -216,9 +213,7 @@ export var popoverRoot = function popoverRoot(Root) {
|
|
216
213
|
onFocus: onFocus,
|
217
214
|
onBlur: onBlur,
|
218
215
|
className: cx(className, classes.target)
|
219
|
-
}, target), children && portalRef.current && /*#__PURE__*/React.createElement(
|
220
|
-
container: portalRef.current
|
221
|
-
}, /*#__PURE__*/React.createElement(Root, _extends({
|
216
|
+
}, target), children && portalRef.current && /*#__PURE__*/ReactDOM.createPortal( /*#__PURE__*/React.createElement(Root, _extends({
|
222
217
|
view: view,
|
223
218
|
className: className
|
224
219
|
}, rest), /*#__PURE__*/React.createElement(StyledPopover, _extends({}, attributes.popper, {
|
@@ -232,7 +227,7 @@ export var popoverRoot = function popoverRoot(Root) {
|
|
232
227
|
className: classes.arrow,
|
233
228
|
ref: setArrowElement,
|
234
229
|
style: styles.arrow
|
235
|
-
}, attributes.arrow)), children))));
|
230
|
+
}, attributes.arrow)), children)), portalRef.current));
|
236
231
|
});
|
237
232
|
};
|
238
233
|
export var popoverConfig = {
|
@@ -9,10 +9,9 @@ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len
|
|
9
9
|
function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t["return"] && (u = t["return"](), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
|
10
10
|
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
11
11
|
import React, { forwardRef, useEffect, useRef, useState } from 'react';
|
12
|
+
import ReactDOM from 'react-dom';
|
12
13
|
import { useForkRef, safeUseId } from '@salutejs/plasma-core';
|
13
14
|
import { cx } from '../../utils';
|
14
|
-
import { portalConfig } from '../Portal';
|
15
|
-
import { component, mergeConfig } from '../../engines';
|
16
15
|
import { POPUP_PORTAL_ID } from './PopupContext';
|
17
16
|
import { PopupRoot } from './PopupRoot';
|
18
17
|
import { usePopup } from './hooks';
|
@@ -74,8 +73,6 @@ export var handlePosition = function handlePosition(placement, offset) {
|
|
74
73
|
transform: transform
|
75
74
|
};
|
76
75
|
};
|
77
|
-
var mergedPortalConfig = /*#__PURE__*/mergeConfig(portalConfig);
|
78
|
-
var Portal = /*#__PURE__*/component(mergedPortalConfig);
|
79
76
|
|
80
77
|
/**
|
81
78
|
* Базовый копмонент Popup.
|
@@ -149,9 +146,7 @@ export var popupRoot = function popupRoot(Root) {
|
|
149
146
|
return null;
|
150
147
|
}
|
151
148
|
var cls = cx(className, animationInfo !== null && animationInfo !== void 0 && animationInfo.endAnimation ? classes.endAnimation : '', animationInfo !== null && animationInfo !== void 0 && animationInfo.endTransition ? classes.endTransition : '');
|
152
|
-
return /*#__PURE__*/React.createElement(React.Fragment, null, portalRef.current && /*#__PURE__*/React.createElement(
|
153
|
-
container: portalRef.current
|
154
|
-
}, /*#__PURE__*/React.createElement(Root, _extends({
|
149
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null, portalRef.current && /*#__PURE__*/ReactDOM.createPortal( /*#__PURE__*/React.createElement(Root, _extends({
|
155
150
|
className: cls
|
156
151
|
}, rest), overlay, /*#__PURE__*/React.createElement(PopupRoot, {
|
157
152
|
id: innerId,
|
@@ -161,7 +156,7 @@ export var popupRoot = function popupRoot(Root) {
|
|
161
156
|
zIndex: zIndex,
|
162
157
|
animationInfo: animationInfo,
|
163
158
|
setVisible: setVisible
|
164
|
-
}, children))));
|
159
|
+
}, children)), portalRef.current));
|
165
160
|
});
|
166
161
|
};
|
167
162
|
export var popupConfig = {
|
@@ -49,5 +49,4 @@ export * from './components/Toolbar';
|
|
49
49
|
export * from './components/Sheet';
|
50
50
|
export * from './components/Slider';
|
51
51
|
export * from './components/Range';
|
52
|
-
export * from './components/Accordion';
|
53
|
-
export * from './components/Portal';
|
52
|
+
export * from './components/Accordion';
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"Popover.d.ts","sourceRoot":"","sources":["../../../src/components/Popover/Popover.tsx"],"names":[],"mappings":"AAAA,OAAO,KAA+D,MAAM,OAAO,CAAC;AAMpF,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;
|
1
|
+
{"version":3,"file":"Popover.d.ts","sourceRoot":"","sources":["../../../src/components/Popover/Popover.tsx"],"names":[],"mappings":"AAAA,OAAO,KAA+D,MAAM,OAAO,CAAC;AAMpF,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAIrD,OAAO,KAAK,EAAoB,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAItE,eAAO,MAAM,cAAc,KAAK,CAAC;AACjC,eAAO,MAAM,iBAAiB,wBAAwB,CAAC;AAEvD;;;GAGG;AACH,eAAO,MAAM,WAAW,SAAU,UAAU,cAAc,EAAE,YAAY,CAAC,+JAwPpE,CAAC;AAEN,eAAO,MAAM,aAAa;;;mBA1PQ,UAAU,cAAc,EAAE,YAAY,CAAC;;;;;;;;;;CAuQxE,CAAC"}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"Popup.d.ts","sourceRoot":"","sources":["../../../src/components/Popup/Popup.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAkD,MAAM,OAAO,CAAC;
|
1
|
+
{"version":3,"file":"Popup.d.ts","sourceRoot":"","sources":["../../../src/components/Popup/Popup.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAkD,MAAM,OAAO,CAAC;AAIvE,OAAO,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAGhD,OAAO,KAAK,EAAuB,cAAc,EAAE,iBAAiB,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAMxG,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,sFAsGhE,CAAC;AAEN,eAAO,MAAM,WAAW;;;mBAxGQ,UAAU,cAAc,EAAE,UAAU,CAAC;;;;CA+GpE,CAAC"}
|
package/types/index.d.ts
CHANGED
package/types/index.d.ts.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAEA,cAAc,UAAU,CAAC;AACzB,cAAc,WAAW,CAAC;AAC1B,cAAc,SAAS,CAAC;AACxB,cAAc,SAAS,CAAC;AACxB,cAAc,qBAAqB,CAAC;AACpC,cAAc,yBAAyB,CAAC;AACxC,cAAc,0BAA0B,CAAC;AACzC,cAAc,mBAAmB,CAAC;AAClC,cAAc,mBAAmB,CAAC;AAClC,cAAc,mBAAmB,CAAC;AAClC,cAAc,sBAAsB,CAAC;AACrC,cAAc,uBAAuB,CAAC;AACtC,cAAc,uBAAuB,CAAC;AACtC,cAAc,sBAAsB,CAAC;AACrC,cAAc,uBAAuB,CAAC;AACtC,cAAc,wBAAwB,CAAC;AACvC,cAAc,qBAAqB,CAAC;AACpC,cAAc,mBAAmB,CAAC;AAClC,cAAc,uBAAuB,CAAC;AACtC,cAAc,yBAAyB,CAAC;AACxC,cAAc,oBAAoB,CAAC;AACnC,cAAc,oBAAoB,CAAC;AACnC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,qBAAqB,CAAC;AACpC,cAAc,uBAAuB,CAAC;AACtC,cAAc,qBAAqB,CAAC;AACpC,cAAc,sBAAsB,CAAC;AACrC,cAAc,sBAAsB,CAAC;AACrC,cAAc,uBAAuB,CAAC;AACtC,cAAc,oBAAoB,CAAC;AACnC,cAAc,oBAAoB,CAAC;AACnC,cAAc,sBAAsB,CAAC;AACrC,cAAc,qBAAqB,CAAC;AACpC,cAAc,0BAA0B,CAAC;AACzC,cAAc,yBAAyB,CAAC;AACxC,cAAc,oBAAoB,CAAC;AACnC,cAAc,sBAAsB,CAAC;AACrC,cAAc,0BAA0B,CAAC;AACzC,cAAc,uBAAuB,CAAC;AACtC,cAAc,wBAAwB,CAAC;AACvC,cAAc,yBAAyB,CAAC;AACxC,cAAc,mBAAmB,CAAC;AAClC,cAAc,uBAAuB,CAAC;AACtC,cAAc,qBAAqB,CAAC;AACpC,cAAc,sBAAsB,CAAC;AACrC,cAAc,sBAAsB,CAAC;AACrC,cAAc,oBAAoB,CAAC;AACnC,cAAc,qBAAqB,CAAC;AACpC,cAAc,oBAAoB,CAAC;AACnC,cAAc,wBAAwB,CAAC
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAEA,cAAc,UAAU,CAAC;AACzB,cAAc,WAAW,CAAC;AAC1B,cAAc,SAAS,CAAC;AACxB,cAAc,SAAS,CAAC;AACxB,cAAc,qBAAqB,CAAC;AACpC,cAAc,yBAAyB,CAAC;AACxC,cAAc,0BAA0B,CAAC;AACzC,cAAc,mBAAmB,CAAC;AAClC,cAAc,mBAAmB,CAAC;AAClC,cAAc,mBAAmB,CAAC;AAClC,cAAc,sBAAsB,CAAC;AACrC,cAAc,uBAAuB,CAAC;AACtC,cAAc,uBAAuB,CAAC;AACtC,cAAc,sBAAsB,CAAC;AACrC,cAAc,uBAAuB,CAAC;AACtC,cAAc,wBAAwB,CAAC;AACvC,cAAc,qBAAqB,CAAC;AACpC,cAAc,mBAAmB,CAAC;AAClC,cAAc,uBAAuB,CAAC;AACtC,cAAc,yBAAyB,CAAC;AACxC,cAAc,oBAAoB,CAAC;AACnC,cAAc,oBAAoB,CAAC;AACnC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,qBAAqB,CAAC;AACpC,cAAc,uBAAuB,CAAC;AACtC,cAAc,qBAAqB,CAAC;AACpC,cAAc,sBAAsB,CAAC;AACrC,cAAc,sBAAsB,CAAC;AACrC,cAAc,uBAAuB,CAAC;AACtC,cAAc,oBAAoB,CAAC;AACnC,cAAc,oBAAoB,CAAC;AACnC,cAAc,sBAAsB,CAAC;AACrC,cAAc,qBAAqB,CAAC;AACpC,cAAc,0BAA0B,CAAC;AACzC,cAAc,yBAAyB,CAAC;AACxC,cAAc,oBAAoB,CAAC;AACnC,cAAc,sBAAsB,CAAC;AACrC,cAAc,0BAA0B,CAAC;AACzC,cAAc,uBAAuB,CAAC;AACtC,cAAc,wBAAwB,CAAC;AACvC,cAAc,yBAAyB,CAAC;AACxC,cAAc,mBAAmB,CAAC;AAClC,cAAc,uBAAuB,CAAC;AACtC,cAAc,qBAAqB,CAAC;AACpC,cAAc,sBAAsB,CAAC;AACrC,cAAc,sBAAsB,CAAC;AACrC,cAAc,oBAAoB,CAAC;AACnC,cAAc,qBAAqB,CAAC;AACpC,cAAc,oBAAoB,CAAC;AACnC,cAAc,wBAAwB,CAAC"}
|
@@ -1,36 +0,0 @@
|
|
1
|
-
'use strict';
|
2
|
-
|
3
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
4
|
-
|
5
|
-
var React = require('react');
|
6
|
-
var ReactDOM = require('react-dom');
|
7
|
-
|
8
|
-
/*
|
9
|
-
* Вспомогательный компонент. Используется в Popup, Popover.
|
10
|
-
* Представляет собой ReactDOM.createPortal() в форме компонента.
|
11
|
-
*/
|
12
|
-
var portalRoot = function portalRoot(Root) {
|
13
|
-
return /*#__PURE__*/React.forwardRef(function (_ref, outerRootRef) {
|
14
|
-
var children = _ref.children,
|
15
|
-
container = _ref.container,
|
16
|
-
_ref$disabled = _ref.disabled,
|
17
|
-
disabled = _ref$disabled === void 0 ? false : _ref$disabled;
|
18
|
-
var portalContainer = typeof container === 'function' ? container() : container;
|
19
|
-
return /*#__PURE__*/React.createElement(Root, {
|
20
|
-
disabled: disabled,
|
21
|
-
ref: outerRootRef
|
22
|
-
}, disabled && children, !disabled && /*#__PURE__*/ReactDOM.createPortal(children, portalContainer));
|
23
|
-
});
|
24
|
-
};
|
25
|
-
var portalConfig = {
|
26
|
-
name: 'Portal',
|
27
|
-
tag: 'div',
|
28
|
-
layout: portalRoot,
|
29
|
-
base: '',
|
30
|
-
variations: {},
|
31
|
-
defaults: {}
|
32
|
-
};
|
33
|
-
|
34
|
-
exports.portalConfig = portalConfig;
|
35
|
-
exports.portalRoot = portalRoot;
|
36
|
-
//# sourceMappingURL=Portal.js.map
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"Portal.js","sources":["../../../src/components/Portal/Portal.tsx"],"sourcesContent":["import React, { forwardRef } from 'react';\nimport ReactDOM from 'react-dom';\n\nimport type { RootProps } from '../../engines/types';\n\nimport { PortalProps } from './Portal.types';\n\n/*\n * Вспомогательный компонент. Используется в Popup, Popover.\n * Представляет собой ReactDOM.createPortal() в форме компонента.\n */\nexport const portalRoot = (Root: RootProps<HTMLDivElement, Omit<PortalProps, 'container'>>) =>\n forwardRef<HTMLDivElement, PortalProps>(({ children, container, disabled = false }, outerRootRef) => {\n const portalContainer = typeof container === 'function' ? container() : container;\n\n return (\n <Root disabled={disabled} ref={outerRootRef}>\n {disabled && children}\n {!disabled && ReactDOM.createPortal(children, portalContainer)}\n </Root>\n );\n });\n\nexport const portalConfig = {\n name: 'Portal',\n tag: 'div',\n layout: portalRoot,\n base: '',\n variations: {},\n defaults: {},\n};\n"],"names":["portalRoot","Root","forwardRef","_ref","outerRootRef","children","container","_ref$disabled","disabled","portalContainer","React","createElement","ref","ReactDOM","createPortal","portalConfig","name","tag","layout","base","variations","defaults"],"mappings":";;;;;;;AAOA;AACA;AACA;AACA;IACaA,UAAU,GAAG,SAAbA,UAAUA,CAAIC,IAA+D,EAAA;AAAA,EAAA,oBACtFC,gBAAU,CAA8B,UAAAC,IAAA,EAA4CC,YAAY,EAAK;AAAA,IAAA,IAA1DC,QAAQ,GAAAF,IAAA,CAARE,QAAQ;MAAEC,SAAS,GAAAH,IAAA,CAATG,SAAS;MAAAC,aAAA,GAAAJ,IAAA,CAAEK,QAAQ;AAARA,MAAAA,QAAQ,GAAAD,aAAA,KAAG,KAAA,CAAA,GAAA,KAAK,GAAAA,aAAA,CAAA;IAC5E,IAAME,eAAe,GAAG,OAAOH,SAAS,KAAK,UAAU,GAAGA,SAAS,EAAE,GAAGA,SAAS,CAAA;AAEjF,IAAA,oBACII,KAAA,CAAAC,aAAA,CAACV,IAAI,EAAA;AAACO,MAAAA,QAAQ,EAAEA,QAAS;AAACI,MAAAA,GAAG,EAAER,YAAAA;AAAa,KAAA,EACvCI,QAAQ,IAAIH,QAAQ,EACpB,CAACG,QAAQ,iBAAIK,QAAQ,CAACC,YAAY,CAACT,QAAQ,EAAEI,eAAe,CAC3D,CAAC,CAAA;AAEf,GAAC,CAAC,CAAA;AAAA,EAAA;AAEC,IAAMM,YAAY,GAAG;AACxBC,EAAAA,IAAI,EAAE,QAAQ;AACdC,EAAAA,GAAG,EAAE,KAAK;AACVC,EAAAA,MAAM,EAAElB,UAAU;AAClBmB,EAAAA,IAAI,EAAE,EAAE;EACRC,UAAU,EAAE,EAAE;AACdC,EAAAA,QAAQ,EAAE,EAAC;AACf;;;;;"}
|
@@ -1,31 +0,0 @@
|
|
1
|
-
import React, { forwardRef } from 'react';
|
2
|
-
import ReactDOM from 'react-dom';
|
3
|
-
|
4
|
-
/*
|
5
|
-
* Вспомогательный компонент. Используется в Popup, Popover.
|
6
|
-
* Представляет собой ReactDOM.createPortal() в форме компонента.
|
7
|
-
*/
|
8
|
-
var portalRoot = function portalRoot(Root) {
|
9
|
-
return /*#__PURE__*/forwardRef(function (_ref, outerRootRef) {
|
10
|
-
var children = _ref.children,
|
11
|
-
container = _ref.container,
|
12
|
-
_ref$disabled = _ref.disabled,
|
13
|
-
disabled = _ref$disabled === void 0 ? false : _ref$disabled;
|
14
|
-
var portalContainer = typeof container === 'function' ? container() : container;
|
15
|
-
return /*#__PURE__*/React.createElement(Root, {
|
16
|
-
disabled: disabled,
|
17
|
-
ref: outerRootRef
|
18
|
-
}, disabled && children, !disabled && /*#__PURE__*/ReactDOM.createPortal(children, portalContainer));
|
19
|
-
});
|
20
|
-
};
|
21
|
-
var portalConfig = {
|
22
|
-
name: 'Portal',
|
23
|
-
tag: 'div',
|
24
|
-
layout: portalRoot,
|
25
|
-
base: '',
|
26
|
-
variations: {},
|
27
|
-
defaults: {}
|
28
|
-
};
|
29
|
-
|
30
|
-
export { portalConfig, portalRoot };
|
31
|
-
//# sourceMappingURL=Portal.js.map
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"Portal.js","sources":["../../../src/components/Portal/Portal.tsx"],"sourcesContent":["import React, { forwardRef } from 'react';\nimport ReactDOM from 'react-dom';\n\nimport type { RootProps } from '../../engines/types';\n\nimport { PortalProps } from './Portal.types';\n\n/*\n * Вспомогательный компонент. Используется в Popup, Popover.\n * Представляет собой ReactDOM.createPortal() в форме компонента.\n */\nexport const portalRoot = (Root: RootProps<HTMLDivElement, Omit<PortalProps, 'container'>>) =>\n forwardRef<HTMLDivElement, PortalProps>(({ children, container, disabled = false }, outerRootRef) => {\n const portalContainer = typeof container === 'function' ? container() : container;\n\n return (\n <Root disabled={disabled} ref={outerRootRef}>\n {disabled && children}\n {!disabled && ReactDOM.createPortal(children, portalContainer)}\n </Root>\n );\n });\n\nexport const portalConfig = {\n name: 'Portal',\n tag: 'div',\n layout: portalRoot,\n base: '',\n variations: {},\n defaults: {},\n};\n"],"names":["portalRoot","Root","forwardRef","_ref","outerRootRef","children","container","_ref$disabled","disabled","portalContainer","React","createElement","ref","ReactDOM","createPortal","portalConfig","name","tag","layout","base","variations","defaults"],"mappings":";;;AAOA;AACA;AACA;AACA;IACaA,UAAU,GAAG,SAAbA,UAAUA,CAAIC,IAA+D,EAAA;AAAA,EAAA,oBACtFC,UAAU,CAA8B,UAAAC,IAAA,EAA4CC,YAAY,EAAK;AAAA,IAAA,IAA1DC,QAAQ,GAAAF,IAAA,CAARE,QAAQ;MAAEC,SAAS,GAAAH,IAAA,CAATG,SAAS;MAAAC,aAAA,GAAAJ,IAAA,CAAEK,QAAQ;AAARA,MAAAA,QAAQ,GAAAD,aAAA,KAAG,KAAA,CAAA,GAAA,KAAK,GAAAA,aAAA,CAAA;IAC5E,IAAME,eAAe,GAAG,OAAOH,SAAS,KAAK,UAAU,GAAGA,SAAS,EAAE,GAAGA,SAAS,CAAA;AAEjF,IAAA,oBACII,KAAA,CAAAC,aAAA,CAACV,IAAI,EAAA;AAACO,MAAAA,QAAQ,EAAEA,QAAS;AAACI,MAAAA,GAAG,EAAER,YAAAA;AAAa,KAAA,EACvCI,QAAQ,IAAIH,QAAQ,EACpB,CAACG,QAAQ,iBAAIK,QAAQ,CAACC,YAAY,CAACT,QAAQ,EAAEI,eAAe,CAC3D,CAAC,CAAA;AAEf,GAAC,CAAC,CAAA;AAAA,EAAA;AAEC,IAAMM,YAAY,GAAG;AACxBC,EAAAA,IAAI,EAAE,QAAQ;AACdC,EAAAA,GAAG,EAAE,KAAK;AACVC,EAAAA,MAAM,EAAElB,UAAU;AAClBmB,EAAAA,IAAI,EAAE,EAAE;EACRC,UAAU,EAAE,EAAE;AACdC,EAAAA,QAAQ,EAAE,EAAC;AACf;;;;"}
|
@@ -1,37 +0,0 @@
|
|
1
|
-
"use strict";
|
2
|
-
|
3
|
-
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
4
|
-
Object.defineProperty(exports, "__esModule", {
|
5
|
-
value: true
|
6
|
-
});
|
7
|
-
exports.portalRoot = exports.portalConfig = void 0;
|
8
|
-
var _react = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("react"));
|
9
|
-
var _reactDom = /*#__PURE__*/_interopRequireDefault( /*#__PURE__*/require("react-dom"));
|
10
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
11
|
-
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); }
|
12
|
-
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; }
|
13
|
-
/*
|
14
|
-
* Вспомогательный компонент. Используется в Popup, Popover.
|
15
|
-
* Представляет собой ReactDOM.createPortal() в форме компонента.
|
16
|
-
*/
|
17
|
-
var portalRoot = exports.portalRoot = function portalRoot(Root) {
|
18
|
-
return /*#__PURE__*/(0, _react.forwardRef)(function (_ref, outerRootRef) {
|
19
|
-
var children = _ref.children,
|
20
|
-
container = _ref.container,
|
21
|
-
_ref$disabled = _ref.disabled,
|
22
|
-
disabled = _ref$disabled === void 0 ? false : _ref$disabled;
|
23
|
-
var portalContainer = typeof container === 'function' ? container() : container;
|
24
|
-
return /*#__PURE__*/_react["default"].createElement(Root, {
|
25
|
-
disabled: disabled,
|
26
|
-
ref: outerRootRef
|
27
|
-
}, disabled && children, !disabled && /*#__PURE__*/_reactDom["default"].createPortal(children, portalContainer));
|
28
|
-
});
|
29
|
-
};
|
30
|
-
var portalConfig = exports.portalConfig = {
|
31
|
-
name: 'Portal',
|
32
|
-
tag: 'div',
|
33
|
-
layout: portalRoot,
|
34
|
-
base: '',
|
35
|
-
variations: {},
|
36
|
-
defaults: {}
|
37
|
-
};
|
@@ -1,66 +0,0 @@
|
|
1
|
-
---
|
2
|
-
id: portal
|
3
|
-
title: Portal
|
4
|
-
---
|
5
|
-
|
6
|
-
import { PropsTable, Description } from '@site/src/components';
|
7
|
-
|
8
|
-
# Portal
|
9
|
-
<Description name="Portal" />
|
10
|
-
<PropsTable name="Portal" />
|
11
|
-
|
12
|
-
## Использование
|
13
|
-
|
14
|
-
```tsx live
|
15
|
-
import React, { useState, useRef } from 'react';
|
16
|
-
import { Portal, Button, BodyM } from '@salutejs/{{ package }}';
|
17
|
-
|
18
|
-
export function App() {
|
19
|
-
const [show, setShow] = useState(false);
|
20
|
-
const containerRef = useRef(null);
|
21
|
-
|
22
|
-
return (
|
23
|
-
<>
|
24
|
-
<Button onClick={() => setShow(!show)}>{show ? 'Скрыть' : 'Показать'}</Button>
|
25
|
-
<div style=\{{padding: '1.25rem', marginBottom: '0.625rem', marginTop: '0.625rem', border: '1px solid'}}>
|
26
|
-
<BodyM style=\{{ marginBottom: '1.25rem' }}>Содержимое портала появится в нижнем блоке.</BodyM>
|
27
|
-
{show && containerRef.current && (
|
28
|
-
<Portal container={containerRef.current}>
|
29
|
-
<BodyM bold>Содержимое портала</BodyM>
|
30
|
-
</Portal>
|
31
|
-
)}
|
32
|
-
</div>
|
33
|
-
<div style=\{{padding: '1.25rem', marginBottom: '0.625rem', marginTop: '0.625rem', border: '1px solid'}} ref={containerRef} />
|
34
|
-
</>
|
35
|
-
);
|
36
|
-
}
|
37
|
-
```
|
38
|
-
|
39
|
-
### Disabled
|
40
|
-
Отключить портал можно с помощью свойства `disabled`.
|
41
|
-
В этом случае содержимое портала добавится внутрь родительского элемента.
|
42
|
-
|
43
|
-
```tsx live
|
44
|
-
import React, { useState, useRef } from 'react';
|
45
|
-
import { Portal, Button, BodyM } from '@salutejs/{{ package }}';
|
46
|
-
|
47
|
-
export function App() {
|
48
|
-
const [show, setShow] = useState(false);
|
49
|
-
const containerRef = useRef(null);
|
50
|
-
|
51
|
-
return (
|
52
|
-
<>
|
53
|
-
<Button onClick={() => setShow(!show)}>{show ? 'Скрыть' : 'Показать'}</Button>
|
54
|
-
<div style=\{{padding: '1.25rem', marginBottom: '0.625rem', marginTop: '0.625rem', border: '1px solid'}}>
|
55
|
-
<BodyM style=\{{ marginBottom: '1.25rem' }}>Содержимое портала появится в данном блоке.</BodyM>
|
56
|
-
{show && containerRef.current && (
|
57
|
-
<Portal disabled container={containerRef.current}>
|
58
|
-
<BodyM bold>Содержимое портала</BodyM>
|
59
|
-
</Portal>
|
60
|
-
)}
|
61
|
-
</div>
|
62
|
-
<div style=\{{padding: '1.25rem', marginBottom: '0.625rem', marginTop: '0.625rem', border: '1px solid'}} ref={containerRef} />
|
63
|
-
</>
|
64
|
-
);
|
65
|
-
}
|
66
|
-
```
|
@@ -1,18 +0,0 @@
|
|
1
|
-
"use strict";
|
2
|
-
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
4
|
-
value: true
|
5
|
-
});
|
6
|
-
Object.defineProperty(exports, "portalConfig", {
|
7
|
-
enumerable: true,
|
8
|
-
get: function get() {
|
9
|
-
return _Portal.portalConfig;
|
10
|
-
}
|
11
|
-
});
|
12
|
-
Object.defineProperty(exports, "portalRoot", {
|
13
|
-
enumerable: true,
|
14
|
-
get: function get() {
|
15
|
-
return _Portal.portalRoot;
|
16
|
-
}
|
17
|
-
});
|
18
|
-
var _Portal = /*#__PURE__*/require("./Portal");
|
@@ -1,10 +0,0 @@
|
|
1
|
-
"use strict";
|
2
|
-
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
4
|
-
value: true
|
5
|
-
});
|
6
|
-
exports.Portal = void 0;
|
7
|
-
var _Portal = /*#__PURE__*/require("../../../../components/Portal");
|
8
|
-
var _engines = /*#__PURE__*/require("../../../../engines");
|
9
|
-
var mergedConfig = /*#__PURE__*/(0, _engines.mergeConfig)(_Portal.portalConfig);
|
10
|
-
var Portal = exports.Portal = /*#__PURE__*/(0, _engines.component)(mergedConfig);
|
@@ -1,57 +0,0 @@
|
|
1
|
-
import React, { useState, useRef } from 'react';
|
2
|
-
import type { StoryObj, Meta } from '@storybook/react';
|
3
|
-
import type { ComponentProps } from 'react';
|
4
|
-
import styled from 'styled-components';
|
5
|
-
|
6
|
-
import { Button } from '../Button/Button';
|
7
|
-
import { WithTheme } from '../../../_helpers';
|
8
|
-
import { Body } from '../../../typograpy/components/Body/Body';
|
9
|
-
|
10
|
-
import { Portal } from './Portal';
|
11
|
-
|
12
|
-
const meta: Meta<typeof Portal> = {
|
13
|
-
title: 'plasma_b2c/Portal',
|
14
|
-
decorators: [WithTheme],
|
15
|
-
args: {
|
16
|
-
disabled: false,
|
17
|
-
},
|
18
|
-
};
|
19
|
-
|
20
|
-
export default meta;
|
21
|
-
|
22
|
-
type StoryPortalProps = ComponentProps<typeof Portal>;
|
23
|
-
|
24
|
-
const StyledWrapper = styled.div`
|
25
|
-
padding: 1.25rem;
|
26
|
-
margin-bottom: 0.625rem;
|
27
|
-
margin-top: 0.625rem;
|
28
|
-
|
29
|
-
border: 1px solid;
|
30
|
-
`;
|
31
|
-
|
32
|
-
const StoryDefault = ({ disabled }: StoryPortalProps) => {
|
33
|
-
const [show, setShow] = useState(false);
|
34
|
-
const containerRef = useRef<HTMLDivElement>(null);
|
35
|
-
|
36
|
-
return (
|
37
|
-
<>
|
38
|
-
<Button onClick={() => setShow(!show)}>{show ? 'Скрыть' : 'Показать'}</Button>
|
39
|
-
<StyledWrapper>
|
40
|
-
<Body style={{ marginBottom: '1.25rem' }}>Содержимое портала появится в нижнем блоке.</Body>
|
41
|
-
<Body style={{ marginBottom: '1.25rem' }}>
|
42
|
-
Если портал выключен (disabled), то содержимое появится в данном блоке.
|
43
|
-
</Body>
|
44
|
-
{show && containerRef.current && (
|
45
|
-
<Portal disabled={disabled} container={containerRef.current}>
|
46
|
-
<Body bold>Содержимое портала</Body>
|
47
|
-
</Portal>
|
48
|
-
)}
|
49
|
-
</StyledWrapper>
|
50
|
-
<StyledWrapper ref={containerRef} />
|
51
|
-
</>
|
52
|
-
);
|
53
|
-
};
|
54
|
-
|
55
|
-
export const Default: StoryObj<StoryPortalProps> = {
|
56
|
-
render: (args) => <StoryDefault {...args} />,
|
57
|
-
};
|
@@ -1,10 +0,0 @@
|
|
1
|
-
"use strict";
|
2
|
-
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
4
|
-
value: true
|
5
|
-
});
|
6
|
-
exports.Portal = void 0;
|
7
|
-
var _Portal = /*#__PURE__*/require("../../../../components/Portal");
|
8
|
-
var _engines = /*#__PURE__*/require("../../../../engines");
|
9
|
-
var mergedConfig = /*#__PURE__*/(0, _engines.mergeConfig)(_Portal.portalConfig);
|
10
|
-
var Portal = exports.Portal = /*#__PURE__*/(0, _engines.component)(mergedConfig);
|
@@ -1,57 +0,0 @@
|
|
1
|
-
import React, { useState, useRef } from 'react';
|
2
|
-
import type { StoryObj, Meta } from '@storybook/react';
|
3
|
-
import type { ComponentProps } from 'react';
|
4
|
-
import styled from 'styled-components';
|
5
|
-
|
6
|
-
import { Button } from '../Button/Button';
|
7
|
-
import { WithTheme } from '../../../_helpers';
|
8
|
-
import { Body } from '../../../typograpy/components/Body/Body';
|
9
|
-
|
10
|
-
import { Portal } from './Portal';
|
11
|
-
|
12
|
-
const meta: Meta<typeof Portal> = {
|
13
|
-
title: 'plasma_web/Portal',
|
14
|
-
decorators: [WithTheme],
|
15
|
-
args: {
|
16
|
-
disabled: false,
|
17
|
-
},
|
18
|
-
};
|
19
|
-
|
20
|
-
export default meta;
|
21
|
-
|
22
|
-
type StoryPortalProps = ComponentProps<typeof Portal>;
|
23
|
-
|
24
|
-
const StyledWrapper = styled.div`
|
25
|
-
padding: 1.25rem;
|
26
|
-
margin-bottom: 0.625rem;
|
27
|
-
margin-top: 0.625rem;
|
28
|
-
|
29
|
-
border: 1px solid;
|
30
|
-
`;
|
31
|
-
|
32
|
-
const StoryDefault = ({ disabled }: StoryPortalProps) => {
|
33
|
-
const [show, setShow] = useState(false);
|
34
|
-
const containerRef = useRef<HTMLDivElement>(null);
|
35
|
-
|
36
|
-
return (
|
37
|
-
<>
|
38
|
-
<Button onClick={() => setShow(!show)}>{show ? 'Скрыть' : 'Показать'}</Button>
|
39
|
-
<StyledWrapper>
|
40
|
-
<Body style={{ marginBottom: '1.25rem' }}>Содержимое портала появится в нижнем блоке.</Body>
|
41
|
-
<Body style={{ marginBottom: '1.25rem' }}>
|
42
|
-
Если портал выключен (disabled), то содержимое появится в данном блоке.
|
43
|
-
</Body>
|
44
|
-
{show && containerRef.current && (
|
45
|
-
<Portal disabled={disabled} container={containerRef.current}>
|
46
|
-
<Body bold>Содержимое портала</Body>
|
47
|
-
</Portal>
|
48
|
-
)}
|
49
|
-
</StyledWrapper>
|
50
|
-
<StyledWrapper ref={containerRef} />
|
51
|
-
</>
|
52
|
-
);
|
53
|
-
};
|
54
|
-
|
55
|
-
export const Default: StoryObj<StoryPortalProps> = {
|
56
|
-
render: (args) => <StoryDefault {...args} />,
|
57
|
-
};
|
@@ -1,27 +0,0 @@
|
|
1
|
-
import React, { forwardRef } from 'react';
|
2
|
-
import ReactDOM from 'react-dom';
|
3
|
-
/*
|
4
|
-
* Вспомогательный компонент. Используется в Popup, Popover.
|
5
|
-
* Представляет собой ReactDOM.createPortal() в форме компонента.
|
6
|
-
*/
|
7
|
-
export var portalRoot = function portalRoot(Root) {
|
8
|
-
return /*#__PURE__*/forwardRef(function (_ref, outerRootRef) {
|
9
|
-
var children = _ref.children,
|
10
|
-
container = _ref.container,
|
11
|
-
_ref$disabled = _ref.disabled,
|
12
|
-
disabled = _ref$disabled === void 0 ? false : _ref$disabled;
|
13
|
-
var portalContainer = typeof container === 'function' ? container() : container;
|
14
|
-
return /*#__PURE__*/React.createElement(Root, {
|
15
|
-
disabled: disabled,
|
16
|
-
ref: outerRootRef
|
17
|
-
}, disabled && children, !disabled && /*#__PURE__*/ReactDOM.createPortal(children, portalContainer));
|
18
|
-
});
|
19
|
-
};
|
20
|
-
export var portalConfig = {
|
21
|
-
name: 'Portal',
|
22
|
-
tag: 'div',
|
23
|
-
layout: portalRoot,
|
24
|
-
base: '',
|
25
|
-
variations: {},
|
26
|
-
defaults: {}
|
27
|
-
};
|
@@ -1,66 +0,0 @@
|
|
1
|
-
---
|
2
|
-
id: portal
|
3
|
-
title: Portal
|
4
|
-
---
|
5
|
-
|
6
|
-
import { PropsTable, Description } from '@site/src/components';
|
7
|
-
|
8
|
-
# Portal
|
9
|
-
<Description name="Portal" />
|
10
|
-
<PropsTable name="Portal" />
|
11
|
-
|
12
|
-
## Использование
|
13
|
-
|
14
|
-
```tsx live
|
15
|
-
import React, { useState, useRef } from 'react';
|
16
|
-
import { Portal, Button, BodyM } from '@salutejs/{{ package }}';
|
17
|
-
|
18
|
-
export function App() {
|
19
|
-
const [show, setShow] = useState(false);
|
20
|
-
const containerRef = useRef(null);
|
21
|
-
|
22
|
-
return (
|
23
|
-
<>
|
24
|
-
<Button onClick={() => setShow(!show)}>{show ? 'Скрыть' : 'Показать'}</Button>
|
25
|
-
<div style=\{{padding: '1.25rem', marginBottom: '0.625rem', marginTop: '0.625rem', border: '1px solid'}}>
|
26
|
-
<BodyM style=\{{ marginBottom: '1.25rem' }}>Содержимое портала появится в нижнем блоке.</BodyM>
|
27
|
-
{show && containerRef.current && (
|
28
|
-
<Portal container={containerRef.current}>
|
29
|
-
<BodyM bold>Содержимое портала</BodyM>
|
30
|
-
</Portal>
|
31
|
-
)}
|
32
|
-
</div>
|
33
|
-
<div style=\{{padding: '1.25rem', marginBottom: '0.625rem', marginTop: '0.625rem', border: '1px solid'}} ref={containerRef} />
|
34
|
-
</>
|
35
|
-
);
|
36
|
-
}
|
37
|
-
```
|
38
|
-
|
39
|
-
### Disabled
|
40
|
-
Отключить портал можно с помощью свойства `disabled`.
|
41
|
-
В этом случае содержимое портала добавится внутрь родительского элемента.
|
42
|
-
|
43
|
-
```tsx live
|
44
|
-
import React, { useState, useRef } from 'react';
|
45
|
-
import { Portal, Button, BodyM } from '@salutejs/{{ package }}';
|
46
|
-
|
47
|
-
export function App() {
|
48
|
-
const [show, setShow] = useState(false);
|
49
|
-
const containerRef = useRef(null);
|
50
|
-
|
51
|
-
return (
|
52
|
-
<>
|
53
|
-
<Button onClick={() => setShow(!show)}>{show ? 'Скрыть' : 'Показать'}</Button>
|
54
|
-
<div style=\{{padding: '1.25rem', marginBottom: '0.625rem', marginTop: '0.625rem', border: '1px solid'}}>
|
55
|
-
<BodyM style=\{{ marginBottom: '1.25rem' }}>Содержимое портала появится в данном блоке.</BodyM>
|
56
|
-
{show && containerRef.current && (
|
57
|
-
<Portal disabled container={containerRef.current}>
|
58
|
-
<BodyM bold>Содержимое портала</BodyM>
|
59
|
-
</Portal>
|
60
|
-
)}
|
61
|
-
</div>
|
62
|
-
<div style=\{{padding: '1.25rem', marginBottom: '0.625rem', marginTop: '0.625rem', border: '1px solid'}} ref={containerRef} />
|
63
|
-
</>
|
64
|
-
);
|
65
|
-
}
|
66
|
-
```
|
@@ -1 +0,0 @@
|
|
1
|
-
export {};
|
@@ -1 +0,0 @@
|
|
1
|
-
export { portalConfig, portalRoot } from './Portal';
|