@dr.pogodin/react-utils 1.30.2 → 1.31.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 (140) hide show
  1. package/bin/build.js +5 -0
  2. package/build/development/client/index.js +1 -1
  3. package/build/development/client/index.js.map +1 -1
  4. package/build/development/index.js +8 -1
  5. package/build/development/index.js.map +1 -1
  6. package/build/development/server/index.js +1 -1
  7. package/build/development/server/index.js.map +1 -1
  8. package/build/development/server/utils/index.js +1 -1
  9. package/build/development/shared/components/Checkbox/index.js +2 -2
  10. package/build/development/shared/components/Checkbox/index.js.map +1 -1
  11. package/build/development/shared/components/Input/index.js +2 -2
  12. package/build/development/shared/components/Input/index.js.map +1 -1
  13. package/build/development/shared/components/Modal/index.js +40 -5
  14. package/build/development/shared/components/Modal/index.js.map +1 -1
  15. package/build/development/shared/components/TextArea/index.js +5 -0
  16. package/build/development/shared/components/TextArea/index.js.map +1 -1
  17. package/build/development/shared/components/WithTooltip/index.js +1 -1
  18. package/build/development/shared/components/WithTooltip/index.js.map +1 -1
  19. package/build/development/shared/components/YouTubeVideo/index.js +1 -3
  20. package/build/development/shared/components/YouTubeVideo/index.js.map +1 -1
  21. package/build/development/shared/components/index.js +28 -15
  22. package/build/development/shared/components/index.js.map +1 -1
  23. package/build/development/shared/components/selectors/CustomDropdown/Options/index.js +85 -0
  24. package/build/development/shared/components/selectors/CustomDropdown/Options/index.js.map +1 -0
  25. package/build/development/shared/components/selectors/CustomDropdown/index.js +105 -0
  26. package/build/development/shared/components/selectors/CustomDropdown/index.js.map +1 -0
  27. package/build/development/shared/components/{Dropdown → selectors/NativeDropdown}/index.js +25 -34
  28. package/build/development/shared/components/selectors/NativeDropdown/index.js.map +1 -0
  29. package/build/development/shared/components/selectors/Switch/index.js +76 -0
  30. package/build/development/shared/components/selectors/Switch/index.js.map +1 -0
  31. package/build/development/shared/components/selectors/common.js +24 -0
  32. package/build/development/shared/components/selectors/common.js.map +1 -0
  33. package/build/development/shared/components/selectors/index.js +28 -0
  34. package/build/development/shared/components/selectors/index.js.map +1 -0
  35. package/build/development/shared/utils/index.js +1 -1
  36. package/build/development/shared/utils/index.js.map +1 -1
  37. package/build/development/shared/utils/jest/E2eSsrEnv.js +3 -0
  38. package/build/development/shared/utils/jest/E2eSsrEnv.js.map +1 -1
  39. package/build/development/shared/utils/jest/index.js +1 -1
  40. package/build/development/shared/utils/jest/index.js.map +1 -1
  41. package/build/development/style.css +387 -225
  42. package/build/development/web.bundle.js +113 -53
  43. package/build/production/client/index.js +1 -1
  44. package/build/production/client/index.js.map +1 -1
  45. package/build/production/index.js +1 -1
  46. package/build/production/index.js.map +1 -1
  47. package/build/production/server/index.js +1 -1
  48. package/build/production/server/index.js.map +1 -1
  49. package/build/production/server/utils/index.js +1 -1
  50. package/build/production/shared/components/Checkbox/index.js +2 -2
  51. package/build/production/shared/components/Checkbox/index.js.map +1 -1
  52. package/build/production/shared/components/Input/index.js +1 -1
  53. package/build/production/shared/components/Input/index.js.map +1 -1
  54. package/build/production/shared/components/Modal/index.js +4 -2
  55. package/build/production/shared/components/Modal/index.js.map +1 -1
  56. package/build/production/shared/components/TextArea/index.js +3 -3
  57. package/build/production/shared/components/TextArea/index.js.map +1 -1
  58. package/build/production/shared/components/WithTooltip/index.js +1 -1
  59. package/build/production/shared/components/WithTooltip/index.js.map +1 -1
  60. package/build/production/shared/components/YouTubeVideo/index.js +2 -2
  61. package/build/production/shared/components/YouTubeVideo/index.js.map +1 -1
  62. package/build/production/shared/components/index.js +1 -1
  63. package/build/production/shared/components/index.js.map +1 -1
  64. package/build/production/shared/components/selectors/CustomDropdown/Options/index.js +7 -0
  65. package/build/production/shared/components/selectors/CustomDropdown/Options/index.js.map +1 -0
  66. package/build/production/shared/components/selectors/CustomDropdown/index.js +4 -0
  67. package/build/production/shared/components/selectors/CustomDropdown/index.js.map +1 -0
  68. package/build/production/shared/components/selectors/NativeDropdown/index.js +25 -0
  69. package/build/production/shared/components/selectors/NativeDropdown/index.js.map +1 -0
  70. package/build/production/shared/components/selectors/Switch/index.js +2 -0
  71. package/build/production/shared/components/selectors/Switch/index.js.map +1 -0
  72. package/build/production/shared/components/selectors/common.js +3 -0
  73. package/build/production/shared/components/selectors/common.js.map +1 -0
  74. package/build/production/shared/components/selectors/index.js +2 -0
  75. package/build/production/shared/components/selectors/index.js.map +1 -0
  76. package/build/production/shared/utils/index.js +1 -1
  77. package/build/production/shared/utils/index.js.map +1 -1
  78. package/build/production/shared/utils/jest/E2eSsrEnv.js +3 -1
  79. package/build/production/shared/utils/jest/E2eSsrEnv.js.map +1 -1
  80. package/build/production/shared/utils/jest/index.js +1 -1
  81. package/build/production/shared/utils/jest/index.js.map +1 -1
  82. package/build/production/style.css +1 -1
  83. package/build/production/style.css.map +1 -1
  84. package/build/production/web.bundle.js +1 -1
  85. package/build/production/web.bundle.js.map +1 -1
  86. package/build/types-code/client/index.d.ts +1 -0
  87. package/build/types-code/index.d.ts +1 -1
  88. package/build/types-code/shared/components/Checkbox/index.d.ts +1 -1
  89. package/build/types-code/shared/components/Input/index.d.ts +1 -1
  90. package/build/types-code/shared/components/Modal/index.d.ts +3 -1
  91. package/build/types-code/shared/components/TextArea/index.d.ts +1 -0
  92. package/build/types-code/shared/components/index.d.ts +1 -2
  93. package/build/types-code/shared/components/selectors/CustomDropdown/Options/index.d.ts +17 -0
  94. package/build/types-code/shared/components/selectors/CustomDropdown/index.d.ts +4 -0
  95. package/build/types-code/shared/components/selectors/NativeDropdown/index.d.ts +3 -0
  96. package/build/types-code/shared/components/selectors/Switch/index.d.ts +13 -0
  97. package/build/types-code/shared/components/selectors/common.d.ts +27 -0
  98. package/build/types-code/shared/components/selectors/index.d.ts +3 -0
  99. package/build/types-scss/src/shared/components/Modal/styles.scss.d.ts +1 -0
  100. package/build/types-scss/src/shared/components/selectors/CustomDropdown/Options/style.scss.d.ts +1 -0
  101. package/build/types-scss/src/shared/components/selectors/CustomDropdown/theme.scss.d.ts +10 -0
  102. package/build/types-scss/src/shared/components/{Dropdown → selectors/NativeDropdown}/theme.scss.d.ts +1 -0
  103. package/build/types-scss/src/shared/components/selectors/Switch/theme.scss.d.ts +6 -0
  104. package/package.json +30 -30
  105. package/src/client/index.tsx +2 -1
  106. package/src/index.ts +1 -0
  107. package/src/shared/components/Button/style.scss +1 -0
  108. package/src/shared/components/Checkbox/index.tsx +3 -3
  109. package/src/shared/components/Input/index.tsx +3 -3
  110. package/src/shared/components/Modal/base-theme.scss +1 -1
  111. package/src/shared/components/Modal/index.tsx +40 -5
  112. package/src/shared/components/Modal/styles.scss +2 -4
  113. package/src/shared/components/TextArea/index.tsx +5 -0
  114. package/src/shared/components/TextArea/style.scss +8 -0
  115. package/src/shared/components/YouTubeVideo/base.scss +3 -1
  116. package/src/shared/components/YouTubeVideo/index.tsx +2 -3
  117. package/src/shared/components/index.ts +2 -2
  118. package/src/shared/components/selectors/CustomDropdown/Options/index.tsx +107 -0
  119. package/src/shared/components/selectors/CustomDropdown/Options/style.scss +6 -0
  120. package/src/shared/components/selectors/CustomDropdown/index.tsx +115 -0
  121. package/src/shared/components/selectors/CustomDropdown/theme.scss +90 -0
  122. package/src/shared/components/{Dropdown → selectors/NativeDropdown}/index.tsx +21 -50
  123. package/src/shared/components/{Dropdown → selectors/NativeDropdown}/theme.scss +5 -0
  124. package/src/shared/components/selectors/Switch/index.tsx +94 -0
  125. package/src/shared/components/selectors/Switch/theme.scss +39 -0
  126. package/src/shared/components/selectors/common.ts +54 -0
  127. package/src/shared/components/selectors/index.ts +3 -0
  128. package/src/shared/utils/jest/E2eSsrEnv.ts +5 -1
  129. package/build/development/shared/components/Dropdown/index.js.map +0 -1
  130. package/build/development/shared/components/ScalableRect/index.js +0 -80
  131. package/build/development/shared/components/ScalableRect/index.js.map +0 -1
  132. package/build/production/shared/components/Dropdown/index.js +0 -24
  133. package/build/production/shared/components/Dropdown/index.js.map +0 -1
  134. package/build/production/shared/components/ScalableRect/index.js +0 -21
  135. package/build/production/shared/components/ScalableRect/index.js.map +0 -1
  136. package/build/types-code/shared/components/Dropdown/index.d.ts +0 -17
  137. package/build/types-code/shared/components/ScalableRect/index.d.ts +0 -19
  138. package/build/types-scss/src/shared/components/ScalableRect/style.scss.d.ts +0 -2
  139. package/src/shared/components/ScalableRect/index.tsx +0 -84
  140. package/src/shared/components/ScalableRect/style.scss +0 -10
package/bin/build.js CHANGED
@@ -75,6 +75,11 @@ const cmdLineArgs = program.opts();
75
75
 
76
76
  const { buildType } = cmdLineArgs;
77
77
 
78
+ if (program.args.length) {
79
+ const details = program.args.map((x) => `\t${x}`).join('\n');
80
+ program.error(`Unrecognized arguments:\n${details}`);
81
+ }
82
+
78
83
  /* Validates the build type argument, */
