@dr.pogodin/react-utils 1.35.3 → 1.36.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (185) hide show
  1. package/LICENSE.md +1 -1
  2. package/bin/build.js +7 -6
  3. package/build/development/client/getInj.js +3 -10
  4. package/build/development/client/getInj.js.map +1 -1
  5. package/build/development/client/index.js +2 -9
  6. package/build/development/client/index.js.map +1 -1
  7. package/build/development/index.js +1 -15
  8. package/build/development/index.js.map +1 -1
  9. package/build/development/server/Cache.js +19 -19
  10. package/build/development/server/Cache.js.map +1 -1
  11. package/build/development/server/renderer.js +7 -4
  12. package/build/development/server/renderer.js.map +1 -1
  13. package/build/development/server/server.js +4 -1
  14. package/build/development/server/server.js.map +1 -1
  15. package/build/development/shared/components/Button/index.js +1 -16
  16. package/build/development/shared/components/Button/index.js.map +1 -1
  17. package/build/development/shared/components/Checkbox/index.js +1 -29
  18. package/build/development/shared/components/Checkbox/index.js.map +1 -1
  19. package/build/development/shared/components/GenericLink/index.js +0 -15
  20. package/build/development/shared/components/GenericLink/index.js.map +1 -1
  21. package/build/development/shared/components/Input/index.js +1 -8
  22. package/build/development/shared/components/Input/index.js.map +1 -1
  23. package/build/development/shared/components/MetaTags.js +0 -12
  24. package/build/development/shared/components/MetaTags.js.map +1 -1
  25. package/build/development/shared/components/Modal/index.js +2 -13
  26. package/build/development/shared/components/Modal/index.js.map +1 -1
  27. package/build/development/shared/components/PageLayout/index.js +1 -10
  28. package/build/development/shared/components/PageLayout/index.js.map +1 -1
  29. package/build/development/shared/components/TextArea/index.js +1 -12
  30. package/build/development/shared/components/TextArea/index.js.map +1 -1
  31. package/build/development/shared/components/Throbber/index.js +1 -6
  32. package/build/development/shared/components/Throbber/index.js.map +1 -1
  33. package/build/development/shared/components/WithTooltip/Tooltip.js +1 -8
  34. package/build/development/shared/components/WithTooltip/Tooltip.js.map +1 -1
  35. package/build/development/shared/components/WithTooltip/index.js +1 -9
  36. package/build/development/shared/components/WithTooltip/index.js.map +1 -1
  37. package/build/development/shared/components/YouTubeVideo/index.js +2 -11
  38. package/build/development/shared/components/YouTubeVideo/index.js.map +1 -1
  39. package/build/development/shared/components/selectors/CustomDropdown/Options/index.js +1 -16
  40. package/build/development/shared/components/selectors/CustomDropdown/Options/index.js.map +1 -1
  41. package/build/development/shared/components/selectors/CustomDropdown/index.js +2 -12
  42. package/build/development/shared/components/selectors/CustomDropdown/index.js.map +1 -1
  43. package/build/development/shared/components/selectors/NativeDropdown/index.js +2 -12
  44. package/build/development/shared/components/selectors/NativeDropdown/index.js.map +1 -1
  45. package/build/development/shared/components/selectors/Switch/index.js +21 -28
  46. package/build/development/shared/components/selectors/Switch/index.js.map +1 -1
  47. package/build/development/shared/components/selectors/common.js +0 -19
  48. package/build/development/shared/components/selectors/common.js.map +1 -1
  49. package/build/development/shared/components/selectors/index.js +0 -13
  50. package/build/development/shared/components/selectors/index.js.map +1 -1
  51. package/build/development/shared/utils/globalState.js.map +1 -1
  52. package/build/development/shared/utils/jest/index.js +4 -2
  53. package/build/development/shared/utils/jest/index.js.map +1 -1
  54. package/build/development/shared/utils/splitComponent.js +21 -28
  55. package/build/development/shared/utils/splitComponent.js.map +1 -1
  56. package/build/development/web.bundle.js +28 -38
  57. package/build/production/client/getInj.js +3 -7
  58. package/build/production/client/getInj.js.map +1 -1
  59. package/build/production/client/index.js +1 -1
  60. package/build/production/client/index.js.map +1 -1
  61. package/build/production/index.js +1 -4
  62. package/build/production/index.js.map +1 -1
  63. package/build/production/server/Cache.js +3 -3
  64. package/build/production/server/Cache.js.map +1 -1
  65. package/build/production/server/renderer.js +2 -2
  66. package/build/production/server/renderer.js.map +1 -1
  67. package/build/production/server/server.js +1 -1
  68. package/build/production/server/server.js.map +1 -1
  69. package/build/production/shared/components/Button/index.js +3 -3
  70. package/build/production/shared/components/Button/index.js.map +1 -1
  71. package/build/production/shared/components/Checkbox/index.js +1 -16
  72. package/build/production/shared/components/Checkbox/index.js.map +1 -1
  73. package/build/production/shared/components/GenericLink/index.js +2 -2
  74. package/build/production/shared/components/GenericLink/index.js.map +1 -1
  75. package/build/production/shared/components/Input/index.js +2 -2
  76. package/build/production/shared/components/Input/index.js.map +1 -1
  77. package/build/production/shared/components/MetaTags.js +2 -2
  78. package/build/production/shared/components/MetaTags.js.map +1 -1
  79. package/build/production/shared/components/Modal/index.js +2 -2
  80. package/build/production/shared/components/Modal/index.js.map +1 -1
  81. package/build/production/shared/components/PageLayout/index.js +2 -2
  82. package/build/production/shared/components/PageLayout/index.js.map +1 -1
  83. package/build/production/shared/components/TextArea/index.js +2 -2
  84. package/build/production/shared/components/TextArea/index.js.map +1 -1
  85. package/build/production/shared/components/Throbber/index.js +2 -2
  86. package/build/production/shared/components/Throbber/index.js.map +1 -1
  87. package/build/production/shared/components/WithTooltip/Tooltip.js +3 -3
  88. package/build/production/shared/components/WithTooltip/Tooltip.js.map +1 -1
  89. package/build/production/shared/components/WithTooltip/index.js +2 -2
  90. package/build/production/shared/components/WithTooltip/index.js.map +1 -1
  91. package/build/production/shared/components/YouTubeVideo/index.js +3 -3
  92. package/build/production/shared/components/YouTubeVideo/index.js.map +1 -1
  93. package/build/production/shared/components/selectors/CustomDropdown/Options/index.js +2 -2
  94. package/build/production/shared/components/selectors/CustomDropdown/Options/index.js.map +1 -1
  95. package/build/production/shared/components/selectors/CustomDropdown/index.js +2 -2
  96. package/build/production/shared/components/selectors/CustomDropdown/index.js.map +1 -1
  97. package/build/production/shared/components/selectors/NativeDropdown/index.js +3 -3
  98. package/build/production/shared/components/selectors/NativeDropdown/index.js.map +1 -1
  99. package/build/production/shared/components/selectors/Switch/index.js +1 -1
  100. package/build/production/shared/components/selectors/Switch/index.js.map +1 -1
  101. package/build/production/shared/components/selectors/common.js +2 -4
  102. package/build/production/shared/components/selectors/common.js.map +1 -1
  103. package/build/production/shared/components/selectors/index.js +1 -1
  104. package/build/production/shared/components/selectors/index.js.map +1 -1
  105. package/build/production/shared/utils/globalState.js.map +1 -1
  106. package/build/production/shared/utils/jest/index.js +1 -1
  107. package/build/production/shared/utils/jest/index.js.map +1 -1
  108. package/build/production/shared/utils/splitComponent.js +10 -12
  109. package/build/production/shared/utils/splitComponent.js.map +1 -1
  110. package/build/production/web.bundle.js +1 -1
  111. package/build/production/web.bundle.js.map +1 -1
  112. package/build/types-code/client/getInj.d.ts +0 -6
  113. package/build/types-code/client/index.d.ts +1 -2
  114. package/build/types-code/index.d.ts +2 -3
  115. package/build/types-code/server/Cache.d.ts +3 -11
  116. package/build/types-code/server/index.d.ts +0 -2
  117. package/build/types-code/server/renderer.d.ts +0 -1
  118. package/build/types-code/server/server.d.ts +0 -1
  119. package/build/types-code/shared/components/Button/index.d.ts +3 -4
  120. package/build/types-code/shared/components/Checkbox/index.d.ts +3 -12
  121. package/build/types-code/shared/components/Input/index.d.ts +4 -5
  122. package/build/types-code/shared/components/Link.d.ts +0 -1
  123. package/build/types-code/shared/components/Modal/index.d.ts +3 -4
  124. package/build/types-code/shared/components/NavLink.d.ts +0 -1
  125. package/build/types-code/shared/components/PageLayout/index.d.ts +4 -4
  126. package/build/types-code/shared/components/TextArea/index.d.ts +4 -5
  127. package/build/types-code/shared/components/Throbber/index.d.ts +4 -4
  128. package/build/types-code/shared/components/WithTooltip/Tooltip.d.ts +1 -1
  129. package/build/types-code/shared/components/WithTooltip/index.d.ts +2 -3
  130. package/build/types-code/shared/components/YouTubeVideo/index.d.ts +3 -4
  131. package/build/types-code/shared/components/selectors/CustomDropdown/Options/index.d.ts +1 -2
  132. package/build/types-code/shared/components/selectors/CustomDropdown/index.d.ts +2 -3
  133. package/build/types-code/shared/components/selectors/NativeDropdown/index.d.ts +2 -2
  134. package/build/types-code/shared/components/selectors/Switch/index.d.ts +4 -5
  135. package/build/types-code/shared/components/selectors/common.d.ts +5 -11
  136. package/build/types-code/shared/components/selectors/index.d.ts +1 -1
  137. package/build/types-code/shared/utils/globalState.d.ts +6 -2
  138. package/build/types-code/shared/utils/jest/index.d.ts +4 -1
  139. package/build/types-code/shared/utils/splitComponent.d.ts +0 -1
  140. package/build/types-code/shared/utils/webpack.d.ts +0 -1
  141. package/config/babel/node-ssr.js +1 -1
  142. package/config/babel/webpack.js +1 -1
  143. package/config/eslint/default.json +1 -0
  144. package/config/eslint/jest.json +1 -0
  145. package/config/eslint/typescript.js +7 -0
  146. package/config/typescript/base.json +9 -0
  147. package/config/webpack/app-base.d.ts +0 -1
  148. package/config/webpack/app-base.js +1 -1
  149. package/config/webpack/app-development.js +1 -1
  150. package/config/webpack/app-production.js +1 -1
  151. package/config/webpack/lib-base.js +1 -2
  152. package/config/webpack/lib-development.js +1 -1
  153. package/config/webpack/lib-production.js +1 -1
  154. package/package.json +28 -27
  155. package/src/client/getInj.ts +3 -9
  156. package/src/client/index.tsx +1 -3
  157. package/src/index.ts +1 -10
  158. package/src/server/Cache.ts +31 -30
  159. package/src/server/renderer.tsx +8 -5
  160. package/src/server/server.ts +6 -1
  161. package/src/shared/components/Button/index.tsx +2 -20
  162. package/src/shared/components/Checkbox/index.tsx +2 -37
  163. package/src/shared/components/GenericLink/index.tsx +0 -15
  164. package/src/shared/components/Input/index.tsx +6 -15
  165. package/src/shared/components/MetaTags.tsx +0 -12
  166. package/src/shared/components/Modal/index.tsx +3 -22
  167. package/src/shared/components/PageLayout/index.tsx +8 -24
  168. package/src/shared/components/TextArea/index.tsx +6 -24
  169. package/src/shared/components/Throbber/index.tsx +6 -18
  170. package/src/shared/components/WithTooltip/Tooltip.tsx +6 -14
  171. package/src/shared/components/WithTooltip/index.tsx +3 -24
  172. package/src/shared/components/YouTubeVideo/index.tsx +3 -20
  173. package/src/shared/components/selectors/CustomDropdown/Options/index.tsx +2 -20
  174. package/src/shared/components/selectors/CustomDropdown/index.tsx +3 -27
  175. package/src/shared/components/selectors/NativeDropdown/index.tsx +3 -27
  176. package/src/shared/components/selectors/Switch/index.tsx +34 -50
  177. package/src/shared/components/selectors/common.ts +13 -45
  178. package/src/shared/components/selectors/index.ts +0 -2
  179. package/src/shared/utils/globalState.ts +6 -0
  180. package/src/shared/utils/jest/index.tsx +13 -2
  181. package/src/shared/utils/splitComponent.tsx +24 -29
  182. package/tsconfig.configs.json +7 -3
  183. package/tsconfig.json +3 -10
  184. package/tsconfig.types.json +1 -7
  185. package/tstyche.config.json +6 -0
