@dr.pogodin/react-utils 1.53.1 → 1.54.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 (139) hide show
  1. package/build/development/client/index.js +2 -0
  2. package/build/development/client/index.js.map +1 -1
  3. package/build/development/index.js +2 -2
  4. package/build/development/index.js.map +1 -1
  5. package/build/development/shared/components/Button/index.js +149 -71
  6. package/build/development/shared/components/Button/index.js.map +1 -1
  7. package/build/development/shared/components/Checkbox/index.js +77 -24
  8. package/build/development/shared/components/Checkbox/index.js.map +1 -1
  9. package/build/development/shared/components/GenericLink/index.js +133 -54
  10. package/build/development/shared/components/GenericLink/index.js.map +1 -1
  11. package/build/development/shared/components/Input/index.js +168 -45
  12. package/build/development/shared/components/Input/index.js.map +1 -1
  13. package/build/development/shared/components/Link.js +23 -13
  14. package/build/development/shared/components/Link.js.map +1 -1
  15. package/build/development/shared/components/Modal/index.js +203 -87
  16. package/build/development/shared/components/Modal/index.js.map +1 -1
  17. package/build/development/shared/components/NavLink.js +16 -7
  18. package/build/development/shared/components/NavLink.js.map +1 -1
  19. package/build/development/shared/components/PageLayout/index.js +77 -15
  20. package/build/development/shared/components/PageLayout/index.js.map +1 -1
  21. package/build/development/shared/components/TextArea/index.js +169 -68
  22. package/build/development/shared/components/TextArea/index.js.map +1 -1
  23. package/build/development/shared/components/Throbber/index.js +51 -13
  24. package/build/development/shared/components/Throbber/index.js.map +1 -1
  25. package/build/development/shared/components/WithTooltip/Tooltip.js +73 -34
  26. package/build/development/shared/components/WithTooltip/Tooltip.js.map +1 -1
  27. package/build/development/shared/components/WithTooltip/index.js +19 -19
  28. package/build/development/shared/components/WithTooltip/index.js.map +1 -1
  29. package/build/development/shared/components/YouTubeVideo/index.js +66 -23
  30. package/build/development/shared/components/YouTubeVideo/index.js.map +1 -1
  31. package/build/development/shared/components/selectors/CustomDropdown/Options/index.js +104 -56
  32. package/build/development/shared/components/selectors/CustomDropdown/Options/index.js.map +1 -1
  33. package/build/development/shared/components/selectors/CustomDropdown/index.js +173 -75
  34. package/build/development/shared/components/selectors/CustomDropdown/index.js.map +1 -1
  35. package/build/development/shared/components/selectors/Switch/index.js +86 -36
  36. package/build/development/shared/components/selectors/Switch/index.js.map +1 -1
  37. package/build/development/shared/utils/globalState.js +2 -2
  38. package/build/development/shared/utils/globalState.js.map +1 -1
  39. package/build/development/shared/utils/index.js +1 -1
  40. package/build/development/shared/utils/index.js.map +1 -1
  41. package/build/development/shared/utils/splitComponent.js +125 -55
  42. package/build/development/shared/utils/splitComponent.js.map +1 -1
  43. package/build/development/shared/utils/time.js +55 -20
  44. package/build/development/shared/utils/time.js.map +1 -1
  45. package/build/production/client/index.js +2 -2
  46. package/build/production/client/index.js.map +1 -1
  47. package/build/production/index.js +1 -1
  48. package/build/production/index.js.map +1 -1
  49. package/build/production/shared/components/Button/index.js +2 -13
  50. package/build/production/shared/components/Button/index.js.map +1 -1
  51. package/build/production/shared/components/Checkbox/index.js +1 -1
  52. package/build/production/shared/components/Checkbox/index.js.map +1 -1
  53. package/build/production/shared/components/GenericLink/index.js +2 -15
  54. package/build/production/shared/components/GenericLink/index.js.map +1 -1
  55. package/build/production/shared/components/Input/index.js +2 -11
  56. package/build/production/shared/components/Input/index.js.map +1 -1
  57. package/build/production/shared/components/Link.js +2 -4
  58. package/build/production/shared/components/Link.js.map +1 -1
  59. package/build/production/shared/components/Modal/index.js +2 -10
  60. package/build/production/shared/components/Modal/index.js.map +1 -1
  61. package/build/production/shared/components/NavLink.js +1 -4
  62. package/build/production/shared/components/NavLink.js.map +1 -1
  63. package/build/production/shared/components/PageLayout/index.js +2 -2
  64. package/build/production/shared/components/PageLayout/index.js.map +1 -1
  65. package/build/production/shared/components/TextArea/index.js +1 -21
  66. package/build/production/shared/components/TextArea/index.js.map +1 -1
  67. package/build/production/shared/components/Throbber/index.js +2 -2
  68. package/build/production/shared/components/Throbber/index.js.map +1 -1
  69. package/build/production/shared/components/WithTooltip/Tooltip.js +2 -7
  70. package/build/production/shared/components/WithTooltip/Tooltip.js.map +1 -1
  71. package/build/production/shared/components/WithTooltip/index.js +3 -3
  72. package/build/production/shared/components/WithTooltip/index.js.map +1 -1
  73. package/build/production/shared/components/YouTubeVideo/index.js +2 -5
  74. package/build/production/shared/components/YouTubeVideo/index.js.map +1 -1
  75. package/build/production/shared/components/selectors/CustomDropdown/Options/index.js +1 -6
  76. package/build/production/shared/components/selectors/CustomDropdown/Options/index.js.map +1 -1
  77. package/build/production/shared/components/selectors/CustomDropdown/index.js +1 -7
  78. package/build/production/shared/components/selectors/CustomDropdown/index.js.map +1 -1
  79. package/build/production/shared/components/selectors/Switch/index.js +1 -1
  80. package/build/production/shared/components/selectors/Switch/index.js.map +1 -1
  81. package/build/production/shared/utils/globalState.js +1 -1
  82. package/build/production/shared/utils/globalState.js.map +1 -1
  83. package/build/production/shared/utils/index.js +1 -1
  84. package/build/production/shared/utils/index.js.map +1 -1
  85. package/build/production/shared/utils/splitComponent.js +3 -10
  86. package/build/production/shared/utils/splitComponent.js.map +1 -1
  87. package/build/production/shared/utils/time.js +2 -2
  88. package/build/production/shared/utils/time.js.map +1 -1
  89. package/build/types-code/index.d.ts +2 -2
  90. package/build/types-code/shared/utils/globalState.d.ts +2 -2
  91. package/build/types-code/shared/utils/index.d.ts +1 -1
  92. package/build/types-code/shared/utils/splitComponent.d.ts +1 -0
  93. package/build/web/client/index.js +2 -2
  94. package/build/web/client/index.js.map +1 -1
  95. package/build/web/index.js +1 -1
  96. package/build/web/index.js.map +1 -1
  97. package/build/web/shared/components/Button/index.js +2 -13
  98. package/build/web/shared/components/Button/index.js.map +1 -1
  99. package/build/web/shared/components/Checkbox/index.js +1 -1
  100. package/build/web/shared/components/Checkbox/index.js.map +1 -1
  101. package/build/web/shared/components/GenericLink/index.js +2 -15
  102. package/build/web/shared/components/GenericLink/index.js.map +1 -1
  103. package/build/web/shared/components/Input/index.js +2 -11
  104. package/build/web/shared/components/Input/index.js.map +1 -1
  105. package/build/web/shared/components/Link.js +2 -4
  106. package/build/web/shared/components/Link.js.map +1 -1
  107. package/build/web/shared/components/Modal/index.js +2 -10
  108. package/build/web/shared/components/Modal/index.js.map +1 -1
  109. package/build/web/shared/components/NavLink.js +1 -4
  110. package/build/web/shared/components/NavLink.js.map +1 -1
  111. package/build/web/shared/components/PageLayout/index.js +2 -2
  112. package/build/web/shared/components/PageLayout/index.js.map +1 -1
  113. package/build/web/shared/components/TextArea/index.js +1 -21
  114. package/build/web/shared/components/TextArea/index.js.map +1 -1
  115. package/build/web/shared/components/Throbber/index.js +2 -2
  116. package/build/web/shared/components/Throbber/index.js.map +1 -1
  117. package/build/web/shared/components/WithTooltip/Tooltip.js +2 -7
  118. package/build/web/shared/components/WithTooltip/Tooltip.js.map +1 -1
  119. package/build/web/shared/components/WithTooltip/index.js +3 -3
  120. package/build/web/shared/components/WithTooltip/index.js.map +1 -1
  121. package/build/web/shared/components/YouTubeVideo/index.js +2 -5
  122. package/build/web/shared/components/YouTubeVideo/index.js.map +1 -1
  123. package/build/web/shared/components/selectors/CustomDropdown/Options/index.js +1 -6
  124. package/build/web/shared/components/selectors/CustomDropdown/Options/index.js.map +1 -1
  125. package/build/web/shared/components/selectors/CustomDropdown/index.js +1 -7
  126. package/build/web/shared/components/selectors/CustomDropdown/index.js.map +1 -1
  127. package/build/web/shared/components/selectors/Switch/index.js +1 -1
  128. package/build/web/shared/components/selectors/Switch/index.js.map +1 -1
  129. package/build/web/shared/utils/globalState.js +1 -1
  130. package/build/web/shared/utils/globalState.js.map +1 -1
  131. package/build/web/shared/utils/index.js +1 -1
  132. package/build/web/shared/utils/index.js.map +1 -1
  133. package/build/web/shared/utils/splitComponent.js +3 -10
  134. package/build/web/shared/utils/splitComponent.js.map +1 -1
  135. package/build/web/shared/utils/time.js +2 -2
  136. package/build/web/shared/utils/time.js.map +1 -1
  137. package/config/babel/webpack.d.ts +1 -0
  138. package/config/babel/webpack.js +10 -12
  139. package/package.json +6 -4