79
84
  if (!VALID_BUILD_TYPES.includes(buildType)) {
80
85
  throw new Error('Invalid build type');
@@ -24,7 +24,7 @@ function Launch(Application) {
24
24
  const container = document.getElementById('react-view');
25
25
  if (!container) throw Error('Failed to find container for React app');
26
26
  const scene = /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactGlobalState.GlobalStateProvider, {
27
- initialState: (0, _getInj.default)().ISTATE,
27
+ initialState: (0, _getInj.default)().ISTATE || options.initialState,
28
28
  children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactRouterDom.BrowserRouter, {
29
29
  future: {
30
30
  v7_relativeSplatPath: true
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":["require","_reactGlobalState","_client","_reactRouterDom","_getInj","_interopRequireDefault","_jsxRuntime","Launch","Application","options","arguments","length","undefined","container","document","getElementById","Error","scene","jsx","GlobalStateProvider","initialState","getInj","ISTATE","children","BrowserRouter","future","v7_relativeSplatPath","dontHydrate","root","createRoot","render","hydrateRoot"],"sources":["../../../src/client/index.tsx"],"sourcesContent":["// Initialization of client-side code.\n/* global document */\n\nimport { type ComponentType } from 'react';\n\nimport { GlobalStateProvider } from '@dr.pogodin/react-global-state';\n\nimport { createRoot, hydrateRoot } from 'react-dom/client';\nimport { BrowserRouter } from 'react-router-dom';\n\nimport getInj from './getInj';\n\ntype OptionsT = {\n dontHydrate?: boolean;\n};\n\n/**\n * Prepares and launches the app at client side.\n * @param Application Root application component\n * @param [options={}] Optional. Additional settings.\n */\nexport default function Launch(\n Application: ComponentType,\n options: OptionsT = {},\n) {\n const container = document.getElementById('react-view');\n if (!container) throw Error('Failed to find container for React app');\n const scene = (\n <GlobalStateProvider initialState={getInj().ISTATE}>\n <BrowserRouter future={{ v7_relativeSplatPath: true }}>\n <Application />\n </BrowserRouter>\n </GlobalStateProvider>\n );\n\n if (options.dontHydrate) {\n const root = createRoot(container);\n root.render(scene);\n } else hydrateRoot(container, scene);\n}\n"],"mappings":";;;;;;;AAGAA,OAAA;AAEA,IAAAC,iBAAA,GAAAD,OAAA;AAEA,IAAAE,OAAA,GAAAF,OAAA;AACA,IAAAG,eAAA,GAAAH,OAAA;AAEA,IAAAI,OAAA,GAAAC,sBAAA,CAAAL,OAAA;AAA8B,IAAAM,WAAA,GAAAN,OAAA;AAV9B;AACA;;AAeA;AACA;AACA;AACA;AACA;AACe,SAASO,MAAMA,CAC5BC,WAA0B,EAE1B;EAAA,IADAC,OAAiB,GAAAC,SAAA,CAAAC,MAAA,QAAAD,SAAA,QAAAE,SAAA,GAAAF,SAAA,MAAG,CAAC,CAAC;EAEtB,MAAMG,SAAS,GAAGC,QAAQ,CAACC,cAAc,CAAC,YAAY,CAAC;EACvD,IAAI,CAACF,SAAS,EAAE,MAAMG,KAAK,CAAC,wCAAwC,CAAC;EACrE,MAAMC,KAAK,gBACT,IAAAX,WAAA,CAAAY,GAAA,EAACjB,iBAAA,CAAAkB,mBAAmB;IAACC,YAAY,EAAE,IAAAC,eAAM,EAAC,CAAC,CAACC,MAAO;IAAAC,QAAA,eACjD,IAAAjB,WAAA,CAAAY,GAAA,EAACf,eAAA,CAAAqB,aAAa;MAACC,MAAM,EAAE;QAAEC,oBAAoB,EAAE;MAAK,CAAE;MAAAH,QAAA,eACpD,IAAAjB,WAAA,CAAAY,GAAA,EAACV,WAAW,IAAE;IAAC,CACF;EAAC,CACG,CACtB;EAED,IAAIC,OAAO,CAACkB,WAAW,EAAE;IACvB,MAAMC,IAAI,GAAG,IAAAC,kBAAU,EAAChB,SAAS,CAAC;IAClCe,IAAI,CAACE,MAAM,CAACb,KAAK,CAAC;EACpB,CAAC,MAAM,IAAAc,mBAAW,EAAClB,SAAS,EAAEI,KAAK,CAAC;AACtC","ignoreList":[]}
1
+ {"version":3,"file":"index.js","names":["require","_reactGlobalState","_client","_reactRouterDom","_getInj","_interopRequireDefault","_jsxRuntime","Launch","Application","options","arguments","length","undefined","container","document","getElementById","Error","scene","jsx","GlobalStateProvider","initialState","getInj","ISTATE","children","BrowserRouter","future","v7_relativeSplatPath","dontHydrate","root","createRoot","render","hydrateRoot"],"sources":["../../../src/client/index.tsx"],"sourcesContent":["// Initialization of client-side code.\n/* global document */\n\nimport { type ComponentType } from 'react';\n\nimport { GlobalStateProvider } from '@dr.pogodin/react-global-state';\n\nimport { createRoot, hydrateRoot } from 'react-dom/client';\nimport { BrowserRouter } from 'react-router-dom';\n\nimport getInj from './getInj';\n\ntype OptionsT = {\n dontHydrate?: boolean;\n initialState?: any;\n};\n\n/**\n * Prepares and launches the app at client side.\n * @param Application Root application component\n * @param [options={}] Optional. Additional settings.\n */\nexport default function Launch(\n Application: ComponentType,\n options: OptionsT = {},\n) {\n const container = document.getElementById('react-view');\n if (!container) throw Error('Failed to find container for React app');\n const scene = (\n <GlobalStateProvider initialState={getInj().ISTATE || options.initialState}>\n <BrowserRouter future={{ v7_relativeSplatPath: true }}>\n <Application />\n </BrowserRouter>\n </GlobalStateProvider>\n );\n\n if (options.dontHydrate) {\n const root = createRoot(container);\n root.render(scene);\n } else hydrateRoot(container, scene);\n}\n"],"mappings":";;;;;;;AAGAA,OAAA;AAEA,IAAAC,iBAAA,GAAAD,OAAA;AAEA,IAAAE,OAAA,GAAAF,OAAA;AACA,IAAAG,eAAA,GAAAH,OAAA;AAEA,IAAAI,OAAA,GAAAC,sBAAA,CAAAL,OAAA;AAA8B,IAAAM,WAAA,GAAAN,OAAA;AAV9B;AACA;;AAgBA;AACA;AACA;AACA;AACA;AACe,SAASO,MAAMA,CAC5BC,WAA0B,EAE1B;EAAA,IADAC,OAAiB,GAAAC,SAAA,CAAAC,MAAA,QAAAD,SAAA,QAAAE,SAAA,GAAAF,SAAA,MAAG,CAAC,CAAC;EAEtB,MAAMG,SAAS,GAAGC,QAAQ,CAACC,cAAc,CAAC,YAAY,CAAC;EACvD,IAAI,CAACF,SAAS,EAAE,MAAMG,KAAK,CAAC,wCAAwC,CAAC;EACrE,MAAMC,KAAK,gBACT,IAAAX,WAAA,CAAAY,GAAA,EAACjB,iBAAA,CAAAkB,mBAAmB;IAACC,YAAY,EAAE,IAAAC,eAAM,EAAC,CAAC,CAACC,MAAM,IAAIb,OAAO,CAACW,YAAa;IAAAG,QAAA,eACzE,IAAAjB,WAAA,CAAAY,GAAA,EAACf,eAAA,CAAAqB,aAAa;MAACC,MAAM,EAAE;QAAEC,oBAAoB,EAAE;MAAK,CAAE;MAAAH,QAAA,eACpD,IAAAjB,WAAA,CAAAY,GAAA,EAACV,WAAW,IAAE;IAAC,CACF;EAAC,CACG,CACtB;EAED,IAAIC,OAAO,CAACkB,WAAW,EAAE;IACvB,MAAMC,IAAI,GAAG,IAAAC,kBAAU,EAAChB,SAAS,CAAC;IAClCe,IAAI,CAACE,MAAM,CAACb,KAAK,CAAC;EACpB,CAAC,MAAM,IAAAc,mBAAW,EAAClB,SAAS,EAAEI,KAAK,CAAC;AACtC","ignoreList":[]}
@@ -24,6 +24,7 @@ var _exportNames = {
24
24
  PT: true,
25
25
  getGlobalState: true,
26
26
  GlobalStateProvider: true,
27
+ newAsyncDataEnvelope: true,
27
28
  useAsyncCollection: true,
28
29
  useAsyncData: true,
29
30
  useGlobalState: true,
@@ -97,6 +98,12 @@ Object.defineProperty(exports, "isomorphy", {
97
98
  return _utils.isomorphy;
98
99
  }
99
100
  });
101
+ Object.defineProperty(exports, "newAsyncDataEnvelope", {
102
+ enumerable: true,
103
+ get: function () {
104
+ return _reactGlobalState.newAsyncDataEnvelope;
105
+ }
106
+ });
100
107
  exports.server = void 0;
101
108
  Object.defineProperty(exports, "splitComponent", {
102
109
  enumerable: true,
@@ -170,7 +177,7 @@ Object.keys(_components).forEach(function (key) {
170
177
  });
171
178
  });
172
179
  function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
173
- function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
180
+ function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
174
181
  const server = exports.server = _utils.webpack.requireWeak("./server", __dirname);
175
182
  const client = exports.client = server ? undefined : require("./client").default;
176
183
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":["_utils","require","_axios","_interopRequireDefault","_PT","_interopRequireWildcard","exports","PT","_reactGlobalState","_components","Object","keys","forEach","key","prototype","hasOwnProperty","call","_exportNames","defineProperty","enumerable","get","_getRequireWildcardCache","e","WeakMap","r","t","__esModule","default","has","n","__proto__","a","getOwnPropertyDescriptor","u","i","set","server","webpack","requireWeak","__dirname","client","undefined"],"sources":["../../src/index.ts"],"sourcesContent":["import 'styles/global.scss';\n\nimport { webpack } from 'utils';\n\nimport type ServerT from './server';\n\nconst server = webpack.requireWeak('./server', __dirname) as (typeof ServerT) | null;\n\nconst client = server ? undefined : require('./client').default;\n\nexport { default as api } from 'axios';\nexport * as PT from 'prop-types';\n\nexport {\n type AsyncCollectionLoaderT,\n type AsyncDataEnvelopeT,\n type AsyncDataLoaderT,\n type ForceT,\n type UseAsyncDataOptionsT,\n type UseAsyncDataResT,\n type UseGlobalStateResT,\n type ValueOrInitializerT,\n getGlobalState,\n GlobalStateProvider,\n useAsyncCollection,\n useAsyncData,\n useGlobalState,\n withGlobalStateType,\n} from '@dr.pogodin/react-global-state';\n\nexport * from 'components';\n\nexport {\n type Theme,\n config,\n Barrier,\n Emitter,\n isomorphy,\n getSsrContext,\n JU,\n Semaphore,\n splitComponent,\n themed,\n ThemeProvider,\n time,\n webpack,\n withRetries,\n} from 'utils';\n\nexport { client, server };\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEA,IAAAA,MAAA,GAAAC,OAAA;AAQA,IAAAC,MAAA,GAAAC,sBAAA,CAAAF,OAAA;AAAuC,IAAAG,GAAA,GAAAC,uBAAA,CAAAJ,OAAA;AAAAK,OAAA,CAAAC,EAAA,GAAAH,GAAA;AAGvC,IAAAI,iBAAA,GAAAP,OAAA;AAiBA,IAAAQ,WAAA,GAAAR,OAAA;AAAAS,MAAA,CAAAC,IAAA,CAAAF,WAAA,EAAAG,OAAA,WAAAC,GAAA;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,CAAAQ,cAAA,CAAAW,CAAA,EAAAI,CAAA,EAAAC,CAAA,IAAAL,CAAA,CAAAI,CAAA,IAAAX,CAAA,CAAAW,CAAA,YAAAJ,CAAA,CAAAF,OAAA,GAAAL,CAAA,EAAAG,CAAA,IAAAA,CAAA,CAAAU,GAAA,CAAAb,CAAA,EAAAO,CAAA,GAAAA,CAAA;AAxB3B,MAAMO,MAAM,GAAA9B,OAAA,CAAA8B,MAAA,GAAGC,cAAO,CAACC,WAAW,aAAaC,SAAS,CAA4B;AAEpF,MAAMC,MAAM,GAAAlC,OAAA,CAAAkC,MAAA,GAAGJ,MAAM,GAAGK,SAAS,GAAGxC,OAAO,WAAW,CAAC,CAAC0B,OAAO","ignoreList":[]}
1
+ {"version":3,"file":"index.js","names":["_utils","require","_axios","_interopRequireDefault","_PT","_interopRequireWildcard","exports","PT","_reactGlobalState","_components","Object","keys","forEach","key","prototype","hasOwnProperty","call","_exportNames","defineProperty","enumerable","get","_getRequireWildcardCache","e","WeakMap","r","t","__esModule","default","has","n","__proto__","a","getOwnPropertyDescriptor","u","i","set","server","webpack","requireWeak","__dirname","client","undefined"],"sources":["../../src/index.ts"],"sourcesContent":["import 'styles/global.scss';\n\nimport { webpack } from 'utils';\n\nimport type ServerT from './server';\n\nconst server = webpack.requireWeak('./server', __dirname) as (typeof ServerT) | null;\n\nconst client = server ? undefined : require('./client').default;\n\nexport { default as api } from 'axios';\nexport * as PT from 'prop-types';\n\nexport {\n type AsyncCollectionLoaderT,\n type AsyncDataEnvelopeT,\n type AsyncDataLoaderT,\n type ForceT,\n type UseAsyncDataOptionsT,\n type UseAsyncDataResT,\n type UseGlobalStateResT,\n type ValueOrInitializerT,\n getGlobalState,\n GlobalStateProvider,\n newAsyncDataEnvelope,\n useAsyncCollection,\n useAsyncData,\n useGlobalState,\n withGlobalStateType,\n} from '@dr.pogodin/react-global-state';\n\nexport * from 'components';\n\nexport {\n type Theme,\n config,\n Barrier,\n Emitter,\n isomorphy,\n getSsrContext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,SAAAJ,CAAA,eAAAA,CAAA,uBAAAA,CAAA,yBAAAA,CAAA,WAAAK,OAAA,EAAAL,CAAA,QAAAG,CAAA,GAAAJ,wBAAA,CAAAG,CAAA,OAAAC,CAAA,IAAAA,CAAA,CAAAG,GAAA,CAAAN,CAAA,UAAAG,CAAA,CAAAL,GAAA,CAAAE,CAAA,OAAAO,CAAA,KAAAC,SAAA,UAAAC,CAAA,GAAArB,MAAA,CAAAQ,cAAA,IAAAR,MAAA,CAAAsB,wBAAA,WAAAC,CAAA,IAAAX,CAAA,oBAAAW,CAAA,OAAAlB,cAAA,CAAAC,IAAA,CAAAM,CAAA,EAAAW,CAAA,SAAAC,CAAA,GAAAH,CAAA,GAAArB,MAAA,CAAAsB,wBAAA,CAAAV,CAAA,EAAAW,CAAA,UAAAC,CAAA,KAAAA,CAAA,CAAAd,GAAA,IAAAc,CAAA,CAAAC,GAAA,IAAAzB,MAAA,CAAAQ,cAAA,CAAAW,CAAA,EAAAI,CAAA,EAAAC,CAAA,IAAAL,CAAA,CAAAI,CAAA,IAAAX,CAAA,CAAAW,CAAA,YAAAJ,CAAA,CAAAF,OAAA,GAAAL,CAAA,EAAAG,CAAA,IAAAA,CAAA,CAAAU,GAAA,CAAAb,CAAA,EAAAO,CAAA,GAAAA,CAAA;AAzB3B,MAAMO,MAAM,GAAA9B,OAAA,CAAA8B,MAAA,GAAGC,cAAO,CAACC,WAAW,aAAaC,SAAS,CAA4B;AAEpF,MAAMC,MAAM,GAAAlC,OAAA,CAAAkC,MAAA,GAAGJ,MAAM,GAAGK,SAAS,GAAGxC,OAAO,WAAW,CAAC,CAAC0B,OAAO","ignoreList":[]}
@@ -27,7 +27,7 @@ var _server = _interopRequireWildcard(require("./server"));
27
27
  var _renderer = require("./renderer");
28
28
  var _utils = require("./utils");
29
29
  function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
30
- function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
30
+ function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
31
31
  /* Polyfill required by ReactJS. */
32
32
 
33
33
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":["require","_http","_interopRequireDefault","_https","_lodash","_server","_interopRequireWildcard","_renderer","_utils","_getRequireWildcardCache","e","WeakMap","r","t","__esModule","default","has","get","n","__proto__","a","Object","defineProperty","getOwnPropertyDescriptor","u","prototype","hasOwnProperty","call","i","set","normalizePort","value","port","toNumber","isFinite","isNumber","launchServer","webpackConfig","options","ops","cloneDeep","process","env","PORT","defaults","httpsRedirect","logger","undefined","newDefaultLogger","defaultLogLevel","defaultLoggerLogLevel","expressServer","serverFactory","httpServer","https","createServer","cert","key","http","on","error","syscall","bind","isString","code","exit","addr","address","info","NODE_ENV","listen","SCRIPT_LOCATIONS"],"sources":["../../../src/server/index.ts"],"sourcesContent":["import 'source-map-support/register';\n\nimport http from 'http';\nimport https from 'https';\n\nimport {\n cloneDeep,\n defaults,\n isFinite,\n isNumber,\n isString,\n toNumber,\n} from 'lodash';\n\n/* Polyfill required by ReactJS. */\nimport 'raf/polyfill';\n\nimport { type Configuration } from 'webpack';\n\nimport serverFactory, { type OptionsT as ServerOptionsT } from './server';\nimport { SCRIPT_LOCATIONS, newDefaultLogger } from './renderer';\n\nexport {\n getDefaultCspSettings,\n} from './server';\n\nexport { errors } from './utils';\n\n/**\n * Normalizes a port into a number, string, or false.\n * TODO: Drop this function?\n * @param value Port name or number.\n * @return Port number (Number), name (String), or false.\n */\nfunction normalizePort(value: number | string) {\n const port = toNumber(value);\n if (isFinite(port)) return port; /* port number */\n if (!isNumber(port)) return value; /* named pipe */\n return false;\n}\n\ntype OptionsT = ServerOptionsT & {\n https?: {\n cert: string;\n key: string;\n },\n\n // TODO: Should we limit it to number | string, and throw if it is different value?\n port?: false | number | string;\n};\n\n/**\n * Creates and launches web-server for ReactJS application. Allows zero\n * or detailed configuration, supports server-side rendering,\n * and development tools, including Hot Module Reloading (HMR).\n *\n * NOTE: Many of options defined below are passed down to the server and\n * renderer factories, and their declared default values are set in those\n * factories, rather than here.\n *\n * @param {object} webpackConfig Webpack configuration used to build\n * the frontend bundle. In production mode the server will read out of it\n * `context`, `publicPath`, and a few other parameters, necessary to locate\n * and serve the app bundle. In development mode the server will use entire\n * provided config to build the app bundle in memory, and further watch and\n * update it via HMR.\n * @param {object} [options] Additional parameters.\n * @param {Component} [options.Application] The root ReactJS component of\n * the app to use for the server-side rendering. When not provided\n * the server-side rendering is disabled.\n * @param {function} [options.beforeExpressJsError] Asynchronous callback\n * (`(server) => Promise<boolean>`) to be executed just before the default error\n * handler is added to ExpressJS server. If the callback is provided and its\n * result resolves to a truthy value, `react-utils` won't attach the default\n * error handler.\n * @param {function} [options.beforeExpressJsSetup] Asynchronous callback\n * (`(server) => Promise) to be executed right after ExpressJS server creation,\n * before any configuration is performed.\n * @param {BeforeRenderHook} [options.beforeRender] The hook to run just before\n * the server-side rendering. For each incoming request, it will be executed\n * just before the HTML markup is generated at the server. It allows to load\n * and provide the data necessary for server-side rendering, and also to inject\n * additional configuration and scripts into the generated HTML code.\n * @param {boolean} [options.noCsp] Set `true` to disable\n * Content-Security-Policy (CSP) headers altogether.\n * @param {function} [options.cspSettingsHook] A hook allowing\n * to customize [CSP](https://developer.mozilla.org/en-US/docs/Web/HTTP/CSP)\n * settings for [helmet](https://github.com/helmetjs/helmet)'s\n * `contentSecurityPolicy` middleware on per-request basis.\n *\n * If provided it should be a with signature: \\\n * `(defaultSettings: object, req: object)` &rArr; `object` \\\n * which gets the default settings (also used without the hook),\n * and the incoming request object. The hook response will be passed\n * as options to the helmet `contentSecurityPolicy` middleware.\n *\n * Currently, the default settings is the following object in production\n * environment:\n * ```js\n * {\n * directives: {\n * defaultSrc: [\"'self'\"],\n * baseUri: [\"'self'\"],\n * blockAllMixedContent: [],\n * fontSrc: [\"'self'\", 'https:', 'data:'],\n * frameAncestors: [\"'self'\"],\n * frameSrc: [\"'self'\", 'https://*.youtube.com'],\n * imgSrc: [\"'self'\", 'data:'],\n * objectSrc: [\"'none'\"],\n * scriptSrc: [\"'self'\", \"'unsafe-eval'\", `'nonce-UNIQUE_NONCE_VALUE'`],\n * scriptSrcAttr: [\"'none'\"],\n * styleSrc: [\"'self'\", 'https:', \"'unsafe-inline'\"],\n * upgradeInsecureRequests: [] // Removed in dev mode.\n * }\n * }\n * ```\n * It matches the default value used by Helmet with a few updates:\n * - YouTube host is whitelisted in the `frameSrc` directive to ensure\n * the {@link YouTubeVideo} component works.\n * - An unique per-request nonce is added to `scriptSrc` directive to\n * whitelist auxiliary scripts injected by react-utils. The actual nonce\n * value can be fetched by host code via `.nonce` field of `req` argument\n * of `.beforeRender` hook.\n * - `upgradeInsecureRequests` directive is removed in development mode,\n * to simplify local testing with http requests.\n * @param {string} [options.defaultLoggerLogLevel='info'] Log level for\n * the default logger, which is created if no `logger` option provided.\n * @param {boolean} [options.devMode] Pass in `true` to start the server in\n * development mode.\n * @param {string} [options.favicon] Path to the favicon to use by the server.\n * By default no favicon is used.\n * @param {object} [options.https] If provided, HTTPS server will be started,\n * instead of HTTP otherwise. The object should provide SSL certificate and key\n * via two string fields: `cert`, and `key`.\n * @param {string} [options.https.cert] SSL Certificate.\n * @param {string} [options.https.key] SSL key.\n * @param {boolean} [options.httpsRedirect=true] Pass in `true` to enable\n * automatic redirection of all incoming HTTP requests to HTTPS.\n *\n * To smoothly use it at `localhost` you need to run the server in HTTPS mode,\n * and also properly create and install a self-signed SSL sertificate on your\n * system. This article is helpful:\n * [How to get HTTPS working on your local development environment in 5 minutes](https://medium.freecodecamp.org/how-to-get-https-working-on-your-local-development-environment-in-5-minutes-7af615770eec)\n * @param {Logger} [options.logger] The logger to use at server side.\n * By default [`winston`](https://www.npmjs.com/package/winston) logger\n * with console transport is used. The logger you provide, or the default\n * `winston` logger otherwise, will be attached to the created ExpressJS server\n * object.\n * @param {function} [options.onExpressJsSetup] An async callback\n * (`(server) => Promise`) to be triggered when most of the server\n * configuration is completed, just before the server-side renderer,\n * and the default error handler are attached. You can use it to mount\n * custom API routes. The server-side logger can be accessed as `server.logger`.\n * @param {number|string} [options.port=3000] The port to start the server on.\n * @param {number} [options.staticCacheSize=1.e7] The maximum\n * static cache size in bytes. Defaults to ~10 MB.\n * @param {function} [options.staticCacheController] When given, it activates,\n * and controls the static caching of generated HTML markup. When this function\n * is provided, on each incoming request it is triggered with the request\n * passed in as the argument. To attempt to serve the response from the cache\n * it should return the object with the following fields:\n * - `key: string` &ndash; the cache key for the response;\n * - `maxage?: number` &ndash; the maximum age of cached result in ms.\n * If undefined - infinite age is assumed.\n * @param {number} [options.maxSsrRounds=10] Maximum number of SSR rounds.\n * @param {number} [options.ssrTimeout=1000] SSR timeout in milliseconds,\n * defaults to 1 second.\n * @return {Promise<{ expressServer: object, httpServer: object }>} Resolves to\n * an object with created Express and HTTP servers.\n */\nexport default async function launchServer(webpackConfig: Configuration, options: OptionsT) {\n /* Options normalization. */\n const ops = options ? cloneDeep(options) : {};\n ops.port = normalizePort(ops.port || process.env.PORT || 3000);\n defaults(ops, { httpsRedirect: true });\n\n // TODO: Need a separate type for normalized options, which guarantees\n // the logger is set!\n if (ops.logger === undefined) {\n ops.logger = newDefaultLogger({\n defaultLogLevel: ops.defaultLoggerLogLevel,\n });\n }\n\n /* Creates servers, resolves and sets the port. */\n const expressServer = await serverFactory(webpackConfig, ops);\n\n let httpServer: http.Server;\n if (ops.https) {\n httpServer = https.createServer({\n cert: ops.https.cert,\n key: ops.https.key,\n }, expressServer);\n } else httpServer = http.createServer(expressServer);\n\n /* Sets error handler for HTTP(S) server. */\n httpServer.on('error', (error: Error) => {\n if ((error as any).syscall !== 'listen') throw error;\n const bind = isString(ops.port) ? `Pipe ${ops.port}` : `Port ${ops.port}`;\n\n /* Human-readable message for some specific listen errors. */\n switch ((error as any).code) {\n case 'EACCES':\n ops.logger!.error(`${bind} requires elevated privileges`);\n return process.exit(1);\n case 'EADDRINUSE':\n ops.logger!.error(`${bind} is already in use`);\n return process.exit(1);\n default:\n throw error;\n }\n });\n\n /* Listening event handler for HTTP(S) server. */\n httpServer.on('listening', () => {\n const addr = httpServer.address()!;\n const bind = isString(addr) ? `pipe ${addr}` : `port ${addr.port}`;\n ops.logger!.info(`Server listening on ${bind} in ${\n process.env.NODE_ENV} mode`);\n });\n\n httpServer.listen(ops.port);\n\n return {\n expressServer,\n httpServer,\n };\n}\n\nlaunchServer.SCRIPT_LOCATIONS = SCRIPT_LOCATIONS;\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAAAA,OAAA;AAEA,IAAAC,KAAA,GAAAC,sBAAA,CAAAF,OAAA;AACA,IAAAG,MAAA,GAAAD,sBAAA,CAAAF,OAAA;AAEA,IAAAI,OAAA,GAAAJ,OAAA;AAUAA,OAAA;AAEAA,OAAA;AAEA,IAAAK,OAAA,GAAAC,uBAAA,CAAAN,OAAA;AACA,IAAAO,SAAA,GAAAP,OAAA;AAMA,IAAAQ,MAAA,GAAAR,OAAA;AAAiC,SAAAS,yBA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AI,IAAAG,gBAAQ,EAACF,IAAI,CAAC,EAAE,OAAOA,IAAI,CAAC,CAAC;EACjC,IAAI,CAAC,IAAAG,gBAAQ,EAACH,IAAI,CAAC,EAAE,OAAOD,KAAK,CAAC,CAAC;EACnC,OAAO,KAAK;AACd;AAYA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACe,eAAeK,YAAYA,CAACC,aAA4B,EAAEC,OAAiB,EAAE;EAC1F;EACA,MAAMC,GAAG,GAAGD,OAAO,GAAG,IAAAE,iBAAS,EAACF,OAAO,CAAC,GAAG,CAAC,CAAC;EAC7CC,GAAG,CAACP,IAAI,GAAGF,aAAa,CAACS,GAAG,CAACP,IAAI,IAAIS,OAAO,CAACC,GAAG,CAACC,IAAI,IAAI,IAAI,CAAC;EAC9D,IAAAC,gBAAQ,EAACL,GAAG,EAAE;IAAEM,aAAa,EAAE;EAAK,CAAC,CAAC;;EAEtC;EACA;EACA,IAAIN,GAAG,CAACO,MAAM,KAAKC,SAAS,EAAE;IAC5BR,GAAG,CAACO,MAAM,GAAG,IAAAE,0BAAgB,EAAC;MAC5BC,eAAe,EAAEV,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GAAI,QAAOA,IAAK,EAAC,GAAI,QAAOA,IAAI,CAAClC,IAAK,EAAC;IAClEO,GAAG,CAACO,MAAM,CAAEsB,IAAI,CAAE,uBAAsBN,IAAK,OAC3CrB,OAAO,CAACC,GAAG,CAAC2B,QAAS,OAAM,CAAC;EAChC,CAAC,CAAC;EAEFhB,UAAU,CAACiB,MAAM,CAAC/B,GAAG,CAACP,IAAI,CAAC;EAE3B,OAAO;IACLmB,aAAa;IACbE;EACF,CAAC;AACH;AAEAjB,YAAY,CAACmC,gBAAgB,GAAGA,0BAAgB","ignoreList":[]}
1
+ {"version":3,"file":"index.js","names":["require","_http","_interopRequireDefault","_https","_lodash","_server","_interopRequireWildcard","_renderer","_utils","_getRequireWildcardCache","e","WeakMap","r","t","__esModule","default","has","get","n","__proto__","a","Object","defineProperty","getOwnPropertyDescriptor","u","hasOwnProperty","call","i","set","normalizePort","value","port","toNumber","isFinite","isNumber","launchServer","webpackConfig","options","ops","cloneDeep","process","env","PORT","defaults","httpsRedirect","logger","undefined","newDefaultLogger","defaultLogLevel","defaultLoggerLogLevel","expressServer","serverFactory","httpServer","https","createServer","cert","key","http","on","error","syscall","bind","isString","code","exit","addr","address","info","NODE_ENV","listen","SCRIPT_LOCATIONS"],"sources":["../../../src/server/index.ts"],"sourcesContent":["import 'source-map-support/register';\n\nimport http from 'http';\nimport https from 'https';\n\nimport {\n cloneDeep,\n defaults,\n isFinite,\n isNumber,\n isString,\n toNumber,\n} from 'lodash';\n\n/* Polyfill required by ReactJS. */\nimport 'raf/polyfill';\n\nimport { type Configuration } from 'webpack';\n\nimport serverFactory, { type OptionsT as ServerOptionsT } from './server';\nimport { SCRIPT_LOCATIONS, newDefaultLogger } from './renderer';\n\nexport {\n getDefaultCspSettings,\n} from './server';\n\nexport { errors } from './utils';\n\n/**\n * Normalizes a port into a number, string, or false.\n * TODO: Drop this function?\n * @param value Port name or number.\n * @return Port number (Number), name (String), or false.\n */\nfunction normalizePort(value: number | string) {\n const port = toNumber(value);\n if (isFinite(port)) return port; /* port number */\n if (!isNumber(port)) return value; /* named pipe */\n return false;\n}\n\ntype OptionsT = ServerOptionsT & {\n https?: {\n cert: string;\n key: string;\n },\n\n // TODO: Should we limit it to number | string, and throw if it is different value?\n port?: false | number | string;\n};\n\n/**\n * Creates and launches web-server for ReactJS application. Allows zero\n * or detailed configuration, supports server-side rendering,\n * and development tools, including Hot Module Reloading (HMR).\n *\n * NOTE: Many of options defined below are passed down to the server and\n * renderer factories, and their declared default values are set in those\n * factories, rather than here.\n *\n * @param {object} webpackConfig Webpack configuration used to build\n * the frontend bundle. In production mode the server will read out of it\n * `context`, `publicPath`, and a few other parameters, necessary to locate\n * and serve the app bundle. In development mode the server will use entire\n * provided config to build the app bundle in memory, and further watch and\n * update it via HMR.\n * @param {object} [options] Additional parameters.\n * @param {Component} [options.Application] The root ReactJS component of\n * the app to use for the server-side rendering. When not provided\n * the server-side rendering is disabled.\n * @param {function} [options.beforeExpressJsError] Asynchronous callback\n * (`(server) => Promise<boolean>`) to be executed just before the default error\n * handler is added to ExpressJS server. If the callback is provided and its\n * result resolves to a truthy value, `react-utils` won't attach the default\n * error handler.\n * @param {function} [options.beforeExpressJsSetup] Asynchronous callback\n * (`(server) => Promise) to be executed right after ExpressJS server creation,\n * before any configuration is performed.\n * @param {BeforeRenderHook} [options.beforeRender] The hook to run just before\n * the server-side rendering. For each incoming request, it will be executed\n * just before the HTML markup is generated at the server. It allows to load\n * and provide the data necessary for server-side rendering, and also to inject\n * additional configuration and scripts into the generated HTML code.\n * @param {boolean} [options.noCsp] Set `true` to disable\n * Content-Security-Policy (CSP) headers altogether.\n * @param {function} [options.cspSettingsHook] A hook allowing\n * to customize [CSP](https://developer.mozilla.org/en-US/docs/Web/HTTP/CSP)\n * settings for [helmet](https://github.com/helmetjs/helmet)'s\n * `contentSecurityPolicy` middleware on per-request basis.\n *\n * If provided it should be a with signature: \\\n * `(defaultSettings: object, req: object)` &rArr; `object` \\\n * which gets the default settings (also used without the hook),\n * and the incoming request object. The hook response will be passed\n * as options to the helmet `contentSecurityPolicy` middleware.\n *\n * Currently, the default settings is the following object in production\n * environment:\n * ```js\n * {\n * directives: {\n * defaultSrc: [\"'self'\"],\n * baseUri: [\"'self'\"],\n * blockAllMixedContent: [],\n * fontSrc: [\"'self'\", 'https:', 'data:'],\n * frameAncestors: [\"'self'\"],\n * frameSrc: [\"'self'\", 'https://*.youtube.com'],\n * imgSrc: [\"'self'\", 'data:'],\n * objectSrc: [\"'none'\"],\n * scriptSrc: [\"'self'\", \"'unsafe-eval'\", `'nonce-UNIQUE_NONCE_VALUE'`],\n * scriptSrcAttr: [\"'none'\"],\n * styleSrc: [\"'self'\", 'https:', \"'unsafe-inline'\"],\n * upgradeInsecureRequests: [] // Removed in dev mode.\n * }\n * }\n * ```\n * It matches the default value used by Helmet with a few updates:\n * - YouTube host is whitelisted in the `frameSrc` directive to ensure\n * the {@link YouTubeVideo} component works.\n * - An unique per-request nonce is added to `scriptSrc` directive to\n * whitelist auxiliary scripts injected by react-utils. The actual nonce\n * value can be fetched by host code via `.nonce` field of `req` argument\n * of `.beforeRender` hook.\n * - `upgradeInsecureRequests` directive is removed in development mode,\n * to simplify local testing with http requests.\n * @param {string} [options.defaultLoggerLogLevel='info'] Log level for\n * the default logger, which is created if no `logger` option provided.\n * @param {boolean} [options.devMode] Pass in `true` to start the server in\n * development mode.\n * @param {string} [options.favicon] Path to the favicon to use by the server.\n * By default no favicon is used.\n * @param {object} [options.https] If provided, HTTPS server will be started,\n * instead of HTTP otherwise. The object should provide SSL certificate and key\n * via two string fields: `cert`, and `key`.\n * @param {string} [options.https.cert] SSL Certificate.\n * @param {string} [options.https.key] SSL key.\n * @param {boolean} [options.httpsRedirect=true] Pass in `true` to enable\n * automatic redirection of all incoming HTTP requests to HTTPS.\n *\n * To smoothly use it at `localhost` you need to run the server in HTTPS mode,\n * and also properly create and install a self-signed SSL sertificate on your\n * system. This article is helpful:\n * [How to get HTTPS working on your local development environment in 5 minutes](https://medium.freecodecamp.org/how-to-get-https-working-on-your-local-development-environment-in-5-minutes-7af615770eec)\n * @param {Logger} [options.logger] The logger to use at server side.\n * By default [`winston`](https://www.npmjs.com/package/winston) logger\n * with console transport is used. The logger you provide, or the default\n * `winston` logger otherwise, will be attached to the created ExpressJS server\n * object.\n * @param {function} [options.onExpressJsSetup] An async callback\n * (`(server) => Promise`) to be triggered when most of the server\n * configuration is completed, just before the server-side renderer,\n * and the default error handler are attached. You can use it to mount\n * custom API routes. The server-side logger can be accessed as `server.logger`.\n * @param {number|string} [options.port=3000] The port to start the server on.\n * @param {number} [options.staticCacheSize=1.e7] The maximum\n * static cache size in bytes. Defaults to ~10 MB.\n * @param {function} [options.staticCacheController] When given, it activates,\n * and controls the static caching of generated HTML markup. When this function\n * is provided, on each incoming request it is triggered with the request\n * passed in as the argument. To attempt to serve the response from the cache\n * it should return the object with the following fields:\n * - `key: string` &ndash; the cache key for the response;\n * - `maxage?: number` &ndash; the maximum age of cached result in ms.\n * If undefined - infinite age is assumed.\n * @param {number} [options.maxSsrRounds=10] Maximum number of SSR rounds.\n * @param {number} [options.ssrTimeout=1000] SSR timeout in milliseconds,\n * defaults to 1 second.\n * @return {Promise<{ expressServer: object, httpServer: object }>} Resolves to\n * an object with created Express and HTTP servers.\n */\nexport default async function launchServer(webpackConfig: Configuration, options: OptionsT) {\n /* Options normalization. */\n const ops = options ? cloneDeep(options) : {};\n ops.port = normalizePort(ops.port || process.env.PORT || 3000);\n defaults(ops, { httpsRedirect: true });\n\n // TODO: Need a separate type for normalized options, which guarantees\n // the logger is set!\n if (ops.logger === undefined) {\n ops.logger = newDefaultLogger({\n defaultLogLevel: ops.defaultLoggerLogLevel,\n });\n }\n\n /* Creates servers, resolves and sets the port. */\n const expressServer = await serverFactory(webpackConfig, ops);\n\n let httpServer: http.Server;\n if (ops.https) {\n httpServer = https.createServer({\n cert: ops.https.cert,\n key: ops.https.key,\n }, expressServer);\n } else httpServer = http.createServer(expressServer);\n\n /* Sets error handler for HTTP(S) server. */\n httpServer.on('error', (error: Error) => {\n if ((error as any).syscall !== 'listen') throw error;\n const bind = isString(ops.port) ? `Pipe ${ops.port}` : `Port ${ops.port}`;\n\n /* Human-readable message for some specific listen errors. */\n switch ((error as any).code) {\n case 'EACCES':\n ops.logger!.error(`${bind} requires elevated privileges`);\n return process.exit(1);\n case 'EADDRINUSE':\n ops.logger!.error(`${bind} is already in use`);\n return process.exit(1);\n default:\n throw error;\n }\n });\n\n /* Listening event handler for HTTP(S) server. */\n httpServer.on('listening', () => {\n const addr = httpServer.address()!;\n const bind = isString(addr) ? `pipe ${addr}` : `port ${addr.port}`;\n ops.logger!.info(`Server listening on ${bind} in ${\n process.env.NODE_ENV} mode`);\n });\n\n httpServer.listen(ops.port);\n\n return {\n expressServer,\n httpServer,\n };\n}\n\nlaunchServer.SCRIPT_LOCATIONS = SCRIPT_LOCATIONS;\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAAAA,OAAA;AAEA,IAAAC,KAAA,GAAAC,sBAAA,CAAAF,OAAA;AACA,IAAAG,MAAA,GAAAD,sBAAA,CAAAF,OAAA;AAEA,IAAAI,OAAA,GAAAJ,OAAA;AAUAA,OAAA;AAEAA,OAAA;AAEA,IAAAK,OAAA,GAAAC,uBAAA,CAAAN,OAAA;AACA,IAAAO,SAAA,GAAAP,OAAA;AAMA,IAAAQ,MAAA,GAAAR,OAAA;AAAiC,SAAAS,yBAAAC,CAAA,6BAAAC,OAAA,mBAAAC,CAAA,OAAAD,OAAA,IAAAE,CAAA,OAAAF,OAAA,YAAAF,wBAAA,YAAAA,CAAAC,CAAA,WAAAA,CAAA,GAAAG,CAAA,GAAAD,CAAA,KAAAF,CAAA;AAAA,SAAAJ,wBAAAI,CAAA,EAAAE,CAAA,SAAAA,CAAA,IAAAF,CAAA,IAAAA,CAAA,CAAAI,UAAA,SAAAJ,CAAA,eAAAA,CAAA,uBAAAA,CAAA,yBAAAA,CAAA,WAAAK,OAAA,EAAAL,CAAA,QAA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;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACe,eAAeK,YAAYA,CAACC,aAA4B,EAAEC,OAAiB,EAAE;EAC1F;EACA,MAAMC,GAAG,GAAGD,OAAO,GAAG,IAAAE,iBAAS,EAACF,OAAO,CAAC,GAAG,CAAC,CAAC;EAC7CC,GAAG,CAACP,IAAI,GAAGF,aAAa,CAACS,GAAG,CAACP,IAAI,IAAIS,OAAO,CAACC,GAAG,CAACC,IAAI,IAAI,IAAI,CAAC;EAC9D,IAAAC,gBAAQ,EAACL,GAAG,EAAE;IAAEM,aAAa,EAAE;EAAK,CAAC,CAAC;;EAEtC;EACA;EACA,IAAIN,GAAG,CAACO,MAAM,KAAKC,SAAS,EAAE;IAC5BR,GAAG,CAACO,MAAM,GAAG,IAAAE,0BAAgB,EAAC;MAC5BC,eAAe,EAAEV,GAAG,CAACW;IACvB,CAAC,CAAC;EACJ;;EAEA;EACA,MAAMC,aAAa,GAAG,MAAM,IAAAC,eAAa,EAACf,aAAa,EAAEE,GAAG,CAAC;EAE7D,IAAIc,UAAuB;EAC3B,IAAId,GAAG,CAACe,KAAK,EAAE;IACbD,UAAU,GAAGC,cAAK,CAACC,YAAY,CAAC;MAC9BC,IAAI,EAAEjB,GAAG,CAACe,KAAK,CAACE,IAAI;MACpBC,GAAG,EAAElB,GAAG,CAACe,KAAK,CAACG;IACjB,CAAC,EAAEN,aAAa,CAAC;EACnB,CAAC,MAAME,UAAU,GAA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5 @@ exports.errors = void 0;
7
7
  var _errors = _interopRequireWildcard(require("./errors"));
8
8
  exports.errors = _errors;
9
9
  function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
10
- function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
10
+ function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
11
11
  //# sourceMappingURL=index.js.map
@@ -24,7 +24,7 @@ const Checkbox = ({
24
24
  theme
25
25
  }) => /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
26
26
  className: theme.container,
27
- children: [label === undefined ? null : /*#__PURE__*/(0, _jsxRuntime.jsx)("p", {
27
+ children: [label === undefined ? null : /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
28
28
  className: theme.label,
29
29
  children: label
30
30
  }), /*#__PURE__*/(0, _jsxRuntime.jsx)("input", {
@@ -56,7 +56,7 @@ const ThemedCheckbox = (0, _reactThemes.default)(Checkbox, 'Checkbox', validThem
56
56
  */
57
57
  Checkbox.propTypes = {
58
58
  checked: _propTypes.default.bool,
59
- label: _propTypes.default.string,
59
+ label: _propTypes.default.node,
60
60
  onChange: _propTypes.default.func,
61
61
  theme: ThemedCheckbox.themeType.isRequired
62
62
  };
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":["_propTypes","_interopRequireDefault","require","_reactThemes","_jsxRuntime","defaultTheme","validThemeKeys","Checkbox","checked","label","onChange","theme","jsxs","className","container","children","undefined","jsx","checkbox","type","ThemedCheckbox","themed","propTypes","PT","bool","string","func","themeType","isRequired","defaultProps","_default","exports","default"],"sources":["../../../../../src/shared/components/Checkbox/index.tsx"],"sourcesContent":["import PT from 'prop-types';\n\nimport themed, { type Theme } from '@dr.pogodin/react-themes';\n\nimport defaultTheme from './theme.scss';\n\nconst validThemeKeys = ['checkbox', 'container', 'label'] as const;\n\ntype PropT = {\n checked?: boolean;\n label?: string;\n onChange?: React.ChangeEventHandler<HTMLInputElement>;\n theme: Theme<typeof validThemeKeys>;\n};\n\nconst Checkbox: React.FunctionComponent<PropT> = ({\n checked,\n label,\n onChange,\n theme,\n}) => (\n <div className={theme.container}>\n { label === undefined ? null : <p className={theme.label}>{label}</p> }\n <input\n checked={checked}\n className={theme.checkbox}\n onChange={onChange}\n type=\"checkbox\"\n />\n </div>\n);\n\n/**\n * Checkbox component theme: a map of\n * CSS classes to append to its elements:\n * @prop [checkbox] to the underlying checkbox `<input>` element.\n * @prop [container] to the root checkbox element.\n * @prop [label] to the checkbox label element.\n */\nconst ThemedCheckbox = themed(\n Checkbox,\n 'Checkbox',\n validThemeKeys,\n defaultTheme,\n);\n\n/**\n * The `<Checkbox>` component implements themeable checkboxes.\n * @param [props] Component properties.\n * @param [props.checked] Checkbox value.\n * @param [props.label] Checkbox label.\n * @param [props.onChange] State change handler.\n * @param [props.theme] _Ad hoc_ theme.\n * @param [props....]\n * [Other properties of themeable components](https://www.npmjs.com/package/@dr.pogodin/react-themes#themed-component-properties).\n */\nCheckbox.propTypes = {\n checked: PT.bool,\n label: PT.string,\n onChange: PT.func,\n theme: ThemedCheckbox.themeType.isRequired,\n};\n\nCheckbox.defaultProps = {\n checked: undefined,\n label: undefined,\n onChange: undefined,\n};\n\nexport default ThemedCheckbox;\n"],"mappings":";;;;;;;AAAA,IAAAA,UAAA,GAAAC,sBAAA,CAAAC,OAAA;AAEA,IAAAC,YAAA,GAAAF,sBAAA,CAAAC,OAAA;AAA8D,IAAAE,WAAA,GAAAF,OAAA;AAAA,MAAAG,YAAA;EAAA;EAAA;EAAA;EAAA;EAAA;EAAA;AAAA;AAI9D,MAAMC,cAAc,GAAG,CAAC,UAAU,EAAE,WAAW,EAAE,OAAO,CAAU;AASlE,MAAMC,QAAwC,GAAGA,CAAC;EAChDC,OAAO;EACPC,KAAK;EACLC,QAAQ;EACRC;AACF,CAAC,kBACC,IAAAP,WAAA,CAAAQ,IAAA;EAAKC,SAAS,EAAEF,KAAK,CAACG,SAAU;EAAAC,QAAA,GAC5BN,KAAK,KAAKO,SAAS,GAAG,IAAI,gBAAG,IAAAZ,WAAA,CAAAa,GAAA;IAAGJ,SAAS,EAAEF,KAAK,CAACF,KAAM;IAAAM,QAAA,EAAEN;EAAK,CAAI,CAAC,eACrE,IAAAL,WAAA,CAAAa,GAAA;IACET,OAAO,EAAEA,OAAQ;IACjBK,SAAS,EAAEF,KAAK,CAACO,QAAS;IAC1BR,QAAQ,EAAEA,QAAS;IACnBS,IAAI,EAAC;EAAU,CAChB,CAAC;AAAA,CACC,CACN;;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAMC,cAAc,GAAG,IAAAC,oBAAM,EAC3Bd,QAAQ,EACR,UAAU,EACVD,cAAc,EACdD,YACF,CAAC;;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACAE,QAAQ,CAACe,SAAS,GAAG;EACnBd,OAAO,EAAEe,kBAAE,CAACC,IAAI;EAChBf,KAAK,EAAEc,kBAAE,CAACE,MAAM;EAChBf,QAAQ,EAAEa,kBAAE,CAACG,IAAI;EACjBf,KAAK,EAAES,cAAc,CAACO,SAAS,CAACC;AAClC,CAAC;AAEDrB,QAAQ,CAACsB,YAAY,GAAG;EACtBrB,OAAO,EAAEQ,SAAS;EAClBP,KAAK,EAAEO,SAAS;EAChBN,QAAQ,EAAEM;AACZ,CAAC;AAAC,IAAAc,QAAA,GAAAC,OAAA,CAAAC,OAAA,GAEaZ,cAAc","ignoreList":[]}
1
+ {"version":3,"file":"index.js","names":["_propTypes","_interopRequireDefault","require","_reactThemes","_jsxRuntime","defaultTheme","validThemeKeys","Checkbox","checked","label","onChange","theme","jsxs","className","container","children","undefined","jsx","checkbox","type","ThemedCheckbox","themed","propTypes","PT","bool","node","func","themeType","isRequired","defaultProps","_default","exports","default"],"sources":["../../../../../src/shared/components/Checkbox/index.tsx"],"sourcesContent":["import PT from 'prop-types';\n\nimport themed, { type Theme } from '@dr.pogodin/react-themes';\n\nimport defaultTheme from './theme.scss';\n\nconst validThemeKeys = ['checkbox', 'container', 'label'] as const;\n\ntype PropT = {\n checked?: boolean;\n label?: React.ReactNode;\n onChange?: React.ChangeEventHandler<HTMLInputElement>;\n theme: Theme<typeof validThemeKeys>;\n};\n\nconst Checkbox: React.FunctionComponent<PropT> = ({\n checked,\n label,\n onChange,\n theme,\n}) => (\n <div className={theme.container}>\n { label === undefined ? null : <div className={theme.label}>{label}</div> }\n <input\n checked={checked}\n className={theme.checkbox}\n onChange={onChange}\n type=\"checkbox\"\n />\n </div>\n);\n\n/**\n * Checkbox component theme: a map of\n * CSS classes to append to its elements:\n * @prop [checkbox] to the underlying checkbox `<input>` element.\n * @prop [container] to the root checkbox element.\n * @prop [label] to the checkbox label element.\n */\nconst ThemedCheckbox = themed(\n Checkbox,\n 'Checkbox',\n validThemeKeys,\n defaultTheme,\n);\n\n/**\n * The `<Checkbox>` component implements themeable checkboxes.\n * @param [props] Component properties.\n * @param [props.checked] Checkbox value.\n * @param [props.label] Checkbox label.\n * @param [props.onChange] State change handler.\n * @param [props.theme] _Ad hoc_ theme.\n * @param [props....]\n * [Other properties of themeable components](https://www.npmjs.com/package/@dr.pogodin/react-themes#themed-component-properties).\n */\nCheckbox.propTypes = {\n checked: PT.bool,\n label: PT.node,\n onChange: PT.func,\n theme: ThemedCheckbox.themeType.isRequired,\n};\n\nCheckbox.defaultProps = {\n checked: undefined,\n label: undefined,\n onChange: undefined,\n};\n\nexport default ThemedCheckbox;\n"],"mappings":";;;;;;;AAAA,IAAAA,UAAA,GAAAC,sBAAA,CAAAC,OAAA;AAEA,IAAAC,YAAA,GAAAF,sBAAA,CAAAC,OAAA;AAA8D,IAAAE,WAAA,GAAAF,OAAA;AAAA,MAAAG,YAAA;EAAA;EAAA;EAAA;EAAA;EAAA;EAAA;AAAA;AAI9D,MAAMC,cAAc,GAAG,CAAC,UAAU,EAAE,WAAW,EAAE,OAAO,CAAU;AASlE,MAAMC,QAAwC,GAAGA,CAAC;EAChDC,OAAO;EACPC,KAAK;EACLC,QAAQ;EACRC;AACF,CAAC,kBACC,IAAAP,WAAA,CAAAQ,IAAA;EAAKC,SAAS,EAAEF,KAAK,CAACG,SAAU;EAAAC,QAAA,GAC5BN,KAAK,KAAKO,SAAS,GAAG,IAAI,gBAAG,IAAAZ,WAAA,CAAAa,GAAA;IAAKJ,SAAS,EAAEF,KAAK,CAACF,KAAM;IAAAM,QAAA,EAAEN;EAAK,CAAM,CAAC,eACzE,IAAAL,WAAA,CAAAa,GAAA;IACET,OAAO,EAAEA,OAAQ;IACjBK,SAAS,EAAEF,KAAK,CAACO,QAAS;IAC1BR,QAAQ,EAAEA,QAAS;IACnBS,IAAI,EAAC;EAAU,CAChB,CAAC;AAAA,CACC,CACN;;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAMC,cAAc,GAAG,IAAAC,oBAAM,EAC3Bd,QAAQ,EACR,UAAU,EACVD,cAAc,EACdD,YACF,CAAC;;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACAE,QAAQ,CAACe,SAAS,GAAG;EACnBd,OAAO,EAAEe,kBAAE,CAACC,IAAI;EAChBf,KAAK,EAAEc,kBAAE,CAACE,IAAI;EACdf,QAAQ,EAAEa,kBAAE,CAACG,IAAI;EACjBf,KAAK,EAAES,cAAc,CAACO,SAAS,CAACC;AAClC,CAAC;AAEDrB,QAAQ,CAACsB,YAAY,GAAG;EACtBrB,OAAO,EAAEQ,SAAS;EAClBP,KAAK,EAAEO,SAAS;EAChBN,QAAQ,EAAEM;AACZ,CAAC;AAAC,IAAAc,QAAA,GAAAC,OAAA,CAAAC,OAAA,GAEaZ,cAAc","ignoreList":[]}
@@ -33,7 +33,7 @@ const Input = /*#__PURE__*/(0, _react.forwardRef)(({
33
33
  ...rest
34
34
  }, ref) => /*#__PURE__*/(0, _jsxRuntime.jsxs)("span", {
35
35
  className: theme.container,
36
- children: [label === undefined ? null : /*#__PURE__*/(0, _jsxRuntime.jsx)("p", {
36
+ children: [label === undefined ? null : /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
37
37
  className: theme.label,
38
38
  children: label
39
39
  }), /*#__PURE__*/(0, _jsxRuntime.jsx)("input", {
@@ -44,7 +44,7 @@ const Input = /*#__PURE__*/(0, _react.forwardRef)(({
44
44
  }));
45
45
  const ThemedInput = (0, _reactThemes.default)(Input, 'Input', validThemeKeys, defaultTheme);
46
46
  Input.propTypes = {
47
- label: _propTypes.default.string,
47
+ label: _propTypes.default.node,
48
48
  theme: ThemedInput.themeType.isRequired
49
49
  };
50
50
  Input.defaultProps = {
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":["_propTypes","_interopRequireDefault","require","_react","_reactThemes","_jsxRuntime","defaultTheme","validThemeKeys","Input","forwardRef","label","theme","rest","ref","jsxs","className","container","children","undefined","jsx","input","ThemedInput","themed","propTypes","PT","string","themeType","isRequired","defaultProps","_default","exports","default"],"sources":["../../../../../src/shared/components/Input/index.tsx"],"sourcesContent":["import PT from 'prop-types';\nimport { forwardRef } from 'react';\n\nimport themed, { type Theme } from '@dr.pogodin/react-themes';\n\nimport defaultTheme from './theme.scss';\n\nconst validThemeKeys = [\n 'container',\n 'input',\n 'label',\n] as const;\n\ntype PropsT = React.InputHTMLAttributes<HTMLInputElement> & {\n label?: string;\n theme: Theme<typeof validThemeKeys>;\n};\n\n/**\n * Themeable input field, based on the standard HTML `<input>` element.\n * @param [props]\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 = forwardRef<HTMLInputElement, PropsT>((\n {\n label,\n theme,\n ...rest\n }: PropsT,\n ref,\n) => (\n <span className={theme.container}>\n { label === undefined ? null : <p className={theme.label}>{label}</p> }\n <input\n className={theme.input}\n ref={ref}\n {...rest} // eslint-disable-line react/jsx-props-no-spreading\n />\n </span>\n));\n\nconst ThemedInput = themed(Input, 'Input', validThemeKeys, defaultTheme);\n\nInput.propTypes = {\n label: PT.string,\n theme: ThemedInput.themeType.isRequired,\n};\n\nInput.defaultProps = {\n label: undefined,\n};\n\nexport default ThemedInput;\n"],"mappings":";;;;;;;AAAA,IAAAA,UAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,MAAA,GAAAD,OAAA;AAEA,IAAAE,YAAA,GAAAH,sBAAA,CAAAC,OAAA;AAA8D,IAAAG,WAAA,GAAAH,OAAA;AAAA,MAAAI,YAAA;EAAA;EAAA;EAAA;EAAA;EAAA;EAAA;AAAA;AAI9D,MAAMC,cAAc,GAAG,CACrB,WAAW,EACX,OAAO,EACP,OAAO,CACC;AAOV;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAMC,KAAK,gBAAG,IAAAC,iBAAU,EAA2B,CACjD;EACEC,KAAK;EACLC,KAAK;EACL,GAAGC;AACG,CAAC,EACTC,GAAG,kBAEH,IAAAR,WAAA,CAAAS,IAAA;EAAMC,SAAS,EAAEJ,KAAK,CAACK,SAAU;EAAAC,QAAA,GAC7BP,KAAK,KAAKQ,SAAS,GAAG,IAAI,gBAAG,IAAAb,WAAA,CAAAc,GAAA;IAAGJ,SAAS,EAAEJ,KAAK,CAACD,KAAM;IAAAO,QAAA,EAAEP;EAAK,CAAI,CAAC,eACrE,IAAAL,WAAA,CAAAc,GAAA;IACEJ,SAAS,EAAEJ,KAAK,CAACS,KAAM;IACvBP,GAAG,EAAEA,GAAI;IAAA,GACLD;EAAI,CACT,CAAC;AAAA,CACE,CACP,CAAC;AAEF,MAAMS,WAAW,GAAG,IAAAC,oBAAM,EAACd,KAAK,EAAE,OAAO,EAAED,cAAc,EAAED,YAAY,CAAC;AAExEE,KAAK,CAACe,SAAS,GAAG;EAChBb,KAAK,EAAEc,kBAAE,CAACC,MAAM;EAChBd,KAAK,EAAEU,WAAW,CAACK,SAAS,CAACC;AAC/B,CAAC;AAEDnB,KAAK,CAACoB,YAAY,GAAG;EACnBlB,KAAK,EAAEQ;AACT,CAAC;AAAC,IAAAW,QAAA,GAAAC,OAAA,CAAAC,OAAA,GAEaV,WAAW","ignoreList":[]}
1
+ {"version":3,"file":"index.js","names":["_propTypes","_interopRequireDefault","require","_react","_reactThemes","_jsxRuntime","defaultTheme","validThemeKeys","Input","forwardRef","label","theme","rest","ref","jsxs","className","container","children","undefined","jsx","input","ThemedInput","themed","propTypes","PT","node","themeType","isRequired","defaultProps","_default","exports","default"],"sources":["../../../../../src/shared/components/Input/index.tsx"],"sourcesContent":["import PT from 'prop-types';\nimport { forwardRef } from 'react';\n\nimport themed, { type Theme } from '@dr.pogodin/react-themes';\n\nimport defaultTheme from './theme.scss';\n\nconst validThemeKeys = [\n 'container',\n 'input',\n 'label',\n] as const;\n\ntype PropsT = React.InputHTMLAttributes<HTMLInputElement> & {\n label?: React.ReactNode;\n theme: Theme<typeof validThemeKeys>;\n};\n\n/**\n * Themeable input field, based on the standard HTML `<input>` element.\n * @param [props]\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 = forwardRef<HTMLInputElement, PropsT>((\n {\n label,\n theme,\n ...rest\n }: PropsT,\n ref,\n) => (\n <span className={theme.container}>\n { label === undefined ? null : <div className={theme.label}>{label}</div> }\n <input\n className={theme.input}\n ref={ref}\n {...rest} // eslint-disable-line react/jsx-props-no-spreading\n />\n </span>\n));\n\nconst ThemedInput = themed(Input, 'Input', validThemeKeys, defaultTheme);\n\nInput.propTypes = {\n label: PT.node,\n theme: ThemedInput.themeType.isRequired,\n};\n\nInput.defaultProps = {\n label: undefined,\n};\n\nexport default ThemedInput;\n"],"mappings":";;;;;;;AAAA,IAAAA,UAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,MAAA,GAAAD,OAAA;AAEA,IAAAE,YAAA,GAAAH,sBAAA,CAAAC,OAAA;AAA8D,IAAAG,WAAA,GAAAH,OAAA;AAAA,MAAAI,YAAA;EAAA;EAAA;EAAA;EAAA;EAAA;EAAA;AAAA;AAI9D,MAAMC,cAAc,GAAG,CACrB,WAAW,EACX,OAAO,EACP,OAAO,CACC;AAOV;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAMC,KAAK,gBAAG,IAAAC,iBAAU,EAA2B,CACjD;EACEC,KAAK;EACLC,KAAK;EACL,GAAGC;AACG,CAAC,EACTC,GAAG,kBAEH,IAAAR,WAAA,CAAAS,IAAA;EAAMC,SAAS,EAAEJ,KAAK,CAACK,SAAU;EAAAC,QAAA,GAC7BP,KAAK,KAAKQ,SAAS,GAAG,IAAI,gBAAG,IAAAb,WAAA,CAAAc,GAAA;IAAKJ,SAAS,EAAEJ,KAAK,CAACD,KAAM;IAAAO,QAAA,EAAEP;EAAK,CAAM,CAAC,eACzE,IAAAL,WAAA,CAAAc,GAAA;IACEJ,SAAS,EAAEJ,KAAK,CAACS,KAAM;IACvBP,GAAG,EAAEA,GAAI;IAAA,GACLD;EAAI,CACT,CAAC;AAAA,CACE,CACP,CAAC;AAEF,MAAMS,WAAW,GAAG,IAAAC,oBAAM,EAACd,KAAK,EAAE,OAAO,EAAED,cAAc,EAAED,YAAY,CAAC;AAExEE,KAAK,CAACe,SAAS,GAAG;EAChBb,KAAK,EAAEc,kBAAE,CAACC,IAAI;EACdd,KAAK,EAAEU,WAAW,CAACK,SAAS,CAACC;AAC/B,CAAC;AAEDnB,KAAK,CAACoB,YAAY,GAAG;EACnBlB,KAAK,EAAEQ;AACT,CAAC;AAAC,IAAAW,QAAA,GAAAC,OAAA,CAAAC,OAAA,GAEaV,WAAW","ignoreList":[]}
@@ -19,6 +19,9 @@ const baseTheme = {
19
19
  "overlay": "-dr-pogodin-react-utils___src-shared-components-Modal-base-theme___overlay___ye2BZo",
20
20
  "container": "-dr-pogodin-react-utils___src-shared-components-Modal-base-theme___container___gyZ4rc"
21
21
  };
22
+ const S = {
23
+ "scrollingDisabledByModal": "-dr-pogodin-react-utils___src-shared-components-Modal-styles___scrollingDisabledByModal___5fRFtF"
24
+ };
22
25
  const validThemeKeys = ['container', 'overlay'];
23
26
  /**
24
27
  * The `<Modal>` component implements a simple themeable modal window, wrapped
@@ -32,7 +35,10 @@ const validThemeKeys = ['container', 'overlay'];
32
35
  * @param {ModalTheme} [props.theme] _Ad hoc_ theme.
33
36
  */
34
37
  const BaseModal = ({
38
+ cancelOnScrolling,
35
39
  children,
40
+ containerStyle,
41
+ dontDisableScrolling,
36
42
  onCancel,
37
43
  theme
38
44
  }) => {
@@ -41,14 +47,36 @@ const BaseModal = ({
41
47
  const [portal, setPortal] = (0, _react.useState)();
42
48
  (0, _react.useEffect)(() => {
43
49
  const p = document.createElement('div');
44
- document.body.classList.add('scrolling-disabled-by-modal');
45
50
  document.body.appendChild(p);
46
51
  setPortal(p);
47
52
  return () => {
48
- document.body.classList.remove('scrolling-disabled-by-modal');
49
53
  document.body.removeChild(p);
50
54
  };
51
55
  }, []);
56
+
57
+ // Sets up modal cancellation of scrolling, if opted-in.
58
+ (0, _react.useEffect)(() => {
59
+ if (cancelOnScrolling && onCancel) {
60
+ window.addEventListener('scroll', onCancel);
61
+ }
62
+ return () => {
63
+ if (cancelOnScrolling && onCancel) {
64
+ window.removeEventListener('scroll', onCancel);
65
+ }
66
+ };
67
+ }, [cancelOnScrolling, onCancel]);
68
+
69
+ // Disables window scrolling, if it is not opted-out.
70
+ (0, _react.useEffect)(() => {
71
+ if (!dontDisableScrolling) {
72
+ document.body.classList.add(S.scrollingDisabledByModal);
73
+ }
74
+ return () => {
75
+ if (!dontDisableScrolling) {
76
+ document.body.classList.remove(S.scrollingDisabledByModal);
77
+ }
78
+ };
79
+ }, [dontDisableScrolling]);
52
80
  const focusLast = (0, _react.useMemo)(() => /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
53
81
  onFocus: () => {
54
82
  const elems = containerRef.current?.querySelectorAll('*');
@@ -84,6 +112,7 @@ const BaseModal = ({
84
112
  onWheel: event => event.stopPropagation(),
85
113
  ref: containerRef,
86
114
  role: "dialog",
115
+ style: containerStyle,
87
116
  children: children
88
117
  }), /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
89
118
  onFocus: () => {
@@ -98,13 +127,19 @@ const BaseModal = ({
98
127
  exports.BaseModal = BaseModal;
99
128
  const ThemedModal = (0, _reactThemes.default)(BaseModal, 'Modal', validThemeKeys, baseTheme);
100
129
  BaseModal.propTypes = {
101
- onCancel: _propTypes.default.func,
130
+ cancelOnScrolling: _propTypes.default.bool,
102
131
  children: _propTypes.default.node,
132
+ containerStyle: _propTypes.default.shape({}),
133
+ dontDisableScrolling: _propTypes.default.bool,
134
+ onCancel: _propTypes.default.func,
103
135
  theme: ThemedModal.themeType.isRequired
104
136
  };
105
137
  BaseModal.defaultProps = {
106
- onCancel: _lodash.noop,
107
- children: null
138
+ cancelOnScrolling: false,
139
+ children: null,
140
+ containerStyle: undefined,
141
+ dontDisableScrolling: false,
142
+ onCancel: _lodash.noop
108
143
  };
109
144
  var _default = exports.default = ThemedModal;
110
145
  /* Non-themed version of the Modal. */
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":["_lodash","require","_react","_reactDom","_interopRequireDefault","_propTypes","_reactThemes","_jsxRuntime","baseTheme","validThemeKeys","BaseModal","children","onCancel","theme","containerRef","useRef","overlayRef","portal","setPortal","useState","useEffect","p","document","createElement","body","classList","add","appendChild","remove","removeChild","focusLast","useMemo","jsx","onFocus","elems","current","querySelectorAll","i","length","focus","activeElement","tabIndex","ReactDom","createPortal","jsxs","Fragment","className","overlay","onClick","onKeyDown","e","key","ref","node","role","container","onWheel","event","stopPropagation","exports","ThemedModal","themed","propTypes","PT","func","themeType","isRequired","defaultProps","noop","_default","default"],"sources":["../../../../../src/shared/components/Modal/index.tsx"],"sourcesContent":["/* global document */\n\nimport { noop } from 'lodash';\n\nimport {\n type ReactNode,\n useEffect,\n useMemo,\n useRef,\n useState,\n} from 'react';\n\nimport ReactDom from 'react-dom';\nimport PT from 'prop-types';\nimport themed, { type Theme } from '@dr.pogodin/react-themes';\n\nimport baseTheme from './base-theme.scss';\nimport './styles.scss';\n\nconst validThemeKeys = ['container', 'overlay'] as const;\n\ntype PropsT = {\n children?: ReactNode;\n onCancel?: () => void;\n theme: Theme<typeof validThemeKeys>;\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: React.FunctionComponent<PropsT> = ({\n children,\n onCancel,\n theme,\n}) => {\n const containerRef = useRef<HTMLDivElement | null>(null);\n const overlayRef = useRef<HTMLDivElement | null>(null);\n const [portal, setPortal] = useState<HTMLDivElement>();\n\n useEffect(() => {\n const p = document.createElement('div');\n document.body.classList.add('scrolling-disabled-by-modal');\n document.body.appendChild(p);\n setPortal(p);\n return () => {\n document.body.classList.remove('scrolling-disabled-by-modal');\n document.body.removeChild(p);\n };\n }, []);\n\n const focusLast = useMemo(() => (\n <div\n onFocus={() => {\n const elems = containerRef.current?.querySelectorAll('*') as NodeListOf<HTMLElement>;\n for (let i = elems.length - 1; i >= 0; --i) {\n elems[i].focus();\n if (document.activeElement === elems[i]) return;\n }\n overlayRef.current?.focus();\n }}\n /* eslint-disable jsx-a11y/no-noninteractive-tabindex */\n tabIndex={0}\n /* eslint-enable jsx-a11y/no-noninteractive-tabindex */\n />\n ), []);\n\n return portal ? ReactDom.createPortal(\n (\n <>\n {focusLast}\n <div\n aria-label=\"Cancel\"\n className={theme.overlay}\n onClick={() => onCancel && onCancel()}\n onKeyDown={(e) => {\n if (e.key === 'Escape' && onCancel) onCancel();\n }}\n ref={(node) => {\n if (node && node !== overlayRef.current) {\n overlayRef.current = node;\n node.focus();\n }\n }}\n role=\"button\"\n tabIndex={0}\n />\n <div\n aria-modal=\"true\"\n className={theme.container}\n onWheel={(event) => event.stopPropagation()}\n ref={containerRef}\n role=\"dialog\"\n >\n {children}\n </div>\n <div\n onFocus={() => {\n overlayRef.current?.focus();\n }}\n /* eslint-disable jsx-a11y/no-noninteractive-tabindex */\n tabIndex={0}\n /* eslint-enable jsx-a11y/no-noninteractive-tabindex */\n />\n {focusLast}\n </>\n ),\n portal,\n ) : null;\n};\n\nconst ThemedModal = themed(\n BaseModal,\n 'Modal',\n validThemeKeys,\n baseTheme,\n);\n\nBaseModal.propTypes = {\n onCancel: PT.func,\n children: PT.node,\n theme: ThemedModal.themeType.isRequired,\n};\n\nBaseModal.defaultProps = {\n onCancel: noop,\n children: null,\n};\n\nexport default ThemedModal;\n\n/* Non-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E,cAAW,MAAM;MACjBc,SAAS,EAAEjC,KAAK,CAAC0C,SAAU;MAC3BC,OAAO,EAAGC,KAAK,IAAKA,KAAK,CAACC,eAAe,CAAC,CAAE;MAC5CN,GAAG,EAAEtC,YAAa;MAClBwC,IAAI,EAAC,QAAQ;MAAA3C,QAAA,EAEZA;IAAQ,CACN,CAAC,eACN,IAAAJ,WAAA,CAAAyB,GAAA;MACEC,OAAO,EAAEA,CAAA,KAAM;QACbjB,UAAU,CAACmB,OAAO,EAAEI,KAAK,CAAC,CAAC;MAC7B;MACA;MACAE,QAAQ,EAAE;MACV;IAAA,CACD,CAAC,EACDX,SAAS;EAAA,CACV,CAAC,EAELb,MACF,CAAC,GAAG,IAAI;AACV,CAAC;AAAC0C,OAAA,CAAAjD,SAAA,GAAAA,SAAA;AAEF,MAAMkD,WAAW,GAAG,IAAAC,oBAAM,EACxBnD,SAAS,EACT,OAAO,EACPD,cAAc,EACdD,SACF,CAAC;AAEDE,SAAS,CAACoD,SAAS,GAAG;EACpBlD,QAAQ,EAAEmD,kBAAE,CAACC,IAAI;EACjBrD,QAAQ,EAAEoD,kBAAE,CAACV,IAAI;EACjBxC,KAAK,EAAE+C,WAAW,CAACK,SAAS,CAACC;AAC/B,CAAC;AAEDxD,SAAS,CAACyD,YAAY,GAAG;EACvBvD,QAAQ,EAAEwD,YAAI;EACdzD,QAAQ,EAAE;AACZ,CAAC;AAAC,IAAA0D,QAAA,GAAAV,OAAA,CAAAW,OAAA,GAEaV,WAAW;AAE1B","ignoreList":[]}
1
+ {"version":3,"file":"index.js","names":["_lodash","require","_react","_reactDom","_interopRequireDefault","_propTypes","_reactThemes","_jsxRuntime","baseTheme","S","validThemeKeys","BaseModal","cancelOnScrolling","children","containerStyle","dontDisableScrolling","onCancel","theme","containerRef","useRef","overlayRef","portal","setPortal","useState","useEffect","p","document","createElement","body","appendChild","removeChild","window","addEventListener","removeEventListener","classList","add","scrollingDisabledByModal","remove","focusLast","useMemo","jsx","onFocus","elems","current","querySelectorAll","i","length","focus","activeElement","tabIndex","ReactDom","createPortal","jsxs","Fragment","className","overlay","onClick","onKeyDown","e","key","ref","node","role","container","onWheel","event","stopPropagation","style","exports","ThemedModal","themed","propTypes","PT","bool","shape","func","themeType","isRequired","defaultProps","undefined","noop","_default","default"],"sources":["../../../../../src/shared/components/Modal/index.tsx"],"sourcesContent":["/* global document */\n\nimport { noop } from 'lodash';\n\nimport {\n type ReactNode,\n useEffect,\n useMemo,\n useRef,\n useState,\n} from 'react';\n\nimport ReactDom from 'react-dom';\nimport PT from 'prop-types';\nimport themed, { type Theme } from '@dr.pogodin/react-themes';\n\nimport baseTheme from './base-theme.scss';\nimport S from './styles.scss';\n\nconst validThemeKeys = ['container', 'overlay'] as const;\n\ntype PropsT = {\n cancelOnScrolling?: boolean;\n children?: ReactNode;\n containerStyle?: React.CSSProperties;\n dontDisableScrolling?: boolean;\n onCancel?: () => void;\n theme: Theme<typeof validThemeKeys>;\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: React.FunctionComponent<PropsT> = ({\n cancelOnScrolling,\n children,\n containerStyle,\n dontDisableScrolling,\n onCancel,\n theme,\n}) => {\n const containerRef = useRef<HTMLDivElement | null>(null);\n const overlayRef = useRef<HTMLDivElement | null>(null);\n const [portal, setPortal] = useState<HTMLDivElement>();\n\n useEffect(() => {\n const p = document.createElement('div');\n document.body.appendChild(p);\n setPortal(p);\n return () => {\n document.body.removeChild(p);\n };\n }, []);\n\n // Sets up modal cancellation of scrolling, if opted-in.\n useEffect(() => {\n if (cancelOnScrolling && onCancel) {\n window.addEventListener('scroll', onCancel);\n }\n return () => {\n if (cancelOnScrolling && onCancel) {\n window.removeEventListener('scroll', 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('*') as NodeListOf<HTMLElement>;\n for (let i = elems.length - 1; i >= 0; --i) {\n elems[i].focus();\n if (document.activeElement === elems[i]) return;\n }\n overlayRef.current?.focus();\n }}\n /* eslint-disable jsx-a11y/no-noninteractive-tabindex */\n tabIndex={0}\n /* eslint-enable jsx-a11y/no-noninteractive-tabindex */\n />\n ), []);\n\n return portal ? ReactDom.createPortal(\n (\n <>\n {focusLast}\n <div\n aria-label=\"Cancel\"\n className={theme.overlay}\n onClick={() => onCancel && onCancel()}\n onKeyDown={(e) => {\n if (e.key === 'Escape' && onCancel) onCancel();\n }}\n ref={(node) => {\n if (node && node !== overlayRef.current) {\n overlayRef.current = node;\n node.focus();\n }\n }}\n role=\"button\"\n tabIndex={0}\n />\n <div\n aria-modal=\"true\"\n className={theme.container}\n onWheel={(event) => event.stopPropagation()}\n ref={containerRef}\n role=\"dialog\"\n style={containerStyle}\n >\n {children}\n </div>\n <div\n onFocus={() => {\n overlayRef.current?.focus();\n }}\n /* eslint-disable jsx-a11y/no-noninteractive-tabindex */\n tabIndex={0}\n /* eslint-enable jsx-a11y/no-noninteractive-tabindex */\n />\n {focusLast}\n </>\n ),\n portal,\n ) : null;\n};\n\nconst ThemedModal = themed(\n BaseModal,\n 'Modal',\n validThemeKeys,\n baseTheme,\n);\n\nBaseModal.propTypes = {\n cancelOnScrolling: PT.bool,\n children: PT.node,\n containerStyle: PT.shape({}),\n dontDisableScrolling: PT.bool,\n onCancel: PT.func,\n theme: ThemedModal.themeType.isRequired,\n};\n\nBaseModal.defaultProps = {\n cancelOnScrolling: false,\n children: null,\n containerStyle: undefined,\n dontDisableScrolling: false,\n onCancel: noop,\n};\n\nexport default ThemedModal;\n\n/* Non-themed version of the Modal. */\nexport { BaseModal };\n"],"mappings":";;;;;;;AAEA,IAAAA,OAAA,GAAAC,OAAA;AAEA,IAAAC,MAAA,GAAAD,OAAA;AAQA,IAAAE,SAAA,GAAAC,sBAAA,CAAAH,OAAA;AACA,IAAAI,UAAA,GAAAD,sBAAA,CAAAH,OAAA;AACA,IAAAK,YAAA,GAAAF,sBAAA,CAAAH,OAAA;AAA8D,IAAAM,WAAA,GAAAN,OAAA;AAd9D;AAAA,MAAAO,SAAA;EAAA;EAAA;EAAA;EAAA;EAAA;AAAA;AAAA,MAAAC,CAAA;EAAA;AAAA;AAmBA,MAAMC,cAAc,GAAG,CAAC,WAAW,EAAE,SAAS,CAAU;AAWxD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAMC,SAA0C,GAAGA,CAAC;EAClDC,iBAAiB;EACjBC,QAAQ;EACRC,cAAc;EACdC,oBAAoB;EACpBC,QAAQ;EACRC;AACF,CAAC,KAAK;EACJ,MAAMC,YAAY,GAAG,IAAAC,aAAM,EAAwB,IAAI,CAAC;EACxD,MAAMC,UAAU,GAAG,IAAAD,aAAM,EAAwB,IAAI,CAAC;EACtD,MAAM,CAACE,MAAM,EAAEC,SAAS,CAAC,GAAG,IAAAC,eAAQ,EAAiB,CAAC;EAEtD,IAAAC,gBAAS,EAAC,MAAM;IACd,MAAMC,CAAC,GAAGC,QAAQ,CAACC,aAAa,CAAC,KAAK,CAAC;IACvCD,QAAQ,CAACE,IAAI,CAACC,WAAW,CAACJ,CAAC,CAAC;IAC5BH,SAAS,CAACG,CAAC,CAAC;IACZ,OAAO,MAAM;MACXC,QAAQ,CAACE,IAAI,CAACE,WA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CACD,CAAC,EACDX,SAAS;EAAA,CACV,CAAC,EAELjB,MACF,CAAC,GAAG,IAAI;AACV,CAAC;AAAC+C,OAAA,CAAAzD,SAAA,GAAAA,SAAA;AAEF,MAAM0D,WAAW,GAAG,IAAAC,oBAAM,EACxB3D,SAAS,EACT,OAAO,EACPD,cAAc,EACdF,SACF,CAAC;AAEDG,SAAS,CAAC4D,SAAS,GAAG;EACpB3D,iBAAiB,EAAE4D,kBAAE,CAACC,IAAI;EAC1B5D,QAAQ,EAAE2D,kBAAE,CAACX,IAAI;EACjB/C,cAAc,EAAE0D,kBAAE,CAACE,KAAK,CAAC,CAAC,CAAC,CAAC;EAC5B3D,oBAAoB,EAAEyD,kBAAE,CAACC,IAAI;EAC7BzD,QAAQ,EAAEwD,kBAAE,CAACG,IAAI;EACjB1D,KAAK,EAAEoD,WAAW,CAACO,SAAS,CAACC;AAC/B,CAAC;AAEDlE,SAAS,CAACmE,YAAY,GAAG;EACvBlE,iBAAiB,EAAE,KAAK;EACxBC,QAAQ,EAAE,IAAI;EACdC,cAAc,EAAEiE,SAAS;EACzBhE,oBAAoB,EAAE,KAAK;EAC3BC,QAAQ,EAAEgE;AACZ,CAAC;AAAC,IAAAC,QAAA,GAAAb,OAAA,CAAAc,OAAA,GAEab,WAAW;AAE1B","ignoreList":[]}
@@ -19,6 +19,7 @@ const defaultTheme = {
19
19
  };
20
20
  const validThemeKeys = ['container', 'hidden', 'textarea'];
21
21
  const TextArea = ({
22
+ disabled,
22
23
  onChange,
23
24
  onKeyDown,
24
25
  placeholder,
@@ -60,9 +61,11 @@ const TextArea = ({
60
61
  className: `${theme.textarea} ${theme.hidden}`,
61
62
  value: localValue
62
63
  }), /*#__PURE__*/(0, _jsxRuntime.jsx)("textarea", {
64
+ disabled: disabled
63
65
  // When value is "undefined" the text area is not-managed, and we should
64
66
  // manage it internally for the measurement / resizing functionality
65
67
  // to work.
68
+ ,
66
69
  onChange: value === undefined ? e => {
67
70
  setLocalValue(e.target.value);
68
71
  } : onChange,
@@ -78,6 +81,7 @@ const TextArea = ({
78
81
  };
79
82
  const ThemedTextArea = (0, _reactThemes.default)(TextArea, 'TextArea', validThemeKeys, defaultTheme);
80
83
  TextArea.propTypes = {
84
+ disabled: _propTypes.default.bool,
81
85
  onChange: _propTypes.default.func,
82
86
  onKeyDown: _propTypes.default.func,
83
87
  placeholder: _propTypes.default.string,
@@ -85,6 +89,7 @@ TextArea.propTypes = {
85
89
  value: _propTypes.default.string
86
90
  };
87
91
  TextArea.defaultProps = {
92
+ disabled: false,
88
93
  onChange: undefined,
89
94
  onKeyDown: undefined,
90
95
  placeholder: '',
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":["_react","require","_propTypes","_interopRequireDefault","_reactThemes","_jsxRuntime","defaultTheme","validThemeKeys","TextArea","onChange","onKeyDown","placeholder","theme","value","hiddenAreaRef","useRef","height","setHeight","useState","localValue","setLocalValue","undefined","useEffect","el","current","cb","scrollHeight","observer","ResizeObserver","observe","disconnect","jsxs","className","container","children","jsx","readOnly","ref","textarea","hidden","e","target","style","ThemedTextArea","themed","propTypes","PT","func","string","themeType","isRequired","defaultProps","_default","exports","default"],"sources":["../../../../../src/shared/components/TextArea/index.tsx"],"sourcesContent":["import { useEffect, useRef, useState } from 'react';\nimport PT from 'prop-types';\n\nimport themed, { type Theme } from '@dr.pogodin/react-themes';\n\nimport defaultTheme from './style.scss';\n\nconst validThemeKeys = [\n 'container',\n 'hidden',\n 'textarea',\n] as const;\n\ntype Props = {\n onChange?: React.ChangeEventHandler<HTMLTextAreaElement>;\n onKeyDown?: React.KeyboardEventHandler<HTMLTextAreaElement>;\n placeholder?: string;\n theme: Theme<typeof validThemeKeys>;\n value?: string;\n};\n\nconst TextArea: React.FunctionComponent<Props> = ({\n onChange,\n onKeyDown,\n placeholder,\n theme,\n value,\n}) => {\n const hiddenAreaRef = useRef<HTMLTextAreaElement>(null);\n const [height, setHeight] = useState<number | undefined>();\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 // This resizes the text area when its content is modified.\n useEffect(() => {\n const el = hiddenAreaRef.current;\n if (el) setHeight(el.scrollHeight);\n }, [localValue]);\n\n return (\n <div className={theme.container}>\n <textarea\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 className={`${theme.textarea} ${theme.hidden}`}\n value={localValue}\n />\n <textarea\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={value === undefined ? ((e) => {\n setLocalValue(e.target.value);\n }) : onChange}\n onKeyDown={onKeyDown}\n placeholder={placeholder}\n style={{ height }}\n className={theme.textarea}\n value={localValue}\n />\n </div>\n );\n};\n\nconst ThemedTextArea = themed(\n TextArea,\n 'TextArea',\n validThemeKeys,\n defaultTheme,\n);\n\nTextArea.propTypes = {\n onChange: PT.func,\n onKeyDown: PT.func,\n placeholder: PT.string,\n theme: ThemedTextArea.themeType.isRequired,\n value: PT.string,\n};\n\nTextArea.defaultProps = {\n onChange: undefined,\n onKeyDown: undefined,\n placeholder: '',\n value: undefined,\n};\n\nexport default ThemedTextArea;\n"],"mappings":";;;;;;;AAAA,IAAAA,MAAA,GAAAC,OAAA;AACA,IAAAC,UAAA,GAAAC,sBAAA,CAAAF,OAAA;AAEA,IAAAG,YAAA,GAAAD,sBAAA,CAAAF,OAAA;AAA8D,IAAAI,WAAA,GAAAJ,OAAA;AAAA,MAAAK,YAAA;EAAA;EAAA;EAAA;EAAA;EAAA;EAAA;AAAA;AAI9D,MAAMC,cAAc,GAAG,CACrB,WAAW,EACX,QAAQ,EACR,UAAU,CAC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AS,EAAG,GAAEpB,KAAK,CAAC0B,QAAS,IAAG1B,KAAK,CAAC2B,MAAO,EAAE;MAC/C1B,KAAK,EAAEM;IAAW,CACnB,CAAC,eACF,IAAAd,WAAA,CAAA8B,GAAA;MACE;MACA;MACA;MACA1B,QAAQ,EAAEI,KAAK,KAAKQ,SAAS,GAAKmB,CAAC,IAAK;QACtCpB,aAAa,CAACoB,CAAC,CAACC,MAAM,CAAC5B,KAAK,CAAC;MAC/B,CAAC,GAAIJ,QAAS;MACdC,SAAS,EAAEA,SAAU;MACrBC,WAAW,EAAEA,WAAY;MACzB+B,KAAK,EAAE;QAAE1B;MAAO,CAAE;MAClBgB,SAAS,EAAEpB,KAAK,CAAC0B,QAAS;MAC1BzB,KAAK,EAAEM;IAAW,CACnB,CAAC;EAAA,CACC,CAAC;AAEV,CAAC;AAED,MAAMwB,cAAc,GAAG,IAAAC,oBAAM,EAC3BpC,QAAQ,EACR,UAAU,EACVD,cAAc,EACdD,YACF,CAAC;AAEDE,QAAQ,CAACqC,SAAS,GAAG;EACnBpC,QAAQ,EAAEqC,kBAAE,CAACC,IAAI;EACjBrC,SAAS,EAAEoC,kBAAE,CAACC,IAAI;EAClBpC,WAAW,EAAEmC,kBAAE,CAACE,MAAM;EACtBpC,KAAK,EAAE+B,cAAc,CAACM,SAAS,CAACC,UAAU;EAC1CrC,KAAK,EAAEiC,kBAAE,CAACE;AACZ,CAAC;AAEDxC,QAAQ,CAAC2C,YAAY,GAAG;EACtB1C,QAAQ,EAAEY,SAAS;EACnBX,SAAS,EAAEW,SAAS;EACpBV,WAAW,EAAE,EAAE;EACfE,KAAK,EAAEQ;AACT,CAAC;AAAC,IAAA+B,QAAA,GAAAC,OAAA,CAAAC,OAAA,GAEaX,cAAc","ignoreList":[]}
1
+ {"version":3,"file":"index.js","names":["_react","require","_propTypes","_interopRequireDefault","_reactThemes","_jsxRuntime","defaultTheme","validThemeKeys","TextArea","disabled","onChange","onKeyDown","placeholder","theme","value","hiddenAreaRef","useRef","height","setHeight","useState","localValue","setLocalValue","undefined","useEffect","el","current","cb","scrollHeight","observer","ResizeObserver","observe","disconnect","jsxs","className","container","children","jsx","readOnly","ref","textarea","hidden","e","target","style","ThemedTextArea","themed","propTypes","PT","bool","func","string","themeType","isRequired","defaultProps","_default","exports","default"],"sources":["../../../../../src/shared/components/TextArea/index.tsx"],"sourcesContent":["import { useEffect, useRef, useState } from 'react';\nimport PT from 'prop-types';\n\nimport themed, { type Theme } from '@dr.pogodin/react-themes';\n\nimport defaultTheme from './style.scss';\n\nconst validThemeKeys = [\n 'container',\n 'hidden',\n 'textarea',\n] as const;\n\ntype Props = {\n disabled?: boolean;\n onChange?: React.ChangeEventHandler<HTMLTextAreaElement>;\n onKeyDown?: React.KeyboardEventHandler<HTMLTextAreaElement>;\n placeholder?: string;\n theme: Theme<typeof validThemeKeys>;\n value?: string;\n};\n\nconst TextArea: React.FunctionComponent<Props> = ({\n disabled,\n onChange,\n onKeyDown,\n placeholder,\n theme,\n value,\n}) => {\n const hiddenAreaRef = useRef<HTMLTextAreaElement>(null);\n const [height, setHeight] = useState<number | undefined>();\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 // This resizes the text area when its content is modified.\n useEffect(() => {\n const el = hiddenAreaRef.current;\n if (el) setHeight(el.scrollHeight);\n }, [localValue]);\n\n return (\n <div className={theme.container}>\n <textarea\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 className={`${theme.textarea} ${theme.hidden}`}\n value={localValue}\n />\n <textarea\n disabled={disabled}\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={value === undefined ? ((e) => {\n setLocalValue(e.target.value);\n }) : onChange}\n onKeyDown={onKeyDown}\n placeholder={placeholder}\n style={{ height }}\n className={theme.textarea}\n value={localValue}\n />\n </div>\n );\n};\n\nconst ThemedTextArea = themed(\n TextArea,\n 'TextArea',\n validThemeKeys,\n defaultTheme,\n);\n\nTextArea.propTypes = {\n disabled: PT.bool,\n onChange: PT.func,\n onKeyDown: PT.func,\n placeholder: PT.string,\n theme: ThemedTextArea.themeType.isRequired,\n value: PT.string,\n};\n\nTextArea.defaultProps = {\n disabled: false,\n onChange: undefined,\n onKeyDown: undefined,\n placeholder: '',\n value: undefined,\n};\n\nexport default ThemedTextArea;\n"],"mappings":";;;;;;;AAAA,IAAAA,MAAA,GAAAC,OAAA;AACA,IAAAC,UAAA,GAAAC,sBAAA,CAAAF,OAAA;AAEA,IAAAG,YAAA,GAAAD,sBAAA,CAAAF,OAAA;AAA8D,IAAAI,WAAA,GAAAJ,OAAA;AAAA,MAAAK,YAAA;EAAA;EAAA;EAAA;EAAA;EAAA;EAAA;AAAA;AAI9D,MAAMC,cAAc,GAAG,CACrB,WAAW,EACX,QAAQ,EACR,UAAU,CACF;AAWV,MAAMC,QAAwC,GAAGA,CAAC;EAChDC,QAAQ;EACRC,QAAQ;EACRC,SAAS;EACTC,WAAW;EACXC,KAAK;EACLC;AACF,CAAC,KAAK;EACJ,MAAMC,aAAa,GAAG,IAAAC,aAAM,EAAsB,IAAI,CAAC;EACvD,MAAM,CAACC,MAAM,EAAEC,SAAS,CAAC,GAAG,IAAAC,eAAQ,EAAqB,CAAC;EAE1D,MAAM,CAACC,UAAU,EAAEC,aAAa,CAAC,GAAG,IAAAF,eAAQ,EAACL,KAAK,IAAI,EAAE,CAAC;EACzD,IAAIA,KAAK,KAAKQ,SAAS,IAAIF,UAAU,KAAKN,KAAK,EAAEO,aAAa,CAACP,KAAK,CAAC;;EAErE;EACA,IAAAS,gBAAS,EA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CAAC0B,QAAS;MAC1BzB,KAAK,EAAEM;IAAW,CACnB,CAAC;EAAA,CACC,CAAC;AAEV,CAAC;AAED,MAAMwB,cAAc,GAAG,IAAAC,oBAAM,EAC3BrC,QAAQ,EACR,UAAU,EACVD,cAAc,EACdD,YACF,CAAC;AAEDE,QAAQ,CAACsC,SAAS,GAAG;EACnBrC,QAAQ,EAAEsC,kBAAE,CAACC,IAAI;EACjBtC,QAAQ,EAAEqC,kBAAE,CAACE,IAAI;EACjBtC,SAAS,EAAEoC,kBAAE,CAACE,IAAI;EAClBrC,WAAW,EAAEmC,kBAAE,CAACG,MAAM;EACtBrC,KAAK,EAAE+B,cAAc,CAACO,SAAS,CAACC,UAAU;EAC1CtC,KAAK,EAAEiC,kBAAE,CAACG;AACZ,CAAC;AAED1C,QAAQ,CAAC6C,YAAY,GAAG;EACtB5C,QAAQ,EAAE,KAAK;EACfC,QAAQ,EAAEY,SAAS;EACnBX,SAAS,EAAEW,SAAS;EACpBV,WAAW,EAAE,EAAE;EACfE,KAAK,EAAEQ;AACT,CAAC;AAAC,IAAAgC,QAAA,GAAAC,OAAA,CAAAC,OAAA,GAEaZ,cAAc","ignoreList":[]}
@@ -11,7 +11,7 @@ var _reactThemes = _interopRequireDefault(require("@dr.pogodin/react-themes"));
11
11
  var _Tooltip = _interopRequireWildcard(require("./Tooltip"));
12
12
  var _jsxRuntime = require("react/jsx-runtime");
13
13
  function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
14
- function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
14
+ function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
15
15
  /* global window */
16
16
  const defaultTheme = {
17
17
  "ad": "-dr-pogodin-react-utils___src-shared-components-WithTooltip-default-theme___ad___4xT7zE",
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":["_propTypes","_interopRequireDefault","require","_react","_reactThemes","_Tooltip","_interopRequireWildcard","_jsxRuntime","_getRequireWildcardCache","e","WeakMap","r","t","__esModule","default","has","get","n","__proto__","a","Object","defineProperty","getOwnPropertyDescriptor","u","prototype","hasOwnProperty","call","i","set","defaultTheme","validThemeKeys","validTooltipThemeKeys","Wrapper","children","placement","tip","theme","current","heap","useRef","lastCursorX","lastCursorY","triggeredByTouch","timerId","undefined","tooltipRef","wrapperRef","showTooltip","setShowTooltip","useState","updatePortalPosition","cursorX","cursorY","setTimeout","wrapperRect","getBoundingClientRect","left","right","top","bottom","pointTo","window","scrollX","scrollY","useEffect","listener","addEventListener","removeEventListener","jsxs","className","wrapper","onMouseLeave","onMouseMove","clientX","clientY","onClick","clearTimeout","onTouchStart","ref","role","jsx","ThemedWrapper","themed","PLACEMENTS","propTypes","PT","node","oneOf","values","themeType","isRequired","defaultProps","ABOVE_CURSOR","_default","exports"],"sources":["../../../../../src/shared/components/WithTooltip/index.tsx"],"sourcesContent":["/* global window */\n\nimport PT from 'prop-types';\nimport {\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 PLACEMENTS,\n validThemeKeys as validTooltipThemeKeys,\n} from './Tooltip';\n\nimport defaultTheme from './default-theme.scss';\n\nconst validThemeKeys = [...validTooltipThemeKeys, 'wrapper'] as const;\n\ntype PropsT = {\n children?: ReactNode;\n placement?: PLACEMENTS;\n tip?: ReactNode;\n theme: Theme<typeof validThemeKeys>;\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 {object} props Component properties.\n * @param {React.node} props.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: React.FunctionComponent<PropsT> = ({\n children,\n placement,\n tip,\n theme,\n}) => {\n const { current: heap } = useRef<HeapT>({\n lastCursorX: 0,\n lastCursorY: 0,\n triggeredByTouch: false,\n timerId: undefined,\n });\n const tooltipRef = useRef<TooltipRefT>();\n const wrapperRef = useRef<HTMLDivElement>(null);\n const [showTooltip, setShowTooltip] = useState(false);\n\n const updatePortalPosition = (cursorX: number, cursorY: number) => {\n if (!showTooltip) {\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 if (!heap.timerId) {\n heap.timerId = setTimeout(() => {\n heap.triggeredByTouch = false;\n heap.timerId = undefined;\n setShowTooltip(true);\n }, 300);\n }\n\n // Otherwise we can just open the tooltip right away.\n } else setShowTooltip(true);\n } else {\n const wrapperRect = wrapperRef.current!.getBoundingClientRect();\n if (\n cursorX < wrapperRect.left\n || cursorX > wrapperRect.right\n || cursorY < wrapperRect.top\n || cursorY > wrapperRect.bottom\n ) {\n setShowTooltip(false);\n } else if (tooltipRef.current) {\n tooltipRef.current.pointTo(\n cursorX + window.scrollX,\n cursorY + window.scrollY,\n placement!,\n wrapperRef.current!,\n );\n }\n }\n };\n\n useEffect(() => {\n if (showTooltip && tip !== null) {\n // This is necessary to ensure that even when a single mouse event\n // arrives to a tool-tipped component, the tooltip is correctly positioned\n // once opened (because similar call above does not have effect until\n // the tooltip is fully mounted, and that is delayed to future rendering\n // cycle due to the implementation).\n if (tooltipRef.current) {\n tooltipRef.current.pointTo(\n heap.lastCursorX + window.scrollX,\n heap.lastCursorY + window.scrollY,\n placement!,\n wrapperRef.current!,\n );\n }\n\n const listener = () => setShowTooltip(false);\n window.addEventListener('scroll', listener);\n return () => window.removeEventListener('scroll', listener);\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 onMouseLeave={() => setShowTooltip(false)}\n onMouseMove={(e) => updatePortalPosition(e.clientX, e.clientY)}\n onClick={() => {\n if (heap.timerId) {\n clearTimeout(heap.timerId);\n heap.timerId = undefined;\n heap.triggeredByTouch = false;\n }\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 = themed(\n Wrapper,\n 'WithTooltip',\n [\n 'appearance',\n 'arrow',\n 'container',\n 'content',\n 'wrapper',\n ],\n defaultTheme,\n);\n\ntype ExportT = typeof ThemedWrapper & {\n PLACEMENTS: typeof PLACEMENTS;\n};\n\nconst e: ExportT = ThemedWrapper as ExportT;\n\ne.PLACEMENTS = PLACEMENTS;\n\nWrapper.propTypes = {\n children: PT.node,\n placement: PT.oneOf(Object.values(PLACEMENTS)),\n theme: ThemedWrapper.themeType.isRequired,\n tip: PT.node,\n};\n\nWrapper.defaultProps = {\n children: null,\n placement: PLACEMENTS.ABOVE_CURSOR,\n tip: null,\n};\n\nexport default e;\n"],"mappings":";;;;;;;AAEA,IAAAA,UAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,MAAA,GAAAD,OAAA;AAOA,IAAAE,YAAA,GAAAH,sBAAA,CAAAC,OAAA;AAEA,IAAAG,QAAA,GAAAC,uBAAA,CAAAJ,OAAA;AAGmB,IAAAK,WAAA,GAAAL,OAAA;AAAA,SAAAM,yBAAAC,CAAA,6BAAAC,OAAA,mBAAAC,CAAA,OAAAD,OAAA,IAAAE,CAAA,OAAAF,OAAA,YAAAF,wBAAA,YAAAA,CAAAC,CAAA,WAAAA,CAAA,GAAAG,CAAA,GAAAD,CAAA,KAAAF,CAAA;AAAA,SAAAH,wBAAAG,CAAA,EAAAE,CAAA,SAAAA,CAAA,IAAAF,CAAA,IAAAA,CAAA,CAAAI,UAAA,SAAAJ,CAAA,eAAAA,CAAA,uBAAAA,CAAA,yBAAAA,CAAA,WAAAK,OAAA,EAAAL,CAAA,QAAAG,CAAA,GAAAJ,wBAAA,CAAAG,CAAA,OAAAC,CAAA,IAAAA,CAAA,CAAAG,GAAA,CAAAN,CAAA,UAAAG,CAAA,CAAAI,GAAA,CAAAP,CAAA,OAAAQ,CAAA,KAAAC,SAAA,UAAAC,CAAA,GAAAC,MAAA,CAAAC,cAAA,IAAAD,MAAA,CAAAE,wBAAA,WAAAC,CAAA,IAAAd,CAAA,oBAAAc,CAA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AAU,CAAC,GACrD,IAAI,EAETF,QAAQ;EAAA,CACN,CAAC;AAEV,CAAC;AAED,MAAMgD,aAAa,GAAG,IAAAC,oBAAM,EAC1BlD,OAAO,EACP,aAAa,EACb,CACE,YAAY,EACZ,OAAO,EACP,WAAW,EACX,SAAS,EACT,SAAS,CACV,EACDH,YACF,CAAC;AAMD,MAAMpB,CAAU,GAAGwE,aAAwB;AAE3CxE,CAAC,CAAC0E,UAAU,GAAGA,mBAAU;AAEzBnD,OAAO,CAACoD,SAAS,GAAG;EAClBnD,QAAQ,EAAEoD,kBAAE,CAACC,IAAI;EACjBpD,SAAS,EAAEmD,kBAAE,CAACE,KAAK,CAACnE,MAAM,CAACoE,MAAM,CAACL,mBAAU,CAAC,CAAC;EAC9C/C,KAAK,EAAE6C,aAAa,CAACQ,SAAS,CAACC,UAAU;EACzCvD,GAAG,EAAEkD,kBAAE,CAACC;AACV,CAAC;AAEDtD,OAAO,CAAC2D,YAAY,GAAG;EACrB1D,QAAQ,EAAE,IAAI;EACdC,SAAS,EAAEiD,mBAAU,CAACS,YAAY;EAClCzD,GAAG,EAAE;AACP,CAAC;AAAC,IAAA0D,QAAA,GAAAC,OAAA,CAAAhF,OAAA,GAEaL,CAAC","ignoreList":[]}
1
+ {"version":3,"file":"index.js","names":["_propTypes","_interopRequireDefault","require","_react","_reactThemes","_Tooltip","_interopRequireWildcard","_jsxRuntime","_getRequireWildcardCache","e","WeakMap","r","t","__esModule","default","has","get","n","__proto__","a","Object","defineProperty","getOwnPropertyDescriptor","u","hasOwnProperty","call","i","set","defaultTheme","validThemeKeys","validTooltipThemeKeys","Wrapper","children","placement","tip","theme","current","heap","useRef","lastCursorX","lastCursorY","triggeredByTouch","timerId","undefined","tooltipRef","wrapperRef","showTooltip","setShowTooltip","useState","updatePortalPosition","cursorX","cursorY","setTimeout","wrapperRect","getBoundingClientRect","left","right","top","bottom","pointTo","window","scrollX","scrollY","useEffect","listener","addEventListener","removeEventListener","jsxs","className","wrapper","onMouseLeave","onMouseMove","clientX","clientY","onClick","clearTimeout","onTouchStart","ref","role","jsx","ThemedWrapper","themed","PLACEMENTS","propTypes","PT","node","oneOf","values","themeType","isRequired","defaultProps","ABOVE_CURSOR","_default","exports"],"sources":["../../../../../src/shared/components/WithTooltip/index.tsx"],"sourcesContent":["/* global window */\n\nimport PT from 'prop-types';\nimport {\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 PLACEMENTS,\n validThemeKeys as validTooltipThemeKeys,\n} from './Tooltip';\n\nimport defaultTheme from './default-theme.scss';\n\nconst validThemeKeys = [...validTooltipThemeKeys, 'wrapper'] as const;\n\ntype PropsT = {\n children?: ReactNode;\n placement?: PLACEMENTS;\n tip?: ReactNode;\n theme: Theme<typeof validThemeKeys>;\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 {object} props Component properties.\n * @param {React.node} props.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: React.FunctionComponent<PropsT> = ({\n children,\n placement,\n tip,\n theme,\n}) => {\n const { current: heap } = useRef<HeapT>({\n lastCursorX: 0,\n lastCursorY: 0,\n triggeredByTouch: false,\n timerId: undefined,\n });\n const tooltipRef = useRef<TooltipRefT>();\n const wrapperRef = useRef<HTMLDivElement>(null);\n const [showTooltip, setShowTooltip] = useState(false);\n\n const updatePortalPosition = (cursorX: number, cursorY: number) => {\n if (!showTooltip) {\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 if (!heap.timerId) {\n heap.timerId = setTimeout(() => {\n heap.triggeredByTouch = false;\n heap.timerId = undefined;\n setShowTooltip(true);\n }, 300);\n }\n\n // Otherwise we can just open the tooltip right away.\n } else setShowTooltip(true);\n } else {\n const wrapperRect = wrapperRef.current!.getBoundingClientRect();\n if (\n cursorX < wrapperRect.left\n || cursorX > wrapperRect.right\n || cursorY < wrapperRect.top\n || cursorY > wrapperRect.bottom\n ) {\n setShowTooltip(false);\n } else if (tooltipRef.current) {\n tooltipRef.current.pointTo(\n cursorX + window.scrollX,\n cursorY + window.scrollY,\n placement!,\n wrapperRef.current!,\n );\n }\n }\n };\n\n useEffect(() => {\n if (showTooltip && tip !== null) {\n // This is necessary to ensure that even when a single mouse event\n // arrives to a tool-tipped component, the tooltip is correctly positioned\n // once opened (because similar call above does not have effect until\n // the tooltip is fully mounted, and that is delayed to future rendering\n // cycle due to the implementation).\n if (tooltipRef.current) {\n tooltipRef.current.pointTo(\n heap.lastCursorX + window.scrollX,\n heap.lastCursorY + window.scrollY,\n placement!,\n wrapperRef.current!,\n );\n }\n\n const listener = () => setShowTooltip(false);\n window.addEventListener('scroll', listener);\n return () => window.removeEventListener('scroll', listener);\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 onMouseLeave={() => setShowTooltip(false)}\n onMouseMove={(e) => updatePortalPosition(e.clientX, e.clientY)}\n onClick={() => {\n if (heap.timerId) {\n clearTimeout(heap.timerId);\n heap.timerId = undefined;\n heap.triggeredByTouch = false;\n }\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 = themed(\n Wrapper,\n 'WithTooltip',\n [\n 'appearance',\n 'arrow',\n 'container',\n 'content',\n 'wrapper',\n ],\n defaultTheme,\n);\n\ntype ExportT = typeof ThemedWrapper & {\n PLACEMENTS: typeof PLACEMENTS;\n};\n\nconst e: ExportT = ThemedWrapper as ExportT;\n\ne.PLACEMENTS = PLACEMENTS;\n\nWrapper.propTypes = {\n children: PT.node,\n placement: PT.oneOf(Object.values(PLACEMENTS)),\n theme: ThemedWrapper.themeType.isRequired,\n tip: PT.node,\n};\n\nWrapper.defaultProps = {\n children: null,\n placement: PLACEMENTS.ABOVE_CURSOR,\n tip: null,\n};\n\nexport default e;\n"],"mappings":";;;;;;;AAEA,IAAAA,UAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,MAAA,GAAAD,OAAA;AAOA,IAAAE,YAAA,GAAAH,sBAAA,CAAAC,OAAA;AAEA,IAAAG,QAAA,GAAAC,uBAAA,CAAAJ,OAAA;AAGmB,IAAAK,WAAA,GAAAL,OAAA;AAAA,SAAAM,yBAAAC,CAAA,6BAAAC,OAAA,mBAAAC,CAAA,OAAAD,OAAA,IAAAE,CAAA,OAAAF,OAAA,YAAAF,wBAAA,YAAAA,CAAAC,CAAA,WAAAA,CAAA,GAAAG,CAAA,GAAAD,CAAA,KAAAF,CAAA;AAAA,SAAAH,wBAAAG,CAAA,EAAAE,CAAA,SAAAA,CAAA,IAAAF,CAAA,IAAAA,CAAA,CAAAI,UAAA,SAAAJ,CAAA,eAAAA,CAAA,uBAAAA,CAAA,yBAAAA,CAAA,WAAAK,OAAA,EAAAL,CAAA,QAAAG,CAAA,G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;IAChBiC,IAAI,EAAC,cAAc;IAAA9C,QAAA,GAGjBc,WAAW,IAAIZ,GAAG,KAAK,IAAI,gBACzB,IAAA3B,WAAA,CAAAwE,GAAA,EAAC1E,QAAA,CAAAS,OAAO;MAAC+D,GAAG,EAAEjC,UAAW;MAACT,KAAK,EAAEA,KAAM;MAAAH,QAAA,EAAEE;IAAG,CAAU,CAAC,GACrD,IAAI,EAETF,QAAQ;EAAA,CACN,CAAC;AAEV,CAAC;AAED,MAAMgD,aAAa,GAAG,IAAAC,oBAAM,EAC1BlD,OAAO,EACP,aAAa,EACb,CACE,YAAY,EACZ,OAAO,EACP,WAAW,EACX,SAAS,EACT,SAAS,CACV,EACDH,YACF,CAAC;AAMD,MAAMnB,CAAU,GAAGuE,aAAwB;AAE3CvE,CAAC,CAACyE,UAAU,GAAGA,mBAAU;AAEzBnD,OAAO,CAACoD,SAAS,GAAG;EAClBnD,QAAQ,EAAEoD,kBAAE,CAACC,IAAI;EACjBpD,SAAS,EAAEmD,kBAAE,CAACE,KAAK,CAAClE,MAAM,CAACmE,MAAM,CAACL,mBAAU,CAAC,CAAC;EAC9C/C,KAAK,EAAE6C,aAAa,CAACQ,SAAS,CAACC,UAAU;EACzCvD,GAAG,EAAEkD,kBAAE,CAACC;AACV,CAAC;AAEDtD,OAAO,CAAC2D,YAAY,GAAG;EACrB1D,QAAQ,EAAE,IAAI;EACdC,SAAS,EAAEiD,mBAAU,CAACS,YAAY;EAClCzD,GAAG,EAAE;AACP,CAAC;AAAC,IAAA0D,QAAA,GAAAC,OAAA,CAAA/E,OAAA,GAEaL,CAAC","ignoreList":[]}
@@ -8,7 +8,6 @@ exports.default = void 0;
8
8
  var _propTypes = _interopRequireDefault(require("prop-types"));
9
9
  var _qs = _interopRequireDefault(require("qs"));
10
10
  var _reactThemes = _interopRequireDefault(require("@dr.pogodin/react-themes"));
11
- var _ScalableRect = _interopRequireDefault(require("../ScalableRect"));
12
11
  var _Throbber = _interopRequireDefault(require("../Throbber"));
13
12
  var _jsxRuntime = require("react/jsx-runtime");
14
13
  const baseTheme = {
@@ -59,9 +58,8 @@ const YouTubeVideo = ({
59
58
  // TODO: https://developers.google.com/youtube/player_parameters
60
59
  // More query parameters can be exposed via the component props.
61
60
 
62
- return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_ScalableRect.default, {
61
+ return /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
63
62
  className: theme.container,
64
- ratio: "16:9",
65
63
  children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_Throbber.default, {
66
64
  theme: throbberTheme
67
65
  }), /*#__PURE__*/(0, _jsxRuntime.jsx)("iframe", {