@dr.pogodin/react-utils 1.30.2 → 1.31.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (140) hide show
  1. package/bin/build.js +5 -0
  2. package/build/development/client/index.js +1 -1
  3. package/build/development/client/index.js.map +1 -1
  4. package/build/development/index.js +8 -1
  5. package/build/development/index.js.map +1 -1
  6. package/build/development/server/index.js +1 -1
  7. package/build/development/server/index.js.map +1 -1
  8. package/build/development/server/utils/index.js +1 -1
  9. package/build/development/shared/components/Checkbox/index.js +2 -2
  10. package/build/development/shared/components/Checkbox/index.js.map +1 -1
  11. package/build/development/shared/components/Input/index.js +2 -2
  12. package/build/development/shared/components/Input/index.js.map +1 -1
  13. package/build/development/shared/components/Modal/index.js +40 -5
  14. package/build/development/shared/components/Modal/index.js.map +1 -1
  15. package/build/development/shared/components/TextArea/index.js +5 -0
  16. package/build/development/shared/components/TextArea/index.js.map +1 -1
  17. package/build/development/shared/components/WithTooltip/index.js +1 -1
  18. package/build/development/shared/components/WithTooltip/index.js.map +1 -1
  19. package/build/development/shared/components/YouTubeVideo/index.js +1 -3
  20. package/build/development/shared/components/YouTubeVideo/index.js.map +1 -1
  21. package/build/development/shared/components/index.js +28 -15
  22. package/build/development/shared/components/index.js.map +1 -1
  23. package/build/development/shared/components/selectors/CustomDropdown/Options/index.js +85 -0
  24. package/build/development/shared/components/selectors/CustomDropdown/Options/index.js.map +1 -0
  25. package/build/development/shared/components/selectors/CustomDropdown/index.js +105 -0
  26. package/build/development/shared/components/selectors/CustomDropdown/index.js.map +1 -0
  27. package/build/development/shared/components/{Dropdown → selectors/NativeDropdown}/index.js +25 -34
  28. package/build/development/shared/components/selectors/NativeDropdown/index.js.map +1 -0
  29. package/build/development/shared/components/selectors/Switch/index.js +76 -0
  30. package/build/development/shared/components/selectors/Switch/index.js.map +1 -0
  31. package/build/development/shared/components/selectors/common.js +24 -0
  32. package/build/development/shared/components/selectors/common.js.map +1 -0
  33. package/build/development/shared/components/selectors/index.js +28 -0
  34. package/build/development/shared/components/selectors/index.js.map +1 -0
  35. package/build/development/shared/utils/index.js +1 -1
  36. package/build/development/shared/utils/index.js.map +1 -1
  37. package/build/development/shared/utils/jest/E2eSsrEnv.js +3 -0
  38. package/build/development/shared/utils/jest/E2eSsrEnv.js.map +1 -1
  39. package/build/development/shared/utils/jest/index.js +1 -1
  40. package/build/development/shared/utils/jest/index.js.map +1 -1
  41. package/build/development/style.css +387 -225
  42. package/build/development/web.bundle.js +113 -53
  43. package/build/production/client/index.js +1 -1
  44. package/build/production/client/index.js.map +1 -1
  45. package/build/production/index.js +1 -1
  46. package/build/production/index.js.map +1 -1
  47. package/build/production/server/index.js +1 -1
  48. package/build/production/server/index.js.map +1 -1
  49. package/build/production/server/utils/index.js +1 -1
  50. package/build/production/shared/components/Checkbox/index.js +2 -2
  51. package/build/production/shared/components/Checkbox/index.js.map +1 -1
  52. package/build/production/shared/components/Input/index.js +1 -1
  53. package/build/production/shared/components/Input/index.js.map +1 -1
  54. package/build/production/shared/components/Modal/index.js +4 -2
  55. package/build/production/shared/components/Modal/index.js.map +1 -1
  56. package/build/production/shared/components/TextArea/index.js +3 -3
  57. package/build/production/shared/components/TextArea/index.js.map +1 -1
  58. package/build/production/shared/components/WithTooltip/index.js +1 -1
  59. package/build/production/shared/components/WithTooltip/index.js.map +1 -1
  60. package/build/production/shared/components/YouTubeVideo/index.js +2 -2
  61. package/build/production/shared/components/YouTubeVideo/index.js.map +1 -1
  62. package/build/production/shared/components/index.js +1 -1
  63. package/build/production/shared/components/index.js.map +1 -1
  64. package/build/production/shared/components/selectors/CustomDropdown/Options/index.js +7 -0
  65. package/build/production/shared/components/selectors/CustomDropdown/Options/index.js.map +1 -0
  66. package/build/production/shared/components/selectors/CustomDropdown/index.js +4 -0
  67. package/build/production/shared/components/selectors/CustomDropdown/index.js.map +1 -0
  68. package/build/production/shared/components/selectors/NativeDropdown/index.js +25 -0
  69. package/build/production/shared/components/selectors/NativeDropdown/index.js.map +1 -0
  70. package/build/production/shared/components/selectors/Switch/index.js +2 -0
  71. package/build/production/shared/components/selectors/Switch/index.js.map +1 -0
  72. package/build/production/shared/components/selectors/common.js +3 -0
  73. package/build/production/shared/components/selectors/common.js.map +1 -0
  74. package/build/production/shared/components/selectors/index.js +2 -0
  75. package/build/production/shared/components/selectors/index.js.map +1 -0
  76. package/build/production/shared/utils/index.js +1 -1
  77. package/build/production/shared/utils/index.js.map +1 -1
  78. package/build/production/shared/utils/jest/E2eSsrEnv.js +3 -1
  79. package/build/production/shared/utils/jest/E2eSsrEnv.js.map +1 -1
  80. package/build/production/shared/utils/jest/index.js +1 -1
  81. package/build/production/shared/utils/jest/index.js.map +1 -1
  82. package/build/production/style.css +1 -1
  83. package/build/production/style.css.map +1 -1
  84. package/build/production/web.bundle.js +1 -1
  85. package/build/production/web.bundle.js.map +1 -1
  86. package/build/types-code/client/index.d.ts +1 -0
  87. package/build/types-code/index.d.ts +1 -1
  88. package/build/types-code/shared/components/Checkbox/index.d.ts +1 -1
  89. package/build/types-code/shared/components/Input/index.d.ts +1 -1
  90. package/build/types-code/shared/components/Modal/index.d.ts +3 -1
  91. package/build/types-code/shared/components/TextArea/index.d.ts +1 -0
  92. package/build/types-code/shared/components/index.d.ts +1 -2
  93. package/build/types-code/shared/components/selectors/CustomDropdown/Options/index.d.ts +17 -0
  94. package/build/types-code/shared/components/selectors/CustomDropdown/index.d.ts +4 -0
  95. package/build/types-code/shared/components/selectors/NativeDropdown/index.d.ts +3 -0
  96. package/build/types-code/shared/components/selectors/Switch/index.d.ts +13 -0
  97. package/build/types-code/shared/components/selectors/common.d.ts +27 -0
  98. package/build/types-code/shared/components/selectors/index.d.ts +3 -0
  99. package/build/types-scss/src/shared/components/Modal/styles.scss.d.ts +1 -0
  100. package/build/types-scss/src/shared/components/selectors/CustomDropdown/Options/style.scss.d.ts +1 -0
  101. package/build/types-scss/src/shared/components/selectors/CustomDropdown/theme.scss.d.ts +10 -0
  102. package/build/types-scss/src/shared/components/{Dropdown → selectors/NativeDropdown}/theme.scss.d.ts +1 -0
  103. package/build/types-scss/src/shared/components/selectors/Switch/theme.scss.d.ts +6 -0
  104. package/package.json +30 -30
  105. package/src/client/index.tsx +2 -1
  106. package/src/index.ts +1 -0
  107. package/src/shared/components/Button/style.scss +1 -0
  108. package/src/shared/components/Checkbox/index.tsx +3 -3
  109. package/src/shared/components/Input/index.tsx +3 -3
  110. package/src/shared/components/Modal/base-theme.scss +1 -1
  111. package/src/shared/components/Modal/index.tsx +40 -5
  112. package/src/shared/components/Modal/styles.scss +2 -4
  113. package/src/shared/components/TextArea/index.tsx +5 -0
  114. package/src/shared/components/TextArea/style.scss +8 -0
  115. package/src/shared/components/YouTubeVideo/base.scss +3 -1
  116. package/src/shared/components/YouTubeVideo/index.tsx +2 -3
  117. package/src/shared/components/index.ts +2 -2
  118. package/src/shared/components/selectors/CustomDropdown/Options/index.tsx +107 -0
  119. package/src/shared/components/selectors/CustomDropdown/Options/style.scss +6 -0
  120. package/src/shared/components/selectors/CustomDropdown/index.tsx +115 -0
  121. package/src/shared/components/selectors/CustomDropdown/theme.scss +90 -0
  122. package/src/shared/components/{Dropdown → selectors/NativeDropdown}/index.tsx +21 -50
  123. package/src/shared/components/{Dropdown → selectors/NativeDropdown}/theme.scss +5 -0
  124. package/src/shared/components/selectors/Switch/index.tsx +94 -0
  125. package/src/shared/components/selectors/Switch/theme.scss +39 -0
  126. package/src/shared/components/selectors/common.ts +54 -0
  127. package/src/shared/components/selectors/index.ts +3 -0
  128. package/src/shared/utils/jest/E2eSsrEnv.ts +5 -1
  129. package/build/development/shared/components/Dropdown/index.js.map +0 -1
  130. package/build/development/shared/components/ScalableRect/index.js +0 -80
  131. package/build/development/shared/components/ScalableRect/index.js.map +0 -1
  132. package/build/production/shared/components/Dropdown/index.js +0 -24
  133. package/build/production/shared/components/Dropdown/index.js.map +0 -1
  134. package/build/production/shared/components/ScalableRect/index.js +0 -21
  135. package/build/production/shared/components/ScalableRect/index.js.map +0 -1
  136. package/build/types-code/shared/components/Dropdown/index.d.ts +0 -17
  137. package/build/types-code/shared/components/ScalableRect/index.d.ts +0 -19
  138. package/build/types-scss/src/shared/components/ScalableRect/style.scss.d.ts +0 -2
  139. package/src/shared/components/ScalableRect/index.tsx +0 -84
  140. package/src/shared/components/ScalableRect/style.scss +0 -10
