@salutejs/plasma-new-hope 0.157.1-canary.1412.11127658499.0 → 0.157.1-canary.1454.11127745883.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (131) hide show
  1. package/cjs/components/Attach/Attach.js +13 -9
  2. package/cjs/components/Attach/Attach.js.map +1 -1
  3. package/cjs/components/Attach/utils/addSeparator.js +17 -0
  4. package/cjs/components/Attach/utils/addSeparator.js.map +1 -0
  5. package/cjs/components/Attach/utils/index.js +11 -0
  6. package/cjs/components/Attach/utils/index.js.map +1 -0
  7. package/cjs/components/Drawer/Drawer.css +3 -4
  8. package/cjs/components/Drawer/Drawer.js +1 -1
  9. package/cjs/components/Drawer/Drawer.styles.js +0 -3
  10. package/cjs/components/Drawer/Drawer.styles.js.map +1 -1
  11. package/cjs/components/Drawer/hooks/useDrawer.js +1 -1
  12. package/cjs/components/Modal/Modal.css +3 -4
  13. package/cjs/components/Modal/hooks/useModal.js +1 -1
  14. package/cjs/components/Notification/NotificationsProvider.css +3 -4
  15. package/cjs/components/Popup/Popup.css +3 -0
  16. package/cjs/components/Popup/Popup.js +41 -29
  17. package/cjs/components/Popup/Popup.js.map +1 -1
  18. package/cjs/components/Popup/Popup.styles.js +27 -55
  19. package/cjs/components/Popup/Popup.styles.js.map +1 -1
  20. package/cjs/components/Popup/Popup.styles_141jyqa.css +3 -0
  21. package/cjs/components/Popup/PopupContext.js +10 -30
  22. package/cjs/components/Popup/PopupContext.js.map +1 -1
  23. package/cjs/components/Popup/PopupRoot.js +1 -1
  24. package/cjs/components/Popup/PopupRoot.js.map +1 -1
  25. package/cjs/components/Popup/hooks/usePopup.js +3 -6
  26. package/cjs/components/Popup/hooks/usePopup.js.map +1 -1
  27. package/cjs/index.css +3 -4
  28. package/emotion/cjs/components/Attach/Attach.js +9 -6
  29. package/emotion/cjs/components/Attach/utils/addSeparator.js +15 -0
  30. package/emotion/cjs/components/Attach/utils/index.js +9 -7
  31. package/emotion/cjs/components/Popup/Popup.js +41 -29
  32. package/emotion/cjs/components/Popup/Popup.styles.js +17 -35
  33. package/emotion/cjs/components/Popup/PopupContext.js +10 -30
  34. package/emotion/cjs/components/Popup/PopupRoot.js +3 -1
  35. package/emotion/cjs/components/Popup/hooks/usePopup.js +3 -6
  36. package/emotion/cjs/examples/plasma_b2c/components/Modal/Modal.stories.tsx +0 -3
  37. package/emotion/cjs/examples/plasma_b2c/components/Popup/Popup.stories.tsx +0 -3
  38. package/emotion/cjs/examples/plasma_web/components/Modal/Modal.stories.tsx +0 -3
  39. package/emotion/cjs/examples/plasma_web/components/Popup/Popup.stories.tsx +0 -3
  40. package/emotion/es/components/Attach/Attach.js +10 -7
  41. package/emotion/es/components/Attach/utils/addSeparator.js +9 -0
  42. package/emotion/es/components/Attach/utils/index.js +2 -1
  43. package/emotion/es/components/Popup/Popup.js +43 -30
  44. package/emotion/es/components/Popup/Popup.styles.js +16 -34
  45. package/emotion/es/components/Popup/PopupContext.js +11 -30
  46. package/emotion/es/components/Popup/PopupRoot.js +3 -1
  47. package/emotion/es/components/Popup/hooks/usePopup.js +3 -6
  48. package/emotion/es/examples/plasma_b2c/components/Modal/Modal.stories.tsx +0 -3
  49. package/emotion/es/examples/plasma_b2c/components/Popup/Popup.stories.tsx +0 -3
  50. package/emotion/es/examples/plasma_web/components/Modal/Modal.stories.tsx +0 -3
  51. package/emotion/es/examples/plasma_web/components/Popup/Popup.stories.tsx +0 -3
  52. package/es/components/Attach/Attach.js +13 -9
  53. package/es/components/Attach/Attach.js.map +1 -1
  54. package/es/components/Attach/utils/addSeparator.js +13 -0
  55. package/es/components/Attach/utils/addSeparator.js.map +1 -0
  56. package/es/components/Attach/utils/index.js +7 -0
  57. package/es/components/Attach/utils/index.js.map +1 -0
  58. package/es/components/Drawer/Drawer.css +3 -4
  59. package/es/components/Drawer/Drawer.js +1 -1
  60. package/es/components/Drawer/Drawer.styles.js +0 -3
  61. package/es/components/Drawer/Drawer.styles.js.map +1 -1
  62. package/es/components/Drawer/hooks/useDrawer.js +1 -1
  63. package/es/components/Modal/Modal.css +3 -4
  64. package/es/components/Modal/hooks/useModal.js +1 -1
  65. package/es/components/Notification/NotificationsProvider.css +3 -4
  66. package/es/components/Popup/Popup.css +3 -0
  67. package/es/components/Popup/Popup.js +43 -31
  68. package/es/components/Popup/Popup.js.map +1 -1
  69. package/es/components/Popup/Popup.styles.js +28 -54
  70. package/es/components/Popup/Popup.styles.js.map +1 -1
  71. package/es/components/Popup/Popup.styles_141jyqa.css +3 -0
  72. package/es/components/Popup/PopupContext.js +11 -31
  73. package/es/components/Popup/PopupContext.js.map +1 -1
  74. package/es/components/Popup/PopupRoot.js +1 -1
  75. package/es/components/Popup/PopupRoot.js.map +1 -1
  76. package/es/components/Popup/hooks/usePopup.js +3 -6
  77. package/es/components/Popup/hooks/usePopup.js.map +1 -1
  78. package/es/index.css +3 -4
  79. package/package.json +2 -2
  80. package/styled-components/cjs/components/Attach/Attach.js +9 -6
  81. package/styled-components/cjs/components/Attach/utils/addSeparator.js +15 -0
  82. package/styled-components/cjs/components/Attach/utils/index.js +9 -7
  83. package/styled-components/cjs/components/Popup/Popup.js +41 -29
  84. package/styled-components/cjs/components/Popup/Popup.styles.js +14 -23
  85. package/styled-components/cjs/components/Popup/PopupContext.js +10 -30
  86. package/styled-components/cjs/components/Popup/PopupRoot.js +3 -1
  87. package/styled-components/cjs/components/Popup/hooks/usePopup.js +3 -6
  88. package/styled-components/cjs/examples/plasma_b2c/components/Modal/Modal.stories.tsx +0 -3
  89. package/styled-components/cjs/examples/plasma_b2c/components/Popup/Popup.stories.tsx +0 -3
  90. package/styled-components/cjs/examples/plasma_web/components/Modal/Modal.stories.tsx +0 -3
  91. package/styled-components/cjs/examples/plasma_web/components/Popup/Popup.stories.tsx +0 -3
  92. package/styled-components/es/components/Attach/Attach.js +10 -7
  93. package/styled-components/es/components/Attach/utils/addSeparator.js +9 -0
  94. package/styled-components/es/components/Attach/utils/index.js +2 -1
  95. package/styled-components/es/components/Popup/Popup.js +43 -30
  96. package/styled-components/es/components/Popup/Popup.styles.js +13 -22
  97. package/styled-components/es/components/Popup/PopupContext.js +11 -30
  98. package/styled-components/es/components/Popup/PopupRoot.js +3 -1
  99. package/styled-components/es/components/Popup/hooks/usePopup.js +3 -6
  100. package/styled-components/es/examples/plasma_b2c/components/Modal/Modal.stories.tsx +0 -3
  101. package/styled-components/es/examples/plasma_b2c/components/Popup/Popup.stories.tsx +0 -3
  102. package/styled-components/es/examples/plasma_web/components/Modal/Modal.stories.tsx +0 -3
  103. package/styled-components/es/examples/plasma_web/components/Popup/Popup.stories.tsx +0 -3
  104. package/types/components/Attach/Attach.d.ts.map +1 -1
  105. package/types/components/Attach/utils/addSeparator.d.ts +2 -0
  106. package/types/components/Attach/utils/addSeparator.d.ts.map +1 -0
  107. package/types/components/Attach/utils/index.d.ts +2 -1
  108. package/types/components/Attach/utils/index.d.ts.map +1 -1
  109. package/types/components/Popup/Popup.d.ts +1 -1
  110. package/types/components/Popup/Popup.d.ts.map +1 -1
  111. package/types/components/Popup/Popup.styles.d.ts +1 -4
  112. package/types/components/Popup/Popup.styles.d.ts.map +1 -1
  113. package/types/components/Popup/Popup.types.d.ts +0 -3
  114. package/types/components/Popup/Popup.types.d.ts.map +1 -1
  115. package/types/components/Popup/PopupContext.d.ts.map +1 -1
  116. package/types/components/Popup/hooks/usePopup.d.ts +1 -2
  117. package/types/components/Popup/hooks/usePopup.d.ts.map +1 -1
  118. package/cjs/components/Attach/utils/truncateFilename.js +0 -24
  119. package/cjs/components/Attach/utils/truncateFilename.js.map +0 -1
  120. package/cjs/components/Popup/Popup.styles_1uw5px0.css +0 -4
  121. package/cjs/components/Popup/PopupContext.css +0 -4
  122. package/emotion/cjs/components/Attach/utils/truncateFilename.js +0 -23
  123. package/emotion/es/components/Attach/utils/truncateFilename.js +0 -17
  124. package/es/components/Attach/utils/truncateFilename.js +0 -20
  125. package/es/components/Attach/utils/truncateFilename.js.map +0 -1
  126. package/es/components/Popup/Popup.styles_1uw5px0.css +0 -4
  127. package/es/components/Popup/PopupContext.css +0 -4
  128. package/styled-components/cjs/components/Attach/utils/truncateFilename.js +0 -23
  129. package/styled-components/es/components/Attach/utils/truncateFilename.js +0 -17
  130. package/types/components/Attach/utils/truncateFilename.d.ts +0 -7
  131. package/types/components/Attach/utils/truncateFilename.d.ts.map +0 -1
