@dr.pogodin/react-utils 1.21.1 → 1.21.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/development/client/index.js +0 -7
- package/build/development/client/index.js.map +1 -1
- package/build/development/client/init.js +3 -17
- package/build/development/client/init.js.map +1 -1
- package/build/development/index.js +0 -13
- package/build/development/index.js.map +1 -1
- package/build/development/server/Cache.js +2 -9
- package/build/development/server/Cache.js.map +1 -1
- package/build/development/server/index.js +7 -32
- package/build/development/server/index.js.map +1 -1
- package/build/development/server/renderer.js +24 -80
- package/build/development/server/renderer.js.map +1 -1
- package/build/development/server/server.js +21 -61
- package/build/development/server/server.js.map +1 -1
- package/build/development/server/utils/errors.js +2 -9
- package/build/development/server/utils/errors.js.map +1 -1
- package/build/development/server/utils/index.js +0 -4
- package/build/development/shared/components/Button/index.js +2 -13
- package/build/development/shared/components/Button/index.js.map +1 -1
- package/build/development/shared/components/Checkbox/index.js +2 -9
- package/build/development/shared/components/Checkbox/index.js.map +1 -1
- package/build/development/shared/components/CodeSplit/index.js +11 -22
- package/build/development/shared/components/CodeSplit/index.js.map +1 -1
- package/build/development/shared/components/Dropdown/index.js +0 -11
- package/build/development/shared/components/Dropdown/index.js.map +1 -1
- package/build/development/shared/components/GenericLink/index.js +3 -9
- package/build/development/shared/components/GenericLink/index.js.map +1 -1
- package/build/development/shared/components/Input/index.js +0 -7
- package/build/development/shared/components/Input/index.js.map +1 -1
- package/build/development/shared/components/Link.js +3 -6
- package/build/development/shared/components/Link.js.map +1 -1
- package/build/development/shared/components/MetaTags.js +1 -8
- package/build/development/shared/components/MetaTags.js.map +1 -1
- package/build/development/shared/components/Modal/index.js +2 -19
- package/build/development/shared/components/Modal/index.js.map +1 -1
- package/build/development/shared/components/NavLink.js +2 -6
- package/build/development/shared/components/NavLink.js.map +1 -1
- package/build/development/shared/components/PageLayout/index.js +0 -7
- package/build/development/shared/components/PageLayout/index.js.map +1 -1
- package/build/development/shared/components/ScalableRect/index.js +1 -6
- package/build/development/shared/components/ScalableRect/index.js.map +1 -1
- package/build/development/shared/components/Throbber/index.js +0 -9
- package/build/development/shared/components/Throbber/index.js.map +1 -1
- package/build/development/shared/components/WithTooltip/Tooltip.js +9 -28
- package/build/development/shared/components/WithTooltip/Tooltip.js.map +1 -1
- package/build/development/shared/components/WithTooltip/index.js +0 -16
- package/build/development/shared/components/WithTooltip/index.js.map +1 -1
- package/build/development/shared/components/YouTubeVideo/index.js +3 -11
- package/build/development/shared/components/YouTubeVideo/index.js.map +1 -1
- package/build/development/shared/components/index.js +0 -17
- package/build/development/shared/components/index.js.map +1 -1
- package/build/development/shared/utils/Barrier.js +1 -13
- package/build/development/shared/utils/Barrier.js.map +1 -1
- package/build/development/shared/utils/Emitter.js +4 -13
- package/build/development/shared/utils/Emitter.js.map +1 -1
- package/build/development/shared/utils/Semaphore.js +13 -19
- package/build/development/shared/utils/Semaphore.js.map +1 -1
- package/build/development/shared/utils/config.js +0 -5
- package/build/development/shared/utils/config.js.map +1 -1
- package/build/development/shared/utils/index.js +5 -26
- package/build/development/shared/utils/index.js.map +1 -1
- package/build/development/shared/utils/isomorphy.js +6 -12
- package/build/development/shared/utils/isomorphy.js.map +1 -1
- package/build/development/shared/utils/jest/E2eSsrEnv.js +20 -41
- package/build/development/shared/utils/jest/E2eSsrEnv.js.map +1 -1
- package/build/development/shared/utils/jest/index.js +10 -31
- package/build/development/shared/utils/jest/index.js.map +1 -1
- package/build/development/shared/utils/splitComponent.js +2 -5
- package/build/development/shared/utils/splitComponent.js.map +1 -1
- package/build/development/shared/utils/time.js +6 -15
- package/build/development/shared/utils/time.js.map +1 -1
- package/build/development/shared/utils/webpack.js +1 -5
- package/build/development/shared/utils/webpack.js.map +1 -1
- package/build/development/style.css +5 -24
- package/build/development/web.bundle.js +27 -27
- package/build/production/client/index.js.map +1 -1
- package/build/production/client/init.js.map +1 -1
- package/build/production/index.js.map +1 -1
- package/build/production/server/Cache.js.map +1 -1
- package/build/production/server/index.js.map +1 -1
- package/build/production/server/renderer.js.map +1 -1
- package/build/production/server/server.js.map +1 -1
- package/build/production/server/utils/errors.js.map +1 -1
- package/build/production/shared/components/Button/index.js.map +1 -1
- package/build/production/shared/components/Checkbox/index.js.map +1 -1
- package/build/production/shared/components/CodeSplit/index.js.map +1 -1
- package/build/production/shared/components/Dropdown/index.js.map +1 -1
- package/build/production/shared/components/GenericLink/index.js.map +1 -1
- package/build/production/shared/components/Input/index.js.map +1 -1
- package/build/production/shared/components/Link.js.map +1 -1
- package/build/production/shared/components/MetaTags.js.map +1 -1
- package/build/production/shared/components/Modal/index.js.map +1 -1
- package/build/production/shared/components/NavLink.js.map +1 -1
- package/build/production/shared/components/PageLayout/index.js.map +1 -1
- package/build/production/shared/components/ScalableRect/index.js.map +1 -1
- package/build/production/shared/components/Throbber/index.js.map +1 -1
- package/build/production/shared/components/WithTooltip/Tooltip.js.map +1 -1
- package/build/production/shared/components/WithTooltip/index.js.map +1 -1
- package/build/production/shared/components/YouTubeVideo/index.js.map +1 -1
- package/build/production/shared/components/index.js.map +1 -1
- package/build/production/shared/utils/Barrier.js.map +1 -1
- package/build/production/shared/utils/Emitter.js.map +1 -1
- package/build/production/shared/utils/Semaphore.js.map +1 -1
- package/build/production/shared/utils/config.js.map +1 -1
- package/build/production/shared/utils/index.js.map +1 -1
- package/build/production/shared/utils/isomorphy.js.map +1 -1
- package/build/production/shared/utils/jest/E2eSsrEnv.js.map +1 -1
- package/build/production/shared/utils/jest/index.js.map +1 -1
- package/build/production/shared/utils/splitComponent.js.map +1 -1
- package/build/production/shared/utils/time.js.map +1 -1
- package/build/production/shared/utils/webpack.js.map +1 -1
- package/build/production/style.css +1 -1
- package/build/production/style.css.map +1 -1
- package/build/production/web.bundle.js.map +1 -1
- package/config/babel/node-ssr.js +1 -1
- package/package.json +24 -24
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["BaseModal","children","onCancel","theme","containerRef","useRef","overlayRef","portal","setPortal","useState","useEffect","p","document","createElement","body","classList","add","appendChild","remove","removeChild","focusLast","useMemo","elems","current","querySelectorAll","i","length","focus","activeElement","ReactDom","createPortal","overlay","e","key","node","container","event","stopPropagation","ThemedModal","themed","baseTheme","propTypes","PT","func","themeType","isRequired","defaultProps","noop"],"sources":["../../../../../src/shared/components/Modal/index.jsx"],"sourcesContent":["/* global document */\n\nimport { noop } from 'lodash';\n\nimport {\n useEffect,\n useMemo,\n useRef,\n useState,\n} from 'react';\n\nimport ReactDom from 'react-dom';\nimport PT from 'prop-types';\nimport themed from '@dr.pogodin/react-themes';\n\nimport baseTheme from './base-theme.scss';\nimport './styles.scss';\n\n/**\n * The `<Modal>` component implements a simple themeable modal window, wrapped\n * into the default theme. `<BaseModal>` exposes the base non-themed component.\n * **Children:** Component children are rendered as the modal content.\n * @param {object} props Component properties. Beside props documented below,\n * [Other theming properties](https://www.npmjs.com/package/@dr.pogodin/react-themes#themed-component-properties) are supported as well.\n * @param {function} [props.onCancel] The callback to trigger when user\n * clicks outside the modal, or presses Escape. It is expected to hide the\n * modal.\n * @param {ModalTheme} [props.theme] _Ad hoc_ theme.\n */\nfunction BaseModal({\n children,\n onCancel,\n theme,\n}) {\n const containerRef = useRef();\n const overlayRef = useRef();\n const [portal, setPortal] = useState();\n\n useEffect(() => {\n const p = document.createElement('div');\n document.body.classList.add('scrolling-disabled-by-modal');\n document.body.appendChild(p);\n setPortal(p);\n return () => {\n document.body.classList.remove('scrolling-disabled-by-modal');\n document.body.removeChild(p);\n };\n }, []);\n\n const focusLast = useMemo(() => (\n <div\n onFocus={() => {\n const elems = containerRef.current.querySelectorAll('*');\n for (let i = elems.length - 1; i >= 0; --i) {\n elems[i].focus();\n if (document.activeElement === elems[i]) return;\n }\n overlayRef.current.focus();\n }}\n /* eslint-disable jsx-a11y/no-noninteractive-tabindex */\n tabIndex=\"0\"\n /* eslint-enable jsx-a11y/no-noninteractive-tabindex */\n />\n ), []);\n\n return portal ? ReactDom.createPortal(\n (\n <>\n {focusLast}\n <div\n aria-label=\"Cancel\"\n className={theme.overlay}\n onClick={() => onCancel()}\n onKeyDown={(e) => {\n if (e.key === 'Escape') onCancel();\n }}\n ref={(node) => {\n if (node && node !== overlayRef.current) {\n overlayRef.current = node;\n node.focus();\n }\n }}\n role=\"button\"\n tabIndex=\"0\"\n />\n <div\n aria-modal=\"true\"\n className={theme.container}\n onWheel={(event) => event.stopPropagation()}\n ref={containerRef}\n role=\"dialog\"\n >\n {children}\n </div>\n <div\n onFocus={() => {\n overlayRef.current.focus();\n }}\n /* eslint-disable jsx-a11y/no-noninteractive-tabindex */\n tabIndex=\"0\"\n /* eslint-enable jsx-a11y/no-noninteractive-tabindex */\n />\n {focusLast}\n </>\n ),\n portal,\n ) : null;\n}\n\nconst ThemedModal = themed(\n 'Modal',\n [\n 'container',\n 'overlay',\n ],\n baseTheme,\n)(BaseModal);\n\nBaseModal.propTypes = {\n onCancel: PT.func,\n children: PT.node,\n theme: ThemedModal.themeType.isRequired,\n};\n\nBaseModal.defaultProps = {\n onCancel: noop,\n children: null,\n};\n\nexport default ThemedModal;\n\n/* Non-themed version of the Modal. */\nexport { BaseModal };\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","names":["BaseModal","children","onCancel","theme","containerRef","useRef","overlayRef","portal","setPortal","useState","useEffect","p","document","createElement","body","classList","add","appendChild","remove","removeChild","focusLast","useMemo","elems","current","querySelectorAll","i","length","focus","activeElement","ReactDom","createPortal","overlay","e","key","node","container","event","stopPropagation","ThemedModal","themed","baseTheme","propTypes","PT","func","themeType","isRequired","defaultProps","noop"],"sources":["../../../../../src/shared/components/Modal/index.jsx"],"sourcesContent":["/* global document */\n\nimport { noop } from 'lodash';\n\nimport {\n useEffect,\n useMemo,\n useRef,\n useState,\n} from 'react';\n\nimport ReactDom from 'react-dom';\nimport PT from 'prop-types';\nimport themed from '@dr.pogodin/react-themes';\n\nimport baseTheme from './base-theme.scss';\nimport './styles.scss';\n\n/**\n * The `<Modal>` component implements a simple themeable modal window, wrapped\n * into the default theme. `<BaseModal>` exposes the base non-themed component.\n * **Children:** Component children are rendered as the modal content.\n * @param {object} props Component properties. Beside props documented below,\n * [Other theming properties](https://www.npmjs.com/package/@dr.pogodin/react-themes#themed-component-properties) are supported as well.\n * @param {function} [props.onCancel] The callback to trigger when user\n * clicks outside the modal, or presses Escape. It is expected to hide the\n * modal.\n * @param {ModalTheme} [props.theme] _Ad hoc_ theme.\n */\nfunction BaseModal({\n children,\n onCancel,\n theme,\n}) {\n const containerRef = useRef();\n const overlayRef = useRef();\n const [portal, setPortal] = useState();\n\n useEffect(() => {\n const p = document.createElement('div');\n document.body.classList.add('scrolling-disabled-by-modal');\n document.body.appendChild(p);\n setPortal(p);\n return () => {\n document.body.classList.remove('scrolling-disabled-by-modal');\n document.body.removeChild(p);\n };\n }, []);\n\n const focusLast = useMemo(() => (\n <div\n onFocus={() => {\n const elems = containerRef.current.querySelectorAll('*');\n for (let i = elems.length - 1; i >= 0; --i) {\n elems[i].focus();\n if (document.activeElement === elems[i]) return;\n }\n overlayRef.current.focus();\n }}\n /* eslint-disable jsx-a11y/no-noninteractive-tabindex */\n tabIndex=\"0\"\n /* eslint-enable jsx-a11y/no-noninteractive-tabindex */\n />\n ), []);\n\n return portal ? ReactDom.createPortal(\n (\n <>\n {focusLast}\n <div\n aria-label=\"Cancel\"\n className={theme.overlay}\n onClick={() => onCancel()}\n onKeyDown={(e) => {\n if (e.key === 'Escape') onCancel();\n }}\n ref={(node) => {\n if (node && node !== overlayRef.current) {\n overlayRef.current = node;\n node.focus();\n }\n }}\n role=\"button\"\n tabIndex=\"0\"\n />\n <div\n aria-modal=\"true\"\n className={theme.container}\n onWheel={(event) => event.stopPropagation()}\n ref={containerRef}\n role=\"dialog\"\n >\n {children}\n </div>\n <div\n onFocus={() => {\n overlayRef.current.focus();\n }}\n /* eslint-disable jsx-a11y/no-noninteractive-tabindex */\n tabIndex=\"0\"\n /* eslint-enable jsx-a11y/no-noninteractive-tabindex */\n />\n {focusLast}\n </>\n ),\n portal,\n ) : null;\n}\n\nconst ThemedModal = themed(\n 'Modal',\n [\n 'container',\n 'overlay',\n ],\n baseTheme,\n)(BaseModal);\n\nBaseModal.propTypes = {\n onCancel: PT.func,\n children: PT.node,\n theme: ThemedModal.themeType.isRequired,\n};\n\nBaseModal.defaultProps = {\n onCancel: noop,\n children: null,\n};\n\nexport default ThemedModal;\n\n/* Non-themed version of the Modal. */\nexport { BaseModal };\n"],"mappings":";;;;;;;;AAEA;AAEA;AAOA;AACA;AACA;AAA8C;AAb9C;AAAA;EAAA;EAAA;EAAA;EAAA;EAAA;AAAA;AAkBA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAASA,SAAS,CAAC;EACjBC,QAAQ;EACRC,QAAQ;EACRC;AACF,CAAC,EAAE;EACD,MAAMC,YAAY,GAAG,IAAAC,aAAM,GAAE;EAC7B,MAAMC,UAAU,GAAG,IAAAD,aAAM,GAAE;EAC3B,MAAM,CAACE,MAAM,EAAEC,SAAS,CAAC,GAAG,IAAAC,eAAQ,GAAE;EAEtC,IAAAC,gBAAS,EAAC,MAAM;IACd,MAAMC,CAAC,GAAGC,QAAQ,CAACC,aAAa,CAAC,KAAK,CAAC;IACvCD,QAAQ,CAACE,IAAI,CAACC,SAAS,CAACC,GAAG,CAAC,6BAA6B,CAAC;IAC1DJ,QAAQ,CAACE,IAAI,CAACG,WAAW,CAACN,CAAC,CAAC;IAC5BH,SAAS,CAACG,CAAC,CAAC;IACZ,OAAO,MAAM;MACXC,QAAQ,CAACE,IAAI,CAACC,SAAS,CAACG,MAAM,CAAC,6BAA6B,CAAC;MAC7DN,QAAQ,CAACE,IAAI,CAACK,WAAW,CAACR,CAAC,CAAC;IAC9B,CAAC;EACH,CAAC,EAAE,EAAE,CAAC;EAEN,MAAMS,SAAS,GAAG,IAAAC,cAAO,EAAC,mBACxB;IACE,OAAO,EAAE,MAAM;MACb,MAAMC,KAAK,GA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AC;MACT;IAAA,EACA,EACDP,SAAS;EAAA,EACT,EAELb,MAAM,CACP,GAAG,IAAI;AACV;AAEA,MAAM+B,WAAW,GAAG,IAAAC,oBAAM,EACxB,OAAO,EACP,CACE,WAAW,EACX,SAAS,CACV,EACDC,SAAS,CACV,CAACxC,SAAS,CAAC;AAEZA,SAAS,CAACyC,SAAS,GAAG;EACpBvC,QAAQ,EAAEwC,kBAAE,CAACC,IAAI;EACjB1C,QAAQ,EAAEyC,kBAAE,CAACR,IAAI;EACjB/B,KAAK,EAAEmC,WAAW,CAACM,SAAS,CAACC;AAC/B,CAAC;AAED7C,SAAS,CAAC8C,YAAY,GAAG;EACvB5C,QAAQ,EAAE6C,YAAI;EACd9C,QAAQ,EAAE;AACZ,CAAC;AAAC,eAEaqC,WAAW;AAE1B;AAAA"}
|
|
@@ -1,21 +1,17 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
|
|
5
4
|
Object.defineProperty(exports, "__esModule", {
|
|
6
5
|
value: true
|
|
7
6
|
});
|
|
8
7
|
exports.default = NavLink;
|
|
9
|
-
|
|
10
8
|
var _reactRouterDom = require("react-router-dom");
|
|
11
|
-
|
|
12
9
|
var _GenericLink = _interopRequireDefault(require("./GenericLink"));
|
|
13
|
-
|
|
14
10
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
15
|
-
|
|
16
11
|
function NavLink(props) {
|
|
17
12
|
/* eslint-disable react/jsx-props-no-spreading */
|
|
18
|
-
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_GenericLink.default, {
|
|
13
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_GenericLink.default, {
|
|
14
|
+
...props,
|
|
19
15
|
routerLinkType: _reactRouterDom.NavLink
|
|
20
16
|
});
|
|
21
17
|
/* eslint-enable react/jsx-props-no-spreading */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NavLink.js","names":["NavLink","props","RrNavLink"],"sources":["../../../../src/shared/components/NavLink.jsx"],"sourcesContent":["import { NavLink as RrNavLink } from 'react-router-dom';\n\nimport GenericLink from './GenericLink';\n\nexport default function NavLink(props) {\n /* eslint-disable react/jsx-props-no-spreading */\n return <GenericLink {...props} routerLinkType={RrNavLink} />;\n /* eslint-enable react/jsx-props-no-spreading */\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"NavLink.js","names":["NavLink","props","RrNavLink"],"sources":["../../../../src/shared/components/NavLink.jsx"],"sourcesContent":["import { NavLink as RrNavLink } from 'react-router-dom';\n\nimport GenericLink from './GenericLink';\n\nexport default function NavLink(props) {\n /* eslint-disable react/jsx-props-no-spreading */\n return <GenericLink {...props} routerLinkType={RrNavLink} />;\n /* eslint-enable react/jsx-props-no-spreading */\n}\n"],"mappings":";;;;;;;AAAA;AAEA;AAAwC;AAEzB,SAASA,OAAO,CAACC,KAAK,EAAE;EACrC;EACA,oBAAO,qBAAC,oBAAW;IAAA,GAAKA,KAAK;IAAE,cAAc,EAAEC;EAAU,EAAG;EAC5D;AACF"}
|
|
@@ -1,18 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
|
|
5
4
|
Object.defineProperty(exports, "__esModule", {
|
|
6
5
|
value: true
|
|
7
6
|
});
|
|
8
7
|
exports.default = void 0;
|
|
9
|
-
|
|
10
8
|
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
11
|
-
|
|
12
9
|
var _utils = require("../../utils");
|
|
13
|
-
|
|
14
10
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
15
|
-
|
|
16
11
|
const baseTheme = {
|
|
17
12
|
"context": "-dr-pogodin-react-utils___src-shared-components-PageLayout-base-theme___context___m4mL-M",
|
|
18
13
|
"ad": "-dr-pogodin-react-utils___src-shared-components-PageLayout-base-theme___ad___m3-mdC",
|
|
@@ -36,7 +31,6 @@ const baseTheme = {
|
|
|
36
31
|
* @param {...any} [props....]
|
|
37
32
|
* [Other theming properties](https://www.npmjs.com/package/@dr.pogodin/react-themes#themed-component-properties)
|
|
38
33
|
*/
|
|
39
|
-
|
|
40
34
|
function PageLayout({
|
|
41
35
|
children,
|
|
42
36
|
leftSidePanelContent,
|
|
@@ -57,7 +51,6 @@ function PageLayout({
|
|
|
57
51
|
})]
|
|
58
52
|
});
|
|
59
53
|
}
|
|
60
|
-
|
|
61
54
|
const ThemedPageLayout = (0, _utils.themed)('PageLayout', ['container', 'leftSidePanel', 'mainPanel', 'rightSidePanel', 'sidePanel'], baseTheme)(PageLayout);
|
|
62
55
|
PageLayout.propTypes = {
|
|
63
56
|
children: _propTypes.default.node,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["PageLayout","children","leftSidePanelContent","rightSidePanelContent","theme","container","sidePanel","leftSidePanel","join","mainPanel","rightSidePanel","ThemedPageLayout","themed","baseTheme","propTypes","PT","node","themeType","isRequired","defaultProps"],"sources":["../../../../../src/shared/components/PageLayout/index.jsx"],"sourcesContent":["import PT from 'prop-types';\n\nimport { themed } from 'utils';\n\nimport baseTheme from './base-theme.scss';\n\n/**\n * Simple and themeable page layout. It keeps the main content centered in\n * a column of limited width, which fills entire viewport on small screens\n * (under `$screen-md = 1024px` size). At larger screens the column keeps\n * `$screen-md` size, and it is centered at the page, surrounded by side\n * panels, where additional content can be displayed.\n *\n * **Children:** Component children are rendered as the content of main panel.\n * @param {object} [props] Component properties.\n * @param {Node} [props.leftSidePanelContent] The content for left side panel.\n * @param {Node} [props.rightSidePanelContent] The content for right side panel.\n * @param {PageLayoutTheme} [props.theme] _Ad hoc_ theme.\n * @param {...any} [props....]\n * [Other theming properties](https://www.npmjs.com/package/@dr.pogodin/react-themes#themed-component-properties)\n */\nfunction PageLayout({\n children,\n leftSidePanelContent,\n rightSidePanelContent,\n theme,\n}) {\n return (\n <div className={theme.container}>\n <div className={[theme.sidePanel, theme.leftSidePanel].join(' ')}>\n {leftSidePanelContent}\n </div>\n <div className={theme.mainPanel}>\n {children}\n </div>\n <div className={[theme.sidePanel, theme.rightSidePanel].join(' ')}>\n {rightSidePanelContent}\n </div>\n </div>\n );\n}\n\nconst ThemedPageLayout = themed('PageLayout', [\n 'container',\n 'leftSidePanel',\n 'mainPanel',\n 'rightSidePanel',\n 'sidePanel',\n], baseTheme)(PageLayout);\n\nPageLayout.propTypes = {\n children: PT.node,\n leftSidePanelContent: PT.node,\n rightSidePanelContent: PT.node,\n theme: ThemedPageLayout.themeType.isRequired,\n};\n\nPageLayout.defaultProps = {\n children: null,\n leftSidePanelContent: null,\n rightSidePanelContent: null,\n};\n\nexport default ThemedPageLayout;\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","names":["PageLayout","children","leftSidePanelContent","rightSidePanelContent","theme","container","sidePanel","leftSidePanel","join","mainPanel","rightSidePanel","ThemedPageLayout","themed","baseTheme","propTypes","PT","node","themeType","isRequired","defaultProps"],"sources":["../../../../../src/shared/components/PageLayout/index.jsx"],"sourcesContent":["import PT from 'prop-types';\n\nimport { themed } from 'utils';\n\nimport baseTheme from './base-theme.scss';\n\n/**\n * Simple and themeable page layout. It keeps the main content centered in\n * a column of limited width, which fills entire viewport on small screens\n * (under `$screen-md = 1024px` size). At larger screens the column keeps\n * `$screen-md` size, and it is centered at the page, surrounded by side\n * panels, where additional content can be displayed.\n *\n * **Children:** Component children are rendered as the content of main panel.\n * @param {object} [props] Component properties.\n * @param {Node} [props.leftSidePanelContent] The content for left side panel.\n * @param {Node} [props.rightSidePanelContent] The content for right side panel.\n * @param {PageLayoutTheme} [props.theme] _Ad hoc_ theme.\n * @param {...any} [props....]\n * [Other theming properties](https://www.npmjs.com/package/@dr.pogodin/react-themes#themed-component-properties)\n */\nfunction PageLayout({\n children,\n leftSidePanelContent,\n rightSidePanelContent,\n theme,\n}) {\n return (\n <div className={theme.container}>\n <div className={[theme.sidePanel, theme.leftSidePanel].join(' ')}>\n {leftSidePanelContent}\n </div>\n <div className={theme.mainPanel}>\n {children}\n </div>\n <div className={[theme.sidePanel, theme.rightSidePanel].join(' ')}>\n {rightSidePanelContent}\n </div>\n </div>\n );\n}\n\nconst ThemedPageLayout = themed('PageLayout', [\n 'container',\n 'leftSidePanel',\n 'mainPanel',\n 'rightSidePanel',\n 'sidePanel',\n], baseTheme)(PageLayout);\n\nPageLayout.propTypes = {\n children: PT.node,\n leftSidePanelContent: PT.node,\n rightSidePanelContent: PT.node,\n theme: ThemedPageLayout.themeType.isRequired,\n};\n\nPageLayout.defaultProps = {\n children: null,\n leftSidePanelContent: null,\n rightSidePanelContent: null,\n};\n\nexport default ThemedPageLayout;\n"],"mappings":";;;;;;;AAAA;AAEA;AAA+B;AAAA;EAAA;EAAA;EAAA;EAAA;EAAA;EAAA;AAAA;AAI/B;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAASA,UAAU,CAAC;EAClBC,QAAQ;EACRC,oBAAoB;EACpBC,qBAAqB;EACrBC;AACF,CAAC,EAAE;EACD,oBACE;IAAK,SAAS,EAAEA,KAAK,CAACC,SAAU;IAAA,wBAC9B;MAAK,SAAS,EAAE,CAACD,KAAK,CAACE,SAAS,EAAEF,KAAK,CAACG,aAAa,CAAC,CAACC,IAAI,CAAC,GAAG,CAAE;MAAA,UAC9DN;IAAoB,EACjB,eACN;MAAK,SAAS,EAAEE,KAAK,CAACK,SAAU;MAAA,UAC7BR;IAAQ,EACL,eACN;MAAK,SAAS,EAAE,CAACG,KAAK,CAACE,SAAS,EAAEF,KAAK,CAACM,cAAc,CAAC,CAACF,IAAI,CAAC,GAAG,CAAE;MAAA,UAC/DL;IAAqB,EAClB;EAAA,EACF;AAEV;AAEA,MAAMQ,gBAAgB,GAAG,IAAAC,aAAM,EAAC,YAAY,EAAE,CAC5C,WAAW,EACX,eAAe,EACf,WAAW,EACX,gBAAgB,EAChB,WAAW,CACZ,EAAEC,SAAS,CAAC,CAACb,UAAU,CAAC;AAEzBA,UAAU,CAACc,SAAS,GAAG;EACrBb,QAAQ,EAAEc,kBAAE,CAACC,IAAI;EACjBd,oBAAoB,EAAEa,kBAAE,CAACC,IAAI;EAC7Bb,qBAAqB,EAAEY,kBAAE,CAACC,IAAI;EAC9BZ,KAAK,EAAEO,gBAAgB,CAACM,SAAS,CAACC;AACpC,CAAC;AAEDlB,UAAU,CAACmB,YAAY,GAAG;EACxBlB,QAAQ,EAAE,IAAI;EACdC,oBAAoB,EAAE,IAAI;EAC1BC,qBAAqB,EAAE;AACzB,CAAC;AAAC,eAEaQ,gBAAgB;AAAA"}
|
|
@@ -1,16 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
|
|
5
4
|
Object.defineProperty(exports, "__esModule", {
|
|
6
5
|
value: true
|
|
7
6
|
});
|
|
8
7
|
exports.default = ScalableRect;
|
|
9
|
-
|
|
10
8
|
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
11
|
-
|
|
12
9
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
13
|
-
|
|
14
10
|
/**
|
|
15
11
|
* The `<ScalableRect>` component implements container keeping given aspect
|
|
16
12
|
* ratio, while its width is altered.
|
|
@@ -28,6 +24,7 @@ function ScalableRect({
|
|
|
28
24
|
}) {
|
|
29
25
|
const aux = ratio.split(':');
|
|
30
26
|
const paddingBottom = `${100 * aux[1] / aux[0]}%`;
|
|
27
|
+
|
|
31
28
|
/* NOTE: In case the following code looks strange to you, mind that we want to
|
|
32
29
|
* allow the user to set custom styles on this component. If user passes in a
|
|
33
30
|
* "className" prop (possibly "styleName", but that one is converted to
|
|
@@ -35,7 +32,6 @@ function ScalableRect({
|
|
|
35
32
|
* should not interfere with the sizing behavior, thus we need an extra <div>
|
|
36
33
|
* level in this component; however, if user does not need a custom styling,
|
|
37
34
|
* we can save one level of HTML code, so we do it. */
|
|
38
|
-
|
|
39
35
|
const rect = /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
40
36
|
style: {
|
|
41
37
|
paddingBottom
|
|
@@ -51,7 +47,6 @@ function ScalableRect({
|
|
|
51
47
|
children: rect
|
|
52
48
|
}) : rect;
|
|
53
49
|
}
|
|
54
|
-
|
|
55
50
|
ScalableRect.defaultProps = {
|
|
56
51
|
children: null,
|
|
57
52
|
className: null,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["ScalableRect","children","className","ratio","aux","split","paddingBottom","rect","defaultProps","propTypes","PT","node","string"],"sources":["../../../../../src/shared/components/ScalableRect/index.jsx"],"sourcesContent":["import PT from 'prop-types';\n\nimport './style.scss';\n\n/**\n * The `<ScalableRect>` component implements container keeping given aspect\n * ratio, while its width is altered.\n *\n * **Children:** Component children are rendered as the component's content.\n * @param {object} props\n * @param {string} [props.className] CSS class for component container.\n * @param {string} [props.ratio=1:1] Ratio of the rendered rectangle sides,\n * in `W:H` form.\n */\nexport default function ScalableRect({ children, className, ratio }) {\n const aux = ratio.split(':');\n const paddingBottom = `${(100 * aux[1]) / aux[0]}%`;\n\n /* NOTE: In case the following code looks strange to you, mind that we want to\n * allow the user to set custom styles on this component. If user passes in a\n * \"className\" prop (possibly \"styleName\", but that one is converted to\n * \"className\" by Babel just before being passed into this component), it\n * should not interfere with the sizing behavior, thus we need an extra <div>\n * level in this component; however, if user does not need a custom styling,\n * we can save one level of HTML code, so we do it. */\n const rect = (\n <div\n style={{ paddingBottom }}\n styleName=\"container\"\n >\n <div styleName=\"wrapper\">\n {children}\n </div>\n </div>\n );\n return className ? (\n <div className={className}>\n {rect}\n </div>\n ) : rect;\n}\n\nScalableRect.defaultProps = {\n children: null,\n className: null,\n ratio: '1:1',\n};\n\nScalableRect.propTypes = {\n children: PT.node,\n className: PT.string,\n ratio: PT.string,\n};\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","names":["ScalableRect","children","className","ratio","aux","split","paddingBottom","rect","defaultProps","propTypes","PT","node","string"],"sources":["../../../../../src/shared/components/ScalableRect/index.jsx"],"sourcesContent":["import PT from 'prop-types';\n\nimport './style.scss';\n\n/**\n * The `<ScalableRect>` component implements container keeping given aspect\n * ratio, while its width is altered.\n *\n * **Children:** Component children are rendered as the component's content.\n * @param {object} props\n * @param {string} [props.className] CSS class for component container.\n * @param {string} [props.ratio=1:1] Ratio of the rendered rectangle sides,\n * in `W:H` form.\n */\nexport default function ScalableRect({ children, className, ratio }) {\n const aux = ratio.split(':');\n const paddingBottom = `${(100 * aux[1]) / aux[0]}%`;\n\n /* NOTE: In case the following code looks strange to you, mind that we want to\n * allow the user to set custom styles on this component. If user passes in a\n * \"className\" prop (possibly \"styleName\", but that one is converted to\n * \"className\" by Babel just before being passed into this component), it\n * should not interfere with the sizing behavior, thus we need an extra <div>\n * level in this component; however, if user does not need a custom styling,\n * we can save one level of HTML code, so we do it. */\n const rect = (\n <div\n style={{ paddingBottom }}\n styleName=\"container\"\n >\n <div styleName=\"wrapper\">\n {children}\n </div>\n </div>\n );\n return className ? (\n <div className={className}>\n {rect}\n </div>\n ) : rect;\n}\n\nScalableRect.defaultProps = {\n children: null,\n className: null,\n ratio: '1:1',\n};\n\nScalableRect.propTypes = {\n children: PT.node,\n className: PT.string,\n ratio: PT.string,\n};\n"],"mappings":";;;;;;;AAAA;AAA4B;AAI5B;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACe,SAASA,YAAY,CAAC;EAAEC,QAAQ;EAAEC,SAAS;EAAEC;AAAM,CAAC,EAAE;EACnE,MAAMC,GAAG,GAAGD,KAAK,CAACE,KAAK,CAAC,GAAG,CAAC;EAC5B,MAAMC,aAAa,GAAI,GAAG,GAAG,GAAGF,GAAG,CAAC,CAAC,CAAC,GAAIA,GAAG,CAAC,CAAC,CAAE,GAAE;;EAEnD;AACF;AACA;AACA;AACA;AACA;AACA;EACE,MAAMG,IAAI,gBACR;IACE,KAAK,EAAE;MAAED;IAAc,CAAE;IACzB,SAAS,EAAC,yFAAW;IAAA,uBAErB;MAAK,SAAS,EAAC,uFAAS;MAAA,UACrBL;IAAQ;EACL,EAET;EACD,OAAOC,SAAS,gBACd;IAAK,SAAS,EAAEA,SAAU;IAAA,UACvBK;EAAI,EACD,GACJA,IAAI;AACV;AAEAP,YAAY,CAACQ,YAAY,GAAG;EAC1BP,QAAQ,EAAE,IAAI;EACdC,SAAS,EAAE,IAAI;EACfC,KAAK,EAAE;AACT,CAAC;AAEDH,YAAY,CAACS,SAAS,GAAG;EACvBR,QAAQ,EAAES,kBAAE,CAACC,IAAI;EACjBT,SAAS,EAAEQ,kBAAE,CAACE,MAAM;EACpBT,KAAK,EAAEO,kBAAE,CAACE;AACZ,CAAC"}
|
|
@@ -1,18 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
|
|
5
4
|
Object.defineProperty(exports, "__esModule", {
|
|
6
5
|
value: true
|
|
7
6
|
});
|
|
8
7
|
exports.default = void 0;
|
|
9
|
-
|
|
10
8
|
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
11
|
-
|
|
12
9
|
var _reactThemes = _interopRequireDefault(require("@dr.pogodin/react-themes"));
|
|
13
|
-
|
|
14
10
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
15
|
-
|
|
16
11
|
const defaultTheme = {
|
|
17
12
|
"context": "-dr-pogodin-react-utils___src-shared-components-Throbber-theme___context___uIObt7",
|
|
18
13
|
"ad": "-dr-pogodin-react-utils___src-shared-components-Throbber-theme___ad___XIxe9o",
|
|
@@ -30,7 +25,6 @@ const defaultTheme = {
|
|
|
30
25
|
* @param {...any} [props....]
|
|
31
26
|
* [Other theming properties](https://www.npmjs.com/package/@dr.pogodin/react-themes#themed-component-properties)
|
|
32
27
|
*/
|
|
33
|
-
|
|
34
28
|
function Throbber({
|
|
35
29
|
theme
|
|
36
30
|
}) {
|
|
@@ -45,7 +39,6 @@ function Throbber({
|
|
|
45
39
|
})]
|
|
46
40
|
});
|
|
47
41
|
}
|
|
48
|
-
|
|
49
42
|
Throbber.defaultProps = {
|
|
50
43
|
theme: {}
|
|
51
44
|
};
|
|
@@ -55,8 +48,6 @@ Throbber.propTypes = {
|
|
|
55
48
|
circle: _propTypes.default.string
|
|
56
49
|
})
|
|
57
50
|
};
|
|
58
|
-
|
|
59
51
|
var _default = (0, _reactThemes.default)('Throbber', ['circle', 'container'], defaultTheme)(Throbber);
|
|
60
|
-
|
|
61
52
|
exports.default = _default;
|
|
62
53
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["Throbber","theme","container","circle","defaultProps","propTypes","PT","shape","string","themed","defaultTheme"],"sources":["../../../../../src/shared/components/Throbber/index.jsx"],"sourcesContent":["import PT from 'prop-types';\nimport themed from '@dr.pogodin/react-themes';\n\nimport defaultTheme from './theme.scss';\n\n/**\n * Throbber is an \"action in progress\" indicator, which renders\n * three bouncing circles as a simple pending activity indicator,\n * and can be further themed to a certain degree.\n * @param {object} [props] Component properties.\n * @param {ThrobberTheme} [props.theme] _Ad hoc_ theme.\n * @param {...any} [props....]\n * [Other theming properties](https://www.npmjs.com/package/@dr.pogodin/react-themes#themed-component-properties)\n */\nfunction Throbber({\n theme,\n}) {\n return (\n <span className={theme.container} styleName=\"container\">\n <span className={theme.circle} styleName=\"circle\" />\n <span className={theme.circle} styleName=\"circle\" />\n <span className={theme.circle} styleName=\"circle\" />\n </span>\n );\n}\n\nThrobber.defaultProps = {\n theme: {},\n};\n\nThrobber.propTypes = {\n theme: PT.shape({\n container: PT.string,\n circle: PT.string,\n }),\n};\n\nexport default themed('Throbber', [\n 'circle',\n 'container',\n], defaultTheme)(Throbber);\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","names":["Throbber","theme","container","circle","defaultProps","propTypes","PT","shape","string","themed","defaultTheme"],"sources":["../../../../../src/shared/components/Throbber/index.jsx"],"sourcesContent":["import PT from 'prop-types';\nimport themed from '@dr.pogodin/react-themes';\n\nimport defaultTheme from './theme.scss';\n\n/**\n * Throbber is an \"action in progress\" indicator, which renders\n * three bouncing circles as a simple pending activity indicator,\n * and can be further themed to a certain degree.\n * @param {object} [props] Component properties.\n * @param {ThrobberTheme} [props.theme] _Ad hoc_ theme.\n * @param {...any} [props....]\n * [Other theming properties](https://www.npmjs.com/package/@dr.pogodin/react-themes#themed-component-properties)\n */\nfunction Throbber({\n theme,\n}) {\n return (\n <span className={theme.container} styleName=\"container\">\n <span className={theme.circle} styleName=\"circle\" />\n <span className={theme.circle} styleName=\"circle\" />\n <span className={theme.circle} styleName=\"circle\" />\n </span>\n );\n}\n\nThrobber.defaultProps = {\n theme: {},\n};\n\nThrobber.propTypes = {\n theme: PT.shape({\n container: PT.string,\n circle: PT.string,\n }),\n};\n\nexport default themed('Throbber', [\n 'circle',\n 'container',\n], defaultTheme)(Throbber);\n"],"mappings":";;;;;;;AAAA;AACA;AAA8C;AAAA;EAAA;EAAA;EAAA;EAAA;EAAA;EAAA;AAAA;AAI9C;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAASA,QAAQ,CAAC;EAChBC;AACF,CAAC,EAAE;EACD,oBACE;IAAM,SAAS,GAAEA,KAAK,CAACC,SAAS,GAAfD,KAAK,CAACC,SAAS,oGAAC;IAAA,wBAC/B;MAAM,SAAS,GAAED,KAAK,CAACE,MAAM,GAAZF,KAAK,CAACE,MAAM;IAAC,EAAsB,eACpD;MAAM,SAAS,GAAEF,KAAK,CAACE,MAAM,GAAZF,KAAK,CAACE,MAAM;IAAC,EAAsB,eACpD;MAAM,SAAS,GAAEF,KAAK,CAACE,MAAM,GAAZF,KAAK,CAACE,MAAM;IAAC,EAAsB;EAAA,EAC/C;AAEX;AAEAH,QAAQ,CAACI,YAAY,GAAG;EACtBH,KAAK,EAAE,CAAC;AACV,CAAC;AAEDD,QAAQ,CAACK,SAAS,GAAG;EACnBJ,KAAK,EAAEK,kBAAE,CAACC,KAAK,CAAC;IACdL,SAAS,EAAEI,kBAAE,CAACE,MAAM;IACpBL,MAAM,EAAEG,kBAAE,CAACE;EACb,CAAC;AACH,CAAC;AAAC,eAEa,IAAAC,oBAAM,EAAC,UAAU,EAAE,CAChC,QAAQ,EACR,WAAW,CACZ,EAAEC,YAAY,CAAC,CAACV,QAAQ,CAAC;AAAA"}
|
|
@@ -1,24 +1,18 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
|
|
5
4
|
Object.defineProperty(exports, "__esModule", {
|
|
6
5
|
value: true
|
|
7
6
|
});
|
|
8
7
|
exports.default = exports.PLACEMENTS = void 0;
|
|
9
|
-
|
|
10
8
|
var _react = require("react");
|
|
11
|
-
|
|
12
9
|
var _reactDom = require("react-dom");
|
|
13
|
-
|
|
14
10
|
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
15
|
-
|
|
16
11
|
/**
|
|
17
12
|
* The actual tooltip component. It is rendered outside the regular document
|
|
18
13
|
* hierarchy, and with sub-components managed without React to achieve the best
|
|
19
14
|
* performance during animation.
|
|
20
15
|
*/
|
|
21
|
-
|
|
22
16
|
/* global document, window */
|
|
23
17
|
|
|
24
18
|
/* Valid placements of the rendered tooltip. They will be overriden when
|
|
@@ -32,6 +26,7 @@ const PLACEMENTS = {
|
|
|
32
26
|
exports.PLACEMENTS = PLACEMENTS;
|
|
33
27
|
const ARROW_STYLE_DOWN = ['border-bottom-color:transparent', 'border-left-color:transparent', 'border-right-color:transparent'].join(';');
|
|
34
28
|
const ARROW_STYLE_UP = ['border-top-color:transparent', 'border-left-color:transparent', 'border-right-color:transparent'].join(';');
|
|
29
|
+
|
|
35
30
|
/**
|
|
36
31
|
* Creates tooltip components.
|
|
37
32
|
* @ignore
|
|
@@ -40,7 +35,6 @@ const ARROW_STYLE_UP = ['border-top-color:transparent', 'border-left-color:trans
|
|
|
40
35
|
* @return {object} Object with DOM references to the container components:
|
|
41
36
|
* container, arrow, content.
|
|
42
37
|
*/
|
|
43
|
-
|
|
44
38
|
function createTooltipComponents(theme) {
|
|
45
39
|
const arrow = document.createElement('div');
|
|
46
40
|
if (theme.arrow) arrow.setAttribute('class', theme.arrow);
|
|
@@ -57,6 +51,7 @@ function createTooltipComponents(theme) {
|
|
|
57
51
|
content
|
|
58
52
|
};
|
|
59
53
|
}
|
|
54
|
+
|
|
60
55
|
/**
|
|
61
56
|
* Generates bounding client rectangles for tooltip components.
|
|
62
57
|
* @ignore
|
|
@@ -66,21 +61,18 @@ function createTooltipComponents(theme) {
|
|
|
66
61
|
* @return {{ arrow: object, container}} Object holding tooltip rectangles in
|
|
67
62
|
* two fields.
|
|
68
63
|
*/
|
|
69
|
-
|
|
70
|
-
|
|
71
64
|
function calcTooltipRects(tooltip) {
|
|
72
65
|
return {
|
|
73
66
|
arrow: tooltip.arrow.getBoundingClientRect(),
|
|
74
67
|
container: tooltip.container.getBoundingClientRect()
|
|
75
68
|
};
|
|
76
69
|
}
|
|
70
|
+
|
|
77
71
|
/**
|
|
78
72
|
* Calculates the document viewport size.
|
|
79
73
|
* @ignore
|
|
80
74
|
* @return {{x, y, width, height}}
|
|
81
75
|
*/
|
|
82
|
-
|
|
83
|
-
|
|
84
76
|
function calcViewportRect() {
|
|
85
77
|
const {
|
|
86
78
|
pageXOffset,
|
|
@@ -99,6 +91,7 @@ function calcViewportRect() {
|
|
|
99
91
|
bottom: pageYOffset + clientHeight
|
|
100
92
|
};
|
|
101
93
|
}
|
|
94
|
+
|
|
102
95
|
/**
|
|
103
96
|
* Calculates tooltip and arrow positions for the placement just above
|
|
104
97
|
* the cursor.
|
|
@@ -115,8 +108,6 @@ function calcViewportRect() {
|
|
|
115
108
|
* - {number} containerY
|
|
116
109
|
* - {string} baseArrowStyle
|
|
117
110
|
*/
|
|
118
|
-
|
|
119
|
-
|
|
120
111
|
function calcPositionAboveXY(x, y, tooltipRects) {
|
|
121
112
|
const {
|
|
122
113
|
arrow,
|
|
@@ -133,6 +124,7 @@ function calcPositionAboveXY(x, y, tooltipRects) {
|
|
|
133
124
|
baseArrowStyle: ARROW_STYLE_DOWN
|
|
134
125
|
};
|
|
135
126
|
}
|
|
127
|
+
|
|
136
128
|
/*
|
|
137
129
|
const HIT = {
|
|
138
130
|
NONE: false,
|
|
@@ -150,7 +142,6 @@ const HIT = {
|
|
|
150
142
|
* @param {object} viewportRect
|
|
151
143
|
* @return {HIT}
|
|
152
144
|
*/
|
|
153
|
-
|
|
154
145
|
/*
|
|
155
146
|
function checkViewportFit(pos, tooltipRects, viewportRect) {
|
|
156
147
|
const { containerX, containerY } = pos;
|
|
@@ -169,7 +160,6 @@ function checkViewportFit(pos, tooltipRects, viewportRect) {
|
|
|
169
160
|
* @param {number} pageXOffset
|
|
170
161
|
* @param {number} pageXWidth
|
|
171
162
|
*/
|
|
172
|
-
|
|
173
163
|
/*
|
|
174
164
|
function xPageFitCorrection(x, y, pos, pageXOffset, pageXWidth) {
|
|
175
165
|
if (pos.containerX < pageXOffset + 6) {
|
|
@@ -200,56 +190,47 @@ function xPageFitCorrection(x, y, pos, pageXOffset, pageXWidth) {
|
|
|
200
190
|
* @param {object} tooltip.arrow DOM reference to the tooltip arrow.
|
|
201
191
|
* @param {object} tooltip.container DOM reference to the tooltip container.
|
|
202
192
|
*/
|
|
203
|
-
|
|
204
|
-
|
|
205
193
|
function setComponentPositions(pageX, pageY, placement, element, tooltip) {
|
|
206
194
|
const tooltipRects = calcTooltipRects(tooltip);
|
|
207
195
|
const viewportRect = calcViewportRect();
|
|
208
|
-
/* Default container coords: tooltip at the top. */
|
|
209
196
|
|
|
197
|
+
/* Default container coords: tooltip at the top. */
|
|
210
198
|
const pos = calcPositionAboveXY(pageX, pageY, tooltipRects);
|
|
211
|
-
|
|
212
199
|
if (pos.containerX < viewportRect.left + 6) {
|
|
213
200
|
pos.containerX = viewportRect.left + 6;
|
|
214
201
|
pos.arrowX = Math.max(6, pageX - pos.containerX - tooltipRects.arrow.width / 2);
|
|
215
202
|
} else {
|
|
216
203
|
const maxX = viewportRect.right - 6 - tooltipRects.container.width;
|
|
217
|
-
|
|
218
204
|
if (pos.containerX > maxX) {
|
|
219
205
|
pos.containerX = maxX;
|
|
220
206
|
pos.arrowX = Math.min(tooltipRects.container.width - 6, pageX - pos.containerX - tooltipRects.arrow.width / 2);
|
|
221
207
|
}
|
|
222
208
|
}
|
|
223
|
-
/* If tooltip has not enough space on top - make it bottom tooltip. */
|
|
224
|
-
|
|
225
209
|
|
|
210
|
+
/* If tooltip has not enough space on top - make it bottom tooltip. */
|
|
226
211
|
if (pos.containerY < viewportRect.top + 6) {
|
|
227
212
|
pos.containerY += tooltipRects.container.height + 2 * tooltipRects.arrow.height;
|
|
228
213
|
pos.arrowY -= tooltipRects.container.height + tooltipRects.arrow.height;
|
|
229
214
|
pos.baseArrowStyle = ARROW_STYLE_UP;
|
|
230
215
|
}
|
|
231
|
-
|
|
232
216
|
const containerStyle = `left:${pos.containerX}px;top:${pos.containerY}px`;
|
|
233
217
|
tooltip.container.setAttribute('style', containerStyle);
|
|
234
218
|
const arrowStyle = `${pos.baseArrowStyle};left:${pos.arrowX}px;top:${pos.arrowY}px`;
|
|
235
219
|
tooltip.arrow.setAttribute('style', arrowStyle);
|
|
236
220
|
}
|
|
237
|
-
/* The Tooltip component itself. */
|
|
238
|
-
|
|
239
221
|
|
|
222
|
+
/* The Tooltip component itself. */
|
|
240
223
|
const Tooltip = /*#__PURE__*/(0, _react.forwardRef)(({
|
|
241
224
|
children,
|
|
242
225
|
theme
|
|
243
226
|
}, ref) => {
|
|
244
227
|
const [components, setComponents] = (0, _react.useState)(null);
|
|
245
|
-
|
|
246
228
|
const pointTo = (pageX, pageY, placement, element) => components && setComponentPositions(pageX, pageY, placement, element, components);
|
|
247
|
-
|
|
248
229
|
(0, _react.useImperativeHandle)(ref, () => ({
|
|
249
230
|
pointTo
|
|
250
231
|
}));
|
|
251
|
-
/* Inits and destroys tooltip components. */
|
|
252
232
|
|
|
233
|
+
/* Inits and destroys tooltip components. */
|
|
253
234
|
(0, _react.useEffect)(() => {
|
|
254
235
|
const x = createTooltipComponents(theme);
|
|
255
236
|
setComponents(x);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Tooltip.js","names":["PLACEMENTS","ABOVE_CURSOR","ABOVE_ELEMENT","BELOW_CURSOR","BELOW_ELEMENT","ARROW_STYLE_DOWN","join","ARROW_STYLE_UP","createTooltipComponents","theme","arrow","document","createElement","setAttribute","content","container","appendChild","body","calcTooltipRects","tooltip","getBoundingClientRect","calcViewportRect","pageXOffset","pageYOffset","window","documentElement","clientHeight","clientWidth","left","right","top","bottom","calcPositionAboveXY","x","y","tooltipRects","arrowX","width","arrowY","height","containerX","containerY","baseArrowStyle","setComponentPositions","pageX","pageY","placement","element","viewportRect","pos","Math","max","maxX","min","containerStyle","arrowStyle","Tooltip","forwardRef","children","ref","components","setComponents","useState","pointTo","useImperativeHandle","useEffect","removeChild","createPortal","propTypes","PT","node","shape","isRequired","defaultProps"],"sources":["../../../../../src/shared/components/WithTooltip/Tooltip.jsx"],"sourcesContent":["/**\n * The actual tooltip component. It is rendered outside the regular document\n * hierarchy, and with sub-components managed without React to achieve the best\n * performance during animation.\n */\n/* global document, window */\n\nimport {\n forwardRef,\n useEffect,\n useImperativeHandle,\n useState,\n} from 'react';\nimport { createPortal } from 'react-dom';\n\nimport PT from 'prop-types';\n\n/* Valid placements of the rendered tooltip. They will be overriden when\n * necessary to fit the tooltip within the viewport. */\nexport const PLACEMENTS = {\n ABOVE_CURSOR: 'ABOVE_CURSOR',\n ABOVE_ELEMENT: 'ABOVE_ELEMENT',\n BELOW_CURSOR: 'BELOW_CURSOR',\n BELOW_ELEMENT: 'BELOW_ELEMENT',\n};\n\nconst ARROW_STYLE_DOWN = [\n 'border-bottom-color:transparent',\n 'border-left-color:transparent',\n 'border-right-color:transparent',\n].join(';');\n\nconst ARROW_STYLE_UP = [\n 'border-top-color:transparent',\n 'border-left-color:transparent',\n 'border-right-color:transparent',\n].join(';');\n\n/**\n * Creates tooltip components.\n * @ignore\n * @param {object} theme Themes to use for tooltip container, arrow,\n * and content.\n * @return {object} Object with DOM references to the container components:\n * container, arrow, content.\n */\nfunction createTooltipComponents(theme) {\n const arrow = document.createElement('div');\n if (theme.arrow) arrow.setAttribute('class', theme.arrow);\n\n const content = document.createElement('div');\n if (theme.content) content.setAttribute('class', theme.content);\n\n const container = document.createElement('div');\n if (theme.container) container.setAttribute('class', theme.container);\n\n container.appendChild(arrow);\n container.appendChild(content);\n document.body.appendChild(container);\n\n return { container, arrow, content };\n}\n\n/**\n * Generates bounding client rectangles for tooltip components.\n * @ignore\n * @param {object} tooltip DOM references to the tooltip components.\n * @param {object} tooltip.arrow\n * @param {object} tooltip.container\n * @return {{ arrow: object, container}} Object holding tooltip rectangles in\n * two fields.\n */\nfunction calcTooltipRects(tooltip) {\n return {\n arrow: tooltip.arrow.getBoundingClientRect(),\n container: tooltip.container.getBoundingClientRect(),\n };\n}\n\n/**\n * Calculates the document viewport size.\n * @ignore\n * @return {{x, y, width, height}}\n */\nfunction calcViewportRect() {\n const { pageXOffset, pageYOffset } = window;\n const { documentElement: { clientHeight, clientWidth } } = document;\n return {\n left: pageXOffset,\n right: pageXOffset + clientWidth,\n top: pageYOffset,\n bottom: pageYOffset + clientHeight,\n };\n}\n\n/**\n * Calculates tooltip and arrow positions for the placement just above\n * the cursor.\n * @ignore\n * @param {number} x Cursor page-x position.\n * @param {number} y Cursor page-y position.\n * @param {object} tooltipRects Bounding client rectangles of tooltip parts.\n * @param {object} tooltipRects.arrow\n * @param {object} tooltipRects.container\n * @return {object} Contains the following fields:\n * - {number} arrowX\n * - {number} arrowY\n * - {number} containerX\n * - {number} containerY\n * - {string} baseArrowStyle\n */\nfunction calcPositionAboveXY(x, y, tooltipRects) {\n const { arrow, container } = tooltipRects;\n return {\n arrowX: 0.5 * (container.width - arrow.width),\n arrowY: container.height,\n containerX: x - container.width / 2,\n containerY: y - container.height - arrow.height / 1.5,\n\n // TODO: Instead of already setting the base style here, we should\n // introduce a set of constants for arrow directions, which will help\n // to do checks dependant on the arrow direction.\n baseArrowStyle: ARROW_STYLE_DOWN,\n };\n}\n\n/*\nconst HIT = {\n NONE: false,\n LEFT: 'LEFT',\n RIGHT: 'RIGHT',\n TOP: 'TOP',\n BOTTOM: 'BOTTOM',\n};\n*/\n\n/**\n * Checks whether\n * @param {object} pos\n * @param {object} tooltipRects\n * @param {object} viewportRect\n * @return {HIT}\n */\n/*\nfunction checkViewportFit(pos, tooltipRects, viewportRect) {\n const { containerX, containerY } = pos;\n if (containerX < viewportRect.left + 6) return HIT.LEFT;\n if (containerX > viewportRect.right - 6) return HIT.RIGHT;\n return HIT.NONE;\n}\n*/\n\n/**\n * Shifts tooltip horizontally to fit into the viewport, while keeping\n * the arrow pointed to the XY point.\n * @param {number} x\n * @param {number} y\n * @param {object} pos\n * @param {number} pageXOffset\n * @param {number} pageXWidth\n */\n/*\nfunction xPageFitCorrection(x, y, pos, pageXOffset, pageXWidth) {\n if (pos.containerX < pageXOffset + 6) {\n pos.containerX = pageXOffset + 6;\n pos.arrowX = Math.max(6, pageX - containerX - arrowRect.width / 2);\n } else {\n const maxX = pageXOffset + docRect.width - containerRect.width - 6;\n if (containerX > maxX) {\n containerX = maxX;\n arrowX = Math.min(\n containerRect.width - 6,\n pageX - containerX - arrowRect.width / 2,\n );\n }\n }\n}\n*/\n\n/**\n * Sets positions of tooltip components to point the tooltip to the specified\n * page point.\n * @ignore\n * @param {number} pageX\n * @param {number} pageY\n * @param {PLACEMENTS} placement\n * @param {object} element DOM reference to the element wrapped by the tooltip.\n * @param {object} tooltip\n * @param {object} tooltip.arrow DOM reference to the tooltip arrow.\n * @param {object} tooltip.container DOM reference to the tooltip container.\n */\nfunction setComponentPositions(\n pageX,\n pageY,\n placement,\n element,\n tooltip,\n) {\n const tooltipRects = calcTooltipRects(tooltip);\n const viewportRect = calcViewportRect();\n\n /* Default container coords: tooltip at the top. */\n const pos = calcPositionAboveXY(pageX, pageY, tooltipRects);\n\n if (pos.containerX < viewportRect.left + 6) {\n pos.containerX = viewportRect.left + 6;\n pos.arrowX = Math.max(\n 6,\n pageX - pos.containerX - tooltipRects.arrow.width / 2,\n );\n } else {\n const maxX = viewportRect.right - 6 - tooltipRects.container.width;\n if (pos.containerX > maxX) {\n pos.containerX = maxX;\n pos.arrowX = Math.min(\n tooltipRects.container.width - 6,\n pageX - pos.containerX - tooltipRects.arrow.width / 2,\n );\n }\n }\n\n /* If tooltip has not enough space on top - make it bottom tooltip. */\n if (pos.containerY < viewportRect.top + 6) {\n pos.containerY += tooltipRects.container.height\n + 2 * tooltipRects.arrow.height;\n pos.arrowY -= tooltipRects.container.height\n + tooltipRects.arrow.height;\n pos.baseArrowStyle = ARROW_STYLE_UP;\n }\n\n const containerStyle = `left:${pos.containerX}px;top:${pos.containerY}px`;\n tooltip.container.setAttribute('style', containerStyle);\n\n const arrowStyle = `${pos.baseArrowStyle};left:${pos.arrowX}px;top:${pos.arrowY}px`;\n tooltip.arrow.setAttribute('style', arrowStyle);\n}\n\n/* The Tooltip component itself. */\nconst Tooltip = forwardRef(({ children, theme }, ref) => {\n const [components, setComponents] = useState(null);\n\n const pointTo = (pageX, pageY, placement, element) => components\n && setComponentPositions(pageX, pageY, placement, element, components);\n useImperativeHandle(ref, () => ({ pointTo }));\n\n /* Inits and destroys tooltip components. */\n useEffect(() => {\n const x = createTooltipComponents(theme);\n setComponents(x);\n return () => {\n document.body.removeChild(x.container);\n setComponents(null);\n };\n }, [theme]);\n\n return components ? createPortal(children, components.content) : null;\n});\n\nTooltip.propTypes = {\n children: PT.node,\n theme: PT.shape().isRequired,\n};\n\nTooltip.defaultProps = {\n children: null,\n};\n\nexport default Tooltip;\n"],"mappings":";;;;;;;;;AAOA;;AAMA;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B,CAAD,CAAb;IACA,OAAO,MAAM;MACXtB,QAAQ,CAACM,IAAT,CAAciD,WAAd,CAA0BjC,CAAC,CAAClB,SAA5B;MACA8C,aAAa,CAAC,IAAD,CAAb;IACD,CAHD;EAID,CAPD,EAOG,CAACpD,KAAD,CAPH;EASA,OAAOmD,UAAU,gBAAG,IAAAO,sBAAA,EAAaT,QAAb,EAAuBE,UAAU,CAAC9C,OAAlC,CAAH,GAAgD,IAAjE;AACD,CAlBe,CAAhB;AAoBA0C,OAAO,CAACY,SAAR,GAAoB;EAClBV,QAAQ,EAAEW,kBAAA,CAAGC,IADK;EAElB7D,KAAK,EAAE4D,kBAAA,CAAGE,KAAH,GAAWC;AAFA,CAApB;AAKAhB,OAAO,CAACiB,YAAR,GAAuB;EACrBf,QAAQ,EAAE;AADW,CAAvB;eAIeF,O"}
|
|
1
|
+
{"version":3,"file":"Tooltip.js","names":["PLACEMENTS","ABOVE_CURSOR","ABOVE_ELEMENT","BELOW_CURSOR","BELOW_ELEMENT","ARROW_STYLE_DOWN","join","ARROW_STYLE_UP","createTooltipComponents","theme","arrow","document","createElement","setAttribute","content","container","appendChild","body","calcTooltipRects","tooltip","getBoundingClientRect","calcViewportRect","pageXOffset","pageYOffset","window","documentElement","clientHeight","clientWidth","left","right","top","bottom","calcPositionAboveXY","x","y","tooltipRects","arrowX","width","arrowY","height","containerX","containerY","baseArrowStyle","setComponentPositions","pageX","pageY","placement","element","viewportRect","pos","Math","max","maxX","min","containerStyle","arrowStyle","Tooltip","forwardRef","children","ref","components","setComponents","useState","pointTo","useImperativeHandle","useEffect","removeChild","createPortal","propTypes","PT","node","shape","isRequired","defaultProps"],"sources":["../../../../../src/shared/components/WithTooltip/Tooltip.jsx"],"sourcesContent":["/**\n * The actual tooltip component. It is rendered outside the regular document\n * hierarchy, and with sub-components managed without React to achieve the best\n * performance during animation.\n */\n/* global document, window */\n\nimport {\n forwardRef,\n useEffect,\n useImperativeHandle,\n useState,\n} from 'react';\nimport { createPortal } from 'react-dom';\n\nimport PT from 'prop-types';\n\n/* Valid placements of the rendered tooltip. They will be overriden when\n * necessary to fit the tooltip within the viewport. */\nexport const PLACEMENTS = {\n ABOVE_CURSOR: 'ABOVE_CURSOR',\n ABOVE_ELEMENT: 'ABOVE_ELEMENT',\n BELOW_CURSOR: 'BELOW_CURSOR',\n BELOW_ELEMENT: 'BELOW_ELEMENT',\n};\n\nconst ARROW_STYLE_DOWN = [\n 'border-bottom-color:transparent',\n 'border-left-color:transparent',\n 'border-right-color:transparent',\n].join(';');\n\nconst ARROW_STYLE_UP = [\n 'border-top-color:transparent',\n 'border-left-color:transparent',\n 'border-right-color:transparent',\n].join(';');\n\n/**\n * Creates tooltip components.\n * @ignore\n * @param {object} theme Themes to use for tooltip container, arrow,\n * and content.\n * @return {object} Object with DOM references to the container components:\n * container, arrow, content.\n */\nfunction createTooltipComponents(theme) {\n const arrow = document.createElement('div');\n if (theme.arrow) arrow.setAttribute('class', theme.arrow);\n\n const content = document.createElement('div');\n if (theme.content) content.setAttribute('class', theme.content);\n\n const container = document.createElement('div');\n if (theme.container) container.setAttribute('class', theme.container);\n\n container.appendChild(arrow);\n container.appendChild(content);\n document.body.appendChild(container);\n\n return { container, arrow, content };\n}\n\n/**\n * Generates bounding client rectangles for tooltip components.\n * @ignore\n * @param {object} tooltip DOM references to the tooltip components.\n * @param {object} tooltip.arrow\n * @param {object} tooltip.container\n * @return {{ arrow: object, container}} Object holding tooltip rectangles in\n * two fields.\n */\nfunction calcTooltipRects(tooltip) {\n return {\n arrow: tooltip.arrow.getBoundingClientRect(),\n container: tooltip.container.getBoundingClientRect(),\n };\n}\n\n/**\n * Calculates the document viewport size.\n * @ignore\n * @return {{x, y, width, height}}\n */\nfunction calcViewportRect() {\n const { pageXOffset, pageYOffset } = window;\n const { documentElement: { clientHeight, clientWidth } } = document;\n return {\n left: pageXOffset,\n right: pageXOffset + clientWidth,\n top: pageYOffset,\n bottom: pageYOffset + clientHeight,\n };\n}\n\n/**\n * Calculates tooltip and arrow positions for the placement just above\n * the cursor.\n * @ignore\n * @param {number} x Cursor page-x position.\n * @param {number} y Cursor page-y position.\n * @param {object} tooltipRects Bounding client rectangles of tooltip parts.\n * @param {object} tooltipRects.arrow\n * @param {object} tooltipRects.container\n * @return {object} Contains the following fields:\n * - {number} arrowX\n * - {number} arrowY\n * - {number} containerX\n * - {number} containerY\n * - {string} baseArrowStyle\n */\nfunction calcPositionAboveXY(x, y, tooltipRects) {\n const { arrow, container } = tooltipRects;\n return {\n arrowX: 0.5 * (container.width - arrow.width),\n arrowY: container.height,\n containerX: x - container.width / 2,\n containerY: y - container.height - arrow.height / 1.5,\n\n // TODO: Instead of already setting the base style here, we should\n // introduce a set of constants for arrow directions, which will help\n // to do checks dependant on the arrow direction.\n baseArrowStyle: ARROW_STYLE_DOWN,\n };\n}\n\n/*\nconst HIT = {\n NONE: false,\n LEFT: 'LEFT',\n RIGHT: 'RIGHT',\n TOP: 'TOP',\n BOTTOM: 'BOTTOM',\n};\n*/\n\n/**\n * Checks whether\n * @param {object} pos\n * @param {object} tooltipRects\n * @param {object} viewportRect\n * @return {HIT}\n */\n/*\nfunction checkViewportFit(pos, tooltipRects, viewportRect) {\n const { containerX, containerY } = pos;\n if (containerX < viewportRect.left + 6) return HIT.LEFT;\n if (containerX > viewportRect.right - 6) return HIT.RIGHT;\n return HIT.NONE;\n}\n*/\n\n/**\n * Shifts tooltip horizontally to fit into the viewport, while keeping\n * the arrow pointed to the XY point.\n * @param {number} x\n * @param {number} y\n * @param {object} pos\n * @param {number} pageXOffset\n * @param {number} pageXWidth\n */\n/*\nfunction xPageFitCorrection(x, y, pos, pageXOffset, pageXWidth) {\n if (pos.containerX < pageXOffset + 6) {\n pos.containerX = pageXOffset + 6;\n pos.arrowX = Math.max(6, pageX - containerX - arrowRect.width / 2);\n } else {\n const maxX = pageXOffset + docRect.width - containerRect.width - 6;\n if (containerX > maxX) {\n containerX = maxX;\n arrowX = Math.min(\n containerRect.width - 6,\n pageX - containerX - arrowRect.width / 2,\n );\n }\n }\n}\n*/\n\n/**\n * Sets positions of tooltip components to point the tooltip to the specified\n * page point.\n * @ignore\n * @param {number} pageX\n * @param {number} pageY\n * @param {PLACEMENTS} placement\n * @param {object} element DOM reference to the element wrapped by the tooltip.\n * @param {object} tooltip\n * @param {object} tooltip.arrow DOM reference to the tooltip arrow.\n * @param {object} tooltip.container DOM reference to the tooltip container.\n */\nfunction setComponentPositions(\n pageX,\n pageY,\n placement,\n element,\n tooltip,\n) {\n const tooltipRects = calcTooltipRects(tooltip);\n const viewportRect = calcViewportRect();\n\n /* Default container coords: tooltip at the top. */\n const pos = calcPositionAboveXY(pageX, pageY, tooltipRects);\n\n if (pos.containerX < viewportRect.left + 6) {\n pos.containerX = viewportRect.left + 6;\n pos.arrowX = Math.max(\n 6,\n pageX - pos.containerX - tooltipRects.arrow.width / 2,\n );\n } else {\n const maxX = viewportRect.right - 6 - tooltipRects.container.width;\n if (pos.containerX > maxX) {\n pos.containerX = maxX;\n pos.arrowX = Math.min(\n tooltipRects.container.width - 6,\n pageX - pos.containerX - tooltipRects.arrow.width / 2,\n );\n }\n }\n\n /* If tooltip has not enough space on top - make it bottom tooltip. */\n if (pos.containerY < viewportRect.top + 6) {\n pos.containerY += tooltipRects.container.height\n + 2 * tooltipRects.arrow.height;\n pos.arrowY -= tooltipRects.container.height\n + tooltipRects.arrow.height;\n pos.baseArrowStyle = ARROW_STYLE_UP;\n }\n\n const containerStyle = `left:${pos.containerX}px;top:${pos.containerY}px`;\n tooltip.container.setAttribute('style', containerStyle);\n\n const arrowStyle = `${pos.baseArrowStyle};left:${pos.arrowX}px;top:${pos.arrowY}px`;\n tooltip.arrow.setAttribute('style', arrowStyle);\n}\n\n/* The Tooltip component itself. */\nconst Tooltip = forwardRef(({ children, theme }, ref) => {\n const [components, setComponents] = useState(null);\n\n const pointTo = (pageX, pageY, placement, element) => components\n && setComponentPositions(pageX, pageY, placement, element, components);\n useImperativeHandle(ref, () => ({ pointTo }));\n\n /* Inits and destroys tooltip components. */\n useEffect(() => {\n const x = createTooltipComponents(theme);\n setComponents(x);\n return () => {\n document.body.removeChild(x.container);\n setComponents(null);\n };\n }, [theme]);\n\n return components ? createPortal(children, components.content) : null;\n});\n\nTooltip.propTypes = {\n children: PT.node,\n theme: PT.shape().isRequired,\n};\n\nTooltip.defaultProps = {\n children: null,\n};\n\nexport default Tooltip;\n"],"mappings":";;;;;;;AAOA;AAMA;AAEA;AAfA;AACA;AACA;AACA;AACA;AACA;;AAYA;AACA;AACO,MAAMA,UAAU,GAAG;EACxBC,YAAY,EAAE,cAAc;EAC5BC,aAAa,EAAE,eAAe;EAC9BC,YAAY,EAAE,cAAc;EAC5BC,aAAa,EAAE;AACjB,CAAC;AAAC;AAEF,MAAMC,gBAAgB,GAAG,CACvB,iCAAiC,EACjC,+BAA+B,EAC/B,gCAAgC,CACjC,CAACC,IAAI,CAAC,GAAG,CAAC;AAEX,MAAMC,cAAc,GAAG,CACrB,8BAA8B,EAC9B,+BAA+B,EAC/B,gCAAgC,CACjC,CAACD,IAAI,CAAC,GAAG,CAAC;;AAEX;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAASE,uBAAuB,CAACC,KAAK,EAAE;EACtC,MAAMC,KAAK,GAAGC,QAAQ,CAACC,aAAa,CAAC,KAAK,CAAC;EAC3C,IAAIH,KAAK,CAACC,KAAK,EAAEA,KAAK,CAACG,YAAY,CAAC,OAAO,EAAEJ,KAAK,CAACC,KAAK,CAAC;EAEzD,MAAMI,OAAO,GAAGH,QAAQ,CAACC,aAAa,CAAC,KAAK,CAAC;EAC7C,IAAIH,KAAK,CAACK,OAAO,EAAEA,OAAO,CAACD,YAAY,CAAC,OAAO,EAAEJ,KAAK,CAACK,OAAO,CAAC;EAE/D,MAAMC,SAAS,GAAGJ,QAAQ,CAACC,aAAa,CAAC,KAAK,CAAC;EAC/C,IAAIH,KAAK,CAACM,SAAS,EAAEA,SAAS,CAACF,YAAY,CAAC,OAAO,EA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AEC,KAAK,EAAEC,SAAS,EAAEC,OAAO,EAAEa,UAAU,CAAC;EACxE,IAAAI,0BAAmB,EAACL,GAAG,EAAE,OAAO;IAAEI;EAAQ,CAAC,CAAC,CAAC;;EAE7C;EACA,IAAAE,gBAAS,EAAC,MAAM;IACd,MAAMhC,CAAC,GAAGzB,uBAAuB,CAACC,KAAK,CAAC;IACxCoD,aAAa,CAAC5B,CAAC,CAAC;IAChB,OAAO,MAAM;MACXtB,QAAQ,CAACM,IAAI,CAACiD,WAAW,CAACjC,CAAC,CAAClB,SAAS,CAAC;MACtC8C,aAAa,CAAC,IAAI,CAAC;IACrB,CAAC;EACH,CAAC,EAAE,CAACpD,KAAK,CAAC,CAAC;EAEX,OAAOmD,UAAU,gBAAG,IAAAO,sBAAY,EAACT,QAAQ,EAAEE,UAAU,CAAC9C,OAAO,CAAC,GAAG,IAAI;AACvE,CAAC,CAAC;AAEF0C,OAAO,CAACY,SAAS,GAAG;EAClBV,QAAQ,EAAEW,kBAAE,CAACC,IAAI;EACjB7D,KAAK,EAAE4D,kBAAE,CAACE,KAAK,EAAE,CAACC;AACpB,CAAC;AAEDhB,OAAO,CAACiB,YAAY,GAAG;EACrBf,QAAQ,EAAE;AACZ,CAAC;AAAC,eAEaF,OAAO;AAAA"}
|
|
@@ -1,26 +1,17 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
|
|
5
4
|
Object.defineProperty(exports, "__esModule", {
|
|
6
5
|
value: true
|
|
7
6
|
});
|
|
8
7
|
exports.default = void 0;
|
|
9
|
-
|
|
10
8
|
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
11
|
-
|
|
12
9
|
var _react = require("react");
|
|
13
|
-
|
|
14
10
|
var _utils = require("../../utils");
|
|
15
|
-
|
|
16
11
|
var _Tooltip = _interopRequireWildcard(require("./Tooltip"));
|
|
17
|
-
|
|
18
12
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
19
|
-
|
|
20
13
|
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
21
|
-
|
|
22
14
|
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
23
|
-
|
|
24
15
|
/* global window */
|
|
25
16
|
const defaultTheme = {
|
|
26
17
|
"ad": "-dr-pogodin-react-utils___src-shared-components-WithTooltip-default-theme___ad___4xT7zE",
|
|
@@ -46,7 +37,6 @@ const defaultTheme = {
|
|
|
46
37
|
* _e.g._ a tooltip text. This will be the tooltip content.
|
|
47
38
|
* @param {WithTooltipTheme} props.theme _Ad hoc_ theme.
|
|
48
39
|
*/
|
|
49
|
-
|
|
50
40
|
function Wrapper({
|
|
51
41
|
children,
|
|
52
42
|
placement,
|
|
@@ -56,11 +46,9 @@ function Wrapper({
|
|
|
56
46
|
const tooltipRef = (0, _react.useRef)();
|
|
57
47
|
const wrapperRef = (0, _react.useRef)();
|
|
58
48
|
const [showTooltip, setShowTooltip] = (0, _react.useState)(false);
|
|
59
|
-
|
|
60
49
|
const updatePortalPosition = (cursorX, cursorY) => {
|
|
61
50
|
if (!showTooltip) setShowTooltip(true);else {
|
|
62
51
|
const wrapperRect = wrapperRef.current.getBoundingClientRect();
|
|
63
|
-
|
|
64
52
|
if (cursorX < wrapperRect.left || cursorX > wrapperRect.right || cursorY < wrapperRect.top || cursorY > wrapperRect.bottom) {
|
|
65
53
|
setShowTooltip(false);
|
|
66
54
|
} else if (tooltipRef.current) {
|
|
@@ -68,15 +56,12 @@ function Wrapper({
|
|
|
68
56
|
}
|
|
69
57
|
}
|
|
70
58
|
};
|
|
71
|
-
|
|
72
59
|
(0, _react.useEffect)(() => {
|
|
73
60
|
if (showTooltip && tip !== null) {
|
|
74
61
|
const listener = () => setShowTooltip(false);
|
|
75
|
-
|
|
76
62
|
window.addEventListener('scroll', listener);
|
|
77
63
|
return () => window.removeEventListener('scroll', listener);
|
|
78
64
|
}
|
|
79
|
-
|
|
80
65
|
return undefined;
|
|
81
66
|
}, [showTooltip, tip]);
|
|
82
67
|
return /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
|
|
@@ -91,7 +76,6 @@ function Wrapper({
|
|
|
91
76
|
}) : null, children]
|
|
92
77
|
});
|
|
93
78
|
}
|
|
94
|
-
|
|
95
79
|
const ThemedWrapper = (0, _utils.themed)('WithTooltip', ['appearance', 'arrow', 'container', 'content', 'wrapper'], defaultTheme)(Wrapper);
|
|
96
80
|
ThemedWrapper.PLACEMENTS = _Tooltip.PLACEMENTS;
|
|
97
81
|
Wrapper.propTypes = {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["Wrapper","children","placement","tip","theme","tooltipRef","useRef","wrapperRef","showTooltip","setShowTooltip","useState","updatePortalPosition","cursorX","cursorY","wrapperRect","current","getBoundingClientRect","left","right","top","bottom","pointTo","window","pageXOffset","pageYOffset","useEffect","listener","addEventListener","removeEventListener","undefined","wrapper","e","clientX","clientY","ThemedWrapper","themed","defaultTheme","PLACEMENTS","propTypes","PT","node","oneOf","Object","values","themeType","isRequired","defaultProps","ABOVE_CURSOR"],"sources":["../../../../../src/shared/components/WithTooltip/index.jsx"],"sourcesContent":["/* global window */\n\nimport PT from 'prop-types';\nimport { useEffect, useRef, useState } from 'react';\n\nimport { themed } from 'utils';\n\nimport Tooltip, { PLACEMENTS } from './Tooltip';\n\nimport defaultTheme from './default-theme.scss';\n\n/**\n * Implements a simple to use and themeable tooltip component, _e.g._\n * ```js\n * <WithTooltip tip=\"This is example tooltip.\">\n * <p>Hover to see the tooltip.</p>\n * </WithTooltip>\n * ```\n * **Children:** Children are rendered in the place of `<WithTooltip>`,\n * and when hovered the tooltip is shown. By default the wrapper itself is\n * `<div>` block with `display: inline-block`.\n * @param {object} props Component properties.\n * @param {React.node} props.tip – Anything React is able to render,\n * _e.g._ a tooltip text. This will be the tooltip content.\n * @param {WithTooltipTheme} props.theme _Ad hoc_ theme.\n */\nfunction Wrapper({\n children,\n placement,\n tip,\n theme,\n}) {\n const tooltipRef = useRef();\n const wrapperRef = useRef();\n const [showTooltip, setShowTooltip] = useState(false);\n\n const updatePortalPosition = (cursorX, cursorY) => {\n if (!showTooltip) setShowTooltip(true);\n else {\n const wrapperRect = wrapperRef.current.getBoundingClientRect();\n if (\n cursorX < wrapperRect.left\n || cursorX > wrapperRect.right\n || cursorY < wrapperRect.top\n || cursorY > wrapperRect.bottom\n ) {\n setShowTooltip(false);\n } else if (tooltipRef.current) {\n tooltipRef.current.pointTo(\n cursorX + window.pageXOffset,\n cursorY + window.pageYOffset,\n placement,\n wrapperRef.current,\n );\n }\n }\n };\n\n useEffect(() => {\n if (showTooltip && tip !== null) {\n const listener = () => setShowTooltip(false);\n window.addEventListener('scroll', listener);\n return () => window.removeEventListener('scroll', listener);\n }\n return undefined;\n }, [showTooltip, tip]);\n\n return (\n <div\n className={theme.wrapper}\n onMouseLeave={() => setShowTooltip(false)}\n onMouseMove={(e) => updatePortalPosition(e.clientX, e.clientY)}\n ref={wrapperRef}\n >\n {\n showTooltip && tip !== null ? (\n <Tooltip ref={tooltipRef} theme={theme}>{tip}</Tooltip>\n ) : null\n }\n {children}\n </div>\n );\n}\n\nconst ThemedWrapper = themed(\n 'WithTooltip',\n [\n 'appearance',\n 'arrow',\n 'container',\n 'content',\n 'wrapper',\n ],\n defaultTheme,\n)(Wrapper);\n\nThemedWrapper.PLACEMENTS = PLACEMENTS;\n\nWrapper.propTypes = {\n children: PT.node,\n placement: PT.oneOf(Object.values(PLACEMENTS)),\n theme: ThemedWrapper.themeType.isRequired,\n tip: PT.node,\n};\n\nWrapper.defaultProps = {\n children: null,\n placement: PLACEMENTS.ABOVE_CURSOR,\n tip: null,\n};\n\nexport default ThemedWrapper;\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","names":["Wrapper","children","placement","tip","theme","tooltipRef","useRef","wrapperRef","showTooltip","setShowTooltip","useState","updatePortalPosition","cursorX","cursorY","wrapperRect","current","getBoundingClientRect","left","right","top","bottom","pointTo","window","pageXOffset","pageYOffset","useEffect","listener","addEventListener","removeEventListener","undefined","wrapper","e","clientX","clientY","ThemedWrapper","themed","defaultTheme","PLACEMENTS","propTypes","PT","node","oneOf","Object","values","themeType","isRequired","defaultProps","ABOVE_CURSOR"],"sources":["../../../../../src/shared/components/WithTooltip/index.jsx"],"sourcesContent":["/* global window */\n\nimport PT from 'prop-types';\nimport { useEffect, useRef, useState } from 'react';\n\nimport { themed } from 'utils';\n\nimport Tooltip, { PLACEMENTS } from './Tooltip';\n\nimport defaultTheme from './default-theme.scss';\n\n/**\n * Implements a simple to use and themeable tooltip component, _e.g._\n * ```js\n * <WithTooltip tip=\"This is example tooltip.\">\n * <p>Hover to see the tooltip.</p>\n * </WithTooltip>\n * ```\n * **Children:** Children are rendered in the place of `<WithTooltip>`,\n * and when hovered the tooltip is shown. By default the wrapper itself is\n * `<div>` block with `display: inline-block`.\n * @param {object} props Component properties.\n * @param {React.node} props.tip – Anything React is able to render,\n * _e.g._ a tooltip text. This will be the tooltip content.\n * @param {WithTooltipTheme} props.theme _Ad hoc_ theme.\n */\nfunction Wrapper({\n children,\n placement,\n tip,\n theme,\n}) {\n const tooltipRef = useRef();\n const wrapperRef = useRef();\n const [showTooltip, setShowTooltip] = useState(false);\n\n const updatePortalPosition = (cursorX, cursorY) => {\n if (!showTooltip) setShowTooltip(true);\n else {\n const wrapperRect = wrapperRef.current.getBoundingClientRect();\n if (\n cursorX < wrapperRect.left\n || cursorX > wrapperRect.right\n || cursorY < wrapperRect.top\n || cursorY > wrapperRect.bottom\n ) {\n setShowTooltip(false);\n } else if (tooltipRef.current) {\n tooltipRef.current.pointTo(\n cursorX + window.pageXOffset,\n cursorY + window.pageYOffset,\n placement,\n wrapperRef.current,\n );\n }\n }\n };\n\n useEffect(() => {\n if (showTooltip && tip !== null) {\n const listener = () => setShowTooltip(false);\n window.addEventListener('scroll', listener);\n return () => window.removeEventListener('scroll', listener);\n }\n return undefined;\n }, [showTooltip, tip]);\n\n return (\n <div\n className={theme.wrapper}\n onMouseLeave={() => setShowTooltip(false)}\n onMouseMove={(e) => updatePortalPosition(e.clientX, e.clientY)}\n ref={wrapperRef}\n >\n {\n showTooltip && tip !== null ? (\n <Tooltip ref={tooltipRef} theme={theme}>{tip}</Tooltip>\n ) : null\n }\n {children}\n </div>\n );\n}\n\nconst ThemedWrapper = themed(\n 'WithTooltip',\n [\n 'appearance',\n 'arrow',\n 'container',\n 'content',\n 'wrapper',\n ],\n defaultTheme,\n)(Wrapper);\n\nThemedWrapper.PLACEMENTS = PLACEMENTS;\n\nWrapper.propTypes = {\n children: PT.node,\n placement: PT.oneOf(Object.values(PLACEMENTS)),\n theme: ThemedWrapper.themeType.isRequired,\n tip: PT.node,\n};\n\nWrapper.defaultProps = {\n children: null,\n placement: PLACEMENTS.ABOVE_CURSOR,\n tip: null,\n};\n\nexport default ThemedWrapper;\n"],"mappings":";;;;;;;AAEA;AACA;AAEA;AAEA;AAAgD;AAAA;AAAA;AAPhD;AAAA;EAAA;EAAA;EAAA;EAAA;EAAA;EAAA;EAAA;AAAA;AAWA;AACA;AACA;AACA;AAC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