@dr.pogodin/react-utils 1.47.4 → 1.48.0

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 (129) hide show
  1. package/build/development/client/getInj.js +4 -0
  2. package/build/development/client/getInj.js.map +1 -1
  3. package/build/development/index.js +1 -1
  4. package/build/development/index.js.map +1 -1
  5. package/build/development/server/server.js +0 -1
  6. package/build/development/server/server.js.map +1 -1
  7. package/build/development/shared/components/Button/index.js +13 -9
  8. package/build/development/shared/components/Button/index.js.map +1 -1
  9. package/build/development/shared/components/Checkbox/index.js +8 -7
  10. package/build/development/shared/components/Checkbox/index.js.map +1 -1
  11. package/build/development/shared/components/Input/index.js +14 -12
  12. package/build/development/shared/components/Input/index.js.map +1 -1
  13. package/build/development/shared/components/Modal/index.js +15 -3
  14. package/build/development/shared/components/Modal/index.js.map +1 -1
  15. package/build/development/shared/components/PageLayout/index.js +18 -15
  16. package/build/development/shared/components/PageLayout/index.js.map +1 -1
  17. package/build/development/shared/components/TextArea/index.js +9 -8
  18. package/build/development/shared/components/TextArea/index.js.map +1 -1
  19. package/build/development/shared/components/Throbber/index.js +15 -12
  20. package/build/development/shared/components/Throbber/index.js.map +1 -1
  21. package/build/development/shared/components/WithTooltip/index.js +6 -6
  22. package/build/development/shared/components/WithTooltip/index.js.map +1 -1
  23. package/build/development/shared/components/YouTubeVideo/index.js +6 -5
  24. package/build/development/shared/components/YouTubeVideo/index.js.map +1 -1
  25. package/build/development/shared/components/selectors/CustomDropdown/index.js +13 -12
  26. package/build/development/shared/components/selectors/CustomDropdown/index.js.map +1 -1
  27. package/build/development/shared/components/selectors/NativeDropdown/index.js +11 -10
  28. package/build/development/shared/components/selectors/NativeDropdown/index.js.map +1 -1
  29. package/build/development/shared/components/selectors/Switch/index.js +9 -9
  30. package/build/development/shared/components/selectors/Switch/index.js.map +1 -1
  31. package/build/development/shared/components/selectors/common.js.map +1 -1
  32. package/build/development/shared/components/selectors/index.js +1 -1
  33. package/build/development/shared/components/selectors/index.js.map +1 -1
  34. package/build/development/shared/utils/index.js +2 -5
  35. package/build/development/shared/utils/index.js.map +1 -1
  36. package/build/development/shared/utils/jest/E2eSsrEnv.js +0 -1
  37. package/build/development/shared/utils/jest/E2eSsrEnv.js.map +1 -1
  38. package/build/production/client/getInj.js +2 -2
  39. package/build/production/client/getInj.js.map +1 -1
  40. package/build/production/index.js +1 -1
  41. package/build/production/index.js.map +1 -1
  42. package/build/production/server/server.js +1 -1
  43. package/build/production/server/server.js.map +1 -1
  44. package/build/production/shared/components/Button/index.js +3 -8
  45. package/build/production/shared/components/Button/index.js.map +1 -1
  46. package/build/production/shared/components/Checkbox/index.js +1 -1
  47. package/build/production/shared/components/Checkbox/index.js.map +1 -1
  48. package/build/production/shared/components/Input/index.js +6 -6
  49. package/build/production/shared/components/Input/index.js.map +1 -1
  50. package/build/production/shared/components/Modal/index.js +3 -2
  51. package/build/production/shared/components/Modal/index.js.map +1 -1
  52. package/build/production/shared/components/PageLayout/index.js +2 -2
  53. package/build/production/shared/components/PageLayout/index.js.map +1 -1
  54. package/build/production/shared/components/TextArea/index.js +4 -4
  55. package/build/production/shared/components/TextArea/index.js.map +1 -1
  56. package/build/production/shared/components/Throbber/index.js +2 -2
  57. package/build/production/shared/components/Throbber/index.js.map +1 -1
  58. package/build/production/shared/components/WithTooltip/index.js +3 -3
  59. package/build/production/shared/components/WithTooltip/index.js.map +1 -1
  60. package/build/production/shared/components/YouTubeVideo/index.js +4 -4
  61. package/build/production/shared/components/YouTubeVideo/index.js.map +1 -1
  62. package/build/production/shared/components/selectors/CustomDropdown/index.js +2 -2
  63. package/build/production/shared/components/selectors/CustomDropdown/index.js.map +1 -1
  64. package/build/production/shared/components/selectors/NativeDropdown/index.js +3 -3
  65. package/build/production/shared/components/selectors/NativeDropdown/index.js.map +1 -1
  66. package/build/production/shared/components/selectors/Switch/index.js +1 -1
  67. package/build/production/shared/components/selectors/Switch/index.js.map +1 -1
  68. package/build/production/shared/components/selectors/common.js.map +1 -1
  69. package/build/production/shared/components/selectors/index.js +1 -1
  70. package/build/production/shared/components/selectors/index.js.map +1 -1
  71. package/build/production/shared/utils/index.js +1 -1
  72. package/build/production/shared/utils/index.js.map +1 -1
  73. package/build/production/shared/utils/jest/E2eSsrEnv.js +1 -1
  74. package/build/production/shared/utils/jest/E2eSsrEnv.js.map +1 -1
  75. package/build/types-code/index.d.ts +1 -1
  76. package/build/types-code/shared/components/Button/index.d.ts +6 -10
  77. package/build/types-code/shared/components/Checkbox/index.d.ts +4 -3
  78. package/build/types-code/shared/components/Input/index.d.ts +12 -4
  79. package/build/types-code/shared/components/Modal/index.d.ts +6 -3
  80. package/build/types-code/shared/components/PageLayout/index.d.ts +19 -4
  81. package/build/types-code/shared/components/TextArea/index.d.ts +4 -4
  82. package/build/types-code/shared/components/Throbber/index.d.ts +13 -3
  83. package/build/types-code/shared/components/WithTooltip/index.d.ts +18 -4
  84. package/build/types-code/shared/components/YouTubeVideo/index.d.ts +20 -4
  85. package/build/types-code/shared/components/selectors/CustomDropdown/index.d.ts +3 -2
  86. package/build/types-code/shared/components/selectors/NativeDropdown/index.d.ts +22 -2
  87. package/build/types-code/shared/components/selectors/Switch/index.d.ts +7 -6
  88. package/build/types-code/shared/components/selectors/common.d.ts +2 -3
  89. package/build/types-code/shared/components/selectors/index.d.ts +2 -2
  90. package/build/types-code/shared/utils/index.d.ts +2 -7
  91. package/build/web/client/getInj.js +3 -0
  92. package/build/web/client/getInj.js.map +1 -1
  93. package/build/web/index.js +1 -1
  94. package/build/web/index.js.map +1 -1
  95. package/build/web/server/server.js +0 -1
  96. package/build/web/server/server.js.map +1 -1
  97. package/build/web/shared/components/Button/index.js +13 -9
  98. package/build/web/shared/components/Button/index.js.map +1 -1
  99. package/build/web/shared/components/Checkbox/index.js +8 -7
  100. package/build/web/shared/components/Checkbox/index.js.map +1 -1
  101. package/build/web/shared/components/Input/index.js +14 -12
  102. package/build/web/shared/components/Input/index.js.map +1 -1
  103. package/build/web/shared/components/Modal/index.js +15 -3
  104. package/build/web/shared/components/Modal/index.js.map +1 -1
  105. package/build/web/shared/components/PageLayout/index.js +18 -15
  106. package/build/web/shared/components/PageLayout/index.js.map +1 -1
  107. package/build/web/shared/components/TextArea/index.js +9 -8
  108. package/build/web/shared/components/TextArea/index.js.map +1 -1
  109. package/build/web/shared/components/Throbber/index.js +15 -12
  110. package/build/web/shared/components/Throbber/index.js.map +1 -1
  111. package/build/web/shared/components/WithTooltip/index.js +6 -6
  112. package/build/web/shared/components/WithTooltip/index.js.map +1 -1
  113. package/build/web/shared/components/YouTubeVideo/index.js +6 -5
  114. package/build/web/shared/components/YouTubeVideo/index.js.map +1 -1
  115. package/build/web/shared/components/selectors/CustomDropdown/index.js +13 -12
  116. package/build/web/shared/components/selectors/CustomDropdown/index.js.map +1 -1
  117. package/build/web/shared/components/selectors/NativeDropdown/index.js +11 -10
  118. package/build/web/shared/components/selectors/NativeDropdown/index.js.map +1 -1
  119. package/build/web/shared/components/selectors/Switch/index.js +9 -9
  120. package/build/web/shared/components/selectors/Switch/index.js.map +1 -1
  121. package/build/web/shared/components/selectors/common.js.map +1 -1
  122. package/build/web/shared/components/selectors/index.js +1 -1
  123. package/build/web/shared/components/selectors/index.js.map +1 -1
  124. package/build/web/shared/utils/index.js +2 -5
  125. package/build/web/shared/utils/index.js.map +1 -1
  126. package/build/web/shared/utils/jest/E2eSsrEnv.js +0 -1
  127. package/build/web/shared/utils/jest/E2eSsrEnv.js.map +1 -1
  128. package/config/babel/webpack.js +1 -1
  129. package/package.json +15 -15
@@ -1,4 +1,4 @@
1
- import themed from '@dr.pogodin/react-themes';
1
+ import { useTheme } from '@dr.pogodin/react-themes';
2
2
  import defaultTheme from "./theme.scss";
3
3
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
4
4
  /**
@@ -12,15 +12,18 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
12
12
  */
