@dr.pogodin/react-utils 1.48.13 → 1.48.14

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.
Files changed (109) hide show
  1. package/bin/build.js +4 -7
  2. package/build/development/server/index.js +1 -1
  3. package/build/development/server/index.js.map +1 -1
  4. package/build/development/server/renderer.js +7 -5
  5. package/build/development/server/renderer.js.map +1 -1
  6. package/build/development/server/server.js +1 -1
  7. package/build/development/server/server.js.map +1 -1
  8. package/build/development/server/utils/errors.js +1 -0
  9. package/build/development/server/utils/errors.js.map +1 -1
  10. package/build/development/shared/components/Modal/index.js +1 -1
  11. package/build/development/shared/components/Modal/index.js.map +1 -1
  12. package/build/development/shared/components/YouTubeVideo/index.js.map +1 -1
  13. package/build/development/shared/utils/jest/E2eSsrEnv.js +5 -5
  14. package/build/development/shared/utils/jest/E2eSsrEnv.js.map +1 -1
  15. package/build/development/shared/utils/jest/index.js +1 -0
  16. package/build/development/shared/utils/jest/index.js.map +1 -1
  17. package/build/development/shared/utils/webpack.js +1 -1
  18. package/build/development/shared/utils/webpack.js.map +1 -1
  19. package/build/production/client/getInj.js +3 -3
  20. package/build/production/client/getInj.js.map +1 -1
  21. package/build/production/client/index.js +1 -1
  22. package/build/production/client/index.js.map +1 -1
  23. package/build/production/client/init.js +3 -3
  24. package/build/production/client/init.js.map +1 -1
  25. package/build/production/index.js +1 -1
  26. package/build/production/index.js.map +1 -1
  27. package/build/production/server/Cache.js +3 -3
  28. package/build/production/server/Cache.js.map +1 -1
  29. package/build/production/server/index.js +2 -2
  30. package/build/production/server/index.js.map +1 -1
  31. package/build/production/server/renderer.js +20 -20
  32. package/build/production/server/renderer.js.map +1 -1
  33. package/build/production/server/server.js +7 -7
  34. package/build/production/server/server.js.map +1 -1
  35. package/build/production/server/utils/errors.js +5 -5
  36. package/build/production/server/utils/errors.js.map +1 -1
  37. package/build/production/shared/components/Button/index.js +3 -3
  38. package/build/production/shared/components/Button/index.js.map +1 -1
  39. package/build/production/shared/components/Checkbox/index.js +1 -1
  40. package/build/production/shared/components/Checkbox/index.js.map +1 -1
  41. package/build/production/shared/components/GenericLink/index.js +3 -3
  42. package/build/production/shared/components/GenericLink/index.js.map +1 -1
  43. package/build/production/shared/components/Input/index.js +2 -2
  44. package/build/production/shared/components/Input/index.js.map +1 -1
  45. package/build/production/shared/components/Modal/index.js +7 -7
  46. package/build/production/shared/components/Modal/index.js.map +1 -1
  47. package/build/production/shared/components/PageLayout/index.js +1 -1
  48. package/build/production/shared/components/PageLayout/index.js.map +1 -1
  49. package/build/production/shared/components/TextArea/index.js +3 -3
  50. package/build/production/shared/components/TextArea/index.js.map +1 -1
  51. package/build/production/shared/components/Throbber/index.js +1 -1
  52. package/build/production/shared/components/Throbber/index.js.map +1 -1
  53. package/build/production/shared/components/WithTooltip/Tooltip.js +6 -6
  54. package/build/production/shared/components/WithTooltip/Tooltip.js.map +1 -1
  55. package/build/production/shared/components/WithTooltip/index.js +4 -4
  56. package/build/production/shared/components/WithTooltip/index.js.map +1 -1
  57. package/build/production/shared/components/YouTubeVideo/index.js +1 -1
  58. package/build/production/shared/components/YouTubeVideo/index.js.map +1 -1
  59. package/build/production/shared/components/selectors/CustomDropdown/Options/index.js +2 -2
  60. package/build/production/shared/components/selectors/CustomDropdown/Options/index.js.map +1 -1
  61. package/build/production/shared/components/selectors/CustomDropdown/index.js +2 -2
  62. package/build/production/shared/components/selectors/CustomDropdown/index.js.map +1 -1
  63. package/build/production/shared/components/selectors/NativeDropdown/index.js +2 -2
  64. package/build/production/shared/components/selectors/NativeDropdown/index.js.map +1 -1
  65. package/build/production/shared/components/selectors/Switch/index.js +1 -1
  66. package/build/production/shared/components/selectors/Switch/index.js.map +1 -1
  67. package/build/production/shared/components/selectors/common.js +1 -1
  68. package/build/production/shared/components/selectors/common.js.map +1 -1
  69. package/build/production/shared/utils/config.js +1 -1
  70. package/build/production/shared/utils/config.js.map +1 -1
  71. package/build/production/shared/utils/isomorphy/buildInfo.js +2 -2
  72. package/build/production/shared/utils/isomorphy/buildInfo.js.map +1 -1
  73. package/build/production/shared/utils/isomorphy/index.js +4 -4
  74. package/build/production/shared/utils/isomorphy/index.js.map +1 -1
  75. package/build/production/shared/utils/jest/E2eSsrEnv.js +13 -13
  76. package/build/production/shared/utils/jest/E2eSsrEnv.js.map +1 -1
  77. package/build/production/shared/utils/jest/global.js +1 -1
  78. package/build/production/shared/utils/jest/global.js.map +1 -1
  79. package/build/production/shared/utils/jest/index.js +11 -11
  80. package/build/production/shared/utils/jest/index.js.map +1 -1
  81. package/build/production/shared/utils/splitComponent.js +12 -12
  82. package/build/production/shared/utils/splitComponent.js.map +1 -1
  83. package/build/production/shared/utils/time.js +2 -2
  84. package/build/production/shared/utils/time.js.map +1 -1
  85. package/build/production/shared/utils/webpack.js +4 -4
  86. package/build/production/shared/utils/webpack.js.map +1 -1
  87. package/build/types-code/server/index.d.ts +1 -1
  88. package/build/types-code/server/renderer.d.ts +1 -1
  89. package/build/web/server/index.js +1 -1
  90. package/build/web/server/index.js.map +1 -1
  91. package/build/web/server/renderer.js +7 -5
  92. package/build/web/server/renderer.js.map +1 -1
  93. package/build/web/server/server.js +1 -1
  94. package/build/web/server/server.js.map +1 -1
  95. package/build/web/server/utils/errors.js +1 -0
  96. package/build/web/server/utils/errors.js.map +1 -1
  97. package/build/web/shared/components/Modal/index.js +1 -1
  98. package/build/web/shared/components/Modal/index.js.map +1 -1
  99. package/build/web/shared/components/YouTubeVideo/index.js.map +1 -1
  100. package/build/web/shared/utils/jest/E2eSsrEnv.js +5 -5
  101. package/build/web/shared/utils/jest/E2eSsrEnv.js.map +1 -1
  102. package/build/web/shared/utils/jest/index.js +1 -0
  103. package/build/web/shared/utils/jest/index.js.map +1 -1
  104. package/build/web/shared/utils/webpack.js +1 -1
  105. package/build/web/shared/utils/webpack.js.map +1 -1
  106. package/config/webpack/app-base.js +2 -2
  107. package/config/webpack/app-development.js +1 -1
  108. package/package.json +11 -11
  109. package/tsconfig.json +1 -1
@@ -1,5 +1,5 @@
1
1
  // The <Button> component implements a standard button / button-like link.