@@ -1 +1 @@
1
- {"version":3,"file":"server.js","names":["_path","require","_url","_lodash","_compression","_interopRequireDefault","_cookieParser","_csurf","_express","_serveFavicon","_helmet","_morgan","_requestIp","_uuid","_renderer","_errors","defaultCspSettings","directives","mapValues","helmet","contentSecurityPolicy","getDefaultDirectives","array","filter","item","push","getDefaultCspSettings","cloneDeep","factory","webpackConfig","options","rendererOps","pick","renderer","rendererFactory","publicPath","output","server","express","beforeExpressJsSetup","logger","httpsRedirect","use","req","res","next","schema","headers","url","host","originalUrl","redirect","compression","crossOriginEmbedderPolicy","crossOriginOpenerPolicy","crossOriginResourcePolicy","noCsp","req2","nonce","uuid","cspNonce","cspSettings","cspSettingsHook","favicon","send","json","limit","urlencoded","extended","cookieParser","requestIp","mw","csrf","cookie","loggerMiddleware","token","clientIp","FORMAT","stream","write","info","bind","get","static","path","setHeaders","set","devMode","global","location","href","pathToFileURL","process","cwd","sep","webpack","webpackDevMiddleware","webpackHotMiddleware","compiler","serverSideRender","onExpressJsSetup","newError","ERRORS","NOT_FOUND","CODES","dontAttachDefaultErrorHandler","beforeExpressJsError","error","headersSent","status","INTERNAL_SERVER_ERROR","serverSide","log","message","getErrorForCode","env","NODE_ENV","undefined"],"sources":["../../../src/server/server.ts"],"sourcesContent":["/**\n * Creation of standard ExpressJS server for ReactJS apps.\n */\n\nimport { sep } from 'path';\nimport { pathToFileURL } from 'url';\n\nimport {\n cloneDeep,\n mapValues,\n pick,\n} from 'lodash';\n\nimport compression from 'compression';\nimport cookieParser from 'cookie-parser';\nimport csrf from '@dr.pogodin/csurf';\n\nimport express, {\n type Express,\n type NextFunction,\n type Request,\n type Response,\n} from 'express';\n\nimport favicon from 'serve-favicon';\nimport helmet, { type HelmetOptions } from 'helmet';\nimport loggerMiddleware from 'morgan';\nimport requestIp from 'request-ip';\nimport { v4 as uuid } from 'uuid';\nimport { type Configuration } from 'webpack';\n\nimport rendererFactory, {\n type LoggerI,\n type OptionsT as RendererOptionsT,\n} from './renderer';\n\nimport {\n CODES,\n ERRORS,\n getErrorForCode,\n newError,\n} from './utils/errors';\n\nexport type CspOptionsT =\nExclude<HelmetOptions['contentSecurityPolicy'], boolean | undefined>;\n\ninterface RequestT extends Request {\n cspNonce: string;\n nonce: string;\n}\n\n/**\n * Default Content Security Policy settings.\n * @ignore\n */\nconst defaultCspSettings = {\n directives: mapValues(\n helmet.contentSecurityPolicy.getDefaultDirectives(),\n\n // 'https:' options (automatic re-write of insecure URLs to secure ones)\n // is removed to facilitate local development with HTTP server. In cloud\n // deployments we assume Apache or Nginx server in front of out app takes\n // care about such re-writes.\n (array) => (array as string[]).filter((item: string) => item !== 'https:'),\n ),\n};\ndefaultCspSettings.directives['frame-src'] = [\n \"'self'\",\n\n // YouTube domain is whitelisted to allow <YouTubeVideo> component to work\n // out of box.\n 'https://*.youtube.com',\n];\ndefaultCspSettings.directives['script-src'].push(\"'unsafe-eval'\");\n\n// No need for automatic re-writes via Content Security Policy settings:\n// the forefront Apache or Nginx server is supposed to take care of this\n// in production cloud deployments.\ndelete defaultCspSettings.directives['upgrade-insecure-requests'];\n\n/**\n * @category Utilities\n * @func server/getDefaultCspSettings\n * @global\n * @desc\n * ```js\n * import { server } from '@dr.pogodin/react-utils';\n * const { getDefaultCspSettings } from '@dr.pogodin/react-utils';\n * ```\n * @return {{\n * directives: object\n * }} A deep copy of default CSP settings object used by `react-utils`,\n * with the exception of `nonce-xxx` clause in `script-src` directive,\n * which is added dynamically for each request.\n */\nexport function getDefaultCspSettings() {\n return cloneDeep(defaultCspSettings);\n}\n\ntype ServerT = Express & {\n logger: LoggerI;\n};\n\nexport type OptionsT = RendererOptionsT & {\n beforeExpressJsError?: (server: ServerT) => Promise<boolean>;\n beforeExpressJsSetup?: (server: ServerT) => Promise<void>;\n cspSettingsHook?: (\n defaultOptions: CspOptionsT,\n req: Request,\n ) => CspOptionsT;\n devMode?: boolean;\n httpsRedirect?: boolean;\n onExpressJsSetup?: (server: ServerT) => Promise<void> | void;\n};\n\nexport default async function factory(\n webpackConfig: Configuration,\n options: OptionsT,\n) {\n const rendererOps: RendererOptionsT = pick(options, [\n 'Application',\n 'beforeRender',\n 'favicon',\n 'logger',\n 'maxSsrRounds',\n 'noCsp',\n 'ssrTimeout',\n 'staticCacheController',\n 'staticCacheSize',\n ]);\n const renderer = rendererFactory(webpackConfig, rendererOps);\n const { publicPath } = webpackConfig.output!;\n\n const server = express() as ServerT;\n\n if (options.beforeExpressJsSetup) {\n await options.beforeExpressJsSetup(server);\n }\n\n if (options.logger) server.logger = options.logger;\n\n if (options.httpsRedirect) {\n server.use((req, res, next) => {\n const schema = req.headers['x-forwarded-proto'];\n if (schema === 'http') {\n let url = `https://${req.headers.host}`;\n if (req.originalUrl !== '/') url += req.originalUrl;\n return res.redirect(url);\n }\n return next();\n });\n }\n\n server.use(compression());\n server.use(\n helmet({\n contentSecurityPolicy: false,\n crossOriginEmbedderPolicy: false,\n crossOriginOpenerPolicy: false,\n crossOriginResourcePolicy: false,\n }),\n );\n\n if (!options.noCsp) {\n server.use(\n (req: Request, res: Response, next: NextFunction) => {\n const req2 = req as RequestT;\n\n req2.nonce = uuid();\n\n // TODO: This is deprecated, but it is kept for now for backward\n // compatibility. Should be removed sometime later.\n req2.cspNonce = req2.nonce;\n\n // The deep clone is necessary here to ensure that default value can't be\n // mutated during request processing.\n let cspSettings: CspOptionsT = cloneDeep(defaultCspSettings);\n (cspSettings.directives?.['script-src'] as string[]).push(`'nonce-${req2.nonce}'`);\n if (options.cspSettingsHook) {\n cspSettings = options.cspSettingsHook(cspSettings, req);\n }\n helmet.contentSecurityPolicy(cspSettings)(req, res, next);\n },\n );\n }\n\n if (options.favicon) {\n server.use(favicon(options.favicon));\n }\n\n server.use('/robots.txt', (req, res) => res.send('User-agent: *\\nDisallow:'));\n\n server.use(express.json({ limit: '300kb' }));\n server.use(express.urlencoded({ extended: false }));\n server.use(cookieParser());\n server.use(requestIp.mw());\n\n server.use(csrf({ cookie: true }));\n\n loggerMiddleware.token(\n 'ip',\n (req: Request & { clientIp: string }) => req.clientIp,\n );\n const FORMAT = ':ip > :status :method :url :response-time ms :res[content-length] :referrer :user-agent';\n server.use(loggerMiddleware(FORMAT, {\n stream: {\n // TODO: This implies the logger is always set. Is it on a higher level?\n // then mark it as always present.\n write: options.logger!.info.bind(options.logger),\n },\n }));\n\n // Note: no matter the \"public path\", we want the service worker, if any,\n // to be served from the root, to have all web app pages in its scope.\n // Thus, this setup to serve it. Probably, need some more configuration\n // for special cases, but this will do for now.\n server.get('/__service-worker.js', express.static(\n webpackConfig.output?.path || '',\n {\n setHeaders: (res) => res.set('Cache-Control', 'no-cache'),\n },\n ));\n\n /* Setup of Hot Module Reloading for development environment.\n * These dependencies are not used, nor installed for production use,\n * hence we should violate some import-related lint rules. */\n /* eslint-disable global-require */\n /* eslint-disable import/no-extraneous-dependencies */\n /* eslint-disable import/no-unresolved */\n if (options.devMode) {\n // This is a workaround for SASS bug:\n // https://github.com/dart-lang/sdk/issues/27979\n // which manifests itself sometimes when webpack dev middleware is used\n // (in dev mode), and app modules are imported in some unfortunate ways.\n if (!global.location) {\n global.location = {\n href: `${pathToFileURL(process.cwd()).href}${sep}`,\n } as Location;\n }\n\n const webpack = require('webpack');\n const webpackDevMiddleware = require('webpack-dev-middleware');\n const webpackHotMiddleware = require('webpack-hot-middleware');\n const compiler = webpack(webpackConfig);\n server.use(webpackDevMiddleware(compiler, {\n publicPath,\n serverSideRender: true,\n }));\n server.use(webpackHotMiddleware(compiler));\n }\n /* eslint-enable global-require */\n /* eslint-enable import/no-extraneous-dependencies */\n /* eslint-enable import/no-unresolved */\n\n server.use(publicPath as string, express.static(webpackConfig.output!.path!));\n\n if (options.onExpressJsSetup) {\n await options.onExpressJsSetup(server);\n }\n server.use(renderer);\n\n /* Detects 404 errors, and forwards them to the error handler. */\n server.use((req, res, next) => {\n next(newError(ERRORS.NOT_FOUND, CODES.NOT_FOUND));\n });\n\n let dontAttachDefaultErrorHandler;\n if (options.beforeExpressJsError) {\n dontAttachDefaultErrorHandler = await options.beforeExpressJsError(server);\n }\n\n /* Error handler. */\n if (!dontAttachDefaultErrorHandler) {\n // TODO: Do we need this error handler at all? It actually seems to do\n // what the default ExpressJS error handler does anyway, see:\n // https://expressjs.com/en/guide/error-handling.html\n //\n // TODO: It is better to move the default error handler definition\n // to a stand-alone function at top-level, but the use of options.logger\n // prevents to do it without some extra refactoring. Should be done sometime\n // though.\n server.use((\n error: any,\n req: Request,\n res: Response,\n next: NextFunction,\n ) => {\n // TODO: This is needed to correctly handled any errors thrown after\n // sending initial response to the client.\n if (res.headersSent) return next(error);\n\n const status = error.status || CODES.INTERNAL_SERVER_ERROR;\n const serverSide = status >= CODES.INTERNAL_SERVER_ERROR;\n\n // Log server-side errors always, client-side at debug level only.\n options.logger!.log(serverSide ? 'error' : 'debug', error);\n\n let message = error.message || getErrorForCode(status);\n if (serverSide && process.env.NODE_ENV === 'production') {\n message = ERRORS.INTERNAL_SERVER_ERROR;\n }\n\n res.status(status).send(message);\n return undefined;\n });\n }\n\n return server;\n}\n"],"mappings":";;;;;;;;AAIA,IAAAA,KAAA,GAAAC,OAAA;AACA,IAAAC,IAAA,GAAAD,OAAA;AAEA,IAAAE,OAAA,GAAAF,OAAA;AAMA,IAAAG,YAAA,GAAAC,sBAAA,CAAAJ,OAAA;AACA,IAAAK,aAAA,GAAAD,sBAAA,CAAAJ,OAAA;AACA,IAAAM,MAAA,GAAAF,sBAAA,CAAAJ,OAAA;AAEA,IAAAO,QAAA,GAAAH,sBAAA,CAAAJ,OAAA;AAOA,IAAAQ,aAAA,GAAAJ,sBAAA,CAAAJ,OAAA;AACA,IAAAS,OAAA,GAAAL,sBAAA,CAAAJ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,CAACC,QAAQ,KAAK,YAAY,EAAE;QACvDH,OAAO,GAAGX,cAAM,CAACQ,qBAAqB;MACxC;MAEAlE,GAAG,CAACiE,MAAM,CAACA,MAAM,CAAC,CAAC7C,IAAI,CAACiD,OAAO,CAAC;MAChC,OAAOI,SAAS;IAClB,CAAC,CAAC;EACJ;EAEA,OAAOhF,MAAM;AACf","ignoreList":[]}
1
+ {"version":3,"file":"server.js","names":["_path","require","_url","_lodash","_compression","_interopRequireDefault","_cookieParser","_csurf","_express","_serveFavicon","_helmet","_morgan","_requestIp","_uuid","_renderer","_errors","defaultCspSettings","directives","mapValues","helmet","contentSecurityPolicy","getDefaultDirectives","array","filter","item","push","getDefaultCspSettings","cloneDeep","factory","webpackConfig","options","rendererOps","pick","renderer","rendererFactory","publicPath","output","server","express","beforeExpressJsSetup","logger","httpsRedirect","use","req","res","next","schema","headers","url","host","originalUrl","redirect","compression","crossOriginEmbedderPolicy","crossOriginOpenerPolicy","crossOriginResourcePolicy","noCsp","req2","nonce","uuid","cspNonce","cspSettings","cspSettingsHook","favicon","send","json","limit","urlencoded","extended","cookieParser","requestIp","mw","csrf","cookie","loggerMiddleware","token","clientIp","FORMAT","stream","write","info","bind","get","static","path","setHeaders","set","devMode","global","location","href","pathToFileURL","process","cwd","sep","webpack","webpackDevMiddleware","webpackHotMiddleware","compiler","serverSideRender","onExpressJsSetup","newError","ERRORS","NOT_FOUND","CODES","dontAttachDefaultErrorHandler","beforeExpressJsError","error","headersSent","status","INTERNAL_SERVER_ERROR","serverSide","log","message","getErrorForCode","env","NODE_ENV","undefined"],"sources":["../../../src/server/server.ts"],"sourcesContent":["/**\n * Creation of standard ExpressJS server for ReactJS apps.\n */\n\nimport { sep } from 'path';\nimport { pathToFileURL } from 'url';\n\nimport {\n cloneDeep,\n mapValues,\n pick,\n} from 'lodash';\n\nimport compression from 'compression';\nimport cookieParser from 'cookie-parser';\nimport csrf from '@dr.pogodin/csurf';\n\nimport express, {\n type Express,\n type NextFunction,\n type Request,\n type Response,\n} from 'express';\n\nimport favicon from 'serve-favicon';\nimport helmet, { type HelmetOptions } from 'helmet';\nimport loggerMiddleware from 'morgan';\nimport requestIp from 'request-ip';\nimport { v4 as uuid } from 'uuid';\nimport { type Configuration } from 'webpack';\n\nimport rendererFactory, {\n type LoggerI,\n type OptionsT as RendererOptionsT,\n} from './renderer';\n\nimport {\n CODES,\n ERRORS,\n getErrorForCode,\n newError,\n} from './utils/errors';\n\nexport type CspOptionsT =\nExclude<HelmetOptions['contentSecurityPolicy'], boolean | undefined>;\n\ninterface RequestT extends Request {\n cspNonce: string;\n nonce: string;\n}\n\n/**\n * Default Content Security Policy settings.\n * @ignore\n */\nconst defaultCspSettings = {\n directives: mapValues(\n helmet.contentSecurityPolicy.getDefaultDirectives(),\n\n // 'https:' options (automatic re-write of insecure URLs to secure ones)\n // is removed to facilitate local development with HTTP server. In cloud\n // deployments we assume Apache or Nginx server in front of out app takes\n // care about such re-writes.\n (array) => (array as string[]).filter((item: string) => item !== 'https:'),\n ),\n};\ndefaultCspSettings.directives['frame-src'] = [\n \"'self'\",\n\n // YouTube domain is whitelisted to allow <YouTubeVideo> component to work\n // out of box.\n 'https://*.youtube.com',\n];\n\n{\n const directives = defaultCspSettings.directives['script-src'];\n if (directives) directives.push(\"'unsafe-eval'\");\n else defaultCspSettings.directives['script-src'] = [\"'unsafe-eval'\"];\n}\n\n// No need for automatic re-writes via Content Security Policy settings:\n// the forefront Apache or Nginx server is supposed to take care of this\n// in production cloud deployments.\ndelete defaultCspSettings.directives['upgrade-insecure-requests'];\n\n/**\n * @category Utilities\n * @func server/getDefaultCspSettings\n * @global\n * @desc\n * ```js\n * import { server } from '@dr.pogodin/react-utils';\n * const { getDefaultCspSettings } from '@dr.pogodin/react-utils';\n * ```\n * @return {{\n * directives: object\n * }} A deep copy of default CSP settings object used by `react-utils`,\n * with the exception of `nonce-xxx` clause in `script-src` directive,\n * which is added dynamically for each request.\n */\nexport function getDefaultCspSettings() {\n return cloneDeep(defaultCspSettings);\n}\n\ntype ServerT = Express & {\n logger: LoggerI;\n};\n\nexport type OptionsT = RendererOptionsT & {\n beforeExpressJsError?: (server: ServerT) => Promise<boolean>;\n beforeExpressJsSetup?: (server: ServerT) => Promise<void>;\n cspSettingsHook?: (\n defaultOptions: CspOptionsT,\n req: Request,\n ) => CspOptionsT;\n devMode?: boolean;\n httpsRedirect?: boolean;\n onExpressJsSetup?: (server: ServerT) => Promise<void> | void;\n};\n\nexport default async function factory(\n webpackConfig: Configuration,\n options: OptionsT,\n) {\n const rendererOps: RendererOptionsT = pick(options, [\n 'Application',\n 'beforeRender',\n 'favicon',\n 'logger',\n 'maxSsrRounds',\n 'noCsp',\n 'ssrTimeout',\n 'staticCacheController',\n 'staticCacheSize',\n ]);\n const renderer = rendererFactory(webpackConfig, rendererOps);\n const { publicPath } = webpackConfig.output!;\n\n const server = express() as ServerT;\n\n if (options.beforeExpressJsSetup) {\n await options.beforeExpressJsSetup(server);\n }\n\n if (options.logger) server.logger = options.logger;\n\n if (options.httpsRedirect) {\n server.use((req, res, next) => {\n const schema = req.headers['x-forwarded-proto'];\n if (schema === 'http') {\n let url = `https://${req.headers.host}`;\n if (req.originalUrl !== '/') url += req.originalUrl;\n return res.redirect(url);\n }\n return next();\n });\n }\n\n server.use(compression());\n server.use(\n helmet({\n contentSecurityPolicy: false,\n crossOriginEmbedderPolicy: false,\n crossOriginOpenerPolicy: false,\n crossOriginResourcePolicy: false,\n }),\n );\n\n if (!options.noCsp) {\n server.use(\n (req: Request, res: Response, next: NextFunction) => {\n const req2 = req as RequestT;\n\n req2.nonce = uuid();\n\n // TODO: This is deprecated, but it is kept for now for backward\n // compatibility. Should be removed sometime later.\n req2.cspNonce = req2.nonce;\n\n // The deep clone is necessary here to ensure that default value can't be\n // mutated during request processing.\n let cspSettings: CspOptionsT = cloneDeep(defaultCspSettings);\n (cspSettings.directives?.['script-src'] as string[]).push(`'nonce-${req2.nonce}'`);\n if (options.cspSettingsHook) {\n cspSettings = options.cspSettingsHook(cspSettings, req);\n }\n helmet.contentSecurityPolicy(cspSettings)(req, res, next);\n },\n );\n }\n\n if (options.favicon) {\n server.use(favicon(options.favicon));\n }\n\n server.use('/robots.txt', (req, res) => res.send('User-agent: *\\nDisallow:'));\n\n server.use(express.json({ limit: '300kb' }));\n server.use(express.urlencoded({ extended: false }));\n server.use(cookieParser());\n server.use(requestIp.mw());\n\n server.use(csrf({ cookie: true }));\n\n loggerMiddleware.token(\n 'ip',\n (req: Request & { clientIp: string }) => req.clientIp,\n );\n const FORMAT = ':ip > :status :method :url :response-time ms :res[content-length] :referrer :user-agent';\n server.use(loggerMiddleware(FORMAT, {\n stream: {\n // TODO: This implies the logger is always set. Is it on a higher level?\n // then mark it as always present.\n write: options.logger!.info.bind(options.logger),\n },\n }));\n\n // Note: no matter the \"public path\", we want the service worker, if any,\n // to be served from the root, to have all web app pages in its scope.\n // Thus, this setup to serve it. Probably, need some more configuration\n // for special cases, but this will do for now.\n server.get('/__service-worker.js', express.static(\n webpackConfig.output?.path || '',\n {\n setHeaders: (res) => res.set('Cache-Control', 'no-cache'),\n },\n ));\n\n /* Setup of Hot Module Reloading for development environment.\n * These dependencies are not used, nor installed for production use,\n * hence we should violate some import-related lint rules. */\n /* eslint-disable global-require */\n /* eslint-disable import/no-extraneous-dependencies */\n /* eslint-disable import/no-unresolved */\n if (options.devMode) {\n // This is a workaround for SASS bug:\n // https://github.com/dart-lang/sdk/issues/27979\n // which manifests itself sometimes when webpack dev middleware is used\n // (in dev mode), and app modules are imported in some unfortunate ways.\n if (!global.location) {\n global.location = {\n href: `${pathToFileURL(process.cwd()).href}${sep}`,\n } as Location;\n }\n\n const webpack = require('webpack');\n const webpackDevMiddleware = require('webpack-dev-middleware');\n const webpackHotMiddleware = require('webpack-hot-middleware');\n const compiler = webpack(webpackConfig);\n server.use(webpackDevMiddleware(compiler, {\n publicPath,\n serverSideRender: true,\n }));\n server.use(webpackHotMiddleware(compiler));\n }\n /* eslint-enable global-require */\n /* eslint-enable import/no-extraneous-dependencies */\n /* eslint-enable import/no-unresolved */\n\n server.use(publicPath as string, express.static(webpackConfig.output!.path!));\n\n if (options.onExpressJsSetup) {\n await options.onExpressJsSetup(server);\n }\n server.use(renderer);\n\n /* Detects 404 errors, and forwards them to the error handler. */\n server.use((req, res, next) => {\n next(newError(ERRORS.NOT_FOUND, CODES.NOT_FOUND));\n });\n\n let dontAttachDefaultErrorHandler;\n if (options.beforeExpressJsError) {\n dontAttachDefaultErrorHandler = await options.beforeExpressJsError(server);\n }\n\n /* Error handler. */\n if (!dontAttachDefaultErrorHandler) {\n // TODO: Do we need this error handler at all? It actually seems to do\n // what the default ExpressJS error handler does anyway, see:\n // https://expressjs.com/en/guide/error-handling.html\n //\n // TODO: It is better to move the default error handler definition\n // to a stand-alone function at top-level, but the use of options.logger\n // prevents to do it without some extra refactoring. Should be done sometime\n // though.\n server.use((\n error: any,\n req: Request,\n res: Response,\n next: NextFunction,\n ) => {\n // TODO: This is needed to correctly handled any errors thrown after\n // sending initial response to the client.\n if (res.headersSent) return next(error);\n\n const status = error.status || CODES.INTERNAL_SERVER_ERROR;\n const serverSide = status >= CODES.INTERNAL_SERVER_ERROR;\n\n // Log server-side errors always, client-side at debug level only.\n options.logger!.log(serverSide ? 'error' : 'debug', error);\n\n let message = error.message || getErrorForCode(status);\n if (serverSide && process.env.NODE_ENV === 'production') {\n message = ERRORS.INTERNAL_SERVER_ERROR;\n }\n\n res.status(status).send(message);\n return undefined;\n });\n }\n\n return server;\n}\n"],"mappings":";;;;;;;;AAIA,IAAAA,KAAA,GAAAC,OAAA;AACA,IAAAC,IAAA,GAAAD,OAAA;AAEA,IAAAE,OAAA,GAAAF,OAAA;AAMA,IAAAG,YAAA,GAAAC,sBAAA,CAAAJ,OAAA;AACA,IAAAK,aAAA,GAAAD,sBAAA,CAAAJ,OAAA;AACA,IAAAM,MAAA,GAAAF,sBAAA,CAAAJ,OAAA;AAEA,IAAAO,QAAA,GAAAH,sBAAA,CA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qBAAqB;;MAExD;MACAhF,OAAO,CAACU,MAAM,CAAEwE,GAAG,CAACD,UAAU,GAAG,OAAO,GAAG,OAAO,EAAEJ,KAAK,CAAC;MAE1D,IAAIM,OAAO,GAAGN,KAAK,CAACM,OAAO,IAAI,IAAAC,uBAAe,EAACL,MAAM,CAAC;MACtD,IAAIE,UAAU,IAAInB,OAAO,CAACuB,GAAG,CAACC,QAAQ,KAAK,YAAY,EAAE;QACvDH,OAAO,GAAGX,cAAM,CAACQ,qBAAqB;MACxC;MAEAlE,GAAG,CAACiE,MAAM,CAACA,MAAM,CAAC,CAAC7C,IAAI,CAACiD,OAAO,CAAC;MAChC,OAAOI,SAAS;IAClB,CAAC,CAAC;EACJ;EAEA,OAAOhF,MAAM;AACf","ignoreList":[]}
@@ -5,7 +5,6 @@ Object.defineProperty(exports, "__esModule", {
5
5
  value: true
6
6
  });