@@ -6,11 +6,7 @@ Object.defineProperty(exports, "__esModule", {
6
6
  });
7
7
  exports.usePopupContext = exports.PopupProvider = exports.POPUP_PORTAL_ID = void 0;
8
8
  var _react = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("react"));
9
- var _reactDom = /*#__PURE__*/_interopRequireDefault( /*#__PURE__*/require("react-dom"));
10
9
  var _ModalContext = /*#__PURE__*/require("../Modal/ModalContext");
11
- var _utils = /*#__PURE__*/require("../../utils");
12
- var _Popup = /*#__PURE__*/require("./Popup.styles");
13
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
14
10
  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); }
15
11
  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; }
16
12
  function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
@@ -27,12 +23,9 @@ var POPUP_PORTAL_ID = exports.POPUP_PORTAL_ID = 'plasma-popup-root';
27
23
  var items = [];
28
24
  var PopupContext = /*#__PURE__*/(0, _react.createContext)({
29
25
  items: items,
30
- rootId: POPUP_PORTAL_ID,
31
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
32
26
  register: function register(_info) {
33
27
  throw new Error('Function not implemented. Add PopupProvider');
34
28
  },
35
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
36
29
  unregister: function unregister(_id) {
37
30
  throw new Error('Function not implemented. Add PopupProvider');
38
31
  }
@@ -42,46 +35,29 @@ var usePopupContext = exports.usePopupContext = function usePopupContext() {
42
35
  };
43
36
  var PopupProvider = exports.PopupProvider = function PopupProvider(_ref) {
44
37
  var children = _ref.children;
45
- var globalItemsCount = (0, _react.useRef)(0);
46
- var prevBodyOverflowY = (0, _react.useRef)(_utils.canUseDOM ? document.body.style.overflowY : '');
47
- // eslint-disable-next-line no-shadow
38
+ var prevBodyOverflowY = (0, _react.useRef)(typeof document !== 'undefined' ? document.body.style.overflowY : '');
48
39
  var _useState = (0, _react.useState)([]),
49
40
  _useState2 = _slicedToArray(_useState, 2),
50
41
  items = _useState2[0],
51
42
  setItems = _useState2[1];
52
- var uuid = (0, _utils.safeUseId)();
53
- var rootId = "".concat(POPUP_PORTAL_ID, "-").concat(uuid);
54
43
  var register = function register(info) {
55
- if (!_utils.canUseDOM) {
56
- return;
57
- }
58
44
  setItems(function (prevItems) {
59
45
  var _info$info;
60
46
  if ((_info$info = info.info) !== null && _info$info !== void 0 && _info$info.isModal && !(0, _ModalContext.hasModals)(prevItems)) {
61
47
  prevBodyOverflowY.current = document.body.style.overflowY;
62
48
  document.body.style.overflowY = 'hidden';
63
49
  }
64
- if (info.isGlobalPopup) {
65
- globalItemsCount.current += 1;
66
- }
67
50
  return [].concat(_toConsumableArray(prevItems), [info]);
68
51
  });
69
52
  };
70
53
  var unregister = function unregister(id) {
71
- if (!_utils.canUseDOM) {
72
- return;
73
- }
74
54
  setItems(function (prevItems) {
75
- var _prevItems$index;
76
55
  var index = prevItems.findIndex(function (item) {
77
56
  return id === item.id;
78
57
  });
79
58
  if (index === -1) {
80
59
  return prevItems;
81
60
  }
82
- if (prevItems !== null && prevItems !== void 0 && (_prevItems$index = prevItems[index]) !== null && _prevItems$index !== void 0 && _prevItems$index.isGlobalPopup) {
83
- globalItemsCount.current -= 1;
84
- }
85
61
  var prevHasModals = (0, _ModalContext.hasModals)(prevItems);
86
62
  prevItems.splice(index, 1);
87
63
  if (prevHasModals && !(0, _ModalContext.hasModals)(prevItems)) {
@@ -94,14 +70,18 @@ var PopupProvider = exports.PopupProvider = function PopupProvider(_ref) {
94
70
  };
95
71
  var context = {
96
72
  items: items,
97
- rootId: rootId,
98
73
  register: register,
99
74
  unregister: unregister
100
75
  };
76
+ (0, _react.useEffect)(function () {
77
+ return function () {
78
+ var portal = document.createElement('div');
79
+ if (portal && document.body.contains(portal)) {
80
+ document.body.removeChild(portal);
81
+ }
82
+ };
83
+ }, []);
101
84
  return /*#__PURE__*/_react["default"].createElement(PopupContext.Provider, {
102
85
  value: context
103
- }, children, /*#__PURE__*/_reactDom["default"].createPortal( /*#__PURE__*/_react["default"].createElement(_Popup.StyledPortal, {
104
- id: rootId,
105
- hasContent: globalItemsCount.current > 0
106
- }), document.body));
86
+ }, children);
107
87
  };
@@ -10,7 +10,7 @@ var _plasmaCore = /*#__PURE__*/require("@salutejs/plasma-core");
10
10
  var _PopupContext = /*#__PURE__*/require("./PopupContext");
11
11
  var _Popup = /*#__PURE__*/require("./Popup.styles");
12
12
  var _Popup2 = /*#__PURE__*/require("./Popup.tokens");
13
- var _excluded = ["id", "placement", "offset", "setVisible", "children", "role", "zIndex", "animationInfo"];
13
+ var _excluded = ["id", "placement", "offset", "frame", "setVisible", "children", "role", "zIndex", "animationInfo", "className"];
14
14
  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); }
15
15
  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; }
16
16
  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); }