@@ -1,6 +1,7 @@
1
1
  import { type ComponentType } from 'react';
2
2
  type OptionsT = {
3
3
  dontHydrate?: boolean;
4
+ initialState?: any;
4
5
  };
5
6
  /**
6
7
  * Prepares and launches the app at client side.
@@ -4,7 +4,7 @@ declare const server: typeof ServerT | null;
4
4
  declare const client: any;
5
5
  export { default as api } from 'axios';
6
6
  export * as PT from 'prop-types';
7
- export { type AsyncCollectionLoaderT, type AsyncDataEnvelopeT, type AsyncDataLoaderT, type ForceT, type UseAsyncDataOptionsT, type UseAsyncDataResT, type UseGlobalStateResT, type ValueOrInitializerT, getGlobalState, GlobalStateProvider, useAsyncCollection, useAsyncData, useGlobalState, withGlobalStateType, } from '@dr.pogodin/react-global-state';
7
+ export { type AsyncCollectionLoaderT, type AsyncDataEnvelopeT, type AsyncDataLoaderT, type ForceT, type UseAsyncDataOptionsT, type UseAsyncDataResT, type UseGlobalStateResT, type ValueOrInitializerT, getGlobalState, GlobalStateProvider, newAsyncDataEnvelope, useAsyncCollection, useAsyncData, useGlobalState, withGlobalStateType, } from '@dr.pogodin/react-global-state';
8
8
  export * from './shared/components';
9
9
  export { type Theme, config, Barrier, Emitter, isomorphy, getSsrContext, JU, Semaphore, splitComponent, themed, ThemeProvider, time, webpack, withRetries, } from './shared/utils';
10
10
  export { client, server };
@@ -3,7 +3,7 @@ import { type Theme } from '@dr.pogodin/react-themes';
3
3
  declare const validThemeKeys: readonly ["checkbox", "container", "label"];
4
4
  type PropT = {
5
5
  checked?: boolean;
6
- label?: string;
6
+ label?: React.ReactNode;
7
7
  onChange?: React.ChangeEventHandler<HTMLInputElement>;
8
8
  theme: Theme<typeof validThemeKeys>;
9
9
  };
@@ -2,7 +2,7 @@
2
2
  import { type Theme } from '@dr.pogodin/react-themes';
3
3
  declare const validThemeKeys: readonly ["container", "input", "label"];
4
4
  declare const ThemedInput: import("@dr.pogodin/react-themes").ThemedComponent<React.InputHTMLAttributes<HTMLInputElement> & {
5
- label?: string | undefined;
5
+ label?: React.ReactNode;
6
6
  theme: Theme<typeof validThemeKeys>;
7
7
  } & React.RefAttributes<HTMLInputElement>>;
8
8
  export default ThemedInput;
@@ -1,9 +1,11 @@
1
1
  import { type ReactNode } from 'react';
2
2
  import { type Theme } from '@dr.pogodin/react-themes';
3
- import './styles.scss';
4
3
  declare const validThemeKeys: readonly ["container", "overlay"];
5
4
  type PropsT = {
5
+ cancelOnScrolling?: boolean;
6
6
  children?: ReactNode;
7
+ containerStyle?: React.CSSProperties;
8
+ dontDisableScrolling?: boolean;
7
9
  onCancel?: () => void;
8
10
  theme: Theme<typeof validThemeKeys>;
9
11
  };
@@ -2,6 +2,7 @@
2
2
  import { type Theme } from '@dr.pogodin/react-themes';
3
3
  declare const validThemeKeys: readonly ["container", "hidden", "textarea"];
4
4
  type Props = {
5
+ disabled?: boolean;
5
6
  onChange?: React.ChangeEventHandler<HTMLTextAreaElement>;
6
7
  onKeyDown?: React.KeyboardEventHandler<HTMLTextAreaElement>;
7
8
  placeholder?: string;
@@ -1,16 +1,15 @@
1
1
  /**
2
2
  * Just an aggregation of all exported components into a single module.
3
3
  */
