@dr.pogodin/react-utils 1.28.1 → 1.29.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (89) hide show
  1. package/build/development/index.js +36 -84
  2. package/build/development/index.js.map +1 -1
  3. package/build/development/shared/components/Button/index.js +2 -1
  4. package/build/development/shared/components/Button/index.js.map +1 -1
  5. package/build/development/shared/components/Checkbox/index.js +2 -1
  6. package/build/development/shared/components/Checkbox/index.js.map +1 -1
  7. package/build/development/shared/components/Dropdown/index.js +14 -9
  8. package/build/development/shared/components/Dropdown/index.js.map +1 -1
  9. package/build/development/shared/components/Input/index.js +2 -1
  10. package/build/development/shared/components/Input/index.js.map +1 -1
  11. package/build/development/shared/components/Modal/index.js +2 -1
  12. package/build/development/shared/components/Modal/index.js.map +1 -1
  13. package/build/development/shared/components/PageLayout/index.js +2 -1
  14. package/build/development/shared/components/PageLayout/index.js.map +1 -1
  15. package/build/development/shared/components/TextArea/index.js +94 -0
  16. package/build/development/shared/components/TextArea/index.js.map +1 -0
  17. package/build/development/shared/components/Throbber/index.js +2 -1
  18. package/build/development/shared/components/Throbber/index.js.map +1 -1
  19. package/build/development/shared/components/WithTooltip/Tooltip.js +2 -1
  20. package/build/development/shared/components/WithTooltip/Tooltip.js.map +1 -1
  21. package/build/development/shared/components/WithTooltip/index.js +1 -0
  22. package/build/development/shared/components/WithTooltip/index.js.map +1 -1
  23. package/build/development/shared/components/YouTubeVideo/index.js +2 -1
  24. package/build/development/shared/components/YouTubeVideo/index.js.map +1 -1
  25. package/build/development/shared/components/index.js +7 -0
  26. package/build/development/shared/components/index.js.map +1 -1
  27. package/build/development/style.css +89 -0
  28. package/build/development/web.bundle.js +33 -13
  29. package/build/production/index.js +1 -1
  30. package/build/production/index.js.map +1 -1
  31. package/build/production/shared/components/Button/index.js +2 -2
  32. package/build/production/shared/components/Button/index.js.map +1 -1
  33. package/build/production/shared/components/Checkbox/index.js +2 -2
  34. package/build/production/shared/components/Checkbox/index.js.map +1 -1
  35. package/build/production/shared/components/Dropdown/index.js +2 -2
  36. package/build/production/shared/components/Dropdown/index.js.map +1 -1
  37. package/build/production/shared/components/Input/index.js +2 -2
  38. package/build/production/shared/components/Input/index.js.map +1 -1
  39. package/build/production/shared/components/Modal/index.js +2 -2
  40. package/build/production/shared/components/Modal/index.js.map +1 -1
  41. package/build/production/shared/components/PageLayout/index.js +2 -2
  42. package/build/production/shared/components/PageLayout/index.js.map +1 -1
  43. package/build/production/shared/components/TextArea/index.js +10 -0
  44. package/build/production/shared/components/TextArea/index.js.map +1 -0
  45. package/build/production/shared/components/Throbber/index.js +2 -2
  46. package/build/production/shared/components/Throbber/index.js.map +1 -1
  47. package/build/production/shared/components/WithTooltip/Tooltip.js +2 -2
  48. package/build/production/shared/components/WithTooltip/Tooltip.js.map +1 -1
  49. package/build/production/shared/components/WithTooltip/index.js +1 -1
  50. package/build/production/shared/components/WithTooltip/index.js.map +1 -1
  51. package/build/production/shared/components/YouTubeVideo/index.js +2 -2
  52. package/build/production/shared/components/YouTubeVideo/index.js.map +1 -1
  53. package/build/production/shared/components/index.js +1 -1
  54. package/build/production/shared/components/index.js.map +1 -1
  55. package/build/production/style.css +1 -1
  56. package/build/production/style.css.map +1 -1
  57. package/build/production/web.bundle.js +1 -1
  58. package/build/production/web.bundle.js.map +1 -1
  59. package/build/types-code/index.d.ts +1 -1
  60. package/build/types-code/shared/components/Button/index.d.ts +2 -5
  61. package/build/types-code/shared/components/Checkbox/index.d.ts +2 -5
  62. package/build/types-code/shared/components/Dropdown/index.d.ts +2 -8
  63. package/build/types-code/shared/components/Input/index.d.ts +2 -5
  64. package/build/types-code/shared/components/Modal/index.d.ts +2 -4
  65. package/build/types-code/shared/components/PageLayout/index.d.ts +2 -7
  66. package/build/types-code/shared/components/TextArea/index.d.ts +12 -0
  67. package/build/types-code/shared/components/Throbber/index.d.ts +2 -5
  68. package/build/types-code/shared/components/WithTooltip/Tooltip.d.ts +1 -6
  69. package/build/types-code/shared/components/WithTooltip/index.d.ts +3 -4
  70. package/build/types-code/shared/components/YouTubeVideo/index.d.ts +2 -4
  71. package/build/types-code/shared/components/index.d.ts +1 -0
  72. package/build/types-scss/src/shared/components/Dropdown/theme.scss.d.ts +1 -0
  73. package/build/types-scss/src/shared/components/TextArea/style.scss.d.ts +6 -0
  74. package/package.json +33 -33
  75. package/src/index.ts +1 -16
  76. package/src/shared/components/Button/index.tsx +4 -10
  77. package/src/shared/components/Checkbox/index.tsx +9 -10
  78. package/src/shared/components/Dropdown/index.tsx +28 -25
  79. package/src/shared/components/Dropdown/theme.scss +6 -0
  80. package/src/shared/components/Input/index.tsx +8 -10
  81. package/src/shared/components/Modal/index.tsx +4 -8
  82. package/src/shared/components/PageLayout/index.tsx +15 -14
  83. package/src/shared/components/TextArea/index.tsx +107 -0
  84. package/src/shared/components/TextArea/style.scss +37 -0
  85. package/src/shared/components/Throbber/index.tsx +8 -10
  86. package/src/shared/components/WithTooltip/Tooltip.tsx +10 -6
  87. package/src/shared/components/WithTooltip/index.tsx +7 -4
  88. package/src/shared/components/YouTubeVideo/index.tsx +4 -8
  89. package/src/shared/components/index.ts +2 -0
@@ -4,36 +4,37 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
4
4
  Object.defineProperty(exports, "__esModule", {
5
5
  value: true
6
6
  });
7
+ var _exportNames = {
8
+ client: true,
9
+ server: true,
10
+ config: true,
11
+ Barrier: true,
12
+ Emitter: true,
13
+ isomorphy: true,
14
+ getSsrContext: true,
15
+ JU: true,
16
+ Semaphore: true,
17
+ splitComponent: true,
18
+ themed: true,
19
+ ThemeProvider: true,
20
+ time: true,
21
+ webpack: true,
22
+ withRetries: true,
23
+ api: true,
24
+ PT: true,
25
+ getGlobalState: true,
26
+ GlobalStateProvider: true,
27
+ useAsyncCollection: true,
28
+ useAsyncData: true,
29
+ useGlobalState: true,
30
+ withGlobalStateType: true
31
+ };
7
32
  Object.defineProperty(exports, "Barrier", {
8
33
  enumerable: true,
9
34
  get: function () {
10
35
  return _utils.Barrier;
11
36
  }
12
37
  });
