@dr.pogodin/react-utils 1.48.10 → 1.48.13
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.
- package/build/development/client/index.js +1 -1
- package/build/development/client/index.js.map +1 -1
- package/build/development/index.js +2 -2
- package/build/development/index.js.map +1 -1
- package/build/development/server/index.js +1 -1
- package/build/development/server/index.js.map +1 -1
- package/build/development/server/renderer.js +5 -5
- package/build/development/server/renderer.js.map +1 -1
- package/build/development/server/server.js +2 -2
- package/build/development/server/server.js.map +1 -1
- package/build/development/shared/components/Button/index.js.map +1 -1
- package/build/development/shared/components/Checkbox/index.js.map +1 -1
- package/build/development/shared/components/Link.js.map +1 -1
- package/build/development/shared/components/Modal/index.js +1 -1
- package/build/development/shared/components/Modal/index.js.map +1 -1
- package/build/development/shared/components/NavLink.js.map +1 -1
- package/build/development/shared/components/WithTooltip/Tooltip.js.map +1 -1
- package/build/development/shared/components/WithTooltip/index.js +2 -2
- package/build/development/shared/components/WithTooltip/index.js.map +1 -1
- package/build/development/shared/components/YouTubeVideo/index.js.map +1 -1
- package/build/development/shared/components/index.js +3 -3
- package/build/development/shared/components/index.js.map +1 -1
- package/build/development/shared/components/selectors/CustomDropdown/Options/index.js.map +1 -1
- package/build/development/shared/components/selectors/NativeDropdown/index.js.map +1 -1
- package/build/development/shared/utils/config.js.map +1 -1
- package/build/development/shared/utils/index.js +1 -1
- package/build/development/shared/utils/index.js.map +1 -1
- package/build/development/shared/utils/time.js +1 -1
- package/build/development/shared/utils/time.js.map +1 -1
- package/build/development/shared/utils/webpack.js.map +1 -1
- package/build/production/client/index.js +1 -1
- package/build/production/client/index.js.map +1 -1
- package/build/production/index.js +1 -1
- package/build/production/index.js.map +1 -1
- package/build/production/server/index.js +1 -1
- package/build/production/server/index.js.map +1 -1
- package/build/production/server/renderer.js +3 -3
- package/build/production/server/renderer.js.map +1 -1
- package/build/production/server/server.js +1 -1
- package/build/production/server/server.js.map +1 -1
- package/build/production/shared/components/Button/index.js.map +1 -1
- package/build/production/shared/components/Checkbox/index.js.map +1 -1
- package/build/production/shared/components/Link.js.map +1 -1
- package/build/production/shared/components/Modal/index.js +1 -1
- package/build/production/shared/components/Modal/index.js.map +1 -1
- package/build/production/shared/components/NavLink.js.map +1 -1
- package/build/production/shared/components/WithTooltip/Tooltip.js.map +1 -1
- package/build/production/shared/components/WithTooltip/index.js +1 -1
- package/build/production/shared/components/WithTooltip/index.js.map +1 -1
- package/build/production/shared/components/YouTubeVideo/index.js.map +1 -1
- package/build/production/shared/components/index.js +1 -1
- package/build/production/shared/components/index.js.map +1 -1
- package/build/production/shared/components/selectors/CustomDropdown/Options/index.js.map +1 -1
- package/build/production/shared/components/selectors/NativeDropdown/index.js.map +1 -1
- package/build/production/shared/utils/config.js.map +1 -1
- package/build/production/shared/utils/index.js +1 -1
- package/build/production/shared/utils/index.js.map +1 -1
- package/build/production/shared/utils/time.js +1 -1
- package/build/production/shared/utils/time.js.map +1 -1
- package/build/production/shared/utils/webpack.js.map +1 -1
- package/build/types-code/index.d.ts +2 -2
- package/build/types-code/server/index.d.ts +1 -1
- package/build/types-code/server/renderer.d.ts +1 -1
- package/build/types-code/server/server.d.ts +1 -1
- package/build/types-code/shared/components/Button/index.d.ts +1 -1
- package/build/types-code/shared/components/Checkbox/index.d.ts +1 -1
- package/build/types-code/shared/components/Link.d.ts +1 -1
- package/build/types-code/shared/components/NavLink.d.ts +1 -1
- package/build/types-code/shared/components/WithTooltip/Tooltip.d.ts +1 -1
- package/build/types-code/shared/components/WithTooltip/index.d.ts +4 -4
- package/build/types-code/shared/components/index.d.ts +3 -3
- package/build/types-code/shared/components/selectors/CustomDropdown/Options/index.d.ts +2 -2
- package/build/types-code/shared/utils/config.d.ts +1 -1
- package/build/types-code/shared/utils/index.d.ts +1 -1
- package/build/types-code/shared/utils/webpack.d.ts +1 -1
- package/build/web/client/index.js +1 -1
- package/build/web/client/index.js.map +1 -1
- package/build/web/index.js +2 -2
- package/build/web/index.js.map +1 -1
- package/build/web/server/index.js +1 -1
- package/build/web/server/index.js.map +1 -1
- package/build/web/server/renderer.js +5 -5
- package/build/web/server/renderer.js.map +1 -1
- package/build/web/server/server.js +2 -2
- package/build/web/server/server.js.map +1 -1
- package/build/web/shared/components/Button/index.js.map +1 -1
- package/build/web/shared/components/Checkbox/index.js.map +1 -1
- package/build/web/shared/components/Link.js.map +1 -1
- package/build/web/shared/components/Modal/index.js +1 -1
- package/build/web/shared/components/Modal/index.js.map +1 -1
- package/build/web/shared/components/NavLink.js.map +1 -1
- package/build/web/shared/components/WithTooltip/Tooltip.js.map +1 -1
- package/build/web/shared/components/WithTooltip/index.js +2 -2
- package/build/web/shared/components/WithTooltip/index.js.map +1 -1
- package/build/web/shared/components/YouTubeVideo/index.js.map +1 -1
- package/build/web/shared/components/index.js +3 -3
- package/build/web/shared/components/index.js.map +1 -1
- package/build/web/shared/components/selectors/CustomDropdown/Options/index.js.map +1 -1
- package/build/web/shared/components/selectors/NativeDropdown/index.js.map +1 -1
- package/build/web/shared/utils/config.js.map +1 -1
- package/build/web/shared/utils/index.js +1 -1
- package/build/web/shared/utils/index.js.map +1 -1
- package/build/web/shared/utils/time.js +1 -1
- package/build/web/shared/utils/time.js.map +1 -1
- package/build/web/shared/utils/webpack.js.map +1 -1
- package/config/babel/webpack.d.ts +1 -1
- package/config/babel/webpack.js +1 -1
- package/config/webpack/app-base.d.ts +1 -1
- package/config/webpack/app-development.d.ts +1 -1
- package/package.json +14 -14
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["useEffect","useRef","useState","useTheme","Tooltip","PLACEMENTS","defaultTheme","jsx","_jsx","jsxs","_jsxs","WithTooltip","children","placement","ABOVE_CURSOR","
|
|
1
|
+
{"version":3,"file":"index.js","names":["useEffect","useRef","useState","useTheme","Tooltip","PLACEMENTS","defaultTheme","jsx","_jsx","jsxs","_jsxs","WithTooltip","children","placement","ABOVE_CURSOR","theme","tip","custom","current","heap","lastCursorX","lastCursorY","timerId","undefined","triggeredByTouch","tooltipRef","wrapperRef","showTooltip","setShowTooltip","updatePortalPosition","cursorX","cursorY","wrapperRect","getBoundingClientRect","left","right","top","bottom","pointTo","window","scrollX","scrollY","setTimeout","listener","addEventListener","removeEventListener","className","wrapper","onClick","clearTimeout","onMouseLeave","onMouseMove","e","clientX","clientY","onTouchStart","ref","role"],"sources":["../../../../../src/shared/components/WithTooltip/index.tsx"],"sourcesContent":["/* global window */\n\nimport {\n type FunctionComponent,\n type ReactNode,\n useEffect,\n useRef,\n useState,\n} from 'react';\n\nimport { type Theme, useTheme } from '@dr.pogodin/react-themes';\n\nimport Tooltip, {\n PLACEMENTS,\n type ThemeKeysT as TooltipThemeKeysT,\n} from './Tooltip';\n\nimport defaultTheme from './default-theme.scss';\n\ntype PropsT = {\n children?: ReactNode;\n placement?: PLACEMENTS;\n theme?: Theme<'wrapper' | TooltipThemeKeysT>;\n tip?: ReactNode;\n};\n\ntype TooltipRefT = {\n pointTo: (\n x: number,\n y: number,\n placement: PLACEMENTS,\n wrapperRef: HTMLDivElement,\n ) => void;\n};\n\ntype HeapT = {\n lastCursorX: number;\n lastCursorY: number;\n timerId?: NodeJS.Timeout;\n triggeredByTouch: boolean;\n};\n\n/**\n * Implements a simple to use and themeable tooltip component, _e.g._\n * ```js\n * <WithTooltip tip=\"This is example tooltip.\">\n * <p>Hover to see the tooltip.</p>\n * </WithTooltip>\n * ```\n * **Children:** Children are rendered in the place of `<WithTooltip>`,\n * and when hovered the tooltip is shown. By default the wrapper itself is\n * `<div>` block with `display: inline-block`.\n * @param tip – Anything React is able to render,\n * _e.g._ a tooltip text. This will be the tooltip content.\n * @param {WithTooltipTheme} props.theme _Ad hoc_ theme.\n */\nconst WithTooltip: FunctionComponent<PropsT> = ({\n children,\n placement = PLACEMENTS.ABOVE_CURSOR,\n theme,\n tip,\n}) => {\n const custom = useTheme('WithTooltip', defaultTheme, theme);\n\n const { current: heap } = useRef<HeapT>({\n lastCursorX: 0,\n lastCursorY: 0,\n timerId: undefined,\n triggeredByTouch: false,\n });\n const tooltipRef = useRef<TooltipRefT>(null);\n const wrapperRef = useRef<HTMLDivElement>(null);\n const [showTooltip, setShowTooltip] = useState(false);\n\n const updatePortalPosition = (cursorX: number, cursorY: number) => {\n if (showTooltip) {\n const wrapperRect = wrapperRef.current!.getBoundingClientRect();\n if (\n cursorX < wrapperRect.left\n || cursorX > wrapperRect.right\n || cursorY < wrapperRect.top\n || cursorY > wrapperRect.bottom\n ) {\n setShowTooltip(false);\n } else if (tooltipRef.current) {\n tooltipRef.current.pointTo(\n cursorX + window.scrollX,\n cursorY + window.scrollY,\n placement,\n wrapperRef.current!,\n );\n }\n } else {\n heap.lastCursorX = cursorX;\n heap.lastCursorY = cursorY;\n\n // If tooltip was triggered by a touch, we delay its opening by a bit,\n // to ensure it was not a touch-click - in the case of touch click we\n // want to do the click, rather than show the tooltip, and the delay\n // gives click handler a chance to abort the tooltip openning.\n if (heap.triggeredByTouch) {\n heap.timerId ??= setTimeout(() => {\n heap.triggeredByTouch = false;\n heap.timerId = undefined;\n setShowTooltip(true);\n }, 300);\n\n // Otherwise we can just open the tooltip right away.\n } else setShowTooltip(true);\n }\n };\n\n useEffect(() => {\n if (showTooltip && tip !== null) {\n // This is necessary to ensure that even when a single mouse event\n // arrives to a tool-tipped component, the tooltip is correctly positioned\n // once opened (because similar call above does not have effect until\n // the tooltip is fully mounted, and that is delayed to future rendering\n // cycle due to the implementation).\n if (tooltipRef.current) {\n tooltipRef.current.pointTo(\n heap.lastCursorX + window.scrollX,\n heap.lastCursorY + window.scrollY,\n placement,\n wrapperRef.current!,\n );\n }\n\n const listener = () => {\n setShowTooltip(false);\n };\n window.addEventListener('scroll', listener);\n return () => {\n window.removeEventListener('scroll', listener);\n };\n }\n return undefined;\n }, [\n heap.lastCursorX,\n heap.lastCursorY,\n placement,\n showTooltip,\n tip,\n ]);\n\n return (\n <div\n className={custom.wrapper}\n onClick={() => {\n if (heap.timerId) {\n clearTimeout(heap.timerId);\n heap.timerId = undefined;\n heap.triggeredByTouch = false;\n }\n }}\n onMouseLeave={() => {\n setShowTooltip(false);\n }}\n onMouseMove={(e) => {\n updatePortalPosition(e.clientX, e.clientY);\n }}\n onTouchStart={() => {\n heap.triggeredByTouch = true;\n }}\n ref={wrapperRef}\n role=\"presentation\"\n >\n {\n showTooltip && tip !== null\n ? <Tooltip ref={tooltipRef} theme={custom}>{tip}</Tooltip>\n : null\n }\n {children}\n </div>\n );\n};\n\ntype ExportT = {\n PLACEMENTS: typeof PLACEMENTS;\n} & typeof WithTooltip;\n\nconst e: ExportT = WithTooltip as ExportT;\n\ne.PLACEMENTS = PLACEMENTS;\n\nexport default e;\n"],"mappings":"AAAA,mBAEA,OAGEA,SAAS,CACTC,MAAM,CACNC,QAAQ,KACH,OAAO,CAEd,OAAqBC,QAAQ,KAAQ,0BAA0B,OAExD,CAAAC,OAAO,EACZC,UAAU,0BAAAC,YAAA,oIAIoC,OAAAC,GAAA,IAAAC,IAAA,CAAAC,IAAA,IAAAC,KAAA,yBAyBhD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,GACA,KAAM,CAAAC,WAAsC,CAAGA,CAAC,CAC9CC,QAAQ,CACRC,SAAS,CAAGR,UAAU,CAACS,YAAY,CACnCC,KAAK,CACLC,GACF,CAAC,GAAK,CACJ,KAAM,CAAAC,MAAM,CAAGd,QAAQ,CAAC,aAAa,CAAEG,YAAY,CAAES,KAAK,CAAC,CAE3D,KAAM,CAAEG,OAAO,CAAEC,IAAK,CAAC,CAAGlB,MAAM,CAAQ,CACtCmB,WAAW,CAAE,CAAC,CACdC,WAAW,CAAE,CAAC,CACdC,OAAO,CAAEC,SAAS,CAClBC,gBAAgB,CAAE,KACpB,CAAC,CAAC,CACF,KAAM,CAAAC,UAAU,CAAGxB,MAAM,CAAc,IAAI,CAAC,CAC5C,KAAM,CAAAyB,UAAU,CAAGzB,MAAM,CAAiB,IAAI,CAA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,CAAEE,MAAO,CAAAL,QAAA,CAAEI,GAAG,CAAU,CAAC,CACxD,IAAI,CAETJ,QAAQ,EACN,CAET,CAAC,CAMD,KAAM,CAAAwC,CAAU,CAAGzC,WAAsB,CAEzCyC,CAAC,CAAC/C,UAAU,CAAGA,UAAU,CAEzB,cAAe,CAAA+C,CAAC","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["qs","useTheme","Throbber","defaultTheme","throbberTheme","jsx","_jsx","jsxs","_jsxs","YouTubeVideo","autoplay","src","theme","title","custom","srcParts","split","url","queryString","query","parse","videoId","v","match","stringify","className","container","children","allow","allowFullScreen","video"],"sources":["../../../../../src/shared/components/YouTubeVideo/index.tsx"],"sourcesContent":["import
|
|
1
|
+
{"version":3,"file":"index.js","names":["qs","useTheme","Throbber","defaultTheme","throbberTheme","jsx","_jsx","jsxs","_jsxs","YouTubeVideo","autoplay","src","theme","title","custom","srcParts","split","url","queryString","query","parse","videoId","v","match","stringify","className","container","children","allow","allowFullScreen","video"],"sources":["../../../../../src/shared/components/YouTubeVideo/index.tsx"],"sourcesContent":["import type { FunctionComponent } from 'react';\n\nimport qs from 'qs';\n\nimport { type Theme, useTheme } from '@dr.pogodin/react-themes';\n\nimport Throbber from 'components/Throbber';\n\nimport defaultTheme from './base.scss';\nimport throbberTheme from './throbber.scss';\n\ntype ThemeT = Theme<'container' | 'video'>;\n\ntype PropsT = {\n autoplay?: boolean;\n src: string;\n theme?: ThemeT;\n title?: string;\n};\n\n/**\n * A component for embeding a YouTube video.\n * @param [props] Component properties.\n * @param [props.autoplay] If `true` the video will start to play\n * automatically once loaded.\n * @param [props.src] URL of the video to play. Can be in any of\n * the following formats, and keeps any additional query parameters understood\n * by the YouTube IFrame player:\n * - `https://www.youtube.com/watch?v=NdF6Rmt6Ado`\n * - `https://youtu.be/NdF6Rmt6Ado`\n * - `https://www.youtube.com/embed/NdF6Rmt6Ado`\n * @param [props.theme] _Ad hoc_ theme.\n * @param [props.title] The `title` attribute to add to the player\n * IFrame.\n */\nconst YouTubeVideo: FunctionComponent<PropsT> = ({\n autoplay,\n src,\n theme,\n title,\n}) => {\n const custom = useTheme('YouTubeVideo', defaultTheme, theme);\n\n const srcParts = src.split('?');\n let [url] = srcParts;\n const [, queryString] = srcParts;\n const query = queryString ? qs.parse(queryString) : {};\n\n const videoId = query.v ?? url?.match(/\\/([a-zA-Z0-9-_]*)$/)?.[1];\n url = `https://www.youtube.com/embed/${videoId as string}`;\n\n delete query.v;\n query.autoplay = autoplay ? '1' : '0';\n url += `?${qs.stringify(query)}`;\n\n // TODO: https://developers.google.com/youtube/player_parameters\n // More query parameters can be exposed via the component props.\n\n return (\n <div className={custom.container}>\n <Throbber theme={throbberTheme} />\n {/* TODO: I guess, we better add the sanbox, but right now I don't have\n time to carefully explore which restrictions should be lifted to allow\n embed YouTube player to work... sometime later we'll take care of it */\n }\n <iframe // eslint-disable-line react/iframe-missing-sandbox\n allow=\"autoplay\"\n allowFullScreen\n className={custom.video}\n src={url}\n title={title}\n />\n </div>\n );\n};\n\nexport default YouTubeVideo;\n"],"mappings":"AAEA,MAAO,CAAAA,EAAE,KAAM,IAAI,CAEnB,OAAqBC,QAAQ,KAAQ,0BAA0B,OAExD,CAAAC,QAAQ,kCAAAC,YAAA,+FAAAC,aAAA,yEAG6B,OAAAC,GAAA,IAAAC,IAAA,CAAAC,IAAA,IAAAC,KAAA,yBAW5C;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,GACA,KAAM,CAAAC,YAAuC,CAAGA,CAAC,CAC/CC,QAAQ,CACRC,GAAG,CACHC,KAAK,CACLC,KACF,CAAC,GAAK,CACJ,KAAM,CAAAC,MAAM,CAAGb,QAAQ,CAAC,cAAc,CAAEE,YAAY,CAAES,KAAK,CAAC,CAE5D,KAAM,CAAAG,QAAQ,CAAGJ,GAAG,CAACK,KAAK,CAAC,GAAG,CAAC,CAC/B,GAAI,CAACC,GAAG,CAAC,CAAGF,QAAQ,CACpB,KAAM,EAAGG,WAAW,CAAC,CAAGH,QAAQ,CAChC,KAAM,CAAAI,KAAK,CAAGD,WAAW,CAAGlB,EAAE,CAACoB,KAAK,CAACF,WAAW,CAAC,CAAG,CAAC,CAAC,CAEtD,KAAM,CAAAG,OAAO,CAAGF,KAAK,CAACG,CAAC,EAAIL,GAAG,EAAEM,KAAK,CAAC,qBAAqB,CAAC,GAAG,CAAC,CAAC,CACjEN,GAAG,CAAG,iCAAiCI,OAAO,EAAY,CAE1D,MAAO,CAAAF,KAAK,CAACG,CAAC,CACdH,KAAK,CAACT,QAAQ,CAAGA,QAAQ,CAAG,GAAG,CAAG,GAAG,CACrCO,GAAG,EAAI,IAAIjB,EAAE,CAACwB,SAAS,CAACL,KAAK,CAAC,EAAE,CAEhC;AACA;AAEA,mBACEX,KAAA,QAAKiB,SAAS,CAAEX,MAAM,CAACY,SAAU,CAAAC,QAAA,eAC/BrB,IAAA,CAACJ,QAAQ,EAACU,KAAK,CAAER,aAAc,CAAE,CAAC,cAKlCE,IAAA,WAAQ;AACNsB,KAAK,CAAC,UAAU,CAChBC,eAAe,MACfJ,SAAS,CAAEX,MAAM,CAACgB,KAAM,CACxBnB,GAAG,CAAEM,GAAI,CACTJ,KAAK,CAAEA,KAAM,CACd,CAAC,EACC,CAET,CAAC,CAED,cAAe,CAAAJ,YAAY","ignoreList":[]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Just an aggregation of all exported components into a single module.
|
|
3
|
-
*/export{MetaTags}from"@dr.pogodin/react-helmet";export*from"./selectors/index.js";export{default as Button
|
|
3
|
+
*/export{MetaTags}from"@dr.pogodin/react-helmet";export*from"./selectors/index.js";export{BaseButton,default as Button}from"./Button/index.js";export{default as Checkbox}from"./Checkbox/index.js";export{default as Input}from"./Input/index.js";export{default as Link}from"./Link.js";export{BaseModal,default as Modal}from"./Modal/index.js";export{default as NavLink}from"./NavLink.js";export{default as PageLayout}from"./PageLayout/index.js";export{default as Throbber}from"./Throbber/index.js";export{default as WithTooltip}from"./WithTooltip/index.js";export{default as YouTubeVideo}from"./YouTubeVideo/index.js";export{default as TextArea}from"./TextArea/index.js";
|
|
4
4
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["MetaTags","
|
|
1
|
+
{"version":3,"file":"index.js","names":["MetaTags","BaseButton","default","Button","Checkbox","Input","Link","BaseModal","Modal","NavLink","PageLayout","Throbber","WithTooltip","YouTubeVideo","TextArea"],"sources":["../../../../src/shared/components/index.ts"],"sourcesContent":["/**\n * Just an aggregation of all exported components into a single module.\n */\n\nexport { MetaTags } from '@dr.pogodin/react-helmet';\n\nexport * from 'components/selectors';\n\nexport { BaseButton, default as Button } from 'components/Button';\nexport { default as Checkbox } from 'components/Checkbox';\nexport { default as Input } from 'components/Input';\nexport { default as Link } from 'components/Link';\nexport { BaseModal, default as Modal } from 'components/Modal';\nexport { default as NavLink } from 'components/NavLink';\nexport { default as PageLayout } from 'components/PageLayout';\nexport { default as Throbber } from 'components/Throbber';\nexport { default as WithTooltip } from 'components/WithTooltip';\nexport { default as YouTubeVideo } from 'components/YouTubeVideo';\n\nexport { default as TextArea } from './TextArea';\n"],"mappings":"AAAA;AACA;AACA,GAEA,OAASA,QAAQ,KAAQ,0BAA0B,0CAI1CC,UAAU,CAAEC,OAAO,GAAI,CAAAC,MAAM,gCAC7BD,OAAO,GAAI,CAAAE,QAAQ,kCACnBF,OAAO,GAAI,CAAAG,KAAK,+BAChBH,OAAO,GAAI,CAAAI,IAAI,wBACfC,SAAS,CAAEL,OAAO,GAAI,CAAAM,KAAK,+BAC3BN,OAAO,GAAI,CAAAO,OAAO,2BAClBP,OAAO,GAAI,CAAAQ,UAAU,oCACrBR,OAAO,GAAI,CAAAS,QAAQ,kCACnBT,OAAO,GAAI,CAAAU,WAAW,qCACtBV,OAAO,GAAI,CAAAW,YAAY,sCAEvBX,OAAO,GAAI,CAAAY,QAAQ","ignoreList":[]}
|
|
@@ -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
|
|
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":"wLAAA,OAIEA,mBAAmB,CACnBC,MAAM,KACD,OAAO,QAELC,SAAS,sCAMhBC,eAAe,6BAAAC,CAAA,sBAGY,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,KACrE,CAiBA,KAAM,CAAAC,OAAkC,CAAGA,CAAC,CAC1CC,cAAc,CACdC,cAAc,CACdC,MAAM,CACNC,QAAQ,CACRC,QAAQ,CACRC,WAAW,CACXC,OAAO,CACPC,GACF,CAAC,GAAK,CACJ,KAAM,CAAAC,MAAM,CAAGrB,MAAM,CAAiB,IAAI,CAAC,CAE3CD,mBAAmB,CAACqB,GAAG,CAAE,KAAO,CAC9BE,OAAO,CAAEA,CAAA,GAAM,CACb,KAAM,CAAAC,CAAC,CAAGF,MAAM,CAACG,OAAO,EAAEC,aAAa,CACvC,GAAI,CAACF,CAAC,CAAE,MAAO,CAAAG,SAAS,CAExB,KAAM,CAAAC,IAAI,CAAGN,MAAM,CAACG,OAAO,CAAEI,qBAAqB,CAAC,CAAC,CACpD,KAAM,CAAAC,KAAK,CAAGC,MAAM,CAACC,gBAAgB,CAACR,CAAC,CAAC,CACxC,KAAM,CAAAS,OAA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,CAAAR,QAAA,cAEF7C,IAAA,QAAKe,GAAG,CAAEC,MAAO,CAAA6B,QAAA,CAAEZ,WAAW,CAAM,CAAC,CAC5B,CAEf,CAAC,CAED,cAAe,CAAA1B,OAAO","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["useTheme","optionValueName","defaultTheme","jsx","_jsx","jsxs","_jsxs","Dropdown","filter","label","onChange","options","testId","theme","value","isValidValue","optionElements","composed","option","iValue","iName","push","className","children","hiddenOption","disabled","selectClassName","select","invalid","container","undefined","dropdown","process","env","NODE_ENV","arrow"],"sources":["../../../../../../src/shared/components/selectors/NativeDropdown/index.tsx"],"sourcesContent":["// Implements dropdown based on the native HTML <select> element.\n\nimport type { FunctionComponent } from 'react';\n\nimport { useTheme } from '@dr.pogodin/react-themes';\n\nimport {
|
|
1
|
+
{"version":3,"file":"index.js","names":["useTheme","optionValueName","defaultTheme","jsx","_jsx","jsxs","_jsxs","Dropdown","filter","label","onChange","options","testId","theme","value","isValidValue","optionElements","composed","option","iValue","iName","push","className","children","hiddenOption","disabled","selectClassName","select","invalid","container","undefined","dropdown","process","env","NODE_ENV","arrow"],"sources":["../../../../../../src/shared/components/selectors/NativeDropdown/index.tsx"],"sourcesContent":["// Implements dropdown based on the native HTML <select> element.\n\nimport type { FunctionComponent } from 'react';\n\nimport { useTheme } from '@dr.pogodin/react-themes';\n\nimport { type PropsT, optionValueName } from '../common';\n\nimport defaultTheme from './theme.scss';\n\n/**\n * Implements a themeable dropdown list. Internally it is rendered with help of\n * the standard HTML `<select>` element, thus the styling support is somewhat\n * limited.\n * @param [props] Component properties.\n * @param [props.filter] Options filter function. If provided, only\n * those elements of `options` list will be used by the dropdown, for which this\n * filter returns `true`.\n * @param [props.label] Dropdown label.\n * @param [props.onChange] Selection event handler.\n * @param [props.options=[]] Array of dropdown\n * options. For string elements the option value and name will be the same.\n * It is allowed to mix DropdownOption and string elements in the same option\n * list.\n * @param [props.theme] _Ad hoc_ theme.\n * @param [props.value] Currently selected value.\n * @param [props....]\n * [Other theming properties](https://www.npmjs.com/package/@dr.pogodin/react-themes#themed-component-properties)\n */\nconst Dropdown: FunctionComponent<PropsT<string>> = ({\n filter,\n label,\n onChange,\n options,\n testId,\n theme,\n value,\n}) => {\n let isValidValue = false;\n const optionElements = [];\n\n const composed = useTheme('Dropdown', defaultTheme, theme);\n\n for (const option of options) {\n if (!filter || filter(option)) {\n const [iValue, iName] = optionValueName(option);\n isValidValue ||= iValue === value;\n optionElements.push(\n <option className={composed.option} key={iValue} value={iValue}>\n {iName}\n </option>,\n );\n }\n }\n\n // NOTE: This element represents the current `value` when it does not match\n // any valid option. In Chrome, and some other browsers, we are able to hide\n // it from the opened dropdown; in others, e.g. Safari, the best we can do is\n // to show it as disabled.\n const hiddenOption = isValidValue ? null : (\n <option\n className={composed.hiddenOption}\n disabled\n key=\"__reactUtilsHiddenOption\"\n value={value}\n >\n {value}\n </option>\n );\n\n let selectClassName = composed.select;\n if (!isValidValue) selectClassName += ` ${composed.invalid}`;\n\n return (\n <div className={composed.container}>\n { label === undefined\n ? null : <div className={composed.label}>{label}</div> }\n <div className={composed.dropdown}>\n <select\n className={selectClassName}\n data-testid={process.env.NODE_ENV === 'production' ? undefined : testId}\n onChange={onChange}\n value={value}\n >\n {hiddenOption}\n {optionElements}\n </select>\n <div className={composed.arrow} />\n </div>\n </div>\n );\n};\n\nexport default Dropdown;\n"],"mappings":"wLAAA;AAIA,OAASA,QAAQ,KAAQ,0BAA0B,QAE7BC,eAAe,0BAAAC,YAAA,gOAIrC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,GAlBA,OAAAC,GAAA,IAAAC,IAAA,CAAAC,IAAA,IAAAC,KAAA,yBAmBA,KAAM,CAAAC,QAA2C,CAAGA,CAAC,CACnDC,MAAM,CACNC,KAAK,CACLC,QAAQ,CACRC,OAAO,CACPC,MAAM,CACN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,SAAS,CAAEI,eAAgB,CAC3B,cAAaM,OAAO,CAACC,GAAG,CAACC,QAAQ,GAAK,YAAY,CAAGJ,SAAS,CAAGlB,MAAO,CACxEF,QAAQ,CAAEA,QAAS,CACnBI,KAAK,CAAEA,KAAM,CAAAS,QAAA,EAEZC,YAAY,CACZR,cAAc,EACT,CAAC,cACTZ,IAAA,QAAKkB,SAAS,CAAEL,QAAQ,CAACkB,KAAM,CAAE,CAAC,EAC/B,CAAC,EACH,CAET,CAAC,CAED,cAAe,CAAA5B,QAAQ","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.js","names":["parse","clientGetInj","IS_CLIENT_SIDE","requireWeak","config","injectCsrfToken","cfg","document","CSRF","cookie","csrfToken","getConfig","sync","inj","Promise","then","injection","res","CONFIG","weak","Error"],"sources":["../../../../src/shared/utils/config.ts"],"sourcesContent":["/* global document */\n\nimport { parse } from 'cookie';\n\nimport clientGetInj from '../../client/getInj';\n\nimport { IS_CLIENT_SIDE } from './isomorphy/environment-check';\nimport { requireWeak } from './webpack';\n\ntype ConfigT = Record<string, unknown>;\n\nlet config: ConfigT | Promise<ConfigT> | undefined;\n\n/**\n * Injects CSRF token into config (on client-side only).\n *\n * BEWARE: It mutates the argument, and also returns it as the result,\n * for chaining.\n */\nfunction injectCsrfToken(cfg: ConfigT): ConfigT {\n // The safeguard for \"document\" is necessary because in non-Node environments,\n // like React Native, IS_CLIENT_SIDE is \"true\", however \"document\" and a bunch\n // of other browser-world features are not available.\n if (IS_CLIENT_SIDE && typeof document !== 'undefined') {\n // eslint-disable-next-line no-param-reassign\n cfg.CSRF = parse(document.cookie).csrfToken;\n }\n\n return cfg;\n}\n\nexport function getConfig<T extends ConfigT>(sync: true): T;\n\nexport function getConfig<T extends ConfigT>(sync?: boolean): T |
|
|
1
|
+
{"version":3,"file":"config.js","names":["parse","clientGetInj","IS_CLIENT_SIDE","requireWeak","config","injectCsrfToken","cfg","document","CSRF","cookie","csrfToken","getConfig","sync","inj","Promise","then","injection","res","CONFIG","weak","Error"],"sources":["../../../../src/shared/utils/config.ts"],"sourcesContent":["/* global document */\n\nimport { parse } from 'cookie';\n\nimport clientGetInj from '../../client/getInj';\n\nimport { IS_CLIENT_SIDE } from './isomorphy/environment-check';\nimport { requireWeak } from './webpack';\n\ntype ConfigT = Record<string, unknown>;\n\nlet config: ConfigT | Promise<ConfigT> | undefined;\n\n/**\n * Injects CSRF token into config (on client-side only).\n *\n * BEWARE: It mutates the argument, and also returns it as the result,\n * for chaining.\n */\nfunction injectCsrfToken(cfg: ConfigT): ConfigT {\n // The safeguard for \"document\" is necessary because in non-Node environments,\n // like React Native, IS_CLIENT_SIDE is \"true\", however \"document\" and a bunch\n // of other browser-world features are not available.\n if (IS_CLIENT_SIDE && typeof document !== 'undefined') {\n // eslint-disable-next-line no-param-reassign\n cfg.CSRF = parse(document.cookie).csrfToken;\n }\n\n return cfg;\n}\n\nexport function getConfig<T extends ConfigT>(sync: true): T;\n\nexport function getConfig<T extends ConfigT>(sync?: boolean): Promise<T> | T;\n\nexport function getConfig<T extends ConfigT>(sync?: boolean): Promise<T> | T {\n if (!config) {\n if (IS_CLIENT_SIDE) {\n const inj = clientGetInj();\n config = inj instanceof Promise\n ? inj.then((injection) => {\n const res = injectCsrfToken(injection.CONFIG ?? {});\n config = res;\n return res;\n })\n : injectCsrfToken(inj.CONFIG ?? {});\n } else {\n const weak = requireWeak<ConfigT>('config');\n if (!weak) throw Error('Internal error');\n config = weak;\n }\n }\n\n if (sync && (config instanceof Promise)) {\n throw Error('The config is not available yet');\n }\n\n return config as T;\n}\n"],"mappings":"AAAA,qBAEA,OAASA,KAAK,KAAQ,QAAQ,OAEvB,CAAAC,YAAY,qCAEVC,cAAc,+CACdC,WAAW,oBAIpB,GAAI,CAAAC,MAA8C,CAElD;AACA;AACA;AACA;AACA;AACA,GACA,QAAS,CAAAC,eAAeA,CAACC,GAAY,CAAW,CAC9C;AACA;AACA;AACA,GAAIJ,cAAc,EAAI,MAAO,CAAAK,QAAQ,GAAK,WAAW,CAAE,CACrD;AACAD,GAAG,CAACE,IAAI,CAAGR,KAAK,CAACO,QAAQ,CAACE,MAAM,CAAC,CAACC,SACpC,CAEA,MAAO,CAAAJ,GACT,CAMA,MAAO,SAAS,CAAAK,SAASA,CAAoBC,IAAc,CAAkB,CAC3E,GAAI,CAACR,MAAM,CAAE,CACX,GAAIF,cAAc,CAAE,CAClB,KAAM,CAAAW,GAAG,CAAGZ,YAAY,CAAC,CAAC,CAC1BG,MAAM,CAAGS,GAAG,WAAY,CAAAC,OAAO,CAC3BD,GAAG,CAACE,IAAI,CAAEC,SAAS,EAAK,CACxB,KAAM,CAAAC,GAAG,CAAGZ,eAAe,CAACW,SAAS,CAACE,MAAM,EAAI,CAAC,CAAC,CAAC,CACnDd,MAAM,CAAGa,GAAG,CACZ,MAAO,CAAAA,GACT,CAAC,CAAC,CACAZ,eAAe,CAACQ,GAAG,CAACK,MAAM,EAAI,CAAC,CAAC,CACtC,CAAC,IAAM,CACL,KAAM,CAAAC,IAAI,CAAGhB,WAAW,CAAU,QAAQ,CAAC,CAC3C,GAAI,CAACgB,IAAI,CAAE,KAAM,CAAAC,KAAK,CAAC,gBAAgB,CAAC,CACxChB,MAAM,CAAGe,IACX,CACF,CAEA,GAAIP,IAAI,EAAKR,MAAM,WAAY,CAAAU,OAAQ,CAAE,CACvC,KAAM,CAAAM,KAAK,CAAC,iCAAiC,CAC/C,CAEA,MAAO,CAAAhB,MACT","ignoreList":[]}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{getConfig}from"./config.js";import*as isomorphy from"./isomorphy/index.js";import time from"./time.js";import*as webpack from"./webpack.js";export{
|
|
1
|
+
import{getConfig}from"./config.js";import*as isomorphy from"./isomorphy/index.js";import time from"./time.js";import*as webpack from"./webpack.js";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.js";export{default as splitComponent}from"./splitComponent.js";export{getConfig,isomorphy,time,webpack};
|
|
2
2
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["getConfig","isomorphy","time","webpack","
|
|
1
|
+
{"version":3,"file":"index.js","names":["getConfig","isomorphy","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 * as isomorphy from './isomorphy';\nimport time from './time';\nimport * as webpack from './webpack';\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 {\n getConfig,\n isomorphy,\n time,\n webpack,\n};\n"],"mappings":"OAASA,SAAS,yBACX,GAAK,CAAAC,SAAS,kCACd,CAAAC,IAAI,uBACJ,GAAK,CAAAC,OAAO,oBAEnB,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,QAExBC,aAAa,+BACbC,OAAO,GAAI,CAAAC,cAAc,2BAElC,OACElB,SAAS,CACTC,SAAS,CACTC,IAAI,CACJC,OAAO","ignoreList":[]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{serialize}from"cookie";import
|
|
1
|
+
import{serialize}from"cookie";import dayjs from"dayjs";import{useEffect}from"react";import{DAY_MS,HOUR_MS,MIN_MS,SEC_MS,YEAR_MS,timer}from"@dr.pogodin/js-utils";import{useGlobalState}from"@dr.pogodin/react-global-state";import{getSsrContext}from"./globalState.js";/**
|
|
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
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"time.js","names":["serialize","
|
|
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,O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,CACf,IAAM,CACJ,KAAM,CAAAkB,KAAK,CAAGJ,UAAU,EACnBC,UAAU,EAAEI,GAAG,CAACC,OAAO,CAACN,UAAU,CAAW,CAClD,MAAO,CAAAI,KAAK,CAAGG,QAAQ,CAACH,KAAK,CAAC,CAAG,CACnC,CACF,CAAC,CACD7B,SAAS,CAAC,IAAM,CACd,KAAM,CAAAiC,IAAI,CAAG,GAAI,CAAAlB,IAAM,CACvB,KAAM,CAAAc,KAAK,CAAGI,IAAI,CAACC,iBAAiB,CAAC,CAAC,CACtCN,SAAS,CAACC,KAAK,CAAC,CAChB,GAAIJ,UAAU,CAAE,CACdU,QAAQ,CAACC,MAAM,CAAGtC,SAAS,CAAC2B,UAAU,CAAEI,KAAK,CAACQ,QAAQ,CAAC,CAAC,CAAE,CAAEC,IAAI,CAAE,GAAI,CAAC,CACzE,CACF,CAAC,CAAE,CAACb,UAAU,CAAEG,SAAS,CAAC,CAAC,CAC3B,MAAO,CAAAD,MACT,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 +1 @@
|
|
|
1
|
-
{"version":3,"file":"webpack.js","names":["createRequire","IS_CLIENT_SIDE","IS_SERVER_SIDE","require","import","meta","url","requireWeak","modulePath","basePathOrOptions","basePath","ops","resolve","path","module","default","def","named","res","Object","entries","forEach","name","value","assigned","undefined","Error","resolveWeak"],"sources":["../../../../src/shared/utils/webpack.ts"],"sourcesContent":["import type PathNS from 'node:path';\n\n// eslint-disable-next-line import/enforce-node-protocol-usage\nimport { createRequire } from 'module';\n\nimport { IS_CLIENT_SIDE, IS_SERVER_SIDE } from './isomorphy';\n\ntype RequireWeakOptionsT = {\n basePath?: string;\n};\n\ntype RequireWeakResT<T> = T extends { default: infer D }\n ? (D extends null | undefined ? T : D & Omit<T, 'default'>)\n : T;\n\nlet require: ((url: string) => unknown) | undefined;\n\nif (IS_SERVER_SIDE) require = createRequire(import.meta.url);\n\n/**\n * Requires the specified module without including it into the bundle during\n * Webpack build.\n * @param modulePath\n * @param [basePath]\n * @return Required module.\n */\nexport function requireWeak<T extends object>(\n modulePath: string,\n\n // TODO: For now `basePath` can be provided directly as a string here,\n // for backward compatibility. Deprecate it in future, if any other\n // breaking changes are done for requireWeak().\n basePathOrOptions?:
|
|
1
|
+
{"version":3,"file":"webpack.js","names":["createRequire","IS_CLIENT_SIDE","IS_SERVER_SIDE","require","import","meta","url","requireWeak","modulePath","basePathOrOptions","basePath","ops","resolve","path","module","default","def","named","res","Object","entries","forEach","name","value","assigned","undefined","Error","resolveWeak"],"sources":["../../../../src/shared/utils/webpack.ts"],"sourcesContent":["import type PathNS from 'node:path';\n\n// eslint-disable-next-line import/enforce-node-protocol-usage\nimport { createRequire } from 'module';\n\nimport { IS_CLIENT_SIDE, IS_SERVER_SIDE } from './isomorphy';\n\ntype RequireWeakOptionsT = {\n basePath?: string;\n};\n\ntype RequireWeakResT<T> = T extends { default: infer D }\n ? (D extends null | undefined ? T : D & Omit<T, 'default'>)\n : T;\n\nlet require: ((url: string) => unknown) | undefined;\n\nif (IS_SERVER_SIDE) require = createRequire(import.meta.url);\n\n/**\n * Requires the specified module without including it into the bundle during\n * Webpack build.\n * @param modulePath\n * @param [basePath]\n * @return Required module.\n */\nexport function requireWeak<T extends object>(\n modulePath: string,\n\n // TODO: For now `basePath` can be provided directly as a string here,\n // for backward compatibility. Deprecate it in future, if any other\n // breaking changes are done for requireWeak().\n basePathOrOptions?: RequireWeakOptionsT | string,\n): RequireWeakResT<T> | null {\n if (IS_CLIENT_SIDE) return null;\n\n let basePath: string | undefined;\n let ops: RequireWeakOptionsT;\n if (typeof basePathOrOptions === 'string') {\n basePath = basePathOrOptions;\n } else {\n ops = basePathOrOptions ?? {};\n ({ basePath } = ops);\n }\n\n // eslint-disable-next-line @typescript-eslint/unbound-method\n const { resolve } = require!('node:path') as typeof PathNS;\n\n const path = basePath ? resolve(basePath, modulePath) : modulePath;\n\n const module = require!(path) as T;\n\n if (!('default' in module) || !module.default) return module as RequireWeakResT<T>;\n\n const { default: def, ...named } = module;\n\n const res = def as RequireWeakResT<T>;\n\n Object.entries(named).forEach(([name, value]) => {\n const assigned = res[name as keyof RequireWeakResT<T>];\n if (assigned === undefined) {\n (res[name as keyof RequireWeakResT<T>] as unknown) = value;\n } else if (assigned !== value) {\n throw Error('Conflict between default and named exports');\n }\n });\n return res;\n}\n\n/**\n * Resolves specified module path with help of Babel's module resolver.\n * Yes, the function itself just returns its argument to the caller, but Babel\n * is configured to resolve the first argument of resolveWeak(..) function, thus\n * the result will be the resolved path.\n * @param {string} modulePath\n * @return {string} Absolute or relative path to the module.\n */\nexport function resolveWeak(modulePath: string): string {\n return modulePath;\n}\n"],"mappings":"mJAEA;AACA,OAASA,aAAa,KAAQ,QAAQ,QAE7BC,cAAc,CAAEC,cAAc,4BAUvC,GAAI,CAAAC,OAA+C,CAEnD,GAAID,cAAc,CAAEC,OAAO,CAAGH,aAAa,CAACI,MAAM,CAACC,IAAI,CAACC,GAAG,CAAC,CAE5D;AACA;AACA;AACA;AACA;AACA;AACA,GACA,MAAO,SAAS,CAAAC,WAAWA,CACzBC,UAAkB,CAElB;AACA;AACA;AACAC,iBAAgD,CACrB,CAC3B,GAAIR,cAAc,CAAE,MAAO,KAAI,CAE/B,GAAI,CAAAS,QAA4B,CAChC,GAAI,CAAAC,GAAwB,CAC5B,GAAI,MAAO,CAAAF,iBAAiB,GAAK,QAAQ,CAAE,CACzCC,QAAQ,CAAGD,iBACb,CAAC,IAAM,CACLE,GAAG,CAAGF,iBAAiB,EAAI,CAAC,CAAC,CAC7B,CAAC,CAAEC,QAAS,CAAC,CAAGC,GAAG,CACrB,CAEA;AACA,KAAM,CAAEC,OAAQ,CAAC,CAAGT,OAAO,CAAE,WAAW,CAAkB,CAE1D,KAAM,CAAAU,IAAI,CAAGH,QAAQ,CAAGE,OAAO,CAACF,QAAQ,CAAEF,UAAU,CAAC,CAAGA,UAAU,CAElE,KAAM,CAAAM,MAAM,CAAGX,OAAO,CAAEU,IAAI,CAAM,CAElC,GAAI,EAAE,SAAS,EAAI,CAAAC,MAAM,CAAC,EAAI,CAACA,MAAM,CAACC,OAAO,CAAE,MAAO,CAAAD,MAAM,CAE5D,KAAM,CAAEC,OAAO,CAAEC,GAAG,CAAE,GAAGC,KAAM,CAAC,CAAGH,MAAM,CAEzC,KAAM,CAAAI,GAAG,CAAGF,GAAyB,CAErCG,MAAM,CAACC,OAAO,CAACH,KAAK,CAAC,CAACI,OAAO,CAAC,CAAC,CAACC,IAAI,CAAEC,KAAK,CAAC,GAAK,CAC/C,KAAM,CAAAC,QAAQ,CAAGN,GAAG,CAACI,IAAI,CAA6B,CACtD,GAAIE,QAAQ,GAAKC,SAAS,CAAE,CACzBP,GAAG,CAACI,IAAI,CAA6B,CAAeC,KACvD,CAAC,IAAM,IAAIC,QAAQ,GAAKD,KAAK,CAAE,CAC7B,KAAM,CAAAG,KAAK,CAAC,4CAA4C,CAC1D,CACF,CAAC,CAAC,CACF,MAAO,CAAAR,GACT,CAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,GACA,MAAO,SAAS,CAAAS,WAAWA,CAACnB,UAAkB,CAAU,CACtD,MAAO,CAAAA,UACT","ignoreList":[]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { type
|
|
1
|
+
export { type AsyncCollectionLoaderT, type AsyncCollectionT, type AsyncDataEnvelopeT, type AsyncDataLoaderT, type ForceT, GlobalStateProvider, type UseAsyncDataOptionsT, type UseAsyncDataResT, type UseGlobalStateResT, type ValueOrInitializerT, getGlobalState, newAsyncDataEnvelope, useAsyncCollection, useAsyncData, useGlobalState, withGlobalStateType, } from '@dr.pogodin/react-global-state';
|
|
2
2
|
export * from './shared/components';
|
|
3
3
|
export { type BeforeRenderResT, type BeforeRenderT, type ConfigT, type ServerSsrContext, type ServerT, } from './server';
|
|
4
|
-
export {
|
|
4
|
+
export { Barrier, Cached, Emitter, type Listener, type ObjectKey, Semaphore, THEME_COMPOSE, THEME_PRIORITY, type Theme, ThemeProvider, assertEmptyObject, getConfig, getSsrContext, isomorphy, splitComponent, time, useTheme, webpack, withRetries, } from './shared/utils';
|
|
@@ -6,7 +6,7 @@ import { type OptionsT as ServerOptionsT, type ServerT, getDefaultCspSettings }
|
|
|
6
6
|
import { SCRIPT_LOCATIONS } from './renderer';
|
|
7
7
|
export * from './utils';
|
|
8
8
|
export type { BeforeRenderResT, BeforeRenderT, ConfigT, ServerSsrContext, } from './renderer';
|
|
9
|
-
export {
|
|
9
|
+
export { SCRIPT_LOCATIONS, type ServerT, getDefaultCspSettings, };
|
|
10
10
|
type OptionsT = ServerOptionsT & {
|
|
11
11
|
https?: {
|
|
12
12
|
cert: string;
|
|
@@ -75,9 +75,9 @@ export type OptionsT = {
|
|
|
75
75
|
logger?: LoggerI;
|
|
76
76
|
maxSsrRounds?: number;
|
|
77
77
|
noCsp?: boolean;
|
|
78
|
-
staticCacheSize?: number;
|
|
79
78
|
ssrTimeout?: number;
|
|
80
79
|
staticCacheController?: (req: Request) => CacheRefT | null | undefined;
|
|
80
|
+
staticCacheSize?: number;
|
|
81
81
|
};
|
|
82
82
|
/**
|
|
83
83
|
* Creates the middleware.
|
|
@@ -28,7 +28,7 @@ export type ServerT = Express & {
|
|
|
28
28
|
logger: LoggerI;
|
|
29
29
|
};
|
|
30
30
|
export type OptionsT = RendererOptionsT & {
|
|
31
|
-
beforeExpressJsError?: (server: ServerT) => boolean |
|
|
31
|
+
beforeExpressJsError?: (server: ServerT) => Promise<boolean> | boolean;
|
|
32
32
|
beforeExpressJsSetup?: (server: ServerT) => Promise<void> | void;
|
|
33
33
|
cookieSignatureSecret?: string;
|
|
34
34
|
cspSettingsHook?: (defaultOptions: CspOptionsT, req: Request) => CspOptionsT;
|
|
@@ -7,7 +7,7 @@ type PropsT = {
|
|
|
7
7
|
disabled?: boolean;
|
|
8
8
|
enforceA?: boolean;
|
|
9
9
|
keepScrollPosition?: boolean;
|
|
10
|
-
onClick?:
|
|
10
|
+
onClick?: KeyboardEventHandler & MouseEventHandler;
|
|
11
11
|
onKeyDown?: KeyboardEventHandler;
|
|
12
12
|
onKeyUp?: KeyboardEventHandler;
|
|
13
13
|
onMouseDown?: MouseEventHandler;
|
|
@@ -8,5 +8,5 @@ type PropT<ValueT> = {
|
|
|
8
8
|
testId?: string;
|
|
9
9
|
theme?: Theme<'checkbox' | 'container' | 'disabled' | 'indeterminate' | 'label'>;
|
|
10
10
|
};
|
|
11
|
-
declare const Checkbox: <ValueT extends
|
|
11
|
+
declare const Checkbox: <ValueT extends "indeterminate" | boolean = boolean>({ checked, disabled, label, onChange, testId, theme, }: PropT<ValueT>) => ReactNode;
|
|
12
12
|
export default Checkbox;
|
|
@@ -7,6 +7,6 @@
|
|
|
7
7
|
*/
|
|
8
8
|
import { type LinkProps } from 'react-router';
|
|
9
9
|
import { type PropsT as GenericLinkPropsT } from './GenericLink';
|
|
10
|
-
type PropsT = Omit<GenericLinkPropsT, 'routerLinkType'
|
|
10
|
+
type PropsT = LinkProps & Omit<GenericLinkPropsT, 'routerLinkType'>;
|
|
11
11
|
declare const Link: React.FunctionComponent<PropsT>;
|
|
12
12
|
export default Link;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type NavLinkProps } from 'react-router';
|
|
2
2
|
import { type PropsT as GenericLinkPropsT } from './GenericLink';
|
|
3
|
-
type PropsT = Omit<GenericLinkPropsT, 'routerLinkType'
|
|
3
|
+
type PropsT = NavLinkProps & Omit<GenericLinkPropsT, 'routerLinkType'>;
|
|
4
4
|
declare const NavLink: React.FunctionComponent<PropsT>;
|
|
5
5
|
export default NavLink;
|
|
@@ -15,7 +15,7 @@ export declare enum PLACEMENTS {
|
|
|
15
15
|
BELOW_CURSOR = "BELOW_CURSOR",
|
|
16
16
|
BELOW_ELEMENT = "BELOW_ELEMENT"
|
|
17
17
|
}
|
|
18
|
-
export type ThemeKeysT = 'appearance' | 'arrow' | '
|
|
18
|
+
export type ThemeKeysT = 'appearance' | 'arrow' | 'container' | 'content';
|
|
19
19
|
type TooltipThemeT = Theme<ThemeKeysT>;
|
|
20
20
|
declare const Tooltip: FunctionComponent<{
|
|
21
21
|
children?: ReactNode;
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { type FunctionComponent, type ReactNode } from 'react';
|
|
2
2
|
import { type Theme } from '@dr.pogodin/react-themes';
|
|
3
|
-
import { type ThemeKeysT as TooltipThemeKeysT
|
|
3
|
+
import { PLACEMENTS, type ThemeKeysT as TooltipThemeKeysT } from './Tooltip';
|
|
4
4
|
type PropsT = {
|
|
5
5
|
children?: ReactNode;
|
|
6
6
|
placement?: PLACEMENTS;
|
|
7
|
-
tip?: ReactNode;
|
|
8
7
|
theme?: Theme<'wrapper' | TooltipThemeKeysT>;
|
|
8
|
+
tip?: ReactNode;
|
|
9
9
|
};
|
|
10
10
|
/**
|
|
11
11
|
* Implements a simple to use and themeable tooltip component, _e.g._
|
|
@@ -22,8 +22,8 @@ type PropsT = {
|
|
|
22
22
|
* @param {WithTooltipTheme} props.theme _Ad hoc_ theme.
|
|
23
23
|
*/
|
|
24
24
|
declare const WithTooltip: FunctionComponent<PropsT>;
|
|
25
|
-
type ExportT =
|
|
25
|
+
type ExportT = {
|
|
26
26
|
PLACEMENTS: typeof PLACEMENTS;
|
|
27
|
-
};
|
|
27
|
+
} & typeof WithTooltip;
|
|
28
28
|
declare const e: ExportT;
|
|
29
29
|
export default e;
|
|
@@ -3,13 +3,13 @@
|
|
|
3
3
|
*/
|
|
4
4
|
export { MetaTags } from '@dr.pogodin/react-helmet';
|
|
5
5
|
export * from './selectors';
|
|
6
|
-
export { default as Button
|
|
6
|
+
export { BaseButton, default as Button } from './Button';
|
|
7
7
|
export { default as Checkbox } from './Checkbox';
|
|
8
8
|
export { default as Input } from './Input';
|
|
9
9
|
export { default as Link } from './Link';
|
|
10
|
-
export { default as
|
|
11
|
-
export { default as Modal, BaseModal } from './Modal';
|
|
10
|
+
export { BaseModal, default as Modal } from './Modal';
|
|
12
11
|
export { default as NavLink } from './NavLink';
|
|
12
|
+
export { default as PageLayout } from './PageLayout';
|
|
13
13
|
export { default as Throbber } from './Throbber';
|
|
14
14
|
export { default as WithTooltip } from './WithTooltip';
|
|
15
15
|
export { default as YouTubeVideo } from './YouTubeVideo';
|
|
@@ -13,10 +13,10 @@ type PropsT = {
|
|
|
13
13
|
containerClass: string;
|
|
14
14
|
containerStyle?: ContainerPosT;
|
|
15
15
|
filter?: (item: OptionT<ReactNode> | ValueT) => boolean;
|
|
16
|
-
optionClass: string;
|
|
17
|
-
options: Readonly<OptionsT<ReactNode>>;
|
|
18
16
|
onCancel: () => void;
|
|
19
17
|
onChange: (value: ValueT) => void;
|
|
18
|
+
optionClass: string;
|
|
19
|
+
options: Readonly<OptionsT<ReactNode>>;
|
|
20
20
|
ref?: RefObject<RefT | null>;
|
|
21
21
|
};
|
|
22
22
|
declare const Options: FunctionComponent<PropsT>;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
type ConfigT = Record<string, unknown>;
|
|
2
2
|
export declare function getConfig<T extends ConfigT>(sync: true): T;
|
|
3
|
-
export declare function getConfig<T extends ConfigT>(sync?: boolean): T |
|
|
3
|
+
export declare function getConfig<T extends ConfigT>(sync?: boolean): Promise<T> | T;
|
|
4
4
|
export {};
|
|
@@ -2,7 +2,7 @@ import { getConfig } from './config';
|
|
|
2
2
|
import * as isomorphy from './isomorphy';
|
|
3
3
|
import time from './time';
|
|
4
4
|
import * as webpack from './webpack';
|
|
5
|
-
export {
|
|
5
|
+
export { Barrier, Cached, Emitter, type Listener, type ObjectKey, Semaphore, assertEmptyObject, withRetries, } from '@dr.pogodin/js-utils';
|
|
6
6
|
export { COMPOSE as THEME_COMPOSE, PRIORITY as THEME_PRIORITY, type Theme, ThemeProvider, useTheme, } from '@dr.pogodin/react-themes';
|
|
7
7
|
export { getSsrContext } from './globalState';
|
|
8
8
|
export { default as splitComponent } from './splitComponent';
|
|
@@ -11,7 +11,7 @@ type RequireWeakResT<T> = T extends {
|
|
|
11
11
|
* @param [basePath]
|
|
12
12
|
* @return Required module.
|
|
13
13
|
*/
|
|
14
|
-
export declare function requireWeak<T extends object>(modulePath: string, basePathOrOptions?:
|
|
14
|
+
export declare function requireWeak<T extends object>(modulePath: string, basePathOrOptions?: RequireWeakOptionsT | string): RequireWeakResT<T> | null;
|
|
15
15
|
/**
|
|
16
16
|
* Resolves specified module path with help of Babel's module resolver.
|
|
17
17
|
* Yes, the function itself just returns its argument to the caller, but Babel
|
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
/* global document */
|
|
3
3
|
|
|
4
4
|
import { createRoot, hydrateRoot } from 'react-dom/client';
|
|
5
|
-
import { HelmetProvider } from '@dr.pogodin/react-helmet';
|
|
6
5
|
import { BrowserRouter } from 'react-router';
|
|
7
6
|
import { GlobalStateProvider } from '@dr.pogodin/react-global-state';
|
|
7
|
+
import { HelmetProvider } from '@dr.pogodin/react-helmet';
|
|
8
8
|
import getInj from "./getInj";
|
|
9
9
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
10
10
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["createRoot","hydrateRoot","
|
|
1
|
+
{"version":3,"file":"index.js","names":["createRoot","hydrateRoot","BrowserRouter","GlobalStateProvider","HelmetProvider","getInj","jsx","_jsx","launchClient","Application","options","inj","container","document","getElementById","Error","scene","initialState","ISTATE","children","dontHydrate","root","render"],"sources":["../../../src/client/index.tsx"],"sourcesContent":["// Initialization of client-side code.\n/* global document */\n\nimport type { ComponentType } from 'react';\nimport { createRoot, hydrateRoot } from 'react-dom/client';\nimport { BrowserRouter } from 'react-router';\n\nimport { GlobalStateProvider } from '@dr.pogodin/react-global-state';\nimport { HelmetProvider } from '@dr.pogodin/react-helmet';\n\nimport getInj from './getInj';\n\ntype OptionsT = {\n dontHydrate?: boolean;\n initialState?: unknown;\n};\n\n/**\n * Prepares and launches the app at client side.\n * @param Application Root application component\n * @param [options={}] Optional. Additional settings.\n */\nexport async function launchClient(\n Application: ComponentType,\n options: OptionsT = {},\n): Promise<void> {\n const inj = await getInj();\n\n const container = document.getElementById('react-view');\n if (!container) throw Error('Failed to find container for React app');\n const scene = (\n <GlobalStateProvider initialState={inj.ISTATE ?? options.initialState}>\n <BrowserRouter>\n <HelmetProvider>\n <Application />\n </HelmetProvider>\n </BrowserRouter>\n </GlobalStateProvider>\n );\n\n if (options.dontHydrate) {\n const root = createRoot(container);\n root.render(scene);\n } else hydrateRoot(container, scene);\n}\n"],"mappings":"AAAA;AACA;;AAGA,SAASA,UAAU,EAAEC,WAAW,QAAQ,kBAAkB;AAC1D,SAASC,aAAa,QAAQ,cAAc;AAE5C,SAASC,mBAAmB,QAAQ,gCAAgC;AACpE,SAASC,cAAc,QAAQ,0BAA0B;AAEzD,OAAOC,MAAM;AAAiB,SAAAC,GAAA,IAAAC,IAAA;AAO9B;AACA;AACA;AACA;AACA;AACA,OAAO,eAAeC,YAAYA,CAChCC,WAA0B,EAC1BC,OAAiB,GAAG,CAAC,CAAC,EACP;EACf,MAAMC,GAAG,GAAG,MAAMN,MAAM,CAAC,CAAC;EAE1B,MAAMO,SAAS,GAAGC,QAAQ,CAACC,cAAc,CAAC,YAAY,CAAC;EACvD,IAAI,CAACF,SAAS,EAAE,MAAMG,KAAK,CAAC,wCAAwC,CAAC;EACrE,MAAMC,KAAK,gBACTT,IAAA,CAACJ,mBAAmB;IAACc,YAAY,EAAEN,GAAG,CAACO,MAAM,IAAIR,OAAO,CAACO,YAAa;IAAAE,QAAA,eACpEZ,IAAA,CAACL,aAAa;MAAAiB,QAAA,eACZZ,IAAA,CAACH,cAAc;QAAAe,QAAA,eACbZ,IAAA,CAACE,WAAW,IAAE;MAAC,CACD;IAAC,CACJ;EAAC,CACG,CACtB;EAED,IAAIC,OAAO,CAACU,WAAW,EAAE;IACvB,MAAMC,IAAI,GAAGrB,UAAU,CAACY,SAAS,CAAC;IAClCS,IAAI,CAACC,MAAM,CAACN,KAAK,CAAC;EACpB,CAAC,MAAMf,WAAW,CAACW,SAAS,EAAEI,KAAK,CAAC;AACtC","ignoreList":[]}
|
package/build/web/index.js
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
if (global.REACT_UTILS_LIBRARY_LOADED) {
|
|
6
6
|
throw Error('React utils library is already loaded');
|
|
7
7
|
} else global.REACT_UTILS_LIBRARY_LOADED = true;
|
|
8
|
-
export {
|
|
8
|
+
export { GlobalStateProvider, getGlobalState, newAsyncDataEnvelope, useAsyncCollection, useAsyncData, useGlobalState, withGlobalStateType } from '@dr.pogodin/react-global-state';
|
|
9
9
|
export * from "./shared/components";
|
|
10
|
-
export {
|
|
10
|
+
export { Barrier, Cached, Emitter, Semaphore, THEME_COMPOSE, THEME_PRIORITY, ThemeProvider, assertEmptyObject, getConfig, getSsrContext, isomorphy, splitComponent, time, useTheme, webpack, withRetries } from "./shared/utils";
|
|
11
11
|
//# sourceMappingURL=index.js.map
|
package/build/web/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["global","REACT_UTILS_LIBRARY_LOADED","Error","
|
|
1
|
+
{"version":3,"file":"index.js","names":["global","REACT_UTILS_LIBRARY_LOADED","Error","GlobalStateProvider","getGlobalState","newAsyncDataEnvelope","useAsyncCollection","useAsyncData","useGlobalState","withGlobalStateType","Barrier","Cached","Emitter","Semaphore","THEME_COMPOSE","THEME_PRIORITY","ThemeProvider","assertEmptyObject","getConfig","getSsrContext","isomorphy","splitComponent","time","useTheme","webpack","withRetries"],"sources":["../../src/index.ts"],"sourcesContent":["// It is a safeguard against multiple instances / versions of the library\n// being loaded into environment by mistake (e.g. because of different\n// packages pinning down different exact versions of the lib, thus preventing\n// a proper dedupe and using a single common library version).\nif (global.REACT_UTILS_LIBRARY_LOADED) {\n throw Error('React utils library is already loaded');\n} else global.REACT_UTILS_LIBRARY_LOADED = true;\n\nexport {\n type AsyncCollectionLoaderT,\n type AsyncCollectionT,\n type AsyncDataEnvelopeT,\n type AsyncDataLoaderT,\n type ForceT,\n GlobalStateProvider,\n type UseAsyncDataOptionsT,\n type UseAsyncDataResT,\n type UseGlobalStateResT,\n type ValueOrInitializerT,\n getGlobalState,\n newAsyncDataEnvelope,\n useAsyncCollection,\n useAsyncData,\n useGlobalState,\n withGlobalStateType,\n} from '@dr.pogodin/react-global-state';\n\nexport * from 'components';\n\nexport {\n type BeforeRenderResT,\n type BeforeRenderT,\n type ConfigT,\n type ServerSsrContext,\n type ServerT,\n} from './server';\n\nexport {\n Barrier,\n Cached,\n Emitter,\n type Listener,\n type ObjectKey,\n Semaphore,\n THEME_COMPOSE,\n THEME_PRIORITY,\n type Theme,\n ThemeProvider,\n assertEmptyObject,\n getConfig,\n getSsrContext,\n isomorphy,\n splitComponent,\n time,\n useTheme,\n webpack,\n withRetries,\n} from 'utils';\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA,IAAIA,MAAM,CAACC,0BAA0B,EAAE;EACrC,MAAMC,KAAK,CAAC,uCAAuC,CAAC;AACtD,CAAC,MAAMF,MAAM,CAACC,0BAA0B,GAAG,IAAI;AAE/C,SAMEE,mBAAmB,EAKnBC,cAAc,EACdC,oBAAoB,EACpBC,kBAAkB,EAClBC,YAAY,EACZC,cAAc,EACdC,mBAAmB,QACd,gCAAgC;AAEvC;AAUA,SACEC,OAAO,EACPC,MAAM,EACNC,OAAO,EAGPC,SAAS,EACTC,aAAa,EACbC,cAAc,EAEdC,aAAa,EACbC,iBAAiB,EACjBC,SAAS,EACTC,aAAa,EACbC,SAAS,EACTC,cAAc,EACdC,IAAI,EACJC,QAAQ,EACRC,OAAO,EACPC,WAAW","ignoreList":[]}
|
|
@@ -11,7 +11,7 @@ import 'raf/polyfill.js';
|
|
|
11
11
|
import serverFactory, { getDefaultCspSettings } from "./server";
|
|
12
12
|
import { SCRIPT_LOCATIONS, newDefaultLogger } from "./renderer";
|
|
13
13
|
export * from "./utils";
|
|
14
|
-
export {
|
|
14
|
+
export { SCRIPT_LOCATIONS, getDefaultCspSettings };
|
|
15
15
|
|
|
16
16
|
/**
|
|
17
17
|
* Normalizes a port into a number, string, or false.
|