4
+ export * from './selectors';
4
5
  export { default as Button } from './Button';
5
6
  export { default as Checkbox } from './Checkbox';
6
- export { default as Dropdown } from './Dropdown';
7
7
  export { default as Input } from './Input';
8
8
  export { default as Link } from './Link';
9
9
  export { default as PageLayout } from './PageLayout';
10
10
  export { default as MetaTags } from './MetaTags';
11
11
  export { default as Modal, BaseModal } from './Modal';
12
12
  export { default as NavLink } from './NavLink';
13
- export { default as ScalableRect } from './ScalableRect';
14
13
  export { default as Throbber } from './Throbber';
15
14
  export { default as WithTooltip } from './WithTooltip';
16
15
  export { default as YouTubeVideo } from './YouTubeVideo';
@@ -0,0 +1,17 @@
1
+ /// <reference types="react" />
2
+ import { type OptionT, type OptionsT } from '../../common';
3
+ type PropsT = {
4
+ anchorRect: {
5
+ bottom: number;
6
+ left: number;
7
+ width: number;
8
+ };
9
+ containerClass: string;
10
+ filter?: (item: OptionT<React.ReactNode> | string) => boolean;
11
+ optionClass: string;
12
+ options: OptionsT<React.ReactNode>;
13
+ onCancel: () => void;
14
+ onChange: (value: string) => void;
15
+ };
16
+ declare const Options: React.FunctionComponent<PropsT>;
17
+ export default Options;
@@ -0,0 +1,4 @@
1
+ /// <reference types="react" />
2
+ import { type PropsT } from '../common';
3
+ declare const ThemedCustomDropdown: import("@dr.pogodin/react-themes").ThemedComponent<PropsT<React.ReactNode, (value: string) => void>>;
4
+ export default ThemedCustomDropdown;
@@ -0,0 +1,3 @@
1
+ import { type PropsT } from '../common';
2
+ declare const ThemedDropdown: import("@dr.pogodin/react-themes").ThemedComponent<PropsT<string>>;
3
+ export default ThemedDropdown;
@@ -0,0 +1,13 @@
1
+ /// <reference types="react" />
2
+ import { type Theme } from '@dr.pogodin/react-themes';
3
+ import { type OptionsT } from '../common';
4
+ declare const validThemeKeys: readonly ["container", "label", "option", "selected", "switch"];
5
+ type PropsT = {
6
+ label?: React.ReactNode;
7
+ onChange?: (value: string) => void;
8
+ options?: Readonly<OptionsT<React.ReactNode>>;
9
+ theme: Theme<typeof validThemeKeys>;
10
+ value?: string;
11
+ };
12
+ declare const ThemedSwitch: import("@dr.pogodin/react-themes").ThemedComponent<PropsT>;
13
+ export default ThemedSwitch;
@@ -0,0 +1,27 @@
1
+ /// <reference types="react" />
2
+ import PT from 'prop-types';
3
+ import type { Theme } from '@dr.pogodin/react-themes';
4
+ export declare const validThemeKeys: readonly ["active", "arrow", "container", "dropdown", "hiddenOption", "label", "option", "select"];
5
+ export type OptionT<NameT> = {
6
+ name?: NameT | null;
7
+ value: string;
8
+ };
9
+ export type OptionsT<NameT> = Array<OptionT<NameT> | string>;
10
+ export type PropsT<NameT, OnChangeT = React.ChangeEventHandler<HTMLSelectElement>> = {
11
+ filter?: (item: OptionT<NameT> | string) => boolean;
12
+ label?: React.ReactNode;
13
+ onChange?: OnChangeT;
14
+ options?: OptionsT<NameT>;
15
+ theme: Theme<typeof validThemeKeys>;
16
+ value?: string;
17
+ };
18
+ export declare const optionValidator: PT.Requireable<NonNullable<string | NonNullable<PT.InferProps<{
19
+ name: PT.Requireable<string>;
20
+ value: PT.Validator<string>;
21
+ }>>>>;
22
+ export declare const optionsValidator: PT.Requireable<NonNullable<NonNullable<string | NonNullable<PT.InferProps<{
23
+ name: PT.Requireable<string>;
24
+ value: PT.Validator<string>;
25
+ }>>>>[]>;
26
+ /** Returns option value and name as a tuple. */
27
+ export declare function optionValueName<NameT>(option: OptionT<NameT> | string): [string, NameT | string];
@@ -0,0 +1,3 @@
1
+ export { default as CustomDropdown } from './CustomDropdown';
2
+ export { default as Dropdown } from './NativeDropdown';
3
+ export { default as Switch } from './Switch';
@@ -0,0 +1 @@
1
+ export declare const scrollingDisabledByModal: string;
@@ -0,0 +1 @@
1
+ export declare const overlay: string;
@@ -0,0 +1,10 @@
1
+ export declare const active: string;
2
+ export declare const ad: string;
3
+ export declare const arrow: string;
4
+ export declare const container: string;
5
+ export declare const context: string;
6
+ export declare const dropdown: string;
7
+ export declare const hoc: string;
8
+ export declare const label: string;
9
+ export declare const option: string;
10
+ export declare const select: string;
@@ -1,3 +1,4 @@
1
+ export declare const active: string;
1
2
  export declare const ad: string;
