@dr.pogodin/react-utils 1.53.0 → 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 (141) 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 +10 -8
  140. package/tsconfig.json +1 -1
  141. package/tsconfig.types.json +1 -1
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":["useImperativeHandle","useRef","BaseModal","optionValueName","S","jsx","_jsx","areEqual","a","b","left","top","width","Options","containerClass","containerStyle","filter","onCancel","onChange","optionClass","options","ref","opsRef","measure","e","current","parentElement","undefined","rect","getBoundingClientRect","style","window","getComputedStyle","mBottom","parseFloat","marginBottom","mTop","marginTop","height","optionNodes","option","iValue","iName","push","className","onClick","stopPropagation","onKeyDown","key","role","tabIndex","children","cancelOnScrolling","dontDisableScrolling","theme","ad","container","context","hoc","overlay"],"sources":["../../../../../../../src/shared/components/selectors/CustomDropdown/Options/index.tsx"],"sourcesContent":["import {\n type FunctionComponent,\n type ReactNode,\n type RefObject,\n useImperativeHandle,\n useRef,\n} from 'react';\n\nimport { BaseModal } from 'components/Modal';\n\nimport {\n type OptionT,\n type OptionsT,\n type ValueT,\n optionValueName,\n} from '../../common';\n\nimport S from './style.scss';\n\nexport type ContainerPosT = {\n left: number;\n top: number;\n width: number;\n};\n\nexport function areEqual(a?: ContainerPosT, b?: ContainerPosT): boolean {\n return a?.left === b?.left && a?.top === b?.top && a?.width === b?.width;\n}\n\nexport type RefT = {\n measure: () => DOMRect | undefined;\n};\n\ntype PropsT = {\n containerClass: string;\n containerStyle?: ContainerPosT;\n filter?: (item: OptionT<ReactNode> | ValueT) => boolean;\n onCancel: () => void;\n onChange: (value: ValueT) => void;\n optionClass: string;\n options: Readonly<OptionsT<ReactNode>>;\n ref?: RefObject<RefT | null>;\n};\n\nconst Options: FunctionComponent<PropsT> = ({\n containerClass,\n containerStyle,\n filter,\n onCancel,\n onChange,\n optionClass,\n options,\n ref,\n}) => {\n const opsRef = useRef<HTMLDivElement>(null);\n\n useImperativeHandle(ref, () => ({\n measure: () => {\n const e = opsRef.current?.parentElement;\n if (!e) return undefined;\n\n const rect = opsRef.current!.getBoundingClientRect();\n const style = window.getComputedStyle(e);\n const mBottom = parseFloat(style.marginBottom);\n const mTop = parseFloat(style.marginTop);\n\n rect.height += mBottom + mTop;\n\n return rect;\n },\n }), []);\n\n const optionNodes: ReactNode[] = [];\n for (const option of options) {\n if (!filter || filter(option)) {\n const [iValue, iName] = optionValueName(option);\n optionNodes.push(\n <div\n className={optionClass}\n key={iValue}\n onClick={(e) => {\n onChange(iValue);\n e.stopPropagation();\n }}\n onKeyDown={(e) => {\n if (e.key === 'Enter') {\n onChange(iValue);\n e.stopPropagation();\n }\n }}\n role=\"button\"\n tabIndex={0}\n >\n {iName}\n </div>,\n );\n }\n }\n\n return (\n <BaseModal\n // Closes the dropdown (cancels the selection) on any page scrolling attempt.\n // This is the same native <select> elements do on scrolling, and at least for\n // now we have no reason to deal with complications needed to support open\n // dropdowns during the scrolling (that would need to re-position it in\n // response to the position changes of the root dropdown element).\n cancelOnScrolling\n dontDisableScrolling\n onCancel={onCancel}\n style={containerStyle}\n theme={{\n ad: '',\n container: containerClass,\n context: '',\n hoc: '',\n overlay: S.overlay,\n }}\n >\n <div ref={opsRef}>{optionNodes}</div>\n </BaseModal>\n );\n};\n\nexport default Options;\n"],"mappings":"0IAAA,OAIEA,mBAAmB,CACnBC,MAAM,KACD,OAAO,CAEd,OAASC,SAAS,sBAElB,OAIEC,eAAe,oBAGjB,MAAO,CAAAC,CAAC,oBAAqB,OAAAC,GAAA,IAAAC,IAAA,yBAQ7B,MAAO,SAAS,CAAAC,QAAQA,CAACC,CAAiB,CAAEC,CAAiB,CAAW,CACtE,MAAO,CAAAD,CAAC,EAAEE,IAAI,GAAKD,CAAC,EAAEC,IAAI,EAAIF,CAAC,EAAEG,GAAG,GAAKF,CAAC,EAAEE,GAAG,EAAIH,CAAC,EAAEI,KAAK,GAAKH,CAAC,EAAEG,KAAK,CAC1E,CAiBA,KAAM,CAAAC,OAAkC,CAAGA,CAAC,CAC1CC,cAAc,CACdC,cAAc,CACdC,MAAM,CACNC,QAAQ,CACRC,QAAQ,CACRC,WAAW,CACXC,OAAO,CACPC,GACF,CAAC,GA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AC,CAAC,CACrB,CACF,CAAE,CACFG,IAAI,CAAC,QAAQ,CACbC,QAAQ,CAAE,CAAE,CAAAC,QAAA,CAEXT,KAAK,EAdDD,MAeF,CACP,CAAC,CACH,CACF,CAEA,mBACEnC,IAAA,CAACJ,SACC;AACA;AACA;AACA;AACA;AAAA,EACAkD,iBAAiB,MACjBC,oBAAoB,MACpBpC,QAAQ,CAAEA,QAAS,CACnBa,KAAK,CAAEf,cAAe,CACtBuC,KAAK,CAAE,CACLC,EAAE,CAAE,EAAE,CACNC,SAAS,CAAE1C,cAAc,CACzB2C,OAAO,CAAE,EAAE,CACXC,GAAG,CAAE,EAAE,CACPC,OAAO,CAAEvD,CAAC,CAACuD,OACb,CAAE,CAAAR,QAAA,cAEF7C,IAAA,QAAKe,GAAG,CAAEC,MAAO,CAAA6B,QAAA,CAAEZ,WAAW,CAAM,CAAC,CAC5B,CAAC,CAEhB,CAAC,CAED,cAAe,CAAA1B,OAAO","ignoreList":[]}
1
+ {"version":3,"file":"index.js","names":["useImperativeHandle","useRef","BaseModal","optionValueName","S","jsx","_jsx","areEqual","a","b","left","top","width","Options","t0","$","_c","containerClass","containerStyle","filter","onCancel","onChange","optionClass","options","ref","opsRef","t1","t2","Symbol","for","measure","e","current","parentElement","rect","getBoundingClientRect","style","window","getComputedStyle","mBottom","parseFloat","marginBottom","mTop","marginTop","height","optionNodes","option","iValue","iName","push","onClick","e_0","stopPropagation","onKeyDown","e_1","key","role","tabIndex","children","t3","ad","container","context","hoc","overlay","t4","t5","cancelOnScrolling","dontDisableScrolling","theme"],"sources":["../../../../../../../src/shared/components/selectors/CustomDropdown/Options/index.tsx"],"sourcesContent":["import {\n type FunctionComponent,\n type ReactNode,\n type RefObject,\n useImperativeHandle,\n useRef,\n} from 'react';\n\nimport { BaseModal } from 'components/Modal';\n\nimport {\n type OptionT,\n type OptionsT,\n type ValueT,\n optionValueName,\n} from '../../common';\n\nimport S from './style.scss';\n\nexport type ContainerPosT = {\n left: number;\n top: number;\n width: number;\n};\n\nexport function areEqual(a?: ContainerPosT, b?: ContainerPosT): boolean {\n return a?.left === b?.left && a?.top === b?.top && a?.width === b?.width;\n}\n\nexport type RefT = {\n measure: () => DOMRect | undefined;\n};\n\ntype PropsT = {\n containerClass: string;\n containerStyle?: ContainerPosT;\n filter?: (item: OptionT<ReactNode> | ValueT) => boolean;\n onCancel: () => void;\n onChange: (value: ValueT) => void;\n optionClass: string;\n options: Readonly<OptionsT<ReactNode>>;\n ref?: RefObject<RefT | null>;\n};\n\nconst Options: FunctionComponent<PropsT> = ({\n containerClass,\n containerStyle,\n filter,\n onCancel,\n onChange,\n optionClass,\n options,\n ref,\n}) => {\n const opsRef = useRef<HTMLDivElement>(null);\n\n useImperativeHandle(ref, () => ({\n measure: () => {\n const e = opsRef.current?.parentElement;\n if (!e) return undefined;\n\n const rect = opsRef.current!.getBoundingClientRect();\n const style = window.getComputedStyle(e);\n const mBottom = parseFloat(style.marginBottom);\n const mTop = parseFloat(style.marginTop);\n\n rect.height += mBottom + mTop;\n\n return rect;\n },\n }), []);\n\n const optionNodes: ReactNode[] = [];\n for (const option of options) {\n if (!filter || filter(option)) {\n const [iValue, iName] = optionValueName(option);\n optionNodes.push(\n <div\n className={optionClass}\n key={iValue}\n onClick={(e) => {\n onChange(iValue);\n e.stopPropagation();\n }}\n onKeyDown={(e) => {\n if (e.key === 'Enter') {\n onChange(iValue);\n e.stopPropagation();\n }\n }}\n role=\"button\"\n tabIndex={0}\n >\n {iName}\n </div>,\n );\n }\n }\n\n return (\n <BaseModal\n // Closes the dropdown (cancels the selection) on any page scrolling attempt.\n // This is the same native <select> elements do on scrolling, and at least for\n // now we have no reason to deal with complications needed to support open\n // dropdowns during the scrolling (that would need to re-position it in\n // response to the position changes of the root dropdown element).\n cancelOnScrolling\n dontDisableScrolling\n onCancel={onCancel}\n style={containerStyle}\n theme={{\n ad: '',\n container: containerClass,\n context: '',\n hoc: '',\n overlay: S.overlay,\n }}\n >\n <div ref={opsRef}>{opt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C,EAAA,CACD,EAAE,CAAAC,SAAA,CACK5C,cAAc,CAAA6C,OAAA,CAChB,EAAE,CAAAC,GAAA,CACN,EAAE,CAAAC,OAAA,CACE5D,CAAC,CAAA4D,OACZ,CAAC,CAAAjD,CAAA,IAAAE,cAAAF,CAAA,KAAA4C,EAAA,MAAAA,EAAA,CAAA5C,CAAA,QAAAkD,EAAA,IAAAlD,CAAA,MAAA8B,WAAA,EAEDoB,EAAA,cAAA3D,IAAA,QAAUmB,GAAM,CAANA,MAAM,CAAAiC,QAAA,CAAGb,WAAW,CAAM,CAAC,CAAA9B,CAAA,IAAA8B,WAAA9B,CAAA,MAAAkD,EAAA,MAAAA,EAAA,CAAAlD,CAAA,SAAAmD,EAAA,IAAAnD,CAAA,OAAAG,cAAA,EAAAH,CAAA,OAAAK,QAAA,EAAAL,CAAA,OAAA4C,EAAA,EAAA5C,CAAA,OAAAkD,EAAA,EAlBvCC,EAAA,cAAA5D,IAAA,CAACJ,SAAS,EAMRiE,iBAAiB,CAAjB,IAAiB,CACjBC,oBAAoB,CAApB,IAAoB,CACVhD,QAAQ,CAARA,QAAQ,CACXF,KAAc,CAAdA,cAAc,CACdmD,KAMN,CANMV,EAMN,CAAAD,QAAA,CAEDO,EAAqC,CAC5B,CAAC,CAAAlD,CAAA,KAAAG,cAAAH,CAAA,MAAAK,QAAAL,CAAA,MAAA4C,EAAA5C,CAAA,MAAAkD,EAAAlD,CAAA,MAAAmD,EAAA,MAAAA,EAAA,CAAAnD,CAAA,WAnBZ,CAAAmD,EAmBY,CAEf,CAED,cAAe,CAAArD,OAAO","ignoreList":[]}
@@ -1,8 +1,2 @@
1
- import"core-js/modules/es.iterator.constructor.js";import"core-js/modules/es.iterator.filter.js";import{useEffect,useRef,useState}from"react";import{useTheme}from"@dr.pogodin/react-themes";import{optionValueName}from"../common";import Options,{areEqual}from"./Options";import defaultTheme from"./theme.scss";import{Fragment as _Fragment,jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";const CustomDropdown=({filter,label,onChange,options,theme,value})=>{const custom=useTheme("CustomDropdown",defaultTheme,theme);const[active,setActive]=useState(false);const dropdownRef=useRef(null);const opsRef=useRef(null);const[opsPos,setOpsPos]=useState();const[upward,setUpward]=useState(false);useEffect(()=>{if(!active)return undefined;let id;const cb=()=>{const anchor=dropdownRef.current?.getBoundingClientRect();const opsRect=opsRef.current?.measure();if(anchor&&opsRect){const fitsDown=anchor.bottom+opsRect.height<(window.visualViewport?.height??0);const fitsUp=anchor.top-opsRect.height>0;const up=!fitsDown&&fitsUp;setUpward(up);const pos=up?{left:anchor.left,top:anchor.top-opsRect.height-1,width:anchor.width}:{left:anchor.left,top:anchor.bottom,width:anchor.width};setOpsPos(now=>areEqual(now,pos)?now:pos);}id=requestAnimationFrame(cb);};requestAnimationFrame(cb);return()=>{cancelAnimationFrame(id);};},[active]);const openList=e=>{const view=window.visualViewport;const rect=dropdownRef.current.getBoundingClientRect();setActive(true);// NOTE: This first opens the dropdown off-screen, where it is measured
2
- // by an effect declared above, and then positioned below, or above
3
- // the original dropdown element, depending where it fits best
4
- // (if we first open it downward, it would flick if we immediately
5
- // move it above, at least with the current position update via local
6
- // react state, and not imperatively).
7
- setOpsPos({left:view?.width??0,top:view?.height??0,width:rect.width});e.stopPropagation();};let selected=/*#__PURE__*/_jsx(_Fragment,{children:"\u200C"});for(const option of options){if(!filter||filter(option)){const[iValue,iName]=optionValueName(option);if(iValue===value){selected=iName;break;}}}let containerClassName=custom.container;if(active)containerClassName+=` ${custom.active}`;let opsContainerClass=custom.select??"";if(upward){containerClassName+=` ${custom.upward}`;opsContainerClass+=` ${custom.upward}`;}return/*#__PURE__*/_jsxs("div",{className:containerClassName,children:[label===undefined?null:/*#__PURE__*/_jsx("div",{className:custom.label,children:label}),/*#__PURE__*/_jsxs("div",{className:custom.dropdown,onClick:openList,onKeyDown:e=>{if(e.key==="Enter")openList(e);},ref:dropdownRef,role:"listbox",tabIndex:0,children:[selected,/*#__PURE__*/_jsx("div",{className:custom.arrow})]}),active?/*#__PURE__*/_jsx(Options,{containerClass:opsContainerClass,containerStyle:opsPos,onCancel:()=>{setActive(false);},onChange:newValue=>{setActive(false);if(onChange)onChange(newValue);},optionClass:custom.option??"",options:options,ref:opsRef}):null]});};export default CustomDropdown;
1
+ import"core-js/modules/es.iterator.constructor.js";import"core-js/modules/es.iterator.filter.js";import{c as _c}from"react/compiler-runtime";import{useEffect,useRef,useState}from"react";import{useTheme}from"@dr.pogodin/react-themes";import{optionValueName}from"../common";import Options,{areEqual}from"./Options";import defaultTheme from"./theme.scss";import{Fragment as _Fragment,jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";const CustomDropdown=t0=>{const $=_c(31);const{filter,label,onChange,options,theme,value}=t0;const custom=useTheme("CustomDropdown",defaultTheme,theme);const[active,setActive]=useState(false);const dropdownRef=useRef(null);const opsRef=useRef(null);const[opsPos,setOpsPos]=useState();const[upward,setUpward]=useState(false);let t1;let t2;if($[0]!==active){t1=()=>{if(!active){return}let id;const cb=()=>{const anchor=dropdownRef.current?.getBoundingClientRect();const opsRect=opsRef.current?.measure();if(anchor&&opsRect){const fitsDown=anchor.bottom+opsRect.height<(window.visualViewport?.height??0);const fitsUp=anchor.top-opsRect.height>0;const up=!fitsDown&&fitsUp;setUpward(up);const pos=up?{left:anchor.left,top:anchor.top-opsRect.height-1,width:anchor.width}:{left:anchor.left,top:anchor.bottom,width:anchor.width};setOpsPos(now=>areEqual(now,pos)?now:pos)}id=requestAnimationFrame(cb);};requestAnimationFrame(cb);return()=>{cancelAnimationFrame(id)}};t2=[active];$[0]=active;$[1]=t1;$[2]=t2}else{t1=$[1];t2=$[2]}useEffect(t1,t2);let t3;if($[3]===Symbol.for("react.memo_cache_sentinel")){t3=e=>{const view=window.visualViewport;const rect=dropdownRef.current.getBoundingClientRect();setActive(true);setOpsPos({left:view?.width??0,top:view?.height??0,width:rect.width});e.stopPropagation()};$[3]=t3}else{t3=$[3]}const openList=t3;let t4;if($[4]===Symbol.for("react.memo_cache_sentinel")){t4=/*#__PURE__*/_jsx(_Fragment,{children:"\u200C"});$[4]=t4}else{t4=$[4]}let selected=t4;if($[5]!==filter||$[6]!==options||$[7]!==value){for(const option of options){if(!filter||filter(option)){const[iValue,iName]=optionValueName(option);if(iValue===value){selected=iName;break;}}}$[5]=filter;$[6]=options;$[7]=value;$[8]=selected}else{selected=$[8]}let containerClassName=custom.container;if(active){containerClassName=containerClassName+` ${custom.active}`;}let opsContainerClass=custom.select??"";if(upward){containerClassName=containerClassName+` ${custom.upward}`;opsContainerClass=opsContainerClass+` ${custom.upward}`;}let t5;if($[9]!==custom.label||$[10]!==label){t5=label===undefined?null:/*#__PURE__*/_jsx("div",{className:custom.label,children:label});$[9]=custom.label;$[10]=label;$[11]=t5}else{t5=$[11]}let t6;if($[12]===Symbol.for("react.memo_cache_sentinel")){t6=e_0=>{if(e_0.key==="Enter"){openList(e_0)}};$[12]=t6}else{t6=$[12]}let t7;if($[13]!==custom.arrow){t7=/*#__PURE__*/_jsx("div",{className:custom.arrow});$[13]=custom.arrow;$[14]=t7}else{t7=$[14]}let t8;if($[15]!==custom.dropdown||$[16]!==selected||$[17]!==t7){t8=/*#__PURE__*/_jsxs("div",{className:custom.dropdown,onClick:openList,onKeyDown:t6,ref:dropdownRef,role:"listbox",tabIndex:0,children:[selected,t7]});$[15]=custom.dropdown;$[16]=selected;$[17]=t7;$[18]=t8}else{t8=$[18]}let t9;if($[19]!==active||$[20]!==custom.option||$[21]!==onChange||$[22]!==opsContainerClass||$[23]!==opsPos||$[24]!==options){t9=active?/*#__PURE__*/_jsx(Options,{containerClass:opsContainerClass,containerStyle:opsPos,onCancel:()=>{setActive(false)},onChange:newValue=>{setActive(false);if(onChange){onChange(newValue)}},optionClass:custom.option??"",options:options,ref:opsRef}):null;$[19]=active;$[20]=custom.option;$[21]=onChange;$[22]=opsContainerClass;$[23]=opsPos;$[24]=options;$[25]=t9}else{t9=$[25]}let t10;if($[26]!==containerClassName||$[27]!==t5||$[28]!==t8||$[29]!==t9){t10=/*#__PURE__*/_jsxs("div",{className:containerClassName,children:[t5,t8,t9]});$[26]=containerClassName;$[27]=t5;$[28]=t8;$[29]=t9;$[30]=t10}else{t10=$[30]}return t10};export default CustomDropdown;
8
2
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":["useEffect","useRef","useState","useTheme","optionValueName","Options","areEqual","defaultTheme","Fragment","_Fragment","jsx","_jsx","jsxs","_jsxs","CustomDropdown","filter","label","onChange","options","theme","value","custom","active","setActive","dropdownRef","opsRef","opsPos","setOpsPos","upward","setUpward","undefined","id","cb","anchor","current","getBoundingClientRect","opsRect","measure","fitsDown","bottom","height","window","visualViewport","fitsUp","top","up","pos","left","width","now","requestAnimationFrame","cancelAnimationFrame","openList","e","view","rect","stopPropagation","selected","children","option","iValue","iName","containerClassName","container","opsContainerClass","select","className","dropdown","onClick","onKeyDown","key","ref","role","tabIndex","arrow","containerClass","containerStyle","onCancel","newValue","optionClass"],"sources":["../../../../../../src/shared/components/selectors/CustomDropdown/index.tsx"],"sourcesContent":["import {\n type FunctionComponent,\n type ReactNode,\n useEffect,\n useRef,\n useState,\n} from 'react';\n\nimport { useTheme } from '@dr.pogodin/react-themes';\n\nimport { type PropsT, type ValueT, optionValueName } from '../common';\n\nimport Options, { type ContainerPosT, type RefT, areEqual } from './Options';\n\nimport defaultTheme from './theme.scss';\n\nconst CustomDropdown: FunctionComponent<\n PropsT<ReactNode, (value: ValueT) => void>\n> = ({\n filter,\n label,\n onChange,\n options,\n theme,\n value,\n}) => {\n const custom = useTheme('CustomDropdown', defaultTheme, theme);\n\n const [active, setActive] = useState(false);\n\n const dropdownRef = useRef<HTMLDivElement>(null);\n const opsRef = useRef<RefT>(null);\n\n const [opsPos, setOpsPos] = useState<ContainerPosT>();\n const [upward, setUpward] = useState(false);\n\n useEffect(() => {\n if (!active) return undefined;\n\n let id: number;\n const cb = () => {\n const anchor = dropdownRef.current?.getBoundingClientRect();\n const opsRect = opsRef.current?.measure();\n if (anchor && opsRect) {\n const fitsDown = anchor.bottom + opsRect.height\n < (window.visualViewport?.height ?? 0);\n const fitsUp = anchor.top - opsRect.height > 0;\n\n const up = !fitsDown && fitsUp;\n setUpward(up);\n\n const pos = up ? {\n left: anchor.left,\n top: anchor.top - opsRect.height - 1,\n width: anchor.width,\n } : {\n left: anchor.left,\n top: anchor.bottom,\n width: anchor.width,\n };\n\n setOpsPos((now) => (areEqual(now, pos) ? now : pos));\n }\n id = requestAnimationFrame(cb);\n };\n requestAnimationFrame(cb);\n\n return () => {\n cancelAnimationFrame(id);\n };\n }, [active]);\n\n const openList = (\n e: React.KeyboardEvent<HTMLDivElement> | React.MouseEvent<HTMLDivElement>,\n ) => {\n const view = window.visualViewport;\n const rect = dropdownRef.current!.getBoundingClientRect();\n setActive(true);\n\n // NOTE: This first opens the dropdown off-screen, where it is measured\n // by an effect declared above, and then positioned below, or above\n // the original dropdown element, depending where it fits best\n // (if we first open it downward, it would flick if we immediately\n // move it above, at least with the current position update via local\n // react state, and not imperatively).\n setOpsPos({\n left: view?.width ?? 0,\n top: view?.height ?? 0,\n width: rect.width,\n });\n\n e.stopPropagation();\n };\n\n let selected: React.ReactNode = <>&zwnj;</>;\n for (const option of options) {\n if (!filter || filter(option)) {\n const [iValue, iName] = optionValueName(option);\n if (iValue === value) {\n selected = iName;\n break;\n }\n }\n }\n\n let containerClassName = custom.container;\n if (active) containerClassName += ` ${custom.active}`;\n\n let opsContainerClass = custom.select ?? '';\n if (upward) {\n containerClassName += ` ${custom.upward}`;\n opsContainerClass += ` ${custom.upward}`;\n }\n\n return (\n <div className={containerClassName}>\n {label === undefined ? null\n : <div className={custom.label}>{label}</div>}\n <div\n className={custom.dropdown}\n onClick={openList}\n onKeyDown={(e) => {\n if (e.key === 'Enter') openList(e);\n }}\n ref={dropdownRef}\n role=\"listbox\"\n tabIndex={0}\n >\n {selected}\n <div className={custom.arrow} />\n </div>\n {\n active ? (\n <Options\n containerClass={opsContainerClass}\n containerStyle={opsPos}\n onCancel={() => {\n setActive(false);\n }}\n onChange={(newValue) => {\n setActive(false);\n if (onChange) onChange(newValue);\n }}\n optionClass={custom.option ?? ''}\n options={options}\n ref={opsRef}\n />\n ) : null\n }\n </div>\n );\n};\n\nexport default CustomDropdown;\n"],"mappings":"iGAAA,OAGEA,SAAS,CACTC,MAAM,CACNC,QAAQ,KACH,OAAO,CAEd,OAASC,QAAQ,KAAQ,0BAA0B,CAEnD,OAAmCC,eAAe,iBAElD,MAAO,CAAAC,OAAO,EAAmCC,QAAQ,iBAEzD,MAAO,CAAAC,YAAY,oBAAqB,OAAAC,QAAA,IAAAC,SAAA,CAAAC,GAAA,IAAAC,IAAA,CAAAC,IAAA,IAAAC,KAAA,yBAExC,KAAM,CAAAC,cAEL,CAAGA,CAAC,CACHC,MAAM,CACNC,KAAK,CACLC,QAAQ,CACRC,OAAO,CACPC,KAAK,CACLC,KACF,CAAC,GAAK,CACJ,KAAM,CAAAC,MAAM,CAAGlB,QAAQ,CAAC,gBAAgB,CAAEI,YAAY,CAAEY,KAAK,CAAC,CAE9D,KAAM,CAACG,MAAM,CAAEC,SAAS,CAAC,CAAGrB,QAAQ,CAAC,KAAK,CAAC,CAE3C,KAAM,CAAAsB,WAAW,CAAGvB,MAAM,CAAiB,IAAI,CAAC,CAChD,KAAM,CAAAwB,MAAM,CAAGxB,MAAM,CAAO,IAAI,CAAC,CAEjC,KAAM,CAACyB,MAAM,CAAEC,SAAS,CAAC,CAAGzB,QAAQ,CAAgB,CAAC,CACrD,KAAM,CAAC0B,MAAM,CAAEC,SAAS,CAAC,CAAG3B,QAAQ,CAAC,KAAK,CAAC,CAE3CF,SAAS,CAAC,IAAM,CACd,GAAI,CAACsB,MAAM,CAAE,MAAO,CAAAQ,SAAS,CAE7B,GAAI,CAAAC,EAAU,CACd,KAAM,CAAAC,EAAE,CAAGA,CAAA,GAAM,CACf,KAAM,CAAAC,MAAM,CAAGT,WAAW,CAACU,OAAO,EAAE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C,QAAA,CAAE1C,KAAK,CAAM,CAAC,cAC/CH,KAAA,QACEqD,SAAS,CAAE7C,MAAM,CAAC8C,QAAS,CAC3BC,OAAO,CAAEhB,QAAS,CAClBiB,SAAS,CAAGhB,CAAC,EAAK,CAChB,GAAIA,CAAC,CAACiB,GAAG,GAAK,OAAO,CAAElB,QAAQ,CAACC,CAAC,CAAC,CACpC,CAAE,CACFkB,GAAG,CAAE/C,WAAY,CACjBgD,IAAI,CAAC,SAAS,CACdC,QAAQ,CAAE,CAAE,CAAAf,QAAA,EAEXD,QAAQ,cACT9C,IAAA,QAAKuD,SAAS,CAAE7C,MAAM,CAACqD,KAAM,CAAE,CAAC,EAC7B,CAAC,CAEJpD,MAAM,cACJX,IAAA,CAACN,OAAO,EACNsE,cAAc,CAAEX,iBAAkB,CAClCY,cAAc,CAAElD,MAAO,CACvBmD,QAAQ,CAAEA,CAAA,GAAM,CACdtD,SAAS,CAAC,KAAK,CAAC,CAClB,CAAE,CACFN,QAAQ,CAAG6D,QAAQ,EAAK,CACtBvD,SAAS,CAAC,KAAK,CAAC,CAChB,GAAIN,QAAQ,CAAEA,QAAQ,CAAC6D,QAAQ,CAAC,CAClC,CAAE,CACFC,WAAW,CAAE1D,MAAM,CAACsC,MAAM,EAAI,EAAG,CACjCzC,OAAO,CAAEA,OAAQ,CACjBqD,GAAG,CAAE9C,MAAO,CACb,CAAC,CACA,IAAI,EAEP,CAAC,CAEV,CAAC,CAED,cAAe,CAAAX,cAAc","ignoreList":[]}
1
+ {"version":3,"file":"index.js","names":["useEffect","useRef","useState","useTheme","optionValueName","Options","areEqual","defaultTheme","Fragment","_Fragment","jsx","_jsx","jsxs","_jsxs","CustomDropdown","t0","$","_c","filter","label","onChange","options","theme","value","custom","active","setActive","dropdownRef","opsRef","opsPos","setOpsPos","upward","setUpward","t1","t2","id","cb","anchor","current","getBoundingClientRect","opsRect","measure","fitsDown","bottom","height","window","visualViewport","fitsUp","top","up","pos","left","width","now","requestAnimationFrame","cancelAnimationFrame","t3","Symbol","for","e","view","rect","stopPropagation","openList","t4","children","selected","option","iValue","iName","containerClassName","container","opsContainerClass","select","t5","undefined","className","t6","e_0","key","t7","arrow","t8","dropdown","onKeyDown","role","tabIndex","t9","onCancel","newValue","optionClass","t10"],"sources":["../../../../../../src/shared/components/selectors/CustomDropdown/index.tsx"],"sourcesContent":["import {\n type FunctionComponent,\n type ReactNode,\n useEffect,\n useRef,\n useState,\n} from 'react';\n\nimport { useTheme } from '@dr.pogodin/react-themes';\n\nimport { type PropsT, type ValueT, optionValueName } from '../common';\n\nimport Options, { type ContainerPosT, type RefT, areEqual } from './Options';\n\nimport defaultTheme from './theme.scss';\n\nconst CustomDropdown: FunctionComponent<\n PropsT<ReactNode, (value: ValueT) => void>\n> = ({\n filter,\n label,\n onChange,\n options,\n theme,\n value,\n}) => {\n const custom = useTheme('CustomDropdown', defaultTheme, theme);\n\n const [active, setActive] = useState(false);\n\n const dropdownRef = useRef<HTMLDivElement>(null);\n const opsRef = useRef<RefT>(null);\n\n const [opsPos, setOpsPos] = useState<ContainerPosT>();\n const [upward, setUpward] = useState(false);\n\n useEffect(() => {\n if (!active) return undefined;\n\n let id: number;\n const cb = () => {\n const anchor = dropdownRef.current?.getBoundingClientRect();\n const opsRect = opsRef.current?.measure();\n if (anchor && opsRect) {\n const fitsDown = anchor.bottom + opsRect.height\n < (window.visualViewport?.height ?? 0);\n const fitsUp = anchor.top - opsRect.height > 0;\n\n const up = !fitsDown && fitsUp;\n setUpward(up);\n\n const pos = up ? {\n left: anchor.left,\n top: anchor.top - opsRect.height - 1,\n width: anchor.width,\n } : {\n left: anchor.left,\n top: anchor.bottom,\n width: anchor.width,\n };\n\n setOpsPos((now) => (areEqual(now, pos) ? now : pos));\n }\n id = requestAnimationFrame(cb);\n };\n requestAnimationFrame(cb);\n\n return () => {\n cancelAnimationFrame(id);\n };\n }, [active]);\n\n const openList = (\n e: React.KeyboardEvent<HTMLDivElement> | React.MouseEvent<HTMLDivElement>,\n ) => {\n const view = window.visualViewport;\n const rect = dropdownRef.current!.getBoundingClientRect();\n setActive(true);\n\n // NOTE: This first opens the dropdown off-screen, where it is measured\n // by an effect declared above, and then positioned below, or above\n // the original dropdown element, depending where it fits best\n // (if we first open it downward, it would flick if we immediately\n // move it above, at least with the current position update via local\n // react state, and not imperatively).\n setOpsPos({\n left: view?.width ?? 0,\n top: view?.height ?? 0,\n width: rect.width,\n });\n\n e.stopPropagation();\n };\n\n let selected: React.ReactNode = <>&zwnj;</>;\n for (const option of options) {\n if (!filter || filter(option)) {\n const [iValue, iName] = optionValueName(option);\n if (iValue === value) {\n selected = iName;\n break;\n }\n }\n }\n\n let containerClassName = custom.container;\n if (active) containerClassName += ` ${custom.active}`;\n\n let opsContainerClass = custom.select ?? '';\n if (upward) {\n containerClassName += ` ${custom.upward}`;\n opsContainerClass += ` ${custom.upward}`;\n }\n\n return (\n <div className={containerClassName}>\n {label === undefined ? null\n : <div className={custom.label}>{label}</div>}\n <div\n className={custom.dropdown}\n onClick={openList}\n onKeyDown={(e) => {\n if (e.key === 'Enter') openList(e);\n }}\n ref={dropdownRef}\n role=\"listbox\"\n tabIndex={0}\n >\n {selected}\n <div className={custom.arrow} />\n </div>\n {\n active ? (\n <Options\n containerClass={opsContainerClass}\n containerStyle={opsPos}\n onCancel={() => {\n setActive(false);\n }}\n onChange={(newValue) => {\n setActive(false);\n if (onChange) onChange(newValue);\n }}\n optionClass={custom.option ?? ''}\n options={options}\n ref={opsRef}\n />\n ) : null\n }\n </div>\n );\n};\n\nexport default CustomDropdown;\n"],"mappings":"6IAAA,OAGEA,SAAS,CACTC,MAAM,CACNC,QAAQ,KACH,OAAO,CAEd,OAASC,QAAQ,KAAQ,0BAA0B,CAEnD,OAAmCC,eAAe,iBAElD,MAAO,CAAAC,OAAO,EAAmCC,QAAQ,iBAEzD,MAAO,CAAAC,YAAY,oBAAqB,OAAAC,QAAA,IAAAC,SAAA,CAAAC,GAAA,IAAAC,IAAA,CAAAC,IAAA,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CAAA,MAAAuE,EAAAvE,CAAA,MAAA2E,GAAA,MAAAA,GAAA,CAAA3E,CAAA,WAlCN,CAAA2E,GAkCM,CAET,CAED,cAAe,CAAA7E,cAAc","ignoreList":[]}
@@ -1,2 +1,2 @@
1
- import"core-js/modules/es.array.push.js";import{useTheme}from"@dr.pogodin/react-themes";import{optionValueName}from"../common";import defaultTheme from"./theme.scss";import{jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";export const Switch=({label,onChange,options,theme,value})=>{const composed=useTheme("Switch",defaultTheme,theme);if(!options||!composed.option)throw Error("Internal error");const optionNodes=[];for(const option of options){const[iValue,iName]=optionValueName(option);let className=composed.option;let onPress;if(iValue===value)className+=` ${composed.selected}`;else if(onChange){onPress=()=>{onChange(iValue);};}optionNodes.push(onPress?/*#__PURE__*/_jsx("div",{className:className,onClick:onPress,onKeyDown:e=>{if(e.key==="Enter")onPress();},role:"button",tabIndex:0,children:iName},iValue):/*#__PURE__*/_jsx("div",{className:className,children:iName},iValue));}return/*#__PURE__*/_jsxs("div",{className:composed.container,children:[label?/*#__PURE__*/_jsx("div",{className:composed.label,children:label}):null,/*#__PURE__*/_jsx("div",{className:composed.options,children:optionNodes})]});};
1
+ import"core-js/modules/es.array.push.js";import{c as _c}from"react/compiler-runtime";import{useTheme}from"@dr.pogodin/react-themes";import{optionValueName}from"../common";import defaultTheme from"./theme.scss";import{jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";export const Switch=t0=>{const $=_c(16);const{label,onChange,options,theme,value}=t0;const composed=useTheme("Switch",defaultTheme,theme);if(!options||!composed.option){throw Error("Internal error");}let optionNodes;if($[0]!==composed.option||$[1]!==composed.selected||$[2]!==onChange||$[3]!==options||$[4]!==value){optionNodes=[];for(const option of options){const[iValue,iName]=optionValueName(option);let className=composed.option;let onPress;if(iValue===value){className=className+` ${composed.selected}`;}else{if(onChange){onPress=()=>{onChange(iValue)};}}optionNodes.push(onPress?/*#__PURE__*/_jsx("div",{className:className,onClick:onPress,onKeyDown:e=>{if(e.key==="Enter"){onPress()}},role:"button",tabIndex:0,children:iName},iValue):/*#__PURE__*/_jsx("div",{className:className,children:iName},iValue))}$[0]=composed.option;$[1]=composed.selected;$[2]=onChange;$[3]=options;$[4]=value;$[5]=optionNodes}else{optionNodes=$[5]}let t1;if($[6]!==composed.label||$[7]!==label){t1=label?/*#__PURE__*/_jsx("div",{className:composed.label,children:label}):null;$[6]=composed.label;$[7]=label;$[8]=t1}else{t1=$[8]}let t2;if($[9]!==composed.options||$[10]!==optionNodes){t2=/*#__PURE__*/_jsx("div",{className:composed.options,children:optionNodes});$[9]=composed.options;$[10]=optionNodes;$[11]=t2}else{t2=$[11]}let t3;if($[12]!==composed.container||$[13]!==t1||$[14]!==t2){t3=/*#__PURE__*/_jsxs("div",{className:composed.container,children:[t1,t2]});$[12]=composed.container;$[13]=t1;$[14]=t2;$[15]=t3}else{t3=$[15]}return t3};
2
2
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":["useTheme","optionValueName","defaultTheme","jsx","_jsx","jsxs","_jsxs","Switch","label","onChange","options","theme","value","composed","option","Error","optionNodes","iValue","iName","className","onPress","selected","push","onClick","onKeyDown","e","key","role","tabIndex","children","container"],"sources":["../../../../../../src/shared/components/selectors/Switch/index.tsx"],"sourcesContent":["import type { FunctionComponent, ReactNode } from 'react';\n\nimport { type Theme, useTheme } from '@dr.pogodin/react-themes';\n\nimport {\n type OptionsT,\n type ValueT,\n optionValueName,\n} from '../common';\n\nimport defaultTheme from './theme.scss';\n\ntype ThemeT = Theme<'container' | 'label' | 'option' | 'options' | 'selected'>;\n\ntype PropsT = {\n label?: ReactNode;\n onChange?: (value: ValueT) => void;\n options?: Readonly<OptionsT<ReactNode>>;\n theme?: ThemeT;\n value?: ValueT;\n};\n\nexport const Switch: FunctionComponent<PropsT> = ({\n label,\n onChange,\n options,\n theme,\n value,\n}) => {\n const composed = useTheme('Switch', defaultTheme, theme);\n\n if (!options || !composed.option) throw Error('Internal error');\n\n const optionNodes: React.ReactNode[] = [];\n for (const option of options) {\n const [iValue, iName] = optionValueName(option);\n\n let className: string = composed.option;\n let onPress: (() => void) | undefined;\n if (iValue === value) className += ` ${composed.selected}`;\n else if (onChange) {\n onPress = () => {\n onChange(iValue);\n };\n }\n\n optionNodes.push(\n onPress\n ? (\n <div\n className={className}\n key={iValue}\n onClick={onPress}\n onKeyDown={(e) => {\n if (e.key === 'Enter') onPress();\n }}\n role=\"button\"\n tabIndex={0}\n >\n {iName}\n </div>\n )\n : <div className={className} key={iValue}>{iName}</div>,\n );\n }\n\n return (\n <div className={composed.container}>\n {label ? <div className={composed.label}>{label}</div> : null}\n\n <div className={composed.options}>\n {optionNodes}\n </div>\n </div>\n );\n};\n"],"mappings":"yCAEA,OAAqBA,QAAQ,KAAQ,0BAA0B,CAE/D,OAGEC,eAAe,iBAGjB,MAAO,CAAAC,YAAY,oBAAqB,OAAAC,GAAA,IAAAC,IAAA,CAAAC,IAAA,IAAAC,KAAA,yBAYxC,MAAO,MAAM,CAAAC,MAAiC,CAAGA,CAAC,CAChDC,KAAK,CACLC,QAAQ,CACRC,OAAO,CACPC,KAAK,CACLC,KACF,CAAC,GAAK,CACJ,KAAM,CAAAC,QAAQ,CAAGb,QAAQ,CAAC,QAAQ,CAAEE,YAAY,CAAES,KAAK,CAAC,CAExD,GAAI,CAACD,OAAO,EAAI,CAACG,QAAQ,CAACC,MAAM,CAAE,KAAM,CAAAC,KAAK,CAAC,gBAAgB,CAAC,CAE/D,KAAM,CAAAC,WAA8B,CAAG,EAAE,CACzC,IAAK,KAAM,CAAAF,MAAM,GAAI,CAAAJ,OAAO,CAAE,CAC5B,KAAM,CAACO,MAAM,CAAEC,KAAK,CAAC,CAAGjB,eAAe,CAACa,MAAM,CAAC,CAE/C,GAAI,CAAAK,SAAiB,CAAGN,QAAQ,CAACC,MAAM,CACvC,GAAI,CAAAM,OAAiC,CACrC,GAAIH,MAAM,GAAKL,KAAK,CAAEO,SAAS,EAAI,IAAIN,QAAQ,CAACQ,QAAQ,EAAE,CAAC,IACtD,IAAIZ,QAAQ,CAAE,CACjBW,OAAO,CAAGA,CAAA,GAAM,CACdX,QAAQ,CAACQ,MAAM,CAAC,CAClB,CAAC,CACH,CAEAD,WAAW,CAACM,IAAI,CACdF,OAAO,cAEHhB,IAAA,QACEe,SAAS,CAAEA,SAAU,CAErBI,OAAO,CAAEH,OAAQ,CACjBI,SAAS,CAAGC,CAAC,EAAK,CAChB,GAAIA,CAAC,CAACC,GAAG,GAAK,OAAO,CAAEN,OAAO,CAAC,CAAC,CAClC,CAAE,CACFO,IAAI,CAAC,QAAQ,CACbC,QAAQ,CAAE,CAAE,CAAAC,QAAA,CAEXX,KAAK,EARDD,MASF,CAAC,cAENb,IAAA,QAAKe,SAAS,CAAEA,SAAU,CAAAU,QAAA,CAAeX,KAAK,EAAdD,MAAoB,CAC1D,CAAC,CACH,CAEA,mBACEX,KAAA,QAAKa,SAAS,CAAEN,QAAQ,CAACiB,SAAU,CAAAD,QAAA,EAChCrB,KAAK,cAAGJ,IAAA,QAAKe,SAAS,CAAEN,QAAQ,CAACL,KAAM,CAAAqB,QAAA,CAAErB,KAAK,CAAM,CAAC,CAAG,IAAI,cAE7DJ,IAAA,QAAKe,SAAS,CAAEN,QAAQ,CAACH,OAAQ,CAAAmB,QAAA,CAC9Bb,WAAW,CACT,CAAC,EACH,CAAC,CAEV,CAAC","ignoreList":[]}
1
+ {"version":3,"file":"index.js","names":["useTheme","optionValueName","defaultTheme","jsx","_jsx","jsxs","_jsxs","Switch","t0","$","_c","label","onChange","options","theme","value","composed","option","Error","optionNodes","selected","iValue","iName","className","onPress","push","onKeyDown","e","key","role","tabIndex","children","t1","t2","t3","container"],"sources":["../../../../../../src/shared/components/selectors/Switch/index.tsx"],"sourcesContent":["import type { FunctionComponent, ReactNode } from 'react';\n\nimport { type Theme, useTheme } from '@dr.pogodin/react-themes';\n\nimport {\n type OptionsT,\n type ValueT,\n optionValueName,\n} from '../common';\n\nimport defaultTheme from './theme.scss';\n\ntype ThemeT = Theme<'container' | 'label' | 'option' | 'options' | 'selected'>;\n\ntype PropsT = {\n label?: ReactNode;\n onChange?: (value: ValueT) => void;\n options?: Readonly<OptionsT<ReactNode>>;\n theme?: ThemeT;\n value?: ValueT;\n};\n\nexport const Switch: FunctionComponent<PropsT> = ({\n label,\n onChange,\n options,\n theme,\n value,\n}) => {\n const composed = useTheme('Switch', defaultTheme, theme);\n\n if (!options || !composed.option) throw Error('Internal error');\n\n const optionNodes: React.ReactNode[] = [];\n for (const option of options) {\n const [iValue, iName] = optionValueName(option);\n\n let className: string = composed.option;\n let onPress: (() => void) | undefined;\n if (iValue === value) className += ` ${composed.selected}`;\n else if (onChange) {\n onPress = () => {\n onChange(iValue);\n };\n }\n\n optionNodes.push(\n onPress\n ? (\n <div\n className={className}\n key={iValue}\n onClick={onPress}\n onKeyDown={(e) => {\n if (e.key === 'Enter') onPress();\n }}\n role=\"button\"\n tabIndex={0}\n >\n {iName}\n </div>\n )\n : <div className={className} key={iValue}>{iName}</div>,\n );\n }\n\n return (\n <div className={composed.container}>\n {label ? <div className={composed.label}>{label}</div> : null}\n\n <div className={composed.options}>\n {optionNodes}\n </div>\n </div>\n );\n};\n"],"mappings":"qFAEA,OAAqBA,QAAQ,KAAQ,0BAA0B,CAE/D,OAGEC,eAAe,iBAGjB,MAAO,CAAAC,YAAY,oBAAqB,OAAAC,GAAA,IAAAC,IAAA,CAAAC,IAAA,IAAAC,KAAA,yBAYxC,MAAO,MAAM,CAAAC,MAAiC,CAAGC,EAAA,SAAAC,CAAA,CAAAC,EAAA,KAAC,MAAAC,KAAA,CAAAC,QAAA,CAAAC,OAAA,CAAAC,KAAA,CAAAC,KAAA,EAAAP,EAMjD,CACC,MAAAQ,QAAA,CAAiBhB,QAAQ,CAAC,QAAQ,CAAEE,YAAY,CAAEY,KAAK,CAAC,CAExD,GAAI,CAACD,OAA2B,EAA5B,CAAaG,QAAQ,CAAAC,M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B,EAAA,IAAAvB,CAAA,MAAAO,QAAA,CAAAL,KAAA,EAAAF,CAAA,MAAAE,KAAA,EAIIqB,EAAA,CAAArB,KAAK,cAALP,IAAA,QAAwBmB,SAAc,CAAdP,QAAQ,CAAAL,KAAM,CAAAoB,QAAA,CAAGpB,KAAK,CAAa,CAAC,CAA5D,IAA4D,CAAAF,CAAA,IAAAO,QAAA,CAAAL,KAAAF,CAAA,KAAAE,KAAAF,CAAA,KAAAuB,EAAA,MAAAA,EAAA,CAAAvB,CAAA,QAAAwB,EAAA,IAAAxB,CAAA,MAAAO,QAAA,CAAAH,OAAA,EAAAJ,CAAA,OAAAU,WAAA,EAE7Dc,EAAA,cAAA7B,IAAA,QAAgBmB,SAAgB,CAAhBP,QAAQ,CAAAH,OAAQ,CAAAkB,QAAA,CAC7BZ,WAAW,CACT,CAAC,CAAAV,CAAA,IAAAO,QAAA,CAAAH,OAAAJ,CAAA,MAAAU,WAAAV,CAAA,MAAAwB,EAAA,MAAAA,EAAA,CAAAxB,CAAA,SAAAyB,EAAA,IAAAzB,CAAA,OAAAO,QAAA,CAAAmB,SAAA,EAAA1B,CAAA,OAAAuB,EAAA,EAAAvB,CAAA,OAAAwB,EAAA,EALRC,EAAA,cAAA5B,KAAA,QAAgBiB,SAAkB,CAAlBP,QAAQ,CAAAmB,SAAU,CAAAJ,QAAA,EAC/BC,EAA4D,CAE7DC,EAEM,EACH,CAAC,CAAAxB,CAAA,KAAAO,QAAA,CAAAmB,SAAA1B,CAAA,MAAAuB,EAAAvB,CAAA,MAAAwB,EAAAxB,CAAA,MAAAyB,EAAA,MAAAA,EAAA,CAAAzB,CAAA,WANN,CAAAyB,EAMM,CAET","ignoreList":[]}
@@ -2,5 +2,5 @@ import{withGlobalStateType}from"@dr.pogodin/react-global-state";/** Mapping "chu
2
2
  // TODO: Not 100% sure now, whether it indeed can be replaced by type,
3
3
  // or do we really need it to be an interface. Keeping the interface for now.
4
4
  // eslint-disable-next-line @typescript-eslint/consistent-type-definitions
5
- const{getSsrContext}=withGlobalStateType();export{getSsrContext};
5
+ const{useSsrContext}=withGlobalStateType();export{useSsrContext};
6
6
  //# sourceMappingURL=globalState.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"globalState.js","names":["withGlobalStateType","getSsrContext"],"sources":["../../../../src/shared/utils/globalState.ts"],"sourcesContent":["import type { Request } from 'express';\n\nimport { type SsrContext, withGlobalStateType } from '@dr.pogodin/react-global-state';\n\n/** Mapping \"chunkName\" > array of asset paths. */\nexport type ChunkGroupsT = Record<string, string[]>;\n\n// The type of data object injected by server into generated markup.\nexport type InjT = {\n CHUNK_GROUPS?: ChunkGroupsT;\n CONFIG?: Record<string, unknown>;\n ISTATE?: unknown;\n};\n\ndeclare global {\n // eslint-disable-next-line @typescript-eslint/consistent-type-definitions\n interface Window {\n REACT_UTILS_INJECTION?: InjT;\n }\n}\n\n// TODO: Not 100% sure now, whether it indeed can be replaced by type,\n// or do we really need it to be an interface. Keeping the interface for now.\n// eslint-disable-next-line @typescript-eslint/consistent-type-definitions\nexport interface SsrContextT<StateT> extends SsrContext<StateT> {\n chunkGroups: ChunkGroupsT;\n chunks: string[];\n\n /** If set at the end of SSR, the rendered will trigger\n * server-side redirect to this URL (and use the status\n * code). */\n redirectTo?: string;\n\n req: Request;\n status: number;\n}\n\nconst {\n getSsrContext,\n} = withGlobalStateType<unknown, SsrContextT<unknown>>();\n\nexport {\n getSsrContext,\n};\n"],"mappings":"AAEA,OAA0BA,mBAAmB,KAAQ,gCAAgC,CAErF,kDAGA;AAcA;AACA;AACA;AAcA,KAAM,CACJC,aACF,CAAC,CAAGD,mBAAmB,CAAgC,CAAC,CAExD,OACEC,aAAa","ignoreList":[]}
1
+ {"version":3,"file":"globalState.js","names":["withGlobalStateType","useSsrContext"],"sources":["../../../../src/shared/utils/globalState.ts"],"sourcesContent":["import type { Request } from 'express';\n\nimport { type SsrContext, withGlobalStateType } from '@dr.pogodin/react-global-state';\n\n/** Mapping \"chunkName\" > array of asset paths. */\nexport type ChunkGroupsT = Record<string, string[]>;\n\n// The type of data object injected by server into generated markup.\nexport type InjT = {\n CHUNK_GROUPS?: ChunkGroupsT;\n CONFIG?: Record<string, unknown>;\n ISTATE?: unknown;\n};\n\ndeclare global {\n // eslint-disable-next-line @typescript-eslint/consistent-type-definitions\n interface Window {\n REACT_UTILS_INJECTION?: InjT;\n }\n}\n\n// TODO: Not 100% sure now, whether it indeed can be replaced by type,\n// or do we really need it to be an interface. Keeping the interface for now.\n// eslint-disable-next-line @typescript-eslint/consistent-type-definitions\nexport interface SsrContextT<StateT> extends SsrContext<StateT> {\n chunkGroups: ChunkGroupsT;\n chunks: string[];\n\n /** If set at the end of SSR, the rendered will trigger\n * server-side redirect to this URL (and use the status\n * code). */\n redirectTo?: string;\n\n req: Request;\n status: number;\n}\n\nconst {\n useSsrContext,\n} = withGlobalStateType<unknown, SsrContextT<unknown>>();\n\nexport {\n useSsrContext,\n};\n"],"mappings":"AAEA,OAA0BA,mBAAmB,KAAQ,gCAAgC,CAErF,kDAGA;AAcA;AACA;AACA;AAcA,KAAM,CACJC,aACF,CAAC,CAAGD,mBAAmB,CAAgC,CAAC,CAExD,OACEC,aAAa","ignoreList":[]}
@@ -1,2 +1,2 @@
1
- import{getConfig}from"./config";import time from"./time";import*as webpack from"./webpack";export*from"./isomorphy";export{Barrier,Cached,Emitter,Semaphore,assertEmptyObject,withRetries}from"@dr.pogodin/js-utils";export{COMPOSE as THEME_COMPOSE,PRIORITY as THEME_PRIORITY,ThemeProvider,useTheme}from"@dr.pogodin/react-themes";export{getSsrContext}from"./globalState";export{default as splitComponent}from"./splitComponent";export{getConfig,time,webpack};
1
+ import{getConfig}from"./config";import time from"./time";import*as webpack from"./webpack";export*from"./isomorphy";export{Barrier,Cached,Emitter,Semaphore,assertEmptyObject,withRetries}from"@dr.pogodin/js-utils";export{COMPOSE as THEME_COMPOSE,PRIORITY as THEME_PRIORITY,ThemeProvider,useTheme}from"@dr.pogodin/react-themes";export{useSsrContext}from"./globalState";export{default as splitComponent}from"./splitComponent";export{getConfig,time,webpack};
2
2
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":["getConfig","time","webpack","Barrier","Cached","Emitter","Semaphore","assertEmptyObject","withRetries","COMPOSE","THEME_COMPOSE","PRIORITY","THEME_PRIORITY","ThemeProvider","useTheme","getSsrContext","default","splitComponent"],"sources":["../../../../src/shared/utils/index.ts"],"sourcesContent":["import { getConfig } from './config';\nimport time from './time';\nimport * as webpack from './webpack';\n\nexport * from './isomorphy';\n\nexport {\n Barrier,\n Cached,\n Emitter,\n type Listener,\n type ObjectKey,\n Semaphore,\n assertEmptyObject,\n withRetries,\n} from '@dr.pogodin/js-utils';\n\nexport {\n COMPOSE as THEME_COMPOSE,\n PRIORITY as THEME_PRIORITY,\n type Theme,\n ThemeProvider,\n useTheme,\n} from '@dr.pogodin/react-themes';\n\nexport { getSsrContext } from './globalState';\nexport { default as splitComponent } from './splitComponent';\n\nexport { getConfig, time, webpack };\n"],"mappings":"AAAA,OAASA,SAAS,gBAClB,MAAO,CAAAC,IAAI,cACX,MAAO,GAAK,CAAAC,OAAO,iBAEnB,yBAEA,OACEC,OAAO,CACPC,MAAM,CACNC,OAAO,CAGPC,SAAS,CACTC,iBAAiB,CACjBC,WAAW,KACN,sBAAsB,CAE7B,OACEC,OAAO,GAAI,CAAAC,aAAa,CACxBC,QAAQ,GAAI,CAAAC,cAAc,CAE1BC,aAAa,CACbC,QAAQ,KACH,0BAA0B,CAEjC,OAASC,aAAa,qBACtB,OAASC,OAAO,GAAI,CAAAC,cAAc,wBAElC,OAASjB,SAAS,CAAEC,IAAI,CAAEC,OAAO","ignoreList":[]}
1
+ {"version":3,"file":"index.js","names":["getConfig","time","webpack","Barrier","Cached","Emitter","Semaphore","assertEmptyObject","withRetries","COMPOSE","THEME_COMPOSE","PRIORITY","THEME_PRIORITY","ThemeProvider","useTheme","useSsrContext","default","splitComponent"],"sources":["../../../../src/shared/utils/index.ts"],"sourcesContent":["import { getConfig } from './config';\nimport time from './time';\nimport * as webpack from './webpack';\n\nexport * from './isomorphy';\n\nexport {\n Barrier,\n Cached,\n Emitter,\n type Listener,\n type ObjectKey,\n Semaphore,\n assertEmptyObject,\n withRetries,\n} from '@dr.pogodin/js-utils';\n\nexport {\n COMPOSE as THEME_COMPOSE,\n PRIORITY as THEME_PRIORITY,\n type Theme,\n ThemeProvider,\n useTheme,\n} from '@dr.pogodin/react-themes';\n\nexport { useSsrContext } from './globalState';\nexport { default as splitComponent } from './splitComponent';\n\nexport { getConfig, time, webpack };\n"],"mappings":"AAAA,OAASA,SAAS,gBAClB,MAAO,CAAAC,IAAI,cACX,MAAO,GAAK,CAAAC,OAAO,iBAEnB,yBAEA,OACEC,OAAO,CACPC,MAAM,CACNC,OAAO,CAGPC,SAAS,CACTC,iBAAiB,CACjBC,WAAW,KACN,sBAAsB,CAE7B,OACEC,OAAO,GAAI,CAAAC,aAAa,CACxBC,QAAQ,GAAI,CAAAC,cAAc,CAE1BC,aAAa,CACbC,QAAQ,KACH,0BAA0B,CAEjC,OAASC,aAAa,qBACtB,OAASC,OAAO,GAAI,CAAAC,cAAc,wBAElC,OAASjB,SAAS,CAAEC,IAAI,CAAEC,OAAO","ignoreList":[]}
@@ -1,4 +1,4 @@
1
- import"core-js/modules/es.array.push.js";import"core-js/modules/es.iterator.constructor.js";import"core-js/modules/es.set.difference.v2.js";import"core-js/modules/es.set.intersection.v2.js";import"core-js/modules/es.set.is-disjoint-from.v2.js";import"core-js/modules/es.set.is-subset-of.v2.js";import"core-js/modules/es.set.is-superset-of.v2.js";import"core-js/modules/es.set.symmetric-difference.v2.js";import"core-js/modules/es.set.union.v2.js";/* global document */import{Suspense,lazy,useInsertionEffect}from"react";import{Barrier}from"@dr.pogodin/js-utils";import{getSsrContext}from"./globalState";import{IS_CLIENT_SIDE,IS_SERVER_SIDE,getBuildInfo}from"./isomorphy";import{jsx as _jsx}from"react/jsx-runtime";function getClientChunkGroups(){if(!IS_CLIENT_SIDE)return undefined;return(async()=>{const{default:getInj}=await import(/* webpackChunkName: "react-utils-client-side-code" */"../../client/getInj");const inj=await getInj();return inj.CHUNK_GROUPS??{};})();}const refCounts={};function getPublicPath(){return getBuildInfo().publicPath;}/**
1
+ import"core-js/modules/es.array.push.js";import"core-js/modules/es.iterator.constructor.js";import"core-js/modules/es.set.difference.v2.js";import"core-js/modules/es.set.intersection.v2.js";import"core-js/modules/es.set.is-disjoint-from.v2.js";import"core-js/modules/es.set.is-subset-of.v2.js";import"core-js/modules/es.set.is-superset-of.v2.js";import"core-js/modules/es.set.symmetric-difference.v2.js";import"core-js/modules/es.set.union.v2.js";import{c as _c}from"react/compiler-runtime";/* global document */import{Suspense,lazy,useInsertionEffect}from"react";import{Barrier}from"@dr.pogodin/js-utils";import{useSsrContext}from"./globalState";import{IS_CLIENT_SIDE,IS_SERVER_SIDE,assertClientSide,getBuildInfo}from"./isomorphy";import{jsx as _jsx}from"react/jsx-runtime";let clientChunkGroups;export function setClientChunkGroups(groups){assertClientSide();clientChunkGroups=groups;}const refCounts={};function getPublicPath(){return getBuildInfo().publicPath;}/**
2
2
  * Client-side only! Ensures the specified CSS stylesheet is loaded into
3
3
  * the document; loads if it is missing; and does simple reference counting
4
4
  * to facilitate future clean-up.
@@ -51,15 +51,8 @@ import"core-js/modules/es.array.push.js";import"core-js/modules/es.iterator.cons
51
51
  // ) {
52
52
  // throw Error(`Repeated splitComponent() call for the chunk "${chunkName}"`);
53
53
  // } else usedChunkNames.add(chunkName);
54
- const LazyComponent=/*#__PURE__*/lazy(async()=>{const clientChunkGroups=await getClientChunkGroups();// On the client side we can check right away if the chunk name is known.
55
- if(IS_CLIENT_SIDE){if(!clientChunkGroups)throw Error("Internal error");assertChunkName(chunkName,clientChunkGroups);}const resolved=await getComponent();const Component="default"in resolved?resolved.default:resolved;// This pre-loads necessary stylesheets prior to the first mount of
54
+ const LazyComponent=/*#__PURE__*/lazy(async()=>{const resolved=await getComponent();const Component="default"in resolved?resolved.default:resolved;// This pre-loads necessary stylesheets prior to the first mount of
56
55
  // the component (the lazy load function is executed by React one at
57
56
  // the frist mount).
58
- if(IS_CLIENT_SIDE){if(!clientChunkGroups)throw Error("Internal error");await bookStyleSheets(chunkName,clientChunkGroups,false);}const Wrapper=({children,ref,...rest})=>{// On the server side we'll assert the chunk name here,
59
- // and also push it to the SSR chunks array.
60
- if(IS_SERVER_SIDE){const{chunkGroups,chunks}=getSsrContext();assertChunkName(chunkName,chunkGroups);if(!chunks.includes(chunkName))chunks.push(chunkName);}// This takes care about stylesheets management every time an instance of
61
- // this component is mounted / unmounted.
62
- useInsertionEffect(()=>{if(!clientChunkGroups)throw Error("Internal error");void bookStyleSheets(chunkName,clientChunkGroups,true);return()=>{freeStyleSheets(chunkName,clientChunkGroups);};},[]);return/*#__PURE__*/_jsx(Component// eslint-disable-next-line react/jsx-props-no-spreading
63
- ,{...rest,ref:ref,children:children});};return{default:Wrapper};});const CodeSplit=({children,...rest})=>/*#__PURE__*/_jsx(Suspense,{fallback:placeholder,children:/*#__PURE__*/_jsx(LazyComponent// eslint-disable-next-line react/jsx-props-no-spreading
64
- ,{...rest,children:children})});return CodeSplit;}
57
+ if(IS_CLIENT_SIDE){if(!clientChunkGroups)throw Error("Internal error");await bookStyleSheets(chunkName,clientChunkGroups,false);}const Wrapper=t0=>{const $=_c(12);let children;let chunkGroups;let ref;let rest;if($[0]!==t0){({children,chunkGroups,ref,...rest}=t0);$[0]=t0;$[1]=children;$[2]=chunkGroups;$[3]=ref;$[4]=rest}else{children=$[1];chunkGroups=$[2];ref=$[3];rest=$[4]}let t1;let t2;if($[5]!==chunkGroups){t1=()=>{if(!clientChunkGroups){throw Error("Internal error");}bookStyleSheets(chunkName,chunkGroups,true);return()=>{freeStyleSheets(chunkName,chunkGroups)}};t2=[chunkGroups];$[5]=chunkGroups;$[6]=t1;$[7]=t2}else{t1=$[6];t2=$[7]}useInsertionEffect(t1,t2);const t3=rest;let t4;if($[8]!==children||$[9]!==ref||$[10]!==t3){t4=/*#__PURE__*/_jsx(Component,{...t3,ref:ref,children:children});$[8]=children;$[9]=ref;$[10]=t3;$[11]=t4}else{t4=$[11]}return t4};return{default:Wrapper};});const CodeSplit=t0=>{const $=_c(7);let children;let rest;if($[0]!==t0){({children,...rest}=t0);$[0]=t0;$[1]=children;$[2]=rest}else{children=$[1];rest=$[2]}let chunkGroups;const ssrContext=useSsrContext(false);if(IS_SERVER_SIDE){if(!ssrContext){throw Error("Internal error");}({chunkGroups}=ssrContext);const{chunks}=ssrContext;if(!chunks.includes(chunkName)){chunks.push(chunkName)}}else{if(!clientChunkGroups){throw Error("Internal error");}chunkGroups=clientChunkGroups;}assertChunkName(chunkName,chunkGroups);const t1=rest;let t2;if($[3]!==children||$[4]!==chunkGroups||$[5]!==t1){t2=/*#__PURE__*/_jsx(Suspense,{fallback:placeholder,children:/*#__PURE__*/_jsx(LazyComponent,{...t1,chunkGroups:chunkGroups,children:children})});$[3]=children;$[4]=chunkGroups;$[5]=t1;$[6]=t2}else{t2=$[6]}return t2};return CodeSplit;}
65
58
  //# sourceMappingURL=splitComponent.js.map
@@ -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":"+bAAA,qBAEA,OAKEA,QAAQ,CACRC,IAAI,CACJC,kBAAkB,KACb,OAAO,CAEd,OAASC,OAAO,KAAQ,sBAAsB,CAE9C,OAA4BC,aAAa,qBAEzC,OACEC,cAAc,CACdC,cAAc,CACdC,YAAY,mBACO,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,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CAAC,IAAM,CACvB,GAAI,CAACgE,iBAAiB,CAAE,KAAM,CAAA7B,KAAK,CAAC,gBAAgB,CAAC,CACrD,IAAK,CAAAW,eAAe,CAACF,SAAS,CAAEoB,iBAAiB,CAAE,IAAI,CAAC,CACxD,MAAO,IAAM,CACXP,eAAe,CAACb,SAAS,CAAEoB,iBAAiB,CAAC,CAC/C,CAAC,CACH,CAAC,CAAE,EAAE,CAAC,CAEN,mBACEzD,IAAA,CAAC2D,SACC;AAAA,KACKI,IAAI,CACTD,GAAG,CAAEA,GAAI,CAAAD,QAAA,CAERA,QAAQ,CACA,CAAC,CAEhB,CAAC,CAED,MAAO,CAAE1D,OAAO,CAAEyD,OAAQ,CAAC,CAC7B,CAAC,CAAC,CAEF,KAAM,CAAAM,SAAmD,CAAGA,CAAC,CAC3DL,QAAQ,CACR,GAAGE,IACY,CAAC,gBAChB/D,IAAA,CAACT,QAAQ,EAAC4E,QAAQ,CAAEZ,WAAY,CAAAM,QAAA,cAC9B7D,IAAA,CAACwD,aACC;AAAA,KACIO,IAAI,CAAAF,QAAA,CAEPA,QAAQ,CACI,CAAC,CACR,CACX,CAED,MAAO,CAAAK,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"],"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":"2eAAA,qBAEA,OAKEA,QAAQ,CACRC,IAAI,CACJC,kBAAkB,KACb,OAAO,CAEd,OAASC,OAAO,KAAQ,sBAAsB,CAE9C,OAA4BC,aAAa,qBAEzC,OACEC,cAAc,CACdC,cAAc,CACdC,gBAAgB,CAChBC,YAAY,mBACO,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,KA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,MAAM,CAAA3B,IAAK,CAACT,SAAS,CAAC,CAAC,MAExD,GAAI,CAACjC,iBAAiB,EAAE,KAAM,CAAAwB,KAAK,CAAC,gBAAgB,CAAC,CAAC,CACtDU,YAAclC,iBAAiB,CAApB,CAGbgC,eAAe,CAACC,SAAS,CAAEC,WAAW,CAAC,CAM7B,MAAA6B,EAAA,CAAAD,IAAI,CAAuC,IAAAE,EAAA,IAAAN,CAAA,MAAAE,QAAA,EAAAF,CAAA,MAAAxB,WAAA,EAAAwB,CAAA,MAAAK,EAAA,EAHnDC,EAAA,cAAAjE,IAAA,CAACV,QAAQ,EAAW8D,QAAW,CAAXA,WAAW,CAAAS,QAAA,cAC7B7D,IAAA,CAACqD,aAAa,KAERW,EAA2C,CAElC7B,WAAW,CAAXA,WAAW,CAAA0B,QAAA,CAEvBA,QAAQ,CACI,CAAC,CACR,CAAC,CAAAF,CAAA,IAAAE,QAAAF,CAAA,KAAAxB,WAAAwB,CAAA,KAAAK,EAAAL,CAAA,KAAAM,EAAA,MAAAA,EAAA,CAAAN,CAAA,UATX,CAAAM,EASW,CAEd,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";/**
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";/**
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,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,qBAEtB;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,CA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,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,S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,SAAS,CAACgC,UAAU,CAAEM,OAAK,CAAAY,QAAS,CAAC,CAAC,CAAE,CAAAC,IAAA,CAAQ,GAAI,CAAC,CAAxD,CAChB,CACF,CAAEP,EAAA,EAACZ,UAAU,CAAEU,SAAS,CAAC,CAAAd,CAAA,IAAAI,UAAAJ,CAAA,KAAAc,SAAAd,CAAA,KAAAe,EAAAf,CAAA,KAAAgB,EAAA,MAAAD,EAAA,CAAAf,CAAA,GAAAgB,CAAA,GAAAhB,CAAA,IAP1B1B,SAAS,CAACyC,EAOT,CAAEC,EAAuB,CAAC,OACpB,CAAAH,MAAM,CAGf,KAAM,CAAAW,IAAI,CAAG,CACXjD,MAAM,CACNC,OAAO,CACPC,MAAM,CACNC,MAAM,CACNC,OAAO,CACPQ,GAAG,CAAEE,IAAI,CAACF,GAAG,CACbP,KAAK,CACLG,UAAU,CACVe,iBACF,CAAC,CAED,cAAe,CAAA2B,MAAM,CAACC,MAAM,CAACrD,KAAK,CAAEmD,IAAI,CAAC","ignoreList":[]}
@@ -14,6 +14,7 @@ type ModuleT = 'amd' | 'auto' | 'cjs' | 'commonjs' | 'systemjs' | 'umd' | false;
14
14
  export type OptionsT = {
15
15
  modules?: ModuleT;
16
16
  noRR?: boolean;
17
+ noReactCompiler?: boolean;
17
18
  noStyling?: boolean;
18
19
  targets?: Record<string, string> | string | string[];
19
20
  typescript?: boolean;
@@ -21,19 +21,17 @@ var ENVIRONMENTS;
21
21
  */
22
22
  function newBaseConfig(options) {
23
23
  var _a, _b;
24
+ const plugins = [];
25
+ if (!options.noReactCompiler)
26
+ plugins.push('babel-plugin-react-compiler');
27
+ plugins.push(['module-resolver', {
28
+ extensions: ['.js', '.jsx', '.ts', '.tsx'],
29
+ root: ['./src/shared', './src'],
30
+ }], ['@babel/transform-runtime', {
31
+ useESModules: true,
32
+ }]);
24
33
  return {
25
- plugins: [
26
- ['module-resolver', {
27
- extensions: ['.js', '.jsx', '.ts', '.tsx'],
28
- root: [
29
- './src/shared',
30
- './src',
31
- ],
32
- }],
33
- ['@babel/transform-runtime', {
34
- useESModules: true,
35
- }],
36
- ],
34
+ plugins,
37
35
  presets: [
38
36
  ['@babel/env', {
39
37
  bugfixes: true,
package/package.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "1.53.0",
2
+ "version": "1.54.0",
3
3
  "bin": {
4
4
  "react-utils-build": "bin/build.js",
5
5
  "react-utils-setup": "bin/setup.js"
@@ -13,11 +13,11 @@
13
13
  "@dr.pogodin/babel-plugin-react-css-modules": "^6.13.9",
14
14
  "@dr.pogodin/csurf": "^1.17.1",
15
15
  "@dr.pogodin/js-utils": "^0.1.8",
16
- "@dr.pogodin/react-global-state": "^0.23.0",
16
+ "@dr.pogodin/react-global-state": "^0.24.0",
17
17
  "@dr.pogodin/react-helmet": "^3.2.2",
18
- "@dr.pogodin/react-themes": "^1.10.4",
18
+ "@dr.pogodin/react-themes": "^1.10.5",
19
19
  "@jest/environment": "^30.4.1",
20
- "axios": "^1.17.0",
20
+ "axios": "^1.18.0",
21
21
  "commander": "^15.0.0",
22
22
  "compression": "^1.8.1",
23
23
  "config": "^4.4.1",
@@ -35,10 +35,10 @@
35
35
  "raf": "^3.4.1",
36
36
  "react": "^19.2.7",
37
37
  "react-dom": "^19.2.7",
38
- "react-router": "^7.17.0",
38
+ "react-router": "^7.18.0",
39
39
  "request-ip": "^3.3.0",
40
40
  "rimraf": "^6.1.3",
41
- "serialize-javascript": "^7.0.5",
41
+ "serialize-javascript": "^7.0.6",
42
42
  "serve-favicon": "^2.5.1",
43
43
  "source-map-support": "^0.5.21",
44
44
  "winston": "^3.19.0"
@@ -56,6 +56,7 @@
56
56
  "@dr.pogodin/babel-plugin-transform-assets": "^1.2.6",
57
57
  "@dr.pogodin/babel-preset-svgr": "^1.9.3",
58
58
  "@dr.pogodin/eslint-configs": "^0.2.14",
59
+ "@jest/globals": "^30.4.1",
59
60
  "@pmmmwh/react-refresh-webpack-plugin": "^0.6.2",
60
61
  "@standard-schema/spec": "^1.1.0",
61
62
  "@testing-library/dom": "^10.4.1",
@@ -86,13 +87,14 @@
86
87
  "babel-loader": "^10.1.1",
87
88
  "babel-plugin-add-import-extension": "^1.6.0",
88
89
  "babel-plugin-module-resolver": "^5.0.3",
90
+ "babel-plugin-react-compiler": "^1.0.0",
89
91
  "babel-plugin-transform-import-meta": "^2.3.3",
90
92
  "css-loader": "^7.1.4",
91
93
  "css-minimizer-webpack-plugin": "^8.0.0",
92
94
  "identity-obj-proxy": "^3.0.0",
93
95
  "jest": "^30.4.2",
94
96
  "jest-environment-jsdom": "^30.4.1",
95
- "memfs": "^4.57.6",
97
+ "memfs": "^4.57.8",
96
98
  "mini-css-extract-plugin": "^2.10.2",
97
99
  "mockdate": "^3.0.5",
98
100
  "nodelist-foreach-polyfill": "^1.2.0",
@@ -102,7 +104,7 @@
102
104
  "pretty": "^2.0.0",
103
105
  "react-refresh": "^0.18.0",
104
106
  "resolve-url-loader": "^5.0.0",
105
- "sass": "^1.100.0",
107
+ "sass": "^1.101.0",
106
108
  "sass-loader": "^17.0.0",
107
109
  "sitemap": "^9.0.1",
108
110
  "source-map-loader": "^5.0.0",
package/tsconfig.json CHANGED
@@ -10,7 +10,7 @@
10
10
  // statements in the code, thus breaking Webpack's code splitting.
11
11
  // See: https://davidea.st/articles/webpack-typescript-code-split-wont-work
12
12
  "module": "ESNext",
13
- "moduleResolution": "Node",
13
+ "moduleResolution": "bundler",
14
14
 
15
15
  "paths": {
16
16
  "*": ["./src/shared/*", "./src/*", "./*"]
@@ -21,7 +21,7 @@
21
21
  // statements in the code, thus breaking Webpack's code splitting.
22
22
  // See: https://davidea.st/articles/webpack-typescript-code-split-wont-work
23
23
  "module": "ESNext",
24
- "moduleResolution": "Node",
24
+ "moduleResolution": "bundler",
25
25
 
26
26
  "outDir": "build/types-code",
27
27