@dr.pogodin/react-utils 1.53.1 → 1.54.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (145) hide show
  1. package/build/development/client/index.js +2 -0
  2. package/build/development/client/index.js.map +1 -1
  3. package/build/development/index.js +2 -2
  4. package/build/development/index.js.map +1 -1
  5. package/build/development/shared/components/Button/index.js +149 -71
  6. package/build/development/shared/components/Button/index.js.map +1 -1
  7. package/build/development/shared/components/Checkbox/index.js +77 -24
  8. package/build/development/shared/components/Checkbox/index.js.map +1 -1
  9. package/build/development/shared/components/GenericLink/index.js +133 -54
  10. package/build/development/shared/components/GenericLink/index.js.map +1 -1
  11. package/build/development/shared/components/Input/index.js +168 -45
  12. package/build/development/shared/components/Input/index.js.map +1 -1
  13. package/build/development/shared/components/Link.js +23 -13
  14. package/build/development/shared/components/Link.js.map +1 -1
  15. package/build/development/shared/components/Modal/index.js +203 -87
  16. package/build/development/shared/components/Modal/index.js.map +1 -1
  17. package/build/development/shared/components/NavLink.js +16 -7
  18. package/build/development/shared/components/NavLink.js.map +1 -1
  19. package/build/development/shared/components/PageLayout/index.js +77 -15
  20. package/build/development/shared/components/PageLayout/index.js.map +1 -1
  21. package/build/development/shared/components/TextArea/index.js +169 -68
  22. package/build/development/shared/components/TextArea/index.js.map +1 -1
  23. package/build/development/shared/components/Throbber/index.js +51 -13
  24. package/build/development/shared/components/Throbber/index.js.map +1 -1
  25. package/build/development/shared/components/WithTooltip/Tooltip.js +73 -34
  26. package/build/development/shared/components/WithTooltip/Tooltip.js.map +1 -1
  27. package/build/development/shared/components/WithTooltip/index.js +19 -19
  28. package/build/development/shared/components/WithTooltip/index.js.map +1 -1
  29. package/build/development/shared/components/YouTubeVideo/index.js +66 -23
  30. package/build/development/shared/components/YouTubeVideo/index.js.map +1 -1
  31. package/build/development/shared/components/selectors/CustomDropdown/Options/index.js +104 -56
  32. package/build/development/shared/components/selectors/CustomDropdown/Options/index.js.map +1 -1
  33. package/build/development/shared/components/selectors/CustomDropdown/index.js +173 -75
  34. package/build/development/shared/components/selectors/CustomDropdown/index.js.map +1 -1
  35. package/build/development/shared/components/selectors/Switch/index.js +86 -36
  36. package/build/development/shared/components/selectors/Switch/index.js.map +1 -1
  37. package/build/development/shared/utils/globalState.js +2 -2
  38. package/build/development/shared/utils/globalState.js.map +1 -1
  39. package/build/development/shared/utils/index.js +2 -2
  40. package/build/development/shared/utils/index.js.map +1 -1
  41. package/build/development/shared/utils/jest/index.js +19 -7
  42. package/build/development/shared/utils/jest/index.js.map +1 -1
  43. package/build/development/shared/utils/splitComponent.js +125 -55
  44. package/build/development/shared/utils/splitComponent.js.map +1 -1
  45. package/build/development/shared/utils/time.js +55 -20
  46. package/build/development/shared/utils/time.js.map +1 -1
  47. package/build/production/client/index.js +2 -2
  48. package/build/production/client/index.js.map +1 -1
  49. package/build/production/index.js +1 -1
  50. package/build/production/index.js.map +1 -1
  51. package/build/production/shared/components/Button/index.js +2 -13
  52. package/build/production/shared/components/Button/index.js.map +1 -1
  53. package/build/production/shared/components/Checkbox/index.js +1 -1
  54. package/build/production/shared/components/Checkbox/index.js.map +1 -1
  55. package/build/production/shared/components/GenericLink/index.js +2 -15
  56. package/build/production/shared/components/GenericLink/index.js.map +1 -1
  57. package/build/production/shared/components/Input/index.js +2 -11
  58. package/build/production/shared/components/Input/index.js.map +1 -1
  59. package/build/production/shared/components/Link.js +2 -4
  60. package/build/production/shared/components/Link.js.map +1 -1
  61. package/build/production/shared/components/Modal/index.js +2 -10
  62. package/build/production/shared/components/Modal/index.js.map +1 -1
  63. package/build/production/shared/components/NavLink.js +1 -4
  64. package/build/production/shared/components/NavLink.js.map +1 -1
  65. package/build/production/shared/components/PageLayout/index.js +2 -2
  66. package/build/production/shared/components/PageLayout/index.js.map +1 -1
  67. package/build/production/shared/components/TextArea/index.js +1 -21
  68. package/build/production/shared/components/TextArea/index.js.map +1 -1
  69. package/build/production/shared/components/Throbber/index.js +2 -2
  70. package/build/production/shared/components/Throbber/index.js.map +1 -1
  71. package/build/production/shared/components/WithTooltip/Tooltip.js +2 -7
  72. package/build/production/shared/components/WithTooltip/Tooltip.js.map +1 -1
  73. package/build/production/shared/components/WithTooltip/index.js +3 -3
  74. package/build/production/shared/components/WithTooltip/index.js.map +1 -1
  75. package/build/production/shared/components/YouTubeVideo/index.js +2 -5
  76. package/build/production/shared/components/YouTubeVideo/index.js.map +1 -1
  77. package/build/production/shared/components/selectors/CustomDropdown/Options/index.js +1 -6
  78. package/build/production/shared/components/selectors/CustomDropdown/Options/index.js.map +1 -1
  79. package/build/production/shared/components/selectors/CustomDropdown/index.js +1 -7
  80. package/build/production/shared/components/selectors/CustomDropdown/index.js.map +1 -1
  81. package/build/production/shared/components/selectors/Switch/index.js +1 -1
  82. package/build/production/shared/components/selectors/Switch/index.js.map +1 -1
  83. package/build/production/shared/utils/globalState.js +1 -1
  84. package/build/production/shared/utils/globalState.js.map +1 -1
  85. package/build/production/shared/utils/index.js +1 -1
  86. package/build/production/shared/utils/index.js.map +1 -1
  87. package/build/production/shared/utils/jest/index.js +10 -3
  88. package/build/production/shared/utils/jest/index.js.map +1 -1
  89. package/build/production/shared/utils/splitComponent.js +3 -10
  90. package/build/production/shared/utils/splitComponent.js.map +1 -1
  91. package/build/production/shared/utils/time.js +2 -2
  92. package/build/production/shared/utils/time.js.map +1 -1
  93. package/build/types-code/index.d.ts +2 -2
  94. package/build/types-code/shared/utils/globalState.d.ts +2 -2
  95. package/build/types-code/shared/utils/index.d.ts +2 -2
  96. package/build/types-code/shared/utils/splitComponent.d.ts +1 -0
  97. package/build/web/client/index.js +2 -2
  98. package/build/web/client/index.js.map +1 -1
  99. package/build/web/index.js +1 -1
  100. package/build/web/index.js.map +1 -1
  101. package/build/web/shared/components/Button/index.js +2 -13
  102. package/build/web/shared/components/Button/index.js.map +1 -1
  103. package/build/web/shared/components/Checkbox/index.js +1 -1
  104. package/build/web/shared/components/Checkbox/index.js.map +1 -1
  105. package/build/web/shared/components/GenericLink/index.js +2 -15
  106. package/build/web/shared/components/GenericLink/index.js.map +1 -1
  107. package/build/web/shared/components/Input/index.js +2 -11
  108. package/build/web/shared/components/Input/index.js.map +1 -1
  109. package/build/web/shared/components/Link.js +2 -4
  110. package/build/web/shared/components/Link.js.map +1 -1
  111. package/build/web/shared/components/Modal/index.js +2 -10
  112. package/build/web/shared/components/Modal/index.js.map +1 -1
  113. package/build/web/shared/components/NavLink.js +1 -4
  114. package/build/web/shared/components/NavLink.js.map +1 -1
  115. package/build/web/shared/components/PageLayout/index.js +2 -2
  116. package/build/web/shared/components/PageLayout/index.js.map +1 -1
  117. package/build/web/shared/components/TextArea/index.js +1 -21
  118. package/build/web/shared/components/TextArea/index.js.map +1 -1
  119. package/build/web/shared/components/Throbber/index.js +2 -2
  120. package/build/web/shared/components/Throbber/index.js.map +1 -1
  121. package/build/web/shared/components/WithTooltip/Tooltip.js +2 -7
  122. package/build/web/shared/components/WithTooltip/Tooltip.js.map +1 -1
  123. package/build/web/shared/components/WithTooltip/index.js +3 -3
  124. package/build/web/shared/components/WithTooltip/index.js.map +1 -1
  125. package/build/web/shared/components/YouTubeVideo/index.js +2 -5
  126. package/build/web/shared/components/YouTubeVideo/index.js.map +1 -1
  127. package/build/web/shared/components/selectors/CustomDropdown/Options/index.js +1 -6
  128. package/build/web/shared/components/selectors/CustomDropdown/Options/index.js.map +1 -1
  129. package/build/web/shared/components/selectors/CustomDropdown/index.js +1 -7
  130. package/build/web/shared/components/selectors/CustomDropdown/index.js.map +1 -1
  131. package/build/web/shared/components/selectors/Switch/index.js +1 -1
  132. package/build/web/shared/components/selectors/Switch/index.js.map +1 -1
  133. package/build/web/shared/utils/globalState.js +1 -1
  134. package/build/web/shared/utils/globalState.js.map +1 -1
  135. package/build/web/shared/utils/index.js +1 -1
  136. package/build/web/shared/utils/index.js.map +1 -1
  137. package/build/web/shared/utils/jest/index.js +10 -3
  138. package/build/web/shared/utils/jest/index.js.map +1 -1
  139. package/build/web/shared/utils/splitComponent.js +3 -10
  140. package/build/web/shared/utils/splitComponent.js.map +1 -1
  141. package/build/web/shared/utils/time.js +2 -2
  142. package/build/web/shared/utils/time.js.map +1 -1
  143. package/config/babel/webpack.d.ts +1 -0
  144. package/config/babel/webpack.js +10 -12
  145. package/package.json +6 -4
