@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 +1 @@
|
|
|
1
|
-
{"version":3,"file":"errors.js","names":["
|
|
1
|
+
{"version":3,"file":"errors.js","names":["StatusCodes","CODES","ReasonPhrases","ERRORS","getReasonPhrase","getErrorForCode","ErrorWithStatus","Error","status","INTERNAL_SERVER_ERROR","newError","message","statusCode","error","fail","assert","value","schema","BAD_REQUEST","result","validate","Promise","issues","JSON","stringify"],"sources":["../../../../src/server/utils/errors.ts"],"sourcesContent":["/**\n * @category Utilities\n * @module server/errors\n * @desc\n * ```js\n * import { server } from '@dr.pogodin/react-utils';\n * const { errors } = server;\n * ```\n * Server-side helpers for error handling.\n */\n\nimport {\n StatusCodes as CODES,\n ReasonPhrases as ERRORS,\n getReasonPhrase as getErrorForCode,\n} from 'http-status-codes';\n\nimport type { StandardSchemaV1 } from '@standard-schema/spec';\n\n/**\n * @static\n * @const CODES\n * @desc An alias for\n * [StatusCodes object from **http-status-codes** library](https://www.npmjs.com/package/http-status-codes).\n * It is a map between HTTP status code names and corresponding numeric codes.\n * @example\n * import { server } from '@dr.pogodin/react-utils';\n * const { CODES } = server.errors;\n * console.log(CODES.BAD_REQUEST); // Prints: 400\n */\nexport { CODES };\n\n/**\n * @static\n * @const ERRORS\n * @desc An alias for\n * [ReasonPhrases object from **http-status-codes** library](https://www.npmjs.com/package/http-status-codes).\n * It is a map between HTTP status code names and their pretty-printed forms.\n * @example\n * import { server } from '@dr.pogodin/react-utils';\n * const { ERRORS } = server.errors;\n * console.log(ERRORS.BAD_REQUEST); // Prints: Bad Request\n */\nexport { ERRORS };\n\n/**\n * @static\n * @func getErrorForCode\n * @desc An alias for\n * [getReasonPhrase() function from **http-status-codes** library](https://www.npmjs.com/package/http-status-codes).\n * Given an HTTP code it returns the corresponding error text.\n * @param {number} code HTTP code.\n * @return {string} HTTP error text.\n * @example\n * import { server } from '@dr.pogodin/react-utils';\n * console.log(server.errors.getErrorForCode(400)); // Prints: Bad Request\n */\nexport { getErrorForCode };\n\n// TODO: It could accept the status code as a constructor argument.\nclass ErrorWithStatus extends Error {\n status: number = CODES.INTERNAL_SERVER_ERROR;\n}\n\n/**\n * ```js\n * import { server } from '@dr.pogodin/react-utils';\n * const { newError } = server.errors;\n * ```\n * Creates a new `Error` object with given message, and HTTP status code\n * attached as `status` field.\n * @param {string} message Error message.\n * @param {number} [statusCode=500] HTTP status code. Defaults to 500 (Internal\n * Server Error).\n * @return {Error}\n */\nexport function newError(\n message: string,\n statusCode = CODES.INTERNAL_SERVER_ERROR,\n): ErrorWithStatus {\n const error = new ErrorWithStatus(message);\n error.status = statusCode;\n return error;\n}\n\n/**\n * Throws an error with given message and HTTP status code.\n */\nexport function fail(\n message: string,\n statusCode: CODES = CODES.INTERNAL_SERVER_ERROR,\n): Error {\n throw newError(message, statusCode);\n}\n\n/**\n * Validates the `value` against the given \"standard\" validation `schema`.\n * Resolves to the correctly typed `value`, if it has passed the validation;\n * otherwise throws an error.\n * @param value The value to validate.\n * @param schema The \"standard\" validation schema to use.\n * @param [message] Optional error message, to prepend the validation error\n * message.\n * @param [statusCode=400] HTTP status code. Defaults to 400 (Bad Request).\n */\nexport async function assert<T extends StandardSchemaV1>(\n value: unknown,\n schema: T,\n message = '',\n statusCode = CODES.BAD_REQUEST,\n): Promise<StandardSchemaV1.InferOutput<T>> {\n let result = schema['~standard'].validate(value);\n if (result instanceof Promise) result = await result;\n\n if (result.issues) {\n let error = JSON.stringify(result.issues, null, 2);\n if (message) error = `${message}\\n\\n${error}`;\n throw fail(error, statusCode);\n }\n\n return result.value;\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,GAEA,OACEA,WAAW,GAAI,CAAAC,KAAK,CACpBC,aAAa,GAAI,CAAAC,MAAM,CACvBC,eAAe,GAAI,CAAAC,eAAe,KAC7B,mBAAmB,CAI1B;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,GACA,OAASJ,KAAK,EAEd;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,GACA,OAASE,MAAM,EAEf;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,GACA,OAASE,eAAe,EAExB;AACA,KAAM,CAAAC,eAAe,QAAS,CAAAC,KAAM,CAClCC,MAAM,CAAWP,KAAK,CAACQ,qBACzB,CAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,GACA,MAAO,SAAS,CAAAC,QAAQA,CACtBC,OAAe,CACfC,UAAU,CAAGX,KAAK,CAACQ,qBAAqB,CACvB,CACjB,KAAM,CAAAI,KAAK,CAAG,GAAI,CAAAP,eAAe,CAACK,OAAO,CAAC,CAC1CE,KAAK,CAACL,MAAM,CAAGI,UAAU,CACzB,MAAO,CAAAC,KACT,CAEA;AACA;AACA,GACA,MAAO,SAAS,CAAAC,IAAIA,CAClBH,OAAe,CACfC,UAAiB,CAAGX,KAAK,CAACQ,qBAAqB,CACxC,CACP,KAAM,CAAAC,QAAQ,CAACC,OAAO,CAAEC,UAAU,CACpC,CAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,GACA,MAAO,eAAe,CAAAG,MAAMA,CAC1BC,KAAc,CACdC,MAAS,CACTN,OAAO,CAAG,EAAE,CACZC,UAAU,CAAGX,KAAK,CAACiB,WAAW,CACY,CAC1C,GAAI,CAAAC,MAAM,CAAGF,MAAM,CAAC,WAAW,CAAC,CAACG,QAAQ,CAACJ,KAAK,CAAC,CAChD,GAAIG,MAAM,WAAY,CAAAE,OAAO,CAAEF,MAAM,CAAG,KAAM,CAAAA,MAAM,CAEpD,GAAIA,MAAM,CAACG,MAAM,CAAE,CACjB,GAAI,CAAAT,KAAK,CAAGU,IAAI,CAACC,SAAS,CAACL,MAAM,CAACG,MAAM,CAAE,IAAI,CAAE,CAAC,CAAC,CAClD,GAAIX,OAAO,CAAEE,KAAK,CAAG,GAAGF,OAAO,OAAOE,KAAK,EAAE,CAC7C,KAAM,CAAAC,IAAI,CAACD,KAAK,CAAED,UAAU,CAC9B,CAEA,MAAO,CAAAO,MAAM,CAACH,KAChB","ignoreList":[]}
|
|
@@ -1,2 +1,3 @@
|
|
|
1
|
-
|
|
1
|
+
// Aggregates utility modules together.
|
|
2
|
+
export*from"./errors.js";
|
|
2
3
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":[],"sources":["../../../../src/server/utils/index.ts"],"sourcesContent":["// Aggregates utility modules together.\n\nexport *
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../../../../src/server/utils/index.ts"],"sourcesContent":["// Aggregates utility modules together.\n\nexport * from './errors';\n"],"mappings":"AAAA;AAAA","ignoreList":[]}
|
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
|
|
2
|
-
const defaultTheme={"context":"
|
|
1
|
+
// The <Button> component implements a standard button / button-like link.
|
|
2
|
+
import themed from"@dr.pogodin/react-themes";import Link from"../Link.js";const defaultTheme={"context":"_0S7CYa","ad":"YFXz0-","hoc":"BElFuo","button":"hXiBOw","active":"biX-UA","disabled":"_-6CH9q"};import{jsx as _jsx}from"react/jsx-runtime";export const BaseButton=({active,children,disabled,enforceA,onClick,onKeyDown:onKeyDownProp,onKeyUp,onMouseDown,onMouseUp,onPointerDown,onPointerUp,openNewTab,replace,testId,theme,to})=>{let className=theme.button;if(active&&theme.active)className+=` ${theme.active}`;if(disabled){if(theme.disabled)className+=` ${theme.disabled}`;return/*#__PURE__*/_jsx("div",{className:className,"data-testid":process.env.NODE_ENV==="production"?undefined:testId,children:children})}let onKeyDown=onKeyDownProp;if(!onKeyDown&&onClick){onKeyDown=e=>{if(e.key==="Enter")onClick(e)}}if(to){return/*#__PURE__*/_jsx(Link,{className:className,"data-testid":process.env.NODE_ENV==="production"?undefined:testId,enforceA:enforceA,onClick:onClick// TODO: For now, the `onKeyDown` handler is not passed to the <Link>,
|
|
3
3
|
// as <Link> component does not call it anyway, presumably due to
|
|
4
4
|
// the inner implementation details. We should look into supporting it:
|
|
5
5
|
// https://github.com/birdofpreyru/react-utils/issues/444
|
|
6
6
|
// onKeyDown={onKeyDown}
|
|
7
|
-
,onKeyUp:onKeyUp,onMouseDown:onMouseDown,onMouseUp:onMouseUp,onPointerDown:onPointerDown,onPointerUp:onPointerUp,openNewTab:openNewTab,replace:replace,to:to,children:children})}return/*#__PURE__*/(
|
|
7
|
+
,onKeyUp:onKeyUp,onMouseDown:onMouseDown,onMouseUp:onMouseUp,onPointerDown:onPointerDown,onPointerUp:onPointerUp,openNewTab:openNewTab,replace:replace,to:to,children:children})}return/*#__PURE__*/_jsx("div",{className:className,"data-testid":process.env.NODE_ENV==="production"?undefined:testId,onClick:onClick,onKeyDown:onKeyDown,onKeyUp:onKeyUp,onMouseDown:onMouseDown,onMouseUp:onMouseUp,onPointerDown:onPointerDown,onPointerUp:onPointerUp,role:"button",tabIndex:0,children:children})};/**
|
|
8
8
|
* Button component theme: a map of CSS
|
|
9
9
|
* class names to append to button elements:
|
|
10
10
|
* @prop {string} [active] to the root element of active button.
|
|
11
11
|
* @prop {string} [button] to the root element of any button.
|
|
12
12
|
* @prop {string} [disabled] to the root element of disabled button.
|
|
13
|
-
*/
|
|
13
|
+
*/export default/* #__PURE__ */themed(BaseButton,"Button",defaultTheme);
|
|
14
14
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["
|
|
1
|
+
{"version":3,"file":"index.js","names":["themed","Link","defaultTheme","jsx","_jsx","BaseButton","active","children","disabled","enforceA","onClick","onKeyDown","onKeyDownProp","onKeyUp","onMouseDown","onMouseUp","onPointerDown","onPointerUp","openNewTab","replace","testId","theme","to","className","button","process","env","NODE_ENV","undefined","e","key","role","tabIndex"],"sources":["../../../../../src/shared/components/Button/index.tsx"],"sourcesContent":["// The <Button> component implements a standard button / button-like link.\n\nimport type {\n FunctionComponent,\n KeyboardEventHandler,\n MouseEventHandler,\n PointerEventHandler,\n ReactNode,\n} from 'react';\n\nimport themed, { type Theme } from '@dr.pogodin/react-themes';\n\nimport Link from 'components/Link';\n\nimport defaultTheme from './style.scss';\n\ntype PropsT = {\n active?: boolean;\n children?: ReactNode;\n disabled?: boolean;\n enforceA?: boolean;\n onClick?: MouseEventHandler & KeyboardEventHandler;\n onKeyDown?: KeyboardEventHandler;\n onKeyUp?: KeyboardEventHandler;\n onMouseDown?: MouseEventHandler;\n onMouseUp?: MouseEventHandler;\n onPointerDown?: PointerEventHandler;\n onPointerUp?: PointerEventHandler;\n openNewTab?: boolean;\n replace?: boolean;\n testId?: string;\n theme: Theme<'active' | 'button' | 'disabled'>;\n // TODO: It needs a more precise typing of the object option.\n to?: object | string;\n};\n\nexport const BaseButton: FunctionComponent<PropsT> = ({\n active,\n children,\n disabled,\n enforceA,\n onClick,\n onKeyDown: onKeyDownProp,\n onKeyUp,\n onMouseDown,\n onMouseUp,\n onPointerDown,\n onPointerUp,\n openNewTab,\n replace,\n testId,\n theme,\n to,\n}) => {\n let className = theme.button;\n if (active && theme.active) className += ` ${theme.active}`;\n if (disabled) {\n if (theme.disabled) className += ` ${theme.disabled}`;\n return (\n <div\n className={className}\n data-testid={process.env.NODE_ENV === 'production' ? undefined : testId}\n >\n {children}\n </div>\n );\n }\n\n let onKeyDown = onKeyDownProp;\n if (!onKeyDown && onClick) {\n onKeyDown = (e) => {\n if (e.key === 'Enter') onClick(e);\n };\n }\n\n if (to) {\n return (\n <Link\n className={className}\n data-testid={process.env.NODE_ENV === 'production' ? undefined : testId}\n enforceA={enforceA}\n onClick={onClick}\n\n // TODO: For now, the `onKeyDown` handler is not passed to the <Link>,\n // as <Link> component does not call it anyway, presumably due to\n // the inner implementation details. We should look into supporting it:\n // https://github.com/birdofpreyru/react-utils/issues/444\n // onKeyDown={onKeyDown}\n\n onKeyUp={onKeyUp}\n onMouseDown={onMouseDown}\n onMouseUp={onMouseUp}\n onPointerDown={onPointerDown}\n onPointerUp={onPointerUp}\n openNewTab={openNewTab}\n replace={replace}\n to={to}\n >\n {children}\n </Link>\n );\n }\n\n return (\n <div\n className={className}\n data-testid={process.env.NODE_ENV === 'production' ? undefined : testId}\n onClick={onClick}\n onKeyDown={onKeyDown}\n onKeyUp={onKeyUp}\n onMouseDown={onMouseDown}\n onMouseUp={onMouseUp}\n onPointerDown={onPointerDown}\n onPointerUp={onPointerUp}\n role=\"button\"\n tabIndex={0}\n >\n {children}\n </div>\n );\n};\n\n/**\n * Button component theme: a map of CSS\n * class names to append to button elements:\n * @prop {string} [active] to the root element of active button.\n * @prop {string} [button] to the root element of any button.\n * @prop {string} [disabled] to the root element of disabled button.\n */\nexport default /* #__PURE__ */ themed(BaseButton, 'Button', defaultTheme);\n"],"mappings":"AAAA;AAUA,MAAO,CAAAA,MAAM,KAAsB,0BAA0B,OAEtD,CAAAC,IAAI,wBAAAC,YAAA,6GAE6B,OAAAC,GAAA,IAAAC,IAAA,yBAsBxC,MAAO,MAAM,CAAAC,UAAqC,CAAGA,CAAC,CACpDC,MAAM,CACNC,QAAQ,CACRC,QAAQ,CACRC,QAAQ,CACRC,OAAO,CACPC,SAAS,CAAEC,aAAa,CACxBC,OAAO,CACPC,WAAW,CACXC,SAAS,CACTC,aAAa,CACbC,WAAW,CACXC,UAAU,CACVC,OAAO,CACPC,MAAM,CACNC,KAAK,CACLC,EACF,CAAC,GAAK,CACJ,GAAI,CAAAC,SAAS,CAAGF,KAAK,CAACG,MAAM,CAC5B,GAAIlB,MAAM,EAAIe,KAAK,CAACf,MAAM,CAAEiB,SAAS,EAAI,IAAIF,KAAK,CAACf,MAAM,EAAE,CAC3D,GAAIE,QAAQ,CAAE,CACZ,GAAIa,KAAK,CAACb,QAAQ,CAAEe,SAAS,EAAI,IAAIF,KAAK,CAACb,QAAQ,EAAE,CACrD,mBACEJ,IAAA,QACEmB,SAAS,CAAEA,SAAU,CACrB,cAAaE,OAAO,CAACC,GAAG,CAACC,QAAQ,GAAK,YAAY,CAAGC,SAAS,CAAGR,MAAO,CAAAb,QAAA,CAEvEA,QAAQ,CACN,CAET,CAEA,GAAI,CAAAI,SAAS,CAAGC,aAAa,CAC7B,GAAI,CAACD,SAAS,EAAID,OAAO,CAAE,CACzBC,SAAS,CAAIkB,CAAC,EAAK,CACjB,GAAIA,CAAC,CAACC,GAAG,GAAK,OAAO,CAAEpB,OAAO,CAACmB,CAAC,CAClC,CACF,CAEA,GAAIP,EAAE,CAAE,CACN,mBACElB,IAAA,CAACH,IAAI,EACHsB,SAAS,CAAEA,SAAU,CACrB,cAAaE,OAAO,CAACC,GAAG,CAACC,QAAQ,GAAK,YAAY,CAAGC,SAAS,CAAGR,MAAO,CACxEX,QAAQ,CAAEA,QAAS,CACnBC,OAAO,CAAEA,OAET;AACA;AACA;AACA;AACA;AAAA,CAEAG,OAAO,CAAEA,OAAQ,CACjBC,WAAW,CAAEA,WAAY,CACzBC,SAAS,CAAEA,SAAU,CACrBC,aAAa,CAAEA,aAAc,CAC7BC,WAAW,CAAEA,WAAY,CACzBC,UAAU,CAAEA,UAAW,CACvBC,OAAO,CAAEA,OAAQ,CACjBG,EAAE,CAAEA,EAAG,CAAAf,QAAA,CAENA,QAAQ,CACL,CAEV,CAEA,mBACEH,IAAA,QACEmB,SAAS,CAAEA,SAAU,CACrB,cAAaE,OAAO,CAACC,GAAG,CAACC,QAAQ,GAAK,YAAY,CAAGC,SAAS,CAAGR,MAAO,CACxEV,OAAO,CAAEA,OAAQ,CACjBC,SAAS,CAAEA,SAAU,CACrBE,OAAO,CAAEA,OAAQ,CACjBC,WAAW,CAAEA,WAAY,CACzBC,SAAS,CAAEA,SAAU,CACrBC,aAAa,CAAEA,aAAc,CAC7BC,WAAW,CAAEA,WAAY,CACzBc,IAAI,CAAC,QAAQ,CACbC,QAAQ,CAAE,CAAE,CAAAzB,QAAA,CAEXA,QAAQ,CACN,CAET,CAAC,CAED;AACA;AACA;AACA;AACA;AACA;AACA,GACA,cAAe,eAAgBP,MAAM,CAACK,UAAU,CAAE,QAAQ,CAAEH,YAAY,CAAC","ignoreList":[]}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
|
|
1
|
+
import themed from"@dr.pogodin/react-themes";const defaultTheme={"context":"_08mmmo","ad":"Hc06MV","hoc":"toOtOd","checkbox":"v4DmWM","indeterminate":"ckSC8W","container":"g7wee9","label":"XQ57WS","disabled":"baVvQA"};import{jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";const Checkbox=({checked,disabled,label,onChange,testId,theme})=>{let containerClassName=theme.container;if(disabled)containerClassName+=` ${theme.disabled}`;let checkboxClassName=theme.checkbox;if(checked==="indeterminate")checkboxClassName+=` ${theme.indeterminate}`;return/*#__PURE__*/_jsxs("div",{className:containerClassName,children:[label===undefined?null:/*#__PURE__*/_jsx("div",{className:theme.label,children:label}),/*#__PURE__*/_jsx("input",{checked:checked===undefined?undefined:checked===true,className:checkboxClassName,"data-testid":process.env.NODE_ENV==="production"?undefined:testId,disabled:disabled,onChange:onChange,onClick:e=>{e.stopPropagation()},type:"checkbox"})]})};export default/* #__PURE__ */themed(Checkbox,"Checkbox",defaultTheme);
|
|
2
2
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["
|
|
1
|
+
{"version":3,"file":"index.js","names":["themed","defaultTheme","jsx","_jsx","jsxs","_jsxs","Checkbox","checked","disabled","label","onChange","testId","theme","containerClassName","container","checkboxClassName","checkbox","indeterminate","className","children","undefined","process","env","NODE_ENV","onClick","e","stopPropagation","type"],"sources":["../../../../../src/shared/components/Checkbox/index.tsx"],"sourcesContent":["import themed, { type Theme } from '@dr.pogodin/react-themes';\n\nimport defaultTheme from './theme.scss';\n\ntype PropT<ValueT> = {\n checked?: ValueT;\n disabled?: boolean;\n label?: React.ReactNode;\n onChange?: React.ChangeEventHandler<HTMLInputElement>;\n testId?: string;\n theme: Theme<\n | 'checkbox'\n | 'container'\n | 'disabled'\n | 'indeterminate'\n | 'label'\n >;\n};\n\nconst Checkbox = <ValueT extends boolean | 'indeterminate' = boolean>({\n checked,\n disabled,\n label,\n onChange,\n testId,\n theme,\n}: PropT<ValueT>) => {\n let containerClassName = theme.container;\n if (disabled) containerClassName += ` ${theme.disabled}`;\n\n let checkboxClassName = theme.checkbox;\n if (checked === 'indeterminate') checkboxClassName += ` ${theme.indeterminate}`;\n\n return (\n <div className={containerClassName}>\n { label === undefined\n ? null : <div className={theme.label}>{label}</div> }\n <input\n checked={checked === undefined ? undefined : checked === true}\n className={checkboxClassName}\n data-testid={process.env.NODE_ENV === 'production' ? undefined : testId}\n disabled={disabled}\n onChange={onChange}\n onClick={(e) => {\n e.stopPropagation();\n }}\n type=\"checkbox\"\n />\n </div>\n );\n};\n\nexport default /* #__PURE__ */ themed(Checkbox, 'Checkbox', defaultTheme);\n"],"mappings":"AAAA,MAAO,CAAAA,MAAM,KAAsB,0BAA0B,OAAAC,YAAA,2JAErB,OAAAC,GAAA,IAAAC,IAAA,CAAAC,IAAA,IAAAC,KAAA,yBAiBxC,KAAM,CAAAC,QAAQ,CAAGA,CAAqD,CACpEC,OAAO,CACPC,QAAQ,CACRC,KAAK,CACLC,QAAQ,CACRC,MAAM,CACNC,KACa,CAAC,GAAK,CACnB,GAAI,CAAAC,kBAAkB,CAAGD,KAAK,CAACE,SAAS,CACxC,GAAIN,QAAQ,CAAEK,kBAAkB,EAAI,IAAID,KAAK,CAACJ,QAAQ,EAAE,CAExD,GAAI,CAAAO,iBAAiB,CAAGH,KAAK,CAACI,QAAQ,CACtC,GAAIT,OAAO,GAAK,eAAe,CAAEQ,iBAAiB,EAAI,IAAIH,KAAK,CAACK,aAAa,EAAE,CAE/E,mBACEZ,KAAA,QAAKa,SAAS,CAAEL,kBAAmB,CAAAM,QAAA,EAC/BV,KAAK,GAAKW,SAAS,CACjB,IAAI,cAAGjB,IAAA,QAAKe,SAAS,CAAEN,KAAK,CAACH,KAAM,CAAAU,QAAA,CAAEV,KAAK,CAAM,CAAC,cACrDN,IAAA,UACEI,OAAO,CAAEA,OAAO,GAAKa,SAAS,CAAGA,SAAS,CAAGb,OAAO,GAAK,IAAK,CAC9DW,SAAS,CAAEH,iBAAkB,CAC7B,cAAaM,OAAO,CAACC,GAAG,CAACC,QAAQ,GAAK,YAAY,CAAGH,SAAS,CAAGT,MAAO,CACxEH,QAAQ,CAAEA,QAAS,CACnBE,QAAQ,CAAEA,QAAS,CACnBc,OAAO,CAAGC,CAAC,EAAK,CACdA,CAAC,CAACC,eAAe,CAAC,CACpB,CAAE,CACFC,IAAI,CAAC,UAAU,CAChB,CAAC,EACC,CAET,CAAC,CAED,cAAe,eAAgB3B,MAAM,CAACM,QAAQ,CAAE,UAAU,CAAEL,YAAY,CAAC","ignoreList":[]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
import{jsx as _jsx}from"react/jsx-runtime";/**
|
|
2
2
|
* The `<Link>` component, and almost identical `<NavLink>` component, are
|
|
3
3
|
* auxiliary wrappers around
|
|
4
4
|
* [React Router](https://github.com/ReactTraining/react-router)'s
|
|
@@ -41,14 +41,14 @@
|
|
|
41
41
|
* - It is opted explicitely by `enforceA` prop;
|
|
42
42
|
* - It should be opened in a new tab;
|
|
43
43
|
* - It is an absolte URL (starts with http:// or https://);
|
|
44
|
-
* - It is anchor link (starts with #). */if(disabled||enforceA||openNewTab||to.match(/^(#|(https?|mailto):)/)){return/*#__PURE__*/(
|
|
44
|
+
* - It is anchor link (starts with #). */if(disabled||enforceA||openNewTab||to.match(/^(#|(https?|mailto):)/)){return/*#__PURE__*/_jsx("a",{className:className// TODO: This requires a fix: disabled is not really an attribute of <a>
|
|
45
45
|
// tag, thus for disabled option we rather should render a plain text
|
|
46
46
|
// styled as a link.
|
|
47
47
|
// disabled={disabled}
|
|
48
|
-
,href:to,onClick:disabled?e=>{e.preventDefault()}:onClick,onMouseDown:disabled?e=>{e.preventDefault()}:onMouseDown,rel:"noopener noreferrer",target:openNewTab?"_blank":"",children:children})}const L=routerLinkType;return/*#__PURE__*/(
|
|
48
|
+
,href:to,onClick:disabled?e=>{e.preventDefault()}:onClick,onMouseDown:disabled?e=>{e.preventDefault()}:onMouseDown,rel:"noopener noreferrer",styleName:"link",target:openNewTab?"_blank":"",children:children})}const L=routerLinkType;return/*#__PURE__*/_jsx(L,{className:className,discover:"none"// disabled
|
|
49
49
|
,onClick:e=>{// Executes the user-provided event handler, if any.
|
|
50
50
|
if(onClick)onClick(e);// By default, clicking the link scrolls the page to beginning.
|
|
51
51
|
if(!keepScrollPosition)window.scroll(0,0)},onMouseDown:onMouseDown,replace:replace,to:to// TODO: Refactor it later.
|
|
52
52
|
// eslint-disable-next-line react/jsx-props-no-spreading
|
|
53
|
-
,...rest,children:children})};
|
|
53
|
+
,...rest,children:children})};export default GenericLink;
|
|
54
54
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["GenericLink","children","className","disabled","enforceA","keepScrollPosition","onClick","onMouseDown","openNewTab","replace","routerLinkType","to","rest","match","
|
|
1
|
+
{"version":3,"file":"index.js","names":["jsx","_jsx","GenericLink","children","className","disabled","enforceA","keepScrollPosition","onClick","onMouseDown","openNewTab","replace","routerLinkType","to","rest","match","href","e","preventDefault","rel","styleName","target","L","discover","window","scroll"],"sources":["../../../../../src/shared/components/GenericLink/index.tsx"],"sourcesContent":["import type { ReactNode } from 'react';\n\nimport type {\n Link,\n LinkProps,\n NavLink,\n NavLinkProps,\n} from 'react-router';\n\nimport './style.scss';\n\ntype LinkT = typeof Link;\ntype NavLinkT = typeof NavLink;\n\ntype ToT = Parameters<typeof Link>[0]['to'];\n\nexport type PropsT = {\n children?: ReactNode;\n className?: string;\n disabled?: boolean;\n enforceA?: boolean;\n keepScrollPosition?: boolean;\n onClick?: React.MouseEventHandler<HTMLAnchorElement>;\n onMouseDown?: React.MouseEventHandler<HTMLAnchorElement>;\n openNewTab?: boolean;\n replace?: boolean;\n routerLinkType: LinkT | NavLinkT;\n to: ToT;\n};\n\n/**\n * The `<Link>` component, and almost identical `<NavLink>` component, are\n * auxiliary wrappers around\n * [React Router](https://github.com/ReactTraining/react-router)'s\n * `<Link>` and `<NavLink>` components; they help to handle external and\n * internal links in uniform manner.\n *\n * @param [props] Component properties.\n * @param [props.className] CSS classes to apply to the link.\n * @param [props.disabled] Disables the link.\n * @param [props.enforceA] `true` enforces rendering of the link as\n * a simple `<a>` element.\n * @param [props.keepScrollPosition] If `true`, and the link is\n * rendered as a React Router's component, it won't reset the viewport scrolling\n * position to the origin when clicked.\n * @param [props.onClick] Event handler to trigger upon click.\n * @param [props.onMouseDown] Event handler to trigger on MouseDown\n * event.\n * @param [props.openNewTab] If `true` the link opens in a new tab.\n * @param [props.replace] When `true`, the link will replace current\n * entry in the history stack instead of adding a new one.\n * @param [props.to] Link URL.\n * @param [props.activeClassName] **`<NavLink>`** only: CSS class(es)\n * to apply to rendered link when it is active.\n * @param [props.activeStyle] **`<NavLink>`** only: CSS styles\n * to apply to the rendered link when it is active.\n * @param [props.exact] **`<NavLink>`** only: if `true`, the active\n * class/style will only be applied if the location is matched exactly.\n * @param [props.isActive] **`<NavLink>`** only: Add extra\n * logic for determining whether the link is active. This should be used if you\n * want to do more than verify that the link’s pathname matches the current URL\n * pathname.\n * @param [props.location] **`<NavLink>`** only: `isActive` compares\n * current history location (usually the current browser URL). To compare to\n * a different location, a custom `location` can be passed.\n * @param [props.strict] **`<NavLink>`** only: . When `true`, trailing\n * slash on a location’s pathname will be taken into consideration when\n * determining if the location matches the current URL. See the `<Route strict>`\n * documentation for more information.\n */\nconst GenericLink = ({\n children,\n className,\n disabled,\n enforceA,\n keepScrollPosition,\n onClick,\n onMouseDown,\n openNewTab,\n replace,\n routerLinkType,\n to,\n ...rest\n}: (LinkProps | NavLinkProps) & PropsT): ReactNode => {\n /* Renders Link as <a> element if:\n * - It is opted explicitely by `enforceA` prop;\n * - It should be opened in a new tab;\n * - It is an absolte URL (starts with http:// or https://);\n * - It is anchor link (starts with #). */\n if (disabled || enforceA || openNewTab\n || (to as string).match(/^(#|(https?|mailto):)/)) {\n return (\n <a\n className={className}\n // TODO: This requires a fix: disabled is not really an attribute of <a>\n // tag, thus for disabled option we rather should render a plain text\n // styled as a link.\n // disabled={disabled}\n href={to as string}\n onClick={disabled ? (e) => {\n e.preventDefault();\n } : onClick}\n onMouseDown={disabled ? (e) => {\n e.preventDefault();\n } : onMouseDown}\n rel=\"noopener noreferrer\"\n styleName=\"link\"\n target={openNewTab ? '_blank' : ''}\n >\n {children}\n </a>\n );\n }\n\n const L = routerLinkType;\n\n return (\n <L\n className={className}\n discover=\"none\"\n // disabled\n onClick={(e: React.MouseEvent<HTMLAnchorElement>) => {\n // Executes the user-provided event handler, if any.\n if (onClick) onClick(e);\n\n // By default, clicking the link scrolls the page to beginning.\n if (!keepScrollPosition) window.scroll(0, 0);\n }}\n onMouseDown={onMouseDown}\n replace={replace}\n to={to}\n // TODO: Refactor it later.\n // eslint-disable-next-line react/jsx-props-no-spreading\n {...rest}\n >\n {children}\n </L>\n );\n};\n\nexport default GenericLink;\n"],"mappings":"AASsB,OAAAA,GAAA,IAAAC,IAAA,yBAqBtB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,GACA,KAAM,CAAAC,WAAW,CAAGA,CAAC,CACnBC,QAAQ,CACRC,SAAS,CACTC,QAAQ,CACRC,QAAQ,CACRC,kBAAkB,CAClBC,OAAO,CACPC,WAAW,CACXC,UAAU,CACVC,OAAO,CACPC,cAAc,CACdC,EAAE,CACF,GAAGC,IACgC,CAAC,GAAgB,CACpD;AACF;AACA;AACA;AACA,4CACE,GAAIT,QAAQ,EAAIC,QAAQ,EAAII,UAAU,EAChCG,EAAE,CAAYE,KAAK,CAAC,uBAAuB,CAAC,CAAE,CAClD,mBACEd,IAAA,MACEG,SAAS,CAAEA,SACX;AACA;AACA;AACA;AAAA,CACAY,IAAI,CAAEH,EAAa,CACnBL,OAAO,CAAEH,QAAQ,CAAIY,CAAC,EAAK,CACzBA,CAAC,CAACC,cAAc,CAAC,CACnB,CAAC,CAAGV,OAAQ,CACZC,WAAW,CAAEJ,QAAQ,CAAIY,CAAC,EAAK,CAC7BA,CAAC,CAACC,cAAc,CAAC,CACnB,CAAC,CAAGT,WAAY,CAChBU,GAAG,CAAC,qBAAqB,CACzBC,SAAS,CAAC,MAAM,CAChBC,MAAM,CAAEX,UAAU,CAAG,QAAQ,CAAG,EAAG,CAAAP,QAAA,CAElCA,QAAQ,CACR,CAEP,CAEA,KAAM,CAAAmB,CAAC,CAAGV,cAAc,CAExB,mBACEX,IAAA,CAACqB,CAAC,EACAlB,SAAS,CAAEA,SAAU,CACrBmB,QAAQ,CAAC,MACT;AAAA,CACAf,OAAO,CAAGS,CAAsC,EAAK,CACnD;AACA,GAAIT,OAAO,CAAEA,OAAO,CAACS,CAAC,CAAC,CAEvB;AACA,GAAI,CAACV,kBAAkB,CAAEiB,MAAM,CAACC,MAAM,CAAC,CAAC,CAAE,CAAC,CAC7C,CAAE,CACFhB,WAAW,CAAEA,WAAY,CACzBE,OAAO,CAAEA,OAAQ,CACjBE,EAAE,CAAEA,EACJ;AACA;AAAA,IACIC,IAAI,CAAAX,QAAA,CAEPA,QAAQ,CACR,CAEP,CAAC,CAED,cAAe,CAAAD,WAAW","ignoreList":[]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
import{useRef,useState}from"react";import themed from"@dr.pogodin/react-themes";const defaultTheme={"context":"-Jj9Dp","ad":"IOZUc8","hoc":"nSzLXc","container":"wW08uK","children":"hCuQWP","input":"oYQ-Uo","label":"OTmX5n","error":"_7jrZ-X","errorMessage":"qjYbwz"};import{jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";/**
|
|
2
2
|
* Themeable input field, based on the standard HTML `<input>` element.
|
|
3
3
|
* @param [props.label] Input label.
|
|
4
4
|
* @param [props.theme] _Ad hoc_ theme.
|
|
@@ -7,12 +7,12 @@
|
|
|
7
7
|
* `<input>` element.
|
|
8
8
|
*/const Input=({children,error,label,ref,testId,theme,...rest})=>{// NOTE: As of now, it is only updated when "theme.focused" is defined,
|
|
9
9
|
// as otherwise its value is not used.
|
|
10
|
-
const[focused,setFocused]=
|
|
10
|
+
const[focused,setFocused]=useState(false);const localRef=useRef(null);let containerClassName=theme.container;// NOTE: As of now, "focused" can be true only when "theme.focused"
|
|
11
11
|
// is provided.
|
|
12
|
-
if(focused/* && theme.focused */)containerClassName+=` ${theme.focused}`;if(!rest.value&&theme.empty)containerClassName+=` ${theme.empty}`;if(error)containerClassName+=` ${theme.error}`;return/*#__PURE__*/(
|
|
12
|
+
if(focused/* && theme.focused */)containerClassName+=` ${theme.focused}`;if(!rest.value&&theme.empty)containerClassName+=` ${theme.empty}`;if(error)containerClassName+=` ${theme.error}`;return/*#__PURE__*/_jsxs("div",{className:containerClassName,onFocus:()=>{// TODO: It does not really work if a callback-style `ref` is passed in,
|
|
13
13
|
// we need a more complex logic to cover that case, but for now this serves
|
|
14
14
|
// the case we need it for.
|
|
15
|
-
if(typeof ref==="object")ref?.current?.focus();else localRef.current?.focus()},children:[label===undefined?null:/*#__PURE__*/(
|
|
15
|
+
if(typeof ref==="object")ref?.current?.focus();else localRef.current?.focus()},children:[label===undefined?null:/*#__PURE__*/_jsx("div",{className:theme.label,children:label}),/*#__PURE__*/_jsx("input",{className:theme.input,"data-testid":process.env.NODE_ENV==="production"?undefined:testId,ref:ref??localRef// TODO: Avoid the spreading later.
|
|
16
16
|
// eslint-disable-next-line react/jsx-props-no-spreading
|
|
17
|
-
,...rest,onBlur:theme.focused?e=>{setFocused(false);rest.onBlur?.(e)}:rest.onBlur,onFocus:theme.focused?e=>{setFocused(true);rest.onFocus?.(e)}:rest.onFocus}),error&&error!==true?/*#__PURE__*/(
|
|
17
|
+
,...rest,onBlur:theme.focused?e=>{setFocused(false);rest.onBlur?.(e)}:rest.onBlur,onFocus:theme.focused?e=>{setFocused(true);rest.onFocus?.(e)}:rest.onFocus}),error&&error!==true?/*#__PURE__*/_jsx("div",{className:theme.errorMessage,children:error}):null,children?/*#__PURE__*/_jsx("div",{className:theme.children,children:children}):null]})};export default/* #__PURE__ */themed(Input,"Input",defaultTheme);
|
|
18
18
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["
|
|
1
|
+
{"version":3,"file":"index.js","names":["useRef","useState","themed","defaultTheme","jsx","_jsx","jsxs","_jsxs","Input","children","error","label","ref","testId","theme","rest","focused","setFocused","localRef","containerClassName","container","value","empty","className","onFocus","current","focus","undefined","input","process","env","NODE_ENV","onBlur","e","errorMessage"],"sources":["../../../../../src/shared/components/Input/index.tsx"],"sourcesContent":["import {\n type FunctionComponent,\n type ReactNode,\n type Ref,\n useRef,\n useState,\n} from 'react';\n\nimport themed, { type Theme } from '@dr.pogodin/react-themes';\n\nimport defaultTheme from './theme.scss';\n\ntype ThemeKeyT = 'children' | 'container' | 'empty' | 'error' | 'errorMessage'\n | 'focused' | 'input' | 'label';\n\ntype PropsT = React.InputHTMLAttributes<HTMLInputElement> & {\n children?: ReactNode;\n error?: ReactNode;\n label?: React.ReactNode;\n ref?: Ref<HTMLInputElement>;\n testId?: string;\n theme: Theme<ThemeKeyT>;\n};\n\n/**\n * Themeable input field, based on the standard HTML `<input>` element.\n * @param [props.label] Input label.\n * @param [props.theme] _Ad hoc_ theme.\n * @param [props...] [Other theming properties](https://www.npmjs.com/package/@dr.pogodin/react-themes#themed-component-properties)\n * @param [props...] Any other properties are passed to the underlying\n * `<input>` element.\n */\nconst Input: FunctionComponent<PropsT> = ({\n children,\n error,\n label,\n ref,\n testId,\n theme,\n ...rest\n}) => {\n // NOTE: As of now, it is only updated when \"theme.focused\" is defined,\n // as otherwise its value is not used.\n const [focused, setFocused] = useState(false);\n\n const localRef = useRef<HTMLInputElement>(null);\n\n let containerClassName = theme.container;\n\n // NOTE: As of now, \"focused\" can be true only when \"theme.focused\"\n // is provided.\n if (focused /* && theme.focused */) containerClassName += ` ${theme.focused}`;\n\n if (!rest.value && theme.empty) containerClassName += ` ${theme.empty}`;\n\n if (error) containerClassName += ` ${theme.error}`;\n\n return (\n <div\n className={containerClassName}\n onFocus={() => {\n // TODO: It does not really work if a callback-style `ref` is passed in,\n // we need a more complex logic to cover that case, but for now this serves\n // the case we need it for.\n if (typeof ref === 'object') ref?.current?.focus();\n else localRef.current?.focus();\n }}\n >\n {label === undefined ? null : <div className={theme.label}>{label}</div>}\n <input\n className={theme.input}\n data-testid={process.env.NODE_ENV === 'production' ? undefined : testId}\n ref={ref ?? localRef}\n\n // TODO: Avoid the spreading later.\n // eslint-disable-next-line react/jsx-props-no-spreading\n {...rest}\n\n onBlur={theme.focused ? (e) => {\n setFocused(false);\n rest.onBlur?.(e);\n } : rest.onBlur}\n onFocus={theme.focused ? (e) => {\n setFocused(true);\n rest.onFocus?.(e);\n } : rest.onFocus}\n />\n {error && error !== true\n ? <div className={theme.errorMessage}>{error}</div>\n : null}\n {children ? <div className={theme.children}>{children}</div> : null}\n </div>\n );\n};\n\nexport default /* #__PURE__ */ themed(Input, 'Input', defaultTheme);\n"],"mappings":"AAAA,OAIEA,MAAM,CACNC,QAAQ,KACH,OAAO,CAEd,MAAO,CAAAC,MAAM,KAAsB,0BAA0B,OAAAC,YAAA,wKAErB,OAAAC,GAAA,IAAAC,IAAA,CAAAC,IAAA,IAAAC,KAAA,yBAcxC;AACA;AACA;AACA;AACA;AACA;AACA;AACA,GACA,KAAM,CAAAC,KAAgC,CAAGA,CAAC,CACxCC,QAAQ,CACRC,KAAK,CACLC,KAAK,CACLC,GAAG,CACHC,MAAM,CACNC,KAAK,CACL,GAAGC,IACL,CAAC,GAAK,CACJ;AACA;AACA,KAAM,CAACC,OAAO,CAAEC,UAAU,CAAC,CAAGhB,QAAQ,CAAC,KAAK,CAAC,CAE7C,KAAM,CAAAiB,QAAQ,CAAGlB,MAAM,CAAmB,IAAI,CAAC,CAE/C,GAAI,CAAAmB,kBAAkB,CAAGL,KAAK,CAACM,SAAS,CAExC;AACA;AACA,GAAIJ,OAAQ,uBAAwBG,kBAAkB,EAAI,IAAIL,KAAK,CAACE,OAAO,EAAE,CAE7E,GAAI,CAACD,IAAI,CAACM,KAAK,EAAIP,KAAK,CAACQ,KAAK,CAAEH,kBAAkB,EAAI,IAAIL,KAAK,CAACQ,KAAK,EAAE,CAEvE,GAAIZ,KAAK,CAAES,kBAAkB,EAAI,IAAIL,KAAK,CAACJ,KAAK,EAAE,CAElD,mBACEH,KAAA,QACEgB,SAAS,CAAEJ,kBAAmB,CAC9BK,OAAO,CAAEA,CAAA,GAAM,CACb;AACA;AACA;AACA,GAAI,MAAO,CAAAZ,GAAG,GAAK,QAAQ,CAAEA,GAAG,EAAEa,OAAO,EAAEC,KAAK,CAAC,CAAC,CAAC,IAC9C,CAAAR,QAAQ,CAACO,OAAO,EAAEC,KAAK,CAAC,CAC/B,CAAE,CAAAjB,QAAA,EAEDE,KAAK,GAAKgB,SAAS,CAAG,IAAI,cAAGtB,IAAA,QAAKkB,SAAS,CAAET,KAAK,CAACH,KAAM,CAAAF,QAAA,CAAEE,KAAK,CAAM,CAAC,cACxEN,IAAA,UACEkB,SAAS,CAAET,KAAK,CAACc,KAAM,CACvB,cAAaC,OAAO,CAACC,GAAG,CAACC,QAAQ,GAAK,YAAY,CAAGJ,SAAS,CAAGd,MAAO,CACxED,GAAG,CAAEA,GAAG,EAAIM,QAEZ;AACA;AAAA,IACIH,IAAI,CAERiB,MAAM,CAAElB,KAAK,CAACE,OAAO,CAAIiB,CAAC,EAAK,CAC7BhB,UAAU,CAAC,KAAK,CAAC,CACjBF,IAAI,CAACiB,MAAM,GAAGC,CAAC,CACjB,CAAC,CAAGlB,IAAI,CAACiB,MAAO,CAChBR,OAAO,CAAEV,KAAK,CAACE,OAAO,CAAIiB,CAAC,EAAK,CAC9BhB,UAAU,CAAC,IAAI,CAAC,CAChBF,IAAI,CAACS,OAAO,GAAGS,CAAC,CAClB,CAAC,CAAGlB,IAAI,CAACS,OAAQ,CAClB,CAAC,CACDd,KAAK,EAAIA,KAAK,GAAK,IAAI,cACpBL,IAAA,QAAKkB,SAAS,CAAET,KAAK,CAACoB,YAAa,CAAAzB,QAAA,CAAEC,KAAK,CAAM,CAAC,CACjD,IAAI,CACPD,QAAQ,cAAGJ,IAAA,QAAKkB,SAAS,CAAET,KAAK,CAACL,QAAS,CAAAA,QAAA,CAAEA,QAAQ,CAAM,CAAC,CAAG,IAAI,EAChE,CAET,CAAC,CAED,cAAe,eAAgBP,MAAM,CAACM,KAAK,CAAE,OAAO,CAAEL,YAAY,CAAC","ignoreList":[]}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
|
|
1
|
+
/**
|
|
2
2
|
* The Link wraps around React Router's Link component, to automatically replace
|
|
3
3
|
* it by the regular <a> element when:
|
|
4
4
|
* - The target reference points to another domain;
|
|
5
5
|
* - User opts to open the reference in a new tab;
|
|
6
6
|
* - User explicitely opts to use <a>.
|
|
7
|
-
*/const Link=props=>/*#__PURE__*/(
|
|
7
|
+
*/import{Link as RrLink}from"react-router";import GenericLink from"./GenericLink/index.js";import{jsx as _jsx}from"react/jsx-runtime";const Link=props=>/*#__PURE__*/_jsx(GenericLink// TODO: Avoid the spreading later.
|
|
8
8
|
// eslint-disable-next-line react/jsx-props-no-spreading
|
|
9
|
-
,{...props,routerLinkType:
|
|
9
|
+
,{...props,routerLinkType:RrLink});export default Link;
|
|
10
10
|
//# sourceMappingURL=Link.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Link.js","names":["
|
|
1
|
+
{"version":3,"file":"Link.js","names":["Link","RrLink","GenericLink","jsx","_jsx","props","routerLinkType"],"sources":["../../../../src/shared/components/Link.tsx"],"sourcesContent":["/**\n * The Link wraps around React Router's Link component, to automatically replace\n * it by the regular <a> element when:\n * - The target reference points to another domain;\n * - User opts to open the reference in a new tab;\n * - User explicitely opts to use <a>.\n */\n\nimport { type LinkProps, Link as RrLink } from 'react-router';\n\nimport GenericLink, { type PropsT as GenericLinkPropsT } from './GenericLink';\n\ntype PropsT = Omit<GenericLinkPropsT, 'routerLinkType'> & LinkProps;\n\nconst Link: React.FunctionComponent<PropsT>\n = (props) => (\n <GenericLink\n // TODO: Avoid the spreading later.\n // eslint-disable-next-line react/jsx-props-no-spreading\n {...props}\n routerLinkType={RrLink}\n />\n );\n\nexport default Link;\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA,GAEA,OAAyBA,IAAI,GAAI,CAAAC,MAAM,KAAQ,cAAc,OAEtD,CAAAC,WAAW,8BAA4D,OAAAC,GAAA,IAAAC,IAAA,yBAI9E,KAAM,CAAAJ,IAAqC,CACtCK,KAAK,eACND,IAAA,CAACF,WACC;AACA;AAAA,KACIG,KAAK,CACTC,cAAc,CAAEL,MAAO,CACxB,CACF,CAEH,cAAe,CAAAD,IAAI","ignoreList":[]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
import{useEffect,useMemo,useRef}from"react";import{createPortal}from"react-dom";import themed from"@dr.pogodin/react-themes";const baseTheme={"context":"sCYXfW","ad":"e0BH-f","hoc":"vqUuSP","overlay":"uAH4as","container":"zqpc6q"};const S={"scrollingDisabledByModal":"yfvOIZ"};import{jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";/**
|
|
2
2
|
* The `<Modal>` component implements a simple themeable modal window, wrapped
|
|
3
3
|
* into the default theme. `<BaseModal>` exposes the base non-themed component.
|
|
4
4
|
* **Children:** Component children are rendered as the modal content.
|
|
@@ -8,12 +8,12 @@
|
|
|
8
8
|
* clicks outside the modal, or presses Escape. It is expected to hide the
|
|
9
9
|
* modal.
|
|
10
10
|
* @param {ModalTheme} [props.theme] _Ad hoc_ theme.
|
|
11
|
-
*/const BaseModal=({cancelOnScrolling,children,containerStyle,dontDisableScrolling,onCancel,overlayStyle,style,testId,testIdForOverlay,theme})=>{const containerRef=
|
|
12
|
-
|
|
13
|
-
|
|
11
|
+
*/const BaseModal=({cancelOnScrolling,children,containerStyle,dontDisableScrolling,onCancel,overlayStyle,style,testId,testIdForOverlay,theme})=>{const containerRef=useRef(null);const overlayRef=useRef(null);// Sets up modal cancellation of scrolling, if opted-in.
|
|
12
|
+
useEffect(()=>{if(cancelOnScrolling&&onCancel){window.addEventListener("scroll",onCancel);window.addEventListener("wheel",onCancel)}return()=>{if(cancelOnScrolling&&onCancel){window.removeEventListener("scroll",onCancel);window.removeEventListener("wheel",onCancel)}}},[cancelOnScrolling,onCancel]);// Disables window scrolling, if it is not opted-out.
|
|
13
|
+
useEffect(()=>{if(!dontDisableScrolling){document.body.classList.add(S.scrollingDisabledByModal)}return()=>{if(!dontDisableScrolling){document.body.classList.remove(S.scrollingDisabledByModal)}}},[dontDisableScrolling]);const focusLast=useMemo(()=>/*#__PURE__*/_jsx("div",{onFocus:()=>{const elems=containerRef.current.querySelectorAll("*");for(let i=elems.length-1;i>=0;--i){elems[i].focus();if(document.activeElement===elems[i])return}overlayRef.current?.focus()}// TODO: Have a look at this later.
|
|
14
14
|
// eslint-disable-next-line jsx-a11y/no-noninteractive-tabindex
|
|
15
|
-
,tabIndex:0}),[]);return/*#__PURE__*/
|
|
16
|
-
"aria-modal":"true",className:theme.container,"data-testid":process.env.NODE_ENV==="production"?undefined:testId,onClick:e=>{e.stopPropagation()},onWheel:event=>{event.stopPropagation()},ref:containerRef,role:"dialog",style:style??containerStyle,children:children}),/*#__PURE__*/(
|
|
15
|
+
,tabIndex:0}),[]);return/*#__PURE__*/createPortal(/*#__PURE__*/_jsxs("div",{children:[focusLast,/*#__PURE__*/_jsx("div",{"aria-label":"Cancel",className:theme.overlay,"data-testid":process.env.NODE_ENV==="production"?undefined:testIdForOverlay,onClick:e=>{if(onCancel){onCancel();e.stopPropagation()}},onKeyDown:e=>{if(e.key==="Escape"&&onCancel){onCancel();e.stopPropagation()}},ref:node=>{if(node&&node!==overlayRef.current){overlayRef.current=node;node.focus()}},role:"button",style:overlayStyle,tabIndex:0}),/*#__PURE__*/_jsx("div",{// eslint-disable-line jsx-a11y/click-events-have-key-events, jsx-a11y/no-noninteractive-element-interactions
|
|
16
|
+
"aria-modal":"true",className:theme.container,"data-testid":process.env.NODE_ENV==="production"?undefined:testId,onClick:e=>{e.stopPropagation()},onWheel:event=>{event.stopPropagation()},ref:containerRef,role:"dialog",style:style??containerStyle,children:children}),/*#__PURE__*/_jsx("div",{onFocus:()=>{overlayRef.current?.focus()}// TODO: Have a look at this later.
|
|
17
17
|
// eslint-disable-next-line jsx-a11y/no-noninteractive-tabindex
|
|
18
|
-
,tabIndex:0}),focusLast]}),document.body)};
|
|
18
|
+
,tabIndex:0}),focusLast]}),document.body)};export default/* #__PURE__ */themed(BaseModal,"Modal",baseTheme);/* Non-themed version of the Modal. */export{BaseModal};
|
|
19
19
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["
|
|
1
|
+
{"version":3,"file":"index.js","names":["useEffect","useMemo","useRef","createPortal","themed","baseTheme","S","jsx","_jsx","jsxs","_jsxs","BaseModal","cancelOnScrolling","children","containerStyle","dontDisableScrolling","onCancel","overlayStyle","style","testId","testIdForOverlay","theme","containerRef","overlayRef","window","addEventListener","removeEventListener","document","body","classList","add","scrollingDisabledByModal","remove","focusLast","onFocus","elems","current","querySelectorAll","i","length","focus","activeElement","tabIndex","className","overlay","process","env","NODE_ENV","undefined","onClick","e","stopPropagation","onKeyDown","key","ref","node","role","container","onWheel","event"],"sources":["../../../../../src/shared/components/Modal/index.tsx"],"sourcesContent":["import {\n type CSSProperties,\n type FunctionComponent,\n type ReactNode,\n useEffect,\n useMemo,\n useRef,\n} from 'react';\n\nimport { createPortal } from 'react-dom';\nimport themed, { type Theme } from '@dr.pogodin/react-themes';\n\nimport baseTheme from './base-theme.scss';\nimport S from './styles.scss';\n\ntype PropsT = {\n cancelOnScrolling?: boolean;\n children?: ReactNode;\n dontDisableScrolling?: boolean;\n onCancel?: () => void;\n overlayStyle?: CSSProperties;\n style?: CSSProperties;\n testId?: string;\n testIdForOverlay?: string;\n theme: Theme<'container' | 'overlay'>;\n\n /** @deprecated */\n containerStyle?: CSSProperties;\n};\n\n/**\n * The `<Modal>` component implements a simple themeable modal window, wrapped\n * into the default theme. `<BaseModal>` exposes the base non-themed component.\n * **Children:** Component children are rendered as the modal content.\n * @param {object} props Component properties. Beside props documented below,\n * [Other theming properties](https://www.npmjs.com/package/@dr.pogodin/react-themes#themed-component-properties) are supported as well.\n * @param {function} [props.onCancel] The callback to trigger when user\n * clicks outside the modal, or presses Escape. It is expected to hide the\n * modal.\n * @param {ModalTheme} [props.theme] _Ad hoc_ theme.\n */\nconst BaseModal: FunctionComponent<PropsT> = ({\n cancelOnScrolling,\n children,\n containerStyle,\n dontDisableScrolling,\n onCancel,\n overlayStyle,\n style,\n testId,\n testIdForOverlay,\n theme,\n}) => {\n const containerRef = useRef<HTMLDivElement | null>(null);\n const overlayRef = useRef<HTMLDivElement | null>(null);\n\n // Sets up modal cancellation of scrolling, if opted-in.\n useEffect(() => {\n if (cancelOnScrolling && onCancel) {\n window.addEventListener('scroll', onCancel);\n window.addEventListener('wheel', onCancel);\n }\n return () => {\n if (cancelOnScrolling && onCancel) {\n window.removeEventListener('scroll', onCancel);\n window.removeEventListener('wheel', onCancel);\n }\n };\n }, [cancelOnScrolling, onCancel]);\n\n // Disables window scrolling, if it is not opted-out.\n useEffect(() => {\n if (!dontDisableScrolling) {\n document.body.classList.add(S.scrollingDisabledByModal);\n }\n return () => {\n if (!dontDisableScrolling) {\n document.body.classList.remove(S.scrollingDisabledByModal);\n }\n };\n }, [dontDisableScrolling]);\n\n const focusLast = useMemo(() => (\n <div\n onFocus={() => {\n const elems = containerRef.current!.querySelectorAll('*');\n for (let i = elems.length - 1; i >= 0; --i) {\n (elems[i] as HTMLElement).focus();\n if (document.activeElement === elems[i]) return;\n }\n overlayRef.current?.focus();\n }}\n // TODO: Have a look at this later.\n // eslint-disable-next-line jsx-a11y/no-noninteractive-tabindex\n tabIndex={0}\n />\n ), []);\n\n return createPortal(\n (\n <div>\n {focusLast}\n <div\n aria-label=\"Cancel\"\n className={theme.overlay}\n data-testid={\n process.env.NODE_ENV === 'production'\n ? undefined : testIdForOverlay\n }\n onClick={(e) => {\n if (onCancel) {\n onCancel();\n e.stopPropagation();\n }\n }}\n onKeyDown={(e) => {\n if (e.key === 'Escape' && onCancel) {\n onCancel();\n e.stopPropagation();\n }\n }}\n ref={(node) => {\n if (node && node !== overlayRef.current) {\n overlayRef.current = node;\n node.focus();\n }\n }}\n role=\"button\"\n style={overlayStyle}\n tabIndex={0}\n />\n {\n // NOTE: These rules are disabled because our intention is to keep\n // the element non-interactive (thus not on the keyboard focus chain),\n // and it has `onClick` handler merely to stop propagation of click\n // events to its parent container. This is needed because, for example\n // when the modal is wrapped into an interactive element we don't want\n // any clicks inside the modal to bubble-up to that parent element\n // (because visually and logically the modal dialog does not belong\n // to its parent container, where it technically belongs from\n // the HTML mark-up perpective).\n }\n <div // eslint-disable-line jsx-a11y/click-events-have-key-events, jsx-a11y/no-noninteractive-element-interactions\n aria-modal=\"true\"\n className={theme.container}\n data-testid={process.env.NODE_ENV === 'production' ? undefined : testId}\n onClick={(e) => {\n e.stopPropagation();\n }}\n onWheel={(event) => {\n event.stopPropagation();\n }}\n ref={containerRef}\n role=\"dialog\"\n style={style ?? containerStyle}\n >\n {children}\n </div>\n <div\n onFocus={() => {\n overlayRef.current?.focus();\n }}\n // TODO: Have a look at this later.\n // eslint-disable-next-line jsx-a11y/no-noninteractive-tabindex\n tabIndex={0}\n />\n {focusLast}\n </div>\n ),\n document.body,\n );\n};\n\nexport default /* #__PURE__ */ themed(BaseModal, 'Modal', baseTheme);\n\n/* Non-themed version of the Modal. */\nexport { BaseModal };\n"],"mappings":"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","ignoreList":[]}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
|
|
1
|
+
import{NavLink as RrNavLink}from"react-router";import GenericLink from"./GenericLink/index.js";import{jsx as _jsx}from"react/jsx-runtime";const NavLink=props=>/*#__PURE__*/_jsx(GenericLink// TODO: I guess, we better re-write it to avoid the props spreading,
|
|
2
2
|
// but no need to spend time on it right now.
|
|
3
3
|
// eslint-disable-next-line react/jsx-props-no-spreading
|
|
4
|
-
,{...props,routerLinkType:
|
|
4
|
+
,{...props,routerLinkType:RrNavLink});export default NavLink;
|
|
5
5
|
//# sourceMappingURL=NavLink.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NavLink.js","names":["
|
|
1
|
+
{"version":3,"file":"NavLink.js","names":["NavLink","RrNavLink","GenericLink","jsx","_jsx","props","routerLinkType"],"sources":["../../../../src/shared/components/NavLink.tsx"],"sourcesContent":["import { type NavLinkProps, NavLink as RrNavLink } from 'react-router';\n\nimport GenericLink, { type PropsT as GenericLinkPropsT } from './GenericLink';\n\ntype PropsT = Omit<GenericLinkPropsT, 'routerLinkType'> & NavLinkProps;\n\nconst NavLink: React.FunctionComponent<PropsT>\n = (props) => (\n <GenericLink\n // TODO: I guess, we better re-write it to avoid the props spreading,\n // but no need to spend time on it right now.\n // eslint-disable-next-line react/jsx-props-no-spreading\n {...props}\n routerLinkType={RrNavLink}\n />\n );\n\nexport default NavLink;\n"],"mappings":"AAAA,OAA4BA,OAAO,GAAI,CAAAC,SAAS,KAAQ,cAAc,OAE/D,CAAAC,WAAW,8BAA4D,OAAAC,GAAA,IAAAC,IAAA,yBAI9E,KAAM,CAAAJ,OAAwC,CACzCK,KAAK,eACND,IAAA,CAACF,WACC;AACA;AACA;AAAA,KACIG,KAAK,CACTC,cAAc,CAAEL,SAAU,CAC3B,CACF,CAEH,cAAe,CAAAD,OAAO","ignoreList":[]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
import themed from"@dr.pogodin/react-themes";const baseTheme={"context":"zv9tdn","ad":"yr8hbI","hoc":"_01Mz0J","container":"blPmpk","mainPanel":"zPoY0u","sidePanel":"mRD159"};import{jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";/**
|
|
2
2
|
* Simple and themeable page layout. It keeps the main content centered in
|
|
3
3
|
* a column of limited width, which fills entire viewport on small screens
|
|
4
4
|
* (under `$screen-md = 1024px` size). At larger screens the column keeps
|
|
@@ -12,5 +12,5 @@
|
|
|
12
12
|
* @param {PageLayoutTheme} [props.theme] _Ad hoc_ theme.
|
|
13
13
|
* @param {...any} [props....]
|
|
14
14
|
* [Other theming properties](https://www.npmjs.com/package/@dr.pogodin/react-themes#themed-component-properties)
|
|
15
|
-
*/const PageLayout=({children,leftSidePanelContent,rightSidePanelContent,theme})=>/*#__PURE__*/(
|
|
15
|
+
*/const PageLayout=({children,leftSidePanelContent,rightSidePanelContent,theme})=>/*#__PURE__*/_jsxs("div",{className:theme.container,children:[/*#__PURE__*/_jsx("div",{className:[theme.sidePanel,theme.leftSidePanel].join(" "),children:leftSidePanelContent}),/*#__PURE__*/_jsx("div",{className:theme.mainPanel,children:children}),/*#__PURE__*/_jsx("div",{className:[theme.sidePanel,theme.rightSidePanel].join(" "),children:rightSidePanelContent})]});export default/* #__PURE__ */themed(PageLayout,"PageLayout",baseTheme);
|
|
16
16
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["
|
|
1
|
+
{"version":3,"file":"index.js","names":["themed","baseTheme","jsx","_jsx","jsxs","_jsxs","PageLayout","children","leftSidePanelContent","rightSidePanelContent","theme","className","container","sidePanel","leftSidePanel","join","mainPanel","rightSidePanel"],"sources":["../../../../../src/shared/components/PageLayout/index.tsx"],"sourcesContent":["import type { ReactNode } from 'react';\n\nimport themed, { type Theme } from '@dr.pogodin/react-themes';\n\nimport baseTheme from './base-theme.scss';\n\ntype ThemeKeyT = 'container' | 'leftSidePanel' | 'mainPanel' | 'rightSidePanel'\n | 'sidePanel';\n\ntype PropsT = {\n children?: ReactNode;\n leftSidePanelContent?: ReactNode;\n rightSidePanelContent?: ReactNode;\n theme: Theme<ThemeKeyT>;\n};\n\n/**\n * Simple and themeable page layout. It keeps the main content centered in\n * a column of limited width, which fills entire viewport on small screens\n * (under `$screen-md = 1024px` size). At larger screens the column keeps\n * `$screen-md` size, and it is centered at the page, surrounded by side\n * panels, where additional content can be displayed.\n *\n * **Children:** Component children are rendered as the content of main panel.\n * @param {object} [props] Component properties.\n * @param {Node} [props.leftSidePanelContent] The content for left side panel.\n * @param {Node} [props.rightSidePanelContent] The content for right side panel.\n * @param {PageLayoutTheme} [props.theme] _Ad hoc_ theme.\n * @param {...any} [props....]\n * [Other theming properties](https://www.npmjs.com/package/@dr.pogodin/react-themes#themed-component-properties)\n */\nconst PageLayout: React.FunctionComponent<PropsT> = ({\n children,\n leftSidePanelContent,\n rightSidePanelContent,\n theme,\n}) => (\n <div className={theme.container}>\n <div className={[theme.sidePanel, theme.leftSidePanel].join(' ')}>\n {leftSidePanelContent}\n </div>\n <div className={theme.mainPanel}>\n {children}\n </div>\n <div className={[theme.sidePanel, theme.rightSidePanel].join(' ')}>\n {rightSidePanelContent}\n </div>\n </div>\n);\n\nexport default /* #__PURE__ */ themed(PageLayout, 'PageLayout', baseTheme);\n"],"mappings":"AAEA,MAAO,CAAAA,MAAM,KAAsB,0BAA0B,OAAAC,SAAA,mHAEnB,OAAAC,GAAA,IAAAC,IAAA,CAAAC,IAAA,IAAAC,KAAA,yBAY1C;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,GACA,KAAM,CAAAC,UAA2C,CAAGA,CAAC,CACnDC,QAAQ,CACRC,oBAAoB,CACpBC,qBAAqB,CACrBC,KACF,CAAC,gBACCL,KAAA,QAAKM,SAAS,CAAED,KAAK,CAACE,SAAU,CAAAL,QAAA,eAC9BJ,IAAA,QAAKQ,SAAS,CAAE,CAACD,KAAK,CAACG,SAAS,CAAEH,KAAK,CAACI,aAAa,CAAC,CAACC,IAAI,CAAC,GAAG,CAAE,CAAAR,QAAA,CAC9DC,oBAAoB,CAClB,CAAC,cACNL,IAAA,QAAKQ,SAAS,CAAED,KAAK,CAACM,SAAU,CAAAT,QAAA,CAC7BA,QAAQ,CACN,CAAC,cACNJ,IAAA,QAAKQ,SAAS,CAAE,CAACD,KAAK,CAACG,SAAS,CAAEH,KAAK,CAACO,cAAc,CAAC,CAACF,IAAI,CAAC,GAAG,CAAE,CAAAR,QAAA,CAC/DE,qBAAqB,CACnB,CAAC,EACH,CACN,CAED,cAAe,eAAgBT,MAAM,CAACM,UAAU,CAAE,YAAY,CAAEL,SAAS,CAAC","ignoreList":[]}
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
import{useEffect,useLayoutEffect,useRef,useState}from"react";import themed from"@dr.pogodin/react-themes";const defaultTheme={"context":"tECG8C","ad":"epeH4O","hoc":"_2kFnSt","container":"lV5ZyX","label":"_7qDPW1","textarea":"gkaNJJ","error":"ObwtG4","errorMessage":"ikIw0x","hidden":"-UyujK"};import{jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";const TextArea=({disabled,error,label,onBlur,onChange,onKeyDown,placeholder,testId,theme,value})=>{const hiddenAreaRef=useRef(null);const[height,setHeight]=useState();const textAreaRef=useRef(null);const[localValue,setLocalValue]=useState(value??"");if(value!==undefined&&localValue!==value)setLocalValue(value);// This resizes text area's height when its width is changed for any reason.
|
|
2
|
+
useEffect(()=>{const el=hiddenAreaRef.current;if(!el)return undefined;const cb=()=>{setHeight(el.scrollHeight)};const observer=new ResizeObserver(cb);observer.observe(el);return()=>{observer.disconnect()}},[]);// Resizes the text area when its content is modified.
|
|
3
3
|
//
|
|
4
4
|
// NOTE: useLayoutEffect() instead of useEffect() makes difference here,
|
|
5
5
|
// as it helps to avoid visible "content/height" jumps (i.e. with just
|
|
6
6
|
// useEffect() it becomes visible how the content is modified first,
|
|
7
7
|
// and then input height is incremented, if necessary).
|
|
8
8
|
// See: https://github.com/birdofpreyru/react-utils/issues/313
|
|
9
|
-
|
|
9
|
+
useLayoutEffect(()=>{const el=hiddenAreaRef.current;if(el)setHeight(el.scrollHeight)},[localValue]);let containerClassName=theme.container;if(error)containerClassName+=` ${theme.error}`;return/*#__PURE__*/_jsxs("div",{className:containerClassName,onFocus:()=>{textAreaRef.current?.focus()},children:[label===undefined?null:/*#__PURE__*/_jsx("div",{className:theme.label,children:label}),/*#__PURE__*/_jsx("textarea",{className:`${theme.textarea} ${theme.hidden}`// This text area is hidden underneath the primary one below,
|
|
10
10
|
// and it is used for text measurements, to implement auto-scaling
|
|
11
11
|
// of the primary textarea's height.
|
|
12
12
|
,readOnly:true,ref:hiddenAreaRef// The "-1" value of "tabIndex" removes this hidden text area from
|
|
@@ -15,8 +15,8 @@
|
|
|
15
15
|
// area is zero, thus collapsing <TextArea> height below the single line
|
|
16
16
|
// input height. To avoid it we fallback to whitespace (" ") character
|
|
17
17
|
// here.
|
|
18
|
-
,value:localValue||" "}),/*#__PURE__*/(
|
|
18
|
+
,value:localValue||" "}),/*#__PURE__*/_jsx("textarea",{className:theme.textarea,"data-testid":process.env.NODE_ENV==="production"?undefined:testId,disabled:disabled,onBlur:onBlur// When value is "undefined" the text area is not-managed, and we should
|
|
19
19
|
// manage it internally for the measurement / resizing functionality
|
|
20
20
|
// to work.
|
|
21
|
-
,onChange:value===undefined?e=>{setLocalValue(e.target.value)}:onChange,onKeyDown:onKeyDown,placeholder:placeholder,ref:textAreaRef,style:{height},value:localValue}),error&&error!==true?/*#__PURE__*/(
|
|
21
|
+
,onChange:value===undefined?e=>{setLocalValue(e.target.value)}:onChange,onKeyDown:onKeyDown,placeholder:placeholder,ref:textAreaRef,style:{height},value:localValue}),error&&error!==true?/*#__PURE__*/_jsx("div",{className:theme.errorMessage,children:error}):null]})};export default/* #__PURE__ */themed(TextArea,"TextArea",defaultTheme);
|
|
22
22
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["
|
|
1
|
+
{"version":3,"file":"index.js","names":["useEffect","useLayoutEffect","useRef","useState","themed","defaultTheme","jsx","_jsx","jsxs","_jsxs","TextArea","disabled","error","label","onBlur","onChange","onKeyDown","placeholder","testId","theme","value","hiddenAreaRef","height","setHeight","textAreaRef","localValue","setLocalValue","undefined","el","current","cb","scrollHeight","observer","ResizeObserver","observe","disconnect","containerClassName","container","className","onFocus","focus","children","textarea","hidden","readOnly","ref","tabIndex","process","env","NODE_ENV","e","target","style","errorMessage"],"sources":["../../../../../src/shared/components/TextArea/index.tsx"],"sourcesContent":["import {\n type ChangeEventHandler,\n type FocusEventHandler,\n type FunctionComponent,\n type KeyboardEventHandler,\n type ReactNode,\n useEffect,\n useLayoutEffect,\n useRef,\n useState,\n} from 'react';\n\nimport themed, { type Theme } from '@dr.pogodin/react-themes';\n\nimport defaultTheme from './style.scss';\n\ntype ThemeKeyT = 'container' | 'error' | 'errorMessage' | 'hidden' | 'label'\n | 'textarea';\n\ntype Props = {\n disabled?: boolean;\n error?: ReactNode;\n label?: string;\n onBlur?: FocusEventHandler<HTMLTextAreaElement>;\n onChange?: ChangeEventHandler<HTMLTextAreaElement>;\n onKeyDown?: KeyboardEventHandler<HTMLTextAreaElement>;\n placeholder?: string;\n testId?: string;\n theme: Theme<ThemeKeyT>;\n value?: string;\n};\n\nconst TextArea: FunctionComponent<Props> = ({\n disabled,\n error,\n label,\n onBlur,\n onChange,\n onKeyDown,\n placeholder,\n testId,\n theme,\n value,\n}) => {\n const hiddenAreaRef = useRef<HTMLTextAreaElement>(null);\n const [height, setHeight] = useState<number | undefined>();\n\n const textAreaRef = useRef<HTMLTextAreaElement>(null);\n\n const [localValue, setLocalValue] = useState(value ?? '');\n if (value !== undefined && localValue !== value) setLocalValue(value);\n\n // This resizes text area's height when its width is changed for any reason.\n useEffect(() => {\n const el = hiddenAreaRef.current;\n if (!el) return undefined;\n\n const cb = () => {\n setHeight(el.scrollHeight);\n };\n const observer = new ResizeObserver(cb);\n observer.observe(el);\n\n return () => {\n observer.disconnect();\n };\n }, []);\n\n // Resizes the text area when its content is modified.\n //\n // NOTE: useLayoutEffect() instead of useEffect() makes difference here,\n // as it helps to avoid visible \"content/height\" jumps (i.e. with just\n // useEffect() it becomes visible how the content is modified first,\n // and then input height is incremented, if necessary).\n // See: https://github.com/birdofpreyru/react-utils/issues/313\n useLayoutEffect(() => {\n const el = hiddenAreaRef.current;\n if (el) setHeight(el.scrollHeight);\n }, [localValue]);\n\n let containerClassName = theme.container;\n if (error) containerClassName += ` ${theme.error}`;\n\n return (\n <div\n className={containerClassName}\n onFocus={() => {\n textAreaRef.current?.focus();\n }}\n >\n {label === undefined ? null : <div className={theme.label}>{label}</div>}\n <textarea\n className={`${theme.textarea} ${theme.hidden}`}\n\n // This text area is hidden underneath the primary one below,\n // and it is used for text measurements, to implement auto-scaling\n // of the primary textarea's height.\n readOnly\n ref={hiddenAreaRef}\n\n // The \"-1\" value of \"tabIndex\" removes this hidden text area from\n // the tab-focus-chain.\n tabIndex={-1}\n\n // NOTE: With empty string value (\"\") the scrolling height of this text\n // area is zero, thus collapsing <TextArea> height below the single line\n // input height. To avoid it we fallback to whitespace (\" \") character\n // here.\n value={localValue || ' '}\n />\n <textarea\n className={theme.textarea}\n data-testid={process.env.NODE_ENV === 'production' ? undefined : testId}\n disabled={disabled}\n onBlur={onBlur}\n\n // When value is \"undefined\" the text area is not-managed, and we should\n // manage it internally for the measurement / resizing functionality\n // to work.\n onChange={\n value === undefined\n ? (e) => {\n setLocalValue(e.target.value);\n } : onChange\n }\n onKeyDown={onKeyDown}\n placeholder={placeholder}\n ref={textAreaRef}\n style={{ height }}\n value={localValue}\n />\n {error && error !== true\n ? <div className={theme.errorMessage}>{error}</div>\n : null}\n </div>\n );\n};\n\nexport default /* #__PURE__ */ themed(TextArea, 'TextArea', defaultTheme);\n"],"mappings":"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","ignoreList":[]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
import themed from"@dr.pogodin/react-themes";const defaultTheme={"context":"eVCJf-","ad":"CU2B6H","hoc":"_1V5iVx","bouncing":"h6ZYmQ","container":"VDVI-X","circle":"Y2rzbL"};import{jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";/**
|
|
2
2
|
* Throbber is an "action in progress" indicator, which renders
|
|
3
3
|
* three bouncing circles as a simple pending activity indicator,
|
|
4
4
|
* and can be further themed to a certain degree.
|
|
@@ -6,5 +6,5 @@
|
|
|
6
6
|
* @param {ThrobberTheme} [props.theme] _Ad hoc_ theme.
|
|
7
7
|
* @param {...any} [props....]
|
|
8
8
|
* [Other theming properties](https://www.npmjs.com/package/@dr.pogodin/react-themes#themed-component-properties)
|
|
9
|
-
*/const Throbber=({theme})=>/*#__PURE__*/(
|
|
9
|
+
*/const Throbber=({theme})=>/*#__PURE__*/_jsxs("span",{className:theme.container,children:[/*#__PURE__*/_jsx("span",{className:theme.circle}),/*#__PURE__*/_jsx("span",{className:theme.circle}),/*#__PURE__*/_jsx("span",{className:theme.circle})]});export default/* #__PURE__ */themed(Throbber,"Throbber",defaultTheme);
|
|
10
10
|
//# sourceMappingURL=index.js.map
|