@@ -1 +1 @@
1
- {"version":3,"file":"splitComponent.js","names":["Suspense","lazy","useInsertionEffect","Barrier","getSsrContext","IS_CLIENT_SIDE","IS_SERVER_SIDE","getBuildInfo","jsx","_jsx","getClientChunkGroups","undefined","default","getInj","inj","CHUNK_GROUPS","refCounts","getPublicPath","publicPath","bookStyleSheet","name","loadedSheets","refCount","res","path","fullPath","document","location","origin","has","link","querySelector","createElement","setAttribute","head","appendChild","addEventListener","Error","resolve","current","getLoadedStyleSheets","Set","styleSheets","href","add","assertChunkName","chunkName","chunkGroups","bookStyleSheets","promises","assets","Promise","asset","endsWith","promise","push","length","allSettled","then","freeStyleSheets","pathRefCount","remove","splitComponent","getComponent","placeholder","LazyComponent","clientChunkGroups","resolved","Component","Wrapper","children","ref","rest","chunks","includes","CodeSplit","fallback"],"sources":["../../../../src/shared/utils/splitComponent.tsx"],"sourcesContent":["/* global document */\n\nimport {\n type ComponentType,\n type FunctionComponent,\n type ReactNode,\n type RefObject,\n Suspense,\n lazy,\n useInsertionEffect,\n} from 'react';\n\nimport { Barrier } from '@dr.pogodin/js-utils';\n\nimport { type ChunkGroupsT, getSsrContext } from './globalState';\n\nimport {\n IS_CLIENT_SIDE,\n IS_SERVER_SIDE,\n getBuildInfo,\n} from './isomorphy';\n\nfunction getClientChunkGroups(): Promise<ChunkGroupsT> | undefined {\n if (!IS_CLIENT_SIDE) return undefined;\n\n return (async () => {\n const { default: getInj } = await import(/* webpackChunkName: \"react-utils-client-side-code\" */ '../../client/getInj');\n\n const inj = await getInj();\n return inj.CHUNK_GROUPS ?? {};\n })();\n}\n\nconst refCounts: Record<string, number> = {};\n\nfunction getPublicPath() {\n return getBuildInfo().publicPath;\n}\n\n/**\n * Client-side only! Ensures the specified CSS stylesheet is loaded into\n * the document; loads if it is missing; and does simple reference counting\n * to facilitate future clean-up.\n * @param name\n * @param loadedSheets\n * @param refCount\n * @return\n */\nfunction bookStyleSheet(\n name: string,\n loadedSheets: Set<string>,\n refCount: boolean,\n): Promise<void> | undefined {\n let res: Barrier<void> | undefined;\n const path = `${getPublicPath()}/${name}`;\n const fullPath = `${document.location.origin}${path}`;\n\n if (!loadedSheets.has(fullPath)) {\n let link = document.querySelector(`link[href=\"${path}\"]`);\n\n if (!link) {\n link = document.createElement('link');\n link.setAttribute('rel', 'stylesheet');\n link.setAttribute('href', path);\n document.head.appendChild(link);\n }\n\n res = new Barrier<void>();\n link.addEventListener('load', () => {\n if (!res) throw Error('Internal error');\n void res.resolve();\n });\n link.addEventListener('error', () => {\n if (!res) throw Error('Internal error');\n void res.resolve();\n });\n }\n\n if (refCount) {\n const current = refCounts[path] ?? 0;\n refCounts[path] = 1 + current;\n }\n\n return res;\n}\n\n/**\n * Generates the set of URLs for currently loaded, linked stylesheets.\n * @return\n */\nfunction getLoadedStyleSheets(): Set<string> {\n const res = new Set<string>();\n const { styleSheets } = document;\n for (const { href } of styleSheets) {\n if (href) res.add(href);\n }\n return res;\n}\n\nfunction assertChunkName(\n chunkName: string,\n chunkGroups: ChunkGroupsT,\n) {\n if (chunkGroups[chunkName]) return;\n throw Error(`Unknown chunk name \"${chunkName}\"`);\n}\n\n/**\n * Client-side only! Ensures all CSS stylesheets required for the specified\n * code chunk are loaded into the document; loads the missing ones; and does\n * simple reference counting to facilitate future clean-up.\n * @param chunkName Chunk name.\n * @param refCount\n * @return Resolves once all pending stylesheets, necessary for\n * the chunk, are either loaded, or failed to load.\n */\nexport async function bookStyleSheets(\n chunkName: string,\n chunkGroups: ChunkGroupsT,\n refCount: boolean,\n): Promise<void> {\n const promises = [];\n const assets = chunkGroups[chunkName];\n if (!assets) return Promise.resolve();\n\n const loadedSheets = getLoadedStyleSheets();\n\n for (const asset of assets) {\n if (asset.endsWith('.css')) {\n const promise = bookStyleSheet(asset, loadedSheets, refCount);\n if (promise) promises.push(promise);\n }\n }\n\n return promises.length\n ? Promise.allSettled(promises).then()\n : Promise.resolve();\n}\n\n/**\n * Client-side only! Frees from the document all CSS stylesheets that are\n * required by the specified chunk, and have reference counter equal to one\n * (for chunks with larger reference counter values, it just decrements\n * the reference counter).\n * @param {string} chunkName\n */\nexport function freeStyleSheets(\n chunkName: string,\n chunkGroups: ChunkGroupsT,\n): void {\n const assets = chunkGroups[chunkName];\n if (!assets) return;\n\n for (const asset of assets) {\n if (asset.endsWith('.css')) {\n const path = `${getPublicPath()}/${asset}`;\n\n const pathRefCount = refCounts[path];\n if (pathRefCount) {\n if (pathRefCount <= 1) {\n document.head.querySelector(`link[href=\"${path}\"]`)!.remove();\n delete refCounts[path];\n } else refCounts[path] = pathRefCount - 1;\n }\n }\n }\n}\n\n// Holds the set of chunk names already used for splitComponent() calls.\n// const usedChunkNames = new Set();\n\ntype ComponentOrModule<PropsT> = ComponentType<PropsT> | {\n default: ComponentType<PropsT>;\n};\n\ntype GenericComponentPropsT = {\n children?: ReactNode;\n ref?: RefObject<unknown>;\n\n // NOTE: This is necessary, as without it this type (with only optional\n // fields) will be conisdered as \"weak\" by TypeScript, and it will be\n // a error to assign to it any type that does not use \"children\", or \"ref\".\n [propName: string]: unknown;\n};\n\n/**\n * Given an async component retrieval function `getComponent()` it creates\n * a special \"code split\" component, which uses <Suspense> to asynchronously\n * load on demand the code required by `getComponent()`.\n * @param options\n * @param options.chunkName\n * @param {function} options.getComponent\n * @param {React.Element} [options.placeholder]\n * @return {React.ElementType}\n */\nexport default function splitComponent<\n ComponentPropsT extends GenericComponentPropsT,\n>({\n chunkName,\n getComponent,\n placeholder,\n}: {\n chunkName: string;\n getComponent: () => Promise<ComponentOrModule<ComponentPropsT>>;\n placeholder?: ReactNode;\n}): FunctionComponent<ComponentPropsT> {\n // TODO: For now I commented out this safeguard check, as I am not sure how\n // to easily make it work: it should not be triggered in HMR mode, but if I\n // add the code relying on import.meta, it fails in Jest environment, because\n // Jest does not support ES modules yet, and import.meta is not support in\n // CommonJS modules, and the \"babel-plugin-transform-import-meta\" plugin\n // we use to workaround this issue for import.meta.dirname, etc. does not\n // transform import.meta.webpackHot\n\n // The correct usage of splitComponent() assumes a single call per chunk.\n // if (usedChunkNames.has(chunkName)\n\n // When HMR happens splitComponent() ends up getting called again for some\n // chunks, thus we should not throw this error. Not sure, if we need to do\n // some additional handling in that case, or just not throwing is all we\n // need.\n // && !import.meta.webpackHot\n // ) {\n // throw Error(`Repeated splitComponent() call for the chunk \"${chunkName}\"`);\n // } else usedChunkNames.add(chunkName);\n\n const LazyComponent = lazy(async () => {\n const clientChunkGroups = await getClientChunkGroups();\n\n // On the client side we can check right away if the chunk name is known.\n if (IS_CLIENT_SIDE) {\n if (!clientChunkGroups) throw Error('Internal error');\n assertChunkName(chunkName, clientChunkGroups);\n }\n\n const resolved = await getComponent();\n const Component = 'default' in resolved ? resolved.default : resolved;\n\n // This pre-loads necessary stylesheets prior to the first mount of\n // the component (the lazy load function is executed by React one at\n // the frist mount).\n if (IS_CLIENT_SIDE) {\n if (!clientChunkGroups) throw Error('Internal error');\n await bookStyleSheets(chunkName, clientChunkGroups, false);\n }\n\n const Wrapper: FunctionComponent<ComponentPropsT> = ({\n children,\n ref,\n ...rest\n }) => {\n // On the server side we'll assert the chunk name here,\n // and also push it to the SSR chunks array.\n if (IS_SERVER_SIDE) {\n const { chunkGroups, chunks } = getSsrContext()!;\n assertChunkName(chunkName, chunkGroups);\n if (!chunks.includes(chunkName)) chunks.push(chunkName);\n }\n\n // This takes care about stylesheets management every time an instance of\n // this component is mounted / unmounted.\n useInsertionEffect(() => {\n if (!clientChunkGroups) throw Error('Internal error');\n void bookStyleSheets(chunkName, clientChunkGroups, true);\n return () => {\n freeStyleSheets(chunkName, clientChunkGroups);\n };\n }, []);\n\n return (\n <Component\n // eslint-disable-next-line react/jsx-props-no-spreading\n {...(rest as unknown as ComponentPropsT)}\n ref={ref}\n >\n {children}\n </Component>\n );\n };\n\n return { default: Wrapper };\n });\n\n const CodeSplit: React.FunctionComponent<ComponentPropsT> = ({\n children,\n ...rest\n }: ComponentPropsT) => (\n <Suspense fallback={placeholder}>\n <LazyComponent\n // eslint-disable-next-line react/jsx-props-no-spreading\n {...rest as Parameters<typeof LazyComponent>[0]}\n >\n {children}\n </LazyComponent>\n </Suspense>\n );\n\n return CodeSplit;\n}\n"],"mappings":"6rBAAA,qBAEA,OAKEA,QAAQ,CACRC,IAAI,CACJC,kBAAkB,KACb,OAAO,CAEd,OAASC,OAAO,KAAQ,sBAAsB,CAE9C,OAA4BC,aAAa,+BAGvCC,cAAc,CACdC,cAAc,CACdC,YAAY,4BACO,OAAAC,GAAA,IAAAC,IAAA,yBAErB,QAAS,CAAAC,oBAAoBA,CAAA,CAAsC,CACjE,GAAI,CAACL,cAAc,CAAE,MAAO,CAAAM,SAAS,CAErC,MAAO,CAAC,SAAY,CAClB,KAAM,CAAEC,OAAO,CAAEC,MAAO,CAAC,CAAG,KAAM,OAAM,CAAC,2EAA4E,CAAC,CAEtH,KAAM,CAAAC,GAAG,CAAG,KAAM,CAAAD,MAAM,CAAC,CAAC,CAC1B,MAAO,CAAAC,GAAG,CAACC,YAAY,EAAI,CAAC,CAAC,CAC/B,CAAC,EAAE,CAAC,CACN,CAEA,KAAM,CAAAC,SAAiC,CAAG,CAAC,CAAC,CAE5C,QAAS,CAAAC,aAAaA,CAAA,CAAG,CACvB,MAAO,CAAAV,YAAY,CAAC,CAAC,CAACW,UAAU,CAClC,CAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,GACA,QAAS,CAAAC,cAAcA,CACrBC,IAAY,CACZC,YAAyB,CACzBC,QAAiB,CACU,CAC3B,GAAI,CAAAC,GAA8B,CAClC,KAAM,CAAAC,IAAI,CAAG,GAAGP,aAAa,CAAC,CAAC,IAAIG,IAAI,EAAE,CACzC,KAAM,CAAAK,QAAQ,CAAG,GAAGC,QAAQ,CAACC,QAAQ,CAACC,MAAM,GAAGJ,IAAI,EAAE,CAErD,GAAI,CAACH,YAAY,CAACQ,GAAG,CAACJ,QAAQ,CAAC,CAAE,CAC/B,GAAI,CAAAK,IAAI,CAAGJ,QAAQ,CAACK,aAAa,CAAC,cAAcP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AK,SAAS,CAClB","ignoreList":[]}
1
+ {"version":3,"file":"splitComponent.js","names":["Suspense","lazy","useInsertionEffect","Barrier","useSsrContext","IS_CLIENT_SIDE","IS_SERVER_SIDE","assertClientSide","getBuildInfo","jsx","_jsx","clientChunkGroups","setClientChunkGroups","groups","refCounts","getPublicPath","publicPath","bookStyleSheet","name","loadedSheets","refCount","res","path","fullPath","document","location","origin","has","link","querySelector","createElement","setAttribute","head","appendChild","addEventListener","Error","resolve","current","getLoadedStyleSheets","Set","styleSheets","href","add","assertChunkName","chunkName","chunkGroups","bookStyleSheets","promises","assets","Promise","asset","endsWith","promise","push","length","allSettled","then","freeStyleSheets","pathRefCount","remove","splitComponent","getComponent","placeholder","LazyComponent","resolved","Component","default","Wrapper","t0","$","_c","children","ref","rest","t1","t2","t3","t4","CodeSplit","ssrContext","chunks","includes","fallback"],"sources":["../../../../src/shared/utils/splitComponent.tsx"],"sourcesContent":["/* global document */\n\nimport {\n type ComponentType,\n type FunctionComponent,\n type ReactNode,\n type RefObject,\n Suspense,\n lazy,\n useInsertionEffect,\n} from 'react';\n\nimport { Barrier } from '@dr.pogodin/js-utils';\n\nimport { type ChunkGroupsT, useSsrContext } from './globalState';\n\nimport {\n IS_CLIENT_SIDE,\n IS_SERVER_SIDE,\n assertClientSide,\n getBuildInfo,\n} from './isomorphy';\n\nlet clientChunkGroups: ChunkGroupsT | undefined;\n\nexport function setClientChunkGroups(groups: ChunkGroupsT): void {\n assertClientSide();\n clientChunkGroups = groups;\n}\n\nconst refCounts: Record<string, number> = {};\n\nfunction getPublicPath() {\n return getBuildInfo().publicPath;\n}\n\n/**\n * Client-side only! Ensures the specified CSS stylesheet is loaded into\n * the document; loads if it is missing; and does simple reference counting\n * to facilitate future clean-up.\n * @param name\n * @param loadedSheets\n * @param refCount\n * @return\n */\nfunction bookStyleSheet(\n name: string,\n loadedSheets: Set<string>,\n refCount: boolean,\n): Promise<void> | undefined {\n let res: Barrier<void> | undefined;\n const path = `${getPublicPath()}/${name}`;\n const fullPath = `${document.location.origin}${path}`;\n\n if (!loadedSheets.has(fullPath)) {\n let link = document.querySelector(`link[href=\"${path}\"]`);\n\n if (!link) {\n link = document.createElement('link');\n link.setAttribute('rel', 'stylesheet');\n link.setAttribute('href', path);\n document.head.appendChild(link);\n }\n\n res = new Barrier<void>();\n link.addEventListener('load', () => {\n if (!res) throw Error('Internal error');\n void res.resolve();\n });\n link.addEventListener('error', () => {\n if (!res) throw Error('Internal error');\n void res.resolve();\n });\n }\n\n if (refCount) {\n const current = refCounts[path] ?? 0;\n refCounts[path] = 1 + current;\n }\n\n return res;\n}\n\n/**\n * Generates the set of URLs for currently loaded, linked stylesheets.\n * @return\n */\nfunction getLoadedStyleSheets(): Set<string> {\n const res = new Set<string>();\n const { styleSheets } = document;\n for (const { href } of styleSheets) {\n if (href) res.add(href);\n }\n return res;\n}\n\nfunction assertChunkName(\n chunkName: string,\n chunkGroups: ChunkGroupsT,\n) {\n if (chunkGroups[chunkName]) return;\n throw Error(`Unknown chunk name \"${chunkName}\"`);\n}\n\n/**\n * Client-side only! Ensures all CSS stylesheets required for the specified\n * code chunk are loaded into the document; loads the missing ones; and does\n * simple reference counting to facilitate future clean-up.\n * @param chunkName Chunk name.\n * @param refCount\n * @return Resolves once all pending stylesheets, necessary for\n * the chunk, are either loaded, or failed to load.\n */\nexport async function bookStyleSheets(\n chunkName: string,\n chunkGroups: ChunkGroupsT,\n refCount: boolean,\n): Promise<void> {\n const promises = [];\n const assets = chunkGroups[chunkName];\n if (!assets) return Promise.resolve();\n\n const loadedSheets = getLoadedStyleSheets();\n\n for (const asset of assets) {\n if (asset.endsWith('.css')) {\n const promise = bookStyleSheet(asset, loadedSheets, refCount);\n if (promise) promises.push(promise);\n }\n }\n\n return promises.length\n ? Promise.allSettled(promises).then()\n : Promise.resolve();\n}\n\n/**\n * Client-side only! Frees from the document all CSS stylesheets that are\n * required by the specified chunk, and have reference counter equal to one\n * (for chunks with larger reference counter values, it just decrements\n * the reference counter).\n * @param {string} chunkName\n */\nexport function freeStyleSheets(\n chunkName: string,\n chunkGroups: ChunkGroupsT,\n): void {\n const assets = chunkGroups[chunkName];\n if (!assets) return;\n\n for (const asset of assets) {\n if (asset.endsWith('.css')) {\n const path = `${getPublicPath()}/${asset}`;\n\n const pathRefCount = refCounts[path];\n if (pathRefCount) {\n if (pathRefCount <= 1) {\n document.head.querySelector(`link[href=\"${path}\"]`)!.remove();\n delete refCounts[path];\n } else refCounts[path] = pathRefCount - 1;\n }\n }\n }\n}\n\n// Holds the set of chunk names already used for splitComponent() calls.\n// const usedChunkNames = new Set();\n\ntype ComponentOrModule<PropsT> = ComponentType<PropsT> | {\n default: ComponentType<PropsT>;\n};\n\ntype GenericComponentPropsT = {\n children?: ReactNode;\n ref?: RefObject<unknown>;\n\n // NOTE: This is necessary, as without it this type (with only optional\n // fields) will be conisdered as \"weak\" by TypeScript, and it will be\n // a error to assign to it any type that does not use \"children\", or \"ref\".\n [propName: string]: unknown;\n};\n\n/**\n * Given an async component retrieval function `getComponent()` it creates\n * a special \"code split\" component, which uses <Suspense> to asynchronously\n * load on demand the code required by `getComponent()`.\n * @param options\n * @param options.chunkName\n * @param {function} options.getComponent\n * @param {React.Element} [options.placeholder]\n * @return {React.ElementType}\n */\nexport default function splitComponent<\n ComponentPropsT extends GenericComponentPropsT,\n>({\n chunkName,\n getComponent,\n placeholder,\n}: {\n chunkName: string;\n getComponent: () => Promise<ComponentOrModule<ComponentPropsT>>;\n placeholder?: ReactNode;\n}): FunctionComponent<ComponentPropsT> {\n // TODO: For now I commented out this safeguard check, as I am not sure how\n // to easily make it work: it should not be triggered in HMR mode, but if I\n // add the code relying on import.meta, it fails in Jest environment, because\n // Jest does not support ES modules yet, and import.meta is not support in\n // CommonJS modules, and the \"babel-plugin-transform-import-meta\" plugin\n // we use to workaround this issue for import.meta.dirname, etc. does not\n // transform import.meta.webpackHot\n\n // The correct usage of splitComponent() assumes a single call per chunk.\n // if (usedChunkNames.has(chunkName)\n\n // When HMR happens splitComponent() ends up getting called again for some\n // chunks, thus we should not throw this error. Not sure, if we need to do\n // some additional handling in that case, or just not throwing is all we\n // need.\n // && !import.meta.webpackHot\n // ) {\n // throw Error(`Repeated splitComponent() call for the chunk \"${chunkName}\"`);\n // } else usedChunkNames.add(chunkName);\n\n const LazyComponent = lazy(async () => {\n const resolved = await getComponent();\n const Component = 'default' in resolved ? resolved.default : resolved;\n\n // This pre-loads necessary stylesheets prior to the first mount of\n // the component (the lazy load function is executed by React one at\n // the frist mount).\n if (IS_CLIENT_SIDE) {\n if (!clientChunkGroups) throw Error('Internal error');\n await bookStyleSheets(chunkName, clientChunkGroups, false);\n }\n\n const Wrapper: FunctionComponent<ComponentPropsT & {\n chunkGroups: ChunkGroupsT;\n }> = ({\n children,\n chunkGroups,\n ref,\n ...rest\n }) => {\n // This takes care about stylesheets management every time an instance of\n // this component is mounted / unmounted.\n useInsertionEffect(() => {\n if (!clientChunkGroups) throw Error('Internal error');\n void bookStyleSheets(chunkName, chunkGroups, true);\n return () => {\n freeStyleSheets(chunkName, chunkGroups);\n };\n }, [chunkGroups]);\n\n return (\n <Component\n // eslint-disable-next-line react/jsx-props-no-spreading\n {...(rest as unknown as ComponentPropsT)}\n ref={ref}\n >\n {children}\n </Component>\n );\n };\n\n return { default: Wrapper };\n });\n\n const CodeSplit: FunctionComponent<ComponentPropsT> = ({\n children,\n ...rest\n }: ComponentPropsT) => {\n let chunkGroups: ChunkGroupsT;\n\n const ssrContext = useSsrContext(false);\n\n // On the server side we'll assert the chunk name here,\n // and also push it to the SSR chunks array.\n if (IS_SERVER_SIDE) {\n if (!ssrContext) throw Error('Internal error');\n ({ chunkGroups } = ssrContext);\n const { chunks } = ssrContext;\n\n if (!chunks.includes(chunkName)) chunks.push(chunkName);\n } else {\n if (!clientChunkGroups) throw Error('Internal error');\n chunkGroups = clientChunkGroups;\n }\n\n assertChunkName(chunkName, chunkGroups);\n\n return (\n <Suspense fallback={placeholder}>\n <LazyComponent\n // eslint-disable-next-line react/jsx-props-no-spreading\n {...rest as Parameters<typeof LazyComponent>[0]}\n\n chunkGroups={chunkGroups}\n >\n {children}\n </LazyComponent>\n </Suspense>\n );\n };\n\n return CodeSplit;\n}\n"],"mappings":"yuBAAA,qBAEA,OAKEA,QAAQ,CACRC,IAAI,CACJC,kBAAkB,KACb,OAAO,CAEd,OAASC,OAAO,KAAQ,sBAAsB,CAE9C,OAA4BC,aAAa,+BAGvCC,cAAc,CACdC,cAAc,CACdC,gBAAgB,CAChBC,YAAY,4BACO,OAAAC,GAAA,IAAAC,IAAA,yBAErB,GAAI,CAAAC,iBAA2C,CAE/C,MAAO,SAAS,CAAAC,oBAAoBA,CAACC,MAAoB,CAAQ,CAC/DN,gBAAgB,CAAC,CAAC,CAClBI,iBAAiB,CAAGE,MAAM,CAC5B,CAEA,KAAM,CAAAC,SAAiC,CAAG,CAAC,CAAC,CAE5C,QAAS,CAAAC,aAAaA,CAAA,CAAG,CACvB,MAAO,CAAAP,YAAY,CAAC,CAAC,CAACQ,UAAU,CAClC,CAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,GACA,QAAS,CAAAC,cAAcA,CACrBC,IAAY,CACZC,YAAyB,CACzBC,QAAiB,CACU,CAC3B,GAAI,CAAAC,GAA8B,CAClC,KAAM,CAAAC,IAAI,CAAG,GAAGP,aAAa,CAAC,CAAC,IAAIG,IAAI,EAAE,CACzC,KAAM,CAAAK,QAAQ,CAAG,GAAGC,QAAQ,CAACC,QAAQ,CAACC,MAAM,GAAGJ,IAAI,EAAE,CAErD,GAAI,CAACH,YAAY,CAACQ,GAAG,CAACJ,QAAQ,CAAC,CAAE,CAC/B,GAAI,CAAAK,IAAI,CAAGJ,QAAQ,CAACK,aAAa,CAAC,cAAcP,IAAI,IAAI,CAAC,CAEzD,GAAI,CAACM,IAAI,CAAE,CACTA,IAAI,CAAGJ,QAAQ,CAACM,aAAa,CAAC,MAAM,CAAC,CACrCF,IAAI,CAACG,YAAY,CAAC,KAA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,OAAAA,EAAA,CAAAN,CAAA,WATX,CAAAM,EASW,EAEd,CAED,MAAO,CAAAG,SAAS,CAClB","ignoreList":[]}
@@ -1,4 +1,4 @@
1
- import{serialize}from"cookie";import dayjs from"dayjs";import{useEffect}from"react";import{DAY_MS,HOUR_MS,MIN_MS,SEC_MS,YEAR_MS,timer}from"@dr.pogodin/js-utils";import{useGlobalState}from"@dr.pogodin/react-global-state";import{getSsrContext}from"./globalState.js";/**
1
+ import{c as _c}from"react/compiler-runtime";import{serialize}from"cookie";import dayjs from"dayjs";import{useEffect}from"react";import{DAY_MS,HOUR_MS,MIN_MS,SEC_MS,YEAR_MS,timer}from"@dr.pogodin/js-utils";import{useGlobalState}from"@dr.pogodin/react-global-state";import{useSsrContext}from"./globalState.js";/**
2
2
  * This react hook wraps Date.now() function in a SSR friendly way,
3
3
  * ensuring that all calls to useCurrent() within the same render return
4
4
  * exactly the same time (which is retrieved from Date.now() first, and
@@ -17,5 +17,5 @@ export function useCurrent({autorefresh=false,globalStatePath="currentTime",prec
17
17
  * as the default value.
18
18
  */// TODO: Should we request the state type as generic parameter, to be able
19
19
  // to verify the give globalStatePath is correct?