13
13
  const Throbber = ({
14
14
  theme
15
- }) => /*#__PURE__*/_jsxs("span", {
16
- className: theme.container,
17
- children: [/*#__PURE__*/_jsx("span", {
18
- className: theme.circle
19
- }), /*#__PURE__*/_jsx("span", {
20
- className: theme.circle
21
- }), /*#__PURE__*/_jsx("span", {
22
- className: theme.circle
23
- })]
24
- });
25
- export default /* #__PURE__ */themed(Throbber, 'Throbber', defaultTheme);
15
+ }) => {
16
+ const custom = useTheme('Throbber', defaultTheme, theme);
17
+ return /*#__PURE__*/_jsxs("span", {
18
+ className: custom.container,
19
+ children: [/*#__PURE__*/_jsx("span", {
20
+ className: custom.circle
21
+ }), /*#__PURE__*/_jsx("span", {
22
+ className: custom.circle
23
+ }), /*#__PURE__*/_jsx("span", {
24
+ className: custom.circle
25
+ })]
26
+ });
27
+ };
28
+ export default Throbber;
26
29
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":["themed","defaultTheme","jsx","_jsx","jsxs","_jsxs","Throbber","theme","className","container","children","circle"],"sources":["../../../../../src/shared/components/Throbber/index.tsx"],"sourcesContent":["import themed, { type Theme } 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};\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: React.FunctionComponent<PropsT> = ({ theme }) => (\n <span className={theme.container}>\n <span className={theme.circle} />\n <span className={theme.circle} />\n <span className={theme.circle} />\n </span>\n);\n\nexport default /* #__PURE__ */ themed(Throbber, 'Throbber', defaultTheme);\n"],"mappings":"AAAA,OAAOA,MAAM,MAAsB,0BAA0B;AAE7D,OAAOC,YAAY;AAAqB,SAAAC,GAAA,IAAAC,IAAA,EAAAC,IAAA,IAAAC,KAAA;AAQxC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAMC,QAAyC,GAAGA,CAAC;EAAEC;AAAM,CAAC,kBAC1DF,KAAA;EAAMG,SAAS,EAAED,KAAK,CAACE,SAAU;EAAAC,QAAA,gBAC/BP,IAAA;IAAMK,SAAS,EAAED,KAAK,CAACI;EAAO,CAAE,CAAC,eACjCR,IAAA;IAAMK,SAAS,EAAED,KAAK,CAACI;EAAO,CAAE,CAAC,eACjCR,IAAA;IAAMK,SAAS,EAAED,KAAK,CAACI;EAAO,CAAE,CAAC;AAAA,CAC7B,CACP;AAED,eAAe,eAAgBX,MAAM,CAACM,QAAQ,EAAE,UAAU,EAAEL,YAAY,CAAC","ignoreList":[]}
1
+ {"version":3,"file":"index.js","names":["useTheme","defaultTheme","jsx","_jsx","jsxs","_jsxs","Throbber","theme","custom","className","container","children","circle"],"sources":["../../../../../src/shared/components/Throbber/index.tsx"],"sourcesContent":["import type { FunctionComponent } from 'react';\n\nimport { 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};\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 }) => {\n const custom = useTheme('Throbber', defaultTheme, theme);\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,SAAqBA,QAAQ,QAAQ,0BAA0B;AAE/D,OAAOC,YAAY;AAAqB,SAAAC,GAAA,IAAAC,IAAA,EAAAC,IAAA,IAAAC,KAAA;AAQxC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAMC,QAAmC,GAAGA,CAAC;EAAEC;AAAM,CAAC,KAAK;EACzD,MAAMC,MAAM,GAAGR,QAAQ,CAAC,UAAU,EAAEC,YAAY,EAAEM,KAAK,CAAC;EAExD,oBACEF,KAAA;IAAMI,SAAS,EAAED,MAAM,CAACE,SAAU;IAAAC,QAAA,gBAChCR,IAAA;MAAMM,SAAS,EAAED,MAAM,CAACI;IAAO,CAAE,CAAC,eAClCT,IAAA;MAAMM,SAAS,EAAED,MAAM,CAACI;IAAO,CAAE,CAAC,eAClCT,IAAA;MAAMM,SAAS,EAAED,MAAM,CAACI;IAAO,CAAE,CAAC;EAAA,CAC9B,CAAC;AAEX,CAAC;AAED,eAAeN,QAAQ","ignoreList":[]}
@@ -1,7 +1,7 @@
1
1
  /* global window */
2
2
 
3
3
  import { useEffect, useRef, useState } from 'react';
4
- import themed from '@dr.pogodin/react-themes';
4
+ import { useTheme } from '@dr.pogodin/react-themes';
5
5
  import Tooltip, { PLACEMENTS } from "./Tooltip";
6
6
  import defaultTheme from "./default-theme.scss";
7
7
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
@@ -19,12 +19,13 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
19
19
  * _e.g._ a tooltip text. This will be the tooltip content.
20
20
  * @param {WithTooltipTheme} props.theme _Ad hoc_ theme.
21
21
  */
22
- const Wrapper = ({
22
+ const WithTooltip = ({
23
23
  children,
24
24
  placement = PLACEMENTS.ABOVE_CURSOR,
25
25
  tip,
26
26
  theme
27
27
  }) => {
28
+ const custom = useTheme('WithTooltip', defaultTheme, theme);
28
29
  const {
29
30
  current: heap
30
31
  } = useRef({
@@ -84,7 +85,7 @@ const Wrapper = ({
84
85
  return undefined;
85
86
  }, [heap.lastCursorX, heap.lastCursorY, placement, showTooltip, tip]);
86
87
  return /*#__PURE__*/_jsxs("div", {
87
- className: theme.wrapper,
88
+ className: custom.wrapper,
88
89
  onClick: () => {
89
90
  if (heap.timerId) {
90
91
  clearTimeout(heap.timerId);
@@ -105,13 +106,12 @@ const Wrapper = ({
105
106
  role: "presentation",
106
107
  children: [showTooltip && tip !== null ? /*#__PURE__*/_jsx(Tooltip, {
107
108
  ref: tooltipRef,
108
- theme: theme,
109
+ theme: custom,
109
110
  children: tip
110
111
  }) : null, children]
111
112
  });
112
113
  };
113
- const ThemedWrapper = /* #__PURE__ */themed(Wrapper, 'WithTooltip', defaultTheme);
114
- const e = ThemedWrapper;
114
+ const e = WithTooltip;
115
115
  e.PLACEMENTS = PLACEMENTS;
116
116
  export default e;
117
117
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":["useEffect","useRef","useState","themed","Tooltip","PLACEMENTS","defaultTheme","jsx","_jsx","jsxs","_jsxs","Wrapper","children","placement","ABOVE_CURSOR","tip","theme","current","heap","lastCursorX","lastCursorY","timerId","undefined","triggeredByTouch","tooltipRef","wrapperRef","showTooltip","setShowTooltip","updatePortalPosition","cursorX","cursorY","wrapperRect","getBoundingClientRect","left","right","top","bottom","pointTo","window","scrollX","scrollY","setTimeout","listener","addEventListener","removeEventListener","className","wrapper","onClick","clearTimeout","onMouseLeave","onMouseMove","e","clientX","clientY","onTouchStart","ref","role","ThemedWrapper"],"sources":["../../../../../src/shared/components/WithTooltip/index.tsx"],"sourcesContent":["/* global window */\n\nimport {\n type FunctionComponent,\n type ReactNode,\n useEffect,\n useRef,\n useState,\n} from 'react';\n\nimport themed, { type Theme } from '@dr.pogodin/react-themes';\n\nimport Tooltip, {\n type ThemeKeysT as TooltipThemeKeysT,\n PLACEMENTS,\n} from './Tooltip';\n\nimport defaultTheme from './default-theme.scss';\n\ntype PropsT = {\n children?: ReactNode;\n placement?: PLACEMENTS;\n tip?: ReactNode;\n theme: Theme<'wrapper' | TooltipThemeKeysT>;\n};\n\ntype TooltipRefT = {\n pointTo: (\n x: number,\n y: number,\n placement: PLACEMENTS,\n wrapperRef: HTMLDivElement,\n ) => void;\n};\n\ntype HeapT = {\n lastCursorX: number;\n lastCursorY: number;\n triggeredByTouch: boolean;\n timerId?: NodeJS.Timeout;\n};\n\n/**\n * Implements a simple to use and themeable tooltip component, _e.g._\n * ```js\n * <WithTooltip tip=\"This is example tooltip.\">\n * <p>Hover to see the tooltip.</p>\n * </WithTooltip>\n * ```\n * **Children:** Children are rendered in the place of `<WithTooltip>`,\n * and when hovered the tooltip is shown. By default the wrapper itself is\n * `<div>` block with `display: inline-block`.\n * @param tip &ndash; Anything React is able to render,\n * _e.g._ a tooltip text. This will be the tooltip content.\n * @param {WithTooltipTheme} props.theme _Ad hoc_ theme.\n */\nconst Wrapper: FunctionComponent<PropsT> = ({\n children,\n placement = PLACEMENTS.ABOVE_CURSOR,\n tip,\n theme,\n}) => {\n const { current: heap } = useRef<HeapT>({\n lastCursorX: 0,\n lastCursorY: 0,\n timerId: undefined,\n triggeredByTouch: false,\n });\n const tooltipRef = useRef<TooltipRefT>(null);\n const wrapperRef = useRef<HTMLDivElement>(null);\n const [showTooltip, setShowTooltip] = useState(false);\n\n const updatePortalPosition = (cursorX: number, cursorY: number) => {\n if (showTooltip) {\n const wrapperRect = wrapperRef.current!.getBoundingClientRect();\n if (\n cursorX < wrapperRect.left\n || cursorX > wrapperRect.right\n || cursorY < wrapperRect.top\n || cursorY > wrapperRect.bottom\n ) {\n setShowTooltip(false);\n } else if (tooltipRef.current) {\n tooltipRef.current.pointTo(\n cursorX + window.scrollX,\n cursorY + window.scrollY,\n placement,\n wrapperRef.current!,\n );\n }\n } else {\n heap.lastCursorX = cursorX;\n heap.lastCursorY = cursorY;\n\n // If tooltip was triggered by a touch, we delay its opening by a bit,\n // to ensure it was not a touch-click - in the case of touch click we\n // want to do the click, rather than show the tooltip, and the delay\n // gives click handler a chance to abort the tooltip openning.\n if (heap.triggeredByTouch) {\n heap.timerId ??= setTimeout(() => {\n heap.triggeredByTouch = false;\n heap.timerId = undefined;\n setShowTooltip(true);\n }, 300);\n\n // Otherwise we can just open the tooltip right away.\n } else setShowTooltip(true);\n }\n };\n\n useEffect(() => {\n if (showTooltip && tip !== null) {\n // This is necessary to ensure that even when a single mouse event\n // arrives to a tool-tipped component, the tooltip is correctly positioned\n // once opened (because similar call above does not have effect until\n // the tooltip is fully mounted, and that is delayed to future rendering\n // cycle due to the implementation).\n if (tooltipRef.current) {\n tooltipRef.current.pointTo(\n heap.lastCursorX + window.scrollX,\n heap.lastCursorY + window.scrollY,\n placement,\n wrapperRef.current!,\n );\n }\n\n const listener = () => {\n setShowTooltip(false);\n };\n window.addEventListener('scroll', listener);\n return () => {\n window.removeEventListener('scroll', listener);\n };\n }\n return undefined;\n }, [\n heap.lastCursorX,\n heap.lastCursorY,\n placement,\n showTooltip,\n tip,\n ]);\n\n return (\n <div\n className={theme.wrapper}\n onClick={() => {\n if (heap.timerId) {\n clearTimeout(heap.timerId);\n heap.timerId = undefined;\n heap.triggeredByTouch = false;\n }\n }}\n onMouseLeave={() => {\n setShowTooltip(false);\n }}\n onMouseMove={(e) => {\n updatePortalPosition(e.clientX, e.clientY);\n }}\n onTouchStart={() => {\n heap.triggeredByTouch = true;\n }}\n ref={wrapperRef}\n role=\"presentation\"\n >\n {\n showTooltip && tip !== null\n ? <Tooltip ref={tooltipRef} theme={theme}>{tip}</Tooltip>\n : null\n }\n {children}\n </div>\n );\n};\n\nconst ThemedWrapper = /* #__PURE__ */ themed(Wrapper, 'WithTooltip', defaultTheme);\n\ntype ExportT = typeof ThemedWrapper & {\n PLACEMENTS: typeof PLACEMENTS;\n};\n\nconst e: ExportT = ThemedWrapper as ExportT;\n\ne.PLACEMENTS = PLACEMENTS;\n\nexport default e;\n"],"mappings":"AAAA;;AAEA,SAGEA,SAAS,EACTC,MAAM,EACNC,QAAQ,QACH,OAAO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,OAAQ;IACzBC,OAAO,EAAEA,CAAA,KAAM;MACb,IAAI7B,IAAI,CAACG,OAAO,EAAE;QAChB2B,YAAY,CAAC9B,IAAI,CAACG,OAAO,CAAC;QAC1BH,IAAI,CAACG,OAAO,GAAGC,SAAS;QACxBJ,IAAI,CAACK,gBAAgB,GAAG,KAAK;MAC/B;IACF,CAAE;IACF0B,YAAY,EAAEA,CAAA,KAAM;MAClBtB,cAAc,CAAC,KAAK,CAAC;IACvB,CAAE;IACFuB,WAAW,EAAGC,CAAC,IAAK;MAClBvB,oBAAoB,CAACuB,CAAC,CAACC,OAAO,EAAED,CAAC,CAACE,OAAO,CAAC;IAC5C,CAAE;IACFC,YAAY,EAAEA,CAAA,KAAM;MAClBpC,IAAI,CAACK,gBAAgB,GAAG,IAAI;IAC9B,CAAE;IACFgC,GAAG,EAAE9B,UAAW;IAChB+B,IAAI,EAAC,cAAc;IAAA5C,QAAA,GAGjBc,WAAW,IAAIX,GAAG,KAAK,IAAI,gBACvBP,IAAA,CAACJ,OAAO;MAACmD,GAAG,EAAE/B,UAAW;MAACR,KAAK,EAAEA,KAAM;MAAAJ,QAAA,EAAEG;IAAG,CAAU,CAAC,GACvD,IAAI,EAETH,QAAQ;EAAA,CACN,CAAC;AAEV,CAAC;AAED,MAAM6C,aAAa,GAAG,eAAgBtD,MAAM,CAACQ,OAAO,EAAE,aAAa,EAAEL,YAAY,CAAC;AAMlF,MAAM6C,CAAU,GAAGM,aAAwB;AAE3CN,CAAC,CAAC9C,UAAU,GAAGA,UAAU;AAEzB,eAAe8C,CAAC","ignoreList":[]}
1
+ {"version":3,"file":"index.js","names":["useEffect","useRef","useState","useTheme","Tooltip","PLACEMENTS","defaultTheme","jsx","_jsx","jsxs","_jsxs","WithTooltip","children","placement","ABOVE_CURSOR","tip","theme","custom","current","heap","lastCursorX","lastCursorY","timerId","undefined","triggeredByTouch","tooltipRef","wrapperRef","showTooltip","setShowTooltip","updatePortalPosition","cursorX","cursorY","wrapperRect","getBoundingClientRect","left","right","top","bottom","pointTo","window","scrollX","scrollY","setTimeout","listener","addEventListener","removeEventListener","className","wrapper","onClick","clearTimeout","onMouseLeave","onMouseMove","e","clientX","clientY","onTouchStart","ref","role"],"sources":["../../../../../src/shared/components/WithTooltip/index.tsx"],"sourcesContent":["/* global window */\n\nimport {\n type FunctionComponent,\n type ReactNode,\n useEffect,\n useRef,\n useState,\n} from 'react';\n\nimport { type Theme, useTheme } from '@dr.pogodin/react-themes';\n\nimport Tooltip, {\n type ThemeKeysT as TooltipThemeKeysT,\n PLACEMENTS,\n} from './Tooltip';\n\nimport defaultTheme from './default-theme.scss';\n\ntype PropsT = {\n children?: ReactNode;\n placement?: PLACEMENTS;\n tip?: ReactNode;\n theme?: Theme<'wrapper' | TooltipThemeKeysT>;\n};\n\ntype TooltipRefT = {\n pointTo: (\n x: number,\n y: number,\n placement: PLACEMENTS,\n wrapperRef: HTMLDivElement,\n ) => void;\n};\n\ntype HeapT = {\n lastCursorX: number;\n lastCursorY: number;\n triggeredByTouch: boolean;\n timerId?: NodeJS.Timeout;\n};\n\n/**\n * Implements a simple to use and themeable tooltip component, _e.g._\n * ```js\n * <WithTooltip tip=\"This is example tooltip.\">\n * <p>Hover to see the tooltip.</p>\n * </WithTooltip>\n * ```\n * **Children:** Children are rendered in the place of `<WithTooltip>`,\n * and when hovered the tooltip is shown. By default the wrapper itself is\n * `<div>` block with `display: inline-block`.\n * @param tip &ndash; Anything React is able to render,\n * _e.g._ a tooltip text. This will be the tooltip content.\n * @param {WithTooltipTheme} props.theme _Ad hoc_ theme.\n */\nconst WithTooltip: FunctionComponent<PropsT> = ({\n children,\n placement = PLACEMENTS.ABOVE_CURSOR,\n tip,\n theme,\n}) => {\n const custom = useTheme('WithTooltip', defaultTheme, theme);\n\n const { current: heap } = useRef<HeapT>({\n lastCursorX: 0,\n lastCursorY: 0,\n timerId: undefined,\n triggeredByTouch: false,\n });\n const tooltipRef = useRef<TooltipRefT>(null);\n const wrapperRef = useRef<HTMLDivElement>(null);\n const [showTooltip, setShowTooltip] = useState(false);\n\n const updatePortalPosition = (cursorX: number, cursorY: number) => {\n if (showTooltip) {\n const wrapperRect = wrapperRef.current!.getBoundingClientRect();\n if (\n cursorX < wrapperRect.left\n || cursorX > wrapperRect.right\n || cursorY < wrapperRect.top\n || cursorY > wrapperRect.bottom\n ) {\n setShowTooltip(false);\n } else if (tooltipRef.current) {\n tooltipRef.current.pointTo(\n cursorX + window.scrollX,\n cursorY + window.scrollY,\n placement,\n wrapperRef.current!,\n );\n }\n } else {\n heap.lastCursorX = cursorX;\n heap.lastCursorY = cursorY;\n\n // If tooltip was triggered by a touch, we delay its opening by a bit,\n // to ensure it was not a touch-click - in the case of touch click we\n // want to do the click, rather than show the tooltip, and the delay\n // gives click handler a chance to abort the tooltip openning.\n if (heap.triggeredByTouch) {\n heap.timerId ??= setTimeout(() => {\n heap.triggeredByTouch = false;\n heap.timerId = undefined;\n setShowTooltip(true);\n }, 300);\n\n // Otherwise we can just open the tooltip right away.\n } else setShowTooltip(true);\n }\n };\n\n useEffect(() => {\n if (showTooltip && tip !== null) {\n // This is necessary to ensure that even when a single mouse event\n // arrives to a tool-tipped component, the tooltip is correctly positioned\n // once opened (because similar call above does not have effect until\n // the tooltip is fully mounted, and that is delayed to future rendering\n // cycle due to the implementation).\n if (tooltipRef.current) {\n tooltipRef.current.pointTo(\n heap.lastCursorX + window.scrollX,\n heap.lastCursorY + window.scrollY,\n placement,\n wrapperRef.current!,\n );\n }\n\n const listener = () => {\n setShowTooltip(false);\n };\n window.addEventListener('scroll', listener);\n return () => {\n window.removeEventListener('scroll', listener);\n };\n }\n return undefined;\n }, [\n heap.lastCursorX,\n heap.lastCursorY,\n placement,\n showTooltip,\n tip,\n ]);\n\n return (\n <div\n className={custom.wrapper}\n onClick={() => {\n if (heap.timerId) {\n clearTimeout(heap.timerId);\n heap.timerId = undefined;\n heap.triggeredByTouch = false;\n }\n }}\n onMouseLeave={() => {\n setShowTooltip(false);\n }}\n onMouseMove={(e) => {\n updatePortalPosition(e.clientX, e.clientY);\n }}\n onTouchStart={() => {\n heap.triggeredByTouch = true;\n }}\n ref={wrapperRef}\n role=\"presentation\"\n >\n {\n showTooltip && tip !== null\n ? <Tooltip ref={tooltipRef} theme={custom}>{tip}</Tooltip>\n : null\n }\n {children}\n </div>\n );\n};\n\ntype ExportT = typeof WithTooltip & {\n PLACEMENTS: typeof PLACEMENTS;\n};\n\nconst e: ExportT = WithTooltip as ExportT;\n\ne.PLACEMENTS = PLACEMENTS;\n\nexport default e;\n"],"mappings":"AAAA;;AAEA,SAGEA,SAAS,EACTC,MAAM,EACNC,QAAQ,QACH,OAAO;AAEd,SAAqBC,QAAQ,QAAQ,0BAA0B;AAE/D,OAAOC,OAAO,IAEZC,UAAU;AAGZ,OAAOC,YAAY;AAA6B,SAAAC,GAAA,IAAAC,IAAA,EAAAC,IAAA,IAAAC,KAAA;AAyBhD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAMC,WAAsC,GAAGA,CAAC;EAC9CC,QAAQ;EACRC,SAAS,GAAGR,UAAU,CAACS,YAAY;EACnCC,GAAG;EACHC;AACF,CAAC,KAAK;EACJ,MAAMC,MAAM,GAAGd,QAAQ,CAAC,aAAa,EAAEG,YAAY,EAAEU,KAAK,CAAC;EAE3D,MAAM;IAAEE,OAAO,EAAEC;EAAK,CAAC,GAAGlB,MAAM,CAAQ;IACtCmB,WAAW,EAAE,CAAC;IACdC,WAAW,EAAE,CAAC;IACdC,OAAO,EAAEC,SAAS;IAClBC,gBAAgB,EAAE;EACpB,CAAC,CAAC;EACF,MAAMC,UAAU,GAAGxB,MAAM,CAAc,IAAI,CAAC;EAC5C,MAAMyB,UAAU,GAAGzB,MAAM,CAAiB,IAAI,CAAC;EAC/C,MAAM,CAAC0B,WAAW,EAAEC,cAAc,CAAC,GAAG1B,QAAQ,CAAC,KAAK,CAAC;EAErD,MAAM2B,oBAAoB,GAAGA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xD,IAAI,EAETH,QAAQ;EAAA,CACN,CAAC;AAEV,CAAC;AAMD,MAAMwC,CAAU,GAAGzC,WAAsB;AAEzCyC,CAAC,CAAC/C,UAAU,GAAGA,UAAU;AAEzB,eAAe+C,CAAC","ignoreList":[]}
@@ -1,7 +1,7 @@
1
1
  import qs from 'qs';
2
- import themed from '@dr.pogodin/react-themes';
2
+ import { useTheme } from '@dr.pogodin/react-themes';
3
3
  import Throbber from "../Throbber";
4
- import baseTheme from "./base.scss";
4
+ import defaultTheme from "./base.scss";
5
5
  import throbberTheme from "./throbber.scss";
6
6
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
7
7
  /**
@@ -25,6 +25,7 @@ const YouTubeVideo = ({
25
25
  theme,
26
26
  title
27
27
  }) => {
28
+ const custom = useTheme('YouTubeVideo', defaultTheme, theme);
28
29
  const srcParts = src.split('?');
29
30
  let [url] = srcParts;
30
31
  const [, queryString] = srcParts;
@@ -39,18 +40,18 @@ const YouTubeVideo = ({
39
40
  // More query parameters can be exposed via the component props.
40
41
 
41
42
  return /*#__PURE__*/_jsxs("div", {
42
- className: theme.container,
43
+ className: custom.container,
43
44
  children: [/*#__PURE__*/_jsx(Throbber, {
44
45
  theme: throbberTheme
45
46
  }), /*#__PURE__*/_jsx("iframe", {
46
47
  // eslint-disable-line react/iframe-missing-sandbox
47
48
  allow: "autoplay",
48
49
  allowFullScreen: true,
49
- className: theme.video,
50
+ className: custom.video,
50
51
  src: url,
51
52
  title: title
52
53
  })]
53
54
  });
54
55
  };
55
- export default /* #__PURE__ */themed(YouTubeVideo, 'YouTubeVideo', baseTheme);
56
+ export default YouTubeVideo;
56
57
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":["qs","themed","Throbber","baseTheme","throbberTheme","jsx","_jsx","jsxs","_jsxs","YouTubeVideo","autoplay","src","theme","title","srcParts","split","url","queryString","query","parse","videoId","v","match","stringify","className","container","children","allow","allowFullScreen","video"],"sources":["../../../../../src/shared/components/YouTubeVideo/index.tsx"],"sourcesContent":["import qs from 'qs';\n\nimport themed, { type Theme } from '@dr.pogodin/react-themes';\n\nimport Throbber from 'components/Throbber';\n\nimport baseTheme from './base.scss';\nimport throbberTheme from './throbber.scss';\n\ntype ComponentThemeT = Theme<'container' | 'video'>;\n\ntype PropsT = {\n autoplay?: boolean;\n src: string;\n theme: ComponentThemeT;\n title?: string;\n};\n\n/**\n * A component for embeding a YouTube video.\n * @param [props] Component properties.\n * @param [props.autoplay] If `true` the video will start to play\n * automatically once loaded.\n * @param [props.src] URL of the video to play. Can be in any of\n * the following formats, and keeps any additional query parameters understood\n * by the YouTube IFrame player:\n * - `https://www.youtube.com/watch?v=NdF6Rmt6Ado`\n * - `https://youtu.be/NdF6Rmt6Ado`\n * - `https://www.youtube.com/embed/NdF6Rmt6Ado`\n * @param [props.theme] _Ad hoc_ theme.\n * @param [props.title] The `title` attribute to add to the player\n * IFrame.\n */\nconst YouTubeVideo: React.FunctionComponent<PropsT> = ({\n autoplay,\n src,\n theme,\n title,\n}) => {\n const srcParts = src.split('?');\n let [url] = srcParts;\n const [, queryString] = srcParts;\n const query = queryString ? qs.parse(queryString) : {};\n\n const videoId = query.v ?? url?.match(/\\/([a-zA-Z0-9-_]*)$/)?.[1];\n url = `https://www.youtube.com/embed/${videoId as string}`;\n\n delete query.v;\n query.autoplay = autoplay ? '1' : '0';\n url += `?${qs.stringify(query)}`;\n\n // TODO: https://developers.google.com/youtube/player_parameters\n // More query parameters can be exposed via the component props.\n\n return (\n <div className={theme.container}>\n <Throbber theme={throbberTheme} />\n {/* TODO: I guess, we better add the sanbox, but right now I don't have\n time to carefully explore which restrictions should be lifted to allow\n embed YouTube player to work... sometime later we'll take care of it */\n }\n <iframe // eslint-disable-line react/iframe-missing-sandbox\n allow=\"autoplay\"\n allowFullScreen\n className={theme.video}\n src={url}\n title={title}\n />\n </div>\n );\n};\n\nexport default /* #__PURE__ */ themed(YouTubeVideo, 'YouTubeVideo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ACTH,KAAK,EAAEA;IAAM,CACd,CAAC;EAAA,CACC,CAAC;AAEV,CAAC;AAED,eAAe,eAAgBZ,MAAM,CAACQ,YAAY,EAAE,cAAc,EAAEN,SAAS,CAAC","ignoreList":[]}
1
+ {"version":3,"file":"index.js","names":["qs","useTheme","Throbber","defaultTheme","throbberTheme","jsx","_jsx","jsxs","_jsxs","YouTubeVideo","autoplay","src","theme","title","custom","srcParts","split","url","queryString","query","parse","videoId","v","match","stringify","className","container","children","allow","allowFullScreen","video"],"sources":["../../../../../src/shared/components/YouTubeVideo/index.tsx"],"sourcesContent":["import qs from 'qs';\nimport type { FunctionComponent } from 'react';\n\nimport { type Theme, useTheme } from '@dr.pogodin/react-themes';\n\nimport Throbber from 'components/Throbber';\n\nimport defaultTheme from './base.scss';\nimport throbberTheme from './throbber.scss';\n\ntype ThemeT = Theme<'container' | 'video'>;\n\ntype PropsT = {\n autoplay?: boolean;\n src: string;\n theme?: ThemeT;\n title?: string;\n};\n\n/**\n * A component for embeding a YouTube video.\n * @param [props] Component properties.\n * @param [props.autoplay] If `true` the video will start to play\n * automatically once loaded.\n * @param [props.src] URL of the video to play. Can be in any of\n * the following formats, and keeps any additional query parameters understood\n * by the YouTube IFrame player:\n * - `https://www.youtube.com/watch?v=NdF6Rmt6Ado`\n * - `https://youtu.be/NdF6Rmt6Ado`\n * - `https://www.youtube.com/embed/NdF6Rmt6Ado`\n * @param [props.theme] _Ad hoc_ theme.\n * @param [props.title] The `title` attribute to add to the player\n * IFrame.\n */\nconst YouTubeVideo: FunctionComponent<PropsT> = ({\n autoplay,\n src,\n theme,\n title,\n}) => {\n const custom = useTheme('YouTubeVideo', defaultTheme, theme);\n\n const srcParts = src.split('?');\n let [url] = srcParts;\n const [, queryString] = srcParts;\n const query = queryString ? qs.parse(queryString) : {};\n\n const videoId = query.v ?? url?.match(/\\/([a-zA-Z0-9-_]*)$/)?.[1];\n url = `https://www.youtube.com/embed/${videoId as string}`;\n\n delete query.v;\n query.autoplay = autoplay ? '1' : '0';\n url += `?${qs.stringify(query)}`;\n\n // TODO: https://developers.google.com/youtube/player_parameters\n // More query parameters can be exposed via the component props.\n\n return (\n <div className={custom.container}>\n <Throbber theme={throbberTheme} />\n {/* TODO: I guess, we better add the sanbox, but right now I don't have\n time to carefully explore which restrictions should be lifted to allow\n embed YouTube player to work... sometime later we'll take care of it */\n }\n <iframe // eslint-disable-line react/iframe-missing-sandbox\n allow=\"autoplay\"\n allowFullScreen\n className={custom.video}\n src={url}\n title={title}\n />\n </div>\n );\n};\n\nexport default YouTubeVideo;\n"],"mappings":"AAAA,OAAOA,EAAE,MAAM,IAAI;AAGnB,SAAqBC,QAAQ,QAAQ,0BAA0B;AAE/D,OAAOC,QAAQ;AAEf,OAAOC,YAAY;AACnB,OAAOC,aAAa;AAAwB,SAAAC,GAAA,IAAAC,IAAA,EAAAC,IAAA,IAAAC,KAAA;AAW5C;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAMC,YAAuC,GAAGA,CAAC;EAC/CC,QAAQ;EACRC,GAAG;EACHC,KAAK;EACLC;AACF,CAAC,KAAK;EACJ,MAAMC,MAAM,GAAGb,QAAQ,CAAC,cAAc,EAAEE,YAAY,EAAES,KAAK,CAAC;EAE5D,MAAMG,QAAQ,GAAGJ,GAAG,CAACK,KAAK,CAAC,GAAG,CAAC;EAC/B,IAAI,CAACC,GAAG,CAAC,GAAGF,QAAQ;EACpB,MAAM,GAAGG,WAAW,CAAC,GAAGH,QAAQ;EAChC,MAAMI,KAAK,GAAGD,WAAW,GAAGlB,EAAE,CAACoB,KAAK,CAACF,WAAW,CAAC,GAAG,CAAC,CAAC;EAEtD,MAAMG,OAAO,GAAGF,KAAK,CAACG,CAAC,IAAIL,GAAG,EAAEM,KAAK,CAAC,qBAAqB,CAAC,GAAG,CAAC,CAAC;EACjEN,GAAG,GAAG,iCAAiCI,OAAO,EAAY;EAE1D,OAAOF,KAAK,CAACG,CAAC;EACdH,KAAK,CAACT,QAAQ,GAAGA,QAAQ,GAAG,GAAG,GAAG,GAAG;EACrCO,GAAG,IAAI,IAAIjB,EAAE,CAACwB,SAAS,CAACL,KAAK,CAAC,EAAE;;EAEhC;EACA;;EAEA,oBACEX,KAAA;IAAKiB,SAAS,EAAEX,MAAM,CAACY,SAAU;IAAAC,QAAA,gBAC/BrB,IAAA,CAACJ,QAAQ;MAACU,KAAK,EAAER;IAAc,CAAE,CAAC,eAKlCE,IAAA;MAAQ;MACNsB,KAAK,EAAC,UAAU;MAChBC,eAAe;MACfJ,SAAS,EAAEX,MAAM,CAACgB,KAAM;MACxBnB,GAAG,EAAEM,GAAI;MACTJ,KAAK,EAAEA;IAAM,CACd,CAAC;EAAA,CACC,CAAC;AAEV,CAAC;AAED,eAAeJ,YAAY","ignoreList":[]}
@@ -1,12 +1,12 @@
1
1
  import "core-js/modules/es.iterator.constructor.js";
2
2
  import "core-js/modules/es.iterator.filter.js";
3
3
  import { useEffect, useRef, useState } from 'react';
4
- import themed from '@dr.pogodin/react-themes';
4
+ import { useTheme } from '@dr.pogodin/react-themes';
5
5
  import { optionValueName } from "../common";
6
6
  import Options, { areEqual } from "./Options";
7
7
  import defaultTheme from "./theme.scss";
8
8
  import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
9
- const BaseCustomDropdown = ({
9
+ const CustomDropdown = ({
10
10
  filter,
11
11
  label,
12
12
  onChange,
@@ -14,6 +14,7 @@ const BaseCustomDropdown = ({
14
14
  theme,
15
15
  value
16
16
  }) => {
17
+ const custom = useTheme('CustomDropdown', defaultTheme, theme);
17
18
  const [active, setActive] = useState(false);
18
19
  const dropdownRef = useRef(null);
19
20
  const opsRef = useRef(null);
@@ -78,20 +79,20 @@ const BaseCustomDropdown = ({
78
79
  }
79
80
  }
80
81
  }
81
- let containerClassName = theme.container;
82
- if (active) containerClassName += ` ${theme.active}`;
83
- let opsContainerClass = theme.select ?? '';
82
+ let containerClassName = custom.container;
83
+ if (active) containerClassName += ` ${custom.active}`;
84
+ let opsContainerClass = custom.select ?? '';
84
85
  if (upward) {
85
- containerClassName += ` ${theme.upward}`;
86
- opsContainerClass += ` ${theme.upward}`;
86
+ containerClassName += ` ${custom.upward}`;
87
+ opsContainerClass += ` ${custom.upward}`;
87
88
  }
88
89
  return /*#__PURE__*/_jsxs("div", {
89
90
  className: containerClassName,
90
91
  children: [label === undefined ? null : /*#__PURE__*/_jsx("div", {
91
- className: theme.label,
92
+ className: custom.label,
92
93
  children: label
93
94
  }), /*#__PURE__*/_jsxs("div", {
94
- className: theme.dropdown,
95
+ className: custom.dropdown,
95
96
  onClick: openList,
96
97
  onKeyDown: e => {
97
98
  if (e.key === 'Enter') openList(e);
@@ -100,7 +101,7 @@ const BaseCustomDropdown = ({
100
101
  role: "listbox",
101
102
  tabIndex: 0,
102
103
  children: [selected, /*#__PURE__*/_jsx("div", {
103
- className: theme.arrow
104
+ className: custom.arrow
104
105
  })]
105
106
  }), active ? /*#__PURE__*/_jsx(Options, {
106
107
  containerClass: opsContainerClass,
@@ -112,11 +113,11 @@ const BaseCustomDropdown = ({
112
113
  setActive(false);
113
114
  if (onChange) onChange(newValue);
114
115
  },
115
- optionClass: theme.option ?? '',
116
+ optionClass: custom.option ?? '',
116
117
  options: options,
117
118
  ref: opsRef
118
119
  }) : null]
119
120
  });
120
121
  };
121
- export default /* #__PURE__ */themed(BaseCustomDropdown, 'CustomDropdown', defaultTheme);
122
+ export default CustomDropdown;
122
123
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":["useEffect","useRef","useState","themed","optionValueName","Options","areEqual","defaultTheme","Fragment","_Fragment","jsx","_jsx","jsxs","_jsxs","BaseCustomDropdown","filter","label","onChange","options","theme","value","active","setActive","dropdownRef","opsRef","opsPos","setOpsPos","upward","setUpward","undefined","id","cb","anchor","current","getBoundingClientRect","opsRect","measure","fitsDown","bottom","height","window","visualViewport","fitsUp","top","up","pos","left","width","now","requestAnimationFrame","cancelAnimationFrame","openList","e","view","rect","stopPropagation","selected","children","option","iValue","iName","containerClassName","container","opsContainerClass","select","className","dropdown","onClick","onKeyDown","key","ref","role","tabIndex","arrow","containerClass","containerStyle","onCancel","newValue","optionClass"],"sources":["../../../../../../src/shared/components/selectors/CustomDropdown/index.tsx"],"sourcesContent":["import { useEffect, useRef, useState } from 'react';\n\nimport themed from '@dr.pogodin/react-themes';\n\nimport { type PropsT, type ValueT, optionValueName } from '../common';\n\nimport Options, { type ContainerPosT, type RefT, areEqual } from './Options';\n\nimport defaultTheme from './theme.scss';\n\nconst BaseCustomDropdown: React.FunctionComponent<\n PropsT<React.ReactNode, (value: ValueT) => void>\n> = ({\n filter,\n label,\n onChange,\n options,\n theme,\n value,\n}) => {\n const [active, setActive] = useState(false);\n\n const dropdownRef = useRef<HTMLDivElement>(null);\n const opsRef = useRef<RefT>(null);\n\n const [opsPos, setOpsPos] = useState<ContainerPosT>();\n const [upward, setUpward] = useState(false);\n\n useEffect(() => {\n if (!active) return undefined;\n\n let id: number;\n const cb = () => {\n const anchor = dropdownRef.current?.getBoundingClientRect();\n const opsRect = opsRef.current?.measure();\n if (anchor && opsRect) {\n const fitsDown = anchor.bottom + opsRect.height\n < (window.visualViewport?.height ?? 0);\n const fitsUp = anchor.top - opsRect.height > 0;\n\n const up = !fitsDown && fitsUp;\n setUpward(up);\n\n const pos = up ? {\n left: anchor.left,\n top: anchor.top - opsRect.height - 1,\n width: anchor.width,\n } : {\n left: anchor.left,\n top: anchor.bottom,\n width: anchor.width,\n };\n\n setOpsPos((now) => (areEqual(now, pos) ? now : pos));\n }\n id = requestAnimationFrame(cb);\n };\n requestAnimationFrame(cb);\n\n return () => {\n cancelAnimationFrame(id);\n };\n }, [active]);\n\n const openList = (\n e: React.KeyboardEvent<HTMLDivElement> | React.MouseEvent<HTMLDivElement>,\n ) => {\n const view = window.visualViewport;\n const rect = dropdownRef.current!.getBoundingClientRect();\n setActive(true);\n\n // NOTE: This first opens the dropdown off-screen, where it is measured\n // by an effect declared above, and then positioned below, or above\n // the original dropdown element, depending where it fits best\n // (if we first open it downward, it would flick if we immediately\n // move it above, at least with the current position update via local\n // react state, and not imperatively).\n setOpsPos({\n left: view?.width ?? 0,\n top: view?.height ?? 0,\n width: rect.width,\n });\n\n e.stopPropagation();\n };\n\n let selected: React.ReactNode = <>&zwnj;</>;\n for (const option of options) {\n if (!filter || filter(option)) {\n const [iValue, iName] = optionValueName(option);\n if (iValue === value) {\n selected = iName;\n break;\n }\n }\n }\n\n let containerClassName = theme.container;\n if (active) containerClassName += ` ${theme.active}`;\n\n let opsContainerClass = theme.select ?? '';\n if (upward) {\n containerClassName += ` ${theme.upward}`;\n opsContainerClass += ` ${theme.upward}`;\n }\n\n return (\n <div className={containerClassName}>\n {label === undefined ? null\n : <div className={theme.label}>{label}</div>}\n <div\n className={theme.dropdown}\n onClick={openList}\n onKeyDown={(e) => {\n if (e.key === 'Enter') openList(e);\n }}\n ref={dropdownRef}\n role=\"listbox\"\n tabIndex={0}\n >\n {selected}\n <div className={theme.arrow} />\n </div>\n {\n active ? (\n <Options\n containerClass={opsContainerClass}\n containerStyle={opsPos}\n onCancel={() => {\n setActive(false);\n }}\n onChange={(newValue) => {\n setActive(false);\n if (onChange) onChange(newValue);\n }}\n optionClass={theme.option ?? ''}\n options={options}\n ref={opsRef}\n />\n ) : null\n }\n </div>\n );\n};\n\nexport default /* #__PURE__ */ themed(BaseCustomDropdown, 'CustomDropdown', defaultTheme);\n"],"mappings":";;AAAA,SAASA,SAAS,EAAEC,MAAM,EAAEC,QAAQ,QAAQ,OAAO;AAEnD,OAAOC,MAAM,MAAM,0BAA0B;AAE7C,SAAmCC,eAAe;AAElD,OAAOC,OAAO,IAAmCC,QAAQ;AAEzD,OAAOC,YAAY;AAAqB,SAAAC,QAAA,IAAAC,SAAA,EAAAC,GAAA,IAAAC,IAAA,EAAAC,IAAA,IAAAC,KAAA;AAExC,MAAMC,kBAEL,GAAGA,C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AEA,QAAQ,CAAC4D,QAAQ,CAAC;MAClC,CAAE;MACFC,WAAW,EAAE3D,KAAK,CAACuC,MAAM,IAAI,EAAG;MAChCxC,OAAO,EAAEA,OAAQ;MACjBoD,GAAG,EAAE9C;IAAO,CACb,CAAC,GACA,IAAI;EAAA,CAEP,CAAC;AAEV,CAAC;AAED,eAAe,eAAgBrB,MAAM,CAACW,kBAAkB,EAAE,gBAAgB,EAAEP,YAAY,CAAC","ignoreList":[]}
1
+ {"version":3,"file":"index.js","names":["useEffect","useRef","useState","useTheme","optionValueName","Options","areEqual","defaultTheme","Fragment","_Fragment","jsx","_jsx","jsxs","_jsxs","CustomDropdown","filter","label","onChange","options","theme","value","custom","active","setActive","dropdownRef","opsRef","opsPos","setOpsPos","upward","setUpward","undefined","id","cb","anchor","current","getBoundingClientRect","opsRect","measure","fitsDown","bottom","height","window","visualViewport","fitsUp","top","up","pos","left","width","now","requestAnimationFrame","cancelAnimationFrame","openList","e","view","rect","stopPropagation","selected","children","option","iValue","iName","containerClassName","container","opsContainerClass","select","className","dropdown","onClick","onKeyDown","key","ref","role","tabIndex","arrow","containerClass","containerStyle","onCancel","newValue","optionClass"],"sources":["../../../../../../src/shared/components/selectors/CustomDropdown/index.tsx"],"sourcesContent":["import {\n type FunctionComponent,\n type ReactNode,\n useEffect,\n useRef,\n useState,\n} from 'react';\n\nimport { useTheme } from '@dr.pogodin/react-themes';\n\nimport { type PropsT, type ValueT, optionValueName } from '../common';\n\nimport Options, { type ContainerPosT, type RefT, areEqual } from './Options';\n\nimport defaultTheme from './theme.scss';\n\nconst CustomDropdown: FunctionComponent<\n PropsT<ReactNode, (value: ValueT) => void>\n> = ({\n filter,\n label,\n onChange,\n options,\n theme,\n value,\n}) => {\n const custom = useTheme('CustomDropdown', defaultTheme, theme);\n\n const [active, setActive] = useState(false);\n\n const dropdownRef = useRef<HTMLDivElement>(null);\n const opsRef = useRef<RefT>(null);\n\n const [opsPos, setOpsPos] = useState<ContainerPosT>();\n const [upward, setUpward] = useState(false);\n\n useEffect(() => {\n if (!active) return undefined;\n\n let id: number;\n const cb = () => {\n const anchor = dropdownRef.current?.getBoundingClientRect();\n const opsRect = opsRef.current?.measure();\n if (anchor && opsRect) {\n const fitsDown = anchor.bottom + opsRect.height\n < (window.visualViewport?.height ?? 0);\n const fitsUp = anchor.top - opsRect.height > 0;\n\n const up = !fitsDown && fitsUp;\n setUpward(up);\n\n const pos = up ? {\n left: anchor.left,\n top: anchor.top - opsRect.height - 1,\n width: anchor.width,\n } : {\n left: anchor.left,\n top: anchor.bottom,\n width: anchor.width,\n };\n\n setOpsPos((now) => (areEqual(now, pos) ? now : pos));\n }\n id = requestAnimationFrame(cb);\n };\n requestAnimationFrame(cb);\n\n return () => {\n cancelAnimationFrame(id);\n };\n }, [active]);\n\n const openList = (\n e: React.KeyboardEvent<HTMLDivElement> | React.MouseEvent<HTMLDivElement>,\n ) => {\n const view = window.visualViewport;\n const rect = dropdownRef.current!.getBoundingClientRect();\n setActive(true);\n\n // NOTE: This first opens the dropdown off-screen, where it is measured\n // by an effect declared above, and then positioned below, or above\n // the original dropdown element, depending where it fits best\n // (if we first open it downward, it would flick if we immediately\n // move it above, at least with the current position update via local\n // react state, and not imperatively).\n setOpsPos({\n left: view?.width ?? 0,\n top: view?.height ?? 0,\n width: rect.width,\n });\n\n e.stopPropagation();\n };\n\n let selected: React.ReactNode = <>&zwnj;</>;\n for (const option of options) {\n if (!filter || filter(option)) {\n const [iValue, iName] = optionValueName(option);\n if (iValue === value) {\n selected = iName;\n break;\n }\n }\n }\n\n let containerClassName = custom.container;\n if (active) containerClassName += ` ${custom.active}`;\n\n let opsContainerClass = custom.select ?? '';\n if (upward) {\n containerClassName += ` ${custom.upward}`;\n opsContainerClass += ` ${custom.upward}`;\n }\n\n return (\n <div className={containerClassName}>\n {label === undefined ? null\n : <div className={custom.label}>{label}</div>}\n <div\n className={custom.dropdown}\n onClick={openList}\n onKeyDown={(e) => {\n if (e.key === 'Enter') openList(e);\n }}\n ref={dropdownRef}\n role=\"listbox\"\n tabIndex={0}\n >\n {selected}\n <div className={custom.arrow} />\n </div>\n {\n active ? (\n <Options\n containerClass={opsContainerClass}\n containerStyle={opsPos}\n onCancel={() => {\n setActive(false);\n }}\n onChange={(newValue) => {\n setActive(false);\n if (onChange) onChange(newValue);\n }}\n optionClass={custom.option ?? ''}\n options={options}\n ref={opsRef}\n />\n ) : null\n }\n </div>\n );\n};\n\nexport default CustomDropdown;\n"],"mappings":";;AAAA,SAGEA,SAAS,EACTC,MAAM,EACNC,QAAQ,QACH,OAAO;AAEd,SAASC,QAAQ,QAAQ,0BAA0B;AAEnD,SAAmCC,eAAe;AAElD,OAAOC,OAAO,IAAmCC,QAAQ;AAEzD,OAAOC,YAAY;AAAqB,SAAAC,QAAA,IAAAC,SAAA,EAAAC,GAAA,IAAAC,IAAA,EAAAC,IAAA,IAAAC,KAAA;AAExC,MAAMC,cAEL,GAAGA,CAAC;EACHC,MAAM;EACNC,KAAK;EACLC,QAAQ;EACRC,OAAO;EACPC,KAAK;EACLC;AACF,CAAC,KAAK;EACJ,MAAMC,MAAM,GAAGlB,QAAQ,CAAC,gBAAgB,EAAEI,YAAY,EAAEY,KAAK,CAAC;EAE9D,MAAM,CAACG,MAAM,EAAEC,SAAS,CAAC,GAAGrB,QAAQ,CAAC,KAAK,CAAC;EAE3C,MAAMsB,WAAW,GAAGvB,MAAM,CAAiB,IAAI,CAAC;EAChD,MAAMwB,MAAM,GAAGxB,MAAM,CAAO,IAAI,CAAC;EAEjC,MAAM,CAACyB,MAAM,EAAEC,SAAS,CAAC,GAAGzB,QAAQ,CAAgB,CAAC;EACrD,MAAM,CAAC0B,MAAM,EAAEC,SAAS,CAAC,GAAG3B,QAAQ,CAAC,KAAK,CAAC;EAE3CF,SAAS,CAAC,MAAM;IACd,IAAI,CAACsB,MAAM,EAAE,OAAOQ,SAAS;IAE7B,IAAIC,EAAU;IACd,MAAMC,EAAE,GAAGA,CAAA,KAAM;MACf,MAAM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C/CH,KAAA;MACEqD,SAAS,EAAE7C,MAAM,CAAC8C,QAAS;MAC3BC,OAAO,EAAEhB,QAAS;MAClBiB,SAAS,EAAGhB,CAAC,IAAK;QAChB,IAAIA,CAAC,CAACiB,GAAG,KAAK,OAAO,EAAElB,QAAQ,CAACC,CAAC,CAAC;MACpC,CAAE;MACFkB,GAAG,EAAE/C,WAAY;MACjBgD,IAAI,EAAC,SAAS;MACdC,QAAQ,EAAE,CAAE;MAAAf,QAAA,GAEXD,QAAQ,eACT9C,IAAA;QAAKuD,SAAS,EAAE7C,MAAM,CAACqD;MAAM,CAAE,CAAC;IAAA,CAC7B,CAAC,EAEJpD,MAAM,gBACJX,IAAA,CAACN,OAAO;MACNsE,cAAc,EAAEX,iBAAkB;MAClCY,cAAc,EAAElD,MAAO;MACvBmD,QAAQ,EAAEA,CAAA,KAAM;QACdtD,SAAS,CAAC,KAAK,CAAC;MAClB,CAAE;MACFN,QAAQ,EAAG6D,QAAQ,IAAK;QACtBvD,SAAS,CAAC,KAAK,CAAC;QAChB,IAAIN,QAAQ,EAAEA,QAAQ,CAAC6D,QAAQ,CAAC;MAClC,CAAE;MACFC,WAAW,EAAE1D,MAAM,CAACsC,MAAM,IAAI,EAAG;MACjCzC,OAAO,EAAEA,OAAQ;MACjBqD,GAAG,EAAE9C;IAAO,CACb,CAAC,GACA,IAAI;EAAA,CAEP,CAAC;AAEV,CAAC;AAED,eAAeX,cAAc","ignoreList":[]}
@@ -3,7 +3,7 @@ import "core-js/modules/es.iterator.constructor.js";
3
3
  import "core-js/modules/es.iterator.filter.js";
4
4
  // Implements dropdown based on the native HTML <select> element.
5
5
 
6
- import themed from '@dr.pogodin/react-themes';
6
+ import { useTheme } from '@dr.pogodin/react-themes';
7
7
  import { optionValueName } from "../common";
8
8
  import defaultTheme from "./theme.scss";
9
9
 
@@ -38,12 +38,13 @@ const Dropdown = ({
38
38
  }) => {
39
39
  let isValidValue = false;
40
40
  const optionElements = [];
41
+ const composed = useTheme('Dropdown', defaultTheme, theme);
41
42
  for (const option of options) {
42
43
  if (!filter || filter(option)) {
43
44
  const [iValue, iName] = optionValueName(option);
44
45
  isValidValue ||= iValue === value;
45
46
  optionElements.push(/*#__PURE__*/_jsx("option", {
46
- className: theme.option,
47
+ className: composed.option,
47
48
  value: iValue,
48
49
  children: iName
49
50
  }, iValue));
@@ -55,20 +56,20 @@ const Dropdown = ({
55
56
  // it from the opened dropdown; in others, e.g. Safari, the best we can do is
56
57
  // to show it as disabled.
57
58
  const hiddenOption = isValidValue ? null : /*#__PURE__*/_jsx("option", {
58
- className: theme.hiddenOption,
59
+ className: composed.hiddenOption,
59
60
  disabled: true,
60
61
  value: value,
61
62
  children: value
62
63
  }, "__reactUtilsHiddenOption");
63
- let selectClassName = theme.select;
64
- if (!isValidValue) selectClassName += ` ${theme.invalid}`;
64
+ let selectClassName = composed.select;
65
+ if (!isValidValue) selectClassName += ` ${composed.invalid}`;
65
66
  return /*#__PURE__*/_jsxs("div", {
66
- className: theme.container,
67
+ className: composed.container,
67
68
  children: [label === undefined ? null : /*#__PURE__*/_jsx("div", {
68
- className: theme.label,
69
+ className: composed.label,
69
70
  children: label
70
71
  }), /*#__PURE__*/_jsxs("div", {
71
- className: theme.dropdown,
72
+ className: composed.dropdown,
72
73
  children: [/*#__PURE__*/_jsxs("select", {
73
74
  className: selectClassName,
74
75
  "data-testid": process.env.NODE_ENV === 'production' ? undefined : testId,
@@ -76,10 +77,10 @@ const Dropdown = ({
76
77
  value: value,
77
78
  children: [hiddenOption, optionElements]
78
79
  }), /*#__PURE__*/_jsx("div", {
79
- className: theme.arrow
80
+ className: composed.arrow
80
81
  })]
81
82
  })]
82
83
  });
83
84
  };
84
- export default /* #__PURE__ */themed(Dropdown, 'Dropdown', defaultTheme);
85
+ export default Dropdown;
85
86
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":["themed","optionValueName","defaultTheme","jsx","_jsx","jsxs","_jsxs","Dropdown","filter","label","onChange","options","testId","theme","value","isValidValue","optionElements","option","iValue","iName","push","className","children","hiddenOption","disabled","selectClassName","select","invalid","container","undefined","dropdown","process","env","NODE_ENV","arrow"],"sources":["../../../../../../src/shared/components/selectors/NativeDropdown/index.tsx"],"sourcesContent":["// Implements dropdown based on the native HTML <select> element.\n\nimport themed from '@dr.pogodin/react-themes';\n\nimport { type PropsT, optionValueName } from '../common';\n\nimport defaultTheme from './theme.scss';\n\n/**\n * Implements a themeable dropdown list. Internally it is rendered with help of\n * the standard HTML `<select>` element, thus the styling support is somewhat\n * limited.\n * @param [props] Component properties.\n * @param [props.filter] Options filter function. If provided, only\n * those elements of `options` list will be used by the dropdown, for which this\n * filter returns `true`.\n * @param [props.label] Dropdown label.\n * @param [props.onChange] Selection event handler.\n * @param [props.options=[]] Array of dropdown\n * options. For string elements the option value and name will be the same.\n * It is allowed to mix DropdownOption and string elements in the same option\n * list.\n * @param [props.theme] _Ad hoc_ theme.\n * @param [props.value] Currently selected value.\n * @param [props....]\n * [Other theming properties](https://www.npmjs.com/package/@dr.pogodin/react-themes#themed-component-properties)\n */\nconst Dropdown: React.FunctionComponent<PropsT<string>> = ({\n filter,\n label,\n onChange,\n options,\n testId,\n theme,\n value,\n}) => {\n let isValidValue = false;\n const optionElements = [];\n\n for (const option of options) {\n if (!filter || filter(option)) {\n const [iValue, iName] = optionValueName(option);\n isValidValue ||= iValue === value;\n optionElements.push(\n <option className={theme.option} key={iValue} value={iValue}>\n {iName}\n </option>,\n );\n }\n }\n\n // NOTE: This element represents the current `value` when it does not match\n // any valid option. In Chrome, and some other browsers, we are able to hide\n // it from the opened dropdown; in others, e.g. Safari, the best we can do is\n // to show it as disabled.\n const hiddenOption = isValidValue ? null : (\n <option\n className={theme.hiddenOption}\n disabled\n key=\"__reactUtilsHiddenOption\"\n value={value}\n >\n {value}\n </option>\n );\n\n let selectClassName = theme.select;\n if (!isValidValue) selectClassName += ` ${theme.invalid}`;\n\n return (\n <div className={theme.container}>\n { label === undefined\n ? null : <div className={theme.label}>{label}</div> }\n <div className={theme.dropdown}>\n <select\n className={selectClassName}\n data-testid={process.env.NODE_ENV === 'production' ? undefined : testId}\n onChange={onChange}\n value={value}\n >\n {hiddenOption}\n {optionElements}\n </select>\n <div className={theme.arrow} />\n </div>\n </div>\n );\n};\n\nexport default /* #__PURE__ */ themed(Dropdown, 'Dropdown', defaultTheme);\n"],"mappings":";;;AAAA;;AAEA,OAAOA,MAAM,MAAM,0BAA0B;AAE7C,SAAsBC,eAAe;AAErC,OAAOC,YAAY;;AAEnB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAlBA,SAAAC,GAAA,IAAAC,IAAA,EAAAC,IAAA,IAAAC,KAAA;AAmBA,MAAMC,QAAiD,GAAGA,CAAC;EACzDC,MAAM;EACNC,KAAK;EACLC,QAAQ;EACRC,OAAO;EACPC,MAAM;EACNC,KAAK;EACLC;AACF,CAAC,KAAK;EACJ,IAAIC,YAAY,GAAG,KAAK;EACxB,MAAMC,cAAc,GAAG,EAAE;EAEzB,KAAK,MAAMC,MAAM,IAAIN,OAAO,EAAE;IAC5B,IAAI,CAACH,MAAM,IAAIA,MAAM,CAACS,MAAM,CAAC,EAAE;MAC7B,MAAM,CAACC,MAAM,EAAEC,KAAK,CAAC,GAAGlB,eAAe,CAACgB,MAAM,CAAC;MAC/CF,YAAY,KAAKG,MAAM,KAAKJ,KAAK;MACjCE,cAAc,CAACI,IAAI,cACjBhB,IAAA;QAAQiB,SAAS,EAAER,KAAK,CAACI,MAAO;QAAcH,KAAK,EAAEI,MAAO;QAAAI,QAAA,EACzDH;MAAK,GAD8BD,MAE9B,CACV,CAAC;IACH;EACF;;EAEA;EACA;EACA;EACA;EACA,MAAMK,YAAY,GAAGR,YAAY,GAAG,IAAI,gBACtCX,IAAA;IACEiB,SAAS,EAAER,KAAK,CAACU,YAAa;IAC9BC,QAAQ;IAERV,KAAK,EAAEA,KAAM;IAAAQ,QAAA,EAEZR;EAAK,GAHF,0BAIE,CACT;EAED,IAAIW,eAAe,GAAGZ,KAAK,CAACa,MAAM;EAClC,IAAI,CAACX,YAAY,EAAEU,eAAe,IAAI,IAAIZ,KAAK,CAACc,OAAO,EAAE;EAEzD,oBACErB,KAAA;IAAKe,SAAS,EAAER,KAAK,CAACe,SAAU;IAAAN,QAAA,GAC5Bb,KAAK,KAAKoB,SAAS,GACjB,IAAI,gBAAGzB,IAAA;MAAKiB,SAAS,EAAER,KAAK,CAACJ,KAAM;MAAAa,QAAA,EAAEb;IAAK,CAAM,CAAC,eACrDH,KAAA;MAAKe,SAAS,EAAER,KAAK,CAACiB,QAAS;MAAAR,QAAA,gBAC7BhB,KAAA;QACEe,SAAS,EAAEI,eAAgB;QAC3B,eAAaM,OAAO,CAACC,GAAG,CAACC,QAAQ,KAAK,YAAY,GAAGJ,SAAS,GAAGjB,MAAO;QACxEF,QAAQ,EAAEA,QAAS;QACnBI,KAAK,EAAEA,KAAM;QAAAQ,QAAA,GAEZC,YAAY,EACZP,cAAc;MAAA,CACT,CAAC,eACTZ,IAAA;QAAKiB,SAAS,EAAER,KAAK,CAACqB;MAAM,CAAE,CAAC;IAAA,CAC5B,CAAC;EAAA,CACH,CAAC;AAEV,CAAC;AAED,eAAe,eAAgBlC,MAAM,CAACO,QAAQ,EAAE,UAAU,EAAEL,YAAY,CAAC","ignoreList":[]}
1
+ {"version":3,"file":"index.js","names":["useTheme","optionValueName","defaultTheme","jsx","_jsx","jsxs","_jsxs","Dropdown","filter","label","onChange","options","testId","theme","value","isValidValue","optionElements","composed","option","iValue","iName","push","className","children","hiddenOption","disabled","selectClassName","select","invalid","container","undefined","dropdown","process","env","NODE_ENV","arrow"],"sources":["../../../../../../src/shared/components/selectors/NativeDropdown/index.tsx"],"sourcesContent":["// Implements dropdown based on the native HTML <select> element.\n\nimport type { FunctionComponent } from 'react';\n\nimport { useTheme } from '@dr.pogodin/react-themes';\n\nimport { optionValueName, type PropsT } from '../common';\n\nimport defaultTheme from './theme.scss';\n\n/**\n * Implements a themeable dropdown list. Internally it is rendered with help of\n * the standard HTML `<select>` element, thus the styling support is somewhat\n * limited.\n * @param [props] Component properties.\n * @param [props.filter] Options filter function. If provided, only\n * those elements of `options` list will be used by the dropdown, for which this\n * filter returns `true`.\n * @param [props.label] Dropdown label.\n * @param [props.onChange] Selection event handler.\n * @param [props.options=[]] Array of dropdown\n * options. For string elements the option value and name will be the same.\n * It is allowed to mix DropdownOption and string elements in the same option\n * list.\n * @param [props.theme] _Ad hoc_ theme.\n * @param [props.value] Currently selected value.\n * @param [props....]\n * [Other theming properties](https://www.npmjs.com/package/@dr.pogodin/react-themes#themed-component-properties)\n */\nconst Dropdown: FunctionComponent<PropsT<string>> = ({\n filter,\n label,\n onChange,\n options,\n testId,\n theme,\n value,\n}) => {\n let isValidValue = false;\n const optionElements = [];\n\n const composed = useTheme('Dropdown', defaultTheme, theme);\n\n for (const option of options) {\n if (!filter || filter(option)) {\n const [iValue, iName] = optionValueName(option);\n isValidValue ||= iValue === value;\n optionElements.push(\n <option className={composed.option} key={iValue} value={iValue}>\n {iName}\n </option>,\n );\n }\n }\n\n // NOTE: This element represents the current `value` when it does not match\n // any valid option. In Chrome, and some other browsers, we are able to hide\n // it from the opened dropdown; in others, e.g. Safari, the best we can do is\n // to show it as disabled.\n const hiddenOption = isValidValue ? null : (\n <option\n className={composed.hiddenOption}\n disabled\n key=\"__reactUtilsHiddenOption\"\n value={value}\n >\n {value}\n </option>\n );\n\n let selectClassName = composed.select;\n if (!isValidValue) selectClassName += ` ${composed.invalid}`;\n\n return (\n <div className={composed.container}>\n { label === undefined\n ? null : <div className={composed.label}>{label}</div> }\n <div className={composed.dropdown}>\n <select\n className={selectClassName}\n data-testid={process.env.NODE_ENV === 'production' ? undefined : testId}\n onChange={onChange}\n value={value}\n >\n {hiddenOption}\n {optionElements}\n </select>\n <div className={composed.arrow} />\n </div>\n </div>\n );\n};\n\nexport default Dropdown;\n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ACW,OAAO,EAAE;EAE5D,oBACEtB,KAAA;IAAKgB,SAAS,EAAEL,QAAQ,CAACY,SAAU;IAAAN,QAAA,GAC/Bd,KAAK,KAAKqB,SAAS,GACjB,IAAI,gBAAG1B,IAAA;MAAKkB,SAAS,EAAEL,QAAQ,CAACR,KAAM;MAAAc,QAAA,EAAEd;IAAK,CAAM,CAAC,eACxDH,KAAA;MAAKgB,SAAS,EAAEL,QAAQ,CAACc,QAAS;MAAAR,QAAA,gBAChCjB,KAAA;QACEgB,SAAS,EAAEI,eAAgB;QAC3B,eAAaM,OAAO,CAACC,GAAG,CAACC,QAAQ,KAAK,YAAY,GAAGJ,SAAS,GAAGlB,MAAO;QACxEF,QAAQ,EAAEA,QAAS;QACnBI,KAAK,EAAEA,KAAM;QAAAS,QAAA,GAEZC,YAAY,EACZR,cAAc;MAAA,CACT,CAAC,eACTZ,IAAA;QAAKkB,SAAS,EAAEL,QAAQ,CAACkB;MAAM,CAAE,CAAC;IAAA,CAC/B,CAAC;EAAA,CACH,CAAC;AAEV,CAAC;AAED,eAAe5B,QAAQ","ignoreList":[]}
@@ -1,22 +1,23 @@
1
1
  import "core-js/modules/es.array.push.js";
2
- import themed from '@dr.pogodin/react-themes';
2
+ import { useTheme } from '@dr.pogodin/react-themes';
3
3
  import { optionValueName } from "../common";
4
4
  import defaultTheme from "./theme.scss";
5
5
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
6
- const BaseSwitch = ({
6
+ export const Switch = ({
7
7
  label,
8
8
  onChange,
9
9
  options,
10
10
  theme,
11
11
  value
12
12
  }) => {
13
- if (!options || !theme.option) throw Error('Internal error');
13
+ const composed = useTheme('Switch', defaultTheme, theme);
14
+ if (!options || !composed.option) throw Error('Internal error');
14
15
  const optionNodes = [];
15
16
  for (const option of options) {
16
17
  const [iValue, iName] = optionValueName(option);
17
- let className = theme.option;
18
+ let className = composed.option;
18
19
  let onPress;
19
- if (iValue === value) className += ` ${theme.selected}`;else if (onChange) {
20
+ if (iValue === value) className += ` ${composed.selected}`;else if (onChange) {
20
21
  onPress = () => {
21
22
  onChange(iValue);
22
23
  };
@@ -36,15 +37,14 @@ const BaseSwitch = ({
36
37
  }, iValue));
37
38
  }
38
39
  return /*#__PURE__*/_jsxs("div", {
39
- className: theme.container,
40
+ className: composed.container,
40
41
  children: [label ? /*#__PURE__*/_jsx("div", {
41
- className: theme.label,
42
+ className: composed.label,
42
43
  children: label
43
44
  }) : null, /*#__PURE__*/_jsx("div", {
44
- className: theme.options,
45
+ className: composed.options,
45
46
  children: optionNodes
46
47
  })]
47
48
  });
48
49
  };
49
- export default /* #__PURE__ */themed(BaseSwitch, 'Switch', defaultTheme);
50
50
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":["themed","optionValueName","defaultTheme","jsx","_jsx","jsxs","_jsxs","BaseSwitch","label","onChange","options","theme","value","option","Error","optionNodes","iValue","iName","className","onPress","selected","push","onClick","onKeyDown","e","key","role","tabIndex","children","container"],"sources":["../../../../../../src/shared/components/selectors/Switch/index.tsx"],"sourcesContent":["import themed, { type Theme } from '@dr.pogodin/react-themes';\n\nimport {\n type OptionsT,\n type ValueT,\n optionValueName,\n} from '../common';\n\nimport defaultTheme from './theme.scss';\n\ntype ThemeKeyT = 'container' | 'label' | 'option' | 'options' | 'selected';\n\ntype PropsT = {\n label?: React.ReactNode;\n onChange?: (value: ValueT) => void;\n options?: Readonly<OptionsT<React.ReactNode>>;\n theme: Theme<ThemeKeyT>;\n value?: ValueT;\n};\n\nconst BaseSwitch: React.FunctionComponent<PropsT> = ({\n label,\n onChange,\n options,\n theme,\n value,\n}) => {\n if (!options || !theme.option) throw Error('Internal error');\n\n const optionNodes: React.ReactNode[] = [];\n for (const option of options) {\n const [iValue, iName] = optionValueName(option);\n\n let className: string = theme.option;\n let onPress: (() => void) | undefined;\n if (iValue === value) className += ` ${theme.selected}`;\n else if (onChange) {\n onPress = () => {\n onChange(iValue);\n };\n }\n\n optionNodes.push(\n onPress\n ? (\n <div\n className={className}\n key={iValue}\n onClick={onPress}\n onKeyDown={(e) => {\n if (e.key === 'Enter') onPress();\n }}\n role=\"button\"\n tabIndex={0}\n >\n {iName}\n </div>\n )\n : <div className={className} key={iValue}>{iName}</div>,\n );\n }\n\n return (\n <div className={theme.container}>\n {label ? <div className={theme.label}>{label}</div> : null}\n\n <div className={theme.options}>\n {optionNodes}\n </div>\n </div>\n );\n};\n\nexport default /* #__PURE__ */ themed(BaseSwitch, 'Switch', defaultTheme);\n"],"mappings":";AAAA,OAAOA,MAAM,MAAsB,0BAA0B;AAE7D,SAGEC,eAAe;AAGjB,OAAOC,YAAY;AAAqB,SAAAC,GAAA,IAAAC,IAAA,EAAAC,IAAA,IAAAC,KAAA;AAYxC,MAAMC,UAA2C,GAAGA,CAAC;EACnDC,KAAK;EACLC,QAAQ;EACRC,OAAO;EACPC,KAAK;EACLC;AACF,CAAC,KAAK;EACJ,IAAI,CAACF,OAAO,IAAI,CAACC,KAAK,CAACE,MAAM,EAAE,MAAMC,KAAK,CAAC,gBAAgB,CAAC;EAE5D,MAAMC,WAA8B,GAAG,EAAE;EACzC,KAAK,MAAMF,MAAM,IAAIH,OAAO,EAAE;IAC5B,MAAM,CAACM,MAAM,EAAEC,KAAK,CAAC,GAAGhB,eAAe,CAACY,MAAM,CAAC;IAE/C,IAAIK,SAAiB,GAAGP,KAAK,CAACE,MAAM;IACpC,IAAIM,OAAiC;IACrC,IAAIH,MAAM,KAAKJ,KAAK,EAAEM,SAAS,IAAI,IAAIP,KAAK,CAACS,QAAQ,EAAE,CAAC,KACnD,IAAIX,QAAQ,EAAE;MACjBU,OAAO,GAAGA,CAAA,KAAM;QACdV,QAAQ,CAACO,MAAM,CAAC;MAClB,CAAC;IACH;IAEAD,WAAW,CAACM,IAAI,CACdF,OAAO,gBAEHf,IAAA;MACEc,SAAS,EAAEA,SAAU;MAErBI,OAAO,EAAEH,OAAQ;MACjBI,SAAS,EAAGC,CAAC,IAAK;QAChB,IAAIA,CAAC,CAACC,GAAG,KAAK,OAAO,EAAEN,OAAO,CAAC,CAAC;MAClC,CAAE;MACFO,IAAI,EAAC,QAAQ;MACbC,QAAQ,EAAE,CAAE;MAAAC,QAAA,EAEXX;IAAK,GARDD,MASF,CAAC,gBAENZ,IAAA;MAAKc,SAAS,EAAEA,SAAU;MAAAU,QAAA,EAAeX;IAAK,GAAdD,MAAoB,CAC1D,CAAC;EACH;EAEA,oBACEV,KAAA;IAAKY,SAAS,EAAEP,KAAK,CAACkB,SAAU;IAAAD,QAAA,GAC7BpB,KAAK,gBAAGJ,IAAA;MAAKc,SAAS,EAAEP,KAAK,CAACH,KAAM;MAAAoB,QAAA,EAAEpB;IAAK,CAAM,CAAC,GAAG,IAAI,eAE1DJ,IAAA;MAAKc,SAAS,EAAEP,KAAK,CAACD,OAAQ;MAAAkB,QAAA,EAC3Bb;IAAW,CACT,CAAC;EAAA,CACH,CAAC;AAEV,CAAC;AAED,eAAe,eAAgBf,MAAM,CAACO,UAAU,EAAE,QAAQ,EAAEL,YAAY,CAAC","ignoreList":[]}
1
+ {"version":3,"file":"index.js","names":["useTheme","optionValueName","defaultTheme","jsx","_jsx","jsxs","_jsxs","Switch","label","onChange","options","theme","value","composed","option","Error","optionNodes","iValue","iName","className","onPress","selected","push","onClick","onKeyDown","e","key","role","tabIndex","children","container"],"sources":["../../../../../../src/shared/components/selectors/Switch/index.tsx"],"sourcesContent":["import type { FunctionComponent, ReactNode } from 'react';\n\nimport { type Theme, useTheme } from '@dr.pogodin/react-themes';\n\nimport {\n type OptionsT,\n type ValueT,\n optionValueName,\n} from '../common';\n\nimport defaultTheme from './theme.scss';\n\ntype ThemeT = Theme<'container' | 'label' | 'option' | 'options' | 'selected'>;\n\ntype PropsT = {\n label?: ReactNode;\n onChange?: (value: ValueT) => void;\n options?: Readonly<OptionsT<ReactNode>>;\n theme?: ThemeT;\n value?: ValueT;\n};\n\nexport const Switch: FunctionComponent<PropsT> = ({\n label,\n onChange,\n options,\n theme,\n value,\n}) => {\n const composed = useTheme('Switch', defaultTheme, theme);\n\n if (!options || !composed.option) throw Error('Internal error');\n\n const optionNodes: React.ReactNode[] = [];\n for (const option of options) {\n const [iValue, iName] = optionValueName(option);\n\n let className: string = composed.option;\n let onPress: (() => void) | undefined;\n if (iValue === value) className += ` ${composed.selected}`;\n else if (onChange) {\n onPress = () => {\n onChange(iValue);\n };\n }\n\n optionNodes.push(\n onPress\n ? (\n <div\n className={className}\n key={iValue}\n onClick={onPress}\n onKeyDown={(e) => {\n if (e.key === 'Enter') onPress();\n }}\n role=\"button\"\n tabIndex={0}\n >\n {iName}\n </div>\n )\n : <div className={className} key={iValue}>{iName}</div>,\n );\n }\n\n return (\n <div className={composed.container}>\n {label ? <div className={composed.label}>{label}</div> : null}\n\n <div className={composed.options}>\n {optionNodes}\n </div>\n </div>\n );\n};\n"],"mappings":";AAEA,SAAqBA,QAAQ,QAAQ,0BAA0B;AAE/D,SAGEC,eAAe;AAGjB,OAAOC,YAAY;AAAqB,SAAAC,GAAA,IAAAC,IAAA,EAAAC,IAAA,IAAAC,KAAA;AAYxC,OAAO,MAAMC,MAAiC,GAAGA,CAAC;EAChDC,KAAK;EACLC,QAAQ;EACRC,OAAO;EACPC,KAAK;EACLC;AACF,CAAC,KAAK;EACJ,MAAMC,QAAQ,GAAGb,QAAQ,CAAC,QAAQ,EAAEE,YAAY,EAAES,KAAK,CAAC;EAExD,IAAI,CAACD,OAAO,IAAI,CAACG,QAAQ,CAACC,MAAM,EAAE,MAAMC,KAAK,CAAC,gBAAgB,CAAC;EAE/D,MAAMC,WAA8B,GAAG,EAAE;EACzC,KAAK,MAAMF,MAAM,IAAIJ,OAAO,EAAE;IAC5B,MAAM,CAACO,MAAM,EAAEC,KAAK,CAAC,GAAGjB,eAAe,CAACa,MAAM,CAAC;IAE/C,IAAIK,SAAiB,GAAGN,QAAQ,CAACC,MAAM;IACvC,IAAIM,OAAiC;IACrC,IAAIH,MAAM,KAAKL,KAAK,EAAEO,SAAS,IAAI,IAAIN,QAAQ,CAACQ,QAAQ,EAAE,CAAC,KACtD,IAAIZ,QAAQ,EAAE;MACjBW,OAAO,GAAGA,CAAA,KAAM;QACdX,QAAQ,CAACQ,MAAM,CAAC;MAClB,CAAC;IACH;IAEAD,WAAW,CAACM,IAAI,CACdF,OAAO,gBAEHhB,IAAA;MACEe,SAAS,EAAEA,SAAU;MAErBI,OAAO,EAAEH,OAAQ;MACjBI,SAAS,EAAGC,CAAC,IAAK;QAChB,IAAIA,CAAC,CAACC,GAAG,KAAK,OAAO,EAAEN,OAAO,CAAC,CAAC;MAClC,CAAE;MACFO,IAAI,EAAC,QAAQ;MACbC,QAAQ,EAAE,CAAE;MAAAC,QAAA,EAEXX;IAAK,GARDD,MASF,CAAC,gBAENb,IAAA;MAAKe,SAAS,EAAEA,SAAU;MAAAU,QAAA,EAAeX;IAAK,GAAdD,MAAoB,CAC1D,CAAC;EACH;EAEA,oBACEX,KAAA;IAAKa,SAAS,EAAEN,QAAQ,CAACiB,SAAU;IAAAD,QAAA,GAChCrB,KAAK,gBAAGJ,IAAA;MAAKe,SAAS,EAAEN,QAAQ,CAACL,KAAM;MAAAqB,QAAA,EAAErB;IAAK,CAAM,CAAC,GAAG,IAAI,eAE7DJ,IAAA;MAAKe,SAAS,EAAEN,QAAQ,CAACH,OAAQ;MAAAmB,QAAA,EAC9Bb;IAAW,CACT,CAAC;EAAA,CACH,CAAC;AAEV,CAAC","ignoreList":[]}
@@ -1 +1 @@
1
- {"version":3,"file":"common.js","names":["isValue","x","type","optionValueName","option","value","name"],"sources":["../../../../../src/shared/components/selectors/common.ts"],"sourcesContent":["// The stuff common between different dropdown implementations.\n\nimport type { Theme } from '@dr.pogodin/react-themes';\n\ntype ThemeKeyT = 'active'\n | 'arrow'\n | 'container'\n | 'dropdown'\n | 'hiddenOption'\n | 'label'\n | 'option'\n | 'select'\n\n // TODO: This is currently only valid for (native) <Dropdown>,\n // other kinds of selectors should be evaluated, and aligned with this\n // feature, if appropriate.\n | 'invalid'\n\n // TODO: This is only valid for <CustomDropdown>, thus we need to re-factor it\n // into a separate theme spec for that component.\n | 'upward';\n\nexport type ValueT = number | string;\n\nexport type OptionT<NameT> = {\n name?: NameT | null;\n value: ValueT;\n};\n\nexport type OptionsT<NameT> = Readonly<Array<OptionT<NameT> | ValueT>>;\n\nexport type PropsT<\n NameT,\n OnChangeT = React.ChangeEventHandler<HTMLSelectElement>,\n> = {\n filter?: (item: OptionT<NameT> | ValueT) => boolean;\n label?: React.ReactNode;\n onChange?: OnChangeT;\n options: Readonly<OptionsT<NameT>>;\n testId?: string;\n theme: Theme<ThemeKeyT>;\n value?: ValueT;\n};\n\nfunction isValue<T>(x: OptionT<T> | ValueT): x is ValueT {\n const type = typeof x;\n return type === 'number' || type === 'string';\n}\n\n/** Returns option value and name as a tuple. */\nexport function optionValueName<NameT>(\n option: OptionT<NameT> | ValueT,\n): [ValueT, NameT | ValueT] {\n return isValue(option)\n ? [option, option]\n : [option.value, option.name ?? option.value];\n}\n"],"mappings":"AAAA;;AA4CA,SAASA,OAAOA,CAAIC,CAAsB,EAAe;EACvD,MAAMC,IAAI,GAAG,OAAOD,CAAC;EACrB,OAAOC,IAAI,KAAK,QAAQ,IAAIA,IAAI,KAAK,QAAQ;AAC/C;;AAEA;AACA,OAAO,SAASC,eAAeA,CAC7BC,MAA+B,EACL;EAC1B,OAAOJ,OAAO,CAACI,MAAM,CAAC,GAClB,CAACA,MAAM,EAAEA,MAAM,CAAC,GAChB,CAACA,MAAM,CAACC,KAAK,EAAED,MAAM,CAACE,IAAI,IAAIF,MAAM,CAACC,KAAK,CAAC;AACjD","ignoreList":[]}
1
+ {"version":3,"file":"common.js","names":["isValue","x","type","optionValueName","option","value","name"],"sources":["../../../../../src/shared/components/selectors/common.ts"],"sourcesContent":["// The stuff common between different dropdown implementations.\n\nimport type { Theme } from '@dr.pogodin/react-themes';\n\nexport type ThemeT = Theme<\n | 'active'\n | 'arrow'\n | 'container'\n | 'dropdown'\n | 'hiddenOption'\n | 'label'\n | 'option'\n | 'select'\n\n // TODO: This is currently only valid for (native) <Dropdown>,\n // other kinds of selectors should be evaluated, and aligned with this\n // feature, if appropriate.\n | 'invalid'\n\n // TODO: This is only valid for <CustomDropdown>, thus we need to re-factor it\n // into a separate theme spec for that component.\n | 'upward'\n>;\n\nexport type ValueT = number | string;\n\nexport type OptionT<NameT> = {\n name?: NameT | null;\n value: ValueT;\n};\n\nexport type OptionsT<NameT> = Readonly<Array<OptionT<NameT> | ValueT>>;\n\nexport type PropsT<\n NameT,\n OnChangeT = React.ChangeEventHandler<HTMLSelectElement>,\n> = {\n filter?: (item: OptionT<NameT> | ValueT) => boolean;\n label?: React.ReactNode;\n onChange?: OnChangeT;\n options: Readonly<OptionsT<NameT>>;\n testId?: string;\n theme: ThemeT;\n value?: ValueT;\n};\n\nfunction isValue<T>(x: OptionT<T> | ValueT): x is ValueT {\n const type = typeof x;\n return type === 'number' || type === 'string';\n}\n\n/** Returns option value and name as a tuple. */\nexport function optionValueName<NameT>(\n option: OptionT<NameT> | ValueT,\n): [ValueT, NameT | ValueT] {\n return isValue(option)\n ? [option, option]\n : [option.value, option.name ?? option.value];\n}\n"],"mappings":"AAAA;;AA8CA,SAASA,OAAOA,CAAIC,CAAsB,EAAe;EACvD,MAAMC,IAAI,GAAG,OAAOD,CAAC;EACrB,OAAOC,IAAI,KAAK,QAAQ,IAAIA,IAAI,KAAK,QAAQ;AAC/C;;AAEA;AACA,OAAO,SAASC,eAAeA,CAC7BC,MAA+B,EACL;EAC1B,OAAOJ,OAAO,CAACI,MAAM,CAAC,GAClB,CAACA,MAAM,EAAEA,MAAM,CAAC,GAChB,CAACA,MAAM,CAACC,KAAK,EAAED,MAAM,CAACE,IAAI,IAAIF,MAAM,CAACC,KAAK,CAAC;AACjD","ignoreList":[]}
@@ -1,4 +1,4 @@
1
1
  export { default as CustomDropdown } from "./CustomDropdown";
2
2
  export { default as Dropdown } from "./NativeDropdown";
3
- export { default as Switch } from "./Switch";
3
+ export { Switch } from "./Switch";
4
4
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":["default","CustomDropdown","Dropdown","Switch"],"sources":["../../../../../src/shared/components/selectors/index.ts"],"sourcesContent":["export { default as CustomDropdown } from './CustomDropdown';\nexport { default as Dropdown } from './NativeDropdown';\nexport { default as Switch } from './Switch';\n\nexport {\n type OptionT,\n type OptionsT,\n} from './common';\n"],"mappings":"AAAA,SAASA,OAAO,IAAIC,cAAc;AAClC,SAASD,OAAO,IAAIE,QAAQ;AAC5B,SAASF,OAAO,IAAIG,MAAM","ignoreList":[]}
1
+ {"version":3,"file":"index.js","names":["default","CustomDropdown","Dropdown","Switch"],"sources":["../../../../../src/shared/components/selectors/index.ts"],"sourcesContent":["export { default as CustomDropdown } from './CustomDropdown';\nexport { default as Dropdown } from './NativeDropdown';\nexport { Switch } from './Switch';\n\nexport type { OptionT, OptionsT } from './common';\n"],"mappings":"AAAA,SAASA,OAAO,IAAIC,cAAc;AAClC,SAASD,OAAO,IAAIE,QAAQ;AAC5B,SAASC,MAAM","ignoreList":[]}
@@ -1,13 +1,10 @@
1
- import themedImpl, { COMPOSE, PRIORITY, ThemeProvider } from '@dr.pogodin/react-themes';
2
1
  import { getConfig } from "./config";
3
2
  import * as isomorphy from "./isomorphy";
4
3
  import time from "./time";
5
4
  import * as webpack from "./webpack";
6
5
  export { assertEmptyObject, Barrier, Cached, Emitter, Semaphore, withRetries } from '@dr.pogodin/js-utils';
6
+ export { COMPOSE as THEME_COMPOSE, PRIORITY as THEME_PRIORITY, ThemeProvider, useTheme } from '@dr.pogodin/react-themes';
7
7
  export { getSsrContext } from "./globalState";
8
8
  export { default as splitComponent } from "./splitComponent";
9
- const themed = themedImpl;
10
- themed.COMPOSE = COMPOSE;
11
- themed.PRIORITY = PRIORITY;
12
- export { getConfig, isomorphy, themed, ThemeProvider, time, webpack };
9
+ export { getConfig, isomorphy, time, webpack };
13
10
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":["themedImpl","COMPOSE","PRIORITY","ThemeProvider","getConfig","isomorphy","time","webpack","assertEmptyObject","Barrier","Cached","Emitter","Semaphore","withRetries","getSsrContext","default","splitComponent","themed"],"sources":["../../../../src/shared/utils/index.ts"],"sourcesContent":["import themedImpl, {\n COMPOSE,\n PRIORITY,\n type Theme,\n ThemeProvider,\n} from '@dr.pogodin/react-themes';\n\nimport { getConfig } from './config';\nimport * as isomorphy from './isomorphy';\nimport time from './time';\nimport * as webpack from './webpack';\n\nexport {\n assertEmptyObject,\n type Listener,\n type ObjectKey,\n Barrier,\n Cached,\n Emitter,\n Semaphore,\n withRetries,\n} from '@dr.pogodin/js-utils';\n\nexport { getSsrContext } from './globalState';\nexport { default as splitComponent } from './splitComponent';\n\ntype ThemedT = typeof themedImpl & {\n COMPOSE: typeof COMPOSE;\n PRIORITY: typeof PRIORITY;\n};\n\nconst themed: ThemedT = themedImpl as ThemedT;\n\nthemed.COMPOSE = COMPOSE;\nthemed.PRIORITY = PRIORITY;\n\nexport {\n type Theme,\n getConfig,\n isomorphy,\n themed,\n ThemeProvider,\n time,\n webpack,\n};\n"],"mappings":"AAAA,OAAOA,UAAU,IACfC,OAAO,EACPC,QAAQ,EAERC,aAAa,QACR,0BAA0B;AAEjC,SAASC,SAAS;AAClB,OAAO,KAAKC,SAAS;AACrB,OAAOC,IAAI;AACX,OAAO,KAAKC,OAAO;AAEnB,SACEC,iBAAiB,EAGjBC,OAAO,EACPC,MAAM,EACNC,OAAO,EACPC,SAAS,EACTC,WAAW,QACN,sBAAsB;AAE7B,SAASC,aAAa;AACtB,SAASC,OAAO,IAAIC,cAAc;AAOlC,MAAMC,MAAe,GAAGjB,UAAqB;AAE7CiB,MAAM,CAAChB,OAAO,GAAGA,OAAO;AACxBgB,MAAM,CAACf,QAAQ,GAAGA,QAAQ;AAE1B,SAEEE,SAAS,EACTC,SAAS,EACTY,MAAM,EACNd,aAAa,EACbG,IAAI,EACJC,OAAO","ignoreList":[]}
1
+ {"version":3,"file":"index.js","names":["getConfig","isomorphy","time","webpack","assertEmptyObject","Barrier","Cached","Emitter","Semaphore","withRetries","COMPOSE","THEME_COMPOSE","PRIORITY","THEME_PRIORITY","ThemeProvider","useTheme","getSsrContext","default","splitComponent"],"sources":["../../../../src/shared/utils/index.ts"],"sourcesContent":["import { getConfig } from './config';\nimport * as isomorphy from './isomorphy';\nimport time from './time';\nimport * as webpack from './webpack';\n\nexport {\n assertEmptyObject,\n type Listener,\n type ObjectKey,\n Barrier,\n Cached,\n Emitter,\n Semaphore,\n withRetries,\n} from '@dr.pogodin/js-utils';\n\nexport {\n COMPOSE as THEME_COMPOSE,\n PRIORITY as THEME_PRIORITY,\n type Theme,\n ThemeProvider,\n useTheme,\n} from '@dr.pogodin/react-themes';\n\nexport { getSsrContext } from './globalState';\nexport { default as splitComponent } from './splitComponent';\n\nexport {\n getConfig,\n isomorphy,\n time,\n webpack,\n};\n"],"mappings":"AAAA,SAASA,SAAS;AAClB,OAAO,KAAKC,SAAS;AACrB,OAAOC,IAAI;AACX,OAAO,KAAKC,OAAO;AAEnB,SACEC,iBAAiB,EAGjBC,OAAO,EACPC,MAAM,EACNC,OAAO,EACPC,SAAS,EACTC,WAAW,QACN,sBAAsB;AAE7B,SACEC,OAAO,IAAIC,aAAa,EACxBC,QAAQ,IAAIC,cAAc,EAE1BC,aAAa,EACbC,QAAQ,QACH,0BAA0B;AAEjC,SAASC,aAAa;AACtB,SAASC,OAAO,IAAIC,cAAc;AAElC,SACElB,SAAS,EACTC,SAAS,EACTC,IAAI,EACJC,OAAO","ignoreList":[]}
@@ -65,7 +65,6 @@ export default class E2eSsrEnv extends JsdomEnv {
65
65
  await this.loadWebpackConfig();
66
66
  if (!this.global.webpackConfig) throw Error('Failed to load Webpack config');
67
67
  const compiler = webpack(this.global.webpackConfig);
68
- if (!compiler) throw Error('Failed to construct Webpack compiler');
69
68
 
70
69
  // TODO: The "as typeof compiler.outputFileSystem" piece below is
71
70
  // a workaround for the Webpack regression: