@salutejs/plasma-new-hope 0.267.2-canary.1775.13371861190.0 → 0.268.0-dev.0
Sign up to get free protection for your applications and to get access to all the features.
- package/cjs/components/Popover/Popover.js +2 -10
- package/cjs/components/Popover/Popover.js.map +1 -1
- package/cjs/components/Tooltip/Tooltip.js +1 -1
- package/cjs/components/Tooltip/Tooltip.js.map +1 -1
- package/emotion/cjs/components/Popover/Popover.js +2 -10
- package/emotion/cjs/components/Tooltip/Tooltip.js +2 -2
- package/emotion/cjs/examples/plasma_b2c/components/Popover/Popover.stories.tsx +2 -27
- package/emotion/es/components/Popover/Popover.js +2 -10
- package/emotion/es/components/Tooltip/Tooltip.js +2 -2
- package/emotion/es/examples/plasma_b2c/components/Popover/Popover.stories.tsx +2 -27
- package/es/components/Popover/Popover.js +2 -10
- package/es/components/Popover/Popover.js.map +1 -1
- package/es/components/Tooltip/Tooltip.js +1 -1
- package/es/components/Tooltip/Tooltip.js.map +1 -1
- package/package.json +2 -2
- package/styled-components/cjs/components/Popover/Popover.js +2 -10
- package/styled-components/cjs/components/Tooltip/Tooltip.js +1 -1
- package/styled-components/cjs/examples/plasma_b2c/components/Popover/Popover.stories.tsx +2 -27
- package/styled-components/es/components/Popover/Popover.js +2 -10
- package/styled-components/es/components/Tooltip/Tooltip.js +1 -1
- package/styled-components/es/examples/plasma_b2c/components/Popover/Popover.stories.tsx +2 -27
- package/types/components/Popover/Popover.d.ts.map +1 -1
- package/cjs/components/Popover/hooks/usePopoverOffset.js +0 -48
- package/cjs/components/Popover/hooks/usePopoverOffset.js.map +0 -1
- package/cjs/components/_Icon/Icons/IconCross.css +0 -1
- package/emotion/cjs/components/Popover/hooks/usePopoverOffset.js +0 -51
- package/emotion/es/components/Popover/hooks/usePopoverOffset.js +0 -45
- package/es/components/Popover/hooks/usePopoverOffset.js +0 -44
- package/es/components/Popover/hooks/usePopoverOffset.js.map +0 -1
- package/es/components/_Icon/Icons/IconCross.css +0 -1
- package/styled-components/cjs/components/Popover/hooks/usePopoverOffset.js +0 -51
- package/styled-components/es/components/Popover/hooks/usePopoverOffset.js +0 -45
- package/types/components/Popover/hooks/usePopoverOffset.d.ts +0 -9
- package/types/components/Popover/hooks/usePopoverOffset.d.ts.map +0 -1
@@ -1,44 +0,0 @@
|
|
1
|
-
import { slicedToArray as _slicedToArray } from '../../../_virtual/_rollupPluginBabelHelpers.js';
|
2
|
-
import { useState, useEffect } from 'react';
|
3
|
-
|
4
|
-
var allowedPlacements = ['top-start', 'top-end', 'bottom-start', 'bottom-end', 'left-start', 'left-end', 'right-start', 'right-end'];
|
5
|
-
var widthThreshold = 28;
|
6
|
-
var offsetXStartThreshold = 17;
|
7
|
-
var offsetXEndThreshold = 19;
|
8
|
-
var usePopoverOffset = function usePopoverOffset(_ref) {
|
9
|
-
var handleRef = _ref.handleRef,
|
10
|
-
placement = _ref.placement,
|
11
|
-
offsetOuter = _ref.offsetOuter;
|
12
|
-
var _useState = useState(offsetOuter),
|
13
|
-
_useState2 = _slicedToArray(_useState, 2),
|
14
|
-
offset = _useState2[0],
|
15
|
-
setOffset = _useState2[1];
|
16
|
-
useEffect(function () {
|
17
|
-
var refElement = handleRef.current;
|
18
|
-
if (!refElement || !allowedPlacements.includes(placement)) {
|
19
|
-
setOffset(offsetOuter);
|
20
|
-
return;
|
21
|
-
}
|
22
|
-
var _refElement$getBoundi = refElement.getBoundingClientRect(),
|
23
|
-
width = _refElement$getBoundi.width,
|
24
|
-
height = _refElement$getBoundi.height;
|
25
|
-
var isVertical = (placement === null || placement === void 0 ? void 0 : placement.startsWith('top')) || (placement === null || placement === void 0 ? void 0 : placement.startsWith('bottom'));
|
26
|
-
var isEnd = placement === null || placement === void 0 ? void 0 : placement.endsWith('end');
|
27
|
-
var isStart = placement === null || placement === void 0 ? void 0 : placement.endsWith('start');
|
28
|
-
var offsetX = offsetOuter[0];
|
29
|
-
var offsetY = offsetOuter[1];
|
30
|
-
if (isVertical) {
|
31
|
-
if ((isStart || isEnd) && width < widthThreshold) {
|
32
|
-
offsetX = isEnd ? offsetXStartThreshold - width / 2 + offsetOuter[0] : -offsetXStartThreshold + width / 2 - offsetOuter[0];
|
33
|
-
}
|
34
|
-
}
|
35
|
-
if (!isVertical && (isStart || isEnd) && height < widthThreshold) {
|
36
|
-
offsetX = isStart ? -offsetXEndThreshold + height / 2 : offsetXEndThreshold - height / 2;
|
37
|
-
}
|
38
|
-
setOffset([offsetX, offsetY]);
|
39
|
-
}, [handleRef, placement, offsetOuter]);
|
40
|
-
return offset;
|
41
|
-
};
|
42
|
-
|
43
|
-
export { usePopoverOffset };
|
44
|
-
//# sourceMappingURL=usePopoverOffset.js.map
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"usePopoverOffset.js","sources":["../../../../src/components/Popover/hooks/usePopoverOffset.ts"],"sourcesContent":["import { useEffect, useState } from 'react';\n\nconst allowedPlacements = [\n 'top-start',\n 'top-end',\n 'bottom-start',\n 'bottom-end',\n 'left-start',\n 'left-end',\n 'right-start',\n 'right-end',\n] as const;\n\ntype Placement = typeof allowedPlacements[number];\n\nconst widthThreshold = 28;\nconst offsetXStartThreshold = 17;\nconst offsetXEndThreshold = 19;\n\ninterface UsePopoverOffsetOptions {\n handleRef: React.RefObject<HTMLDivElement>;\n placement?: string;\n offsetOuter: [number, number];\n}\n\nexport const usePopoverOffset = ({ handleRef, placement, offsetOuter }: UsePopoverOffsetOptions): [number, number] => {\n const [offset, setOffset] = useState<[number, number]>(offsetOuter);\n\n useEffect(() => {\n const refElement = handleRef.current;\n\n if (!refElement || !allowedPlacements.includes(placement as Placement)) {\n setOffset(offsetOuter);\n return;\n }\n\n const { width, height } = refElement.getBoundingClientRect();\n\n const isVertical = placement?.startsWith('top') || placement?.startsWith('bottom');\n const isEnd = placement?.endsWith('end');\n const isStart = placement?.endsWith('start');\n\n let offsetX = offsetOuter[0];\n const offsetY = offsetOuter[1];\n\n if (isVertical) {\n if ((isStart || isEnd) && width < widthThreshold) {\n offsetX = isEnd\n ? offsetXStartThreshold - width / 2 + offsetOuter[0]\n : -offsetXStartThreshold + width / 2 - offsetOuter[0];\n }\n }\n\n if (!isVertical && (isStart || isEnd) && height < widthThreshold) {\n offsetX = isStart ? -offsetXEndThreshold + height / 2 : offsetXEndThreshold - height / 2;\n }\n\n setOffset([offsetX, offsetY]);\n }, [handleRef, placement, offsetOuter]);\n\n return offset;\n};\n"],"names":["allowedPlacements","widthThreshold","offsetXStartThreshold","offsetXEndThreshold","usePopoverOffset","_ref","handleRef","placement","offsetOuter","_useState","useState","_useState2","_slicedToArray","offset","setOffset","useEffect","refElement","current","includes","_refElement$getBoundi","getBoundingClientRect","width","height","isVertical","startsWith","isEnd","endsWith","isStart","offsetX","offsetY"],"mappings":";;;AAEA,IAAMA,iBAAiB,GAAG,CACtB,WAAW,EACX,SAAS,EACT,cAAc,EACd,YAAY,EACZ,YAAY,EACZ,UAAU,EACV,aAAa,EACb,WAAW,CACL,CAAA;AAIV,IAAMC,cAAc,GAAG,EAAE,CAAA;AACzB,IAAMC,qBAAqB,GAAG,EAAE,CAAA;AAChC,IAAMC,mBAAmB,GAAG,EAAE,CAAA;IAQjBC,gBAAgB,GAAG,SAAnBA,gBAAgBA,CAAAC,IAAA,EAAyF;AAAA,EAAA,IAAnFC,SAAS,GAAAD,IAAA,CAATC,SAAS;IAAEC,SAAS,GAAAF,IAAA,CAATE,SAAS;IAAEC,WAAW,GAAAH,IAAA,CAAXG,WAAW,CAAA;AAChE,EAAA,IAAAC,SAAA,GAA4BC,QAAQ,CAAmBF,WAAW,CAAC;IAAAG,UAAA,GAAAC,cAAA,CAAAH,SAAA,EAAA,CAAA,CAAA;AAA5DI,IAAAA,MAAM,GAAAF,UAAA,CAAA,CAAA,CAAA;AAAEG,IAAAA,SAAS,GAAAH,UAAA,CAAA,CAAA,CAAA,CAAA;AAExBI,EAAAA,SAAS,CAAC,YAAM;AACZ,IAAA,IAAMC,UAAU,GAAGV,SAAS,CAACW,OAAO,CAAA;IAEpC,IAAI,CAACD,UAAU,IAAI,CAAChB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AAW,CAAC,CAAC,CAAC,CAAA;AAC7D,OAAA;AACJ,KAAA;IAEA,IAAI,CAACe,UAAU,KAAKI,OAAO,IAAIF,KAAK,CAAC,IAAIH,MAAM,GAAGrB,cAAc,EAAE;AAC9D2B,MAAAA,OAAO,GAAGD,OAAO,GAAG,CAACxB,mBAAmB,GAAGmB,MAAM,GAAG,CAAC,GAAGnB,mBAAmB,GAAGmB,MAAM,GAAG,CAAC,CAAA;AAC5F,KAAA;AAEAR,IAAAA,SAAS,CAAC,CAACc,OAAO,EAAEC,OAAO,CAAC,CAAC,CAAA;GAChC,EAAE,CAACvB,SAAS,EAAEC,SAAS,EAAEC,WAAW,CAAC,CAAC,CAAA;AAEvC,EAAA,OAAOK,MAAM,CAAA;AACjB;;;;"}
|
@@ -1 +0,0 @@
|
|
1
|
-
.IconRoot_7pl7ig_svvlqhf__32c458a1{display:-webkit-inline-box;display:-webkit-inline-flex;display:-ms-inline-flexbox;display:inline-flex;width:var(--svvlqhf-0);height:var(--svvlqhf-0);-webkit-flex:0 0 var(--svvlqhf-0);-ms-flex:0 0 var(--svvlqhf-0);flex:0 0 var(--svvlqhf-0);}
|
@@ -1,51 +0,0 @@
|
|
1
|
-
"use strict";
|
2
|
-
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
4
|
-
value: true
|
5
|
-
});
|
6
|
-
exports.usePopoverOffset = void 0;
|
7
|
-
var _react = /*#__PURE__*/require("react");
|
8
|
-
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
9
|
-
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
10
|
-
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
11
|
-
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; }
|
12
|
-
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; } }
|
13
|
-
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
14
|
-
var allowedPlacements = ['top-start', 'top-end', 'bottom-start', 'bottom-end', 'left-start', 'left-end', 'right-start', 'right-end'];
|
15
|
-
var widthThreshold = 28;
|
16
|
-
var offsetXStartThreshold = 17;
|
17
|
-
var offsetXEndThreshold = 19;
|
18
|
-
var usePopoverOffset = exports.usePopoverOffset = function usePopoverOffset(_ref) {
|
19
|
-
var handleRef = _ref.handleRef,
|
20
|
-
placement = _ref.placement,
|
21
|
-
offsetOuter = _ref.offsetOuter;
|
22
|
-
var _useState = (0, _react.useState)(offsetOuter),
|
23
|
-
_useState2 = _slicedToArray(_useState, 2),
|
24
|
-
offset = _useState2[0],
|
25
|
-
setOffset = _useState2[1];
|
26
|
-
(0, _react.useEffect)(function () {
|
27
|
-
var refElement = handleRef.current;
|
28
|
-
if (!refElement || !allowedPlacements.includes(placement)) {
|
29
|
-
setOffset(offsetOuter);
|
30
|
-
return;
|
31
|
-
}
|
32
|
-
var _refElement$getBoundi = refElement.getBoundingClientRect(),
|
33
|
-
width = _refElement$getBoundi.width,
|
34
|
-
height = _refElement$getBoundi.height;
|
35
|
-
var isVertical = (placement === null || placement === void 0 ? void 0 : placement.startsWith('top')) || (placement === null || placement === void 0 ? void 0 : placement.startsWith('bottom'));
|
36
|
-
var isEnd = placement === null || placement === void 0 ? void 0 : placement.endsWith('end');
|
37
|
-
var isStart = placement === null || placement === void 0 ? void 0 : placement.endsWith('start');
|
38
|
-
var offsetX = offsetOuter[0];
|
39
|
-
var offsetY = offsetOuter[1];
|
40
|
-
if (isVertical) {
|
41
|
-
if ((isStart || isEnd) && width < widthThreshold) {
|
42
|
-
offsetX = isEnd ? offsetXStartThreshold - width / 2 + offsetOuter[0] : -offsetXStartThreshold + width / 2 - offsetOuter[0];
|
43
|
-
}
|
44
|
-
}
|
45
|
-
if (!isVertical && (isStart || isEnd) && height < widthThreshold) {
|
46
|
-
offsetX = isStart ? -offsetXEndThreshold + height / 2 : offsetXEndThreshold - height / 2;
|
47
|
-
}
|
48
|
-
setOffset([offsetX, offsetY]);
|
49
|
-
}, [handleRef, placement, offsetOuter]);
|
50
|
-
return offset;
|
51
|
-
};
|
@@ -1,45 +0,0 @@
|
|
1
|
-
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
2
|
-
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
3
|
-
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
4
|
-
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; }
|
5
|
-
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; } }
|
6
|
-
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
7
|
-
import { useEffect, useState } from 'react';
|
8
|
-
var allowedPlacements = ['top-start', 'top-end', 'bottom-start', 'bottom-end', 'left-start', 'left-end', 'right-start', 'right-end'];
|
9
|
-
var widthThreshold = 28;
|
10
|
-
var offsetXStartThreshold = 17;
|
11
|
-
var offsetXEndThreshold = 19;
|
12
|
-
export var usePopoverOffset = function usePopoverOffset(_ref) {
|
13
|
-
var handleRef = _ref.handleRef,
|
14
|
-
placement = _ref.placement,
|
15
|
-
offsetOuter = _ref.offsetOuter;
|
16
|
-
var _useState = useState(offsetOuter),
|
17
|
-
_useState2 = _slicedToArray(_useState, 2),
|
18
|
-
offset = _useState2[0],
|
19
|
-
setOffset = _useState2[1];
|
20
|
-
useEffect(function () {
|
21
|
-
var refElement = handleRef.current;
|
22
|
-
if (!refElement || !allowedPlacements.includes(placement)) {
|
23
|
-
setOffset(offsetOuter);
|
24
|
-
return;
|
25
|
-
}
|
26
|
-
var _refElement$getBoundi = refElement.getBoundingClientRect(),
|
27
|
-
width = _refElement$getBoundi.width,
|
28
|
-
height = _refElement$getBoundi.height;
|
29
|
-
var isVertical = (placement === null || placement === void 0 ? void 0 : placement.startsWith('top')) || (placement === null || placement === void 0 ? void 0 : placement.startsWith('bottom'));
|
30
|
-
var isEnd = placement === null || placement === void 0 ? void 0 : placement.endsWith('end');
|
31
|
-
var isStart = placement === null || placement === void 0 ? void 0 : placement.endsWith('start');
|
32
|
-
var offsetX = offsetOuter[0];
|
33
|
-
var offsetY = offsetOuter[1];
|
34
|
-
if (isVertical) {
|
35
|
-
if ((isStart || isEnd) && width < widthThreshold) {
|
36
|
-
offsetX = isEnd ? offsetXStartThreshold - width / 2 + offsetOuter[0] : -offsetXStartThreshold + width / 2 - offsetOuter[0];
|
37
|
-
}
|
38
|
-
}
|
39
|
-
if (!isVertical && (isStart || isEnd) && height < widthThreshold) {
|
40
|
-
offsetX = isStart ? -offsetXEndThreshold + height / 2 : offsetXEndThreshold - height / 2;
|
41
|
-
}
|
42
|
-
setOffset([offsetX, offsetY]);
|
43
|
-
}, [handleRef, placement, offsetOuter]);
|
44
|
-
return offset;
|
45
|
-
};
|
@@ -1,9 +0,0 @@
|
|
1
|
-
/// <reference types="react" />
|
2
|
-
interface UsePopoverOffsetOptions {
|
3
|
-
handleRef: React.RefObject<HTMLDivElement>;
|
4
|
-
placement?: string;
|
5
|
-
offsetOuter: [number, number];
|
6
|
-
}
|
7
|
-
export declare const usePopoverOffset: ({ handleRef, placement, offsetOuter }: UsePopoverOffsetOptions) => [number, number];
|
8
|
-
export {};
|
9
|
-
//# sourceMappingURL=usePopoverOffset.d.ts.map
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"usePopoverOffset.d.ts","sourceRoot":"","sources":["../../../../src/components/Popover/hooks/usePopoverOffset.ts"],"names":[],"mappings":";AAmBA,UAAU,uBAAuB;IAC7B,SAAS,EAAE,KAAK,CAAC,SAAS,CAAC,cAAc,CAAC,CAAC;IAC3C,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,WAAW,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CACjC;AAED,eAAO,MAAM,gBAAgB,0CAA2C,uBAAuB,KAAG,CAAC,MAAM,EAAE,MAAM,CAoChH,CAAC"}
|