@dr.pogodin/react-utils 1.8.5 → 1.10.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 (142) hide show
  1. package/bin/build.js +0 -129
  2. package/bin/release.sh +1 -1
  3. package/bin/setup.js +0 -44
  4. package/build/development/client/index.js +0 -6
  5. package/build/development/client/index.js.map +1 -1
  6. package/build/development/client/init.js +3 -1
  7. package/build/development/client/init.js.map +1 -1
  8. package/build/development/index.js +14 -19
  9. package/build/development/index.js.map +1 -1
  10. package/build/development/server/index.js +1 -51
  11. package/build/development/server/index.js.map +1 -1
  12. package/build/development/server/renderer.js +10 -4
  13. package/build/development/server/renderer.js.map +1 -1
  14. package/build/development/server/server.js +1 -1
  15. package/build/development/server/utils/errors.js +3 -3
  16. package/build/development/shared/components/Button/index.js +7 -42
  17. package/build/development/shared/components/Button/index.js.map +1 -1
  18. package/build/development/shared/components/Checkbox/index.js +7 -14
  19. package/build/development/shared/components/Checkbox/index.js.map +1 -1
  20. package/build/development/shared/components/CodeSplit/index.js +9 -66
  21. package/build/development/shared/components/CodeSplit/index.js.map +1 -1
  22. package/build/development/shared/components/Dropdown/index.js +9 -35
  23. package/build/development/shared/components/Dropdown/index.js.map +1 -1
  24. package/build/development/shared/components/GenericLink/index.js +1 -23
  25. package/build/development/shared/components/GenericLink/index.js.map +1 -1
  26. package/build/development/shared/components/Input/index.js +6 -19
  27. package/build/development/shared/components/Input/index.js.map +1 -1
  28. package/build/development/shared/components/MetaTags.js +0 -21
  29. package/build/development/shared/components/MetaTags.js.map +1 -1
  30. package/build/development/shared/components/Modal/index.js +5 -39
  31. package/build/development/shared/components/Modal/index.js.map +1 -1
  32. package/build/development/shared/components/NavLink.js +0 -10
  33. package/build/development/shared/components/NavLink.js.map +1 -1
  34. package/build/development/shared/components/PageLayout/index.js +6 -31
  35. package/build/development/shared/components/PageLayout/index.js.map +1 -1
  36. package/build/development/shared/components/ScalableRect/index.js +2 -8
  37. package/build/development/shared/components/ScalableRect/index.js.map +1 -1
  38. package/build/development/shared/components/Throbber/index.js +10 -22
  39. package/build/development/shared/components/Throbber/index.js.map +1 -1
  40. package/build/development/shared/components/WithTooltip/index.js +7 -13
  41. package/build/development/shared/components/WithTooltip/index.js.map +1 -1
  42. package/build/development/shared/components/YouTubeVideo/index.js +9 -15
  43. package/build/development/shared/components/YouTubeVideo/index.js.map +1 -1
  44. package/build/development/shared/components/index.js +18 -18
  45. package/build/development/shared/components/index.js.map +1 -1
  46. package/build/development/shared/utils/config.js +0 -22
  47. package/build/development/shared/utils/config.js.map +1 -1
  48. package/build/development/shared/utils/index.js +11 -29
  49. package/build/development/shared/utils/index.js.map +1 -1
  50. package/build/development/shared/utils/isomorphy.js +3 -44
  51. package/build/development/shared/utils/isomorphy.js.map +1 -1
  52. package/build/development/shared/utils/jest.js +12 -126
  53. package/build/development/shared/utils/jest.js.map +1 -1
  54. package/build/development/shared/utils/url.js +1 -1
  55. package/build/development/shared/utils/webpack.js +0 -4
  56. package/build/development/shared/utils/webpack.js.map +1 -1
  57. package/build/development/style.css +149 -149
  58. package/build/development/web.bundle.js +33 -33
  59. package/build/production/client/index.js +0 -6
  60. package/build/production/client/index.js.map +1 -1
  61. package/build/production/client/init.js +2 -1
  62. package/build/production/client/init.js.map +1 -1
  63. package/build/production/index.js +2 -11
  64. package/build/production/index.js.map +1 -1
  65. package/build/production/server/index.js +1 -49
  66. package/build/production/server/index.js.map +1 -1
  67. package/build/production/server/renderer.js +2 -2
  68. package/build/production/server/renderer.js.map +1 -1
  69. package/build/production/server/server.js +1 -1
  70. package/build/production/server/utils/errors.js +1 -1
  71. package/build/production/shared/components/Button/index.js +2 -37
  72. package/build/production/shared/components/Button/index.js.map +1 -1
  73. package/build/production/shared/components/Checkbox/index.js +2 -9
  74. package/build/production/shared/components/Checkbox/index.js.map +1 -1
  75. package/build/production/shared/components/CodeSplit/index.js +2 -65
  76. package/build/production/shared/components/CodeSplit/index.js.map +1 -1
  77. package/build/production/shared/components/Dropdown/index.js +2 -24
  78. package/build/production/shared/components/Dropdown/index.js.map +1 -1
  79. package/build/production/shared/components/GenericLink/index.js +1 -23
  80. package/build/production/shared/components/GenericLink/index.js.map +1 -1
  81. package/build/production/shared/components/Input/index.js +2 -13
  82. package/build/production/shared/components/Input/index.js.map +1 -1
  83. package/build/production/shared/components/MetaTags.js +0 -21
  84. package/build/production/shared/components/MetaTags.js.map +1 -1
  85. package/build/production/shared/components/Modal/index.js +2 -34
  86. package/build/production/shared/components/Modal/index.js.map +1 -1
  87. package/build/production/shared/components/NavLink.js +1 -10
  88. package/build/production/shared/components/NavLink.js.map +1 -1
  89. package/build/production/shared/components/PageLayout/index.js +2 -25
  90. package/build/production/shared/components/PageLayout/index.js.map +1 -1
  91. package/build/production/shared/components/ScalableRect/index.js +1 -7
  92. package/build/production/shared/components/ScalableRect/index.js.map +1 -1
  93. package/build/production/shared/components/Throbber/index.js +2 -13
  94. package/build/production/shared/components/Throbber/index.js.map +1 -1
  95. package/build/production/shared/components/WithTooltip/index.js +1 -7
  96. package/build/production/shared/components/WithTooltip/index.js.map +1 -1
  97. package/build/production/shared/components/YouTubeVideo/index.js +1 -7
  98. package/build/production/shared/components/YouTubeVideo/index.js.map +1 -1
  99. package/build/production/shared/components/index.js +1 -1
  100. package/build/production/shared/components/index.js.map +1 -1
  101. package/build/production/shared/utils/config.js +1 -21
  102. package/build/production/shared/utils/config.js.map +1 -1
  103. package/build/production/shared/utils/index.js +1 -20
  104. package/build/production/shared/utils/index.js.map +1 -1
  105. package/build/production/shared/utils/isomorphy.js +1 -40
  106. package/build/production/shared/utils/isomorphy.js.map +1 -1
  107. package/build/production/shared/utils/jest.js +2 -112
  108. package/build/production/shared/utils/jest.js.map +1 -1
  109. package/build/production/shared/utils/url.js +1 -1
  110. package/build/production/shared/utils/webpack.js +0 -4
  111. package/build/production/shared/utils/webpack.js.map +1 -1
  112. package/build/production/style.css +1 -1
  113. package/build/production/style.css.map +1 -1
  114. package/build/production/web.bundle.js +1 -1
  115. package/build/production/web.bundle.js.map +1 -1
  116. package/config/babel/node-ssr.js +1 -8
  117. package/config/babel/webpack.js +1 -8
  118. package/config/jest/default.js +0 -34
  119. package/config/shared/utils.js +9 -100
  120. package/config/stylelint/default.js +2 -19
  121. package/config/webpack/app-base.js +3 -6
  122. package/config/webpack/app-development.js +0 -23
  123. package/config/webpack/app-production.js +0 -20
  124. package/config/webpack/lib-base.js +3 -66
  125. package/config/webpack/lib-development.js +0 -10
  126. package/config/webpack/lib-production.js +0 -9
  127. package/index.js +21 -10
  128. package/package.json +34 -36
  129. package/src/index.js +6 -61
  130. package/src/styles/_mixins/fonts.scss +4 -4
  131. package/src/styles/mixins.scss +1 -1
  132. package/build/development/styles/global-docs.js +0 -29
  133. package/build/development/styles/global-docs.js.map +0 -1
  134. package/build/development/styles/mixins.js +0 -103
  135. package/build/development/styles/mixins.js.map +0 -1
  136. package/build/production/styles/global-docs.js +0 -28
  137. package/build/production/styles/global-docs.js.map +0 -1
  138. package/build/production/styles/mixins.js +0 -101
  139. package/build/production/styles/mixins.js.map +0 -1
  140. package/config/eslint/docs.js +0 -40
  141. package/config/jsdoc/config.js +0 -34
  142. package/src/README.md +0 -130
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/server/renderer.jsx"],"names":["sanitizedConfig","_","omit","config","SCRIPT_LOCATIONS","BODY_OPEN","DEFAULT","HEAD_OPEN","getBuildInfo","context","url","path","resolve","JSON","parse","fs","readFileSync","readChunkGroupsJson","buildDir","res","err","prepareCipher","key","Promise","reject","forge","random","getBytes","iv","cipher","createCipher","start","isBrotliAcceptable","req","acceptable","get","ops","split","i","length","type","priority","trim","parseFloat","factory","webpackConfig","options","buildInfo","global","TRU_BUILD_INFO","publicPath","outputPath","output","manifestLink","existsSync","cache","staticCacheController","Cache","staticCacheSize","CHUNK_GROUPS","defaults","clone","beforeRender","next","cacheRef","data","noCsp","set","send","error","html","h","toString","regex","RegExp","nonce","replace","configToInject","extraScripts","initialState","all","helmet","App","Application","ssrContext","state","cloneDeep","chunks","markup","ssrStart","Date","now","round","maxSsrRounds","ReactDOM","renderToString","dirty","timeout","ssrTimeout","ok","race","allSettled","pending","time","timer","then","Helmet","renderStatic","chunkGroups","webpackStats","locals","mapValues","toJson","namedChunkGroups","item","assets","map","name","dr_pogodin_react_utils___split_components","update","util","createBuffer","stringify","CONFIG","ISTATE","finish","INJ","encode64","status","chunkSet","Set","forEach","chunk","asset","add","styleChunkString","scriptChunkString","endsWith","bodyOpenExtraScripts","defaultExtraScripts","headOpenExtraScripts","filter","script","isObject","location","code","join","isString","faviconLink","favicon","title","meta","buffer"],"mappings":";;;;;;;;;;;AAIA;;AAEA;;AACA;;AACA;;AACA;;AACA;;AACA;;AAEA;;AACA;;AACA;;AAEA;;AAEA;;;;AAnBA;AACA;AACA;AAmBA,MAAMA,eAAe,GAAGC,gBAAEC,IAAF,CAAOC,eAAP,EAAe,QAAf,CAAxB;;AAEO,MAAMC,gBAAgB,GAAG;AAC9BC,EAAAA,SAAS,EAAE,WADmB;AAE9BC,EAAAA,OAAO,EAAE,SAFqB;AAG9BC,EAAAA,SAAS,EAAE;AAHmB,CAAzB;AAMP;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;;AACA,SAASC,YAAT,CAAsBC,OAAtB,EAA+B;AAC7B,QAAMC,GAAG,GAAGC,cAAKC,OAAL,CAAaH,OAAb,EAAsB,aAAtB,CAAZ;;AACA,SAAOI,IAAI,CAACC,KAAL,CAAWC,YAAGC,YAAH,CAAgBN,GAAhB,CAAX,CAAP;AACD;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AACA,SAASO,mBAAT,CAA6BC,QAA7B,EAAuC;AACrC,QAAMR,GAAG,GAAGC,cAAKC,OAAL,CAAaM,QAAb,EAAuB,uBAAvB,CAAZ;;AACA,MAAIC,GAAJ;;AACA,MAAI;AACFA,IAAAA,GAAG,GAAGN,IAAI,CAACC,KAAL,CAAWC,YA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AAD,EAAQmF,MAAR,KAAmB;AACtC,cAAInF,KAAJ,EAAW,MAAMA,KAAN;AACXmF,UAAAA,MAAM,CAAC7E,KAAP,GAAe1C,GAAG,CAAC0C,KAAnB,CAFsC,CAEZ;;AAC1BpB,UAAAA,KAAK,CAAC+E,GAAN,CAAUkB,MAAV,EAAkBxF,QAAQ,CAAC1C,GAA3B;AACD,SAJD;AAKD;AACF,KA3ND,CA2NE,OAAO+C,KAAP,EAAc;AACdN,MAAAA,IAAI,CAACM,KAAD,CAAJ;AACD;AACF,GA/ND;AAgOD","sourcesContent":["/**\n * ExpressJS middleware for server-side rendering of a ReactJS app.\n */\n\nimport { GlobalStateProvider } from '@dr.pogodin/react-global-state';\n\nimport _ from 'lodash';\nimport config from 'config';\nimport forge from 'node-forge';\nimport fs from 'fs';\nimport path from 'path';\nimport { brotliCompress, brotliDecompress } from 'zlib';\n\nimport ReactDOM from 'react-dom/server';\nimport { Helmet } from 'react-helmet';\nimport { StaticRouter } from 'react-router-dom';\n\nimport time from 'utils/time';\n\nimport Cache from './Cache';\n\nconst sanitizedConfig = _.omit(config, 'SECRET');\n\nexport const SCRIPT_LOCATIONS = {\n BODY_OPEN: 'BODY_OPEN',\n DEFAULT: 'DEFAULT',\n HEAD_OPEN: 'HEAD_OPEN',\n};\n\n/**\n * Reads build-time information about the app. This information is generated\n * by our standard Webpack config for apps, and it is written into\n * \".build-info\" file in the context folder specified in Webpack config.\n * At the moment, that file contains build timestamp and a random 32-bit key,\n * suitable for cryptographical use.\n * @ignore\n * @param {String} context Webpack context path used during the build.\n * @return {Object} Resolves to the build-time information.\n */\nfunction getBuildInfo(context) {\n const url = path.resolve(context, '.build-info');\n return JSON.parse(fs.readFileSync(url));\n}\n\n/**\n * Attempts to read from disk the named chunk groups mapping generated\n * by Webpack during the compilation.\n * It will not work for development builds, where these stats should be captured\n * via compilator callback.\n * @ignore\n * @param {string} buildDir\n * @return {object}\n */\nfunction readChunkGroupsJson(buildDir) {\n const url = path.resolve(buildDir, '__chunk_groups__.json');\n let res;\n try {\n res = JSON.parse(fs.readFileSync(url));\n } catch (err) {\n res = null;\n }\n return res;\n}\n\n/**\n * Prepares a new Cipher for data encryption.\n * @ignore\n * @param {String} key Encryption key (32-bit random key is expected, see\n * node-forge documentation, in case of doubts).\n * @return {Promise} Resolves to the object with two fields:\n * 1. cipher - a new Cipher, ready for encryption;\n * 2. iv - initial vector used by the cipher.\n */\nfunction prepareCipher(key) {\n return new Promise((resolve, reject) => {\n forge.random.getBytes(32, (err, iv) => {\n if (err) reject(err);\n else {\n const cipher = forge.cipher.createCipher('AES-CBC', key);\n cipher.start({ iv });\n resolve({ cipher, iv });\n }\n });\n });\n}\n\n/**\n * Given an incoming HTTP requests, it deduces whether Brotli-encoded responses\n * are acceptable to the caller.\n * @param {object} req\n * @return {boolean}\n * @ignore\n */\nexport function isBrotliAcceptable(req) {\n const acceptable = req.get('accept-encoding');\n if (acceptable) {\n const ops = acceptable.split(',');\n for (let i = 0; i < ops.length; ++i) {\n const [type, priority] = ops[i].trim().split(';q=');\n if ((type === '*' || type === 'br')\n && (!priority || parseFloat(priority) > 0)) {\n return true;\n }\n }\n }\n return false;\n}\n\n/**\n * Creates the middleware.\n * @param {object} webpackConfig\n * @param {object} options Additional options:\n * @param {boolean} [options.favicon] `true` will include favicon\n * link into the rendered HTML templates.\n * @param {boolean} [options.noCsp] `true` means that no\n * Content-Security-Policy (CSP) is used by server, thus the renderer\n * may cut a few corners.\n * @param {number} options.maxSsrRounds\n * @param {number} options.ssrTimeout\n * @return {function} Created middleware.\n */\nexport default function factory(webpackConfig, options) {\n const buildInfo = getBuildInfo(webpackConfig.context);\n\n global.TRU_BUILD_INFO = buildInfo;\n\n // publicPath from webpack.output has a trailing slash at the end.\n const { publicPath, path: outputPath } = webpackConfig.output;\n\n let manifestLink = fs.existsSync(`${outputPath}/manifest.json`);\n manifestLink = manifestLink ? (\n `<link rel=\"manifest\" href=\"${publicPath}manifest.json\"></link>`\n ) : '';\n\n // TODO: Update the caching mechanics to stored cached data gzipped,\n // and serve them without a need to unpacking server-side.\n const cache = options.staticCacheController\n ? new Cache(options.staticCacheSize) : null;\n\n const CHUNK_GROUPS = readChunkGroupsJson(outputPath);\n\n const ops = _.defaults(_.clone(options), {\n beforeRender: () => Promise.resolve({}),\n });\n\n return async (req, res, next) => {\n try {\n let cacheRef;\n if (cache) {\n cacheRef = options.staticCacheController(req);\n if (cacheRef) {\n const data = cache.get(cacheRef);\n if (data !== null) {\n if (options.noCsp && isBrotliAcceptable(req)) {\n res.set('Content-Type', 'text/html');\n res.set('Content-Encoding', 'br');\n res.send(data);\n } else {\n brotliDecompress(data, (error, html) => {\n if (error) next(error);\n else {\n let h = html.toString();\n if (!options.noCsp) {\n // TODO: Starting from Node v15 we'll be able to use string's\n // .replaceAll() method instead relying on reg. expression for\n // global matching.\n const regex = new RegExp(data.nonce, 'g');\n h = h.replace(regex, req.nonce);\n }\n res.send(h);\n }\n });\n }\n return;\n }\n }\n }\n\n const [{\n configToInject,\n extraScripts,\n initialState,\n }, {\n cipher,\n iv,\n }] = await Promise.all([\n ops.beforeRender(req, sanitizedConfig),\n prepareCipher(buildInfo.key),\n ]);\n\n let helmet;\n\n /* Optional server-side rendering. */\n let App = options.Application;\n const ssrContext = {\n req,\n state: _.cloneDeep(initialState || {}),\n\n // Array of chunk names encountered during the rendering.\n chunks: [],\n };\n if (App) {\n let markup;\n const ssrStart = Date.now();\n for (let round = 0; round < options.maxSsrRounds; ++round) {\n ssrContext.chunks = [];\n markup = ReactDOM.renderToString((\n <GlobalStateProvider\n initialState={ssrContext.state}\n ssrContext={ssrContext}\n >\n <StaticRouter\n context={ssrContext}\n location={req.url}\n >\n <App />\n </StaticRouter>\n </GlobalStateProvider>\n ));\n\n if (!ssrContext.dirty) break;\n\n /* eslint-disable no-await-in-loop */\n const timeout = options.ssrTimeout + ssrStart - Date.now();\n const ok = timeout > 0 && await Promise.race([\n Promise.allSettled(ssrContext.pending),\n time.timer(timeout).then(() => false),\n ]);\n if (!ok) break;\n /* eslint-enable no-await-in-loop */\n }\n App = markup;\n\n /* This takes care about server-side rendering of page title and meta tags\n * (still demands injection into HTML template, which happens below). */\n helmet = Helmet.renderStatic();\n }\n\n let chunkGroups;\n const webpackStats = _.get(res.locals, 'webpack.devMiddleware.stats');\n if (webpackStats) {\n chunkGroups = _.mapValues(\n webpackStats.toJson({\n all: false,\n chunkGroups: true,\n }).namedChunkGroups,\n (item) => item.assets.map(({ name }) => name),\n );\n } else if (CHUNK_GROUPS) chunkGroups = CHUNK_GROUPS;\n else chunkGroups = {};\n\n /* Encrypts data to be injected into HTML.\n * Keep in mind, that this encryption is no way secure: as the JS bundle\n * contains decryption key and is able to decode it at the client side.\n * Hovewer, for a number of reasons, encryption of injected data is still\n * better than injection of a plain text. */\n delete ssrContext.state.dr_pogodin_react_utils___split_components;\n cipher.update(forge.util.createBuffer(JSON.stringify({\n CHUNK_GROUPS: chunkGroups,\n CONFIG: configToInject || sanitizedConfig,\n ISTATE: ssrContext.state,\n }), 'utf8'));\n cipher.finish();\n const INJ = forge.util.encode64(`${iv}${cipher.output.data}`);\n\n if (ssrContext.status) res.status(ssrContext.status);\n\n const chunkSet = new Set();\n\n // TODO: \"main\" chunk has to be added explicitly,\n // because unlike all other chunks they are not managed by <CodeSplit>\n // component, thus they are not added to the ssrContext.chunks\n // automatically. Actually, names of these entry chunks should be\n // read from Wepback config, as the end user may customize them,\n // remove or add other entry points, but it requires additional\n // efforts to figure out how to automatically order them right,\n // thus for now this handles the default config.\n [\n 'main',\n ...ssrContext.chunks,\n ].forEach((chunk) => {\n const assets = chunkGroups[chunk];\n if (assets) assets.forEach((asset) => chunkSet.add(asset));\n });\n\n let styleChunkString = '';\n let scriptChunkString = '';\n chunkSet.forEach((chunk) => {\n if (chunk.endsWith('.css')) {\n styleChunkString += `<link href=\"${publicPath}${chunk}\" rel=\"stylesheet\" />`;\n } else if (\n chunk.endsWith('.js')\n // In dev mode HMR adds JS updates into asset arrays,\n // and they (updates) should be ignored.\n && !chunk.endsWith('.hot-update.js')\n ) {\n scriptChunkString += `<script src=\"${publicPath}${chunk}\" type=\"application/javascript\"></script>`;\n }\n });\n\n let bodyOpenExtraScripts;\n let defaultExtraScripts;\n let headOpenExtraScripts;\n if (extraScripts) {\n bodyOpenExtraScripts = extraScripts\n .filter((script) => _.isObject(script)\n && script.location === SCRIPT_LOCATIONS.BODY_OPEN)\n .map((script) => script.code)\n .join('');\n defaultExtraScripts = extraScripts\n .filter((script) => _.isString(script)\n || script.location === SCRIPT_LOCATIONS.DEFAULT)\n .map((script) => (_.isString(script) ? script : script.code))\n .join('');\n headOpenExtraScripts = extraScripts\n .filter((script) => _.isObject(script)\n && script.location === SCRIPT_LOCATIONS.HEAD_OPEN)\n .map((script) => script.code)\n .join('');\n }\n\n const faviconLink = ops.favicon ? (\n '<link rel=\"shortcut icon\" href=\"/favicon.ico\" />'\n ) : '';\n\n const html = `<!DOCTYPE html>\n <html lang=\"en\">\n <head>\n ${headOpenExtraScripts || ''}\n ${helmet ? helmet.title.toString() : ''}\n ${helmet ? helmet.meta.toString() : ''}\n <meta name=\"theme-color\" content=\"#FFFFFF\"/>\n ${manifestLink}\n ${styleChunkString}\n ${faviconLink}\n <meta charset=\"utf-8\" />\n <meta\n content=\"width=device-width,initial-scale=1.0\"\n name=\"viewport\"\n />\n </head>\n <body>\n ${bodyOpenExtraScripts || ''}\n <div id=\"react-view\">${App || ''}</div>\n <script\n id=\"inj\"\n type=\"application/javascript\"\n ${options.noCsp ? '' : `nonce=\"${req.nonce}\"`}\n >\n window.INJ=\"${INJ}\"\n </script>\n ${scriptChunkString}\n ${defaultExtraScripts || ''}\n </body>\n </html>`;\n\n res.send(html);\n\n if (cacheRef) {\n brotliCompress(html, (error, buffer) => {\n if (error) throw error;\n buffer.nonce = req.nonce; // eslint-disable-line no-param-reassign\n cache.add(buffer, cacheRef.key);\n });\n }\n } catch (error) {\n next(error);\n }\n };\n}\n"],"file":"renderer.js"}
1
+ {"version":3,"sources":["../../../src/server/renderer.jsx"],"names":["sanitizedConfig","_","omit","config","SCRIPT_LOCATIONS","BODY_OPEN","DEFAULT","HEAD_OPEN","getBuildInfo","context","url","path","resolve","JSON","parse","fs","readFileSync","readChunkGroupsJson","buildDir","res","err","prepareCipher","key","Promise","reject","forge","random","getBytes","iv","cipher","createCipher","start","isBrotliAcceptable","req","acceptable","get","ops","split","i","length","type","priority","trim","parseFloat","factory","webpackConfig","options","buildInfo","global","TRU_BUILD_INFO","publicPath","outputPath","output","manifestLink","existsSync","cache","staticCacheController","Cache","staticCacheSize","CHUNK_GROUPS","defaults","clone","beforeRender","next","cacheRef","data","noCsp","set","send","error","html","h","toString","regex","RegExp","nonce","replace","configToInject","extraScripts","initialState","all","helmet","App","Application","ssrContext","state","cloneDeep","chunks","markup","ssrStart","Date","now","round","maxSsrRounds","ReactDOM","renderToString","dirty","timeout","ssrTimeout","ok","race","allSettled","pending","time","timer","then","Helmet","renderStatic","chunkGroups","webpackStats","locals","mapValues","toJson","namedChunkGroups","item","assets","map","name","dr_pogodin_react_utils___split_components","payload","CONFIG","ISTATE","ignoreFunction","unsafe","update","util","createBuffer","finish","INJ","encode64","status","chunkSet","Set","forEach","chunk","asset","add","styleChunkString","scriptChunkString","endsWith","bodyOpenExtraScripts","defaultExtraScripts","headOpenExtraScripts","filter","script","isObject","location","code","join","isString","faviconLink","favicon","title","meta","buffer"],"mappings":";;;;;;;;;;;AAIA;;AAEA;;AACA;;AACA;;AACA;;AACA;;AACA;;AAEA;;AACA;;AACA;;AACA;;AAEA;;AAEA;;;;AApBA;AACA;AACA;AAoBA,MAAMA,eAAe,GAAGC,gBAAEC,IAAF,CAAOC,eAAP,EAAe,QAAf,CAAxB;;AAEO,MAAMC,gBAAgB,GAAG;AAC9BC,EAAAA,SAAS,EAAE,WADmB;AAE9BC,EAAAA,OAAO,EAAE,SAFqB;AAG9BC,EAAAA,SAAS,EAAE;AAHmB,CAAzB;AAMP;AACA;AACA;AACA;AACA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,MAAM,GAAGA,MAAM,CAACwE,IAAP,CAAYjF,QAAZ,EAAH,GAA4B,EAAG;AACnD;AACA,cAAcnB,YAAa;AAC3B,cAAcoF,gBAAiB;AAC/B,cAAca,WAAY;AAC1B;AACA;AACA;AACA;AACA;AACA;AACA;AACA,cAAcV,oBAAoB,IAAI,EAAG;AACzC,mCAAmC1D,GAAG,IAAI,EAAG;AAC7C;AACA;AACA;AACA,gBAAgBpC,OAAO,CAACoB,KAAR,GAAgB,EAAhB,GAAsB,UAASjC,GAAG,CAAC0C,KAAM,GAAG;AAC5D;AACA,4BAA4BqD,GAAI;AAChC;AACA,cAAcU,iBAAkB;AAChC,cAAcG,mBAAmB,IAAI,EAAG;AACxC;AACA,gBA7BM;AA+BA1H,MAAAA,GAAG,CAACiD,IAAJ,CAASE,IAAT;;AAEA,UAAIN,QAAJ,EAAc;AACZ,kCAAeM,IAAf,EAAqB,CAACD,KAAD,EAAQqF,MAAR,KAAmB;AACtC,cAAIrF,KAAJ,EAAW,MAAMA,KAAN;AACXqF,UAAAA,MAAM,CAAC/E,KAAP,GAAe1C,GAAG,CAAC0C,KAAnB,CAFsC,CAEZ;;AAC1BpB,UAAAA,KAAK,CAACiF,GAAN,CAAUkB,MAAV,EAAkB1F,QAAQ,CAAC1C,GAA3B;AACD,SAJD;AAKD;AACF,KAhOD,CAgOE,OAAO+C,KAAP,EAAc;AACdN,MAAAA,IAAI,CAACM,KAAD,CAAJ;AACD;AACF,GApOD;AAqOD","sourcesContent":["/**\n * ExpressJS middleware for server-side rendering of a ReactJS app.\n */\n\nimport { GlobalStateProvider } from '@dr.pogodin/react-global-state';\n\nimport _ from 'lodash';\nimport config from 'config';\nimport forge from 'node-forge';\nimport fs from 'fs';\nimport path from 'path';\nimport { brotliCompress, brotliDecompress } from 'zlib';\n\nimport ReactDOM from 'react-dom/server';\nimport { Helmet } from 'react-helmet';\nimport { StaticRouter } from 'react-router-dom';\nimport serializeJs from 'serialize-javascript';\n\nimport time from 'utils/time';\n\nimport Cache from './Cache';\n\nconst sanitizedConfig = _.omit(config, 'SECRET');\n\nexport const SCRIPT_LOCATIONS = {\n BODY_OPEN: 'BODY_OPEN',\n DEFAULT: 'DEFAULT',\n HEAD_OPEN: 'HEAD_OPEN',\n};\n\n/**\n * Reads build-time information about the app. This information is generated\n * by our standard Webpack config for apps, and it is written into\n * \".build-info\" file in the context folder specified in Webpack config.\n * At the moment, that file contains build timestamp and a random 32-bit key,\n * suitable for cryptographical use.\n * @ignore\n * @param {String} context Webpack context path used during the build.\n * @return {Object} Resolves to the build-time information.\n */\nfunction getBuildInfo(context) {\n const url = path.resolve(context, '.build-info');\n return JSON.parse(fs.readFileSync(url));\n}\n\n/**\n * Attempts to read from disk the named chunk groups mapping generated\n * by Webpack during the compilation.\n * It will not work for development builds, where these stats should be captured\n * via compilator callback.\n * @ignore\n * @param {string} buildDir\n * @return {object}\n */\nfunction readChunkGroupsJson(buildDir) {\n const url = path.resolve(buildDir, '__chunk_groups__.json');\n let res;\n try {\n res = JSON.parse(fs.readFileSync(url));\n } catch (err) {\n res = null;\n }\n return res;\n}\n\n/**\n * Prepares a new Cipher for data encryption.\n * @ignore\n * @param {String} key Encryption key (32-bit random key is expected, see\n * node-forge documentation, in case of doubts).\n * @return {Promise} Resolves to the object with two fields:\n * 1. cipher - a new Cipher, ready for encryption;\n * 2. iv - initial vector used by the cipher.\n */\nfunction prepareCipher(key) {\n return new Promise((resolve, reject) => {\n forge.random.getBytes(32, (err, iv) => {\n if (err) reject(err);\n else {\n const cipher = forge.cipher.createCipher('AES-CBC', key);\n cipher.start({ iv });\n resolve({ cipher, iv });\n }\n });\n });\n}\n\n/**\n * Given an incoming HTTP requests, it deduces whether Brotli-encoded responses\n * are acceptable to the caller.\n * @param {object} req\n * @return {boolean}\n * @ignore\n */\nexport function isBrotliAcceptable(req) {\n const acceptable = req.get('accept-encoding');\n if (acceptable) {\n const ops = acceptable.split(',');\n for (let i = 0; i < ops.length; ++i) {\n const [type, priority] = ops[i].trim().split(';q=');\n if ((type === '*' || type === 'br')\n && (!priority || parseFloat(priority) > 0)) {\n return true;\n }\n }\n }\n return false;\n}\n\n/**\n * Creates the middleware.\n * @param {object} webpackConfig\n * @param {object} options Additional options:\n * @param {boolean} [options.favicon] `true` will include favicon\n * link into the rendered HTML templates.\n * @param {boolean} [options.noCsp] `true` means that no\n * Content-Security-Policy (CSP) is used by server, thus the renderer\n * may cut a few corners.\n * @param {number} options.maxSsrRounds\n * @param {number} options.ssrTimeout\n * @return {function} Created middleware.\n */\nexport default function factory(webpackConfig, options) {\n const buildInfo = getBuildInfo(webpackConfig.context);\n\n global.TRU_BUILD_INFO = buildInfo;\n\n // publicPath from webpack.output has a trailing slash at the end.\n const { publicPath, path: outputPath } = webpackConfig.output;\n\n let manifestLink = fs.existsSync(`${outputPath}/manifest.json`);\n manifestLink = manifestLink ? (\n `<link rel=\"manifest\" href=\"${publicPath}manifest.json\"></link>`\n ) : '';\n\n // TODO: Update the caching mechanics to stored cached data gzipped,\n // and serve them without a need to unpacking server-side.\n const cache = options.staticCacheController\n ? new Cache(options.staticCacheSize) : null;\n\n const CHUNK_GROUPS = readChunkGroupsJson(outputPath);\n\n const ops = _.defaults(_.clone(options), {\n beforeRender: () => Promise.resolve({}),\n });\n\n return async (req, res, next) => {\n try {\n let cacheRef;\n if (cache) {\n cacheRef = options.staticCacheController(req);\n if (cacheRef) {\n const data = cache.get(cacheRef);\n if (data !== null) {\n if (options.noCsp && isBrotliAcceptable(req)) {\n res.set('Content-Type', 'text/html');\n res.set('Content-Encoding', 'br');\n res.send(data);\n } else {\n brotliDecompress(data, (error, html) => {\n if (error) next(error);\n else {\n let h = html.toString();\n if (!options.noCsp) {\n // TODO: Starting from Node v15 we'll be able to use string's\n // .replaceAll() method instead relying on reg. expression for\n // global matching.\n const regex = new RegExp(data.nonce, 'g');\n h = h.replace(regex, req.nonce);\n }\n res.send(h);\n }\n });\n }\n return;\n }\n }\n }\n\n const [{\n configToInject,\n extraScripts,\n initialState,\n }, {\n cipher,\n iv,\n }] = await Promise.all([\n ops.beforeRender(req, sanitizedConfig),\n prepareCipher(buildInfo.key),\n ]);\n\n let helmet;\n\n /* Optional server-side rendering. */\n let App = options.Application;\n const ssrContext = {\n req,\n state: _.cloneDeep(initialState || {}),\n\n // Array of chunk names encountered during the rendering.\n chunks: [],\n };\n if (App) {\n let markup;\n const ssrStart = Date.now();\n for (let round = 0; round < options.maxSsrRounds; ++round) {\n ssrContext.chunks = [];\n markup = ReactDOM.renderToString((\n <GlobalStateProvider\n initialState={ssrContext.state}\n ssrContext={ssrContext}\n >\n <StaticRouter\n context={ssrContext}\n location={req.url}\n >\n <App />\n </StaticRouter>\n </GlobalStateProvider>\n ));\n\n if (!ssrContext.dirty) break;\n\n /* eslint-disable no-await-in-loop */\n const timeout = options.ssrTimeout + ssrStart - Date.now();\n const ok = timeout > 0 && await Promise.race([\n Promise.allSettled(ssrContext.pending),\n time.timer(timeout).then(() => false),\n ]);\n if (!ok) break;\n /* eslint-enable no-await-in-loop */\n }\n App = markup;\n\n /* This takes care about server-side rendering of page title and meta tags\n * (still demands injection into HTML template, which happens below). */\n helmet = Helmet.renderStatic();\n }\n\n let chunkGroups;\n const webpackStats = _.get(res.locals, 'webpack.devMiddleware.stats');\n if (webpackStats) {\n chunkGroups = _.mapValues(\n webpackStats.toJson({\n all: false,\n chunkGroups: true,\n }).namedChunkGroups,\n (item) => item.assets.map(({ name }) => name),\n );\n } else if (CHUNK_GROUPS) chunkGroups = CHUNK_GROUPS;\n else chunkGroups = {};\n\n /* Encrypts data to be injected into HTML.\n * Keep in mind, that this encryption is no way secure: as the JS bundle\n * contains decryption key and is able to decode it at the client side.\n * Hovewer, for a number of reasons, encryption of injected data is still\n * better than injection of a plain text. */\n delete ssrContext.state.dr_pogodin_react_utils___split_components;\n\n const payload = serializeJs({\n CHUNK_GROUPS: chunkGroups,\n CONFIG: configToInject || sanitizedConfig,\n ISTATE: ssrContext.state,\n }, {\n ignoreFunction: true,\n unsafe: true,\n });\n cipher.update(forge.util.createBuffer(payload, 'utf8'));\n cipher.finish();\n const INJ = forge.util.encode64(`${iv}${cipher.output.data}`);\n\n if (ssrContext.status) res.status(ssrContext.status);\n\n const chunkSet = new Set();\n\n // TODO: \"main\" chunk has to be added explicitly,\n // because unlike all other chunks they are not managed by <CodeSplit>\n // component, thus they are not added to the ssrContext.chunks\n // automatically. Actually, names of these entry chunks should be\n // read from Wepback config, as the end user may customize them,\n // remove or add other entry points, but it requires additional\n // efforts to figure out how to automatically order them right,\n // thus for now this handles the default config.\n [\n 'main',\n ...ssrContext.chunks,\n ].forEach((chunk) => {\n const assets = chunkGroups[chunk];\n if (assets) assets.forEach((asset) => chunkSet.add(asset));\n });\n\n let styleChunkString = '';\n let scriptChunkString = '';\n chunkSet.forEach((chunk) => {\n if (chunk.endsWith('.css')) {\n styleChunkString += `<link href=\"${publicPath}${chunk}\" rel=\"stylesheet\" />`;\n } else if (\n chunk.endsWith('.js')\n // In dev mode HMR adds JS updates into asset arrays,\n // and they (updates) should be ignored.\n && !chunk.endsWith('.hot-update.js')\n ) {\n scriptChunkString += `<script src=\"${publicPath}${chunk}\" type=\"application/javascript\"></script>`;\n }\n });\n\n let bodyOpenExtraScripts;\n let defaultExtraScripts;\n let headOpenExtraScripts;\n if (extraScripts) {\n bodyOpenExtraScripts = extraScripts\n .filter((script) => _.isObject(script)\n && script.location === SCRIPT_LOCATIONS.BODY_OPEN)\n .map((script) => script.code)\n .join('');\n defaultExtraScripts = extraScripts\n .filter((script) => _.isString(script)\n || script.location === SCRIPT_LOCATIONS.DEFAULT)\n .map((script) => (_.isString(script) ? script : script.code))\n .join('');\n headOpenExtraScripts = extraScripts\n .filter((script) => _.isObject(script)\n && script.location === SCRIPT_LOCATIONS.HEAD_OPEN)\n .map((script) => script.code)\n .join('');\n }\n\n const faviconLink = ops.favicon ? (\n '<link rel=\"shortcut icon\" href=\"/favicon.ico\" />'\n ) : '';\n\n const html = `<!DOCTYPE html>\n <html lang=\"en\">\n <head>\n ${headOpenExtraScripts || ''}\n ${helmet ? helmet.title.toString() : ''}\n ${helmet ? helmet.meta.toString() : ''}\n <meta name=\"theme-color\" content=\"#FFFFFF\"/>\n ${manifestLink}\n ${styleChunkString}\n ${faviconLink}\n <meta charset=\"utf-8\" />\n <meta\n content=\"width=device-width,initial-scale=1.0\"\n name=\"viewport\"\n />\n </head>\n <body>\n ${bodyOpenExtraScripts || ''}\n <div id=\"react-view\">${App || ''}</div>\n <script\n id=\"inj\"\n type=\"application/javascript\"\n ${options.noCsp ? '' : `nonce=\"${req.nonce}\"`}\n >\n window.INJ=\"${INJ}\"\n </script>\n ${scriptChunkString}\n ${defaultExtraScripts || ''}\n </body>\n </html>`;\n\n res.send(html);\n\n if (cacheRef) {\n brotliCompress(html, (error, buffer) => {\n if (error) throw error;\n buffer.nonce = req.nonce; // eslint-disable-line no-param-reassign\n cache.add(buffer, cacheRef.key);\n });\n }\n } catch (error) {\n next(error);\n }\n };\n}\n"],"file":"renderer.js"}
@@ -5,8 +5,8 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
5
5
  Object.defineProperty(exports, "__esModule", {
6
6
  value: true
7
7
  });
8
- exports.getDefaultCspSettings = getDefaultCspSettings;
9
8
  exports.default = factory;
9
+ exports.getDefaultCspSettings = getDefaultCspSettings;
10
10
 
11
11
  var _lodash = require("lodash");
12
12
 
@@ -5,9 +5,6 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
5
5
  Object.defineProperty(exports, "__esModule", {
6
6
  value: true
7
7
  });
8
- exports.newError = newError;
9
- exports.fail = fail;
10
- exports.assert = assert;
11
8
  Object.defineProperty(exports, "CODES", {
12
9
  enumerable: true,
13
10
  get: function () {
@@ -20,6 +17,8 @@ Object.defineProperty(exports, "ERRORS", {
20
17
  return _httpStatusCodes.ReasonPhrases;
21
18
  }
22
19
  });
20
+ exports.assert = assert;
21
+ exports.fail = fail;
23
22
  Object.defineProperty(exports, "getErrorForCode", {
24
23
  enumerable: true,
25
24
  get: function () {
@@ -32,6 +31,7 @@ Object.defineProperty(exports, "joi", {
32
31
  return _joi.default;
33
32
  }
34
33
  });
34
+ exports.newError = newError;
35
35
 
36
36
  var _httpStatusCodes = require("http-status-codes");
37
37
 
@@ -17,12 +17,12 @@ var _jsxRuntime = require("react/jsx-runtime");
17
17
 
18
18
  // The <Button> component implements a standard button / button-like link.
19
19
  var defaultTheme = {
20
- "context": "-dr-pogodin-react-utils___src-shared-components-Button-style___context___1orYrC",
21
- "ad": "-dr-pogodin-react-utils___src-shared-components-Button-style___ad___14A3nZ",
22
- "hoc": "-dr-pogodin-react-utils___src-shared-components-Button-style___hoc___5EzTm9",
23
- "button": "-dr-pogodin-react-utils___src-shared-components-Button-style___button___3-kJlZ",
24
- "active": "-dr-pogodin-react-utils___src-shared-components-Button-style___active___3UaAP4",
25
- "disabled": "-dr-pogodin-react-utils___src-shared-components-Button-style___disabled___JnSSAY"
20
+ "context": "-dr-pogodin-react-utils___src-shared-components-Button-style___context___33qmle",
21
+ "ad": "-dr-pogodin-react-utils___src-shared-components-Button-style___ad___JqF7SX",
22
+ "hoc": "-dr-pogodin-react-utils___src-shared-components-Button-style___hoc___6uVxU-",
23
+ "button": "-dr-pogodin-react-utils___src-shared-components-Button-style___button___2629gm",
24
+ "active": "-dr-pogodin-react-utils___src-shared-components-Button-style___active___2qX90D",
25
+ "disabled": "-dr-pogodin-react-utils___src-shared-components-Button-style___disabled___24vuTm"
26
26
  };
27
27
 
28
28
  function BaseButton({
@@ -72,8 +72,7 @@ function BaseButton({
72
72
  });
73
73
  }
74
74
  /**
75
- * @category Components
76
- * @typedef {object} ButtonTheme {@link Button} component theme: a map of CSS
75
+ * Button component theme: a map of CSS
77
76
  * class names to append to button elements:
78
77
  * @prop {string} [active] to the root element of active button.
79
78
  * @prop {string} [button] to the root element of any button.
@@ -83,25 +82,8 @@ function BaseButton({
83
82
 
84
83
  const ThemedButton = (0, _utils.themed)('Button', ['active', 'button', 'disabled'], defaultTheme)(BaseButton);
85
84
  /**
86
- * @category Components
87
- * @func Button
88
- * @desc
89
- * ```js
90
- * import { Button } from '@dr.pogodin/react-utils';
91
- * ```
92
85
  * Implements themeable buttons, and button-line links (elements which look
93
86
  * like buttons, but behave as links) in the same uniform manner.
94
- *
95
- * Under the hood, a `<Button>` instance is rendered as:
96
- * 1. `<div>` when the button is disabled. It helps to ensure exactly
97
- * the same style of disabled buttons and button-like links.
98
- * 2. `<Link>` when `to` property is set.
99
- * This takes care about internal and external links.
100
- * 3. `<div>` element, otherwise. `<Link>` component could also play the button
101
- * role, but is more efficient to use `<div>` in this case.
102
- *
103
- * **Children:** Component children, if any, are rendered as button content.
104
- *
105
87
  * @param {object} [props] Component props.
106
88
  * @param {boolean} [props.active] Set `true` to render the button as
107
89
  * active, even if it is not active otherwise.
@@ -124,23 +106,6 @@ const ThemedButton = (0, _utils.themed)('Button', ['active', 'button', 'disabled
124
106
  * or URL.
125
107
  * @param {...any} [props....]
126
108
  * [Other properties of themeable components](https://www.npmjs.com/package/@dr.pogodin/react-themes#themed-component-properties)
127
- *
128
- * @example
129
- * import React from 'react';
130
- * import { Button } from '@dr.pogodin/react-utils';
131
- *
132
- * export default function ButtonDemo() {
133
- * return (
134
- * <div>
135
- * <Button onClick={() => alert('Button Clicked')}>Button</Button>
136
- * <Button to="https://dr.pogodin.studio" openNewTab>
137
- * Button-Like Link
138
- * </Button>
139
- * <Button disabled>Disabled Button</Button>
140
- * <Button active>Forced-Active Button</Button>
141
- * </div>
142
- * );
143
- * }
144
109
  */
145
110
 
146
111
  BaseButton.defaultProps = {
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../src/shared/components/Button/index.jsx"],"names":["BaseButton","active","children","disabled","enforceA","onClick","onMouseDown","openNewTab","replace","theme","to","className","button","ThemedButton","defaultTheme","defaultProps","undefined","propTypes","PT","bool","node","func","themeType","isRequired","oneOfType","object","string"],"mappings":";;;;;;;;;AAEA;;AAEA;;AAEA;;;;AANA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AAb;AAViB,CAAvB;eAaeb,Y","sourcesContent":["// The <Button> component implements a standard button / button-like link.\n\nimport PT from 'prop-types';\n\nimport Link from 'components/Link';\n\nimport { themed } from 'utils';\n\nimport defaultTheme from './style.scss';\n\nfunction BaseButton({\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 return (\n <div\n className={className}\n onClick={onClick}\n onKeyPress={onClick}\n onMouseDown={onMouseDown}\n role=\"button\"\n tabIndex={0}\n >\n {children}\n </div>\n );\n}\n\n/**\n * @category Components\n * @typedef {object} ButtonTheme {@link 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('Button', [\n 'active',\n 'button',\n 'disabled',\n], defaultTheme)(BaseButton);\n\n/**\n * @category Components\n * @func Button\n * @desc\n * ```js\n * import { Button } from '@dr.pogodin/react-utils';\n * ```\n * Implements themeable buttons, and button-line links (elements which look\n * like buttons, but behave as links) in the same uniform manner.\n *\n * Under the hood, a `<Button>` instance is rendered as:\n * 1. `<div>` when the button is disabled. It helps to ensure exactly\n * the same style of disabled buttons and button-like links.\n * 2. `<Link>` when `to` property is set.\n * This takes care about internal and external links.\n * 3. `<div>` element, otherwise. `<Link>` component could also play the button\n * role, but is more efficient to use `<div>` in this case.\n *\n * **Children:** Component children, if any, are rendered as button content.\n *\n * @param {object} [props] Component props.\n * @param {boolean} [props.active] Set `true` to render the button as\n * active, even if it is not active otherwise.\n * @param {boolean} [props.disabled] Set `true` to disable the button.\n * @param {boolean} [props.enforceA] When the button is rendered as `<Link>`\n * component, this prop enforces it to be rendered as a simple `<a>` element\n * (external link), rather than the React router's internal link.\n * See `<Link>` documentation to learn when links are rendered as `<a>`\n * by default.\n * @param {function} [props.onClick] Click event handler.\n * @param {function} [props.onMouseDown] Mouse down event handler.\n * @param {boolean} [props.openNewTab] Set `true` to open link in the new tab.\n * @param {boolean} [props.replace] When the button is rendered as\n * `<Link>`, and the target URL is internal, this property tells that\n * the new route should replace the last record in the browser's history,\n * rather than to be pushed as a new entry into the history stack.\n * @param {ButtonTheme} [props.theme] _Ad hoc_ button theme.\n * @param {object|string} [props.to] If specified, the button will be rendered\n * as `<Link>` (if not disabled), and it will point to the specified location\n * or URL.\n * @param {...any} [props....]\n * [Other properties of themeable components](https://www.npmjs.com/package/@dr.pogodin/react-themes#themed-component-properties)\n *\n * @example\n * import React from 'react';\n * import { Button } from '@dr.pogodin/react-utils';\n *\n * export default function ButtonDemo() {\n * return (\n * <div>\n * <Button onClick={() => alert('Button Clicked')}>Button</Button>\n * <Button to=\"https://dr.pogodin.studio\" openNewTab>\n * Button-Like Link\n * </Button>\n * <Button disabled>Disabled Button</Button>\n * <Button active>Forced-Active Button</Button>\n * </div>\n * );\n * }\n */\nBaseButton.defaultProps = {\n active: false,\n children: undefined,\n disabled: false,\n enforceA: false,\n onClick: undefined,\n onMouseDown: undefined,\n openNewTab: false,\n replace: false,\n to: undefined,\n};\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"],"file":"index.js"}
1
+ {"version":3,"sources":["../../../../../src/shared/components/Button/index.jsx"],"names":["BaseButton","active","children","disabled","enforceA","onClick","onMouseDown","openNewTab","replace","theme","to","className","button","ThemedButton","defaultTheme","defaultProps","undefined","propTypes","PT","bool","node","func","themeType","isRequired","oneOfType","object","string"],"mappings":";;;;;;;;;AAEA;;AAEA;;AAEA;;;;AANA;;;;;;;;;;AAUA,SAASA,UAAT,CAAoB;AAClBC,EAAAA,MADkB;AAElBC,EAAAA,QAFkB;AAGlBC,EAAAA,QAHkB;AAIlBC,EAAAA,QAJkB;AAKlBC,EAAAA,OALkB;AAMlBC,EAAAA,WANkB;AAOlBC,EAAAA,UAPkB;AAQlBC,EAAAA,OARkB;AASlBC,EAAAA,KATkB;AAUlBC,EAAAA;AAVkB,CAApB,EAWG;AACD,MAAIC,SAAS,GAAGF,KAAK,CAACG,MAAtB;AACA,MAAIX,MAAM,IAAIQ,KAAK,CAACR,MAApB,EAA4BU,SAAS,IAAK,IAAGF,KAAK,CAACR,MAAO,EAA9B;;AAC5B,MAAIE,QAAJ,EAAc;AACZ,QAAIM,KAAK,CAACN,QAAV,EAAoBQ,SAAS,IAAK,IAAGF,KAAK,CAACN,QAAS,EAAhC;AACpB,wBACE;AAAK,MAAA,SAAS,EAAEQ,SAAhB;AAAA,gBACGT;AADH,MADF;AAKD;;AACD,MAAIQ,EAAJ,EAAQ;AACN,wBACE,qBAAC,aAAD;AACE,MAAA,SAAS,EAAEC,SADb;AAEE,MAAA,QAAQ,EAAEP,QAFZ;AAGE,MAAA,OAAO,EAAEC,OAHX;AAIE,MAAA,WAAW,EAAEC,WAJf;AAKE,MAAA,UAAU,EAAEC,UALd;AAME,MAAA,OAAO,EAAEC,OANX;AAOE,MAAA,EAAE,EAAEE,EAPN;AAAA,gBASGR;AATH,MADF;AAaD;;AACD,sBACE;AACE,IAAA,SAAS,EAAES,SADb;AAEE,IAAA,OAAO,EAAEN,OAFX;AAGE,IAAA,UAAU,EAAEA,OAHd;AAIE,IAAA,WAAW,EAAEC,WAJf;AAKE,IAAA,IAAI,EAAC,QALP;AAME,IAAA,QAAQ,EAAE,CANZ;AAAA,cA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Content":["// The <Button> component implements a standard button / button-like link.\n\nimport PT from 'prop-types';\n\nimport Link from 'components/Link';\n\nimport { themed } from 'utils';\n\nimport defaultTheme from './style.scss';\n\nfunction BaseButton({\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 return (\n <div\n className={className}\n onClick={onClick}\n onKeyPress={onClick}\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('Button', [\n 'active',\n 'button',\n 'disabled',\n], defaultTheme)(BaseButton);\n\n/**\n * Implements themeable buttons, and button-line links (elements which look\n * like buttons, but behave as links) in the same uniform manner.\n * @param {object} [props] Component props.\n * @param {boolean} [props.active] Set `true` to render the button as\n * active, even if it is not active otherwise.\n * @param {boolean} [props.disabled] Set `true` to disable the button.\n * @param {boolean} [props.enforceA] When the button is rendered as `<Link>`\n * component, this prop enforces it to be rendered as a simple `<a>` element\n * (external link), rather than the React router's internal link.\n * See `<Link>` documentation to learn when links are rendered as `<a>`\n * by default.\n * @param {function} [props.onClick] Click event handler.\n * @param {function} [props.onMouseDown] Mouse down event handler.\n * @param {boolean} [props.openNewTab] Set `true` to open link in the new tab.\n * @param {boolean} [props.replace] When the button is rendered as\n * `<Link>`, and the target URL is internal, this property tells that\n * the new route should replace the last record in the browser's history,\n * rather than to be pushed as a new entry into the history stack.\n * @param {ButtonTheme} [props.theme] _Ad hoc_ button theme.\n * @param {object|string} [props.to] If specified, the button will be rendered\n * as `<Link>` (if not disabled), and it will point to the specified location\n * or URL.\n * @param {...any} [props....]\n * [Other properties of themeable components](https://www.npmjs.com/package/@dr.pogodin/react-themes#themed-component-properties)\n */\nBaseButton.defaultProps = {\n active: false,\n children: undefined,\n disabled: false,\n enforceA: false,\n onClick: undefined,\n onMouseDown: undefined,\n openNewTab: false,\n replace: false,\n to: undefined,\n};\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"],"file":"index.js"}
@@ -14,12 +14,12 @@ var _utils = require("../../utils");
14
14
  var _jsxRuntime = require("react/jsx-runtime");
15
15
 
16
16
  var defaultTheme = {
17
- "context": "-dr-pogodin-react-utils___src-shared-components-Checkbox-theme___context___Eo3d0U",
18
- "ad": "-dr-pogodin-react-utils___src-shared-components-Checkbox-theme___ad___1zOOw4",
19
- "hoc": "-dr-pogodin-react-utils___src-shared-components-Checkbox-theme___hoc___Db_vtL",
20
- "checkbox": "-dr-pogodin-react-utils___src-shared-components-Checkbox-theme___checkbox___TKBJM0",
21
- "container": "-dr-pogodin-react-utils___src-shared-components-Checkbox-theme___container___265CXn",
22
- "label": "-dr-pogodin-react-utils___src-shared-components-Checkbox-theme___label___2_7qW7"
17
+ "context": "-dr-pogodin-react-utils___src-shared-components-Checkbox-theme___context___3elv1W",
18
+ "ad": "-dr-pogodin-react-utils___src-shared-components-Checkbox-theme___ad___38el0G",
19
+ "hoc": "-dr-pogodin-react-utils___src-shared-components-Checkbox-theme___hoc___285jVN",
20
+ "checkbox": "-dr-pogodin-react-utils___src-shared-components-Checkbox-theme___checkbox___1OUp4C",
21
+ "container": "-dr-pogodin-react-utils___src-shared-components-Checkbox-theme___container___32kN_q",
22
+ "label": "-dr-pogodin-react-utils___src-shared-components-Checkbox-theme___label___26M9Hw"
23
23
  };
24
24
 
25
25
  function Checkbox({
@@ -42,8 +42,7 @@ function Checkbox({
42
42
  });
43
43
  }
44
44
  /**
45
- * @category Components
46
- * @typedef {object} CheckboxTheme {@link Checkbox} component theme: a map of
45
+ * Checkbox component theme: a map of
47
46
  * CSS classes to append to its elements:
48
47
  * @prop {string} [checkbox] to the underlying checkbox `<input>` element.
49
48
  * @prop {string} [container] to the root checkbox element.
@@ -53,12 +52,6 @@ function Checkbox({
53
52
 
54
53
  const ThemedCheckbox = (0, _utils.themed)('Checkbox', ['checkbox', 'container', 'label'], defaultTheme)(Checkbox);
55
54
  /**
56
- * @category Components
57
- * @func Checkbox
58
- * @desc
59
- * ```js
60
- * import { Checkbox } from '@dr.pogodin/react-utils';
61
- * ```
62
55
  * The `<Checkbox>` component implements themeable checkboxes.
63
56
  * @param {object} [props] Component properties.
64
57
  * @param {boolean} [props.checked] Checkbox value.
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../src/shared/components/Checkbox/index.jsx"],"names":["Checkbox","checked","label","onChange","theme","container","undefined","checkbox","ThemedCheckbox","defaultTheme","propTypes","PT","bool","string","func","themeType","isRequired","defaultProps"],"mappings":";;;;;;;;;AAAA;;AAEA;;;;;;;;;;;;;AAIA,SAASA,QAAT,CAAkB;AAChBC,EAAAA,OADgB;AAEhBC,EAAAA,KAFgB;AAGhBC,EAAAA,QAHgB;AAIhBC,EAAAA;AAJgB,CAAlB,EAKG;AACD,sBACE;AAAK,IAAA,SAAS,EAAEA,KAAK,CAACC,SAAtB;AAAA,eACIH,KAAK,KAAKI,SAAV,GAAsB,IAAtB,gBAA6B;AAAG,MAAA,SAAS,EAAEF,KAAK,CAACF,KAApB;AAAA,gBAA4BA;AAA5B,MADjC,eAEE;AACE,MAAA,OAAO,EAAED,OADX;AAEE,MAAA,SAAS,EAAEG,KAAK,CAACG,QAFnB;AAGE,MAAA,QAAQ,EAAEJ,QAHZ;AAIE,MAAA,IAAI,EAAC;AAJP,MAFF;AAAA,IADF;AAWD;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AACA,MAAMK,cAAc,GAAG,mBAAO,UAAP,EAAmB,CACxC,UADwC,EAExC,WAFwC,EAGxC,OAHwC,CAAnB,EAIpBC,YAJoB,EAINT,QAJM,CAAvB;AAMA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACAA,QAAQ,CAACU,SAAT,GAAqB;AACnBT,EAAAA,OAAO,EAAEU,mBAAGC,IADO;AAEnBV,EAAAA,KAAK,EAAES,mBAAGE,MAFS;AAGnBV,EAAAA,QAAQ,EAAEQ,mBAAGG,IAHM;AAInBV,EAAAA,KAAK,EAAEI,cAAc,CAACO,SAAf,CAAyBC;AAJb,CAArB;AAOAhB,QAAQ,CAACiB,YAAT,GAAwB;AACtBhB,EAAAA,OAAO,EAAEK,SADa;AAEtBJ,EAAAA,KAAK,EAAEI,SAFe;AAGtBH,EAAAA,QAAQ,EAAEG;AAHY,CAAxB;eAMeE,c","sourcesContent":["import PT from 'prop-types';\n\nimport { themed } from 'utils';\n\nimport defaultTheme from './theme.scss';\n\nfunction Checkbox({\n checked,\n label,\n onChange,\n theme,\n}) {\n return (\n <div className={theme.container}>\n { label === undefined ? null : <p className={theme.label}>{label}</p> }\n <input\n checked={checked}\n className={theme.checkbox}\n onChange={onChange}\n type=\"checkbox\"\n />\n </div>\n );\n}\n\n/**\n * @category Components\n * @typedef {object} CheckboxTheme {@link Checkbox} component theme: a map of\n * CSS classes to append to its elements:\n * @prop {string} [checkbox] to the underlying checkbox `<input>` element.\n * @prop {string} [container] to the root checkbox element.\n * @prop {string} [label] to the checkbox label element.\n */\nconst ThemedCheckbox = themed('Checkbox', [\n 'checkbox',\n 'container',\n 'label',\n], defaultTheme)(Checkbox);\n\n/**\n * @category Components\n * @func Checkbox\n * @desc\n * ```js\n * import { Checkbox } from '@dr.pogodin/react-utils';\n * ```\n * The `<Checkbox>` component implements themeable checkboxes.\n * @param {object} [props] Component properties.\n * @param {boolean} [props.checked] Checkbox value.\n * @param {string} [props.label] Checkbox label.\n * @param {function} [props.onChange] State change handler.\n * @param {CheckboxTheme} [props.theme] _Ad hoc_ theme.\n * @param {...any} [props....]\n * [Other properties of themeable components](https://www.npmjs.com/package/@dr.pogodin/react-themes#themed-component-properties).\n */\nCheckbox.propTypes = {\n checked: PT.bool,\n label: PT.string,\n onChange: PT.func,\n theme: ThemedCheckbox.themeType.isRequired,\n};\n\nCheckbox.defaultProps = {\n checked: undefined,\n label: undefined,\n onChange: undefined,\n};\n\nexport default ThemedCheckbox;\n"],"file":"index.js"}
1
+ {"version":3,"sources":["../../../../../src/shared/components/Checkbox/index.jsx"],"names":["Checkbox","checked","label","onChange","theme","container","undefined","checkbox","ThemedCheckbox","defaultTheme","propTypes","PT","bool","string","func","themeType","isRequired","defaultProps"],"mappings":";;;;;;;;;AAAA;;AAEA;;;;;;;;;;;;;AAIA,SAASA,QAAT,CAAkB;AAChBC,EAAAA,OADgB;AAEhBC,EAAAA,KAFgB;AAGhBC,EAAAA,QAHgB;AAIhBC,EAAAA;AAJgB,CAAlB,EAKG;AACD,sBACE;AAAK,IAAA,SAAS,EAAEA,KAAK,CAACC,SAAtB;AAAA,eACIH,KAAK,KAAKI,SAAV,GAAsB,IAAtB,gBAA6B;AAAG,MAAA,SAAS,EAAEF,KAAK,CAACF,KAApB;AAAA,gBAA4BA;AAA5B,MADjC,eAEE;AACE,MAAA,OAAO,EAAED,OADX;AAEE,MAAA,SAAS,EAAEG,KAAK,CAACG,QAFnB;AAGE,MAAA,QAAQ,EAAEJ,QAHZ;AAIE,MAAA,IAAI,EAAC;AAJP,MAFF;AAAA,IADF;AAWD;AAED;AACA;AACA;AACA;AACA;AACA;AACA;;;AACA,MAAMK,cAAc,GAAG,mBAAO,UAAP,EAAmB,CACxC,UADwC,EAExC,WAFwC,EAGxC,OAHwC,CAAnB,EAIpBC,YAJoB,EAINT,QAJM,CAAvB;AAMA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACAA,QAAQ,CAACU,SAAT,GAAqB;AACnBT,EAAAA,OAAO,EAAEU,mBAAGC,IADO;AAEnBV,EAAAA,KAAK,EAAES,mBAAGE,MAFS;AAGnBV,EAAAA,QAAQ,EAAEQ,mBAAGG,IAHM;AAInBV,EAAAA,KAAK,EAAEI,cAAc,CAACO,SAAf,CAAyBC;AAJb,CAArB;AAOAhB,QAAQ,CAACiB,YAAT,GAAwB;AACtBhB,EAAAA,OAAO,EAAEK,SADa;AAEtBJ,EAAAA,KAAK,EAAEI,SAFe;AAGtBH,EAAAA,QAAQ,EAAEG;AAHY,CAAxB;eAMeE,c","sourcesContent":["import PT from 'prop-types';\n\nimport { themed } from 'utils';\n\nimport defaultTheme from './theme.scss';\n\nfunction Checkbox({\n checked,\n label,\n onChange,\n theme,\n}) {\n return (\n <div className={theme.container}>\n { label === undefined ? null : <p className={theme.label}>{label}</p> }\n <input\n checked={checked}\n className={theme.checkbox}\n onChange={onChange}\n type=\"checkbox\"\n />\n </div>\n );\n}\n\n/**\n * Checkbox component theme: a map of\n * CSS classes to append to its elements:\n * @prop {string} [checkbox] to the underlying checkbox `<input>` element.\n * @prop {string} [container] to the root checkbox element.\n * @prop {string} [label] to the checkbox label element.\n */\nconst ThemedCheckbox = themed('Checkbox', [\n 'checkbox',\n 'container',\n 'label',\n], defaultTheme)(Checkbox);\n\n/**\n * The `<Checkbox>` component implements themeable checkboxes.\n * @param {object} [props] Component properties.\n * @param {boolean} [props.checked] Checkbox value.\n * @param {string} [props.label] Checkbox label.\n * @param {function} [props.onChange] State change handler.\n * @param {CheckboxTheme} [props.theme] _Ad hoc_ theme.\n * @param {...any} [props....]\n * [Other properties of themeable components](https://www.npmjs.com/package/@dr.pogodin/react-themes#themed-component-properties).\n */\nCheckbox.propTypes = {\n checked: PT.bool,\n label: PT.string,\n onChange: PT.func,\n theme: ThemedCheckbox.themeType.isRequired,\n};\n\nCheckbox.defaultProps = {\n checked: undefined,\n label: undefined,\n onChange: undefined,\n};\n\nexport default ThemedCheckbox;\n"],"file":"index.js"}
@@ -11,72 +11,15 @@ var _utils = require("../../utils");
11
11
 
12
12
  var _ClientSide = _interopRequireDefault(require("./ClientSide"));
13
13
 
14
- /**
15
- * @category Components
16
- * @func CodeSplit
17
- * @desc
18
- * ```js
19
- * import { CodeSplit } from '@dr.pogodin/react-utils';
20
- * ```
21
- * The `<CodeSplit>` component implements separation of an app part into
22
- * separate code & style chunks (thus, allowing to split compiled app bundle
23
- * into smaller lazy-loaded pieces).
24
- * @param {object} props Component properties.
25
- * @param {string} props.chunkName Unique chunk name.
26
- * @param {function} props.getComponentAsync Asynchronous function which
27
- * resolves to the component to render in place of the `<CodeSplit>`
28
- * (_i.e._ the component which we are splitting into a separate chunk),
29
- * and uses dynamic `import()` with Webpack's
30
- * [webpackChunkName](https://webpack.js.org/api/module-methods/#magic-comments) magic
31
- * comment stating the same chunk name, as was specified via the `chunkName`
32
- * property above.
33
- * @param {function} [props.getComponentServer] A synchronous version of
34
- * `getComponentAsync()` to be used during server-side rendering. If not
35
- * provided, the server-side code will fallback to the asynchronous
36
- * `getComponentAsync()`, which is sub-optimal. If provided, it will be called
37
- * with a special {@link resolveRequire} function passed in as the only
38
- * argument, which should be used to correctly resolve & require necessary
39
- * modules, without Webpack being able to detect it and thus bundle them
40
- * into client-side code (also see the example below).
41
- * @param {function} [props.placeholder] Placeholder React component to render
42
- * while the code for actual splitted component is being loaded.
43
- * @param {...any} [props....] Any other properties are passed as is into
44
- * the splitted component.
45
- * @example
46
- * // Assume <SampleComponent> is a React sub-tree we want to split into
47
- * // a stand-alone chunk. To achieve it, we use <CodeSplit> to declare
48
- * // an auxiliary <WrappedSampleComponent>, which we'll use everywhere
49
- * // in the code instead of <SampleComponent>. In result <SampleComponent>,
50
- * // and any other components in its sub-tree, not required directly in
51
- * // other chunks, will be placed into a dedicated chunk.
52
- *
53
- * // WrappedSampleComponent.jsx
54
- * import { CodeSplit, webpack } from '@dr.pogodin/react-utils';
55
- *
56
- * export default function WrappedSampleComponent(props) {
57
- * return (
58
- * <CodeSplit
59
- * chunkName="sample-component"
60
- * getComponentAsync={
61
- * // NOTE: Use the normal comment block opening and closing at
62
- * // the next line instead of / * and * / (whitespaces between
63
- * // start and slash had to be added due to limitations of our
64
- * // documentation setup).
65
- * () => import(/ * webpackChunkName: 'sample-component' * / 'path/to/SampleComponent')
66
- * }
67
- * getComponentServer={
68
- * // NOTE: You cannot just use the standard require() here, as it would
69
- * // cause Webpack to bundle in required module into the current chunk,
70
- * // instead of the split one. Thus, this workaround.
71
- * (resolveRequire) => resolveRequire(__dirname, 'path/to/SampleComponent');
72
- * }
73
- * placeholder={() => <div>Optional Placeholder</div>}
74
- * {...props}
75
- * />
76
- * );
77
- * }
78
- */
79
- var _default = _utils.isomorphy.IS_SERVER_SIDE ? _utils.webpack.requireWeak(`${__dirname}/ServerSide`) : _ClientSide.default;
14
+ let Component; // eslint-disable-line import/no-mutable-exports
80
15
 
16
+ try {
17
+ Component = _utils.isomorphy.IS_SERVER_SIDE && _utils.webpack.requireWeak(`${__dirname}/ServerSide`);
18
+ } catch (error) {
19
+ Component = undefined;
20
+ }
21
+
22
+ if (!Component) Component = _ClientSide.default;
23
+ var _default = Component;
81
24
  exports.default = _default;
82
25
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../src/shared/components/CodeSplit/index.js"],"names":["isomorphy","IS_SERVER_SIDE","webpack","requireWeak","__dirname","ClientSide"],"mappings":";;;;;;;;;AAkEA;;AAEA;;AApEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;eAMeA,iBAAUC,cAAV,GACXC,eAAQC,WAAR,CAAqB,GAAEC,SAAU,aAAjC,CADW,GACsCC,mB","sourcesContent":["/**\n * @category Components\n * @func CodeSplit\n * @desc\n * ```js\n * import { CodeSplit } from '@dr.pogodin/react-utils';\n * ```\n * The `<CodeSplit>` component implements separation of an app part into\n * separate code & style chunks (thus, allowing to split compiled app bundle\n * into smaller lazy-loaded pieces).\n * @param {object} props Component properties.\n * @param {string} props.chunkName Unique chunk name.\n * @param {function} props.getComponentAsync Asynchronous function which\n * resolves to the component to render in place of the `<CodeSplit>`\n * (_i.e._ the component which we are splitting into a separate chunk),\n * and uses dynamic `import()` with Webpack's\n * [webpackChunkName](https://webpack.js.org/api/module-methods/#magic-comments) magic\n * comment stating the same chunk name, as was specified via the `chunkName`\n * property above.\n * @param {function} [props.getComponentServer] A synchronous version of\n * `getComponentAsync()` to be used during server-side rendering. If not\n * provided, the server-side code will fallback to the asynchronous\n * `getComponentAsync()`, which is sub-optimal. If provided, it will be called\n * with a special {@link resolveRequire} function passed in as the only\n * argument, which should be used to correctly resolve & require necessary\n * modules, without Webpack being able to detect it and thus bundle them\n * into client-side code (also see the example below).\n * @param {function} [props.placeholder] Placeholder React component to render\n * while the code for actual splitted component is being loaded.\n * @param {...any} [props....] Any other properties are passed as is into\n * the splitted component.\n * @example\n * // Assume <SampleComponent> is a React sub-tree we want to split into\n * // a stand-alone chunk. To achieve it, we use <CodeSplit> to declare\n * // an auxiliary <WrappedSampleComponent>, which we'll use everywhere\n * // in the code instead of <SampleComponent>. In result <SampleComponent>,\n * // and any other components in its sub-tree, not required directly in\n * // other chunks, will be placed into a dedicated chunk.\n *\n * // WrappedSampleComponent.jsx\n * import { CodeSplit, webpack } from '@dr.pogodin/react-utils';\n *\n * export default function WrappedSampleComponent(props) {\n * return (\n * <CodeSplit\n * chunkName=\"sample-component\"\n * getComponentAsync={\n * // NOTE: Use the normal comment block opening and closing at\n * // the next line instead of / * and * / (whitespaces between\n * // start and slash had to be added due to limitations of our\n * // documentation setup).\n * () => import(/ * webpackChunkName: 'sample-component' * / 'path/to/SampleComponent')\n * }\n * getComponentServer={\n * // NOTE: You cannot just use the standard require() here, as it would\n * // cause Webpack to bundle in required module into the current chunk,\n * // instead of the split one. Thus, this workaround.\n * (resolveRequire) => resolveRequire(__dirname, 'path/to/SampleComponent');\n * }\n * placeholder={() => <div>Optional Placeholder</div>}\n * {...props}\n * />\n * );\n * }\n */\n\nimport { isomorphy, webpack } from 'utils';\n\nimport ClientSide from './ClientSide';\n\nexport default isomorphy.IS_SERVER_SIDE\n ? webpack.requireWeak(`${__dirname}/ServerSide`) : ClientSide;\n"],"file":"index.js"}
1
+ {"version":3,"sources":["../../../../../src/shared/components/CodeSplit/index.js"],"names":["Component","isomorphy","IS_SERVER_SIDE","webpack","requireWeak","__dirname","error","undefined","ClientSide"],"mappings":";;;;;;;;;AAAA;;AAEA;;AAEA,IAAIA,SAAJ,C,CAAe;;AAEf,IAAI;AACFA,EAAAA,SAAS,GAAGC,iBAAUC,cAAV,IACPC,eAAQC,WAAR,CAAqB,GAAEC,SAAU,aAAjC,CADL;AAED,CAHD,CAGE,OAAOC,KAAP,EAAc;AACdN,EAAAA,SAAS,GAAGO,SAAZ;AACD;;AAED,IAAI,CAACP,SAAL,EAAgBA,SAAS,GAAGQ,mBAAZ;eAEDR,S","sourcesContent":["import { isomorphy, webpack } from 'utils';\n\nimport ClientSide from './ClientSide';\n\nlet Component; // eslint-disable-line import/no-mutable-exports\n\ntry {\n Component = isomorphy.IS_SERVER_SIDE\n && webpack.requireWeak(`${__dirname}/ServerSide`);\n} catch (error) {\n Component = undefined;\n}\n\nif (!Component) Component = ClientSide;\n\nexport default Component;\n"],"file":"index.js"}
@@ -16,31 +16,17 @@ var _utils = require("../../utils");
16
16
  var _jsxRuntime = require("react/jsx-runtime");
17
17
 
18
18
  var defaultTheme = {
19
- "context": "-dr-pogodin-react-utils___src-shared-components-Dropdown-theme___context___36FjKe",
20
- "ad": "-dr-pogodin-react-utils___src-shared-components-Dropdown-theme___ad___1tuabC",
21
- "hoc": "-dr-pogodin-react-utils___src-shared-components-Dropdown-theme___hoc___IXTRRj",
22
- "arrow": "-dr-pogodin-react-utils___src-shared-components-Dropdown-theme___arrow___zk_X_t",
23
- "container": "-dr-pogodin-react-utils___src-shared-components-Dropdown-theme___container___2pSA6T",
24
- "label": "-dr-pogodin-react-utils___src-shared-components-Dropdown-theme___label___22Z9dt",
25
- "option": "-dr-pogodin-react-utils___src-shared-components-Dropdown-theme___option___3VERnT",
26
- "hiddenOption": "-dr-pogodin-react-utils___src-shared-components-Dropdown-theme___hiddenOption___24WdmW",
27
- "select": "-dr-pogodin-react-utils___src-shared-components-Dropdown-theme___select___3plxWK"
19
+ "context": "-dr-pogodin-react-utils___src-shared-components-Dropdown-theme___context___1Q72zU",
20
+ "ad": "-dr-pogodin-react-utils___src-shared-components-Dropdown-theme___ad___3NkITs",
21
+ "hoc": "-dr-pogodin-react-utils___src-shared-components-Dropdown-theme___hoc___2_yK-d",
22
+ "arrow": "-dr-pogodin-react-utils___src-shared-components-Dropdown-theme___arrow___3rmWiD",
23
+ "container": "-dr-pogodin-react-utils___src-shared-components-Dropdown-theme___container___2boEEf",
24
+ "label": "-dr-pogodin-react-utils___src-shared-components-Dropdown-theme___label___ViWitu",
25
+ "option": "-dr-pogodin-react-utils___src-shared-components-Dropdown-theme___option___1KVBKB",
26
+ "hiddenOption": "-dr-pogodin-react-utils___src-shared-components-Dropdown-theme___hiddenOption___2ydMjo",
27
+ "select": "-dr-pogodin-react-utils___src-shared-components-Dropdown-theme___select___sJDuEV"
28
28
  };
29
29
  /**
30
- * @category Components
31
- * @typedef {object} DropdownOption Represents a single option inside
32
- * {@link Dropdown} component.
33
- * @prop {string} [name] Option name (displayed in UI). If not given,
34
- * the `value` is used as the name.
35
- * @prop {string} value Option value key (used inside the code).
36
- */
37
-
38
- /**
39
- * @category Components
40
- * @desc
41
- * ```js
42
- * import { Dropdown } from '@dr.pogodin/react-utils';
43
- * ```
44
30
  * Implements a themeable dropdown list. Internally it is rendered with help of
45
31
  * the standard HTML `<select>` element, thus the styling support is somewhat
46
32
  * limited.
@@ -104,18 +90,6 @@ function Dropdown({
104
90
  })]
105
91
  });
106
92
  }
107
- /**
108
- * @category Components
109
- * @typedef {object} DropdownTheme {@link Dropdown} component theme.
110
- * @prop {string} [arrow] Class name for arrow element.
111
- * @prop {string} [container] Class name for the root dropdown element.
112
- * @prop {string} [hiddenOption] Class name for the "hidden option" element,
113
- * which is rendered when dropdown value is undefined.
114
- * @prop {string} [label] Class name for label element.
115
- * @prop {string} [option] Class name for each option item element.
116
- * @prop {string} [select] Class name for the underlying `<select>` element.
117
- */
118
-
119
93
 
120
94
  const ThemedDropdown = (0, _utils.themed)('Dropdown', ['arrow', 'container', 'hiddenOption', 'label', 'option', 'select'], defaultTheme)(Dropdown);
121
95
  Dropdown.propTypes = {
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../src/shared/components/Dropdown/index.jsx"],"names":["Dropdown","filter","label","onChange","options","theme","value","optionArray","hiddenOption","i","length","op","push","option","name","undefined","container","select","arrow","ThemedDropdown","defaultTheme","propTypes","PT","func","string","arrayOf","oneOfType","shape","node","isRequired","themeType","defaultProps"],"mappings":";;;;;;;;;AAAA;;AACA;;AAEA;;;;;;;;;;;;;;;AAIA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,SAASA,QAAT,CAAkB;AAChBC,EAAAA,MADgB;AAEhBC,EAAAA,KAFgB;AAGhBC,E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;AACA;AACA;AACA;;;AACA,MAAMC,cAAc,GAAG,mBAAO,UAAP,EAAmB,CACxC,OADwC,EAExC,WAFwC,EAGxC,cAHwC,EAIxC,OAJwC,EAKxC,QALwC,EAMxC,QANwC,CAAnB,EAOpBC,YAPoB,EAONpB,QAPM,CAAvB;AASAA,QAAQ,CAACqB,SAAT,GAAqB;AACnBpB,EAAAA,MAAM,EAAEqB,mBAAGC,IADQ;AAEnBrB,EAAAA,KAAK,EAAEoB,mBAAGE,MAFS;AAGnBrB,EAAAA,QAAQ,EAAEmB,mBAAGC,IAHM;AAInBnB,EAAAA,OAAO,EAAEkB,mBAAGG,OAAH,CACPH,mBAAGI,SAAH,CAAa,CACXJ,mBAAGK,KAAH,CAAS;AACPb,IAAAA,IAAI,EAAEQ,mBAAGM,IADF;AAEPtB,IAAAA,KAAK,EAAEgB,mBAAGE,MAAH,CAAUK;AAFV,GAAT,CADW,EAKXP,mBAAGE,MALQ,CAAb,EAMGK,UAPI,CAJU;AAanBxB,EAAAA,KAAK,EAAEc,cAAc,CAACW,SAAf,CAAyBD,UAbb;AAcnBvB,EAAAA,KAAK,EAAEgB,mBAAGE;AAdS,CAArB;AAiBAxB,QAAQ,CAAC+B,YAAT,GAAwB;AACtB9B,EAAAA,MAAM,EAAEc,SADc;AAEtBb,EAAAA,KAAK,EAAEa,SAFe;AAGtBZ,EAAAA,QAAQ,EAAEY,SAHY;AAItBX,EAAAA,OAAO,EAAE,EAJa;AAKtBE,EAAAA,KAAK,EAAES;AALe,CAAxB;eAQeI,c","sourcesContent":["import { isString } from 'lodash';\nimport PT from 'prop-types';\n\nimport { themed } from 'utils';\n\nimport defaultTheme from './theme.scss';\n\n/**\n * @category Components\n * @typedef {object} DropdownOption Represents a single option inside\n * {@link Dropdown} component.\n * @prop {string} [name] Option name (displayed in UI). If not given,\n * the `value` is used as the name.\n * @prop {string} value Option value key (used inside the code).\n */\n\n/**\n * @category Components\n * @desc\n * ```js\n * import { Dropdown } from '@dr.pogodin/react-utils';\n * ```\n * Implements a themeable dropdown list. Internally it is rendered with help of\n * the standard HTML `<select>` element, thus the styling support is somewhat\n * limited.\n * @param {object} [props] Component properties.\n * @param {function} [props.filter] Options filter function. If provided, only\n * those elements of `options` list will be used by the dropdown, for which this\n * filter returns `true`.\n * @param {string} [props.label] Dropdown label.\n * @param {string} [props.onChange] Selection event handler.\n * @param {DropdownOption[]|string[]} [props.options=[]] Array of dropdown\n * options. For string elements the option value and name will be the same.\n * It is allowed to mix DropdownOption and string elements in the same option\n * list.\n * @param {DropdownTheme} [props.theme] _Ad hoc_ theme.\n * @param {string} [props.value] Currently selected value.\n * @param {...any} [props....]\n * [Other theming properties](https://www.npmjs.com/package/@dr.pogodin/react-themes#themed-component-properties)\n */\nfunction Dropdown({\n filter,\n label,\n onChange,\n options,\n theme,\n value,\n}) {\n const optionArray = [(\n <option\n className={theme.hiddenOption}\n key=\"__reactUtilsHiddenOption\"\n >\n &zwnj;\n </option>\n )];\n for (let i = 0; i < options.length; ++i) {\n let op = options[i];\n if (!filter || filter(op)) {\n if (isString(op)) op = { value: op };\n optionArray.push((\n <option className={theme.option} key={op.value} value={op.value}>\n {op.name === undefined ? op.value : op.name }\n </option>\n ));\n }\n }\n return (\n <div className={theme.container}>\n { label === undefined ? null : <p className={theme.label}>{label}</p> }\n <select\n className={theme.select}\n onChange={onChange}\n value={value}\n >\n {optionArray}\n </select>\n <div className={theme.arrow}>▼</div>\n </div>\n );\n}\n\n/**\n * @category Components\n * @typedef {object} DropdownTheme {@link Dropdown} component theme.\n * @prop {string} [arrow] Class name for arrow element.\n * @prop {string} [container] Class name for the root dropdown element.\n * @prop {string} [hiddenOption] Class name for the \"hidden option\" element,\n * which is rendered when dropdown value is undefined.\n * @prop {string} [label] Class name for label element.\n * @prop {string} [option] Class name for each option item element.\n * @prop {string} [select] Class name for the underlying `<select>` element.\n */\nconst ThemedDropdown = themed('Dropdown', [\n 'arrow',\n 'container',\n 'hiddenOption',\n 'label',\n 'option',\n 'select',\n], defaultTheme)(Dropdown);\n\nDropdown.propTypes = {\n filter: PT.func,\n label: PT.string,\n onChange: PT.func,\n options: PT.arrayOf(\n PT.oneOfType([\n PT.shape({\n name: PT.node,\n value: PT.string.isRequired,\n }),\n PT.string,\n ]).isRequired,\n ),\n theme: ThemedDropdown.themeType.isRequired,\n value: PT.string,\n};\n\nDropdown.defaultProps = {\n filter: undefined,\n label: undefined,\n onChange: undefined,\n options: [],\n value: undefined,\n};\n\nexport default ThemedDropdown;\n"],"file":"index.js"}
1
+ {"version":3,"sources":["../../../../../src/shared/components/Dropdown/index.jsx"],"names":["Dropdown","filter","label","onChange","options","theme","value","optionArray","hiddenOption","i","length","op","push","option","name","undefined","container","select","arrow","ThemedDropdown","defaultTheme","propTypes","PT","func","string","arrayOf","oneOfType","shape","node","isRequired","themeType","defaultProps"],"mappings":";;;;;;;;;AAAA;;AACA;;AAEA;;;;;;;;;;;;;;;AAIA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,SAASA,QAAT,CAAkB;AAChBC,EAAAA,MADgB;AAEhBC,EAAAA,KAFgB;AAGhBC,EAAAA,QAHgB;AAIhBC,EAAAA,OAJgB;AAKhBC,EAAAA,KALgB;AAMhBC,EAAAA;AANgB,CAAlB,EAOG;AACD,QAAMC,WAAW,GAAG,cAClB;AACE,IAAA,SAAS,EAAEF,KAAK,CAACG,YADnB;AAAA;AAAA,KAEM,0BAFN,CADkB,CAApB;;AAQA,OAAK,IAAIC,CAAC,GAAG,CAAb,EAAgBA,CAAC,GAAGL,OAAO,CAACM,MAA5B,EAAoC,EAAED,CAAtC,EAAyC;AACvC,QAAIE,EAAE,GAAGP,OAAO,CAACK,CAAD,CAAhB;;AACA,QAAI,CAACR,MAAD,IAAWA,MAAM,CAACU,EAAD,CAArB,EAA2B;AACzB,UAAI,sBAASA,EAAT,CAAJ,EAAkBA,EAAE,GAAG;AAAEL,QAAAA,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UK;AAFV,GAAT,CADW,EAKXP,mBAAGE,MALQ,CAAb,EAMGK,UAPI,CAJU;AAanBxB,EAAAA,KAAK,EAAEc,cAAc,CAACW,SAAf,CAAyBD,UAbb;AAcnBvB,EAAAA,KAAK,EAAEgB,mBAAGE;AAdS,CAArB;AAiBAxB,QAAQ,CAAC+B,YAAT,GAAwB;AACtB9B,EAAAA,MAAM,EAAEc,SADc;AAEtBb,EAAAA,KAAK,EAAEa,SAFe;AAGtBZ,EAAAA,QAAQ,EAAEY,SAHY;AAItBX,EAAAA,OAAO,EAAE,EAJa;AAKtBE,EAAAA,KAAK,EAAES;AALe,CAAxB;eAQeI,c","sourcesContent":["import { isString } from 'lodash';\nimport PT from 'prop-types';\n\nimport { themed } from 'utils';\n\nimport defaultTheme from './theme.scss';\n\n/**\n * Implements a themeable dropdown list. Internally it is rendered with help of\n * the standard HTML `<select>` element, thus the styling support is somewhat\n * limited.\n * @param {object} [props] Component properties.\n * @param {function} [props.filter] Options filter function. If provided, only\n * those elements of `options` list will be used by the dropdown, for which this\n * filter returns `true`.\n * @param {string} [props.label] Dropdown label.\n * @param {string} [props.onChange] Selection event handler.\n * @param {DropdownOption[]|string[]} [props.options=[]] Array of dropdown\n * options. For string elements the option value and name will be the same.\n * It is allowed to mix DropdownOption and string elements in the same option\n * list.\n * @param {DropdownTheme} [props.theme] _Ad hoc_ theme.\n * @param {string} [props.value] Currently selected value.\n * @param {...any} [props....]\n * [Other theming properties](https://www.npmjs.com/package/@dr.pogodin/react-themes#themed-component-properties)\n */\nfunction Dropdown({\n filter,\n label,\n onChange,\n options,\n theme,\n value,\n}) {\n const optionArray = [(\n <option\n className={theme.hiddenOption}\n key=\"__reactUtilsHiddenOption\"\n >\n &zwnj;\n </option>\n )];\n for (let i = 0; i < options.length; ++i) {\n let op = options[i];\n if (!filter || filter(op)) {\n if (isString(op)) op = { value: op };\n optionArray.push((\n <option className={theme.option} key={op.value} value={op.value}>\n {op.name === undefined ? op.value : op.name }\n </option>\n ));\n }\n }\n return (\n <div className={theme.container}>\n { label === undefined ? null : <p className={theme.label}>{label}</p> }\n <select\n className={theme.select}\n onChange={onChange}\n value={value}\n >\n {optionArray}\n </select>\n <div className={theme.arrow}>▼</div>\n </div>\n );\n}\n\nconst ThemedDropdown = themed('Dropdown', [\n 'arrow',\n 'container',\n 'hiddenOption',\n 'label',\n 'option',\n 'select',\n], defaultTheme)(Dropdown);\n\nDropdown.propTypes = {\n filter: PT.func,\n label: PT.string,\n onChange: PT.func,\n options: PT.arrayOf(\n PT.oneOfType([\n PT.shape({\n name: PT.node,\n value: PT.string.isRequired,\n }),\n PT.string,\n ]).isRequired,\n ),\n theme: ThemedDropdown.themeType.isRequired,\n value: PT.string,\n};\n\nDropdown.defaultProps = {\n filter: undefined,\n label: undefined,\n onChange: undefined,\n options: [],\n value: undefined,\n};\n\nexport default ThemedDropdown;\n"],"file":"index.js"}
@@ -16,34 +16,12 @@ var _jsxRuntime = require("react/jsx-runtime");
16
16
  /* global window */
17
17
 
18
18
  /**
19
- * @category Components
20
- * @func Link
21
- * @desc
22
- * ```js
23
- * import { Link } from '@dr.pogodin/react-utils';
24
- * ```
25
19
  * The `<Link>` component, and almost identical `<NavLink>` component, are
26
20
  * auxiliary wrappers around
27
21
  * [React Router](https://github.com/ReactTraining/react-router)'s
28
22
  * `<Link>` and `<NavLink>` components; they help to handle external and
29
23
  * internal links in uniform manner.
30
24
  *
31
- * The `<Link>` (`<NavLink>`) component is rendered as a simple `<a>` element
32
- * when:
33
- * 1. The link is absolute, i.e. starts with `http://` or `https://`.
34
- * 2. The link points to an anchor, i.e. starts with `#` symbol.
35
- * 3. The link should be opened in a new tab (`openNewTab` property).
36
- * 4. Explicitly opted by the `enforceA` property.
37
- *
38
- * Otherwise it is rendered as the usual React Router's `<Link>` (`<NavLink>`).
39
- * Also in this case links to the current page scroll the page to its top when
40
- * clicked.
41
- *
42
- * Both `<Link>` and `<NavLink>` support all properties of the underlying React
43
- * Router's components, along with some additional props:
44
- *
45
- * **Children:** Child components are rendered as link's content.
46
- *
47
25
  * @param {object} [props] Component properties.
48
26
  * @param {string} [props.className] CSS classes to apply to the link.
49
27
  * @param {boolean} [props.disabled] Disables the link.
@@ -98,7 +76,7 @@ function GenericLink({
98
76
  * - It is anchor link (starts with #). */
99
77
  if (disabled || enforceA || openNewTab || to.match(/^(#|(https?|mailto):)/)) {
100
78
  return /*#__PURE__*/(0, _jsxRuntime.jsx)("a", {
101
- className: (className ? className + " " : "") + "-dr-pogodin-react-utils___src-shared-components-GenericLink-style___link___1j1FQ2",
79
+ className: (className ? className + " " : "") + "-dr-pogodin-react-utils___src-shared-components-GenericLink-style___link___2InLXV",
102
80
  disabled: disabled,
103
81
  href: to,
104
82
  onClick: disabled ? e => e.preventDefault() : onClick,
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../src/shared/components/GenericLink/index.jsx"],"names":["GenericLink","children","className","disabled","enforceA","keepScrollPosition","onClick","onMouseDown","openNewTab","replace","routerLinkType","to","rest","match","e","preventDefault","window","scroll","defaultProps","propTypes","PT","node","string","bool","func","elementType","isRequired","oneOfType","object"],"mappings":";;;;;;;;;AAEA;;AACA;;;;AAHA;;AAOA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACe,SAASA,WAAT,CAAqB;AAClCC,EAAAA,QADkC;AAElCC,EAAAA,SAFkC;AAGlCC,EAAAA,QAHkC;AAIlCC,EAAAA,QAJkC;AAKlCC,EAAAA,kBALkC;AAMlCC,EAAAA,OANkC;AAOlCC,EAAAA,WAPkC;AAQlCC,EAAAA,UARkC;AAS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;AAKzBC,EAAAA,kBAAkB,EAAE,KALK;AAMzBC,EAAAA,OAAO,EAAE,IANgB;AAOzBC,EAAAA,WAAW,EAAE,IAPY;AAQzBC,EAAAA,UAAU,EAAE,KARa;AASzBC,EAAAA,OAAO,EAAE,KATgB;AAUzBE,EAAAA,EAAE,EAAE;AAVqB,CAA3B;AAaAX,WAAW,CAACmB,SAAZ,GAAwB;AACtBlB,EAAAA,QAAQ,EAAEmB,mBAAGC,IADS;AAEtBnB,EAAAA,SAAS,EAAEkB,mBAAGE,MAFQ;AAGtBnB,EAAAA,QAAQ,EAAEiB,mBAAGG,IAHS;AAItBnB,EAAAA,QAAQ,EAAEgB,mBAAGG,IAJS;AAKtBlB,EAAAA,kBAAkB,EAAEe,mBAAGG,IALD;AAMtBjB,EAAAA,OAAO,EAAEc,mBAAGI,IANU;AAOtBjB,EAAAA,WAAW,EAAEa,mBAAGI,IAPM;AAQtBhB,EAAAA,UAAU,EAAEY,mBAAGG,IARO;AAStBd,EAAAA,OAAO,EAAEW,mBAAGG,IATU;AAUtBb,EAAAA,cAAc,EAAEU,mBAAGK,WAAH,CAAeC,UAVT;AAWtBf,EAAAA,EAAE,EAAES,mBAAGO,SAAH,CAAa,CAACP,mBAAGQ,MAAJ,EAAYR,mBAAGE,MAAf,CAAb;AAXkB,CAAxB","sourcesContent":["/* global window */\n\nimport PT from 'prop-types';\nimport { createElement } from 'react';\n\nimport './style.scss';\n\n/**\n * @category Components\n * @func Link\n * @desc\n * ```js\n * import { Link } from '@dr.pogodin/react-utils';\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 * The `<Link>` (`<NavLink>`) component is rendered as a simple `<a>` element\n * when:\n * 1. The link is absolute, i.e. starts with `http://` or `https://`.\n * 2. The link points to an anchor, i.e. starts with `#` symbol.\n * 3. The link should be opened in a new tab (`openNewTab` property).\n * 4. Explicitly opted by the `enforceA` property.\n *\n * Otherwise it is rendered as the usual React Router's `<Link>` (`<NavLink>`).\n * Also in this case links to the current page scroll the page to its top when\n * clicked.\n *\n * Both `<Link>` and `<NavLink>` support all properties of the underlying React\n * Router's components, along with some additional props:\n *\n * **Children:** Child components are rendered as link's content.\n *\n * @param {object} [props] Component properties.\n * @param {string} [props.className] CSS classes to apply to the link.\n * @param {boolean} [props.disabled] Disables the link.\n * @param {boolean} [props.enforceA] `true` enforces rendering of the link as\n * a simple `<a>` element.\n * @param {boolean} [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 {function} [props.onClick] Event handler to trigger upon click.\n * @param {function} [props.onMouseDown] Event handler to trigger on MouseDown\n * event.\n * @param {boolean} [props.openNewTab] If `true` the link opens in a new tab.\n * @param {boolean} [props.replace] When `true`, the link will replace current\n * entry in the history stack instead of adding a new one.\n * @param {string} [props.to] Link URL.\n * @param {string} [props.activeClassName] **`<NavLink>`** only: CSS class(es)\n * to apply to rendered link when it is active.\n * @param {string} [props.activeStyle] **`<NavLink>`** only: CSS styles\n * to apply to the rendered link when it is active.\n * @param {boolean} [props.exact] **`<NavLink>`** only: if `true`, the active\n * class/style will only be applied if the location is matched exactly.\n * @param {function} [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 {object} [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 {boolean} [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 */\nexport default function GenericLink({\n children,\n className,\n disabled,\n enforceA,\n keepScrollPosition,\n onClick,\n onMouseDown,\n openNewTab,\n replace,\n routerLinkType,\n to,\n ...rest\n}) {\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.match(/^(#|(https?|mailto):)/)) {\n return (\n <a\n className={className}\n disabled={disabled}\n href={to}\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 /* Otherwise we render the link as React Router's Link or NavLink element. */\n return createElement(routerLinkType, {\n className,\n disabled,\n onMouseDown,\n replace,\n to,\n onClick: (e) => {\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,\n }, children);\n}\n\nGenericLink.defaultProps = {\n children: null,\n className: null,\n disabled: false,\n enforceA: false,\n keepScrollPosition: false,\n onClick: null,\n onMouseDown: null,\n openNewTab: false,\n replace: false,\n to: '',\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"],"file":"index.js"}
1
+ {"version":3,"sources":["../../../../../src/shared/components/GenericLink/index.jsx"],"names":["GenericLink","children","className","disabled","enforceA","keepScrollPosition","onClick","onMouseDown","openNewTab","replace","routerLinkType","to","rest","match","e","preventDefault","window","scroll","defaultProps","propTypes","PT","node","string","bool","func","elementType","isRequired","oneOfType","object"],"mappings":";;;;;;;;;AAEA;;AACA;;;;AAHA;;AAOA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;A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;AACA,UAAI,CAACT,kBAAL,EAAyBW,MAAM,CAACC,MAAP,CAAc,CAAd,EAAiB,CAAjB;AAC1B,KAZkC;AAanC,OAAGL;AAbgC,GAA9B,EAcJX,QAdI,CAAP;AAeD;;AAEDD,WAAW,CAACkB,YAAZ,GAA2B;AACzBjB,EAAAA,QAAQ,EAAE,IADe;AAEzBC,EAAAA,SAAS,EAAE,IAFc;AAGzBC,EAAAA,QAAQ,EAAE,KAHe;AAIzBC,EAAAA,QAAQ,EAAE,KAJe;AAKzBC,EAAAA,kBAAkB,EAAE,KALK;AAMzBC,EAAAA,OAAO,EAAE,IANgB;AAOzBC,EAAAA,WAAW,EAAE,IAPY;AAQzBC,EAAAA,UAAU,EAAE,KARa;AASzBC,EAAAA,OAAO,EAAE,KATgB;AAUzBE,EAAAA,EAAE,EAAE;AAVqB,CAA3B;AAaAX,WAAW,CAACmB,SAAZ,GAAwB;AACtBlB,EAAAA,QAAQ,EAAEmB,mBAAGC,IADS;AAEtBnB,EAAAA,SAAS,EAAEkB,mBAAGE,MAFQ;AAGtBnB,EAAAA,QAAQ,EAAEiB,mBAAGG,IAHS;AAItBnB,EAAAA,QAAQ,EAAEgB,mBAAGG,IAJS;AAKtBlB,EAAAA,kBAAkB,EAAEe,mBAAGG,IALD;AAMtBjB,EAAAA,OAAO,EAAEc,mBAAGI,IANU;AAOtBjB,EAAAA,WAAW,EAAEa,mBAAGI,IAPM;AAQtBhB,EAAAA,UAAU,EAAEY,mBAAGG,IARO;AAStBd,EAAAA,OAAO,EAAEW,mBAAGG,IATU;AAUtBb,EAAAA,cAAc,EAAEU,mBAAGK,WAAH,CAAeC,UAVT;AAWtBf,EAAAA,EAAE,EAAES,mBAAGO,SAAH,CAAa,CAACP,mBAAGQ,MAAJ,EAAYR,mBAAGE,MAAf,CAAb;AAXkB,CAAxB","sourcesContent":["/* global window */\n\nimport PT from 'prop-types';\nimport { createElement } from 'react';\n\nimport './style.scss';\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 {object} [props] Component properties.\n * @param {string} [props.className] CSS classes to apply to the link.\n * @param {boolean} [props.disabled] Disables the link.\n * @param {boolean} [props.enforceA] `true` enforces rendering of the link as\n * a simple `<a>` element.\n * @param {boolean} [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 {function} [props.onClick] Event handler to trigger upon click.\n * @param {function} [props.onMouseDown] Event handler to trigger on MouseDown\n * event.\n * @param {boolean} [props.openNewTab] If `true` the link opens in a new tab.\n * @param {boolean} [props.replace] When `true`, the link will replace current\n * entry in the history stack instead of adding a new one.\n * @param {string} [props.to] Link URL.\n * @param {string} [props.activeClassName] **`<NavLink>`** only: CSS class(es)\n * to apply to rendered link when it is active.\n * @param {string} [props.activeStyle] **`<NavLink>`** only: CSS styles\n * to apply to the rendered link when it is active.\n * @param {boolean} [props.exact] **`<NavLink>`** only: if `true`, the active\n * class/style will only be applied if the location is matched exactly.\n * @param {function} [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 {object} [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 {boolean} [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 */\nexport default function GenericLink({\n children,\n className,\n disabled,\n enforceA,\n keepScrollPosition,\n onClick,\n onMouseDown,\n openNewTab,\n replace,\n routerLinkType,\n to,\n ...rest\n}) {\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.match(/^(#|(https?|mailto):)/)) {\n return (\n <a\n className={className}\n disabled={disabled}\n href={to}\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 /* Otherwise we render the link as React Router's Link or NavLink element. */\n return createElement(routerLinkType, {\n className,\n disabled,\n onMouseDown,\n replace,\n to,\n onClick: (e) => {\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,\n }, children);\n}\n\nGenericLink.defaultProps = {\n children: null,\n className: null,\n disabled: false,\n enforceA: false,\n keepScrollPosition: false,\n onClick: null,\n onMouseDown: null,\n openNewTab: false,\n replace: false,\n to: '',\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"],"file":"index.js"}