@dr.pogodin/react-utils 1.54.3 → 1.55.0-alpha.1
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/__type_tests__/ts-compiler-behavior.ts +13 -0
- package/__type_tests__/type-exports.ts +17 -0
- package/babel.build.config.js +9 -0
- package/babel.config.js +2 -5
- package/babel.libweb.config.js +2 -3
- package/babel.scripts.config.js +5 -11
- package/bin/build.js +4 -21
- package/bin/release.sh +1 -1
- package/build/development/client/getInj.js +2 -9
- package/build/development/client/getInj.js.map +1 -1
- package/build/development/client/index.js.map +1 -1
- package/build/development/client/init.js +1 -3
- package/build/development/client/init.js.map +1 -1
- package/build/development/index.js.map +1 -1
- package/build/development/server/Cache.js.map +1 -1
- package/build/development/server/index.js.map +1 -1
- package/build/development/server/renderer.js +10 -24
- package/build/development/server/renderer.js.map +1 -1
- package/build/development/server/server.js +6 -8
- package/build/development/server/server.js.map +1 -1
- package/build/development/server/utils/errors.js +11 -11
- package/build/development/server/utils/errors.js.map +1 -1
- package/build/development/shared/components/Button/index.js.map +1 -1
- package/build/development/shared/components/Checkbox/index.js.map +1 -1
- package/build/development/shared/components/GenericLink/index.js.map +1 -1
- package/build/development/shared/components/Input/index.js.map +1 -1
- package/build/development/shared/components/Link.js.map +1 -1
- package/build/development/shared/components/Modal/index.js.map +1 -1
- package/build/development/shared/components/NavLink.js.map +1 -1
- package/build/development/shared/components/PageLayout/index.js.map +1 -1
- package/build/development/shared/components/TextArea/index.js.map +1 -1
- package/build/development/shared/components/Throbber/index.js.map +1 -1
- package/build/development/shared/components/WithTooltip/Tooltip.js.map +1 -1
- package/build/development/shared/components/WithTooltip/index.js.map +1 -1
- package/build/development/shared/components/YouTubeVideo/index.js.map +1 -1
- package/build/development/shared/components/index.js.map +1 -1
- package/build/development/shared/components/selectors/CustomDropdown/Options/index.js +2 -5
- package/build/development/shared/components/selectors/CustomDropdown/Options/index.js.map +1 -1
- package/build/development/shared/components/selectors/CustomDropdown/index.js +1 -4
- package/build/development/shared/components/selectors/CustomDropdown/index.js.map +1 -1
- package/build/development/shared/components/selectors/NativeDropdown/index.js +2 -5
- package/build/development/shared/components/selectors/NativeDropdown/index.js.map +1 -1
- package/build/development/shared/components/selectors/Switch/index.js +2 -2
- package/build/development/shared/components/selectors/Switch/index.js.map +1 -1
- package/build/development/shared/components/selectors/common.js.map +1 -1
- package/build/development/shared/components/selectors/index.js.map +1 -1
- package/build/development/shared/utils/config.js.map +1 -1
- package/build/development/shared/utils/globalState.js.map +1 -1
- package/build/development/shared/utils/index.js.map +1 -1
- package/build/development/shared/utils/isomorphy/buildInfo.js.map +1 -1
- package/build/development/shared/utils/isomorphy/environment-check.js.map +1 -1
- package/build/development/shared/utils/isomorphy/index.js +4 -5
- package/build/development/shared/utils/isomorphy/index.js.map +1 -1
- package/build/development/shared/utils/jest/E2eSsrEnv/index.js +32 -71
- package/build/development/shared/utils/jest/E2eSsrEnv/index.js.map +1 -1
- package/build/development/shared/utils/jest/E2eSsrEnv/ssr-preload.js +23 -0
- package/build/development/shared/utils/jest/E2eSsrEnv/ssr-preload.js.map +1 -0
- package/build/development/shared/utils/jest/E2eSsrEnv/ssr.js +1 -1
- package/build/development/shared/utils/jest/E2eSsrEnv/ssr.js.map +1 -1
- package/build/development/shared/utils/jest/global.js.map +1 -1
- package/build/development/shared/utils/jest/index.js +3 -3
- package/build/development/shared/utils/jest/index.js.map +1 -1
- package/build/development/shared/utils/splitComponent.js +3 -16
- package/build/development/shared/utils/splitComponent.js.map +1 -1
- package/build/development/shared/utils/time.js +28 -65
- package/build/development/shared/utils/time.js.map +1 -1
- package/build/development/shared/utils/webpack.js +3 -5
- package/build/development/shared/utils/webpack.js.map +1 -1
- package/build/production/client/getInj.js +1 -1
- package/build/production/client/getInj.js.map +1 -1
- 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 +5 -5
- package/build/production/server/renderer.js.map +1 -1
- package/build/production/server/server.js +4 -4
- package/build/production/server/server.js.map +1 -1
- package/build/production/server/utils/errors.js +2 -2
- 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/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/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/TextArea/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/components/selectors/CustomDropdown/Options/index.js +1 -1
- package/build/production/shared/components/selectors/CustomDropdown/Options/index.js.map +1 -1
- package/build/production/shared/components/selectors/CustomDropdown/index.js +1 -1
- package/build/production/shared/components/selectors/CustomDropdown/index.js.map +1 -1
- package/build/production/shared/components/selectors/NativeDropdown/index.js +2 -2
- package/build/production/shared/components/selectors/NativeDropdown/index.js.map +1 -1
- package/build/production/shared/components/selectors/Switch/index.js +1 -1
- package/build/production/shared/components/selectors/Switch/index.js.map +1 -1
- package/build/production/shared/components/selectors/common.js.map +1 -1
- package/build/production/shared/components/selectors/index.js.map +1 -1
- package/build/production/shared/utils/config.js.map +1 -1
- package/build/production/shared/utils/globalState.js.map +1 -1
- package/build/production/shared/utils/index.js.map +1 -1
- package/build/production/shared/utils/isomorphy/buildInfo.js.map +1 -1
- package/build/production/shared/utils/isomorphy/environment-check.js.map +1 -1
- package/build/production/shared/utils/isomorphy/index.js.map +1 -1
- package/build/production/shared/utils/jest/E2eSsrEnv/index.js +12 -37
- package/build/production/shared/utils/jest/E2eSsrEnv/index.js.map +1 -1
- package/build/production/shared/utils/jest/E2eSsrEnv/ssr-preload.js +5 -0
- package/build/production/shared/utils/jest/E2eSsrEnv/ssr-preload.js.map +1 -0
- package/build/production/shared/utils/jest/E2eSsrEnv/ssr.js +1 -1
- package/build/production/shared/utils/jest/E2eSsrEnv/ssr.js.map +1 -1
- package/build/production/shared/utils/jest/global.js.map +1 -1
- package/build/production/shared/utils/jest/index.js +3 -3
- package/build/production/shared/utils/jest/index.js.map +1 -1
- package/build/production/shared/utils/splitComponent.js +3 -3
- package/build/production/shared/utils/splitComponent.js.map +1 -1
- package/build/production/shared/utils/time.js +2 -2
- package/build/production/shared/utils/time.js.map +1 -1
- package/build/production/shared/utils/webpack.js +3 -3
- package/build/production/shared/utils/webpack.js.map +1 -1
- package/build/types-code/shared/utils/webpack.d.ts +2 -2
- package/build/web/client/getInj.js +2 -2
- package/build/web/client/getInj.js.map +1 -1
- package/build/web/client/index.js +1 -1
- package/build/web/client/index.js.map +1 -1
- package/build/web/client/init.js +1 -1
- package/build/web/client/init.js.map +1 -1
- package/build/web/index.js +1 -1
- package/build/web/index.js.map +1 -1
- package/build/web/server/Cache.js.map +1 -1
- package/build/web/server/index.js +1 -1
- package/build/web/server/index.js.map +1 -1
- package/build/web/server/renderer.js +6 -6
- package/build/web/server/renderer.js.map +1 -1
- package/build/web/server/server.js +5 -5
- package/build/web/server/server.js.map +1 -1
- package/build/web/server/utils/errors.js +2 -2
- package/build/web/server/utils/errors.js.map +1 -1
- package/build/web/server/utils/index.js +1 -1
- package/build/web/server/utils/index.js.map +1 -1
- package/build/web/shared/components/Button/index.js +1 -1
- package/build/web/shared/components/Button/index.js.map +1 -1
- package/build/web/shared/components/Checkbox/index.js.map +1 -1
- package/build/web/shared/components/GenericLink/index.js.map +1 -1
- package/build/web/shared/components/Input/index.js.map +1 -1
- package/build/web/shared/components/Link.js +1 -1
- package/build/web/shared/components/Link.js.map +1 -1
- package/build/web/shared/components/Modal/index.js.map +1 -1
- package/build/web/shared/components/NavLink.js +1 -1
- package/build/web/shared/components/NavLink.js.map +1 -1
- package/build/web/shared/components/PageLayout/index.js.map +1 -1
- package/build/web/shared/components/TextArea/index.js.map +1 -1
- package/build/web/shared/components/Throbber/index.js.map +1 -1
- package/build/web/shared/components/WithTooltip/Tooltip.js.map +1 -1
- package/build/web/shared/components/WithTooltip/index.js +1 -1
- package/build/web/shared/components/WithTooltip/index.js.map +1 -1
- package/build/web/shared/components/YouTubeVideo/index.js +1 -1
- package/build/web/shared/components/YouTubeVideo/index.js.map +1 -1
- package/build/web/shared/components/index.js +1 -1
- package/build/web/shared/components/index.js.map +1 -1
- package/build/web/shared/components/selectors/CustomDropdown/Options/index.js +1 -1
- package/build/web/shared/components/selectors/CustomDropdown/Options/index.js.map +1 -1
- package/build/web/shared/components/selectors/CustomDropdown/index.js +1 -1
- package/build/web/shared/components/selectors/CustomDropdown/index.js.map +1 -1
- package/build/web/shared/components/selectors/NativeDropdown/index.js +3 -3
- package/build/web/shared/components/selectors/NativeDropdown/index.js.map +1 -1
- package/build/web/shared/components/selectors/Switch/index.js +1 -1
- package/build/web/shared/components/selectors/Switch/index.js.map +1 -1
- package/build/web/shared/components/selectors/common.js.map +1 -1
- package/build/web/shared/components/selectors/index.js +1 -1
- package/build/web/shared/components/selectors/index.js.map +1 -1
- package/build/web/shared/utils/config.js +1 -1
- package/build/web/shared/utils/config.js.map +1 -1
- package/build/web/shared/utils/globalState.js.map +1 -1
- package/build/web/shared/utils/index.js +1 -1
- package/build/web/shared/utils/index.js.map +1 -1
- package/build/web/shared/utils/isomorphy/buildInfo.js.map +1 -1
- package/build/web/shared/utils/isomorphy/environment-check.js.map +1 -1
- package/build/web/shared/utils/isomorphy/index.js +1 -1
- package/build/web/shared/utils/isomorphy/index.js.map +1 -1
- package/build/web/shared/utils/jest/E2eSsrEnv/index.js +12 -37
- package/build/web/shared/utils/jest/E2eSsrEnv/index.js.map +1 -1
- package/build/web/shared/utils/jest/E2eSsrEnv/ssr-preload.js +5 -0
- package/build/web/shared/utils/jest/E2eSsrEnv/ssr-preload.js.map +1 -0
- package/build/web/shared/utils/jest/E2eSsrEnv/ssr.js +2 -2
- package/build/web/shared/utils/jest/E2eSsrEnv/ssr.js.map +1 -1
- package/build/web/shared/utils/jest/global.js.map +1 -1
- package/build/web/shared/utils/jest/index.js +4 -4
- package/build/web/shared/utils/jest/index.js.map +1 -1
- package/build/web/shared/utils/splitComponent.js +3 -3
- package/build/web/shared/utils/splitComponent.js.map +1 -1
- package/build/web/shared/utils/time.js +2 -2
- package/build/web/shared/utils/time.js.map +1 -1
- package/build/web/shared/utils/webpack.js +4 -4
- package/build/web/shared/utils/webpack.js.map +1 -1
- package/config/babel/node-ssr.d.ts +2 -3
- package/config/babel/node-ssr.js +15 -55
- package/config/babel/webpack.d.ts +7 -5
- package/config/babel/webpack.js +19 -24
- package/config/eslint/default.mjs +1 -1
- package/config/jest/default.js +6 -7
- package/config/jest/resolver.js +1 -3
- package/config/jest/setup.js +2 -2
- package/config/stylelint/default.js +1 -4
- package/config/webpack/app-base.js +40 -41
- package/config/webpack/app-development.d.ts +1 -1
- package/config/webpack/app-development.js +12 -18
- package/config/webpack/app-production.d.ts +1 -1
- package/config/webpack/app-production.js +10 -16
- package/package.json +38 -35
- package/patches/jest-resolve+30.4.1.patch +29 -0
- package/tsconfig.configs.json +6 -1
- package/tsconfig.json +2 -1
- package/tsconfig.types.json +1 -0
- package/tstyche.json +1 -1
- package/babel.module.config.js +0 -11
- package/build/development/shared/utils/jest/E2eSsrEnv/register.js +0 -6
- package/build/development/shared/utils/jest/E2eSsrEnv/register.js.map +0 -1
- package/build/production/shared/utils/jest/E2eSsrEnv/register.js +0 -3
- package/build/production/shared/utils/jest/E2eSsrEnv/register.js.map +0 -1
- package/build/web/shared/utils/jest/E2eSsrEnv/register.js +0 -3
- package/build/web/shared/utils/jest/E2eSsrEnv/register.js.map +0 -1
- /package/build/types-code/shared/utils/jest/E2eSsrEnv/{register.d.ts → ssr-preload.d.ts} +0 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Link.js","names":["
|
|
1
|
+
{"version":3,"file":"Link.js","names":["RrLink"],"sources":["../../../../src/shared/components/Link.tsx"],"sourcesContent":["/**\n * The Link wraps around React Router's Link component, to automatically replace\n * it by the regular <a> element when:\n * - The target reference points to another domain;\n * - User opts to open the reference in a new tab;\n * - User explicitely opts to use <a>.\n */\n\nimport { type LinkProps, Link as RrLink } from 'react-router';\n\nimport GenericLink, { type PropsT as GenericLinkPropsT } from './GenericLink';\n\ntype PropsT = LinkProps & Omit<GenericLinkPropsT, 'routerLinkType'>;\n\nconst Link: React.FunctionComponent<PropsT>\n = (props) => (\n <GenericLink\n // TODO: Avoid the spreading later.\n // eslint-disable-next-line react/jsx-props-no-spreading\n {...props}\n routerLinkType={RrLink}\n />\n );\n\nexport default Link;\n"],"mappings":"4CAAA;AACA;AACA;AACA;AACA;AACA;AACA,GAEA,OAAyB,IAAI,GAAI,OAAM,KAAQ,cAAc,CAAC,MAEvD,YAAW,yEAIlB,KAAM,KAAqC,CACvC,8CACA,qBAAC,WAAW,KAGN,KAAK,CACOA,cAAM,CAAN,MAAM,CACvB,CAAC,uCALF,GAKE,CACH,CAEH,cAAe,KAAI","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["useEffect","useMemo","useRef","createPortal","useTheme","defaultTheme","S","jsx","_jsx","jsxs","_jsxs","BaseModal","t0","$","_c","cancelOnScrolling","children","containerStyle","dontDisableScrolling","onCancel","overlayStyle","style","testId","testIdForOverlay","theme","containerRef","overlayRef","t1","t2","window","addEventListener","removeEventListener","t3","t4","document","body","classList","add","scrollingDisabledByModal","remove","t5","Symbol","for","onFocus","elems","current","querySelectorAll","i","length","focus","activeElement","tabIndex","focusLast","t6","process","env","NODE_ENV","undefined","t7","t8","e","stopPropagation","e_0","key","t9","node","t10","overlay","className","onClick","onKeyDown","ref","role","t11","t12","t13","container","_temp","onWheel","_temp2","t14","t15","Modal","rest","composed","e_1","event"],"sources":["../../../../../src/shared/components/Modal/index.tsx"],"sourcesContent":["import {\n type CSSProperties,\n type FunctionComponent,\n type ReactNode,\n useEffect,\n useMemo,\n useRef,\n} from 'react';\n\nimport { createPortal } from 'react-dom';\n\nimport { type Theme, useTheme } from '@dr.pogodin/react-themes';\n\nimport defaultTheme from './base-theme.scss';\nimport S from './styles.scss';\n\ntype ThemeT = Theme<'container' | 'overlay'>;\n\ntype PropsT = {\n cancelOnScrolling?: boolean;\n children?: ReactNode;\n dontDisableScrolling?: boolean;\n onCancel?: () => void;\n overlayStyle?: CSSProperties;\n style?: CSSProperties;\n testId?: string;\n testIdForOverlay?: string;\n theme: ThemeT;\n\n /** @deprecated */\n containerStyle?: CSSProperties;\n};\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 */\nconst BaseModal: FunctionComponent<PropsT> = ({\n cancelOnScrolling,\n children,\n containerStyle,\n dontDisableScrolling,\n onCancel,\n overlayStyle,\n style,\n testId,\n testIdForOverlay,\n theme,\n}) => {\n const containerRef = useRef<HTMLDivElement | null>(null);\n const overlayRef = useRef<HTMLDivElement | null>(null);\n\n // Sets up modal cancellation of scrolling, if opted-in.\n useEffect(() => {\n if (cancelOnScrolling && onCancel) {\n window.addEventListener('scroll', onCancel);\n window.addEventListener('wheel', onCancel);\n }\n return () => {\n if (cancelOnScrolling && onCancel) {\n window.removeEventListener('scroll', onCancel);\n window.removeEventListener('wheel', onCancel);\n }\n };\n }, [cancelOnScrolling, onCancel]);\n\n // Disables window scrolling, if it is not opted-out.\n useEffect(() => {\n if (!dontDisableScrolling) {\n document.body.classList.add(S.scrollingDisabledByModal);\n }\n return () => {\n if (!dontDisableScrolling) {\n document.body.classList.remove(S.scrollingDisabledByModal);\n }\n };\n }, [dontDisableScrolling]);\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] as HTMLElement).focus();\n if (document.activeElement === elems[i]) return;\n }\n overlayRef.current?.focus();\n }}\n // TODO: Have a look at this later.\n // eslint-disable-next-line jsx-a11y/no-noninteractive-tabindex\n tabIndex={0}\n />\n ), []);\n\n return createPortal(\n (\n <div>\n {focusLast}\n <div\n aria-label=\"Cancel\"\n className={theme.overlay}\n data-testid={\n process.env.NODE_ENV === 'production'\n ? undefined : testIdForOverlay\n }\n onClick={(e) => {\n if (onCancel) {\n onCancel();\n e.stopPropagation();\n }\n }}\n onKeyDown={(e) => {\n if (e.key === 'Escape' && onCancel) {\n onCancel();\n e.stopPropagation();\n }\n }}\n ref={(node) => {\n if (node && node !== overlayRef.current) {\n overlayRef.current = node;\n node.focus();\n }\n }}\n role=\"button\"\n style={overlayStyle}\n tabIndex={0}\n />\n {\n // NOTE: These rules are disabled because our intention is to keep\n // the element non-interactive (thus not on the keyboard focus chain),\n // and it has `onClick` handler merely to stop propagation of click\n // events to its parent container. This is needed because, for example\n // when the modal is wrapped into an interactive element we don't want\n // any clicks inside the modal to bubble-up to that parent element\n // (because visually and logically the modal dialog does not belong\n // to its parent container, where it technically belongs from\n // the HTML mark-up perpective).\n }\n <div // eslint-disable-line jsx-a11y/click-events-have-key-events, jsx-a11y/no-noninteractive-element-interactions\n aria-modal=\"true\"\n className={theme.container}\n data-testid={process.env.NODE_ENV === 'production' ? undefined : testId}\n onClick={(e) => {\n e.stopPropagation();\n }}\n onWheel={(event) => {\n event.stopPropagation();\n }}\n ref={containerRef}\n role=\"dialog\"\n style={style ?? containerStyle}\n >\n {children}\n </div>\n <div\n onFocus={() => {\n overlayRef.current?.focus();\n }}\n // TODO: Have a look at this later.\n // eslint-disable-next-line jsx-a11y/no-noninteractive-tabindex\n tabIndex={0}\n />\n {focusLast}\n </div>\n ),\n document.body,\n );\n};\n\n/* Non-themed version of the Modal. */\nexport { BaseModal };\n\nconst Modal: FunctionComponent<\n Omit<PropsT, 'theme'> & { theme?: ThemeT }\n> = ({ theme, ...rest }) => {\n const composed = useTheme('Modal', defaultTheme, theme);\n\n // eslint-disable-next-line react/jsx-props-no-spreading\n return <BaseModal {...rest} theme={composed} />;\n};\n\nexport default Modal;\n"],"mappings":"4CAAA,OAIEA,SAAS,CACTC,OAAO,CACPC,MAAM,KACD,OAAO,CAEd,OAASC,YAAY,KAAQ,WAAW,CAExC,OAAqBC,QAAQ,KAAQ,0BAA0B,CAE/D,MAAO,CAAAC,YAAY,yBACnB,MAAO,CAAAC,CAAC,qBAAsB,OAAAC,GAAA,IAAAC,IAAA,CAAAC,IAAA,IAAAC,KAAA,yBAmB9B;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,GACA,KAAM,CAAAC,SAAoC,CAAGC,EAAA,SAAAC,CAAA,CAAAC,EAAA,KAAC,MAAAC,iBAAA,CAAAC,QAAA,CAAAC,cAAA,CAAAC,oBAAA,CAAAC,QAAA,CAAAC,YAAA,CAAAC,KAAA,CAAAC,MAAA,CAAAC,gBAAA,CAAAC,KAAA,EAAAZ,EAW7C,CACC,MAAAa,YAAA,CAAqBvB,MAAM,CAAwB,IAAI,CAAC,CACxD,MAAAwB,UAAA,CAAmBxB,MAAM,CAAwB,IAAI,CAAC,CAAC,IAAAyB,EAAA,KAAAC,EAAA,IAAAf,CAAA,MAAAE,iBAAA,EAAAF,CAAA,MAAAM,QAAA,EAG7CQ,EAAA,CAAAA,CAAA,IACR,GAAIZ,iBAA6B,EAA7BI,QAA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AiBhF,QAAQ,CAAC,OAAO,CAAEC,YAAY,CAAEmB,KAAK,CAAC,CAAC,IAAAG,EAAA,IAAAd,CAAA,MAAAuE,QAAA,EAAAvE,CAAA,MAAAsE,IAAA,EAGjDxD,EAAA,cAAAnB,IAAA,CAACG,SAAS,KAAKwE,IAAI,CAASC,KAAQ,CAARA,QAAQ,CAAG,CAAC,CAAAvE,CAAA,IAAAuE,QAAAvE,CAAA,KAAAsE,IAAAtE,CAAA,KAAAc,EAAA,MAAAA,EAAA,CAAAd,CAAA,UAAxC,CAAAc,EAAwC,CAChD,CAED,cAAe,CAAAuD,KAAK,CAhJyB,SAAAL,MAAAQ,GAAA,EA0GjCzB,GAAC,CAAAC,eAAgB,CAAC,CAAC,CA1Gc,SAAAkB,OAAAO,KAAA,EA6GjCA,KAAK,CAAAzB,eAAgB,CAAC,CAAC","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"index.js","names":["e","overlayStyle","containerRef","composed"],"sources":["../../../../../src/shared/components/Modal/index.tsx"],"sourcesContent":["import {\n type CSSProperties,\n type FunctionComponent,\n type ReactNode,\n useEffect,\n useMemo,\n useRef,\n} from 'react';\n\nimport { createPortal } from 'react-dom';\n\nimport { type Theme, useTheme } from '@dr.pogodin/react-themes';\n\nimport defaultTheme from './base-theme.scss';\nimport S from './styles.scss';\n\ntype ThemeT = Theme<'container' | 'overlay'>;\n\ntype PropsT = {\n cancelOnScrolling?: boolean;\n children?: ReactNode;\n dontDisableScrolling?: boolean;\n onCancel?: () => void;\n overlayStyle?: CSSProperties;\n style?: CSSProperties;\n testId?: string;\n testIdForOverlay?: string;\n theme: ThemeT;\n\n /** @deprecated */\n containerStyle?: CSSProperties;\n};\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 */\nconst BaseModal: FunctionComponent<PropsT> = ({\n cancelOnScrolling,\n children,\n containerStyle,\n dontDisableScrolling,\n onCancel,\n overlayStyle,\n style,\n testId,\n testIdForOverlay,\n theme,\n}) => {\n const containerRef = useRef<HTMLDivElement | null>(null);\n const overlayRef = useRef<HTMLDivElement | null>(null);\n\n // Sets up modal cancellation of scrolling, if opted-in.\n useEffect(() => {\n if (cancelOnScrolling && onCancel) {\n window.addEventListener('scroll', onCancel);\n window.addEventListener('wheel', onCancel);\n }\n return () => {\n if (cancelOnScrolling && onCancel) {\n window.removeEventListener('scroll', onCancel);\n window.removeEventListener('wheel', onCancel);\n }\n };\n }, [cancelOnScrolling, onCancel]);\n\n // Disables window scrolling, if it is not opted-out.\n useEffect(() => {\n if (!dontDisableScrolling) {\n document.body.classList.add(S.scrollingDisabledByModal);\n }\n return () => {\n if (!dontDisableScrolling) {\n document.body.classList.remove(S.scrollingDisabledByModal);\n }\n };\n }, [dontDisableScrolling]);\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] as HTMLElement).focus();\n if (document.activeElement === elems[i]) return;\n }\n overlayRef.current?.focus();\n }}\n // TODO: Have a look at this later.\n // eslint-disable-next-line jsx-a11y/no-noninteractive-tabindex\n tabIndex={0}\n />\n ), []);\n\n return createPortal(\n (\n <div>\n {focusLast}\n <div\n aria-label=\"Cancel\"\n className={theme.overlay}\n data-testid={\n process.env.NODE_ENV === 'production'\n ? undefined : testIdForOverlay\n }\n onClick={(e) => {\n if (onCancel) {\n onCancel();\n e.stopPropagation();\n }\n }}\n onKeyDown={(e) => {\n if (e.key === 'Escape' && onCancel) {\n onCancel();\n e.stopPropagation();\n }\n }}\n ref={(node) => {\n if (node && node !== overlayRef.current) {\n overlayRef.current = node;\n node.focus();\n }\n }}\n role=\"button\"\n style={overlayStyle}\n tabIndex={0}\n />\n {\n // NOTE: These rules are disabled because our intention is to keep\n // the element non-interactive (thus not on the keyboard focus chain),\n // and it has `onClick` handler merely to stop propagation of click\n // events to its parent container. This is needed because, for example\n // when the modal is wrapped into an interactive element we don't want\n // any clicks inside the modal to bubble-up to that parent element\n // (because visually and logically the modal dialog does not belong\n // to its parent container, where it technically belongs from\n // the HTML mark-up perpective).\n }\n <div // eslint-disable-line jsx-a11y/click-events-have-key-events, jsx-a11y/no-noninteractive-element-interactions\n aria-modal=\"true\"\n className={theme.container}\n data-testid={process.env.NODE_ENV === 'production' ? undefined : testId}\n onClick={(e) => {\n e.stopPropagation();\n }}\n onWheel={(event) => {\n event.stopPropagation();\n }}\n ref={containerRef}\n role=\"dialog\"\n style={style ?? containerStyle}\n >\n {children}\n </div>\n <div\n onFocus={() => {\n overlayRef.current?.focus();\n }}\n // TODO: Have a look at this later.\n // eslint-disable-next-line jsx-a11y/no-noninteractive-tabindex\n tabIndex={0}\n />\n {focusLast}\n </div>\n ),\n document.body,\n );\n};\n\n/* Non-themed version of the Modal. */\nexport { BaseModal };\n\nconst Modal: FunctionComponent<\n Omit<PropsT, 'theme'> & { theme?: ThemeT }\n> = ({ theme, ...rest }) => {\n const composed = useTheme('Modal', defaultTheme, theme);\n\n // eslint-disable-next-line react/jsx-props-no-spreading\n return <BaseModal {...rest} theme={composed} />;\n};\n\nexport default Modal;\n"],"mappings":"4CAAA,OAIE,SAAS,CACT,OAAO,CACP,MAAM,KACD,OAAO,CAEd,OAAS,YAAY,KAAQ,WAAW,CAExC,OAAqB,QAAQ,KAAQ,0BAA0B,CAE/D,MAAO,aAAY,yBACnB,MAAO,EAAC,qBAAsB,yDAmB9B;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,GACA,KAAM,UAAoC,CAAG,oBAAC,kIAW7C,CACC,mBAAqB,MAAM,C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AQ,CAAG,CAAC,oDAAxC,GAAwC,CAChD,CAED,cAAe,MAAK,CAhJyB,oBA0GjCH,GAAC,gBAAgB,CAAC,CAAC,CA1Gc,uBA6GjC,KAAK,gBAAgB,CAAC,CAAC","ignoreList":[]}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{c as _c}from"react/compiler-runtime";import{NavLink as RrNavLink}from"react-router";import GenericLink from"./GenericLink";import{jsx as _jsx}from"react/jsx-runtime";const NavLink=props=>{const $=_c(2);let t0;if($[0]!==props){t0=/*#__PURE__*/_jsx(GenericLink,{...props,routerLinkType:RrNavLink});$[0]=props;$[1]=t0}else{t0=$[1]}return t0};export default NavLink;
|
|
1
|
+
import{c as _c}from"react/compiler-runtime";import{NavLink as RrNavLink}from"react-router";import GenericLink from"./GenericLink/index.js";import{jsx as _jsx}from"react/jsx-runtime";const NavLink=props=>{const $=_c(2);let t0;if($[0]!==props){t0=/*#__PURE__*/_jsx(GenericLink,{...props,routerLinkType:RrNavLink});$[0]=props;$[1]=t0}else{t0=$[1]}return t0};export default NavLink;
|
|
2
2
|
//# sourceMappingURL=NavLink.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NavLink.js","names":["
|
|
1
|
+
{"version":3,"file":"NavLink.js","names":["RrNavLink"],"sources":["../../../../src/shared/components/NavLink.tsx"],"sourcesContent":["import { type NavLinkProps, NavLink as RrNavLink } from 'react-router';\n\nimport GenericLink, { type PropsT as GenericLinkPropsT } from './GenericLink';\n\ntype PropsT = NavLinkProps & Omit<GenericLinkPropsT, 'routerLinkType'>;\n\nconst NavLink: React.FunctionComponent<PropsT>\n = (props) => (\n <GenericLink\n // TODO: I guess, we better re-write it to avoid the props spreading,\n // but no need to spend time on it right now.\n // eslint-disable-next-line react/jsx-props-no-spreading\n {...props}\n routerLinkType={RrNavLink}\n />\n );\n\nexport default NavLink;\n"],"mappings":"4CAAA,OAA4B,OAAO,GAAI,UAAS,KAAQ,cAAc,CAAC,MAEhE,YAAW,yEAIlB,KAAM,QAAwC,CAC1C,8CACA,qBAAC,WAAW,KAIN,KAAK,CACOA,cAAS,CAAT,SAAS,CAC1B,CAAC,uCANF,GAME,CACH,CAEH,cAAe,QAAO","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":[
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../../../../../src/shared/components/PageLayout/index.tsx"],"sourcesContent":["import type { FunctionComponent, ReactNode } from 'react';\n\nimport { type Theme, useTheme } from '@dr.pogodin/react-themes';\n\nimport baseTheme from './base-theme.scss';\n\ntype ThemeKeyT = 'container' | 'leftSidePanel' | 'mainPanel' | 'rightSidePanel'\n | 'sidePanel';\n\ntype PropsT = {\n children?: ReactNode;\n leftSidePanelContent?: ReactNode;\n rightSidePanelContent?: ReactNode;\n theme?: Theme<ThemeKeyT>;\n};\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 */\nconst PageLayout: FunctionComponent<PropsT> = ({\n children,\n leftSidePanelContent,\n rightSidePanelContent,\n theme,\n}) => {\n const composed = useTheme('PageLayout', baseTheme, theme);\n return (\n <div className={composed.container}>\n <div className={[composed.sidePanel, composed.leftSidePanel].join(' ')}>\n {leftSidePanelContent}\n </div>\n <div className={composed.mainPanel}>\n {children}\n </div>\n <div className={[composed.sidePanel, composed.rightSidePanel].join(' ')}>\n {rightSidePanelContent}\n </div>\n </div>\n );\n};\n\nexport default PageLayout;\n"],"mappings":"4CAEA,OAAqB,QAAQ,KAAQ,0BAA0B,CAE/D,MAAO,UAAS,yBAA0B,yDAY1C;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,GACA,KAAM,WAAqC,CAAG,oBAAC,mEAK9C,CACC,eAAiB,QAAQ,CAAC,YAAY,CAAE,SAAS,CAAE,KAAK,CAAC,CAEvC,iBAAQ,UAAU,qEAChB,IAAC,QAAQ,UAAU,CAAE,QAAQ,cAAc,CAAC,0EAA5C,WAA4C,KAAK,CAAC,GAAG,CAAC,mDAAtE,4BAAgB,SAAsD,CAAtD,EAAsD,UACnE,oBAAoB,CAClB,CAAC,8GACN,4BAAgB,SAAkB,CAAlB,QAAQ,UAAU,UAC/B,QAAQ,CACN,CAAC,kIACU,IAAC,QAAQ,UAAU,CAAE,QAAQ,eAAe,CAAC,8EAA7C,WAA6C,KAAK,CAAC,GAAG,CAAC,sDAAvE,4BAAgB,SAAuD,CAAvD,EAAuD,UACpE,qBAAqB,CACnB,CAAC,uIATR,6BAAgB,SAAkB,CAAlB,EAAkB,WAChC,EAEM,CACN,EAEM,CACN,EAEM,EACH,CAAC,kFAVN,GAUM,CAET,CAED,cAAe,WAAU","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["useEffect","useLayoutEffect","useRef","useState","useTheme","defaultTheme","jsx","_jsx","jsxs","_jsxs","TextArea","t0","$","_c","disabled","error","label","onBlur","onChange","onKeyDown","placeholder","ref","testId","theme","value","custom","hiddenAreaRef","height","setHeight","textAreaRef","localValue","setLocalValue","undefined","t1","t2","Symbol","for","el","current","cb","scrollHeight","observer","ResizeObserver","observe","disconnect","t3","el_0","t4","containerClassName","container","t5","focus","t6","className","children","t7","textarea","hidden","t8","t9","readOnly","tabIndex","t10","process","env","NODE_ENV","t11","e","target","t12","node","t13","t14","style","t15","errorMessage","t16","onFocus"],"sources":["../../../../../src/shared/components/TextArea/index.tsx"],"sourcesContent":["import {\n type ChangeEventHandler,\n type FocusEventHandler,\n type FunctionComponent,\n type KeyboardEventHandler,\n type ReactNode,\n type Ref,\n useEffect,\n useLayoutEffect,\n useRef,\n useState,\n} from 'react';\n\nimport { type Theme, useTheme } from '@dr.pogodin/react-themes';\n\nimport defaultTheme from './style.scss';\n\ntype ThemeKeyT = 'container' | 'error' | 'errorMessage' | 'hidden' | 'label'\n | 'textarea';\n\ntype Props = {\n disabled?: boolean;\n error?: ReactNode;\n label?: string;\n onBlur?: FocusEventHandler<HTMLTextAreaElement>;\n onChange?: ChangeEventHandler<HTMLTextAreaElement>;\n onKeyDown?: KeyboardEventHandler<HTMLTextAreaElement>;\n placeholder?: string;\n ref?: Ref<HTMLTextAreaElement>;\n testId?: string;\n theme?: Theme<ThemeKeyT>;\n value?: string;\n};\n\nconst TextArea: FunctionComponent<Props> = ({\n disabled,\n error,\n label,\n onBlur,\n onChange,\n onKeyDown,\n placeholder,\n ref,\n testId,\n theme,\n value,\n}) => {\n const custom = useTheme('TextArea', defaultTheme, theme);\n\n const hiddenAreaRef = useRef<HTMLTextAreaElement>(null);\n const [height, setHeight] = useState<number | undefined>();\n\n const textAreaRef = useRef<HTMLTextAreaElement>(null);\n\n const [localValue, setLocalValue] = useState(value ?? '');\n if (value !== undefined && localValue !== value) setLocalValue(value);\n\n // This resizes text area's height when its width is changed for any reason.\n useEffect(() => {\n const el = hiddenAreaRef.current;\n if (!el) return undefined;\n\n const cb = () => {\n setHeight(el.scrollHeight);\n };\n const observer = new ResizeObserver(cb);\n observer.observe(el);\n\n return () => {\n observer.disconnect();\n };\n }, []);\n\n // Resizes the text area when its content is modified.\n //\n // NOTE: useLayoutEffect() instead of useEffect() makes difference here,\n // as it helps to avoid visible \"content/height\" jumps (i.e. with just\n // useEffect() it becomes visible how the content is modified first,\n // and then input height is incremented, if necessary).\n // See: https://github.com/birdofpreyru/react-utils/issues/313\n useLayoutEffect(() => {\n const el = hiddenAreaRef.current;\n if (el) setHeight(el.scrollHeight);\n }, [localValue]);\n\n let containerClassName = custom.container;\n if (error) containerClassName += ` ${custom.error}`;\n\n return (\n <div\n className={containerClassName}\n onFocus={() => {\n textAreaRef.current?.focus();\n }}\n >\n {label === undefined ? null : <div className={custom.label}>{label}</div>}\n <textarea\n className={`${custom.textarea} ${custom.hidden}`}\n\n // This text area is hidden underneath the primary one below,\n // and it is used for text measurements, to implement auto-scaling\n // of the primary textarea's height.\n readOnly\n ref={hiddenAreaRef}\n\n // The \"-1\" value of \"tabIndex\" removes this hidden text area from\n // the tab-focus-chain.\n tabIndex={-1}\n\n // NOTE: With empty string value (\"\") the scrolling height of this text\n // area is zero, thus collapsing <TextArea> height below the single line\n // input height. To avoid it we fallback to whitespace (\" \") character\n // here.\n value={localValue || ' '}\n />\n <textarea\n className={custom.textarea}\n data-testid={process.env.NODE_ENV === 'production' ? undefined : testId}\n disabled={disabled}\n onBlur={onBlur}\n\n // When value is \"undefined\" the text area is not-managed, and we should\n // manage it internally for the measurement / resizing functionality\n // to work.\n onChange={\n value === undefined\n ? (e) => {\n setLocalValue(e.target.value);\n } : onChange\n }\n onKeyDown={onKeyDown}\n placeholder={placeholder}\n\n ref={(node) => {\n textAreaRef.current = node;\n\n if (typeof ref === 'function') ref(node);\n\n // eslint-disable-next-line no-param-reassign\n else if (ref) ref.current = node;\n }}\n\n style={{ height }}\n value={localValue}\n />\n {error && error !== true\n ? <div className={custom.errorMessage}>{error}</div>\n : null}\n </div>\n );\n};\n\nexport default TextArea;\n"],"mappings":"4CAAA,OAOEA,SAAS,CACTC,eAAe,CACfC,MAAM,CACNC,QAAQ,KACH,OAAO,CAEd,OAAqBC,QAAQ,KAAQ,0BAA0B,CAE/D,MAAO,CAAAC,YAAY,oBAAqB,OAAAC,GAAA,IAAAC,IAAA,CAAAC,IAAA,IAAAC,KAAA,yBAmBxC,KAAM,CAAAC,QAAkC,CAAGC,EAAA,SAAAC,CAAA,CAAAC,EAAA,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AAH,CAAA,KAAAa,MAAA,CAAAkD,YAAA/D,CAAA,MAAAG,KAAAH,CAAA,MAAA8D,GAAA,MAAAA,GAAA,CAAA9D,CAAA,SAAAgE,GAAA,IAAAhE,CAAA,OAAAoC,kBAAA,EAAApC,CAAA,OAAA4D,GAAA,EAAA5D,CAAA,OAAA8D,GAAA,EAAA9D,CAAA,OAAAwC,EAAA,EAAAxC,CAAA,OAAA+C,EAAA,EA1DViB,GAAA,cAAAnE,KAAA,QACauC,SAAkB,CAAlBA,kBAAkB,CACpB6B,OAER,CAFQ3B,EAER,CAAAI,QAAA,EAEAF,EAAwE,CACzEO,EAkBE,CACFa,GA6BE,CACDE,GAEO,EACL,CAAC,CAAA9D,CAAA,KAAAoC,kBAAApC,CAAA,MAAA4D,GAAA5D,CAAA,MAAA8D,GAAA9D,CAAA,MAAAwC,EAAAxC,CAAA,MAAA+C,EAAA/C,CAAA,MAAAgE,GAAA,MAAAA,GAAA,CAAAhE,CAAA,WA3DN,CAAAgE,GA2DM,CAET,CAED,cAAe,CAAAlE,QAAQ","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"index.js","names":["el","hiddenAreaRef","localValue","containerClassName"],"sources":["../../../../../src/shared/components/TextArea/index.tsx"],"sourcesContent":["import {\n type ChangeEventHandler,\n type FocusEventHandler,\n type FunctionComponent,\n type KeyboardEventHandler,\n type ReactNode,\n type Ref,\n useEffect,\n useLayoutEffect,\n useRef,\n useState,\n} from 'react';\n\nimport { type Theme, useTheme } from '@dr.pogodin/react-themes';\n\nimport defaultTheme from './style.scss';\n\ntype ThemeKeyT = 'container' | 'error' | 'errorMessage' | 'hidden' | 'label'\n | 'textarea';\n\ntype Props = {\n disabled?: boolean;\n error?: ReactNode;\n label?: string;\n onBlur?: FocusEventHandler<HTMLTextAreaElement>;\n onChange?: ChangeEventHandler<HTMLTextAreaElement>;\n onKeyDown?: KeyboardEventHandler<HTMLTextAreaElement>;\n placeholder?: string;\n ref?: Ref<HTMLTextAreaElement>;\n testId?: string;\n theme?: Theme<ThemeKeyT>;\n value?: string;\n};\n\nconst TextArea: FunctionComponent<Props> = ({\n disabled,\n error,\n label,\n onBlur,\n onChange,\n onKeyDown,\n placeholder,\n ref,\n testId,\n theme,\n value,\n}) => {\n const custom = useTheme('TextArea', defaultTheme, theme);\n\n const hiddenAreaRef = useRef<HTMLTextAreaElement>(null);\n const [height, setHeight] = useState<number | undefined>();\n\n const textAreaRef = useRef<HTMLTextAreaElement>(null);\n\n const [localValue, setLocalValue] = useState(value ?? '');\n if (value !== undefined && localValue !== value) setLocalValue(value);\n\n // This resizes text area's height when its width is changed for any reason.\n useEffect(() => {\n const el = hiddenAreaRef.current;\n if (!el) return undefined;\n\n const cb = () => {\n setHeight(el.scrollHeight);\n };\n const observer = new ResizeObserver(cb);\n observer.observe(el);\n\n return () => {\n observer.disconnect();\n };\n }, []);\n\n // Resizes the text area when its content is modified.\n //\n // NOTE: useLayoutEffect() instead of useEffect() makes difference here,\n // as it helps to avoid visible \"content/height\" jumps (i.e. with just\n // useEffect() it becomes visible how the content is modified first,\n // and then input height is incremented, if necessary).\n // See: https://github.com/birdofpreyru/react-utils/issues/313\n useLayoutEffect(() => {\n const el = hiddenAreaRef.current;\n if (el) setHeight(el.scrollHeight);\n }, [localValue]);\n\n let containerClassName = custom.container;\n if (error) containerClassName += ` ${custom.error}`;\n\n return (\n <div\n className={containerClassName}\n onFocus={() => {\n textAreaRef.current?.focus();\n }}\n >\n {label === undefined ? null : <div className={custom.label}>{label}</div>}\n <textarea\n className={`${custom.textarea} ${custom.hidden}`}\n\n // This text area is hidden underneath the primary one below,\n // and it is used for text measurements, to implement auto-scaling\n // of the primary textarea's height.\n readOnly\n ref={hiddenAreaRef}\n\n // The \"-1\" value of \"tabIndex\" removes this hidden text area from\n // the tab-focus-chain.\n tabIndex={-1}\n\n // NOTE: With empty string value (\"\") the scrolling height of this text\n // area is zero, thus collapsing <TextArea> height below the single line\n // input height. To avoid it we fallback to whitespace (\" \") character\n // here.\n value={localValue || ' '}\n />\n <textarea\n className={custom.textarea}\n data-testid={process.env.NODE_ENV === 'production' ? undefined : testId}\n disabled={disabled}\n onBlur={onBlur}\n\n // When value is \"undefined\" the text area is not-managed, and we should\n // manage it internally for the measurement / resizing functionality\n // to work.\n onChange={\n value === undefined\n ? (e) => {\n setLocalValue(e.target.value);\n } : onChange\n }\n onKeyDown={onKeyDown}\n placeholder={placeholder}\n\n ref={(node) => {\n textAreaRef.current = node;\n\n if (typeof ref === 'function') ref(node);\n\n // eslint-disable-next-line no-param-reassign\n else if (ref) ref.current = node;\n }}\n\n style={{ height }}\n value={localValue}\n />\n {error && error !== true\n ? <div className={custom.errorMessage}>{error}</div>\n : null}\n </div>\n );\n};\n\nexport default TextArea;\n"],"mappings":"4CAAA,OAOE,SAAS,CACT,eAAe,CACf,MAAM,CACN,QAAQ,KACH,OAAO,CAEd,OAAqB,QAAQ,KAAQ,0BAA0B,CAE/D,MAAO,aAAY,oBAAqB,yDAmBxC,KAAM,SAAkC,CAAG,oBAAC,2FAY3C,CACC,aAAe,QAAQ,CAAC,UAAU,CAAE,YAAY,CAAE,KAAK,CAAC,CAExD,oBAAsB,MAAM,CAAsB,IAAI,CAAC,CACvD,wBAA4B,QAAQ,CAAqB,CAAC,CAE1D,kBAAoB,MAAM,CAAsB,IAAI,CAAC,CAErD,gCAAoC,QAAQ,CAAC,KAAW,EAAX,EAAW,CAAC,CACzD,GAAI,KAAK,GAAK,SAAiC,EAApB,UAAU,GAAK,KAAK,EAAE,aAAa,CAAC,KAAK,CAAC,CAAC,iEAG5D,QACR,SAAW,aAAa,QAAQ,CAChC,GAAI,CAAC,EAAE,SAEP,SAAW,KACT,SAAS,CAAC,EAAE,aAAa,CAAC,CAC3B,CACD,eAAiB,GAAI,eAAc,CAAC,EAAE,CAAC,CACvC,QAAQ,QAAQ,CAAC,EAAE,CAAC,OAEb,KACL,QAAQ,WAAW,CAAC,CAAC,CACtB,CACF,CAAE,KAAE,sCAbL,SAAS,CAAC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AAU,CACVC,KAAU,CAAV,UAAU,CAClB,CAAC,8NACD,SAAuB,EAAd,KAAK,GAAK,IAEZ,cAFP,YACmB,SAAmB,CAAnB,MAAM,aAAa,UAAG,KAAK,CACxC,CAAC,CAFP,IAEO,yJA1DV,8BACaC,SAAkB,CAAlB,kBAAkB,CACpB,OAER,CAFQ,EAER,WAEA,EAAwE,CACzE,EAkBE,CACF,GA6BE,CACD,GAEO,EACL,CAAC,+FA3DN,IA2DM,CAET,CAED,cAAe,SAAQ","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":[
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../../../../../src/shared/components/Throbber/index.tsx"],"sourcesContent":["import type { FunctionComponent } from 'react';\n\nimport { type PRIORITY, type Theme, useTheme } from '@dr.pogodin/react-themes';\n\nimport defaultTheme from './theme.scss';\n\ntype ThemeKeyT = 'bouncing' | 'circle' | 'container';\n\ntype PropsT = {\n theme?: Theme<ThemeKeyT>;\n themePriority?: PRIORITY;\n};\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 */\nconst Throbber: FunctionComponent<PropsT> = ({ theme, themePriority }) => {\n const custom = useTheme('Throbber', defaultTheme, theme, {\n themePriority,\n });\n\n return (\n <span className={custom.container}>\n <span className={custom.circle} />\n <span className={custom.circle} />\n <span className={custom.circle} />\n </span>\n );\n};\n\nexport default Throbber;\n"],"mappings":"4CAEA,OAAoC,QAAQ,KAAQ,0BAA0B,CAE9E,MAAO,aAAY,oBAAqB,yDASxC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,GACA,KAAM,SAAmC,CAAG,oBAAC,6BAAwB,iCACV,iBAEzD,CAAC,yCAFD,aAAe,QAAQ,CAAC,UAAU,CAAE,YAAY,CAAE,KAAK,CAAE,EAExD,CAAC,CAAC,8CAIC,6BAAiB,SAAa,CAAb,MAAM,OAAO,CAAG,CAAC,CAClC,6BAAiB,SAAa,CAAb,MAAM,OAAO,CAAG,CAAC,CAClC,6BAAiB,SAAa,CAAb,MAAM,OAAO,CAAG,CAAC,6IAHpC,8BAAiB,SAAgB,CAAhB,MAAM,UAAU,WAC/B,EAAkC,CAClC,EAAkC,CAClC,EAAkC,EAC9B,CAAC,4EAJP,GAIO,CAEV,CAED,cAAe,SAAQ","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Tooltip.js","names":["useImperativeHandle","useRef","createPortal","jsx","_jsx","jsxs","_jsxs","PLACEMENTS","ARROW_STYLE_DOWN","join","ARROW_STYLE_UP","calcTooltipRects","tooltip","arrow","getBoundingClientRect","container","calcViewportRect","scrollX","scrollY","window","documentElement","clientHeight","clientWidth","document","bottom","left","right","top","calcPositionAboveXY","x","y","tooltipRects","arrowX","width","arrowY","height","containerX","containerY","baseArrowStyle","setComponentPositions","pageX","pageY","placement","element","viewportRect","pos","Math","max","maxX","min","containerStyle","setAttribute","arrowStyle","Tooltip","t0","$","_c","children","ref","theme","arrowRef","containerRef","contentRef","t1","Symbol","for","current","Error","content","pointTo","t2","t3","className","t4","t5","body"],"sources":["../../../../../src/shared/components/WithTooltip/Tooltip.tsx"],"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\nimport {\n type FunctionComponent,\n type ReactNode,\n type RefObject,\n useImperativeHandle,\n useRef,\n} from 'react';\n\nimport { createPortal } from 'react-dom';\n\nimport type { Theme } from '@dr.pogodin/react-themes';\n\n/**\n * Valid placements of the rendered tooltip. They will be overriden when\n * necessary to fit the tooltip within the viewport.\n */\nexport enum 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\ntype ComponentsT = {\n arrow: HTMLDivElement;\n container: HTMLDivElement;\n content: HTMLDivElement;\n};\n\nexport type ThemeKeysT = 'appearance' | 'arrow' | 'container' | 'content';\n\ntype TooltipThemeT = Theme<ThemeKeysT>;\n\ntype TooltipRectsT = {\n arrow: DOMRect;\n container: DOMRect;\n};\n\n/**\n * Generates bounding client rectangles for tooltip components.\n * @ignore\n * @param tooltip DOM references to the tooltip components.\n * @param tooltip.arrow\n * @param tooltip.container\n * @return Object holding tooltip rectangles in\n * two fields.\n */\nfunction calcTooltipRects(tooltip: ComponentsT): TooltipRectsT {\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 { scrollX, scrollY } = window;\n const { documentElement: { clientHeight, clientWidth } } = document;\n return {\n bottom: scrollY + clientHeight,\n left: scrollX,\n right: scrollX + clientWidth,\n top: scrollY,\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(\n x: number,\n y: number,\n tooltipRects: TooltipRectsT,\n) {\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// const HIT = {\n// NONE: false,\n// LEFT: 'LEFT',\n// RIGHT: 'RIGHT',\n// TOP: 'TOP',\n// BOTTOM: 'BOTTOM',\n// };\n\n/**\n * Checks whether\n * @param {object} pos\n * @param {object} tooltipRects\n * @param {object} viewportRect\n * @return {HIT}\n */\n// function 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 * 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// function 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 * Sets positions of tooltip components to point the tooltip to the specified\n * page point.\n * @ignore\n * @param pageX\n * @param pageY\n * @param placement\n * @param element DOM reference to the element wrapped by the tooltip.\n * @param tooltip\n * @param tooltip.arrow DOM reference to the tooltip arrow.\n * @param tooltip.container DOM reference to the tooltip container.\n */\nfunction setComponentPositions(\n pageX: number,\n pageY: number,\n placement: PLACEMENTS | undefined,\n element: HTMLElement | undefined,\n tooltip: ComponentsT,\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: FunctionComponent<{\n children?: ReactNode;\n ref?: RefObject<unknown>;\n theme: TooltipThemeT;\n}> = ({ children, ref, theme }) => {\n // NOTE: The way it has to be implemented, for clean mounting and unmounting\n // at the client side, the <Tooltip> is fully mounted into DOM in the next\n // rendering cycles, and only then it can be correctly measured and positioned.\n // Thus, when we create the <Tooltip> we have to record its target positioning\n // details, and then apply them when it is created.\n\n const arrowRef = useRef<HTMLDivElement>(null);\n const containerRef = useRef<HTMLDivElement>(null);\n const contentRef = useRef<HTMLDivElement>(null);\n\n const pointTo = (\n pageX: number,\n pageY: number,\n placement: PLACEMENTS,\n element: HTMLElement,\n ) => {\n if (!arrowRef.current || !containerRef.current || !contentRef.current) {\n throw Error('Internal error');\n }\n\n setComponentPositions(pageX, pageY, placement, element, {\n arrow: arrowRef.current,\n container: containerRef.current,\n content: contentRef.current,\n });\n };\n useImperativeHandle(ref, () => ({ pointTo }));\n\n return createPortal(\n (\n <div className={theme.container} ref={containerRef}>\n <div className={theme.arrow} ref={arrowRef} />\n <div className={theme.content} ref={contentRef}>{children}</div>\n </div>\n ),\n document.body,\n );\n};\n\nexport default Tooltip;\n"],"mappings":"4CAAA;AACA;AACA;AACA;AACA,GAEA,OAIEA,mBAAmB,CACnBC,MAAM,KACD,OAAO,CAEd,OAASC,YAAY,KAAQ,WAAW,CAAC,OAAAC,GAAA,IAAAC,IAAA,CAAAC,IAAA,IAAAC,KAAA,yBAIzC;AACA;AACA;AACA,GACA,UAAY,CAAAC,UAAU,uBAAVA,UAAU,EAAVA,UAAU,gCAAVA,UAAU,kCAAVA,UAAU,gCAAVA,UAAU,wCAAV,CAAAA,UAAU,MAOtB,KAAM,CAAAC,gBAAgB,CAAG,CACvB,iCAAiC,CACjC,+BAA+B,CAC/B,gCAAgC,CACjC,CAACC,IAAI,CAAC,GAAG,CAAC,CAEX,KAAM,CAAAC,cAAc,CAAG,CACrB,8BAA8B,CAC9B,+BAA+B,CAC/B,gCAAgC,CACjC,CAACD,IAAI,CAAC,GAAG,CAAC,CAiBX;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,GACA,QAAS,CAAAE,gBAAgBA,CAACC,OAAoB,CAAiB,CAC7D,MAAO,CACLC,KAAK,CAAED,OAAO,CAACC,KAAK,CAACC,qBAAqB,CAAC,CAAC,CAC5CC,SAAS,CAAEH,OAAO,CAACG,SAAS,CAACD,qBAAqB,CAAC,CACrD,CAAC,CACH,CAEA;AACA;AACA;AACA;AACA,GACA,QAAS,CAAAE,gBAAgBA,CAAA,CAAG,CAC1B,KAAM,CAAEC,OAAO,CAAEC,OAAQ,CAAC,CAAGC,MAAM,CACnC,KAAM,CAAEC,eAAe,CAAE,CAAEC,YAAY,CAAEC,WAAY,CAAE,CAAC,CAAGC,QAAQ,CACnE,MAAO,CACLC,MAAM,CAAEN,OAAO,CAAGG,YAAY,CAC9BI,IAAI,CAAER,OAAO,CACbS,KAAK,CAAET,OAAO,CAAGK,WAAW,CAC5BK,GAAG,CAAET,OACP,CAAC,CACH,CAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,GACA,QAAS,CAAAU,mBAAmBA,CAC1BC,CAAS,CACTC,CAAS,CACTC,YAA2B,CAC3B,CACA,KAAM,CAAElB,KAAK,CAAEE,SAAU,CAAC,CAAGgB,YAAY,CACzC,MAAO,CACLC,MAAM,CAAE,GAAG,EAAIjB,SAAS,CAACkB,KAAK,CAAGpB,KAAK,CAACoB,KAAK,CAAC,CAC7CC,MAAM,CAAEnB,SAAS,CAACoB,MAAM,CACxBC,UAAU,CAAEP,CAAC,CAAGd,SAAS,CAACkB,KAAK,CAAG,CAAC,CACnCI,UAAU,CAAEP,CAAC,CAAGf,SAAS,CAACoB,MAAM,CAAGtB,KAAK,CAACsB,MAAM,CAAG,GAAG,CAErD;AACA;AACA;AACAG,cAAc,CAAE9B,gBAClB,CAAC,CACH,CAEA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,GACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,GACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,GACA,QAAS,CAAA+B,qBAAqBA,CAC5BC,KAAa,CACbC,KAAa,CACbC,SAAiC,CACjCC,OAAgC,CAChC/B,OAAoB,CACpB,CACA,KAAM,CAAAmB,YAAY,CAAGpB,gBAAgB,CAACC,OAAO,CAAC,CAC9C,KAAM,CAAAgC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,MAAAmB,EAAA,MAAAA,EAAA,CAAAnB,CAAA,WARM,CAAAmB,EAQN,CACF,CAED,cAAe,CAAArB,OAAO","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"Tooltip.js","names":["arrowRef","contentRef","containerRef"],"sources":["../../../../../src/shared/components/WithTooltip/Tooltip.tsx"],"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\nimport {\n type FunctionComponent,\n type ReactNode,\n type RefObject,\n useImperativeHandle,\n useRef,\n} from 'react';\n\nimport { createPortal } from 'react-dom';\n\nimport type { Theme } from '@dr.pogodin/react-themes';\n\n/**\n * Valid placements of the rendered tooltip. They will be overriden when\n * necessary to fit the tooltip within the viewport.\n */\nexport enum 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\ntype ComponentsT = {\n arrow: HTMLDivElement;\n container: HTMLDivElement;\n content: HTMLDivElement;\n};\n\nexport type ThemeKeysT = 'appearance' | 'arrow' | 'container' | 'content';\n\ntype TooltipThemeT = Theme<ThemeKeysT>;\n\ntype TooltipRectsT = {\n arrow: DOMRect;\n container: DOMRect;\n};\n\n/**\n * Generates bounding client rectangles for tooltip components.\n * @ignore\n * @param tooltip DOM references to the tooltip components.\n * @param tooltip.arrow\n * @param tooltip.container\n * @return Object holding tooltip rectangles in\n * two fields.\n */\nfunction calcTooltipRects(tooltip: ComponentsT): TooltipRectsT {\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 { scrollX, scrollY } = window;\n const { documentElement: { clientHeight, clientWidth } } = document;\n return {\n bottom: scrollY + clientHeight,\n left: scrollX,\n right: scrollX + clientWidth,\n top: scrollY,\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(\n x: number,\n y: number,\n tooltipRects: TooltipRectsT,\n) {\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// const HIT = {\n// NONE: false,\n// LEFT: 'LEFT',\n// RIGHT: 'RIGHT',\n// TOP: 'TOP',\n// BOTTOM: 'BOTTOM',\n// };\n\n/**\n * Checks whether\n * @param {object} pos\n * @param {object} tooltipRects\n * @param {object} viewportRect\n * @return {HIT}\n */\n// function 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 * 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// function 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 * Sets positions of tooltip components to point the tooltip to the specified\n * page point.\n * @ignore\n * @param pageX\n * @param pageY\n * @param placement\n * @param element DOM reference to the element wrapped by the tooltip.\n * @param tooltip\n * @param tooltip.arrow DOM reference to the tooltip arrow.\n * @param tooltip.container DOM reference to the tooltip container.\n */\nfunction setComponentPositions(\n pageX: number,\n pageY: number,\n placement: PLACEMENTS | undefined,\n element: HTMLElement | undefined,\n tooltip: ComponentsT,\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: FunctionComponent<{\n children?: ReactNode;\n ref?: RefObject<unknown>;\n theme: TooltipThemeT;\n}> = ({ children, ref, theme }) => {\n // NOTE: The way it has to be implemented, for clean mounting and unmounting\n // at the client side, the <Tooltip> is fully mounted into DOM in the next\n // rendering cycles, and only then it can be correctly measured and positioned.\n // Thus, when we create the <Tooltip> we have to record its target positioning\n // details, and then apply them when it is created.\n\n const arrowRef = useRef<HTMLDivElement>(null);\n const containerRef = useRef<HTMLDivElement>(null);\n const contentRef = useRef<HTMLDivElement>(null);\n\n const pointTo = (\n pageX: number,\n pageY: number,\n placement: PLACEMENTS,\n element: HTMLElement,\n ) => {\n if (!arrowRef.current || !containerRef.current || !contentRef.current) {\n throw Error('Internal error');\n }\n\n setComponentPositions(pageX, pageY, placement, element, {\n arrow: arrowRef.current,\n container: containerRef.current,\n content: contentRef.current,\n });\n };\n useImperativeHandle(ref, () => ({ pointTo }));\n\n return createPortal(\n (\n <div className={theme.container} ref={containerRef}>\n <div className={theme.arrow} ref={arrowRef} />\n <div className={theme.content} ref={contentRef}>{children}</div>\n </div>\n ),\n document.body,\n );\n};\n\nexport default Tooltip;\n"],"mappings":"4CAAA;AACA;AACA;AACA;AACA,GAEA,OAIE,mBAAmB,CACnB,MAAM,KACD,OAAO,CAEd,OAAS,YAAY,KAAQ,WAAW,CAAC,yDAIzC;AACA;AACA;AACA,GACA,UAAY,WAAU,uBAAV,UAAU,EAAV,UAAU,gCAAV,UAAU,kCAAV,UAAU,gCAAV,UAAU,wCAAV,WAAU,MAOtB,KAAM,iBAAgB,CAAG,CACvB,iCAAiC,CACjC,+BAA+B,CAC/B,gCAAgC,CACjC,CAAC,IAAI,CAAC,GAAG,CAAC,CAEX,KAAM,eAAc,CAAG,CACrB,8BAA8B,CAC9B,+BAA+B,CAC/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UAAG,QAAQ,CAAM,CAAC,+GAJ/D,4BAAY,cAEf,aAAgB,SAAe,CAAf,KAAK,UAAU,CAAOC,GAAY,CAAZ,YAAY,WAChD,EAA8C,CAC9C,EAAgE,EAC7D,CAAC,CAER,QAAQ,KACV,CAAC,mEARM,GAQN,CACF,CAED,cAAe,QAAO","ignoreList":[]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/* global window */import{useEffect,useRef,useState}from"react";import{useTheme}from"@dr.pogodin/react-themes";import Tooltip,{PLACEMENTS}from"./Tooltip";import defaultTheme from"./default-theme.scss";import{jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";/**
|
|
1
|
+
/* global window */import{useEffect,useRef,useState}from"react";import{useTheme}from"@dr.pogodin/react-themes";import Tooltip,{PLACEMENTS}from"./Tooltip.js";import defaultTheme from"./default-theme.scss";import{jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";/**
|
|
2
2
|
* Implements a simple to use and themeable tooltip component, _e.g._
|
|
3
3
|
* ```js
|
|
4
4
|
* <WithTooltip tip="This is example tooltip.">
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["useEffect","useRef","useState","useTheme","Tooltip","PLACEMENTS","defaultTheme","jsx","_jsx","jsxs","_jsxs","WithTooltip","children","className","classNameProp","onClick","onContextMenu","onMouseLeave","onMouseMove","onTouchStart","placement","ABOVE_CURSOR","ref","style","theme","tip","htmlAttributes","custom","heap","setHeap","lastCursorX","lastCursorY","timerId","undefined","triggeredByTouch","tooltipRef","wrapperRef","showTooltip","setShowTooltip","updatePortalPosition","cursorX","cursorY","wrapperRect","current","getBoundingClientRect","left","right","top","bottom","pointTo","window","scrollX","scrollY","prev","res","setTimeout","p","listener","addEventListener","removeEventListener","container","wrapper","clearTimeout","e","preventDefault","ignoreMouseMove","clientX","clientY","touch","targetTouches","item","node","role"],"sources":["../../../../../src/shared/components/WithTooltip/index.tsx"],"sourcesContent":["/* global window */\n\nimport {\n type FunctionComponent,\n type HTMLAttributes,\n type ReactNode,\n type RefObject,\n useEffect,\n useRef,\n useState,\n} from 'react';\n\nimport { type Theme, useTheme } from '@dr.pogodin/react-themes';\n\nimport Tooltip, {\n PLACEMENTS,\n type ThemeKeysT as TooltipThemeKeysT,\n} from './Tooltip';\n\nimport defaultTheme from './default-theme.scss';\n\ntype PropsT = HTMLAttributes<HTMLDivElement> & {\n children?: ReactNode;\n placement?: PLACEMENTS;\n ref?: RefObject<HTMLDivElement | null>;\n theme?: Theme<'wrapper' | TooltipThemeKeysT>;\n tip?: ReactNode;\n};\n\ntype TooltipRefT = {\n pointTo: (\n x: number,\n y: number,\n placement: PLACEMENTS,\n wrapperRef: HTMLDivElement,\n ) => void;\n};\n\ntype HeapT = {\n ignoreMouseMove?: boolean;\n lastCursorX: number;\n lastCursorY: number;\n timerId?: NodeJS.Timeout;\n triggeredByTouch: boolean;\n};\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 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 */\nconst WithTooltip: FunctionComponent<PropsT> = ({\n children,\n className: classNameProp,\n onClick,\n onContextMenu,\n onMouseLeave,\n onMouseMove,\n onTouchStart,\n placement = PLACEMENTS.ABOVE_CURSOR,\n ref,\n style,\n theme,\n tip,\n ...htmlAttributes\n}) => {\n const custom = useTheme('WithTooltip', defaultTheme, theme);\n\n const [heap, setHeap] = useState<HeapT>({\n lastCursorX: 0,\n lastCursorY: 0,\n timerId: undefined,\n triggeredByTouch: false,\n });\n\n const tooltipRef = useRef<TooltipRefT>(null);\n const wrapperRef = useRef<HTMLDivElement>(null);\n const [showTooltip, setShowTooltip] = useState(false);\n\n const updatePortalPosition = (cursorX: number, cursorY: number) => {\n if (showTooltip) {\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.scrollX,\n cursorY + window.scrollY,\n placement,\n wrapperRef.current!,\n );\n }\n } else {\n setHeap((prev) => {\n const res: HeapT = {\n ...prev,\n lastCursorX: cursorX,\n lastCursorY: cursorY,\n };\n\n // If tooltip was triggered by a touch, we delay its opening by a bit,\n // to ensure it was not a touch-click - in the case of touch click we\n // want to do the click, rather than show the tooltip, and the delay\n // gives click handler a chance to abort the tooltip openning.\n if (res.triggeredByTouch) {\n res.timerId ??= setTimeout(() => {\n setHeap((p) => ({\n ...p,\n timerId: undefined,\n triggeredByTouch: false,\n }));\n\n setShowTooltip(true);\n }, 300);\n\n // Otherwise we can just open the tooltip right away.\n } else setShowTooltip(true);\n\n return res;\n });\n }\n };\n\n useEffect(() => {\n if (showTooltip && tip !== null) {\n // This is necessary to ensure that even when a single mouse event\n // arrives to a tool-tipped component, the tooltip is correctly positioned\n // once opened (because similar call above does not have effect until\n // the tooltip is fully mounted, and that is delayed to future rendering\n // cycle due to the implementation).\n if (tooltipRef.current) {\n setHeap((prev) => {\n tooltipRef.current?.pointTo(\n prev.lastCursorX + window.scrollX,\n prev.lastCursorY + window.scrollY,\n placement,\n wrapperRef.current!,\n );\n return prev;\n });\n }\n\n const listener = () => {\n setShowTooltip(false);\n };\n window.addEventListener('scroll', listener);\n return () => {\n window.removeEventListener('scroll', listener);\n };\n }\n return undefined;\n }, [\n placement,\n showTooltip,\n tip,\n ]);\n\n let container = custom.wrapper;\n if (classNameProp) container += ` ${classNameProp}`;\n\n useEffect(() => {\n const listener = () => {\n setShowTooltip(false);\n heap.triggeredByTouch = false;\n if (heap.timerId) {\n clearTimeout(heap.timerId);\n heap.timerId = undefined;\n heap.triggeredByTouch = false;\n }\n };\n window.addEventListener('touchcancel', listener);\n window.addEventListener('touchend', listener);\n return () => {\n window.removeEventListener('touchcancel', listener);\n window.removeEventListener('touchend', listener);\n };\n }, [heap]);\n\n return (\n <div\n className={container}\n onClick={(e) => {\n if (heap.timerId) {\n clearTimeout(heap.timerId);\n\n setHeap({\n ...heap,\n timerId: undefined,\n triggeredByTouch: false,\n });\n }\n onClick?.(e);\n }}\n onContextMenu={(e) => {\n e.preventDefault();\n onContextMenu?.(e);\n }}\n onMouseLeave={(e) => {\n setShowTooltip(false);\n onMouseLeave?.(e);\n }}\n onMouseMove={(e) => {\n // NOTE: Because on touch devices mouse move events are still fired\n // after touch is released, to emulate mouse clicks for old websites.\n // If we don't ignore it here, the tooltip will appear after the touch\n // is released.\n if (!heap.ignoreMouseMove) {\n updatePortalPosition(e.clientX, e.clientY);\n }\n onMouseMove?.(e);\n }}\n onTouchStart={(e) => {\n setHeap({\n ...heap,\n ignoreMouseMove: true,\n triggeredByTouch: true,\n });\n\n // TODO: I guess, it should be something more complex here,\n // to actually respond to the first / whatever touch we need.\n const touch = e.targetTouches.item(0);\n updatePortalPosition(touch.clientX, touch.clientY);\n\n onTouchStart?.(e);\n }}\n ref={(node) => {\n wrapperRef.current = node;\n\n // eslint-disable-next-line no-param-reassign\n if (ref) ref.current = node;\n }}\n role=\"presentation\"\n style={style}\n\n // eslint-disable-next-line react/jsx-props-no-spreading\n {...htmlAttributes}\n >\n {\n showTooltip && tip !== null\n ? <Tooltip ref={tooltipRef} theme={custom}>{tip}</Tooltip>\n : null\n }\n {children}\n </div>\n );\n};\n\ntype ExportT = {\n PLACEMENTS: typeof PLACEMENTS;\n} & typeof WithTooltip;\n\nconst e: ExportT = WithTooltip as ExportT;\n\ne.PLACEMENTS = PLACEMENTS;\n\nexport default e;\n"],"mappings":"AAAA,mBAEA,OAKEA,SAAS,CACTC,MAAM,CACNC,QAA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FC,IAAI,CAAC,cAAc,CACnBjD,KAAK,CAAEA,KAEP;AAAA,IACIG,cAAc,CAAAd,QAAA,EAGhByB,WAAW,EAAIZ,GAAG,GAAK,IAAI,cACvBjB,IAAA,CAACJ,OAAO,EAACkB,GAAG,CAAEa,UAAW,CAACX,KAAK,CAAEG,MAAO,CAAAf,QAAA,CAAEa,GAAG,CAAU,CAAC,CACxD,IAAI,CAETb,QAAQ,EACN,CAAC,CAEV,CAAC,CAMD,KAAM,CAAAmD,CAAU,CAAGpD,WAAsB,CAEzCoD,CAAC,CAAC1D,UAAU,CAAGA,UAAU,CAEzB,cAAe,CAAA0D,CAAC","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"index.js","names":["prev","listener","e"],"sources":["../../../../../src/shared/components/WithTooltip/index.tsx"],"sourcesContent":["/* global window */\n\nimport {\n type FunctionComponent,\n type HTMLAttributes,\n type ReactNode,\n type RefObject,\n useEffect,\n useRef,\n useState,\n} from 'react';\n\nimport { type Theme, useTheme } from '@dr.pogodin/react-themes';\n\nimport Tooltip, {\n PLACEMENTS,\n type ThemeKeysT as TooltipThemeKeysT,\n} from './Tooltip';\n\nimport defaultTheme from './default-theme.scss';\n\ntype PropsT = HTMLAttributes<HTMLDivElement> & {\n children?: ReactNode;\n placement?: PLACEMENTS;\n ref?: RefObject<HTMLDivElement | null>;\n theme?: Theme<'wrapper' | TooltipThemeKeysT>;\n tip?: ReactNode;\n};\n\ntype TooltipRefT = {\n pointTo: (\n x: number,\n y: number,\n placement: PLACEMENTS,\n wrapperRef: HTMLDivElement,\n ) => void;\n};\n\ntype HeapT = {\n ignoreMouseMove?: boolean;\n lastCursorX: number;\n lastCursorY: number;\n timerId?: NodeJS.Timeout;\n triggeredByTouch: boolean;\n};\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 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 */\nconst WithTooltip: FunctionComponent<PropsT> = ({\n children,\n className: classNameProp,\n onClick,\n onContextMenu,\n onMouseLeave,\n onMouseMove,\n onTouchStart,\n placement = PLACEMENTS.ABOVE_CURSOR,\n ref,\n style,\n theme,\n tip,\n ...htmlAttributes\n}) => {\n const custom = useTheme('WithTooltip', defaultTheme, theme);\n\n const [heap, setHeap] = useState<HeapT>({\n lastCursorX: 0,\n lastCursorY: 0,\n timerId: undefined,\n triggeredByTouch: false,\n });\n\n const tooltipRef = useRef<TooltipRefT>(null);\n const wrapperRef = useRef<HTMLDivElement>(null);\n const [showTooltip, setShowTooltip] = useState(false);\n\n const updatePortalPosition = (cursorX: number, cursorY: number) => {\n if (showTooltip) {\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.scrollX,\n cursorY + window.scrollY,\n placement,\n wrapperRef.current!,\n );\n }\n } else {\n setHeap((prev) => {\n const res: HeapT = {\n ...prev,\n lastCursorX: cursorX,\n lastCursorY: cursorY,\n };\n\n // If tooltip was triggered by a touch, we delay its opening by a bit,\n // to ensure it was not a touch-click - in the case of touch click we\n // want to do the click, rather than show the tooltip, and the delay\n // gives click handler a chance to abort the tooltip openning.\n if (res.triggeredByTouch) {\n res.timerId ??= setTimeout(() => {\n setHeap((p) => ({\n ...p,\n timerId: undefined,\n triggeredByTouch: false,\n }));\n\n setShowTooltip(true);\n }, 300);\n\n // Otherwise we can just open the tooltip right away.\n } else setShowTooltip(true);\n\n return res;\n });\n }\n };\n\n useEffect(() => {\n if (showTooltip && tip !== null) {\n // This is necessary to ensure that even when a single mouse event\n // arrives to a tool-tipped component, the tooltip is correctly positioned\n // once opened (because similar call above does not have effect until\n // the tooltip is fully mounted, and that is delayed to future rendering\n // cycle due to the implementation).\n if (tooltipRef.current) {\n setHeap((prev) => {\n tooltipRef.current?.pointTo(\n prev.lastCursorX + window.scrollX,\n prev.lastCursorY + window.scrollY,\n placement,\n wrapperRef.current!,\n );\n return prev;\n });\n }\n\n const listener = () => {\n setShowTooltip(false);\n };\n window.addEventListener('scroll', listener);\n return () => {\n window.removeEventListener('scroll', listener);\n };\n }\n return undefined;\n }, [\n placement,\n showTooltip,\n tip,\n ]);\n\n let container = custom.wrapper;\n if (classNameProp) container += ` ${classNameProp}`;\n\n useEffect(() => {\n const listener = () => {\n setShowTooltip(false);\n heap.triggeredByTouch = false;\n if (heap.timerId) {\n clearTimeout(heap.timerId);\n heap.timerId = undefined;\n heap.triggeredByTouch = false;\n }\n };\n window.addEventListener('touchcancel', listener);\n window.addEventListener('touchend', listener);\n return () => {\n window.removeEventListener('touchcancel', listener);\n window.removeEventListener('touchend', listener);\n };\n }, [heap]);\n\n return (\n <div\n className={container}\n onClick={(e) => {\n if (heap.timerId) {\n clearTimeout(heap.timerId);\n\n setHeap({\n ...heap,\n timerId: undefined,\n triggeredByTouch: false,\n });\n }\n onClick?.(e);\n }}\n onContextMenu={(e) => {\n e.preventDefault();\n onContextMenu?.(e);\n }}\n onMouseLeave={(e) => {\n setShowTooltip(false);\n onMouseLeave?.(e);\n }}\n onMouseMove={(e) => {\n // NOTE: Because on touch devices mouse move events are still fired\n // after touch is released, to emulate mouse clicks for old websites.\n // If we don't ignore it here, the tooltip will appear after the touch\n // is released.\n if (!heap.ignoreMouseMove) {\n updatePortalPosition(e.clientX, e.clientY);\n }\n onMouseMove?.(e);\n }}\n onTouchStart={(e) => {\n setHeap({\n ...heap,\n ignoreMouseMove: true,\n triggeredByTouch: true,\n });\n\n // TODO: I guess, it should be something more complex here,\n // to actually respond to the first / whatever touch we need.\n const touch = e.targetTouches.item(0);\n updatePortalPosition(touch.clientX, touch.clientY);\n\n onTouchStart?.(e);\n }}\n ref={(node) => {\n wrapperRef.current = node;\n\n // eslint-disable-next-line no-param-reassign\n if (ref) ref.current = node;\n }}\n role=\"presentation\"\n style={style}\n\n // eslint-disable-next-line react/jsx-props-no-spreading\n {...htmlAttributes}\n >\n {\n showTooltip && tip !== null\n ? <Tooltip ref={tooltipRef} theme={custom}>{tip}</Tooltip>\n : null\n }\n {children}\n </div>\n );\n};\n\ntype ExportT = {\n PLACEMENTS: typeof PLACEMENTS;\n} & typeof WithTooltip;\n\nconst e: ExportT = WithTooltip as ExportT;\n\ne.PLACEMENTS = PLACEMENTS;\n\nexport default e;\n"],"mappings":"AAAA,mBAEA,OAKE,SAAS,CACT,MAAM,CACN,QAAQ,KACH,OAAO,CAEd,OAAqB,QAAQ,KAAQ,0BAA0B,CAAC,MAEzD,QAAO,EACZ,UAAU,oBAIZ,MAAO,aAAY,4BAA6B,yDA2BhD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,GACA,KAAM,YAAsC,CAAG,CAAC,CAC9C,QAAQ,CACR,SAAS,CAAE,aAAa,CACxB,OAAO,CACP,aAAa,CACb,YAAY,CACZ,WAAW,CACX,YAAY,CACZ,SAAS,CAAG,UAAU,CAAC,YAAY,CACnC,GAAG,CACH,KAAK,CACL,KAAK,CACL,GAAG,CACH,GAAG,cACL,CAAC,GAAK,CACJ,KAAM,OAAM,CAAG,QAAQ,CAAC,aAAa,CAAE,YAAY,CAAE,KAAK,CAAC,CAE3D,KAAM,CAAC,IAAI,CAAE,OAAO,CAAC,CAAG,QAAQ,CAAQ,CACtC,WAAW,CAAE,CAAC,CACd,WAAW,CAAE,CAAC,CACd,OAAO,CAAE,SAAS,CAClB,gBAAgB,CAAE,KACpB,CAAC,CAAC,CAEF,KAAM,WAAU,CAAG,MAAM,CAAc,IAAI,CAAC,C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I,GAAG,CAAE,GAAG,CAAC,OAAO,CAAG,IAAI,CAC7B,CAAE,CACF,IAAI,CAAC,cAAc,CACnB,KAAK,CAAE,KAEP;AAAA,IACI,cAAc,WAGhB,WAAW,EAAI,GAAG,GAAK,IAAI,cACvB,KAAC,OAAO,EAAC,GAAG,CAAE,UAAW,CAAC,KAAK,CAAE,MAAO,UAAE,GAAG,CAAU,CAAC,CACxD,IAAI,CAET,QAAQ,EACN,CAAC,CAEV,CAAC,CAMD,KAAM,EAAU,CAAG,WAAsB,CAEzC,CAAC,CAAC,UAAU,CAAG,UAAU,CAEzB,cAAe,EAAC","ignoreList":[]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{c as _c}from"react/compiler-runtime";import qs from"qs";import{useTheme}from"@dr.pogodin/react-themes";import Throbber from"../Throbber";import defaultTheme from"./base.scss";import throbberTheme from"./throbber.scss";import{jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";/**
|
|
1
|
+
import{c as _c}from"react/compiler-runtime";import qs from"qs";import{useTheme}from"@dr.pogodin/react-themes";import Throbber from"../Throbber/index.js";import defaultTheme from"./base.scss";import throbberTheme from"./throbber.scss";import{jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";/**
|
|
2
2
|
* A component for embeding a YouTube video.
|
|
3
3
|
* @param [props] Component properties.
|
|
4
4
|
* @param [props.autoplay] If `true` the video will start to play
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["
|
|
1
|
+
{"version":3,"file":"index.js","names":["url","throbberTheme"],"sources":["../../../../../src/shared/components/YouTubeVideo/index.tsx"],"sourcesContent":["import qs from 'qs';\nimport type { FunctionComponent } from 'react';\n\nimport { type Theme, useTheme } from '@dr.pogodin/react-themes';\n\nimport Throbber from 'components/Throbber';\n\nimport defaultTheme from './base.scss';\nimport throbberTheme from './throbber.scss';\n\ntype ThemeT = Theme<'container' | 'video'>;\n\ntype PropsT = {\n autoplay?: boolean;\n src: string;\n theme?: ThemeT;\n title?: string;\n};\n\n/**\n * A component for embeding a YouTube video.\n * @param [props] Component properties.\n * @param [props.autoplay] If `true` the video will start to play\n * automatically once loaded.\n * @param [props.src] URL of the video to play. Can be in any of\n * the following formats, and keeps any additional query parameters understood\n * by the YouTube IFrame player:\n * - `https://www.youtube.com/watch?v=NdF6Rmt6Ado`\n * - `https://youtu.be/NdF6Rmt6Ado`\n * - `https://www.youtube.com/embed/NdF6Rmt6Ado`\n * @param [props.theme] _Ad hoc_ theme.\n * @param [props.title] The `title` attribute to add to the player\n * IFrame.\n */\nconst YouTubeVideo: FunctionComponent<PropsT> = ({\n autoplay,\n src,\n theme,\n title,\n}) => {\n const custom = useTheme('YouTubeVideo', defaultTheme, theme);\n\n const srcParts = src.split('?');\n let [url] = srcParts;\n const [, queryString] = srcParts;\n const query = queryString ? qs.parse(queryString) : {};\n\n const videoId = query.v ?? url?.match(/\\/([a-zA-Z0-9-_]*)$/)?.[1];\n url = `https://www.youtube.com/embed/${videoId as string}`;\n\n delete query.v;\n query.autoplay = autoplay ? '1' : '0';\n url += `?${qs.stringify(query)}`;\n\n // TODO: https://developers.google.com/youtube/player_parameters\n // More query parameters can be exposed via the component props.\n\n return (\n <div className={custom.container}>\n <Throbber theme={throbberTheme} />\n {/* TODO: I guess, we better add the sanbox, but right now I don't have\n time to carefully explore which restrictions should be lifted to allow\n embed YouTube player to work... sometime later we'll take care of it */\n }\n <iframe // eslint-disable-line react/iframe-missing-sandbox\n allow=\"autoplay\"\n allowFullScreen\n className={custom.video}\n src={url}\n title={title}\n />\n </div>\n );\n};\n\nexport default YouTubeVideo;\n"],"mappings":"4CAAA,MAAO,GAAE,KAAM,IAAI,CAGnB,OAAqB,QAAQ,KAAQ,0BAA0B,CAAC,MAEzD,SAAQ,4BAEf,MAAO,aAAY,mBACnB,MAAO,cAAa,uBAAwB,yDAW5C;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,GACA,KAAM,aAAuC,CAAG,oBAAC,kCAKhD,CACC,aAAe,QAAQ,CAAC,cAAc,CAAE,YAAY,CAAE,KAAK,CAAC,CAAC,sDAE7D,eAAiB,GAAG,MAAM,CAAC,GAAG,CAAC,CAC/B,MAAY,QAAQ,CACpB,oBAAwB,QAAQ,CAChC,YAAc,WAAW,CAAG,EAAE,MAAM,CAAC,WAAgB,CAAC,CAAxC,CAAuC,CAAC,CAEtD,cAAgB,KAAK,EAA4C,EAAtC,GAAG,OAA8B,CAAtB,qBAA0B,CAAC,MACjE,GAAAA,CAAMA,iCAAiC,OAAO,EAAY,CAE1D,MAAO,MAAK,EAAE,CACd,KAAK,UAAY,QAAQ,CAAR,GAAoB,CAApB,GAAH,CACdA,GAAA,GAAG,CAAQ,KAAE,UAAU,CAAC,KAAK,CAAC,+EAA9B,IAAAA,EAAG,CAAI,IAAI,EAAmB,EAAE,2DAO5B,qBAAC,QAAQ,EAAQC,KAAa,CAAb,aAAa,CAAG,CAAC,+EAKlC,+BACQ,KAAU,CAAV,UAAU,CAChB,eAAe,CAAf,IAAe,CACJ,SAAY,CAAZ,MAAM,MAAM,CAClBD,GAAG,CAAH,GAAG,CACD,KAAK,CAAL,KAAK,CACb,CAAC,4GAZJ,6BAAgB,SAAgB,CAAhB,MAAM,UAAU,WAC9B,EAAkC,CAKlC,EAME,EACC,CAAC,8DAbN,GAaM,CAET,CAED,cAAe,aAAY","ignoreList":[]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Just an aggregation of all exported components into a single module.
|
|
3
|
-
*/export{MetaTags}from"@dr.pogodin/react-helmet";export*from"./selectors";export{BaseButton,default as Button}from"./Button";export{default as Checkbox}from"./Checkbox";export{default as Input}from"./Input";export{default as Link}from"./Link";export{BaseModal,default as Modal}from"./Modal";export{default as NavLink}from"./NavLink";export{default as PageLayout}from"./PageLayout";export{default as Throbber}from"./Throbber";export{default as WithTooltip}from"./WithTooltip";export{default as YouTubeVideo}from"./YouTubeVideo";export{default as TextArea}from"./TextArea";
|
|
3
|
+
*/export{MetaTags}from"@dr.pogodin/react-helmet";export*from"./selectors/index.js";export{BaseButton,default as Button}from"./Button/index.js";export{default as Checkbox}from"./Checkbox/index.js";export{default as Input}from"./Input/index.js";export{default as Link}from"./Link.js";export{BaseModal,default as Modal}from"./Modal/index.js";export{default as NavLink}from"./NavLink.js";export{default as PageLayout}from"./PageLayout/index.js";export{default as Throbber}from"./Throbber/index.js";export{default as WithTooltip}from"./WithTooltip/index.js";export{default as YouTubeVideo}from"./YouTubeVideo/index.js";export{default as TextArea}from"./TextArea/index.js";
|
|
4
4
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":[
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../../../../src/shared/components/index.ts"],"sourcesContent":["/**\n * Just an aggregation of all exported components into a single module.\n */\n\nexport { MetaTags } from '@dr.pogodin/react-helmet';\n\nexport * from 'components/selectors';\n\nexport { BaseButton, default as Button } from 'components/Button';\nexport { default as Checkbox } from 'components/Checkbox';\nexport { default as Input } from 'components/Input';\nexport { default as Link } from 'components/Link';\nexport { BaseModal, default as Modal } from 'components/Modal';\nexport { default as NavLink } from 'components/NavLink';\nexport { default as PageLayout } from 'components/PageLayout';\nexport { default as Throbber } from 'components/Throbber';\nexport { default as WithTooltip } from 'components/WithTooltip';\nexport { default as YouTubeVideo } from 'components/YouTubeVideo';\n\nexport { default as TextArea } from './TextArea';\n"],"mappings":"AAAA;AACA;AACA,GAEA,OAAS,QAAQ,KAAQ,0BAA0B,CAAC,yCAI3C,UAAU,CAAE,OAAO,GAAI,OAAM,gCAC7B,OAAO,GAAI,SAAQ,kCACnB,OAAO,GAAI,MAAK,+BAChB,OAAO,GAAI,KAAI,wBACf,SAAS,CAAE,OAAO,GAAI,MAAK,+BAC3B,OAAO,GAAI,QAAO,2BAClB,OAAO,GAAI,WAAU,oCACrB,OAAO,GAAI,SAAQ,kCACnB,OAAO,GAAI,YAAW,qCACtB,OAAO,GAAI,aAAY,sCAEvB,OAAO,GAAI,SAAQ","ignoreList":[]}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import"core-js
|
|
1
|
+
import _pushInstanceProperty from"core-js-pure/stable/instance/push.js";import{c as _c}from"react/compiler-runtime";import{useImperativeHandle,useRef}from"react";import{BaseModal}from"../../../Modal/index.js";import{optionValueName}from"../../common.js";import S from"./style.scss";import{jsx as _jsx}from"react/jsx-runtime";export function areEqual(a,b){return a?.left===b?.left&&a?.top===b?.top&&a?.width===b?.width;}const Options=t0=>{const $=_c(16);const{containerClass,containerStyle,filter,onCancel,onChange,optionClass,options,ref}=t0;const opsRef=useRef(null);let t1;let t2;if($[0]===Symbol.for("react.memo_cache_sentinel")){t1=()=>({measure:()=>{const e=opsRef.current?.parentElement;if(!e){return}const rect=opsRef.current.getBoundingClientRect();const style=window.getComputedStyle(e);const mBottom=parseFloat(style.marginBottom);const mTop=parseFloat(style.marginTop);rect.height=rect.height+(mBottom+mTop);return rect}});t2=[];$[0]=t1;$[1]=t2}else{t1=$[0];t2=$[1]}useImperativeHandle(ref,t1,t2);let optionNodes;if($[2]!==filter||$[3]!==onChange||$[4]!==optionClass||$[5]!==options){optionNodes=[];for(const option of options){if(!filter||filter(option)){const[iValue,iName]=optionValueName(option);_pushInstanceProperty(optionNodes).call(optionNodes,/*#__PURE__*/_jsx("div",{className:optionClass,onClick:e_0=>{onChange(iValue);e_0.stopPropagation()},onKeyDown:e_1=>{if(e_1.key==="Enter"){onChange(iValue);e_1.stopPropagation()}},role:"button",tabIndex:0,children:iName},iValue))}}$[2]=filter;$[3]=onChange;$[4]=optionClass;$[5]=options;$[6]=optionNodes}else{optionNodes=$[6]}let t3;if($[7]!==containerClass){t3={ad:"",container:containerClass,context:"",hoc:"",overlay:S.overlay};$[7]=containerClass;$[8]=t3}else{t3=$[8]}let t4;if($[9]!==optionNodes){t4=/*#__PURE__*/_jsx("div",{ref:opsRef,children:optionNodes});$[9]=optionNodes;$[10]=t4}else{t4=$[10]}let t5;if($[11]!==containerStyle||$[12]!==onCancel||$[13]!==t3||$[14]!==t4){t5=/*#__PURE__*/_jsx(BaseModal,{cancelOnScrolling:true,dontDisableScrolling:true,onCancel:onCancel,style:containerStyle,theme:t3,children:t4});$[11]=containerStyle;$[12]=onCancel;$[13]=t3;$[14]=t4;$[15]=t5}else{t5=$[15]}return t5};export default Options;
|
|
2
2
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["
|
|
1
|
+
{"version":3,"file":"index.js","names":["optionClass","e","opsRef","containerStyle"],"sources":["../../../../../../../src/shared/components/selectors/CustomDropdown/Options/index.tsx"],"sourcesContent":["import {\n type FunctionComponent,\n type ReactNode,\n type RefObject,\n useImperativeHandle,\n useRef,\n} from 'react';\n\nimport { BaseModal } from 'components/Modal';\n\nimport {\n type OptionT,\n type OptionsT,\n type ValueT,\n optionValueName,\n} from '../../common';\n\nimport S from './style.scss';\n\nexport type ContainerPosT = {\n left: number;\n top: number;\n width: number;\n};\n\nexport function areEqual(a?: ContainerPosT, b?: ContainerPosT): boolean {\n return a?.left === b?.left && a?.top === b?.top && a?.width === b?.width;\n}\n\nexport type RefT = {\n measure: () => DOMRect | undefined;\n};\n\ntype PropsT = {\n containerClass: string;\n containerStyle?: ContainerPosT;\n filter?: (item: OptionT<ReactNode> | ValueT) => boolean;\n onCancel: () => void;\n onChange: (value: ValueT) => void;\n optionClass: string;\n options: Readonly<OptionsT<ReactNode>>;\n ref?: RefObject<RefT | null>;\n};\n\nconst Options: FunctionComponent<PropsT> = ({\n containerClass,\n containerStyle,\n filter,\n onCancel,\n onChange,\n optionClass,\n options,\n ref,\n}) => {\n const opsRef = useRef<HTMLDivElement>(null);\n\n useImperativeHandle(ref, () => ({\n measure: () => {\n const e = opsRef.current?.parentElement;\n if (!e) return undefined;\n\n const rect = opsRef.current!.getBoundingClientRect();\n const style = window.getComputedStyle(e);\n const mBottom = parseFloat(style.marginBottom);\n const mTop = parseFloat(style.marginTop);\n\n rect.height += mBottom + mTop;\n\n return rect;\n },\n }), []);\n\n const optionNodes: ReactNode[] = [];\n for (const option of options) {\n if (!filter || filter(option)) {\n const [iValue, iName] = optionValueName(option);\n optionNodes.push(\n <div\n className={optionClass}\n key={iValue}\n onClick={(e) => {\n onChange(iValue);\n e.stopPropagation();\n }}\n onKeyDown={(e) => {\n if (e.key === 'Enter') {\n onChange(iValue);\n e.stopPropagation();\n }\n }}\n role=\"button\"\n tabIndex={0}\n >\n {iName}\n </div>,\n );\n }\n }\n\n return (\n <BaseModal\n // Closes the dropdown (cancels the selection) on any page scrolling attempt.\n // This is the same native <select> elements do on scrolling, and at least for\n // now we have no reason to deal with complications needed to support open\n // dropdowns during the scrolling (that would need to re-position it in\n // response to the position changes of the root dropdown element).\n cancelOnScrolling\n dontDisableScrolling\n onCancel={onCancel}\n style={containerStyle}\n theme={{\n ad: '',\n container: containerClass,\n context: '',\n hoc: '',\n overlay: S.overlay,\n }}\n >\n <div ref={opsRef}>{optionNodes}</div>\n </BaseModal>\n );\n};\n\nexport default Options;\n"],"mappings":"oHAAA,OAIE,mBAAmB,CACnB,MAAM,KACD,OAAO,CAAC,OAEN,SAAS,sCAMhB,eAAe,uBAGjB,MAAO,EAAC,oBAAqB,2CAQ7B,MAAO,SAAS,SAAQ,CAAC,CAAiB,CAAE,CAAiB,CAAW,CACtE,MAAO,EAAC,EAAE,IAAI,GAAK,CAAC,EAAE,IAAI,EAAI,CAAC,EAAE,GAAG,GAAK,CAAC,EAAE,GAAG,EAAI,CAAC,EAAE,KAAK,GAAK,CAAC,EAAE,KAAK,CAC1E,CAiBA,KAAM,QAAkC,CAAG,oBAAC,wFAS3C,CACC,aAAe,MAAM,CAAiB,IAAI,CAAC,CAAC,iEAEnB,QAAO,SACrB,KACP,QAAU,MAAM,QAAuB,gBACvC,GAAI,CAAC,CAAC,SAEN,WAAa,MAAM,QAAQ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
1
|
+
import{c as _c}from"react/compiler-runtime";import{useEffect,useRef,useState}from"react";import{useTheme}from"@dr.pogodin/react-themes";import{optionValueName}from"../common.js";import Options,{areEqual}from"./Options/index.js";import defaultTheme from"./theme.scss";import{Fragment as _Fragment,jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";const CustomDropdown=t0=>{const $=_c(31);const{filter,label,onChange,options,theme,value}=t0;const custom=useTheme("CustomDropdown",defaultTheme,theme);const[active,setActive]=useState(false);const dropdownRef=useRef(null);const opsRef=useRef(null);const[opsPos,setOpsPos]=useState();const[upward,setUpward]=useState(false);let t1;let t2;if($[0]!==active){t1=()=>{if(!active){return}let id;const cb=()=>{const anchor=dropdownRef.current?.getBoundingClientRect();const opsRect=opsRef.current?.measure();if(anchor&&opsRect){const fitsDown=anchor.bottom+opsRect.height<(window.visualViewport?.height??0);const fitsUp=anchor.top-opsRect.height>0;const up=!fitsDown&&fitsUp;setUpward(up);const pos=up?{left:anchor.left,top:anchor.top-opsRect.height-1,width:anchor.width}:{left:anchor.left,top:anchor.bottom,width:anchor.width};setOpsPos(now=>areEqual(now,pos)?now:pos)}id=requestAnimationFrame(cb);};requestAnimationFrame(cb);return()=>{cancelAnimationFrame(id)}};t2=[active];$[0]=active;$[1]=t1;$[2]=t2}else{t1=$[1];t2=$[2]}useEffect(t1,t2);let t3;if($[3]===Symbol.for("react.memo_cache_sentinel")){t3=e=>{const view=window.visualViewport;const rect=dropdownRef.current.getBoundingClientRect();setActive(true);setOpsPos({left:view?.width??0,top:view?.height??0,width:rect.width});e.stopPropagation()};$[3]=t3}else{t3=$[3]}const openList=t3;let t4;if($[4]===Symbol.for("react.memo_cache_sentinel")){t4=/*#__PURE__*/_jsx(_Fragment,{children:""});$[4]=t4}else{t4=$[4]}let selected=t4;if($[5]!==filter||$[6]!==options||$[7]!==value){for(const option of options){if(!filter||filter(option)){const[iValue,iName]=optionValueName(option);if(iValue===value){selected=iName;break;}}}$[5]=filter;$[6]=options;$[7]=value;$[8]=selected}else{selected=$[8]}let containerClassName=custom.container;if(active){containerClassName=containerClassName+` ${custom.active}`;}let opsContainerClass=custom.select??"";if(upward){containerClassName=containerClassName+` ${custom.upward}`;opsContainerClass=opsContainerClass+` ${custom.upward}`;}let t5;if($[9]!==custom.label||$[10]!==label){t5=label===undefined?null:/*#__PURE__*/_jsx("div",{className:custom.label,children:label});$[9]=custom.label;$[10]=label;$[11]=t5}else{t5=$[11]}let t6;if($[12]===Symbol.for("react.memo_cache_sentinel")){t6=e_0=>{if(e_0.key==="Enter"){openList(e_0)}};$[12]=t6}else{t6=$[12]}let t7;if($[13]!==custom.arrow){t7=/*#__PURE__*/_jsx("div",{className:custom.arrow});$[13]=custom.arrow;$[14]=t7}else{t7=$[14]}let t8;if($[15]!==custom.dropdown||$[16]!==selected||$[17]!==t7){t8=/*#__PURE__*/_jsxs("div",{className:custom.dropdown,onClick:openList,onKeyDown:t6,ref:dropdownRef,role:"listbox",tabIndex:0,children:[selected,t7]});$[15]=custom.dropdown;$[16]=selected;$[17]=t7;$[18]=t8}else{t8=$[18]}let t9;if($[19]!==active||$[20]!==custom.option||$[21]!==onChange||$[22]!==opsContainerClass||$[23]!==opsPos||$[24]!==options){t9=active?/*#__PURE__*/_jsx(Options,{containerClass:opsContainerClass,containerStyle:opsPos,onCancel:()=>{setActive(false)},onChange:newValue=>{setActive(false);if(onChange){onChange(newValue)}},optionClass:custom.option??"",options:options,ref:opsRef}):null;$[19]=active;$[20]=custom.option;$[21]=onChange;$[22]=opsContainerClass;$[23]=opsPos;$[24]=options;$[25]=t9}else{t9=$[25]}let t10;if($[26]!==containerClassName||$[27]!==t5||$[28]!==t8||$[29]!==t9){t10=/*#__PURE__*/_jsxs("div",{className:containerClassName,children:[t5,t8,t9]});$[26]=containerClassName;$[27]=t5;$[28]=t8;$[29]=t9;$[30]=t10}else{t10=$[30]}return t10};export default CustomDropdown;
|
|
2
2
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["useEffect","useRef","useState","useTheme","optionValueName","Options","areEqual","defaultTheme","Fragment","_Fragment","jsx","_jsx","jsxs","_jsxs","CustomDropdown","t0","$","_c","filter","label","onChange","options","theme","value","custom","active","setActive","dropdownRef","opsRef","opsPos","setOpsPos","upward","setUpward","t1","t2","id","cb","anchor","current","getBoundingClientRect","opsRect","measure","fitsDown","bottom","height","window","visualViewport","fitsUp","top","up","pos","left","width","now","requestAnimationFrame","cancelAnimationFrame","t3","Symbol","for","e","view","rect","stopPropagation","openList","t4","children","selected","option","iValue","iName","containerClassName","container","opsContainerClass","select","t5","undefined","className","t6","e_0","key","t7","arrow","t8","dropdown","onKeyDown","role","tabIndex","t9","onCancel","newValue","optionClass","t10"],"sources":["../../../../../../src/shared/components/selectors/CustomDropdown/index.tsx"],"sourcesContent":["import {\n type FunctionComponent,\n type ReactNode,\n useEffect,\n useRef,\n useState,\n} from 'react';\n\nimport { useTheme } from '@dr.pogodin/react-themes';\n\nimport { type PropsT, type ValueT, optionValueName } from '../common';\n\nimport Options, { type ContainerPosT, type RefT, areEqual } from './Options';\n\nimport defaultTheme from './theme.scss';\n\nconst CustomDropdown: FunctionComponent<\n PropsT<ReactNode, (value: ValueT) => void>\n> = ({\n filter,\n label,\n onChange,\n options,\n theme,\n value,\n}) => {\n const custom = useTheme('CustomDropdown', defaultTheme, theme);\n\n const [active, setActive] = useState(false);\n\n const dropdownRef = useRef<HTMLDivElement>(null);\n const opsRef = useRef<RefT>(null);\n\n const [opsPos, setOpsPos] = useState<ContainerPosT>();\n const [upward, setUpward] = useState(false);\n\n useEffect(() => {\n if (!active) return undefined;\n\n let id: number;\n const cb = () => {\n const anchor = dropdownRef.current?.getBoundingClientRect();\n const opsRect = opsRef.current?.measure();\n if (anchor && opsRect) {\n const fitsDown = anchor.bottom + opsRect.height\n < (window.visualViewport?.height ?? 0);\n const fitsUp = anchor.top - opsRect.height > 0;\n\n const up = !fitsDown && fitsUp;\n setUpward(up);\n\n const pos = up ? {\n left: anchor.left,\n top: anchor.top - opsRect.height - 1,\n width: anchor.width,\n } : {\n left: anchor.left,\n top: anchor.bottom,\n width: anchor.width,\n };\n\n setOpsPos((now) => (areEqual(now, pos) ? now : pos));\n }\n id = requestAnimationFrame(cb);\n };\n requestAnimationFrame(cb);\n\n return () => {\n cancelAnimationFrame(id);\n };\n }, [active]);\n\n const openList = (\n e: React.KeyboardEvent<HTMLDivElement> | React.MouseEvent<HTMLDivElement>,\n ) => {\n const view = window.visualViewport;\n const rect = dropdownRef.current!.getBoundingClientRect();\n setActive(true);\n\n // NOTE: This first opens the dropdown off-screen, where it is measured\n // by an effect declared above, and then positioned below, or above\n // the original dropdown element, depending where it fits best\n // (if we first open it downward, it would flick if we immediately\n // move it above, at least with the current position update via local\n // react state, and not imperatively).\n setOpsPos({\n left: view?.width ?? 0,\n top: view?.height ?? 0,\n width: rect.width,\n });\n\n e.stopPropagation();\n };\n\n let selected: React.ReactNode = <>‌</>;\n for (const option of options) {\n if (!filter || filter(option)) {\n const [iValue, iName] = optionValueName(option);\n if (iValue === value) {\n selected = iName;\n break;\n }\n }\n }\n\n let containerClassName = custom.container;\n if (active) containerClassName += ` ${custom.active}`;\n\n let opsContainerClass = custom.select ?? '';\n if (upward) {\n containerClassName += ` ${custom.upward}`;\n opsContainerClass += ` ${custom.upward}`;\n }\n\n return (\n <div className={containerClassName}>\n {label === undefined ? null\n : <div className={custom.label}>{label}</div>}\n <div\n className={custom.dropdown}\n onClick={openList}\n onKeyDown={(e) => {\n if (e.key === 'Enter') openList(e);\n }}\n ref={dropdownRef}\n role=\"listbox\"\n tabIndex={0}\n >\n {selected}\n <div className={custom.arrow} />\n </div>\n {\n active ? (\n <Options\n containerClass={opsContainerClass}\n containerStyle={opsPos}\n onCancel={() => {\n setActive(false);\n }}\n onChange={(newValue) => {\n setActive(false);\n if (onChange) onChange(newValue);\n }}\n optionClass={custom.option ?? ''}\n options={options}\n ref={opsRef}\n />\n ) : null\n }\n </div>\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AtD,CAAA,OAAA0D,EAAA,EAAA1D,CAAA,OAAAkE,EAAA,EAAAlE,CAAA,OAAAuE,EAAA,EAhCZI,GAAA,cAAA9E,KAAA,QAAgByD,SAAkB,CAAlBA,kBAAkB,CAAAL,QAAA,EAC/BS,EAC8C,CAC/CQ,EAYM,CAEJK,EAeQ,EAEP,CAAC,CAAAvE,CAAA,KAAAsD,kBAAAtD,CAAA,MAAA0D,EAAA1D,CAAA,MAAAkE,EAAAlE,CAAA,MAAAuE,EAAAvE,CAAA,MAAA2E,GAAA,MAAAA,GAAA,CAAA3E,CAAA,WAlCN,CAAA2E,GAkCM,CAET,CAED,cAAe,CAAA7E,cAAc","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"index.js","names":["id","selected","e","openList","dropdownRef","opsContainerClass","opsPos","opsRef","containerClassName"],"sources":["../../../../../../src/shared/components/selectors/CustomDropdown/index.tsx"],"sourcesContent":["import {\n type FunctionComponent,\n type ReactNode,\n useEffect,\n useRef,\n useState,\n} from 'react';\n\nimport { useTheme } from '@dr.pogodin/react-themes';\n\nimport { type PropsT, type ValueT, optionValueName } from '../common';\n\nimport Options, { type ContainerPosT, type RefT, areEqual } from './Options';\n\nimport defaultTheme from './theme.scss';\n\nconst CustomDropdown: FunctionComponent<\n PropsT<ReactNode, (value: ValueT) => void>\n> = ({\n filter,\n label,\n onChange,\n options,\n theme,\n value,\n}) => {\n const custom = useTheme('CustomDropdown', defaultTheme, theme);\n\n const [active, setActive] = useState(false);\n\n const dropdownRef = useRef<HTMLDivElement>(null);\n const opsRef = useRef<RefT>(null);\n\n const [opsPos, setOpsPos] = useState<ContainerPosT>();\n const [upward, setUpward] = useState(false);\n\n useEffect(() => {\n if (!active) return undefined;\n\n let id: number;\n const cb = () => {\n const anchor = dropdownRef.current?.getBoundingClientRect();\n const opsRect = opsRef.current?.measure();\n if (anchor && opsRect) {\n const fitsDown = anchor.bottom + opsRect.height\n < (window.visualViewport?.height ?? 0);\n const fitsUp = anchor.top - opsRect.height > 0;\n\n const up = !fitsDown && fitsUp;\n setUpward(up);\n\n const pos = up ? {\n left: anchor.left,\n top: anchor.top - opsRect.height - 1,\n width: anchor.width,\n } : {\n left: anchor.left,\n top: anchor.bottom,\n width: anchor.width,\n };\n\n setOpsPos((now) => (areEqual(now, pos) ? now : pos));\n }\n id = requestAnimationFrame(cb);\n };\n requestAnimationFrame(cb);\n\n return () => {\n cancelAnimationFrame(id);\n };\n }, [active]);\n\n const openList = (\n e: React.KeyboardEvent<HTMLDivElement> | React.MouseEvent<HTMLDivElement>,\n ) => {\n const view = window.visualViewport;\n const rect = dropdownRef.current!.getBoundingClientRect();\n setActive(true);\n\n // NOTE: This first opens the dropdown off-screen, where it is measured\n // by an effect declared above, and then positioned below, or above\n // the original dropdown element, depending where it fits best\n // (if we first open it downward, it would flick if we immediately\n // move it above, at least with the current position update via local\n // react state, and not imperatively).\n setOpsPos({\n left: view?.width ?? 0,\n top: view?.height ?? 0,\n width: rect.width,\n });\n\n e.stopPropagation();\n };\n\n let selected: React.ReactNode = <>‌</>;\n for (const option of options) {\n if (!filter || filter(option)) {\n const [iValue, iName] = optionValueName(option);\n if (iValue === value) {\n selected = iName;\n break;\n }\n }\n }\n\n let containerClassName = custom.container;\n if (active) containerClassName += ` ${custom.active}`;\n\n let opsContainerClass = custom.select ?? '';\n if (upward) {\n containerClassName += ` ${custom.upward}`;\n opsContainerClass += ` ${custom.upward}`;\n }\n\n return (\n <div className={containerClassName}>\n {label === undefined ? null\n : <div className={custom.label}>{label}</div>}\n <div\n className={custom.dropdown}\n onClick={openList}\n onKeyDown={(e) => {\n if (e.key === 'Enter') openList(e);\n }}\n ref={dropdownRef}\n role=\"listbox\"\n tabIndex={0}\n >\n {selected}\n <div className={custom.arrow} />\n </div>\n {\n active ? (\n <Options\n containerClass={opsContainerClass}\n containerStyle={opsPos}\n onCancel={() => {\n setActive(false);\n }}\n onChange={(newValue) => {\n setActive(false);\n if (onChange) onChange(newValue);\n }}\n optionClass={custom.option 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,CAAC,4GAXlC,6BACa,SAAe,CAAf,MAAM,SAAS,CACjBC,OAAQ,CAAR,QAAQ,CACN,SAEV,CAFU,EAEV,CACIC,GAAW,CAAX,WAAW,CACX,IAAS,CAAT,SAAS,CACJ,QAAC,CAAD,CAAC,WAEV,QAAQ,CACT,EAAgC,EAC7B,CAAC,qMAEJ,SAAM,cAAN,KACG,OAAO,EACUC,cAAiB,CAAjB,iBAAiB,CACjBC,cAAM,CAAN,MAAM,CACZ,QAET,CAFS,KACR,SAAS,CAAC,KAAK,CAAC,CACjB,CACS,QAGT,CAHS,WACR,SAAS,CAAC,KAAK,CAAC,CAChB,GAAI,QAAQ,EAAE,QAAQ,CAAC,QAAQ,CAAC,CAAC,CAClC,CACY,WAAmB,CAAnB,MAAM,OAAa,EAAnB,EAAmB,CACvB,OAAO,CAAP,OAAO,CACXC,GAAM,CAAN,MAAM,CAER,CAAC,CAfR,IAeQ,sMAhCZ,8BAAgBC,SAAkB,CAAlB,kBAAkB,WAC/B,EAC8C,CAC/C,EAYM,CAEJ,EAeQ,EAEP,CAAC,oFAlCN,IAkCM,CAET,CAED,cAAe,eAAc","ignoreList":[]}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import"core-js
|
|
2
|
-
import{useTheme}from"@dr.pogodin/react-themes";import{optionValueName}from"../common";import defaultTheme from"./theme.scss";/**
|
|
1
|
+
import _pushInstanceProperty from"core-js-pure/stable/instance/push.js";// Implements dropdown based on the native HTML <select> element.
|
|
2
|
+
import{useTheme}from"@dr.pogodin/react-themes";import{optionValueName}from"../common.js";import defaultTheme from"./theme.scss";/**
|
|
3
3
|
* Implements a themeable dropdown list. Internally it is rendered with help of
|
|
4
4
|
* the standard HTML `<select>` element, thus the styling support is somewhat
|
|
5
5
|
* limited.
|
|
@@ -17,7 +17,7 @@ import{useTheme}from"@dr.pogodin/react-themes";import{optionValueName}from"../co
|
|
|
17
17
|
* @param [props.value] Currently selected value.
|
|
18
18
|
* @param [props....]
|
|
19
19
|
* [Other theming properties](https://www.npmjs.com/package/@dr.pogodin/react-themes#themed-component-properties)
|
|
20
|
-
*/import{jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";const Dropdown=({filter,label,onChange,onClick,options,testId,theme,value})=>{let isValidValue=false;const optionElements=[];const composed=useTheme("Dropdown",defaultTheme,theme);for(const option of options){if(!filter||filter(option)){const[iValue,iName]=optionValueName(option);isValidValue||=iValue===value;optionElements.
|
|
20
|
+
*/import{jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";const Dropdown=({filter,label,onChange,onClick,options,testId,theme,value})=>{let isValidValue=false;const optionElements=[];const composed=useTheme("Dropdown",defaultTheme,theme);for(const option of options){if(!filter||filter(option)){const[iValue,iName]=optionValueName(option);isValidValue||=iValue===value;_pushInstanceProperty(optionElements).call(optionElements,/*#__PURE__*/_jsx("option",{className:composed.option,value:iValue,children:iName},iValue));}}// NOTE: This element represents the current `value` when it does not match
|
|
21
21
|
// any valid option. In Chrome, and some other browsers, we are able to hide
|
|
22
22
|
// it from the opened dropdown; in others, e.g. Safari, the best we can do is
|
|
23
23
|
// to show it as disabled.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":[
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../../../../../../src/shared/components/selectors/NativeDropdown/index.tsx"],"sourcesContent":["// Implements dropdown based on the native HTML <select> element.\n\nimport type { FunctionComponent } from 'react';\n\nimport { useTheme } from '@dr.pogodin/react-themes';\n\nimport { type PropsT, optionValueName } from '../common';\n\nimport defaultTheme from './theme.scss';\n\n/**\n * Implements a themeable dropdown list. Internally it is rendered with help of\n * the standard HTML `<select>` element, thus the styling support is somewhat\n * limited.\n * @param [props] Component properties.\n * @param [props.filter] Options filter function. If provided, only\n * those elements of `options` list will be used by the dropdown, for which this\n * filter returns `true`.\n * @param [props.label] Dropdown label.\n * @param [props.onChange] Selection event handler.\n * @param [props.options=[]] Array of dropdown\n * options. For string elements the option value and name will be the same.\n * It is allowed to mix DropdownOption and string elements in the same option\n * list.\n * @param [props.theme] _Ad hoc_ theme.\n * @param [props.value] Currently selected value.\n * @param [props....]\n * [Other theming properties](https://www.npmjs.com/package/@dr.pogodin/react-themes#themed-component-properties)\n */\nconst Dropdown: FunctionComponent<PropsT<string>> = ({\n filter,\n label,\n onChange,\n onClick,\n options,\n testId,\n theme,\n value,\n}) => {\n let isValidValue = false;\n const optionElements = [];\n\n const composed = useTheme('Dropdown', defaultTheme, theme);\n\n for (const option of options) {\n if (!filter || filter(option)) {\n const [iValue, iName] = optionValueName(option);\n isValidValue ||= iValue === value;\n optionElements.push(\n <option className={composed.option} key={iValue} value={iValue}>\n {iName}\n </option>,\n );\n }\n }\n\n // NOTE: This element represents the current `value` when it does not match\n // any valid option. In Chrome, and some other browsers, we are able to hide\n // it from the opened dropdown; in others, e.g. Safari, the best we can do is\n // to show it as disabled.\n const hiddenOption = isValidValue ? null : (\n <option\n className={composed.hiddenOption}\n disabled\n key=\"__reactUtilsHiddenOption\"\n value={value}\n >\n {value}\n </option>\n );\n\n let selectClassName = composed.select;\n if (!isValidValue) selectClassName += ` ${composed.invalid}`;\n\n return (\n <div className={composed.container}>\n { label === undefined\n ? null : <div className={composed.label}>{label}</div> }\n <div className={composed.dropdown}>\n <select\n className={selectClassName}\n data-testid={process.env.NODE_ENV === 'production' ? undefined : testId}\n onChange={onChange}\n onClick={onClick}\n value={value}\n >\n {hiddenOption}\n {optionElements}\n </select>\n <div className={composed.arrow} />\n </div>\n </div>\n );\n};\n\nexport default Dropdown;\n"],"mappings":"wEAAA;AAIA,OAAS,QAAQ,KAAQ,0BAA0B,CAAC,OAE9B,eAAe,oBAErC,MAAO,aAAY,oBAEnB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,GAlBA,yDAmBA,KAAM,SAA2C,CAAG,CAAC,CACnD,MAAM,CACN,KAAK,CACL,QAAQ,CACR,OAAO,C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