@dr.pogodin/react-utils 1.47.0-alpha.2 → 1.47.0-alpha.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/babel.config.js +1 -1
- package/babel.module.config.js +11 -0
- package/bin/build.js +8 -4
- package/bin/setup.js +2 -3
- package/build/development/client/getInj.js +9 -18
- package/build/development/client/getInj.js.map +1 -1
- package/build/development/client/index.js +14 -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 +9 -178
- 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 +25 -50
- package/build/development/server/index.js.map +1 -1
- package/build/development/server/renderer.js +56 -67
- package/build/development/server/renderer.js.map +1 -1
- package/build/development/server/server.js +47 -58
- package/build/development/server/server.js.map +1 -1
- package/build/development/server/utils/errors.js +8 -31
- package/build/development/server/utils/errors.js.map +1 -1
- package/build/development/server/utils/index.js +2 -9
- package/build/development/server/utils/index.js.map +1 -1
- package/build/development/shared/components/Button/index.js +9 -16
- package/build/development/shared/components/Button/index.js.map +1 -1
- package/build/development/shared/components/Checkbox/index.js +6 -13
- package/build/development/shared/components/Checkbox/index.js.map +1 -1
- package/build/development/shared/components/GenericLink/index.js +4 -10
- package/build/development/shared/components/GenericLink/index.js.map +1 -1
- package/build/development/shared/components/Input/index.js +11 -18
- package/build/development/shared/components/Input/index.js.map +1 -1
- package/build/development/shared/components/Link.js +6 -13
- package/build/development/shared/components/Link.js.map +1 -1
- package/build/development/shared/components/Modal/index.js +16 -22
- package/build/development/shared/components/Modal/index.js.map +1 -1
- package/build/development/shared/components/NavLink.js +6 -13
- package/build/development/shared/components/NavLink.js.map +1 -1
- package/build/development/shared/components/PageLayout/index.js +7 -14
- package/build/development/shared/components/PageLayout/index.js.map +1 -1
- package/build/development/shared/components/TextArea/index.js +15 -22
- package/build/development/shared/components/TextArea/index.js.map +1 -1
- package/build/development/shared/components/Throbber/index.js +7 -14
- package/build/development/shared/components/Throbber/index.js.map +1 -1
- package/build/development/shared/components/WithTooltip/Tooltip.js +12 -18
- package/build/development/shared/components/WithTooltip/Tooltip.js.map +1 -1
- package/build/development/shared/components/WithTooltip/index.js +16 -23
- package/build/development/shared/components/WithTooltip/index.js.map +1 -1
- package/build/development/shared/components/YouTubeVideo/index.js +10 -17
- package/build/development/shared/components/YouTubeVideo/index.js.map +1 -1
- package/build/development/shared/components/index.js +16 -130
- package/build/development/shared/components/index.js.map +1 -1
- package/build/development/shared/components/selectors/CustomDropdown/Options/index.js +12 -19
- package/build/development/shared/components/selectors/CustomDropdown/Options/index.js.map +1 -1
- package/build/development/shared/components/selectors/CustomDropdown/index.js +20 -28
- package/build/development/shared/components/selectors/CustomDropdown/index.js.map +1 -1
- package/build/development/shared/components/selectors/NativeDropdown/index.js +13 -19
- package/build/development/shared/components/selectors/NativeDropdown/index.js.map +1 -1
- package/build/development/shared/components/selectors/Switch/index.js +10 -17
- package/build/development/shared/components/selectors/Switch/index.js.map +1 -1
- package/build/development/shared/components/selectors/common.js +1 -7
- package/build/development/shared/components/selectors/common.js.map +1 -1
- package/build/development/shared/components/selectors/index.js +3 -27
- package/build/development/shared/components/selectors/index.js.map +1 -1
- package/build/development/shared/utils/config.js +8 -16
- 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 +20 -31
- package/build/development/shared/utils/jest/E2eSsrEnv.js.map +1 -1
- package/build/development/shared/utils/jest/global.js +1 -7
- package/build/development/shared/utils/jest/global.js.map +1 -1
- package/build/development/shared/utils/jest/index.js +20 -44
- package/build/development/shared/utils/jest/index.js.map +1 -1
- package/build/development/shared/utils/splitComponent.js +22 -29
- 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 +13 -16
- package/build/development/shared/utils/webpack.js.map +1 -1
- package/build/production/client/getInj.js +5 -5
- 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 -2
- 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 +21 -19
- package/build/production/server/renderer.js.map +1 -1
- package/build/production/server/server.js +9 -9
- 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 +3 -3
- package/build/production/shared/utils/config.js.map +1 -1
- package/build/production/shared/utils/globalState.js +2 -2
- package/build/production/shared/utils/globalState.js.map +1 -1
- package/build/production/shared/utils/index.js +1 -1
- package/build/production/shared/utils/index.js.map +1 -1
- package/build/production/shared/utils/isomorphy/buildInfo.js +3 -3
- package/build/production/shared/utils/isomorphy/buildInfo.js.map +1 -1
- package/build/production/shared/utils/isomorphy/environment-check.js +3 -3
- package/build/production/shared/utils/isomorphy/environment-check.js.map +1 -1
- package/build/production/shared/utils/isomorphy/index.js +4 -4
- package/build/production/shared/utils/isomorphy/index.js.map +1 -1
- package/build/production/shared/utils/jest/E2eSsrEnv.js +14 -14
- package/build/production/shared/utils/jest/E2eSsrEnv.js.map +1 -1
- package/build/production/shared/utils/jest/global.js +1 -1
- package/build/production/shared/utils/jest/global.js.map +1 -1
- package/build/production/shared/utils/jest/index.js +11 -11
- package/build/production/shared/utils/jest/index.js.map +1 -1
- package/build/production/shared/utils/splitComponent.js +11 -11
- 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 -1
- package/build/types-code/server/index.d.ts +2 -2
- package/build/web/client/getInj.js +2 -2
- package/build/web/client/getInj.js.map +1 -1
- package/build/web/server/index.js +9 -15
- package/build/web/server/index.js.map +1 -1
- package/build/web/server/renderer.js +12 -10
- package/build/web/server/renderer.js.map +1 -1
- package/build/web/server/server.js +2 -4
- package/build/web/server/server.js.map +1 -1
- package/build/web/shared/utils/jest/E2eSsrEnv.js +1 -2
- package/build/web/shared/utils/jest/E2eSsrEnv.js.map +1 -1
- package/build/web/shared/utils/webpack.js +11 -7
- package/build/web/shared/utils/webpack.js.map +1 -1
- package/config/babel/node-ssr.js +5 -5
- package/config/jest/default.js +1 -0
- package/config/webpack/app-base.js +11 -10
- package/config/webpack/app-development.js +3 -3
- package/config/webpack/lib-base.js +1 -1
- package/package.json +8 -6
- package/src/client/getInj.ts +2 -2
- package/src/server/index.ts +9 -15
- package/src/server/renderer.tsx +11 -10
- package/src/server/server.ts +2 -4
- package/src/shared/utils/jest/E2eSsrEnv.ts +1 -2
- package/src/shared/utils/webpack.ts +14 -8
- package/types.d.ts +1 -1
|
@@ -1,14 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
Object.defineProperty(exports, "__esModule", {
|
|
5
|
-
value: true
|
|
6
|
-
});
|
|
7
|
-
exports.default = void 0;
|
|
8
|
-
var _qs = _interopRequireDefault(require("qs"));
|
|
9
|
-
var _reactThemes = _interopRequireDefault(require("@dr.pogodin/react-themes"));
|
|
10
|
-
var _Throbber = _interopRequireDefault(require("../Throbber"));
|
|
11
|
-
var _jsxRuntime = require("react/jsx-runtime");
|
|
1
|
+
import qs from 'qs';
|
|
2
|
+
import themed from '@dr.pogodin/react-themes';
|
|
3
|
+
import Throbber from "../Throbber/index.js";
|
|
12
4
|
const baseTheme = {
|
|
13
5
|
"context": "-dr-pogodin-react-utils___build-web-shared-components-YouTubeVideo-base___context___Pa7GiX",
|
|
14
6
|
"ad": "-dr-pogodin-react-utils___build-web-shared-components-YouTubeVideo-base___ad___NikZ57",
|
|
@@ -22,6 +14,7 @@ const throbberTheme = {
|
|
|
22
14
|
"hoc": "-dr-pogodin-react-utils___build-web-shared-components-YouTubeVideo-throbber___hoc___T5TGzT",
|
|
23
15
|
"container": "-dr-pogodin-react-utils___build-web-shared-components-YouTubeVideo-throbber___container___IgN6Uf"
|
|
24
16
|
};
|
|
17
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
25
18
|
/**
|
|
26
19
|
* A component for embeding a YouTube video.
|
|
27
20
|
* @param [props] Component properties.
|
|
@@ -46,21 +39,21 @@ const YouTubeVideo = ({
|
|
|
46
39
|
const srcParts = src.split('?');
|
|
47
40
|
let [url] = srcParts;
|
|
48
41
|
const [, queryString] = srcParts;
|
|
49
|
-
const query = queryString ?
|
|
42
|
+
const query = queryString ? qs.parse(queryString) : {};
|
|
50
43
|
const videoId = query.v ?? url?.match(/\/([a-zA-Z0-9-_]*)$/)?.[1];
|
|
51
44
|
url = `https://www.youtube.com/embed/${videoId}`;
|
|
52
45
|
delete query.v;
|
|
53
46
|
query.autoplay = autoplay ? '1' : '0';
|
|
54
|
-
url += `?${
|
|
47
|
+
url += `?${qs.stringify(query)}`;
|
|
55
48
|
|
|
56
49
|
// TODO: https://developers.google.com/youtube/player_parameters
|
|
57
50
|
// More query parameters can be exposed via the component props.
|
|
58
51
|
|
|
59
|
-
return /*#__PURE__*/(
|
|
52
|
+
return /*#__PURE__*/_jsxs("div", {
|
|
60
53
|
className: theme.container,
|
|
61
|
-
children: [/*#__PURE__*/(
|
|
54
|
+
children: [/*#__PURE__*/_jsx(Throbber, {
|
|
62
55
|
theme: throbberTheme
|
|
63
|
-
}), /*#__PURE__*/(
|
|
56
|
+
}), /*#__PURE__*/_jsx("iframe", {
|
|
64
57
|
// eslint-disable-line react/iframe-missing-sandbox
|
|
65
58
|
allow: "autoplay",
|
|
66
59
|
allowFullScreen: true,
|
|
@@ -70,5 +63,5 @@ const YouTubeVideo = ({
|
|
|
70
63
|
})]
|
|
71
64
|
});
|
|
72
65
|
};
|
|
73
|
-
|
|
66
|
+
export default themed(YouTubeVideo, 'YouTubeVideo', baseTheme);
|
|
74
67
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["
|
|
1
|
+
{"version":3,"file":"index.js","names":["qs","themed","Throbber","baseTheme","throbberTheme","jsx","_jsx","jsxs","_jsxs","YouTubeVideo","autoplay","src","theme","title","srcParts","split","url","queryString","query","parse","videoId","v","match","stringify","className","container","children","allow","allowFullScreen","video"],"sources":["../../../../../src/shared/components/YouTubeVideo/index.tsx"],"sourcesContent":["import qs from 'qs';\n\nimport themed, { type Theme } from '@dr.pogodin/react-themes';\n\nimport Throbber from 'components/Throbber';\n\nimport baseTheme from './base.scss';\nimport throbberTheme from './throbber.scss';\n\ntype ComponentThemeT = Theme<'container' | 'video'>;\n\ntype PropsT = {\n autoplay?: boolean;\n src: string;\n theme: ComponentThemeT;\n title?: string;\n};\n\n/**\n * A component for embeding a YouTube video.\n * @param [props] Component properties.\n * @param [props.autoplay] If `true` the video will start to play\n * automatically once loaded.\n * @param [props.src] URL of the video to play. Can be in any of\n * the following formats, and keeps any additional query parameters understood\n * by the YouTube IFrame player:\n * - `https://www.youtube.com/watch?v=NdF6Rmt6Ado`\n * - `https://youtu.be/NdF6Rmt6Ado`\n * - `https://www.youtube.com/embed/NdF6Rmt6Ado`\n * @param [props.theme] _Ad hoc_ theme.\n * @param [props.title] The `title` attribute to add to the player\n * IFrame.\n */\nconst YouTubeVideo: React.FunctionComponent<PropsT> = ({\n autoplay,\n src,\n theme,\n title,\n}) => {\n const srcParts = src.split('?');\n let [url] = srcParts;\n const [, queryString] = srcParts;\n const query = queryString ? qs.parse(queryString) : {};\n\n const videoId = query.v ?? url?.match(/\\/([a-zA-Z0-9-_]*)$/)?.[1];\n url = `https://www.youtube.com/embed/${videoId as string}`;\n\n delete query.v;\n query.autoplay = autoplay ? '1' : '0';\n url += `?${qs.stringify(query)}`;\n\n // TODO: https://developers.google.com/youtube/player_parameters\n // More query parameters can be exposed via the component props.\n\n return (\n <div className={theme.container}>\n <Throbber theme={throbberTheme} />\n {/* TODO: I guess, we better add the sanbox, but right now I don't have\n time to carefully explore which restrictions should be lifted to allow\n embed YouTube player to work... sometime later we'll take care of it */\n }\n <iframe // eslint-disable-line react/iframe-missing-sandbox\n allow=\"autoplay\"\n allowFullScreen\n className={theme.video}\n src={url}\n title={title}\n />\n </div>\n );\n};\n\nexport default themed(YouTubeVideo, 'YouTubeVideo', baseTheme);\n"],"mappings":"AAAA,OAAOA,EAAE,MAAM,IAAI;AAEnB,OAAOC,MAAM,MAAsB,0BAA0B;AAAA,OAEtDC,QAAQ;AAAA,MAAAC,SAAA;EAAA;EAAA;EAAA;EAAA;EAAA;AAAA;AAAA,MAAAC,aAAA;EAAA;EAAA;EAAA;EAAA;AAAA;AAG6B,SAAAC,GAAA,IAAAC,IAAA,EAAAC,IAAA,IAAAC,KAAA;AAW5C;AACA;AACA;AACA;AACA;AACA;AACA;A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
|
2
4
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
BaseModal: true,
|
|
17
|
-
NavLink: true,
|
|
18
|
-
Throbber: true,
|
|
19
|
-
WithTooltip: true,
|
|
20
|
-
YouTubeVideo: true,
|
|
21
|
-
TextArea: true
|
|
22
|
-
};
|
|
23
|
-
Object.defineProperty(exports, "BaseButton", {
|
|
24
|
-
enumerable: true,
|
|
25
|
-
get: function () {
|
|
26
|
-
return _Button.BaseButton;
|
|
27
|
-
}
|
|
28
|
-
});
|
|
29
|
-
Object.defineProperty(exports, "BaseModal", {
|
|
30
|
-
enumerable: true,
|
|
31
|
-
get: function () {
|
|
32
|
-
return _Modal.BaseModal;
|
|
33
|
-
}
|
|
34
|
-
});
|
|
35
|
-
Object.defineProperty(exports, "Button", {
|
|
36
|
-
enumerable: true,
|
|
37
|
-
get: function () {
|
|
38
|
-
return _Button.default;
|
|
39
|
-
}
|
|
40
|
-
});
|
|
41
|
-
Object.defineProperty(exports, "Checkbox", {
|
|
42
|
-
enumerable: true,
|
|
43
|
-
get: function () {
|
|
44
|
-
return _Checkbox.default;
|
|
45
|
-
}
|
|
46
|
-
});
|
|
47
|
-
Object.defineProperty(exports, "Input", {
|
|
48
|
-
enumerable: true,
|
|
49
|
-
get: function () {
|
|
50
|
-
return _Input.default;
|
|
51
|
-
}
|
|
52
|
-
});
|
|
53
|
-
Object.defineProperty(exports, "Link", {
|
|
54
|
-
enumerable: true,
|
|
55
|
-
get: function () {
|
|
56
|
-
return _Link.default;
|
|
57
|
-
}
|
|
58
|
-
});
|
|
59
|
-
Object.defineProperty(exports, "MetaTags", {
|
|
60
|
-
enumerable: true,
|
|
61
|
-
get: function () {
|
|
62
|
-
return _reactHelmet.MetaTags;
|
|
63
|
-
}
|
|
64
|
-
});
|
|
65
|
-
Object.defineProperty(exports, "Modal", {
|
|
66
|
-
enumerable: true,
|
|
67
|
-
get: function () {
|
|
68
|
-
return _Modal.default;
|
|
69
|
-
}
|
|
70
|
-
});
|
|
71
|
-
Object.defineProperty(exports, "NavLink", {
|
|
72
|
-
enumerable: true,
|
|
73
|
-
get: function () {
|
|
74
|
-
return _NavLink.default;
|
|
75
|
-
}
|
|
76
|
-
});
|
|
77
|
-
Object.defineProperty(exports, "PageLayout", {
|
|
78
|
-
enumerable: true,
|
|
79
|
-
get: function () {
|
|
80
|
-
return _PageLayout.default;
|
|
81
|
-
}
|
|
82
|
-
});
|
|
83
|
-
Object.defineProperty(exports, "TextArea", {
|
|
84
|
-
enumerable: true,
|
|
85
|
-
get: function () {
|
|
86
|
-
return _TextArea.default;
|
|
87
|
-
}
|
|
88
|
-
});
|
|
89
|
-
Object.defineProperty(exports, "Throbber", {
|
|
90
|
-
enumerable: true,
|
|
91
|
-
get: function () {
|
|
92
|
-
return _Throbber.default;
|
|
93
|
-
}
|
|
94
|
-
});
|
|
95
|
-
Object.defineProperty(exports, "WithTooltip", {
|
|
96
|
-
enumerable: true,
|
|
97
|
-
get: function () {
|
|
98
|
-
return _WithTooltip.default;
|
|
99
|
-
}
|
|
100
|
-
});
|
|
101
|
-
Object.defineProperty(exports, "YouTubeVideo", {
|
|
102
|
-
enumerable: true,
|
|
103
|
-
get: function () {
|
|
104
|
-
return _YouTubeVideo.default;
|
|
105
|
-
}
|
|
106
|
-
});
|
|
107
|
-
var _reactHelmet = require("@dr.pogodin/react-helmet");
|
|
108
|
-
var _selectors = require("./selectors");
|
|
109
|
-
Object.keys(_selectors).forEach(function (key) {
|
|
110
|
-
if (key === "default" || key === "__esModule") return;
|
|
111
|
-
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
112
|
-
if (key in exports && exports[key] === _selectors[key]) return;
|
|
113
|
-
Object.defineProperty(exports, key, {
|
|
114
|
-
enumerable: true,
|
|
115
|
-
get: function () {
|
|
116
|
-
return _selectors[key];
|
|
117
|
-
}
|
|
118
|
-
});
|
|
119
|
-
});
|
|
120
|
-
var _Button = _interopRequireWildcard(require("./Button"));
|
|
121
|
-
var _Checkbox = _interopRequireDefault(require("./Checkbox"));
|
|
122
|
-
var _Input = _interopRequireDefault(require("./Input"));
|
|
123
|
-
var _Link = _interopRequireDefault(require("./Link"));
|
|
124
|
-
var _PageLayout = _interopRequireDefault(require("./PageLayout"));
|
|
125
|
-
var _Modal = _interopRequireWildcard(require("./Modal"));
|
|
126
|
-
var _NavLink = _interopRequireDefault(require("./NavLink"));
|
|
127
|
-
var _Throbber = _interopRequireDefault(require("./Throbber"));
|
|
128
|
-
var _WithTooltip = _interopRequireDefault(require("./WithTooltip"));
|
|
129
|
-
var _YouTubeVideo = _interopRequireDefault(require("./YouTubeVideo"));
|
|
130
|
-
var _TextArea = _interopRequireDefault(require("./TextArea"));
|
|
131
|
-
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
|
|
5
|
+
export { MetaTags } from '@dr.pogodin/react-helmet';
|
|
6
|
+
export * from "./selectors/index.js";
|
|
7
|
+
export { default as Button, BaseButton } from "./Button/index.js";
|
|
8
|
+
export { default as Checkbox } from "./Checkbox/index.js";
|
|
9
|
+
export { default as Input } from "./Input/index.js";
|
|
10
|
+
export { default as Link } from "./Link.js";
|
|
11
|
+
export { default as PageLayout } from "./PageLayout/index.js";
|
|
12
|
+
export { default as Modal, BaseModal } from "./Modal/index.js";
|
|
13
|
+
export { default as NavLink } from "./NavLink.js";
|
|
14
|
+
export { default as Throbber } from "./Throbber/index.js";
|
|
15
|
+
export { default as WithTooltip } from "./WithTooltip/index.js";
|
|
16
|
+
export { default as YouTubeVideo } from "./YouTubeVideo/index.js";
|
|
17
|
+
export { default as TextArea } from "./TextArea/index.js";
|
|
132
18
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["
|
|
1
|
+
{"version":3,"file":"index.js","names":["MetaTags","default","Button","BaseButton","Checkbox","Input","Link","PageLayout","Modal","BaseModal","NavLink","Throbber","WithTooltip","YouTubeVideo","TextArea"],"sources":["../../../../src/shared/components/index.ts"],"sourcesContent":["/**\n * Just an aggregation of all exported components into a single module.\n */\n\nexport { MetaTags } from '@dr.pogodin/react-helmet';\n\nexport * from 'components/selectors';\n\nexport { default as Button, BaseButton } from 'components/Button';\nexport { default as Checkbox } from 'components/Checkbox';\nexport { default as Input } from 'components/Input';\nexport { default as Link } from 'components/Link';\nexport { default as PageLayout } from 'components/PageLayout';\nexport { default as Modal, BaseModal } from 'components/Modal';\nexport { default as NavLink } from 'components/NavLink';\nexport { default as Throbber } from 'components/Throbber';\nexport { default as WithTooltip } from 'components/WithTooltip';\nexport { default as YouTubeVideo } from 'components/YouTubeVideo';\n\nexport { default as TextArea } from './TextArea';\n"],"mappings":"AAAA;AACA;AACA;;AAEA,SAASA,QAAQ,QAAQ,0BAA0B;AAAA;AAAA,SAI1CC,OAAO,IAAIC,MAAM,EAAEC,UAAU;AAAA,SAC7BF,OAAO,IAAIG,QAAQ;AAAA,SACnBH,OAAO,IAAII,KAAK;AAAA,SAChBJ,OAAO,IAAIK,IAAI;AAAA,SACfL,OAAO,IAAIM,UAAU;AAAA,SACrBN,OAAO,IAAIO,KAAK,EAAEC,SAAS;AAAA,SAC3BR,OAAO,IAAIS,OAAO;AAAA,SAClBT,OAAO,IAAIU,QAAQ;AAAA,SACnBV,OAAO,IAAIW,WAAW;AAAA,SACtBX,OAAO,IAAIY,YAAY;AAAA,SAEvBZ,OAAO,IAAIa,QAAQ","ignoreList":[]}
|
|
@@ -1,18 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.areEqual = areEqual;
|
|
7
|
-
exports.default = void 0;
|
|
8
|
-
var _react = require("react");
|
|
9
|
-
var _Modal = require("../../../Modal");
|
|
10
|
-
var _common = require("../../common");
|
|
11
|
-
var _jsxRuntime = require("react/jsx-runtime");
|
|
1
|
+
import { useImperativeHandle, useRef } from 'react';
|
|
2
|
+
import { BaseModal } from "../../../Modal/index.js";
|
|
3
|
+
import { optionValueName } from "../../common.js";
|
|
12
4
|
const S = {
|
|
13
5
|
"overlay": "-dr-pogodin-react-utils___build-web-shared-components-selectors-CustomDropdown-Options-style___overlay___ntZ5My"
|
|
14
6
|
};
|
|
15
|
-
|
|
7
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
8
|
+
export function areEqual(a, b) {
|
|
16
9
|
return a?.left === b?.left && a?.top === b?.top && a?.width === b?.width;
|
|
17
10
|
}
|
|
18
11
|
const Options = ({
|
|
@@ -25,8 +18,8 @@ const Options = ({
|
|
|
25
18
|
options,
|
|
26
19
|
ref
|
|
27
20
|
}) => {
|
|
28
|
-
const opsRef =
|
|
29
|
-
|
|
21
|
+
const opsRef = useRef(null);
|
|
22
|
+
useImperativeHandle(ref, () => ({
|
|
30
23
|
measure: () => {
|
|
31
24
|
const e = opsRef.current?.parentElement;
|
|
32
25
|
if (!e) return undefined;
|
|
@@ -41,8 +34,8 @@ const Options = ({
|
|
|
41
34
|
const optionNodes = [];
|
|
42
35
|
for (const option of options) {
|
|
43
36
|
if (!filter || filter(option)) {
|
|
44
|
-
const [iValue, iName] =
|
|
45
|
-
optionNodes.push(/*#__PURE__*/(
|
|
37
|
+
const [iValue, iName] = optionValueName(option);
|
|
38
|
+
optionNodes.push(/*#__PURE__*/_jsx("div", {
|
|
46
39
|
className: optionClass,
|
|
47
40
|
onClick: e => {
|
|
48
41
|
onChange(iValue);
|
|
@@ -60,7 +53,7 @@ const Options = ({
|
|
|
60
53
|
}, iValue));
|
|
61
54
|
}
|
|
62
55
|
}
|
|
63
|
-
return /*#__PURE__*/(
|
|
56
|
+
return /*#__PURE__*/_jsx(BaseModal
|
|
64
57
|
// Closes the dropdown (cancels the selection) on any page scrolling attempt.
|
|
65
58
|
// This is the same native <select> elements do on scrolling, and at least for
|
|
66
59
|
// now we have no reason to deal with complications needed to support open
|
|
@@ -78,11 +71,11 @@ const Options = ({
|
|
|
78
71
|
hoc: '',
|
|
79
72
|
overlay: S.overlay
|
|
80
73
|
},
|
|
81
|
-
children: /*#__PURE__*/(
|
|
74
|
+
children: /*#__PURE__*/_jsx("div", {
|
|
82
75
|
ref: opsRef,
|
|
83
76
|
children: optionNodes
|
|
84
77
|
})
|
|
85
78
|
});
|
|
86
79
|
};
|
|
87
|
-
|
|
80
|
+
export default Options;
|
|
88
81
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["
|
|
1
|
+
{"version":3,"file":"index.js","names":["useImperativeHandle","useRef","BaseModal","optionValueName","S","jsx","_jsx","areEqual","a","b","left","top","width","Options","containerClass","containerStyle","filter","onCancel","onChange","optionClass","options","ref","opsRef","measure","e","current","parentElement","undefined","rect","getBoundingClientRect","style","window","getComputedStyle","mBottom","parseFloat","marginBottom","mTop","marginTop","height","optionNodes","option","iValue","iName","push","className","onClick","stopPropagation","onKeyDown","key","role","tabIndex","children","cancelOnScrolling","dontDisableScrolling","theme","ad","container","context","hoc","overlay"],"sources":["../../../../../../../src/shared/components/selectors/CustomDropdown/Options/index.tsx"],"sourcesContent":["import {\n type FunctionComponent,\n type ReactNode,\n type RefObject,\n useImperativeHandle,\n useRef,\n} from 'react';\n\nimport { BaseModal } from 'components/Modal';\n\nimport {\n type OptionT,\n type OptionsT,\n type ValueT,\n optionValueName,\n} from '../../common';\n\nimport S from './style.scss';\n\nexport type ContainerPosT = {\n left: number;\n top: number;\n width: number;\n};\n\nexport function areEqual(a?: ContainerPosT, b?: ContainerPosT): boolean {\n return a?.left === b?.left && a?.top === b?.top && a?.width === b?.width;\n}\n\nexport type RefT = {\n measure: () => DOMRect | undefined;\n};\n\ntype PropsT = {\n containerClass: string;\n containerStyle?: ContainerPosT;\n filter?: (item: OptionT<ReactNode> | ValueT) => boolean;\n optionClass: string;\n options: Readonly<OptionsT<ReactNode>>;\n onCancel: () => void;\n onChange: (value: ValueT) => void;\n ref?: RefObject<RefT | null>;\n};\n\nconst Options: FunctionComponent<PropsT> = ({\n containerClass,\n containerStyle,\n filter,\n onCancel,\n onChange,\n optionClass,\n options,\n ref,\n}) => {\n const opsRef = useRef<HTMLDivElement>(null);\n\n useImperativeHandle(ref, () => ({\n measure: () => {\n const e = opsRef.current?.parentElement;\n if (!e) return undefined;\n\n const rect = opsRef.current!.getBoundingClientRect();\n const style = window.getComputedStyle(e);\n const mBottom = parseFloat(style.marginBottom);\n const mTop = parseFloat(style.marginTop);\n\n rect.height += mBottom + mTop;\n\n return rect;\n },\n }), []);\n\n const optionNodes: ReactNode[] = [];\n for (const option of options) {\n if (!filter || filter(option)) {\n const [iValue, iName] = optionValueName(option);\n optionNodes.push(\n <div\n className={optionClass}\n key={iValue}\n onClick={(e) => {\n onChange(iValue);\n e.stopPropagation();\n }}\n onKeyDown={(e) => {\n if (e.key === 'Enter') {\n onChange(iValue);\n e.stopPropagation();\n }\n }}\n role=\"button\"\n tabIndex={0}\n >\n {iName}\n </div>,\n );\n }\n }\n\n return (\n <BaseModal\n // Closes the dropdown (cancels the selection) on any page scrolling attempt.\n // This is the same native <select> elements do on scrolling, and at least for\n // now we have no reason to deal with complications needed to support open\n // dropdowns during the scrolling (that would need to re-position it in\n // response to the position changes of the root dropdown element).\n cancelOnScrolling\n dontDisableScrolling\n onCancel={onCancel}\n style={containerStyle}\n theme={{\n ad: '',\n container: containerClass,\n context: '',\n hoc: '',\n overlay: S.overlay,\n }}\n >\n <div ref={opsRef}>{optionNodes}</div>\n </BaseModal>\n );\n};\n\nexport default Options;\n"],"mappings":"AAAA,SAIEA,mBAAmB,EACnBC,MAAM,QACD,OAAO;AAAA,SAELC,SAAS;AAAA,SAMhBC,eAAe;AAAA,MAAAC,CAAA;EAAA;AAAA;AAGY,SAAAC,GAAA,IAAAC,IAAA;AAQ7B,OAAO,SAASC,QAAQA,CAACC,CAAiB,EAAEC,CAAiB,EAAW;EACtE,OAAOD,CAAC,EAAEE,IAAI,KAAKD,CAAC,EAAEC,IAAI,IAAIF,CAAC,EAAEG,GAAG,KAAKF,CAAC,EAAEE,GAAG,IAAIH,CAAC,EAAEI,KAAK,KAAKH,CAAC,EAAEG,KAAK;AAC1E;AAiBA,MAAMC,OAAkC,GAAGA,CAAC;EAC1CC,cAAc;EACdC,cAAc;EACdC,MAAM;EACNC,QAAQ;EACRC,QAAQ;EACRC,WAAW;EACXC,OAAO;EACPC;AACF,CAAC,KAAK;EACJ,MAAMC,MAAM,GAAGrB,MAAM,CAAiB,IAAI,CAAC;EAE3CD,mBAAmB,CAACqB,GAAG,EAAE,OAAO;IAC9BE,OAAO,EAAEA,CAAA,KAAM;MACb,MAAMC,CAAC,GAAGF,MAAM,CAACG,OAAO,EAAEC,aAAa;MACvC,IAAI,CAACF,CAAC,EAAE,OAAOG,SAAS;MAExB,MAAMC,IAAI,GAAGN,MAAM,CAACG,OAAO,CAAEI,qBAAqB,CAAC,CAAC;MACpD,MAAMC,KAAK,GAAGC,MAAM,CAACC,gBAAgB,CAACR,CAAC,CAAC;MACxC,MAAMS,OAAO,GAAGC,UAAU,CAACJ,KAAK,CAACK,YAAY,CAAC;MAC9C,MAAMC,IAAI,GAAGF,UAAU,CAACJ,KAAK,CAACO,SAAS,CAAC;MAExCT,IAAI,CAACU,MAAM,IAAIL,OAAO,GAAGG,IAAI;MAE7B,OAAOR,IAAI;IAC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
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
value: true
|
|
6
|
-
});
|
|
7
|
-
exports.default = void 0;
|
|
8
|
-
var _react = require("react");
|
|
9
|
-
var _reactThemes = _interopRequireDefault(require("@dr.pogodin/react-themes"));
|
|
10
|
-
var _common = require("../common");
|
|
11
|
-
var _Options = _interopRequireWildcard(require("./Options"));
|
|
12
|
-
var _jsxRuntime = require("react/jsx-runtime");
|
|
13
|
-
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
|
|
1
|
+
import { useEffect, useRef, useState } from 'react';
|
|
2
|
+
import themed from '@dr.pogodin/react-themes';
|
|
3
|
+
import { optionValueName } from "../common.js";
|
|
4
|
+
import Options, { areEqual } from "./Options/index.js";
|
|
14
5
|
const defaultTheme = {
|
|
15
6
|
"context": "-dr-pogodin-react-utils___build-web-shared-components-selectors-CustomDropdown-theme___context___SNj3wp",
|
|
16
7
|
"ad": "-dr-pogodin-react-utils___build-web-shared-components-selectors-CustomDropdown-theme___ad___T6eOJ-",
|
|
@@ -24,6 +15,7 @@ const defaultTheme = {
|
|
|
24
15
|
"active": "-dr-pogodin-react-utils___build-web-shared-components-selectors-CustomDropdown-theme___active___RoOAZK",
|
|
25
16
|
"upward": "-dr-pogodin-react-utils___build-web-shared-components-selectors-CustomDropdown-theme___upward___--5Xpy"
|
|
26
17
|
};
|
|
18
|
+
import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
27
19
|
const BaseCustomDropdown = ({
|
|
28
20
|
filter,
|
|
29
21
|
label,
|
|
@@ -32,12 +24,12 @@ const BaseCustomDropdown = ({
|
|
|
32
24
|
theme,
|
|
33
25
|
value
|
|
34
26
|
}) => {
|
|
35
|
-
const [active, setActive] =
|
|
36
|
-
const dropdownRef =
|
|
37
|
-
const opsRef =
|
|
38
|
-
const [opsPos, setOpsPos] =
|
|
39
|
-
const [upward, setUpward] =
|
|
40
|
-
|
|
27
|
+
const [active, setActive] = useState(false);
|
|
28
|
+
const dropdownRef = useRef(null);
|
|
29
|
+
const opsRef = useRef(null);
|
|
30
|
+
const [opsPos, setOpsPos] = useState();
|
|
31
|
+
const [upward, setUpward] = useState(false);
|
|
32
|
+
useEffect(() => {
|
|
41
33
|
if (!active) return undefined;
|
|
42
34
|
let id;
|
|
43
35
|
const cb = () => {
|
|
@@ -57,7 +49,7 @@ const BaseCustomDropdown = ({
|
|
|
57
49
|
top: anchor.bottom,
|
|
58
50
|
width: anchor.width
|
|
59
51
|
};
|
|
60
|
-
setOpsPos(now =>
|
|
52
|
+
setOpsPos(now => areEqual(now, pos) ? now : pos);
|
|
61
53
|
}
|
|
62
54
|
id = requestAnimationFrame(cb);
|
|
63
55
|
};
|
|
@@ -84,12 +76,12 @@ const BaseCustomDropdown = ({
|
|
|
84
76
|
});
|
|
85
77
|
e.stopPropagation();
|
|
86
78
|
};
|
|
87
|
-
let selected = /*#__PURE__*/(
|
|
79
|
+
let selected = /*#__PURE__*/_jsx(_Fragment, {
|
|
88
80
|
children: "\u200C"
|
|
89
81
|
});
|
|
90
82
|
for (const option of options) {
|
|
91
83
|
if (!filter || filter(option)) {
|
|
92
|
-
const [iValue, iName] =
|
|
84
|
+
const [iValue, iName] = optionValueName(option);
|
|
93
85
|
if (iValue === value) {
|
|
94
86
|
selected = iName;
|
|
95
87
|
break;
|
|
@@ -103,12 +95,12 @@ const BaseCustomDropdown = ({
|
|
|
103
95
|
containerClassName += ` ${theme.upward}`;
|
|
104
96
|
opsContainerClass += ` ${theme.upward}`;
|
|
105
97
|
}
|
|
106
|
-
return /*#__PURE__*/(
|
|
98
|
+
return /*#__PURE__*/_jsxs("div", {
|
|
107
99
|
className: containerClassName,
|
|
108
|
-
children: [label === undefined ? null : /*#__PURE__*/(
|
|
100
|
+
children: [label === undefined ? null : /*#__PURE__*/_jsx("div", {
|
|
109
101
|
className: theme.label,
|
|
110
102
|
children: label
|
|
111
|
-
}), /*#__PURE__*/(
|
|
103
|
+
}), /*#__PURE__*/_jsxs("div", {
|
|
112
104
|
className: theme.dropdown,
|
|
113
105
|
onClick: openList,
|
|
114
106
|
onKeyDown: e => {
|
|
@@ -117,10 +109,10 @@ const BaseCustomDropdown = ({
|
|
|
117
109
|
ref: dropdownRef,
|
|
118
110
|
role: "listbox",
|
|
119
111
|
tabIndex: 0,
|
|
120
|
-
children: [selected, /*#__PURE__*/(
|
|
112
|
+
children: [selected, /*#__PURE__*/_jsx("div", {
|
|
121
113
|
className: theme.arrow
|
|
122
114
|
})]
|
|
123
|
-
}), active ? /*#__PURE__*/(
|
|
115
|
+
}), active ? /*#__PURE__*/_jsx(Options, {
|
|
124
116
|
containerClass: opsContainerClass,
|
|
125
117
|
containerStyle: opsPos,
|
|
126
118
|
onCancel: () => {
|
|
@@ -136,5 +128,5 @@ const BaseCustomDropdown = ({
|
|
|
136
128
|
}) : null]
|
|
137
129
|
});
|
|
138
130
|
};
|
|
139
|
-
|
|
131
|
+
export default themed(BaseCustomDropdown, 'CustomDropdown', defaultTheme);
|
|
140
132
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["
|
|
1
|
+
{"version":3,"file":"index.js","names":["useEffect","useRef","useState","themed","optionValueName","Options","areEqual","defaultTheme","Fragment","_Fragment","jsx","_jsx","jsxs","_jsxs","BaseCustomDropdown","filter","label","onChange","options","theme","value","active","setActive","dropdownRef","opsRef","opsPos","setOpsPos","upward","setUpward","undefined","id","cb","anchor","current","getBoundingClientRect","opsRect","measure","fitsDown","bottom","height","window","visualViewport","fitsUp","top","up","pos","left","width","now","requestAnimationFrame","cancelAnimationFrame","openList","e","view","rect","stopPropagation","selected","children","option","iValue","iName","containerClassName","container","opsContainerClass","select","className","dropdown","onClick","onKeyDown","key","ref","role","tabIndex","arrow","containerClass","containerStyle","onCancel","newValue","optionClass"],"sources":["../../../../../../src/shared/components/selectors/CustomDropdown/index.tsx"],"sourcesContent":["import { useEffect, useRef, useState } from 'react';\n\nimport themed from '@dr.pogodin/react-themes';\n\nimport { type PropsT, type ValueT, optionValueName } from '../common';\n\nimport Options, { type ContainerPosT, type RefT, areEqual } from './Options';\n\nimport defaultTheme from './theme.scss';\n\nconst BaseCustomDropdown: React.FunctionComponent<\n PropsT<React.ReactNode, (value: ValueT) => void>\n> = ({\n filter,\n label,\n onChange,\n options,\n theme,\n value,\n}) => {\n const [active, setActive] = useState(false);\n\n const dropdownRef = useRef<HTMLDivElement>(null);\n const opsRef = useRef<RefT>(null);\n\n const [opsPos, setOpsPos] = useState<ContainerPosT>();\n const [upward, setUpward] = useState(false);\n\n useEffect(() => {\n if (!active) return undefined;\n\n let id: number;\n const cb = () => {\n const anchor = dropdownRef.current?.getBoundingClientRect();\n const opsRect = opsRef.current?.measure();\n if (anchor && opsRect) {\n const fitsDown = anchor.bottom + opsRect.height\n < (window.visualViewport?.height ?? 0);\n const fitsUp = anchor.top - opsRect.height > 0;\n\n const up = !fitsDown && fitsUp;\n setUpward(up);\n\n const pos = up ? {\n left: anchor.left,\n top: anchor.top - opsRect.height - 1,\n width: anchor.width,\n } : {\n left: anchor.left,\n top: anchor.bottom,\n width: anchor.width,\n };\n\n setOpsPos((now) => (areEqual(now, pos) ? now : pos));\n }\n id = requestAnimationFrame(cb);\n };\n requestAnimationFrame(cb);\n\n return () => {\n cancelAnimationFrame(id);\n };\n }, [active]);\n\n const openList = (\n e: React.KeyboardEvent<HTMLDivElement> | React.MouseEvent<HTMLDivElement>,\n ) => {\n const view = window.visualViewport;\n const rect = dropdownRef.current!.getBoundingClientRect();\n setActive(true);\n\n // NOTE: This first opens the dropdown off-screen, where it is measured\n // by an effect declared above, and then positioned below, or above\n // the original dropdown element, depending where it fits best\n // (if we first open it downward, it would flick if we immediately\n // move it above, at least with the current position update via local\n // react state, and not imperatively).\n setOpsPos({\n left: view?.width ?? 0,\n top: view?.height ?? 0,\n width: rect.width,\n });\n\n e.stopPropagation();\n };\n\n let selected: React.ReactNode = <>‌</>;\n for (const option of options) {\n if (!filter || filter(option)) {\n const [iValue, iName] = optionValueName(option);\n if (iValue === value) {\n selected = iName;\n break;\n }\n }\n }\n\n let containerClassName = theme.container;\n if (active) containerClassName += ` ${theme.active}`;\n\n let opsContainerClass = theme.select ?? '';\n if (upward) {\n containerClassName += ` ${theme.upward}`;\n opsContainerClass += ` ${theme.upward}`;\n }\n\n return (\n <div className={containerClassName}>\n {label === undefined ? null\n : <div className={theme.label}>{label}</div>}\n <div\n className={theme.dropdown}\n onClick={openList}\n onKeyDown={(e) => {\n if (e.key === 'Enter') openList(e);\n }}\n ref={dropdownRef}\n role=\"listbox\"\n tabIndex={0}\n >\n {selected}\n <div className={theme.arrow} />\n </div>\n {\n active ? (\n <Options\n containerClass={opsContainerClass}\n containerStyle={opsPos}\n onCancel={() => {\n setActive(false);\n }}\n onChange={(newValue) => {\n setActive(false);\n if (onChange) onChange(newValue);\n }}\n optionClass={theme.option ?? ''}\n options={options}\n ref={opsRef}\n />\n ) : null\n }\n </div>\n );\n};\n\nexport default themed(BaseCustomDropdown, 'CustomDropdown', defaultTheme);\n"],"mappings":"AAAA,SAASA,SAAS,EAAEC,MAAM,EAAEC,QAAQ,QAAQ,OAAO;AAEnD,OAAOC,MAAM,MAAM,0BAA0B;AAAA,SAEVC,eAAe;AAAA,OAE3CC,OAAO,IAAmCC,QAAQ;AAAA,MAAAC,YAAA;EAAA;EAAA;EAAA;EAAA;EAAA;EAAA;EAAA;EAAA;EAAA;EAAA;EAAA;AAA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AC,KAAK,CAAC;MAClB,CAAE;MACFL,QAAQ,EAAG4D,QAAQ,IAAK;QACtBvD,SAAS,CAAC,KAAK,CAAC;QAChB,IAAIL,QAAQ,EAAEA,QAAQ,CAAC4D,QAAQ,CAAC;MAClC,CAAE;MACFC,WAAW,EAAE3D,KAAK,CAACuC,MAAM,IAAI,EAAG;MAChCxC,OAAO,EAAEA,OAAQ;MACjBoD,GAAG,EAAE9C;IAAO,CACb,CAAC,GACA,IAAI;EAAA,CAEP,CAAC;AAEV,CAAC;AAED,eAAerB,MAAM,CAACW,kBAAkB,EAAE,gBAAgB,EAAEP,YAAY,CAAC","ignoreList":[]}
|
|
@@ -1,14 +1,7 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
Object.defineProperty(exports, "__esModule", {
|
|
5
|
-
value: true
|
|
6
|
-
});
|
|
7
|
-
exports.default = void 0;
|
|
8
|
-
var _reactThemes = _interopRequireDefault(require("@dr.pogodin/react-themes"));
|
|
9
|
-
var _common = require("../common");
|
|
10
|
-
var _jsxRuntime = require("react/jsx-runtime");
|
|
11
1
|
// Implements dropdown based on the native HTML <select> element.
|
|
2
|
+
|
|
3
|
+
import themed from '@dr.pogodin/react-themes';
|
|
4
|
+
import { optionValueName } from "../common.js";
|
|
12
5
|
const defaultTheme = {
|
|
13
6
|
"context": "-dr-pogodin-react-utils___build-web-shared-components-selectors-NativeDropdown-theme___context___WbwY1Y",
|
|
14
7
|
"ad": "-dr-pogodin-react-utils___build-web-shared-components-selectors-NativeDropdown-theme___ad___AP5hsY",
|
|
@@ -42,6 +35,7 @@ const defaultTheme = {
|
|
|
42
35
|
* @param [props....]
|
|
43
36
|
* [Other theming properties](https://www.npmjs.com/package/@dr.pogodin/react-themes#themed-component-properties)
|
|
44
37
|
*/
|
|
38
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
45
39
|
const Dropdown = ({
|
|
46
40
|
filter,
|
|
47
41
|
label,
|
|
@@ -55,9 +49,9 @@ const Dropdown = ({
|
|
|
55
49
|
const optionElements = [];
|
|
56
50
|
for (const option of options) {
|
|
57
51
|
if (!filter || filter(option)) {
|
|
58
|
-
const [iValue, iName] =
|
|
52
|
+
const [iValue, iName] = optionValueName(option);
|
|
59
53
|
isValidValue ||= iValue === value;
|
|
60
|
-
optionElements.push(/*#__PURE__*/(
|
|
54
|
+
optionElements.push(/*#__PURE__*/_jsx("option", {
|
|
61
55
|
className: theme.option,
|
|
62
56
|
value: iValue,
|
|
63
57
|
children: iName
|
|
@@ -69,7 +63,7 @@ const Dropdown = ({
|
|
|
69
63
|
// any valid option. In Chrome, and some other browsers, we are able to hide
|
|
70
64
|
// it from the opened dropdown; in others, e.g. Safari, the best we can do is
|
|
71
65
|
// to show it as disabled.
|
|
72
|
-
const hiddenOption = isValidValue ? null : /*#__PURE__*/(
|
|
66
|
+
const hiddenOption = isValidValue ? null : /*#__PURE__*/_jsx("option", {
|
|
73
67
|
className: theme.hiddenOption,
|
|
74
68
|
disabled: true,
|
|
75
69
|
value: value,
|
|
@@ -77,24 +71,24 @@ const Dropdown = ({
|
|
|
77
71
|
}, "__reactUtilsHiddenOption");
|
|
78
72
|
let selectClassName = theme.select;
|
|
79
73
|
if (!isValidValue) selectClassName += ` ${theme.invalid}`;
|
|
80
|
-
return /*#__PURE__*/(
|
|
74
|
+
return /*#__PURE__*/_jsxs("div", {
|
|
81
75
|
className: theme.container,
|
|
82
|
-
children: [label === undefined ? null : /*#__PURE__*/(
|
|
76
|
+
children: [label === undefined ? null : /*#__PURE__*/_jsx("div", {
|
|
83
77
|
className: theme.label,
|
|
84
78
|
children: label
|
|
85
|
-
}), /*#__PURE__*/(
|
|
79
|
+
}), /*#__PURE__*/_jsxs("div", {
|
|
86
80
|
className: theme.dropdown,
|
|
87
|
-
children: [/*#__PURE__*/(
|
|
81
|
+
children: [/*#__PURE__*/_jsxs("select", {
|
|
88
82
|
className: selectClassName,
|
|
89
83
|
"data-testid": process.env.NODE_ENV === 'production' ? undefined : testId,
|
|
90
84
|
onChange: onChange,
|
|
91
85
|
value: value,
|
|
92
86
|
children: [hiddenOption, optionElements]
|
|
93
|
-
}), /*#__PURE__*/(
|
|
87
|
+
}), /*#__PURE__*/_jsx("div", {
|
|
94
88
|
className: theme.arrow
|
|
95
89
|
})]
|
|
96
90
|
})]
|
|
97
91
|
});
|
|
98
92
|
};
|
|
99
|
-
|
|
93
|
+
export default themed(Dropdown, 'Dropdown', defaultTheme);
|
|
100
94
|
//# sourceMappingURL=index.js.map
|