2
- import{useTheme}from"@dr.pogodin/react-themes";import Link from"../Link.js";const defaultTheme={"context":"_0S7CYa","ad":"YFXz0-","hoc":"BElFuo","button":"hXiBOw","active":"biX-UA","disabled":"_-6CH9q"};import{jsx as _jsx}from"react/jsx-runtime";export const BaseButton=({active,children,disabled,enforceA,keepScrollPosition,onClick,onKeyDown:onKeyDownProp,onKeyUp,onMouseDown,onMouseUp,onPointerDown,onPointerUp,openNewTab,replace,testId,theme,to})=>{let className=theme.button;if(active&&theme.active)className+=` ${theme.active}`;if(disabled){if(theme.disabled)className+=` ${theme.disabled}`;return/*#__PURE__*/_jsx("div",{className:className,"data-testid":process.env.NODE_ENV==="production"?undefined:testId,children:children})}let onKeyDown=onKeyDownProp;if(!onKeyDown&&onClick){onKeyDown=e=>{if(e.key==="Enter")onClick(e)}}if(to){return/*#__PURE__*/_jsx(Link,{className:className,"data-testid":process.env.NODE_ENV==="production"?undefined:testId,enforceA:enforceA// TODO: This was exposed as a hotifx... however, I guess we better want
2
+ import{useTheme}from"@dr.pogodin/react-themes";import Link from"../Link.js";const defaultTheme={"context":"_0S7CYa","ad":"YFXz0-","hoc":"BElFuo","button":"hXiBOw","active":"biX-UA","disabled":"_-6CH9q"};import{jsx as _jsx}from"react/jsx-runtime";export const BaseButton=({active,children,disabled,enforceA,keepScrollPosition,onClick,onKeyDown:onKeyDownProp,onKeyUp,onMouseDown,onMouseUp,onPointerDown,onPointerUp,openNewTab,replace,testId,theme,to})=>{let className=theme.button;if(active&&theme.active)className+=` ${theme.active}`;if(disabled){if(theme.disabled)className+=` ${theme.disabled}`;return/*#__PURE__*/_jsx("div",{className:className,"data-testid":process.env.NODE_ENV==="production"?undefined:testId,children:children});}let onKeyDown=onKeyDownProp;if(!onKeyDown&&onClick){onKeyDown=e=>{if(e.key==="Enter")onClick(e);};}if(to){return/*#__PURE__*/_jsx(Link,{className:className,"data-testid":process.env.NODE_ENV==="production"?undefined:testId,enforceA:enforceA// TODO: This was exposed as a hotifx... however, I guess we better want
3
3
  // to check if the `to` URL contains an anchor (#), and if it does we should
4
4
  // automatically opt to keep the position here; and enforce <a> (as
5
5
  // react-router link does not seem to respect the hash tag either,
@@ -9,6 +9,6 @@ import{useTheme}from"@dr.pogodin/react-themes";import Link from"../Link.js";cons
9
9
  // the inner implementation details. We should look into supporting it:
10
10
  // https://github.com/birdofpreyru/react-utils/issues/444
11
11
  // onKeyDown={onKeyDown}
12
- ,onKeyUp:onKeyUp,onMouseDown:onMouseDown,onMouseUp:onMouseUp,onPointerDown:onPointerDown,onPointerUp:onPointerUp,openNewTab:openNewTab,replace:replace,to:to,children:children})}return/*#__PURE__*/_jsx("div",{className:className,"data-testid":process.env.NODE_ENV==="production"?undefined:testId,onClick:onClick,onKeyDown:onKeyDown,onKeyUp:onKeyUp,onMouseDown:onMouseDown,onMouseUp:onMouseUp,onPointerDown:onPointerDown,onPointerUp:onPointerUp,role:"button",tabIndex:0,children:children})};const Button=({theme,...rest})=>{const composed=useTheme("Button",defaultTheme,theme);// eslint-disable-next-line react/jsx-props-no-spreading
13
- return/*#__PURE__*/_jsx(BaseButton,{...rest,theme:composed})};export default Button;
12
+ ,onKeyUp:onKeyUp,onMouseDown:onMouseDown,onMouseUp:onMouseUp,onPointerDown:onPointerDown,onPointerUp:onPointerUp,openNewTab:openNewTab,replace:replace,to:to,children:children});}return/*#__PURE__*/_jsx("div",{className:className,"data-testid":process.env.NODE_ENV==="production"?undefined:testId,onClick:onClick,onKeyDown:onKeyDown,onKeyUp:onKeyUp,onMouseDown:onMouseDown,onMouseUp:onMouseUp,onPointerDown:onPointerDown,onPointerUp:onPointerUp,role:"button",tabIndex:0,children:children});};const Button=({theme,...rest})=>{const composed=useTheme("Button",defaultTheme,theme);// eslint-disable-next-line react/jsx-props-no-spreading
13
+ return/*#__PURE__*/_jsx(BaseButton,{...rest,theme:composed});};export default Button;
14
14
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":["useTheme","Link","defaultTheme","jsx","_jsx","BaseButton","active","children","disabled","enforceA","keepScrollPosition","onClick","onKeyDown","onKeyDownProp","onKeyUp","onMouseDown","onMouseUp","onPointerDown","onPointerUp","openNewTab","replace","testId","theme","to","className","button","process","env","NODE_ENV","undefined","e","key","role","tabIndex","Button","rest","composed"],"sources":["../../../../../src/shared/components/Button/index.tsx"],"sourcesContent":["// The <Button> component implements a standard button / button-like link.\n\nimport type {\n FunctionComponent,\n KeyboardEventHandler,\n MouseEventHandler,\n PointerEventHandler,\n ReactNode,\n} from 'react';\n\nimport { type Theme, useTheme } from '@dr.pogodin/react-themes';\n\nimport Link from 'components/Link';\n\nimport defaultTheme from './style.scss';\n\ntype ThemeT = Theme<'active' | 'button' | 'disabled'>;\n\ntype PropsT = {\n active?: boolean;\n children?: ReactNode;\n disabled?: boolean;\n enforceA?: boolean;\n keepScrollPosition?: boolean;\n onClick?: KeyboardEventHandler & MouseEventHandler;\n onKeyDown?: KeyboardEventHandler;\n onKeyUp?: KeyboardEventHandler;\n onMouseDown?: MouseEventHandler;\n onMouseUp?: MouseEventHandler;\n onPointerDown?: PointerEventHandler;\n onPointerUp?: PointerEventHandler;\n openNewTab?: boolean;\n replace?: boolean;\n testId?: string;\n theme: ThemeT;\n\n // TODO: It needs a more precise typing of the object option.\n to?: object | string;\n};\n\nexport const BaseButton: FunctionComponent<PropsT> = ({\n active,\n children,\n disabled,\n enforceA,\n keepScrollPosition,\n onClick,\n onKeyDown: onKeyDownProp,\n onKeyUp,\n onMouseDown,\n onMouseUp,\n onPointerDown,\n onPointerUp,\n openNewTab,\n replace,\n testId,\n theme,\n to,\n}) => {\n let className = theme.button;\n if (active && theme.active) className += ` ${theme.active}`;\n if (disabled) {\n if (theme.disabled) className += ` ${theme.disabled}`;\n return (\n <div\n className={className}\n data-testid={process.env.NODE_ENV === 'production' ? undefined : testId}\n >\n {children}\n </div>\n );\n }\n\n let onKeyDown = onKeyDownProp;\n if (!onKeyDown && onClick) {\n onKeyDown = (e) => {\n if (e.key === 'Enter') onClick(e);\n };\n }\n\n if (to) {\n return (\n <Link\n className={className}\n data-testid={process.env.NODE_ENV === 'production' ? undefined : testId}\n enforceA={enforceA}\n\n // TODO: This was exposed as a hotifx... however, I guess we better want\n // to check if the `to` URL contains an anchor (#), and if it does we should\n // automatically opt to keep the position here; and enforce <a> (as\n // react-router link does not seem to respect the hash tag either,\n // at least not without some additional settings).\n keepScrollPosition={keepScrollPosition}\n\n onClick={onClick}\n\n // TODO: For now, the `onKeyDown` handler is not passed to the <Link>,\n // as <Link> component does not call it anyway, presumably due to\n // the inner implementation details. We should look into supporting it:\n // https://github.com/birdofpreyru/react-utils/issues/444\n // onKeyDown={onKeyDown}\n\n onKeyUp={onKeyUp}\n onMouseDown={onMouseDown}\n onMouseUp={onMouseUp}\n onPointerDown={onPointerDown}\n onPointerUp={onPointerUp}\n openNewTab={openNewTab}\n replace={replace}\n to={to}\n >\n {children}\n </Link>\n );\n }\n\n return (\n <div\n className={className}\n data-testid={process.env.NODE_ENV === 'production' ? undefined : testId}\n onClick={onClick}\n onKeyDown={onKeyDown}\n onKeyUp={onKeyUp}\n onMouseDown={onMouseDown}\n onMouseUp={onMouseUp}\n onPointerDown={onPointerDown}\n onPointerUp={onPointerUp}\n role=\"button\"\n tabIndex={0}\n >\n {children}\n </div>\n );\n};\n\nconst Button: FunctionComponent<\n Omit<PropsT, 'theme'> & { theme?: ThemeT }\n> = ({ theme, ...rest }) => {\n const composed = useTheme('Button', defaultTheme, theme);\n\n // eslint-disable-next-line react/jsx-props-no-spreading\n return <BaseButton {...rest} theme={composed} />;\n};\n\nexport default Button;\n"],"mappings":"AAAA;AAUA,OAAqBA,QAAQ,KAAQ,0BAA0B,OAExD,CAAAC,IAAI,wBAAAC,YAAA,6GAE6B,OAAAC,GAAA,IAAAC,IAAA,yBA0BxC,MAAO,MAAM,CAAAC,UAAqC,CAAGA,CAAC,CACpDC,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AAEA,SAAU,CACrBC,aAAa,CAAEA,aAAc,CAC7BC,WAAW,CAAEA,WAAY,CACzBC,UAAU,CAAEA,UAAW,CACvBC,OAAO,CAAEA,OAAQ,CACjBG,EAAE,CAAEA,EAAG,CAAAhB,QAAA,CAENA,QAAQ,CACL,CAEV,CAEA,mBACEH,IAAA,QACEoB,SAAS,CAAEA,SAAU,CACrB,cAAaE,OAAO,CAACC,GAAG,CAACC,QAAQ,GAAK,YAAY,CAAGC,SAAS,CAAGR,MAAO,CACxEV,OAAO,CAAEA,OAAQ,CACjBC,SAAS,CAAEA,SAAU,CACrBE,OAAO,CAAEA,OAAQ,CACjBC,WAAW,CAAEA,WAAY,CACzBC,SAAS,CAAEA,SAAU,CACrBC,aAAa,CAAEA,aAAc,CAC7BC,WAAW,CAAEA,WAAY,CACzBc,IAAI,CAAC,QAAQ,CACbC,QAAQ,CAAE,CAAE,CAAA1B,QAAA,CAEXA,QAAQ,CACN,CAET,CAAC,CAED,KAAM,CAAA2B,MAEL,CAAGA,CAAC,CAAEZ,KAAK,CAAE,GAAGa,IAAK,CAAC,GAAK,CAC1B,KAAM,CAAAC,QAAQ,CAAGpC,QAAQ,CAAC,QAAQ,CAAEE,YAAY,CAAEoB,KAAK,CAAC,CAExD;AACA,mBAAOlB,IAAA,CAACC,UAAU,KAAK8B,IAAI,CAAEb,KAAK,CAAEc,QAAS,CAAE,CACjD,CAAC,CAED,cAAe,CAAAF,MAAM","ignoreList":[]}
1
+ {"version":3,"file":"index.js","names":["useTheme","Link","defaultTheme","jsx","_jsx","BaseButton","active","children","disabled","enforceA","keepScrollPosition","onClick","onKeyDown","onKeyDownProp","onKeyUp","onMouseDown","onMouseUp","onPointerDown","onPointerUp","openNewTab","replace","testId","theme","to","className","button","process","env","NODE_ENV","undefined","e","key","role","tabIndex","Button","rest","composed"],"sources":["../../../../../src/shared/components/Button/index.tsx"],"sourcesContent":["// The <Button> component implements a standard button / button-like link.\n\nimport type {\n FunctionComponent,\n KeyboardEventHandler,\n MouseEventHandler,\n PointerEventHandler,\n ReactNode,\n} from 'react';\n\nimport { type Theme, useTheme } from '@dr.pogodin/react-themes';\n\nimport Link from 'components/Link';\n\nimport defaultTheme from './style.scss';\n\ntype ThemeT = Theme<'active' | 'button' | 'disabled'>;\n\ntype PropsT = {\n active?: boolean;\n children?: ReactNode;\n disabled?: boolean;\n enforceA?: boolean;\n keepScrollPosition?: boolean;\n onClick?: KeyboardEventHandler & MouseEventHandler;\n onKeyDown?: KeyboardEventHandler;\n onKeyUp?: KeyboardEventHandler;\n onMouseDown?: MouseEventHandler;\n onMouseUp?: MouseEventHandler;\n onPointerDown?: PointerEventHandler;\n onPointerUp?: PointerEventHandler;\n openNewTab?: boolean;\n replace?: boolean;\n testId?: string;\n theme: ThemeT;\n\n // TODO: It needs a more precise typing of the object option.\n to?: object | string;\n};\n\nexport const BaseButton: FunctionComponent<PropsT> = ({\n active,\n children,\n disabled,\n enforceA,\n keepScrollPosition,\n onClick,\n onKeyDown: onKeyDownProp,\n onKeyUp,\n onMouseDown,\n onMouseUp,\n onPointerDown,\n onPointerUp,\n openNewTab,\n replace,\n testId,\n theme,\n to,\n}) => {\n let className = theme.button;\n if (active && theme.active) className += ` ${theme.active}`;\n if (disabled) {\n if (theme.disabled) className += ` ${theme.disabled}`;\n return (\n <div\n className={className}\n data-testid={process.env.NODE_ENV === 'production' ? undefined : testId}\n >\n {children}\n </div>\n );\n }\n\n let onKeyDown = onKeyDownProp;\n if (!onKeyDown && onClick) {\n onKeyDown = (e) => {\n if (e.key === 'Enter') onClick(e);\n };\n }\n\n if (to) {\n return (\n <Link\n className={className}\n data-testid={process.env.NODE_ENV === 'production' ? undefined : testId}\n enforceA={enforceA}\n\n // TODO: This was exposed as a hotifx... however, I guess we better want\n // to check if the `to` URL contains an anchor (#), and if it does we should\n // automatically opt to keep the position here; and enforce <a> (as\n // react-router link does not seem to respect the hash tag either,\n // at least not without some additional settings).\n keepScrollPosition={keepScrollPosition}\n\n onClick={onClick}\n\n // TODO: For now, the `onKeyDown` handler is not passed to the <Link>,\n // as <Link> component does not call it anyway, presumably due to\n // the inner implementation details. We should look into supporting it:\n // https://github.com/birdofpreyru/react-utils/issues/444\n // onKeyDown={onKeyDown}\n\n onKeyUp={onKeyUp}\n onMouseDown={onMouseDown}\n onMouseUp={onMouseUp}\n onPointerDown={onPointerDown}\n onPointerUp={onPointerUp}\n openNewTab={openNewTab}\n replace={replace}\n to={to}\n >\n {children}\n </Link>\n );\n }\n\n return (\n <div\n className={className}\n data-testid={process.env.NODE_ENV === 'production' ? undefined : testId}\n onClick={onClick}\n onKeyDown={onKeyDown}\n onKeyUp={onKeyUp}\n onMouseDown={onMouseDown}\n onMouseUp={onMouseUp}\n onPointerDown={onPointerDown}\n onPointerUp={onPointerUp}\n role=\"button\"\n tabIndex={0}\n >\n {children}\n </div>\n );\n};\n\nconst Button: FunctionComponent<\n Omit<PropsT, 'theme'> & { theme?: ThemeT }\n> = ({ theme, ...rest }) => {\n const composed = useTheme('Button', defaultTheme, theme);\n\n // eslint-disable-next-line react/jsx-props-no-spreading\n return <BaseButton {...rest} theme={composed} />;\n};\n\nexport default Button;\n"],"mappings":"AAAA;AAUA,OAAqBA,QAAQ,KAAQ,0BAA0B,OAExD,CAAAC,IAAI,wBAAAC,YAAA,6GAE6B,OAAAC,GAAA,IAAAC,IAAA,yBA0BxC,MAAO,MAAM,CAAAC,UAAqC,CAAGA,CAAC,CACpDC,MAAM,CACNC,QAAQ,CACRC,QAAQ,CACRC,QAAQ,CACRC,kBAAkB,CAClBC,OAAO,CACPC,SAAS,CAAEC,aAAa,CACxBC,OAAO,CACPC,WAAW,CACXC,SAAS,CACTC,aAAa,CACbC,WAAW,CACXC,UAAU,CACVC,OAAO,CACPC,MAAM,CACNC,KAAK,CACLC,EACF,CAAC,GAAK,CACJ,GAAI,CAAAC,SAAS,CAAGF,KAAK,CAACG,MAAM,CAC5B,GAAInB,MAAM,EAAIgB,KAAK,CAAChB,MAAM,CAAEkB,S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CACxEV,OAAO,CAAEA,OAAQ,CACjBC,SAAS,CAAEA,SAAU,CACrBE,OAAO,CAAEA,OAAQ,CACjBC,WAAW,CAAEA,WAAY,CACzBC,SAAS,CAAEA,SAAU,CACrBC,aAAa,CAAEA,aAAc,CAC7BC,WAAW,CAAEA,WAAY,CACzBc,IAAI,CAAC,QAAQ,CACbC,QAAQ,CAAE,CAAE,CAAA1B,QAAA,CAEXA,QAAQ,CACN,CAAC,CAEV,CAAC,CAED,KAAM,CAAA2B,MAEL,CAAGA,CAAC,CAAEZ,KAAK,CAAE,GAAGa,IAAK,CAAC,GAAK,CAC1B,KAAM,CAAAC,QAAQ,CAAGpC,QAAQ,CAAC,QAAQ,CAAEE,YAAY,CAAEoB,KAAK,CAAC,CAExD;AACA,mBAAOlB,IAAA,CAACC,UAAU,KAAK8B,IAAI,CAAEb,KAAK,CAAEc,QAAS,CAAE,CAAC,CAClD,CAAC,CAED,cAAe,CAAAF,MAAM","ignoreList":[]}
@@ -1,2 +1,2 @@
1
- import{useTheme}from"@dr.pogodin/react-themes";const defaultTheme={"context":"_08mmmo","ad":"Hc06MV","hoc":"toOtOd","checkbox":"v4DmWM","indeterminate":"ckSC8W","container":"g7wee9","label":"XQ57WS","disabled":"baVvQA"};import{jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";const Checkbox=({checked,disabled,label,onChange,testId,theme})=>{const composed=useTheme("Checkbox",defaultTheme,theme);let containerClassName=composed.container;if(disabled)containerClassName+=` ${composed.disabled}`;let checkboxClassName=composed.checkbox;if(checked==="indeterminate")checkboxClassName+=` ${composed.indeterminate}`;return/*#__PURE__*/_jsxs("div",{className:containerClassName,children:[label===undefined?null:/*#__PURE__*/_jsx("div",{className:composed.label,children:label}),/*#__PURE__*/_jsx("input",{checked:checked===undefined?undefined:checked===true,className:checkboxClassName,"data-testid":process.env.NODE_ENV==="production"?undefined:testId,disabled:disabled,onChange:onChange,onClick:e=>{e.stopPropagation()},type:"checkbox"})]})};export default Checkbox;
1
+ import{useTheme}from"@dr.pogodin/react-themes";const defaultTheme={"context":"_08mmmo","ad":"Hc06MV","hoc":"toOtOd","checkbox":"v4DmWM","indeterminate":"ckSC8W","container":"g7wee9","label":"XQ57WS","disabled":"baVvQA"};import{jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";const Checkbox=({checked,disabled,label,onChange,testId,theme})=>{const composed=useTheme("Checkbox",defaultTheme,theme);let containerClassName=composed.container;if(disabled)containerClassName+=` ${composed.disabled}`;let checkboxClassName=composed.checkbox;if(checked==="indeterminate")checkboxClassName+=` ${composed.indeterminate}`;return/*#__PURE__*/_jsxs("div",{className:containerClassName,children:[label===undefined?null:/*#__PURE__*/_jsx("div",{className:composed.label,children:label}),/*#__PURE__*/_jsx("input",{checked:checked===undefined?undefined:checked===true,className:checkboxClassName,"data-testid":process.env.NODE_ENV==="production"?undefined:testId,disabled:disabled,onChange:onChange,onClick:e=>{e.stopPropagation();},type:"checkbox"})]});};export default Checkbox;
2
2
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":["useTheme","defaultTheme","jsx","_jsx","jsxs","_jsxs","Checkbox","checked","disabled","label","onChange","testId","theme","composed","containerClassName","container","checkboxClassName","checkbox","indeterminate","className","children","undefined","process","env","NODE_ENV","onClick","e","stopPropagation","type"],"sources":["../../../../../src/shared/components/Checkbox/index.tsx"],"sourcesContent":["import type { ReactNode } from 'react';\n\nimport { type Theme, useTheme } from '@dr.pogodin/react-themes';\n\nimport defaultTheme from './theme.scss';\n\ntype PropT<ValueT> = {\n checked?: ValueT;\n disabled?: boolean;\n label?: React.ReactNode;\n onChange?: React.ChangeEventHandler<HTMLInputElement>;\n testId?: string;\n theme?: Theme<\n | 'checkbox'\n | 'container'\n | 'disabled'\n | 'indeterminate'\n | 'label'\n >;\n};\n\nconst Checkbox = <ValueT extends 'indeterminate' | boolean = boolean>({\n checked,\n disabled,\n label,\n onChange,\n testId,\n theme,\n}: PropT<ValueT>): ReactNode => {\n const composed = useTheme('Checkbox', defaultTheme, theme);\n\n let containerClassName = composed.container;\n if (disabled) containerClassName += ` ${composed.disabled}`;\n\n let checkboxClassName = composed.checkbox;\n if (checked === 'indeterminate') checkboxClassName += ` ${composed.indeterminate}`;\n\n return (\n <div className={containerClassName}>\n { label === undefined\n ? null : <div className={composed.label}>{label}</div> }\n <input\n checked={checked === undefined ? undefined : checked === true}\n className={checkboxClassName}\n data-testid={process.env.NODE_ENV === 'production' ? undefined : testId}\n disabled={disabled}\n onChange={onChange}\n onClick={(e) => {\n e.stopPropagation();\n }}\n type=\"checkbox\"\n />\n </div>\n );\n};\n\nexport default Checkbox;\n"],"mappings":"AAEA,OAAqBA,QAAQ,KAAQ,0BAA0B,OAAAC,YAAA,2JAEvB,OAAAC,GAAA,IAAAC,IAAA,CAAAC,IAAA,IAAAC,KAAA,yBAiBxC,KAAM,CAAAC,QAAQ,CAAGA,CAAqD,CACpEC,OAAO,CACPC,QAAQ,CACRC,KAAK,CACLC,QAAQ,CACRC,MAAM,CACNC,KACa,CAAC,GAAgB,CAC9B,KAAM,CAAAC,QAAQ,CAAGb,QAAQ,CAAC,UAAU,CAAEC,YAAY,CAAEW,KAAK,CAAC,CAE1D,GAAI,CAAAE,kBAAkB,CAAGD,QAAQ,CAACE,SAAS,CAC3C,GAAIP,QAAQ,CAAEM,kBAAkB,EAAI,IAAID,QAAQ,CAACL,QAAQ,EAAE,CAE3D,GAAI,CAAAQ,iBAAiB,CAAGH,QAAQ,CAACI,QAAQ,CACzC,GAAIV,OAAO,GAAK,eAAe,CAAES,iBAAiB,EAAI,IAAIH,QAAQ,CAACK,aAAa,EAAE,CAElF,mBACEb,KAAA,QAAKc,SAAS,CAAEL,kBAAmB,CAAAM,QAAA,EAC/BX,KAAK,GAAKY,SAAS,CACjB,IAAI,cAAGlB,IAAA,QAAKgB,SAAS,CAAEN,QAAQ,CAACJ,KAAM,CAAAW,QAAA,CAAEX,KAAK,CAAM,CAAC,cACxDN,IAAA,UACEI,OAAO,CAAEA,OAAO,GAAKc,SAAS,CAAGA,SAAS,CAAGd,OAAO,GAAK,IAAK,CAC9DY,SAAS,CAAEH,iBAAkB,CAC7B,cAAaM,OAAO,CAACC,GAAG,CAACC,QAAQ,GAAK,YAAY,CAAGH,SAAS,CAAGV,MAAO,CACxEH,QAAQ,CAAEA,QAAS,CACnBE,QAAQ,CAAEA,QAAS,CACnBe,OAAO,CAAGC,CAAC,EAAK,CACdA,CAAC,CAACC,eAAe,CAAC,CACpB,CAAE,CACFC,IAAI,CAAC,UAAU,CAChB,CAAC,EACC,CAET,CAAC,CAED,cAAe,CAAAtB,QAAQ","ignoreList":[]}
1
+ {"version":3,"file":"index.js","names":["useTheme","defaultTheme","jsx","_jsx","jsxs","_jsxs","Checkbox","checked","disabled","label","onChange","testId","theme","composed","containerClassName","container","checkboxClassName","checkbox","indeterminate","className","children","undefined","process","env","NODE_ENV","onClick","e","stopPropagation","type"],"sources":["../../../../../src/shared/components/Checkbox/index.tsx"],"sourcesContent":["import type { ReactNode } from 'react';\n\nimport { type Theme, useTheme } from '@dr.pogodin/react-themes';\n\nimport defaultTheme from './theme.scss';\n\ntype PropT<ValueT> = {\n checked?: ValueT;\n disabled?: boolean;\n label?: React.ReactNode;\n onChange?: React.ChangeEventHandler<HTMLInputElement>;\n testId?: string;\n theme?: Theme<\n | 'checkbox'\n | 'container'\n | 'disabled'\n | 'indeterminate'\n | 'label'\n >;\n};\n\nconst Checkbox = <ValueT extends 'indeterminate' | boolean = boolean>({\n checked,\n disabled,\n label,\n onChange,\n testId,\n theme,\n}: PropT<ValueT>): ReactNode => {\n const composed = useTheme('Checkbox', defaultTheme, theme);\n\n let containerClassName = composed.container;\n if (disabled) containerClassName += ` ${composed.disabled}`;\n\n let checkboxClassName = composed.checkbox;\n if (checked === 'indeterminate') checkboxClassName += ` ${composed.indeterminate}`;\n\n return (\n <div className={containerClassName}>\n { label === undefined\n ? null : <div className={composed.label}>{label}</div> }\n <input\n checked={checked === undefined ? undefined : checked === true}\n className={checkboxClassName}\n data-testid={process.env.NODE_ENV === 'production' ? undefined : testId}\n disabled={disabled}\n onChange={onChange}\n onClick={(e) => {\n e.stopPropagation();\n }}\n type=\"checkbox\"\n />\n </div>\n );\n};\n\nexport default Checkbox;\n"],"mappings":"AAEA,OAAqBA,QAAQ,KAAQ,0BAA0B,OAAAC,YAAA,2JAEvB,OAAAC,GAAA,IAAAC,IAAA,CAAAC,IAAA,IAAAC,KAAA,yBAiBxC,KAAM,CAAAC,QAAQ,CAAGA,CAAqD,CACpEC,OAAO,CACPC,QAAQ,CACRC,KAAK,CACLC,QAAQ,CACRC,MAAM,CACNC,KACa,CAAC,GAAgB,CAC9B,KAAM,CAAAC,QAAQ,CAAGb,QAAQ,CAAC,UAAU,CAAEC,YAAY,CAAEW,KAAK,CAAC,CAE1D,GAAI,CAAAE,kBAAkB,CAAGD,QAAQ,CAACE,SAAS,CAC3C,GAAIP,QAAQ,CAAEM,kBAAkB,EAAI,IAAID,QAAQ,CAACL,QAAQ,EAAE,CAE3D,GAAI,CAAAQ,iBAAiB,CAAGH,QAAQ,CAACI,QAAQ,CACzC,GAAIV,OAAO,GAAK,eAAe,CAAES,iBAAiB,EAAI,IAAIH,QAAQ,CAACK,aAAa,EAAE,CAElF,mBACEb,KAAA,QAAKc,SAAS,CAAEL,kBAAmB,CAAAM,QAAA,EAC/BX,KAAK,GAAKY,SAAS,CACjB,IAAI,cAAGlB,IAAA,QAAKgB,SAAS,CAAEN,QAAQ,CAACJ,KAAM,CAAAW,QAAA,CAAEX,KAAK,CAAM,CAAC,cACxDN,IAAA,UACEI,OAAO,CAAEA,OAAO,GAAKc,SAAS,CAAGA,SAAS,CAAGd,OAAO,GAAK,IAAK,CAC9DY,SAAS,CAAEH,iBAAkB,CAC7B,cAAaM,OAAO,CAACC,GAAG,CAACC,QAAQ,GAAK,YAAY,CAAGH,SAAS,CAAGV,MAAO,CACxEH,QAAQ,CAAEA,QAAS,CACnBE,QAAQ,CAAEA,QAAS,CACnBe,OAAO,CAAGC,CAAC,EAAK,CACdA,CAAC,CAACC,eAAe,CAAC,CAAC,CACrB,CAAE,CACFC,IAAI,CAAC,UAAU,CAChB,CAAC,EACC,CAAC,CAEV,CAAC,CAED,cAAe,CAAAtB,QAAQ","ignoreList":[]}
@@ -45,10 +45,10 @@ import{jsx as _jsx}from"react/jsx-runtime";/**
45
45
  // tag, thus for disabled option we rather should render a plain text
46
46
  // styled as a link.
47
47
  // disabled={disabled}
48
- ,href:to,onClick:disabled?e=>{e.preventDefault()}:onClick,onMouseDown:disabled?e=>{e.preventDefault()}:onMouseDown,rel:"noopener noreferrer",styleName:"link",target:openNewTab?"_blank":"",children:children})}const L=routerLinkType;return/*#__PURE__*/_jsx(L,{className:className,discover:"none"// disabled
48
+ ,href:to,onClick:disabled?e=>{e.preventDefault();}:onClick,onMouseDown:disabled?e=>{e.preventDefault();}:onMouseDown,rel:"noopener noreferrer",styleName:"link",target:openNewTab?"_blank":"",children:children});}const L=routerLinkType;return/*#__PURE__*/_jsx(L,{className:className,discover:"none"// disabled
49
49
  ,onClick:e=>{// Executes the user-provided event handler, if any.
50
50
  if(onClick)onClick(e);// By default, clicking the link scrolls the page to beginning.
51
- if(!keepScrollPosition)window.scroll(0,0)},onMouseDown:onMouseDown,replace:replace,to:to// TODO: Refactor it later.
51
+ if(!keepScrollPosition)window.scroll(0,0);},onMouseDown:onMouseDown,replace:replace,to:to// TODO: Refactor it later.
52
52
  // eslint-disable-next-line react/jsx-props-no-spreading
53
- ,...rest,children:children})};export default GenericLink;
53
+ ,...rest,children:children});};export default GenericLink;
54
54
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":["jsx","_jsx","GenericLink","children","className","disabled","enforceA","keepScrollPosition","onClick","onMouseDown","openNewTab","replace","routerLinkType","to","rest","match","href","e","preventDefault","rel","styleName","target","L","discover","window","scroll"],"sources":["../../../../../src/shared/components/GenericLink/index.tsx"],"sourcesContent":["import type { ReactNode } from 'react';\n\nimport type {\n Link,\n LinkProps,\n NavLink,\n NavLinkProps,\n} from 'react-router';\n\nimport './style.scss';\n\ntype LinkT = typeof Link;\ntype NavLinkT = typeof NavLink;\n\ntype ToT = Parameters<typeof Link>[0]['to'];\n\nexport type PropsT = {\n children?: ReactNode;\n className?: string;\n disabled?: boolean;\n enforceA?: boolean;\n keepScrollPosition?: boolean;\n onClick?: React.MouseEventHandler<HTMLAnchorElement>;\n onMouseDown?: React.MouseEventHandler<HTMLAnchorElement>;\n openNewTab?: boolean;\n replace?: boolean;\n routerLinkType: LinkT | NavLinkT;\n to: ToT;\n};\n\n/**\n * The `<Link>` component, and almost identical `<NavLink>` component, are\n * auxiliary wrappers around\n * [React Router](https://github.com/ReactTraining/react-router)'s\n * `<Link>` and `<NavLink>` components; they help to handle external and\n * internal links in uniform manner.\n *\n * @param [props] Component properties.\n * @param [props.className] CSS classes to apply to the link.\n * @param [props.disabled] Disables the link.\n * @param [props.enforceA] `true` enforces rendering of the link as\n * a simple `<a>` element.\n * @param [props.keepScrollPosition] If `true`, and the link is\n * rendered as a React Router's component, it won't reset the viewport scrolling\n * position to the origin when clicked.\n * @param [props.onClick] Event handler to trigger upon click.\n * @param [props.onMouseDown] Event handler to trigger on MouseDown\n * event.\n * @param [props.openNewTab] If `true` the link opens in a new tab.\n * @param [props.replace] When `true`, the link will replace current\n * entry in the history stack instead of adding a new one.\n * @param [props.to] Link URL.\n * @param [props.activeClassName] **`<NavLink>`** only: CSS class(es)\n * to apply to rendered link when it is active.\n * @param [props.activeStyle] **`<NavLink>`** only: CSS styles\n * to apply to the rendered link when it is active.\n * @param [props.exact] **`<NavLink>`** only: if `true`, the active\n * class/style will only be applied if the location is matched exactly.\n * @param [props.isActive] **`<NavLink>`** only: Add extra\n * logic for determining whether the link is active. This should be used if you\n * want to do more than verify that the link’s pathname matches the current URL\n * pathname.\n * @param [props.location] **`<NavLink>`** only: `isActive` compares\n * current history location (usually the current browser URL). To compare to\n * a different location, a custom `location` can be passed.\n * @param [props.strict] **`<NavLink>`** only: . When `true`, trailing\n * slash on a location’s pathname will be taken into consideration when\n * determining if the location matches the current URL. See the `<Route strict>`\n * documentation for more information.\n */\nconst GenericLink = ({\n children,\n className,\n disabled,\n enforceA,\n keepScrollPosition,\n onClick,\n onMouseDown,\n openNewTab,\n replace,\n routerLinkType,\n to,\n ...rest\n}: (LinkProps | NavLinkProps) & PropsT): ReactNode => {\n /* Renders Link as <a> element if:\n * - It is opted explicitely by `enforceA` prop;\n * - It should be opened in a new tab;\n * - It is an absolte URL (starts with http:// or https://);\n * - It is anchor link (starts with #). */\n if (disabled || enforceA || openNewTab\n || (to as string).match(/^(#|(https?|mailto):)/)) {\n return (\n <a\n className={className}\n // TODO: This requires a fix: disabled is not really an attribute of <a>\n // tag, thus for disabled option we rather should render a plain text\n // styled as a link.\n // disabled={disabled}\n href={to as string}\n onClick={disabled ? (e) => {\n e.preventDefault();\n } : onClick}\n onMouseDown={disabled ? (e) => {\n e.preventDefault();\n } : onMouseDown}\n rel=\"noopener noreferrer\"\n styleName=\"link\"\n target={openNewTab ? '_blank' : ''}\n >\n {children}\n </a>\n );\n }\n\n const L = routerLinkType;\n\n return (\n <L\n className={className}\n discover=\"none\"\n // disabled\n onClick={(e: React.MouseEvent<HTMLAnchorElement>) => {\n // Executes the user-provided event handler, if any.\n if (onClick) onClick(e);\n\n // By default, clicking the link scrolls the page to beginning.\n if (!keepScrollPosition) window.scroll(0, 0);\n }}\n onMouseDown={onMouseDown}\n replace={replace}\n to={to}\n // TODO: Refactor it later.\n // eslint-disable-next-line react/jsx-props-no-spreading\n {...rest}\n >\n {children}\n </L>\n );\n};\n\nexport default GenericLink;\n"],"mappings":"AASsB,OAAAA,GAAA,IAAAC,IAAA,yBAqBtB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA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AAA,IACIC,IAAI,CAAAX,QAAA,CAEPA,QAAQ,CACR,CAEP,CAAC,CAED,cAAe,CAAAD,WAAW","ignoreList":[]}
1
+ {"version":3,"file":"index.js","names":["jsx","_jsx","GenericLink","children","className","disabled","enforceA","keepScrollPosition","onClick","onMouseDown","openNewTab","replace","routerLinkType","to","rest","match","href","e","preventDefault","rel","styleName","target","L","discover","window","scroll"],"sources":["../../../../../src/shared/components/GenericLink/index.tsx"],"sourcesContent":["import type { ReactNode } from 'react';\n\nimport type {\n Link,\n LinkProps,\n NavLink,\n NavLinkProps,\n} from 'react-router';\n\nimport './style.scss';\n\ntype LinkT = typeof Link;\ntype NavLinkT = typeof NavLink;\n\ntype ToT = Parameters<typeof Link>[0]['to'];\n\nexport type PropsT = {\n children?: ReactNode;\n className?: string;\n disabled?: boolean;\n enforceA?: boolean;\n keepScrollPosition?: boolean;\n onClick?: React.MouseEventHandler<HTMLAnchorElement>;\n onMouseDown?: React.MouseEventHandler<HTMLAnchorElement>;\n openNewTab?: boolean;\n replace?: boolean;\n routerLinkType: LinkT | NavLinkT;\n to: ToT;\n};\n\n/**\n * The `<Link>` component, and almost identical `<NavLink>` component, are\n * auxiliary wrappers around\n * [React Router](https://github.com/ReactTraining/react-router)'s\n * `<Link>` and `<NavLink>` components; they help to handle external and\n * internal links in uniform manner.\n *\n * @param [props] Component properties.\n * @param [props.className] CSS classes to apply to the link.\n * @param [props.disabled] Disables the link.\n * @param [props.enforceA] `true` enforces rendering of the link as\n * a simple `<a>` element.\n * @param [props.keepScrollPosition] If `true`, and the link is\n * rendered as a React Router's component, it won't reset the viewport scrolling\n * position to the origin when clicked.\n * @param [props.onClick] Event handler to trigger upon click.\n * @param [props.onMouseDown] Event handler to trigger on MouseDown\n * event.\n * @param [props.openNewTab] If `true` the link opens in a new tab.\n * @param [props.replace] When `true`, the link will replace current\n * entry in the history stack instead of adding a new one.\n * @param [props.to] Link URL.\n * @param [props.activeClassName] **`<NavLink>`** only: CSS class(es)\n * to apply to rendered link when it is active.\n * @param [props.activeStyle] **`<NavLink>`** only: CSS styles\n * to apply to the rendered link when it is active.\n * @param [props.exact] **`<NavLink>`** only: if `true`, the active\n * class/style will only be applied if the location is matched exactly.\n * @param [props.isActive] **`<NavLink>`** only: Add extra\n * logic for determining whether the link is active. This should be used if you\n * want to do more than verify that the link’s pathname matches the current URL\n * pathname.\n * @param [props.location] **`<NavLink>`** only: `isActive` compares\n * current history location (usually the current browser URL). To compare to\n * a different location, a custom `location` can be passed.\n * @param [props.strict] **`<NavLink>`** only: . When `true`, trailing\n * slash on a location’s pathname will be taken into consideration when\n * determining if the location matches the current URL. See the `<Route strict>`\n * documentation for more information.\n */\nconst GenericLink = ({\n children,\n className,\n disabled,\n enforceA,\n keepScrollPosition,\n onClick,\n onMouseDown,\n openNewTab,\n replace,\n routerLinkType,\n to,\n ...rest\n}: (LinkProps | NavLinkProps) & PropsT): ReactNode => {\n /* Renders Link as <a> element if:\n * - It is opted explicitely by `enforceA` prop;\n * - It should be opened in a new tab;\n * - It is an absolte URL (starts with http:// or https://);\n * - It is anchor link (starts with #). */\n if (disabled || enforceA || openNewTab\n || (to as string).match(/^(#|(https?|mailto):)/)) {\n return (\n <a\n className={className}\n // TODO: This requires a fix: disabled is not really an attribute of <a>\n // tag, thus for disabled option we rather should render a plain text\n // styled as a link.\n // disabled={disabled}\n href={to as string}\n onClick={disabled ? (e) => {\n e.preventDefault();\n } : onClick}\n onMouseDown={disabled ? (e) => {\n e.preventDefault();\n } : onMouseDown}\n rel=\"noopener noreferrer\"\n styleName=\"link\"\n target={openNewTab ? '_blank' : ''}\n >\n {children}\n </a>\n );\n }\n\n const L = routerLinkType;\n\n return (\n <L\n className={className}\n discover=\"none\"\n // disabled\n onClick={(e: React.MouseEvent<HTMLAnchorElement>) => {\n // Executes the user-provided event handler, if any.\n if (onClick) onClick(e);\n\n // By default, clicking the link scrolls the page to beginning.\n if (!keepScrollPosition) window.scroll(0, 0);\n }}\n onMouseDown={onMouseDown}\n replace={replace}\n to={to}\n // TODO: Refactor it later.\n // eslint-disable-next-line react/jsx-props-no-spreading\n {...rest}\n >\n {children}\n </L>\n );\n};\n\nexport default GenericLink;\n"],"mappings":"AASsB,OAAAA,GAAA,IAAAC,IAAA,yBAqBtB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,GACA,KAAM,CAAAC,WAAW,CAAGA,CAAC,CACnBC,QAAQ,CACRC,SAAS,CACTC,QAAQ,CACRC,QAAQ,CACRC,kBAAkB,CAClBC,OAAO,CACPC,WAAW,CACXC,UAAU,CACVC,OAAO,CACPC,cAAc,CACdC,EAAE,CACF,GAAGC,IACgC,CAAC,GAAgB,CACpD;AACF;AACA;AACA;AACA,4CACE,GAAIT,QAAQ,EAAIC,QAAQ,EAAII,UAAU,EAChCG,EAAE,CAAYE,KAAK,CAAC,uBAAuB,CAAC,CAAE,CAClD,mBACEd,IAAA,MACEG,SAAS,CAAEA,SACX;AACA;AACA;AACA;AAAA,CACAY,IAAI,CAAEH,EAAa,CACnBL,OAAO,CAAEH,QAAQ,CAAIY,CAAC,EAAK,CACzBA,CAAC,CAACC,cAAc,CAAC,CAAC,CACpB,CAAC,CAAGV,OAAQ,CACZC,WAAW,CAAEJ,QAAQ,CAAIY,CAAC,EAAK,CAC7BA,CAAC,CAACC,cAAc,CAAC,CAAC,CACpB,CAAC,CAAGT,WAAY,CAChBU,GAAG,CAAC,qBAAqB,CACzBC,SAAS,CAAC,MAAM,CAChBC,MAAM,CAAEX,UAAU,CAAG,QAAQ,CAAG,EAAG,CAAAP,QAAA,CAElCA,QAAQ,CACR,CAAC,CAER,CAEA,KAAM,CAAAmB,CAAC,CAAGV,cAAc,CAExB,mBACEX,IAAA,CAACqB,CAAC,EACAlB,SAAS,CAAEA,SAAU,CACrBmB,QAAQ,CAAC,MACT;AAAA,CACAf,OAAO,CAAGS,CAAsC,EAAK,CACnD;AACA,GAAIT,OAAO,CAAEA,OAAO,CAACS,CAAC,CAAC,CAEvB;AACA,GAAI,CAACV,kBAAkB,CAAEiB,MAAM,CAACC,MAAM,CAAC,CAAC,CAAE,CAAC,CAAC,CAC9C,CAAE,CACFhB,WAAW,CAAEA,WAAY,CACzBE,OAAO,CAAEA,OAAQ,CACjBE,EAAE,CAAEA,EACJ;AACA;AAAA,IACIC,IAAI,CAAAX,QAAA,CAEPA,QAAQ,CACR,CAAC,CAER,CAAC,CAED,cAAe,CAAAD,WAAW","ignoreList":[]}
@@ -12,7 +12,7 @@ const[focused,setFocused]=useState(false);const localRef=useRef(null);let contai
12
12
  if(focused/* && theme.focused */)containerClassName+=` ${composed.focused}`;if(!rest.value&&composed.empty)containerClassName+=` ${composed.empty}`;if(error)containerClassName+=` ${composed.error}`;return/*#__PURE__*/_jsxs("div",{className:containerClassName,onFocus:()=>{// TODO: It does not really work if a callback-style `ref` is passed in,
13
13
  // we need a more complex logic to cover that case, but for now this serves
14
14
  // the case we need it for.
15
- if(typeof ref==="object")ref?.current?.focus();else localRef.current?.focus()},children:[label===undefined?null:/*#__PURE__*/_jsx("div",{className:composed.label,children:label}),/*#__PURE__*/_jsx("input",{className:composed.input,"data-testid":process.env.NODE_ENV==="production"?undefined:testId,ref:ref??localRef// TODO: Avoid the spreading later.
15
+ if(typeof ref==="object")ref?.current?.focus();else localRef.current?.focus();},children:[label===undefined?null:/*#__PURE__*/_jsx("div",{className:composed.label,children:label}),/*#__PURE__*/_jsx("input",{className:composed.input,"data-testid":process.env.NODE_ENV==="production"?undefined:testId,ref:ref??localRef// TODO: Avoid the spreading later.
16
16
  // eslint-disable-next-line react/jsx-props-no-spreading
17
- ,...rest,onBlur:composed.focused?e=>{setFocused(false);rest.onBlur?.(e)}:rest.onBlur,onFocus:composed.focused?e=>{setFocused(true);rest.onFocus?.(e)}:rest.onFocus}),error&&error!==true?/*#__PURE__*/_jsx("div",{className:composed.errorMessage,children:error}):null,children?/*#__PURE__*/_jsx("div",{className:composed.children,children:children}):null]})};export default Input;
17
+ ,...rest,onBlur:composed.focused?e=>{setFocused(false);rest.onBlur?.(e);}:rest.onBlur,onFocus:composed.focused?e=>{setFocused(true);rest.onFocus?.(e);}:rest.onFocus}),error&&error!==true?/*#__PURE__*/_jsx("div",{className:composed.errorMessage,children:error}):null,children?/*#__PURE__*/_jsx("div",{className:composed.children,children:children}):null]});};export default Input;
18
18
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":["useRef","useState","useTheme","defaultTheme","jsx","_jsx","jsxs","_jsxs","Input","children","composeAdhocTheme","error","label","ref","testId","theme","rest","composed","focused","setFocused","localRef","containerClassName","container","value","empty","className","onFocus","current","focus","undefined","input","process","env","NODE_ENV","onBlur","e","errorMessage"],"sources":["../../../../../src/shared/components/Input/index.tsx"],"sourcesContent":["import {\n type FunctionComponent,\n type ReactNode,\n type Ref,\n useRef,\n useState,\n} from 'react';\n\nimport { type COMPOSE, type Theme, useTheme } from '@dr.pogodin/react-themes';\n\nimport defaultTheme from './theme.scss';\n\ntype ThemeKeyT = 'children' | 'container' | 'empty' | 'error' | 'errorMessage'\n | 'focused' | 'input' | 'label';\n\ntype PropsT = React.InputHTMLAttributes<HTMLInputElement> & {\n children?: ReactNode;\n composeAdhocTheme?: COMPOSE;\n error?: ReactNode;\n label?: React.ReactNode;\n ref?: Ref<HTMLInputElement>;\n testId?: string;\n theme?: Theme<ThemeKeyT>;\n};\n\n/**\n * Themeable input field, based on the standard HTML `<input>` element.\n * @param [props.label] Input label.\n * @param [props.theme] _Ad hoc_ theme.\n * @param [props...] [Other theming properties](https://www.npmjs.com/package/@dr.pogodin/react-themes#themed-component-properties)\n * @param [props...] Any other properties are passed to the underlying\n * `<input>` element.\n */\nconst Input: FunctionComponent<PropsT> = ({\n children,\n composeAdhocTheme,\n error,\n label,\n ref,\n testId,\n theme,\n ...rest\n}) => {\n const composed = useTheme('Input', defaultTheme, theme, {\n composeAdhocTheme,\n });\n\n // NOTE: As of now, it is only updated when \"theme.focused\" is defined,\n // as otherwise its value is not used.\n const [focused, setFocused] = useState(false);\n\n const localRef = useRef<HTMLInputElement>(null);\n\n let containerClassName = composed.container;\n\n // NOTE: As of now, \"focused\" can be true only when \"theme.focused\"\n // is provided.\n if (focused /* && theme.focused */) containerClassName += ` ${composed.focused}`;\n\n if (!rest.value && composed.empty) containerClassName += ` ${composed.empty}`;\n\n if (error) containerClassName += ` ${composed.error}`;\n\n return (\n <div\n className={containerClassName}\n onFocus={() => {\n // TODO: It does not really work if a callback-style `ref` is passed in,\n // we need a more complex logic to cover that case, but for now this serves\n // the case we need it for.\n if (typeof ref === 'object') ref?.current?.focus();\n else localRef.current?.focus();\n }}\n >\n {label === undefined\n ? null : <div className={composed.label}>{label}</div>}\n <input\n className={composed.input}\n data-testid={process.env.NODE_ENV === 'production' ? undefined : testId}\n ref={ref ?? localRef}\n\n // TODO: Avoid the spreading later.\n // eslint-disable-next-line react/jsx-props-no-spreading\n {...rest}\n\n onBlur={composed.focused ? (e) => {\n setFocused(false);\n rest.onBlur?.(e);\n } : rest.onBlur}\n onFocus={composed.focused ? (e) => {\n setFocused(true);\n rest.onFocus?.(e);\n } : rest.onFocus}\n />\n {error && error !== true\n ? <div className={composed.errorMessage}>{error}</div>\n : null}\n {children ? <div className={composed.children}>{children}</div> : null}\n </div>\n );\n};\n\nexport default Input;\n"],"mappings":"AAAA,OAIEA,MAAM,CACNC,QAAQ,KACH,OAAO,CAEd,OAAmCC,QAAQ,KAAQ,0BAA0B,OAAAC,YAAA,wKAErC,OAAAC,GAAA,IAAAC,IAAA,CAAAC,IAAA,IAAAC,KAAA,yBAexC;AACA;AACA;AACA;AACA;AACA;AACA;AACA,GACA,KAAM,CAAAC,KAAgC,CAAGA,CAAC,CACxCC,QAAQ,CACRC,iBAAiB,CACjBC,KAAK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CACxED,GAAG,CAAEA,GAAG,EAAIO,QAEZ;AACA;AAAA,IACIJ,IAAI,CAERkB,MAAM,CAAEjB,QAAQ,CAACC,OAAO,CAAIiB,CAAC,EAAK,CAChChB,UAAU,CAAC,KAAK,CAAC,CACjBH,IAAI,CAACkB,MAAM,GAAGC,CAAC,CACjB,CAAC,CAAGnB,IAAI,CAACkB,MAAO,CAChBR,OAAO,CAAET,QAAQ,CAACC,OAAO,CAAIiB,CAAC,EAAK,CACjChB,UAAU,CAAC,IAAI,CAAC,CAChBH,IAAI,CAACU,OAAO,GAAGS,CAAC,CAClB,CAAC,CAAGnB,IAAI,CAACU,OAAQ,CAClB,CAAC,CACDf,KAAK,EAAIA,KAAK,GAAK,IAAI,cACpBN,IAAA,QAAKoB,SAAS,CAAER,QAAQ,CAACmB,YAAa,CAAA3B,QAAA,CAAEE,KAAK,CAAM,CAAC,CACpD,IAAI,CACPF,QAAQ,cAAGJ,IAAA,QAAKoB,SAAS,CAAER,QAAQ,CAACR,QAAS,CAAAA,QAAA,CAAEA,QAAQ,CAAM,CAAC,CAAG,IAAI,EACnE,CAET,CAAC,CAED,cAAe,CAAAD,KAAK","ignoreList":[]}
1
+ {"version":3,"file":"index.js","names":["useRef","useState","useTheme","defaultTheme","jsx","_jsx","jsxs","_jsxs","Input","children","composeAdhocTheme","error","label","ref","testId","theme","rest","composed","focused","setFocused","localRef","containerClassName","container","value","empty","className","onFocus","current","focus","undefined","input","process","env","NODE_ENV","onBlur","e","errorMessage"],"sources":["../../../../../src/shared/components/Input/index.tsx"],"sourcesContent":["import {\n type FunctionComponent,\n type ReactNode,\n type Ref,\n useRef,\n useState,\n} from 'react';\n\nimport { type COMPOSE, type Theme, useTheme } from '@dr.pogodin/react-themes';\n\nimport defaultTheme from './theme.scss';\n\ntype ThemeKeyT = 'children' | 'container' | 'empty' | 'error' | 'errorMessage'\n | 'focused' | 'input' | 'label';\n\ntype PropsT = React.InputHTMLAttributes<HTMLInputElement> & {\n children?: ReactNode;\n composeAdhocTheme?: COMPOSE;\n error?: ReactNode;\n label?: React.ReactNode;\n ref?: Ref<HTMLInputElement>;\n testId?: string;\n theme?: Theme<ThemeKeyT>;\n};\n\n/**\n * Themeable input field, based on the standard HTML `<input>` element.\n * @param [props.label] Input label.\n * @param [props.theme] _Ad hoc_ theme.\n * @param [props...] [Other theming properties](https://www.npmjs.com/package/@dr.pogodin/react-themes#themed-component-properties)\n * @param [props...] Any other properties are passed to the underlying\n * `<input>` element.\n */\nconst Input: FunctionComponent<PropsT> = ({\n children,\n composeAdhocTheme,\n error,\n label,\n ref,\n testId,\n theme,\n ...rest\n}) => {\n const composed = useTheme('Input', defaultTheme, theme, {\n composeAdhocTheme,\n });\n\n // NOTE: As of now, it is only updated when \"theme.focused\" is defined,\n // as otherwise its value is not used.\n const [focused, setFocused] = useState(false);\n\n const localRef = useRef<HTMLInputElement>(null);\n\n let containerClassName = composed.container;\n\n // NOTE: As of now, \"focused\" can be true only when \"theme.focused\"\n // is provided.\n if (focused /* && theme.focused */) containerClassName += ` ${composed.focused}`;\n\n if (!rest.value && composed.empty) containerClassName += ` ${composed.empty}`;\n\n if (error) containerClassName += ` ${composed.error}`;\n\n return (\n <div\n className={containerClassName}\n onFocus={() => {\n // TODO: It does not really work if a callback-style `ref` is passed in,\n // we need a more complex logic to cover that case, but for now this serves\n // the case we need it for.\n if (typeof ref === 'object') ref?.current?.focus();\n else localRef.current?.focus();\n }}\n >\n {label === undefined\n ? null : <div className={composed.label}>{label}</div>}\n <input\n className={composed.input}\n data-testid={process.env.NODE_ENV === 'production' ? undefined : testId}\n ref={ref ?? localRef}\n\n // TODO: Avoid the spreading later.\n // eslint-disable-next-line react/jsx-props-no-spreading\n {...rest}\n\n onBlur={composed.focused ? (e) => {\n setFocused(false);\n rest.onBlur?.(e);\n } : rest.onBlur}\n onFocus={composed.focused ? (e) => {\n setFocused(true);\n rest.onFocus?.(e);\n } : rest.onFocus}\n />\n {error && error !== true\n ? <div className={composed.errorMessage}>{error}</div>\n : null}\n {children ? <div className={composed.children}>{children}</div> : null}\n </div>\n );\n};\n\nexport default Input;\n"],"mappings":"AAAA,OAIEA,MAAM,CACNC,QAAQ,KACH,OAAO,CAEd,OAAmCC,QAAQ,KAAQ,0BAA0B,OAAAC,YAAA,wKAErC,OAAAC,GAAA,IAAAC,IAAA,CAAAC,IAAA,IAAAC,KAAA,yBAexC;AACA;AACA;AACA;AACA;AACA;AACA;AACA,GACA,KAAM,CAAAC,KAAgC,CAAGA,CAAC,CACxCC,QAAQ,CACRC,iBAAiB,CACjBC,KAAK,CACLC,KAAK,CACLC,GAAG,CACHC,MAAM,CACNC,KAAK,CACL,GAAGC,IACL,CAAC,GAAK,CACJ,KAAM,CAAAC,QAAQ,CAAGf,QAAQ,CAAC,OAAO,CAAEC,YAAY,CAAEY,KAAK,CAAE,CACtDL,iBACF,CAAC,CAAC,CAEF;AACA;AACA,KAAM,CAACQ,OAAO,CAAEC,UAAU,CAAC,CAAGlB,QAAQ,CAAC,KAAK,CAAC,CAE7C,KAAM,CAAAmB,QAAQ,CAAGpB,MAAM,CAAmB,IAAI,CAAC,CAE/C,GAAI,CAAAqB,kBAAkB,CAAGJ,QAAQ,CAACK,SAAS,CAE3C;AACA;AACA,GAAIJ,OAAQ,uBAAwBG,kBAAkB,EAAI,IAAIJ,QAAQ,CAACC,OAAO,EAAE,CAEhF,GAAI,CAACF,IAAI,CAACO,KAAK,EAAIN,QAAQ,CAACO,KAAK,CAAEH,kBAAkB,EAAI,IAAIJ,QAAQ,CAACO,KAAK,EAAE,CAE7E,GAAIb,KAAK,CAAEU,kBAAkB,EAAI,IAAIJ,QAAQ,CAACN,KAAK,EAAE,CAErD,mBACEJ,KAAA,QACEkB,SAAS,CAAEJ,kBAAmB,CAC9BK,OAAO,CAAEA,CAAA,GAAM,CACb;AACA;AACA;AACA,GAAI,MAAO,CAAAb,GAAG,GAAK,QAAQ,CAAEA,GAAG,EAAEc,OAAO,EAAEC,KAAK,CAAC,CAAC,CAAC,IAC9C,CAAAR,QAAQ,CAACO,OAAO,EAAEC,KAAK,CAAC,CAAC,CAChC,CAAE,CAAAnB,QAAA,EAEDG,KAAK,GAAKiB,SAAS,CAChB,IAAI,cAAGxB,IAAA,QAAKoB,SAAS,CAAER,QAAQ,CAACL,KAAM,CAAAH,QAAA,CAAEG,KAAK,CAAM,CAAC,cACxDP,IAAA,UACEoB,SAAS,CAAER,QAAQ,CAACa,KAAM,CAC1B,cAAaC,OAAO,CAACC,GAAG,CAACC,QAAQ,GAAK,YAAY,CAAGJ,SAAS,CAAGf,MAAO,CACxED,GAAG,CAAEA,GAAG,EAAIO,QAEZ;AACA;AAAA,IACIJ,IAAI,CAERkB,MAAM,CAAEjB,QAAQ,CAACC,OAAO,CAAIiB,CAAC,EAAK,CAChChB,UAAU,CAAC,KAAK,CAAC,CACjBH,IAAI,CAACkB,MAAM,GAAGC,CAAC,CAAC,CAClB,CAAC,CAAGnB,IAAI,CAACkB,MAAO,CAChBR,OAAO,CAAET,QAAQ,CAACC,OAAO,CAAIiB,CAAC,EAAK,CACjChB,UAAU,CAAC,IAAI,CAAC,CAChBH,IAAI,CAACU,OAAO,GAAGS,CAAC,CAAC,CACnB,CAAC,CAAGnB,IAAI,CAACU,OAAQ,CAClB,CAAC,CACDf,KAAK,EAAIA,KAAK,GAAK,IAAI,cACpBN,IAAA,QAAKoB,SAAS,CAAER,QAAQ,CAACmB,YAAa,CAAA3B,QAAA,CAAEE,KAAK,CAAM,CAAC,CACpD,IAAI,CACPF,QAAQ,cAAGJ,IAAA,QAAKoB,SAAS,CAAER,QAAQ,CAACR,QAAS,CAAAA,QAAA,CAAEA,QAAQ,CAAM,CAAC,CAAG,IAAI,EACnE,CAAC,CAEV,CAAC,CAED,cAAe,CAAAD,KAAK","ignoreList":[]}
@@ -1,4 +1,4 @@
1
- import{useEffect,useMemo,useRef}from"react";import{useTheme}from"@dr.pogodin/react-themes";import{createPortal}from"react-dom";const defaultTheme={"context":"sCYXfW","ad":"e0BH-f","hoc":"vqUuSP","overlay":"uAH4as","container":"zqpc6q"};const S={"scrollingDisabledByModal":"yfvOIZ"};import{jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";/**
1
+ import{useEffect,useMemo,useRef}from"react";import{createPortal}from"react-dom";import{useTheme}from"@dr.pogodin/react-themes";const defaultTheme={"context":"sCYXfW","ad":"e0BH-f","hoc":"vqUuSP","overlay":"uAH4as","container":"zqpc6q"};const S={"scrollingDisabledByModal":"yfvOIZ"};import{jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";/**
2
2
  * The `<Modal>` component implements a simple themeable modal window, wrapped
3
3
  * into the default theme. `<BaseModal>` exposes the base non-themed component.
4
4
  * **Children:** Component children are rendered as the modal content.
@@ -9,12 +9,12 @@ import{useEffect,useMemo,useRef}from"react";import{useTheme}from"@dr.pogodin/rea
9
9
  * modal.
10
10
  * @param {ModalTheme} [props.theme] _Ad hoc_ theme.
11
11
  */const BaseModal=({cancelOnScrolling,children,containerStyle,dontDisableScrolling,onCancel,overlayStyle,style,testId,testIdForOverlay,theme})=>{const containerRef=useRef(null);const overlayRef=useRef(null);// Sets up modal cancellation of scrolling, if opted-in.
12
- useEffect(()=>{if(cancelOnScrolling&&onCancel){window.addEventListener("scroll",onCancel);window.addEventListener("wheel",onCancel)}return()=>{if(cancelOnScrolling&&onCancel){window.removeEventListener("scroll",onCancel);window.removeEventListener("wheel",onCancel)}}},[cancelOnScrolling,onCancel]);// Disables window scrolling, if it is not opted-out.
13
- useEffect(()=>{if(!dontDisableScrolling){document.body.classList.add(S.scrollingDisabledByModal)}return()=>{if(!dontDisableScrolling){document.body.classList.remove(S.scrollingDisabledByModal)}}},[dontDisableScrolling]);const focusLast=useMemo(()=>/*#__PURE__*/_jsx("div",{onFocus:()=>{const elems=containerRef.current.querySelectorAll("*");for(let i=elems.length-1;i>=0;--i){elems[i].focus();if(document.activeElement===elems[i])return}overlayRef.current?.focus()}// TODO: Have a look at this later.
12
+ useEffect(()=>{if(cancelOnScrolling&&onCancel){window.addEventListener("scroll",onCancel);window.addEventListener("wheel",onCancel);}return()=>{if(cancelOnScrolling&&onCancel){window.removeEventListener("scroll",onCancel);window.removeEventListener("wheel",onCancel);}};},[cancelOnScrolling,onCancel]);// Disables window scrolling, if it is not opted-out.
13
+ useEffect(()=>{if(!dontDisableScrolling){document.body.classList.add(S.scrollingDisabledByModal);}return()=>{if(!dontDisableScrolling){document.body.classList.remove(S.scrollingDisabledByModal);}};},[dontDisableScrolling]);const focusLast=useMemo(()=>/*#__PURE__*/_jsx("div",{onFocus:()=>{const elems=containerRef.current.querySelectorAll("*");for(let i=elems.length-1;i>=0;--i){elems[i].focus();if(document.activeElement===elems[i])return;}overlayRef.current?.focus();}// TODO: Have a look at this later.
14
14
  // eslint-disable-next-line jsx-a11y/no-noninteractive-tabindex
15
- ,tabIndex:0}),[]);return/*#__PURE__*/createPortal(/*#__PURE__*/_jsxs("div",{children:[focusLast,/*#__PURE__*/_jsx("div",{"aria-label":"Cancel",className:theme.overlay,"data-testid":process.env.NODE_ENV==="production"?undefined:testIdForOverlay,onClick:e=>{if(onCancel){onCancel();e.stopPropagation()}},onKeyDown:e=>{if(e.key==="Escape"&&onCancel){onCancel();e.stopPropagation()}},ref:node=>{if(node&&node!==overlayRef.current){overlayRef.current=node;node.focus()}},role:"button",style:overlayStyle,tabIndex:0}),/*#__PURE__*/_jsx("div",{// eslint-disable-line jsx-a11y/click-events-have-key-events, jsx-a11y/no-noninteractive-element-interactions
16
- "aria-modal":"true",className:theme.container,"data-testid":process.env.NODE_ENV==="production"?undefined:testId,onClick:e=>{e.stopPropagation()},onWheel:event=>{event.stopPropagation()},ref:containerRef,role:"dialog",style:style??containerStyle,children:children}),/*#__PURE__*/_jsx("div",{onFocus:()=>{overlayRef.current?.focus()}// TODO: Have a look at this later.
15
+ ,tabIndex:0}),[]);return/*#__PURE__*/createPortal(/*#__PURE__*/_jsxs("div",{children:[focusLast,/*#__PURE__*/_jsx("div",{"aria-label":"Cancel",className:theme.overlay,"data-testid":process.env.NODE_ENV==="production"?undefined:testIdForOverlay,onClick:e=>{if(onCancel){onCancel();e.stopPropagation();}},onKeyDown:e=>{if(e.key==="Escape"&&onCancel){onCancel();e.stopPropagation();}},ref:node=>{if(node&&node!==overlayRef.current){overlayRef.current=node;node.focus();}},role:"button",style:overlayStyle,tabIndex:0}),/*#__PURE__*/_jsx("div",{// eslint-disable-line jsx-a11y/click-events-have-key-events, jsx-a11y/no-noninteractive-element-interactions
16
+ "aria-modal":"true",className:theme.container,"data-testid":process.env.NODE_ENV==="production"?undefined:testId,onClick:e=>{e.stopPropagation();},onWheel:event=>{event.stopPropagation();},ref:containerRef,role:"dialog",style:style??containerStyle,children:children}),/*#__PURE__*/_jsx("div",{onFocus:()=>{overlayRef.current?.focus();}// TODO: Have a look at this later.
17
17
  // eslint-disable-next-line jsx-a11y/no-noninteractive-tabindex
18
- ,tabIndex:0}),focusLast]}),document.body)};/* Non-themed version of the Modal. */export{BaseModal};const Modal=({theme,...rest})=>{const composed=useTheme("Modal",defaultTheme,theme);// eslint-disable-next-line react/jsx-props-no-spreading
19
- return/*#__PURE__*/_jsx(BaseModal,{...rest,theme:composed})};export default Modal;
18
+ ,tabIndex:0}),focusLast]}),document.body);};/* Non-themed version of the Modal. */export{BaseModal};const Modal=({theme,...rest})=>{const composed=useTheme("Modal",defaultTheme,theme);// eslint-disable-next-line react/jsx-props-no-spreading
19
+ return/*#__PURE__*/_jsx(BaseModal,{...rest,theme:composed});};export default Modal;
20
20
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":["useEffect","useMemo","useRef","useTheme","createPortal","defaultTheme","S","jsx","_jsx","jsxs","_jsxs","BaseModal","cancelOnScrolling","children","containerStyle","dontDisableScrolling","onCancel","overlayStyle","style","testId","testIdForOverlay","theme","containerRef","overlayRef","window","addEventListener","removeEventListener","document","body","classList","add","scrollingDisabledByModal","remove","focusLast","onFocus","elems","current","querySelectorAll","i","length","focus","activeElement","tabIndex","className","overlay","process","env","NODE_ENV","undefined","onClick","e","stopPropagation","onKeyDown","key","ref","node","role","container","onWheel","event","Modal","rest","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 { type Theme, useTheme } from '@dr.pogodin/react-themes';\nimport { createPortal } from 'react-dom';\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":"AAAA,OAIEA,SAAS,CACTC,OAAO,CACPC,MAAM,KACD,OAAO,CAEd,OAAqBC,QAAQ,KAAQ,0BAA0B,CAC/D,OAASC,YAAY,KAAQ,WAAW,OAAAC,YAAA,iGAAAC,CAAA,uCAGV,OAAAC,GAAA,IAAAC,IAAA,CAAAC,IAAA,IAAAC,KAAA,yBAmB9B;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,GACA,KAAM,CAAAC,SAAoC,CAAGA,CAAC,CAC5CC,iBAAiB,CACjBC,QAAQ,CACRC,cAAc,CACdC,oBAAoB,CACpBC,QAAQ,CACRC,YAAY,CACZC,KAAK,CACLC,MAAM,CACNC,gBAAgB,CAChBC,KACF,CAAC,GAAK,CACJ,KAAM,CAAAC,YAAY,CAAGpB,MAAM,CAAwB,IAAI,CAAC,CACxD,KAAM,CAAAqB,UAAU,CAAGrB,MAAM,CAAwB,IAAI,CAAC,CAEtD;AACAF,SAAS,CAAC,IAAM,CACd,GAAIY,iBAAiB,EAAII,QAAQ,CAAE,CACjCQ,MAAM,CAACC,gBAAgB,CAAC,QAAQ,CAAET,QAAQ,CAAC,CAC3CQ,MAAM,CAACC,gBAAgB,CAAC,OAAO,CAAET,QAAQ,CAC3C,CACA,MAAO,IA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A;AACA;AAAA,CACAE,QAAQ,CAAE,CAAE,CACb,CAAC,CACDT,SAAS,EACP,CAAC,CAERN,QAAQ,CAACC,IACX,CACF,CAAC,CAED,sCACA,OAASjB,SAAS,EAElB,KAAM,CAAAiD,KAEL,CAAGA,CAAC,CAAEvC,KAAK,CAAE,GAAGwC,IAAK,CAAC,GAAK,CAC1B,KAAM,CAAAC,QAAQ,CAAG3D,QAAQ,CAAC,OAAO,CAAEE,YAAY,CAAEgB,KAAK,CAAC,CAEvD;AACA,mBAAOb,IAAA,CAACG,SAAS,KAAKkD,IAAI,CAAExC,KAAK,CAAEyC,QAAS,CAAE,CAChD,CAAC,CAED,cAAe,CAAAF,KAAK","ignoreList":[]}
1
+ {"version":3,"file":"index.js","names":["useEffect","useMemo","useRef","createPortal","useTheme","defaultTheme","S","jsx","_jsx","jsxs","_jsxs","BaseModal","cancelOnScrolling","children","containerStyle","dontDisableScrolling","onCancel","overlayStyle","style","testId","testIdForOverlay","theme","containerRef","overlayRef","window","addEventListener","removeEventListener","document","body","classList","add","scrollingDisabledByModal","remove","focusLast","onFocus","elems","current","querySelectorAll","i","length","focus","activeElement","tabIndex","className","overlay","process","env","NODE_ENV","undefined","onClick","e","stopPropagation","onKeyDown","key","ref","node","role","container","onWheel","event","Modal","rest","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":"AAAA,OAIEA,SAAS,CACTC,OAAO,CACPC,MAAM,KACD,OAAO,CAEd,OAASC,YAAY,KAAQ,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}
@@ -12,5 +12,5 @@ import{useTheme}from"@dr.pogodin/react-themes";const baseTheme={"context":"zv9td
12
12
  * @param {PageLayoutTheme} [props.theme] _Ad hoc_ theme.
13
13
  * @param {...any} [props....]
14
14
  * [Other theming properties](https://www.npmjs.com/package/@dr.pogodin/react-themes#themed-component-properties)
15
- */const PageLayout=({children,leftSidePanelContent,rightSidePanelContent,theme})=>{const composed=useTheme("PageLayout",baseTheme,theme);return/*#__PURE__*/_jsxs("div",{className:composed.container,children:[/*#__PURE__*/_jsx("div",{className:[composed.sidePanel,composed.leftSidePanel].join(" "),children:leftSidePanelContent}),/*#__PURE__*/_jsx("div",{className:composed.mainPanel,children:children}),/*#__PURE__*/_jsx("div",{className:[composed.sidePanel,composed.rightSidePanel].join(" "),children:rightSidePanelContent})]})};export default PageLayout;
15
+ */const PageLayout=({children,leftSidePanelContent,rightSidePanelContent,theme})=>{const composed=useTheme("PageLayout",baseTheme,theme);return/*#__PURE__*/_jsxs("div",{className:composed.container,children:[/*#__PURE__*/_jsx("div",{className:[composed.sidePanel,composed.leftSidePanel].join(" "),children:leftSidePanelContent}),/*#__PURE__*/_jsx("div",{className:composed.mainPanel,children:children}),/*#__PURE__*/_jsx("div",{className:[composed.sidePanel,composed.rightSidePanel].join(" "),children:rightSidePanelContent})]});};export default PageLayout;
16
16
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":["useTheme","baseTheme","jsx","_jsx","jsxs","_jsxs","PageLayout","children","leftSidePanelContent","rightSidePanelContent","theme","composed","className","container","sidePanel","leftSidePanel","join","mainPanel","rightSidePanel"],"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":"AAEA,OAAqBA,QAAQ,KAAQ,0BAA0B,OAAAC,SAAA,mHAErB,OAAAC,GAAA,IAAAC,IAAA,CAAAC,IAAA,IAAAC,KAAA,yBAY1C;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,GACA,KAAM,CAAAC,UAAqC,CAAGA,CAAC,CAC7CC,QAAQ,CACRC,oBAAoB,CACpBC,qBAAqB,CACrBC,KACF,CAAC,GAAK,CACJ,KAAM,CAAAC,QAAQ,CAAGX,QAAQ,CAAC,YAAY,CAAEC,SAAS,CAAES,KAAK,CAAC,CACzD,mBACEL,KAAA,QAAKO,SAAS,CAAED,QAAQ,CAACE,SAAU,CAAAN,QAAA,eACjCJ,IAAA,QAAKS,SAAS,CAAE,CAACD,QAAQ,CAACG,SAAS,CAAEH,QAAQ,CAACI,aAAa,CAAC,CAACC,IAAI,CAAC,GAAG,CAAE,CAAAT,QAAA,CACpEC,oBAAoB,CAClB,CAAC,cACNL,IAAA,QAAKS,SAAS,CAAED,QAAQ,CAACM,SAAU,CAAAV,QAAA,CAChCA,QAAQ,CACN,CAAC,cACNJ,IAAA,QAAKS,SAAS,CAAE,CAACD,QAAQ,CAACG,SAAS,CAAEH,QAAQ,CAACO,cAAc,CAAC,CAACF,IAAI,CAAC,GAAG,CAAE,CAAAT,QAAA,CACrEE,qBAAqB,CACnB,CAAC,EACH,CAET,CAAC,CAED,cAAe,CAAAH,UAAU","ignoreList":[]}
1
+ {"version":3,"file":"index.js","names":["useTheme","baseTheme","jsx","_jsx","jsxs","_jsxs","PageLayout","children","leftSidePanelContent","rightSidePanelContent","theme","composed","className","container","sidePanel","leftSidePanel","join","mainPanel","rightSidePanel"],"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":"AAEA,OAAqBA,QAAQ,KAAQ,0BAA0B,OAAAC,SAAA,mHAErB,OAAAC,GAAA,IAAAC,IAAA,CAAAC,IAAA,IAAAC,KAAA,yBAY1C;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,GACA,KAAM,CAAAC,UAAqC,CAAGA,CAAC,CAC7CC,QAAQ,CACRC,oBAAoB,CACpBC,qBAAqB,CACrBC,KACF,CAAC,GAAK,CACJ,KAAM,CAAAC,QAAQ,CAAGX,QAAQ,CAAC,YAAY,CAAEC,SAAS,CAAES,KAAK,CAAC,CACzD,mBACEL,KAAA,QAAKO,SAAS,CAAED,QAAQ,CAACE,SAAU,CAAAN,QAAA,eACjCJ,IAAA,QAAKS,SAAS,CAAE,CAACD,QAAQ,CAACG,SAAS,CAAEH,QAAQ,CAACI,aAAa,CAAC,CAACC,IAAI,CAAC,GAAG,CAAE,CAAAT,QAAA,CACpEC,oBAAoB,CAClB,CAAC,cACNL,IAAA,QAAKS,SAAS,CAAED,QAAQ,CAACM,SAAU,CAAAV,QAAA,CAChCA,QAAQ,CACN,CAAC,cACNJ,IAAA,QAAKS,SAAS,CAAE,CAACD,QAAQ,CAACG,SAAS,CAAEH,QAAQ,CAACO,cAAc,CAAC,CAACF,IAAI,CAAC,GAAG,CAAE,CAAAT,QAAA,CACrEE,qBAAqB,CACnB,CAAC,EACH,CAAC,CAEV,CAAC,CAED,cAAe,CAAAH,UAAU","ignoreList":[]}
@@ -1,12 +1,12 @@
1
1
  import{useEffect,useLayoutEffect,useRef,useState}from"react";import{useTheme}from"@dr.pogodin/react-themes";const defaultTheme={"context":"tECG8C","ad":"epeH4O","hoc":"_2kFnSt","container":"lV5ZyX","label":"_7qDPW1","textarea":"gkaNJJ","error":"ObwtG4","errorMessage":"ikIw0x","hidden":"-UyujK"};import{jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";const TextArea=({disabled,error,label,onBlur,onChange,onKeyDown,placeholder,testId,theme,value})=>{const custom=useTheme("TextArea",defaultTheme,theme);const hiddenAreaRef=useRef(null);const[height,setHeight]=useState();const textAreaRef=useRef(null);const[localValue,setLocalValue]=useState(value??"");if(value!==undefined&&localValue!==value)setLocalValue(value);// This resizes text area's height when its width is changed for any reason.
2
- useEffect(()=>{const el=hiddenAreaRef.current;if(!el)return undefined;const cb=()=>{setHeight(el.scrollHeight)};const observer=new ResizeObserver(cb);observer.observe(el);return()=>{observer.disconnect()}},[]);// Resizes the text area when its content is modified.
2
+ useEffect(()=>{const el=hiddenAreaRef.current;if(!el)return undefined;const cb=()=>{setHeight(el.scrollHeight);};const observer=new ResizeObserver(cb);observer.observe(el);return()=>{observer.disconnect();};},[]);// Resizes the text area when its content is modified.
3
3
  //
4
4
  // NOTE: useLayoutEffect() instead of useEffect() makes difference here,
5
5
  // as it helps to avoid visible "content/height" jumps (i.e. with just
6
6
  // useEffect() it becomes visible how the content is modified first,
7
7
  // and then input height is incremented, if necessary).
8
8
  // See: https://github.com/birdofpreyru/react-utils/issues/313
9
- useLayoutEffect(()=>{const el=hiddenAreaRef.current;if(el)setHeight(el.scrollHeight)},[localValue]);let containerClassName=custom.container;if(error)containerClassName+=` ${custom.error}`;return/*#__PURE__*/_jsxs("div",{className:containerClassName,onFocus:()=>{textAreaRef.current?.focus()},children:[label===undefined?null:/*#__PURE__*/_jsx("div",{className:custom.label,children:label}),/*#__PURE__*/_jsx("textarea",{className:`${custom.textarea} ${custom.hidden}`// This text area is hidden underneath the primary one below,
9
+ useLayoutEffect(()=>{const el=hiddenAreaRef.current;if(el)setHeight(el.scrollHeight);},[localValue]);let containerClassName=custom.container;if(error)containerClassName+=` ${custom.error}`;return/*#__PURE__*/_jsxs("div",{className:containerClassName,onFocus:()=>{textAreaRef.current?.focus();},children:[label===undefined?null:/*#__PURE__*/_jsx("div",{className:custom.label,children:label}),/*#__PURE__*/_jsx("textarea",{className:`${custom.textarea} ${custom.hidden}`// This text area is hidden underneath the primary one below,
10
10
  // and it is used for text measurements, to implement auto-scaling
11
11
  // of the primary textarea's height.
12
12
  ,readOnly:true,ref:hiddenAreaRef// The "-1" value of "tabIndex" removes this hidden text area from
@@ -18,5 +18,5 @@ useLayoutEffect(()=>{const el=hiddenAreaRef.current;if(el)setHeight(el.scrollHei
18
18
  ,value:localValue||" "}),/*#__PURE__*/_jsx("textarea",{className:custom.textarea,"data-testid":process.env.NODE_ENV==="production"?undefined:testId,disabled:disabled,onBlur:onBlur// When value is "undefined" the text area is not-managed, and we should
19
19
  // manage it internally for the measurement / resizing functionality
20
20
  // to work.
21
- ,onChange:value===undefined?e=>{setLocalValue(e.target.value)}:onChange,onKeyDown:onKeyDown,placeholder:placeholder,ref:textAreaRef,style:{height},value:localValue}),error&&error!==true?/*#__PURE__*/_jsx("div",{className:custom.errorMessage,children:error}):null]})};export default TextArea;
21
+ ,onChange:value===undefined?e=>{setLocalValue(e.target.value);}:onChange,onKeyDown:onKeyDown,placeholder:placeholder,ref:textAreaRef,style:{height},value:localValue}),error&&error!==true?/*#__PURE__*/_jsx("div",{className:custom.errorMessage,children:error}):null]});};export default TextArea;
22
22
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":["useEffect","useLayoutEffect","useRef","useState","useTheme","defaultTheme","jsx","_jsx","jsxs","_jsxs","TextArea","disabled","error","label","onBlur","onChange","onKeyDown","placeholder","testId","theme","value","custom","hiddenAreaRef","height","setHeight","textAreaRef","localValue","setLocalValue","undefined","el","current","cb","scrollHeight","observer","ResizeObserver","observe","disconnect","containerClassName","container","className","onFocus","focus","children","textarea","hidden","readOnly","ref","tabIndex","process","env","NODE_ENV","e","target","style","errorMessage"],"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 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 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 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 ref={textAreaRef}\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":"AAAA,OAMEA,SAAS,CACTC,eAAe,CACfC,MAAM,CACNC,QAAQ,KACH,OAAO,CAEd,OAAqBC,QAAQ,KAAQ,0BAA0B,OAAAC,YAAA,0KAEvB,OAAAC,GAAA,IAAAC,IAAA,CAAAC,IAAA,IAAAC,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C,CACDd,KAAK,EAAIA,KAAK,GAAK,IAAI,cACpBL,IAAA,QAAKgC,SAAS,CAAElB,MAAM,CAACiC,YAAa,CAAAZ,QAAA,CAAE9B,KAAK,CAAM,CAAC,CAClD,IAAI,EACL,CAET,CAAC,CAED,cAAe,CAAAF,QAAQ","ignoreList":[]}
1
+ {"version":3,"file":"index.js","names":["useEffect","useLayoutEffect","useRef","useState","useTheme","defaultTheme","jsx","_jsx","jsxs","_jsxs","TextArea","disabled","error","label","onBlur","onChange","onKeyDown","placeholder","testId","theme","value","custom","hiddenAreaRef","height","setHeight","textAreaRef","localValue","setLocalValue","undefined","el","current","cb","scrollHeight","observer","ResizeObserver","observe","disconnect","containerClassName","container","className","onFocus","focus","children","textarea","hidden","readOnly","ref","tabIndex","process","env","NODE_ENV","e","target","style","errorMessage"],"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 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 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 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 ref={textAreaRef}\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":"AAAA,OAMEA,SAAS,CACTC,eAAe,CACfC,MAAM,CACNC,QAAQ,KACH,OAAO,CAEd,OAAqBC,QAAQ,KAAQ,0BAA0B,OAAAC,YAAA,0KAEvB,OAAAC,GAAA,IAAAC,IAAA,CAAAC,IAAA,IAAAC,KAAA,yBAkBxC,KAAM,CAAAC,QAAkC,CAAGA,CAAC,CAC1CC,QAAQ,CACRC,KAAK,CACLC,KAAK,CACLC,MAAM,CACNC,QAAQ,CACRC,SAAS,CACTC,WAAW,CACXC,MAAM,CACNC,KAAK,CACLC,KACF,CAAC,GAAK,CACJ,KAAM,CAAAC,MAAM,CAAGjB,QAAQ,CAAC,UAAU,CAAEC,YAAY,CAAEc,KAAK,CAAC,CAExD,KAAM,CAAAG,aAAa,CAAGpB,MAAM,CAAsB,IAAI,CAAC,CACvD,KAAM,CAACqB,MAAM,CAAEC,SAAS,CAAC,CAAGrB,QAAQ,CAAqB,CAAC,CAE1D,KAAM,CAAAsB,WAAW,CAAGvB,MAAM,CAAsB,IAAI,CAAC,CAErD,KAAM,CAACwB,UAAU,CAAEC,aAAa,CAAC,CAAGxB,QAAQ,CAACiB,KAAK,EAAI,EAAE,CAAC,CACzD,GAAIA,KAAK,GAAKQ,SAAS,EAAIF,UAAU,GAAKN,KAAK,CAAEO,aAAa,CAACP,KAAK,CAAC,CAErE;AACApB,SAAS,CAAC,IAAM,CACd,KAAM,CAAA6B,EAAE,CAAGP,aAAa,CAACQ,OAAO,CAChC,GAAI,CAACD,EAAE,CAAE,MAAO,CAAAD,SAAS,CAEzB,KAAM,CAAAG,EAAE,CAAGA,CAAA,GAAM,CACfP,SAAS,CAACK,EAAE,CAACG,YAAY,CAAC,CAC5B,CAAC,CACD,KAAM,CAAAC,QAAQ,CAAG,GAAI,CAAAC,cAAc,CAACH,EAAE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M,CAAEA,MAER;AACA;AACA;AAAA,CACAC,QAAQ,CACNK,KAAK,GAAKQ,SAAS,CACduB,CAAC,EAAK,CACPxB,aAAa,CAACwB,CAAC,CAACC,MAAM,CAAChC,KAAK,CAAC,CAC/B,CAAC,CAAGL,QACP,CACDC,SAAS,CAAEA,SAAU,CACrBC,WAAW,CAAEA,WAAY,CACzB6B,GAAG,CAAErB,WAAY,CACjB4B,KAAK,CAAE,CAAE9B,MAAO,CAAE,CAClBH,KAAK,CAAEM,UAAW,CACnB,CAAC,CACDd,KAAK,EAAIA,KAAK,GAAK,IAAI,cACpBL,IAAA,QAAKgC,SAAS,CAAElB,MAAM,CAACiC,YAAa,CAAAZ,QAAA,CAAE9B,KAAK,CAAM,CAAC,CAClD,IAAI,EACL,CAAC,CAEV,CAAC,CAED,cAAe,CAAAF,QAAQ","ignoreList":[]}
@@ -6,5 +6,5 @@ import{useTheme}from"@dr.pogodin/react-themes";const defaultTheme={"context":"eV
6
6
  * @param {ThrobberTheme} [props.theme] _Ad hoc_ theme.
7
7
  * @param {...any} [props....]
8
8
  * [Other theming properties](https://www.npmjs.com/package/@dr.pogodin/react-themes#themed-component-properties)
9
- */const Throbber=({theme,themePriority})=>{const custom=useTheme("Throbber",defaultTheme,theme,{themePriority});return/*#__PURE__*/_jsxs("span",{className:custom.container,children:[/*#__PURE__*/_jsx("span",{className:custom.circle}),/*#__PURE__*/_jsx("span",{className:custom.circle}),/*#__PURE__*/_jsx("span",{className:custom.circle})]})};export default Throbber;
9
+ */const Throbber=({theme,themePriority})=>{const custom=useTheme("Throbber",defaultTheme,theme,{themePriority});return/*#__PURE__*/_jsxs("span",{className:custom.container,children:[/*#__PURE__*/_jsx("span",{className:custom.circle}),/*#__PURE__*/_jsx("span",{className:custom.circle}),/*#__PURE__*/_jsx("span",{className:custom.circle})]});};export default Throbber;
10
10
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":["useTheme","defaultTheme","jsx","_jsx","jsxs","_jsxs","Throbber","theme","themePriority","custom","className","container","children","circle"],"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":"AAEA,OAAoCA,QAAQ,KAAQ,0BAA0B,OAAAC,YAAA,+GAEtC,OAAAC,GAAA,IAAAC,IAAA,CAAAC,IAAA,IAAAC,KAAA,yBASxC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,GACA,KAAM,CAAAC,QAAmC,CAAGA,CAAC,CAAEC,KAAK,CAAEC,aAAc,CAAC,GAAK,CACxE,KAAM,CAAAC,MAAM,CAAGT,QAAQ,CAAC,UAAU,CAAEC,YAAY,CAAEM,KAAK,CAAE,CACvDC,aACF,CAAC,CAAC,CAEF,mBACEH,KAAA,SAAMK,SAAS,CAAED,MAAM,CAACE,SAAU,CAAAC,QAAA,eAChCT,IAAA,SAAMO,SAAS,CAAED,MAAM,CAACI,MAAO,CAAE,CAAC,cAClCV,IAAA,SAAMO,SAAS,CAAED,MAAM,CAACI,MAAO,CAAE,CAAC,cAClCV,IAAA,SAAMO,SAAS,CAAED,MAAM,CAACI,MAAO,CAAE,CAAC,EAC9B,CAEV,CAAC,CAED,cAAe,CAAAP,QAAQ","ignoreList":[]}
1
+ {"version":3,"file":"index.js","names":["useTheme","defaultTheme","jsx","_jsx","jsxs","_jsxs","Throbber","theme","themePriority","custom","className","container","children","circle"],"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":"AAEA,OAAoCA,QAAQ,KAAQ,0BAA0B,OAAAC,YAAA,+GAEtC,OAAAC,GAAA,IAAAC,IAAA,CAAAC,IAAA,IAAAC,KAAA,yBASxC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,GACA,KAAM,CAAAC,QAAmC,CAAGA,CAAC,CAAEC,KAAK,CAAEC,aAAc,CAAC,GAAK,CACxE,KAAM,CAAAC,MAAM,CAAGT,QAAQ,CAAC,UAAU,CAAEC,YAAY,CAAEM,KAAK,CAAE,CACvDC,aACF,CAAC,CAAC,CAEF,mBACEH,KAAA,SAAMK,SAAS,CAAED,MAAM,CAACE,SAAU,CAAAC,QAAA,eAChCT,IAAA,SAAMO,SAAS,CAAED,MAAM,CAACI,MAAO,CAAE,CAAC,cAClCV,IAAA,SAAMO,SAAS,CAAED,MAAM,CAACI,MAAO,CAAE,CAAC,cAClCV,IAAA,SAAMO,SAAS,CAAED,MAAM,CAACI,MAAO,CAAE,CAAC,EAC9B,CAAC,CAEX,CAAC,CAED,cAAe,CAAAP,QAAQ","ignoreList":[]}
@@ -5,7 +5,7 @@
5
5
  */import{useImperativeHandle,useRef}from"react";import{createPortal}from"react-dom";import{jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";/**
6
6
  * Valid placements of the rendered tooltip. They will be overriden when
7
7
  * necessary to fit the tooltip within the viewport.
8
- */export let PLACEMENTS=/*#__PURE__*/function(PLACEMENTS){PLACEMENTS["ABOVE_CURSOR"]="ABOVE_CURSOR";PLACEMENTS["ABOVE_ELEMENT"]="ABOVE_ELEMENT";PLACEMENTS["BELOW_CURSOR"]="BELOW_CURSOR";PLACEMENTS["BELOW_ELEMENT"]="BELOW_ELEMENT";return PLACEMENTS}({});const ARROW_STYLE_DOWN=["border-bottom-color:transparent","border-left-color:transparent","border-right-color:transparent"].join(";");const ARROW_STYLE_UP=["border-top-color:transparent","border-left-color:transparent","border-right-color:transparent"].join(";");/**
8
+ */export let PLACEMENTS=/*#__PURE__*/function(PLACEMENTS){PLACEMENTS["ABOVE_CURSOR"]="ABOVE_CURSOR";PLACEMENTS["ABOVE_ELEMENT"]="ABOVE_ELEMENT";PLACEMENTS["BELOW_CURSOR"]="BELOW_CURSOR";PLACEMENTS["BELOW_ELEMENT"]="BELOW_ELEMENT";return PLACEMENTS;}({});const ARROW_STYLE_DOWN=["border-bottom-color:transparent","border-left-color:transparent","border-right-color:transparent"].join(";");const ARROW_STYLE_UP=["border-top-color:transparent","border-left-color:transparent","border-right-color:transparent"].join(";");/**
9
9
  * Generates bounding client rectangles for tooltip components.
10
10
  * @ignore
11
11
  * @param tooltip DOM references to the tooltip components.
@@ -13,11 +13,11 @@
13
13
  * @param tooltip.container
14
14
  * @return Object holding tooltip rectangles in
15
15
  * two fields.
16
- */function calcTooltipRects(tooltip){return{arrow:tooltip.arrow.getBoundingClientRect(),container:tooltip.container.getBoundingClientRect()}}/**
16
+ */function calcTooltipRects(tooltip){return{arrow:tooltip.arrow.getBoundingClientRect(),container:tooltip.container.getBoundingClientRect()};}/**
17
17
  * Calculates the document viewport size.
18
18
  * @ignore
19
19
  * @return {{x, y, width, height}}
20
- */function calcViewportRect(){const{scrollX,scrollY}=window;const{documentElement:{clientHeight,clientWidth}}=document;return{bottom:scrollY+clientHeight,left:scrollX,right:scrollX+clientWidth,top:scrollY}}/**
20
+ */function calcViewportRect(){const{scrollX,scrollY}=window;const{documentElement:{clientHeight,clientWidth}}=document;return{bottom:scrollY+clientHeight,left:scrollX,right:scrollX+clientWidth,top:scrollY};}/**
21
21
  * Calculates tooltip and arrow positions for the placement just above
22
22
  * the cursor.
23
23
  * @ignore
@@ -35,7 +35,7 @@
35
35
  */function calcPositionAboveXY(x,y,tooltipRects){const{arrow,container}=tooltipRects;return{arrowX:0.5*(container.width-arrow.width),arrowY:container.height,containerX:x-container.width/2,containerY:y-container.height-arrow.height/1.5,// TODO: Instead of already setting the base style here, we should
36
36
  // introduce a set of constants for arrow directions, which will help
37
37
  // to do checks dependant on the arrow direction.
38
- baseArrowStyle:ARROW_STYLE_DOWN}}// const HIT = {
38
+ baseArrowStyle:ARROW_STYLE_DOWN};}// const HIT = {
39
39
  // NONE: false,
40
40
  // LEFT: 'LEFT',
41
41
  // RIGHT: 'RIGHT',
@@ -88,10 +88,10 @@ baseArrowStyle:ARROW_STYLE_DOWN}}// const HIT = {
88
88
  * @param tooltip
89
89
  * @param tooltip.arrow DOM reference to the tooltip arrow.
90
90
  * @param tooltip.container DOM reference to the tooltip container.
91
- */function setComponentPositions(pageX,pageY,placement,element,tooltip){const tooltipRects=calcTooltipRects(tooltip);const viewportRect=calcViewportRect();/* Default container coords: tooltip at the top. */const pos=calcPositionAboveXY(pageX,pageY,tooltipRects);if(pos.containerX<viewportRect.left+6){pos.containerX=viewportRect.left+6;pos.arrowX=Math.max(6,pageX-pos.containerX-tooltipRects.arrow.width/2)}else{const maxX=viewportRect.right-6-tooltipRects.container.width;if(pos.containerX>maxX){pos.containerX=maxX;pos.arrowX=Math.min(tooltipRects.container.width-6,pageX-pos.containerX-tooltipRects.arrow.width/2)}}/* If tooltip has not enough space on top - make it bottom tooltip. */if(pos.containerY<viewportRect.top+6){pos.containerY+=tooltipRects.container.height+2*tooltipRects.arrow.height;pos.arrowY-=tooltipRects.container.height+tooltipRects.arrow.height;pos.baseArrowStyle=ARROW_STYLE_UP}const containerStyle=`left:${pos.containerX}px;top:${pos.containerY}px`;tooltip.container.setAttribute("style",containerStyle);const arrowStyle=`${pos.baseArrowStyle};left:${pos.arrowX}px;top:${pos.arrowY}px`;tooltip.arrow.setAttribute("style",arrowStyle)}/* The Tooltip component itself. */const Tooltip=({children,ref,theme})=>{// NOTE: The way it has to be implemented, for clean mounting and unmounting
91
+ */function setComponentPositions(pageX,pageY,placement,element,tooltip){const tooltipRects=calcTooltipRects(tooltip);const viewportRect=calcViewportRect();/* Default container coords: tooltip at the top. */const pos=calcPositionAboveXY(pageX,pageY,tooltipRects);if(pos.containerX<viewportRect.left+6){pos.containerX=viewportRect.left+6;pos.arrowX=Math.max(6,pageX-pos.containerX-tooltipRects.arrow.width/2);}else{const maxX=viewportRect.right-6-tooltipRects.container.width;if(pos.containerX>maxX){pos.containerX=maxX;pos.arrowX=Math.min(tooltipRects.container.width-6,pageX-pos.containerX-tooltipRects.arrow.width/2);}}/* If tooltip has not enough space on top - make it bottom tooltip. */if(pos.containerY<viewportRect.top+6){pos.containerY+=tooltipRects.container.height+2*tooltipRects.arrow.height;pos.arrowY-=tooltipRects.container.height+tooltipRects.arrow.height;pos.baseArrowStyle=ARROW_STYLE_UP;}const containerStyle=`left:${pos.containerX}px;top:${pos.containerY}px`;tooltip.container.setAttribute("style",containerStyle);const arrowStyle=`${pos.baseArrowStyle};left:${pos.arrowX}px;top:${pos.arrowY}px`;tooltip.arrow.setAttribute("style",arrowStyle);}/* The Tooltip component itself. */const Tooltip=({children,ref,theme})=>{// NOTE: The way it has to be implemented, for clean mounting and unmounting
92
92
  // at the client side, the <Tooltip> is fully mounted into DOM in the next
93
93
  // rendering cycles, and only then it can be correctly measured and positioned.
94
94
  // Thus, when we create the <Tooltip> we have to record its target positioning
95
95
  // details, and then apply them when it is created.
96
- const arrowRef=useRef(null);const containerRef=useRef(null);const contentRef=useRef(null);const pointTo=(pageX,pageY,placement,element)=>{if(!arrowRef.current||!containerRef.current||!contentRef.current){throw Error("Internal error")}setComponentPositions(pageX,pageY,placement,element,{arrow:arrowRef.current,container:containerRef.current,content:contentRef.current})};useImperativeHandle(ref,()=>({pointTo}));return/*#__PURE__*/createPortal(/*#__PURE__*/_jsxs("div",{className:theme.container,ref:containerRef,children:[/*#__PURE__*/_jsx("div",{className:theme.arrow,ref:arrowRef}),/*#__PURE__*/_jsx("div",{className:theme.content,ref:contentRef,children:children})]}),document.body)};export default Tooltip;
96
+ const arrowRef=useRef(null);const containerRef=useRef(null);const contentRef=useRef(null);const pointTo=(pageX,pageY,placement,element)=>{if(!arrowRef.current||!containerRef.current||!contentRef.current){throw Error("Internal error");}setComponentPositions(pageX,pageY,placement,element,{arrow:arrowRef.current,container:containerRef.current,content:contentRef.current});};useImperativeHandle(ref,()=>({pointTo}));return/*#__PURE__*/createPortal(/*#__PURE__*/_jsxs("div",{className:theme.container,ref:containerRef,children:[/*#__PURE__*/_jsx("div",{className:theme.arrow,ref:arrowRef}),/*#__PURE__*/_jsx("div",{className:theme.content,ref:contentRef,children:children})]}),document.body);};export default Tooltip;
97
97
  //# sourceMappingURL=Tooltip.js.map
@@ -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","children","ref","theme","arrowRef","containerRef","contentRef","pointTo","current","Error","content","className","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":"AAAA;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,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ACjD,KAAM,CAAA0D,UAAU,CAAG1D,MAAM,CAAiB,IAAI,CAAC,CAE/C,KAAM,CAAA2D,OAAO,CAAGA,CACdpB,KAAa,CACbC,KAAa,CACbC,SAAqB,CACrBC,OAAoB,GACjB,CACH,GAAI,CAACc,QAAQ,CAACI,OAAO,EAAI,CAACH,YAAY,CAACG,OAAO,EAAI,CAACF,UAAU,CAACE,OAAO,CAAE,CACrE,KAAM,CAAAC,KAAK,CAAC,gBAAgB,CAC9B,CAEAvB,qBAAqB,CAACC,KAAK,CAAEC,KAAK,CAAEC,SAAS,CAAEC,OAAO,CAAE,CACtD9B,KAAK,CAAE4C,QAAQ,CAACI,OAAO,CACvB9C,SAAS,CAAE2C,YAAY,CAACG,OAAO,CAC/BE,OAAO,CAAEJ,UAAU,CAACE,OACtB,CAAC,CACH,CAAC,CACD7D,mBAAmB,CAACuD,GAAG,CAAE,KAAO,CAAEK,OAAQ,CAAC,CAAC,CAAC,CAE7C,mBAAO1D,YAAY,cAEfI,KAAA,QAAK0D,SAAS,CAAER,KAAK,CAACzC,SAAU,CAACwC,GAAG,CAAEG,YAAa,CAAAJ,QAAA,eACjDlD,IAAA,QAAK4D,SAAS,CAAER,KAAK,CAAC3C,KAAM,CAAC0C,GAAG,CAAEE,QAAS,CAAE,CAAC,cAC9CrD,IAAA,QAAK4D,SAAS,CAAER,KAAK,CAACO,OAAQ,CAACR,GAAG,CAAEI,UAAW,CAAAL,QAAA,CAAEA,QAAQ,CAAM,CAAC,EAC7D,CAAC,CAER/B,QAAQ,CAAC0C,IACX,CACF,CAAC,CAED,cAAe,CAAAZ,OAAO","ignoreList":[]}
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","children","ref","theme","arrowRef","containerRef","contentRef","pointTo","current","Error","content","className","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":"AAAA;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,OAOtB,KAAM,CAAAC,gBAAgB,CAAG,CACvB,iCAAiC,CACjC,+BAA+B,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B,KAAa,CACbC,KAAa,CACbC,SAAqB,CACrBC,OAAoB,GACjB,CACH,GAAI,CAACc,QAAQ,CAACI,OAAO,EAAI,CAACH,YAAY,CAACG,OAAO,EAAI,CAACF,UAAU,CAACE,OAAO,CAAE,CACrE,KAAM,CAAAC,KAAK,CAAC,gBAAgB,CAAC,CAC/B,CAEAvB,qBAAqB,CAACC,KAAK,CAAEC,KAAK,CAAEC,SAAS,CAAEC,OAAO,CAAE,CACtD9B,KAAK,CAAE4C,QAAQ,CAACI,OAAO,CACvB9C,SAAS,CAAE2C,YAAY,CAACG,OAAO,CAC/BE,OAAO,CAAEJ,UAAU,CAACE,OACtB,CAAC,CAAC,CACJ,CAAC,CACD7D,mBAAmB,CAACuD,GAAG,CAAE,KAAO,CAAEK,OAAQ,CAAC,CAAC,CAAC,CAE7C,mBAAO1D,YAAY,cAEfI,KAAA,QAAK0D,SAAS,CAAER,KAAK,CAACzC,SAAU,CAACwC,GAAG,CAAEG,YAAa,CAAAJ,QAAA,eACjDlD,IAAA,QAAK4D,SAAS,CAAER,KAAK,CAAC3C,KAAM,CAAC0C,GAAG,CAAEE,QAAS,CAAE,CAAC,cAC9CrD,IAAA,QAAK4D,SAAS,CAAER,KAAK,CAACO,OAAQ,CAACR,GAAG,CAAEI,UAAW,CAAAL,QAAA,CAAEA,QAAQ,CAAM,CAAC,EAC7D,CAAC,CAER/B,QAAQ,CAAC0C,IACX,CAAC,CACH,CAAC,CAED,cAAe,CAAAZ,OAAO","ignoreList":[]}
@@ -11,15 +11,15 @@
11
11
  * @param tip &ndash; Anything React is able to render,
12
12
  * _e.g._ a tooltip text. This will be the tooltip content.
13
13
  * @param {WithTooltipTheme} props.theme _Ad hoc_ theme.
14
- */const WithTooltip=({children,placement=PLACEMENTS.ABOVE_CURSOR,theme,tip})=>{const custom=useTheme("WithTooltip",defaultTheme,theme);const{current:heap}=useRef({lastCursorX:0,lastCursorY:0,timerId:undefined,triggeredByTouch:false});const tooltipRef=useRef(null);const wrapperRef=useRef(null);const[showTooltip,setShowTooltip]=useState(false);const updatePortalPosition=(cursorX,cursorY)=>{if(showTooltip){const wrapperRect=wrapperRef.current.getBoundingClientRect();if(cursorX<wrapperRect.left||cursorX>wrapperRect.right||cursorY<wrapperRect.top||cursorY>wrapperRect.bottom){setShowTooltip(false)}else if(tooltipRef.current){tooltipRef.current.pointTo(cursorX+window.scrollX,cursorY+window.scrollY,placement,wrapperRef.current)}}else{heap.lastCursorX=cursorX;heap.lastCursorY=cursorY;// If tooltip was triggered by a touch, we delay its opening by a bit,
14
+ */const WithTooltip=({children,placement=PLACEMENTS.ABOVE_CURSOR,theme,tip})=>{const custom=useTheme("WithTooltip",defaultTheme,theme);const{current:heap}=useRef({lastCursorX:0,lastCursorY:0,timerId:undefined,triggeredByTouch:false});const tooltipRef=useRef(null);const wrapperRef=useRef(null);const[showTooltip,setShowTooltip]=useState(false);const updatePortalPosition=(cursorX,cursorY)=>{if(showTooltip){const wrapperRect=wrapperRef.current.getBoundingClientRect();if(cursorX<wrapperRect.left||cursorX>wrapperRect.right||cursorY<wrapperRect.top||cursorY>wrapperRect.bottom){setShowTooltip(false);}else if(tooltipRef.current){tooltipRef.current.pointTo(cursorX+window.scrollX,cursorY+window.scrollY,placement,wrapperRef.current);}}else{heap.lastCursorX=cursorX;heap.lastCursorY=cursorY;// If tooltip was triggered by a touch, we delay its opening by a bit,
15
15
  // to ensure it was not a touch-click - in the case of touch click we
16
16
  // want to do the click, rather than show the tooltip, and the delay
17
17
  // gives click handler a chance to abort the tooltip openning.
18
- if(heap.triggeredByTouch){heap.timerId??=setTimeout(()=>{heap.triggeredByTouch=false;heap.timerId=undefined;setShowTooltip(true)},300);// Otherwise we can just open the tooltip right away.
19
- }else setShowTooltip(true)}};useEffect(()=>{if(showTooltip&&tip!==null){// This is necessary to ensure that even when a single mouse event
18
+ if(heap.triggeredByTouch){heap.timerId??=setTimeout(()=>{heap.triggeredByTouch=false;heap.timerId=undefined;setShowTooltip(true);},300);// Otherwise we can just open the tooltip right away.
19
+ }else setShowTooltip(true);}};useEffect(()=>{if(showTooltip&&tip!==null){// This is necessary to ensure that even when a single mouse event
20
20
  // arrives to a tool-tipped component, the tooltip is correctly positioned
21
21
  // once opened (because similar call above does not have effect until
22
22
  // the tooltip is fully mounted, and that is delayed to future rendering
23
23
  // cycle due to the implementation).
24
- if(tooltipRef.current){tooltipRef.current.pointTo(heap.lastCursorX+window.scrollX,heap.lastCursorY+window.scrollY,placement,wrapperRef.current)}const listener=()=>{setShowTooltip(false)};window.addEventListener("scroll",listener);return()=>{window.removeEventListener("scroll",listener)}}return undefined},[heap.lastCursorX,heap.lastCursorY,placement,showTooltip,tip]);return/*#__PURE__*/_jsxs("div",{className:custom.wrapper,onClick:()=>{if(heap.timerId){clearTimeout(heap.timerId);heap.timerId=undefined;heap.triggeredByTouch=false}},onMouseLeave:()=>{setShowTooltip(false)},onMouseMove:e=>{updatePortalPosition(e.clientX,e.clientY)},onTouchStart:()=>{heap.triggeredByTouch=true},ref:wrapperRef,role:"presentation",children:[showTooltip&&tip!==null?/*#__PURE__*/_jsx(Tooltip,{ref:tooltipRef,theme:custom,children:tip}):null,children]})};const e=WithTooltip;e.PLACEMENTS=PLACEMENTS;export default e;
24
+ if(tooltipRef.current){tooltipRef.current.pointTo(heap.lastCursorX+window.scrollX,heap.lastCursorY+window.scrollY,placement,wrapperRef.current);}const listener=()=>{setShowTooltip(false);};window.addEventListener("scroll",listener);return()=>{window.removeEventListener("scroll",listener);};}return undefined;},[heap.lastCursorX,heap.lastCursorY,placement,showTooltip,tip]);return/*#__PURE__*/_jsxs("div",{className:custom.wrapper,onClick:()=>{if(heap.timerId){clearTimeout(heap.timerId);heap.timerId=undefined;heap.triggeredByTouch=false;}},onMouseLeave:()=>{setShowTooltip(false);},onMouseMove:e=>{updatePortalPosition(e.clientX,e.clientY);},onTouchStart:()=>{heap.triggeredByTouch=true;},ref:wrapperRef,role:"presentation",children:[showTooltip&&tip!==null?/*#__PURE__*/_jsx(Tooltip,{ref:tooltipRef,theme:custom,children:tip}):null,children]});};const e=WithTooltip;e.PLACEMENTS=PLACEMENTS;export default e;
25
25
  //# sourceMappingURL=index.js.map