@dr.pogodin/react-utils 1.47.0-alpha.1 → 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 -1
- package/babel.module.config.js +11 -0
- package/bin/build.js +8 -4
- package/bin/setup.js +2 -3
- 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 -183
- 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 -50
- package/build/development/server/index.js.map +1 -1
- package/build/development/server/renderer.js +83 -92
- package/build/development/server/renderer.js.map +1 -1
- package/build/development/server/server.js +58 -62
- 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 +9 -16
- package/build/development/shared/components/Button/index.js.map +1 -1
- package/build/development/shared/components/Checkbox/index.js +6 -13
- package/build/development/shared/components/Checkbox/index.js.map +1 -1
- package/build/development/shared/components/GenericLink/index.js +4 -10
- package/build/development/shared/components/GenericLink/index.js.map +1 -1
- package/build/development/shared/components/Input/index.js +11 -18
- 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 +16 -22
- 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 +7 -14
- package/build/development/shared/components/PageLayout/index.js.map +1 -1
- package/build/development/shared/components/TextArea/index.js +15 -22
- package/build/development/shared/components/TextArea/index.js.map +1 -1
- package/build/development/shared/components/Throbber/index.js +7 -14
- package/build/development/shared/components/Throbber/index.js.map +1 -1
- package/build/development/shared/components/WithTooltip/Tooltip.js +12 -18
- package/build/development/shared/components/WithTooltip/Tooltip.js.map +1 -1
- package/build/development/shared/components/WithTooltip/index.js +16 -23
- package/build/development/shared/components/WithTooltip/index.js.map +1 -1
- package/build/development/shared/components/YouTubeVideo/index.js +10 -17
- 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 +18 -19
- package/build/development/shared/components/selectors/CustomDropdown/Options/index.js.map +1 -1
- package/build/development/shared/components/selectors/CustomDropdown/index.js +24 -28
- package/build/development/shared/components/selectors/CustomDropdown/index.js.map +1 -1
- package/build/development/shared/components/selectors/NativeDropdown/index.js +19 -19
- package/build/development/shared/components/selectors/NativeDropdown/index.js.map +1 -1
- package/build/development/shared/components/selectors/Switch/index.js +12 -17
- 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 +24 -31
- 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 -46
- 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 -6
- 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 +14 -14
- 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 +55 -44
- package/build/web/client/getInj.js.map +1 -1
- package/build/web/client/index.js +15 -21
- package/build/web/client/index.js.map +1 -1
- package/build/web/client/init.js +2 -4
- package/build/web/client/init.js.map +1 -1
- package/build/web/index.js +1 -15
- package/build/web/index.js.map +1 -1
- package/build/web/server/index.js +12 -21
- package/build/web/server/index.js.map +1 -1
- package/build/web/server/renderer.js +34 -40
- package/build/web/server/renderer.js.map +1 -1
- package/build/web/server/server.js +14 -11
- package/build/web/server/server.js.map +1 -1
- package/build/web/server/utils/index.js +1 -1
- package/build/web/server/utils/index.js.map +1 -1
- package/build/web/shared/components/Button/index.js +1 -1
- package/build/web/shared/components/Button/index.js.map +1 -1
- package/build/web/shared/components/Checkbox/index.js +1 -1
- package/build/web/shared/components/Checkbox/index.js.map +1 -1
- package/build/web/shared/components/Input/index.js +1 -1
- package/build/web/shared/components/Input/index.js.map +1 -1
- package/build/web/shared/components/Modal/index.js +3 -3
- package/build/web/shared/components/Modal/index.js.map +1 -1
- package/build/web/shared/components/PageLayout/index.js +1 -1
- package/build/web/shared/components/PageLayout/index.js.map +1 -1
- package/build/web/shared/components/TextArea/index.js +1 -1
- package/build/web/shared/components/TextArea/index.js.map +1 -1
- package/build/web/shared/components/Throbber/index.js +1 -1
- package/build/web/shared/components/Throbber/index.js.map +1 -1
- package/build/web/shared/components/WithTooltip/index.js +1 -1
- package/build/web/shared/components/WithTooltip/index.js.map +1 -1
- package/build/web/shared/components/YouTubeVideo/index.js +1 -1
- package/build/web/shared/components/YouTubeVideo/index.js.map +1 -1
- package/build/web/shared/components/selectors/CustomDropdown/Options/index.js +3 -0
- package/build/web/shared/components/selectors/CustomDropdown/Options/index.js.map +1 -1
- package/build/web/shared/components/selectors/CustomDropdown/index.js +3 -1
- package/build/web/shared/components/selectors/CustomDropdown/index.js.map +1 -1
- package/build/web/shared/components/selectors/NativeDropdown/index.js +4 -1
- package/build/web/shared/components/selectors/NativeDropdown/index.js.map +1 -1
- package/build/web/shared/components/selectors/Switch/index.js +2 -1
- package/build/web/shared/components/selectors/Switch/index.js.map +1 -1
- package/build/web/shared/utils/config.js +38 -14
- package/build/web/shared/utils/config.js.map +1 -1
- package/build/web/shared/utils/index.js +2 -2
- package/build/web/shared/utils/index.js.map +1 -1
- package/build/web/shared/utils/jest/E2eSsrEnv.js +3 -2
- package/build/web/shared/utils/jest/E2eSsrEnv.js.map +1 -1
- package/build/web/shared/utils/splitComponent.js +27 -20
- package/build/web/shared/utils/splitComponent.js.map +1 -1
- package/build/web/shared/utils/webpack.js +13 -7
- package/build/web/shared/utils/webpack.js.map +1 -1
- package/config/babel/node-ssr.js +12 -6
- 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 +23 -15
- package/config/webpack/app-development.js +2 -3
- package/config/webpack/lib-base.js +1 -2
- package/package.json +35 -25
- package/types.d.ts +1 -6
- package/node-entry.js +0 -15
- package/src/client/getInj.ts +0 -51
- package/src/client/index.tsx +0 -43
- package/src/client/init.ts +0 -52
- package/src/index.ts +0 -79
- package/src/server/Cache.ts +0 -61
- package/src/server/index.ts +0 -249
- package/src/server/renderer.tsx +0 -653
- package/src/server/server.ts +0 -332
- package/src/server/utils/errors.ts +0 -122
- package/src/server/utils/index.ts +0 -3
- package/src/shared/components/Button/index.tsx +0 -130
- package/src/shared/components/Button/style.scss +0 -54
- package/src/shared/components/Checkbox/index.tsx +0 -53
- package/src/shared/components/Checkbox/theme.scss +0 -63
- package/src/shared/components/GenericLink/index.tsx +0 -141
- package/src/shared/components/GenericLink/style.scss +0 -3
- package/src/shared/components/Input/index.tsx +0 -96
- package/src/shared/components/Input/theme.scss +0 -52
- package/src/shared/components/Link.tsx +0 -25
- package/src/shared/components/Modal/base-theme.scss +0 -38
- package/src/shared/components/Modal/index.tsx +0 -177
- package/src/shared/components/Modal/styles.scss +0 -3
- package/src/shared/components/NavLink.tsx +0 -18
- package/src/shared/components/PageLayout/base-theme.scss +0 -30
- package/src/shared/components/PageLayout/index.tsx +0 -51
- package/src/shared/components/TextArea/index.tsx +0 -139
- package/src/shared/components/TextArea/style.scss +0 -68
- package/src/shared/components/Throbber/index.tsx +0 -28
- package/src/shared/components/Throbber/theme.scss +0 -26
- package/src/shared/components/WithTooltip/Tooltip.tsx +0 -274
- package/src/shared/components/WithTooltip/default-theme.scss +0 -36
- package/src/shared/components/WithTooltip/index.tsx +0 -186
- package/src/shared/components/YouTubeVideo/base.scss +0 -15
- package/src/shared/components/YouTubeVideo/index.tsx +0 -73
- package/src/shared/components/YouTubeVideo/throbber.scss +0 -11
- package/src/shared/components/index.ts +0 -20
- package/src/shared/components/selectors/CustomDropdown/Options/index.tsx +0 -124
- package/src/shared/components/selectors/CustomDropdown/Options/style.scss +0 -6
- package/src/shared/components/selectors/CustomDropdown/index.tsx +0 -146
- package/src/shared/components/selectors/CustomDropdown/theme.scss +0 -118
- package/src/shared/components/selectors/NativeDropdown/index.tsx +0 -90
- package/src/shared/components/selectors/NativeDropdown/theme.scss +0 -81
- package/src/shared/components/selectors/Switch/index.tsx +0 -74
- package/src/shared/components/selectors/Switch/theme.scss +0 -39
- 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/buildInfo.ts +0 -50
- package/src/shared/utils/isomorphy/environment-check.ts +0 -18
- package/src/shared/utils/isomorphy/index.ts +0 -36
- package/src/shared/utils/jest/E2eSsrEnv.ts +0 -305
- package/src/shared/utils/jest/global.ts +0 -17
- package/src/shared/utils/jest/index.ts +0 -215
- package/src/shared/utils/splitComponent.tsx +0 -275
- package/src/shared/utils/time.ts +0 -101
- package/src/shared/utils/webpack.ts +0 -74
- package/src/styles/_global/reset.css +0 -52
- package/src/styles/_mixins/fonts.scss +0 -40
- package/src/styles/_mixins/media.scss +0 -150
- package/src/styles/_mixins/typography.scss +0 -83
- package/src/styles/global.scss +0 -11
- package/src/styles/mixins.scss +0 -6
|
@@ -1,90 +0,0 @@
|
|
|
1
|
-
// Implements dropdown based on the native HTML <select> element.
|
|
2
|
-
|
|
3
|
-
import themed from '@dr.pogodin/react-themes';
|
|
4
|
-
|
|
5
|
-
import { type PropsT, optionValueName } from '../common';
|
|
6
|
-
|
|
7
|
-
import defaultTheme from './theme.scss';
|
|
8
|
-
|
|
9
|
-
/**
|
|
10
|
-
* Implements a themeable dropdown list. Internally it is rendered with help of
|
|
11
|
-
* the standard HTML `<select>` element, thus the styling support is somewhat
|
|
12
|
-
* limited.
|
|
13
|
-
* @param [props] Component properties.
|
|
14
|
-
* @param [props.filter] Options filter function. If provided, only
|
|
15
|
-
* those elements of `options` list will be used by the dropdown, for which this
|
|
16
|
-
* filter returns `true`.
|
|
17
|
-
* @param [props.label] Dropdown label.
|
|
18
|
-
* @param [props.onChange] Selection event handler.
|
|
19
|
-
* @param [props.options=[]] Array of dropdown
|
|
20
|
-
* options. For string elements the option value and name will be the same.
|
|
21
|
-
* It is allowed to mix DropdownOption and string elements in the same option
|
|
22
|
-
* list.
|
|
23
|
-
* @param [props.theme] _Ad hoc_ theme.
|
|
24
|
-
* @param [props.value] Currently selected value.
|
|
25
|
-
* @param [props....]
|
|
26
|
-
* [Other theming properties](https://www.npmjs.com/package/@dr.pogodin/react-themes#themed-component-properties)
|
|
27
|
-
*/
|
|
28
|
-
const Dropdown: React.FunctionComponent<PropsT<string>> = ({
|
|
29
|
-
filter,
|
|
30
|
-
label,
|
|
31
|
-
onChange,
|
|
32
|
-
options,
|
|
33
|
-
testId,
|
|
34
|
-
theme,
|
|
35
|
-
value,
|
|
36
|
-
}) => {
|
|
37
|
-
let isValidValue = false;
|
|
38
|
-
const optionElements = [];
|
|
39
|
-
|
|
40
|
-
for (const option of options) {
|
|
41
|
-
if (!filter || filter(option)) {
|
|
42
|
-
const [iValue, iName] = optionValueName(option);
|
|
43
|
-
isValidValue ||= iValue === value;
|
|
44
|
-
optionElements.push(
|
|
45
|
-
<option className={theme.option} key={iValue} value={iValue}>
|
|
46
|
-
{iName}
|
|
47
|
-
</option>,
|
|
48
|
-
);
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
// NOTE: This element represents the current `value` when it does not match
|
|
53
|
-
// any valid option. In Chrome, and some other browsers, we are able to hide
|
|
54
|
-
// it from the opened dropdown; in others, e.g. Safari, the best we can do is
|
|
55
|
-
// to show it as disabled.
|
|
56
|
-
const hiddenOption = isValidValue ? null : (
|
|
57
|
-
<option
|
|
58
|
-
className={theme.hiddenOption}
|
|
59
|
-
disabled
|
|
60
|
-
key="__reactUtilsHiddenOption"
|
|
61
|
-
value={value}
|
|
62
|
-
>
|
|
63
|
-
{value}
|
|
64
|
-
</option>
|
|
65
|
-
);
|
|
66
|
-
|
|
67
|
-
let selectClassName = theme.select;
|
|
68
|
-
if (!isValidValue) selectClassName += ` ${theme.invalid}`;
|
|
69
|
-
|
|
70
|
-
return (
|
|
71
|
-
<div className={theme.container}>
|
|
72
|
-
{ label === undefined
|
|
73
|
-
? null : <div className={theme.label}>{label}</div> }
|
|
74
|
-
<div className={theme.dropdown}>
|
|
75
|
-
<select
|
|
76
|
-
className={selectClassName}
|
|
77
|
-
data-testid={process.env.NODE_ENV === 'production' ? undefined : testId}
|
|
78
|
-
onChange={onChange}
|
|
79
|
-
value={value}
|
|
80
|
-
>
|
|
81
|
-
{hiddenOption}
|
|
82
|
-
{optionElements}
|
|
83
|
-
</select>
|
|
84
|
-
<div className={theme.arrow} />
|
|
85
|
-
</div>
|
|
86
|
-
</div>
|
|
87
|
-
);
|
|
88
|
-
};
|
|
89
|
-
|
|
90
|
-
export default themed(Dropdown, 'Dropdown', defaultTheme);
|
|
@@ -1,81 +0,0 @@
|
|
|
1
|
-
*,
|
|
2
|
-
.context,
|
|
3
|
-
.ad.hoc {
|
|
4
|
-
&.dropdown {
|
|
5
|
-
display: flex;
|
|
6
|
-
flex: 1;
|
|
7
|
-
min-width: 5.5em;
|
|
8
|
-
overflow: hidden;
|
|
9
|
-
position: relative;
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
&.arrow {
|
|
13
|
-
background-image: linear-gradient(to top, lightgray, white 50%, white);
|
|
14
|
-
border: 1px solid gray;
|
|
15
|
-
border-radius: 0 0.3em 0.3em 0;
|
|
16
|
-
bottom: 0;
|
|
17
|
-
padding: 0.3em 0.6em;
|
|
18
|
-
pointer-events: none;
|
|
19
|
-
position: absolute;
|
|
20
|
-
right: 0;
|
|
21
|
-
top: 0;
|
|
22
|
-
|
|
23
|
-
&::after {
|
|
24
|
-
content: '▼';
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
&.container {
|
|
29
|
-
align-items: center;
|
|
30
|
-
display: inline-flex;
|
|
31
|
-
margin: 0.1em;
|
|
32
|
-
position: relative;
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
.active + &.arrow,
|
|
36
|
-
:active + &.arrow {
|
|
37
|
-
background-image: linear-gradient(to bottom, lightgray, white 50%, white);
|
|
38
|
-
border-bottom-right-radius: 0;
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
:focus + &.arrow {
|
|
42
|
-
border-color: blue;
|
|
43
|
-
border-left-color: gray;
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
&.label {
|
|
47
|
-
margin: 0 0.6em 0 1.5em;
|
|
48
|
-
pointer-events: none;
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
&.option { color: black; }
|
|
52
|
-
&.hiddenOption { display: none; }
|
|
53
|
-
|
|
54
|
-
&.select {
|
|
55
|
-
appearance: none;
|
|
56
|
-
background: white;
|
|
57
|
-
border: 1px solid gray;
|
|
58
|
-
border-radius: 0.3em;
|
|
59
|
-
color: inherit;
|
|
60
|
-
cursor: pointer;
|
|
61
|
-
display: inline-block;
|
|
62
|
-
flex: 1;
|
|
63
|
-
font: inherit;
|
|
64
|
-
max-width: 100%;
|
|
65
|
-
outline: none;
|
|
66
|
-
padding: 0.3em 3.3em calc(0.3em + 1px) 1.2em;
|
|
67
|
-
|
|
68
|
-
&:active {
|
|
69
|
-
background: white;
|
|
70
|
-
border-bottom-left-radius: 0;
|
|
71
|
-
border-bottom-right-radius: 0;
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
&:focus {
|
|
75
|
-
border-color: blue;
|
|
76
|
-
box-shadow: 0 0 3px 1px lightblue;
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
&.invalid { color: gray; }
|
|
80
|
-
}
|
|
81
|
-
}
|
|
@@ -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,39 +0,0 @@
|
|
|
1
|
-
*,
|
|
2
|
-
.context,
|
|
3
|
-
.ad.hoc {
|
|
4
|
-
&.container {
|
|
5
|
-
align-items: center;
|
|
6
|
-
display: flex;
|
|
7
|
-
gap: 0.6em;
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
&.option {
|
|
11
|
-
border: 1px solid transparent;
|
|
12
|
-
border-radius: 0.3em;
|
|
13
|
-
cursor: pointer;
|
|
14
|
-
outline: none;
|
|
15
|
-
padding: 0 0.9em;
|
|
16
|
-
|
|
17
|
-
&:focus {
|
|
18
|
-
border-color: blue;
|
|
19
|
-
box-shadow: 0 0 3px 1px lightblue;
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
&.selected {
|
|
24
|
-
border: 1px solid gray;
|
|
25
|
-
background: white;
|
|
26
|
-
cursor: default;
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
&.options {
|
|
30
|
-
align-items: center;
|
|
31
|
-
background: whitesmoke;
|
|
32
|
-
border: 1px solid gray;
|
|
33
|
-
border-radius: 0.3em;
|
|
34
|
-
display: flex;
|
|
35
|
-
gap: 0.3em;
|
|
36
|
-
padding: 0.3em;
|
|
37
|
-
user-select: none;
|
|
38
|
-
}
|
|
39
|
-
}
|
|
@@ -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;
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
import type { Request } from 'express';
|
|
2
|
-
|
|
3
|
-
import { type SsrContext, withGlobalStateType } from '@dr.pogodin/react-global-state';
|
|
4
|
-
|
|
5
|
-
/** Mapping "chunkName" > array of asset paths. */
|
|
6
|
-
export type ChunkGroupsT = Record<string, string[]>;
|
|
7
|
-
|
|
8
|
-
// The type of data object injected by server into generated markup.
|
|
9
|
-
export type InjT = {
|
|
10
|
-
CHUNK_GROUPS?: ChunkGroupsT;
|
|
11
|
-
CONFIG?: Record<string, unknown>;
|
|
12
|
-
ISTATE?: unknown;
|
|
13
|
-
};
|
|
14
|
-
|
|
15
|
-
declare global {
|
|
16
|
-
// eslint-disable-next-line @typescript-eslint/consistent-type-definitions
|
|
17
|
-
interface Window {
|
|
18
|
-
REACT_UTILS_INJECTION?: InjT;
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
// TODO: Not 100% sure now, whether it indeed can be replaced by type,
|
|
23
|
-
// or do we really need it to be an interface. Keeping the interface for now.
|
|
24
|
-
// eslint-disable-next-line @typescript-eslint/consistent-type-definitions
|
|
25
|
-
export interface SsrContextT<StateT> extends SsrContext<StateT> {
|
|
26
|
-
chunkGroups: ChunkGroupsT;
|
|
27
|
-
chunks: string[];
|
|
28
|
-
|
|
29
|
-
/** If set at the end of SSR, the rendered will trigger
|
|
30
|
-
* server-side redirect to this URL (and use the status
|
|
31
|
-
* code). */
|
|
32
|
-
redirectTo?: string;
|
|
33
|
-
|
|
34
|
-
req: Request;
|
|
35
|
-
status: number;
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
const {
|
|
39
|
-
getSsrContext,
|
|
40
|
-
} = withGlobalStateType<unknown, SsrContextT<unknown>>();
|
|
41
|
-
|
|
42
|
-
export {
|
|
43
|
-
getSsrContext,
|
|
44
|
-
};
|
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
import themedImpl, {
|
|
2
|
-
COMPOSE,
|
|
3
|
-
PRIORITY,
|
|
4
|
-
type Theme,
|
|
5
|
-
ThemeProvider,
|
|
6
|
-
} from '@dr.pogodin/react-themes';
|
|
7
|
-
|
|
8
|
-
import config from './config';
|
|
9
|
-
import * as isomorphy from './isomorphy';
|
|
10
|
-
import time from './time';
|
|
11
|
-
import * as webpack from './webpack';
|
|
12
|
-
|
|
13
|
-
export {
|
|
14
|
-
assertEmptyObject,
|
|
15
|
-
type Listener,
|
|
16
|
-
type ObjectKey,
|
|
17
|
-
Barrier,
|
|
18
|
-
Cached,
|
|
19
|
-
Emitter,
|
|
20
|
-
Semaphore,
|
|
21
|
-
withRetries,
|
|
22
|
-
} from '@dr.pogodin/js-utils';
|
|
23
|
-
|
|
24
|
-
export { getSsrContext } from './globalState';
|
|
25
|
-
export { default as splitComponent } from './splitComponent';
|
|
26
|
-
|
|
27
|
-
type ThemedT = typeof themedImpl & {
|
|
28
|
-
COMPOSE: typeof COMPOSE;
|
|
29
|
-
PRIORITY: typeof PRIORITY;
|
|
30
|
-
};
|
|
31
|
-
|
|
32
|
-
const themed: ThemedT = themedImpl as ThemedT;
|
|
33
|
-
|
|
34
|
-
themed.COMPOSE = COMPOSE;
|
|
35
|
-
themed.PRIORITY = PRIORITY;
|
|
36
|
-
|
|
37
|
-
export {
|
|
38
|
-
type Theme,
|
|
39
|
-
config,
|
|
40
|
-
isomorphy,
|
|
41
|
-
themed,
|
|
42
|
-
ThemeProvider,
|
|
43
|
-
time,
|
|
44
|
-
webpack,
|
|
45
|
-
};
|
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
// Encapsulates access to "Build Info" data.
|
|
2
|
-
|
|
3
|
-
// BEWARE: This should match the type of build info object generated by
|
|
4
|
-
// Webpack build (see "/config/webpack/app-base.js"), and currently this
|
|
5
|
-
// match is not checked automatically.
|
|
6
|
-
export type BuildInfoT = {
|
|
7
|
-
key: string;
|
|
8
|
-
publicPath: string;
|
|
9
|
-
timestamp: string;
|
|
10
|
-
useServiceWorker: boolean;
|
|
11
|
-
};
|
|
12
|
-
|
|
13
|
-
// Depending on the build mode & environment, BUILD_INFO is either a global
|
|
14
|
-
// variable defined at the app launch, or it is replaced by the actual value
|
|
15
|
-
// by the Webpack build.
|
|
16
|
-
declare const BUILD_INFO: BuildInfoT | undefined;
|
|
17
|
-
|
|
18
|
-
let buildInfo: BuildInfoT | undefined;
|
|
19
|
-
|
|
20
|
-
// On the client side "BUILD_INFO" should be injected by Webpack. Note, however,
|
|
21
|
-
// that in test environment we may need situations were environment is mocked as
|
|
22
|
-
// client-side, although no proper Webpack compilation is executed, thus no info
|
|
23
|
-
// injected; because of this we don't do a hard environment check here.
|
|
24
|
-
if (typeof BUILD_INFO !== 'undefined') buildInfo = BUILD_INFO;
|
|
25
|
-
|
|
26
|
-
/**
|
|
27
|
-
* In scenarious where "BUILD_INFO" is not injected by Webpack (server-side,
|
|
28
|
-
* tests, etc.) we expect the host codebase to explicitly set it before it is
|
|
29
|
-
* ever requested. As a precaution, this function throws if build info has been
|
|
30
|
-
* set already, unless `force` flag is explicitly set.
|
|
31
|
-
* @param info
|
|
32
|
-
* @param force
|
|
33
|
-
*/
|
|
34
|
-
export function setBuildInfo(info?: BuildInfoT, force = false): void {
|
|
35
|
-
if (buildInfo !== undefined && !force) {
|
|
36
|
-
throw Error('"Build Info" is already initialized');
|
|
37
|
-
}
|
|
38
|
-
buildInfo = info;
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
/**
|
|
42
|
-
* Returns "Build Info" object; throws if it has not been initialized yet.
|
|
43
|
-
* @returns
|
|
44
|
-
*/
|
|
45
|
-
export function getBuildInfo(): BuildInfoT {
|
|
46
|
-
if (buildInfo === undefined) {
|
|
47
|
-
throw Error('"Build Info" has not been initialized yet');
|
|
48
|
-
}
|
|
49
|
-
return buildInfo;
|
|
50
|
-
}
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
// Checks for client- vs. server-side environment detection.
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* `true` within client-side environment (browser), `false` at server-side.
|
|
5
|
-
*/
|
|
6
|
-
export const IS_CLIENT_SIDE: boolean = typeof process !== 'object'
|
|
7
|
-
// NOTE: Because in this case we assume the host environment might be partially
|
|
8
|
-
// polyfilled to emulate some Node interfaces, thus it might have global `process`
|
|
9
|
-
// object, but without `versions` sub-object inside it.
|
|
10
|
-
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
|
|
11
|
-
|| !process.versions?.node
|
|
12
|
-
|| !!global.REACT_UTILS_FORCE_CLIENT_SIDE
|
|
13
|
-
|| typeof REACT_UTILS_WEBPACK_BUNDLE !== 'undefined';
|
|
14
|
-
|
|
15
|
-
/**
|
|
16
|
-
* `true` within the server-side environment (node), `false` at client-side.
|
|
17
|
-
*/
|
|
18
|
-
export const IS_SERVER_SIDE: boolean = !IS_CLIENT_SIDE;
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
import { getBuildInfo } from './buildInfo';
|
|
2
|
-
import { IS_CLIENT_SIDE, IS_SERVER_SIDE } from './environment-check';
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* @ignore
|
|
6
|
-
* @return {string} Code mode: "development" or "production".
|
|
7
|
-
*/
|
|
8
|
-
function getMode() {
|
|
9
|
-
return process.env.NODE_ENV;
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
/**
|
|
13
|
-
* Returns `true` if development version of the code is running;
|
|
14
|
-
* `false` otherwise.
|
|
15
|
-
*/
|
|
16
|
-
export function isDevBuild(): boolean {
|
|
17
|
-
return getMode() === 'development';
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
/**
|
|
21
|
-
* Returns `true` if production build of the code is running;
|
|
22
|
-
* `false` otherwise.
|
|
23
|
-
*/
|
|
24
|
-
export function isProdBuild(): boolean {
|
|
25
|
-
return getMode() === 'production';
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
/**
|
|
29
|
-
* Returns build timestamp of the front-end JS bundle.
|
|
30
|
-
* @return ISO date/time string.
|
|
31
|
-
*/
|
|
32
|
-
export function buildTimestamp(): string {
|
|
33
|
-
return getBuildInfo().timestamp;
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
export { IS_CLIENT_SIDE, IS_SERVER_SIDE, getBuildInfo };
|