@dr.pogodin/react-utils 1.25.5 → 1.26.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.
- package/babel.config.js +3 -1
- package/bin/build.js +25 -5
- package/build/development/client/getInj.js +9 -8
- package/build/development/client/getInj.js.map +1 -1
- package/build/development/client/index.js +6 -3
- package/build/development/client/index.js.map +1 -1
- package/build/development/client/init.js +4 -0
- package/build/development/client/init.js.map +1 -1
- package/build/development/index.js +168 -42
- package/build/development/index.js.map +1 -1
- package/build/development/server/Cache.js +13 -13
- package/build/development/server/Cache.js.map +1 -1
- package/build/development/server/index.js +16 -24
- package/build/development/server/index.js.map +1 -1
- package/build/development/server/renderer.js +56 -44
- package/build/development/server/renderer.js.map +1 -1
- package/build/development/server/server.js +9 -5
- package/build/development/server/server.js.map +1 -1
- package/build/development/server/utils/errors.js +12 -9
- package/build/development/server/utils/errors.js.map +1 -1
- package/build/development/server/utils/index.js +2 -2
- package/build/development/server/utils/index.js.map +1 -1
- package/build/development/shared/components/Button/index.js +8 -7
- package/build/development/shared/components/Button/index.js.map +1 -1
- package/build/development/shared/components/Checkbox/index.js +25 -28
- package/build/development/shared/components/Checkbox/index.js.map +1 -1
- package/build/development/shared/components/Dropdown/index.js +25 -19
- package/build/development/shared/components/Dropdown/index.js.map +1 -1
- package/build/development/shared/components/GenericLink/index.js +44 -37
- package/build/development/shared/components/GenericLink/index.js.map +1 -1
- package/build/development/shared/components/Input/index.js +8 -9
- package/build/development/shared/components/Input/index.js.map +1 -1
- package/build/development/shared/components/Link.js +10 -9
- package/build/development/shared/components/Link.js.map +1 -1
- package/build/development/shared/components/MetaTags.js +22 -18
- package/build/development/shared/components/MetaTags.js.map +1 -1
- package/build/development/shared/components/Modal/index.js +17 -18
- package/build/development/shared/components/Modal/index.js.map +1 -1
- package/build/development/shared/components/NavLink.js +10 -9
- package/build/development/shared/components/NavLink.js.map +1 -1
- package/build/development/shared/components/PageLayout/index.js +17 -20
- package/build/development/shared/components/PageLayout/index.js.map +1 -1
- package/build/development/shared/components/ScalableRect/index.js +27 -7
- package/build/development/shared/components/ScalableRect/index.js.map +1 -1
- package/build/development/shared/components/Throbber/index.js +14 -23
- package/build/development/shared/components/Throbber/index.js.map +1 -1
- package/build/development/shared/components/WithTooltip/Tooltip.js +20 -24
- package/build/development/shared/components/WithTooltip/Tooltip.js.map +1 -1
- package/build/development/shared/components/WithTooltip/index.js +11 -11
- package/build/development/shared/components/WithTooltip/index.js.map +1 -1
- package/build/development/shared/components/YouTubeVideo/index.js +16 -15
- package/build/development/shared/components/YouTubeVideo/index.js.map +1 -1
- package/build/development/shared/components/index.js +2 -2
- package/build/development/shared/components/index.js.map +1 -1
- package/build/development/shared/utils/config.js +1 -2
- package/build/development/shared/utils/config.js.map +1 -1
- package/build/development/shared/utils/globalState.js +15 -0
- package/build/development/shared/utils/globalState.js.map +1 -0
- package/build/development/shared/utils/index.js +13 -11
- package/build/development/shared/utils/index.js.map +1 -1
- package/build/development/shared/utils/isomorphy/buildInfo.js +7 -3
- package/build/development/shared/utils/isomorphy/buildInfo.js.map +1 -1
- package/build/development/shared/utils/isomorphy/environment-check.js +2 -4
- package/build/development/shared/utils/isomorphy/environment-check.js.map +1 -1
- package/build/development/shared/utils/isomorphy/index.js.map +1 -1
- package/build/development/shared/utils/jest/E2eSsrEnv.js +35 -28
- package/build/development/shared/utils/jest/E2eSsrEnv.js.map +1 -1
- package/build/development/shared/utils/jest/global.js +17 -0
- package/build/development/shared/utils/jest/global.js.map +1 -0
- package/build/development/shared/utils/jest/index.js +18 -11
- package/build/development/shared/utils/jest/index.js.map +1 -1
- package/build/development/shared/utils/splitComponent.js +25 -34
- package/build/development/shared/utils/splitComponent.js.map +1 -1
- package/build/development/shared/utils/time.js +16 -13
- package/build/development/shared/utils/time.js.map +1 -1
- package/build/development/shared/utils/webpack.js +3 -3
- package/build/development/shared/utils/webpack.js.map +1 -1
- package/build/development/web.bundle.js +92 -82
- package/build/production/client/getInj.js +1 -1
- package/build/production/client/getInj.js.map +1 -1
- package/build/production/client/index.js +4 -4
- package/build/production/client/index.js.map +1 -1
- package/build/production/client/init.js +3 -1
- package/build/production/client/init.js.map +1 -1
- package/build/production/index.js +1 -1
- package/build/production/index.js.map +1 -1
- package/build/production/server/Cache.js +7 -8
- package/build/production/server/Cache.js.map +1 -1
- package/build/production/server/index.js +5 -4
- package/build/production/server/index.js.map +1 -1
- package/build/production/server/renderer.js +32 -30
- package/build/production/server/renderer.js.map +1 -1
- package/build/production/server/server.js +7 -5
- package/build/production/server/server.js.map +1 -1
- package/build/production/server/utils/errors.js +9 -10
- package/build/production/server/utils/errors.js.map +1 -1
- package/build/production/server/utils/index.js +1 -1
- package/build/production/server/utils/index.js.map +1 -1
- package/build/production/shared/components/Button/index.js +4 -4
- package/build/production/shared/components/Button/index.js.map +1 -1
- package/build/production/shared/components/Checkbox/index.js +12 -12
- package/build/production/shared/components/Checkbox/index.js.map +1 -1
- package/build/production/shared/components/Dropdown/index.js +11 -11
- package/build/production/shared/components/Dropdown/index.js.map +1 -1
- package/build/production/shared/components/GenericLink/index.js +25 -20
- package/build/production/shared/components/GenericLink/index.js.map +1 -1
- package/build/production/shared/components/Input/index.js +7 -7
- package/build/production/shared/components/Input/index.js.map +1 -1
- package/build/production/shared/components/Link.js +2 -2
- package/build/production/shared/components/Link.js.map +1 -1
- package/build/production/shared/components/MetaTags.js +10 -10
- package/build/production/shared/components/MetaTags.js.map +1 -1
- package/build/production/shared/components/Modal/index.js +2 -2
- package/build/production/shared/components/Modal/index.js.map +1 -1
- package/build/production/shared/components/NavLink.js +1 -1
- package/build/production/shared/components/NavLink.js.map +1 -1
- package/build/production/shared/components/PageLayout/index.js +2 -2
- package/build/production/shared/components/PageLayout/index.js.map +1 -1
- package/build/production/shared/components/ScalableRect/index.js +7 -3
- package/build/production/shared/components/ScalableRect/index.js.map +1 -1
- package/build/production/shared/components/Throbber/index.js +2 -2
- package/build/production/shared/components/Throbber/index.js.map +1 -1
- package/build/production/shared/components/WithTooltip/Tooltip.js +13 -13
- package/build/production/shared/components/WithTooltip/Tooltip.js.map +1 -1
- package/build/production/shared/components/WithTooltip/index.js +3 -3
- package/build/production/shared/components/WithTooltip/index.js.map +1 -1
- package/build/production/shared/components/YouTubeVideo/index.js +7 -7
- 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/utils/config.js +1 -1
- package/build/production/shared/utils/config.js.map +1 -1
- package/build/production/shared/utils/globalState.js +3 -0
- package/build/production/shared/utils/globalState.js.map +1 -0
- package/build/production/shared/utils/index.js +3 -3
- package/build/production/shared/utils/index.js.map +1 -1
- package/build/production/shared/utils/isomorphy/buildInfo.js +7 -4
- package/build/production/shared/utils/isomorphy/buildInfo.js.map +1 -1
- package/build/production/shared/utils/isomorphy/environment-check.js +2 -2
- package/build/production/shared/utils/isomorphy/environment-check.js.map +1 -1
- package/build/production/shared/utils/isomorphy/index.js.map +1 -1
- package/build/production/shared/utils/jest/E2eSsrEnv.js +9 -9
- package/build/production/shared/utils/jest/E2eSsrEnv.js.map +1 -1
- package/build/production/shared/utils/jest/global.js +2 -0
- package/build/production/shared/utils/jest/global.js.map +1 -0
- package/build/production/shared/utils/jest/index.js +6 -6
- package/build/production/shared/utils/jest/index.js.map +1 -1
- package/build/production/shared/utils/splitComponent.js +16 -16
- package/build/production/shared/utils/splitComponent.js.map +1 -1
- package/build/production/shared/utils/time.js +12 -8
- package/build/production/shared/utils/time.js.map +1 -1
- package/build/production/shared/utils/webpack.js +3 -3
- package/build/production/shared/utils/webpack.js.map +1 -1
- package/build/production/web.bundle.js +1 -1
- package/build/production/web.bundle.js.map +1 -1
- package/build/types-code/client/getInj.d.ts +3 -0
- package/build/types-code/client/index.d.ts +11 -0
- package/build/types-code/client/init.d.ts +9 -0
- package/build/types-code/index.d.ts +10 -0
- package/build/types-code/server/Cache.d.ts +37 -0
- package/build/types-code/server/index.d.ts +145 -0
- package/build/types-code/server/renderer.d.ts +106 -0
- package/build/types-code/server/server.d.ts +41 -0
- package/build/types-code/server/utils/errors.d.ts +104 -0
- package/build/types-code/server/utils/index.d.ts +1 -0
- package/build/types-code/shared/components/Button/index.d.ts +27 -0
- package/build/types-code/shared/components/Checkbox/index.d.ts +21 -0
- package/build/types-code/shared/components/Dropdown/index.d.ts +23 -0
- package/build/types-code/shared/components/GenericLink/index.d.ts +61 -0
- package/build/types-code/shared/components/Input/index.d.ts +11 -0
- package/build/types-code/shared/components/Link.d.ts +12 -0
- package/build/types-code/shared/components/MetaTags.d.ts +68 -0
- package/build/types-code/shared/components/Modal/index.d.ts +26 -0
- package/build/types-code/shared/components/NavLink.d.ts +5 -0
- package/build/types-code/shared/components/PageLayout/index.d.ts +16 -0
- package/build/types-code/shared/components/ScalableRect/index.d.ts +19 -0
- package/build/types-code/shared/components/Throbber/index.d.ts +9 -0
- package/build/types-code/shared/components/WithTooltip/Tooltip.d.ts +23 -0
- package/build/types-code/shared/components/WithTooltip/index.d.ts +17 -0
- package/build/types-code/shared/components/YouTubeVideo/index.d.ts +13 -0
- package/build/types-code/shared/components/index.d.ts +16 -0
- package/build/types-code/shared/utils/config.d.ts +2 -0
- package/build/types-code/shared/utils/globalState.d.ts +20 -0
- package/build/types-code/shared/utils/index.d.ts +52 -0
- package/build/types-code/shared/utils/isomorphy/buildInfo.d.ts +23 -0
- package/build/types-code/shared/utils/isomorphy/environment-check.d.ts +11 -0
- package/build/types-code/shared/utils/isomorphy/index.d.ts +20 -0
- package/build/types-code/shared/utils/jest/E2eSsrEnv.d.ts +31 -0
- package/build/types-code/shared/utils/jest/global.d.ts +12 -0
- package/build/types-code/shared/utils/jest/index.d.ts +85 -0
- package/build/types-code/shared/utils/splitComponent.d.ts +41 -0
- package/build/types-code/shared/utils/time.d.ts +62 -0
- package/build/types-code/shared/utils/webpack.d.ts +18 -0
- package/build/types-scss/__tests__/js/config/publicPath support/__assets__/style.scss.d.ts +1 -0
- package/build/types-scss/__tests__/js/config/stylename-generation/__assets__/MockPackageA/TestComponent/style.scss.d.ts +1 -0
- package/build/types-scss/__tests__/js/config/stylename-generation/__assets__/MockPackageB/TestComponent/style.scss.d.ts +1 -0
- package/build/types-scss/__tests__/js/config/stylename-generation/__assets__/style.scss.d.ts +1 -0
- package/build/types-scss/__tests__/js/shared/components/NavLink/styles.scss.d.ts +1 -0
- package/build/types-scss/__tests__/js/shared/utils/splitComponent/__assets__/SampleScene/ComponentA/style.scss.d.ts +1 -0
- package/build/types-scss/__tests__/js/shared/utils/splitComponent/__assets__/SampleScene/ComponentB/style.scss.d.ts +1 -0
- package/build/types-scss/__tests__/js/shared/utils/splitComponent/__assets__/SampleScene/ComponentC/style.scss.d.ts +1 -0
- package/build/types-scss/__tests__/js/shared/utils/splitComponent/__assets__/SampleScene/style.scss.d.ts +1 -0
- package/build/types-scss/__tests__/ts/config/publicPath support/__assets__/style.scss.d.ts +1 -0
- package/build/types-scss/__tests__/ts/config/stylename-generation/__assets__/MockPackageA/TestComponent/style.scss.d.ts +1 -0
- package/build/types-scss/__tests__/ts/config/stylename-generation/__assets__/MockPackageB/TestComponent/style.scss.d.ts +1 -0
- package/build/types-scss/__tests__/ts/config/stylename-generation/__assets__/style.scss.d.ts +1 -0
- package/build/types-scss/__tests__/ts/shared/components/NavLink/styles.scss.d.ts +1 -0
- package/build/types-scss/__tests__/ts/shared/utils/splitComponent/__assets__/SampleScene/ComponentA/style.scss.d.ts +1 -0
- package/build/types-scss/__tests__/ts/shared/utils/splitComponent/__assets__/SampleScene/ComponentB/style.scss.d.ts +1 -0
- package/build/types-scss/__tests__/ts/shared/utils/splitComponent/__assets__/SampleScene/ComponentC/style.scss.d.ts +1 -0
- package/build/types-scss/__tests__/ts/shared/utils/splitComponent/__assets__/SampleScene/style.scss.d.ts +1 -0
- package/build/types-scss/src/shared/components/Button/style.scss.d.ts +6 -0
- package/build/types-scss/src/shared/components/Checkbox/theme.scss.d.ts +6 -0
- package/build/types-scss/src/shared/components/Dropdown/theme.scss.d.ts +9 -0
- package/build/types-scss/src/shared/components/GenericLink/style.scss.d.ts +1 -0
- package/build/types-scss/src/shared/components/Input/theme.scss.d.ts +6 -0
- package/build/types-scss/src/shared/components/Modal/base-theme.scss.d.ts +5 -0
- package/build/types-scss/src/shared/components/PageLayout/base-theme.scss.d.ts +6 -0
- package/build/types-scss/src/shared/components/ScalableRect/style.scss.d.ts +2 -0
- package/build/types-scss/src/shared/components/Throbber/theme.scss.d.ts +6 -0
- package/build/types-scss/src/shared/components/WithTooltip/default-theme.scss.d.ts +7 -0
- package/build/types-scss/src/shared/components/YouTubeVideo/base.scss.d.ts +5 -0
- package/build/types-scss/src/shared/components/YouTubeVideo/throbber.scss.d.ts +4 -0
- package/config/eslint/jest.json +3 -2
- package/config/eslint/typescript.js +34 -0
- package/config/jest/default.js +3 -3
- package/package.json +75 -33
- package/src/client/getInj.ts +43 -0
- package/src/client/index.tsx +40 -0
- package/src/client/init.ts +47 -0
- package/src/index.ts +58 -0
- package/src/server/Cache.ts +68 -0
- package/src/server/index.ts +230 -0
- package/src/server/renderer.tsx +604 -0
- package/src/server/server.ts +309 -0
- package/src/server/utils/errors.ts +135 -0
- package/src/server/utils/index.ts +3 -0
- package/src/shared/components/Button/index.tsx +146 -0
- package/src/shared/components/Button/style.scss +53 -0
- package/src/shared/components/Checkbox/index.tsx +71 -0
- package/src/shared/components/Checkbox/theme.scss +43 -0
- package/src/shared/components/Dropdown/index.tsx +144 -0
- package/src/shared/components/Dropdown/theme.scss +63 -0
- package/src/shared/components/GenericLink/index.tsx +157 -0
- package/src/shared/components/GenericLink/style.scss +3 -0
- package/src/shared/components/Input/index.tsx +59 -0
- package/src/shared/components/Input/theme.scss +27 -0
- package/src/shared/components/Link.tsx +21 -0
- package/src/shared/components/MetaTags.tsx +170 -0
- package/src/shared/components/Modal/base-theme.scss +38 -0
- package/src/shared/components/Modal/index.tsx +144 -0
- package/src/shared/components/Modal/styles.scss +5 -0
- package/src/shared/components/NavLink.tsx +13 -0
- package/src/shared/components/PageLayout/base-theme.scss +30 -0
- package/src/shared/components/PageLayout/index.tsx +76 -0
- package/src/shared/components/ScalableRect/index.tsx +84 -0
- package/src/shared/components/ScalableRect/style.scss +10 -0
- package/src/shared/components/Throbber/index.tsx +43 -0
- package/src/shared/components/Throbber/theme.scss +26 -0
- package/src/shared/components/WithTooltip/Tooltip.tsx +353 -0
- package/src/shared/components/WithTooltip/default-theme.scss +36 -0
- package/src/shared/components/WithTooltip/index.tsx +204 -0
- package/src/shared/components/YouTubeVideo/base.scss +13 -0
- package/src/shared/components/YouTubeVideo/index.tsx +96 -0
- package/src/shared/components/YouTubeVideo/throbber.scss +11 -0
- package/src/shared/components/index.ts +17 -0
- package/src/shared/utils/config.ts +21 -0
- package/src/shared/utils/globalState.ts +29 -0
- package/src/shared/utils/index.ts +105 -0
- package/src/shared/utils/isomorphy/buildInfo.ts +54 -0
- package/src/shared/utils/isomorphy/environment-check.ts +18 -0
- package/src/shared/utils/isomorphy/index.ts +38 -0
- package/src/shared/utils/jest/E2eSsrEnv.ts +250 -0
- package/src/shared/utils/jest/global.ts +19 -0
- package/src/shared/utils/jest/index.tsx +157 -0
- package/src/shared/utils/splitComponent.tsx +255 -0
- package/src/shared/utils/time.ts +118 -0
- package/src/shared/utils/webpack.ts +45 -0
- package/src/styles/_global/reset.css +52 -0
- package/src/styles/global.scss +11 -0
- package/tsconfig.configs.json +18 -0
- package/tsconfig.json +27 -0
- package/tsconfig.types.json +53 -0
- package/typed-scss-modules.config.ts +9 -0
- package/types.d.ts +37 -0
- package/{webpack.config.js → webpack.config.ts} +7 -3
- package/config/babel/node-ssr.js +0 -85
- package/config/babel/webpack.js +0 -122
- package/config/webpack/app-base.js +0 -330
- package/config/webpack/app-development.js +0 -80
- package/config/webpack/app-production.js +0 -60
- package/config/webpack/lib-base.js +0 -155
- package/config/webpack/lib-development.js +0 -45
- package/config/webpack/lib-production.js +0 -44
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { type ReactNode } from 'react';
|
|
2
|
+
type PropsT = {
|
|
3
|
+
children?: ReactNode;
|
|
4
|
+
description: string;
|
|
5
|
+
image?: string;
|
|
6
|
+
siteName?: string;
|
|
7
|
+
socialDescription?: string;
|
|
8
|
+
socialTitle?: string;
|
|
9
|
+
title: string;
|
|
10
|
+
url?: string;
|
|
11
|
+
};
|
|
12
|
+
/**
|
|
13
|
+
* The `<MetaTags>` component is an auxiliary wrapper around `react-helmet`,
|
|
14
|
+
* which helps to inject meta tags (page title, a brief content description,
|
|
15
|
+
* and social media thumbnails) into generated pages.
|
|
16
|
+
*
|
|
17
|
+
* When `<MetaTags>` are nested within the app's component tree, meta tags
|
|
18
|
+
* content injected by components encountered down the tree overrides tags
|
|
19
|
+
* injected by previously encountered `<MetaTags>` components.
|
|
20
|
+
*
|
|
21
|
+
* **Children:** `<MetaTags>` children, if any, are rendered at the component's
|
|
22
|
+
* location. The context passes down all meta tag properties of parent
|
|
23
|
+
* `<MetaTag>` instances. These properties can fetched within children
|
|
24
|
+
* hierarchy in the following way, thus facilitating tags modification by
|
|
25
|
+
* children:
|
|
26
|
+
* ```jsx
|
|
27
|
+
* import { useContext } from 'react';
|
|
28
|
+
* import { MetaTags } from '@dr.pogodin/react-utils';
|
|
29
|
+
* export default function SampleComponent() {
|
|
30
|
+
* const { title, description, ...rest } = useContext(MetaTags.Context);
|
|
31
|
+
* // Do something with these props here, e.g. prefix the page title with
|
|
32
|
+
* // the component name:
|
|
33
|
+
* return (
|
|
34
|
+
* <MetaTags title={`Sample component - ${title}`} />
|
|
35
|
+
* );
|
|
36
|
+
* }
|
|
37
|
+
* ```
|
|
38
|
+
* @param [props]
|
|
39
|
+
* @param [props.description] Page description to use in
|
|
40
|
+
* the `description` meta tag, and as a default description of Open Graph Tags.
|
|
41
|
+
* @param [props.image] The absolute URL of thumbnail image to use
|
|
42
|
+
* in Open Graph Tags (`twitter:image`, and `og:image`). By default these tags
|
|
43
|
+
* are not injected.
|
|
44
|
+
*
|
|
45
|
+
* **BEWARE:** It must be a complete, absolute URL, including the correct
|
|
46
|
+
* website domain and HTTP schema.
|
|
47
|
+
*
|
|
48
|
+
* @param [props.siteName]: The site name to use in `twitter:site`,
|
|
49
|
+
* and `og:sitename` tags. By default these tags are not injected.
|
|
50
|
+
*
|
|
51
|
+
* @param [props.socialDescription] The site description to use in
|
|
52
|
+
* `twitter:description` and `og:description` meta tags. By default the value of
|
|
53
|
+
* `description` prop is used.
|
|
54
|
+
* @param [props.socialTitle] The page title to use in
|
|
55
|
+
* `twitter:title`, `og:title`, and `og:image:alt` tags. By default the value of
|
|
56
|
+
* `title` prop is used. Also the `og:image:alt` tag is only injected if `image`
|
|
57
|
+
* prop is present.
|
|
58
|
+
*
|
|
59
|
+
* @param props.title: The page name to use in the `<title>` tag.
|
|
60
|
+
* It is also used as the default value of `socialTitle` prop.
|
|
61
|
+
*
|
|
62
|
+
* @param [props.url] The page URL to use in `og:url` tag.
|
|
63
|
+
* By default the tag is not injected.
|
|
64
|
+
*/
|
|
65
|
+
declare const MetaTags: React.FunctionComponent<PropsT> & {
|
|
66
|
+
Context: React.Context<PropsT>;
|
|
67
|
+
};
|
|
68
|
+
export default MetaTags;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { type ReactNode } from 'react';
|
|
2
|
+
import { type Theme } from '@dr.pogodin/react-themes';
|
|
3
|
+
import './styles.scss';
|
|
4
|
+
type PropsT = {
|
|
5
|
+
children?: ReactNode;
|
|
6
|
+
onCancel?: () => void;
|
|
7
|
+
theme: Theme & {
|
|
8
|
+
container?: string;
|
|
9
|
+
overlay?: string;
|
|
10
|
+
};
|
|
11
|
+
};
|
|
12
|
+
/**
|
|
13
|
+
* The `<Modal>` component implements a simple themeable modal window, wrapped
|
|
14
|
+
* into the default theme. `<BaseModal>` exposes the base non-themed component.
|
|
15
|
+
* **Children:** Component children are rendered as the modal content.
|
|
16
|
+
* @param {object} props Component properties. Beside props documented below,
|
|
17
|
+
* [Other theming properties](https://www.npmjs.com/package/@dr.pogodin/react-themes#themed-component-properties) are supported as well.
|
|
18
|
+
* @param {function} [props.onCancel] The callback to trigger when user
|
|
19
|
+
* clicks outside the modal, or presses Escape. It is expected to hide the
|
|
20
|
+
* modal.
|
|
21
|
+
* @param {ModalTheme} [props.theme] _Ad hoc_ theme.
|
|
22
|
+
*/
|
|
23
|
+
declare const BaseModal: React.FunctionComponent<PropsT>;
|
|
24
|
+
declare const ThemedModal: import("@dr.pogodin/react-themes").ThemedComponent<PropsT>;
|
|
25
|
+
export default ThemedModal;
|
|
26
|
+
export { BaseModal };
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { ReactNode } from 'react';
|
|
2
|
+
import { type Theme } from '@dr.pogodin/react-themes';
|
|
3
|
+
type PropsT = {
|
|
4
|
+
children?: ReactNode;
|
|
5
|
+
leftSidePanelContent?: ReactNode;
|
|
6
|
+
rightSidePanelContent?: ReactNode;
|
|
7
|
+
theme: Theme & {
|
|
8
|
+
container?: string;
|
|
9
|
+
mainPanel?: string;
|
|
10
|
+
sidePanel?: string;
|
|
11
|
+
leftSidePanel?: string;
|
|
12
|
+
rightSidePanel?: string;
|
|
13
|
+
};
|
|
14
|
+
};
|
|
15
|
+
declare const ThemedPageLayout: import("@dr.pogodin/react-themes").ThemedComponent<PropsT>;
|
|
16
|
+
export default ThemedPageLayout;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { type ReactNode } from 'react';
|
|
2
|
+
import './style.scss';
|
|
3
|
+
type PropsT = {
|
|
4
|
+
children?: ReactNode;
|
|
5
|
+
className?: string;
|
|
6
|
+
ratio?: `${number}:${number}`;
|
|
7
|
+
};
|
|
8
|
+
/**
|
|
9
|
+
* The `<ScalableRect>` component implements container keeping given aspect
|
|
10
|
+
* ratio, while its width is altered.
|
|
11
|
+
*
|
|
12
|
+
* **Children:** Component children are rendered as the component's content.
|
|
13
|
+
* @param {object} props
|
|
14
|
+
* @param {string} [props.className] CSS class for component container.
|
|
15
|
+
* @param {string} [props.ratio=1:1] Ratio of the rendered rectangle sides,
|
|
16
|
+
* in `W:H` form.
|
|
17
|
+
*/
|
|
18
|
+
declare const ScalableRect: React.FunctionComponent<PropsT>;
|
|
19
|
+
export default ScalableRect;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { type Theme } from '@dr.pogodin/react-themes';
|
|
2
|
+
type PropsT = {
|
|
3
|
+
theme: Theme & {
|
|
4
|
+
container?: string;
|
|
5
|
+
circle?: string;
|
|
6
|
+
};
|
|
7
|
+
};
|
|
8
|
+
declare const ThemedThrobber: import("@dr.pogodin/react-themes").ThemedComponent<PropsT>;
|
|
9
|
+
export default ThemedThrobber;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The actual tooltip component. It is rendered outside the regular document
|
|
3
|
+
* hierarchy, and with sub-components managed without React to achieve the best
|
|
4
|
+
* performance during animation.
|
|
5
|
+
*/
|
|
6
|
+
import { type ReactNode } from 'react';
|
|
7
|
+
export declare enum PLACEMENTS {
|
|
8
|
+
ABOVE_CURSOR = "ABOVE_CURSOR",
|
|
9
|
+
ABOVE_ELEMENT = "ABOVE_ELEMENT",
|
|
10
|
+
BELOW_CURSOR = "BELOW_CURSOR",
|
|
11
|
+
BELOW_ELEMENT = "BELOW_ELEMENT"
|
|
12
|
+
}
|
|
13
|
+
export interface TooltipThemeT {
|
|
14
|
+
appearance?: string;
|
|
15
|
+
arrow?: string;
|
|
16
|
+
content?: string;
|
|
17
|
+
container?: string;
|
|
18
|
+
}
|
|
19
|
+
declare const Tooltip: React.ForwardRefExoticComponent<{
|
|
20
|
+
children?: ReactNode;
|
|
21
|
+
theme: any;
|
|
22
|
+
} & React.RefAttributes<unknown>>;
|
|
23
|
+
export default Tooltip;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { type ReactNode } from 'react';
|
|
2
|
+
import { type Theme } from '@dr.pogodin/react-themes';
|
|
3
|
+
import { PLACEMENTS, type TooltipThemeT } from './Tooltip';
|
|
4
|
+
type PropsT = {
|
|
5
|
+
children?: ReactNode;
|
|
6
|
+
placement?: PLACEMENTS;
|
|
7
|
+
tip?: ReactNode;
|
|
8
|
+
theme: Theme & TooltipThemeT & {
|
|
9
|
+
wrapper?: string;
|
|
10
|
+
};
|
|
11
|
+
};
|
|
12
|
+
declare const ThemedWrapper: import("@dr.pogodin/react-themes").ThemedComponent<PropsT>;
|
|
13
|
+
type ExportT = typeof ThemedWrapper & {
|
|
14
|
+
PLACEMENTS: typeof PLACEMENTS;
|
|
15
|
+
};
|
|
16
|
+
declare const e: ExportT;
|
|
17
|
+
export default e;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { type Theme } from '@dr.pogodin/react-themes';
|
|
2
|
+
type ComponentThemeT = Theme & {
|
|
3
|
+
container?: string;
|
|
4
|
+
video?: string;
|
|
5
|
+
};
|
|
6
|
+
type PropsT = {
|
|
7
|
+
autoplay?: boolean;
|
|
8
|
+
src: string;
|
|
9
|
+
theme: ComponentThemeT;
|
|
10
|
+
title?: string;
|
|
11
|
+
};
|
|
12
|
+
declare const ThemedYouTubeVideo: import("@dr.pogodin/react-themes").ThemedComponent<PropsT>;
|
|
13
|
+
export default ThemedYouTubeVideo;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Just an aggregation of all exported components into a single module.
|
|
3
|
+
*/
|
|
4
|
+
export { default as Button } from './Button';
|
|
5
|
+
export { default as Checkbox } from './Checkbox';
|
|
6
|
+
export { default as Dropdown } from './Dropdown';
|
|
7
|
+
export { default as Input } from './Input';
|
|
8
|
+
export { default as Link } from './Link';
|
|
9
|
+
export { default as PageLayout } from './PageLayout';
|
|
10
|
+
export { default as MetaTags } from './MetaTags';
|
|
11
|
+
export { default as Modal, BaseModal } from './Modal';
|
|
12
|
+
export { default as NavLink } from './NavLink';
|
|
13
|
+
export { default as ScalableRect } from './ScalableRect';
|
|
14
|
+
export { default as Throbber } from './Throbber';
|
|
15
|
+
export { default as WithTooltip } from './WithTooltip';
|
|
16
|
+
export { default as YouTubeVideo } from './YouTubeVideo';
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { Request } from 'express';
|
|
2
|
+
import { type SsrContext } from '@dr.pogodin/react-global-state';
|
|
3
|
+
export type ChunkGroupsT = {
|
|
4
|
+
[chunkName: string]: string[];
|
|
5
|
+
};
|
|
6
|
+
export type InjT = {
|
|
7
|
+
CHUNK_GROUPS?: ChunkGroupsT;
|
|
8
|
+
CONFIG?: {
|
|
9
|
+
[key: string]: any;
|
|
10
|
+
};
|
|
11
|
+
ISTATE?: unknown;
|
|
12
|
+
};
|
|
13
|
+
export interface SsrContextT<StateT> extends SsrContext<StateT> {
|
|
14
|
+
chunkGroups: ChunkGroupsT;
|
|
15
|
+
chunks: string[];
|
|
16
|
+
req: Request;
|
|
17
|
+
status: number;
|
|
18
|
+
}
|
|
19
|
+
declare const getSsrContext: (throwWithoutSsrContext?: boolean | undefined) => SsrContextT<unknown> | undefined;
|
|
20
|
+
export { getSsrContext, };
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import themedImpl, { type Theme, COMPOSE, PRIORITY, ThemeProvider } from '@dr.pogodin/react-themes';
|
|
2
|
+
import config from './config';
|
|
3
|
+
import * as isomorphy from './isomorphy';
|
|
4
|
+
import time from './time';
|
|
5
|
+
import * as webpack from './webpack';
|
|
6
|
+
import type * as JuT from './jest';
|
|
7
|
+
export { Barrier, Emitter, Semaphore } from '@dr.pogodin/js-utils';
|
|
8
|
+
export { getSsrContext } from './globalState';
|
|
9
|
+
export { default as splitComponent } from './splitComponent';
|
|
10
|
+
type ThemedT = typeof themedImpl & {
|
|
11
|
+
COMPOSE: typeof COMPOSE;
|
|
12
|
+
PRIORITY: typeof PRIORITY;
|
|
13
|
+
};
|
|
14
|
+
declare const themed: ThemedT;
|
|
15
|
+
declare const JU: typeof JuT | null;
|
|
16
|
+
/**
|
|
17
|
+
* @category Utilities
|
|
18
|
+
* @global
|
|
19
|
+
* @func withRetries
|
|
20
|
+
* @desc
|
|
21
|
+
* ```js
|
|
22
|
+
* import { withRetries } from '@dr.pogodin/react-utils';
|
|
23
|
+
* ```
|
|
24
|
+
* Attempts to perform given asynchronous `action` up to `maxRetries` times,
|
|
25
|
+
* with the given `interval` between attempts. If any attempt is successful,
|
|
26
|
+
* the result is returned immediately, with no further attempts done;
|
|
27
|
+
* otherwise, if all attempts fail, the result Promise rejects after the last
|
|
28
|
+
* attempt.
|
|
29
|
+
* @param {function} action
|
|
30
|
+
* @param {number} [maxRetries=5] Optional. Maximum number of retries. Defaults
|
|
31
|
+
* to 5 attempts.
|
|
32
|
+
* @param {number} [interval=1000] Optional. Interval between retries [ms].
|
|
33
|
+
* Defaults to 1 second.
|
|
34
|
+
* @return {Promise} Resolves to the result of successful operation, or
|
|
35
|
+
* rejects with the error from the latst failed attempt.
|
|
36
|
+
* @example
|
|
37
|
+
* import { withRetries } from '@dr.pogodin/react-utils';
|
|
38
|
+
*
|
|
39
|
+
* let firstCall = true;
|
|
40
|
+
*
|
|
41
|
+
* function sampleAction() {
|
|
42
|
+
* if (!firstCall) return 'success';
|
|
43
|
+
* firstCall = false;
|
|
44
|
+
* throw Error('The first call to this method fails');
|
|
45
|
+
* }
|
|
46
|
+
*
|
|
47
|
+
* withRetries(sampleAction).then(console.log);
|
|
48
|
+
* // It will print 'success' after one second, once the second attempt
|
|
49
|
+
* // is performed.
|
|
50
|
+
*/
|
|
51
|
+
export declare function withRetries(action: () => Promise<unknown>, maxRetries?: number, interval?: number): Promise<unknown>;
|
|
52
|
+
export { type Theme, config, isomorphy, JU, themed, ThemeProvider, time, webpack, };
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
export type BuildInfoT = {
|
|
2
|
+
key: string;
|
|
3
|
+
publicPath: string;
|
|
4
|
+
timestamp: string;
|
|
5
|
+
useServiceWorker: boolean;
|
|
6
|
+
};
|
|
7
|
+
declare global {
|
|
8
|
+
const BUILD_INFO: BuildInfoT | undefined;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* In scenarious where "BUILD_INFO" is not injected by Webpack (server-side,
|
|
12
|
+
* tests, etc.) we expect the host codebase to explicitly set it before it is
|
|
13
|
+
* ever requested. As a precaution, this function throws if build info has been
|
|
14
|
+
* set already, unless `force` flag is explicitly set.
|
|
15
|
+
* @param info
|
|
16
|
+
* @param force
|
|
17
|
+
*/
|
|
18
|
+
export declare function setBuildInfo(info?: BuildInfoT, force?: boolean): void;
|
|
19
|
+
/**
|
|
20
|
+
* Returns "Build Info" object; throws if it has not been initialized yet.
|
|
21
|
+
* @returns
|
|
22
|
+
*/
|
|
23
|
+
export declare function getBuildInfo(): BuildInfoT;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
declare global {
|
|
2
|
+
var REACT_UTILS_FORCE_CLIENT_SIDE: boolean | undefined;
|
|
3
|
+
}
|
|
4
|
+
/**
|
|
5
|
+
* `true` within client-side environment (browser), `false` at server-side.
|
|
6
|
+
*/
|
|
7
|
+
export declare const IS_CLIENT_SIDE: boolean;
|
|
8
|
+
/**
|
|
9
|
+
* `true` within the server-side environment (node), `false` at client-side.
|
|
10
|
+
*/
|
|
11
|
+
export declare const IS_SERVER_SIDE: boolean;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { getBuildInfo } from './buildInfo';
|
|
2
|
+
import { IS_CLIENT_SIDE, IS_SERVER_SIDE } from './environment-check';
|
|
3
|
+
/**
|
|
4
|
+
* Returns `true` if development version of the code is running;
|
|
5
|
+
* `false` otherwise.
|
|
6
|
+
* @return {boolean}
|
|
7
|
+
*/
|
|
8
|
+
export declare function isDevBuild(): boolean;
|
|
9
|
+
/**
|
|
10
|
+
* Returns `true` if production build of the code is running;
|
|
11
|
+
* `false` otherwise.
|
|
12
|
+
* @return {boolean}
|
|
13
|
+
*/
|
|
14
|
+
export declare function isProdBuild(): boolean;
|
|
15
|
+
/**
|
|
16
|
+
* Returns build timestamp of the front-end JS bundle.
|
|
17
|
+
* @return {string} ISO date/time string.
|
|
18
|
+
*/
|
|
19
|
+
export declare function buildTimestamp(): string;
|
|
20
|
+
export { IS_CLIENT_SIDE, IS_SERVER_SIDE, getBuildInfo };
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Jest environment for end-to-end SSR and client-side testing. It relies on
|
|
3
|
+
* the standard react-utils mechanics to execute SSR of given scene, and also
|
|
4
|
+
* Webpack build of the code for client-side execution, it further exposes
|
|
5
|
+
* Jsdom environment for the client-side testing of the outcomes.
|
|
6
|
+
*/
|
|
7
|
+
import JsdomEnv from 'jest-environment-jsdom';
|
|
8
|
+
import webpack from 'webpack';
|
|
9
|
+
import type { EnvironmentContext, JestEnvironmentConfig } from '@jest/environment';
|
|
10
|
+
export default class E2eSsrEnv extends JsdomEnv {
|
|
11
|
+
pragmas: Record<string, string | string[]>;
|
|
12
|
+
ssrRequest: object;
|
|
13
|
+
rootDir: string;
|
|
14
|
+
testFolder: string;
|
|
15
|
+
withSsr: boolean;
|
|
16
|
+
webpackStats?: webpack.StatsCompilation;
|
|
17
|
+
/**
|
|
18
|
+
* Loads Webpack config, and exposes it to the environment via global
|
|
19
|
+
* webpackConfig object.
|
|
20
|
+
*/
|
|
21
|
+
loadWebpackConfig(): void;
|
|
22
|
+
/**
|
|
23
|
+
* Executes Webpack build.
|
|
24
|
+
* @return {Promise}
|
|
25
|
+
*/
|
|
26
|
+
runWebpack(): Promise<void>;
|
|
27
|
+
runSsr(): Promise<void>;
|
|
28
|
+
constructor(config: JestEnvironmentConfig, context: EnvironmentContext);
|
|
29
|
+
setup(): Promise<void>;
|
|
30
|
+
teardown(): Promise<void>;
|
|
31
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { type IFs } from 'memfs';
|
|
2
|
+
import webpack from 'webpack';
|
|
3
|
+
declare global {
|
|
4
|
+
interface Window {
|
|
5
|
+
ssrMarkup: string | undefined;
|
|
6
|
+
ssrStatus: number | undefined;
|
|
7
|
+
webpackConfig: webpack.Configuration | undefined;
|
|
8
|
+
webpackOutputFs: IFs;
|
|
9
|
+
webpackStats?: webpack.StatsCompilation;
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
export default function getGlobal(): Window;
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
/// <reference types="trusted-types" />
|
|
2
|
+
import { type ReactElement, type ReactNode } from 'react';
|
|
3
|
+
import TU, { act } from 'react-dom/test-utils';
|
|
4
|
+
import Renderer from 'react-test-renderer';
|
|
5
|
+
/**
|
|
6
|
+
* An alias for [act(..)](https://reactjs.org/docs/test-utils.html#act)
|
|
7
|
+
* from `react-dom/test-utils`.
|
|
8
|
+
* @param {function} action
|
|
9
|
+
*/
|
|
10
|
+
export { act };
|
|
11
|
+
export { default as getGlobal } from './global';
|
|
12
|
+
declare global {
|
|
13
|
+
var IS_REACT_ACT_ENVIRONMENT: boolean | undefined;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Tricks **react-utils** into thinking the test is running within client-side
|
|
17
|
+
* (browser) environment.
|
|
18
|
+
*/
|
|
19
|
+
export declare function mockClientSide(): void;
|
|
20
|
+
/**
|
|
21
|
+
* Reverts the effect of {@link module:JU.mockClientSide mockClientSide(..)}.
|
|
22
|
+
*/
|
|
23
|
+
export declare function unmockClientSide(): void;
|
|
24
|
+
/**
|
|
25
|
+
* Generates a mock UUID, or better said it determenistically transforms given
|
|
26
|
+
* `seed` number into a UUID-formatted string.
|
|
27
|
+
* @param {number} seed
|
|
28
|
+
* @return {string}
|
|
29
|
+
*/
|
|
30
|
+
export declare function getMockUuid(seed?: number): string;
|
|
31
|
+
/**
|
|
32
|
+
* Advances mock timers, and mock date by the specified time.
|
|
33
|
+
* @param {number} time Time step [ms].
|
|
34
|
+
* @returns {Promise} Wait for this to "jump after" any async code which should
|
|
35
|
+
* be executed because of the mock time movement.
|
|
36
|
+
*/
|
|
37
|
+
export declare function mockTimer(time: number): Promise<void>;
|
|
38
|
+
export type MountedSceneT = HTMLElement & {
|
|
39
|
+
destroy: () => void;
|
|
40
|
+
};
|
|
41
|
+
/**
|
|
42
|
+
* Mounts `scene` to the DOM, and returns the root scene element.
|
|
43
|
+
* @param scene
|
|
44
|
+
* @return Created container DOM element with destroy() function
|
|
45
|
+
* attached.
|
|
46
|
+
*/
|
|
47
|
+
export declare function mount(scene: ReactNode): MountedSceneT;
|
|
48
|
+
/**
|
|
49
|
+
* Renders provided ReactJS component into JSON representation of the component
|
|
50
|
+
* tree, using [`react-test-renderer`](https://www.npmjs.com/package/react-test-renderer).
|
|
51
|
+
* @param {object} component ReactJS component to render.
|
|
52
|
+
* @return {object} JSON representation of the rendered tree.
|
|
53
|
+
* @example
|
|
54
|
+
* import { JU } from '@dr.pogodin/react-utils';
|
|
55
|
+
* console.log(JU.render(<div>Example</div>));
|
|
56
|
+
*/
|
|
57
|
+
export declare function render(component: ReactElement): Renderer.ReactTestRendererJSON | Renderer.ReactTestRendererJSON[] | null;
|
|
58
|
+
/**
|
|
59
|
+
* Generates a shallow render of given ReactJS component, using
|
|
60
|
+
* [react-test-renderer/shallow](https://reactjs.org/docs/shallow-renderer.html)
|
|
61
|
+
* and returns the result.
|
|
62
|
+
* @param {object} component ReactJS component to render.
|
|
63
|
+
* @return {object} JSON representation of the shallow component's render tree.
|
|
64
|
+
*/
|
|
65
|
+
export declare function shallowRender(component: ReactElement): ReactElement<any, string | React.JSXElementConstructor<any>>;
|
|
66
|
+
/**
|
|
67
|
+
* Makes a shallow snapshot test of the given ReactJS component, and also
|
|
68
|
+
* returns JSON representation of the rendered component tree. Under the hood
|
|
69
|
+
* it uses {@link module:JU.shallowRender shallowRender(..)} to generate
|
|
70
|
+
* the render, then executes `expect(RENDER_RESULT).toMatchSnapshot()`,
|
|
71
|
+
* and finally returns the `RENDER_RESULT` to the caller.
|
|
72
|
+
* @param {object} component ReactJS component to render.
|
|
73
|
+
* @return {object} JSON representation of shallow render.
|
|
74
|
+
*/
|
|
75
|
+
export declare function shallowSnapshot(component: ReactElement): ReactElement<any, string | React.JSXElementConstructor<any>>;
|
|
76
|
+
/**
|
|
77
|
+
* Makes snapshot test of the given ReactJS component, and also returns JSON
|
|
78
|
+
* representation of the rendered component tree. Under the hood, it uses
|
|
79
|
+
* {@link module:JU.render render(..)} to render it, then executes
|
|
80
|
+
* `expect(RENDER_RESULT).toMatchSnapshot()`, and then returns `RENDER_RESULT`.
|
|
81
|
+
* @param {object} component ReactJS component to render.
|
|
82
|
+
* @return {object} JSON render of the component.
|
|
83
|
+
*/
|
|
84
|
+
export declare function snapshot(component: ReactElement): Renderer.ReactTestRendererJSON | Renderer.ReactTestRendererJSON[] | null;
|
|
85
|
+
export declare const simulate: typeof TU.Simulate;
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { type ComponentType, type ReactNode } from 'react';
|
|
2
|
+
import { type ChunkGroupsT } from './globalState';
|
|
3
|
+
/**
|
|
4
|
+
* Client-side only! Ensures all CSS stylesheets required for the specified
|
|
5
|
+
* code chunk are loaded into the document; loads the missing ones; and does
|
|
6
|
+
* simple reference counting to facilitate future clean-up.
|
|
7
|
+
* @param chunkName Chunk name.
|
|
8
|
+
* @param refCount
|
|
9
|
+
* @return Resolves once all pending stylesheets, necessary for
|
|
10
|
+
* the chunk, are either loaded, or failed to load.
|
|
11
|
+
*/
|
|
12
|
+
export declare function bookStyleSheets(chunkName: string, chunkGroups: ChunkGroupsT, refCount: boolean): Promise<void>;
|
|
13
|
+
/**
|
|
14
|
+
* Client-side only! Frees from the document all CSS stylesheets that are
|
|
15
|
+
* required by the specified chunk, and have reference counter equal to one
|
|
16
|
+
* (for chunks with larger reference counter values, it just decrements
|
|
17
|
+
* the reference counter).
|
|
18
|
+
* @param {string} chunkName
|
|
19
|
+
*/
|
|
20
|
+
export declare function freeStyleSheets(chunkName: string, chunkGroups: ChunkGroupsT): void;
|
|
21
|
+
type ComponentOrModule<PropsT> = ComponentType<PropsT> | {
|
|
22
|
+
default: ComponentType<PropsT>;
|
|
23
|
+
};
|
|
24
|
+
/**
|
|
25
|
+
* Given an async component retrieval function `getComponent()` it creates
|
|
26
|
+
* a special "code split" component, which uses <Suspense> to asynchronously
|
|
27
|
+
* load on demand the code required by `getComponent()`.
|
|
28
|
+
* @param options
|
|
29
|
+
* @param options.chunkName
|
|
30
|
+
* @param {function} options.getComponent
|
|
31
|
+
* @param {React.Element} [options.placeholder]
|
|
32
|
+
* @return {React.ElementType}
|
|
33
|
+
*/
|
|
34
|
+
export default function splitComponent<ComponentPropsT extends {
|
|
35
|
+
children?: ReactNode;
|
|
36
|
+
}>({ chunkName, getComponent, placeholder, }: {
|
|
37
|
+
chunkName: string;
|
|
38
|
+
getComponent: () => Promise<ComponentOrModule<ComponentPropsT>>;
|
|
39
|
+
placeholder?: ReactNode;
|
|
40
|
+
}): React.FunctionComponent<ComponentPropsT>;
|
|
41
|
+
export {};
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import dayjs from 'dayjs';
|
|
2
|
+
import { timer } from '@dr.pogodin/js-utils';
|
|
3
|
+
/**
|
|
4
|
+
* This react hook wraps Date.now() function in a SSR friendly way,
|
|
5
|
+
* ensuring that all calls to useCurrent() within the same render return
|
|
6
|
+
* exactly the same time (which is retrieved from Date.now() first, and
|
|
7
|
+
* then stored in the global state to be reused in all other calls), which
|
|
8
|
+
* is also passed and used in the first client side render, and then updated
|
|
9
|
+
* with a finite precision to avoid infinite re-rendering loops.
|
|
10
|
+
* @param [options] Optional settings.
|
|
11
|
+
* @param [options.globalStatePath="currentTime"] Global state path
|
|
12
|
+
* to keep the current time value.
|
|
13
|
+
* @param [options.precision= 5 * time.SEC_MS] Current time precision.
|
|
14
|
+
* The hook won't update the current time stored in the global state unless it
|
|
15
|
+
* is different from Date.now() result by this number (in milliseconds).
|
|
16
|
+
* Default to 5 seconds.
|
|
17
|
+
* @param [options.autorefresh=false] Set `true` to automatically
|
|
18
|
+
* refresh time stored in the global state with the given `precision` (and
|
|
19
|
+
* thus automatically re-rendering components dependent on this hook, or
|
|
20
|
+
* the global state with the period equal to the `precision`.
|
|
21
|
+
* @return Unix timestamp in milliseconds.
|
|
22
|
+
*/
|
|
23
|
+
export declare function useCurrent({ autorefresh, globalStatePath, precision, }?: {
|
|
24
|
+
autorefresh?: boolean | undefined;
|
|
25
|
+
globalStatePath?: string | undefined;
|
|
26
|
+
precision?: number | undefined;
|
|
27
|
+
}): number;
|
|
28
|
+
/**
|
|
29
|
+
* Wraps the standard Date.getTimezoneOffset() method in a SSR-friendly way.
|
|
30
|
+
* This hook retrieves the offset value at the client side and uses a cookie
|
|
31
|
+
* to pass it to the server in subsequent requests from that user. At the server
|
|
32
|
+
* side the value from cookie is used in renders and passed back to the client
|
|
33
|
+
* via the global state. Prior to the value being known (in the very first
|
|
34
|
+
* request from the user, when the cookie is still missing), zero value is used
|
|
35
|
+
* as the default value.
|
|
36
|
+
*
|
|
37
|
+
* @param {object} [options] Optional settings.
|
|
38
|
+
* @param {string} [options.cookieName="timezoneOffset"] Optional. The name of
|
|
39
|
+
* cookie to use to store the timezone offset. Defaults "timezoneOffset". Set
|
|
40
|
+
* to a falsy value to forbid using cookies altogether (in that case the hook
|
|
41
|
+
* will always return zero value at the server-side, and in the first render
|
|
42
|
+
* at the client-side).
|
|
43
|
+
* @param {string} [options.timezoneOffset="timezoneOffset"] Optional.
|
|
44
|
+
* The global state path to store the offset. Defaults "timezoneOffset".
|
|
45
|
+
* @return {number} Timezone offset.
|
|
46
|
+
*/
|
|
47
|
+
export declare function useTimezoneOffset({ cookieName, globalStatePath, }?: {
|
|
48
|
+
cookieName?: string | undefined;
|
|
49
|
+
globalStatePath?: string | undefined;
|
|
50
|
+
}): number;
|
|
51
|
+
declare const _default: typeof dayjs & {
|
|
52
|
+
DAY_MS: number;
|
|
53
|
+
HOUR_MS: number;
|
|
54
|
+
MIN_MS: number;
|
|
55
|
+
SEC_MS: number;
|
|
56
|
+
YEAR_MS: number;
|
|
57
|
+
now: () => number;
|
|
58
|
+
timer: typeof timer;
|
|
59
|
+
useCurrent: typeof useCurrent;
|
|
60
|
+
useTimezoneOffset: typeof useTimezoneOffset;
|
|
61
|
+
};
|
|
62
|
+
export default _default;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
/**
|
|
3
|
+
* Requires the specified module without including it into the bundle during
|
|
4
|
+
* Webpack build.
|
|
5
|
+
* @param modulePath
|
|
6
|
+
* @param [basePath]
|
|
7
|
+
* @return Required module.
|
|
8
|
+
*/
|
|
9
|
+
export declare function requireWeak(modulePath: string, basePath?: string): NodeJS.Module | null;
|
|
10
|
+
/**
|
|
11
|
+
* Resolves specified module path with help of Babel's module resolver.
|
|
12
|
+
* Yes, the function itself just returns its argument to the caller, but Babel
|
|
13
|
+
* is configured to resolve the first argument of resolveWeak(..) function, thus
|
|
14
|
+
* the result will be the resolved path.
|
|
15
|
+
* @param {string} modulePath
|
|
16
|
+
* @return {string} Absolute or relative path to the module.
|
|
17
|
+
*/
|
|
18
|
+
export declare function resolveWeak(modulePath: string): string;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const container: string;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const testClassName: string;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const testClassName: string;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const sampleClassName: string;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const navLink: string;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const container: string;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const container: string;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const container: string;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const container: string;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const container: string;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const testClassName: string;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const testClassName: string;
|