@@ -1,18 +1,9 @@
1
- import{useRef,useState}from"react";import{useTheme}from"@dr.pogodin/react-themes";import defaultTheme from"./theme.scss";import{jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";/**
1
+ import{c as _c}from"react/compiler-runtime";import{useRef,useState}from"react";import{useTheme}from"@dr.pogodin/react-themes";import defaultTheme from"./theme.scss";import{jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";/**
2
2
  * Themeable input field, based on the standard HTML `<input>` element.
3
3
  * @param [props.label] Input label.
4
4
  * @param [props.theme] _Ad hoc_ theme.
5
5
  * @param [props...] [Other theming properties](https://www.npmjs.com/package/@dr.pogodin/react-themes#themed-component-properties)
6
6
  * @param [props...] Any other properties are passed to the underlying
7
7
  * `<input>` element.
8
- */const Input=({children,composeAdhocTheme,error,label,ref,testId,theme,...rest})=>{const composed=useTheme("Input",defaultTheme,theme,{composeAdhocTheme});// NOTE: As of now, it is only updated when "theme.focused" is defined,
9
- // as otherwise its value is not used.
10
- const[focused,setFocused]=useState(false);const localRef=useRef(null);let containerClassName=composed.container;// NOTE: As of now, "focused" can be true only when "theme.focused"
11
- // is provided.
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
- // we need a more complex logic to cover that case, but for now this serves
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.
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;
8
+ */const Input=t0=>{const $=_c(42);let children;let composeAdhocTheme;let error;let label;let ref;let rest;let testId;let theme;if($[0]!==t0){({children,composeAdhocTheme,error,label,ref,testId,theme,...rest}=t0);$[0]=t0;$[1]=children;$[2]=composeAdhocTheme;$[3]=error;$[4]=label;$[5]=ref;$[6]=rest;$[7]=testId;$[8]=theme}else{children=$[1];composeAdhocTheme=$[2];error=$[3];label=$[4];ref=$[5];rest=$[6];testId=$[7];theme=$[8]}let t1;if($[9]!==composeAdhocTheme){t1={composeAdhocTheme};$[9]=composeAdhocTheme;$[10]=t1}else{t1=$[10]}const composed=useTheme("Input",defaultTheme,theme,t1);const[focused,setFocused]=useState(false);const localRef=useRef(null);let containerClassName=composed.container;if(focused){containerClassName=containerClassName+` ${composed.focused}`;}if(!rest.value&&composed.empty){containerClassName=containerClassName+` ${composed.empty}`;}if(error){containerClassName=containerClassName+` ${composed.error}`;}let t2;if($[11]!==ref){t2=()=>{if(typeof ref==="object"){ref?.current?.focus()}else{localRef.current?.focus()}};$[11]=ref;$[12]=t2}else{t2=$[12]}let t3;if($[13]!==composed.label||$[14]!==label){t3=label===undefined?null:/*#__PURE__*/_jsx("div",{className:composed.label,children:label});$[13]=composed.label;$[14]=label;$[15]=t3}else{t3=$[15]}const t4=process.env.NODE_ENV==="production"?undefined:testId;const t5=ref??localRef;let t6;if($[16]!==composed.focused||$[17]!==rest){t6=composed.focused?e=>{setFocused(false);rest.onBlur?.(e)}:rest.onBlur;$[16]=composed.focused;$[17]=rest;$[18]=t6}else{t6=$[18]}let t7;if($[19]!==composed.focused||$[20]!==rest){t7=composed.focused?e_0=>{setFocused(true);rest.onFocus?.(e_0)}:rest.onFocus;$[19]=composed.focused;$[20]=rest;$[21]=t7}else{t7=$[21]}let t8;if($[22]!==composed.input||$[23]!==rest||$[24]!==t4||$[25]!==t5||$[26]!==t6||$[27]!==t7){t8=/*#__PURE__*/_jsx("input",{className:composed.input,"data-testid":t4,ref:t5,...rest,onBlur:t6,onFocus:t7});$[22]=composed.input;$[23]=rest;$[24]=t4;$[25]=t5;$[26]=t6;$[27]=t7;$[28]=t8}else{t8=$[28]}let t9;if($[29]!==composed.errorMessage||$[30]!==error){t9=error&&error!==true?/*#__PURE__*/_jsx("div",{className:composed.errorMessage,children:error}):null;$[29]=composed.errorMessage;$[30]=error;$[31]=t9}else{t9=$[31]}let t10;if($[32]!==children||$[33]!==composed.children){t10=children?/*#__PURE__*/_jsx("div",{className:composed.children,children:children}):null;$[32]=children;$[33]=composed.children;$[34]=t10}else{t10=$[34]}let t11;if($[35]!==containerClassName||$[36]!==t10||$[37]!==t2||$[38]!==t3||$[39]!==t8||$[40]!==t9){t11=/*#__PURE__*/_jsxs("div",{className:containerClassName,onFocus:t2,children:[t3,t8,t9,t10]});$[35]=containerClassName;$[36]=t10;$[37]=t2;$[38]=t3;$[39]=t8;$[40]=t9;$[41]=t11}else{t11=$[41]}return t11};export default Input;
18
9
  //# 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,CAE7E,MAAO,CAAAC,YAAY,oBAAqB,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,IA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QAAA,CAAEA,QAAQ,CAAM,CAAC,CAAG,IAAI,EACnE,CAAC,CAEV,CAAC,CAED,cAAe,CAAAD,KAAK","ignoreList":[]}
1
+ {"version":3,"file":"index.js","names":["useRef","useState","useTheme","defaultTheme","jsx","_jsx","jsxs","_jsxs","Input","t0","$","_c","children","composeAdhocTheme","error","label","ref","rest","testId","theme","t1","composed","focused","setFocused","localRef","containerClassName","container","value","empty","t2","current","focus","t3","undefined","className","t4","process","env","NODE_ENV","t5","t6","e","onBlur","t7","e_0","onFocus","t8","input","t9","errorMessage","t10","t11"],"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":"4CAAA,OAIEA,MAAM,CACNC,QAAQ,KACH,OAAO,CAEd,OAAmCC,QAAQ,KAAQ,0BAA0B,CAE7E,MAAO,CAAAC,YAAY,oBAAqB,OAAAC,GAAA,IAAAC,IAAA,CAAAC,IAAA,IAAAC,KAAA,yBAexC;AACA;AACA;AACA;AACA;AACA;AACA;AACA,GACA,KAAM,CAAAC,KAAgC,CAAGC,EAAA,SAAAC,CAAA,CAAAC,EAAA,SAAAC,QAAA,KAAAC,iBAAA,KAAAC,KAAA,KAAAC,KAAA,KAAAC,GAAA,KAAAC,IAAA,KAAAC,MAAA,KAAAC,KAAA,IAAAT,CAAA,MAAAD,EAAA,EAAC,EAAAG,QAAA,CAAAC,iBAAA,CAAAC,KAAA,CAAAC,KAAA,CAAAC,GAAA,CAAAE,MAAA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C,CAAA,SAAAwC,GAAA,IAAAxC,CAAA,OAAAE,QAAA,EAAAF,CAAA,OAAAW,QAAA,CAAAT,QAAA,EACPsC,GAAA,CAAAtC,QAAQ,cAARP,IAAA,QAA2B6B,SAAiB,CAAjBb,QAAQ,CAAAT,QAAS,CAAAA,QAAA,CAAGA,QAAQ,CAAa,CAAC,CAArE,IAAqE,CAAAF,CAAA,KAAAE,QAAAF,CAAA,MAAAW,QAAA,CAAAT,QAAAF,CAAA,MAAAwC,GAAA,MAAAA,GAAA,CAAAxC,CAAA,SAAAyC,GAAA,IAAAzC,CAAA,OAAAe,kBAAA,EAAAf,CAAA,OAAAwC,GAAA,EAAAxC,CAAA,OAAAmB,EAAA,EAAAnB,CAAA,OAAAsB,EAAA,EAAAtB,CAAA,OAAAoC,EAAA,EAAApC,CAAA,OAAAsC,EAAA,EAjCxEG,GAAA,cAAA5C,KAAA,QACakB,SAAkB,CAAlBA,kBAAkB,CACpBoB,OAMR,CANQhB,EAMR,CAAAjB,QAAA,EAEAoB,EACuD,CACxDc,EAiBE,CACDE,EAEO,CACPE,GAAqE,EACnE,CAAC,CAAAxC,CAAA,KAAAe,kBAAAf,CAAA,MAAAwC,GAAAxC,CAAA,MAAAmB,EAAAnB,CAAA,MAAAsB,EAAAtB,CAAA,MAAAoC,EAAApC,CAAA,MAAAsC,EAAAtC,CAAA,MAAAyC,GAAA,MAAAA,GAAA,CAAAzC,CAAA,WAlCN,CAAAyC,GAkCM,CAET,CAED,cAAe,CAAA3C,KAAK","ignoreList":[]}
@@ -1,10 +1,8 @@
1
- /**
1
+ import{c as _c}from"react/compiler-runtime";/**
2
2
  * The Link wraps around React Router's Link component, to automatically replace
3
3
  * it by the regular <a> element when:
4
4
  * - The target reference points to another domain;
5
5
  * - User opts to open the reference in a new tab;
6
6
  * - User explicitely opts to use <a>.
7
- */import{Link as RrLink}from"react-router";import GenericLink from"./GenericLink";import{jsx as _jsx}from"react/jsx-runtime";const Link=props=>/*#__PURE__*/_jsx(GenericLink// TODO: Avoid the spreading later.
8
- // eslint-disable-next-line react/jsx-props-no-spreading
9
- ,{...props,routerLinkType:RrLink});export default Link;
7
+ */import{Link as RrLink}from"react-router";import GenericLink from"./GenericLink";import{jsx as _jsx}from"react/jsx-runtime";const Link=props=>{const $=_c(2);let t0;if($[0]!==props){t0=/*#__PURE__*/_jsx(GenericLink,{...props,routerLinkType:RrLink});$[0]=props;$[1]=t0}else{t0=$[1]}return t0};export default Link;
10
8
  //# sourceMappingURL=Link.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"Link.js","names":["Link","RrLink","GenericLink","jsx","_jsx","props","routerLinkType"],"sources":["../../../../src/shared/components/Link.tsx"],"sourcesContent":["/**\n * The Link wraps around React Router's Link component, to automatically replace\n * it by the regular <a> element when:\n * - The target reference points to another domain;\n * - User opts to open the reference in a new tab;\n * - User explicitely opts to use <a>.\n */\n\nimport { type LinkProps, Link as RrLink } from 'react-router';\n\nimport GenericLink, { type PropsT as GenericLinkPropsT } from './GenericLink';\n\ntype PropsT = LinkProps & Omit<GenericLinkPropsT, 'routerLinkType'>;\n\nconst Link: React.FunctionComponent<PropsT>\n = (props) => (\n <GenericLink\n // TODO: Avoid the spreading later.\n // eslint-disable-next-line react/jsx-props-no-spreading\n {...props}\n routerLinkType={RrLink}\n />\n );\n\nexport default Link;\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA,GAEA,OAAyBA,IAAI,GAAI,CAAAC,MAAM,KAAQ,cAAc,CAE7D,MAAO,CAAAC,WAAW,qBAA4D,OAAAC,GAAA,IAAAC,IAAA,yBAI9E,KAAM,CAAAJ,IAAqC,CACtCK,KAAK,eACND,IAAA,CAACF,WACC;AACA;AAAA,KACIG,KAAK,CACTC,cAAc,CAAEL,MAAO,CACxB,CACF,CAEH,cAAe,CAAAD,IAAI","ignoreList":[]}
1
+ {"version":3,"file":"Link.js","names":["Link","RrLink","GenericLink","jsx","_jsx","props","$","_c","t0"],"sources":["../../../../src/shared/components/Link.tsx"],"sourcesContent":["/**\n * The Link wraps around React Router's Link component, to automatically replace\n * it by the regular <a> element when:\n * - The target reference points to another domain;\n * - User opts to open the reference in a new tab;\n * - User explicitely opts to use <a>.\n */\n\nimport { type LinkProps, Link as RrLink } from 'react-router';\n\nimport GenericLink, { type PropsT as GenericLinkPropsT } from './GenericLink';\n\ntype PropsT = LinkProps & Omit<GenericLinkPropsT, 'routerLinkType'>;\n\nconst Link: React.FunctionComponent<PropsT>\n = (props) => (\n <GenericLink\n // TODO: Avoid the spreading later.\n // eslint-disable-next-line react/jsx-props-no-spreading\n {...props}\n routerLinkType={RrLink}\n />\n );\n\nexport default Link;\n"],"mappings":"4CAAA;AACA;AACA;AACA;AACA;AACA;AACA,GAEA,OAAyBA,IAAI,GAAI,CAAAC,MAAM,KAAQ,cAAc,CAE7D,MAAO,CAAAC,WAAW,qBAA4D,OAAAC,GAAA,IAAAC,IAAA,yBAI9E,KAAM,CAAAJ,IAAqC,CACvCK,KAAA,SAAAC,CAAA,CAAAC,EAAA,QAAAC,EAAA,IAAAF,CAAA,MAAAD,KAAA,EACAG,EAAA,cAAAJ,IAAA,CAACF,WAAW,KAGNG,KAAK,CACOJ,cAAM,CAANA,MAAM,CACvB,CAAC,CAAAK,CAAA,IAAAD,KAAAC,CAAA,KAAAE,EAAA,MAAAA,EAAA,CAAAF,CAAA,UALF,CAAAE,EAKE,CACH,CAEH,cAAe,CAAAR,IAAI","ignoreList":[]}
@@ -1,4 +1,4 @@
1
- import{useEffect,useMemo,useRef}from"react";import{createPortal}from"react-dom";import{useTheme}from"@dr.pogodin/react-themes";import defaultTheme from"./base-theme.scss";import S from"./styles.scss";import{jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";/**
1
+ import{c as _c}from"react/compiler-runtime";import{useEffect,useMemo,useRef}from"react";import{createPortal}from"react-dom";import{useTheme}from"@dr.pogodin/react-themes";import defaultTheme from"./base-theme.scss";import S from"./styles.scss";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.
@@ -8,13 +8,5 @@ import{useEffect,useMemo,useRef}from"react";import{createPortal}from"react-dom";
8
8
  * clicks outside the modal, or presses Escape. It is expected to hide the
9
9
  * modal.
10
10
  * @param {ModalTheme} [props.theme] _Ad hoc_ theme.
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.
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.
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;
11
+ */const BaseModal=t0=>{const $=_c(27);const{cancelOnScrolling,children,containerStyle,dontDisableScrolling,onCancel,overlayStyle,style,testId,testIdForOverlay,theme}=t0;const containerRef=useRef(null);const overlayRef=useRef(null);let t1;let t2;if($[0]!==cancelOnScrolling||$[1]!==onCancel){t1=()=>{if(cancelOnScrolling&&onCancel){window.addEventListener("scroll",onCancel);window.addEventListener("wheel",onCancel)}return()=>{if(cancelOnScrolling&&onCancel){window.removeEventListener("scroll",onCancel);window.removeEventListener("wheel",onCancel)}}};t2=[cancelOnScrolling,onCancel];$[0]=cancelOnScrolling;$[1]=onCancel;$[2]=t1;$[3]=t2}else{t1=$[2];t2=$[3]}useEffect(t1,t2);let t3;let t4;if($[4]!==dontDisableScrolling){t3=()=>{if(!dontDisableScrolling){document.body.classList.add(S.scrollingDisabledByModal)}return()=>{if(!dontDisableScrolling){document.body.classList.remove(S.scrollingDisabledByModal)}}};t4=[dontDisableScrolling];$[4]=dontDisableScrolling;$[5]=t3;$[6]=t4}else{t3=$[5];t4=$[6]}useEffect(t3,t4);let t5;if($[7]===Symbol.for("react.memo_cache_sentinel")){t5=/*#__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()},tabIndex:0});$[7]=t5}else{t5=$[7]}const focusLast=t5;const t6=process.env.NODE_ENV==="production"?undefined:testIdForOverlay;let t7;let t8;if($[8]!==onCancel){t7=e=>{if(onCancel){onCancel();e.stopPropagation()}};t8=e_0=>{if(e_0.key==="Escape"&&onCancel){onCancel();e_0.stopPropagation()}};$[8]=onCancel;$[9]=t7;$[10]=t8}else{t7=$[9];t8=$[10]}let t9;if($[11]===Symbol.for("react.memo_cache_sentinel")){t9=node=>{if(node&&node!==overlayRef.current){overlayRef.current=node;node.focus()}};$[11]=t9}else{t9=$[11]}let t10;if($[12]!==overlayStyle||$[13]!==t6||$[14]!==t7||$[15]!==t8||$[16]!==theme.overlay){t10=/*#__PURE__*/_jsx("div",{"aria-label":"Cancel",className:theme.overlay,"data-testid":t6,onClick:t7,onKeyDown:t8,ref:t9,role:"button",style:overlayStyle,tabIndex:0});$[12]=overlayStyle;$[13]=t6;$[14]=t7;$[15]=t8;$[16]=theme.overlay;$[17]=t10}else{t10=$[17]}const t11=process.env.NODE_ENV==="production"?undefined:testId;const t12=style??containerStyle;let t13;if($[18]!==children||$[19]!==t11||$[20]!==t12||$[21]!==theme.container){t13=/*#__PURE__*/_jsx("div",{"aria-modal":"true",className:theme.container,"data-testid":t11,onClick:_temp,onWheel:_temp2,ref:containerRef,role:"dialog",style:t12,children:children});$[18]=children;$[19]=t11;$[20]=t12;$[21]=theme.container;$[22]=t13}else{t13=$[22]}let t14;if($[23]===Symbol.for("react.memo_cache_sentinel")){t14=/*#__PURE__*/_jsx("div",{onFocus:()=>{overlayRef.current?.focus()},tabIndex:0});$[23]=t14}else{t14=$[23]}let t15;if($[24]!==t10||$[25]!==t13){t15=/*#__PURE__*/createPortal(/*#__PURE__*/_jsxs("div",{children:[focusLast,t10,t13,t14,focusLast]}),document.body);$[24]=t10;$[25]=t13;$[26]=t15}else{t15=$[26]}return t15};/* Non-themed version of the Modal. */export{BaseModal};const Modal=t0=>{const $=_c(6);let rest;let theme;if($[0]!==t0){({theme,...rest}=t0);$[0]=t0;$[1]=rest;$[2]=theme}else{rest=$[1];theme=$[2]}const composed=useTheme("Modal",defaultTheme,theme);let t1;if($[3]!==composed||$[4]!==rest){t1=/*#__PURE__*/_jsx(BaseModal,{...rest,theme:composed});$[3]=composed;$[4]=rest;$[5]=t1}else{t1=$[5]}return t1};export default Modal;function _temp(e_1){e_1.stopPropagation()}function _temp2(event){event.stopPropagation()}
20
12
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
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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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","t0","$","_c","cancelOnScrolling","children","containerStyle","dontDisableScrolling","onCancel","overlayStyle","style","testId","testIdForOverlay","theme","containerRef","overlayRef","t1","t2","window","addEventListener","removeEventListener","t3","t4","document","body","classList","add","scrollingDisabledByModal","remove","t5","Symbol","for","onFocus","elems","current","querySelectorAll","i","length","focus","activeElement","tabIndex","focusLast","t6","process","env","NODE_ENV","undefined","t7","t8","e","stopPropagation","e_0","key","t9","node","t10","overlay","className","onClick","onKeyDown","ref","role","t11","t12","t13","container","_temp","onWheel","_temp2","t14","t15","Modal","rest","composed","e_1","event"],"sources":["../../../../../src/shared/components/Modal/index.tsx"],"sourcesContent":["import {\n type CSSProperties,\n type FunctionComponent,\n type ReactNode,\n useEffect,\n useMemo,\n useRef,\n} from 'react';\n\nimport { createPortal } from 'react-dom';\n\nimport { type Theme, useTheme } from '@dr.pogodin/react-themes';\n\nimport defaultTheme from './base-theme.scss';\nimport S from './styles.scss';\n\ntype ThemeT = Theme<'container' | 'overlay'>;\n\ntype PropsT = {\n cancelOnScrolling?: boolean;\n children?: ReactNode;\n dontDisableScrolling?: boolean;\n onCancel?: () => void;\n overlayStyle?: CSSProperties;\n style?: CSSProperties;\n testId?: string;\n testIdForOverlay?: string;\n theme: ThemeT;\n\n /** @deprecated */\n containerStyle?: CSSProperties;\n};\n\n/**\n * The `<Modal>` component implements a simple themeable modal window, wrapped\n * into the default theme. `<BaseModal>` exposes the base non-themed component.\n * **Children:** Component children are rendered as the modal content.\n * @param {object} props Component properties. Beside props documented below,\n * [Other theming properties](https://www.npmjs.com/package/@dr.pogodin/react-themes#themed-component-properties) are supported as well.\n * @param {function} [props.onCancel] The callback to trigger when user\n * clicks outside the modal, or presses Escape. It is expected to hide the\n * modal.\n * @param {ModalTheme} [props.theme] _Ad hoc_ theme.\n */\nconst BaseModal: FunctionComponent<PropsT> = ({\n cancelOnScrolling,\n children,\n containerStyle,\n dontDisableScrolling,\n onCancel,\n overlayStyle,\n style,\n testId,\n testIdForOverlay,\n theme,\n}) => {\n const containerRef = useRef<HTMLDivElement | null>(null);\n const overlayRef = useRef<HTMLDivElement | null>(null);\n\n // Sets up modal cancellation of scrolling, if opted-in.\n useEffect(() => {\n if (cancelOnScrolling && onCancel) {\n window.addEventListener('scroll', onCancel);\n window.addEventListener('wheel', onCancel);\n }\n return () => {\n if (cancelOnScrolling && onCancel) {\n window.removeEventListener('scroll', onCancel);\n window.removeEventListener('wheel', onCancel);\n }\n };\n }, [cancelOnScrolling, onCancel]);\n\n // Disables window scrolling, if it is not opted-out.\n useEffect(() => {\n if (!dontDisableScrolling) {\n document.body.classList.add(S.scrollingDisabledByModal);\n }\n return () => {\n if (!dontDisableScrolling) {\n document.body.classList.remove(S.scrollingDisabledByModal);\n }\n };\n }, [dontDisableScrolling]);\n\n const focusLast = useMemo(() => (\n <div\n onFocus={() => {\n const elems = containerRef.current!.querySelectorAll('*');\n for (let i = elems.length - 1; i >= 0; --i) {\n (elems[i] as HTMLElement).focus();\n if (document.activeElement === elems[i]) return;\n }\n overlayRef.current?.focus();\n }}\n // TODO: Have a look at this later.\n // eslint-disable-next-line jsx-a11y/no-noninteractive-tabindex\n tabIndex={0}\n />\n ), []);\n\n return createPortal(\n (\n <div>\n {focusLast}\n <div\n aria-label=\"Cancel\"\n className={theme.overlay}\n data-testid={\n process.env.NODE_ENV === 'production'\n ? undefined : testIdForOverlay\n }\n onClick={(e) => {\n if (onCancel) {\n onCancel();\n e.stopPropagation();\n }\n }}\n onKeyDown={(e) => {\n if (e.key === 'Escape' && onCancel) {\n onCancel();\n e.stopPropagation();\n }\n }}\n ref={(node) => {\n if (node && node !== overlayRef.current) {\n overlayRef.current = node;\n node.focus();\n }\n }}\n role=\"button\"\n style={overlayStyle}\n tabIndex={0}\n />\n {\n // NOTE: These rules are disabled because our intention is to keep\n // the element non-interactive (thus not on the keyboard focus chain),\n // and it has `onClick` handler merely to stop propagation of click\n // events to its parent container. This is needed because, for example\n // when the modal is wrapped into an interactive element we don't want\n // any clicks inside the modal to bubble-up to that parent element\n // (because visually and logically the modal dialog does not belong\n // to its parent container, where it technically belongs from\n // the HTML mark-up perpective).\n }\n <div // eslint-disable-line jsx-a11y/click-events-have-key-events, jsx-a11y/no-noninteractive-element-interactions\n aria-modal=\"true\"\n className={theme.container}\n data-testid={process.env.NODE_ENV === 'production' ? undefined : testId}\n onClick={(e) => {\n e.stopPropagation();\n }}\n onWheel={(event) => {\n event.stopPropagation();\n }}\n ref={containerRef}\n role=\"dialog\"\n style={style ?? containerStyle}\n >\n {children}\n </div>\n <div\n onFocus={() => {\n overlayRef.current?.focus();\n }}\n // TODO: Have a look at this later.\n // eslint-disable-next-line jsx-a11y/no-noninteractive-tabindex\n tabIndex={0}\n />\n {focusLast}\n </div>\n ),\n document.body,\n );\n};\n\n/* Non-themed version of the Modal. */\nexport { BaseModal };\n\nconst Modal: FunctionComponent<\n Omit<PropsT, 'theme'> & { theme?: ThemeT }\n> = ({ theme, ...rest }) => {\n const composed = useTheme('Modal', defaultTheme, theme);\n\n // eslint-disable-next-line react/jsx-props-no-spreading\n return <BaseModal {...rest} theme={composed} />;\n};\n\nexport default Modal;\n"],"mappings":"4CAAA,OAIEA,SAAS,CACTC,OAAO,CACPC,MAAM,KACD,OAAO,CAEd,OAASC,YAAY,KAAQ,WAAW,CAExC,OAAqBC,QAAQ,KAAQ,0BAA0B,CAE/D,MAAO,CAAAC,YAAY,yBACnB,MAAO,CAAAC,CAAC,qBAAsB,OAAAC,GAAA,IAAAC,IAAA,CAAAC,IAAA,IAAAC,KAAA,yBAmB9B;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,GACA,KAAM,CAAAC,SAAoC,CAAGC,EAAA,SAAAC,CAAA,CAAAC,EAAA,KAAC,MAAAC,iBAAA,CAAA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GAAA,CAAApE,CAAA,WAxEM,CAAAoE,GAwEN,CACF,CAED,sCACA,OAAStE,SAAS,EAElB,KAAM,CAAAuE,KAEL,CAAGtE,EAAA,SAAAC,CAAA,CAAAC,EAAA,QAAAqE,IAAA,KAAA3D,KAAA,IAAAX,CAAA,MAAAD,EAAA,EAAC,EAAAY,KAAA,IAAA2D,IAAA,EAAAvE,EAAkB,EAAAC,CAAA,IAAAD,EAAAC,CAAA,KAAAsE,IAAAtE,CAAA,KAAAW,KAAA,MAAA2D,IAAA,CAAAtE,CAAA,GAAAW,CAAA,MAAAX,CAAA,IACrB,MAAAuE,QAAA,CAAiBhF,QAAQ,CAAC,OAAO,CAAEC,YAAY,CAAEmB,KAAK,CAAC,CAAC,IAAAG,EAAA,IAAAd,CAAA,MAAAuE,QAAA,EAAAvE,CAAA,MAAAsE,IAAA,EAGjDxD,EAAA,cAAAnB,IAAA,CAACG,SAAS,KAAKwE,IAAI,CAASC,KAAQ,CAARA,QAAQ,CAAG,CAAC,CAAAvE,CAAA,IAAAuE,QAAAvE,CAAA,KAAAsE,IAAAtE,CAAA,KAAAc,EAAA,MAAAA,EAAA,CAAAd,CAAA,UAAxC,CAAAc,EAAwC,CAChD,CAED,cAAe,CAAAuD,KAAK,CAhJyB,SAAAL,MAAAQ,GAAA,EA0GjCzB,GAAC,CAAAC,eAAgB,CAAC,CAAC,CA1Gc,SAAAkB,OAAAO,KAAA,EA6GjCA,KAAK,CAAAzB,eAAgB,CAAC,CAAC","ignoreList":[]}
@@ -1,5 +1,2 @@
1
- import{NavLink as RrNavLink}from"react-router";import GenericLink from"./GenericLink";import{jsx as _jsx}from"react/jsx-runtime";const NavLink=props=>/*#__PURE__*/_jsx(GenericLink// TODO: I guess, we better re-write it to avoid the props spreading,
2
- // but no need to spend time on it right now.
3
- // eslint-disable-next-line react/jsx-props-no-spreading
4
- ,{...props,routerLinkType:RrNavLink});export default NavLink;
1
+ import{c as _c}from"react/compiler-runtime";import{NavLink as RrNavLink}from"react-router";import GenericLink from"./GenericLink";import{jsx as _jsx}from"react/jsx-runtime";const NavLink=props=>{const $=_c(2);let t0;if($[0]!==props){t0=/*#__PURE__*/_jsx(GenericLink,{...props,routerLinkType:RrNavLink});$[0]=props;$[1]=t0}else{t0=$[1]}return t0};export default NavLink;
5
2
  //# sourceMappingURL=NavLink.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"NavLink.js","names":["NavLink","RrNavLink","GenericLink","jsx","_jsx","props","routerLinkType"],"sources":["../../../../src/shared/components/NavLink.tsx"],"sourcesContent":["import { type NavLinkProps, NavLink as RrNavLink } from 'react-router';\n\nimport GenericLink, { type PropsT as GenericLinkPropsT } from './GenericLink';\n\ntype PropsT = NavLinkProps & Omit<GenericLinkPropsT, 'routerLinkType'>;\n\nconst NavLink: React.FunctionComponent<PropsT>\n = (props) => (\n <GenericLink\n // TODO: I guess, we better re-write it to avoid the props spreading,\n // but no need to spend time on it right now.\n // eslint-disable-next-line react/jsx-props-no-spreading\n {...props}\n routerLinkType={RrNavLink}\n />\n );\n\nexport default NavLink;\n"],"mappings":"AAAA,OAA4BA,OAAO,GAAI,CAAAC,SAAS,KAAQ,cAAc,CAEtE,MAAO,CAAAC,WAAW,qBAA4D,OAAAC,GAAA,IAAAC,IAAA,yBAI9E,KAAM,CAAAJ,OAAwC,CACzCK,KAAK,eACND,IAAA,CAACF,WACC;AACA;AACA;AAAA,KACIG,KAAK,CACTC,cAAc,CAAEL,SAAU,CAC3B,CACF,CAEH,cAAe,CAAAD,OAAO","ignoreList":[]}
1
+ {"version":3,"file":"NavLink.js","names":["NavLink","RrNavLink","GenericLink","jsx","_jsx","props","$","_c","t0"],"sources":["../../../../src/shared/components/NavLink.tsx"],"sourcesContent":["import { type NavLinkProps, NavLink as RrNavLink } from 'react-router';\n\nimport GenericLink, { type PropsT as GenericLinkPropsT } from './GenericLink';\n\ntype PropsT = NavLinkProps & Omit<GenericLinkPropsT, 'routerLinkType'>;\n\nconst NavLink: React.FunctionComponent<PropsT>\n = (props) => (\n <GenericLink\n // TODO: I guess, we better re-write it to avoid the props spreading,\n // but no need to spend time on it right now.\n // eslint-disable-next-line react/jsx-props-no-spreading\n {...props}\n routerLinkType={RrNavLink}\n />\n );\n\nexport default NavLink;\n"],"mappings":"4CAAA,OAA4BA,OAAO,GAAI,CAAAC,SAAS,KAAQ,cAAc,CAEtE,MAAO,CAAAC,WAAW,qBAA4D,OAAAC,GAAA,IAAAC,IAAA,yBAI9E,KAAM,CAAAJ,OAAwC,CAC1CK,KAAA,SAAAC,CAAA,CAAAC,EAAA,QAAAC,EAAA,IAAAF,CAAA,MAAAD,KAAA,EACAG,EAAA,cAAAJ,IAAA,CAACF,WAAW,KAING,KAAK,CACOJ,cAAS,CAATA,SAAS,CAC1B,CAAC,CAAAK,CAAA,IAAAD,KAAAC,CAAA,KAAAE,EAAA,MAAAA,EAAA,CAAAF,CAAA,UANF,CAAAE,EAME,CACH,CAEH,cAAe,CAAAR,OAAO","ignoreList":[]}
@@ -1,4 +1,4 @@
1
- import{useTheme}from"@dr.pogodin/react-themes";import baseTheme from"./base-theme.scss";import{jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";/**
1
+ import{c as _c}from"react/compiler-runtime";import{useTheme}from"@dr.pogodin/react-themes";import baseTheme from"./base-theme.scss";import{jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";/**
2
2
  * Simple and themeable page layout. It keeps the main content centered in
3
3
  * a column of limited width, which fills entire viewport on small screens
4
4
  * (under `$screen-md = 1024px` size). At larger screens the column keeps
@@ -12,5 +12,5 @@ import{useTheme}from"@dr.pogodin/react-themes";import baseTheme from"./base-them
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=t0=>{const $=_c(20);const{children,leftSidePanelContent,rightSidePanelContent,theme}=t0;const composed=useTheme("PageLayout",baseTheme,theme);const t1=composed.container;let t2;if($[0]!==composed.leftSidePanel||$[1]!==composed.sidePanel){t2=[composed.sidePanel,composed.leftSidePanel];$[0]=composed.leftSidePanel;$[1]=composed.sidePanel;$[2]=t2}else{t2=$[2]}const t3=t2.join(" ");let t4;if($[3]!==leftSidePanelContent||$[4]!==t3){t4=/*#__PURE__*/_jsx("div",{className:t3,children:leftSidePanelContent});$[3]=leftSidePanelContent;$[4]=t3;$[5]=t4}else{t4=$[5]}let t5;if($[6]!==children||$[7]!==composed.mainPanel){t5=/*#__PURE__*/_jsx("div",{className:composed.mainPanel,children:children});$[6]=children;$[7]=composed.mainPanel;$[8]=t5}else{t5=$[8]}let t6;if($[9]!==composed.rightSidePanel||$[10]!==composed.sidePanel){t6=[composed.sidePanel,composed.rightSidePanel];$[9]=composed.rightSidePanel;$[10]=composed.sidePanel;$[11]=t6}else{t6=$[11]}const t7=t6.join(" ");let t8;if($[12]!==rightSidePanelContent||$[13]!==t7){t8=/*#__PURE__*/_jsx("div",{className:t7,children:rightSidePanelContent});$[12]=rightSidePanelContent;$[13]=t7;$[14]=t8}else{t8=$[14]}let t9;if($[15]!==composed.container||$[16]!==t4||$[17]!==t5||$[18]!==t8){t9=/*#__PURE__*/_jsxs("div",{className:t1,children:[t4,t5,t8]});$[15]=composed.container;$[16]=t4;$[17]=t5;$[18]=t8;$[19]=t9}else{t9=$[19]}return t9};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,CAE/D,MAAO,CAAAC,SAAS,yBAA0B,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
+ {"version":3,"file":"index.js","names":["useTheme","baseTheme","jsx","_jsx","jsxs","_jsxs","PageLayout","t0","$","_c","children","leftSidePanelContent","rightSidePanelContent","theme","composed","t1","container","t2","leftSidePanel","sidePanel","t3","join","t4","className","t5","mainPanel","t6","rightSidePanel","t7","t8","t9"],"sources":["../../../../../src/shared/components/PageLayout/index.tsx"],"sourcesContent":["import type { FunctionComponent, ReactNode } from 'react';\n\nimport { type Theme, useTheme } from '@dr.pogodin/react-themes';\n\nimport baseTheme from './base-theme.scss';\n\ntype ThemeKeyT = 'container' | 'leftSidePanel' | 'mainPanel' | 'rightSidePanel'\n | 'sidePanel';\n\ntype PropsT = {\n children?: ReactNode;\n leftSidePanelContent?: ReactNode;\n rightSidePanelContent?: ReactNode;\n theme?: Theme<ThemeKeyT>;\n};\n\n/**\n * Simple and themeable page layout. It keeps the main content centered in\n * a column of limited width, which fills entire viewport on small screens\n * (under `$screen-md = 1024px` size). At larger screens the column keeps\n * `$screen-md` size, and it is centered at the page, surrounded by side\n * panels, where additional content can be displayed.\n *\n * **Children:** Component children are rendered as the content of main panel.\n * @param {object} [props] Component properties.\n * @param {Node} [props.leftSidePanelContent] The content for left side panel.\n * @param {Node} [props.rightSidePanelContent] The content for right side panel.\n * @param {PageLayoutTheme} [props.theme] _Ad hoc_ theme.\n * @param {...any} [props....]\n * [Other theming properties](https://www.npmjs.com/package/@dr.pogodin/react-themes#themed-component-properties)\n */\nconst PageLayout: FunctionComponent<PropsT> = ({\n children,\n leftSidePanelContent,\n rightSidePanelContent,\n theme,\n}) => {\n const composed = useTheme('PageLayout', baseTheme, theme);\n return (\n <div className={composed.container}>\n <div className={[composed.sidePanel, composed.leftSidePanel].join(' ')}>\n {leftSidePanelContent}\n </div>\n <div className={composed.mainPanel}>\n {children}\n </div>\n <div className={[composed.sidePanel, composed.rightSidePanel].join(' ')}>\n {rightSidePanelContent}\n </div>\n </div>\n );\n};\n\nexport default PageLayout;\n"],"mappings":"4CAEA,OAAqBA,QAAQ,KAAQ,0BAA0B,CAE/D,MAAO,CAAAC,SAAS,yBAA0B,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,CAAGC,EAAA,SAAAC,CAAA,CAAAC,EAAA,KAAC,MAAAC,QAAA,CAAAC,oBAAA,CAAAC,qBAAA,CAAAC,KAAA,EAAAN,EAK9C,CACC,MAAAO,QAAA,CAAiBd,QAAQ,CAAC,YAAY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A,CAAAK,SAAAX,CAAA,MAAAkB,EAAA,MAAAA,EAAA,CAAAlB,CAAA,KAA7C,MAAAoB,EAAA,CAAAF,EAA6C,CAAAL,IAAK,CAAC,GAAG,CAAC,KAAAQ,EAAA,IAAArB,CAAA,OAAAI,qBAAA,EAAAJ,CAAA,OAAAoB,EAAA,EAAvEC,EAAA,cAAA1B,IAAA,QAAgBoB,SAAuD,CAAvDK,EAAuD,CAAAlB,QAAA,CACpEE,qBAAqB,CACnB,CAAC,CAAAJ,CAAA,KAAAI,qBAAAJ,CAAA,MAAAoB,EAAApB,CAAA,MAAAqB,EAAA,MAAAA,EAAA,CAAArB,CAAA,SAAAsB,EAAA,IAAAtB,CAAA,OAAAM,QAAA,CAAAE,SAAA,EAAAR,CAAA,OAAAc,EAAA,EAAAd,CAAA,OAAAgB,EAAA,EAAAhB,CAAA,OAAAqB,EAAA,EATRC,EAAA,cAAAzB,KAAA,QAAgBkB,SAAkB,CAAlBR,EAAkB,CAAAL,QAAA,EAChCY,EAEM,CACNE,EAEM,CACNK,EAEM,EACH,CAAC,CAAArB,CAAA,KAAAM,QAAA,CAAAE,SAAAR,CAAA,MAAAc,EAAAd,CAAA,MAAAgB,EAAAhB,CAAA,MAAAqB,EAAArB,CAAA,MAAAsB,EAAA,MAAAA,EAAA,CAAAtB,CAAA,WAVN,CAAAsB,EAUM,CAET,CAED,cAAe,CAAAxB,UAAU","ignoreList":[]}
@@ -1,22 +1,2 @@
1
- import{useEffect,useLayoutEffect,useRef,useState}from"react";import{useTheme}from"@dr.pogodin/react-themes";import defaultTheme from"./style.scss";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.
3
- //
4
- // NOTE: useLayoutEffect() instead of useEffect() makes difference here,
5
- // as it helps to avoid visible "content/height" jumps (i.e. with just
6
- // useEffect() it becomes visible how the content is modified first,
7
- // and then input height is incremented, if necessary).
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,
10
- // and it is used for text measurements, to implement auto-scaling
11
- // of the primary textarea's height.
12
- ,readOnly:true,ref:hiddenAreaRef// The "-1" value of "tabIndex" removes this hidden text area from
13
- // the tab-focus-chain.
14
- ,tabIndex:-1// NOTE: With empty string value ("") the scrolling height of this text
15
- // area is zero, thus collapsing <TextArea> height below the single line
16
- // input height. To avoid it we fallback to whitespace (" ") character
17
- // here.
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
- // manage it internally for the measurement / resizing functionality
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;
1
+ import{c as _c}from"react/compiler-runtime";import{useEffect,useLayoutEffect,useRef,useState}from"react";import{useTheme}from"@dr.pogodin/react-themes";import defaultTheme from"./style.scss";import{jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";const TextArea=t0=>{const $=_c(36);const{disabled,error,label,onBlur,onChange,onKeyDown,placeholder,testId,theme,value}=t0;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)}let t1;let t2;if($[0]===Symbol.for("react.memo_cache_sentinel")){t1=()=>{const el=hiddenAreaRef.current;if(!el){return}const cb=()=>{setHeight(el.scrollHeight)};const observer=new ResizeObserver(cb);observer.observe(el);return()=>{observer.disconnect()}};t2=[];$[0]=t1;$[1]=t2}else{t1=$[0];t2=$[1]}useEffect(t1,t2);let t3;if($[2]===Symbol.for("react.memo_cache_sentinel")){t3=()=>{const el_0=hiddenAreaRef.current;if(el_0){setHeight(el_0.scrollHeight)}};$[2]=t3}else{t3=$[2]}let t4;if($[3]!==localValue){t4=[localValue];$[3]=localValue;$[4]=t4}else{t4=$[4]}useLayoutEffect(t3,t4);let containerClassName=custom.container;if(error){containerClassName=containerClassName+` ${custom.error}`;}let t5;if($[5]===Symbol.for("react.memo_cache_sentinel")){t5=()=>{textAreaRef.current?.focus()};$[5]=t5}else{t5=$[5]}let t6;if($[6]!==custom.label||$[7]!==label){t6=label===undefined?null:/*#__PURE__*/_jsx("div",{className:custom.label,children:label});$[6]=custom.label;$[7]=label;$[8]=t6}else{t6=$[8]}const t7=`${custom.textarea} ${custom.hidden}`;const t8=localValue||" ";let t9;if($[9]!==t7||$[10]!==t8){t9=/*#__PURE__*/_jsx("textarea",{className:t7,readOnly:true,ref:hiddenAreaRef,tabIndex:-1,value:t8});$[9]=t7;$[10]=t8;$[11]=t9}else{t9=$[11]}const t10=process.env.NODE_ENV==="production"?undefined:testId;let t11;if($[12]!==onChange||$[13]!==value){t11=value===undefined?e=>{setLocalValue(e.target.value)}:onChange;$[12]=onChange;$[13]=value;$[14]=t11}else{t11=$[14]}let t12;if($[15]!==height){t12={height};$[15]=height;$[16]=t12}else{t12=$[16]}let t13;if($[17]!==custom.textarea||$[18]!==disabled||$[19]!==localValue||$[20]!==onBlur||$[21]!==onKeyDown||$[22]!==placeholder||$[23]!==t10||$[24]!==t11||$[25]!==t12){t13=/*#__PURE__*/_jsx("textarea",{className:custom.textarea,"data-testid":t10,disabled:disabled,onBlur:onBlur,onChange:t11,onKeyDown:onKeyDown,placeholder:placeholder,ref:textAreaRef,style:t12,value:localValue});$[17]=custom.textarea;$[18]=disabled;$[19]=localValue;$[20]=onBlur;$[21]=onKeyDown;$[22]=placeholder;$[23]=t10;$[24]=t11;$[25]=t12;$[26]=t13}else{t13=$[26]}let t14;if($[27]!==custom.errorMessage||$[28]!==error){t14=error&&error!==true?/*#__PURE__*/_jsx("div",{className:custom.errorMessage,children:error}):null;$[27]=custom.errorMessage;$[28]=error;$[29]=t14}else{t14=$[29]}let t15;if($[30]!==containerClassName||$[31]!==t13||$[32]!==t14||$[33]!==t6||$[34]!==t9){t15=/*#__PURE__*/_jsxs("div",{className:containerClassName,onFocus:t5,children:[t6,t9,t13,t14]});$[30]=containerClassName;$[31]=t13;$[32]=t14;$[33]=t6;$[34]=t9;$[35]=t15}else{t15=$[35]}return t15};export default TextArea;
22
2
  //# 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,CAE/D,MAAO,CAAAC,YAAY,oBAAqB,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,UA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reList":[]}
1
+ {"version":3,"file":"index.js","names":["useEffect","useLayoutEffect","useRef","useState","useTheme","defaultTheme","jsx","_jsx","jsxs","_jsxs","TextArea","t0","$","_c","disabled","error","label","onBlur","onChange","onKeyDown","placeholder","testId","theme","value","custom","hiddenAreaRef","height","setHeight","textAreaRef","localValue","setLocalValue","undefined","t1","t2","Symbol","for","el","current","cb","scrollHeight","observer","ResizeObserver","observe","disconnect","t3","el_0","t4","containerClassName","container","t5","focus","t6","className","children","t7","textarea","hidden","t8","t9","readOnly","tabIndex","t10","process","env","NODE_ENV","t11","e","target","t12","t13","style","t14","errorMessage","t15","onFocus"],"sources":["../../../../../src/shared/components/TextArea/index.tsx"],"sourcesContent":["import {\n type ChangeEventHandler,\n type FocusEventHandler,\n type FunctionComponent,\n type KeyboardEventHandler,\n type ReactNode,\n 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":"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AnC,CAAA,OAAAyD,GAAA,EAAAzD,CAAA,OAAA2D,GAAA,EAAA3D,CAAA,OAAAuC,EAAA,EAAAvC,CAAA,OAAA8C,EAAA,EAjDVe,GAAA,cAAAhE,KAAA,QACasC,SAAkB,CAAlBA,kBAAkB,CACpB2B,OAER,CAFQzB,EAER,CAAAI,QAAA,EAEAF,EAAwE,CACzEO,EAkBE,CACFW,GAoBE,CACDE,GAEO,EACL,CAAC,CAAA3D,CAAA,KAAAmC,kBAAAnC,CAAA,MAAAyD,GAAAzD,CAAA,MAAA2D,GAAA3D,CAAA,MAAAuC,EAAAvC,CAAA,MAAA8C,EAAA9C,CAAA,MAAA6D,GAAA,MAAAA,GAAA,CAAA7D,CAAA,WAlDN,CAAA6D,GAkDM,CAET,CAED,cAAe,CAAA/D,QAAQ","ignoreList":[]}
@@ -1,4 +1,4 @@
1
- import{useTheme}from"@dr.pogodin/react-themes";import defaultTheme from"./theme.scss";import{jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";/**
1
+ import{c as _c}from"react/compiler-runtime";import{useTheme}from"@dr.pogodin/react-themes";import defaultTheme from"./theme.scss";import{jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";/**
2
2
  * Throbber is an "action in progress" indicator, which renders
3
3
  * three bouncing circles as a simple pending activity indicator,
4
4
  * and can be further themed to a certain degree.
@@ -6,5 +6,5 @@ import{useTheme}from"@dr.pogodin/react-themes";import defaultTheme from"./theme.
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=t0=>{const $=_c(11);const{theme,themePriority}=t0;let t1;if($[0]!==themePriority){t1={themePriority};$[0]=themePriority;$[1]=t1}else{t1=$[1]}const custom=useTheme("Throbber",defaultTheme,theme,t1);let t2;let t3;let t4;if($[2]!==custom.circle){t2=/*#__PURE__*/_jsx("span",{className:custom.circle});t3=/*#__PURE__*/_jsx("span",{className:custom.circle});t4=/*#__PURE__*/_jsx("span",{className:custom.circle});$[2]=custom.circle;$[3]=t2;$[4]=t3;$[5]=t4}else{t2=$[3];t3=$[4];t4=$[5]}let t5;if($[6]!==custom.container||$[7]!==t2||$[8]!==t3||$[9]!==t4){t5=/*#__PURE__*/_jsxs("span",{className:custom.container,children:[t2,t3,t4]});$[6]=custom.container;$[7]=t2;$[8]=t3;$[9]=t4;$[10]=t5}else{t5=$[10]}return t5};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,CAE9E,MAAO,CAAAC,YAAY,oBAAqB,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":[]}
1
+ {"version":3,"file":"index.js","names":["useTheme","defaultTheme","jsx","_jsx","jsxs","_jsxs","Throbber","t0","$","_c","theme","themePriority","t1","custom","t2","t3","t4","circle","className","t5","container","children"],"sources":["../../../../../src/shared/components/Throbber/index.tsx"],"sourcesContent":["import type { FunctionComponent } from 'react';\n\nimport { type PRIORITY, type Theme, useTheme } from '@dr.pogodin/react-themes';\n\nimport defaultTheme from './theme.scss';\n\ntype ThemeKeyT = 'bouncing' | 'circle' | 'container';\n\ntype PropsT = {\n theme?: Theme<ThemeKeyT>;\n themePriority?: PRIORITY;\n};\n\n/**\n * Throbber is an \"action in progress\" indicator, which renders\n * three bouncing circles as a simple pending activity indicator,\n * and can be further themed to a certain degree.\n * @param {object} [props] Component properties.\n * @param {ThrobberTheme} [props.theme] _Ad hoc_ theme.\n * @param {...any} [props....]\n * [Other theming properties](https://www.npmjs.com/package/@dr.pogodin/react-themes#themed-component-properties)\n */\nconst Throbber: FunctionComponent<PropsT> = ({ theme, themePriority }) => {\n const custom = useTheme('Throbber', defaultTheme, theme, {\n themePriority,\n });\n\n return (\n <span className={custom.container}>\n <span className={custom.circle} />\n <span className={custom.circle} />\n <span className={custom.circle} />\n </span>\n );\n};\n\nexport default Throbber;\n"],"mappings":"4CAEA,OAAoCA,QAAQ,KAAQ,0BAA0B,CAE9E,MAAO,CAAAC,YAAY,oBAAqB,OAAAC,GAAA,IAAAC,IAAA,CAAAC,IAAA,IAAAC,KAAA,yBASxC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,GACA,KAAM,CAAAC,QAAmC,CAAGC,EAAA,SAAAC,CAAA,CAAAC,EAAA,KAAC,MAAAC,KAAA,CAAAC,aAAA,EAAAJ,EAAwB,KAAAK,EAAA,IAAAJ,CAAA,MAAAG,aAAA,EACVC,EAAA,EAAAD,aAEzD,CAAC,CAAAH,CAAA,IAAAG,aAAAH,CAAA,KAAAI,EAAA,MAAAA,EAAA,CAAAJ,CAAA,IAFD,MAAAK,MAAA,CAAeb,QAAQ,CAAC,UAAU,CAAEC,YAAY,CAAES,KAAK,CAAEE,EAExD,CAAC,CAAC,IAAAE,EAAA,KAAAC,EAAA,KAAAC,EAAA,IAAAR,CAAA,MAAAK,MAAA,CAAAI,MAAA,EAICH,EAAA,cAAAX,IAAA,SAAiBe,SAAa,CAAbL,MAAM,CAAAI,MAAO,CAAG,CAAC,CAClCF,EAAA,cAAAZ,IAAA,SAAiBe,SAAa,CAAbL,MAAM,CAAAI,MAAO,CAAG,CAAC,CAClCD,EAAA,cAAAb,IAAA,SAAiBe,SAAa,CAAbL,MAAM,CAAAI,MAAO,CAAG,CAAC,CAAAT,CAAA,IAAAK,MAAA,CAAAI,MAAAT,CAAA,KAAAM,EAAAN,CAAA,KAAAO,EAAAP,CAAA,KAAAQ,EAAA,MAAAF,EAAA,CAAAN,CAAA,GAAAO,CAAA,GAAAP,CAAA,GAAAQ,CAAA,GAAAR,CAAA,QAAAW,EAAA,IAAAX,CAAA,MAAAK,MAAA,CAAAO,SAAA,EAAAZ,CAAA,MAAAM,EAAA,EAAAN,CAAA,MAAAO,EAAA,EAAAP,CAAA,MAAAQ,EAAA,EAHpCG,EAAA,cAAAd,KAAA,SAAiBa,SAAgB,CAAhBL,MAAM,CAAAO,SAAU,CAAAC,QAAA,EAC/BP,EAAkC,CAClCC,EAAkC,CAClCC,EAAkC,EAC9B,CAAC,CAAAR,CAAA,IAAAK,MAAA,CAAAO,SAAAZ,CAAA,KAAAM,EAAAN,CAAA,KAAAO,EAAAP,CAAA,KAAAQ,EAAAR,CAAA,MAAAW,EAAA,MAAAA,EAAA,CAAAX,CAAA,WAJP,CAAAW,EAIO,CAEV,CAED,cAAe,CAAAb,QAAQ","ignoreList":[]}
@@ -1,4 +1,4 @@
1
- /**
1
+ import{c as _c}from"react/compiler-runtime";/**
2
2
  * The actual tooltip component. It is rendered outside the regular document
3
3
  * hierarchy, and with sub-components managed without React to achieve the best
4
4
  * performance during animation.
@@ -88,10 +88,5 @@ 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
92
- // at the client side, the <Tooltip> is fully mounted into DOM in the next
93
- // rendering cycles, and only then it can be correctly measured and positioned.
94
- // Thus, when we create the <Tooltip> we have to record its target positioning
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;
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=t0=>{const $=_c(11);const{children,ref,theme}=t0;const arrowRef=useRef(null);const containerRef=useRef(null);const contentRef=useRef(null);let t1;if($[0]===Symbol.for("react.memo_cache_sentinel")){t1=(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})};$[0]=t1}else{t1=$[0]}const pointTo=t1;let t2;if($[1]===Symbol.for("react.memo_cache_sentinel")){t2=()=>({pointTo});$[1]=t2}else{t2=$[1]}useImperativeHandle(ref,t2);let t3;if($[2]!==theme.arrow){t3=/*#__PURE__*/_jsx("div",{className:theme.arrow,ref:arrowRef});$[2]=theme.arrow;$[3]=t3}else{t3=$[3]}let t4;if($[4]!==children||$[5]!==theme.content){t4=/*#__PURE__*/_jsx("div",{className:theme.content,ref:contentRef,children:children});$[4]=children;$[5]=theme.content;$[6]=t4}else{t4=$[6]}let t5;if($[7]!==t3||$[8]!==t4||$[9]!==theme.container){t5=/*#__PURE__*/createPortal(/*#__PURE__*/_jsxs("div",{className:theme.container,ref:containerRef,children:[t3,t4]}),document.body);$[7]=t3;$[8]=t4;$[9]=theme.container;$[10]=t5}else{t5=$[10]}return t5};export default Tooltip;
97
92
  //# 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;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AAGxD,MAAM,CAAiB,IAAI,CAAC,CAC7C,KAAM,CAAAyD,YAAY,CAAGzD,MAAM,CAAiB,IAAI,CAAC,CACjD,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,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":[]}
1
+ {"version":3,"file":"Tooltip.js","names":["useImperativeHandle","useRef","createPortal","jsx","_jsx","jsxs","_jsxs","PLACEMENTS","ARROW_STYLE_DOWN","join","ARROW_STYLE_UP","calcTooltipRects","tooltip","arrow","getBoundingClientRect","container","calcViewportRect","scrollX","scrollY","window","documentElement","clientHeight","clientWidth","document","bottom","left","right","top","calcPositionAboveXY","x","y","tooltipRects","arrowX","width","arrowY","height","containerX","containerY","baseArrowStyle","setComponentPositions","pageX","pageY","placement","element","viewportRect","pos","Math","max","maxX","min","containerStyle","setAttribute","arrowStyle","Tooltip","t0","$","_c","children","ref","theme","arrowRef","containerRef","contentRef","t1","Symbol","for","current","Error","content","pointTo","t2","t3","className","t4","t5","body"],"sources":["../../../../../src/shared/components/WithTooltip/Tooltip.tsx"],"sourcesContent":["/**\n * The actual tooltip component. It is rendered outside the regular document\n * hierarchy, and with sub-components managed without React to achieve the best\n * performance during animation.\n */\n\nimport {\n type FunctionComponent,\n type ReactNode,\n type RefObject,\n useImperativeHandle,\n useRef,\n} from 'react';\n\nimport { createPortal } from 'react-dom';\n\nimport type { Theme } from '@dr.pogodin/react-themes';\n\n/**\n * Valid placements of the rendered tooltip. They will be overriden when\n * necessary to fit the tooltip within the viewport.\n */\nexport enum PLACEMENTS {\n ABOVE_CURSOR = 'ABOVE_CURSOR',\n ABOVE_ELEMENT = 'ABOVE_ELEMENT',\n BELOW_CURSOR = 'BELOW_CURSOR',\n BELOW_ELEMENT = 'BELOW_ELEMENT',\n}\n\nconst ARROW_STYLE_DOWN = [\n 'border-bottom-color:transparent',\n 'border-left-color:transparent',\n 'border-right-color:transparent',\n].join(';');\n\nconst ARROW_STYLE_UP = [\n 'border-top-color:transparent',\n 'border-left-color:transparent',\n 'border-right-color:transparent',\n].join(';');\n\ntype ComponentsT = {\n arrow: HTMLDivElement;\n container: HTMLDivElement;\n content: HTMLDivElement;\n};\n\nexport type ThemeKeysT = 'appearance' | 'arrow' | 'container' | 'content';\n\ntype TooltipThemeT = Theme<ThemeKeysT>;\n\ntype TooltipRectsT = {\n arrow: DOMRect;\n container: DOMRect;\n};\n\n/**\n * Generates bounding client rectangles for tooltip components.\n * @ignore\n * @param tooltip DOM references to the tooltip components.\n * @param tooltip.arrow\n * @param tooltip.container\n * @return Object holding tooltip rectangles in\n * two fields.\n */\nfunction calcTooltipRects(tooltip: ComponentsT): TooltipRectsT {\n return {\n arrow: tooltip.arrow.getBoundingClientRect(),\n container: tooltip.container.getBoundingClientRect(),\n };\n}\n\n/**\n * Calculates the document viewport size.\n * @ignore\n * @return {{x, y, width, height}}\n */\nfunction calcViewportRect() {\n const { scrollX, scrollY } = window;\n const { documentElement: { clientHeight, clientWidth } } = document;\n return {\n bottom: scrollY + clientHeight,\n left: scrollX,\n right: scrollX + clientWidth,\n top: scrollY,\n };\n}\n\n/**\n * Calculates tooltip and arrow positions for the placement just above\n * the cursor.\n * @ignore\n * @param {number} x Cursor page-x position.\n * @param {number} y Cursor page-y position.\n * @param {object} tooltipRects Bounding client rectangles of tooltip parts.\n * @param {object} tooltipRects.arrow\n * @param {object} tooltipRects.container\n * @return {object} Contains the following fields:\n * - {number} arrowX\n * - {number} arrowY\n * - {number} containerX\n * - {number} containerY\n * - {string} baseArrowStyle\n */\nfunction calcPositionAboveXY(\n x: number,\n y: number,\n tooltipRects: TooltipRectsT,\n) {\n const { arrow, container } = tooltipRects;\n return {\n arrowX: 0.5 * (container.width - arrow.width),\n arrowY: container.height,\n containerX: x - container.width / 2,\n containerY: y - container.height - arrow.height / 1.5,\n\n // TODO: Instead of already setting the base style here, we should\n // introduce a set of constants for arrow directions, which will help\n // to do checks dependant on the arrow direction.\n baseArrowStyle: ARROW_STYLE_DOWN,\n };\n}\n\n// const HIT = {\n// NONE: false,\n// LEFT: 'LEFT',\n// RIGHT: 'RIGHT',\n// TOP: 'TOP',\n// BOTTOM: 'BOTTOM',\n// };\n\n/**\n * Checks whether\n * @param {object} pos\n * @param {object} tooltipRects\n * @param {object} viewportRect\n * @return {HIT}\n */\n// function checkViewportFit(pos, tooltipRects, viewportRect) {\n// const { containerX, containerY } = pos;\n// if (containerX < viewportRect.left + 6) return HIT.LEFT;\n// if (containerX > viewportRect.right - 6) return HIT.RIGHT;\n// return HIT.NONE;\n// }\n\n/**\n * Shifts tooltip horizontally to fit into the viewport, while keeping\n * the arrow pointed to the XY point.\n * @param {number} x\n * @param {number} y\n * @param {object} pos\n * @param {number} pageXOffset\n * @param {number} pageXWidth\n */\n// function xPageFitCorrection(x, y, pos, pageXOffset, pageXWidth) {\n// if (pos.containerX < pageXOffset + 6) {\n// pos.containerX = pageXOffset + 6;\n// pos.arrowX = Math.max(6, pageX - containerX - arrowRect.width / 2);\n// } else {\n// const maxX = pageXOffset + docRect.width - containerRect.width - 6;\n// if (containerX > maxX) {\n// containerX = maxX;\n// arrowX = Math.min(\n// containerRect.width - 6,\n// pageX - containerX - arrowRect.width / 2,\n// );\n// }\n// }\n// }\n\n/**\n * Sets positions of tooltip components to point the tooltip to the specified\n * page point.\n * @ignore\n * @param pageX\n * @param pageY\n * @param placement\n * @param element DOM reference to the element wrapped by the tooltip.\n * @param tooltip\n * @param tooltip.arrow DOM reference to the tooltip arrow.\n * @param tooltip.container DOM reference to the tooltip container.\n */\nfunction setComponentPositions(\n pageX: number,\n pageY: number,\n placement: PLACEMENTS | undefined,\n element: HTMLElement | undefined,\n tooltip: ComponentsT,\n) {\n const tooltipRects = calcTooltipRects(tooltip);\n const viewportRect = calcViewportRect();\n\n /* Default container coords: tooltip at the top. */\n const pos = calcPositionAboveXY(pageX, pageY, tooltipRects);\n\n if (pos.containerX < viewportRect.left + 6) {\n pos.containerX = viewportRect.left + 6;\n pos.arrowX = Math.max(\n 6,\n pageX - pos.containerX - tooltipRects.arrow.width / 2,\n );\n } else {\n const maxX = viewportRect.right - 6 - tooltipRects.container.width;\n if (pos.containerX > maxX) {\n pos.containerX = maxX;\n pos.arrowX = Math.min(\n tooltipRects.container.width - 6,\n pageX - pos.containerX - tooltipRects.arrow.width / 2,\n );\n }\n }\n\n /* If tooltip has not enough space on top - make it bottom tooltip. */\n if (pos.containerY < viewportRect.top + 6) {\n pos.containerY += tooltipRects.container.height\n + 2 * tooltipRects.arrow.height;\n pos.arrowY -= tooltipRects.container.height\n + tooltipRects.arrow.height;\n pos.baseArrowStyle = ARROW_STYLE_UP;\n }\n\n const containerStyle = `left:${pos.containerX}px;top:${pos.containerY}px`;\n tooltip.container.setAttribute('style', containerStyle);\n\n const arrowStyle = `${pos.baseArrowStyle};left:${pos.arrowX}px;top:${pos.arrowY}px`;\n tooltip.arrow.setAttribute('style', arrowStyle);\n}\n\n/* The Tooltip component itself. */\nconst Tooltip: FunctionComponent<{\n children?: ReactNode;\n ref?: RefObject<unknown>;\n theme: TooltipThemeT;\n}> = ({ children, ref, theme }) => {\n // NOTE: The way it has to be implemented, for clean mounting and unmounting\n // at the client side, the <Tooltip> is fully mounted into DOM in the next\n // rendering cycles, and only then it can be correctly measured and positioned.\n // Thus, when we create the <Tooltip> we have to record its target positioning\n // details, and then apply them when it is created.\n\n const arrowRef = useRef<HTMLDivElement>(null);\n const containerRef = useRef<HTMLDivElement>(null);\n const contentRef = useRef<HTMLDivElement>(null);\n\n const pointTo = (\n pageX: number,\n pageY: number,\n placement: PLACEMENTS,\n element: HTMLElement,\n ) => {\n if (!arrowRef.current || !containerRef.current || !contentRef.current) {\n throw Error('Internal error');\n }\n\n setComponentPositions(pageX, pageY, placement, element, {\n arrow: arrowRef.current,\n container: containerRef.current,\n content: contentRef.current,\n });\n };\n useImperativeHandle(ref, () => ({ pointTo }));\n\n return createPortal(\n (\n <div className={theme.container} ref={containerRef}>\n <div className={theme.arrow} ref={arrowRef} />\n <div className={theme.content} ref={contentRef}>{children}</div>\n </div>\n ),\n document.body,\n );\n};\n\nexport default Tooltip;\n"],"mappings":"4CAAA;AACA;AACA;AACA;AACA,GAEA,OAIEA,mBAAmB,CACnBC,MAAM,KACD,OAAO,CAEd,OAASC,YAAY,KAAQ,WAAW,CAAC,OAAAC,GAAA,IAAAC,IAAA,CAAAC,IAAA,IAAAC,KAAA,yBAIzC;AACA;AACA;AACA,GACA,UAAY,CAAAC,UAAU,uBA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AAAE,QAAA,EAAAF,CAAA,MAAAI,KAAA,CAAAS,OAAA,EAC9CK,EAAA,cAAArE,IAAA,QAAgBoE,SAAa,CAAbb,KAAK,CAAAS,OAAQ,CAAON,GAAU,CAAVA,UAAU,CAAAL,QAAA,CAAGA,QAAQ,CAAM,CAAC,CAAAF,CAAA,IAAAE,QAAAF,CAAA,KAAAI,KAAA,CAAAS,OAAAb,CAAA,KAAAkB,EAAA,MAAAA,EAAA,CAAAlB,CAAA,QAAAmB,EAAA,IAAAnB,CAAA,MAAAgB,EAAA,EAAAhB,CAAA,MAAAkB,EAAA,EAAAlB,CAAA,MAAAI,KAAA,CAAA5C,SAAA,EAJ/D2D,EAAA,cAAAxE,YAAY,cAEfI,KAAA,QAAgBkE,SAAe,CAAfb,KAAK,CAAA5C,SAAU,CAAO8C,GAAY,CAAZA,YAAY,CAAAJ,QAAA,EAChDc,EAA8C,CAC9CE,EAAgE,EAC7D,CAAC,CAERlD,QAAQ,CAAAoD,IACV,CAAC,CAAApB,CAAA,IAAAgB,EAAAhB,CAAA,KAAAkB,EAAAlB,CAAA,KAAAI,KAAA,CAAA5C,SAAAwC,CAAA,MAAAmB,EAAA,MAAAA,EAAA,CAAAnB,CAAA,WARM,CAAAmB,EAQN,CACF,CAED,cAAe,CAAArB,OAAO","ignoreList":[]}
@@ -21,13 +21,13 @@ if(res.triggeredByTouch){res.timerId??=setTimeout(()=>{setHeap(p=>({...p,timerId
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){setHeap(prev=>{tooltipRef.current?.pointTo(prev.lastCursorX+window.scrollX,prev.lastCursorY+window.scrollY,placement,wrapperRef.current);return prev;});}const listener=()=>{setShowTooltip(false);};window.addEventListener("scroll",listener);return()=>{window.removeEventListener("scroll",listener);};}return undefined;},[placement,showTooltip,tip]);let container=custom.wrapper;if(classNameProp)container+=` ${classNameProp}`;useEffect(()=>{const listener=()=>{setShowTooltip(false);heap.triggeredByTouch=false;if(heap.timerId){clearTimeout(heap.timerId);heap.timerId=undefined;heap.triggeredByTouch=false;}};window.addEventListener("touchcancel",listener);window.addEventListener("touchend",listener);return()=>{window.removeEventListener("touchcancel",listener);window.removeEventListener("touchend",listener);};},[heap]);return/*#__PURE__*/_jsxs("div",{className:container,onClick:e=>{if(heap.timerId){clearTimeout(heap.timerId);setHeap({...heap,timerId:undefined,triggeredByTouch:false});}onClick?.(e);},onContextMenu:e=>{e.preventDefault();onContextMenu?.(e);},onMouseLeave:e=>{setShowTooltip(false);onMouseLeave?.(e);},onMouseMove:e=>{// NOTE: Because on touch devices mouse move events are still fired
24
+ if(tooltipRef.current){setHeap(prev_0=>{tooltipRef.current?.pointTo(prev_0.lastCursorX+window.scrollX,prev_0.lastCursorY+window.scrollY,placement,wrapperRef.current);return prev_0;});}const listener=()=>{setShowTooltip(false);};window.addEventListener("scroll",listener);return()=>{window.removeEventListener("scroll",listener);};}return undefined;},[placement,showTooltip,tip]);let container=custom.wrapper;if(classNameProp)container+=` ${classNameProp}`;useEffect(()=>{const listener_0=()=>{setShowTooltip(false);heap.triggeredByTouch=false;if(heap.timerId){clearTimeout(heap.timerId);heap.timerId=undefined;heap.triggeredByTouch=false;}};window.addEventListener("touchcancel",listener_0);window.addEventListener("touchend",listener_0);return()=>{window.removeEventListener("touchcancel",listener_0);window.removeEventListener("touchend",listener_0);};},[heap]);return/*#__PURE__*/_jsxs("div",{className:container,onClick:e=>{if(heap.timerId){clearTimeout(heap.timerId);setHeap({...heap,timerId:undefined,triggeredByTouch:false});}onClick?.(e);},onContextMenu:e_0=>{e_0.preventDefault();onContextMenu?.(e_0);},onMouseLeave:e_1=>{setShowTooltip(false);onMouseLeave?.(e_1);},onMouseMove:e_2=>{// NOTE: Because on touch devices mouse move events are still fired
25
25
  // after touch is released, to emulate mouse clicks for old websites.
26
26
  // If we don't ignore it here, the tooltip will appear after the touch
27
27
  // is released.
28
- if(!heap.ignoreMouseMove){updatePortalPosition(e.clientX,e.clientY);}onMouseMove?.(e);},onTouchStart:e=>{setHeap({...heap,ignoreMouseMove:true,triggeredByTouch:true});// TODO: I guess, it should be something more complex here,
28
+ if(!heap.ignoreMouseMove){updatePortalPosition(e_2.clientX,e_2.clientY);}onMouseMove?.(e_2);},onTouchStart:e_3=>{setHeap({...heap,ignoreMouseMove:true,triggeredByTouch:true});// TODO: I guess, it should be something more complex here,
29
29
  // to actually respond to the first / whatever touch we need.
30
- const touch=e.targetTouches.item(0);updatePortalPosition(touch.clientX,touch.clientY);onTouchStart?.(e);},ref:node=>{wrapperRef.current=node;// eslint-disable-next-line no-param-reassign
30
+ const touch=e_3.targetTouches.item(0);updatePortalPosition(touch.clientX,touch.clientY);onTouchStart?.(e_3);},ref:node=>{wrapperRef.current=node;// eslint-disable-next-line no-param-reassign
31
31
  if(ref)ref.current=node;},role:"presentation",style:style// eslint-disable-next-line react/jsx-props-no-spreading
32
32
  ,...htmlAttributes,children:[showTooltip&&tip!==null?/*#__PURE__*/_jsx(Tooltip,{ref:tooltipRef,theme:custom,children:tip}):null,children]});};const e=WithTooltip;e.PLACEMENTS=PLACEMENTS;export default e;
33
33
  //# sourceMappingURL=index.js.map