13
- Object.defineProperty(exports, "BaseModal", {
14
- enumerable: true,
15
- get: function () {
16
- return _components.BaseModal;
17
- }
18
- });
19
- Object.defineProperty(exports, "Button", {
20
- enumerable: true,
21
- get: function () {
22
- return _components.Button;
23
- }
24
- });
25
- Object.defineProperty(exports, "Checkbox", {
26
- enumerable: true,
27
- get: function () {
28
- return _components.Checkbox;
29
- }
30
- });
31
- Object.defineProperty(exports, "Dropdown", {
32
- enumerable: true,
33
- get: function () {
34
- return _components.Dropdown;
35
- }
36
- });
37
38
  Object.defineProperty(exports, "Emitter", {
38
39
  enumerable: true,
39
40
  get: function () {
@@ -46,55 +47,13 @@ Object.defineProperty(exports, "GlobalStateProvider", {
46
47
  return _reactGlobalState.GlobalStateProvider;
47
48
  }
48
49
  });
49
- Object.defineProperty(exports, "Input", {
50
- enumerable: true,
51
- get: function () {
52
- return _components.Input;
53
- }
54
- });
55
50
  Object.defineProperty(exports, "JU", {
56
51
  enumerable: true,
57
52
  get: function () {
58
53
  return _utils.JU;
59
54
  }
60
55
  });
61
- Object.defineProperty(exports, "Link", {
62
- enumerable: true,
63
- get: function () {
64
- return _components.Link;
65
- }
66
- });
67
- Object.defineProperty(exports, "MetaTags", {
68
- enumerable: true,
69
- get: function () {
70
- return _components.MetaTags;
71
- }
72
- });
73
- Object.defineProperty(exports, "Modal", {
74
- enumerable: true,
75
- get: function () {
76
- return _components.Modal;
77
- }
78
- });
79
- Object.defineProperty(exports, "NavLink", {
80
- enumerable: true,
81
- get: function () {
82
- return _components.NavLink;
83
- }
84
- });
85
56
  exports.PT = void 0;
86
- Object.defineProperty(exports, "PageLayout", {
87
- enumerable: true,
88
- get: function () {
89
- return _components.PageLayout;
90
- }
91
- });
92
- Object.defineProperty(exports, "ScalableRect", {
93
- enumerable: true,
94
- get: function () {
95
- return _components.ScalableRect;
96
- }
97
- });
98
57
  Object.defineProperty(exports, "Semaphore", {
99
58
  enumerable: true,
100
59
  get: function () {
@@ -107,24 +66,6 @@ Object.defineProperty(exports, "ThemeProvider", {
107
66
  return _utils.ThemeProvider;
108
67
  }
109
68
  });
110
- Object.defineProperty(exports, "Throbber", {
111
- enumerable: true,
112
- get: function () {
113
- return _components.Throbber;
114
- }
115
- });
116
- Object.defineProperty(exports, "WithTooltip", {
117
- enumerable: true,
118
- get: function () {
119
- return _components.WithTooltip;
120
- }
121
- });
122
- Object.defineProperty(exports, "YouTubeVideo", {
123
- enumerable: true,
124
- get: function () {
125
- return _components.YouTubeVideo;
126
- }
127
- });
128
69
  Object.defineProperty(exports, "api", {
129
70
  enumerable: true,
130
71
  get: function () {
@@ -217,6 +158,17 @@ var _PT = _interopRequireWildcard(require("prop-types"));
217
158
  exports.PT = _PT;
218
159
  var _reactGlobalState = require("@dr.pogodin/react-global-state");
219
160
  var _components = require("./shared/components");
161
+ Object.keys(_components).forEach(function (key) {
162
+ if (key === "default" || key === "__esModule") return;
163
+ if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
164
+ if (key in exports && exports[key] === _components[key]) return;
165
+ Object.defineProperty(exports, key, {
166
+ enumerable: true,
167
+ get: function () {
168
+ return _components[key];
169
+ }
170
+ });
171
+ });
220
172
  function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
221
173
  function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
222
174
  const server = exports.server = _utils.webpack.requireWeak("./server", __dirname);
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":["_utils","require","_axios","_interopRequireDefault","_PT","_interopRequireWildcard","exports","PT","_reactGlobalState","_components","_getRequireWildcardCache","e","WeakMap","r","t","__esModule","default","has","get","n","__proto__","a","Object","defineProperty","getOwnPropertyDescriptor","u","prototype","hasOwnProperty","call","i","set","server","webpack","requireWeak","__dirname","client","undefined"],"sources":["../../src/index.ts"],"sourcesContent":["import 'styles/global.scss';\n\nimport { webpack } from 'utils';\n\nimport type ServerT from './server';\n\nconst server = webpack.requireWeak('./server', __dirname) as (typeof ServerT) | null;\n\nconst client = server ? undefined : require('./client').default;\n\nexport { default as api } from 'axios';\nexport * as PT from 'prop-types';\n\nexport {\n type AsyncCollectionLoaderT,\n type AsyncDataEnvelopeT,\n type AsyncDataLoaderT,\n type ForceT,\n type UseAsyncDataOptionsT,\n type UseAsyncDataResT,\n type UseGlobalStateResT,\n type ValueOrInitializerT,\n getGlobalState,\n GlobalStateProvider,\n useAsyncCollection,\n useAsyncData,\n useGlobalState,\n withGlobalStateType,\n} from '@dr.pogodin/react-global-state';\n\nexport {\n BaseModal,\n Button,\n Checkbox,\n Dropdown,\n Input,\n Link,\n PageLayout,\n MetaTags,\n Modal,\n NavLink,\n ScalableRect,\n Throbber,\n WithTooltip,\n YouTubeVideo,\n} from 'components';\n\nexport {\n type Theme,\n config,\n Barrier,\n Emitter,\n isomorphy,\n getSsrContext,\n JU,\n Semaphore,\n splitComponent,\n themed,\n ThemeProvider,\n time,\n webpack,\n withRetries,\n} from 'utils';\n\nexport { client, server };\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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c,CAAA,YAAAN,CAAA,CAAAH,OAAA,GAAAL,CAAA,EAAAG,CAAA,IAAAA,CAAA,CAAAgB,GAAA,CAAAnB,CAAA,EAAAQ,CAAA,GAAAA,CAAA;AAvCpB,MAAMY,MAAM,GAAAzB,OAAA,CAAAyB,MAAA,GAAGC,cAAO,CAACC,WAAW,aAAaC,SAAS,CAA4B;AAEpF,MAAMC,MAAM,GAAA7B,OAAA,CAAA6B,MAAA,GAAGJ,MAAM,GAAGK,SAAS,GAAGnC,OAAO,WAAW,CAAC,CAACe,OAAO"}
1
+ {"version":3,"file":"index.js","names":["_utils","require","_axios","_interopRequireDefault","_PT","_interopRequireWildcard","exports","PT","_reactGlobalState","_components","Object","keys","forEach","key","prototype","hasOwnProperty","call","_exportNames","defineProperty","enumerable","get","_getRequireWildcardCache","e","WeakMap","r","t","__esModule","default","has","n","__proto__","a","getOwnPropertyDescriptor","u","i","set","server","webpack","requireWeak","__dirname","client","undefined"],"sources":["../../src/index.ts"],"sourcesContent":["import 'styles/global.scss';\n\nimport { webpack } from 'utils';\n\nimport type ServerT from './server';\n\nconst server = webpack.requireWeak('./server', __dirname) as (typeof ServerT) | null;\n\nconst client = server ? undefined : require('./client').default;\n\nexport { default as api } from 'axios';\nexport * as PT from 'prop-types';\n\nexport {\n type AsyncCollectionLoaderT,\n type AsyncDataEnvelopeT,\n type AsyncDataLoaderT,\n type ForceT,\n type UseAsyncDataOptionsT,\n type UseAsyncDataResT,\n type UseGlobalStateResT,\n type ValueOrInitializerT,\n getGlobalState,\n GlobalStateProvider,\n useAsyncCollection,\n useAsyncData,\n useGlobalState,\n withGlobalStateType,\n} from '@dr.pogodin/react-global-state';\n\nexport * from 'components';\n\nexport {\n type Theme,\n config,\n Barrier,\n Emitter,\n isomorphy,\n getSsrContext,\n JU,\n Semaphore,\n splitComponent,\n themed,\n ThemeProvider,\n time,\n webpack,\n withRetries,\n} from 'utils';\n\nexport { client, server };\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;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AA,IAAAA,CAAA,CAAAG,GAAA,CAAAN,CAAA,UAAAG,CAAA,CAAAL,GAAA,CAAAE,CAAA,OAAAO,CAAA,KAAAC,SAAA,UAAAC,CAAA,GAAArB,MAAA,CAAAQ,cAAA,IAAAR,MAAA,CAAAsB,wBAAA,WAAAC,CAAA,IAAAX,CAAA,oBAAAW,CAAA,IAAAvB,MAAA,CAAAI,SAAA,CAAAC,cAAA,CAAAC,IAAA,CAAAM,CAAA,EAAAW,CAAA,SAAAC,CAAA,GAAAH,CAAA,GAAArB,MAAA,CAAAsB,wBAAA,CAAAV,CAAA,EAAAW,CAAA,UAAAC,CAAA,KAAAA,CAAA,CAAAd,GAAA,IAAAc,CAAA,CAAAC,GAAA,IAAAzB,MAAA,CAAAQ,cAAA,CAAAW,CAAA,EAAAI,CAAA,EAAAC,CAAA,IAAAL,CAAA,CAAAI,CAAA,IAAAX,CAAA,CAAAW,CAAA,YAAAJ,CAAA,CAAAF,OAAA,GAAAL,CAAA,EAAAG,CAAA,IAAAA,CAAA,CAAAU,GAAA,CAAAb,CAAA,EAAAO,CAAA,GAAAA,CAAA;AAxB3B,MAAMO,MAAM,GAAA9B,OAAA,CAAA8B,MAAA,GAAGC,cAAO,CAACC,WAAW,aAAaC,SAAS,CAA4B;AAEpF,MAAMC,MAAM,GAAAlC,OAAA,CAAAkC,MAAA,GAAGJ,MAAM,GAAGK,SAAS,GAAGxC,OAAO,WAAW,CAAC,CAAC0B,OAAO"}
@@ -19,6 +19,7 @@ const defaultTheme = {
19
19
  "active": "-dr-pogodin-react-utils___src-shared-components-Button-style___active___MAe9O6",
20
20
  "disabled": "-dr-pogodin-react-utils___src-shared-components-Button-style___disabled___Br9IWV"
21
21
  };
22
+ const validThemeKeys = ['active', 'button', 'disabled'];
22
23
  /* eslint-disable react/function-component-definition */
23
24
  const BaseButton = ({
24
25
  active,
@@ -73,7 +74,7 @@ const BaseButton = ({
73
74
  * @prop {string} [button] to the root element of any button.
74
75
  * @prop {string} [disabled] to the root element of disabled button.
75
76
  */
76
- const ThemedButton = (0, _reactThemes.default)(BaseButton, 'Button', ['active', 'button', 'disabled'], defaultTheme);
77
+ const ThemedButton = (0, _reactThemes.default)(BaseButton, 'Button', validThemeKeys, defaultTheme);
77
78
 
78
79
  /**
79
80
  * Implements themeable buttons, and button-line links (elements which look
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":["_propTypes","_interopRequireDefault","require","_Link","_reactThemes","_jsxRuntime","defaultTheme","BaseButton","active","children","disabled","enforceA","onClick","onMouseDown","openNewTab","replace","theme","to","className","button","jsx","default","onKeyDown","e","key","role","tabIndex","ThemedButton","themed","defaultProps","undefined","propTypes","PT","bool","node","func","themeType","isRequired","oneOfType","object","string","_default","exports"],"sources":["../../../../../src/shared/components/Button/index.tsx"],"sourcesContent":["// The <Button> component implements a standard button / button-like link.\n\nimport PT from 'prop-types';\nimport { type ReactNode } from 'react';\n\nimport Link from 'components/Link';\n\nimport themed, { type Theme } from '@dr.pogodin/react-themes';\n\nimport defaultTheme from './style.scss';\n\ntype PropsT = {\n active?: boolean;\n children?: ReactNode;\n disabled?: boolean;\n enforceA?: boolean;\n onClick?: React.MouseEventHandler & React.KeyboardEventHandler;\n onMouseDown?: React.MouseEventHandler;\n openNewTab?: boolean;\n replace?: boolean;\n theme: Theme & {\n active?: string;\n button?: string;\n disabled?: string;\n };\n // TODO: It needs a more precise typing of the object option.\n to?: object | string;\n};\n\n/* eslint-disable react/function-component-definition */\nconst BaseButton: React.FunctionComponent<PropsT> = ({\n active,\n children,\n disabled,\n enforceA,\n onClick,\n onMouseDown,\n openNewTab,\n replace,\n theme,\n to,\n}) => {\n let className = theme.button;\n if (active && theme.active) className += ` ${theme.active}`;\n if (disabled) {\n if (theme.disabled) className += ` ${theme.disabled}`;\n return (\n <div className={className}>\n {children}\n </div>\n );\n }\n if (to) {\n return (\n <Link\n className={className}\n enforceA={enforceA}\n onClick={onClick}\n onMouseDown={onMouseDown}\n openNewTab={openNewTab}\n replace={replace}\n to={to}\n >\n {children}\n </Link>\n );\n }\n\n return (\n <div\n className={className}\n onClick={onClick}\n onKeyDown={onClick && ((e) => {\n if (e.key === 'Enter') onClick(e);\n })}\n onMouseDown={onMouseDown}\n role=\"button\"\n tabIndex={0}\n >\n {children}\n </div>\n );\n};\n\n/**\n * Button component theme: a map of CSS\n * class names to append to button elements:\n * @prop {string} [active] to the root element of active button.\n * @prop {string} [button] to the root element of any button.\n * @prop {string} [disabled] to the root element of disabled button.\n */\nconst ThemedButton = themed(BaseButton, 'Button', [\n 'active',\n 'button',\n 'disabled',\n], defaultTheme);\n\n/**\n * Implements themeable buttons, and button-line links (elements which look\n * like buttons, but behave as links) in the same uniform manner.\n * @param {object} [props] Component props.\n * @param {boolean} [props.active] Set `true` to render the button as\n * active, even if it is not active otherwise.\n * @param {boolean} [props.disabled] Set `true` to disable the button.\n * @param {boolean} [props.enforceA] When the button is rendered as `<Link>`\n * component, this prop enforces it to be rendered as a simple `<a>` element\n * (external link), rather than the React router's internal link.\n * See `<Link>` documentation to learn when links are rendered as `<a>`\n * by default.\n * @param {function} [props.onClick] Click event handler.\n * @param {function} [props.onMouseDown] Mouse down event handler.\n * @param {boolean} [props.openNewTab] Set `true` to open link in the new tab.\n * @param {boolean} [props.replace] When the button is rendered as\n * `<Link>`, and the target URL is internal, this property tells that\n * the new route should replace the last record in the browser's history,\n * rather than to be pushed as a new entry into the history stack.\n * @param {ButtonTheme} [props.theme] _Ad hoc_ button theme.\n * @param {object|string} [props.to] If specified, the button will be rendered\n * as `<Link>` (if not disabled), and it will point to the specified location\n * or URL.\n * @param {...any} [props....]\n * [Other properties of themeable components](https://www.npmjs.com/package/@dr.pogodin/react-themes#themed-component-properties)\n */\nBaseButton.defaultProps = {\n active: false,\n children: undefined,\n disabled: false,\n enforceA: false,\n onClick: undefined,\n onMouseDown: undefined,\n openNewTab: false,\n replace: false,\n to: undefined,\n};\n\nBaseButton.propTypes = {\n active: PT.bool,\n children: PT.node,\n disabled: PT.bool,\n enforceA: PT.bool,\n onClick: PT.func,\n onMouseDown: PT.func,\n openNewTab: PT.bool,\n replace: PT.bool,\n theme: ThemedButton.themeType.isRequired,\n to: PT.oneOfType([PT.object, PT.string]),\n};\n\nexport default ThemedButton;\n"],"mappings":";;;;;;;AAEA,IAAAA,UAAA,GAAAC,sBAAA,CAAAC,OAAA;AACAA,OAAA;AAEA,IAAAC,KAAA,GAAAF,sBAAA,CAAAC,OAAA;AAEA,IAAAE,YAAA,GAAAH,sBAAA,CAAAC,OAAA;AAA8D,IAAAG,WAAA,GAAAH,OAAA;AAP9D;AAAA,MAAAI,YAAA;EAAA;EAAA;EAAA;EAAA;EAAA;EAAA;AAAA;AA6BA;AACA,MAAMC,UAA2C,GAAGA,CAAC;EACnDC,MAAM;EACNC,QAAQ;EACRC,QAAQ;EACRC,QAAQ;EACRC,OAAO;EACPC,WAAW;EACXC,UAAU;EACVC,OAAO;EACPC,KAAK;EACLC;AACF,CAAC,KAAK;EACJ,IAAIC,SAAS,GAAGF,KAAK,CAACG,MAAM;EAC5B,IAAIX,MAAM,IAAIQ,KAAK,CAACR,MAAM,EAAEU,SAAS,IAAK,IAAGF,KAAK,CAACR,MAAO,EAAC;EAC3D,IAAIE,QAAQ,EAAE;IACZ,IAAIM,KAAK,CAACN,QAAQ,EAAEQ,SAAS,IAAK,IAAGF,KAAK,CAACN,QAAS,EAAC;IACrD,oBACE,IAAAL,WAAA,CAAAe,GAAA;MAAKF,SAAS,EAAEA,SAAU;MAAAT,QAAA,EACvBA;IAAQ,CACN,CAAC;EAEV;EACA,IAAIQ,EAAE,EAAE;IACN,oBACE,IAAAZ,WAAA,CAAAe,GAAA,EAACjB,KAAA,CAAAkB,OAAI;MACHH,SAAS,EAAEA,SAAU;MACrBP,QAAQ,EAAEA,QAAS;MACnBC,OAAO,EAAEA,OAAQ;MACjBC,WAAW,EAAEA,WAAY;MACzBC,UAAU,EAAEA,UAAW;MACvBC,OAAO,EAAEA,OAAQ;MACjBE,EAAE,EA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;EAChBtB,WAAW,EAAEmB,kBAAE,CAACG,IAAI;EACpBrB,UAAU,EAAEkB,kBAAE,CAACC,IAAI;EACnBlB,OAAO,EAAEiB,kBAAE,CAACC,IAAI;EAChBjB,KAAK,EAAEW,YAAY,CAACS,SAAS,CAACC,UAAU;EACxCpB,EAAE,EAAEe,kBAAE,CAACM,SAAS,CAAC,CAACN,kBAAE,CAACO,MAAM,EAAEP,kBAAE,CAACQ,MAAM,CAAC;AACzC,CAAC;AAAC,IAAAC,QAAA,GAAAC,OAAA,CAAArB,OAAA,GAEaM,YAAY"}
1
+ {"version":3,"file":"index.js","names":["_propTypes","_interopRequireDefault","require","_Link","_reactThemes","_jsxRuntime","defaultTheme","validThemeKeys","BaseButton","active","children","disabled","enforceA","onClick","onMouseDown","openNewTab","replace","theme","to","className","button","jsx","default","onKeyDown","e","key","role","tabIndex","ThemedButton","themed","defaultProps","undefined","propTypes","PT","bool","node","func","themeType","isRequired","oneOfType","object","string","_default","exports"],"sources":["../../../../../src/shared/components/Button/index.tsx"],"sourcesContent":["// The <Button> component implements a standard button / button-like link.\n\nimport PT from 'prop-types';\nimport { type ReactNode } from 'react';\n\nimport Link from 'components/Link';\n\nimport themed, { type Theme } from '@dr.pogodin/react-themes';\n\nimport defaultTheme from './style.scss';\n\nconst validThemeKeys = ['active', 'button', 'disabled'] as const;\n\ntype PropsT = {\n active?: boolean;\n children?: ReactNode;\n disabled?: boolean;\n enforceA?: boolean;\n onClick?: React.MouseEventHandler & React.KeyboardEventHandler;\n onMouseDown?: React.MouseEventHandler;\n openNewTab?: boolean;\n replace?: boolean;\n theme: Theme<typeof validThemeKeys>;\n // TODO: It needs a more precise typing of the object option.\n to?: object | string;\n};\n\n/* eslint-disable react/function-component-definition */\nconst BaseButton: React.FunctionComponent<PropsT> = ({\n active,\n children,\n disabled,\n enforceA,\n onClick,\n onMouseDown,\n openNewTab,\n replace,\n theme,\n to,\n}) => {\n let className = theme.button;\n if (active && theme.active) className += ` ${theme.active}`;\n if (disabled) {\n if (theme.disabled) className += ` ${theme.disabled}`;\n return (\n <div className={className}>\n {children}\n </div>\n );\n }\n if (to) {\n return (\n <Link\n className={className}\n enforceA={enforceA}\n onClick={onClick}\n onMouseDown={onMouseDown}\n openNewTab={openNewTab}\n replace={replace}\n to={to}\n >\n {children}\n </Link>\n );\n }\n\n return (\n <div\n className={className}\n onClick={onClick}\n onKeyDown={onClick && ((e) => {\n if (e.key === 'Enter') onClick(e);\n })}\n onMouseDown={onMouseDown}\n role=\"button\"\n tabIndex={0}\n >\n {children}\n </div>\n );\n};\n\n/**\n * Button component theme: a map of CSS\n * class names to append to button elements:\n * @prop {string} [active] to the root element of active button.\n * @prop {string} [button] to the root element of any button.\n * @prop {string} [disabled] to the root element of disabled button.\n */\nconst ThemedButton = themed(BaseButton, 'Button', validThemeKeys, defaultTheme);\n\n/**\n * Implements themeable buttons, and button-line links (elements which look\n * like buttons, but behave as links) in the same uniform manner.\n * @param {object} [props] Component props.\n * @param {boolean} [props.active] Set `true` to render the button as\n * active, even if it is not active otherwise.\n * @param {boolean} [props.disabled] Set `true` to disable the button.\n * @param {boolean} [props.enforceA] When the button is rendered as `<Link>`\n * component, this prop enforces it to be rendered as a simple `<a>` element\n * (external link), rather than the React router's internal link.\n * See `<Link>` documentation to learn when links are rendered as `<a>`\n * by default.\n * @param {function} [props.onClick] Click event handler.\n * @param {function} [props.onMouseDown] Mouse down event handler.\n * @param {boolean} [props.openNewTab] Set `true` to open link in the new tab.\n * @param {boolean} [props.replace] When the button is rendered as\n * `<Link>`, and the target URL is internal, this property tells that\n * the new route should replace the last record in the browser's history,\n * rather than to be pushed as a new entry into the history stack.\n * @param {ButtonTheme} [props.theme] _Ad hoc_ button theme.\n * @param {object|string} [props.to] If specified, the button will be rendered\n * as `<Link>` (if not disabled), and it will point to the specified location\n * or URL.\n * @param {...any} [props....]\n * [Other properties of themeable components](https://www.npmjs.com/package/@dr.pogodin/react-themes#themed-component-properties)\n */\nBaseButton.defaultProps = {\n active: false,\n children: undefined,\n disabled: false,\n enforceA: false,\n onClick: undefined,\n onMouseDown: undefined,\n openNewTab: false,\n replace: false,\n to: undefined,\n};\n\nBaseButton.propTypes = {\n active: PT.bool,\n children: PT.node,\n disabled: PT.bool,\n enforceA: PT.bool,\n onClick: PT.func,\n onMouseDown: PT.func,\n openNewTab: PT.bool,\n replace: PT.bool,\n theme: ThemedButton.themeType.isRequired,\n to: PT.oneOfType([PT.object, PT.string]),\n};\n\nexport default ThemedButton;\n"],"mappings":";;;;;;;AAEA,IAAAA,UAAA,GAAAC,sBAAA,CAAAC,OAAA;AACAA,OAAA;AAEA,IAAAC,KAAA,GAAAF,sBAAA,CAAAC,OAAA;AAEA,IAAAE,YAAA,GAAAH,sBAAA,CAAAC,OAAA;AAA8D,IAAAG,WAAA,GAAAH,OAAA;AAP9D;AAAA,MAAAI,YAAA;EAAA;EAAA;EAAA;EAAA;EAAA;EAAA;AAAA;AAWA,MAAMC,cAAc,GAAG,CAAC,QAAQ,EAAE,QAAQ,EAAE,UAAU,CAAU;AAgBhE;AACA,MAAMC,UAA2C,GAAGA,CAAC;EACnDC,MAAM;EACNC,QAAQ;EACRC,QAAQ;EACRC,QAAQ;EACRC,OAAO;EACPC,WAAW;EACXC,UAAU;EACVC,OAAO;EACPC,KAAK;EACLC;AACF,CAAC,KAAK;EACJ,IAAIC,SAAS,GAAGF,KAAK,CAACG,MAAM;EAC5B,IAAIX,MAAM,IAAIQ,KAAK,CAACR,MAAM,EAAEU,SAAS,IAAK,IAAGF,KAAK,CAACR,MAAO,EAAC;EAC3D,IAAIE,QAAQ,EAAE;IACZ,IAAIM,KAAK,CAACN,QAAQ,EAAEQ,SAAS,IAAK,IAAGF,KAAK,CAACN,QAAS,EAAC;IACrD,oBACE,IAAAN,WAAA,CAAAgB,GAAA;MAAKF,SAAS,EAAEA,SAAU;MAAAT,QAAA,EACvBA;IAAQ,CACN,CAAC;EAEV;EACA,IAAIQ,EAAE,EAAE;IACN,oBACE,IAAAb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B,kBAAE,CAACC,IAAI;EACfxB,QAAQ,EAAEuB,kBAAE,CAACE,IAAI;EACjBxB,QAAQ,EAAEsB,kBAAE,CAACC,IAAI;EACjBtB,QAAQ,EAAEqB,kBAAE,CAACC,IAAI;EACjBrB,OAAO,EAAEoB,kBAAE,CAACG,IAAI;EAChBtB,WAAW,EAAEmB,kBAAE,CAACG,IAAI;EACpBrB,UAAU,EAAEkB,kBAAE,CAACC,IAAI;EACnBlB,OAAO,EAAEiB,kBAAE,CAACC,IAAI;EAChBjB,KAAK,EAAEW,YAAY,CAACS,SAAS,CAACC,UAAU;EACxCpB,EAAE,EAAEe,kBAAE,CAACM,SAAS,CAAC,CAACN,kBAAE,CAACO,MAAM,EAAEP,kBAAE,CAACQ,MAAM,CAAC;AACzC,CAAC;AAAC,IAAAC,QAAA,GAAAC,OAAA,CAAArB,OAAA,GAEaM,YAAY"}
@@ -16,6 +16,7 @@ const defaultTheme = {
16
16
  "container": "-dr-pogodin-react-utils___src-shared-components-Checkbox-theme___container___Kr0g3M",
17
17
  "label": "-dr-pogodin-react-utils___src-shared-components-Checkbox-theme___label___3dML-O"
18
18
  };
19
+ const validThemeKeys = ['checkbox', 'container', 'label'];
19
20
  const Checkbox = ({
20
21
  checked,
21
22
  label,
@@ -41,7 +42,7 @@ const Checkbox = ({
41
42
  * @prop [container] to the root checkbox element.
42
43
  * @prop [label] to the checkbox label element.
43
44
  */
44
- const ThemedCheckbox = (0, _reactThemes.default)(Checkbox, 'Checkbox', ['checkbox', 'container', 'label'], defaultTheme);
45
+ const ThemedCheckbox = (0, _reactThemes.default)(Checkbox, 'Checkbox', validThemeKeys, defaultTheme);
45
46
 
46
47
  /**
47
48
  * The `<Checkbox>` component implements themeable checkboxes.
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":["_propTypes","_interopRequireDefault","require","_reactThemes","_jsxRuntime","defaultTheme","Checkbox","checked","label","onChange","theme","jsxs","className","container","children","undefined","jsx","checkbox","type","ThemedCheckbox","themed","propTypes","PT","bool","string","func","themeType","isRequired","defaultProps","_default","exports","default"],"sources":["../../../../../src/shared/components/Checkbox/index.tsx"],"sourcesContent":["import PT from 'prop-types';\n\nimport themed, { type Theme } from '@dr.pogodin/react-themes';\n\nimport defaultTheme from './theme.scss';\n\ntype PropT = {\n checked?: boolean;\n label?: string;\n onChange?: React.ChangeEventHandler<HTMLInputElement>;\n theme: Theme & {\n checkbox?: string;\n container?: string\n label?: string;\n };\n};\n\nconst Checkbox: React.FunctionComponent<PropT> = ({\n checked,\n label,\n onChange,\n theme,\n}) => (\n <div className={theme.container}>\n { label === undefined ? null : <p className={theme.label}>{label}</p> }\n <input\n checked={checked}\n className={theme.checkbox}\n onChange={onChange}\n type=\"checkbox\"\n />\n </div>\n);\n\n/**\n * Checkbox component theme: a map of\n * CSS classes to append to its elements:\n * @prop [checkbox] to the underlying checkbox `<input>` element.\n * @prop [container] to the root checkbox element.\n * @prop [label] to the checkbox label element.\n */\nconst ThemedCheckbox = themed(Checkbox, 'Checkbox', [\n 'checkbox',\n 'container',\n 'label',\n], defaultTheme);\n\n/**\n * The `<Checkbox>` component implements themeable checkboxes.\n * @param [props] Component properties.\n * @param [props.checked] Checkbox value.\n * @param [props.label] Checkbox label.\n * @param [props.onChange] State change handler.\n * @param [props.theme] _Ad hoc_ theme.\n * @param [props....]\n * [Other properties of themeable components](https://www.npmjs.com/package/@dr.pogodin/react-themes#themed-component-properties).\n */\nCheckbox.propTypes = {\n checked: PT.bool,\n label: PT.string,\n onChange: PT.func,\n theme: ThemedCheckbox.themeType.isRequired,\n};\n\nCheckbox.defaultProps = {\n checked: undefined,\n label: undefined,\n onChange: undefined,\n};\n\nexport default ThemedCheckbox;\n"],"mappings":";;;;;;;AAAA,IAAAA,UAAA,GAAAC,sBAAA,CAAAC,OAAA;AAEA,IAAAC,YAAA,GAAAF,sBAAA,CAAAC,OAAA;AAA8D,IAAAE,WAAA,GAAAF,OAAA;AAAA,MAAAG,YAAA;EAAA;EAAA;EAAA;EAAA;EAAA;EAAA;AAAA;AAe9D,MAAMC,QAAwC,GAAGA,CAAC;EAChDC,OAAO;EACPC,KAAK;EACLC,QAAQ;EACRC;AACF,CAAC,kBACC,IAAAN,WAAA,CAAAO,IAAA;EAAKC,SAAS,EAAEF,KAAK,CAACG,SAAU;EAAAC,QAAA,GAC5BN,KAAK,KAAKO,SAAS,GAAG,IAAI,gBAAG,IAAAX,WAAA,CAAAY,GAAA;IAAGJ,SAAS,EAAEF,KAAK,CAACF,KAAM;IAAAM,QAAA,EAAEN;EAAK,CAAI,CAAC,eACrE,IAAAJ,WAAA,CAAAY,GAAA;IACET,OAAO,EAAEA,OAAQ;IACjBK,SAAS,EAAEF,KAAK,CAACO,QAAS;IAC1BR,QAAQ,EAAEA,QAAS;IACnBS,IAAI,EAAC;EAAU,CAChB,CAAC;AAAA,CACC,CACN;;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAMC,cAAc,GAAG,IAAAC,oBAAM,EAACd,QAAQ,EAAE,UAAU,EAAE,CAClD,UAAU,EACV,WAAW,EACX,OAAO,CACR,EAAED,YAAY,CAAC;;AAEhB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACAC,QAAQ,CAACe,SAAS,GAAG;EACnBd,OAAO,EAAEe,kBAAE,CAACC,IAAI;EAChBf,KAAK,EAAEc,kBAAE,CAACE,MAAM;EAChBf,QAAQ,EAAEa,kBAAE,CAACG,IAAI;EACjBf,KAAK,EAAES,cAAc,CAACO,SAAS,CAACC;AAClC,CAAC;AAEDrB,QAAQ,CAACsB,YAAY,GAAG;EACtBrB,OAAO,EAAEQ,SAAS;EAClBP,KAAK,EAAEO,SAAS;EAChBN,QAAQ,EAAEM;AACZ,CAAC;AAAC,IAAAc,QAAA,GAAAC,OAAA,CAAAC,OAAA,GAEaZ,cAAc"}
1
+ {"version":3,"file":"index.js","names":["_propTypes","_interopRequireDefault","require","_reactThemes","_jsxRuntime","defaultTheme","validThemeKeys","Checkbox","checked","label","onChange","theme","jsxs","className","container","children","undefined","jsx","checkbox","type","ThemedCheckbox","themed","propTypes","PT","bool","string","func","themeType","isRequired","defaultProps","_default","exports","default"],"sources":["../../../../../src/shared/components/Checkbox/index.tsx"],"sourcesContent":["import PT from 'prop-types';\n\nimport themed, { type Theme } from '@dr.pogodin/react-themes';\n\nimport defaultTheme from './theme.scss';\n\nconst validThemeKeys = ['checkbox', 'container', 'label'] as const;\n\ntype PropT = {\n checked?: boolean;\n label?: string;\n onChange?: React.ChangeEventHandler<HTMLInputElement>;\n theme: Theme<typeof validThemeKeys>;\n};\n\nconst Checkbox: React.FunctionComponent<PropT> = ({\n checked,\n label,\n onChange,\n theme,\n}) => (\n <div className={theme.container}>\n { label === undefined ? null : <p className={theme.label}>{label}</p> }\n <input\n checked={checked}\n className={theme.checkbox}\n onChange={onChange}\n type=\"checkbox\"\n />\n </div>\n);\n\n/**\n * Checkbox component theme: a map of\n * CSS classes to append to its elements:\n * @prop [checkbox] to the underlying checkbox `<input>` element.\n * @prop [container] to the root checkbox element.\n * @prop [label] to the checkbox label element.\n */\nconst ThemedCheckbox = themed(\n Checkbox,\n 'Checkbox',\n validThemeKeys,\n defaultTheme,\n);\n\n/**\n * The `<Checkbox>` component implements themeable checkboxes.\n * @param [props] Component properties.\n * @param [props.checked] Checkbox value.\n * @param [props.label] Checkbox label.\n * @param [props.onChange] State change handler.\n * @param [props.theme] _Ad hoc_ theme.\n * @param [props....]\n * [Other properties of themeable components](https://www.npmjs.com/package/@dr.pogodin/react-themes#themed-component-properties).\n */\nCheckbox.propTypes = {\n checked: PT.bool,\n label: PT.string,\n onChange: PT.func,\n theme: ThemedCheckbox.themeType.isRequired,\n};\n\nCheckbox.defaultProps = {\n checked: undefined,\n label: undefined,\n onChange: undefined,\n};\n\nexport default ThemedCheckbox;\n"],"mappings":";;;;;;;AAAA,IAAAA,UAAA,GAAAC,sBAAA,CAAAC,OAAA;AAEA,IAAAC,YAAA,GAAAF,sBAAA,CAAAC,OAAA;A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cAAc"}
@@ -12,6 +12,7 @@ const defaultTheme = {
12
12
  "context": "-dr-pogodin-react-utils___src-shared-components-Dropdown-theme___context___haRIry",
13
13
  "ad": "-dr-pogodin-react-utils___src-shared-components-Dropdown-theme___ad___D4XHG2",
14
14
  "hoc": "-dr-pogodin-react-utils___src-shared-components-Dropdown-theme___hoc___N3nd34",
15
+ "dropdown": "-dr-pogodin-react-utils___src-shared-components-Dropdown-theme___dropdown___-LiQj8",
15
16
  "arrow": "-dr-pogodin-react-utils___src-shared-components-Dropdown-theme___arrow___-zPK7Y",
16
17
  "container": "-dr-pogodin-react-utils___src-shared-components-Dropdown-theme___container___9CQpeA",
17
18
  "label": "-dr-pogodin-react-utils___src-shared-components-Dropdown-theme___label___Gv0kyu",
@@ -19,6 +20,7 @@ const defaultTheme = {
19
20
  "hiddenOption": "-dr-pogodin-react-utils___src-shared-components-Dropdown-theme___hiddenOption___RdW3yR",
20
21
  "select": "-dr-pogodin-react-utils___src-shared-components-Dropdown-theme___select___JXK1uw"
21
22
  };
23
+ const validThemeKeys = ['arrow', 'container', 'dropdown', 'hiddenOption', 'label', 'option', 'select'];
22
24
  /**
23
25
  * Implements a themeable dropdown list. Internally it is rendered with help of
24
26
  * the standard HTML `<select>` element, thus the styling support is somewhat
@@ -84,18 +86,21 @@ const Dropdown = ({
84
86
  children: [label === undefined ? null : /*#__PURE__*/(0, _jsxRuntime.jsx)("p", {
85
87
  className: theme.label,
86
88
  children: label
87
- }), /*#__PURE__*/(0, _jsxRuntime.jsxs)("select", {
88
- className: theme.select,
89
- onChange: onChange,
90
- value: value,
91
- children: [hiddenOption, optionElements]
92
- }), /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
93
- className: theme.arrow,
94
- children: "\u25BC"
89
+ }), /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
90
+ className: theme.dropdown,
91
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsxs)("select", {
92
+ className: theme.select,
93
+ onChange: onChange,
94
+ value: value,
95
+ children: [hiddenOption, optionElements]
96
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
97
+ className: theme.arrow,
98
+ children: "\u25BC"
99
+ })]
95
100
  })]
96
101
  });
97
102
  };
98
- const ThemedDropdown = (0, _reactThemes.default)(Dropdown, 'Dropdown', ['arrow', 'container', 'hiddenOption', 'label', 'option', 'select'], defaultTheme);
103
+ const ThemedDropdown = (0, _reactThemes.default)(Dropdown, 'Dropdown', validThemeKeys, defaultTheme);
99
104
  Dropdown.propTypes = {
100
105
  filter: _propTypes.default.func,
101
106
  label: _propTypes.default.string,
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":["_propTypes","_interopRequireDefault","require","_reactThemes","_jsxRuntime","defaultTheme","Dropdown","filter","label","onChange","options","theme","value","isValidValue","optionElements","i","length","option","optionValue","optionName","name","push","jsx","className","children","hiddenOption","disabled","jsxs","container","undefined","select","arrow","ThemedDropdown","themed","propTypes","PT","func","string","arrayOf","oneOfType","shape","isRequired","themeType","defaultProps","_default","exports","default"],"sources":["../../../../../src/shared/components/Dropdown/index.tsx"],"sourcesContent":["import PT from 'prop-types';\n\nimport themed, { type Theme } from '@dr.pogodin/react-themes';\n\nimport defaultTheme from './theme.scss';\n\ntype DropdownOptionT = {\n name?: string | null;\n value: string;\n};\n\ntype PropsT = {\n filter?: (item: DropdownOptionT | string) => boolean;\n label?: string;\n onChange?: React.ChangeEventHandler<HTMLSelectElement>;\n options?: Array<DropdownOptionT | string>;\n theme: Theme & {\n arrow?: string;\n container?: string;\n hiddenOption?: string;\n label?: string;\n option?: string;\n select?: string;\n };\n value?: string;\n};\n\n/**\n * Implements a themeable dropdown list. Internally it is rendered with help of\n * the standard HTML `<select>` element, thus the styling support is somewhat\n * limited.\n * @param [props] Component properties.\n * @param [props.filter] Options filter function. If provided, only\n * those elements of `options` list will be used by the dropdown, for which this\n * filter returns `true`.\n * @param [props.label] Dropdown label.\n * @param [props.onChange] Selection event handler.\n * @param [props.options=[]] Array of dropdown\n * options. For string elements the option value and name will be the same.\n * It is allowed to mix DropdownOption and string elements in the same option\n * list.\n * @param [props.theme] _Ad hoc_ theme.\n * @param [props.value] Currently selected value.\n * @param [props....]\n * [Other theming properties](https://www.npmjs.com/package/@dr.pogodin/react-themes#themed-component-properties)\n */\nconst Dropdown: React.FunctionComponent<PropsT> = ({\n filter,\n label,\n onChange,\n options = [],\n theme,\n value,\n}) => {\n let isValidValue = false;\n const optionElements = [];\n\n for (let i = 0; i < options.length; ++i) {\n const option = options[i];\n if (!filter || filter(option)) {\n let optionValue: string;\n let optionName: string;\n if (typeof option === 'string') {\n optionName = option;\n optionValue = option;\n } else {\n optionName = option.name || option.value;\n optionValue = option.value;\n }\n isValidValue ||= optionValue === value;\n optionElements.push(\n <option className={theme.option} key={optionValue} value={optionValue}>\n {optionName}\n </option>,\n );\n }\n }\n\n // NOTE: This element represents the current `value` when it does not match\n // any valid option. In Chrome, and some other browsers, we are able to hide\n // it from the opened dropdown; in others, e.g. Safari, the best we can do is\n // to show it as disabled.\n const hiddenOption = isValidValue ? null : (\n <option\n disabled\n className={theme.hiddenOption}\n key=\"__reactUtilsHiddenOption\"\n value={value}\n >\n {value}\n </option>\n );\n\n return (\n <div className={theme.container}>\n { label === undefined ? null : <p className={theme.label}>{label}</p> }\n <select\n className={theme.select}\n onChange={onChange}\n value={value}\n >\n {hiddenOption}\n {optionElements}\n </select>\n <div className={theme.arrow}>▼</div>\n </div>\n );\n};\n\nconst ThemedDropdown = themed(Dropdown, 'Dropdown', [\n 'arrow',\n 'container',\n 'hiddenOption',\n 'label',\n 'option',\n 'select',\n], defaultTheme);\n\nDropdown.propTypes = {\n filter: PT.func,\n label: PT.string,\n onChange: PT.func,\n options: PT.arrayOf(\n PT.oneOfType([\n PT.shape({\n name: PT.string,\n value: PT.string.isRequired,\n }),\n PT.string,\n ]).isRequired,\n ),\n theme: ThemedDropdown.themeType.isRequired,\n value: PT.string,\n};\n\nDropdown.defaultProps = {\n filter: undefined,\n label: undefined,\n onChange: undefined,\n options: [],\n value: '',\n};\n\nexport default ThemedDropdown;\n"],"mappings":";;;;;;;AAAA,IAAAA,UAAA,GAAAC,sBAAA,CAAAC,OAAA;AAEA,IAAAC,YAAA,GAAAF,sBAAA,CAAAC,OAAA;AAA8D,IAAAE,WAAA,GAAAF,OAAA;AAAA,MAAAG,YAAA;EAAA;EAAA;EAAA;EAAA;EAAA;EAAA;EAAA;EAAA;EAAA;AAAA;AAyB9D;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAMC,QAAyC,GAAGA,CAAC;EACjDC,MAAM;EACNC,KAAK;EACLC,QAAQ;EACRC,OAAO,GAAG,EAAE;EACZC,KAAK;EACLC;AACF,CAAC,KAAK;EACJ,IAAIC,YAAY,GAAG,KAAK;EACxB,MAAMC,cAAc,GAAG,EAAE;EAEzB,KAAK,IAAIC,CAAC,GAAG,CAAC,EAAEA,CAAC,GAAGL,OAAO,CAACM,MAAM,EAAE,EAAED,CAAC,EAAE;IACvC,MAAME,MAAM,GAAGP,OAAO,CAACK,CAAC,CAAC;IACzB,IAAI,CAACR,MAAM,IAAIA,MAAM,CAACU,MAAM,CAAC,EAAE;MAC7B,IAAIC,WAAmB;MACvB,IAAIC,UAAkB;MACtB,IAAI,OAAOF,MAAM,KAAK,QAAQ,EAAE;QAC9BE,UAAU,GAAGF,MAAM;QACnBC,WAAW,GAAGD,MAAM;MACtB,CAAC,MAAM;QACLE,UAAU,GAAGF,MAAM,CAACG,IAAI,IAAIH,MAAM,CAACL,KAAK;QACxCM,WAAW,GAAGD,MAAM,CAACL,KAAK;MAC5B;MACAC,YAAY,KAAKK,WAAW,KAAKN,KAAK;MACtCE,cAAc,CAACO,IAAI,eACjB,IAAAjB,WAAA,CAAAkB,GAAA;QAAQC,SAAS,EAAEZ,KAAK,CAACM,MAAO;QAAmBL,KAAK,EAAEM,WAAY;QAAAM,QAAA,EACnEL;MA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AACI,SAAS,CAAC,CACXJ,kBAAE,CAACK,KAAK,CAAC;IACPpB,IAAI,EAAEe,kBAAE,CAACE,MAAM;IACfzB,KAAK,EAAEuB,kBAAE,CAACE,MAAM,CAACI;EACnB,CAAC,CAAC,EACFN,kBAAE,CAACE,MAAM,CACV,CAAC,CAACI,UACL,CAAC;EACD9B,KAAK,EAAEqB,cAAc,CAACU,SAAS,CAACD,UAAU;EAC1C7B,KAAK,EAAEuB,kBAAE,CAACE;AACZ,CAAC;AAED/B,QAAQ,CAACqC,YAAY,GAAG;EACtBpC,MAAM,EAAEsB,SAAS;EACjBrB,KAAK,EAAEqB,SAAS;EAChBpB,QAAQ,EAAEoB,SAAS;EACnBnB,OAAO,EAAE,EAAE;EACXE,KAAK,EAAE;AACT,CAAC;AAAC,IAAAgC,QAAA,GAAAC,OAAA,CAAAC,OAAA,GAEad,cAAc"}
1
+ {"version":3,"file":"index.js","names":["_propTypes","_interopRequireDefault","require","_reactThemes","_jsxRuntime","defaultTheme","validThemeKeys","Dropdown","filter","label","onChange","options","theme","value","isValidValue","optionElements","i","length","option","optionValue","optionName","name","push","jsx","className","children","hiddenOption","disabled","jsxs","container","undefined","dropdown","select","arrow","ThemedDropdown","themed","propTypes","PT","func","string","arrayOf","oneOfType","shape","isRequired","themeType","defaultProps","_default","exports","default"],"sources":["../../../../../src/shared/components/Dropdown/index.tsx"],"sourcesContent":["import PT from 'prop-types';\n\nimport themed, { type Theme } from '@dr.pogodin/react-themes';\n\nimport defaultTheme from './theme.scss';\n\nconst validThemeKeys = [\n 'arrow',\n 'container',\n 'dropdown',\n 'hiddenOption',\n 'label',\n 'option',\n 'select',\n] as const;\n\ntype DropdownOptionT = {\n name?: string | null;\n value: string;\n};\n\ntype PropsT = {\n filter?: (item: DropdownOptionT | string) => boolean;\n label?: string;\n onChange?: React.ChangeEventHandler<HTMLSelectElement>;\n options?: Array<DropdownOptionT | string>;\n theme: Theme<typeof validThemeKeys>;\n value?: string;\n};\n\n/**\n * Implements a themeable dropdown list. Internally it is rendered with help of\n * the standard HTML `<select>` element, thus the styling support is somewhat\n * limited.\n * @param [props] Component properties.\n * @param [props.filter] Options filter function. If provided, only\n * those elements of `options` list will be used by the dropdown, for which this\n * filter returns `true`.\n * @param [props.label] Dropdown label.\n * @param [props.onChange] Selection event handler.\n * @param [props.options=[]] Array of dropdown\n * options. For string elements the option value and name will be the same.\n * It is allowed to mix DropdownOption and string elements in the same option\n * list.\n * @param [props.theme] _Ad hoc_ theme.\n * @param [props.value] Currently selected value.\n * @param [props....]\n * [Other theming properties](https://www.npmjs.com/package/@dr.pogodin/react-themes#themed-component-properties)\n */\nconst Dropdown: React.FunctionComponent<PropsT> = ({\n filter,\n label,\n onChange,\n options = [],\n theme,\n value,\n}) => {\n let isValidValue = false;\n const optionElements = [];\n\n for (let i = 0; i < options.length; ++i) {\n const option = options[i];\n if (!filter || filter(option)) {\n let optionValue: string;\n let optionName: string;\n if (typeof option === 'string') {\n optionName = option;\n optionValue = option;\n } else {\n optionName = option.name || option.value;\n optionValue = option.value;\n }\n isValidValue ||= optionValue === value;\n optionElements.push(\n <option className={theme.option} key={optionValue} value={optionValue}>\n {optionName}\n </option>,\n );\n }\n }\n\n // NOTE: This element represents the current `value` when it does not match\n // any valid option. In Chrome, and some other browsers, we are able to hide\n // it from the opened dropdown; in others, e.g. Safari, the best we can do is\n // to show it as disabled.\n const hiddenOption = isValidValue ? null : (\n <option\n disabled\n className={theme.hiddenOption}\n key=\"__reactUtilsHiddenOption\"\n value={value}\n >\n {value}\n </option>\n );\n\n return (\n <div className={theme.container}>\n { label === undefined ? null : <p className={theme.label}>{label}</p> }\n <div className={theme.dropdown}>\n <select\n className={theme.select}\n onChange={onChange}\n value={value}\n >\n {hiddenOption}\n {optionElements}\n </select>\n <div className={theme.arrow}>▼</div>\n </div>\n </div>\n );\n};\n\nconst ThemedDropdown = themed(\n Dropdown,\n 'Dropdown',\n validThemeKeys,\n defaultTheme,\n);\n\nDropdown.propTypes = {\n filter: PT.func,\n label: PT.string,\n onChange: PT.func,\n options: PT.arrayOf(\n PT.oneOfType([\n PT.shape({\n name: PT.string,\n value: PT.string.isRequired,\n }),\n PT.string,\n ]).isRequired,\n ),\n theme: ThemedDropdown.themeType.isRequired,\n value: PT.string,\n};\n\nDropdown.defaultProps = {\n filter: undefined,\n label: undefined,\n onChange: undefined,\n options: [],\n value: '',\n};\n\nexport default ThemedDropdown;\n"],"mappings":";;;;;;;AAAA,IAAAA,UAAA,GAAAC,sBAAA,CAAAC,OAAA;AAEA,IAAAC,YAAA,GAAAF,sBAAA,CAAAC,OAAA;AAA8D,IAAAE,WAAA,GAAAF,OAAA;AAAA,MAAAG,YAAA;EAAA;EAAA;EAAA;EAAA;EAAA;EAAA;EAAA;EAAA;EAAA;EAAA;AAAA;AAI9D,MAAMC,cAAc,GAAG,CACrB,OAAO,EACP,WAAW,EACX,UAAU,EACV,cAAc,EACd,OAAO,EACP,QAAQ,EACR,QAAQ,CACA;AAgBV;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAMC,QAAyC,GAAGA,CAAC;EACjDC,MAAM;EACNC,KAAK;EACLC,QAAQ;EACRC,OAAO,GAAG,EAAE;EACZC,KAAK;EACLC;AACF,CAAC,KAAK;EACJ,IAAIC,YAAY,GAAG,KAAK;EACxB,MAAMC,cAAc,GAAG,EAAE;EAEzB,KAAK,IAAIC,CAAC,GAAG,CAAC,EAAEA,CAAC,GAAGL,OAAO,CAACM,MAAM,EAAE,EAAED,CAAC,EAAE;IACvC,MAAME,MAAM,GAAGP,OAAO,CAACK,CAAC,CAAC;IACzB,IAAI,CAACR,MAAM,IAAIA,MAAM,CAACU,MAAM,CAAC,EAAE;MAC7B,IAAIC,WAAmB;MACvB,IAAIC,UAAkB;MACtB,IAAI,OAAOF,MAAM,KAAK,QAAQ,EAAE;QAC9BE,UAAU,GAAGF,MAAM;QACnBC,WAAW,GAAG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AAA,CACjC,CAAC;EAAA,CACH,CAAC;AAEV,CAAC;AAED,MAAMS,cAAc,GAAG,IAAAC,oBAAM,EAC3B5B,QAAQ,EACR,UAAU,EACVD,cAAc,EACdD,YACF,CAAC;AAEDE,QAAQ,CAAC6B,SAAS,GAAG;EACnB5B,MAAM,EAAE6B,kBAAE,CAACC,IAAI;EACf7B,KAAK,EAAE4B,kBAAE,CAACE,MAAM;EAChB7B,QAAQ,EAAE2B,kBAAE,CAACC,IAAI;EACjB3B,OAAO,EAAE0B,kBAAE,CAACG,OAAO,CACjBH,kBAAE,CAACI,SAAS,CAAC,CACXJ,kBAAE,CAACK,KAAK,CAAC;IACPrB,IAAI,EAAEgB,kBAAE,CAACE,MAAM;IACf1B,KAAK,EAAEwB,kBAAE,CAACE,MAAM,CAACI;EACnB,CAAC,CAAC,EACFN,kBAAE,CAACE,MAAM,CACV,CAAC,CAACI,UACL,CAAC;EACD/B,KAAK,EAAEsB,cAAc,CAACU,SAAS,CAACD,UAAU;EAC1C9B,KAAK,EAAEwB,kBAAE,CAACE;AACZ,CAAC;AAEDhC,QAAQ,CAACsC,YAAY,GAAG;EACtBrC,MAAM,EAAEsB,SAAS;EACjBrB,KAAK,EAAEqB,SAAS;EAChBpB,QAAQ,EAAEoB,SAAS;EACnBnB,OAAO,EAAE,EAAE;EACXE,KAAK,EAAE;AACT,CAAC;AAAC,IAAAiC,QAAA,GAAAC,OAAA,CAAAC,OAAA,GAEad,cAAc"}
@@ -17,6 +17,7 @@ const defaultTheme = {
17
17
  "input": "-dr-pogodin-react-utils___src-shared-components-Input-theme___input___M07d4s",
18
18
  "label": "-dr-pogodin-react-utils___src-shared-components-Input-theme___label___gfbdq-"
19
19
  };
20
+ const validThemeKeys = ['container', 'input', 'label'];
20
21
  /**
21
22
  * Themeable input field, based on the standard HTML `<input>` element.
22
23
  * @param [props]
@@ -41,7 +42,7 @@ const Input = /*#__PURE__*/(0, _react.forwardRef)(({
41
42
  ...rest
42
43
  })]
43
44
  }));
44
- const ThemedInput = (0, _reactThemes.default)(Input, 'Input', ['container', 'input', 'label'], defaultTheme);
45
+ const ThemedInput = (0, _reactThemes.default)(Input, 'Input', validThemeKeys, defaultTheme);
45
46
  Input.propTypes = {
46
47
  label: _propTypes.default.string,
47
48
  theme: ThemedInput.themeType.isRequired
@@ -1 +1 @@
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"}
1
+ {"version":3,"file":"index.js","names":["_propTypes","_interopRequireDefault","require","_react","_reactThemes","_jsxRuntime","defaultTheme","validThemeKeys","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\nconst validThemeKeys = [\n 'container',\n 'input',\n 'label',\n] as const;\n\ntype PropsT = React.InputHTMLAttributes<HTMLInputElement> & {\n label?: string;\n theme: Theme<typeof validThemeKeys>;\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', validThemeKeys, 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;AAI9D,MAAMC,cAAc,GAAG,CACrB,WAAW,EACX,OAAO,EACP,OAAO,CACC;AAOV;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,IAAAR,WAAA,CAAAS,IAAA;EAAMC,SAAS,EAAEJ,KAAK,CAACK,SAAU;EAAAC,QAAA,GAC7BP,KAAK,KAAKQ,SAAS,GAAG,IAAI,gBAAG,IAAAb,WAAA,CAAAc,GAAA;IAAGJ,SAAS,EAAEJ,KAAK,CAACD,KAAM;IAAAO,QAAA,EAAEP;EAAK,CAAI,CAAC,eACrE,IAAAL,WAAA,CAAAc,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,EAAED,cAAc,EAAED,YAAY,CAAC;AAExEE,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"}
@@ -19,6 +19,7 @@ const baseTheme = {
19
19
  "overlay": "-dr-pogodin-react-utils___src-shared-components-Modal-base-theme___overlay___ye2BZo",
20
20
  "container": "-dr-pogodin-react-utils___src-shared-components-Modal-base-theme___container___gyZ4rc"
21
21
  };
22
+ const validThemeKeys = ['container', 'overlay'];
22
23
  /**
23
24
  * The `<Modal>` component implements a simple themeable modal window, wrapped
24
25
  * into the default theme. `<BaseModal>` exposes the base non-themed component.
@@ -95,7 +96,7 @@ const BaseModal = ({
95
96
  }), portal) : null;
96
97
  };
97
98
  exports.BaseModal = BaseModal;
98
- const ThemedModal = (0, _reactThemes.default)(BaseModal, 'Modal', ['container', 'overlay'], baseTheme);
99
+ const ThemedModal = (0, _reactThemes.default)(BaseModal, 'Modal', validThemeKeys, baseTheme);
99
100
  BaseModal.propTypes = {
100
101
  onCancel: _propTypes.default.func,
101
102
  children: _propTypes.default.node,
@@ -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","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,sBAAA,CAAAH,OAAA;AAA8D,IAAAM,WAAA,GAAAN,OAAA;AAd9D;AAAA,MAAAO,SAAA;EAAA;EAAA;EAAA;EAAA;EAAA;AAAA;AA4BA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAMC,SAA0C,GAAGA,CAAC;EAClDC,QAAQ;EACRC,QAAQ;EACRC;AACF,CAAC,KAAK;EACJ,MAAMC,YAAY,GAAG,IAAAC,aAAM,EAAwB,IAAI,CAAC;EACxD,MAAMC,UAAU,GAAG,IAAAD,aAAM,EAAwB,IAAI,CAAC;EACtD,MAAM,CAACE,MAAM,EAAEC,SAAS,CAAC,GAAG,IAAAC,eAAQ,EAAiB,CAAC;EAEtD,IAAAC,gBAAS,EAAC,MAAM;IACd,MAAMC,CAAC,GAAGC,QAAQ,CAACC,aAAa,CAAC,KAAK,CAAC;IACvCD,QAAQ,CAACE,IAAI,CAACC,SAAS,CAACC,GAAG,CAAC,6BAA6B,CAAC;IAC1DJ,QAAQ,CAACE,IAAI,CAACG,WAAW,CAACN,CAAC,CAAC;IAC5BH,SAAS,CAACG,CAAC,CAAC;IACZ,OAAO,MAAM;MACXC,QAAQ,CAACE,IAAI,CAACC,SAAS,CAACG,MAAM,CAAC,6BAA6B,CAAC;MAC7DN,QAAQ,CAACE,IAAI,CAACK,WAAW,CAACR,CAAC,CAAC;IAC9B,CAAC;EACH,CAAC,EAAE,EAAE,CAAC;EAEN,MAAMS,SAAS,GAAG,IAAAC,cAAO,EAAC,mBACxB,IAAAvB,W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W,MAAM;MACjBc,SAAS,EAAEjC,KAAK,CAAC0C,SAAU;MAC3BC,OAAO,EAAGC,KAAK,IAAKA,KAAK,CAACC,eAAe,CAAC,CAAE;MAC5CN,GAAG,EAAEtC,YAAa;MAClBwC,IAAI,EAAC,QAAQ;MAAA3C,QAAA,EAEZA;IAAQ,CACN,CAAC,eACN,IAAAH,WAAA,CAAAwB,GAAA;MACEC,OAAO,EAAEA,CAAA,KAAM;QACbjB,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"}
1
+ {"version":3,"file":"index.js","names":["_lodash","require","_react","_reactDom","_interopRequireDefault","_propTypes","_reactThemes","_jsxRuntime","baseTheme","validThemeKeys","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\nconst validThemeKeys = ['container', 'overlay'] as const;\n\ntype PropsT = {\n children?: ReactNode;\n onCancel?: () => void;\n theme: Theme<typeof validThemeKeys>;\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 validThemeKeys,\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,sBAAA,CAAAH,OAAA;AAA8D,IAAAM,WAAA,GAAAN,OAAA;AAd9D;AAAA,MAAAO,SAAA;EAAA;EAAA;EAAA;EAAA;EAAA;AAAA;AAmBA,MAAMC,cAAc,GAAG,CAAC,WAAW,EAAE,SAAS,CAAU;AAQxD;AACA;AAC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,EAELb,MACF,CAAC,GAAG,IAAI;AACV,CAAC;AAAC0C,OAAA,CAAAjD,SAAA,GAAAA,SAAA;AAEF,MAAMkD,WAAW,GAAG,IAAAC,oBAAM,EACxBnD,SAAS,EACT,OAAO,EACPD,cAAc,EACdD,SACF,CAAC;AAEDE,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"}
@@ -16,6 +16,7 @@ const baseTheme = {
16
16
  "mainPanel": "-dr-pogodin-react-utils___src-shared-components-PageLayout-base-theme___mainPanel___pPlQO2",
17
17
  "sidePanel": "-dr-pogodin-react-utils___src-shared-components-PageLayout-base-theme___sidePanel___lqNh4h"
18
18
  };
19
+ const validThemeKeys = ['container', 'leftSidePanel', 'mainPanel', 'rightSidePanel', 'sidePanel'];
19
20
  /**
20
21
  * Simple and themeable page layout. It keeps the main content centered in
21
22
  * a column of limited width, which fills entire viewport on small screens
@@ -49,7 +50,7 @@ const PageLayout = ({
49
50
  children: rightSidePanelContent
50
51
  })]
51
52
  });
52
- const ThemedPageLayout = (0, _reactThemes.default)(PageLayout, 'PageLayout', ['container', 'leftSidePanel', 'mainPanel', 'rightSidePanel', 'sidePanel'], baseTheme);
53
+ const ThemedPageLayout = (0, _reactThemes.default)(PageLayout, 'PageLayout', validThemeKeys, baseTheme);
53
54
  PageLayout.propTypes = {
54
55
  children: _propTypes.default.node,
55
56
  leftSidePanelContent: _propTypes.default.node,
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":["_propTypes","_interopRequireDefault","require","_reactThemes","_jsxRuntime","baseTheme","PageLayout","children","leftSidePanelContent","rightSidePanelContent","theme","jsxs","className","container","jsx","sidePanel","leftSidePanel","join","mainPanel","rightSidePanel","ThemedPageLayout","themed","propTypes","PT","node","themeType","isRequired","defaultProps","_default","exports","default"],"sources":["../../../../../src/shared/components/PageLayout/index.tsx"],"sourcesContent":["import PT from 'prop-types';\nimport type { ReactNode } from 'react';\n\nimport themed, { type Theme } from '@dr.pogodin/react-themes';\n\nimport baseTheme from './base-theme.scss';\n\ntype PropsT = {\n children?: ReactNode;\n leftSidePanelContent?: ReactNode;\n rightSidePanelContent?: ReactNode;\n theme: Theme & {\n container?: string;\n mainPanel?: string;\n sidePanel?: string;\n leftSidePanel?: string;\n rightSidePanel?: string;\n };\n};\n\n/**\n * Simple and themeable page layout. It keeps the main content centered in\n * a column of limited width, which fills entire viewport on small screens\n * (under `$screen-md = 1024px` size). At larger screens the column keeps\n * `$screen-md` size, and it is centered at the page, surrounded by side\n * panels, where additional content can be displayed.\n *\n * **Children:** Component children are rendered as the content of main panel.\n * @param {object} [props] Component properties.\n * @param {Node} [props.leftSidePanelContent] The content for left side panel.\n * @param {Node} [props.rightSidePanelContent] The content for right side panel.\n * @param {PageLayoutTheme} [props.theme] _Ad hoc_ theme.\n * @param {...any} [props....]\n * [Other theming properties](https://www.npmjs.com/package/@dr.pogodin/react-themes#themed-component-properties)\n */\nconst PageLayout: React.FunctionComponent<PropsT> = ({\n children,\n leftSidePanelContent,\n rightSidePanelContent,\n theme,\n}) => (\n <div className={theme.container}>\n <div className={[theme.sidePanel, theme.leftSidePanel].join(' ')}>\n {leftSidePanelContent}\n </div>\n <div className={theme.mainPanel}>\n {children}\n </div>\n <div className={[theme.sidePanel, theme.rightSidePanel].join(' ')}>\n {rightSidePanelContent}\n </div>\n </div>\n);\n\nconst ThemedPageLayout = themed(PageLayout, 'PageLayout', [\n 'container',\n 'leftSidePanel',\n 'mainPanel',\n 'rightSidePanel',\n 'sidePanel',\n], baseTheme);\n\nPageLayout.propTypes = {\n children: PT.node,\n leftSidePanelContent: PT.node,\n rightSidePanelContent: PT.node,\n theme: ThemedPageLayout.themeType.isRequired,\n};\n\nPageLayout.defaultProps = {\n children: null,\n leftSidePanelContent: null,\n rightSidePanelContent: null,\n};\n\nexport default ThemedPageLayout;\n"],"mappings":";;;;;;;AAAA,IAAAA,UAAA,GAAAC,sBAAA,CAAAC,OAAA;AAGA,IAAAC,YAAA,GAAAF,sBAAA,CAAAC,OAAA;AAA8D,IAAAE,WAAA,GAAAF,OAAA;AAAA,MAAAG,SAAA;EAAA;EAAA;EAAA;EAAA;EAAA;EAAA;AAAA;AAiB9D;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAMC,UAA2C,GAAGA,CAAC;EACnDC,QAAQ;EACRC,oBAAoB;EACpBC,qBAAqB;EACrBC;AACF,CAAC,kBACC,IAAAN,WAAA,CAAAO,IAAA;EAAKC,SAAS,EAAEF,KAAK,CAACG,SAAU;EAAAN,QAAA,gBAC9B,IAAAH,WAAA,CAAAU,GAAA;IAAKF,SAAS,EAAE,CAACF,KAAK,CAACK,SAAS,EAAEL,KAAK,CAACM,aAAa,CAAC,CAACC,IAAI,CAAC,GAAG,CAAE;IAAAV,QAAA,EAC9DC;EAAoB,CAClB,CAAC,eACN,IAAAJ,WAAA,CAAAU,GAAA;IAAKF,SAAS,EAAEF,KAAK,CAACQ,SAAU;IAAAX,QAAA,EAC7BA;EAAQ,CACN,CAAC,eACN,IAAAH,WAAA,CAAAU,GAAA;IAAKF,SAAS,EAAE,CAACF,KAAK,CAACK,SAAS,EAAEL,KAAK,CAACS,cAAc,CAAC,CAACF,IAAI,CAAC,GAAG,CAAE;IAAAV,QAAA,EAC/DE;EAAqB,CACnB,CAAC;AAAA,CACH,CACN;AAED,MAAMW,gBAAgB,GAAG,IAAAC,oBAAM,EAACf,UAAU,EAAE,YAAY,EAAE,CACxD,WAAW,EACX,eAAe,EACf,WAAW,EACX,gBAAgB,EAChB,WAAW,CACZ,EAAED,SAAS,CAAC;AAEbC,UAAU,CAACgB,SAAS,GAAG;EACrBf,QAAQ,EAAEgB,kBAAE,CAACC,IAAI;EACjBhB,oBAAoB,EAAEe,kBAAE,CAACC,IAAI;EAC7Bf,qBAAqB,EAAEc,kBAAE,CAACC,IAAI;EAC9Bd,KAAK,EAAEU,gBAAgB,CAACK,SAAS,CAACC;AACpC,CAAC;AAEDpB,UAAU,CAACqB,YAAY,GAAG;EACxBpB,QAAQ,EAAE,IAAI;EACdC,oBAAoB,EAAE,IAAI;EAC1BC,qBAAqB,EAAE;AACzB,CAAC;AAAC,IAAAmB,QAAA,GAAAC,OAAA,CAAAC,OAAA,GAEaV,gBAAgB"}
1
+ {"version":3,"file":"index.js","names":["_propTypes","_interopRequireDefault","require","_reactThemes","_jsxRuntime","baseTheme","validThemeKeys","PageLayout","children","leftSidePanelContent","rightSidePanelContent","theme","jsxs","className","container","jsx","sidePanel","leftSidePanel","join","mainPanel","rightSidePanel","ThemedPageLayout","themed","propTypes","PT","node","themeType","isRequired","defaultProps","_default","exports","default"],"sources":["../../../../../src/shared/components/PageLayout/index.tsx"],"sourcesContent":["import PT from 'prop-types';\nimport type { ReactNode } from 'react';\n\nimport themed, { type Theme } from '@dr.pogodin/react-themes';\n\nimport baseTheme from './base-theme.scss';\n\nconst validThemeKeys = [\n 'container',\n 'leftSidePanel',\n 'mainPanel',\n 'rightSidePanel',\n 'sidePanel',\n] as const;\n\ntype PropsT = {\n children?: ReactNode;\n leftSidePanelContent?: ReactNode;\n rightSidePanelContent?: ReactNode;\n theme: Theme<typeof validThemeKeys>;\n};\n\n/**\n * Simple and themeable page layout. It keeps the main content centered in\n * a column of limited width, which fills entire viewport on small screens\n * (under `$screen-md = 1024px` size). At larger screens the column keeps\n * `$screen-md` size, and it is centered at the page, surrounded by side\n * panels, where additional content can be displayed.\n *\n * **Children:** Component children are rendered as the content of main panel.\n * @param {object} [props] Component properties.\n * @param {Node} [props.leftSidePanelContent] The content for left side panel.\n * @param {Node} [props.rightSidePanelContent] The content for right side panel.\n * @param {PageLayoutTheme} [props.theme] _Ad hoc_ theme.\n * @param {...any} [props....]\n * [Other theming properties](https://www.npmjs.com/package/@dr.pogodin/react-themes#themed-component-properties)\n */\nconst PageLayout: React.FunctionComponent<PropsT> = ({\n children,\n leftSidePanelContent,\n rightSidePanelContent,\n theme,\n}) => (\n <div className={theme.container}>\n <div className={[theme.sidePanel, theme.leftSidePanel].join(' ')}>\n {leftSidePanelContent}\n </div>\n <div className={theme.mainPanel}>\n {children}\n </div>\n <div className={[theme.sidePanel, theme.rightSidePanel].join(' ')}>\n {rightSidePanelContent}\n </div>\n </div>\n);\n\nconst ThemedPageLayout = themed(\n PageLayout,\n 'PageLayout',\n validThemeKeys,\n baseTheme,\n);\n\nPageLayout.propTypes = {\n children: PT.node,\n leftSidePanelContent: PT.node,\n rightSidePanelContent: PT.node,\n theme: ThemedPageLayout.themeType.isRequired,\n};\n\nPageLayout.defaultProps = {\n children: null,\n leftSidePanelContent: null,\n rightSidePanelContent: null,\n};\n\nexport default ThemedPageLayout;\n"],"mappings":";;;;;;;AAAA,IAAAA,UAAA,GAAAC,sBAAA,CAAAC,OAAA;AAGA,IAAAC,YAAA,GAAAF,sBAAA,CAAAC,OAAA;AAA8D,IAAAE,WAAA,GAAAF,OAAA;AAAA,MAAAG,SAAA;EAAA;EAAA;EAAA;EAAA;EAAA;EAAA;AAAA;AAI9D,MAAMC,cAAc,GAAG,CACrB,WAAW,EACX,eAAe,EACf,WAAW,EACX,gBAAgB,EAChB,WAAW,CACH;AASV;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAMC,UAA2C,GAAGA,CAAC;EACnDC,QAAQ;EACRC,oBAAoB;EACpBC,qBAAqB;EACrBC;AACF,CAAC,kBACC,IAAAP,WAAA,CAAAQ,IAAA;EAAKC,SAAS,EAAEF,KAAK,CAACG,SAAU;EAAAN,QAAA,gBAC9B,IAAAJ,WAAA,CAAAW,GAAA;IAAKF,SAAS,EAAE,CAACF,KAAK,CAACK,SAAS,EAAEL,KAAK,CAACM,aAAa,CAAC,CAACC,IAAI,CAAC,GAAG,CAAE;IAAAV,QAAA,EAC9DC;EAAoB,CAClB,CAAC,eACN,IAAAL,WAAA,CAAAW,GAAA;IAAKF,SAAS,EAAEF,KAAK,CAACQ,SAAU;IAAAX,QAAA,EAC7BA;EAAQ,CACN,CAAC,eACN,IAAAJ,WAAA,CAAAW,GAAA;IAAKF,SAAS,EAAE,CAACF,KAAK,CAACK,SAAS,EAAEL,KAAK,CAACS,cAAc,CAAC,CAACF,IAAI,CAAC,GAAG,CAAE;IAAAV,QAAA,EAC/DE;EAAqB,CACnB,CAAC;AAAA,CACH,CACN;AAED,MAAMW,gBAAgB,GAAG,IAAAC,oBAAM,EAC7Bf,UAAU,EACV,YAAY,EACZD,cAAc,EACdD,SACF,CAAC;AAEDE,UAAU,CAACgB,SAAS,GAAG;EACrBf,QAAQ,EAAEgB,kBAAE,CAACC,IAAI;EACjBhB,oBAAoB,EAAEe,kBAAE,CAACC,IAAI;EAC7Bf,qBAAqB,EAAEc,kBAAE,CAACC,IAAI;EAC9Bd,KAAK,EAAEU,gBAAgB,CAACK,SAAS,CAACC;AACpC,CAAC;AAEDpB,UAAU,CAACqB,YAAY,GAAG;EACxBpB,QAAQ,EAAE,IAAI;EACdC,oBAAoB,EAAE,IAAI;EAC1BC,qBAAqB,EAAE;AACzB,CAAC;AAAC,IAAAmB,QAAA,GAAAC,OAAA,CAAAC,OAAA,GAEaV,gBAAgB"}
@@ -0,0 +1,94 @@
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 _react = require("react");
9
+ var _propTypes = _interopRequireDefault(require("prop-types"));
10
+ var _reactThemes = _interopRequireDefault(require("@dr.pogodin/react-themes"));
11
+ var _jsxRuntime = require("react/jsx-runtime");
12
+ const defaultTheme = {
13
+ "context": "-dr-pogodin-react-utils___src-shared-components-TextArea-style___context___KVPc7g",
14
+ "ad": "-dr-pogodin-react-utils___src-shared-components-TextArea-style___ad___z2GQ0Z",
15
+ "hoc": "-dr-pogodin-react-utils___src-shared-components-TextArea-style___hoc___8R1Qdj",
16
+ "container": "-dr-pogodin-react-utils___src-shared-components-TextArea-style___container___dzMVIB",
17
+ "textarea": "-dr-pogodin-react-utils___src-shared-components-TextArea-style___textarea___zd-OFg",
18
+ "hidden": "-dr-pogodin-react-utils___src-shared-components-TextArea-style___hidden___GiHBXI"
19
+ };
20
+ const validThemeKeys = ['container', 'hidden', 'textarea'];
21
+ const TextArea = ({
22
+ onChange,
23
+ onKeyDown,
24
+ placeholder,
25
+ theme,
26
+ value
27
+ }) => {
28
+ const hiddenAreaRef = (0, _react.useRef)(null);
29
+ const [height, setHeight] = (0, _react.useState)();
30
+ const [localValue, setLocalValue] = (0, _react.useState)(value || '');
31
+ if (value !== undefined && localValue !== value) setLocalValue(value);
32
+
33
+ // This resizes text area's height when its width is changed for any reason.
34
+ (0, _react.useEffect)(() => {
35
+ const el = hiddenAreaRef.current;
36
+ if (!el) return undefined;
37
+ const cb = () => {
38
+ setHeight(el.scrollHeight);
39
+ };
40
+ const observer = new ResizeObserver(cb);
41
+ observer.observe(el);
42
+ return () => {
43
+ observer.disconnect();
44
+ };
45
+ }, []);
46
+
47
+ // This resizes the text area when its content is modified.
48
+ (0, _react.useEffect)(() => {
49
+ const el = hiddenAreaRef.current;
50
+ if (el) setHeight(el.scrollHeight);
51
+ }, [localValue]);
52
+ return /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
53
+ className: theme.container,
54
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsx)("textarea", {
55
+ // This text area is hidden underneath the primary one below,
56
+ // and it is used for text measurements, to implement auto-scaling
57
+ // of the primary textarea's height.
58
+ readOnly: true,
59
+ ref: hiddenAreaRef,
60
+ className: `${theme.textarea} ${theme.hidden}`,
61
+ value: localValue
62
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)("textarea", {
63
+ // When value is "undefined" the text area is not-managed, and we should
64
+ // manage it internally for the measurement / resizing functionality
65
+ // to work.
66
+ onChange: value === undefined ? e => {
67
+ setLocalValue(e.target.value);
68
+ } : onChange,
69
+ onKeyDown: onKeyDown,
70
+ placeholder: placeholder,
71
+ style: {
72
+ height
73
+ },
74
+ className: theme.textarea,
75
+ value: localValue
76
+ })]
77
+ });
78
+ };
79
+ const ThemedTextArea = (0, _reactThemes.default)(TextArea, 'TextArea', validThemeKeys, defaultTheme);
80
+ TextArea.propTypes = {
81
+ onChange: _propTypes.default.func,
82
+ onKeyDown: _propTypes.default.func,
83
+ placeholder: _propTypes.default.string,
84
+ theme: ThemedTextArea.themeType.isRequired,
85
+ value: _propTypes.default.string
86
+ };
87
+ TextArea.defaultProps = {
88
+ onChange: undefined,
89
+ onKeyDown: undefined,
90
+ placeholder: '',
91
+ value: undefined
92
+ };
93
+ var _default = exports.default = ThemedTextArea;
94
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","names":["_react","require","_propTypes","_interopRequireDefault","_reactThemes","_jsxRuntime","defaultTheme","validThemeKeys","TextArea","onChange","onKeyDown","placeholder","theme","value","hiddenAreaRef","useRef","height","setHeight","useState","localValue","setLocalValue","undefined","useEffect","el","current","cb","scrollHeight","observer","ResizeObserver","observe","disconnect","jsxs","className","container","children","jsx","readOnly","ref","textarea","hidden","e","target","style","ThemedTextArea","themed","propTypes","PT","func","string","themeType","isRequired","defaultProps","_default","exports","default"],"sources":["../../../../../src/shared/components/TextArea/index.tsx"],"sourcesContent":["import { useEffect, useRef, useState } from 'react';\nimport PT from 'prop-types';\n\nimport themed, { type Theme } from '@dr.pogodin/react-themes';\n\nimport defaultTheme from './style.scss';\n\nconst validThemeKeys = [\n 'container',\n 'hidden',\n 'textarea',\n] as const;\n\ntype Props = {\n onChange?: React.ChangeEventHandler<HTMLTextAreaElement>;\n onKeyDown?: React.KeyboardEventHandler<HTMLTextAreaElement>;\n placeholder?: string;\n theme: Theme<typeof validThemeKeys>;\n value?: string;\n};\n\nconst TextArea: React.FunctionComponent<Props> = ({\n onChange,\n onKeyDown,\n placeholder,\n theme,\n value,\n}) => {\n const hiddenAreaRef = useRef<HTMLTextAreaElement>(null);\n const [height, setHeight] = useState<number | undefined>();\n\n const [localValue, setLocalValue] = useState(value || '');\n if (value !== undefined && localValue !== value) setLocalValue(value);\n\n // This resizes text area's height when its width is changed for any reason.\n useEffect(() => {\n const el = hiddenAreaRef.current;\n if (!el) return undefined;\n\n const cb = () => {\n setHeight(el.scrollHeight);\n };\n const observer = new ResizeObserver(cb);\n observer.observe(el);\n\n return () => {\n observer.disconnect();\n };\n }, []);\n\n // This resizes the text area when its content is modified.\n useEffect(() => {\n const el = hiddenAreaRef.current;\n if (el) setHeight(el.scrollHeight);\n }, [localValue]);\n\n return (\n <div className={theme.container}>\n <textarea\n // This text area is hidden underneath the primary one below,\n // and it is used for text measurements, to implement auto-scaling\n // of the primary textarea's height.\n readOnly\n ref={hiddenAreaRef}\n className={`${theme.textarea} ${theme.hidden}`}\n value={localValue}\n />\n <textarea\n // When value is \"undefined\" the text area is not-managed, and we should\n // manage it internally for the measurement / resizing functionality\n // to work.\n onChange={value === undefined ? ((e) => {\n setLocalValue(e.target.value);\n }) : onChange}\n onKeyDown={onKeyDown}\n placeholder={placeholder}\n style={{ height }}\n className={theme.textarea}\n value={localValue}\n />\n </div>\n );\n};\n\nconst ThemedTextArea = themed(\n TextArea,\n 'TextArea',\n validThemeKeys,\n defaultTheme,\n);\n\nTextArea.propTypes = {\n onChange: PT.func,\n onKeyDown: PT.func,\n placeholder: PT.string,\n theme: ThemedTextArea.themeType.isRequired,\n value: PT.string,\n};\n\nTextArea.defaultProps = {\n onChange: undefined,\n onKeyDown: undefined,\n placeholder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