20
- export function useTimezoneOffset({cookieName="timezoneOffset",globalStatePath="timezoneOffset"}={}){const ssrContext=getSsrContext(false);const[offset,setOffset]=useGlobalState(globalStatePath,()=>{const value=cookieName&&ssrContext?.req.cookies[cookieName];return value?parseInt(value):0;});useEffect(()=>{const date=new Date;const value=date.getTimezoneOffset();setOffset(value);if(cookieName){document.cookie=serialize(cookieName,value.toString(),{path:"/"});}},[cookieName,setOffset]);return offset;}const time={DAY_MS,HOUR_MS,MIN_MS,SEC_MS,YEAR_MS,now:Date.now,timer,useCurrent,useTimezoneOffset};export default Object.assign(dayjs,time);
20
+ export function useTimezoneOffset(t0){const $=_c(9);let t1;if($[0]!==t0){t1=t0===undefined?{}:t0;$[0]=t0;$[1]=t1;}else{t1=$[1];}const{cookieName:t2,globalStatePath:t3}=t1;const cookieName=t2===undefined?"timezoneOffset":t2;const globalStatePath=t3===undefined?"timezoneOffset":t3;const ssrContext=useSsrContext(false);let t4;if($[2]!==cookieName||$[3]!==ssrContext?.req){t4=()=>{const value=cookieName&&ssrContext?.req.cookies[cookieName];return value?parseInt(value):0;};$[2]=cookieName;$[3]=ssrContext?.req;$[4]=t4;}else{t4=$[4];}const[offset,setOffset]=useGlobalState(globalStatePath,t4);let t5;let t6;if($[5]!==cookieName||$[6]!==setOffset){t5=()=>{const date=new Date;const value_0=date.getTimezoneOffset();setOffset(value_0);if(cookieName){document.cookie=serialize(cookieName,value_0.toString(),{path:"/"});}};t6=[cookieName,setOffset];$[5]=cookieName;$[6]=setOffset;$[7]=t5;$[8]=t6;}else{t5=$[7];t6=$[8];}useEffect(t5,t6);return offset;}const time={DAY_MS,HOUR_MS,MIN_MS,SEC_MS,YEAR_MS,now:Date.now,timer,useCurrent,useTimezoneOffset};export default Object.assign(dayjs,time);
21
21
  //# sourceMappingURL=time.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"time.js","names":["serialize","dayjs","useEffect","DAY_MS","HOUR_MS","MIN_MS","SEC_MS","YEAR_MS","timer","useGlobalState","getSsrContext","useCurrent","autorefresh","globalStatePath","precision","now","setter","Date","timerId","update","old","neu","Math","abs","setTimeout","clearTimeout","useTimezoneOffset","cookieName","ssrContext","offset","setOffset","value","req","cookies","parseInt","date","getTimezoneOffset","document","cookie","toString","path","time","Object","assign"],"sources":["../../../../src/shared/utils/time.ts"],"sourcesContent":["import { serialize } from 'cookie';\nimport dayjs from 'dayjs';\nimport { useEffect } from 'react';\n\nimport {\n DAY_MS,\n HOUR_MS,\n MIN_MS,\n SEC_MS,\n YEAR_MS,\n timer,\n} from '@dr.pogodin/js-utils';\n\nimport { type ForceT, useGlobalState } from '@dr.pogodin/react-global-state';\n\nimport { getSsrContext } from './globalState';\n\n/**\n * This react hook wraps Date.now() function in a SSR friendly way,\n * ensuring that all calls to useCurrent() within the same render return\n * exactly the same time (which is retrieved from Date.now() first, and\n * then stored in the global state to be reused in all other calls), which\n * is also passed and used in the first client side render, and then updated\n * with a finite precision to avoid infinite re-rendering loops.\n */\n// TODO: Should we request the state type as generic parameter, to be able\n// to verify the give globalStatePath is correct?\nexport function useCurrent({\n autorefresh = false,\n globalStatePath = 'currentTime',\n precision = 5 * SEC_MS,\n} = {}): number {\n const [now, setter] = useGlobalState<ForceT, number>(\n globalStatePath,\n Date.now,\n );\n useEffect(() => {\n let timerId: NodeJS.Timeout | undefined;\n const update = (): void => {\n setter((old) => {\n const neu = Date.now();\n return Math.abs(neu - old) > precision ? neu : old;\n });\n if (autorefresh) timerId = setTimeout(update, precision);\n };\n update();\n return (): void => {\n if (timerId) clearTimeout(timerId);\n };\n }, [autorefresh, precision, setter]);\n return now;\n}\n\n/**\n * Wraps the standard Date.getTimezoneOffset() method in a SSR-friendly way.\n * This hook retrieves the offset value at the client side and uses a cookie\n * to pass it to the server in subsequent requests from that user. At the server\n * side the value from cookie is used in renders and passed back to the client\n * via the global state. Prior to the value being known (in the very first\n * request from the user, when the cookie is still missing), zero value is used\n * as the default value.\n */\n// TODO: Should we request the state type as generic parameter, to be able\n// to verify the give globalStatePath is correct?\nexport function useTimezoneOffset({\n cookieName = 'timezoneOffset',\n globalStatePath = 'timezoneOffset',\n} = {}): number {\n const ssrContext = getSsrContext(false);\n const [offset, setOffset] = useGlobalState<ForceT, number>(\n globalStatePath,\n () => {\n const value = cookieName\n && ssrContext?.req.cookies[cookieName] as string;\n return value ? parseInt(value) : 0;\n },\n );\n useEffect(() => {\n const date = new Date();\n const value = date.getTimezoneOffset();\n setOffset(value);\n if (cookieName) {\n document.cookie = serialize(cookieName, value.toString(), { path: '/' });\n }\n }, [cookieName, setOffset]);\n return offset;\n}\n\nconst time = {\n DAY_MS,\n HOUR_MS,\n MIN_MS,\n SEC_MS,\n YEAR_MS,\n now: Date.now,\n timer,\n useCurrent,\n useTimezoneOffset,\n};\n\nexport default Object.assign(dayjs, time);\n"],"mappings":"AAAA,OAASA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BAAiBA,CAAC,CAChCC,UAAU,CAAG,gBAAgB,CAC7Bd,eAAe,CAAG,gBACpB,CAAC,CAAG,CAAC,CAAC,CAAU,CACd,KAAM,CAAAe,UAAU,CAAGlB,aAAa,CAAC,KAAK,CAAC,CACvC,KAAM,CAACmB,MAAM,CAAEC,SAAS,CAAC,CAAGrB,cAAc,CACxCI,eAAe,CACf,IAAM,CACJ,KAAM,CAAAkB,KAAK,CAAGJ,UAAU,EACnBC,UAAU,EAAEI,GAAG,CAACC,OAAO,CAACN,UAAU,CAAW,CAClD,MAAO,CAAAI,KAAK,CAAGG,QAAQ,CAACH,KAAK,CAAC,CAAG,CAAC,CACpC,CACF,CAAC,CACD7B,SAAS,CAAC,IAAM,CACd,KAAM,CAAAiC,IAAI,CAAG,GAAI,CAAAlB,IAAM,CACvB,KAAM,CAAAc,KAAK,CAAGI,IAAI,CAACC,iBAAiB,CAAC,CAAC,CACtCN,SAAS,CAACC,KAAK,CAAC,CAChB,GAAIJ,UAAU,CAAE,CACdU,QAAQ,CAACC,MAAM,CAAGtC,SAAS,CAAC2B,UAAU,CAAEI,KAAK,CAACQ,QAAQ,CAAC,CAAC,CAAE,CAAEC,IAAI,CAAE,GAAI,CAAC,CAAC,CAC1E,CACF,CAAC,CAAE,CAACb,UAAU,CAAEG,SAAS,CAAC,CAAC,CAC3B,MAAO,CAAAD,MAAM,CACf,CAEA,KAAM,CAAAY,IAAI,CAAG,CACXtC,MAAM,CACNC,OAAO,CACPC,MAAM,CACNC,MAAM,CACNC,OAAO,CACPQ,GAAG,CAAEE,IAAI,CAACF,GAAG,CACbP,KAAK,CACLG,UAAU,CACVe,iBACF,CAAC,CAED,cAAe,CAAAgB,MAAM,CAACC,MAAM,CAAC1C,KAAK,CAAEwC,IAAI,CAAC","ignoreList":[]}
1
+ {"version":3,"file":"time.js","names":["serialize","dayjs","useEffect","DAY_MS","HOUR_MS","MIN_MS","SEC_MS","YEAR_MS","timer","useGlobalState","useSsrContext","useCurrent","autorefresh","globalStatePath","precision","now","setter","Date","timerId","update","old","neu","Math","abs","setTimeout","clearTimeout","useTimezoneOffset","t0","$","_c","t1","undefined","cookieName","t2","t3","ssrContext","t4","req","value","cookies","parseInt","offset","setOffset","t5","t6","date","value_0","getTimezoneOffset","document","cookie","toString","path","time","Object","assign"],"sources":["../../../../src/shared/utils/time.ts"],"sourcesContent":["import { serialize } from 'cookie';\nimport dayjs from 'dayjs';\nimport { useEffect } from 'react';\n\nimport {\n DAY_MS,\n HOUR_MS,\n MIN_MS,\n SEC_MS,\n YEAR_MS,\n timer,\n} from '@dr.pogodin/js-utils';\n\nimport { type ForceT, useGlobalState } from '@dr.pogodin/react-global-state';\n\nimport { useSsrContext } from './globalState';\n\n/**\n * This react hook wraps Date.now() function in a SSR friendly way,\n * ensuring that all calls to useCurrent() within the same render return\n * exactly the same time (which is retrieved from Date.now() first, and\n * then stored in the global state to be reused in all other calls), which\n * is also passed and used in the first client side render, and then updated\n * with a finite precision to avoid infinite re-rendering loops.\n */\n// TODO: Should we request the state type as generic parameter, to be able\n// to verify the give globalStatePath is correct?\nexport function useCurrent({\n autorefresh = false,\n globalStatePath = 'currentTime',\n precision = 5 * SEC_MS,\n} = {}): number {\n const [now, setter] = useGlobalState<ForceT, number>(\n globalStatePath,\n Date.now,\n );\n useEffect(() => {\n let timerId: NodeJS.Timeout | undefined;\n const update = (): void => {\n setter((old) => {\n const neu = Date.now();\n return Math.abs(neu - old) > precision ? neu : old;\n });\n if (autorefresh) timerId = setTimeout(update, precision);\n };\n update();\n return (): void => {\n if (timerId) clearTimeout(timerId);\n };\n }, [autorefresh, precision, setter]);\n return now;\n}\n\n/**\n * Wraps the standard Date.getTimezoneOffset() method in a SSR-friendly way.\n * This hook retrieves the offset value at the client side and uses a cookie\n * to pass it to the server in subsequent requests from that user. At the server\n * side the value from cookie is used in renders and passed back to the client\n * via the global state. Prior to the value being known (in the very first\n * request from the user, when the cookie is still missing), zero value is used\n * as the default value.\n */\n// TODO: Should we request the state type as generic parameter, to be able\n// to verify the give globalStatePath is correct?\nexport function useTimezoneOffset({\n cookieName = 'timezoneOffset',\n globalStatePath = 'timezoneOffset',\n} = {}): number {\n const ssrContext = useSsrContext(false);\n const [offset, setOffset] = useGlobalState<ForceT, number>(\n globalStatePath,\n () => {\n const value = cookieName\n && ssrContext?.req.cookies[cookieName] as string;\n return value ? parseInt(value) : 0;\n },\n );\n useEffect(() => {\n const date = new Date();\n const value = date.getTimezoneOffset();\n setOffset(value);\n if (cookieName) {\n document.cookie = serialize(cookieName, value.toString(), { path: '/' });\n }\n }, [cookieName, setOffset]);\n return offset;\n}\n\nconst time = {\n DAY_MS,\n HOUR_MS,\n MIN_MS,\n SEC_MS,\n YEAR_MS,\n now: Date.now,\n timer,\n useCurrent,\n useTimezoneOffset,\n};\n\nexport default Object.assign(dayjs, time);\n"],"mappings":"4CAAA,OAASA,SAAS,KAAQ,QAAQ,CAClC,MAAO,CAAAC,KAAK,KAAM,OAAO,CACzB,OAASC,SAAS,KAAQ,OAAO,CAEjC,OACEC,MAAM,CACNC,OAAO,CACPC,MAAM,CACNC,MAAM,CACNC,OAAO,CACPC,KAAK,KACA,sBAAsB,CAE7B,OAAsBC,cAAc,KAAQ,gCAAgC,CAE5E,OAASC,aAAa,wBAEtB;AACA;AACA;AACA;AACA;AACA;AACA;AACA,GACA;AACA;AACA,MAAO,SAAS,CAAAC,UAAUA,CAAC,CACzBC,WAAW,CAAG,KAAK,CACnBC,eAAe,CAAG,aAAa,CAC/BC,SAAS,CAAG,CAAC,CAAGR,MAClB,CAAC,CAAG,CAAC,CAAC,CAAU,CACd,KAAM,CAACS,GAAG,CAAEC,MAAM,CAAC,CAAGP,cAAc,CAClCI,eAAe,CACfI,IAAI,CAACF,GACP,CAAC,CACDb,SAAS,CAAC,IAAM,CACd,GAAI,CAAAgB,OAAmC,CACvC,KAAM,CAAAC,MAAM,CAAGA,CAAA,GAAY,CACzBH,MAAM,CAAEI,GAAG,EAAK,CACd,KAAM,CAAAC,G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AACrD,KAAK,CAAEmD,IAAI,CAAC","ignoreList":[]}
@@ -1,5 +1,5 @@
1
- export { type AsyncCollectionLoaderT, type AsyncCollectionT, type AsyncDataEnvelopeT, type AsyncDataLoaderT, type ForceT, GlobalStateProvider, type UseAsyncDataOptionsT, type UseAsyncDataResT, type UseGlobalStateResT, type ValueOrInitializerT, getGlobalState, newAsyncDataEnvelope, useAsyncCollection, useAsyncData, useGlobalState, withGlobalStateType, } from '@dr.pogodin/react-global-state';
1
+ export { type AsyncCollectionLoaderT, type AsyncCollectionT, type AsyncDataEnvelopeT, type AsyncDataLoaderT, type ForceT, GlobalStateProvider, type UseAsyncDataOptionsT, type UseAsyncDataResT, type UseGlobalStateResT, type ValueOrInitializerT, newAsyncDataEnvelope, useAsyncCollection, useAsyncData, useGlobalState, useGlobalStateObject, withGlobalStateType, } from '@dr.pogodin/react-global-state';
2
2
  export * from './shared/components';
3
3
  export { type BeforeRenderResT, type BeforeRenderT, type ConfigT, type ServerSsrContext, type ServerT, } from './server';
4
- export { Barrier, Cached, Emitter, type Listener, type ObjectKey, Semaphore, THEME_COMPOSE, THEME_PRIORITY, type Theme, ThemeProvider, assertEmptyObject, getConfig, getSsrContext, splitComponent, time, useTheme, webpack, withRetries, } from './shared/utils';
4
+ export { Barrier, Cached, Emitter, type Listener, type ObjectKey, Semaphore, THEME_COMPOSE, THEME_PRIORITY, type Theme, ThemeProvider, assertEmptyObject, getConfig, splitComponent, time, useSsrContext, useTheme, webpack, withRetries, } from './shared/utils';
5
5
  export * from './shared/utils/isomorphy';
@@ -22,5 +22,5 @@ export interface SsrContextT<StateT> extends SsrContext<StateT> {
22
22
  req: Request;
23
23
  status: number;
24
24
  }
25
- declare const getSsrContext: (throwWithoutSsrContext?: boolean) => SsrContextT<unknown> | undefined;
26
- export { getSsrContext, };
25
+ declare const useSsrContext: (throwWithoutSsrContext?: boolean) => SsrContextT<unknown> | undefined;
26
+ export { useSsrContext, };
@@ -4,6 +4,6 @@ import * as webpack from './webpack';
4
4
  export * from './isomorphy';
5
5
  export { Barrier, Cached, Emitter, type Listener, type ObjectKey, Semaphore, assertEmptyObject, withRetries, } from '@dr.pogodin/js-utils';
6
6
  export { COMPOSE as THEME_COMPOSE, PRIORITY as THEME_PRIORITY, type Theme, ThemeProvider, useTheme, } from '@dr.pogodin/react-themes';
7
- export { getSsrContext } from './globalState';
7
+ export { useSsrContext } from './globalState';
8
8
  export { default as splitComponent } from './splitComponent';
9
9
  export { getConfig, time, webpack };
@@ -1,5 +1,6 @@
1
1
  import { type ComponentType, type FunctionComponent, type ReactNode, type RefObject } from 'react';
2
2
  import { type ChunkGroupsT } from './globalState';
