@salutejs/plasma-new-hope 0.94.1-canary.1273.9715265388.0 → 0.95.0-canary.1272.9742620045.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 +3 -1
- 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 +3 -1
- 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 +9 -3
- package/cjs/components/Popover/Popover.js.map +1 -1
- package/cjs/components/Popup/Popup.js +9 -3
- package/cjs/components/Popup/Popup.js.map +1 -1
- package/cjs/components/Portal/Portal.js +36 -0
- package/cjs/components/Portal/Portal.js.map +1 -0
- 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/components/Sheet/Sheet.js.map +1 -1
- package/cjs/index.js +3 -0
- 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 +3 -1
- 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 +3 -1
- 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 +9 -3
- package/es/components/Popover/Popover.js.map +1 -1
- package/es/components/Popup/Popup.js +9 -3
- package/es/components/Popup/Popup.js.map +1 -1
- package/es/components/Portal/Portal.js +31 -0
- package/es/components/Portal/Portal.js.map +1 -0
- 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/components/Sheet/Sheet.js +4 -4
- package/es/components/Sheet/Sheet.js.map +1 -1
- package/es/index.js +1 -0
- package/es/index.js.map +1 -1
- package/package.json +2 -2
- package/styled-components/cjs/components/Popover/Popover.js +8 -4
- package/styled-components/cjs/components/Popup/Popup.js +8 -4
- package/styled-components/cjs/components/Portal/Portal.js +37 -0
- package/styled-components/cjs/components/Portal/Portal.template-doc.mdx +66 -0
- package/styled-components/cjs/components/Portal/Portal.types.js +5 -0
- package/styled-components/cjs/components/Portal/index.js +18 -0
- package/styled-components/cjs/components/Sheet/Sheet.js +3 -3
- package/styled-components/cjs/examples/plasma_b2c/components/Portal/Portal.js +10 -0
- package/styled-components/cjs/examples/plasma_b2c/components/Portal/Portal.stories.tsx +57 -0
- package/styled-components/cjs/examples/plasma_b2c/components/Sheet/Sheet.stories.tsx +2 -2
- package/styled-components/cjs/examples/plasma_web/components/Portal/Portal.js +10 -0
- package/styled-components/cjs/examples/plasma_web/components/Portal/Portal.stories.tsx +57 -0
- package/styled-components/cjs/examples/plasma_web/components/Sheet/Sheet.stories.tsx +2 -2
- package/styled-components/cjs/index.js +11 -0
- package/styled-components/es/components/Popover/Popover.js +8 -3
- package/styled-components/es/components/Popup/Popup.js +8 -3
- package/styled-components/es/components/Portal/Portal.js +27 -0
- package/styled-components/es/components/Portal/Portal.template-doc.mdx +66 -0
- package/styled-components/es/components/Portal/Portal.types.js +1 -0
- package/styled-components/es/components/Portal/index.js +1 -0
- package/styled-components/es/components/Sheet/Sheet.js +4 -4
- package/styled-components/es/examples/plasma_b2c/components/Portal/Portal.js +4 -0
- package/styled-components/es/examples/plasma_b2c/components/Portal/Portal.stories.tsx +57 -0
- package/styled-components/es/examples/plasma_b2c/components/Sheet/Sheet.stories.tsx +2 -2
- package/styled-components/es/examples/plasma_web/components/Portal/Portal.js +4 -0
- package/styled-components/es/examples/plasma_web/components/Portal/Portal.stories.tsx +57 -0
- package/styled-components/es/examples/plasma_web/components/Sheet/Sheet.stories.tsx +2 -2
- package/styled-components/es/index.js +2 -1
- package/types/components/Popover/Popover.d.ts.map +1 -1
- package/types/components/Popup/Popup.d.ts.map +1 -1
- package/types/components/Portal/Portal.d.ts +13 -0
- package/types/components/Portal/Portal.d.ts.map +1 -0
- package/types/components/Portal/Portal.types.d.ts +18 -0
- package/types/components/Portal/Portal.types.d.ts.map +1 -0
- package/types/components/Portal/index.d.ts +3 -0
- package/types/components/Portal/index.d.ts.map +1 -0
- package/types/components/Sheet/Sheet.d.ts.map +1 -1
- package/types/components/Sheet/Sheet.types.d.ts +1 -1
- package/types/components/Sheet/Sheet.types.d.ts.map +1 -1
- package/types/examples/plasma_b2c/components/Portal/Portal.d.ts +3 -0
- package/types/examples/plasma_b2c/components/Portal/Portal.d.ts.map +1 -0
- package/types/examples/plasma_web/components/Portal/Portal.d.ts +3 -0
- package/types/examples/plasma_web/components/Portal/Portal.d.ts.map +1 -0
- package/types/index.d.ts +1 -0
- package/types/index.d.ts.map +1 -1
@@ -5,8 +5,8 @@ import '@linaria/react';
|
|
5
5
|
import { dropdownGroupRoot } from '../../../Dropdown/ui/DropdownGroup/DropdownGroup.js';
|
6
6
|
import '@linaria/core';
|
7
7
|
import 'focus-visible';
|
8
|
-
import 'react-dom';
|
9
8
|
import 'react-popper';
|
9
|
+
import 'react-dom';
|
10
10
|
import 'styled-components';
|
11
11
|
import { base as base$1 } from './variations/_view/base.js';
|
12
12
|
import { base as base$2 } from './variations/_size/base.js';
|
@@ -5,8 +5,8 @@ import '@linaria/react';
|
|
5
5
|
import { dropdownHeaderRoot } from '../../../Dropdown/ui/DropdownHeader/DropdownHeader.js';
|
6
6
|
import '@linaria/core';
|
7
7
|
import 'focus-visible';
|
8
|
-
import 'react-dom';
|
9
8
|
import 'react-popper';
|
9
|
+
import 'react-dom';
|
10
10
|
import 'styled-components';
|
11
11
|
import { base as base$1 } from './variations/_view/base.js';
|
12
12
|
import { base as base$2 } from './variations/_size/base.js';
|
@@ -4,8 +4,8 @@ import '@salutejs/plasma-core';
|
|
4
4
|
import '@linaria/react';
|
5
5
|
import '@linaria/core';
|
6
6
|
import 'focus-visible';
|
7
|
-
import 'react-dom';
|
8
7
|
import 'react-popper';
|
8
|
+
import 'react-dom';
|
9
9
|
import { dropdownItemOldRoot } from '../../../Dropdown/ui/DropdownItemOld/DropdownItemOld.js';
|
10
10
|
import { base as base$1 } from './variations/_view/base.js';
|
11
11
|
import { base as base$2 } from './variations/_size/base.js';
|
@@ -1,5 +1,5 @@
|
|
1
1
|
import { objectWithoutProperties as _objectWithoutProperties, extends as _extends } from '../../_virtual/_rollupPluginBabelHelpers.js';
|
2
|
-
import React, { forwardRef
|
2
|
+
import React, { forwardRef } from 'react';
|
3
3
|
import { Overlay } from '../Overlay/Overlay.js';
|
4
4
|
import { cx } from '../../utils/index.js';
|
5
5
|
import { useSheetSwipe } from './hooks/useSheetSwipe.js';
|
@@ -38,9 +38,9 @@ var sheetRoot = function sheetRoot(Root) {
|
|
38
38
|
className = _ref.className,
|
39
39
|
view = _ref.view,
|
40
40
|
restProps = _objectWithoutProperties(_ref, _excluded);
|
41
|
-
var contentWrapperRef = useRef(null);
|
42
|
-
var contentRef = useRef(null);
|
43
|
-
var handleRef = useRef(null);
|
41
|
+
var contentWrapperRef = React.useRef(null);
|
42
|
+
var contentRef = React.useRef(null);
|
43
|
+
var handleRef = React.useRef(null);
|
44
44
|
useOverflow({
|
45
45
|
opened: opened
|
46
46
|
});
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"Sheet.js","sources":["../../../src/components/Sheet/Sheet.tsx"],"sourcesContent":["import React, { forwardRef
|
1
|
+
{"version":3,"file":"Sheet.js","sources":["../../../src/components/Sheet/Sheet.tsx"],"sourcesContent":["import React, { forwardRef } from 'react';\n\nimport { RootProps } from '../../engines';\nimport { Overlay } from '../Overlay';\nimport { cx } from '../../utils';\n\nimport { SheetProps } from './Sheet.types';\nimport { useOverflow, useSheetSwipe } from './hooks';\nimport { classes, tokens } from './Sheet.tokens';\nimport {\n StyledContentWrapper,\n StyledSheetBody,\n StyledSheetContent,\n StyledSheetFooter,\n StyledSheetHandle,\n StyledSheetHeader,\n} from './Sheet.styles';\nimport { base as viewCSS } from './variations/_view/base';\nimport { DEFAULT_Z_INDEX } from './utils';\n\n/**\n * Открывает окно-шторку поверх основного экрана.\n */\n\nexport const sheetRoot = (Root: RootProps<HTMLDivElement, SheetProps>) =>\n forwardRef<HTMLDivElement, SheetProps>(\n (\n {\n opened,\n children,\n onClose,\n hasHandle = true,\n contentHeader,\n isHeaderFixed = false,\n contentFooter,\n isFooterFixed = false,\n withOverlay = true,\n withBlur = false,\n withTransition = true,\n throttleMs,\n className,\n view,\n ...restProps\n },\n rootRef,\n ) => {\n const contentWrapperRef = React.useRef<HTMLDivElement>(null);\n const contentRef = React.useRef<HTMLDivElement>(null);\n const handleRef = React.useRef<HTMLDivElement>(null);\n\n useOverflow({ opened });\n useSheetSwipe({ contentWrapperRef, contentRef, handleRef, throttleMs, onClose });\n\n const hasHeader = Boolean(contentHeader);\n const hasFooter = Boolean(contentFooter);\n\n const closedClass = opened ? undefined : `${classes.closed}`;\n\n const overlayBackgroundToken = withBlur\n ? `var(${tokens.sheetOverlayWithBlurColor})`\n : `var(${tokens.sheetOverlayColor})`;\n\n return (\n <Root opened={opened} onClose={onClose} view={view} ref={rootRef}>\n <StyledContentWrapper\n opened={opened}\n withTransition={withTransition}\n className={cx(closedClass, className)}\n ref={contentWrapperRef}\n {...restProps}\n >\n {hasHandle && <StyledSheetHandle ref={handleRef} />}\n <StyledSheetContent hasHeader={hasHeader} hasFooter={hasFooter} ref={contentRef}>\n {hasHeader && (\n <StyledSheetHeader isHeaderFixed={isHeaderFixed}>{contentHeader}</StyledSheetHeader>\n )}\n <StyledSheetBody>{children}</StyledSheetBody>\n {hasFooter && (\n <StyledSheetFooter isFooterFixed={isFooterFixed}>{contentFooter}</StyledSheetFooter>\n )}\n </StyledSheetContent>\n </StyledContentWrapper>\n {withOverlay && opened && (\n <Overlay\n zIndex={DEFAULT_Z_INDEX}\n backgroundColorProperty={overlayBackgroundToken}\n withBlur={withBlur}\n isClickable\n onOverlayClick={onClose}\n />\n )}\n </Root>\n );\n },\n );\n\nexport const sheetConfig = {\n name: 'Sheet',\n tag: 'div',\n layout: sheetRoot,\n base: '',\n variations: {\n view: {\n css: viewCSS,\n },\n },\n defaults: {\n view: 'default',\n },\n};\n"],"names":["sheetRoot","Root","forwardRef","_ref","rootRef","opened","children","onClose","_ref$hasHandle","hasHandle","contentHeader","_ref$isHeaderFixed","isHeaderFixed","contentFooter","_ref$isFooterFixed","isFooterFixed","_ref$withOverlay","withOverlay","_ref$withBlur","withBlur","_ref$withTransition","withTransition","throttleMs","className","view","restProps","_objectWithoutProperties","_excluded","contentWrapperRef","React","useRef","contentRef","handleRef","useOverflow","useSheetSwipe","hasHeader","Boolean","hasFooter","closedClass","undefined","concat","classes","closed","overlayBackgroundToken","tokens","sheetOverlayWithBlurColor","sheetOverlayColor","createElement","ref","StyledContentWrapper","_extends","cx","StyledSheetHandle","StyledSheetContent","StyledSheetHeader","StyledSheetBody","StyledSheetFooter","Overlay","zIndex","DEFAULT_Z_INDEX","backgroundColorProperty","isClickable","onOverlayClick","sheetConfig","name","tag","layout","base","variations","css","viewCSS","defaults"],"mappings":"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"}
|
package/es/index.js
CHANGED
@@ -183,6 +183,7 @@ export { classes as accordionClasses, tokens as accordionTokens } from './compon
|
|
183
183
|
export { datePickerConfig, datePickerRoot } from './components/DatePicker/SingleDate/SingleDate.js';
|
184
184
|
export { datePickerRangeConfig, datePickerRangeRoot } from './components/DatePicker/RangeDate/RangeDate.js';
|
185
185
|
export { classes as datePickerClasses, tokens as datePickerTokens } from './components/DatePicker/DatePicker.tokens.js';
|
186
|
+
export { portalConfig, portalRoot } from './components/Portal/Portal.js';
|
186
187
|
export { component, mergeConfig } from './engines/common.js';
|
187
188
|
export { canUseDOM } from './utils/canUseDOM.js';
|
188
189
|
export { extractTextFrom } from './utils/extractTextFrom.js';
|
package/es/index.js.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
1
|
+
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@salutejs/plasma-new-hope",
|
3
|
-
"version": "0.
|
3
|
+
"version": "0.95.0-canary.1272.9742620045.0",
|
4
4
|
"description": "Salute Design System blueprint",
|
5
5
|
"main": "cjs/index.js",
|
6
6
|
"module": "es/index.js",
|
@@ -106,5 +106,5 @@
|
|
106
106
|
"react-popper": "2.3.0",
|
107
107
|
"storeon": "3.1.5"
|
108
108
|
},
|
109
|
-
"gitHead": "
|
109
|
+
"gitHead": "a7a70560a63a2496b163fcfecc3d23011039ac0f"
|
110
110
|
}
|
@@ -6,15 +6,15 @@ Object.defineProperty(exports, "__esModule", {
|
|
6
6
|
});
|
7
7
|
exports.popoverRoot = exports.popoverConfig = exports.POPOVER_PORTAL_ID = exports.ESCAPE_KEYCODE = void 0;
|
8
8
|
var _react = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("react"));
|
9
|
-
var _reactDom = /*#__PURE__*/_interopRequireDefault( /*#__PURE__*/require("react-dom"));
|
10
9
|
var _reactPopper = /*#__PURE__*/require("react-popper");
|
11
10
|
var _plasmaCore = /*#__PURE__*/require("@salutejs/plasma-core");
|
11
|
+
var _engines = /*#__PURE__*/require("../../engines");
|
12
12
|
var _utils = /*#__PURE__*/require("../../utils");
|
13
|
+
var _Portal = /*#__PURE__*/require("../Portal");
|
13
14
|
var _base = /*#__PURE__*/require("./variations/_view/base");
|
14
15
|
var _Popover = /*#__PURE__*/require("./Popover.styles");
|
15
16
|
var _Popover2 = /*#__PURE__*/require("./Popover.tokens");
|
16
17
|
var _excluded = ["target", "children", "isOpen", "trigger", "hasArrow", "frame", "className", "placement", "offset", "zIndex", "isFocusTrapped", "closeOnEsc", "preventOverflow", "usePortal", "view", "onToggle", "closeOnOverlayClick"];
|
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); }
|
@@ -33,6 +33,8 @@ function _objectWithoutProperties(source, excluded) { if (source == null) return
|
|
33
33
|
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; }
|
34
34
|
var ESCAPE_KEYCODE = exports.ESCAPE_KEYCODE = 27;
|
35
35
|
var POPOVER_PORTAL_ID = exports.POPOVER_PORTAL_ID = 'plasma-popover-root';
|
36
|
+
var mergedPortalConfig = /*#__PURE__*/(0, _engines.mergeConfig)(_Portal.portalConfig);
|
37
|
+
var Portal = /*#__PURE__*/(0, _engines.component)(mergedPortalConfig);
|
36
38
|
|
37
39
|
/**
|
38
40
|
* Всплывающее окно с возможностью позиционирования
|
@@ -222,7 +224,9 @@ var popoverRoot = exports.popoverRoot = function popoverRoot(Root) {
|
|
222
224
|
onFocus: onFocus,
|
223
225
|
onBlur: onBlur,
|
224
226
|
className: (0, _utils.cx)(className, _Popover2.classes.target)
|
225
|
-
}, target), children && portalRef.current && /*#__PURE__*/
|
227
|
+
}, target), children && portalRef.current && /*#__PURE__*/_react["default"].createElement(Portal, {
|
228
|
+
container: portalRef.current
|
229
|
+
}, /*#__PURE__*/_react["default"].createElement(Root, _extends({
|
226
230
|
view: view,
|
227
231
|
className: className
|
228
232
|
}, rest), /*#__PURE__*/_react["default"].createElement(_Popover.StyledPopover, _extends({}, attributes.popper, {
|
@@ -236,7 +240,7 @@ var popoverRoot = exports.popoverRoot = function popoverRoot(Root) {
|
|
236
240
|
className: _Popover2.classes.arrow,
|
237
241
|
ref: setArrowElement,
|
238
242
|
style: styles.arrow
|
239
|
-
}, attributes.arrow)), children))
|
243
|
+
}, attributes.arrow)), children))));
|
240
244
|
});
|
241
245
|
};
|
242
246
|
var popoverConfig = exports.popoverConfig = {
|
@@ -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"));
|
10
9
|
var _plasmaCore = /*#__PURE__*/require("@salutejs/plasma-core");
|
11
10
|
var _utils = /*#__PURE__*/require("../../utils");
|
11
|
+
var _Portal = /*#__PURE__*/require("../Portal");
|
12
|
+
var _engines = /*#__PURE__*/require("../../engines");
|
12
13
|
var _PopupContext = /*#__PURE__*/require("./PopupContext");
|
13
14
|
var _PopupRoot = /*#__PURE__*/require("./PopupRoot");
|
14
15
|
var _hooks = /*#__PURE__*/require("./hooks");
|
15
16
|
var _Popup = /*#__PURE__*/require("./Popup.tokens");
|
16
17
|
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,6 +83,8 @@ 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);
|
86
88
|
|
87
89
|
/**
|
88
90
|
* Базовый копмонент Popup.
|
@@ -156,7 +158,9 @@ var popupRoot = exports.popupRoot = function popupRoot(Root) {
|
|
156
158
|
return null;
|
157
159
|
}
|
158
160
|
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 : '');
|
159
|
-
return /*#__PURE__*/_react["default"].createElement(_react["default"].Fragment, null, portalRef.current && /*#__PURE__*/
|
161
|
+
return /*#__PURE__*/_react["default"].createElement(_react["default"].Fragment, null, portalRef.current && /*#__PURE__*/_react["default"].createElement(Portal, {
|
162
|
+
container: portalRef.current
|
163
|
+
}, /*#__PURE__*/_react["default"].createElement(Root, _extends({
|
160
164
|
className: cls
|
161
165
|
}, rest), overlay, /*#__PURE__*/_react["default"].createElement(_PopupRoot.PopupRoot, {
|
162
166
|
id: innerId,
|
@@ -166,7 +170,7 @@ var popupRoot = exports.popupRoot = function popupRoot(Root) {
|
|
166
170
|
zIndex: zIndex,
|
167
171
|
animationInfo: animationInfo,
|
168
172
|
setVisible: setVisible
|
169
|
-
}, children))
|
173
|
+
}, children))));
|
170
174
|
});
|
171
175
|
};
|
172
176
|
var popupConfig = exports.popupConfig = {
|
@@ -0,0 +1,37 @@
|
|
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
|
+
};
|
@@ -0,0 +1,66 @@
|
|
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
|
+
```
|
@@ -0,0 +1,18 @@
|
|
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");
|
@@ -46,9 +46,9 @@ var sheetRoot = exports.sheetRoot = function sheetRoot(Root) {
|
|
46
46
|
className = _ref.className,
|
47
47
|
view = _ref.view,
|
48
48
|
restProps = _objectWithoutProperties(_ref, _excluded);
|
49
|
-
var contentWrapperRef =
|
50
|
-
var contentRef =
|
51
|
-
var handleRef =
|
49
|
+
var contentWrapperRef = _react["default"].useRef(null);
|
50
|
+
var contentRef = _react["default"].useRef(null);
|
51
|
+
var handleRef = _react["default"].useRef(null);
|
52
52
|
(0, _hooks.useOverflow)({
|
53
53
|
opened: opened
|
54
54
|
});
|
@@ -0,0 +1,10 @@
|
|
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);
|
@@ -0,0 +1,57 @@
|
|
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
|
+
};
|
@@ -222,7 +222,7 @@ const StoryWithInsideScroll = ({
|
|
222
222
|
<div
|
223
223
|
style={{
|
224
224
|
height: '150px',
|
225
|
-
|
225
|
+
overflow: 'scroll',
|
226
226
|
display: 'flex',
|
227
227
|
flexDirection: 'column',
|
228
228
|
gap: '1rem',
|
@@ -296,7 +296,7 @@ const StoryWithDoubleScroll = ({
|
|
296
296
|
<div
|
297
297
|
style={{
|
298
298
|
height: '150px',
|
299
|
-
|
299
|
+
overflow: 'scroll',
|
300
300
|
display: 'flex',
|
301
301
|
flexDirection: 'column',
|
302
302
|
gap: '1rem',
|
@@ -0,0 +1,10 @@
|
|
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);
|
@@ -0,0 +1,57 @@
|
|
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
|
+
};
|
@@ -222,7 +222,7 @@ const StoryWithInsideScroll = ({
|
|
222
222
|
<div
|
223
223
|
style={{
|
224
224
|
height: '150px',
|
225
|
-
|
225
|
+
overflow: 'scroll',
|
226
226
|
display: 'flex',
|
227
227
|
flexDirection: 'column',
|
228
228
|
gap: '1rem',
|
@@ -296,7 +296,7 @@ const StoryWithDoubleScroll = ({
|
|
296
296
|
<div
|
297
297
|
style={{
|
298
298
|
height: '150px',
|
299
|
-
|
299
|
+
overflow: 'scroll',
|
300
300
|
display: 'flex',
|
301
301
|
flexDirection: 'column',
|
302
302
|
gap: '1rem',
|
@@ -563,4 +563,15 @@ Object.keys(_DatePicker).forEach(function (key) {
|
|
563
563
|
return _DatePicker[key];
|
564
564
|
}
|
565
565
|
});
|
566
|
+
});
|
567
|
+
var _Portal = /*#__PURE__*/require("./components/Portal");
|
568
|
+
Object.keys(_Portal).forEach(function (key) {
|
569
|
+
if (key === "default" || key === "__esModule") return;
|
570
|
+
if (key in exports && exports[key] === _Portal[key]) return;
|
571
|
+
Object.defineProperty(exports, key, {
|
572
|
+
enumerable: true,
|
573
|
+
get: function get() {
|
574
|
+
return _Portal[key];
|
575
|
+
}
|
576
|
+
});
|
566
577
|
});
|
@@ -15,15 +15,18 @@ 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';
|
19
18
|
import { usePopper } from 'react-popper';
|
20
19
|
import { useFocusTrap, useForkRef } from '@salutejs/plasma-core';
|
20
|
+
import { component, mergeConfig } from '../../engines';
|
21
21
|
import { cx } from '../../utils';
|
22
|
+
import { portalConfig } from '../Portal';
|
22
23
|
import { base as viewCSS } from './variations/_view/base';
|
23
24
|
import { StyledArrow, StyledPopover, StyledRoot, StyledWrapper } from './Popover.styles';
|
24
25
|
import { classes } from './Popover.tokens';
|
25
26
|
export var ESCAPE_KEYCODE = 27;
|
26
27
|
export var POPOVER_PORTAL_ID = 'plasma-popover-root';
|
28
|
+
var mergedPortalConfig = /*#__PURE__*/mergeConfig(portalConfig);
|
29
|
+
var Portal = /*#__PURE__*/component(mergedPortalConfig);
|
27
30
|
|
28
31
|
/**
|
29
32
|
* Всплывающее окно с возможностью позиционирования
|
@@ -213,7 +216,9 @@ export var popoverRoot = function popoverRoot(Root) {
|
|
213
216
|
onFocus: onFocus,
|
214
217
|
onBlur: onBlur,
|
215
218
|
className: cx(className, classes.target)
|
216
|
-
}, target), children && portalRef.current && /*#__PURE__*/
|
219
|
+
}, target), children && portalRef.current && /*#__PURE__*/React.createElement(Portal, {
|
220
|
+
container: portalRef.current
|
221
|
+
}, /*#__PURE__*/React.createElement(Root, _extends({
|
217
222
|
view: view,
|
218
223
|
className: className
|
219
224
|
}, rest), /*#__PURE__*/React.createElement(StyledPopover, _extends({}, attributes.popper, {
|
@@ -227,7 +232,7 @@ export var popoverRoot = function popoverRoot(Root) {
|
|
227
232
|
className: classes.arrow,
|
228
233
|
ref: setArrowElement,
|
229
234
|
style: styles.arrow
|
230
|
-
}, attributes.arrow)), children))
|
235
|
+
}, attributes.arrow)), children))));
|
231
236
|
});
|
232
237
|
};
|
233
238
|
export var popoverConfig = {
|