@@ -24,11 +24,13 @@ var PopupRoot = exports.PopupRoot = /*#__PURE__*/(0, _react.forwardRef)(function
24
24
  var id = _ref.id,
25
25
  placement = _ref.placement,
26
26
  offset = _ref.offset,
27
+ frame = _ref.frame,
27
28
  setVisible = _ref.setVisible,
28
29
  children = _ref.children,
29
30
  role = _ref.role,
30
31
  zIndex = _ref.zIndex,
31
32
  animationInfo = _ref.animationInfo,
33
+ className = _ref.className,
32
34
  rest = _objectWithoutProperties(_ref, _excluded);
33
35
  var contentRef = (0, _react.useRef)(null);
34
36
  var innerRef = (0, _plasmaCore.useForkRef)(contentRef, ref);
@@ -18,7 +18,7 @@ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o =
18
18
  function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
19
19
  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; } }
20
20
  function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
21
- // Хук для подключения анимации
21
+ // Хук для поключения анимации
22
22
  var usePopupAnimation = function usePopupAnimation() {
23
23
  var _useState = (0, _react.useState)(false),
24
24
  _useState2 = _slicedToArray(_useState, 2),
@@ -40,7 +40,6 @@ var usePopupAnimation = function usePopupAnimation() {
40
40
  var usePopup = exports.usePopup = function usePopup(_ref) {
41
41
  var isOpen = _ref.isOpen,
42
42
  id = _ref.id,
43
- isGlobalPopup = _ref.isGlobalPopup,
44
43
  popupInfo = _ref.popupInfo,
45
44
  withAnimation = _ref.withAnimation;
46
45
  var _useState5 = (0, _react.useState)(false),
@@ -62,8 +61,7 @@ var usePopup = exports.usePopup = function usePopup(_ref) {
62
61
  // при первом открытии
63
62
  if (isOpen && !isVisible) {
64
63
  popupController.register(_objectSpread({
65
- id: id,
66
- isGlobalPopup: isGlobalPopup
64
+ id: id
67
65
  }, popupInfo));
68
66
  setVisible(true);
69
67
  animationInfo.setEndAnimation(false);
@@ -92,7 +90,6 @@ var usePopup = exports.usePopup = function usePopup(_ref) {
92
90
  isVisible: isVisible,
93
91
  setVisible: setVisible,
94
92
  animationInfo: animationInfo,
95
- withAnimation: withAnimation,
96
- rootId: popupController.rootId
93
+ withAnimation: withAnimation
97
94
  };
98
95
  };
@@ -14,9 +14,6 @@ import { Modal, modalClasses } from './Modal';
14
14
  export default {
15
15
  title: 'plasma_b2c/Modal',
16
16
  decorators: [WithTheme],
17
- parameters: {
18
- docs: { story: { inline: false, iframeHeight: '30rem' } },
19
- },
20
17
  argTypes: {
21
18
  placement: {
22
19
  options: [
@@ -12,9 +12,6 @@ import { Popup, popupClasses, PopupProvider } from './Popup';
12
12
  const meta: Meta<typeof Popup> = {
13
13
  title: 'plasma_b2c/Popup',
14
14
  decorators: [WithTheme],
15
- parameters: {
16
- docs: { story: { inline: false, iframeHeight: '30rem' } },
17
- },
18
15
  argTypes: {
19
16
  placement: {
20
17
  options: [
@@ -14,9 +14,6 @@ import { Modal, modalClasses } from './Modal';
14
14
  export default {
15
15
  title: 'plasma_web/Modal',
16
16
  decorators: [WithTheme],
17
- parameters: {
18
- docs: { story: { inline: false, iframeHeight: '30rem' } },
19
- },
20
17
  argTypes: {
21
18
  placement: {
22
19
  options: [
@@ -12,9 +12,6 @@ import { Popup, popupClasses, PopupProvider } from './Popup';
12
12
  const meta: Meta<typeof Popup> = {
13
13
  title: 'plasma_web/Popup',
14
14
  decorators: [WithTheme],
15
- parameters: {
16
- docs: { story: { inline: false, iframeHeight: '30rem' } },
17
- },
18
15
  argTypes: {
19
16
  placement: {
20
17
  options: [
@@ -17,7 +17,7 @@ import { base as sizeCSS } from './variations/_size/base';
17
17
  import { base as viewCSS } from './variations/_view/base';
18
18
  import { base, StyledHiddenInput, StyledHiddenInputHelper } from './Attach.styles';
19
19
  import { StyledCell } from './ui/Cell/Cell';
20
- import { extractExtension, getFileicon, truncateFilename } from './utils';
20
+ import { extractExtension, getFileicon, addSeparator, separator } from './utils';
21
21
  import { classes } from './Attach.tokens';
22
22
  import { AttachButton } from './components/AttachButton';
23
23
  import { StyledIconButtonCancel } from './ui/IconButton/IconButton.styles';
@@ -76,15 +76,18 @@ export var attachRoot = function attachRoot(Root) {
76
76
  cellLeft = _cellRef$current$getB.left;
77
77
  var leftDiff = cellLeft - parentLeft;
78
78
  var currentTextWidth = textWidth;
79
- var currFilename = filename;
80
- for (var i = filename.length - 1; i > 0; i -= 1) {
79
+ if (currentTextWidth + emptyTextCellWidth.current + leftDiff <= parentWidth || currentTextWidth + emptyTextCellWidth.current < buttonWidth) {
80
+ setTruncatedFilename(filename);
81
+ return;
82
+ }
83
+ var currFilename = addSeparator(filename, separator);
84
+ for (var i = currFilename.indexOf(separator) - 1; i > 0; i -= 1) {
81
85
  if (currentTextWidth + emptyTextCellWidth.current + leftDiff <= parentWidth) {
82
86
  break;
83
87
  }
84
- var newFilename = truncateFilename({
85
- filename: inputHelperRef.current.textContent,
86
- startNameTruncationIndex: i
87
- });
88
+ var left = currFilename.slice(0, i);
89
+ var right = currFilename.slice(i + 1);
90
+ var newFilename = "".concat(left).concat(right);
88
91
  inputHelperRef.current.textContent = newFilename;
89
92
  currentTextWidth = inputHelperRef.current.offsetWidth;
90
93
  if (currentTextWidth + emptyTextCellWidth.current < buttonWidth) {
@@ -0,0 +1,9 @@
1
+ import { extractExtension } from './extractExtension';
2
+ export var addSeparator = function addSeparator(filename, separator) {
3
+ var extension = extractExtension(filename);
4
+ var strings = filename.split('.');
5
+ var name = strings.length > 1 ? strings.slice(0, -1).join('.') : strings[0];
6
+ var lastChar = name[name.length - 1];
7
+ var dotChar = '.';
8
+ return extension === name ? "".concat(name.slice(0, -1)).concat(separator).concat(lastChar) : "".concat(name.slice(0, -1)).concat(separator).concat(lastChar).concat(dotChar).concat(extension);
9
+ };
@@ -1,3 +1,4 @@
1
1
  export { extractExtension } from './extractExtension';
2
2
  export { getFileicon } from './getFileicon';
3
- export { truncateFilename } from './truncateFilename';
3
+ export { addSeparator } from './addSeparator';
4
+ export var separator = '...';
@@ -8,15 +8,14 @@ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o =
8
8
  function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
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
- import React, { forwardRef, useRef } from 'react';
12
- import ReactDOM from 'react-dom';
11
+ import React, { forwardRef, useEffect, useRef, useState } from 'react';
13
12
  import { useForkRef, safeUseId } from '@salutejs/plasma-core';
14
- import { canUseDOM, cx } from '../../utils';
13
+ import { cx } from '../../utils';
15
14
  import { Portal } from '../Portal';
15
+ import { POPUP_PORTAL_ID } from './PopupContext';
16
16
  import { PopupRoot } from './PopupRoot';
17
17
  import { usePopup } from './hooks';
18
18
  import { classes } from './Popup.tokens';
19
- import { StyledPortalContainer } from './Popup.styles';
20
19
  export var handlePosition = function handlePosition(placement, offset) {
21
20
  var x = '0rem';
22
21
  var y = '0rem';
@@ -40,8 +39,8 @@ export var handlePosition = function handlePosition(placement, offset) {
40
39
  var bottom;
41
40
  var transform;
42
41
  var placements = placement.split('-');
43
- placements.forEach(function (placementValue) {
44
- switch (placementValue) {
42
+ placements.forEach(function (placement) {
43
+ switch (placement) {
45
44
  case 'left':
46
45
  left = x;
47
46
  break;
@@ -76,7 +75,7 @@ export var handlePosition = function handlePosition(placement, offset) {
76
75
  };
77
76
 
78
77
  /**
79
- * Базовый компонент Popup.
78
+ * Базовый копмонент Popup.
80
79
  */
81
80
  export var popupRoot = function popupRoot(Root) {
82
81
  return /*#__PURE__*/forwardRef(function (_ref, outerRootRef) {
@@ -106,49 +105,63 @@ export var popupRoot = function popupRoot(Root) {
106
105
  var _usePopup = usePopup({
107
106
  isOpen: innerIsOpen,
108
107
  id: innerId,
109
- isGlobalPopup: !frame || frame === 'document',
110
108
  popupInfo: popupInfo,
111
109
  withAnimation: withAnimation
112
110
  }),
113
111
  isVisible = _usePopup.isVisible,
114
112
  animationInfo = _usePopup.animationInfo,
115
- setVisible = _usePopup.setVisible,
116
- rootId = _usePopup.rootId;
113
+ setVisible = _usePopup.setVisible;
117
114
  var portalRef = useRef(null);
118
115
  var contentRef = useRef(null);
119
116
  var innerRef = useForkRef(contentRef, outerRootRef);
117
+ var _useState = useState(false),
118
+ _useState2 = _slicedToArray(_useState, 2),
119
+ forceRender = _useState2[1];
120
+ useEffect(function () {
121
+ var portal = document.getElementById(POPUP_PORTAL_ID);
122
+ if (typeof frame !== 'string' && frame && frame.current) {
123
+ portal = frame.current;
124
+ }
125
+ if (!portal) {
126
+ portal = document.createElement('div');
127
+ portal.setAttribute('id', POPUP_PORTAL_ID);
128
+ /**
129
+ * Нужно для того, чтобы во фрейме не происходило скачков контента
130
+ * при анимации через transform, если есть элемент с шириной/высотой в 100% (Overlay)
131
+ */
132
+ portal.style.width = '0';
133
+ if (typeof frame === 'string' && frame !== 'document') {
134
+ var _document$getElementB;
135
+ (_document$getElementB = document.getElementById(frame)) === null || _document$getElementB === void 0 || _document$getElementB.appendChild(portal);
136
+ } else {
137
+ document.body.appendChild(portal);
138
+ }
139
+ }
140
+ portalRef.current = portal;
141
+
142
+ /**
143
+ * Изменение стейта нужно для того, чтобы Popup
144
+ * отобразился после записи DOM элемента в portalRef.current
145
+ */
146
+ forceRender(true);
147
+ }, []);
120
148
  if (!isVisible && !innerIsOpen) {
121
149
  return null;
122
150
  }
123
151
  var cls = cx(className, animationInfo !== null && animationInfo !== void 0 && animationInfo.endAnimation ? classes.endAnimation : '', animationInfo !== null && animationInfo !== void 0 && animationInfo.endTransition ? classes.endTransition : '');
124
- var rootNode = /*#__PURE__*/React.createElement(Root, _extends({
152
+ return /*#__PURE__*/React.createElement(React.Fragment, null, portalRef.current && /*#__PURE__*/React.createElement(Portal, {
153
+ container: portalRef.current
154
+ }, /*#__PURE__*/React.createElement(Root, _extends({
125
155
  className: cls
126
156
  }, rest), overlay, /*#__PURE__*/React.createElement(PopupRoot, {
127
157
  id: innerId,
128
158
  ref: innerRef,
129
159
  position: handlePosition(placement, offset),
160
+ frame: frame,
130
161
  zIndex: zIndex,
131
162
  animationInfo: animationInfo,
132
163
  setVisible: setVisible
133
- }, children));
134
- if (typeof frame !== 'string' && frame && frame.current) {
135
- return /*#__PURE__*/React.createElement(Portal, {
136
- container: frame.current
137
- }, rootNode);
138
- }
139
- var withFrameId = typeof frame === 'string' && frame !== 'document';
140
- var containerElement = withFrameId && document.getElementById(frame);
141
- if (containerElement) {
142
- return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/ReactDOM.createPortal( /*#__PURE__*/React.createElement(StyledPortalContainer, {
143
- ref: portalRef
144
- }, portalRef.current && /*#__PURE__*/React.createElement(Portal, {
145
- container: portalRef.current
146
- }, rootNode)), containerElement));
147
- }
148
- var globalPortal = canUseDOM && document.getElementById(rootId);
149
- return /*#__PURE__*/React.createElement(React.Fragment, null, globalPortal && /*#__PURE__*/React.createElement(Portal, {
150
- container: globalPortal
151
- }, rootNode));
164
+ }, children))));
152
165
  });
153
166
  };
154
167
  export var popupConfig = {
@@ -2,27 +2,9 @@ import _styled from "@emotion/styled/base";
2
2
  function _EMOTION_STRINGIFIED_CSS_ERROR__() { return "You have tried to stringify object returned from `css` function. It isn't supposed to be used directly (e.g. as value of the `className` prop), but rather handed to emotion so it can handle it (e.g. as value of `css` prop)."; }
3
3
  import { DEFAULT_Z_INDEX } from './utils';
4
4
  export var StyledPortal = /*#__PURE__*/_styled("div", {
5
- target: "eaqy7mk3",
6
- label: "plasma-new-hope__StyledPortal"
7
- })("position:fixed;top:0;left:0;right:0;bottom:0;z-index:", DEFAULT_Z_INDEX, ";width:", function (_ref) {
8
- var hasContent = _ref.hasContent;
9
- return hasContent ? 'auto' : '0';
10
- }, ";pointer-events:", function (_ref2) {
11
- var hasContent = _ref2.hasContent;
12
- return hasContent ? 'auto' : 'none';
13
- }, ";" + (process.env.NODE_ENV === "production" ? "" : "/*# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIi4uLy4uLy4uLy4uL3NyYy1lbW90aW9uL2NvbXBvbmVudHMvUG9wdXAvUG9wdXAuc3R5bGVzLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUsrRCIsImZ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zPmBcbiAgICBwb3NpdGlvbjogYWJzb2x1dGU7XG4gICAgei1pbmRleDogJHsoeyB6SW5kZXggfSkgPT4gekluZGV4IHx8IERFRkFVTFRfWl9JTkRFWH07XG4gICAgbGVmdDogJHsoeyBwb3NpdGlvbiB9KSA9PiBwb3NpdGlvbi5sZWZ0IHx8ICcnfTtcbiAgICByaWdodDogJHsoeyBwb3NpdGlvbiB9KSA9PiBwb3NpdGlvbi5yaWdodCB8fCAnJ307XG4gICAgdG9wOiAkeyh7IHBvc2l0aW9uIH0pID0+IHBvc2l0aW9uLnRvcCB8fCAnJ307XG4gICAgYm90dG9tOiAkeyh7IHBvc2l0aW9uIH0pID0+IHBvc2l0aW9uLmJvdHRvbSB8fCAnJ307XG4gICAgdHJhbnNmb3JtOiAkeyh7IHBvc2l0aW9uIH0pID0+IHBvc2l0aW9uLnRyYW5zZm9ybSB8fCAnJ307XG5gO1xuIl19 */"));
14
- export var StyledPortalContainer = /*#__PURE__*/_styled("div", {
15
5
  target: "eaqy7mk2",
16
- label: "plasma-new-hope__StyledPortalContainer"
17
- })(process.env.NODE_ENV === "production" ? {
18
- name: "k2uqvh",
19
- styles: "width:0"
20
- } : {
21
- name: "k2uqvh",
22
- styles: "width:0",
23
- map: "/*# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIi4uLy4uLy4uLy4uL3NyYy1lbW90aW9uL2NvbXBvbmVudHMvUG9wdXAvUG9wdXAuc3R5bGVzLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQWlCK0MiLCJmaWxlIjoiLi4vLi4vLi4vLi4vc3JjLWVtb3Rpb24vY29tcG9uZW50cy9Qb3B1cC9Qb3B1cC5zdHlsZXMudHMiLCJzb3VyY2VzQ29udGVudCI6WyJpbXBvcnQgc3R5bGVkIGZyb20gJ0BlbW90aW9uL3N0eWxlZCc7XG5cbmltcG9ydCB0eXBlIHsgUG9wdXBSb290Q29udGFpbm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G9zaXRpb24gfSkgPT4gcG9zaXRpb24ucmlnaHQgfHwgJyd9O1xuICAgIHRvcDogJHsoeyBwb3NpdGlvbiB9KSA9PiBwb3NpdGlvbi50b3AgfHwgJyd9O1xuICAgIGJvdHRvbTogJHsoeyBwb3NpdGlvbiB9KSA9PiBwb3NpdGlvbi5ib3R0b20gfHwgJyd9O1xuICAgIHRyYW5zZm9ybTogJHsoeyBwb3NpdGlvbiB9KSA9PiBwb3NpdGlvbi50cmFuc2Zvcm0gfHwgJyd9O1xuYDtcbiJdfQ== */",
24
- toString: _EMOTION_STRINGIFIED_CSS_ERROR__
25
- });
6
+ label: "plasma-new-hope__StyledPortal"
7
+ })(process.env.NODE_ENV === "production" ? "" : "/*# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIi4uLy4uLy4uLy4uL3NyYy1lbW90aW9uL2NvbXBvbmVudHMvUG9wdXAvUG9wdXAuc3R5bGVzLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUtzQyIsImZpbGUiOiIuLi8uLi8uLi8uLi9zcmMtZW1vdGlvbi9jb21wb25lbnRzL1BvcHVwL1BvcHVwLnN0eWxlcy50cyIsInNvdXJjZXNDb250ZW50IjpbImltcG9ydCBzdHlsZWQgZnJvbSAnQGVtb3Rpb24vc3R5bGVkJztcblxuaW1wb3J0IHR5cGUgeyBQb3B1cFJvb3RDb250YWluZXJQcm9wcyB9IGZyb20gJy4vUG9wdXAudHlwZXMnO1xuaW1wb3J0IHsgREVGQVVMVF9aX0lOREVYIH0gZnJvbSAnLi91dGlscyc7XG5cbmV4cG9ydCBjb25zdCBTdHlsZWRQb3J0YWwgPSBzdHlsZWQuZGl2YGA7XG5cbmV4cG9ydCBjb25zdCBQb3B1cFZpZXcgPSBzdHlsZWQuZGl2YFxuICAgIHBvc2l0aW9uOiByZWxhdGl2ZTtcbiAgICBtYXgtd2lkdGg6IDEwMCU7XG4gICAgcG9pbnRlci1ldmVudHM6IGFsbDtcbmA7XG5cbmV4cG9ydCBjb25zdCBQb3B1cFJvb3RDb250YWluZXIgPSBzdHlsZWQuZGl2PFBvcHVwUm9vdENvbnRhaW5lclByb3BzPmBcbiAgICBwb3NpdGlvbjogYWJzb2x1dGU7XG4gICAgei1pbmRleDogJHsoeyB6SW5kZXggfSkgPT4gekluZGV4IHx8IERFRkFVTFRfWl9JTkRFWH07XG4gICAgbGVmdDogJHsoeyBwb3NpdGlvbiB9KSA9PiBwb3NpdGlvbi5sZWZ0IHx8ICcnfTtcbiAgICByaWdodDogJHsoeyBwb3NpdGlvbiB9KSA9PiBwb3NpdGlvbi5yaWdodCB8fCAnJ307XG4gICAgdG9wOiAkeyh7IHBvc2l0aW9uIH0pID0+IHBvc2l0aW9uLnRvcCB8fCAnJ307XG4gICAgYm90dG9tOiAkeyh7IHBvc2l0aW9uIH0pID0+IHBvc2l0aW9uLmJvdHRvbSB8fCAnJ307XG4gICAgdHJhbnNmb3JtOiAkeyh7IHBvc2l0aW9uIH0pID0+IHBvc2l0aW9uLnRyYW5zZm9ybSB8fCAnJ307XG5gO1xuIl19 */");
26
8
  export var PopupView = /*#__PURE__*/_styled("div", {
27
9
  target: "eaqy7mk1",
28
10
  label: "plasma-new-hope__PopupView"
@@ -32,28 +14,28 @@ export var PopupView = /*#__PURE__*/_styled("div", {
32
14
  } : {
33
15
  name: "1m82nn4",
34
16
  styles: "position:relative;max-width:100%;pointer-events:all",
35
- map: "/*# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIi4uLy4uLy4uLy4uL3NyYy1lbW90aW9uL2NvbXBvbmVudHMvUG9wdXAvUG9wdXAuc3R5bGVzLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQXFCbUMiLCJmaWxlIjoiLi4vLi4vLi4vLi4vc3JjLWVtb3Rpb24vY29tcG9uZW50cy9Qb3B1cC9Qb3B1cC5zdHlsZXMud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gICBtYXgtd2lkdGg6IDEwMCU7XG4gICAgcG9pbnRlci1ldmVudHM6IGFsbDtcbmA7XG5cbmV4cG9ydCBjb25zdCBQb3B1cFJvb3RDb250YWluZXIgPSBzdHlsZWQuZGl2PFBvcHVwUm9vdENvbnRhaW5lclByb3BzPmBcbiAgICBwb3NpdGlvbjogYWJzb2x1dGU7XG4gICAgei1pbmRleDogJHsoeyB6SW5kZXggfSkgPT4gekluZGV4IHx8IERFRkFVTFRfWl9JTkRFWH07XG4gICAgbGVmdDogJHsoeyBwb3NpdGlvbiB9KSA9PiBwb3NpdGlvbi5sZWZ0IHx8ICcnfTtcbiAgICByaWdodDogJHsoeyBwb3NpdGlvbiB9KSA9PiBwb3NpdGlvbi5yaWdodCB8fCAnJ307XG4gICAgdG9wOiAkeyh7IHBvc2l0aW9uIH0pID0+IHBvc2l0aW9uLnRvcCB8fCAnJ307XG4gICAgYm90dG9tOiAkeyh7IHBvc2l0aW9uIH0pID0+IHBvc2l0aW9uLmJvdHRvbSB8fCAnJ307XG4gICAgdHJhbnNmb3JtOiAkeyh7IHBvc2l0aW9uIH0pID0+IHBvc2l0aW9uLnRyYW5zZm9ybSB8fCAnJ307XG5gO1xuIl19 */",
36
18
  toString: _EMOTION_STRINGIFIED_CSS_ERROR__
37
19
  });
38
20
  export var PopupRootContainer = /*#__PURE__*/_styled("div", {
39
21
  target: "eaqy7mk0",
40
22
  label: "plasma-new-hope__PopupRootContainer"
41
- })("position:absolute;z-index:", function (_ref3) {
42
- var zIndex = _ref3.zIndex;
23
+ })("position:absolute;z-index:", function (_ref) {
24
+ var zIndex = _ref.zIndex;
43
25
  return zIndex || DEFAULT_Z_INDEX;
44
- }, ";left:", function (_ref4) {
45
- var position = _ref4.position;
26
+ }, ";left:", function (_ref2) {
27
+ var position = _ref2.position;
46
28
  return position.left || '';
47
- }, ";right:", function (_ref5) {
48
- var position = _ref5.position;
29
+ }, ";right:", function (_ref3) {
30
+ var position = _ref3.position;
49
31
  return position.right || '';
50
- }, ";top:", function (_ref6) {
51
- var position = _ref6.position;
32
+ }, ";top:", function (_ref4) {
33
+ var position = _ref4.position;
52
34
  return position.top || '';
53
- }, ";bottom:", function (_ref7) {
54
- var position = _ref7.position;
35
+ }, ";bottom:", function (_ref5) {
36
+ var position = _ref5.position;
55
37
  return position.bottom || '';
56
- }, ";transform:", function (_ref8) {
57
- var position = _ref8.position;
38
+ }, ";transform:", function (_ref6) {
39
+ var position = _ref6.position;
58
40
  return position.transform || '';
59
- }, ";" + (process.env.NODE_ENV === "production" ? "" : "/*# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIi4uLy4uLy4uLy4uL3NyYy1lbW90aW9uL2NvbXBvbmVudHMvUG9wdXAvUG9wdXAuc3R5bGVzLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQTJCcUUiLCJmaWxlIjoiLi4vLi4vLi4vLi4vc3JjLWVtb3Rpb24vY29tcG9uZW50cy9Qb3B1cC9Qb3B1cC5zdHlsZXMudHMiLCJzb3VyY2VzQ29udGVudCI6WyJpbXBvcnQgc3R5bGVkIGZyb20gJ0BlbW90aW9uL3N0eWxlZCc7XG5cbmltcG9ydCB0eXBlIHsgUG9wdXBSb290Q29udGFpbmVyUHJvcHMgfSBmcm9tICcuL1BvcHVwLnR5cGVzJztcbmltcG9ydCB7IERFRkFVTFRfWl9JTkRFWCB9IGZyb20gJy4vdXRpbHMnO1xuXG5leHBvcnQgY29uc3QgU3R5bGVkUG9ydGFsID0gc3R5bGVkLmRpdjx7IGhhc0NvbnRlbnQ6IGJvb2xlYW4gfT5gXG4gICAgcG9zaXRpb246IGZpeGVkO1xuICAgIHRvcDogMDtcbiAgICBsZWZ0OiAwO1xuICAgIHJpZ2h0OiAwO1xuICAgIGJvdHRvbTogMDtcbiAgICB6LWluZGV4OiAke0RFRkFVTFRfWl9JTkRFWH07XG5cbiAgICB3aWR0aDogJHsoeyBoYXNDb250ZW50IH0pID0+IChoYXNDb250ZW50ID8gJ2F1dG8nIDogJzAnKX07XG4gICAgcG9pbnRlci1ldmVudHM6ICR7KHsgaGFzQ29udGVudCB9KSA9PiAoaGFzQ29udGVudCA/ICdhdXRvJyA6ICdub25lJyl9O1xuYDtcblxuZXhwb3J0IGNvbnN0IFN0eWxlZFBvcnRhbENvbnRhaW5lciA9IHN0eWxlZC5kaXZgXG4gICAgd2lkdGg6IDA7XG5gO1xuXG5leHBvcnQgY29uc3QgUG9wdXBWaWV3ID0gc3R5bGVkLmRpdmBcbiAgICBwb3NpdGlvbjogcmVsYXRpdmU7XG4gICAgbWF4LXdpZHRoOiAxMDAlO1xuICAgIHBvaW50ZXItZXZlbnRzOiBhbGw7XG5gO1xuXG5leHBvcnQgY29uc3QgUG9wdXBSb290Q29udGFpbmVyID0gc3R5bGVkLmRpdjxQb3B1cFJvb3RDb250YWluZXJQcm9wcz5gXG4gICAgcG9zaXRpb246IGFic29sdXRlO1xuICAgIHotaW5kZXg6ICR7KHsgekluZGV4IH0pID0+IHpJbmRleCB8fCBERUZBVUxUX1pfSU5ERVh9O1xuICAgIGxlZnQ6ICR7KHsgcG9zaXRpb24gfSkgPT4gcG9zaXRpb24ubGVmdCB8fCAnJ307XG4gICAgcmlnaHQ6ICR7KHsgcG9zaXRpb24gfSkgPT4gcG9zaXRpb24ucmlnaHQgfHwgJyd9O1xuICAgIHRvcDogJHsoeyBwb3NpdGlvbiB9KSA9PiBwb3NpdGlvbi50b3AgfHwgJyd9O1xuICAgIGJvdHRvbTogJHsoeyBwb3NpdGlvbiB9KSA9PiBwb3NpdGlvbi5ib3R0b20gfHwgJyd9O1xuICAgIHRyYW5zZm9ybTogJHsoeyBwb3NpdGlvbiB9KSA9PiBwb3NpdGlvbi50cmFuc2Zvcm0gfHwgJyd9O1xuYDtcbiJdfQ== */"));
41
+ }, ";" + (process.env.NODE_ENV === "production" ? "" : "/*# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9u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AnJ307XG4gICAgYm90dG9tOiAkeyh7IHBvc2l0aW9uIH0pID0+IHBvc2l0aW9uLmJvdHRvbSB8fCAnJ307XG4gICAgdHJhbnNmb3JtOiAkeyh7IHBvc2l0aW9uIH0pID0+IHBvc2l0aW9uLnRyYW5zZm9ybSB8fCAnJ307XG5gO1xuIl19 */"));
@@ -8,21 +8,15 @@ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o =
8
8
  function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
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
- import React, { createContext, useState, useContext, useRef } from 'react';
12
- import ReactDOM from 'react-dom';
11
+ import React, { createContext, useEffect, useState, useContext, useRef } from 'react';
13
12
  import { hasModals } from '../Modal/ModalContext';
14
- import { canUseDOM, safeUseId } from '../../utils';
15
- import { StyledPortal } from './Popup.styles';
16
13
  export var POPUP_PORTAL_ID = 'plasma-popup-root';
17
14
  var items = [];
18
15
  var PopupContext = /*#__PURE__*/createContext({
19
16
  items: items,
20
- rootId: POPUP_PORTAL_ID,
21
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
22
17
  register: function register(_info) {
23
18
  throw new Error('Function not implemented. Add PopupProvider');
24
19
  },
25
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
26
20
  unregister: function unregister(_id) {
27
21
  throw new Error('Function not implemented. Add PopupProvider');
28
22
  }
@@ -32,46 +26,29 @@ export var usePopupContext = function usePopupContext() {
32
26
  };
33
27
  export var PopupProvider = function PopupProvider(_ref) {
34
28
  var children = _ref.children;
35
- var globalItemsCount = useRef(0);
36
- var prevBodyOverflowY = useRef(canUseDOM ? document.body.style.overflowY : '');
37
- // eslint-disable-next-line no-shadow
29
+ var prevBodyOverflowY = useRef(typeof document !== 'undefined' ? document.body.style.overflowY : '');
38
30
  var _useState = useState([]),
39
31
  _useState2 = _slicedToArray(_useState, 2),
40
32
  items = _useState2[0],
41
33
  setItems = _useState2[1];
42
- var uuid = safeUseId();
43
- var rootId = "".concat(POPUP_PORTAL_ID, "-").concat(uuid);
44
34
  var register = function register(info) {
45
- if (!canUseDOM) {
46
- return;
47
- }
48
35
  setItems(function (prevItems) {
49
36
  var _info$info;
50
37
  if ((_info$info = info.info) !== null && _info$info !== void 0 && _info$info.isModal && !hasModals(prevItems)) {
51
38
  prevBodyOverflowY.current = document.body.style.overflowY;
52
39
  document.body.style.overflowY = 'hidden';
53
40
  }
54
- if (info.isGlobalPopup) {
55
- globalItemsCount.current += 1;
56
- }
57
41
  return [].concat(_toConsumableArray(prevItems), [info]);
58
42
  });
59
43
  };
60
44
  var unregister = function unregister(id) {
61
- if (!canUseDOM) {
62
- return;
63
- }
64
45
  setItems(function (prevItems) {
65
- var _prevItems$index;
66
46
  var index = prevItems.findIndex(function (item) {
67
47
  return id === item.id;
68
48
  });
69
49
  if (index === -1) {
70
50
  return prevItems;
71
51
  }
72
- if (prevItems !== null && prevItems !== void 0 && (_prevItems$index = prevItems[index]) !== null && _prevItems$index !== void 0 && _prevItems$index.isGlobalPopup) {
73
- globalItemsCount.current -= 1;
74
- }
75
52
  var prevHasModals = hasModals(prevItems);
76
53
  prevItems.splice(index, 1);
77
54
  if (prevHasModals && !hasModals(prevItems)) {
@@ -84,14 +61,18 @@ export var PopupProvider = function PopupProvider(_ref) {
84
61
  };
85
62
  var context = {
86
63
  items: items,
87
- rootId: rootId,
88
64
  register: register,
89
65
  unregister: unregister
90
66
  };
67
+ useEffect(function () {
68
+ return function () {
69
+ var portal = document.createElement('div');
70
+ if (portal && document.body.contains(portal)) {
71
+ document.body.removeChild(portal);
72
+ }
73
+ };
74
+ }, []);
91
75
  return /*#__PURE__*/React.createElement(PopupContext.Provider, {
92
76
  value: context
93
- }, children, /*#__PURE__*/ReactDOM.createPortal( /*#__PURE__*/React.createElement(StyledPortal, {
94
- id: rootId,
95
- hasContent: globalItemsCount.current > 0
96
- }), document.body));
77
+ }, children);
97
78
  };
@@ -1,4 +1,4 @@
1
- var _excluded = ["id", "placement", "offset", "setVisible", "children", "role", "zIndex", "animationInfo"];
1
+ var _excluded = ["id", "placement", "offset", "frame", "setVisible", "children", "role", "zIndex", "animationInfo", "className"];
2
2
  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); }
3
3
  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; }
4
4
  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; }
@@ -16,11 +16,13 @@ export var PopupRoot = /*#__PURE__*/forwardRef(function (_ref, ref) {
16
16
  var id = _ref.id,
17
17
  placement = _ref.placement,
18
18
  offset = _ref.offset,
19
+ frame = _ref.frame,
19
20
  setVisible = _ref.setVisible,
20
21
  children = _ref.children,
21
22
  role = _ref.role,
22
23
  zIndex = _ref.zIndex,
23
24
  animationInfo = _ref.animationInfo,
25
+ className = _ref.className,
24
26
  rest = _objectWithoutProperties(_ref, _excluded);
25
27
  var contentRef = useRef(null);
26
28
  var innerRef = useForkRef(contentRef, ref);
@@ -13,7 +13,7 @@ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
13
13
  import { useEffect, useState } from 'react';
14
14
  import { usePopupContext } from '../PopupContext';
15
15
 
16
- // Хук для подключения анимации
16
+ // Хук для поключения анимации
17
17
  var usePopupAnimation = function usePopupAnimation() {
18
18
  var _useState = useState(false),
19
19
  _useState2 = _slicedToArray(_useState, 2),
@@ -35,7 +35,6 @@ var usePopupAnimation = function usePopupAnimation() {
35
35
  export var usePopup = function usePopup(_ref) {
36
36
  var isOpen = _ref.isOpen,
37
37
  id = _ref.id,
38
- isGlobalPopup = _ref.isGlobalPopup,
39
38
  popupInfo = _ref.popupInfo,
40
39
  withAnimation = _ref.withAnimation;
41
40
  var _useState5 = useState(false),
@@ -57,8 +56,7 @@ export var usePopup = function usePopup(_ref) {
57
56
  // при первом открытии
58
57
  if (isOpen && !isVisible) {
59
58
  popupController.register(_objectSpread({
60
- id: id,
61
- isGlobalPopup: isGlobalPopup
59
+ id: id
62
60
  }, popupInfo));
63
61
  setVisible(true);
64
62
  animationInfo.setEndAnimation(false);
@@ -87,7 +85,6 @@ export var usePopup = function usePopup(_ref) {
87
85
  isVisible: isVisible,
88
86
  setVisible: setVisible,
89
87
  animationInfo: animationInfo,
90
- withAnimation: withAnimation,
91
- rootId: popupController.rootId
88
+ withAnimation: withAnimation
92
89
  };
93
90
  };
@@ -14,9 +14,6 @@ import { Modal, modalClasses } from './Modal';
14
14
  export default {
15
15
  title: 'plasma_b2c/Modal',
16
16
  decorators: [WithTheme],
17
- parameters: {
18
- docs: { story: { inline: false, iframeHeight: '30rem' } },
19
- },
20
17
  argTypes: {
21
18
  placement: {
22
19
  options: [