@dr.pogodin/react-utils 1.25.5 → 1.26.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/babel.config.js +3 -1
- package/bin/build.js +25 -5
- package/build/development/client/getInj.js +9 -8
- package/build/development/client/getInj.js.map +1 -1
- package/build/development/client/index.js +6 -3
- package/build/development/client/index.js.map +1 -1
- package/build/development/client/init.js +4 -0
- package/build/development/client/init.js.map +1 -1
- package/build/development/index.js +168 -42
- package/build/development/index.js.map +1 -1
- package/build/development/server/Cache.js +13 -13
- package/build/development/server/Cache.js.map +1 -1
- package/build/development/server/index.js +16 -24
- package/build/development/server/index.js.map +1 -1
- package/build/development/server/renderer.js +56 -44
- package/build/development/server/renderer.js.map +1 -1
- package/build/development/server/server.js +9 -5
- package/build/development/server/server.js.map +1 -1
- package/build/development/server/utils/errors.js +12 -9
- package/build/development/server/utils/errors.js.map +1 -1
- package/build/development/server/utils/index.js +2 -2
- package/build/development/server/utils/index.js.map +1 -1
- package/build/development/shared/components/Button/index.js +8 -7
- package/build/development/shared/components/Button/index.js.map +1 -1
- package/build/development/shared/components/Checkbox/index.js +25 -28
- package/build/development/shared/components/Checkbox/index.js.map +1 -1
- package/build/development/shared/components/Dropdown/index.js +25 -19
- package/build/development/shared/components/Dropdown/index.js.map +1 -1
- package/build/development/shared/components/GenericLink/index.js +44 -37
- package/build/development/shared/components/GenericLink/index.js.map +1 -1
- package/build/development/shared/components/Input/index.js +8 -9
- package/build/development/shared/components/Input/index.js.map +1 -1
- package/build/development/shared/components/Link.js +10 -9
- package/build/development/shared/components/Link.js.map +1 -1
- package/build/development/shared/components/MetaTags.js +22 -18
- package/build/development/shared/components/MetaTags.js.map +1 -1
- package/build/development/shared/components/Modal/index.js +17 -18
- package/build/development/shared/components/Modal/index.js.map +1 -1
- package/build/development/shared/components/NavLink.js +10 -9
- package/build/development/shared/components/NavLink.js.map +1 -1
- package/build/development/shared/components/PageLayout/index.js +17 -20
- package/build/development/shared/components/PageLayout/index.js.map +1 -1
- package/build/development/shared/components/ScalableRect/index.js +27 -7
- package/build/development/shared/components/ScalableRect/index.js.map +1 -1
- package/build/development/shared/components/Throbber/index.js +14 -23
- package/build/development/shared/components/Throbber/index.js.map +1 -1
- package/build/development/shared/components/WithTooltip/Tooltip.js +20 -24
- package/build/development/shared/components/WithTooltip/Tooltip.js.map +1 -1
- package/build/development/shared/components/WithTooltip/index.js +11 -11
- package/build/development/shared/components/WithTooltip/index.js.map +1 -1
- package/build/development/shared/components/YouTubeVideo/index.js +16 -15
- package/build/development/shared/components/YouTubeVideo/index.js.map +1 -1
- package/build/development/shared/components/index.js +2 -2
- package/build/development/shared/components/index.js.map +1 -1
- package/build/development/shared/utils/config.js +1 -2
- package/build/development/shared/utils/config.js.map +1 -1
- package/build/development/shared/utils/globalState.js +15 -0
- package/build/development/shared/utils/globalState.js.map +1 -0
- package/build/development/shared/utils/index.js +13 -11
- package/build/development/shared/utils/index.js.map +1 -1
- package/build/development/shared/utils/isomorphy/buildInfo.js +7 -3
- package/build/development/shared/utils/isomorphy/buildInfo.js.map +1 -1
- package/build/development/shared/utils/isomorphy/environment-check.js +2 -4
- package/build/development/shared/utils/isomorphy/environment-check.js.map +1 -1
- package/build/development/shared/utils/isomorphy/index.js.map +1 -1
- package/build/development/shared/utils/jest/E2eSsrEnv.js +35 -28
- package/build/development/shared/utils/jest/E2eSsrEnv.js.map +1 -1
- package/build/development/shared/utils/jest/global.js +17 -0
- package/build/development/shared/utils/jest/global.js.map +1 -0
- package/build/development/shared/utils/jest/index.js +18 -11
- package/build/development/shared/utils/jest/index.js.map +1 -1
- package/build/development/shared/utils/splitComponent.js +25 -34
- package/build/development/shared/utils/splitComponent.js.map +1 -1
- package/build/development/shared/utils/time.js +16 -13
- package/build/development/shared/utils/time.js.map +1 -1
- package/build/development/shared/utils/webpack.js +3 -3
- package/build/development/shared/utils/webpack.js.map +1 -1
- package/build/development/web.bundle.js +92 -82
- package/build/production/client/getInj.js +1 -1
- package/build/production/client/getInj.js.map +1 -1
- package/build/production/client/index.js +4 -4
- package/build/production/client/index.js.map +1 -1
- package/build/production/client/init.js +3 -1
- package/build/production/client/init.js.map +1 -1
- package/build/production/index.js +1 -1
- package/build/production/index.js.map +1 -1
- package/build/production/server/Cache.js +7 -8
- package/build/production/server/Cache.js.map +1 -1
- package/build/production/server/index.js +5 -4
- package/build/production/server/index.js.map +1 -1
- package/build/production/server/renderer.js +32 -30
- package/build/production/server/renderer.js.map +1 -1
- package/build/production/server/server.js +7 -5
- package/build/production/server/server.js.map +1 -1
- package/build/production/server/utils/errors.js +9 -10
- package/build/production/server/utils/errors.js.map +1 -1
- package/build/production/server/utils/index.js +1 -1
- package/build/production/server/utils/index.js.map +1 -1
- package/build/production/shared/components/Button/index.js +4 -4
- package/build/production/shared/components/Button/index.js.map +1 -1
- package/build/production/shared/components/Checkbox/index.js +12 -12
- package/build/production/shared/components/Checkbox/index.js.map +1 -1
- package/build/production/shared/components/Dropdown/index.js +11 -11
- package/build/production/shared/components/Dropdown/index.js.map +1 -1
- package/build/production/shared/components/GenericLink/index.js +25 -20
- package/build/production/shared/components/GenericLink/index.js.map +1 -1
- package/build/production/shared/components/Input/index.js +7 -7
- package/build/production/shared/components/Input/index.js.map +1 -1
- package/build/production/shared/components/Link.js +2 -2
- package/build/production/shared/components/Link.js.map +1 -1
- package/build/production/shared/components/MetaTags.js +10 -10
- package/build/production/shared/components/MetaTags.js.map +1 -1
- package/build/production/shared/components/Modal/index.js +2 -2
- package/build/production/shared/components/Modal/index.js.map +1 -1
- package/build/production/shared/components/NavLink.js +1 -1
- package/build/production/shared/components/NavLink.js.map +1 -1
- package/build/production/shared/components/PageLayout/index.js +2 -2
- package/build/production/shared/components/PageLayout/index.js.map +1 -1
- package/build/production/shared/components/ScalableRect/index.js +7 -3
- package/build/production/shared/components/ScalableRect/index.js.map +1 -1
- package/build/production/shared/components/Throbber/index.js +2 -2
- package/build/production/shared/components/Throbber/index.js.map +1 -1
- package/build/production/shared/components/WithTooltip/Tooltip.js +13 -13
- package/build/production/shared/components/WithTooltip/Tooltip.js.map +1 -1
- package/build/production/shared/components/WithTooltip/index.js +3 -3
- package/build/production/shared/components/WithTooltip/index.js.map +1 -1
- package/build/production/shared/components/YouTubeVideo/index.js +7 -7
- package/build/production/shared/components/YouTubeVideo/index.js.map +1 -1
- package/build/production/shared/components/index.js +1 -1
- package/build/production/shared/components/index.js.map +1 -1
- package/build/production/shared/utils/config.js +1 -1
- package/build/production/shared/utils/config.js.map +1 -1
- package/build/production/shared/utils/globalState.js +3 -0
- package/build/production/shared/utils/globalState.js.map +1 -0
- package/build/production/shared/utils/index.js +3 -3
- package/build/production/shared/utils/index.js.map +1 -1
- package/build/production/shared/utils/isomorphy/buildInfo.js +7 -4
- package/build/production/shared/utils/isomorphy/buildInfo.js.map +1 -1
- package/build/production/shared/utils/isomorphy/environment-check.js +2 -2
- package/build/production/shared/utils/isomorphy/environment-check.js.map +1 -1
- package/build/production/shared/utils/isomorphy/index.js.map +1 -1
- package/build/production/shared/utils/jest/E2eSsrEnv.js +9 -9
- package/build/production/shared/utils/jest/E2eSsrEnv.js.map +1 -1
- package/build/production/shared/utils/jest/global.js +2 -0
- package/build/production/shared/utils/jest/global.js.map +1 -0
- package/build/production/shared/utils/jest/index.js +6 -6
- package/build/production/shared/utils/jest/index.js.map +1 -1
- package/build/production/shared/utils/splitComponent.js +16 -16
- package/build/production/shared/utils/splitComponent.js.map +1 -1
- package/build/production/shared/utils/time.js +12 -8
- package/build/production/shared/utils/time.js.map +1 -1
- package/build/production/shared/utils/webpack.js +3 -3
- package/build/production/shared/utils/webpack.js.map +1 -1
- package/build/production/web.bundle.js +1 -1
- package/build/production/web.bundle.js.map +1 -1
- package/build/types-code/client/getInj.d.ts +3 -0
- package/build/types-code/client/index.d.ts +11 -0
- package/build/types-code/client/init.d.ts +9 -0
- package/build/types-code/index.d.ts +10 -0
- package/build/types-code/server/Cache.d.ts +37 -0
- package/build/types-code/server/index.d.ts +145 -0
- package/build/types-code/server/renderer.d.ts +106 -0
- package/build/types-code/server/server.d.ts +41 -0
- package/build/types-code/server/utils/errors.d.ts +104 -0
- package/build/types-code/server/utils/index.d.ts +1 -0
- package/build/types-code/shared/components/Button/index.d.ts +27 -0
- package/build/types-code/shared/components/Checkbox/index.d.ts +21 -0
- package/build/types-code/shared/components/Dropdown/index.d.ts +23 -0
- package/build/types-code/shared/components/GenericLink/index.d.ts +61 -0
- package/build/types-code/shared/components/Input/index.d.ts +11 -0
- package/build/types-code/shared/components/Link.d.ts +12 -0
- package/build/types-code/shared/components/MetaTags.d.ts +68 -0
- package/build/types-code/shared/components/Modal/index.d.ts +26 -0
- package/build/types-code/shared/components/NavLink.d.ts +5 -0
- package/build/types-code/shared/components/PageLayout/index.d.ts +16 -0
- package/build/types-code/shared/components/ScalableRect/index.d.ts +19 -0
- package/build/types-code/shared/components/Throbber/index.d.ts +9 -0
- package/build/types-code/shared/components/WithTooltip/Tooltip.d.ts +23 -0
- package/build/types-code/shared/components/WithTooltip/index.d.ts +17 -0
- package/build/types-code/shared/components/YouTubeVideo/index.d.ts +13 -0
- package/build/types-code/shared/components/index.d.ts +16 -0
- package/build/types-code/shared/utils/config.d.ts +2 -0
- package/build/types-code/shared/utils/globalState.d.ts +20 -0
- package/build/types-code/shared/utils/index.d.ts +52 -0
- package/build/types-code/shared/utils/isomorphy/buildInfo.d.ts +23 -0
- package/build/types-code/shared/utils/isomorphy/environment-check.d.ts +11 -0
- package/build/types-code/shared/utils/isomorphy/index.d.ts +20 -0
- package/build/types-code/shared/utils/jest/E2eSsrEnv.d.ts +31 -0
- package/build/types-code/shared/utils/jest/global.d.ts +12 -0
- package/build/types-code/shared/utils/jest/index.d.ts +85 -0
- package/build/types-code/shared/utils/splitComponent.d.ts +41 -0
- package/build/types-code/shared/utils/time.d.ts +62 -0
- package/build/types-code/shared/utils/webpack.d.ts +18 -0
- package/build/types-scss/__tests__/js/config/publicPath support/__assets__/style.scss.d.ts +1 -0
- package/build/types-scss/__tests__/js/config/stylename-generation/__assets__/MockPackageA/TestComponent/style.scss.d.ts +1 -0
- package/build/types-scss/__tests__/js/config/stylename-generation/__assets__/MockPackageB/TestComponent/style.scss.d.ts +1 -0
- package/build/types-scss/__tests__/js/config/stylename-generation/__assets__/style.scss.d.ts +1 -0
- package/build/types-scss/__tests__/js/shared/components/NavLink/styles.scss.d.ts +1 -0
- package/build/types-scss/__tests__/js/shared/utils/splitComponent/__assets__/SampleScene/ComponentA/style.scss.d.ts +1 -0
- package/build/types-scss/__tests__/js/shared/utils/splitComponent/__assets__/SampleScene/ComponentB/style.scss.d.ts +1 -0
- package/build/types-scss/__tests__/js/shared/utils/splitComponent/__assets__/SampleScene/ComponentC/style.scss.d.ts +1 -0
- package/build/types-scss/__tests__/js/shared/utils/splitComponent/__assets__/SampleScene/style.scss.d.ts +1 -0
- package/build/types-scss/__tests__/ts/config/publicPath support/__assets__/style.scss.d.ts +1 -0
- package/build/types-scss/__tests__/ts/config/stylename-generation/__assets__/MockPackageA/TestComponent/style.scss.d.ts +1 -0
- package/build/types-scss/__tests__/ts/config/stylename-generation/__assets__/MockPackageB/TestComponent/style.scss.d.ts +1 -0
- package/build/types-scss/__tests__/ts/config/stylename-generation/__assets__/style.scss.d.ts +1 -0
- package/build/types-scss/__tests__/ts/shared/components/NavLink/styles.scss.d.ts +1 -0
- package/build/types-scss/__tests__/ts/shared/utils/splitComponent/__assets__/SampleScene/ComponentA/style.scss.d.ts +1 -0
- package/build/types-scss/__tests__/ts/shared/utils/splitComponent/__assets__/SampleScene/ComponentB/style.scss.d.ts +1 -0
- package/build/types-scss/__tests__/ts/shared/utils/splitComponent/__assets__/SampleScene/ComponentC/style.scss.d.ts +1 -0
- package/build/types-scss/__tests__/ts/shared/utils/splitComponent/__assets__/SampleScene/style.scss.d.ts +1 -0
- package/build/types-scss/src/shared/components/Button/style.scss.d.ts +6 -0
- package/build/types-scss/src/shared/components/Checkbox/theme.scss.d.ts +6 -0
- package/build/types-scss/src/shared/components/Dropdown/theme.scss.d.ts +9 -0
- package/build/types-scss/src/shared/components/GenericLink/style.scss.d.ts +1 -0
- package/build/types-scss/src/shared/components/Input/theme.scss.d.ts +6 -0
- package/build/types-scss/src/shared/components/Modal/base-theme.scss.d.ts +5 -0
- package/build/types-scss/src/shared/components/PageLayout/base-theme.scss.d.ts +6 -0
- package/build/types-scss/src/shared/components/ScalableRect/style.scss.d.ts +2 -0
- package/build/types-scss/src/shared/components/Throbber/theme.scss.d.ts +6 -0
- package/build/types-scss/src/shared/components/WithTooltip/default-theme.scss.d.ts +7 -0
- package/build/types-scss/src/shared/components/YouTubeVideo/base.scss.d.ts +5 -0
- package/build/types-scss/src/shared/components/YouTubeVideo/throbber.scss.d.ts +4 -0
- package/config/eslint/jest.json +3 -2
- package/config/eslint/typescript.js +34 -0
- package/config/jest/default.js +3 -3
- package/package.json +75 -33
- package/src/client/getInj.ts +43 -0
- package/src/client/index.tsx +40 -0
- package/src/client/init.ts +47 -0
- package/src/index.ts +58 -0
- package/src/server/Cache.ts +68 -0
- package/src/server/index.ts +230 -0
- package/src/server/renderer.tsx +604 -0
- package/src/server/server.ts +309 -0
- package/src/server/utils/errors.ts +135 -0
- package/src/server/utils/index.ts +3 -0
- package/src/shared/components/Button/index.tsx +146 -0
- package/src/shared/components/Button/style.scss +53 -0
- package/src/shared/components/Checkbox/index.tsx +71 -0
- package/src/shared/components/Checkbox/theme.scss +43 -0
- package/src/shared/components/Dropdown/index.tsx +144 -0
- package/src/shared/components/Dropdown/theme.scss +63 -0
- package/src/shared/components/GenericLink/index.tsx +157 -0
- package/src/shared/components/GenericLink/style.scss +3 -0
- package/src/shared/components/Input/index.tsx +59 -0
- package/src/shared/components/Input/theme.scss +27 -0
- package/src/shared/components/Link.tsx +21 -0
- package/src/shared/components/MetaTags.tsx +170 -0
- package/src/shared/components/Modal/base-theme.scss +38 -0
- package/src/shared/components/Modal/index.tsx +144 -0
- package/src/shared/components/Modal/styles.scss +5 -0
- package/src/shared/components/NavLink.tsx +13 -0
- package/src/shared/components/PageLayout/base-theme.scss +30 -0
- package/src/shared/components/PageLayout/index.tsx +76 -0
- package/src/shared/components/ScalableRect/index.tsx +84 -0
- package/src/shared/components/ScalableRect/style.scss +10 -0
- package/src/shared/components/Throbber/index.tsx +43 -0
- package/src/shared/components/Throbber/theme.scss +26 -0
- package/src/shared/components/WithTooltip/Tooltip.tsx +353 -0
- package/src/shared/components/WithTooltip/default-theme.scss +36 -0
- package/src/shared/components/WithTooltip/index.tsx +204 -0
- package/src/shared/components/YouTubeVideo/base.scss +13 -0
- package/src/shared/components/YouTubeVideo/index.tsx +96 -0
- package/src/shared/components/YouTubeVideo/throbber.scss +11 -0
- package/src/shared/components/index.ts +17 -0
- package/src/shared/utils/config.ts +21 -0
- package/src/shared/utils/globalState.ts +29 -0
- package/src/shared/utils/index.ts +105 -0
- package/src/shared/utils/isomorphy/buildInfo.ts +54 -0
- package/src/shared/utils/isomorphy/environment-check.ts +18 -0
- package/src/shared/utils/isomorphy/index.ts +38 -0
- package/src/shared/utils/jest/E2eSsrEnv.ts +250 -0
- package/src/shared/utils/jest/global.ts +19 -0
- package/src/shared/utils/jest/index.tsx +157 -0
- package/src/shared/utils/splitComponent.tsx +255 -0
- package/src/shared/utils/time.ts +118 -0
- package/src/shared/utils/webpack.ts +45 -0
- package/src/styles/_global/reset.css +52 -0
- package/src/styles/global.scss +11 -0
- package/tsconfig.configs.json +18 -0
- package/tsconfig.json +27 -0
- package/tsconfig.types.json +53 -0
- package/typed-scss-modules.config.ts +9 -0
- package/types.d.ts +37 -0
- package/{webpack.config.js → webpack.config.ts} +7 -3
- package/config/babel/node-ssr.js +0 -85
- package/config/babel/webpack.js +0 -122
- package/config/webpack/app-base.js +0 -330
- package/config/webpack/app-development.js +0 -80
- package/config/webpack/app-production.js +0 -60
- package/config/webpack/lib-base.js +0 -155
- package/config/webpack/lib-development.js +0 -45
- package/config/webpack/lib-production.js +0 -44
|
@@ -4,9 +4,10 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
|
|
|
4
4
|
Object.defineProperty(exports, "__esModule", {
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
|
-
exports.default =
|
|
7
|
+
exports.default = void 0;
|
|
8
8
|
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
9
|
-
|
|
9
|
+
require("react");
|
|
10
|
+
require("react-router-dom");
|
|
10
11
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
11
12
|
/* global window */
|
|
12
13
|
|
|
@@ -17,40 +18,40 @@ var _jsxRuntime = require("react/jsx-runtime");
|
|
|
17
18
|
* `<Link>` and `<NavLink>` components; they help to handle external and
|
|
18
19
|
* internal links in uniform manner.
|
|
19
20
|
*
|
|
20
|
-
* @param
|
|
21
|
-
* @param
|
|
22
|
-
* @param
|
|
23
|
-
* @param
|
|
21
|
+
* @param [props] Component properties.
|
|
22
|
+
* @param [props.className] CSS classes to apply to the link.
|
|
23
|
+
* @param [props.disabled] Disables the link.
|
|
24
|
+
* @param [props.enforceA] `true` enforces rendering of the link as
|
|
24
25
|
* a simple `<a>` element.
|
|
25
|
-
* @param
|
|
26
|
+
* @param [props.keepScrollPosition] If `true`, and the link is
|
|
26
27
|
* rendered as a React Router's component, it won't reset the viewport scrolling
|
|
27
28
|
* position to the origin when clicked.
|
|
28
|
-
* @param
|
|
29
|
-
* @param
|
|
29
|
+
* @param [props.onClick] Event handler to trigger upon click.
|
|
30
|
+
* @param [props.onMouseDown] Event handler to trigger on MouseDown
|
|
30
31
|
* event.
|
|
31
|
-
* @param
|
|
32
|
-
* @param
|
|
32
|
+
* @param [props.openNewTab] If `true` the link opens in a new tab.
|
|
33
|
+
* @param [props.replace] When `true`, the link will replace current
|
|
33
34
|
* entry in the history stack instead of adding a new one.
|
|
34
|
-
* @param
|
|
35
|
-
* @param
|
|
35
|
+
* @param [props.to] Link URL.
|
|
36
|
+
* @param [props.activeClassName] **`<NavLink>`** only: CSS class(es)
|
|
36
37
|
* to apply to rendered link when it is active.
|
|
37
|
-
* @param
|
|
38
|
+
* @param [props.activeStyle] **`<NavLink>`** only: CSS styles
|
|
38
39
|
* to apply to the rendered link when it is active.
|
|
39
|
-
* @param
|
|
40
|
+
* @param [props.exact] **`<NavLink>`** only: if `true`, the active
|
|
40
41
|
* class/style will only be applied if the location is matched exactly.
|
|
41
|
-
* @param
|
|
42
|
+
* @param [props.isActive] **`<NavLink>`** only: Add extra
|
|
42
43
|
* logic for determining whether the link is active. This should be used if you
|
|
43
44
|
* want to do more than verify that the link’s pathname matches the current URL
|
|
44
45
|
* pathname.
|
|
45
|
-
* @param
|
|
46
|
+
* @param [props.location] **`<NavLink>`** only: `isActive` compares
|
|
46
47
|
* current history location (usually the current browser URL). To compare to
|
|
47
48
|
* a different location, a custom `location` can be passed.
|
|
48
|
-
* @param
|
|
49
|
+
* @param [props.strict] **`<NavLink>`** only: . When `true`, trailing
|
|
49
50
|
* slash on a location’s pathname will be taken into consideration when
|
|
50
51
|
* determining if the location matches the current URL. See the `<Route strict>`
|
|
51
52
|
* documentation for more information.
|
|
52
53
|
*/
|
|
53
|
-
|
|
54
|
+
const GenericLink = ({
|
|
54
55
|
children,
|
|
55
56
|
className,
|
|
56
57
|
disabled,
|
|
@@ -63,16 +64,20 @@ function GenericLink({
|
|
|
63
64
|
routerLinkType,
|
|
64
65
|
to,
|
|
65
66
|
...rest
|
|
66
|
-
}) {
|
|
67
|
+
}) => {
|
|
67
68
|
/* Renders Link as <a> element if:
|
|
68
69
|
* - It is opted explicitely by `enforceA` prop;
|
|
69
70
|
* - It should be opened in a new tab;
|
|
70
71
|
* - It is an absolte URL (starts with http:// or https://);
|
|
71
72
|
* - It is anchor link (starts with #). */
|
|
72
|
-
if (disabled || enforceA || openNewTab || to
|
|
73
|
+
if (disabled || enforceA || openNewTab || to?.match(/^(#|(https?|mailto):)/)) {
|
|
73
74
|
return /*#__PURE__*/(0, _jsxRuntime.jsx)("a", {
|
|
74
|
-
className: (className ? className + " " : "") + "-dr-pogodin-react-utils___src-shared-components-GenericLink-style___link___zH52sA"
|
|
75
|
-
|
|
75
|
+
className: (className ? className + " " : "") + "-dr-pogodin-react-utils___src-shared-components-GenericLink-style___link___zH52sA"
|
|
76
|
+
// TODO: This requires a fix: disabled is not really an attribute of <a>
|
|
77
|
+
// tag, thus for disabled option we rather should render a plain text
|
|
78
|
+
// styled as a link.
|
|
79
|
+
// disabled={disabled}
|
|
80
|
+
,
|
|
76
81
|
href: to,
|
|
77
82
|
onClick: disabled ? e => e.preventDefault() : onClick,
|
|
78
83
|
onMouseDown: disabled ? e => e.preventDefault() : onMouseDown,
|
|
@@ -81,14 +86,14 @@ function GenericLink({
|
|
|
81
86
|
children: children
|
|
82
87
|
});
|
|
83
88
|
}
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
onMouseDown,
|
|
90
|
-
replace,
|
|
91
|
-
to,
|
|
89
|
+
const L = routerLinkType;
|
|
90
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(L, {
|
|
91
|
+
className: className
|
|
92
|
+
// disabled
|
|
93
|
+
,
|
|
94
|
+
onMouseDown: onMouseDown,
|
|
95
|
+
replace: replace,
|
|
96
|
+
to: to,
|
|
92
97
|
onClick: e => {
|
|
93
98
|
// Executes the user-provided event handler, if any.
|
|
94
99
|
if (onClick) onClick(e);
|
|
@@ -96,17 +101,18 @@ function GenericLink({
|
|
|
96
101
|
// By default, clicking the link scrolls the page to beginning.
|
|
97
102
|
if (!keepScrollPosition) window.scroll(0, 0);
|
|
98
103
|
},
|
|
99
|
-
...rest
|
|
100
|
-
|
|
101
|
-
}
|
|
104
|
+
...rest,
|
|
105
|
+
children: children
|
|
106
|
+
});
|
|
107
|
+
};
|
|
102
108
|
GenericLink.defaultProps = {
|
|
103
109
|
children: null,
|
|
104
|
-
className:
|
|
110
|
+
className: '',
|
|
105
111
|
disabled: false,
|
|
106
112
|
enforceA: false,
|
|
107
113
|
keepScrollPosition: false,
|
|
108
|
-
onClick:
|
|
109
|
-
onMouseDown:
|
|
114
|
+
onClick: undefined,
|
|
115
|
+
onMouseDown: undefined,
|
|
110
116
|
openNewTab: false,
|
|
111
117
|
replace: false,
|
|
112
118
|
to: ''
|
|
@@ -124,4 +130,5 @@ GenericLink.propTypes = {
|
|
|
124
130
|
routerLinkType: _propTypes.default.elementType.isRequired,
|
|
125
131
|
to: _propTypes.default.oneOfType([_propTypes.default.object, _propTypes.default.string])
|
|
126
132
|
};
|
|
133
|
+
var _default = exports.default = GenericLink;
|
|
127
134
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["_propTypes","_interopRequireDefault","require","
|
|
1
|
+
{"version":3,"file":"index.js","names":["_propTypes","_interopRequireDefault","require","_jsxRuntime","GenericLink","children","className","disabled","enforceA","keepScrollPosition","onClick","onMouseDown","openNewTab","replace","routerLinkType","to","rest","match","jsx","href","e","preventDefault","rel","target","L","window","scroll","defaultProps","undefined","propTypes","PT","node","string","bool","func","elementType","isRequired","oneOfType","object","_default","exports","default"],"sources":["../../../../../src/shared/components/GenericLink/index.tsx"],"sourcesContent":["/* global window */\n\nimport PT from 'prop-types';\nimport { type ReactNode } from 'react';\n\nimport { type Link, type NavLink } from 'react-router-dom';\n\nimport './style.scss';\n\ntype ToT = Parameters<typeof Link>[0]['to'];\n\ninterface LinkI {}\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: LinkI;\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: React.FunctionComponent<PropsT> = ({\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}) => {\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 || (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) => e.preventDefault() : onClick}\n onMouseDown={disabled ? (e) => e.preventDefault() : onMouseDown}\n rel=\"noopener noreferrer\"\n styleName=\"link\"\n target={openNewTab ? '_blank' : ''}\n >\n {children}\n </a>\n );\n }\n\n const L = routerLinkType as typeof NavLink;\n\n return (\n <L\n className={className}\n // disabled\n onMouseDown={onMouseDown}\n replace={replace}\n to={to!}\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 {...rest} // eslint-disable-line react/jsx-props-no-spreading\n >\n {children}\n </L>\n );\n};\n\nGenericLink.defaultProps = {\n children: null,\n className: '',\n disabled: false,\n enforceA: false,\n keepScrollPosition: false,\n onClick: undefined,\n onMouseDown: undefined,\n openNewTab: false,\n replace: false,\n to: '',\n};\n\nGenericLink.propTypes = {\n children: PT.node,\n className: PT.string,\n disabled: PT.bool,\n enforceA: PT.bool,\n keepScrollPosition: PT.bool,\n onClick: PT.func,\n onMouseDown: PT.func,\n openNewTab: PT.bool,\n replace: PT.bool,\n routerLinkType: PT.elementType.isRequired,\n to: PT.oneOfType([PT.object, PT.string]),\n};\n\nexport default GenericLink;\n"],"mappings":";;;;;;;AAEA,IAAAA,UAAA,GAAAC,sBAAA,CAAAC,OAAA;AACAA,OAAA;AAEAA,OAAA;AAA2D,IAAAC,WAAA,GAAAD,OAAA;AAL3D;;AA2BA;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;AACA,MAAME,WAA4C,GAAGA,CAAC;EACpDC,QAAQ;EACRC,SAAS;EACTC,QAAQ;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;EACbC,QAAQ,EAAE,KAAK;EACfC,QAAQ,EAAE,KAAK;EACfC,kBAAkB,EAAE,KAAK;EACzBC,OAAO,EAAEkB,SAAS;EAClBjB,WAAW,EAAEiB,SAAS;EACtBhB,UAAU,EAAE,KAAK;EACjBC,OAAO,EAAE,KAAK;EACdE,EAAE,EAAE;AACN,CAAC;AAEDX,WAAW,CAACyB,SAAS,GAAG;EACtBxB,QAAQ,EAAEyB,kBAAE,CAACC,IAAI;EACjBzB,SAAS,EAAEwB,kBAAE,CAACE,MAAM;EACpBzB,QAAQ,EAAEuB,kBAAE,CAACG,IAAI;EACjBzB,QAAQ,EAAEsB,kBAAE,CAACG,IAAI;EACjBxB,kBAAkB,EAAEqB,kBAAE,CAACG,IAAI;EAC3BvB,OAAO,EAAEoB,kBAAE,CAACI,IAAI;EAChBvB,WAAW,EAAEmB,kBAAE,CAACI,IAAI;EACpBtB,UAAU,EAAEkB,kBAAE,CAACG,IAAI;EACnBpB,OAAO,EAAEiB,kBAAE,CAACG,IAAI;EAChBnB,cAAc,EAAEgB,kBAAE,CAACK,WAAW,CAACC,UAAU;EACzCrB,EAAE,EAAEe,kBAAE,CAACO,SAAS,CAAC,CAACP,kBAAE,CAACQ,MAAM,EAAER,kBAAE,CAACE,MAAM,CAAC;AACzC,CAAC;AAAC,IAAAO,QAAA,GAAAC,OAAA,CAAAC,OAAA,GAEarC,WAAW"}
|
|
@@ -7,7 +7,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
7
7
|
exports.default = void 0;
|
|
8
8
|
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
9
9
|
var _react = require("react");
|
|
10
|
-
var
|
|
10
|
+
var _reactThemes = _interopRequireDefault(require("@dr.pogodin/react-themes"));
|
|
11
11
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
12
12
|
const defaultTheme = {
|
|
13
13
|
"context": "-dr-pogodin-react-utils___src-shared-components-Input-theme___context___X5WszA",
|
|
@@ -19,11 +19,11 @@ const defaultTheme = {
|
|
|
19
19
|
};
|
|
20
20
|
/**
|
|
21
21
|
* Themeable input field, based on the standard HTML `<input>` element.
|
|
22
|
-
* @param
|
|
23
|
-
* @param
|
|
24
|
-
* @param
|
|
25
|
-
* @param
|
|
26
|
-
* @param
|
|
22
|
+
* @param [props]
|
|
23
|
+
* @param [props.label] Input label.
|
|
24
|
+
* @param [props.theme] _Ad hoc_ theme.
|
|
25
|
+
* @param [props...] [Other theming properties](https://www.npmjs.com/package/@dr.pogodin/react-themes#themed-component-properties)
|
|
26
|
+
* @param [props...] Any other properties are passed to the underlying
|
|
27
27
|
* `<input>` element.
|
|
28
28
|
*/
|
|
29
29
|
const Input = /*#__PURE__*/(0, _react.forwardRef)(({
|
|
@@ -41,7 +41,7 @@ const Input = /*#__PURE__*/(0, _react.forwardRef)(({
|
|
|
41
41
|
...rest
|
|
42
42
|
})]
|
|
43
43
|
}));
|
|
44
|
-
const ThemedInput = (0,
|
|
44
|
+
const ThemedInput = (0, _reactThemes.default)(Input, 'Input', ['container', 'input', 'label'], defaultTheme);
|
|
45
45
|
Input.propTypes = {
|
|
46
46
|
label: _propTypes.default.string,
|
|
47
47
|
theme: ThemedInput.themeType.isRequired
|
|
@@ -49,6 +49,5 @@ Input.propTypes = {
|
|
|
49
49
|
Input.defaultProps = {
|
|
50
50
|
label: undefined
|
|
51
51
|
};
|
|
52
|
-
var _default = ThemedInput;
|
|
53
|
-
exports.default = _default;
|
|
52
|
+
var _default = exports.default = ThemedInput;
|
|
54
53
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["_propTypes","_interopRequireDefault","require","_react","
|
|
1
|
+
{"version":3,"file":"index.js","names":["_propTypes","_interopRequireDefault","require","_react","_reactThemes","_jsxRuntime","defaultTheme","Input","forwardRef","label","theme","rest","ref","jsxs","className","container","children","undefined","jsx","input","ThemedInput","themed","propTypes","PT","string","themeType","isRequired","defaultProps","_default","exports","default"],"sources":["../../../../../src/shared/components/Input/index.tsx"],"sourcesContent":["import PT from 'prop-types';\nimport { forwardRef } from 'react';\n\nimport themed, { type Theme } from '@dr.pogodin/react-themes';\n\nimport defaultTheme from './theme.scss';\n\ntype PropsT = React.InputHTMLAttributes<HTMLInputElement> & {\n label?: string;\n theme: Theme & {\n container?: string;\n input?: string;\n label?: string;\n };\n};\n\n/**\n * Themeable input field, based on the standard HTML `<input>` element.\n * @param [props]\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 = forwardRef<HTMLInputElement, PropsT>((\n {\n label,\n theme,\n ...rest\n }: PropsT,\n ref,\n) => (\n <span className={theme.container}>\n { label === undefined ? null : <p className={theme.label}>{label}</p> }\n <input\n className={theme.input}\n ref={ref}\n {...rest} // eslint-disable-line react/jsx-props-no-spreading\n />\n </span>\n));\n\nconst ThemedInput = themed(Input, 'Input', [\n 'container',\n 'input',\n 'label',\n], defaultTheme);\n\nInput.propTypes = {\n label: PT.string,\n theme: ThemedInput.themeType.isRequired,\n};\n\nInput.defaultProps = {\n label: undefined,\n};\n\nexport default ThemedInput;\n"],"mappings":";;;;;;;AAAA,IAAAA,UAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,MAAA,GAAAD,OAAA;AAEA,IAAAE,YAAA,GAAAH,sBAAA,CAAAC,OAAA;AAA8D,IAAAG,WAAA,GAAAH,OAAA;AAAA,MAAAI,YAAA;EAAA;EAAA;EAAA;EAAA;EAAA;EAAA;AAAA;AAa9D;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAMC,KAAK,gBAAG,IAAAC,iBAAU,EAA2B,CACjD;EACEC,KAAK;EACLC,KAAK;EACL,GAAGC;AACG,CAAC,EACTC,GAAG,kBAEH,IAAAP,WAAA,CAAAQ,IAAA;EAAMC,SAAS,EAAEJ,KAAK,CAACK,SAAU;EAAAC,QAAA,GAC7BP,KAAK,KAAKQ,SAAS,GAAG,IAAI,gBAAG,IAAAZ,WAAA,CAAAa,GAAA;IAAGJ,SAAS,EAAEJ,KAAK,CAACD,KAAM;IAAAO,QAAA,EAAEP;EAAK,CAAI,CAAC,eACrE,IAAAJ,WAAA,CAAAa,GAAA;IACEJ,SAAS,EAAEJ,KAAK,CAACS,KAAM;IACvBP,GAAG,EAAEA,GAAI;IAAA,GACLD;EAAI,CACT,CAAC;AAAA,CACE,CACP,CAAC;AAEF,MAAMS,WAAW,GAAG,IAAAC,oBAAM,EAACd,KAAK,EAAE,OAAO,EAAE,CACzC,WAAW,EACX,OAAO,EACP,OAAO,CACR,EAAED,YAAY,CAAC;AAEhBC,KAAK,CAACe,SAAS,GAAG;EAChBb,KAAK,EAAEc,kBAAE,CAACC,MAAM;EAChBd,KAAK,EAAEU,WAAW,CAACK,SAAS,CAACC;AAC/B,CAAC;AAEDnB,KAAK,CAACoB,YAAY,GAAG;EACnBlB,KAAK,EAAEQ;AACT,CAAC;AAAC,IAAAW,QAAA,GAAAC,OAAA,CAAAC,OAAA,GAEaV,WAAW"}
|
|
@@ -4,7 +4,7 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
|
|
|
4
4
|
Object.defineProperty(exports, "__esModule", {
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
|
-
exports.default =
|
|
7
|
+
exports.default = void 0;
|
|
8
8
|
var _reactRouterDom = require("react-router-dom");
|
|
9
9
|
var _GenericLink = _interopRequireDefault(require("./GenericLink"));
|
|
10
10
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
@@ -16,12 +16,13 @@ var _jsxRuntime = require("react/jsx-runtime");
|
|
|
16
16
|
* - User explicitely opts to use <a>.
|
|
17
17
|
*/
|
|
18
18
|
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
19
|
+
const Link = props =>
|
|
20
|
+
/*#__PURE__*/
|
|
21
|
+
/* eslint-disable react/jsx-props-no-spreading */
|
|
22
|
+
(0, _jsxRuntime.jsx)(_GenericLink.default, {
|
|
23
|
+
...props,
|
|
24
|
+
routerLinkType: _reactRouterDom.Link
|
|
25
|
+
})
|
|
26
|
+
/* eslint-enable react/jsx-props-no-spreading */;
|
|
27
|
+
var _default = exports.default = Link;
|
|
27
28
|
//# sourceMappingURL=Link.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Link.js","names":["_reactRouterDom","require","_GenericLink","_interopRequireDefault","_jsxRuntime","Link","props","jsx","default","routerLinkType","RrLink"],"sources":["../../../../src/shared/components/Link.
|
|
1
|
+
{"version":3,"file":"Link.js","names":["_reactRouterDom","require","_GenericLink","_interopRequireDefault","_jsxRuntime","Link","props","jsx","default","routerLinkType","RrLink","_default","exports"],"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 { Link as RrLink } from 'react-router-dom';\n\nimport GenericLink, { type PropsT as GenericLinkPropsT } from './GenericLink';\n\ntype PropsT = Omit<GenericLinkPropsT, 'routerLinkType'>;\n\nconst Link: React.FunctionComponent<PropsT> = (props) => (\n /* eslint-disable react/jsx-props-no-spreading */\n <GenericLink {...props} routerLinkType={RrLink} />\n /* eslint-enable react/jsx-props-no-spreading */\n);\n\nexport default Link;\n"],"mappings":";;;;;;;AAQA,IAAAA,eAAA,GAAAC,OAAA;AAEA,IAAAC,YAAA,GAAAC,sBAAA,CAAAF,OAAA;AAA8E,IAAAG,WAAA,GAAAH,OAAA;AAV9E;AACA;AACA;AACA;AACA;AACA;AACA;;AAQA,MAAMI,IAAqC,GAAIC,KAAK;AAAA;AAClD;AACA,IAAAF,WAAA,CAAAG,GAAA,EAACL,YAAA,CAAAM,OAAW;EAAA,GAAKF,KAAK;EAAEG,cAAc,EAAEC;AAAO,CAAE;AACjD,gDACD;AAAC,IAAAC,QAAA,GAAAC,OAAA,CAAAJ,OAAA,GAEaH,IAAI"}
|
|
@@ -4,12 +4,15 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
|
|
|
4
4
|
Object.defineProperty(exports, "__esModule", {
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
|
-
exports.default =
|
|
7
|
+
exports.default = void 0;
|
|
8
8
|
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
9
9
|
var _react = require("react");
|
|
10
10
|
var _reactHelmet = require("react-helmet");
|
|
11
11
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
12
|
-
const Context = /*#__PURE__*/(0, _react.createContext)(
|
|
12
|
+
const Context = /*#__PURE__*/(0, _react.createContext)({
|
|
13
|
+
description: '',
|
|
14
|
+
title: ''
|
|
15
|
+
});
|
|
13
16
|
|
|
14
17
|
/**
|
|
15
18
|
* The `<MetaTags>` component is an auxiliary wrapper around `react-helmet`,
|
|
@@ -37,34 +40,34 @@ const Context = /*#__PURE__*/(0, _react.createContext)();
|
|
|
37
40
|
* );
|
|
38
41
|
* }
|
|
39
42
|
* ```
|
|
40
|
-
* @param
|
|
41
|
-
* @param
|
|
43
|
+
* @param [props]
|
|
44
|
+
* @param [props.description] Page description to use in
|
|
42
45
|
* the `description` meta tag, and as a default description of Open Graph Tags.
|
|
43
|
-
* @param
|
|
46
|
+
* @param [props.image] The absolute URL of thumbnail image to use
|
|
44
47
|
* in Open Graph Tags (`twitter:image`, and `og:image`). By default these tags
|
|
45
48
|
* are not injected.
|
|
46
49
|
*
|
|
47
50
|
* **BEWARE:** It must be a complete, absolute URL, including the correct
|
|
48
51
|
* website domain and HTTP schema.
|
|
49
52
|
*
|
|
50
|
-
* @param
|
|
53
|
+
* @param [props.siteName]: The site name to use in `twitter:site`,
|
|
51
54
|
* and `og:sitename` tags. By default these tags are not injected.
|
|
52
55
|
*
|
|
53
|
-
* @param
|
|
56
|
+
* @param [props.socialDescription] The site description to use in
|
|
54
57
|
* `twitter:description` and `og:description` meta tags. By default the value of
|
|
55
58
|
* `description` prop is used.
|
|
56
|
-
* @param
|
|
59
|
+
* @param [props.socialTitle] The page title to use in
|
|
57
60
|
* `twitter:title`, `og:title`, and `og:image:alt` tags. By default the value of
|
|
58
61
|
* `title` prop is used. Also the `og:image:alt` tag is only injected if `image`
|
|
59
62
|
* prop is present.
|
|
60
63
|
*
|
|
61
|
-
* @param
|
|
64
|
+
* @param props.title: The page name to use in the `<title>` tag.
|
|
62
65
|
* It is also used as the default value of `socialTitle` prop.
|
|
63
66
|
*
|
|
64
|
-
* @param
|
|
67
|
+
* @param [props.url] The page URL to use in `og:url` tag.
|
|
65
68
|
* By default the tag is not injected.
|
|
66
69
|
*/
|
|
67
|
-
|
|
70
|
+
const MetaTags = ({
|
|
68
71
|
children,
|
|
69
72
|
description,
|
|
70
73
|
image,
|
|
@@ -73,7 +76,7 @@ function MetaTags({
|
|
|
73
76
|
socialTitle,
|
|
74
77
|
title,
|
|
75
78
|
url
|
|
76
|
-
}) {
|
|
79
|
+
}) => {
|
|
77
80
|
const socTitle = socialTitle || title;
|
|
78
81
|
const socDesc = socialDescription || description;
|
|
79
82
|
const context = (0, _react.useMemo)(() => ({
|
|
@@ -131,15 +134,15 @@ function MetaTags({
|
|
|
131
134
|
children: children
|
|
132
135
|
}) : null]
|
|
133
136
|
});
|
|
134
|
-
}
|
|
137
|
+
};
|
|
135
138
|
MetaTags.Context = Context;
|
|
136
139
|
MetaTags.defaultProps = {
|
|
137
140
|
children: null,
|
|
138
|
-
image:
|
|
139
|
-
siteName:
|
|
140
|
-
socialDescription:
|
|
141
|
-
socialTitle:
|
|
142
|
-
url:
|
|
141
|
+
image: '',
|
|
142
|
+
siteName: '',
|
|
143
|
+
socialDescription: '',
|
|
144
|
+
socialTitle: '',
|
|
145
|
+
url: ''
|
|
143
146
|
};
|
|
144
147
|
MetaTags.propTypes = {
|
|
145
148
|
children: _propTypes.default.node,
|
|
@@ -151,4 +154,5 @@ MetaTags.propTypes = {
|
|
|
151
154
|
title: _propTypes.default.string.isRequired,
|
|
152
155
|
url: _propTypes.default.string
|
|
153
156
|
};
|
|
157
|
+
var _default = exports.default = MetaTags;
|
|
154
158
|
//# sourceMappingURL=MetaTags.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MetaTags.js","names":["_propTypes","_interopRequireDefault","require","_react","_reactHelmet","_jsxRuntime","Context","createContext","
|
|
1
|
+
{"version":3,"file":"MetaTags.js","names":["_propTypes","_interopRequireDefault","require","_react","_reactHelmet","_jsxRuntime","Context","createContext","description","title","MetaTags","children","image","siteName","socialDescription","socialTitle","url","socTitle","socDesc","context","useMemo","jsxs","Fragment","Helmet","jsx","name","content","Provider","value","defaultProps","propTypes","PT","node","string","isRequired","_default","exports","default"],"sources":["../../../../src/shared/components/MetaTags.tsx"],"sourcesContent":["import PT from 'prop-types';\nimport { type ReactNode, createContext, useMemo } from 'react';\nimport { Helmet } from 'react-helmet';\n\ntype PropsT = {\n children?: ReactNode;\n description: string;\n image?: string;\n siteName?: string;\n socialDescription?: string;\n socialTitle?: string;\n title: string;\n url?: string;\n};\n\nconst Context = createContext<PropsT>({\n description: '',\n title: '',\n});\n\n/**\n * The `<MetaTags>` component is an auxiliary wrapper around `react-helmet`,\n * which helps to inject meta tags (page title, a brief content description,\n * and social media thumbnails) into generated pages.\n *\n * When `<MetaTags>` are nested within the app's component tree, meta tags\n * content injected by components encountered down the tree overrides tags\n * injected by previously encountered `<MetaTags>` components.\n *\n * **Children:** `<MetaTags>` children, if any, are rendered at the component's\n * location. The context passes down all meta tag properties of parent\n * `<MetaTag>` instances. These properties can fetched within children\n * hierarchy in the following way, thus facilitating tags modification by\n * children:\n * ```jsx\n * import { useContext } from 'react';\n * import { MetaTags } from '@dr.pogodin/react-utils';\n * export default function SampleComponent() {\n * const { title, description, ...rest } = useContext(MetaTags.Context);\n * // Do something with these props here, e.g. prefix the page title with\n * // the component name:\n * return (\n * <MetaTags title={`Sample component - ${title}`} />\n * );\n * }\n * ```\n * @param [props]\n * @param [props.description] Page description to use in\n * the `description` meta tag, and as a default description of Open Graph Tags.\n * @param [props.image] The absolute URL of thumbnail image to use\n * in Open Graph Tags (`twitter:image`, and `og:image`). By default these tags\n * are not injected.\n *\n * **BEWARE:** It must be a complete, absolute URL, including the correct\n * website domain and HTTP schema.\n *\n * @param [props.siteName]: The site name to use in `twitter:site`,\n * and `og:sitename` tags. By default these tags are not injected.\n *\n * @param [props.socialDescription] The site description to use in\n * `twitter:description` and `og:description` meta tags. By default the value of\n * `description` prop is used.\n * @param [props.socialTitle] The page title to use in\n * `twitter:title`, `og:title`, and `og:image:alt` tags. By default the value of\n * `title` prop is used. Also the `og:image:alt` tag is only injected if `image`\n * prop is present.\n *\n * @param props.title: The page name to use in the `<title>` tag.\n * It is also used as the default value of `socialTitle` prop.\n *\n * @param [props.url] The page URL to use in `og:url` tag.\n * By default the tag is not injected.\n */\nconst MetaTags: React.FunctionComponent<PropsT> & {\n Context: React.Context<PropsT>;\n} = ({\n children,\n description,\n image,\n siteName,\n socialDescription,\n socialTitle,\n title,\n url,\n}) => {\n const socTitle = socialTitle || title;\n const socDesc = socialDescription || description;\n\n const context = useMemo(() => ({\n description,\n image,\n siteName,\n socialDescription,\n socialTitle,\n title,\n url,\n }), [\n description,\n image,\n siteName,\n socialDescription,\n socialTitle,\n title,\n url,\n ]);\n\n return (\n <>\n <Helmet>\n {/* General tags. */}\n <title>\n {title}\n </title>\n <meta name=\"description\" content={description} />\n\n {/* Twitter cards. */}\n <meta name=\"twitter:card\" content=\"summary_large_image\" />\n <meta name=\"twitter:title\" content={socTitle} />\n <meta name=\"twitter:description\" content={socDesc} />\n { image ? <meta name=\"twitter:image\" content={image} /> : null }\n {\n siteName ? (\n <meta name=\"twitter:site\" content={`@${siteName}`} />\n ) : null\n }\n\n {/* Open Graph data. */}\n <meta name=\"og:title\" content={socTitle} />\n { image ? <meta name=\"og:image\" content={image} /> : null }\n { image ? <meta name=\"og:image:alt\" content={socTitle} /> : null }\n <meta name=\"og:description\" content={socDesc} />\n {\n siteName ? (<meta name=\"og:sitename\" content={siteName} />) : null\n }\n { url ? (<meta name=\"og:url\" content={url} />) : null }\n </Helmet>\n {\n children ? (\n <Context.Provider value={context}>\n {children}\n </Context.Provider>\n ) : null\n }\n </>\n );\n};\n\nMetaTags.Context = Context;\n\nMetaTags.defaultProps = {\n children: null,\n image: '',\n siteName: '',\n socialDescription: '',\n socialTitle: '',\n url: '',\n};\n\nMetaTags.propTypes = {\n children: PT.node,\n description: PT.string.isRequired,\n image: PT.string,\n siteName: PT.string,\n socialDescription: PT.string,\n socialTitle: PT.string,\n title: PT.string.isRequired,\n url: PT.string,\n};\n\nexport default MetaTags;\n"],"mappings":";;;;;;;AAAA,IAAAA,UAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,MAAA,GAAAD,OAAA;AACA,IAAAE,YAAA,GAAAF,OAAA;AAAsC,IAAAG,WAAA,GAAAH,OAAA;AAatC,MAAMI,OAAO,gBAAG,IAAAC,oBAAa,EAAS;EACpCC,WAAW,EAAE,EAAE;EACfC,KAAK,EAAE;AACT,CAAC,CAAC;;AAEF;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;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAMC,QAEL,GAAGA,CAAC;EACHC,QAAQ;EACRH,WAAW;EACXI,KAAK;EACLC,QAAQ;EACRC,iBAAiB;EACjBC,WAAW;EACXN,KAAK;EACLO;AACF,CAAC,KAAK;EACJ,MAAMC,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,CAACC,UAAU;EACjCtB,KAAK,EAAEmB,kBAAE,CAACE,MAAM;EAChBpB,QAAQ,EAAEkB,kBAAE,CAACE,MAAM;EACnBnB,iBAAiB,EAAEiB,kBAAE,CAACE,MAAM;EAC5BlB,WAAW,EAAEgB,kBAAE,CAACE,MAAM;EACtBxB,KAAK,EAAEsB,kBAAE,CAACE,MAAM,CAACC,UAAU;EAC3BlB,GAAG,EAAEe,kBAAE,CAACE;AACV,CAAC;AAAC,IAAAE,QAAA,GAAAC,OAAA,CAAAC,OAAA,GAEa3B,QAAQ"}
|
|
@@ -4,8 +4,7 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
|
|
|
4
4
|
Object.defineProperty(exports, "__esModule", {
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
|
-
exports.BaseModal =
|
|
8
|
-
exports.default = void 0;
|
|
7
|
+
exports.default = exports.BaseModal = void 0;
|
|
9
8
|
var _lodash = require("lodash");
|
|
10
9
|
var _react = require("react");
|
|
11
10
|
var _reactDom = _interopRequireDefault(require("react-dom"));
|
|
@@ -31,13 +30,13 @@ const baseTheme = {
|
|
|
31
30
|
* modal.
|
|
32
31
|
* @param {ModalTheme} [props.theme] _Ad hoc_ theme.
|
|
33
32
|
*/
|
|
34
|
-
|
|
33
|
+
const BaseModal = ({
|
|
35
34
|
children,
|
|
36
35
|
onCancel,
|
|
37
36
|
theme
|
|
38
|
-
}) {
|
|
39
|
-
const containerRef = (0, _react.useRef)();
|
|
40
|
-
const overlayRef = (0, _react.useRef)();
|
|
37
|
+
}) => {
|
|
38
|
+
const containerRef = (0, _react.useRef)(null);
|
|
39
|
+
const overlayRef = (0, _react.useRef)(null);
|
|
41
40
|
const [portal, setPortal] = (0, _react.useState)();
|
|
42
41
|
(0, _react.useEffect)(() => {
|
|
43
42
|
const p = document.createElement('div');
|
|
@@ -51,24 +50,24 @@ function BaseModal({
|
|
|
51
50
|
}, []);
|
|
52
51
|
const focusLast = (0, _react.useMemo)(() => /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
53
52
|
onFocus: () => {
|
|
54
|
-
const elems = containerRef.current
|
|
53
|
+
const elems = containerRef.current?.querySelectorAll('*');
|
|
55
54
|
for (let i = elems.length - 1; i >= 0; --i) {
|
|
56
55
|
elems[i].focus();
|
|
57
56
|
if (document.activeElement === elems[i]) return;
|
|
58
57
|
}
|
|
59
|
-
overlayRef.current
|
|
58
|
+
overlayRef.current?.focus();
|
|
60
59
|
}
|
|
61
60
|
/* eslint-disable jsx-a11y/no-noninteractive-tabindex */,
|
|
62
|
-
tabIndex:
|
|
61
|
+
tabIndex: 0
|
|
63
62
|
/* eslint-enable jsx-a11y/no-noninteractive-tabindex */
|
|
64
63
|
}), []);
|
|
65
64
|
return portal ? /*#__PURE__*/_reactDom.default.createPortal( /*#__PURE__*/(0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
|
|
66
65
|
children: [focusLast, /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
67
66
|
"aria-label": "Cancel",
|
|
68
67
|
className: theme.overlay,
|
|
69
|
-
onClick: () => onCancel(),
|
|
68
|
+
onClick: () => onCancel && onCancel(),
|
|
70
69
|
onKeyDown: e => {
|
|
71
|
-
if (e.key === 'Escape') onCancel();
|
|
70
|
+
if (e.key === 'Escape' && onCancel) onCancel();
|
|
72
71
|
},
|
|
73
72
|
ref: node => {
|
|
74
73
|
if (node && node !== overlayRef.current) {
|
|
@@ -77,7 +76,7 @@ function BaseModal({
|
|
|
77
76
|
}
|
|
78
77
|
},
|
|
79
78
|
role: "button",
|
|
80
|
-
tabIndex:
|
|
79
|
+
tabIndex: 0
|
|
81
80
|
}), /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
82
81
|
"aria-modal": "true",
|
|
83
82
|
className: theme.container,
|
|
@@ -87,15 +86,16 @@ function BaseModal({
|
|
|
87
86
|
children: children
|
|
88
87
|
}), /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
89
88
|
onFocus: () => {
|
|
90
|
-
overlayRef.current
|
|
89
|
+
overlayRef.current?.focus();
|
|
91
90
|
}
|
|
92
91
|
/* eslint-disable jsx-a11y/no-noninteractive-tabindex */,
|
|
93
|
-
tabIndex:
|
|
92
|
+
tabIndex: 0
|
|
94
93
|
/* eslint-enable jsx-a11y/no-noninteractive-tabindex */
|
|
95
94
|
}), focusLast]
|
|
96
95
|
}), portal) : null;
|
|
97
|
-
}
|
|
98
|
-
|
|
96
|
+
};
|
|
97
|
+
exports.BaseModal = BaseModal;
|
|
98
|
+
const ThemedModal = (0, _reactThemes.default)(BaseModal, 'Modal', ['container', 'overlay'], baseTheme);
|
|
99
99
|
BaseModal.propTypes = {
|
|
100
100
|
onCancel: _propTypes.default.func,
|
|
101
101
|
children: _propTypes.default.node,
|
|
@@ -105,7 +105,6 @@ BaseModal.defaultProps = {
|
|
|
105
105
|
onCancel: _lodash.noop,
|
|
106
106
|
children: null
|
|
107
107
|
};
|
|
108
|
-
var _default = ThemedModal;
|
|
108
|
+
var _default = exports.default = ThemedModal;
|
|
109
109
|
/* Non-themed version of the Modal. */
|
|
110
|
-
exports.default = _default;
|
|
111
110
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["_lodash","require","_react","_reactDom","_interopRequireDefault","_propTypes","_reactThemes","_jsxRuntime","baseTheme","BaseModal","children","onCancel","theme","containerRef","useRef","overlayRef","portal","setPortal","useState","useEffect","p","document","createElement","body","classList","add","appendChild","remove","removeChild","focusLast","useMemo","jsx","onFocus","elems","current","querySelectorAll","i","length","focus","activeElement","tabIndex","ReactDom","createPortal","jsxs","Fragment","className","overlay","onClick","onKeyDown","e","key","ref","node","role","container","onWheel","event","stopPropagation","ThemedModal","themed","propTypes","PT","func","themeType","isRequired","defaultProps","noop","_default","
|
|
1
|
+
{"version":3,"file":"index.js","names":["_lodash","require","_react","_reactDom","_interopRequireDefault","_propTypes","_reactThemes","_jsxRuntime","baseTheme","BaseModal","children","onCancel","theme","containerRef","useRef","overlayRef","portal","setPortal","useState","useEffect","p","document","createElement","body","classList","add","appendChild","remove","removeChild","focusLast","useMemo","jsx","onFocus","elems","current","querySelectorAll","i","length","focus","activeElement","tabIndex","ReactDom","createPortal","jsxs","Fragment","className","overlay","onClick","onKeyDown","e","key","ref","node","role","container","onWheel","event","stopPropagation","exports","ThemedModal","themed","propTypes","PT","func","themeType","isRequired","defaultProps","noop","_default","default"],"sources":["../../../../../src/shared/components/Modal/index.tsx"],"sourcesContent":["/* global document */\n\nimport { noop } from 'lodash';\n\nimport {\n type ReactNode,\n useEffect,\n useMemo,\n useRef,\n useState,\n} from 'react';\n\nimport ReactDom from 'react-dom';\nimport PT from 'prop-types';\nimport themed, { type Theme } from '@dr.pogodin/react-themes';\n\nimport baseTheme from './base-theme.scss';\nimport './styles.scss';\n\ntype PropsT = {\n children?: ReactNode;\n onCancel?: () => void;\n theme: Theme & {\n container?: string;\n overlay?: string;\n };\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: React.FunctionComponent<PropsT> = ({\n children,\n onCancel,\n theme,\n}) => {\n const containerRef = useRef<HTMLDivElement | null>(null);\n const overlayRef = useRef<HTMLDivElement | null>(null);\n const [portal, setPortal] = useState<HTMLDivElement>();\n\n useEffect(() => {\n const p = document.createElement('div');\n document.body.classList.add('scrolling-disabled-by-modal');\n document.body.appendChild(p);\n setPortal(p);\n return () => {\n document.body.classList.remove('scrolling-disabled-by-modal');\n document.body.removeChild(p);\n };\n }, []);\n\n const focusLast = useMemo(() => (\n <div\n onFocus={() => {\n const elems = containerRef.current?.querySelectorAll('*') as NodeListOf<HTMLElement>;\n for (let i = elems.length - 1; i >= 0; --i) {\n elems[i].focus();\n if (document.activeElement === elems[i]) return;\n }\n overlayRef.current?.focus();\n }}\n /* eslint-disable jsx-a11y/no-noninteractive-tabindex */\n tabIndex={0}\n /* eslint-enable jsx-a11y/no-noninteractive-tabindex */\n />\n ), []);\n\n return portal ? ReactDom.createPortal(\n (\n <>\n {focusLast}\n <div\n aria-label=\"Cancel\"\n className={theme.overlay}\n onClick={() => onCancel && onCancel()}\n onKeyDown={(e) => {\n if (e.key === 'Escape' && onCancel) onCancel();\n }}\n ref={(node) => {\n if (node && node !== overlayRef.current) {\n overlayRef.current = node;\n node.focus();\n }\n }}\n role=\"button\"\n tabIndex={0}\n />\n <div\n aria-modal=\"true\"\n className={theme.container}\n onWheel={(event) => event.stopPropagation()}\n ref={containerRef}\n role=\"dialog\"\n >\n {children}\n </div>\n <div\n onFocus={() => {\n overlayRef.current?.focus();\n }}\n /* eslint-disable jsx-a11y/no-noninteractive-tabindex */\n tabIndex={0}\n /* eslint-enable jsx-a11y/no-noninteractive-tabindex */\n />\n {focusLast}\n </>\n ),\n portal,\n ) : null;\n};\n\nconst ThemedModal = themed(\n BaseModal,\n 'Modal',\n [\n 'container',\n 'overlay',\n ],\n baseTheme,\n);\n\nBaseModal.propTypes = {\n onCancel: PT.func,\n children: PT.node,\n theme: ThemedModal.themeType.isRequired,\n};\n\nBaseModal.defaultProps = {\n onCancel: noop,\n children: null,\n};\n\nexport default ThemedModal;\n\n/* Non-themed version of the Modal. */\nexport { BaseModal };\n"],"mappings":";;;;;;;AAEA,IAAAA,OAAA,GAAAC,OAAA;AAEA,IAAAC,MAAA,GAAAD,OAAA;AAQA,IAAAE,SAAA,GAAAC,sBAAA,CAAAH,OAAA;AACA,IAAAI,UAAA,GAAAD,sBAAA,CAAAH,OAAA;AACA,IAAAK,YAAA,GAAAF,sBA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B,UAAU,CAACmB,OAAO,EAAEI,KAAK,CAAC,CAAC;MAC7B;MACA;MACAE,QAAQ,EAAE;MACV;IAAA,CACD,CAAC,EACDX,SAAS;EAAA,CACV,CAAC,EAELb,MACF,CAAC,GAAG,IAAI;AACV,CAAC;AAAC0C,OAAA,CAAAjD,SAAA,GAAAA,SAAA;AAEF,MAAMkD,WAAW,GAAG,IAAAC,oBAAM,EACxBnD,SAAS,EACT,OAAO,EACP,CACE,WAAW,EACX,SAAS,CACV,EACDD,SACF,CAAC;AAEDC,SAAS,CAACoD,SAAS,GAAG;EACpBlD,QAAQ,EAAEmD,kBAAE,CAACC,IAAI;EACjBrD,QAAQ,EAAEoD,kBAAE,CAACV,IAAI;EACjBxC,KAAK,EAAE+C,WAAW,CAACK,SAAS,CAACC;AAC/B,CAAC;AAEDxD,SAAS,CAACyD,YAAY,GAAG;EACvBvD,QAAQ,EAAEwD,YAAI;EACdzD,QAAQ,EAAE;AACZ,CAAC;AAAC,IAAA0D,QAAA,GAAAV,OAAA,CAAAW,OAAA,GAEaV,WAAW;AAE1B"}
|
|
@@ -4,16 +4,17 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
|
|
|
4
4
|
Object.defineProperty(exports, "__esModule", {
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
|
-
exports.default =
|
|
7
|
+
exports.default = void 0;
|
|
8
8
|
var _reactRouterDom = require("react-router-dom");
|
|
9
9
|
var _GenericLink = _interopRequireDefault(require("./GenericLink"));
|
|
10
10
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
11
|
+
const NavLink = props =>
|
|
12
|
+
/*#__PURE__*/
|
|
13
|
+
/* eslint-disable react/jsx-props-no-spreading */
|
|
14
|
+
(0, _jsxRuntime.jsx)(_GenericLink.default, {
|
|
15
|
+
...props,
|
|
16
|
+
routerLinkType: _reactRouterDom.NavLink
|
|
17
|
+
})
|
|
18
|
+
/* eslint-enable react/jsx-props-no-spreading */;
|
|
19
|
+
var _default = exports.default = NavLink;
|
|
19
20
|
//# sourceMappingURL=NavLink.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NavLink.js","names":["_reactRouterDom","require","_GenericLink","_interopRequireDefault","_jsxRuntime","NavLink","props","jsx","default","routerLinkType","RrNavLink"],"sources":["../../../../src/shared/components/NavLink.
|
|
1
|
+
{"version":3,"file":"NavLink.js","names":["_reactRouterDom","require","_GenericLink","_interopRequireDefault","_jsxRuntime","NavLink","props","jsx","default","routerLinkType","RrNavLink","_default","exports"],"sources":["../../../../src/shared/components/NavLink.tsx"],"sourcesContent":["import { NavLink as RrNavLink } from 'react-router-dom';\n\nimport GenericLink, { type PropsT as GenericLinkPropsT } from './GenericLink';\n\ntype PropsT = Omit<GenericLinkPropsT, 'routerLinkType'>;\n\nconst NavLink: React.FunctionComponent<PropsT> = (props) => (\n /* eslint-disable react/jsx-props-no-spreading */\n <GenericLink {...props} routerLinkType={RrNavLink} />\n /* eslint-enable react/jsx-props-no-spreading */\n);\n\nexport default NavLink;\n"],"mappings":";;;;;;;AAAA,IAAAA,eAAA,GAAAC,OAAA;AAEA,IAAAC,YAAA,GAAAC,sBAAA,CAAAF,OAAA;AAA8E,IAAAG,WAAA,GAAAH,OAAA;AAI9E,MAAMI,OAAwC,GAAIC,KAAK;AAAA;AACrD;AACA,IAAAF,WAAA,CAAAG,GAAA,EAACL,YAAA,CAAAM,OAAW;EAAA,GAAKF,KAAK;EAAEG,cAAc,EAAEC;AAAU,CAAE;AACpD,gDACD;AAAC,IAAAC,QAAA,GAAAC,OAAA,CAAAJ,OAAA,GAEaH,OAAO"}
|