2
3
  export declare const arrow: string;
3
4
  export declare const container: string;
@@ -0,0 +1,6 @@
1
+ export declare const ad: string;
2
+ export declare const container: string;
3
+ export declare const context: string;
4
+ export declare const hoc: string;
5
+ export declare const option: string;
6
+ export declare const selected: string;
package/package.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "1.30.2",
2
+ "version": "1.31.1",
3
3
  "bin": {
4
4
  "react-utils-build": "bin/build.js",
5
5
  "react-utils-setup": "bin/setup.js"
@@ -8,14 +8,14 @@
8
8
  "url": "https://github.com/birdofpreyru/react-utils/issues"
9
9
  },
10
10
  "dependencies": {
11
- "@babel/runtime": "^7.24.0",
11
+ "@babel/runtime": "^7.24.1",
12
12
  "@dr.pogodin/babel-plugin-react-css-modules": "^6.12.0",
13
13
  "@dr.pogodin/csurf": "^1.13.0",
14
14
  "@dr.pogodin/js-utils": "^0.0.9",
15
15
  "@dr.pogodin/react-global-state": "^0.13.0",
16
16
  "@dr.pogodin/react-themes": "^1.6.0",
17
17
  "@jest/environment": "^29.7.0",
18
- "axios": "^1.6.7",
18
+ "axios": "^1.6.8",
19
19
  "commander": "^12.0.0",
20
20
  "compression": "^1.7.4",
21
21
  "config": "^3.3.11",
@@ -23,7 +23,7 @@
23
23
  "cookie-parser": "^1.4.6",
24
24
  "cross-env": "^7.0.3",
25
25
  "dayjs": "^1.11.10",
26
- "express": "^4.18.3",
26
+ "express": "^4.19.2",
27
27
  "helmet": "^7.1.0",
28
28
  "http-status-codes": "^2.3.0",
29
29
  "joi": "^17.12.2",
@@ -43,38 +43,38 @@
43
43
  "serve-favicon": "^2.5.0",
44
44
  "source-map-support": "^0.5.21",
45
45
  "uuid": "^9.0.1",
46
- "winston": "^3.12.0"
46
+ "winston": "^3.13.0"
47
47
  },
