@dr.pogodin/react-utils 1.46.2 → 1.47.0-alpha.11
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 +1 -0
- package/babel.libweb.config.js +16 -0
- package/babel.module.config.js +11 -0
- package/bin/build.js +21 -11
- package/bin/setup.js +11 -9
- package/build/development/client/getInj.js +57 -44
- package/build/development/client/getInj.js.map +1 -1
- package/build/development/client/index.js +15 -21
- package/build/development/client/index.js.map +1 -1
- package/build/development/client/init.js +2 -6
- package/build/development/client/init.js.map +1 -1
- package/build/development/index.js +3 -177
- package/build/development/index.js.map +1 -1
- package/build/development/server/Cache.js +1 -8
- package/build/development/server/Cache.js.map +1 -1
- package/build/development/server/index.js +22 -45
- package/build/development/server/index.js.map +1 -1
- package/build/development/server/renderer.js +84 -86
- package/build/development/server/renderer.js.map +1 -1
- package/build/development/server/server.js +58 -60
- package/build/development/server/server.js.map +1 -1
- package/build/development/server/utils/errors.js +8 -31
- package/build/development/server/utils/errors.js.map +1 -1
- package/build/development/server/utils/index.js +2 -9
- package/build/development/server/utils/index.js.map +1 -1
- package/build/development/shared/components/Button/index.js +15 -22
- package/build/development/shared/components/Button/index.js.map +1 -1
- package/build/development/shared/components/Checkbox/index.js +14 -21
- package/build/development/shared/components/Checkbox/index.js.map +1 -1
- package/build/development/shared/components/GenericLink/index.js +9 -11
- package/build/development/shared/components/GenericLink/index.js.map +1 -1
- package/build/development/shared/components/Input/index.js +21 -27
- package/build/development/shared/components/Input/index.js.map +1 -1
- package/build/development/shared/components/Link.js +6 -13
- package/build/development/shared/components/Link.js.map +1 -1
- package/build/development/shared/components/Modal/index.js +24 -28
- package/build/development/shared/components/Modal/index.js.map +1 -1
- package/build/development/shared/components/NavLink.js +6 -13
- package/build/development/shared/components/NavLink.js.map +1 -1
- package/build/development/shared/components/PageLayout/index.js +13 -20
- package/build/development/shared/components/PageLayout/index.js.map +1 -1
- package/build/development/shared/components/TextArea/index.js +28 -31
- package/build/development/shared/components/TextArea/index.js.map +1 -1
- package/build/development/shared/components/Throbber/index.js +13 -20
- package/build/development/shared/components/Throbber/index.js.map +1 -1
- package/build/development/shared/components/WithTooltip/Tooltip.js +13 -18
- package/build/development/shared/components/WithTooltip/Tooltip.js.map +1 -1
- package/build/development/shared/components/WithTooltip/index.js +23 -30
- package/build/development/shared/components/WithTooltip/index.js.map +1 -1
- package/build/development/shared/components/YouTubeVideo/index.js +19 -26
- package/build/development/shared/components/YouTubeVideo/index.js.map +1 -1
- package/build/development/shared/components/index.js +16 -130
- package/build/development/shared/components/index.js.map +1 -1
- package/build/development/shared/components/selectors/CustomDropdown/Options/index.js +19 -20
- package/build/development/shared/components/selectors/CustomDropdown/Options/index.js.map +1 -1
- package/build/development/shared/components/selectors/CustomDropdown/index.js +35 -39
- package/build/development/shared/components/selectors/CustomDropdown/index.js.map +1 -1
- package/build/development/shared/components/selectors/NativeDropdown/index.js +31 -31
- package/build/development/shared/components/selectors/NativeDropdown/index.js.map +1 -1
- package/build/development/shared/components/selectors/Switch/index.js +19 -24
- package/build/development/shared/components/selectors/Switch/index.js.map +1 -1
- package/build/development/shared/components/selectors/common.js +1 -7
- package/build/development/shared/components/selectors/common.js.map +1 -1
- package/build/development/shared/components/selectors/index.js +3 -27
- package/build/development/shared/components/selectors/index.js.map +1 -1
- package/build/development/shared/utils/config.js +40 -21
- package/build/development/shared/utils/config.js.map +1 -1
- package/build/development/shared/utils/globalState.js +3 -8
- package/build/development/shared/utils/globalState.js.map +1 -1
- package/build/development/shared/utils/index.js +12 -89
- package/build/development/shared/utils/index.js.map +1 -1
- package/build/development/shared/utils/isomorphy/buildInfo.js +2 -9
- package/build/development/shared/utils/isomorphy/buildInfo.js.map +1 -1
- package/build/development/shared/utils/isomorphy/environment-check.js +2 -8
- package/build/development/shared/utils/isomorphy/environment-check.js.map +1 -1
- package/build/development/shared/utils/isomorphy/index.js +7 -32
- package/build/development/shared/utils/isomorphy/index.js.map +1 -1
- package/build/development/shared/utils/jest/E2eSsrEnv.js +34 -37
- package/build/development/shared/utils/jest/E2eSsrEnv.js.map +1 -1
- package/build/development/shared/utils/jest/global.js +1 -7
- package/build/development/shared/utils/jest/global.js.map +1 -1
- package/build/development/shared/utils/jest/index.js +20 -44
- package/build/development/shared/utils/jest/index.js.map +1 -1
- package/build/development/shared/utils/splitComponent.js +54 -45
- package/build/development/shared/utils/splitComponent.js.map +1 -1
- package/build/development/shared/utils/time.js +22 -31
- package/build/development/shared/utils/time.js.map +1 -1
- package/build/development/shared/utils/webpack.js +17 -16
- package/build/development/shared/utils/webpack.js.map +1 -1
- package/build/production/client/getInj.js +13 -11
- package/build/production/client/getInj.js.map +1 -1
- package/build/production/client/index.js +3 -3
- package/build/production/client/index.js.map +1 -1
- package/build/production/client/init.js +2 -2
- package/build/production/client/init.js.map +1 -1
- package/build/production/index.js +2 -3
- package/build/production/index.js.map +1 -1
- package/build/production/server/Cache.js +3 -3
- package/build/production/server/Cache.js.map +1 -1
- package/build/production/server/index.js +8 -8
- package/build/production/server/index.js.map +1 -1
- package/build/production/server/renderer.js +24 -25
- package/build/production/server/renderer.js.map +1 -1
- package/build/production/server/server.js +9 -11
- package/build/production/server/server.js.map +1 -1
- package/build/production/server/utils/errors.js +9 -9
- package/build/production/server/utils/errors.js.map +1 -1
- package/build/production/server/utils/index.js +2 -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 +1 -1
- package/build/production/shared/components/Checkbox/index.js.map +1 -1
- package/build/production/shared/components/GenericLink/index.js +4 -4
- package/build/production/shared/components/GenericLink/index.js.map +1 -1
- package/build/production/shared/components/Input/index.js +5 -5
- package/build/production/shared/components/Input/index.js.map +1 -1
- package/build/production/shared/components/Link.js +3 -3
- package/build/production/shared/components/Link.js.map +1 -1
- package/build/production/shared/components/Modal/index.js +7 -7
- package/build/production/shared/components/Modal/index.js.map +1 -1
- package/build/production/shared/components/NavLink.js +2 -2
- 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/TextArea/index.js +5 -5
- package/build/production/shared/components/TextArea/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 +4 -4
- package/build/production/shared/components/WithTooltip/Tooltip.js.map +1 -1
- package/build/production/shared/components/WithTooltip/index.js +4 -4
- package/build/production/shared/components/WithTooltip/index.js.map +1 -1
- package/build/production/shared/components/YouTubeVideo/index.js +4 -4
- package/build/production/shared/components/YouTubeVideo/index.js.map +1 -1
- package/build/production/shared/components/index.js +3 -1
- package/build/production/shared/components/index.js.map +1 -1
- package/build/production/shared/components/selectors/CustomDropdown/Options/index.js +2 -2
- package/build/production/shared/components/selectors/CustomDropdown/Options/index.js.map +1 -1
- package/build/production/shared/components/selectors/CustomDropdown/index.js +2 -2
- package/build/production/shared/components/selectors/CustomDropdown/index.js.map +1 -1
- package/build/production/shared/components/selectors/NativeDropdown/index.js +4 -4
- package/build/production/shared/components/selectors/NativeDropdown/index.js.map +1 -1
- package/build/production/shared/components/selectors/Switch/index.js +1 -1
- package/build/production/shared/components/selectors/Switch/index.js.map +1 -1
- package/build/production/shared/components/selectors/common.js +2 -2
- package/build/production/shared/components/selectors/common.js.map +1 -1
- package/build/production/shared/components/selectors/index.js +1 -1
- package/build/production/shared/components/selectors/index.js.map +1 -1
- package/build/production/shared/utils/config.js +8 -6
- package/build/production/shared/utils/config.js.map +1 -1
- package/build/production/shared/utils/globalState.js +2 -2
- package/build/production/shared/utils/globalState.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/isomorphy/buildInfo.js +3 -3
- package/build/production/shared/utils/isomorphy/buildInfo.js.map +1 -1
- package/build/production/shared/utils/isomorphy/environment-check.js +3 -3
- package/build/production/shared/utils/isomorphy/environment-check.js.map +1 -1
- package/build/production/shared/utils/isomorphy/index.js +4 -4
- package/build/production/shared/utils/isomorphy/index.js.map +1 -1
- package/build/production/shared/utils/jest/E2eSsrEnv.js +16 -15
- package/build/production/shared/utils/jest/E2eSsrEnv.js.map +1 -1
- package/build/production/shared/utils/jest/global.js +1 -1
- package/build/production/shared/utils/jest/global.js.map +1 -1
- package/build/production/shared/utils/jest/index.js +11 -11
- package/build/production/shared/utils/jest/index.js.map +1 -1
- package/build/production/shared/utils/splitComponent.js +11 -22
- package/build/production/shared/utils/splitComponent.js.map +1 -1
- package/build/production/shared/utils/time.js +3 -3
- package/build/production/shared/utils/time.js.map +1 -1
- package/build/production/shared/utils/webpack.js +6 -6
- package/build/production/shared/utils/webpack.js.map +1 -1
- package/build/types-code/client/getInj.d.ts +1 -2
- package/build/types-code/client/index.d.ts +1 -1
- package/build/types-code/index.d.ts +1 -7
- package/build/types-code/server/index.d.ts +6 -11
- package/build/types-code/server/utils/index.d.ts +1 -1
- package/build/types-code/shared/utils/config.d.ts +4 -2
- package/build/types-code/shared/utils/index.d.ts +2 -2
- package/build/types-code/shared/utils/splitComponent.d.ts +6 -4
- package/build/web/client/getInj.js +65 -0
- package/build/web/client/getInj.js.map +1 -0
- package/{src/client/index.tsx → build/web/client/index.js} +13 -24
- package/build/web/client/index.js.map +1 -0
- package/{src/client/init.ts → build/web/client/init.js} +9 -14
- package/build/web/client/init.js.map +1 -0
- package/build/web/index.js +11 -0
- package/build/web/index.js.map +1 -0
- package/{src/server/Cache.ts → build/web/server/Cache.js} +15 -22
- package/build/web/server/Cache.js.map +1 -0
- package/{src/server/index.ts → build/web/server/index.js} +32 -81
- package/build/web/server/index.js.map +1 -0
- package/{src/server/renderer.tsx → build/web/server/renderer.js} +188 -333
- package/build/web/server/renderer.js.map +1 -0
- package/{src/server/server.ts → build/web/server/server.js} +82 -182
- package/build/web/server/server.js.map +1 -0
- package/{src/server/utils/errors.ts → build/web/server/utils/errors.js} +6 -25
- package/build/web/server/utils/errors.js.map +1 -0
- package/build/web/server/utils/index.js +4 -0
- package/build/web/server/utils/index.js.map +1 -0
- package/build/web/shared/components/Button/index.js +90 -0
- package/build/web/shared/components/Button/index.js.map +1 -0
- package/build/web/shared/components/Checkbox/index.js +35 -0
- package/build/web/shared/components/Checkbox/index.js.map +1 -0
- package/{src/shared/components/GenericLink/index.tsx → build/web/shared/components/GenericLink/index.js} +44 -78
- package/build/web/shared/components/GenericLink/index.js.map +1 -0
- package/build/web/shared/components/Input/index.js +71 -0
- package/build/web/shared/components/Input/index.js.map +1 -0
- package/build/web/shared/components/Link.js +20 -0
- package/build/web/shared/components/Link.js.map +1 -0
- package/{src → build/web}/shared/components/Modal/base-theme.scss +1 -1
- package/build/web/shared/components/Modal/index.js +128 -0
- package/build/web/shared/components/Modal/index.js.map +1 -0
- package/build/web/shared/components/NavLink.js +13 -0
- package/build/web/shared/components/NavLink.js.map +1 -0
- package/{src → build/web}/shared/components/PageLayout/base-theme.scss +1 -1
- package/{src/shared/components/PageLayout/index.tsx → build/web/shared/components/PageLayout/index.js} +20 -33
- package/build/web/shared/components/PageLayout/index.js.map +1 -0
- package/build/web/shared/components/TextArea/index.js +106 -0
- package/build/web/shared/components/TextArea/index.js.map +1 -0
- package/build/web/shared/components/Throbber/index.js +26 -0
- package/build/web/shared/components/Throbber/index.js.map +1 -0
- package/{src/shared/components/WithTooltip/Tooltip.tsx → build/web/shared/components/WithTooltip/Tooltip.js} +61 -109
- package/build/web/shared/components/WithTooltip/Tooltip.js.map +1 -0
- package/build/web/shared/components/WithTooltip/index.js +117 -0
- package/build/web/shared/components/WithTooltip/index.js.map +1 -0
- package/{src/shared/components/YouTubeVideo/index.tsx → build/web/shared/components/YouTubeVideo/index.js} +23 -40
- package/build/web/shared/components/YouTubeVideo/index.js.map +1 -0
- package/build/web/shared/components/index.js +18 -0
- package/build/web/shared/components/index.js.map +1 -0
- package/build/web/shared/components/selectors/CustomDropdown/Options/index.js +82 -0
- package/build/web/shared/components/selectors/CustomDropdown/Options/index.js.map +1 -0
- package/{src/shared/components/selectors/CustomDropdown/index.tsx → build/web/shared/components/selectors/CustomDropdown/index.js} +56 -80
- package/build/web/shared/components/selectors/CustomDropdown/index.js.map +1 -0
- package/{src/shared/components/selectors/NativeDropdown/index.tsx → build/web/shared/components/selectors/NativeDropdown/index.js} +39 -44
- package/build/web/shared/components/selectors/NativeDropdown/index.js.map +1 -0
- package/build/web/shared/components/selectors/Switch/index.js +50 -0
- package/build/web/shared/components/selectors/Switch/index.js.map +1 -0
- package/build/web/shared/components/selectors/common.js +12 -0
- package/build/web/shared/components/selectors/common.js.map +1 -0
- package/build/web/shared/components/selectors/index.js +4 -0
- package/build/web/shared/components/selectors/index.js.map +1 -0
- package/build/web/shared/utils/config.js +45 -0
- package/build/web/shared/utils/config.js.map +1 -0
- package/build/web/shared/utils/globalState.js +15 -0
- package/build/web/shared/utils/globalState.js.map +1 -0
- package/build/web/shared/utils/index.js +13 -0
- package/build/web/shared/utils/index.js.map +1 -0
- package/{src/shared/utils/isomorphy/buildInfo.ts → build/web/shared/utils/isomorphy/buildInfo.js} +4 -10
- package/build/web/shared/utils/isomorphy/buildInfo.js.map +1 -0
- package/build/web/shared/utils/isomorphy/environment-check.js +17 -0
- package/build/web/shared/utils/isomorphy/environment-check.js.map +1 -0
- package/{src/shared/utils/isomorphy/index.ts → build/web/shared/utils/isomorphy/index.js} +6 -6
- package/build/web/shared/utils/isomorphy/index.js.map +1 -0
- package/{src/shared/utils/jest/E2eSsrEnv.ts → build/web/shared/utils/jest/E2eSsrEnv.js} +73 -140
- package/build/web/shared/utils/jest/E2eSsrEnv.js.map +1 -0
- package/build/web/shared/utils/jest/global.js +4 -0
- package/build/web/shared/utils/jest/global.js.map +1 -0
- package/{src/shared/utils/jest/index.ts → build/web/shared/utils/jest/index.js} +33 -83
- package/build/web/shared/utils/jest/index.js.map +1 -0
- package/{src/shared/utils/splitComponent.tsx → build/web/shared/utils/splitComponent.js} +77 -124
- package/build/web/shared/utils/splitComponent.js.map +1 -0
- package/{src/shared/utils/time.ts → build/web/shared/utils/time.js} +21 -37
- package/build/web/shared/utils/time.js.map +1 -0
- package/build/web/shared/utils/webpack.js +67 -0
- package/build/web/shared/utils/webpack.js.map +1 -0
- package/config/babel/node-ssr.js +12 -3
- package/config/babel/webpack.js +6 -1
- package/config/jest/default.js +8 -2
- package/config/jest/setup.js +8 -1
- package/config/webpack/app-base.js +25 -14
- package/config/webpack/app-development.js +2 -2
- package/config/webpack/lib-base.js +1 -2
- package/package.json +41 -42
- package/types.d.ts +1 -6
- package/build/development/__chunk_groups__.json +0 -6
- package/build/development/style.css +0 -909
- package/build/development/web.bundle.js +0 -752
- package/build/production/__chunk_groups__.json +0 -6
- package/build/production/style.css +0 -2
- package/build/production/style.css.map +0 -1
- package/build/production/web.bundle.js +0 -3
- package/build/production/web.bundle.js.LICENSE.txt +0 -9
- package/build/production/web.bundle.js.map +0 -1
- package/dev-styles.js +0 -1
- package/node-entry.js +0 -15
- package/null.js +0 -1
- package/prod-styles.js +0 -1
- package/src/client/getInj.ts +0 -51
- package/src/index.ts +0 -73
- package/src/server/utils/index.ts +0 -3
- package/src/shared/components/Button/index.tsx +0 -130
- package/src/shared/components/Checkbox/index.tsx +0 -53
- package/src/shared/components/Input/index.tsx +0 -96
- package/src/shared/components/Link.tsx +0 -25
- package/src/shared/components/Modal/index.tsx +0 -177
- package/src/shared/components/NavLink.tsx +0 -18
- package/src/shared/components/TextArea/index.tsx +0 -139
- package/src/shared/components/Throbber/index.tsx +0 -28
- package/src/shared/components/WithTooltip/index.tsx +0 -186
- package/src/shared/components/index.ts +0 -20
- package/src/shared/components/selectors/CustomDropdown/Options/index.tsx +0 -124
- package/src/shared/components/selectors/Switch/index.tsx +0 -74
- package/src/shared/components/selectors/common.ts +0 -57
- package/src/shared/components/selectors/index.ts +0 -8
- package/src/shared/utils/config.ts +0 -28
- package/src/shared/utils/globalState.ts +0 -44
- package/src/shared/utils/index.ts +0 -45
- package/src/shared/utils/isomorphy/environment-check.ts +0 -18
- package/src/shared/utils/jest/global.ts +0 -17
- package/src/shared/utils/webpack.ts +0 -74
- /package/{src → build/web}/shared/components/Button/style.scss +0 -0
- /package/{src → build/web}/shared/components/Checkbox/theme.scss +0 -0
- /package/{src → build/web}/shared/components/GenericLink/style.scss +0 -0
- /package/{src → build/web}/shared/components/Input/theme.scss +0 -0
- /package/{src → build/web}/shared/components/Modal/styles.scss +0 -0
- /package/{src → build/web}/shared/components/TextArea/style.scss +0 -0
- /package/{src → build/web}/shared/components/Throbber/theme.scss +0 -0
- /package/{src → build/web}/shared/components/WithTooltip/default-theme.scss +0 -0
- /package/{src → build/web}/shared/components/YouTubeVideo/base.scss +0 -0
- /package/{src → build/web}/shared/components/YouTubeVideo/throbber.scss +0 -0
- /package/{src → build/web}/shared/components/selectors/CustomDropdown/Options/style.scss +0 -0
- /package/{src → build/web}/shared/components/selectors/CustomDropdown/theme.scss +0 -0
- /package/{src → build/web}/shared/components/selectors/NativeDropdown/theme.scss +0 -0
- /package/{src → build/web}/shared/components/selectors/Switch/theme.scss +0 -0
- /package/{src → build/web}/styles/_global/reset.css +0 -0
- /package/{src → build/web}/styles/_mixins/fonts.scss +0 -0
- /package/{src → build/web}/styles/_mixins/media.scss +0 -0
- /package/{src → build/web}/styles/_mixins/typography.scss +0 -0
- /package/{src → build/web}/styles/global.scss +0 -0
- /package/{src → build/web}/styles/mixins.scss +0 -0
|
@@ -1,139 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
type ChangeEventHandler,
|
|
3
|
-
type FocusEventHandler,
|
|
4
|
-
type FunctionComponent,
|
|
5
|
-
type KeyboardEventHandler,
|
|
6
|
-
type ReactNode,
|
|
7
|
-
useEffect,
|
|
8
|
-
useLayoutEffect,
|
|
9
|
-
useRef,
|
|
10
|
-
useState,
|
|
11
|
-
} from 'react';
|
|
12
|
-
|
|
13
|
-
import themed, { type Theme } from '@dr.pogodin/react-themes';
|
|
14
|
-
|
|
15
|
-
import defaultTheme from './style.scss';
|
|
16
|
-
|
|
17
|
-
type ThemeKeyT = 'container' | 'error' | 'errorMessage' | 'hidden' | 'label'
|
|
18
|
-
| 'textarea';
|
|
19
|
-
|
|
20
|
-
type Props = {
|
|
21
|
-
disabled?: boolean;
|
|
22
|
-
error?: ReactNode;
|
|
23
|
-
label?: string;
|
|
24
|
-
onBlur?: FocusEventHandler<HTMLTextAreaElement>;
|
|
25
|
-
onChange?: ChangeEventHandler<HTMLTextAreaElement>;
|
|
26
|
-
onKeyDown?: KeyboardEventHandler<HTMLTextAreaElement>;
|
|
27
|
-
placeholder?: string;
|
|
28
|
-
testId?: string;
|
|
29
|
-
theme: Theme<ThemeKeyT>;
|
|
30
|
-
value?: string;
|
|
31
|
-
};
|
|
32
|
-
|
|
33
|
-
const TextArea: FunctionComponent<Props> = ({
|
|
34
|
-
disabled,
|
|
35
|
-
error,
|
|
36
|
-
label,
|
|
37
|
-
onBlur,
|
|
38
|
-
onChange,
|
|
39
|
-
onKeyDown,
|
|
40
|
-
placeholder,
|
|
41
|
-
testId,
|
|
42
|
-
theme,
|
|
43
|
-
value,
|
|
44
|
-
}) => {
|
|
45
|
-
const hiddenAreaRef = useRef<HTMLTextAreaElement>(null);
|
|
46
|
-
const [height, setHeight] = useState<number | undefined>();
|
|
47
|
-
|
|
48
|
-
const textAreaRef = useRef<HTMLTextAreaElement>(null);
|
|
49
|
-
|
|
50
|
-
const [localValue, setLocalValue] = useState(value ?? '');
|
|
51
|
-
if (value !== undefined && localValue !== value) setLocalValue(value);
|
|
52
|
-
|
|
53
|
-
// This resizes text area's height when its width is changed for any reason.
|
|
54
|
-
useEffect(() => {
|
|
55
|
-
const el = hiddenAreaRef.current;
|
|
56
|
-
if (!el) return undefined;
|
|
57
|
-
|
|
58
|
-
const cb = () => {
|
|
59
|
-
setHeight(el.scrollHeight);
|
|
60
|
-
};
|
|
61
|
-
const observer = new ResizeObserver(cb);
|
|
62
|
-
observer.observe(el);
|
|
63
|
-
|
|
64
|
-
return () => {
|
|
65
|
-
observer.disconnect();
|
|
66
|
-
};
|
|
67
|
-
}, []);
|
|
68
|
-
|
|
69
|
-
// Resizes the text area when its content is modified.
|
|
70
|
-
//
|
|
71
|
-
// NOTE: useLayoutEffect() instead of useEffect() makes difference here,
|
|
72
|
-
// as it helps to avoid visible "content/height" jumps (i.e. with just
|
|
73
|
-
// useEffect() it becomes visible how the content is modified first,
|
|
74
|
-
// and then input height is incremented, if necessary).
|
|
75
|
-
// See: https://github.com/birdofpreyru/react-utils/issues/313
|
|
76
|
-
useLayoutEffect(() => {
|
|
77
|
-
const el = hiddenAreaRef.current;
|
|
78
|
-
if (el) setHeight(el.scrollHeight);
|
|
79
|
-
}, [localValue]);
|
|
80
|
-
|
|
81
|
-
let containerClassName = theme.container;
|
|
82
|
-
if (error) containerClassName += ` ${theme.error}`;
|
|
83
|
-
|
|
84
|
-
return (
|
|
85
|
-
<div
|
|
86
|
-
className={containerClassName}
|
|
87
|
-
onFocus={() => {
|
|
88
|
-
textAreaRef.current?.focus();
|
|
89
|
-
}}
|
|
90
|
-
>
|
|
91
|
-
{label === undefined ? null : <div className={theme.label}>{label}</div>}
|
|
92
|
-
<textarea
|
|
93
|
-
className={`${theme.textarea} ${theme.hidden}`}
|
|
94
|
-
|
|
95
|
-
// This text area is hidden underneath the primary one below,
|
|
96
|
-
// and it is used for text measurements, to implement auto-scaling
|
|
97
|
-
// of the primary textarea's height.
|
|
98
|
-
readOnly
|
|
99
|
-
ref={hiddenAreaRef}
|
|
100
|
-
|
|
101
|
-
// The "-1" value of "tabIndex" removes this hidden text area from
|
|
102
|
-
// the tab-focus-chain.
|
|
103
|
-
tabIndex={-1}
|
|
104
|
-
|
|
105
|
-
// NOTE: With empty string value ("") the scrolling height of this text
|
|
106
|
-
// area is zero, thus collapsing <TextArea> height below the single line
|
|
107
|
-
// input height. To avoid it we fallback to whitespace (" ") character
|
|
108
|
-
// here.
|
|
109
|
-
value={localValue || ' '}
|
|
110
|
-
/>
|
|
111
|
-
<textarea
|
|
112
|
-
className={theme.textarea}
|
|
113
|
-
data-testid={process.env.NODE_ENV === 'production' ? undefined : testId}
|
|
114
|
-
disabled={disabled}
|
|
115
|
-
onBlur={onBlur}
|
|
116
|
-
|
|
117
|
-
// When value is "undefined" the text area is not-managed, and we should
|
|
118
|
-
// manage it internally for the measurement / resizing functionality
|
|
119
|
-
// to work.
|
|
120
|
-
onChange={
|
|
121
|
-
value === undefined
|
|
122
|
-
? (e) => {
|
|
123
|
-
setLocalValue(e.target.value);
|
|
124
|
-
} : onChange
|
|
125
|
-
}
|
|
126
|
-
onKeyDown={onKeyDown}
|
|
127
|
-
placeholder={placeholder}
|
|
128
|
-
ref={textAreaRef}
|
|
129
|
-
style={{ height }}
|
|
130
|
-
value={localValue}
|
|
131
|
-
/>
|
|
132
|
-
{error && error !== true
|
|
133
|
-
? <div className={theme.errorMessage}>{error}</div>
|
|
134
|
-
: null}
|
|
135
|
-
</div>
|
|
136
|
-
);
|
|
137
|
-
};
|
|
138
|
-
|
|
139
|
-
export default themed(TextArea, 'TextArea', defaultTheme);
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import themed, { type Theme } from '@dr.pogodin/react-themes';
|
|
2
|
-
|
|
3
|
-
import defaultTheme from './theme.scss';
|
|
4
|
-
|
|
5
|
-
type ThemeKeyT = 'bouncing' | 'circle' | 'container';
|
|
6
|
-
|
|
7
|
-
type PropsT = {
|
|
8
|
-
theme: Theme<ThemeKeyT>;
|
|
9
|
-
};
|
|
10
|
-
|
|
11
|
-
/**
|
|
12
|
-
* Throbber is an "action in progress" indicator, which renders
|
|
13
|
-
* three bouncing circles as a simple pending activity indicator,
|
|
14
|
-
* and can be further themed to a certain degree.
|
|
15
|
-
* @param {object} [props] Component properties.
|
|
16
|
-
* @param {ThrobberTheme} [props.theme] _Ad hoc_ theme.
|
|
17
|
-
* @param {...any} [props....]
|
|
18
|
-
* [Other theming properties](https://www.npmjs.com/package/@dr.pogodin/react-themes#themed-component-properties)
|
|
19
|
-
*/
|
|
20
|
-
const Throbber: React.FunctionComponent<PropsT> = ({ theme }) => (
|
|
21
|
-
<span className={theme.container}>
|
|
22
|
-
<span className={theme.circle} />
|
|
23
|
-
<span className={theme.circle} />
|
|
24
|
-
<span className={theme.circle} />
|
|
25
|
-
</span>
|
|
26
|
-
);
|
|
27
|
-
|
|
28
|
-
export default themed(Throbber, 'Throbber', defaultTheme);
|
|
@@ -1,186 +0,0 @@
|
|
|
1
|
-
/* global window */
|
|
2
|
-
|
|
3
|
-
import {
|
|
4
|
-
type FunctionComponent,
|
|
5
|
-
type ReactNode,
|
|
6
|
-
useEffect,
|
|
7
|
-
useRef,
|
|
8
|
-
useState,
|
|
9
|
-
} from 'react';
|
|
10
|
-
|
|
11
|
-
import themed, { type Theme } from '@dr.pogodin/react-themes';
|
|
12
|
-
|
|
13
|
-
import Tooltip, {
|
|
14
|
-
type ThemeKeysT as TooltipThemeKeysT,
|
|
15
|
-
PLACEMENTS,
|
|
16
|
-
} from './Tooltip';
|
|
17
|
-
|
|
18
|
-
import defaultTheme from './default-theme.scss';
|
|
19
|
-
|
|
20
|
-
type PropsT = {
|
|
21
|
-
children?: ReactNode;
|
|
22
|
-
placement?: PLACEMENTS;
|
|
23
|
-
tip?: ReactNode;
|
|
24
|
-
theme: Theme<'wrapper' | TooltipThemeKeysT>;
|
|
25
|
-
};
|
|
26
|
-
|
|
27
|
-
type TooltipRefT = {
|
|
28
|
-
pointTo: (
|
|
29
|
-
x: number,
|
|
30
|
-
y: number,
|
|
31
|
-
placement: PLACEMENTS,
|
|
32
|
-
wrapperRef: HTMLDivElement,
|
|
33
|
-
) => void;
|
|
34
|
-
};
|
|
35
|
-
|
|
36
|
-
type HeapT = {
|
|
37
|
-
lastCursorX: number;
|
|
38
|
-
lastCursorY: number;
|
|
39
|
-
triggeredByTouch: boolean;
|
|
40
|
-
timerId?: NodeJS.Timeout;
|
|
41
|
-
};
|
|
42
|
-
|
|
43
|
-
/**
|
|
44
|
-
* Implements a simple to use and themeable tooltip component, _e.g._
|
|
45
|
-
* ```js
|
|
46
|
-
* <WithTooltip tip="This is example tooltip.">
|
|
47
|
-
* <p>Hover to see the tooltip.</p>
|
|
48
|
-
* </WithTooltip>
|
|
49
|
-
* ```
|
|
50
|
-
* **Children:** Children are rendered in the place of `<WithTooltip>`,
|
|
51
|
-
* and when hovered the tooltip is shown. By default the wrapper itself is
|
|
52
|
-
* `<div>` block with `display: inline-block`.
|
|
53
|
-
* @param tip – Anything React is able to render,
|
|
54
|
-
* _e.g._ a tooltip text. This will be the tooltip content.
|
|
55
|
-
* @param {WithTooltipTheme} props.theme _Ad hoc_ theme.
|
|
56
|
-
*/
|
|
57
|
-
const Wrapper: FunctionComponent<PropsT> = ({
|
|
58
|
-
children,
|
|
59
|
-
placement = PLACEMENTS.ABOVE_CURSOR,
|
|
60
|
-
tip,
|
|
61
|
-
theme,
|
|
62
|
-
}) => {
|
|
63
|
-
const { current: heap } = useRef<HeapT>({
|
|
64
|
-
lastCursorX: 0,
|
|
65
|
-
lastCursorY: 0,
|
|
66
|
-
timerId: undefined,
|
|
67
|
-
triggeredByTouch: false,
|
|
68
|
-
});
|
|
69
|
-
const tooltipRef = useRef<TooltipRefT>(null);
|
|
70
|
-
const wrapperRef = useRef<HTMLDivElement>(null);
|
|
71
|
-
const [showTooltip, setShowTooltip] = useState(false);
|
|
72
|
-
|
|
73
|
-
const updatePortalPosition = (cursorX: number, cursorY: number) => {
|
|
74
|
-
if (showTooltip) {
|
|
75
|
-
const wrapperRect = wrapperRef.current!.getBoundingClientRect();
|
|
76
|
-
if (
|
|
77
|
-
cursorX < wrapperRect.left
|
|
78
|
-
|| cursorX > wrapperRect.right
|
|
79
|
-
|| cursorY < wrapperRect.top
|
|
80
|
-
|| cursorY > wrapperRect.bottom
|
|
81
|
-
) {
|
|
82
|
-
setShowTooltip(false);
|
|
83
|
-
} else if (tooltipRef.current) {
|
|
84
|
-
tooltipRef.current.pointTo(
|
|
85
|
-
cursorX + window.scrollX,
|
|
86
|
-
cursorY + window.scrollY,
|
|
87
|
-
placement,
|
|
88
|
-
wrapperRef.current!,
|
|
89
|
-
);
|
|
90
|
-
}
|
|
91
|
-
} else {
|
|
92
|
-
heap.lastCursorX = cursorX;
|
|
93
|
-
heap.lastCursorY = cursorY;
|
|
94
|
-
|
|
95
|
-
// If tooltip was triggered by a touch, we delay its opening by a bit,
|
|
96
|
-
// to ensure it was not a touch-click - in the case of touch click we
|
|
97
|
-
// want to do the click, rather than show the tooltip, and the delay
|
|
98
|
-
// gives click handler a chance to abort the tooltip openning.
|
|
99
|
-
if (heap.triggeredByTouch) {
|
|
100
|
-
heap.timerId ??= setTimeout(() => {
|
|
101
|
-
heap.triggeredByTouch = false;
|
|
102
|
-
heap.timerId = undefined;
|
|
103
|
-
setShowTooltip(true);
|
|
104
|
-
}, 300);
|
|
105
|
-
|
|
106
|
-
// Otherwise we can just open the tooltip right away.
|
|
107
|
-
} else setShowTooltip(true);
|
|
108
|
-
}
|
|
109
|
-
};
|
|
110
|
-
|
|
111
|
-
useEffect(() => {
|
|
112
|
-
if (showTooltip && tip !== null) {
|
|
113
|
-
// This is necessary to ensure that even when a single mouse event
|
|
114
|
-
// arrives to a tool-tipped component, the tooltip is correctly positioned
|
|
115
|
-
// once opened (because similar call above does not have effect until
|
|
116
|
-
// the tooltip is fully mounted, and that is delayed to future rendering
|
|
117
|
-
// cycle due to the implementation).
|
|
118
|
-
if (tooltipRef.current) {
|
|
119
|
-
tooltipRef.current.pointTo(
|
|
120
|
-
heap.lastCursorX + window.scrollX,
|
|
121
|
-
heap.lastCursorY + window.scrollY,
|
|
122
|
-
placement,
|
|
123
|
-
wrapperRef.current!,
|
|
124
|
-
);
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
const listener = () => {
|
|
128
|
-
setShowTooltip(false);
|
|
129
|
-
};
|
|
130
|
-
window.addEventListener('scroll', listener);
|
|
131
|
-
return () => {
|
|
132
|
-
window.removeEventListener('scroll', listener);
|
|
133
|
-
};
|
|
134
|
-
}
|
|
135
|
-
return undefined;
|
|
136
|
-
}, [
|
|
137
|
-
heap.lastCursorX,
|
|
138
|
-
heap.lastCursorY,
|
|
139
|
-
placement,
|
|
140
|
-
showTooltip,
|
|
141
|
-
tip,
|
|
142
|
-
]);
|
|
143
|
-
|
|
144
|
-
return (
|
|
145
|
-
<div
|
|
146
|
-
className={theme.wrapper}
|
|
147
|
-
onClick={() => {
|
|
148
|
-
if (heap.timerId) {
|
|
149
|
-
clearTimeout(heap.timerId);
|
|
150
|
-
heap.timerId = undefined;
|
|
151
|
-
heap.triggeredByTouch = false;
|
|
152
|
-
}
|
|
153
|
-
}}
|
|
154
|
-
onMouseLeave={() => {
|
|
155
|
-
setShowTooltip(false);
|
|
156
|
-
}}
|
|
157
|
-
onMouseMove={(e) => {
|
|
158
|
-
updatePortalPosition(e.clientX, e.clientY);
|
|
159
|
-
}}
|
|
160
|
-
onTouchStart={() => {
|
|
161
|
-
heap.triggeredByTouch = true;
|
|
162
|
-
}}
|
|
163
|
-
ref={wrapperRef}
|
|
164
|
-
role="presentation"
|
|
165
|
-
>
|
|
166
|
-
{
|
|
167
|
-
showTooltip && tip !== null
|
|
168
|
-
? <Tooltip ref={tooltipRef} theme={theme}>{tip}</Tooltip>
|
|
169
|
-
: null
|
|
170
|
-
}
|
|
171
|
-
{children}
|
|
172
|
-
</div>
|
|
173
|
-
);
|
|
174
|
-
};
|
|
175
|
-
|
|
176
|
-
const ThemedWrapper = themed(Wrapper, 'WithTooltip', defaultTheme);
|
|
177
|
-
|
|
178
|
-
type ExportT = typeof ThemedWrapper & {
|
|
179
|
-
PLACEMENTS: typeof PLACEMENTS;
|
|
180
|
-
};
|
|
181
|
-
|
|
182
|
-
const e: ExportT = ThemedWrapper as ExportT;
|
|
183
|
-
|
|
184
|
-
e.PLACEMENTS = PLACEMENTS;
|
|
185
|
-
|
|
186
|
-
export default e;
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Just an aggregation of all exported components into a single module.
|
|
3
|
-
*/
|
|
4
|
-
|
|
5
|
-
export { MetaTags } from '@dr.pogodin/react-helmet';
|
|
6
|
-
|
|
7
|
-
export * from 'components/selectors';
|
|
8
|
-
|
|
9
|
-
export { default as Button, BaseButton } from 'components/Button';
|
|
10
|
-
export { default as Checkbox } from 'components/Checkbox';
|
|
11
|
-
export { default as Input } from 'components/Input';
|
|
12
|
-
export { default as Link } from 'components/Link';
|
|
13
|
-
export { default as PageLayout } from 'components/PageLayout';
|
|
14
|
-
export { default as Modal, BaseModal } from 'components/Modal';
|
|
15
|
-
export { default as NavLink } from 'components/NavLink';
|
|
16
|
-
export { default as Throbber } from 'components/Throbber';
|
|
17
|
-
export { default as WithTooltip } from 'components/WithTooltip';
|
|
18
|
-
export { default as YouTubeVideo } from 'components/YouTubeVideo';
|
|
19
|
-
|
|
20
|
-
export { default as TextArea } from './TextArea';
|
|
@@ -1,124 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
type FunctionComponent,
|
|
3
|
-
type ReactNode,
|
|
4
|
-
type RefObject,
|
|
5
|
-
useImperativeHandle,
|
|
6
|
-
useRef,
|
|
7
|
-
} from 'react';
|
|
8
|
-
|
|
9
|
-
import { BaseModal } from 'components/Modal';
|
|
10
|
-
|
|
11
|
-
import {
|
|
12
|
-
type OptionT,
|
|
13
|
-
type OptionsT,
|
|
14
|
-
type ValueT,
|
|
15
|
-
optionValueName,
|
|
16
|
-
} from '../../common';
|
|
17
|
-
|
|
18
|
-
import S from './style.scss';
|
|
19
|
-
|
|
20
|
-
export type ContainerPosT = {
|
|
21
|
-
left: number;
|
|
22
|
-
top: number;
|
|
23
|
-
width: number;
|
|
24
|
-
};
|
|
25
|
-
|
|
26
|
-
export function areEqual(a?: ContainerPosT, b?: ContainerPosT): boolean {
|
|
27
|
-
return a?.left === b?.left && a?.top === b?.top && a?.width === b?.width;
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
export type RefT = {
|
|
31
|
-
measure: () => DOMRect | undefined;
|
|
32
|
-
};
|
|
33
|
-
|
|
34
|
-
type PropsT = {
|
|
35
|
-
containerClass: string;
|
|
36
|
-
containerStyle?: ContainerPosT;
|
|
37
|
-
filter?: (item: OptionT<ReactNode> | ValueT) => boolean;
|
|
38
|
-
optionClass: string;
|
|
39
|
-
options: Readonly<OptionsT<ReactNode>>;
|
|
40
|
-
onCancel: () => void;
|
|
41
|
-
onChange: (value: ValueT) => void;
|
|
42
|
-
ref?: RefObject<RefT | null>;
|
|
43
|
-
};
|
|
44
|
-
|
|
45
|
-
const Options: FunctionComponent<PropsT> = ({
|
|
46
|
-
containerClass,
|
|
47
|
-
containerStyle,
|
|
48
|
-
filter,
|
|
49
|
-
onCancel,
|
|
50
|
-
onChange,
|
|
51
|
-
optionClass,
|
|
52
|
-
options,
|
|
53
|
-
ref,
|
|
54
|
-
}) => {
|
|
55
|
-
const opsRef = useRef<HTMLDivElement>(null);
|
|
56
|
-
|
|
57
|
-
useImperativeHandle(ref, () => ({
|
|
58
|
-
measure: () => {
|
|
59
|
-
const e = opsRef.current?.parentElement;
|
|
60
|
-
if (!e) return undefined;
|
|
61
|
-
|
|
62
|
-
const rect = opsRef.current!.getBoundingClientRect();
|
|
63
|
-
const style = window.getComputedStyle(e);
|
|
64
|
-
const mBottom = parseFloat(style.marginBottom);
|
|
65
|
-
const mTop = parseFloat(style.marginTop);
|
|
66
|
-
|
|
67
|
-
rect.height += mBottom + mTop;
|
|
68
|
-
|
|
69
|
-
return rect;
|
|
70
|
-
},
|
|
71
|
-
}), []);
|
|
72
|
-
|
|
73
|
-
const optionNodes: ReactNode[] = [];
|
|
74
|
-
for (const option of options) {
|
|
75
|
-
if (!filter || filter(option)) {
|
|
76
|
-
const [iValue, iName] = optionValueName(option);
|
|
77
|
-
optionNodes.push(
|
|
78
|
-
<div
|
|
79
|
-
className={optionClass}
|
|
80
|
-
key={iValue}
|
|
81
|
-
onClick={(e) => {
|
|
82
|
-
onChange(iValue);
|
|
83
|
-
e.stopPropagation();
|
|
84
|
-
}}
|
|
85
|
-
onKeyDown={(e) => {
|
|
86
|
-
if (e.key === 'Enter') {
|
|
87
|
-
onChange(iValue);
|
|
88
|
-
e.stopPropagation();
|
|
89
|
-
}
|
|
90
|
-
}}
|
|
91
|
-
role="button"
|
|
92
|
-
tabIndex={0}
|
|
93
|
-
>
|
|
94
|
-
{iName}
|
|
95
|
-
</div>,
|
|
96
|
-
);
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
return (
|
|
101
|
-
<BaseModal
|
|
102
|
-
// Closes the dropdown (cancels the selection) on any page scrolling attempt.
|
|
103
|
-
// This is the same native <select> elements do on scrolling, and at least for
|
|
104
|
-
// now we have no reason to deal with complications needed to support open
|
|
105
|
-
// dropdowns during the scrolling (that would need to re-position it in
|
|
106
|
-
// response to the position changes of the root dropdown element).
|
|
107
|
-
cancelOnScrolling
|
|
108
|
-
dontDisableScrolling
|
|
109
|
-
onCancel={onCancel}
|
|
110
|
-
style={containerStyle}
|
|
111
|
-
theme={{
|
|
112
|
-
ad: '',
|
|
113
|
-
container: containerClass,
|
|
114
|
-
context: '',
|
|
115
|
-
hoc: '',
|
|
116
|
-
overlay: S.overlay,
|
|
117
|
-
}}
|
|
118
|
-
>
|
|
119
|
-
<div ref={opsRef}>{optionNodes}</div>
|
|
120
|
-
</BaseModal>
|
|
121
|
-
);
|
|
122
|
-
};
|
|
123
|
-
|
|
124
|
-
export default Options;
|
|
@@ -1,74 +0,0 @@
|
|
|
1
|
-
import themed, { type Theme } from '@dr.pogodin/react-themes';
|
|
2
|
-
|
|
3
|
-
import {
|
|
4
|
-
type OptionsT,
|
|
5
|
-
type ValueT,
|
|
6
|
-
optionValueName,
|
|
7
|
-
} from '../common';
|
|
8
|
-
|
|
9
|
-
import defaultTheme from './theme.scss';
|
|
10
|
-
|
|
11
|
-
type ThemeKeyT = 'container' | 'label' | 'option' | 'options' | 'selected';
|
|
12
|
-
|
|
13
|
-
type PropsT = {
|
|
14
|
-
label?: React.ReactNode;
|
|
15
|
-
onChange?: (value: ValueT) => void;
|
|
16
|
-
options?: Readonly<OptionsT<React.ReactNode>>;
|
|
17
|
-
theme: Theme<ThemeKeyT>;
|
|
18
|
-
value?: ValueT;
|
|
19
|
-
};
|
|
20
|
-
|
|
21
|
-
const BaseSwitch: React.FunctionComponent<PropsT> = ({
|
|
22
|
-
label,
|
|
23
|
-
onChange,
|
|
24
|
-
options,
|
|
25
|
-
theme,
|
|
26
|
-
value,
|
|
27
|
-
}) => {
|
|
28
|
-
if (!options || !theme.option) throw Error('Internal error');
|
|
29
|
-
|
|
30
|
-
const optionNodes: React.ReactNode[] = [];
|
|
31
|
-
for (const option of options) {
|
|
32
|
-
const [iValue, iName] = optionValueName(option);
|
|
33
|
-
|
|
34
|
-
let className: string = theme.option;
|
|
35
|
-
let onPress: (() => void) | undefined;
|
|
36
|
-
if (iValue === value) className += ` ${theme.selected}`;
|
|
37
|
-
else if (onChange) {
|
|
38
|
-
onPress = () => {
|
|
39
|
-
onChange(iValue);
|
|
40
|
-
};
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
optionNodes.push(
|
|
44
|
-
onPress
|
|
45
|
-
? (
|
|
46
|
-
<div
|
|
47
|
-
className={className}
|
|
48
|
-
key={iValue}
|
|
49
|
-
onClick={onPress}
|
|
50
|
-
onKeyDown={(e) => {
|
|
51
|
-
if (e.key === 'Enter') onPress();
|
|
52
|
-
}}
|
|
53
|
-
role="button"
|
|
54
|
-
tabIndex={0}
|
|
55
|
-
>
|
|
56
|
-
{iName}
|
|
57
|
-
</div>
|
|
58
|
-
)
|
|
59
|
-
: <div className={className} key={iValue}>{iName}</div>,
|
|
60
|
-
);
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
return (
|
|
64
|
-
<div className={theme.container}>
|
|
65
|
-
{label ? <div className={theme.label}>{label}</div> : null}
|
|
66
|
-
|
|
67
|
-
<div className={theme.options}>
|
|
68
|
-
{optionNodes}
|
|
69
|
-
</div>
|
|
70
|
-
</div>
|
|
71
|
-
);
|
|
72
|
-
};
|
|
73
|
-
|
|
74
|
-
export default themed(BaseSwitch, 'Switch', defaultTheme);
|
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
// The stuff common between different dropdown implementations.
|
|
2
|
-
|
|
3
|
-
import type { Theme } from '@dr.pogodin/react-themes';
|
|
4
|
-
|
|
5
|
-
type ThemeKeyT = 'active'
|
|
6
|
-
| 'arrow'
|
|
7
|
-
| 'container'
|
|
8
|
-
| 'dropdown'
|
|
9
|
-
| 'hiddenOption'
|
|
10
|
-
| 'label'
|
|
11
|
-
| 'option'
|
|
12
|
-
| 'select'
|
|
13
|
-
|
|
14
|
-
// TODO: This is currently only valid for (native) <Dropdown>,
|
|
15
|
-
// other kinds of selectors should be evaluated, and aligned with this
|
|
16
|
-
// feature, if appropriate.
|
|
17
|
-
| 'invalid'
|
|
18
|
-
|
|
19
|
-
// TODO: This is only valid for <CustomDropdown>, thus we need to re-factor it
|
|
20
|
-
// into a separate theme spec for that component.
|
|
21
|
-
| 'upward';
|
|
22
|
-
|
|
23
|
-
export type ValueT = number | string;
|
|
24
|
-
|
|
25
|
-
export type OptionT<NameT> = {
|
|
26
|
-
name?: NameT | null;
|
|
27
|
-
value: ValueT;
|
|
28
|
-
};
|
|
29
|
-
|
|
30
|
-
export type OptionsT<NameT> = Readonly<Array<OptionT<NameT> | ValueT>>;
|
|
31
|
-
|
|
32
|
-
export type PropsT<
|
|
33
|
-
NameT,
|
|
34
|
-
OnChangeT = React.ChangeEventHandler<HTMLSelectElement>,
|
|
35
|
-
> = {
|
|
36
|
-
filter?: (item: OptionT<NameT> | ValueT) => boolean;
|
|
37
|
-
label?: React.ReactNode;
|
|
38
|
-
onChange?: OnChangeT;
|
|
39
|
-
options: Readonly<OptionsT<NameT>>;
|
|
40
|
-
testId?: string;
|
|
41
|
-
theme: Theme<ThemeKeyT>;
|
|
42
|
-
value?: ValueT;
|
|
43
|
-
};
|
|
44
|
-
|
|
45
|
-
function isValue<T>(x: OptionT<T> | ValueT): x is ValueT {
|
|
46
|
-
const type = typeof x;
|
|
47
|
-
return type === 'number' || type === 'string';
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
/** Returns option value and name as a tuple. */
|
|
51
|
-
export function optionValueName<NameT>(
|
|
52
|
-
option: OptionT<NameT> | ValueT,
|
|
53
|
-
): [ValueT, NameT | ValueT] {
|
|
54
|
-
return isValue(option)
|
|
55
|
-
? [option, option]
|
|
56
|
-
: [option.value, option.name ?? option.value];
|
|
57
|
-
}
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
/* global document */
|
|
2
|
-
|
|
3
|
-
import type CookieM from 'cookie';
|
|
4
|
-
|
|
5
|
-
import { IS_CLIENT_SIDE } from './isomorphy/environment-check';
|
|
6
|
-
import { requireWeak } from './webpack';
|
|
7
|
-
|
|
8
|
-
// TODO: The internal type casting is somewhat messed up here,
|
|
9
|
-
// to be corrected later.
|
|
10
|
-
const config: Record<string, unknown> = (
|
|
11
|
-
IS_CLIENT_SIDE
|
|
12
|
-
// eslint-disable-next-line @typescript-eslint/no-require-imports
|
|
13
|
-
? (require('client/getInj') as {
|
|
14
|
-
default: () => Record<string, unknown>;
|
|
15
|
-
}).default().CONFIG
|
|
16
|
-
: requireWeak('config')
|
|
17
|
-
) as (Record<string, unknown> | undefined) ?? ({} as Record<string, unknown>);
|
|
18
|
-
|
|
19
|
-
// The safeguard for "document" is necessary because in non-Node environments,
|
|
20
|
-
// like React Native, IS_CLIENT_SIDE is "true", however "document" and a bunch
|
|
21
|
-
// of other browser-world features are not available.
|
|
22
|
-
if (IS_CLIENT_SIDE && typeof document !== 'undefined') {
|
|
23
|
-
// eslint-disable-next-line @typescript-eslint/no-require-imports
|
|
24
|
-
const cookie = require('cookie') as typeof CookieM;
|
|
25
|
-
config.CSRF = cookie.parse(document.cookie).csrfToken;
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
export default config;
|