3
+ export declare function setClientChunkGroups(groups: ChunkGroupsT): void;
3
4
  /**
4
5
  * Client-side only! Ensures all CSS stylesheets required for the specified
5
6
  * code chunk are loaded into the document; loads the missing ones; and does
@@ -1,7 +1,7 @@
1
1
  // Initialization of client-side code.
2
- /* global document */import{createRoot,hydrateRoot}from"react-dom/client";import{BrowserRouter}from"react-router";import{GlobalStateProvider}from"@dr.pogodin/react-global-state";import{HelmetProvider}from"@dr.pogodin/react-helmet";import getInj from"./getInj";import{jsx as _jsx}from"react/jsx-runtime";/**
2
+ /* global document */import{createRoot,hydrateRoot}from"react-dom/client";import{BrowserRouter}from"react-router";import{GlobalStateProvider}from"@dr.pogodin/react-global-state";import{HelmetProvider}from"@dr.pogodin/react-helmet";import{setClientChunkGroups}from"../shared/utils/splitComponent";import getInj from"./getInj";import{jsx as _jsx}from"react/jsx-runtime";/**
3
3
  * Prepares and launches the app at client side.
4
4
  * @param Application Root application component
5
5
  * @param [options={}] Optional. Additional settings.
6
- */export async function launchClient(Application,options={}){const inj=await getInj();const container=document.getElementById("react-view");if(!container)throw Error("Failed to find container for React app");const scene=/*#__PURE__*/_jsx(GlobalStateProvider,{initialState:inj.ISTATE??options.initialState,children:/*#__PURE__*/_jsx(BrowserRouter,{children:/*#__PURE__*/_jsx(HelmetProvider,{children:/*#__PURE__*/_jsx(Application,{})})})});if(options.dontHydrate){const root=createRoot(container);root.render(scene);}else hydrateRoot(container,scene);}
6
+ */export async function launchClient(Application,options={}){const inj=await getInj();setClientChunkGroups(inj.CHUNK_GROUPS??{});const container=document.getElementById("react-view");if(!container)throw Error("Failed to find container for React app");const scene=/*#__PURE__*/_jsx(GlobalStateProvider,{initialState:inj.ISTATE??options.initialState,children:/*#__PURE__*/_jsx(BrowserRouter,{children:/*#__PURE__*/_jsx(HelmetProvider,{children:/*#__PURE__*/_jsx(Application,{})})})});if(options.dontHydrate){const root=createRoot(container);root.render(scene);}else hydrateRoot(container,scene);}
7
7
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":["createRoot","hydrateRoot","BrowserRouter","GlobalStateProvider","HelmetProvider","getInj","jsx","_jsx","launchClient","Application","options","inj","container","document","getElementById","Error","scene","initialState","ISTATE","children","dontHydrate","root","render"],"sources":["../../../src/client/index.tsx"],"sourcesContent":["// Initialization of client-side code.\n/* global document */\n\nimport type { ComponentType } from 'react';\nimport { createRoot, hydrateRoot } from 'react-dom/client';\nimport { BrowserRouter } from 'react-router';\n\nimport { GlobalStateProvider } from '@dr.pogodin/react-global-state';\nimport { HelmetProvider } from '@dr.pogodin/react-helmet';\n\nimport getInj from './getInj';\n\ntype OptionsT = {\n dontHydrate?: boolean;\n initialState?: unknown;\n};\n\n/**\n * Prepares and launches the app at client side.\n * @param Application Root application component\n * @param [options={}] Optional. Additional settings.\n */\nexport async function launchClient(\n Application: ComponentType,\n options: OptionsT = {},\n): Promise<void> {\n const inj = await getInj();\n\n const container = document.getElementById('react-view');\n if (!container) throw Error('Failed to find container for React app');\n const scene = (\n <GlobalStateProvider initialState={inj.ISTATE ?? options.initialState}>\n <BrowserRouter>\n <HelmetProvider>\n <Application />\n </HelmetProvider>\n </BrowserRouter>\n </GlobalStateProvider>\n );\n\n if (options.dontHydrate) {\n const root = createRoot(container);\n root.render(scene);\n } else hydrateRoot(container, scene);\n}\n"],"mappings":"AAAA;AACA,qBAGA,OAASA,UAAU,CAAEC,WAAW,KAAQ,kBAAkB,CAC1D,OAASC,aAAa,KAAQ,cAAc,CAE5C,OAASC,mBAAmB,KAAQ,gCAAgC,CACpE,OAASC,cAAc,KAAQ,0BAA0B,CAEzD,MAAO,CAAAC,MAAM,gBAAiB,OAAAC,GAAA,IAAAC,IAAA,yBAO9B;AACA;AACA;AACA;AACA,GACA,MAAO,eAAe,CAAAC,YAAYA,CAChCC,WAA0B,CAC1BC,OAAiB,CAAG,CAAC,CAAC,CACP,CACf,KAAM,CAAAC,GAAG,CAAG,KAAM,CAAAN,MAAM,CAAC,CAAC,CAE1B,KAAM,CAAAO,SAAS,CAAGC,QAAQ,CAACC,cAAc,CAAC,YAAY,CAAC,CACvD,GAAI,CAACF,SAAS,CAAE,KAAM,CAAAG,KAAK,CAAC,wCAAwC,CAAC,CACrE,KAAM,CAAAC,KAAK,cACTT,IAAA,CAACJ,mBAAmB,EAACc,YAAY,CAAEN,GAAG,CAACO,MAAM,EAAIR,OAAO,CAACO,YAAa,CAAAE,QAAA,cACpEZ,IAAA,CAACL,aAAa,EAAAiB,QAAA,cACZZ,IAAA,CAACH,cAAc,EAAAe,QAAA,cACbZ,IAAA,CAACE,WAAW,GAAE,CAAC,CACD,CAAC,CACJ,CAAC,CACG,CACtB,CAED,GAAIC,OAAO,CAACU,WAAW,CAAE,CACvB,KAAM,CAAAC,IAAI,CAAGrB,UAAU,CAACY,SAAS,CAAC,CAClCS,IAAI,CAACC,MAAM,CAACN,KAAK,CAAC,CACpB,CAAC,IAAM,CAAAf,WAAW,CAACW,SAAS,CAAEI,KAAK,CAAC,CACtC","ignoreList":[]}
1
+ {"version":3,"file":"index.js","names":["createRoot","hydrateRoot","BrowserRouter","GlobalStateProvider","HelmetProvider","setClientChunkGroups","getInj","jsx","_jsx","launchClient","Application","options","inj","CHUNK_GROUPS","container","document","getElementById","Error","scene","initialState","ISTATE","children","dontHydrate","root","render"],"sources":["../../../src/client/index.tsx"],"sourcesContent":["// Initialization of client-side code.\n/* global document */\n\nimport type { ComponentType } from 'react';\nimport { createRoot, hydrateRoot } from 'react-dom/client';\nimport { BrowserRouter } from 'react-router';\n\nimport { GlobalStateProvider } from '@dr.pogodin/react-global-state';\nimport { HelmetProvider } from '@dr.pogodin/react-helmet';\n\nimport { setClientChunkGroups } from 'utils/splitComponent';\n\nimport getInj from './getInj';\n\ntype OptionsT = {\n dontHydrate?: boolean;\n initialState?: unknown;\n};\n\n/**\n * Prepares and launches the app at client side.\n * @param Application Root application component\n * @param [options={}] Optional. Additional settings.\n */\nexport async function launchClient(\n Application: ComponentType,\n options: OptionsT = {},\n): Promise<void> {\n const inj = await getInj();\n\n setClientChunkGroups(inj.CHUNK_GROUPS ?? {});\n\n const container = document.getElementById('react-view');\n if (!container) throw Error('Failed to find container for React app');\n const scene = (\n <GlobalStateProvider initialState={inj.ISTATE ?? options.initialState}>\n <BrowserRouter>\n <HelmetProvider>\n <Application />\n </HelmetProvider>\n </BrowserRouter>\n </GlobalStateProvider>\n );\n\n if (options.dontHydrate) {\n const root = createRoot(container);\n root.render(scene);\n } else hydrateRoot(container, scene);\n}\n"],"mappings":"AAAA;AACA,qBAGA,OAASA,UAAU,CAAEC,WAAW,KAAQ,kBAAkB,CAC1D,OAASC,aAAa,KAAQ,cAAc,CAE5C,OAASC,mBAAmB,KAAQ,gCAAgC,CACpE,OAASC,cAAc,KAAQ,0BAA0B,CAEzD,OAASC,oBAAoB,sCAE7B,MAAO,CAAAC,MAAM,gBAAiB,OAAAC,GAAA,IAAAC,IAAA,yBAO9B;AACA;AACA;AACA;AACA,GACA,MAAO,eAAe,CAAAC,YAAYA,CAChCC,WAA0B,CAC1BC,OAAiB,CAAG,CAAC,CAAC,CACP,CACf,KAAM,CAAAC,GAAG,CAAG,KAAM,CAAAN,MAAM,CAAC,CAAC,CAE1BD,oBAAoB,CAACO,GAAG,CAACC,YAAY,EAAI,CAAC,CAAC,CAAC,CAE5C,KAAM,CAAAC,SAAS,CAAGC,QAAQ,CAACC,cAAc,CAAC,YAAY,CAAC,CACvD,GAAI,CAACF,SAAS,CAAE,KAAM,CAAAG,KAAK,CAAC,wCAAwC,CAAC,CACrE,KAAM,CAAAC,KAAK,cACTV,IAAA,CAACL,mBAAmB,EAACgB,YAAY,CAAEP,GAAG,CAACQ,MAAM,EAAIT,OAAO,CAACQ,YAAa,CAAAE,QAAA,cACpEb,IAAA,CAACN,aAAa,EAAAmB,QAAA,cACZb,IAAA,CAACJ,cAAc,EAAAiB,QAAA,cACbb,IAAA,CAACE,WAAW,GAAE,CAAC,CACD,CAAC,CACJ,CAAC,CACG,CACtB,CAED,GAAIC,OAAO,CAACW,WAAW,CAAE,CACvB,KAAM,CAAAC,IAAI,CAAGvB,UAAU,CAACc,SAAS,CAAC,CAClCS,IAAI,CAACC,MAAM,CAACN,KAAK,CAAC,CACpB,CAAC,IAAM,CAAAjB,WAAW,CAACa,SAAS,CAAEI,KAAK,CAAC,CACtC","ignoreList":[]}
@@ -27,5 +27,5 @@ if (import.meta.webpackHot) {
27
27
  delete global.REACT_UTILS_LIBRARY_LOADED;
28
28
  });
29
29
  }