7
7
  exports.default = exports.BaseButton = void 0;
8
- var _propTypes = _interopRequireDefault(require("prop-types"));
9
8
  require("react");
10
9
  var _Link = _interopRequireDefault(require("../Link"));
11
10
  var _reactThemes = _interopRequireDefault(require("@dr.pogodin/react-themes"));
@@ -19,7 +18,6 @@ const defaultTheme = {
19
18
  "active": "-dr-pogodin-react-utils___src-shared-components-Button-style___active___MAe9O6",
20
19
  "disabled": "-dr-pogodin-react-utils___src-shared-components-Button-style___disabled___Br9IWV"
21
20
  };
22
- const validThemeKeys = ['active', 'button', 'disabled'];
23
21
  /* eslint-disable react/function-component-definition */
24
22
  const BaseButton = ({
25
23
  active,
@@ -75,18 +73,5 @@ const BaseButton = ({
75
73
  * @prop {string} [disabled] to the root element of disabled button.
76
74
  */
77
75
  exports.BaseButton = BaseButton;
78
- const ThemedButton = (0, _reactThemes.default)(BaseButton, 'Button', validThemeKeys, defaultTheme);
79
- BaseButton.propTypes = {
80
- active: _propTypes.default.bool,
81
- children: _propTypes.default.node,
82
- disabled: _propTypes.default.bool,
83
- enforceA: _propTypes.default.bool,
84
- onClick: _propTypes.default.func,
85
- onMouseDown: _propTypes.default.func,
86
- openNewTab: _propTypes.default.bool,
87
- replace: _propTypes.default.bool,
88
- theme: ThemedButton.themeType.isRequired,
89
- to: _propTypes.default.oneOfType([_propTypes.default.object, _propTypes.default.string])
90
- };
91
- var _default = exports.default = ThemedButton;
76
+ var _default = exports.default = (0, _reactThemes.default)(BaseButton, 'Button', defaultTheme);
92
77
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":["_propTypes","_interopRequireDefault","require","_Link","_reactThemes","_jsxRuntime","defaultTheme","validThemeKeys","BaseButton","active","children","disabled","enforceA","onClick","onMouseDown","openNewTab","replace","theme","to","className","button","jsx","default","onKeyDown","e","key","role","tabIndex","exports","ThemedButton","themed","propTypes","PT","bool","node","func","themeType","isRequired","oneOfType","object","string","_default"],"sources":["../../../../../src/shared/components/Button/index.tsx"],"sourcesContent":["// The <Button> component implements a standard button / button-like link.\n\nimport PT from 'prop-types';\nimport { type ReactNode } from 'react';\n\nimport Link from 'components/Link';\n\nimport themed, { type Theme } from '@dr.pogodin/react-themes';\n\nimport defaultTheme from './style.scss';\n\nconst validThemeKeys = ['active', 'button', 'disabled'] as const;\n\ntype PropsT = {\n active?: boolean;\n children?: ReactNode;\n disabled?: boolean;\n enforceA?: boolean;\n onClick?: React.MouseEventHandler & React.KeyboardEventHandler;\n onMouseDown?: React.MouseEventHandler;\n openNewTab?: boolean;\n replace?: boolean;\n theme: Theme<typeof validThemeKeys>;\n // TODO: It needs a more precise typing of the object option.\n to?: object | string;\n};\n\n/* eslint-disable react/function-component-definition */\nexport const BaseButton: React.FunctionComponent<PropsT> = ({\n active,\n children,\n disabled,\n enforceA,\n onClick,\n onMouseDown,\n openNewTab,\n replace,\n theme,\n to,\n}) => {\n let className = theme.button;\n if (active && theme.active) className += ` ${theme.active}`;\n if (disabled) {\n if (theme.disabled) className += ` ${theme.disabled}`;\n return (\n <div className={className}>\n {children}\n </div>\n );\n }\n if (to) {\n return (\n <Link\n className={className}\n enforceA={enforceA}\n onClick={onClick}\n onMouseDown={onMouseDown}\n openNewTab={openNewTab}\n replace={replace}\n to={to}\n >\n {children}\n </Link>\n );\n }\n\n return (\n <div\n className={className}\n onClick={onClick}\n onKeyDown={onClick && ((e) => {\n if (e.key === 'Enter') onClick(e);\n })}\n onMouseDown={onMouseDown}\n role=\"button\"\n tabIndex={0}\n >\n {children}\n </div>\n );\n};\n\n/**\n * Button component theme: a map of CSS\n * class names to append to button elements:\n * @prop {string} [active] to the root element of active button.\n * @prop {string} [button] to the root element of any button.\n * @prop {string} [disabled] to the root element of disabled button.\n */\nconst ThemedButton = themed(BaseButton, 'Button', validThemeKeys, defaultTheme);\n\nBaseButton.propTypes = {\n active: PT.bool,\n children: PT.node,\n disabled: PT.bool,\n enforceA: PT.bool,\n onClick: PT.func,\n onMouseDown: PT.func,\n openNewTab: PT.bool,\n replace: PT.bool,\n theme: ThemedButton.themeType.isRequired,\n to: PT.oneOfType([PT.object, PT.string]),\n};\n\nexport default ThemedButton;\n"],"mappings":";;;;;;;AAEA,IAAAA,UAAA,GAAAC,sBAAA,CAAAC,OAAA;AACAA,OAAA;AAEA,IAAAC,KAAA,GAAAF,sBAAA,CAAAC,OAAA;AAEA,IAAAE,YAAA,GAAAH,sBAAA,CAAAC,OAAA;AAA8D,IAAAG,WAAA,GAAAH,OAAA;AAP9D;AAAA,MAAAI,YAAA;EAAA;EAAA;EAAA;EAAA;EAAA;EAAA;AAAA;AAWA,MAAMC,cAAc,GAAG,CAAC,QAAQ,EAAE,QAAQ,EAAE,UAAU,CAAU;AAgBhE;AACO,MAAMC,UAA2C,GAAGA,CAAC;EAC1DC,MAAM;EACNC,QAAQ;EACRC,QAAQ;EACRC,QAAQ;EACRC,OAAO;EACPC,WAAW;EACXC,UAAU;EACVC,OAAO;EACPC,KAAK;EACLC;AACF,CAAC,KAAK;EACJ,IAAIC,SAAS,GAAGF,KAAK,CAACG,MAAM;EAC5B,IAAIX,MAAM,IAAIQ,KAAK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,EAAEsB,kBAAE,CAACE,IAAI;EACjBvB,QAAQ,EAAEqB,kBAAE,CAACC,IAAI;EACjBrB,QAAQ,EAAEoB,kBAAE,CAACC,IAAI;EACjBpB,OAAO,EAAEmB,kBAAE,CAACG,IAAI;EAChBrB,WAAW,EAAEkB,kBAAE,CAACG,IAAI;EACpBpB,UAAU,EAAEiB,kBAAE,CAACC,IAAI;EACnBjB,OAAO,EAAEgB,kBAAE,CAACC,IAAI;EAChBhB,KAAK,EAAEY,YAAY,CAACO,SAAS,CAACC,UAAU;EACxCnB,EAAE,EAAEc,kBAAE,CAACM,SAAS,CAAC,CAACN,kBAAE,CAACO,MAAM,EAAEP,kBAAE,CAACQ,MAAM,CAAC;AACzC,CAAC;AAAC,IAAAC,QAAA,GAAAb,OAAA,CAAAN,OAAA,GAEaO,YAAY","ignoreList":[]}
1
+ {"version":3,"file":"index.js","names":["require","_Link","_interopRequireDefault","_reactThemes","_jsxRuntime","defaultTheme","BaseButton","active","children","disabled","enforceA","onClick","onMouseDown","openNewTab","replace","theme","to","className","button","jsx","default","onKeyDown","e","key","role","tabIndex","exports","_default","themed"],"sources":["../../../../../src/shared/components/Button/index.tsx"],"sourcesContent":["// The <Button> component implements a standard button / button-like link.\n\nimport { type ReactNode } from 'react';\n\nimport Link from 'components/Link';\n\nimport themed, { type Theme } from '@dr.pogodin/react-themes';\n\nimport defaultTheme from './style.scss';\n\ntype PropsT = {\n active?: boolean;\n children?: ReactNode;\n disabled?: boolean;\n enforceA?: boolean;\n onClick?: React.MouseEventHandler & React.KeyboardEventHandler;\n onMouseDown?: React.MouseEventHandler;\n openNewTab?: boolean;\n replace?: boolean;\n theme: Theme<'active' | 'button' | 'disabled'>;\n // TODO: It needs a more precise typing of the object option.\n to?: object | string;\n};\n\n/* eslint-disable react/function-component-definition */\nexport const BaseButton: React.FunctionComponent<PropsT> = ({\n active,\n children,\n disabled,\n enforceA,\n onClick,\n onMouseDown,\n openNewTab,\n replace,\n theme,\n to,\n}) => {\n let className = theme.button;\n if (active && theme.active) className += ` ${theme.active}`;\n if (disabled) {\n if (theme.disabled) className += ` ${theme.disabled}`;\n return (\n <div className={className}>\n {children}\n </div>\n );\n }\n if (to) {\n return (\n <Link\n className={className}\n enforceA={enforceA}\n onClick={onClick}\n onMouseDown={onMouseDown}\n openNewTab={openNewTab}\n replace={replace}\n to={to}\n >\n {children}\n </Link>\n );\n }\n\n return (\n <div\n className={className}\n onClick={onClick}\n onKeyDown={onClick && ((e) => {\n if (e.key === 'Enter') onClick(e);\n })}\n onMouseDown={onMouseDown}\n role=\"button\"\n tabIndex={0}\n >\n {children}\n </div>\n );\n};\n\n/**\n * Button component theme: a map of CSS\n * class names to append to button elements:\n * @prop {string} [active] to the root element of active button.\n * @prop {string} [button] to the root element of any button.\n * @prop {string} [disabled] to the root element of disabled button.\n */\nexport default themed(BaseButton, 'Button', defaultTheme);\n"],"mappings":";;;;;;;AAEAA,OAAA;AAEA,IAAAC,KAAA,GAAAC,sBAAA,CAAAF,OAAA;AAEA,IAAAG,YAAA,GAAAD,sBAAA,CAAAF,OAAA;AAA8D,IAAAI,WAAA,GAAAJ,OAAA;AAN9D;AAAA,MAAAK,YAAA;EAAA;EAAA;EAAA;EAAA;EAAA;EAAA;AAAA;AAwBA;AACO,MAAMC,UAA2C,GAAGA,CAAC;EAC1DC,MAAM;EACNC,QAAQ;EACRC,QAAQ;EACRC,QAAQ;EACRC,OAAO;EACPC,WAAW;EACXC,UAAU;EACVC,OAAO;EACPC,KAAK;EACLC;AACF,CAAC,KAAK;EACJ,IAAIC,SAAS,GAAGF,KAAK,CAACG,MAAM;EAC5B,IAAIX,MAAM,IAAIQ,KAAK,CAACR,MAAM,EAAEU,SAAS,IAAI,IAAIF,KAAK,CAACR,MAAM,EAAE;EAC3D,IAAIE,QAAQ,EAAE;IACZ,IAAIM,KAAK,CAACN,QAAQ,EAAEQ,SAAS,IAAI,IAAIF,KAAK,CAACN,QAAQ,EAAE;IACrD,oBACE,IAAAL,WAAA,CAAAe,GAAA;MAAKF,SAAS,EAAEA,SAAU;MAAAT,QAAA,EACvBA;IAAQ,CACN,CAAC;EAEV;EACA,IAAIQ,EAAE,EAAE;IACN,oBACE,IAAAZ,WAAA,CAAAe,GAAA,EAAClB,KAAA,CAAAmB,OAAI;MACHH,SAAS,EAAEA,SAAU;MACrBP,QAAQ,EAAEA,QAAS;MACnBC,OAAO,EAAEA,OAAQ;MACjBC,WAAW,EAAEA,WAAY;MACzBC,UAAU,EAAEA,UAAW;MACvBC,OAAO,EAAEA,OAAQ;MACjBE,EAAE,EAAEA,EAAG;MAAAR,QAAA,EAENA;IAAQ,CACL,CAAC;EAEX;EAEA,oBACE,IAAAJ,WAAA,CAAAe,GAAA;IACEF,SAAS,EAAEA,SAAU;IACrBN,OAAO,EAAEA,OAAQ;IACjBU,SAAS,EAAEV,OAAO,KAAMW,CAAC,IAAK;MAC5B,IAAIA,CAAC,CAACC,GAAG,KAAK,OAAO,EAAEZ,OAAO,CAACW,CAAC,CAAC;IACnC,CAAC,CAAE;IACHV,WAAW,EAAEA,WAAY;IACzBY,IAAI,EAAC,QAAQ;IACbC,QAAQ,EAAE,CAAE;IAAAjB,QAAA,EAEXA;EAAQ,CACN,CAAC;AAEV,CAAC;;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AANAkB,OAAA,CAAApB,UAAA,GAAAA,UAAA;AAAA,IAAAqB,QAAA,GAAAD,OAAA,CAAAN,OAAA,GAOe,IAAAQ,oBAAM,EAACtB,UAAU,EAAE,QAAQ,EAAED,YAAY,CAAC","ignoreList":[]}
@@ -5,7 +5,6 @@ Object.defineProperty(exports, "__esModule", {
5
5
  value: true
6
6
  });
7
7
  exports.default = void 0;
8
- var _propTypes = _interopRequireDefault(require("prop-types"));
9
8
  var _reactThemes = _interopRequireDefault(require("@dr.pogodin/react-themes"));
10
9
  var _jsxRuntime = require("react/jsx-runtime");
11
10
  const defaultTheme = {
@@ -16,7 +15,6 @@ const defaultTheme = {
16
15
  "container": "-dr-pogodin-react-utils___src-shared-components-Checkbox-theme___container___Kr0g3M",
17
16
  "label": "-dr-pogodin-react-utils___src-shared-components-Checkbox-theme___label___3dML-O"
18
17
  };
19
- const validThemeKeys = ['checkbox', 'container', 'label'];
20
18
  const Checkbox = ({
21
19
  checked,
22
20
  label,
@@ -35,31 +33,5 @@ const Checkbox = ({
35
33
  type: "checkbox"
36
34
  })]
37
35
  });
38
-
39
- /**
40
- * Checkbox component theme: a map of
41
- * CSS classes to append to its elements:
42
- * @prop [checkbox] to the underlying checkbox `<input>` element.
43
- * @prop [container] to the root checkbox element.
44
- * @prop [label] to the checkbox label element.
45
- */
46
- const ThemedCheckbox = (0, _reactThemes.default)(Checkbox, 'Checkbox', validThemeKeys, defaultTheme);
47
-
48
- /**
49
- * The `<Checkbox>` component implements themeable checkboxes.
50
- * @param [props] Component properties.
51
- * @param [props.checked] Checkbox value.
52
- * @param [props.label] Checkbox label.
53
- * @param [props.onChange] State change handler.
54
- * @param [props.theme] _Ad hoc_ theme.
55
- * @param [props....]
56
- * [Other properties of themeable components](https://www.npmjs.com/package/@dr.pogodin/react-themes#themed-component-properties).
57
- */
58
- Checkbox.propTypes = {
59
- checked: _propTypes.default.bool,
60
- label: _propTypes.default.node,
61
- onChange: _propTypes.default.func,
62
- theme: ThemedCheckbox.themeType.isRequired
63
- };
64
- var _default = exports.default = ThemedCheckbox;
36
+ var _default = exports.default = (0, _reactThemes.default)(Checkbox, 'Checkbox', defaultTheme);
65
37
  //# sourceMappingURL=index.js.map
@@ -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","onClick","e","stopPropagation","type","ThemedCheckbox","themed","propTypes","PT","bool","node","func","themeType","isRequired","_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 onClick={(e) => e.stopPropagation()}\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\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,OAAO,EAAGC,CAAC,IAAKA,CAAC,CAACC,eAAe,CAAC,CAAE;IACpCC,IAAI,EAAC;EAAU,CAChB,CAAC;AAAA,CACC,CACN;;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAMC,cAAc,GAAG,IAAAC,oBAAM,EAC3BjB,QAAQ,EACR,UAAU,EACVD,cAAc,EACdD,YACF,CAAC;;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACAE,QAAQ,CAACkB,SAAS,GAAG;EACnBjB,OAAO,EAAEkB,kBAAE,CAACC,IAAI;EAChBlB,KAAK,EAAEiB,kBAAE,CAACE,IAAI;EACdlB,QAAQ,EAAEgB,kBAAE,CAACG,IAAI;EACjBlB,KAAK,EAAEY,cAAc,CAACO,SAAS,CAACC;AAClC,CAAC;AAAC,IAAAC,QAAA,GAAAC,OAAA,CAAAC,OAAA,GAEaX,cAAc","ignoreList":[]}
1
+ {"version":3,"file":"index.js","names":["_reactThemes","_interopRequireDefault","require","_jsxRuntime","defaultTheme","Checkbox","checked","label","onChange","theme","jsxs","className","container","children","undefined","jsx","checkbox","onClick","e","stopPropagation","type","_default","exports","default","themed"],"sources":["../../../../../src/shared/components/Checkbox/index.tsx"],"sourcesContent":["import themed, { type Theme } from '@dr.pogodin/react-themes';\n\nimport defaultTheme from './theme.scss';\n\ntype PropT = {\n checked?: boolean;\n label?: React.ReactNode;\n onChange?: React.ChangeEventHandler<HTMLInputElement>;\n theme: Theme<'checkbox' | 'container' | 'label'>;\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 onClick={(e) => e.stopPropagation()}\n type=\"checkbox\"\n />\n </div>\n);\n\nexport default themed(Checkbox, 'Checkbox', defaultTheme);\n"],"mappings":";;;;;;;AAAA,IAAAA,YAAA,GAAAC,sBAAA,CAAAC,OAAA;AAA8D,IAAAC,WAAA,GAAAD,OAAA;AAAA,MAAAE,YAAA;EAAA;EAAA;EAAA;EAAA;EAAA;EAAA;AAAA;AAW9D,MAAMC,QAAwC,GAAGA,CAAC;EAChDC,OAAO;EACPC,KAAK;EACLC,QAAQ;EACRC;AACF,CAAC,kBACC,IAAAN,WAAA,CAAAO,IAAA;EAAKC,SAAS,EAAEF,KAAK,CAACG,SAAU;EAAAC,QAAA,GAC5BN,KAAK,KAAKO,SAAS,GAAG,IAAI,gBAAG,IAAAX,WAAA,CAAAY,GAAA;IAAKJ,SAAS,EAAEF,KAAK,CAACF,KAAM;IAAAM,QAAA,EAAEN;EAAK,CAAM,CAAC,eACzE,IAAAJ,WAAA,CAAAY,GAAA;IACET,OAAO,EAAEA,OAAQ;IACjBK,SAAS,EAAEF,KAAK,CAACO,QAAS;IAC1BR,QAAQ,EAAEA,QAAS;IACnBS,OAAO,EAAGC,CAAC,IAAKA,CAAC,CAACC,eAAe,CAAC,CAAE;IACpCC,IAAI,EAAC;EAAU,CAChB,CAAC;AAAA,CACC,CACN;AAAC,IAAAC,QAAA,GAAAC,OAAA,CAAAC,OAAA,GAEa,IAAAC,oBAAM,EAACnB,QAAQ,EAAE,UAAU,EAAED,YAAY,CAAC","ignoreList":[]}
@@ -1,11 +1,9 @@
1
1
  "use strict";
2
2
 
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
3
  Object.defineProperty(exports, "__esModule", {
5
4
  value: true
6
5
  });
7
6
  exports.default = void 0;
8
- var _propTypes = _interopRequireDefault(require("prop-types"));
9
7
  require("react");
10
8
  require("react-router-dom");
11
9
  var _jsxRuntime = require("react/jsx-runtime");
@@ -105,18 +103,5 @@ const GenericLink = ({
105
103
  children: children
106
104
  });
107
105
  };
108
- GenericLink.propTypes = {
109
- children: _propTypes.default.node,
110
- className: _propTypes.default.string,
111
- disabled: _propTypes.default.bool,
112
- enforceA: _propTypes.default.bool,
113
- keepScrollPosition: _propTypes.default.bool,
114
- onClick: _propTypes.default.func,
115
- onMouseDown: _propTypes.default.func,
116
- openNewTab: _propTypes.default.bool,
117
- replace: _propTypes.default.bool,
118
- routerLinkType: _propTypes.default.elementType.isRequired,
119
- to: _propTypes.default.oneOfType([_propTypes.default.object, _propTypes.default.string])
120
- };
121
106
  var _default = exports.default = GenericLink;
122
107
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":["_propTypes","_interopRequireDefault","require","_jsxRuntime","GenericLink","children","className","disabled","enforceA","keepScrollPosition","onClick","onMouseDown","openNewTab","replace","routerLinkType","to","rest","match","jsx","href","e","preventDefault","rel","target","L","window","scroll","propTypes","PT","node","string","bool","func","elementType","isRequired","oneOfType","object","_default","exports","default"],"sources":["../../../../../src/shared/components/GenericLink/index.tsx"],"sourcesContent":["/* global window */\n\nimport PT from 'prop-types';\nimport { type ReactNode } from 'react';\n\nimport { type Link, type NavLink } from 'react-router-dom';\n\nimport './style.scss';\n\ntype ToT = Parameters<typeof Link>[0]['to'];\n\ninterface LinkI {}\n\nexport type PropsT = {\n children?: ReactNode;\n className?: string;\n disabled?: boolean;\n enforceA?: boolean;\n keepScrollPosition?: boolean;\n onClick?: React.MouseEventHandler<HTMLAnchorElement>;\n onMouseDown?: React.MouseEventHandler<HTMLAnchorElement>;\n openNewTab?: boolean;\n replace?: boolean;\n routerLinkType: LinkI;\n to?: ToT;\n};\n\n/**\n * The `<Link>` component, and almost identical `<NavLink>` component, are\n * auxiliary wrappers around\n * [React Router](https://github.com/ReactTraining/react-router)'s\n * `<Link>` and `<NavLink>` components; they help to handle external and\n * internal links in uniform manner.\n *\n * @param [props] Component properties.\n * @param [props.className] CSS classes to apply to the link.\n * @param [props.disabled] Disables the link.\n * @param [props.enforceA] `true` enforces rendering of the link as\n * a simple `<a>` element.\n * @param [props.keepScrollPosition] If `true`, and the link is\n * rendered as a React Router's component, it won't reset the viewport scrolling\n * position to the origin when clicked.\n * @param [props.onClick] Event handler to trigger upon click.\n * @param [props.onMouseDown] Event handler to trigger on MouseDown\n * event.\n * @param [props.openNewTab] If `true` the link opens in a new tab.\n * @param [props.replace] When `true`, the link will replace current\n * entry in the history stack instead of adding a new one.\n * @param [props.to] Link URL.\n * @param [props.activeClassName] **`<NavLink>`** only: CSS class(es)\n * to apply to rendered link when it is active.\n * @param [props.activeStyle] **`<NavLink>`** only: CSS styles\n * to apply to the rendered link when it is active.\n * @param [props.exact] **`<NavLink>`** only: if `true`, the active\n * class/style will only be applied if the location is matched exactly.\n * @param [props.isActive] **`<NavLink>`** only: Add extra\n * logic for determining whether the link is active. This should be used if you\n * want to do more than verify that the link’s pathname matches the current URL\n * pathname.\n * @param [props.location] **`<NavLink>`** only: `isActive` compares\n * current history location (usually the current browser URL). To compare to\n * a different location, a custom `location` can be passed.\n * @param [props.strict] **`<NavLink>`** only: . When `true`, trailing\n * slash on a location’s pathname will be taken into consideration when\n * determining if the location matches the current URL. See the `<Route strict>`\n * documentation for more information.\n */\nconst GenericLink: React.FunctionComponent<PropsT> = ({\n children,\n className,\n disabled,\n enforceA,\n keepScrollPosition,\n onClick,\n onMouseDown,\n openNewTab,\n replace,\n routerLinkType,\n to,\n ...rest\n}) => {\n /* Renders Link as <a> element if:\n * - It is opted explicitely by `enforceA` prop;\n * - It should be opened in a new tab;\n * - It is an absolte URL (starts with http:// or https://);\n * - It is anchor link (starts with #). */\n if (disabled || enforceA || openNewTab || (to as string)?.match(/^(#|(https?|mailto):)/)) {\n return (\n <a\n className={className}\n // TODO: This requires a fix: disabled is not really an attribute of <a>\n // tag, thus for disabled option we rather should render a plain text\n // styled as a link.\n // disabled={disabled}\n href={to as string}\n onClick={disabled ? (e) => e.preventDefault() : onClick}\n onMouseDown={disabled ? (e) => e.preventDefault() : onMouseDown}\n rel=\"noopener noreferrer\"\n styleName=\"link\"\n target={openNewTab ? '_blank' : ''}\n >\n {children}\n </a>\n );\n }\n\n const L = routerLinkType as typeof NavLink;\n\n return (\n <L\n className={className}\n // disabled\n onMouseDown={onMouseDown}\n replace={replace}\n to={to!}\n onClick={(e: React.MouseEvent<HTMLAnchorElement>) => {\n // Executes the user-provided event handler, if any.\n if (onClick) onClick(e);\n\n // By default, clicking the link scrolls the page to beginning.\n if (!keepScrollPosition) window.scroll(0, 0);\n }}\n {...rest} // eslint-disable-line react/jsx-props-no-spreading\n >\n {children}\n </L>\n );\n};\n\nGenericLink.propTypes = {\n children: PT.node,\n className: PT.string,\n disabled: PT.bool,\n enforceA: PT.bool,\n keepScrollPosition: PT.bool,\n onClick: PT.func,\n onMouseDown: PT.func,\n openNewTab: PT.bool,\n replace: PT.bool,\n routerLinkType: PT.elementType.isRequired,\n to: PT.oneOfType([PT.object, PT.string]),\n};\n\nexport default GenericLink;\n"],"mappings":";;;;;;;AAEA,IAAAA,UAAA,GAAAC,sBAAA,CAAAC,OAAA;AACAA,OAAA;AAEAA,OAAA;AAA2D,IAAAC,WAAA,GAAAD,OAAA;AAL3D;;AA2BA;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,MA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,SAAS,GAAG;EACtBtB,QAAQ,EAAEuB,kBAAE,CAACC,IAAI;EACjBvB,SAAS,EAAEsB,kBAAE,CAACE,MAAM;EACpBvB,QAAQ,EAAEqB,kBAAE,CAACG,IAAI;EACjBvB,QAAQ,EAAEoB,kBAAE,CAACG,IAAI;EACjBtB,kBAAkB,EAAEmB,kBAAE,CAACG,IAAI;EAC3BrB,OAAO,EAAEkB,kBAAE,CAACI,IAAI;EAChBrB,WAAW,EAAEiB,kBAAE,CAACI,IAAI;EACpBpB,UAAU,EAAEgB,kBAAE,CAACG,IAAI;EACnBlB,OAAO,EAAEe,kBAAE,CAACG,IAAI;EAChBjB,cAAc,EAAEc,kBAAE,CAACK,WAAW,CAACC,UAAU;EACzCnB,EAAE,EAAEa,kBAAE,CAACO,SAAS,CAAC,CAACP,kBAAE,CAACQ,MAAM,EAAER,kBAAE,CAACE,MAAM,CAAC;AACzC,CAAC;AAAC,IAAAO,QAAA,GAAAC,OAAA,CAAAC,OAAA,GAEanC,WAAW","ignoreList":[]}
1
+ {"version":3,"file":"index.js","names":["require","_jsxRuntime","GenericLink","children","className","disabled","enforceA","keepScrollPosition","onClick","onMouseDown","openNewTab","replace","routerLinkType","to","rest","match","jsx","href","e","preventDefault","rel","target","L","window","scroll","_default","exports","default"],"sources":["../../../../../src/shared/components/GenericLink/index.tsx"],"sourcesContent":["/* global window */\n\nimport { type ReactNode } from 'react';\n\nimport { type Link, type NavLink } from 'react-router-dom';\n\nimport './style.scss';\n\ntype ToT = Parameters<typeof Link>[0]['to'];\n\ninterface LinkI {}\n\nexport type PropsT = {\n children?: ReactNode;\n className?: string;\n disabled?: boolean;\n enforceA?: boolean;\n keepScrollPosition?: boolean;\n onClick?: React.MouseEventHandler<HTMLAnchorElement>;\n onMouseDown?: React.MouseEventHandler<HTMLAnchorElement>;\n openNewTab?: boolean;\n replace?: boolean;\n routerLinkType: LinkI;\n to?: ToT;\n};\n\n/**\n * The `<Link>` component, and almost identical `<NavLink>` component, are\n * auxiliary wrappers around\n * [React Router](https://github.com/ReactTraining/react-router)'s\n * `<Link>` and `<NavLink>` components; they help to handle external and\n * internal links in uniform manner.\n *\n * @param [props] Component properties.\n * @param [props.className] CSS classes to apply to the link.\n * @param [props.disabled] Disables the link.\n * @param [props.enforceA] `true` enforces rendering of the link as\n * a simple `<a>` element.\n * @param [props.keepScrollPosition] If `true`, and the link is\n * rendered as a React Router's component, it won't reset the viewport scrolling\n * position to the origin when clicked.\n * @param [props.onClick] Event handler to trigger upon click.\n * @param [props.onMouseDown] Event handler to trigger on MouseDown\n * event.\n * @param [props.openNewTab] If `true` the link opens in a new tab.\n * @param [props.replace] When `true`, the link will replace current\n * entry in the history stack instead of adding a new one.\n * @param [props.to] Link URL.\n * @param [props.activeClassName] **`<NavLink>`** only: CSS class(es)\n * to apply to rendered link when it is active.\n * @param [props.activeStyle] **`<NavLink>`** only: CSS styles\n * to apply to the rendered link when it is active.\n * @param [props.exact] **`<NavLink>`** only: if `true`, the active\n * class/style will only be applied if the location is matched exactly.\n * @param [props.isActive] **`<NavLink>`** only: Add extra\n * logic for determining whether the link is active. This should be used if you\n * want to do more than verify that the link’s pathname matches the current URL\n * pathname.\n * @param [props.location] **`<NavLink>`** only: `isActive` compares\n * current history location (usually the current browser URL). To compare to\n * a different location, a custom `location` can be passed.\n * @param [props.strict] **`<NavLink>`** only: . When `true`, trailing\n * slash on a location’s pathname will be taken into consideration when\n * determining if the location matches the current URL. See the `<Route strict>`\n * documentation for more information.\n */\nconst GenericLink: React.FunctionComponent<PropsT> = ({\n children,\n className,\n disabled,\n enforceA,\n keepScrollPosition,\n onClick,\n onMouseDown,\n openNewTab,\n replace,\n routerLinkType,\n to,\n ...rest\n}) => {\n /* Renders Link as <a> element if:\n * - It is opted explicitely by `enforceA` prop;\n * - It should be opened in a new tab;\n * - It is an absolte URL (starts with http:// or https://);\n * - It is anchor link (starts with #). */\n if (disabled || enforceA || openNewTab || (to as string)?.match(/^(#|(https?|mailto):)/)) {\n return (\n <a\n className={className}\n // TODO: This requires a fix: disabled is not really an attribute of <a>\n // tag, thus for disabled option we rather should render a plain text\n // styled as a link.\n // disabled={disabled}\n href={to as string}\n onClick={disabled ? (e) => e.preventDefault() : onClick}\n onMouseDown={disabled ? (e) => e.preventDefault() : onMouseDown}\n rel=\"noopener noreferrer\"\n styleName=\"link\"\n target={openNewTab ? '_blank' : ''}\n >\n {children}\n </a>\n );\n }\n\n const L = routerLinkType as typeof NavLink;\n\n return (\n <L\n className={className}\n // disabled\n onMouseDown={onMouseDown}\n replace={replace}\n to={to!}\n onClick={(e: React.MouseEvent<HTMLAnchorElement>) => {\n // Executes the user-provided event handler, if any.\n if (onClick) onClick(e);\n\n // By default, clicking the link scrolls the page to beginning.\n if (!keepScrollPosition) window.scroll(0, 0);\n }}\n {...rest} // eslint-disable-line react/jsx-props-no-spreading\n >\n {children}\n </L>\n );\n};\n\nexport default GenericLink;\n"],"mappings":";;;;;;AAEAA,OAAA;AAEAA,OAAA;AAA2D,IAAAC,WAAA,GAAAD,OAAA;AAJ3D;;AA0BA;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,MAAME,WAA4C,GAAGA,CAAC;EACpDC,QAAQ;EACRC,SAAS;EACTC,QAAQ;EACRC,QAAQ;EACRC,kBAAkB;EAClBC,OAAO;EACPC,WAAW;EACXC,UAAU;EACVC,OAAO;EACPC,cAAc;EACdC,EAAE;EACF,GAAGC;AACL,CAAC,KAAK;EACJ;AACF;AACA;AACA;AACA;EACE,IAAIT,QAAQ,IAAIC,QAAQ,IAAII,UAAU,IAAKG,EAAE,EAAaE,KAAK,CAAC,uBAAuB,CAAC,EAAE;IACxF,oBACE,IAAAd,WAAA,CAAAe,GAAA;MACEZ,SAAS,GAAEA,SAAS,GAATA,SAAS;MACpB;MACA;MACA;MACA;MAAA;MACAa,IAAI,EAAEJ,EAAa;MACnBL,OAAO,EAAEH,QAAQ,GAAIa,CAAC,IAAKA,CAAC,CAACC,cAAc,CAAC,CAAC,GAAGX,OAAQ;MACxDC,WAAW,EAAEJ,QAAQ,GAAIa,CAAC,IAAKA,CAAC,CAACC,cAAc,CAAC,CAAC,GAAGV,WAAY;MAChEW,GAAG,EAAC,qBAAqB;MAEzBC,MAAM,EAAEX,UAAU,GAAG,QAAQ,GAAG,EAAG;MAAAP,QAAA,EAElCA;IAAQ,CACR,CAAC;EAER;EAEA,MAAMmB,CAAC,GAAGV,cAAgC;EAE1C,oBACE,IAAAX,WAAA,CAAAe,GAAA,EAACM,CAAC;IACAlB,SAAS,EAAEA;IACX;IAAA;IACAK,WAAW,EAAEA,WAAY;IACzBE,OAAO,EAAEA,OAAQ;IACjBE,EAAE,EAAEA,EAAI;IACRL,OAAO,EAAGU,CAAsC,IAAK;MACnD;MACA,IAAIV,OAAO,EAAEA,OAAO,CAACU,CAAC,CAAC;;MAEvB;MACA,IAAI,CAACX,kBAAkB,EAAEgB,MAAM,CAACC,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC;IAC9C,CAAE;IAAA,GACEV,IAAI;IAAAX,QAAA,EAEPA;EAAQ,CACR,CAAC;AAER,CAAC;AAAC,IAAAsB,QAAA,GAAAC,OAAA,CAAAC,OAAA,GAEazB,WAAW","ignoreList":[]}
@@ -5,7 +5,6 @@ Object.defineProperty(exports, "__esModule", {
5
5
  value: true
6
6
  });
7
7
  exports.default = void 0;
8
- var _propTypes = _interopRequireDefault(require("prop-types"));
9
8
  var _react = require("react");
10
9
  var _reactThemes = _interopRequireDefault(require("@dr.pogodin/react-themes"));
11
10
  var _jsxRuntime = require("react/jsx-runtime");
@@ -17,7 +16,6 @@ const defaultTheme = {
17
16
  "input": "-dr-pogodin-react-utils___src-shared-components-Input-theme___input___M07d4s",
18
17
  "label": "-dr-pogodin-react-utils___src-shared-components-Input-theme___label___gfbdq-"
19
18
  };
20
- const validThemeKeys = ['container', 'input', 'label'];
21
19
  /**
22
20
  * Themeable input field, based on the standard HTML `<input>` element.
23
21
  * @param [props]
@@ -42,10 +40,5 @@ const Input = /*#__PURE__*/(0, _react.forwardRef)(({
42
40
  ...rest
43
41
  })]
44
42
  }));
45
- const ThemedInput = (0, _reactThemes.default)(Input, 'Input', validThemeKeys, defaultTheme);
46
- Input.propTypes = {
47
- label: _propTypes.default.node,
48
- theme: ThemedInput.themeType.isRequired
49
- };
50
- var _default = exports.default = ThemedInput;
43
+ var _default = exports.default = (0, _reactThemes.default)(Input, 'Input', defaultTheme);
51
44
  //# sourceMappingURL=index.js.map
@@ -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","node","themeType","isRequired","_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\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;AAAC,IAAAC,QAAA,GAAAC,OAAA,CAAAC,OAAA,GAEaT,WAAW","ignoreList":[]}
1
+ {"version":3,"file":"index.js","names":["_react","require","_reactThemes","_interopRequireDefault","_jsxRuntime","defaultTheme","Input","forwardRef","label","theme","rest","ref","jsxs","className","container","children","undefined","jsx","input","_default","exports","default","themed"],"sources":["../../../../../src/shared/components/Input/index.tsx"],"sourcesContent":["import { forwardRef } from 'react';\n\nimport themed, { type Theme } from '@dr.pogodin/react-themes';\n\nimport defaultTheme from './theme.scss';\n\ntype ThemeKeyT =\n | 'container'\n | 'input'\n | 'label';\n\ntype PropsT = React.InputHTMLAttributes<HTMLInputElement> & {\n label?: React.ReactNode;\n theme: Theme<ThemeKeyT>;\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\nexport default themed(Input, 'Input', defaultTheme);\n"],"mappings":";;;;;;;AAAA,IAAAA,MAAA,GAAAC,OAAA;AAEA,IAAAC,YAAA,GAAAC,sBAAA,CAAAF,OAAA;AAA8D,IAAAG,WAAA,GAAAH,OAAA;AAAA,MAAAI,YAAA;EAAA;EAAA;EAAA;EAAA;EAAA;EAAA;AAAA;AAc9D;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,IAAAP,WAAA,CAAAQ,IAAA;EAAMC,SAAS,EAAEJ,KAAK,CAACK,SAAU;EAAAC,QAAA,GAC7BP,KAAK,KAAKQ,SAAS,GAAG,IAAI,gBAAG,IAAAZ,WAAA,CAAAa,GAAA;IAAKJ,SAAS,EAAEJ,KAAK,CAACD,KAAM;IAAAO,QAAA,EAAEP;EAAK,CAAM,CAAC,eACzE,IAAAJ,WAAA,CAAAa,GAAA;IACEJ,SAAS,EAAEJ,KAAK,CAACS,KAAM;IACvBP,GAAG,EAAEA,GAAI;IAAA,GACLD;EAAI,CACT,CAAC;AAAA,CACE,CACP,CAAC;AAAC,IAAAS,QAAA,GAAAC,OAAA,CAAAC,OAAA,GAEY,IAAAC,oBAAM,EAAChB,KAAK,EAAE,OAAO,EAAED,YAAY,CAAC","ignoreList":[]}
@@ -1,11 +1,9 @@
1
1
  "use strict";
2
2
 
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
3
  Object.defineProperty(exports, "__esModule", {
5
4
  value: true
6
5
  });
7
6
  exports.default = void 0;
8
- var _propTypes = _interopRequireDefault(require("prop-types"));
9
7
  var _react = require("react");
10
8
  var _reactHelmet = require("react-helmet");
11
9
  var _jsxRuntime = require("react/jsx-runtime");
@@ -136,15 +134,5 @@ const MetaTags = ({
136
134
  });
137
135
  };
138
136
  MetaTags.Context = Context;
139
- MetaTags.propTypes = {
140
- children: _propTypes.default.node,
141
- description: _propTypes.default.string.isRequired,
142
- image: _propTypes.default.string,
143
- siteName: _propTypes.default.string,
144
- socialDescription: _propTypes.default.string,
145
- socialTitle: _propTypes.default.string,
146
- title: _propTypes.default.string.isRequired,
147
- url: _propTypes.default.string
148
- };
149
137
  var _default = exports.default = MetaTags;
150
138
  //# sourceMappingURL=MetaTags.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"MetaTags.js","names":["_propTypes","_interopRequireDefault","require","_react","_reactHelmet","_jsxRuntime","Context","createContext","description","title","MetaTags","children","image","siteName","socialDescription","socialTitle","url","socTitle","socDesc","context","useMemo","jsxs","Fragment","Helmet","jsx","name","content","Provider","value","propTypes","PT","node","string","isRequired","_default","exports","default"],"sources":["../../../../src/shared/components/MetaTags.tsx"],"sourcesContent":["import PT from 'prop-types';\nimport { type ReactNode, createContext, useMemo } from 'react';\nimport { Helmet } from 'react-helmet';\n\ntype PropsT = {\n children?: ReactNode;\n description: string;\n image?: string;\n siteName?: string;\n socialDescription?: string;\n socialTitle?: string;\n title: string;\n url?: string;\n};\n\nconst Context = createContext<PropsT>({\n description: '',\n title: '',\n});\n\n/**\n * The `<MetaTags>` component is an auxiliary wrapper around `react-helmet`,\n * which helps to inject meta tags (page title, a brief content description,\n * and social media thumbnails) into generated pages.\n *\n * When `<MetaTags>` are nested within the app's component tree, meta tags\n * content injected by components encountered down the tree overrides tags\n * injected by previously encountered `<MetaTags>` components.\n *\n * **Children:** `<MetaTags>` children, if any, are rendered at the component's\n * location. The context passes down all meta tag properties of parent\n * `<MetaTag>` instances. These properties can fetched within children\n * hierarchy in the following way, thus facilitating tags modification by\n * children:\n * ```jsx\n * import { useContext } from 'react';\n * import { MetaTags } from '@dr.pogodin/react-utils';\n * export default function SampleComponent() {\n * const { title, description, ...rest } = useContext(MetaTags.Context);\n * // Do something with these props here, e.g. prefix the page title with\n * // the component name:\n * return (\n * <MetaTags title={`Sample component - ${title}`} />\n * );\n * }\n * ```\n * @param [props]\n * @param [props.description] Page description to use in\n * the `description` meta tag, and as a default description of Open Graph Tags.\n * @param [props.image] The absolute URL of thumbnail image to use\n * in Open Graph Tags (`twitter:image`, and `og:image`). By default these tags\n * are not injected.\n *\n * **BEWARE:** It must be a complete, absolute URL, including the correct\n * website domain and HTTP schema.\n *\n * @param [props.siteName]: The site name to use in `twitter:site`,\n * and `og:sitename` tags. By default these tags are not injected.\n *\n * @param [props.socialDescription] The site description to use in\n * `twitter:description` and `og:description` meta tags. By default the value of\n * `description` prop is used.\n * @param [props.socialTitle] The page title to use in\n * `twitter:title`, `og:title`, and `og:image:alt` tags. By default the value of\n * `title` prop is used. Also the `og:image:alt` tag is only injected if `image`\n * prop is present.\n *\n * @param props.title: The page name to use in the `<title>` tag.\n * It is also used as the default value of `socialTitle` prop.\n *\n * @param [props.url] The page URL to use in `og:url` tag.\n * By default the tag is not injected.\n */\nconst MetaTags: React.FunctionComponent<PropsT> & {\n Context: React.Context<PropsT>;\n} = ({\n children,\n description,\n image,\n siteName,\n socialDescription,\n socialTitle,\n title,\n url,\n}) => {\n const socTitle = socialTitle || title;\n const socDesc = socialDescription || description;\n\n const context = useMemo(() => ({\n description,\n image,\n siteName,\n socialDescription,\n socialTitle,\n title,\n url,\n }), [\n description,\n image,\n siteName,\n socialDescription,\n socialTitle,\n title,\n url,\n ]);\n\n return (\n <>\n <Helmet>\n {/* General tags. */}\n <title>\n {title}\n </title>\n <meta name=\"description\" content={description} />\n\n {/* Twitter cards. */}\n <meta name=\"twitter:card\" content=\"summary_large_image\" />\n <meta name=\"twitter:title\" content={socTitle} />\n <meta name=\"twitter:description\" content={socDesc} />\n { image ? <meta name=\"twitter:image\" content={image} /> : null }\n {\n siteName ? (\n <meta name=\"twitter:site\" content={`@${siteName}`} />\n ) : null\n }\n\n {/* Open Graph data. */}\n <meta name=\"og:title\" content={socTitle} />\n { image ? <meta name=\"og:image\" content={image} /> : null }\n { image ? <meta name=\"og:image:alt\" content={socTitle} /> : null }\n <meta name=\"og:description\" content={socDesc} />\n {\n siteName ? (<meta name=\"og:sitename\" content={siteName} />) : null\n }\n { url ? (<meta name=\"og:url\" content={url} />) : null }\n </Helmet>\n {\n children ? (\n <Context.Provider value={context}>\n {children}\n </Context.Provider>\n ) : null\n }\n </>\n );\n};\n\nMetaTags.Context = Context;\n\nMetaTags.propTypes = {\n children: PT.node,\n description: PT.string.isRequired,\n image: PT.string,\n siteName: PT.string,\n socialDescription: PT.string,\n socialTitle: PT.string,\n title: PT.string.isRequired,\n url: PT.string,\n};\n\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E,CAAC,GAAI,IAAI,EAElEG,GAAG,gBAAI,IAAAX,WAAA,CAAAmB,GAAA;QAAMC,IAAI,EAAC,QAAQ;QAACC,OAAO,EAAEV;MAAI,CAAE,CAAC,GAAI,IAAI;IAAA,CAC/C,CAAC,EAEPL,QAAQ,gBACN,IAAAN,WAAA,CAAAmB,GAAA,EAAClB,OAAO,CAACqB,QAAQ;MAACC,KAAK,EAAET,OAAQ;MAAAR,QAAA,EAC9BA;IAAQ,CACO,CAAC,GACjB,IAAI;EAAA,CAEV,CAAC;AAEP,CAAC;AAEDD,QAAQ,CAACJ,OAAO,GAAGA,OAAO;AAE1BI,QAAQ,CAACmB,SAAS,GAAG;EACnBlB,QAAQ,EAAEmB,kBAAE,CAACC,IAAI;EACjBvB,WAAW,EAAEsB,kBAAE,CAACE,MAAM,CAACC,UAAU;EACjCrB,KAAK,EAAEkB,kBAAE,CAACE,MAAM;EAChBnB,QAAQ,EAAEiB,kBAAE,CAACE,MAAM;EACnBlB,iBAAiB,EAAEgB,kBAAE,CAACE,MAAM;EAC5BjB,WAAW,EAAEe,kBAAE,CAACE,MAAM;EACtBvB,KAAK,EAAEqB,kBAAE,CAACE,MAAM,CAACC,UAAU;EAC3BjB,GAAG,EAAEc,kBAAE,CAACE;AACV,CAAC;AAAC,IAAAE,QAAA,GAAAC,OAAA,CAAAC,OAAA,GAEa1B,QAAQ","ignoreList":[]}
1
+ {"version":3,"file":"MetaTags.js","names":["_react","require","_reactHelmet","_jsxRuntime","Context","createContext","description","title","MetaTags","children","image","siteName","socialDescription","socialTitle","url","socTitle","socDesc","context","useMemo","jsxs","Fragment","Helmet","jsx","name","content","Provider","value","_default","exports","default"],"sources":["../../../../src/shared/components/MetaTags.tsx"],"sourcesContent":["import { type ReactNode, createContext, useMemo } from 'react';\nimport { Helmet } from 'react-helmet';\n\ntype PropsT = {\n children?: ReactNode;\n description: string;\n image?: string;\n siteName?: string;\n socialDescription?: string;\n socialTitle?: string;\n title: string;\n url?: string;\n};\n\nconst Context = createContext<PropsT>({\n description: '',\n title: '',\n});\n\n/**\n * The `<MetaTags>` component is an auxiliary wrapper around `react-helmet`,\n * which helps to inject meta tags (page title, a brief content description,\n * and social media thumbnails) into generated pages.\n *\n * When `<MetaTags>` are nested within the app's component tree, meta tags\n * content injected by components encountered down the tree overrides tags\n * injected by previously encountered `<MetaTags>` components.\n *\n * **Children:** `<MetaTags>` children, if any, are rendered at the component's\n * location. The context passes down all meta tag properties of parent\n * `<MetaTag>` instances. These properties can fetched within children\n * hierarchy in the following way, thus facilitating tags modification by\n * children:\n * ```jsx\n * import { useContext } from 'react';\n * import { MetaTags } from '@dr.pogodin/react-utils';\n * export default function SampleComponent() {\n * const { title, description, ...rest } = useContext(MetaTags.Context);\n * // Do something with these props here, e.g. prefix the page title with\n * // the component name:\n * return (\n * <MetaTags title={`Sample component - ${title}`} />\n * );\n * }\n * ```\n * @param [props]\n * @param [props.description] Page description to use in\n * the `description` meta tag, and as a default description of Open Graph Tags.\n * @param [props.image] The absolute URL of thumbnail image to use\n * in Open Graph Tags (`twitter:image`, and `og:image`). By default these tags\n * are not injected.\n *\n * **BEWARE:** It must be a complete, absolute URL, including the correct\n * website domain and HTTP schema.\n *\n * @param [props.siteName]: The site name to use in `twitter:site`,\n * and `og:sitename` tags. By default these tags are not injected.\n *\n * @param [props.socialDescription] The site description to use in\n * `twitter:description` and `og:description` meta tags. By default the value of\n * `description` prop is used.\n * @param [props.socialTitle] The page title to use in\n * `twitter:title`, `og:title`, and `og:image:alt` tags. By default the value of\n * `title` prop is used. Also the `og:image:alt` tag is only injected if `image`\n * prop is present.\n *\n * @param props.title: The page name to use in the `<title>` tag.\n * It is also used as the default value of `socialTitle` prop.\n *\n * @param [props.url] The page URL to use in `og:url` tag.\n * By default the tag is not injected.\n */\nconst MetaTags: React.FunctionComponent<PropsT> & {\n Context: React.Context<PropsT>;\n} = ({\n children,\n description,\n image,\n siteName,\n socialDescription,\n socialTitle,\n title,\n url,\n}) => {\n const socTitle = socialTitle || title;\n const socDesc = socialDescription || description;\n\n const context = useMemo(() => ({\n description,\n image,\n siteName,\n socialDescription,\n socialTitle,\n title,\n url,\n }), [\n description,\n image,\n siteName,\n socialDescription,\n socialTitle,\n title,\n url,\n ]);\n\n return (\n <>\n <Helmet>\n {/* General tags. */}\n <title>\n {title}\n </title>\n <meta name=\"description\" content={description} />\n\n {/* Twitter cards. */}\n <meta name=\"twitter:card\" content=\"summary_large_image\" />\n <meta name=\"twitter:title\" content={socTitle} />\n <meta name=\"twitter:description\" content={socDesc} />\n { image ? <meta name=\"twitter:image\" content={image} /> : null }\n {\n siteName ? (\n <meta name=\"twitter:site\" content={`@${siteName}`} />\n ) : null\n }\n\n {/* Open Graph data. */}\n <meta name=\"og:title\" content={socTitle} />\n { image ? <meta name=\"og:image\" content={image} /> : null }\n { image ? <meta name=\"og:image:alt\" content={socTitle} /> : null }\n <meta name=\"og:description\" content={socDesc} />\n {\n siteName ? (<meta name=\"og:sitename\" content={siteName} />) : null\n }\n { url ? (<meta name=\"og:url\" content={url} />) : null }\n </Helmet>\n {\n children ? (\n <Context.Provider value={context}>\n {children}\n </Context.Provider>\n ) : null\n }\n </>\n );\n};\n\nMetaTags.Context = Context;\n\nexport default MetaTags;\n"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,OAAA;AACA,IAAAC,YAAA,GAAAD,OAAA;AAAsC,IAAAE,WAAA,GAAAF,OAAA;AAatC,MAAMG,OAAO,gBAAG,IAAAC,oBAAa,EAAS;EACpCC,WAAW,EAAE,EAAE;EACfC,KAAK,EAAE;AACT,CAAC,CAAC;;AAEF;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;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Modal = void 0;
8
8
  var _react = require("react");
9
9
  var _reactDom = _interopRequireDefault(require("react-dom"));
10
- var _propTypes = _interopRequireDefault(require("prop-types"));
11
10
  var _reactThemes = _interopRequireDefault(require("@dr.pogodin/react-themes"));
12
11
  var _jsxRuntime = require("react/jsx-runtime");
13
12
  /* global document */
@@ -21,7 +20,6 @@ const baseTheme = {
21
20
  const S = {
22
21
  "scrollingDisabledByModal": "-dr-pogodin-react-utils___src-shared-components-Modal-styles___scrollingDisabledByModal___5fRFtF"
23
22
  };
24
- const validThemeKeys = ['container', 'overlay'];
25
23
  /**
26
24
  * The `<Modal>` component implements a simple themeable modal window, wrapped
27
25
  * into the default theme. `<BaseModal>` exposes the base non-themed component.
@@ -82,7 +80,7 @@ const BaseModal = ({
82
80
  onFocus: () => {
83
81
  const elems = containerRef.current?.querySelectorAll('*');
84
82
  for (let i = elems.length - 1; i >= 0; --i) {
85
- elems[i].focus();
83
+ elems[i]?.focus();
86
84
  if (document.activeElement === elems[i]) return;
87
85
  }
88
86
  overlayRef.current?.focus();
@@ -135,15 +133,6 @@ const BaseModal = ({
135
133
  }), portal) : null;
136
134
  };
137
135
  exports.BaseModal = BaseModal;
138
- const ThemedModal = (0, _reactThemes.default)(BaseModal, 'Modal', validThemeKeys, baseTheme);
139
- BaseModal.propTypes = {
140
- cancelOnScrolling: _propTypes.default.bool,
141
- children: _propTypes.default.node,
142
- containerStyle: _propTypes.default.shape({}),
143
- dontDisableScrolling: _propTypes.default.bool,
144
- onCancel: _propTypes.default.func,
145
- theme: ThemedModal.themeType.isRequired
146
- };
147
- var _default = exports.default = ThemedModal;
136
+ var _default = exports.default = (0, _reactThemes.default)(BaseModal, 'Modal', baseTheme);
148
137
  /* Non-themed version of the Modal. */
149
138
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":["_react","require","_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","e","stopPropagation","onKeyDown","key","ref","node","role","container","onWheel","event","style","exports","ThemedModal","themed","propTypes","PT","bool","shape","func","themeType","isRequired","_default","default"],"sources":["../../../../../src/shared/components/Modal/index.tsx"],"sourcesContent":["/* global document */\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 window.addEventListener('wheel', onCancel);\n }\n return () => {\n if (cancelOnScrolling && onCancel) {\n window.removeEventListener('scroll', onCancel);\n window.removeEventListener('wheel', onCancel);\n }\n };\n }, [cancelOnScrolling, onCancel]);\n\n // Disables window scrolling, if it is not opted-out.\n useEffect(() => {\n if (!dontDisableScrolling) {\n document.body.classList.add(S.scrollingDisabledByModal);\n }\n return () => {\n if (!dontDisableScrolling) {\n document.body.classList.remove(S.scrollingDisabledByModal);\n }\n };\n }, [dontDisableScrolling]);\n\n const focusLast = useMemo(() => (\n <div\n onFocus={() => {\n const elems = containerRef.current?.querySelectorAll('*') 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={(e) => {\n if (onCancel) {\n onCancel();\n e.stopPropagation();\n }\n }}\n onKeyDown={(e) => {\n if (e.key === 'Escape' && onCancel) {\n onCancel();\n e.stopPropagation();\n }\n }}\n ref={(node) => {\n if (node && node !== overlayRef.current) {\n overlayRef.current = node;\n node.focus();\n }\n }}\n role=\"button\"\n tabIndex={0}\n />\n {\n // NOTE: These rules are disabled because our intention is to keep\n // the element non-interactive (thus not on the keyboard focus chain),\n // and it has `onClick` handler merely to stop propagation of click\n // events to its parent container. This is needed because, for example\n // when the modal is wrapped into an interactive element we don't want\n // any clicks inside the modal to bubble-up to that parent element\n // (because visually and logically the modal dialog does not belong\n // to its parent container, where it technically belongs from\n // the HTML mark-up perpective).\n /* eslint-disable jsx-a11y/click-events-have-key-events,\n jsx-a11y/no-noninteractive-element-interactions */\n }\n <div\n aria-modal=\"true\"\n className={theme.container}\n onClick={(e) => e.stopPropagation()}\n onWheel={(event) => event.stopPropagation()}\n ref={containerRef}\n role=\"dialog\"\n style={containerStyle}\n >\n {children}\n </div>\n {/* eslint-enable jsx-a11y/click-events-have-key-events,\n jsx-a11y/no-noninteractive-element-interactions */}\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\nexport default ThemedModal;\n\n/* Non-themed version of the Modal. */\nexport { BaseModal };\n"],"mappings":";;;;;;;AAEA,IAAAA,MAAA,GAAAC,OAAA;AAQA,IAAAC,SAAA,GAAAC,sBAAA,CAAAF,OAAA;AACA,IAAAG,UAAA,GAAAD,sBAAA,CAAAF,OAAA;AACA,IAAAI,YAAA,GAAAF,sBAAA,CAAAF,OAAA;AAA8D,IAAAK,WAAA,GAAAL,OAAA;AAZ9D;AAAA,MAAAM,SAAA;EAAA;EAAA;EAAA;EAAA;EAAA;AAAA;AAAA,MAAAC,CAAA;EAAA;AAAA;AAiBA,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,c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BAAE,CAACC,IAAI;EAC7BzD,QAAQ,EAAEwD,kBAAE,CAACG,IAAI;EACjB1D,KAAK,EAAEoD,WAAW,CAACO,SAAS,CAACC;AAC/B,CAAC;AAAC,IAAAC,QAAA,GAAAV,OAAA,CAAAW,OAAA,GAEaV,WAAW;AAE1B","ignoreList":[]}
1
+ {"version":3,"file":"index.js","names":["_react","require","_reactDom","_interopRequireDefault","_reactThemes","_jsxRuntime","baseTheme","S","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","e","stopPropagation","onKeyDown","key","ref","node","role","container","onWheel","event","style","exports","_default","default","themed"],"sources":["../../../../../src/shared/components/Modal/index.tsx"],"sourcesContent":["/* global document */\n\nimport {\n type ReactNode,\n useEffect,\n useMemo,\n useRef,\n useState,\n} from 'react';\n\nimport ReactDom from 'react-dom';\nimport themed, { type Theme } from '@dr.pogodin/react-themes';\n\nimport baseTheme from './base-theme.scss';\nimport S from './styles.scss';\n\ntype PropsT = {\n cancelOnScrolling?: boolean;\n children?: ReactNode;\n containerStyle?: React.CSSProperties;\n dontDisableScrolling?: boolean;\n onCancel?: () => void;\n theme: Theme<'container' | 'overlay'>;\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 window.addEventListener('wheel', onCancel);\n }\n return () => {\n if (cancelOnScrolling && onCancel) {\n window.removeEventListener('scroll', onCancel);\n window.removeEventListener('wheel', onCancel);\n }\n };\n }, [cancelOnScrolling, onCancel]);\n\n // Disables window scrolling, if it is not opted-out.\n useEffect(() => {\n if (!dontDisableScrolling) {\n document.body.classList.add(S.scrollingDisabledByModal);\n }\n return () => {\n if (!dontDisableScrolling) {\n document.body.classList.remove(S.scrollingDisabledByModal);\n }\n };\n }, [dontDisableScrolling]);\n\n const focusLast = useMemo(() => (\n <div\n onFocus={() => {\n const elems = containerRef.current?.querySelectorAll('*') 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={(e) => {\n if (onCancel) {\n onCancel();\n e.stopPropagation();\n }\n }}\n onKeyDown={(e) => {\n if (e.key === 'Escape' && onCancel) {\n onCancel();\n e.stopPropagation();\n }\n }}\n ref={(node) => {\n if (node && node !== overlayRef.current) {\n overlayRef.current = node;\n node.focus();\n }\n }}\n role=\"button\"\n tabIndex={0}\n />\n {\n // NOTE: These rules are disabled because our intention is to keep\n // the element non-interactive (thus not on the keyboard focus chain),\n // and it has `onClick` handler merely to stop propagation of click\n // events to its parent container. This is needed because, for example\n // when the modal is wrapped into an interactive element we don't want\n // any clicks inside the modal to bubble-up to that parent element\n // (because visually and logically the modal dialog does not belong\n // to its parent container, where it technically belongs from\n // the HTML mark-up perpective).\n /* eslint-disable jsx-a11y/click-events-have-key-events,\n jsx-a11y/no-noninteractive-element-interactions */\n }\n <div\n aria-modal=\"true\"\n className={theme.container}\n onClick={(e) => e.stopPropagation()}\n onWheel={(event) => event.stopPropagation()}\n ref={containerRef}\n role=\"dialog\"\n style={containerStyle}\n >\n {children}\n </div>\n {/* eslint-enable jsx-a11y/click-events-have-key-events,\n jsx-a11y/no-noninteractive-element-interactions */}\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\nexport default themed(BaseModal, 'Modal', baseTheme);\n\n/* Non-themed version of the Modal. */\nexport { BaseModal };\n"],"mappings":";;;;;;;AAEA,IAAAA,MAAA,GAAAC,OAAA;AAQA,IAAAC,SAAA,GAAAC,sBAAA,CAAAF,OAAA;AACA,IAAAG,YAAA,GAAAD,sBAAA,CAAAF,OAAA;AAA8D,IAAAI,WAAA,GAAAJ,OAAA;AAX9D;AAAA,MAAAK,SAAA;EAAA;EAAA;EAAA;EAAA;EAAA;AAAA;AAAA,MAAAC,CAAA;EAAA;AAAA;AAyBA;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,YAA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;QACb,IAAIA,IAAI,IAAIA,IAAI,KAAK1C,UAAU,CAACuB,OAAO,EAAE;UACvCvB,UAAU,CAACuB,OAAO,GAAGmB,IAAI;UACzBA,IAAI,CAACf,KAAK,CAAC,CAAC;QACd;MACF,CAAE;MACFgB,IAAI,EAAC,QAAQ;MACbd,QAAQ,EAAE;IAAE,CACb,CAAC,eAcF,IAAAzC,WAAA,CAAAgC,GAAA;MACE,cAAW,MAAM;MACjBc,SAAS,EAAErC,KAAK,CAAC+C,SAAU;MAC3BR,OAAO,EAAGC,CAAC,IAAKA,CAAC,CAACC,eAAe,CAAC,CAAE;MACpCO,OAAO,EAAGC,KAAK,IAAKA,KAAK,CAACR,eAAe,CAAC,CAAE;MAC5CG,GAAG,EAAE3C,YAAa;MAClB6C,IAAI,EAAC,QAAQ;MACbI,KAAK,EAAErD,cAAe;MAAAD,QAAA,EAErBA;IAAQ,CACN,CAAC,eAGN,IAAAL,WAAA,CAAAgC,GAAA;MACEC,OAAO,EAAEA,CAAA,KAAM;QACbrB,UAAU,CAACuB,OAAO,EAAEI,KAAK,CAAC,CAAC;MAC7B;MACA;MACAE,QAAQ,EAAE;MACV;IAAA,CACD,CAAC,EACDX,SAAS;EAAA,CACV,CAAC,EAELjB,MACF,CAAC,GAAG,IAAI;AACV,CAAC;AAAC+C,OAAA,CAAAzD,SAAA,GAAAA,SAAA;AAAA,IAAA0D,QAAA,GAAAD,OAAA,CAAAE,OAAA,GAEa,IAAAC,oBAAM,EAAC5D,SAAS,EAAE,OAAO,EAAEF,SAAS,CAAC;AAEpD","ignoreList":[]}
@@ -5,7 +5,6 @@ Object.defineProperty(exports, "__esModule", {
5
5
  value: true
6
6
  });
7
7
  exports.default = void 0;
8
- var _propTypes = _interopRequireDefault(require("prop-types"));
9
8
  var _reactThemes = _interopRequireDefault(require("@dr.pogodin/react-themes"));
10
9
  var _jsxRuntime = require("react/jsx-runtime");
11
10
  const baseTheme = {
@@ -16,7 +15,6 @@ const baseTheme = {
16
15
  "mainPanel": "-dr-pogodin-react-utils___src-shared-components-PageLayout-base-theme___mainPanel___pPlQO2",
17
16
  "sidePanel": "-dr-pogodin-react-utils___src-shared-components-PageLayout-base-theme___sidePanel___lqNh4h"
18
17
  };
19
- const validThemeKeys = ['container', 'leftSidePanel', 'mainPanel', 'rightSidePanel', 'sidePanel'];
20
18
  /**
21
19
  * Simple and themeable page layout. It keeps the main content centered in
22
20
  * a column of limited width, which fills entire viewport on small screens
@@ -50,12 +48,5 @@ const PageLayout = ({
50
48
  children: rightSidePanelContent
51
49
  })]
52
50
  });
53
- const ThemedPageLayout = (0, _reactThemes.default)(PageLayout, 'PageLayout', validThemeKeys, baseTheme);
54
- PageLayout.propTypes = {
55
- children: _propTypes.default.node,
56
- leftSidePanelContent: _propTypes.default.node,
57
- rightSidePanelContent: _propTypes.default.node,
58
- theme: ThemedPageLayout.themeType.isRequired
59
- };
60
- var _default = exports.default = ThemedPageLayout;
51
+ var _default = exports.default = (0, _reactThemes.default)(PageLayout, 'PageLayout', baseTheme);
61
52
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":["_propTypes","_interopRequireDefault","require","_reactThemes","_jsxRuntime","baseTheme","validThemeKeys","PageLayout","children","leftSidePanelContent","rightSidePanelContent","theme","jsxs","className","container","jsx","sidePanel","leftSidePanel","join","mainPanel","rightSidePanel","ThemedPageLayout","themed","propTypes","PT","node","themeType","isRequired","_default","exports","default"],"sources":["../../../../../src/shared/components/PageLayout/index.tsx"],"sourcesContent":["import PT from 'prop-types';\nimport type { ReactNode } from 'react';\n\nimport themed, { type Theme } from '@dr.pogodin/react-themes';\n\nimport baseTheme from './base-theme.scss';\n\nconst validThemeKeys = [\n 'container',\n 'leftSidePanel',\n 'mainPanel',\n 'rightSidePanel',\n 'sidePanel',\n] as const;\n\ntype PropsT = {\n children?: ReactNode;\n leftSidePanelContent?: ReactNode;\n rightSidePanelContent?: ReactNode;\n theme: Theme<typeof validThemeKeys>;\n};\n\n/**\n * Simple and themeable page layout. It keeps the main content centered in\n * a column of limited width, which fills entire viewport on small screens\n * (under `$screen-md = 1024px` size). At larger screens the column keeps\n * `$screen-md` size, and it is centered at the page, surrounded by side\n * panels, where additional content can be displayed.\n *\n * **Children:** Component children are rendered as the content of main panel.\n * @param {object} [props] Component properties.\n * @param {Node} [props.leftSidePanelContent] The content for left side panel.\n * @param {Node} [props.rightSidePanelContent] The content for right side panel.\n * @param {PageLayoutTheme} [props.theme] _Ad hoc_ theme.\n * @param {...any} [props....]\n * [Other theming properties](https://www.npmjs.com/package/@dr.pogodin/react-themes#themed-component-properties)\n */\nconst PageLayout: React.FunctionComponent<PropsT> = ({\n children,\n leftSidePanelContent,\n rightSidePanelContent,\n theme,\n}) => (\n <div className={theme.container}>\n <div className={[theme.sidePanel, theme.leftSidePanel].join(' ')}>\n {leftSidePanelContent}\n </div>\n <div className={theme.mainPanel}>\n {children}\n </div>\n <div className={[theme.sidePanel, theme.rightSidePanel].join(' ')}>\n {rightSidePanelContent}\n </div>\n </div>\n);\n\nconst ThemedPageLayout = themed(\n PageLayout,\n 'PageLayout',\n validThemeKeys,\n baseTheme,\n);\n\nPageLayout.propTypes = {\n children: PT.node,\n leftSidePanelContent: PT.node,\n rightSidePanelContent: PT.node,\n theme: ThemedPageLayout.themeType.isRequired,\n};\n\nexport default ThemedPageLayout;\n"],"mappings":";;;;;;;AAAA,IAAAA,UAAA,GAAAC,sBAAA,CAAAC,OAAA;AAGA,IAAAC,YAAA,GAAAF,sBAAA,CAAAC,OAAA;AAA8D,IAAAE,WAAA,GAAAF,OAAA;AAAA,MAAAG,SAAA;EAAA;EAAA;EAAA;EAAA;EAAA;EAAA;AAAA;AAI9D,MAAMC,cAAc,GAAG,CACrB,WAAW,EACX,eAAe,EACf,WAAW,EACX,gBAAgB,EAChB,WAAW,CACH;AASV;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAMC,UAA2C,GAAGA,CAAC;EACnDC,QAAQ;EACRC,oBAAoB;EACpBC,qBAAqB;EACrBC;AACF,CAAC,kBACC,IAAAP,WAAA,CAAAQ,IAAA;EAAKC,SAAS,EAAEF,KAAK,CAACG,SAAU;EAAAN,QAAA,gBAC9B,IAAAJ,WAAA,CAAAW,GAAA;IAAKF,SAAS,EAAE,CAACF,KAAK,CAACK,SAAS,EAAEL,KAAK,CAACM,aAAa,CAAC,CAACC,IAAI,CAAC,GAAG,CAAE;IAAAV,QAAA,EAC9DC;EAAoB,CAClB,CAAC,eACN,IAAAL,WAAA,CAAAW,GAAA;IAAKF,SAAS,EAAEF,KAAK,CAACQ,SAAU;IAAAX,QAAA,EAC7BA;EAAQ,CACN,CAAC,eACN,IAAAJ,WAAA,CAAAW,GAAA;IAAKF,SAAS,EAAE,CAACF,KAAK,CAACK,SAAS,EAAEL,KAAK,CAACS,cAAc,CAAC,CAACF,IAAI,CAAC,GAAG,CAAE;IAAAV,QAAA,EAC/DE;EAAqB,CACnB,CAAC;AAAA,CACH,CACN;AAED,MAAMW,gBAAgB,GAAG,IAAAC,oBAAM,EAC7Bf,UAAU,EACV,YAAY,EACZD,cAAc,EACdD,SACF,CAAC;AAEDE,UAAU,CAACgB,SAAS,GAAG;EACrBf,QAAQ,EAAEgB,kBAAE,CAACC,IAAI;EACjBhB,oBAAoB,EAAEe,kBAAE,CAACC,IAAI;EAC7Bf,qBAAqB,EAAEc,kBAAE,CAACC,IAAI;EAC9Bd,KAAK,EAAEU,gBAAgB,CAACK,SAAS,CAACC;AACpC,CAAC;AAAC,IAAAC,QAAA,GAAAC,OAAA,CAAAC,OAAA,GAEaT,gBAAgB","ignoreList":[]}
1
+ {"version":3,"file":"index.js","names":["_reactThemes","_interopRequireDefault","require","_jsxRuntime","baseTheme","PageLayout","children","leftSidePanelContent","rightSidePanelContent","theme","jsxs","className","container","jsx","sidePanel","leftSidePanel","join","mainPanel","rightSidePanel","_default","exports","default","themed"],"sources":["../../../../../src/shared/components/PageLayout/index.tsx"],"sourcesContent":["import type { ReactNode } from 'react';\n\nimport themed, { type Theme } from '@dr.pogodin/react-themes';\n\nimport baseTheme from './base-theme.scss';\n\ntype ThemeKeyT =\n | 'container'\n | 'leftSidePanel'\n | 'mainPanel'\n | 'rightSidePanel'\n | 'sidePanel';\n\ntype PropsT = {\n children?: ReactNode;\n leftSidePanelContent?: ReactNode;\n rightSidePanelContent?: ReactNode;\n theme: Theme<ThemeKeyT>;\n};\n\n/**\n * Simple and themeable page layout. It keeps the main content centered in\n * a column of limited width, which fills entire viewport on small screens\n * (under `$screen-md = 1024px` size). At larger screens the column keeps\n * `$screen-md` size, and it is centered at the page, surrounded by side\n * panels, where additional content can be displayed.\n *\n * **Children:** Component children are rendered as the content of main panel.\n * @param {object} [props] Component properties.\n * @param {Node} [props.leftSidePanelContent] The content for left side panel.\n * @param {Node} [props.rightSidePanelContent] The content for right side panel.\n * @param {PageLayoutTheme} [props.theme] _Ad hoc_ theme.\n * @param {...any} [props....]\n * [Other theming properties](https://www.npmjs.com/package/@dr.pogodin/react-themes#themed-component-properties)\n */\nconst PageLayout: React.FunctionComponent<PropsT> = ({\n children,\n leftSidePanelContent,\n rightSidePanelContent,\n theme,\n}) => (\n <div className={theme.container}>\n <div className={[theme.sidePanel, theme.leftSidePanel].join(' ')}>\n {leftSidePanelContent}\n </div>\n <div className={theme.mainPanel}>\n {children}\n </div>\n <div className={[theme.sidePanel, theme.rightSidePanel].join(' ')}>\n {rightSidePanelContent}\n </div>\n </div>\n);\n\nexport default themed(PageLayout, 'PageLayout', baseTheme);\n"],"mappings":";;;;;;;AAEA,IAAAA,YAAA,GAAAC,sBAAA,CAAAC,OAAA;AAA8D,IAAAC,WAAA,GAAAD,OAAA;AAAA,MAAAE,SAAA;EAAA;EAAA;EAAA;EAAA;EAAA;EAAA;AAAA;AAkB9D;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAMC,UAA2C,GAAGA,CAAC;EACnDC,QAAQ;EACRC,oBAAoB;EACpBC,qBAAqB;EACrBC;AACF,CAAC,kBACC,IAAAN,WAAA,CAAAO,IAAA;EAAKC,SAAS,EAAEF,KAAK,CAACG,SAAU;EAAAN,QAAA,gBAC9B,IAAAH,WAAA,CAAAU,GAAA;IAAKF,SAAS,EAAE,CAACF,KAAK,CAACK,SAAS,EAAEL,KAAK,CAACM,aAAa,CAAC,CAACC,IAAI,CAAC,GAAG,CAAE;IAAAV,QAAA,EAC9DC;EAAoB,CAClB,CAAC,eACN,IAAAJ,WAAA,CAAAU,GAAA;IAAKF,SAAS,EAAEF,KAAK,CAACQ,SAAU;IAAAX,QAAA,EAC7BA;EAAQ,CACN,CAAC,eACN,IAAAH,WAAA,CAAAU,GAAA;IAAKF,SAAS,EAAE,CAACF,KAAK,CAACK,SAAS,EAAEL,KAAK,CAACS,cAAc,CAAC,CAACF,IAAI,CAAC,GAAG,CAAE;IAAAV,QAAA,EAC/DE;EAAqB,CACnB,CAAC;AAAA,CACH,CACN;AAAC,IAAAW,QAAA,GAAAC,OAAA,CAAAC,OAAA,GAEa,IAAAC,oBAAM,EAACjB,UAAU,EAAE,YAAY,EAAED,SAAS,CAAC","ignoreList":[]}
@@ -6,7 +6,6 @@ Object.defineProperty(exports, "__esModule", {
6
6
  });
7
7
  exports.default = void 0;
8
8
  var _react = require("react");
9
- var _propTypes = _interopRequireDefault(require("prop-types"));
10
9
  var _reactThemes = _interopRequireDefault(require("@dr.pogodin/react-themes"));
11
10
  var _jsxRuntime = require("react/jsx-runtime");
12
11
  const defaultTheme = {
@@ -17,7 +16,6 @@ const defaultTheme = {
17
16
  "textarea": "-dr-pogodin-react-utils___src-shared-components-TextArea-style___textarea___zd-OFg",
18
17
  "hidden": "-dr-pogodin-react-utils___src-shared-components-TextArea-style___hidden___GiHBXI"
19
18
  };
20
- const validThemeKeys = ['container', 'hidden', 'textarea'];
21
19
  const TextArea = ({
22
20
  disabled,
23
21
  onChange,
@@ -79,14 +77,5 @@ const TextArea = ({
79
77
  })]
80
78
  });
81
79
  };
82
- const ThemedTextArea = (0, _reactThemes.default)(TextArea, 'TextArea', validThemeKeys, defaultTheme);
83
- TextArea.propTypes = {
84
- disabled: _propTypes.default.bool,
85
- onChange: _propTypes.default.func,
86
- onKeyDown: _propTypes.default.func,
87
- placeholder: _propTypes.default.string,
88
- theme: ThemedTextArea.themeType.isRequired,
89
- value: _propTypes.default.string
90
- };
91
- var _default = exports.default = ThemedTextArea;
80
+ var _default = exports.default = (0, _reactThemes.default)(TextArea, 'TextArea', defaultTheme);
92
81
  //# sourceMappingURL=index.js.map