48
48
  "description": "Collection of generic ReactJS components and utils",
49
49
  "devDependencies": {
50
- "@babel/cli": "^7.23.9",
51
- "@babel/core": "^7.24.0",
52
- "@babel/eslint-parser": "^7.23.10",
50
+ "@babel/cli": "^7.24.1",
51
+ "@babel/core": "^7.24.3",
52
+ "@babel/eslint-parser": "^7.24.1",
53
53
  "@babel/eslint-plugin": "^7.23.5",
54
54
  "@babel/node": "^7.23.9",
55
- "@babel/plugin-transform-runtime": "^7.24.0",
56
- "@babel/preset-env": "^7.24.0",
57
- "@babel/preset-react": "^7.23.3",
58
- "@babel/preset-typescript": "^7.23.3",
55
+ "@babel/plugin-transform-runtime": "^7.24.3",
56
+ "@babel/preset-env": "^7.24.3",
57
+ "@babel/preset-react": "^7.24.1",
58
+ "@babel/preset-typescript": "^7.24.1",
59
59
  "@babel/register": "^7.23.7",
60
60
  "@dr.pogodin/babel-plugin-transform-assets": "^1.2.2",
61
61
  "@dr.pogodin/babel-preset-svgr": "^1.8.0",
62
62
  "@pmmmwh/react-refresh-webpack-plugin": "^0.5.11",
63
- "@tsconfig/recommended": "^1.0.3",
64
- "@tsd/typescript": "^5.3.3",
63
+ "@tsconfig/recommended": "^1.0.4",
64
+ "@tsd/typescript": "^5.4.3",
65
65
  "@types/compression": "^1.7.5",
66
- "@types/config": "^3.3.3",
66
+ "@types/config": "^3.3.4",
67
67
  "@types/cookie": "^0.6.0",
68
68
  "@types/cookie-parser": "^1.4.7",
69
69
  "@types/csurf": "^1.11.5",
70
70
  "@types/express": "^4.17.21",
71
71
  "@types/jest": "^29.5.12",
72
- "@types/lodash": "^4.14.202",
72
+ "@types/lodash": "^4.17.0",
73
73
  "@types/morgan": "^1.9.9",
74
74
  "@types/node-forge": "^1.3.11",
75
75
  "@types/pretty": "^2.0.3",
76
- "@types/react": "^18.2.64",
77
- "@types/react-dom": "^18.2.21",
76
+ "@types/react": "^18.2.70",
77
+ "@types/react-dom": "^18.2.22",
78
78
  "@types/react-helmet": "^6.1.11",
79
79
  "@types/react-test-renderer": "^18.0.7",
80
80
  "@types/request-ip": "^0.0.41",
@@ -83,11 +83,11 @@
83
83
  "@types/supertest": "^6.0.2",
84
84
  "@types/uuid": "^9.0.8",
85
85
  "@types/webpack": "^5.28.5",
86
- "autoprefixer": "^10.4.18",
86
+ "autoprefixer": "^10.4.19",
87
87
  "babel-jest": "^29.7.0",
88
88
  "babel-loader": "^9.1.3",
89
89
  "babel-plugin-module-resolver": "^5.0.0",
90
- "core-js": "^3.36.0",
90
+ "core-js": "^3.36.1",
91
91
  "css-loader": "^6.10.0",
92
92
  "css-minimizer-webpack-plugin": "^6.0.0",
93
93
  "eslint": "^8.57.0",
@@ -97,16 +97,16 @@
97
97
  "eslint-plugin-import": "^2.29.1",
98
98
  "eslint-plugin-jest": "^27.9.0",
99
99
  "eslint-plugin-jsx-a11y": "^6.8.0",
100
- "eslint-plugin-react": "^7.34.0",
100
+ "eslint-plugin-react": "^7.34.1",
101
101
  "eslint-plugin-react-hooks": "^4.6.0",
102
102
  "identity-obj-proxy": "^3.0.0",
103
103
  "jest": "^29.7.0",
104
104
  "jest-environment-jsdom": "^29.7.0",
105
- "memfs": "^4.7.7",
105
+ "memfs": "^4.8.0",
106
106
  "mini-css-extract-plugin": "^2.8.1",
107
107
  "mockdate": "^3.0.5",
108
108
  "nodelist-foreach-polyfill": "^1.2.0",
109
- "postcss": "^8.4.35",
109
+ "postcss": "^8.4.38",
110
110
  "postcss-loader": "^8.1.1",
111
111
  "postcss-scss": "^4.0.9",
112
112
  "pretty": "^2.0.0",
@@ -114,18 +114,18 @@
114
114
  "react-test-renderer": "^18.2.0",
115
115
  "regenerator-runtime": "^0.14.1",
116
116
  "resolve-url-loader": "^5.0.0",
117
- "sass": "^1.71.1",
117
+ "sass": "^1.72.0",
118
118
  "sass-loader": "^14.1.1",
119
119
  "sitemap": "^7.1.1",
120
- "stylelint": "^16.2.1",
120
+ "stylelint": "^16.3.0",
121
121
  "stylelint-config-standard-scss": "^13.0.0",
122
122
  "supertest": "^6.3.4",
123
123
  "tsc-alias": "^1.8.8",
124
- "typed-scss-modules": "^8.0.0",
125
- "typescript": "^5.4.2",
126
- "typescript-eslint": "^7.1.1",
127
- "webpack": "^5.90.3",
128
- "webpack-dev-middleware": "^7.0.0",
124
+ "typed-scss-modules": "^8.0.1",
125
+ "typescript": "^5.4.3",
126
+ "typescript-eslint": "^7.4.0",
127
+ "webpack": "^5.91.0",
128
+ "webpack-dev-middleware": "^7.1.1",
129
129
  "webpack-hot-middleware": "^2.26.1",
130
130
  "webpack-merge": "^5.10.0",
131
131
  "workbox-core": "^7.0.0",
@@ -12,6 +12,7 @@ import getInj from './getInj';
12
12
 
13
13
  type OptionsT = {
14
14
  dontHydrate?: boolean;
15
+ initialState?: any;
15
16
  };
16
17
 
17
18
  /**
@@ -26,7 +27,7 @@ export default function Launch(
26
27
  const container = document.getElementById('react-view');
27
28
  if (!container) throw Error('Failed to find container for React app');
28
29
  const scene = (
29
- <GlobalStateProvider initialState={getInj().ISTATE}>
30
+ <GlobalStateProvider initialState={getInj().ISTATE || options.initialState}>
30
31
  <BrowserRouter future={{ v7_relativeSplatPath: true }}>
31
32
  <Application />
32
33
  </BrowserRouter>
package/src/index.ts CHANGED
@@ -22,6 +22,7 @@ export {
22
22
  type ValueOrInitializerT,
23
23
  getGlobalState,
24
24
  GlobalStateProvider,
25
+ newAsyncDataEnvelope,
25
26
  useAsyncCollection,
26
27
  useAsyncData,
27
28
  useGlobalState,
@@ -17,6 +17,7 @@
17
17
  padding: 0.3em 1.2em;
18
18
  text-align: center;
19
19
  text-decoration: none;
20
+ user-select: none;
20
21
 
21
22
  &:visited {
22
23
  color: inherit;
@@ -8,7 +8,7 @@ const validThemeKeys = ['checkbox', 'container', 'label'] as const;
8
8
 
9
9
  type PropT = {
10
10
  checked?: boolean;
11
- label?: string;
11
+ label?: React.ReactNode;
12
12
  onChange?: React.ChangeEventHandler<HTMLInputElement>;
13
13
  theme: Theme<typeof validThemeKeys>;
14
14
  };
@@ -20,7 +20,7 @@ const Checkbox: React.FunctionComponent<PropT> = ({
20
20
  theme,
21
21
  }) => (
22
22
  <div className={theme.container}>
23
- { label === undefined ? null : <p className={theme.label}>{label}</p> }
23
+ { label === undefined ? null : <div className={theme.label}>{label}</div> }
24
24
  <input
25
25
  checked={checked}
26
26
  className={theme.checkbox}
@@ -56,7 +56,7 @@ const ThemedCheckbox = themed(
56
56
  */
57
57
  Checkbox.propTypes = {
58
58
  checked: PT.bool,
59
- label: PT.string,
59
+ label: PT.node,
60
60
  onChange: PT.func,
61
61
  theme: ThemedCheckbox.themeType.isRequired,
62
62
  };
@@ -12,7 +12,7 @@ const validThemeKeys = [
12
12
  ] as const;
13
13
 
14
14
  type PropsT = React.InputHTMLAttributes<HTMLInputElement> & {
15
- label?: string;
15
+ label?: React.ReactNode;
16
16
  theme: Theme<typeof validThemeKeys>;
17
17
  };
18
18
 
@@ -34,7 +34,7 @@ const Input = forwardRef<HTMLInputElement, PropsT>((
34
34
  ref,
35
35
  ) => (
36
36
  <span className={theme.container}>
37
- { label === undefined ? null : <p className={theme.label}>{label}</p> }
37
+ { label === undefined ? null : <div className={theme.label}>{label}</div> }
38
38
  <input
39
39
  className={theme.input}
40
40
  ref={ref}
@@ -46,7 +46,7 @@ const Input = forwardRef<HTMLInputElement, PropsT>((
46
46
  const ThemedInput = themed(Input, 'Input', validThemeKeys, defaultTheme);
47
47
 
48
48
  Input.propTypes = {
49
- label: PT.string,
49
+ label: PT.node,
50
50
  theme: ThemedInput.themeType.isRequired,
51
51
  };
52
52
 
@@ -19,7 +19,7 @@
19
19
  &.container {
20
20
  background: #fff;
21
21
  box-shadow: 0 0 14px 1px rgba(38 38 40 / 15%);
22
- border-radius: 4;
22
+ border-radius: 0.3em;
23
23
  max-height: 95vh;
24
24
  max-width: $screen-md;
25
25
  overflow: hidden;
@@ -15,12 +15,15 @@ import PT from 'prop-types';
15
15
  import themed, { type Theme } from '@dr.pogodin/react-themes';
16
16
 
17
17
  import baseTheme from './base-theme.scss';
18
- import './styles.scss';
18
+ import S from './styles.scss';
19
19
 
20
20
  const validThemeKeys = ['container', 'overlay'] as const;
21
21
 
22
22
  type PropsT = {
23
+ cancelOnScrolling?: boolean;
23
24
  children?: ReactNode;
25
+ containerStyle?: React.CSSProperties;
26
+ dontDisableScrolling?: boolean;
24
27
  onCancel?: () => void;
25
28
  theme: Theme<typeof validThemeKeys>;
26
29
  };
@@ -37,7 +40,10 @@ type PropsT = {
37
40
  * @param {ModalTheme} [props.theme] _Ad hoc_ theme.
38
41
  */
39
42
  const BaseModal: React.FunctionComponent<PropsT> = ({
43
+ cancelOnScrolling,
40
44
  children,
45
+ containerStyle,
46
+ dontDisableScrolling,
41
47
  onCancel,
42
48
  theme,
43
49
  }) => {
@@ -47,15 +53,37 @@ const BaseModal: React.FunctionComponent<PropsT> = ({
47
53
 
48
54
  useEffect(() => {
49
55
  const p = document.createElement('div');
50
- document.body.classList.add('scrolling-disabled-by-modal');
51
56
  document.body.appendChild(p);
52
57
  setPortal(p);
53
58
  return () => {
54
- document.body.classList.remove('scrolling-disabled-by-modal');
55
59
  document.body.removeChild(p);
56
60
  };
57
61
  }, []);
58
62
 
63
+ // Sets up modal cancellation of scrolling, if opted-in.
64
+ useEffect(() => {
65
+ if (cancelOnScrolling && onCancel) {
66
+ window.addEventListener('scroll', onCancel);
67
+ }
68
+ return () => {
69
+ if (cancelOnScrolling && onCancel) {
70
+ window.removeEventListener('scroll', onCancel);
71
+ }
72
+ };
73
+ }, [cancelOnScrolling, onCancel]);
74
+
75
+ // Disables window scrolling, if it is not opted-out.
76
+ useEffect(() => {
77
+ if (!dontDisableScrolling) {
78
+ document.body.classList.add(S.scrollingDisabledByModal);
79
+ }
80
+ return () => {
81
+ if (!dontDisableScrolling) {
82
+ document.body.classList.remove(S.scrollingDisabledByModal);
83
+ }
84
+ };
85
+ }, [dontDisableScrolling]);
86
+
59
87
  const focusLast = useMemo(() => (
60
88
  <div
61
89
  onFocus={() => {
@@ -98,6 +126,7 @@ const BaseModal: React.FunctionComponent<PropsT> = ({
98
126
  onWheel={(event) => event.stopPropagation()}
99
127
  ref={containerRef}
100
128
  role="dialog"
129
+ style={containerStyle}
101
130
  >
102
131
  {children}
103
132
  </div>
@@ -124,14 +153,20 @@ const ThemedModal = themed(
124
153
  );
125
154
 
126
155
  BaseModal.propTypes = {
127
- onCancel: PT.func,
156
+ cancelOnScrolling: PT.bool,
128
157
  children: PT.node,
158
+ containerStyle: PT.shape({}),
159
+ dontDisableScrolling: PT.bool,
160
+ onCancel: PT.func,
129
161
  theme: ThemedModal.themeType.isRequired,
130
162
  };
131
163
 
132
164
  BaseModal.defaultProps = {
133
- onCancel: noop,
165
+ cancelOnScrolling: false,
134
166
  children: null,
167
+ containerStyle: undefined,
168
+ dontDisableScrolling: false,
169
+ onCancel: noop,
135
170
  };
136
171
 
137
172
  export default ThemedModal;
@@ -1,5 +1,3 @@
1
- :global {
2
- body.scrolling-disabled-by-modal {
3
- overflow: hidden;
4
- }
1
+ .scrollingDisabledByModal {
2
+ overflow: hidden;
5
3
  }
@@ -12,6 +12,7 @@ const validThemeKeys = [
12
12
  ] as const;
13
13
 
14
14
  type Props = {
15
+ disabled?: boolean;
15
16
  onChange?: React.ChangeEventHandler<HTMLTextAreaElement>;
16
17
  onKeyDown?: React.KeyboardEventHandler<HTMLTextAreaElement>;
17
18
  placeholder?: string;
@@ -20,6 +21,7 @@ type Props = {
20
21
  };
21
22
 
22
23
  const TextArea: React.FunctionComponent<Props> = ({
24
+ disabled,
23
25
  onChange,
24
26
  onKeyDown,
25
27
  placeholder,
@@ -66,6 +68,7 @@ const TextArea: React.FunctionComponent<Props> = ({
66
68
  value={localValue}
67
69
  />
68
70
  <textarea
71
+ disabled={disabled}
69
72
  // When value is "undefined" the text area is not-managed, and we should
70
73
  // manage it internally for the measurement / resizing functionality
71
74
  // to work.
@@ -90,6 +93,7 @@ const ThemedTextArea = themed(
90
93
  );
91
94
 
92
95
  TextArea.propTypes = {
96
+ disabled: PT.bool,
93
97
  onChange: PT.func,
94
98
  onKeyDown: PT.func,
95
99
  placeholder: PT.string,
@@ -98,6 +102,7 @@ TextArea.propTypes = {
98
102
  };
99
103
 
100
104
  TextArea.defaultProps = {
105
+ disabled: false,
101
106
  onChange: undefined,
102
107
  onKeyDown: undefined,
103
108
  placeholder: '',
@@ -1,3 +1,4 @@
1
+ @use "sass:color";
1
2
  @import "styles/mixins";
2
3
 
3
4
  *,
@@ -28,6 +29,13 @@
28
29
  &::placeholder {
29
30
  color: gray;
30
31
  }
32
+
33
+ &:disabled {
34
+ border-color: color.adjust($color: gray, $alpha: -0.66);
35
+ cursor: not-allowed;
36
+ color: color.adjust($color: gray, $alpha: -0.66);
37
+ user-select: none;
38
+ }
31
39
  }
32
40
 
33
41
  &.hidden {
@@ -2,12 +2,14 @@
2
2
  .context,
3
3
  .ad.hoc {
4
4
  .container {
5
+ aspect-ratio: 16 / 9;
5
6
  background: whitesmoke;
7
+ position: relative;
6
8
  }
7
9
 
8
10
  .video {
9
11
  height: 100%;
10
- position: relative;
12
+ position: absolute;
11
13
  width: 100%;
12
14
  }
13
15
  }
@@ -3,7 +3,6 @@ import qs from 'qs';
3
3
 
4
4
  import themed, { type Theme } from '@dr.pogodin/react-themes';
5
5
 
6
- import ScalableRect from 'components/ScalableRect';
7
6
  import Throbber from 'components/Throbber';
8
7
 
9
8
  import baseTheme from './base.scss';
@@ -57,7 +56,7 @@ const YouTubeVideo: React.FunctionComponent<PropsT> = ({
57
56
  // More query parameters can be exposed via the component props.
58
57
 
59
58
  return (
60
- <ScalableRect className={theme.container} ratio="16:9">
59
+ <div className={theme.container}>
61
60
  <Throbber theme={throbberTheme} />
62
61
  <iframe
63
62
  allow="autoplay"
@@ -66,7 +65,7 @@ const YouTubeVideo: React.FunctionComponent<PropsT> = ({
66
65
  src={url}
67
66
  title={title}
68
67
  />
69
- </ScalableRect>
68
+ </div>
70
69
  );
71
70
  };
72
71