30
- */export{GlobalStateProvider,getGlobalState,newAsyncDataEnvelope,useAsyncCollection,useAsyncData,useGlobalState,withGlobalStateType}from"@dr.pogodin/react-global-state";export*from"./shared/components";export{Barrier,Cached,Emitter,Semaphore,THEME_COMPOSE,THEME_PRIORITY,ThemeProvider,assertEmptyObject,getConfig,getSsrContext,splitComponent,time,useTheme,webpack,withRetries}from"./shared/utils";export*from"./shared/utils/isomorphy";
30
+ */export{GlobalStateProvider,newAsyncDataEnvelope,useAsyncCollection,useAsyncData,useGlobalState,useGlobalStateObject,withGlobalStateType}from"@dr.pogodin/react-global-state";export*from"./shared/components";export{Barrier,Cached,Emitter,Semaphore,THEME_COMPOSE,THEME_PRIORITY,ThemeProvider,assertEmptyObject,getConfig,splitComponent,time,useSsrContext,useTheme,webpack,withRetries}from"./shared/utils";export*from"./shared/utils/isomorphy";
31
31
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":["GlobalStateProvider","getGlobalState","newAsyncDataEnvelope","useAsyncCollection","useAsyncData","useGlobalState","withGlobalStateType","Barrier","Cached","Emitter","Semaphore","THEME_COMPOSE","THEME_PRIORITY","ThemeProvider","assertEmptyObject","getConfig","getSsrContext","splitComponent","time","useTheme","webpack","withRetries"],"sources":["../../src/index.ts"],"sourcesContent":["// TODO: For now I commented out this safeguard check, as I am not sure how\n// to easily make it work: it should not be triggered in HMR mode, but if I\n// add the code relying on import.meta, it fails in Jest environment, because\n// Jest does not support ES modules yet, and import.meta is not support in\n// CommonJS modules, and the \"babel-plugin-transform-import-meta\" plugin\n// we use to workaround this issue for import.meta.dirname, etc. does not\n// transform import.meta.webpackHot\n\n// It is a safeguard against multiple instances / versions of the library\n// being loaded into environment by mistake (e.g. because of different\n// packages pinning down different exact versions of the lib, thus preventing\n// a proper dedupe and using a single common library version).\n// if (global.REACT_UTILS_LIBRARY_LOADED) {\n// throw Error('React utils library is already loaded');\n// } else global.REACT_UTILS_LIBRARY_LOADED = true;\n\n/*\ndeclare global {\n // eslint-disable-next-line @typescript-eslint/consistent-type-definitions\n interface ImportMeta {\n webpackHot?: {\n dispose(cb: () => void): void;\n };\n }\n}\n\nif (import.meta.webpackHot) {\n import.meta.webpackHot.dispose(() => {\n delete global.REACT_UTILS_LIBRARY_LOADED;\n });\n}\n*/\n\nexport {\n type AsyncCollectionLoaderT,\n type AsyncCollectionT,\n type AsyncDataEnvelopeT,\n type AsyncDataLoaderT,\n type ForceT,\n GlobalStateProvider,\n type UseAsyncDataOptionsT,\n type UseAsyncDataResT,\n type UseGlobalStateResT,\n type ValueOrInitializerT,\n getGlobalState,\n newAsyncDataEnvelope,\n useAsyncCollection,\n useAsyncData,\n useGlobalState,\n withGlobalStateType,\n} from '@dr.pogodin/react-global-state';\n\nexport * from 'components';\n\nexport {\n type BeforeRenderResT,\n type BeforeRenderT,\n type ConfigT,\n type ServerSsrContext,\n type ServerT,\n} from './server';\n\nexport {\n Barrier,\n Cached,\n Emitter,\n type Listener,\n type ObjectKey,\n Semaphore,\n THEME_COMPOSE,\n THEME_PRIORITY,\n type Theme,\n ThemeProvider,\n assertEmptyObject,\n getConfig,\n getSsrContext,\n splitComponent,\n time,\n useTheme,\n webpack,\n withRetries,\n} from 'utils';\n\nexport * from 'utils/isomorphy';\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,EAEA,OAMEA,mBAAmB,CAKnBC,cAAc,CACdC,oBAAoB,CACpBC,kBAAkB,CAClBC,YAAY,CACZC,cAAc,CACdC,mBAAmB,KACd,gCAAgC,CAEvC,iCAUA,OACEC,OAAO,CACPC,MAAM,CACNC,OAAO,CAGPC,SAAS,CACTC,aAAa,CACbC,cAAc,CAEdC,aAAa,CACbC,iBAAiB,CACjBC,SAAS,CACTC,aAAa,CACbC,cAAc,CACdC,IAAI,CACJC,QAAQ,CACRC,OAAO,CACPC,WAAW,sBAGb","ignoreList":[]}
1
+ {"version":3,"file":"index.js","names":["GlobalStateProvider","newAsyncDataEnvelope","useAsyncCollection","useAsyncData","useGlobalState","useGlobalStateObject","withGlobalStateType","Barrier","Cached","Emitter","Semaphore","THEME_COMPOSE","THEME_PRIORITY","ThemeProvider","assertEmptyObject","getConfig","splitComponent","time","useSsrContext","useTheme","webpack","withRetries"],"sources":["../../src/index.ts"],"sourcesContent":["// TODO: For now I commented out this safeguard check, as I am not sure how\n// to easily make it work: it should not be triggered in HMR mode, but if I\n// add the code relying on import.meta, it fails in Jest environment, because\n// Jest does not support ES modules yet, and import.meta is not support in\n// CommonJS modules, and the \"babel-plugin-transform-import-meta\" plugin\n// we use to workaround this issue for import.meta.dirname, etc. does not\n// transform import.meta.webpackHot\n\n// It is a safeguard against multiple instances / versions of the library\n// being loaded into environment by mistake (e.g. because of different\n// packages pinning down different exact versions of the lib, thus preventing\n// a proper dedupe and using a single common library version).\n// if (global.REACT_UTILS_LIBRARY_LOADED) {\n// throw Error('React utils library is already loaded');\n// } else global.REACT_UTILS_LIBRARY_LOADED = true;\n\n/*\ndeclare global {\n // eslint-disable-next-line @typescript-eslint/consistent-type-definitions\n interface ImportMeta {\n webpackHot?: {\n dispose(cb: () => void): void;\n };\n }\n}\n\nif (import.meta.webpackHot) {\n import.meta.webpackHot.dispose(() => {\n delete global.REACT_UTILS_LIBRARY_LOADED;\n });\n}\n*/\n\nexport {\n type AsyncCollectionLoaderT,\n type AsyncCollectionT,\n type AsyncDataEnvelopeT,\n type AsyncDataLoaderT,\n type ForceT,\n GlobalStateProvider,\n type UseAsyncDataOptionsT,\n type UseAsyncDataResT,\n type UseGlobalStateResT,\n type ValueOrInitializerT,\n newAsyncDataEnvelope,\n useAsyncCollection,\n useAsyncData,\n useGlobalState,\n useGlobalStateObject,\n withGlobalStateType,\n} from '@dr.pogodin/react-global-state';\n\nexport * from 'components';\n\nexport {\n type BeforeRenderResT,\n type BeforeRenderT,\n type ConfigT,\n type ServerSsrContext,\n type ServerT,\n} from './server';\n\nexport {\n Barrier,\n Cached,\n Emitter,\n type Listener,\n type ObjectKey,\n Semaphore,\n THEME_COMPOSE,\n THEME_PRIORITY,\n type Theme,\n ThemeProvider,\n assertEmptyObject,\n getConfig,\n splitComponent,\n time,\n useSsrContext,\n useTheme,\n webpack,\n withRetries,\n} from 'utils';\n\nexport * from 'utils/isomorphy';\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,EAEA,OAMEA,mBAAmB,CAKnBC,oBAAoB,CACpBC,kBAAkB,CAClBC,YAAY,CACZC,cAAc,CACdC,oBAAoB,CACpBC,mBAAmB,KACd,gCAAgC,CAEvC,iCAUA,OACEC,OAAO,CACPC,MAAM,CACNC,OAAO,CAGPC,SAAS,CACTC,aAAa,CACbC,cAAc,CAEdC,aAAa,CACbC,iBAAiB,CACjBC,SAAS,CACTC,cAAc,CACdC,IAAI,CACJC,aAAa,CACbC,QAAQ,CACRC,OAAO,CACPC,WAAW,sBAGb","ignoreList":[]}
@@ -1,14 +1,3 @@
1
- // The <Button> component implements a standard button / button-like link.
2
- import{useTheme}from"@dr.pogodin/react-themes";import Link from"../Link";import defaultTheme from"./style.scss";import{jsx as _jsx}from"react/jsx-runtime";export const BaseButton=({active,children,disabled,enforceA,keepScrollPosition,onClick,onKeyDown:onKeyDownProp,onKeyUp,onMouseDown,onMouseUp,onPointerDown,onPointerUp,openNewTab,replace,testId,theme,to})=>{let className=theme.button;if(active&&theme.active)className+=` ${theme.active}`;if(disabled){if(theme.disabled)className+=` ${theme.disabled}`;return/*#__PURE__*/_jsx("div",{className:className,"data-testid":process.env.NODE_ENV==="production"?undefined:testId,children:children});}let onKeyDown=onKeyDownProp;if(!onKeyDown&&onClick){onKeyDown=e=>{if(e.key==="Enter")onClick(e);};}if(to){return/*#__PURE__*/_jsx(Link,{className:className,"data-testid":process.env.NODE_ENV==="production"?undefined:testId,enforceA:enforceA// TODO: This was exposed as a hotifx... however, I guess we better want
3
- // to check if the `to` URL contains an anchor (#), and if it does we should
4
- // automatically opt to keep the position here; and enforce <a> (as
5
- // react-router link does not seem to respect the hash tag either,
6
- // at least not without some additional settings).
7
- ,keepScrollPosition:keepScrollPosition,onClick:onClick// TODO: For now, the `onKeyDown` handler is not passed to the <Link>,
8
- // as <Link> component does not call it anyway, presumably due to
9
- // the inner implementation details. We should look into supporting it:
10
- // https://github.com/birdofpreyru/react-utils/issues/444
11
- // onKeyDown={onKeyDown}
12
- ,onKeyUp:onKeyUp,onMouseDown:onMouseDown,onMouseUp:onMouseUp,onPointerDown:onPointerDown,onPointerUp:onPointerUp,openNewTab:openNewTab,replace:replace,to:to,children:children});}return/*#__PURE__*/_jsx("div",{className:className,"data-testid":process.env.NODE_ENV==="production"?undefined:testId,onClick:onClick,onKeyDown:onKeyDown,onKeyUp:onKeyUp,onMouseDown:onMouseDown,onMouseUp:onMouseUp,onPointerDown:onPointerDown,onPointerUp:onPointerUp,role:"button",tabIndex:0,children:children});};const Button=({theme,...rest})=>{const composed=useTheme("Button",defaultTheme,theme);// eslint-disable-next-line react/jsx-props-no-spreading
13
- return/*#__PURE__*/_jsx(BaseButton,{...rest,theme:composed});};export default Button;
1
+ import{c as _c}from"react/compiler-runtime";// The <Button> component implements a standard button / button-like link.
2
+ import{useTheme}from"@dr.pogodin/react-themes";import Link from"../Link";import defaultTheme from"./style.scss";import{jsx as _jsx}from"react/jsx-runtime";export const BaseButton=t0=>{const $=_c(32);const{active,children,disabled,enforceA,keepScrollPosition,onClick,onKeyDown:onKeyDownProp,onKeyUp,onMouseDown,onMouseUp,onPointerDown,onPointerUp,openNewTab,replace,testId,theme,to}=t0;let className=theme.button;if(active&&theme.active){className=className+` ${theme.active}`;}if(disabled){if(theme.disabled){className=className+` ${theme.disabled}`;}const t1=process.env.NODE_ENV==="production"?undefined:testId;let t2;if($[0]!==children||$[1]!==className||$[2]!==t1){t2=/*#__PURE__*/_jsx("div",{className:className,"data-testid":t1,children:children});$[0]=children;$[1]=className;$[2]=t1;$[3]=t2}else{t2=$[3]}return t2}let onKeyDown=onKeyDownProp;if(!onKeyDown&&onClick){let t1;if($[4]!==onClick){t1=e=>{if(e.key==="Enter"){onClick(e)}};$[4]=onClick;$[5]=t1}else{t1=$[5]}onKeyDown=t1;}if(to){const t1=process.env.NODE_ENV==="production"?undefined:testId;let t2;if($[6]!==children||$[7]!==className||$[8]!==enforceA||$[9]!==keepScrollPosition||$[10]!==onClick||$[11]!==onKeyUp||$[12]!==onMouseDown||$[13]!==onMouseUp||$[14]!==onPointerDown||$[15]!==onPointerUp||$[16]!==openNewTab||$[17]!==replace||$[18]!==t1||$[19]!==to){t2=/*#__PURE__*/_jsx(Link,{className:className,"data-testid":t1,enforceA:enforceA,keepScrollPosition:keepScrollPosition,onClick:onClick,onKeyUp:onKeyUp,onMouseDown:onMouseDown,onMouseUp:onMouseUp,onPointerDown:onPointerDown,onPointerUp:onPointerUp,openNewTab:openNewTab,replace:replace,to:to,children:children});$[6]=children;$[7]=className;$[8]=enforceA;$[9]=keepScrollPosition;$[10]=onClick;$[11]=onKeyUp;$[12]=onMouseDown;$[13]=onMouseUp;$[14]=onPointerDown;$[15]=onPointerUp;$[16]=openNewTab;$[17]=replace;$[18]=t1;$[19]=to;$[20]=t2}else{t2=$[20]}return t2}const t1=process.env.NODE_ENV==="production"?undefined:testId;let t2;if($[21]!==children||$[22]!==className||$[23]!==onClick||$[24]!==onKeyDown||$[25]!==onKeyUp||$[26]!==onMouseDown||$[27]!==onMouseUp||$[28]!==onPointerDown||$[29]!==onPointerUp||$[30]!==t1){t2=/*#__PURE__*/_jsx("div",{className:className,"data-testid":t1,onClick:onClick,onKeyDown:onKeyDown,onKeyUp:onKeyUp,onMouseDown:onMouseDown,onMouseUp:onMouseUp,onPointerDown:onPointerDown,onPointerUp:onPointerUp,role:"button",tabIndex:0,children:children});$[21]=children;$[22]=className;$[23]=onClick;$[24]=onKeyDown;$[25]=onKeyUp;$[26]=onMouseDown;$[27]=onMouseUp;$[28]=onPointerDown;$[29]=onPointerUp;$[30]=t1;$[31]=t2}else{t2=$[31]}return t2};const Button=t0=>{const $=_c(6);let rest;let theme;if($[0]!==t0){({theme,...rest}=t0);$[0]=t0;$[1]=rest;$[2]=theme}else{rest=$[1];theme=$[2]}const composed=useTheme("Button",defaultTheme,theme);let t1;if($[3]!==composed||$[4]!==rest){t1=/*#__PURE__*/_jsx(BaseButton,{...rest,theme:composed});$[3]=composed;$[4]=rest;$[5]=t1}else{t1=$[5]}return t1};export default Button;
14
3
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":["useTheme","Link","defaultTheme","jsx","_jsx","BaseButton","active","children","disabled","enforceA","keepScrollPosition","onClick","onKeyDown","onKeyDownProp","onKeyUp","onMouseDown","onMouseUp","onPointerDown","onPointerUp","openNewTab","replace","testId","theme","to","className","button","process","env","NODE_ENV","undefined","e","key","role","tabIndex","Button","rest","composed"],"sources":["../../../../../src/shared/components/Button/index.tsx"],"sourcesContent":["// The <Button> component implements a standard button / button-like link.\n\nimport type {\n FunctionComponent,\n KeyboardEventHandler,\n MouseEventHandler,\n PointerEventHandler,\n ReactNode,\n} from 'react';\n\nimport { type Theme, useTheme } from '@dr.pogodin/react-themes';\n\nimport Link from 'components/Link';\n\nimport defaultTheme from './style.scss';\n\ntype ThemeT = Theme<'active' | 'button' | 'disabled'>;\n\ntype PropsT = {\n active?: boolean;\n children?: ReactNode;\n disabled?: boolean;\n enforceA?: boolean;\n keepScrollPosition?: boolean;\n onClick?: KeyboardEventHandler & MouseEventHandler;\n onKeyDown?: KeyboardEventHandler;\n onKeyUp?: KeyboardEventHandler;\n onMouseDown?: MouseEventHandler;\n onMouseUp?: MouseEventHandler;\n onPointerDown?: PointerEventHandler;\n onPointerUp?: PointerEventHandler;\n openNewTab?: boolean;\n replace?: boolean;\n testId?: string;\n theme: ThemeT;\n\n // TODO: It needs a more precise typing of the object option.\n to?: object | string;\n};\n\nexport const BaseButton: FunctionComponent<PropsT> = ({\n active,\n children,\n disabled,\n enforceA,\n keepScrollPosition,\n onClick,\n onKeyDown: onKeyDownProp,\n onKeyUp,\n onMouseDown,\n onMouseUp,\n onPointerDown,\n onPointerUp,\n openNewTab,\n replace,\n testId,\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\n className={className}\n data-testid={process.env.NODE_ENV === 'production' ? undefined : testId}\n >\n {children}\n </div>\n );\n }\n\n let onKeyDown = onKeyDownProp;\n if (!onKeyDown && onClick) {\n onKeyDown = (e) => {\n if (e.key === 'Enter') onClick(e);\n };\n }\n\n if (to) {\n return (\n <Link\n className={className}\n data-testid={process.env.NODE_ENV === 'production' ? undefined : testId}\n enforceA={enforceA}\n\n // TODO: This was exposed as a hotifx... however, I guess we better want\n // to check if the `to` URL contains an anchor (#), and if it does we should\n // automatically opt to keep the position here; and enforce <a> (as\n // react-router link does not seem to respect the hash tag either,\n // at least not without some additional settings).\n keepScrollPosition={keepScrollPosition}\n\n onClick={onClick}\n\n // TODO: For now, the `onKeyDown` handler is not passed to the <Link>,\n // as <Link> component does not call it anyway, presumably due to\n // the inner implementation details. We should look into supporting it:\n // https://github.com/birdofpreyru/react-utils/issues/444\n // onKeyDown={onKeyDown}\n\n onKeyUp={onKeyUp}\n onMouseDown={onMouseDown}\n onMouseUp={onMouseUp}\n onPointerDown={onPointerDown}\n onPointerUp={onPointerUp}\n openNewTab={openNewTab}\n replace={replace}\n to={to}\n >\n {children}\n </Link>\n );\n }\n\n return (\n <div\n className={className}\n data-testid={process.env.NODE_ENV === 'production' ? undefined : testId}\n onClick={onClick}\n onKeyDown={onKeyDown}\n onKeyUp={onKeyUp}\n onMouseDown={onMouseDown}\n onMouseUp={onMouseUp}\n onPointerDown={onPointerDown}\n onPointerUp={onPointerUp}\n role=\"button\"\n tabIndex={0}\n >\n {children}\n </div>\n );\n};\n\nconst Button: FunctionComponent<\n Omit<PropsT, 'theme'> & { theme?: ThemeT }\n> = ({ theme, ...rest }) => {\n const composed = useTheme('Button', defaultTheme, theme);\n\n // eslint-disable-next-line react/jsx-props-no-spreading\n return <BaseButton {...rest} theme={composed} />;\n};\n\nexport default Button;\n"],"mappings":"AAAA;AAUA,OAAqBA,QAAQ,KAAQ,0BAA0B,CAE/D,MAAO,CAAAC,IAAI,eAEX,MAAO,CAAAC,YAAY,oBAAqB,OAAAC,GAAA,IAAAC,IAAA,yBA0BxC,MAAO,MAAM,CAAAC,UAAqC,CAAGA,CAAC,CACpDC,MAAM,CACNC,QAAQ,C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AEA,SAAU,CACrBC,aAAa,CAAEA,aAAc,CAC7BC,WAAW,CAAEA,WAAY,CACzBC,UAAU,CAAEA,UAAW,CACvBC,OAAO,CAAEA,OAAQ,CACjBG,EAAE,CAAEA,EAAG,CAAAhB,QAAA,CAENA,QAAQ,CACL,CAAC,CAEX,CAEA,mBACEH,IAAA,QACEoB,SAAS,CAAEA,SAAU,CACrB,cAAaE,OAAO,CAACC,GAAG,CAACC,QAAQ,GAAK,YAAY,CAAGC,SAAS,CAAGR,MAAO,CACxEV,OAAO,CAAEA,OAAQ,CACjBC,SAAS,CAAEA,SAAU,CACrBE,OAAO,CAAEA,OAAQ,CACjBC,WAAW,CAAEA,WAAY,CACzBC,SAAS,CAAEA,SAAU,CACrBC,aAAa,CAAEA,aAAc,CAC7BC,WAAW,CAAEA,WAAY,CACzBc,IAAI,CAAC,QAAQ,CACbC,QAAQ,CAAE,CAAE,CAAA1B,QAAA,CAEXA,QAAQ,CACN,CAAC,CAEV,CAAC,CAED,KAAM,CAAA2B,MAEL,CAAGA,CAAC,CAAEZ,KAAK,CAAE,GAAGa,IAAK,CAAC,GAAK,CAC1B,KAAM,CAAAC,QAAQ,CAAGpC,QAAQ,CAAC,QAAQ,CAAEE,YAAY,CAAEoB,KAAK,CAAC,CAExD;AACA,mBAAOlB,IAAA,CAACC,UAAU,KAAK8B,IAAI,CAAEb,KAAK,CAAEc,QAAS,CAAE,CAAC,CAClD,CAAC,CAED,cAAe,CAAAF,MAAM","ignoreList":[]}
1
+ {"version":3,"file":"index.js","names":["useTheme","Link","defaultTheme","jsx","_jsx","BaseButton","t0","$","_c","active","children","disabled","enforceA","keepScrollPosition","onClick","onKeyDown","onKeyDownProp","onKeyUp","onMouseDown","onMouseUp","onPointerDown","onPointerUp","openNewTab","replace","testId","theme","to","className","button","t1","process","env","NODE_ENV","undefined","t2","e","key","role","tabIndex","Button","rest","composed"],"sources":["../../../../../src/shared/components/Button/index.tsx"],"sourcesContent":["// The <Button> component implements a standard button / button-like link.\n\nimport type {\n FunctionComponent,\n KeyboardEventHandler,\n MouseEventHandler,\n PointerEventHandler,\n ReactNode,\n} from 'react';\n\nimport { type Theme, useTheme } from '@dr.pogodin/react-themes';\n\nimport Link from 'components/Link';\n\nimport defaultTheme from './style.scss';\n\ntype ThemeT = Theme<'active' | 'button' | 'disabled'>;\n\ntype PropsT = {\n active?: boolean;\n children?: ReactNode;\n disabled?: boolean;\n enforceA?: boolean;\n keepScrollPosition?: boolean;\n onClick?: KeyboardEventHandler & MouseEventHandler;\n onKeyDown?: KeyboardEventHandler;\n onKeyUp?: KeyboardEventHandler;\n onMouseDown?: MouseEventHandler;\n onMouseUp?: MouseEventHandler;\n onPointerDown?: PointerEventHandler;\n onPointerUp?: PointerEventHandler;\n openNewTab?: boolean;\n replace?: boolean;\n testId?: string;\n theme: ThemeT;\n\n // TODO: It needs a more precise typing of the object option.\n to?: object | string;\n};\n\nexport const BaseButton: FunctionComponent<PropsT> = ({\n active,\n children,\n disabled,\n enforceA,\n keepScrollPosition,\n onClick,\n onKeyDown: onKeyDownProp,\n onKeyUp,\n onMouseDown,\n onMouseUp,\n onPointerDown,\n onPointerUp,\n openNewTab,\n replace,\n testId,\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\n className={className}\n data-testid={process.env.NODE_ENV === 'production' ? undefined : testId}\n >\n {children}\n </div>\n );\n }\n\n let onKeyDown = onKeyDownProp;\n if (!onKeyDown && onClick) {\n onKeyDown = (e) => {\n if (e.key === 'Enter') onClick(e);\n };\n }\n\n if (to) {\n return (\n <Link\n className={className}\n data-testid={process.env.NODE_ENV === 'production' ? undefined : testId}\n enforceA={enforceA}\n\n // TODO: This was exposed as a hotifx... however, I guess we better want\n // to check if the `to` URL contains an anchor (#), and if it does we should\n // automatically opt to keep the position here; and enforce <a> (as\n // react-router link does not seem to respect the hash tag either,\n // at least not without some additional settings).\n keepScrollPosition={keepScrollPosition}\n\n onClick={onClick}\n\n // TODO: For now, the `onKeyDown` handler is not passed to the <Link>,\n // as <Link> component does not call it anyway, presumably due to\n // the inner implementation details. We should look into supporting it:\n // https://github.com/birdofpreyru/react-utils/issues/444\n // onKeyDown={onKeyDown}\n\n onKeyUp={onKeyUp}\n onMouseDown={onMouseDown}\n onMouseUp={onMouseUp}\n onPointerDown={onPointerDown}\n onPointerUp={onPointerUp}\n openNewTab={openNewTab}\n replace={replace}\n to={to}\n >\n {children}\n </Link>\n );\n }\n\n return (\n <div\n className={className}\n data-testid={process.env.NODE_ENV === 'production' ? undefined : testId}\n onClick={onClick}\n onKeyDown={onKeyDown}\n onKeyUp={onKeyUp}\n onMouseDown={onMouseDown}\n onMouseUp={onMouseUp}\n onPointerDown={onPointerDown}\n onPointerUp={onPointerUp}\n role=\"button\"\n tabIndex={0}\n >\n {children}\n </div>\n );\n};\n\nconst Button: FunctionComponent<\n Omit<PropsT, 'theme'> & { theme?: ThemeT }\n> = ({ theme, ...rest }) => {\n const composed = useTheme('Button', defaultTheme, theme);\n\n // eslint-disable-next-line react/jsx-props-no-spreading\n return <BaseButton {...rest} theme={composed} />;\n};\n\nexport default Button;\n"],"mappings":"4CAAA;AAUA,OAAqBA,QAAQ,KAAQ,0BAA0B,CAE/D,MAAO,CAAAC,IAAI,eAEX,MAAO,CAAAC,YAAY,oBAAqB,OAAAC,GAAA,IAAAC,IAAA,yBA0BxC,MAAO,MAAM,CAAAC,UAAqC,CAAGC,EAAA,SAAAC,CAAA,CAAAC,EAAA,KAAC,MAAAC,MAAA,CAAAC,QAAA,CAAAC,QAAA,CAAAC,QAAA,CAAAC,kBAAA,CAAAC,OAAA,CAAAC,SAAA,CAAAC,aAAA,CAAAC,OAAA,CAAAC,WAAA,CAAAC,SAAA,CAAAC,aAAA,CAAAC,WAAA,CAAAC,UAAA,CAAAC,OAAA,CAAAC,MAAA,CAAAC,KAAA,CAAAC,EAAA,EAAApB,EAkBrD,CACC,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AA,IACrB,MAAAkC,QAAA,CAAiBzC,QAAQ,CAAC,QAAQ,CAAEE,YAAY,CAAEuB,KAAK,CAAC,CAAC,IAAAI,EAAA,IAAAtB,CAAA,MAAAkC,QAAA,EAAAlC,CAAA,MAAAiC,IAAA,EAGlDX,EAAA,cAAAzB,IAAA,CAACC,UAAU,KAAKmC,IAAI,CAASC,KAAQ,CAARA,QAAQ,CAAG,CAAC,CAAAlC,CAAA,IAAAkC,QAAAlC,CAAA,KAAAiC,IAAAjC,CAAA,KAAAsB,EAAA,MAAAA,EAAA,CAAAtB,CAAA,UAAzC,CAAAsB,EAAyC,CACjD,CAED,cAAe,CAAAU,MAAM","ignoreList":[]}
@@ -1,2 +1,2 @@
1
- import{useTheme}from"@dr.pogodin/react-themes";import defaultTheme from"./theme.scss";import{jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";const Checkbox=({checked,disabled,error,label,onChange,testId,theme})=>{const composed=useTheme("Checkbox",defaultTheme,theme);let containerClassName=composed.container;if(disabled)containerClassName+=` ${composed.disabled}`;let checkboxClassName=composed.checkbox;if(checked==="indeterminate")checkboxClassName+=` ${composed.indeterminate}`;if(error)containerClassName+=` ${composed.error}`;return/*#__PURE__*/_jsxs("div",{className:containerClassName,children:[label===undefined?null:/*#__PURE__*/_jsx("div",{className:composed.label,children:label}),/*#__PURE__*/_jsx("input",{checked:checked===undefined?undefined:checked===true,className:checkboxClassName,"data-testid":process.env.NODE_ENV==="production"?undefined:testId,disabled:disabled,onChange:onChange,onClick:e=>{e.stopPropagation();},type:"checkbox"}),error&&error!==true?/*#__PURE__*/_jsx("div",{className:composed.errorMessage,children:error}):null]});};export default Checkbox;
1
+ import{c as _c}from"react/compiler-runtime";import{useTheme}from"@dr.pogodin/react-themes";import defaultTheme from"./theme.scss";import{jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";const Checkbox=t0=>{const $=_c(17);const{checked,disabled,error,label,onChange,testId,theme}=t0;const composed=useTheme("Checkbox",defaultTheme,theme);let containerClassName=composed.container;if(disabled){containerClassName=containerClassName+` ${composed.disabled}`;}let checkboxClassName=composed.checkbox;if(checked==="indeterminate"){checkboxClassName=checkboxClassName+` ${composed.indeterminate}`;}if(error){containerClassName=containerClassName+` ${composed.error}`;}let t1;if($[0]!==composed.label||$[1]!==label){t1=label===undefined?null:/*#__PURE__*/_jsx("div",{className:composed.label,children:label});$[0]=composed.label;$[1]=label;$[2]=t1}else{t1=$[2]}const t2=checked===undefined?undefined:checked===true;const t3=process.env.NODE_ENV==="production"?undefined:testId;let t4;if($[3]!==checkboxClassName||$[4]!==disabled||$[5]!==onChange||$[6]!==t2||$[7]!==t3){t4=/*#__PURE__*/_jsx("input",{checked:t2,className:checkboxClassName,"data-testid":t3,disabled:disabled,onChange:onChange,onClick:_temp,type:"checkbox"});$[3]=checkboxClassName;$[4]=disabled;$[5]=onChange;$[6]=t2;$[7]=t3;$[8]=t4}else{t4=$[8]}let t5;if($[9]!==composed.errorMessage||$[10]!==error){t5=error&&error!==true?/*#__PURE__*/_jsx("div",{className:composed.errorMessage,children:error}):null;$[9]=composed.errorMessage;$[10]=error;$[11]=t5}else{t5=$[11]}let t6;if($[12]!==containerClassName||$[13]!==t1||$[14]!==t4||$[15]!==t5){t6=/*#__PURE__*/_jsxs("div",{className:containerClassName,children:[t1,t4,t5]});$[12]=containerClassName;$[13]=t1;$[14]=t4;$[15]=t5;$[16]=t6}else{t6=$[16]}return t6};export default Checkbox;function _temp(e){e.stopPropagation()}
2
2
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":["useTheme","defaultTheme","jsx","_jsx","jsxs","_jsxs","Checkbox","checked","disabled","error","label","onChange","testId","theme","composed","containerClassName","container","checkboxClassName","checkbox","indeterminate","className","children","undefined","process","env","NODE_ENV","onClick","e","stopPropagation","type","errorMessage"],"sources":["../../../../../src/shared/components/Checkbox/index.tsx"],"sourcesContent":["import type { ReactNode } from 'react';\n\nimport { type Theme, useTheme } from '@dr.pogodin/react-themes';\n\nimport defaultTheme from './theme.scss';\n\ntype PropT<ValueT> = {\n checked?: ValueT;\n disabled?: boolean;\n error?: ReactNode;\n label?: React.ReactNode;\n onChange?: React.ChangeEventHandler<HTMLInputElement>;\n testId?: string;\n theme?: Theme<\n | 'checkbox'\n | 'container'\n | 'disabled'\n | 'error'\n | 'errorMessage'\n | 'indeterminate'\n | 'label'\n >;\n};\n\nconst Checkbox = <ValueT extends 'indeterminate' | boolean = boolean>({\n checked,\n disabled,\n error,\n label,\n onChange,\n testId,\n theme,\n}: PropT<ValueT>): ReactNode => {\n const composed = useTheme('Checkbox', defaultTheme, theme);\n\n let containerClassName = composed.container;\n if (disabled) containerClassName += ` ${composed.disabled}`;\n\n let checkboxClassName = composed.checkbox;\n if (checked === 'indeterminate') checkboxClassName += ` ${composed.indeterminate}`;\n\n if (error) containerClassName += ` ${composed.error}`;\n\n return (\n <div className={containerClassName}>\n { label === undefined\n ? null : <div className={composed.label}>{label}</div> }\n <input\n checked={checked === undefined ? undefined : checked === true}\n className={checkboxClassName}\n data-testid={process.env.NODE_ENV === 'production' ? undefined : testId}\n disabled={disabled}\n onChange={onChange}\n onClick={(e) => {\n e.stopPropagation();\n }}\n type=\"checkbox\"\n />\n {error && error !== true\n ? <div className={composed.errorMessage}>{error}</div>\n : null}\n </div>\n );\n};\n\nexport default Checkbox;\n"],"mappings":"AAEA,OAAqBA,QAAQ,KAAQ,0BAA0B,CAE/D,MAAO,CAAAC,YAAY,oBAAqB,OAAAC,GAAA,IAAAC,IAAA,CAAAC,IAAA,IAAAC,KAAA,yBAoBxC,KAAM,CAAAC,QAAQ,CAAGA,CAAqD,CACpEC,OAAO,CACPC,QAAQ,CACRC,KAAK,CACLC,KAAK,CACLC,QAAQ,CACRC,MAAM,CACNC,KACa,CAAC,GAAgB,CAC9B,KAAM,CAAAC,QAAQ,CAAGd,QAAQ,CAAC,UAAU,CAAEC,YAAY,CAAEY,KAAK,CAAC,CAE1D,GAAI,CAAAE,kBAAkB,CAAGD,QAAQ,CAACE,SAAS,CAC3C,GAAIR,QAAQ,CAAEO,kBAAkB,EAAI,IAAID,QAAQ,CAACN,QAAQ,EAAE,CAE3D,GAAI,CAAAS,iBAAiB,CAAGH,QAAQ,CAACI,QAAQ,CACzC,GAAIX,OAAO,GAAK,eAAe,CAAEU,iBAAiB,EAAI,IAAIH,QAAQ,CAACK,aAAa,EAAE,CAElF,GAAIV,KAAK,CAAEM,kBAAkB,EAAI,IAAID,QAAQ,CAACL,KAAK,EAAE,CAErD,mBACEJ,KAAA,QAAKe,SAAS,CAAEL,kBAAmB,CAAAM,QAAA,EAC/BX,KAAK,GAAKY,SAAS,CACjB,IAAI,cAAGnB,IAAA,QAAKiB,SAAS,CAAEN,QAAQ,CAACJ,KAAM,CAAAW,QAAA,CAAEX,KAAK,CAAM,CAAC,cACxDP,IAAA,UACEI,OAAO,CAAEA,OAAO,GAAKe,SAAS,CAAGA,SAAS,CAAGf,OAAO,GAAK,IAAK,CAC9Da,SAAS,CAAEH,iBAAkB,CAC7B,cAAaM,OAAO,CAACC,GAAG,CAACC,QAAQ,GAAK,YAAY,CAAGH,SAAS,CAAGV,MAAO,CACxEJ,QAAQ,CAAEA,QAAS,CACnBG,QAAQ,CAAEA,QAAS,CACnBe,OAAO,CAAGC,CAAC,EAAK,CACdA,CAAC,CAACC,eAAe,CAAC,CAAC,CACrB,CAAE,CACFC,IAAI,CAAC,UAAU,CAChB,CAAC,CACDpB,KAAK,EAAIA,KAAK,GAAK,IAAI,cACpBN,IAAA,QAAKiB,SAAS,CAAEN,QAAQ,CAACgB,YAAa,CAAAT,QAAA,CAAEZ,KAAK,CAAM,CAAC,CACpD,IAAI,EACL,CAAC,CAEV,CAAC,CAED,cAAe,CAAAH,QAAQ","ignoreList":[]}
1
+ {"version":3,"file":"index.js","names":["useTheme","defaultTheme","jsx","_jsx","jsxs","_jsxs","Checkbox","t0","$","_c","checked","disabled","error","label","onChange","testId","theme","composed","containerClassName","container","checkboxClassName","checkbox","indeterminate","t1","undefined","className","children","t2","t3","process","env","NODE_ENV","t4","onClick","_temp","type","t5","errorMessage","t6","e","stopPropagation"],"sources":["../../../../../src/shared/components/Checkbox/index.tsx"],"sourcesContent":["import type { ReactNode } from 'react';\n\nimport { type Theme, useTheme } from '@dr.pogodin/react-themes';\n\nimport defaultTheme from './theme.scss';\n\ntype PropT<ValueT> = {\n checked?: ValueT;\n disabled?: boolean;\n error?: ReactNode;\n label?: React.ReactNode;\n onChange?: React.ChangeEventHandler<HTMLInputElement>;\n testId?: string;\n theme?: Theme<\n | 'checkbox'\n | 'container'\n | 'disabled'\n | 'error'\n | 'errorMessage'\n | 'indeterminate'\n | 'label'\n >;\n};\n\nconst Checkbox = <ValueT extends 'indeterminate' | boolean = boolean>({\n checked,\n disabled,\n error,\n label,\n onChange,\n testId,\n theme,\n}: PropT<ValueT>): ReactNode => {\n const composed = useTheme('Checkbox', defaultTheme, theme);\n\n let containerClassName = composed.container;\n if (disabled) containerClassName += ` ${composed.disabled}`;\n\n let checkboxClassName = composed.checkbox;\n if (checked === 'indeterminate') checkboxClassName += ` ${composed.indeterminate}`;\n\n if (error) containerClassName += ` ${composed.error}`;\n\n return (\n <div className={containerClassName}>\n { label === undefined\n ? null : <div className={composed.label}>{label}</div> }\n <input\n checked={checked === undefined ? undefined : checked === true}\n className={checkboxClassName}\n data-testid={process.env.NODE_ENV === 'production' ? undefined : testId}\n disabled={disabled}\n onChange={onChange}\n onClick={(e) => {\n e.stopPropagation();\n }}\n type=\"checkbox\"\n />\n {error && error !== true\n ? <div className={composed.errorMessage}>{error}</div>\n : null}\n </div>\n );\n};\n\nexport default Checkbox;\n"],"mappings":"4CAEA,OAAqBA,QAAQ,KAAQ,0BAA0B,CAE/D,MAAO,CAAAC,YAAY,oBAAqB,OAAAC,GAAA,IAAAC,IAAA,CAAAC,IAAA,IAAAC,KAAA,yBAoBxC,KAAM,CAAAC,QAAQ,CAAGC,EAAA,SAAAC,CAAA,CAAAC,EAAA,K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hC,QAAQ,CAzCN,SAAA4B,MAAAK,CAAA,EA8BPA,CAAC,CAAAC,eAAgB,CAAC,CAAC","ignoreList":[]}
@@ -1,4 +1,4 @@
1
- import S from"./style.scss";import{jsx as _jsx}from"react/jsx-runtime";/**
1
+ import{c as _c}from"react/compiler-runtime";import S from"./style.scss";import{jsx as _jsx}from"react/jsx-runtime";/**
2
2
  * The `<Link>` component, and almost identical `<NavLink>` component, are
3
3
  * auxiliary wrappers around
4
4
  * [React Router](https://github.com/ReactTraining/react-router)'s
@@ -37,18 +37,5 @@ import S from"./style.scss";import{jsx as _jsx}from"react/jsx-runtime";/**
37
37
  * slash on a location’s pathname will be taken into consideration when
38
38
  * determining if the location matches the current URL. See the `<Route strict>`
39
39
  * documentation for more information.
40
- */const GenericLink=({children,className,disabled,enforceA,keepScrollPosition,onClick,onMouseDown,openNewTab,replace,routerLinkType,to,...rest})=>{/* Renders Link as <a> element if:
41
- * - It is opted explicitely by `enforceA` prop;
42
- * - It should be opened in a new tab;
43
- * - It is an absolte URL (starts with http:// or https://);
44
- * - It is anchor link (starts with #). */if(disabled||enforceA||openNewTab||to.match(/^(#|(https?|mailto):)/)){let aClassName=S.link;if(className)aClassName+=` ${className}`;return/*#__PURE__*/_jsx("a",{className:aClassName// TODO: This requires a fix: disabled is not really an attribute of <a>
45
- // tag, thus for disabled option we rather should render a plain text
46
- // styled as a link.
47
- // disabled={disabled}
48
- ,href:to,onClick:disabled?e=>{e.preventDefault();}:onClick,onMouseDown:disabled?e=>{e.preventDefault();}:onMouseDown,rel:"noopener noreferrer",styleName:"link",target:openNewTab?"_blank":"",children:children});}const L=routerLinkType;return/*#__PURE__*/_jsx(L,{className:className,discover:"none"// disabled
49
- ,onClick:e=>{// Executes the user-provided event handler, if any.
50
- if(onClick)onClick(e);// By default, clicking the link scrolls the page to beginning.
51
- if(!keepScrollPosition)window.scroll(0,0);},onMouseDown:onMouseDown,replace:replace,to:to// TODO: Refactor it later.
52
- // eslint-disable-next-line react/jsx-props-no-spreading
53
- ,...rest,children:children});};export default GenericLink;
40
+ */const GenericLink=t0=>{const $=_c(32);let children;let className;let disabled;let enforceA;let keepScrollPosition;let onClick;let onMouseDown;let openNewTab;let replace;let rest;let routerLinkType;let to;if($[0]!==t0){({children,className,disabled,enforceA,keepScrollPosition,onClick,onMouseDown,openNewTab,replace,routerLinkType,to,...rest}=t0);$[0]=t0;$[1]=children;$[2]=className;$[3]=disabled;$[4]=enforceA;$[5]=keepScrollPosition;$[6]=onClick;$[7]=onMouseDown;$[8]=openNewTab;$[9]=replace;$[10]=rest;$[11]=routerLinkType;$[12]=to}else{children=$[1];className=$[2];disabled=$[3];enforceA=$[4];keepScrollPosition=$[5];onClick=$[6];onMouseDown=$[7];openNewTab=$[8];replace=$[9];rest=$[10];routerLinkType=$[11];to=$[12]}if(disabled||enforceA||openNewTab||to.match(/^(#|(https?|mailto):)/)){let aClassName=S.link;if(className){aClassName=aClassName+` ${className}`;}const t1=to;const t2=disabled?_temp:onClick;const t3=disabled?_temp2:onMouseDown;const t4=openNewTab?"_blank":"";let t5;if($[13]!==aClassName||$[14]!==children||$[15]!==t1||$[16]!==t2||$[17]!==t3||$[18]!==t4){t5=/*#__PURE__*/_jsx("a",{className:aClassName,href:t1,onClick:t2,onMouseDown:t3,rel:"noopener noreferrer",styleName:"link",target:t4,children:children});$[13]=aClassName;$[14]=children;$[15]=t1;$[16]=t2;$[17]=t3;$[18]=t4;$[19]=t5}else{t5=$[19]}return t5}const L=routerLinkType;let t1;if($[20]!==keepScrollPosition||$[21]!==onClick){t1=e_1=>{if(onClick){onClick(e_1)}if(!keepScrollPosition){window.scroll(0,0)}};$[20]=keepScrollPosition;$[21]=onClick;$[22]=t1}else{t1=$[22]}let t2;if($[23]!==L||$[24]!==children||$[25]!==className||$[26]!==onMouseDown||$[27]!==replace||$[28]!==rest||$[29]!==t1||$[30]!==to){t2=/*#__PURE__*/_jsx(L,{className:className,discover:"none",onClick:t1,onMouseDown:onMouseDown,replace:replace,to:to,...rest,children:children});$[23]=L;$[24]=children;$[25]=className;$[26]=onMouseDown;$[27]=replace;$[28]=rest;$[29]=t1;$[30]=to;$[31]=t2}else{t2=$[31]}return t2};export default GenericLink;function _temp(e){e.preventDefault()}function _temp2(e_0){e_0.preventDefault()}
54
41
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":["S","jsx","_jsx","GenericLink","children","className","disabled","enforceA","keepScrollPosition","onClick","onMouseDown","openNewTab","replace","routerLinkType","to","rest","match","aClassName","link","href","e","preventDefault","rel","styleName","target","L","discover","window","scroll"],"sources":["../../../../../src/shared/components/GenericLink/index.tsx"],"sourcesContent":["import type { ReactNode } from 'react';\n\nimport type {\n Link,\n LinkProps,\n NavLink,\n NavLinkProps,\n} from 'react-router';\n\nimport S from './style.scss';\n\ntype LinkT = typeof Link;\ntype NavLinkT = typeof NavLink;\n\ntype ToT = Parameters<typeof Link>[0]['to'];\n\nexport type PropsT = {\n children?: ReactNode;\n className?: string;\n disabled?: boolean;\n enforceA?: boolean;\n keepScrollPosition?: boolean;\n onClick?: React.MouseEventHandler<HTMLAnchorElement>;\n onMouseDown?: React.MouseEventHandler<HTMLAnchorElement>;\n openNewTab?: boolean;\n replace?: boolean;\n routerLinkType: LinkT | NavLinkT;\n to: ToT;\n};\n\n/**\n * The `<Link>` component, and almost identical `<NavLink>` component, are\n * auxiliary wrappers around\n * [React Router](https://github.com/ReactTraining/react-router)'s\n * `<Link>` and `<NavLink>` components; they help to handle external and\n * internal links in uniform manner.\n *\n * @param [props] Component properties.\n * @param [props.className] CSS classes to apply to the link.\n * @param [props.disabled] Disables the link.\n * @param [props.enforceA] `true` enforces rendering of the link as\n * a simple `<a>` element.\n * @param [props.keepScrollPosition] If `true`, and the link is\n * rendered as a React Router's component, it won't reset the viewport scrolling\n * position to the origin when clicked.\n * @param [props.onClick] Event handler to trigger upon click.\n * @param [props.onMouseDown] Event handler to trigger on MouseDown\n * event.\n * @param [props.openNewTab] If `true` the link opens in a new tab.\n * @param [props.replace] When `true`, the link will replace current\n * entry in the history stack instead of adding a new one.\n * @param [props.to] Link URL.\n * @param [props.activeClassName] **`<NavLink>`** only: CSS class(es)\n * to apply to rendered link when it is active.\n * @param [props.activeStyle] **`<NavLink>`** only: CSS styles\n * to apply to the rendered link when it is active.\n * @param [props.exact] **`<NavLink>`** only: if `true`, the active\n * class/style will only be applied if the location is matched exactly.\n * @param [props.isActive] **`<NavLink>`** only: Add extra\n * logic for determining whether the link is active. This should be used if you\n * want to do more than verify that the link’s pathname matches the current URL\n * pathname.\n * @param [props.location] **`<NavLink>`** only: `isActive` compares\n * current history location (usually the current browser URL). To compare to\n * a different location, a custom `location` can be passed.\n * @param [props.strict] **`<NavLink>`** only: . When `true`, trailing\n * slash on a location’s pathname will be taken into consideration when\n * determining if the location matches the current URL. See the `<Route strict>`\n * documentation for more information.\n */\nconst GenericLink = ({\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}: (LinkProps | NavLinkProps) & PropsT): ReactNode => {\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\n || (to as string).match(/^(#|(https?|mailto):)/)) {\n let aClassName: string = S.link;\n if (className) aClassName += ` ${className}`;\n\n return (\n <a\n className={aClassName}\n // TODO: This requires a fix: disabled is not really an attribute of <a>\n // tag, thus for disabled option we rather should render a plain text\n // styled as a link.\n // disabled={disabled}\n href={to as string}\n onClick={disabled ? (e) => {\n e.preventDefault();\n } : onClick}\n onMouseDown={disabled ? (e) => {\n e.preventDefault();\n } : onMouseDown}\n rel=\"noopener noreferrer\"\n styleName=\"link\"\n target={openNewTab ? '_blank' : ''}\n >\n {children}\n </a>\n );\n }\n\n const L = routerLinkType;\n\n return (\n <L\n className={className}\n discover=\"none\"\n // disabled\n onClick={(e: React.MouseEvent<HTMLAnchorElement>) => {\n // Executes the user-provided event handler, if any.\n if (onClick) onClick(e);\n\n // By default, clicking the link scrolls the page to beginning.\n if (!keepScrollPosition) window.scroll(0, 0);\n }}\n onMouseDown={onMouseDown}\n replace={replace}\n to={to}\n // TODO: Refactor it later.\n // eslint-disable-next-line react/jsx-props-no-spreading\n {...rest}\n >\n {children}\n </L>\n );\n};\n\nexport default GenericLink;\n"],"mappings":"AASA,MAAO,CAAAA,CAAC,oBAAqB,OAAAC,GAAA,IAAAC,IAAA,yBAqB7B;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,GACA,KAAM,CAAAC,WAAW,CAAGA,CAAC,CACnBC,QAAQ,CACRC,SAAS,CACTC,QAAQ,CACRC,QAAQ,CACRC,kBAAkB,CAClBC,OAAO,CACPC,WAAW,CACXC,UAAU,CACVC,OAAO,CACPC,cAAc,CACdC,EAAE,CACF,GAAGC,IACgC,CAAC,GAAgB,CACpD;AACF;AACA;AACA;AACA,4CACE,GAAIT,QAAQ,EAAIC,QAAQ,EAAII,UAAU,EAChCG,EAAE,CAAYE,KAAK,CAAC,uBAAuB,CAAC,CAAE,CAClD,GAAI,CAAAC,UAAkB,CAAGjB,CAAC,CAACkB,IAAI,CAC/B,GAAIb,SAAS,CAAEY,UAAU,EAAI,IAAIZ,SAAS,EAAE,CAE5C,mBACEH,IAAA,MACEG,SAAS,CAAEY,UACX;AACA;AACA;AACA;AAAA,CACAE,IAAI,CAAEL,EAAa,CACnBL,OAAO,CAAEH,QAAQ,CAAIc,CAAC,EAAK,CACzBA,CAAC,CAACC,cAAc,CAAC,CAAC,CACpB,CAAC,CAAGZ,OAAQ,CACZC,WAAW,CAAEJ,QAAQ,CAAIc,CAAC,EAAK,CAC7BA,CAAC,CAACC,cAAc,CAAC,CAAC,CACpB,CAAC,CAAGX,WAAY,CAChBY,GAAG,CAAC,qBAAqB,CACzBC,SAAS,CAAC,MAAM,CAChBC,MAAM,CAAEb,UAAU,CAAG,QAAQ,CAAG,EAAG,CAAAP,QAAA,CAElCA,QAAQ,CACR,CAAC,CAER,CAEA,KAAM,CAAAqB,CAAC,CAAGZ,cAAc,CAExB,mBACEX,IAAA,CAACuB,CAAC,EACApB,SAAS,CAAEA,SAAU,CACrBqB,QAAQ,CAAC,MACT;AAAA,CACAjB,OAAO,CAAGW,CAAsC,EAAK,CACnD;AACA,GAAIX,OAAO,CAAEA,OAAO,CAACW,CAAC,CAAC,CAEvB;AACA,GAAI,CAACZ,kBAAkB,CAAEmB,MAAM,CAACC,MAAM,CAAC,CAAC,CAAE,CAAC,CAAC,CAC9C,CAAE,CACFlB,WAAW,CAAEA,WAAY,CACzBE,OAAO,CAAEA,OAAQ,CACjBE,EAAE,CAAEA,EACJ;AACA;AAAA,IACIC,IAAI,CAAAX,QAAA,CAEPA,QAAQ,CACR,CAAC,CAER,CAAC,CAED,cAAe,CAAAD,WAAW","ignoreList":[]}
1
+ {"version":3,"file":"index.js","names":["S","jsx","_jsx","GenericLink","t0","$","_c","children","className","disabled","enforceA","keepScrollPosition","onClick","onMouseDown","openNewTab","replace","rest","routerLinkType","to","match","aClassName","link","t1","t2","_temp","t3","_temp2","t4","t5","href","rel","styleName","target","L","e_1","e","window","scroll","discover","preventDefault","e_0"],"sources":["../../../../../src/shared/components/GenericLink/index.tsx"],"sourcesContent":["import type { ReactNode } from 'react';\n\nimport type {\n Link,\n LinkProps,\n NavLink,\n NavLinkProps,\n} from 'react-router';\n\nimport S from './style.scss';\n\ntype LinkT = typeof Link;\ntype NavLinkT = typeof NavLink;\n\ntype ToT = Parameters<typeof Link>[0]['to'];\n\nexport type PropsT = {\n children?: ReactNode;\n className?: string;\n disabled?: boolean;\n enforceA?: boolean;\n keepScrollPosition?: boolean;\n onClick?: React.MouseEventHandler<HTMLAnchorElement>;\n onMouseDown?: React.MouseEventHandler<HTMLAnchorElement>;\n openNewTab?: boolean;\n replace?: boolean;\n routerLinkType: LinkT | NavLinkT;\n to: ToT;\n};\n\n/**\n * The `<Link>` component, and almost identical `<NavLink>` component, are\n * auxiliary wrappers around\n * [React Router](https://github.com/ReactTraining/react-router)'s\n * `<Link>` and `<NavLink>` components; they help to handle external and\n * internal links in uniform manner.\n *\n * @param [props] Component properties.\n * @param [props.className] CSS classes to apply to the link.\n * @param [props.disabled] Disables the link.\n * @param [props.enforceA] `true` enforces rendering of the link as\n * a simple `<a>` element.\n * @param [props.keepScrollPosition] If `true`, and the link is\n * rendered as a React Router's component, it won't reset the viewport scrolling\n * position to the origin when clicked.\n * @param [props.onClick] Event handler to trigger upon click.\n * @param [props.onMouseDown] Event handler to trigger on MouseDown\n * event.\n * @param [props.openNewTab] If `true` the link opens in a new tab.\n * @param [props.replace] When `true`, the link will replace current\n * entry in the history stack instead of adding a new one.\n * @param [props.to] Link URL.\n * @param [props.activeClassName] **`<NavLink>`** only: CSS class(es)\n * to apply to rendered link when it is active.\n * @param [props.activeStyle] **`<NavLink>`** only: CSS styles\n * to apply to the rendered link when it is active.\n * @param [props.exact] **`<NavLink>`** only: if `true`, the active\n * class/style will only be applied if the location is matched exactly.\n * @param [props.isActive] **`<NavLink>`** only: Add extra\n * logic for determining whether the link is active. This should be used if you\n * want to do more than verify that the link’s pathname matches the current URL\n * pathname.\n * @param [props.location] **`<NavLink>`** only: `isActive` compares\n * current history location (usually the current browser URL). To compare to\n * a different location, a custom `location` can be passed.\n * @param [props.strict] **`<NavLink>`** only: . When `true`, trailing\n * slash on a location’s pathname will be taken into consideration when\n * determining if the location matches the current URL. See the `<Route strict>`\n * documentation for more information.\n */\nconst GenericLink = ({\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}: (LinkProps | NavLinkProps) & PropsT): ReactNode => {\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\n || (to as string).match(/^(#|(https?|mailto):)/)) {\n let aClassName: string = S.link;\n if (className) aClassName += ` ${className}`;\n\n return (\n <a\n className={aClassName}\n // TODO: This requires a fix: disabled is not really an attribute of <a>\n // tag, thus for disabled option we rather should render a plain text\n // styled as a link.\n // disabled={disabled}\n href={to as string}\n onClick={disabled ? (e) => {\n e.preventDefault();\n } : onClick}\n onMouseDown={disabled ? (e) => {\n e.preventDefault();\n } : onMouseDown}\n rel=\"noopener noreferrer\"\n styleName=\"link\"\n target={openNewTab ? '_blank' : ''}\n >\n {children}\n </a>\n );\n }\n\n const L = routerLinkType;\n\n return (\n <L\n className={className}\n discover=\"none\"\n // disabled\n onClick={(e: React.MouseEvent<HTMLAnchorElement>) => {\n // Executes the user-provided event handler, if any.\n if (onClick) onClick(e);\n\n // By default, clicking the link scrolls the page to beginning.\n if (!keepScrollPosition) window.scroll(0, 0);\n }}\n onMouseDown={onMouseDown}\n replace={replace}\n to={to}\n // TODO: Refactor it later.\n // eslint-disable-next-line react/jsx-props-no-spreading\n {...rest}\n >\n {children}\n </L>\n );\n};\n\nexport default GenericLink;\n"],"mappings":"4CASA,MAAO,CAAAA,CAAC,oBAAqB,OAAAC,GAAA,IAAAC,IAAA,yBAqB7B;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,GACA,KAAM,CAAAC,WAAW,CAAGC,EAAA,SAAAC,CAAA,CAAAC,EAAA,SAAAC,QAAA,KAAAC,SAAA,KAAAC,QA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,EAAAF,CAAA,OAAAG,SAAA,EAAAH,CAAA,OAAAQ,WAAA,EAAAR,CAAA,OAAAU,OAAA,EAAAV,CAAA,OAAAW,IAAA,EAAAX,CAAA,OAAAiB,EAAA,EAAAjB,CAAA,OAAAa,EAAA,EAVHK,EAAA,cAAArB,IAAA,CAAC+B,CAAC,EACWzB,SAAS,CAATA,SAAS,CACX8B,QAAM,CAAN,MAAM,CAEN1B,OAMR,CANQU,EAMR,CACYT,WAAW,CAAXA,WAAW,CACfE,OAAO,CAAPA,OAAO,CACZG,EAAE,CAAFA,EAAE,IAGFF,IAAI,CAAAT,QAAA,CAEPA,QAAQ,CACR,CAAC,CAAAF,CAAA,KAAA4B,CAAA5B,CAAA,MAAAE,QAAAF,CAAA,MAAAG,SAAAH,CAAA,MAAAQ,WAAAR,CAAA,MAAAU,OAAAV,CAAA,MAAAW,IAAAX,CAAA,MAAAiB,EAAAjB,CAAA,MAAAa,EAAAb,CAAA,MAAAkB,EAAA,MAAAA,EAAA,CAAAlB,CAAA,WAnBJ,CAAAkB,EAmBI,CAEP,CAED,cAAe,CAAApB,WAAW,CAzEN,SAAAqB,MAAAW,CAAA,EAiCVA,CAAC,CAAAI,cAAe,CAAC,CAAC,CAjCR,SAAAb,OAAAc,GAAA,EAoCVL,GAAC,CAAAI,cAAe,CAAC,CAAC","ignoreList":[]}
@@ -1,18 +1,9 @@
1
- import{useRef,useState}from"react";import{useTheme}from"@dr.pogodin/react-themes";import defaultTheme from"./theme.scss";import{jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";/**
1
+ import{c as _c}from"react/compiler-runtime";import{useRef,useState}from"react";import{useTheme}from"@dr.pogodin/react-themes";import defaultTheme from"./theme.scss";import{jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";/**
2
2
  * Themeable input field, based on the standard HTML `<input>` element.
3
3
  * @param [props.label] Input label.
4
4
  * @param [props.theme] _Ad hoc_ theme.
5
5
  * @param [props...] [Other theming properties](https://www.npmjs.com/package/@dr.pogodin/react-themes#themed-component-properties)
6
6
  * @param [props...] Any other properties are passed to the underlying
7
7
  * `<input>` element.
8
- */const Input=({children,composeAdhocTheme,error,label,ref,testId,theme,...rest})=>{const composed=useTheme("Input",defaultTheme,theme,{composeAdhocTheme});// NOTE: As of now, it is only updated when "theme.focused" is defined,
9
- // as otherwise its value is not used.
10
- const[focused,setFocused]=useState(false);const localRef=useRef(null);let containerClassName=composed.container;// NOTE: As of now, "focused" can be true only when "theme.focused"
11
- // is provided.
12
- if(focused/* && theme.focused */)containerClassName+=` ${composed.focused}`;if(!rest.value&&composed.empty)containerClassName+=` ${composed.empty}`;if(error)containerClassName+=` ${composed.error}`;return/*#__PURE__*/_jsxs("div",{className:containerClassName,onFocus:()=>{// TODO: It does not really work if a callback-style `ref` is passed in,
13
- // we need a more complex logic to cover that case, but for now this serves
14
- // the case we need it for.
15
- if(typeof ref==="object")ref?.current?.focus();else localRef.current?.focus();},children:[label===undefined?null:/*#__PURE__*/_jsx("div",{className:composed.label,children:label}),/*#__PURE__*/_jsx("input",{className:composed.input,"data-testid":process.env.NODE_ENV==="production"?undefined:testId,ref:ref??localRef// TODO: Avoid the spreading later.
16
- // eslint-disable-next-line react/jsx-props-no-spreading
17
- ,...rest,onBlur:composed.focused?e=>{setFocused(false);rest.onBlur?.(e);}:rest.onBlur,onFocus:composed.focused?e=>{setFocused(true);rest.onFocus?.(e);}:rest.onFocus}),error&&error!==true?/*#__PURE__*/_jsx("div",{className:composed.errorMessage,children:error}):null,children?/*#__PURE__*/_jsx("div",{className:composed.children,children:children}):null]});};export default Input;
8
+ */const Input=t0=>{const $=_c(42);let children;let composeAdhocTheme;let error;let label;let ref;let rest;let testId;let theme;if($[0]!==t0){({children,composeAdhocTheme,error,label,ref,testId,theme,...rest}=t0);$[0]=t0;$[1]=children;$[2]=composeAdhocTheme;$[3]=error;$[4]=label;$[5]=ref;$[6]=rest;$[7]=testId;$[8]=theme}else{children=$[1];composeAdhocTheme=$[2];error=$[3];label=$[4];ref=$[5];rest=$[6];testId=$[7];theme=$[8]}let t1;if($[9]!==composeAdhocTheme){t1={composeAdhocTheme};$[9]=composeAdhocTheme;$[10]=t1}else{t1=$[10]}const composed=useTheme("Input",defaultTheme,theme,t1);const[focused,setFocused]=useState(false);const localRef=useRef(null);let containerClassName=composed.container;if(focused){containerClassName=containerClassName+` ${composed.focused}`;}if(!rest.value&&composed.empty){containerClassName=containerClassName+` ${composed.empty}`;}if(error){containerClassName=containerClassName+` ${composed.error}`;}let t2;if($[11]!==ref){t2=()=>{if(typeof ref==="object"){ref?.current?.focus()}else{localRef.current?.focus()}};$[11]=ref;$[12]=t2}else{t2=$[12]}let t3;if($[13]!==composed.label||$[14]!==label){t3=label===undefined?null:/*#__PURE__*/_jsx("div",{className:composed.label,children:label});$[13]=composed.label;$[14]=label;$[15]=t3}else{t3=$[15]}const t4=process.env.NODE_ENV==="production"?undefined:testId;const t5=ref??localRef;let t6;if($[16]!==composed.focused||$[17]!==rest){t6=composed.focused?e=>{setFocused(false);rest.onBlur?.(e)}:rest.onBlur;$[16]=composed.focused;$[17]=rest;$[18]=t6}else{t6=$[18]}let t7;if($[19]!==composed.focused||$[20]!==rest){t7=composed.focused?e_0=>{setFocused(true);rest.onFocus?.(e_0)}:rest.onFocus;$[19]=composed.focused;$[20]=rest;$[21]=t7}else{t7=$[21]}let t8;if($[22]!==composed.input||$[23]!==rest||$[24]!==t4||$[25]!==t5||$[26]!==t6||$[27]!==t7){t8=/*#__PURE__*/_jsx("input",{className:composed.input,"data-testid":t4,ref:t5,...rest,onBlur:t6,onFocus:t7});$[22]=composed.input;$[23]=rest;$[24]=t4;$[25]=t5;$[26]=t6;$[27]=t7;$[28]=t8}else{t8=$[28]}let t9;if($[29]!==composed.errorMessage||$[30]!==error){t9=error&&error!==true?/*#__PURE__*/_jsx("div",{className:composed.errorMessage,children:error}):null;$[29]=composed.errorMessage;$[30]=error;$[31]=t9}else{t9=$[31]}let t10;if($[32]!==children||$[33]!==composed.children){t10=children?/*#__PURE__*/_jsx("div",{className:composed.children,children:children}):null;$[32]=children;$[33]=composed.children;$[34]=t10}else{t10=$[34]}let t11;if($[35]!==containerClassName||$[36]!==t10||$[37]!==t2||$[38]!==t3||$[39]!==t8||$[40]!==t9){t11=/*#__PURE__*/_jsxs("div",{className:containerClassName,onFocus:t2,children:[t3,t8,t9,t10]});$[35]=containerClassName;$[36]=t10;$[37]=t2;$[38]=t3;$[39]=t8;$[40]=t9;$[41]=t11}else{t11=$[41]}return t11};export default Input;
18
9
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":["useRef","useState","useTheme","defaultTheme","jsx","_jsx","jsxs","_jsxs","Input","children","composeAdhocTheme","error","label","ref","testId","theme","rest","composed","focused","setFocused","localRef","containerClassName","container","value","empty","className","onFocus","current","focus","undefined","input","process","env","NODE_ENV","onBlur","e","errorMessage"],"sources":["../../../../../src/shared/components/Input/index.tsx"],"sourcesContent":["import {\n type FunctionComponent,\n type ReactNode,\n type Ref,\n useRef,\n useState,\n} from 'react';\n\nimport { type COMPOSE, type Theme, useTheme } from '@dr.pogodin/react-themes';\n\nimport defaultTheme from './theme.scss';\n\ntype ThemeKeyT = 'children' | 'container' | 'empty' | 'error' | 'errorMessage'\n | 'focused' | 'input' | 'label';\n\ntype PropsT = React.InputHTMLAttributes<HTMLInputElement> & {\n children?: ReactNode;\n composeAdhocTheme?: COMPOSE;\n error?: ReactNode;\n label?: React.ReactNode;\n ref?: Ref<HTMLInputElement>;\n testId?: string;\n theme?: Theme<ThemeKeyT>;\n};\n\n/**\n * Themeable input field, based on the standard HTML `<input>` element.\n * @param [props.label] Input label.\n * @param [props.theme] _Ad hoc_ theme.\n * @param [props...] [Other theming properties](https://www.npmjs.com/package/@dr.pogodin/react-themes#themed-component-properties)\n * @param [props...] Any other properties are passed to the underlying\n * `<input>` element.\n */\nconst Input: FunctionComponent<PropsT> = ({\n children,\n composeAdhocTheme,\n error,\n label,\n ref,\n testId,\n theme,\n ...rest\n}) => {\n const composed = useTheme('Input', defaultTheme, theme, {\n composeAdhocTheme,\n });\n\n // NOTE: As of now, it is only updated when \"theme.focused\" is defined,\n // as otherwise its value is not used.\n const [focused, setFocused] = useState(false);\n\n const localRef = useRef<HTMLInputElement>(null);\n\n let containerClassName = composed.container;\n\n // NOTE: As of now, \"focused\" can be true only when \"theme.focused\"\n // is provided.\n if (focused /* && theme.focused */) containerClassName += ` ${composed.focused}`;\n\n if (!rest.value && composed.empty) containerClassName += ` ${composed.empty}`;\n\n if (error) containerClassName += ` ${composed.error}`;\n\n return (\n <div\n className={containerClassName}\n onFocus={() => {\n // TODO: It does not really work if a callback-style `ref` is passed in,\n // we need a more complex logic to cover that case, but for now this serves\n // the case we need it for.\n if (typeof ref === 'object') ref?.current?.focus();\n else localRef.current?.focus();\n }}\n >\n {label === undefined\n ? null : <div className={composed.label}>{label}</div>}\n <input\n className={composed.input}\n data-testid={process.env.NODE_ENV === 'production' ? undefined : testId}\n ref={ref ?? localRef}\n\n // TODO: Avoid the spreading later.\n // eslint-disable-next-line react/jsx-props-no-spreading\n {...rest}\n\n onBlur={composed.focused ? (e) => {\n setFocused(false);\n rest.onBlur?.(e);\n } : rest.onBlur}\n onFocus={composed.focused ? (e) => {\n setFocused(true);\n rest.onFocus?.(e);\n } : rest.onFocus}\n />\n {error && error !== true\n ? <div className={composed.errorMessage}>{error}</div>\n : null}\n {children ? <div className={composed.children}>{children}</div> : null}\n </div>\n );\n};\n\nexport default Input;\n"],"mappings":"AAAA,OAIEA,MAAM,CACNC,QAAQ,KACH,OAAO,CAEd,OAAmCC,QAAQ,KAAQ,0BAA0B,CAE7E,MAAO,CAAAC,YAAY,oBAAqB,OAAAC,GAAA,IAAAC,IAAA,CAAAC,IAAA,IAAAC,KAAA,yBAexC;AACA;AACA;AACA;AACA;AACA;AACA;AACA,GACA,KAAM,CAAAC,KAAgC,CAAGA,CAAC,CACxCC,QAAQ,CACRC,iBAAiB,CACjBC,KAAK,CACLC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ACxED,GAAG,CAAEA,GAAG,EAAIO,QAEZ;AACA;AAAA,IACIJ,IAAI,CAERkB,MAAM,CAAEjB,QAAQ,CAACC,OAAO,CAAIiB,CAAC,EAAK,CAChChB,UAAU,CAAC,KAAK,CAAC,CACjBH,IAAI,CAACkB,MAAM,GAAGC,CAAC,CAAC,CAClB,CAAC,CAAGnB,IAAI,CAACkB,MAAO,CAChBR,OAAO,CAAET,QAAQ,CAACC,OAAO,CAAIiB,CAAC,EAAK,CACjChB,UAAU,CAAC,IAAI,CAAC,CAChBH,IAAI,CAACU,OAAO,GAAGS,CAAC,CAAC,CACnB,CAAC,CAAGnB,IAAI,CAACU,OAAQ,CAClB,CAAC,CACDf,KAAK,EAAIA,KAAK,GAAK,IAAI,cACpBN,IAAA,QAAKoB,SAAS,CAAER,QAAQ,CAACmB,YAAa,CAAA3B,QAAA,CAAEE,KAAK,CAAM,CAAC,CACpD,IAAI,CACPF,QAAQ,cAAGJ,IAAA,QAAKoB,SAAS,CAAER,QAAQ,CAACR,QAAS,CAAAA,QAAA,CAAEA,QAAQ,CAAM,CAAC,CAAG,IAAI,EACnE,CAAC,CAEV,CAAC,CAED,cAAe,CAAAD,KAAK","ignoreList":[]}
1
+ {"version":3,"file":"index.js","names":["useRef","useState","useTheme","defaultTheme","jsx","_jsx","jsxs","_jsxs","Input","t0","$","_c","children","composeAdhocTheme","error","label","ref","rest","testId","theme","t1","composed","focused","setFocused","localRef","containerClassName","container","value","empty","t2","current","focus","t3","undefined","className","t4","process","env","NODE_ENV","t5","t6","e","onBlur","t7","e_0","onFocus","t8","input","t9","errorMessage","t10","t11"],"sources":["../../../../../src/shared/components/Input/index.tsx"],"sourcesContent":["import {\n type FunctionComponent,\n type ReactNode,\n type Ref,\n useRef,\n useState,\n} from 'react';\n\nimport { type COMPOSE, type Theme, useTheme } from '@dr.pogodin/react-themes';\n\nimport defaultTheme from './theme.scss';\n\ntype ThemeKeyT = 'children' | 'container' | 'empty' | 'error' | 'errorMessage'\n | 'focused' | 'input' | 'label';\n\ntype PropsT = React.InputHTMLAttributes<HTMLInputElement> & {\n children?: ReactNode;\n composeAdhocTheme?: COMPOSE;\n error?: ReactNode;\n label?: React.ReactNode;\n ref?: Ref<HTMLInputElement>;\n testId?: string;\n theme?: Theme<ThemeKeyT>;\n};\n\n/**\n * Themeable input field, based on the standard HTML `<input>` element.\n * @param [props.label] Input label.\n * @param [props.theme] _Ad hoc_ theme.\n * @param [props...] [Other theming properties](https://www.npmjs.com/package/@dr.pogodin/react-themes#themed-component-properties)\n * @param [props...] Any other properties are passed to the underlying\n * `<input>` element.\n */\nconst Input: FunctionComponent<PropsT> = ({\n children,\n composeAdhocTheme,\n error,\n label,\n ref,\n testId,\n theme,\n ...rest\n}) => {\n const composed = useTheme('Input', defaultTheme, theme, {\n composeAdhocTheme,\n });\n\n // NOTE: As of now, it is only updated when \"theme.focused\" is defined,\n // as otherwise its value is not used.\n const [focused, setFocused] = useState(false);\n\n const localRef = useRef<HTMLInputElement>(null);\n\n let containerClassName = composed.container;\n\n // NOTE: As of now, \"focused\" can be true only when \"theme.focused\"\n // is provided.\n if (focused /* && theme.focused */) containerClassName += ` ${composed.focused}`;\n\n if (!rest.value && composed.empty) containerClassName += ` ${composed.empty}`;\n\n if (error) containerClassName += ` ${composed.error}`;\n\n return (\n <div\n className={containerClassName}\n onFocus={() => {\n // TODO: It does not really work if a callback-style `ref` is passed in,\n // we need a more complex logic to cover that case, but for now this serves\n // the case we need it for.\n if (typeof ref === 'object') ref?.current?.focus();\n else localRef.current?.focus();\n }}\n >\n {label === undefined\n ? null : <div className={composed.label}>{label}</div>}\n <input\n className={composed.input}\n data-testid={process.env.NODE_ENV === 'production' ? undefined : testId}\n ref={ref ?? localRef}\n\n // TODO: Avoid the spreading later.\n // eslint-disable-next-line react/jsx-props-no-spreading\n {...rest}\n\n onBlur={composed.focused ? (e) => {\n setFocused(false);\n rest.onBlur?.(e);\n } : rest.onBlur}\n onFocus={composed.focused ? (e) => {\n setFocused(true);\n rest.onFocus?.(e);\n } : rest.onFocus}\n />\n {error && error !== true\n ? <div className={composed.errorMessage}>{error}</div>\n : null}\n {children ? <div className={composed.children}>{children}</div> : null}\n </div>\n );\n};\n\nexport default Input;\n"],"mappings":"4CAAA,OAIEA,MAAM,CACNC,QAAQ,KACH,OAAO,CAEd,OAAmCC,QAAQ,KAAQ,0BAA0B,CAE7E,MAAO,CAAAC,YAAY,oBAAqB,OAAAC,GAAA,IAAAC,IAAA,CAAAC,IAAA,IAAAC,KAAA,yBAexC;AACA;AACA;AACA;AACA;AACA;AACA;AACA,GACA,KAAM,CAAAC,KAAgC,CAAGC,EAAA,SAAAC,CAAA,CAAAC,EAAA,SAAAC,QAAA,KAAAC,iBAAA,KAAAC,KAAA,KAAAC,KAAA,KAAAC,GAAA,KAAAC,IAAA,KAAAC,MAAA,KAAAC,KAAA,IAAAT,CAAA,MAAAD,EAAA,EAAC,EAAAG,QAAA,CAAAC,iBAAA,CAAAC,KAAA,CAAAC,KAAA,CAAAC,GAAA,CAAAE,MAAA,CAAAC,KAAA,IAAAF,IAAA,EAAAR,EASzC,EAAAC,CAAA,IAAAD,EAAAC,CAAA,KAAAE,QAAAF,CAAA,KAAAG,iBAAAH,CAAA,KAAAI,KAAAJ,CAAA,KAAAK,KAAAL,CAAA,KAAAM,GAAAN,CAAA,KAAAO,IAAAP,CAAA,KAAAQ,MAAAR,CAAA,KAAAS,KAAA,MAAAP,QAAA,CAAAF,CAAA,GAAAG,CAAA,kBAAAH,CAAA,GAAAI,CAAA,MAAAJ,CAAA,GAAAK,CAAA,MAAAL,CAAA,GAAAM,CAAA,IAAAN,CAAA,GAAAO,CAAA,KAAAP,CAAA,GAAAQ,CAAA,OAAAR,CAAA,GAAAS,CAAA,MAAAT,CAAA,QAAAU,EAAA,IAAAV,CAAA,MAAAG,iBAAA,EACyDO,EAAA,EAAAP,iBAExD,CAAC,CAAAH,CAAA,IAAAG,iBAAAH,CAAA,MAAAU,EAAA,MAAAA,EAAA,C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pBoB,OAMR,CANQhB,EAMR,CAAAjB,QAAA,EAEAoB,EACuD,CACxDc,EAiBE,CACDE,EAEO,CACPE,GAAqE,EACnE,CAAC,CAAAxC,CAAA,KAAAe,kBAAAf,CAAA,MAAAwC,GAAAxC,CAAA,MAAAmB,EAAAnB,CAAA,MAAAsB,EAAAtB,CAAA,MAAAoC,EAAApC,CAAA,MAAAsC,EAAAtC,CAAA,MAAAyC,GAAA,MAAAA,GAAA,CAAAzC,CAAA,WAlCN,CAAAyC,GAkCM,CAET,CAED,cAAe,CAAA3C,KAAK","ignoreList":[]}
@@ -1,10 +1,8 @@
1
- /**
1
+ import{c as _c}from"react/compiler-runtime";/**
2
2
  * The Link wraps around React Router's Link component, to automatically replace
3
3
  * it by the regular <a> element when:
4
4
  * - The target reference points to another domain;
5
5
  * - User opts to open the reference in a new tab;
6
6
  * - User explicitely opts to use <a>.
7
- */import{Link as RrLink}from"react-router";import GenericLink from"./GenericLink";import{jsx as _jsx}from"react/jsx-runtime";const Link=props=>/*#__PURE__*/_jsx(GenericLink// TODO: Avoid the spreading later.
8
- // eslint-disable-next-line react/jsx-props-no-spreading
9
- ,{...props,routerLinkType:RrLink});export default Link;
7
+ */import{Link as RrLink}from"react-router";import GenericLink from"./GenericLink";import{jsx as _jsx}from"react/jsx-runtime";const Link=props=>{const $=_c(2);let t0;if($[0]!==props){t0=/*#__PURE__*/_jsx(GenericLink,{...props,routerLinkType:RrLink});$[0]=props;$[1]=t0}else{t0=$[1]}return t0};export default Link;
10
8
  //# sourceMappingURL=Link.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"Link.js","names":["Link","RrLink","GenericLink","jsx","_jsx","props","routerLinkType"],"sources":["../../../../src/shared/components/Link.tsx"],"sourcesContent":["/**\n * The Link wraps around React Router's Link component, to automatically replace\n * it by the regular <a> element when:\n * - The target reference points to another domain;\n * - User opts to open the reference in a new tab;\n * - User explicitely opts to use <a>.\n */\n\nimport { type LinkProps, Link as RrLink } from 'react-router';\n\nimport GenericLink, { type PropsT as GenericLinkPropsT } from './GenericLink';\n\ntype PropsT = LinkProps & Omit<GenericLinkPropsT, 'routerLinkType'>;\n\nconst Link: React.FunctionComponent<PropsT>\n = (props) => (\n <GenericLink\n // TODO: Avoid the spreading later.\n // eslint-disable-next-line react/jsx-props-no-spreading\n {...props}\n routerLinkType={RrLink}\n />\n );\n\nexport default Link;\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA,GAEA,OAAyBA,IAAI,GAAI,CAAAC,MAAM,KAAQ,cAAc,CAE7D,MAAO,CAAAC,WAAW,qBAA4D,OAAAC,GAAA,IAAAC,IAAA,yBAI9E,KAAM,CAAAJ,IAAqC,CACtCK,KAAK,eACND,IAAA,CAACF,WACC;AACA;AAAA,KACIG,KAAK,CACTC,cAAc,CAAEL,MAAO,CACxB,CACF,CAEH,cAAe,CAAAD,IAAI","ignoreList":[]}
1
+ {"version":3,"file":"Link.js","names":["Link","RrLink","GenericLink","jsx","_jsx","props","$","_c","t0"],"sources":["../../../../src/shared/components/Link.tsx"],"sourcesContent":["/**\n * The Link wraps around React Router's Link component, to automatically replace\n * it by the regular <a> element when:\n * - The target reference points to another domain;\n * - User opts to open the reference in a new tab;\n * - User explicitely opts to use <a>.\n */\n\nimport { type LinkProps, Link as RrLink } from 'react-router';\n\nimport GenericLink, { type PropsT as GenericLinkPropsT } from './GenericLink';\n\ntype PropsT = LinkProps & Omit<GenericLinkPropsT, 'routerLinkType'>;\n\nconst Link: React.FunctionComponent<PropsT>\n = (props) => (\n <GenericLink\n // TODO: Avoid the spreading later.\n // eslint-disable-next-line react/jsx-props-no-spreading\n {...props}\n routerLinkType={RrLink}\n />\n );\n\nexport default Link;\n"],"mappings":"4CAAA;AACA;AACA;AACA;AACA;AACA;AACA,GAEA,OAAyBA,IAAI,GAAI,CAAAC,MAAM,KAAQ,cAAc,CAE7D,MAAO,CAAAC,WAAW,qBAA4D,OAAAC,GAAA,IAAAC,IAAA,yBAI9E,KAAM,CAAAJ,IAAqC,CACvCK,KAAA,SAAAC,CAAA,CAAAC,EAAA,QAAAC,EAAA,IAAAF,CAAA,MAAAD,KAAA,EACAG,EAAA,cAAAJ,IAAA,CAACF,WAAW,KAGNG,KAAK,CACOJ,cAAM,CAANA,MAAM,CACvB,CAAC,CAAAK,CAAA,IAAAD,KAAAC,CAAA,KAAAE,EAAA,MAAAA,EAAA,CAAAF,CAAA,UALF,CAAAE,EAKE,CACH,CAEH,cAAe,CAAAR,IAAI","ignoreList":[]}