@dr.pogodin/react-utils 1.30.2 → 1.31.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (117) hide show
  1. package/bin/build.js +5 -0
  2. package/build/development/client/index.js +1 -1
  3. package/build/development/client/index.js.map +1 -1
  4. package/build/development/index.js +7 -0
  5. package/build/development/index.js.map +1 -1
  6. package/build/development/shared/components/Checkbox/index.js +2 -2
  7. package/build/development/shared/components/Checkbox/index.js.map +1 -1
  8. package/build/development/shared/components/Input/index.js +2 -2
  9. package/build/development/shared/components/Input/index.js.map +1 -1
  10. package/build/development/shared/components/Modal/index.js +25 -5
  11. package/build/development/shared/components/Modal/index.js.map +1 -1
  12. package/build/development/shared/components/TextArea/index.js +5 -0
  13. package/build/development/shared/components/TextArea/index.js.map +1 -1
  14. package/build/development/shared/components/YouTubeVideo/index.js +1 -3
  15. package/build/development/shared/components/YouTubeVideo/index.js.map +1 -1
  16. package/build/development/shared/components/index.js +27 -14
  17. package/build/development/shared/components/index.js.map +1 -1
  18. package/build/development/shared/components/selectors/CustomDropdown/Options/index.js +93 -0
  19. package/build/development/shared/components/selectors/CustomDropdown/Options/index.js.map +1 -0
  20. package/build/development/shared/components/selectors/CustomDropdown/index.js +105 -0
  21. package/build/development/shared/components/selectors/CustomDropdown/index.js.map +1 -0
  22. package/build/development/shared/components/{Dropdown → selectors/NativeDropdown}/index.js +25 -34
  23. package/build/development/shared/components/selectors/NativeDropdown/index.js.map +1 -0
  24. package/build/development/shared/components/selectors/Switch/index.js +76 -0
  25. package/build/development/shared/components/selectors/Switch/index.js.map +1 -0
  26. package/build/development/shared/components/selectors/common.js +24 -0
  27. package/build/development/shared/components/selectors/common.js.map +1 -0
  28. package/build/development/shared/components/selectors/index.js +28 -0
  29. package/build/development/shared/components/selectors/index.js.map +1 -0
  30. package/build/development/style.css +387 -225
  31. package/build/development/web.bundle.js +109 -49
  32. package/build/production/client/index.js +1 -1
  33. package/build/production/client/index.js.map +1 -1
  34. package/build/production/index.js +1 -1
  35. package/build/production/index.js.map +1 -1
  36. package/build/production/shared/components/Checkbox/index.js +2 -2
  37. package/build/production/shared/components/Checkbox/index.js.map +1 -1
  38. package/build/production/shared/components/Input/index.js +1 -1
  39. package/build/production/shared/components/Input/index.js.map +1 -1
  40. package/build/production/shared/components/Modal/index.js +3 -2
  41. package/build/production/shared/components/Modal/index.js.map +1 -1
  42. package/build/production/shared/components/TextArea/index.js +3 -3
  43. package/build/production/shared/components/TextArea/index.js.map +1 -1
  44. package/build/production/shared/components/YouTubeVideo/index.js +2 -2
  45. package/build/production/shared/components/YouTubeVideo/index.js.map +1 -1
  46. package/build/production/shared/components/index.js +1 -1
  47. package/build/production/shared/components/index.js.map +1 -1
  48. package/build/production/shared/components/selectors/CustomDropdown/Options/index.js +7 -0
  49. package/build/production/shared/components/selectors/CustomDropdown/Options/index.js.map +1 -0
  50. package/build/production/shared/components/selectors/CustomDropdown/index.js +4 -0
  51. package/build/production/shared/components/selectors/CustomDropdown/index.js.map +1 -0
  52. package/build/production/shared/components/selectors/NativeDropdown/index.js +25 -0
  53. package/build/production/shared/components/selectors/NativeDropdown/index.js.map +1 -0
  54. package/build/production/shared/components/selectors/Switch/index.js +2 -0
  55. package/build/production/shared/components/selectors/Switch/index.js.map +1 -0
  56. package/build/production/shared/components/selectors/common.js +3 -0
  57. package/build/production/shared/components/selectors/common.js.map +1 -0
  58. package/build/production/shared/components/selectors/index.js +2 -0
  59. package/build/production/shared/components/selectors/index.js.map +1 -0
  60. package/build/production/style.css +1 -1
  61. package/build/production/style.css.map +1 -1
  62. package/build/production/web.bundle.js +1 -1
  63. package/build/production/web.bundle.js.map +1 -1
  64. package/build/types-code/client/index.d.ts +1 -0
  65. package/build/types-code/index.d.ts +1 -1
  66. package/build/types-code/shared/components/Checkbox/index.d.ts +1 -1
  67. package/build/types-code/shared/components/Input/index.d.ts +1 -1
  68. package/build/types-code/shared/components/Modal/index.d.ts +2 -1
  69. package/build/types-code/shared/components/TextArea/index.d.ts +1 -0
  70. package/build/types-code/shared/components/index.d.ts +1 -2
  71. package/build/types-code/shared/components/selectors/CustomDropdown/Options/index.d.ts +17 -0
  72. package/build/types-code/shared/components/selectors/CustomDropdown/index.d.ts +4 -0
  73. package/build/types-code/shared/components/selectors/NativeDropdown/index.d.ts +3 -0
  74. package/build/types-code/shared/components/selectors/Switch/index.d.ts +13 -0
  75. package/build/types-code/shared/components/selectors/common.d.ts +27 -0
  76. package/build/types-code/shared/components/selectors/index.d.ts +3 -0
  77. package/build/types-scss/src/shared/components/Modal/styles.scss.d.ts +1 -0
  78. package/build/types-scss/src/shared/components/selectors/CustomDropdown/Options/style.scss.d.ts +1 -0
  79. package/build/types-scss/src/shared/components/selectors/CustomDropdown/theme.scss.d.ts +10 -0
  80. package/build/types-scss/src/shared/components/{Dropdown → selectors/NativeDropdown}/theme.scss.d.ts +1 -0
  81. package/build/types-scss/src/shared/components/selectors/Switch/theme.scss.d.ts +6 -0
  82. package/package.json +6 -6
  83. package/src/client/index.tsx +2 -1
  84. package/src/index.ts +1 -0
  85. package/src/shared/components/Button/style.scss +1 -0
  86. package/src/shared/components/Checkbox/index.tsx +3 -3
  87. package/src/shared/components/Input/index.tsx +3 -3
  88. package/src/shared/components/Modal/base-theme.scss +1 -1
  89. package/src/shared/components/Modal/index.tsx +24 -5
  90. package/src/shared/components/Modal/styles.scss +2 -4
  91. package/src/shared/components/TextArea/index.tsx +5 -0
  92. package/src/shared/components/TextArea/style.scss +8 -0
  93. package/src/shared/components/YouTubeVideo/base.scss +3 -1
  94. package/src/shared/components/YouTubeVideo/index.tsx +2 -3
  95. package/src/shared/components/index.ts +2 -2
  96. package/src/shared/components/selectors/CustomDropdown/Options/index.tsx +117 -0
  97. package/src/shared/components/selectors/CustomDropdown/Options/style.scss +6 -0
  98. package/src/shared/components/selectors/CustomDropdown/index.tsx +115 -0
  99. package/src/shared/components/selectors/CustomDropdown/theme.scss +90 -0
  100. package/src/shared/components/{Dropdown → selectors/NativeDropdown}/index.tsx +21 -50
  101. package/src/shared/components/{Dropdown → selectors/NativeDropdown}/theme.scss +5 -0
  102. package/src/shared/components/selectors/Switch/index.tsx +94 -0
  103. package/src/shared/components/selectors/Switch/theme.scss +39 -0
  104. package/src/shared/components/selectors/common.ts +54 -0
  105. package/src/shared/components/selectors/index.ts +3 -0
  106. package/build/development/shared/components/Dropdown/index.js.map +0 -1
  107. package/build/development/shared/components/ScalableRect/index.js +0 -80
  108. package/build/development/shared/components/ScalableRect/index.js.map +0 -1
  109. package/build/production/shared/components/Dropdown/index.js +0 -24
  110. package/build/production/shared/components/Dropdown/index.js.map +0 -1
  111. package/build/production/shared/components/ScalableRect/index.js +0 -21
  112. package/build/production/shared/components/ScalableRect/index.js.map +0 -1
  113. package/build/types-code/shared/components/Dropdown/index.d.ts +0 -17
  114. package/build/types-code/shared/components/ScalableRect/index.d.ts +0 -19
  115. package/build/types-scss/src/shared/components/ScalableRect/style.scss.d.ts +0 -2
  116. package/src/shared/components/ScalableRect/index.tsx +0 -84
  117. package/src/shared/components/ScalableRect/style.scss +0 -10
@@ -0,0 +1,105 @@
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 _propTypes = _interopRequireDefault(require("prop-types"));
9
+ var _react = require("react");
10
+ var _reactThemes = _interopRequireDefault(require("@dr.pogodin/react-themes"));
11
+ var _Options = _interopRequireDefault(require("./Options"));
12
+ var _common = require("../common");
13
+ var _jsxRuntime = require("react/jsx-runtime");
14
+ const defaultTheme = {
15
+ "context": "-dr-pogodin-react-utils___src-shared-components-selectors-CustomDropdown-theme___context___9Tod5r",
16
+ "ad": "-dr-pogodin-react-utils___src-shared-components-selectors-CustomDropdown-theme___ad___R58zIg",
17
+ "hoc": "-dr-pogodin-react-utils___src-shared-components-selectors-CustomDropdown-theme___hoc___O-Tp1i",
18
+ "container": "-dr-pogodin-react-utils___src-shared-components-selectors-CustomDropdown-theme___container___oQKv0Y",
19
+ "label": "-dr-pogodin-react-utils___src-shared-components-selectors-CustomDropdown-theme___label___YUPUNs",
20
+ "dropdown": "-dr-pogodin-react-utils___src-shared-components-selectors-CustomDropdown-theme___dropdown___pNEyAA",
21
+ "option": "-dr-pogodin-react-utils___src-shared-components-selectors-CustomDropdown-theme___option___LD2Kzy",
22
+ "select": "-dr-pogodin-react-utils___src-shared-components-selectors-CustomDropdown-theme___select___LP5azC",
23
+ "arrow": "-dr-pogodin-react-utils___src-shared-components-selectors-CustomDropdown-theme___arrow___-wscve",
24
+ "active": "-dr-pogodin-react-utils___src-shared-components-selectors-CustomDropdown-theme___active___k2UDsV"
25
+ };
26
+ const BaseCustomDropdown = ({
27
+ filter,
28
+ label,
29
+ onChange,
30
+ options,
31
+ theme,
32
+ value
33
+ }) => {
34
+ if (!options) throw Error('Internal error');
35
+ const dropdownRef = (0, _react.useRef)(null);
36
+
37
+ // If "null" the dropdown is closed, otherwise it is displayed
38
+ // at the specified coordinates.
39
+ const [anchor, setAnchor] = (0, _react.useState)(null);
40
+ const openList = () => {
41
+ setAnchor(dropdownRef.current.getBoundingClientRect());
42
+ };
43
+ let selected = /*#__PURE__*/(0, _jsxRuntime.jsx)(_jsxRuntime.Fragment, {
44
+ children: "\u200C"
45
+ });
46
+ for (let i = 0; i < options.length; ++i) {
47
+ const option = options[i];
48
+ if (!filter || filter(option)) {
49
+ const [iValue, iName] = (0, _common.optionValueName)(option);
50
+ if (iValue === value) {
51
+ selected = iName;
52
+ break;
53
+ }
54
+ }
55
+ }
56
+ let containerClassName = theme.container;
57
+ if (anchor) containerClassName += ` ${theme.active}`;
58
+ return /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
59
+ className: containerClassName,
60
+ children: [label === undefined ? null : /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
61
+ className: theme.label,
62
+ children: label
63
+ }), /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
64
+ className: theme.dropdown,
65
+ onClick: openList,
66
+ onKeyDown: e => {
67
+ if (e.key === 'Enter') openList();
68
+ },
69
+ ref: dropdownRef,
70
+ role: "listbox",
71
+ tabIndex: 0,
72
+ children: [selected, /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
73
+ className: theme.arrow
74
+ })]
75
+ }), anchor ? /*#__PURE__*/(0, _jsxRuntime.jsx)(_Options.default, {
76
+ anchorRect: anchor,
77
+ containerClass: theme.select || '',
78
+ onCancel: () => setAnchor(null),
79
+ onChange: newValue => {
80
+ setAnchor(null);
81
+ if (onChange) onChange(newValue);
82
+ },
83
+ optionClass: theme.option || '',
84
+ options: options
85
+ }) : null]
86
+ });
87
+ };
88
+ const ThemedCustomDropdown = (0, _reactThemes.default)(BaseCustomDropdown, 'CustomDropdown', _common.validThemeKeys, defaultTheme);
89
+ BaseCustomDropdown.propTypes = {
90
+ filter: _propTypes.default.func,
91
+ label: _propTypes.default.node,
92
+ onChange: _propTypes.default.func,
93
+ options: _propTypes.default.arrayOf(_common.optionValidator.isRequired),
94
+ theme: ThemedCustomDropdown.themeType.isRequired,
95
+ value: _propTypes.default.string
96
+ };
97
+ BaseCustomDropdown.defaultProps = {
98
+ filter: undefined,
99
+ label: undefined,
100
+ onChange: undefined,
101
+ options: [],
102
+ value: undefined
103
+ };
104
+ var _default = exports.default = ThemedCustomDropdown;
105
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","names":["_propTypes","_interopRequireDefault","require","_react","_reactThemes","_Options","_common","_jsxRuntime","defaultTheme","BaseCustomDropdown","filter","label","onChange","options","theme","value","Error","dropdownRef","useRef","anchor","setAnchor","useState","openList","current","getBoundingClientRect","selected","jsx","Fragment","children","i","length","option","iValue","iName","optionValueName","containerClassName","container","active","jsxs","className","undefined","dropdown","onClick","onKeyDown","e","key","ref","role","tabIndex","arrow","default","anchorRect","containerClass","select","onCancel","newValue","optionClass","ThemedCustomDropdown","themed","validThemeKeys","propTypes","PT","func","node","arrayOf","optionValidator","isRequired","themeType","string","defaultProps","_default","exports"],"sources":["../../../../../../src/shared/components/selectors/CustomDropdown/index.tsx"],"sourcesContent":["import PT from 'prop-types';\nimport { useRef, useState } from 'react';\n\nimport themed from '@dr.pogodin/react-themes';\n\nimport Options from './Options';\n\nimport defaultTheme from './theme.scss';\n\nimport {\n type PropsT,\n optionValidator,\n optionValueName,\n validThemeKeys,\n} from '../common';\n\nconst BaseCustomDropdown: React.FunctionComponent<\nPropsT<React.ReactNode, (value: string) => void>\n> = ({\n filter,\n label,\n onChange,\n options,\n theme,\n value,\n}) => {\n if (!options) throw Error('Internal error');\n\n const dropdownRef = useRef<HTMLDivElement>(null);\n\n // If \"null\" the dropdown is closed, otherwise it is displayed\n // at the specified coordinates.\n const [anchor, setAnchor] = useState<DOMRect | null>(null);\n\n const openList = () => {\n setAnchor(dropdownRef.current!.getBoundingClientRect());\n };\n\n let selected: React.ReactNode = <>&zwnj;</>;\n for (let i = 0; i < options.length; ++i) {\n const option = options[i];\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 (anchor) containerClassName += ` ${theme.active}`;\n\n return (\n <div className={containerClassName}>\n {label === undefined ? null : (\n <div className={theme.label}>{label}</div>\n )}\n <div\n className={theme.dropdown}\n onClick={openList}\n onKeyDown={(e) => {\n if (e.key === 'Enter') openList();\n }}\n ref={dropdownRef}\n role=\"listbox\"\n tabIndex={0}\n >\n {selected}\n <div className={theme.arrow} />\n </div>\n {\n anchor ? (\n <Options\n anchorRect={anchor}\n containerClass={theme.select || ''}\n onCancel={() => setAnchor(null)}\n onChange={(newValue) => {\n setAnchor(null);\n if (onChange) onChange(newValue);\n }}\n optionClass={theme.option || ''}\n options={options}\n />\n ) : null\n }\n </div>\n );\n};\n\nconst ThemedCustomDropdown = themed(\n BaseCustomDropdown,\n 'CustomDropdown',\n validThemeKeys,\n defaultTheme,\n);\n\nBaseCustomDropdown.propTypes = {\n filter: PT.func,\n label: PT.node,\n onChange: PT.func,\n options: PT.arrayOf(optionValidator.isRequired),\n theme: ThemedCustomDropdown.themeType.isRequired,\n value: PT.string,\n};\n\nBaseCustomDropdown.defaultProps = {\n filter: undefined,\n label: undefined,\n onChange: undefined,\n options: [],\n value: undefined,\n};\n\nexport default ThemedCustomDropdown;\n"],"mappings":";;;;;;;AAAA,IAAAA,UAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,MAAA,GAAAD,OAAA;AAEA,IAAAE,YAAA,GAAAH,sBAAA,CAAAC,OAAA;AAEA,IAAAG,QAAA,GAAAJ,sBAAA,CAAAC,OAAA;AAIA,IAAAI,OAAA,GAAAJ,OAAA;AAKmB,IAAAK,WAAA,GAAAL,OAAA;AAAA,MAAAM,YAAA;EAAA;EAAA;EAAA;EAAA;EAAA;EAAA;EAAA;EAAA;EAAA;EAAA;AAAA;AAEnB,MAAMC,kBAEL,GAAGA,CAAC;EACHC,MAAM;EACNC,KAAK;EACLC,QAAQ;EACRC,OAAO;EACPC,KAAK;EACLC;AACF,CAAC,KAAK;EACJ,IAAI,CAACF,OAAO,EAAE,MAAMG,KAAK,CAAC,gBAAgB,CAAC;EAE3C,MAAMC,WAAW,GAAG,IAAAC,aAAM,EAAiB,IAAI,CAAC;;EAEhD;EACA;EACA,MAAM,CAACC,MAAM,EAAEC,SAAS,CAAC,GAAG,IAAAC,eAAQ,EAAiB,IAAI,CAAC;EAE1D,MAAMC,QAAQ,GAAGA,CAAA,KAAM;IACrBF,SAAS,CAACH,WAAW,CAACM,OAAO,CAAEC,qBAAqB,CAAC,CAAC,CAAC;EACzD,CAAC;EAED,IAAIC,QAAyB,gBAAG,IAAAlB,WAAA,CAAAmB,GAAA,EAAAnB,WAAA,CAAAoB,QAAA;IAAAC,QAAA,EAAE;EAAM,CAAE,CAAC;EAC3C,KAAK,IAAIC,CAAC,GAAG,CA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C,OAAO;MACNC,UAAU,EAAEhC,MAAO;MACnBiC,cAAc,EAAEtC,KAAK,CAACuC,MAAM,IAAI,EAAG;MACnCC,QAAQ,EAAEA,CAAA,KAAMlC,SAAS,CAAC,IAAI,CAAE;MAChCR,QAAQ,EAAG2C,QAAQ,IAAK;QACtBnC,SAAS,CAAC,IAAI,CAAC;QACf,IAAIR,QAAQ,EAAEA,QAAQ,CAAC2C,QAAQ,CAAC;MAClC,CAAE;MACFC,WAAW,EAAE1C,KAAK,CAACiB,MAAM,IAAI,EAAG;MAChClB,OAAO,EAAEA;IAAQ,CAClB,CAAC,GACA,IAAI;EAAA,CAEP,CAAC;AAEV,CAAC;AAED,MAAM4C,oBAAoB,GAAG,IAAAC,oBAAM,EACjCjD,kBAAkB,EAClB,gBAAgB,EAChBkD,sBAAc,EACdnD,YACF,CAAC;AAEDC,kBAAkB,CAACmD,SAAS,GAAG;EAC7BlD,MAAM,EAAEmD,kBAAE,CAACC,IAAI;EACfnD,KAAK,EAAEkD,kBAAE,CAACE,IAAI;EACdnD,QAAQ,EAAEiD,kBAAE,CAACC,IAAI;EACjBjD,OAAO,EAAEgD,kBAAE,CAACG,OAAO,CAACC,uBAAe,CAACC,UAAU,CAAC;EAC/CpD,KAAK,EAAE2C,oBAAoB,CAACU,SAAS,CAACD,UAAU;EAChDnD,KAAK,EAAE8C,kBAAE,CAACO;AACZ,CAAC;AAED3D,kBAAkB,CAAC4D,YAAY,GAAG;EAChC3D,MAAM,EAAE8B,SAAS;EACjB7B,KAAK,EAAE6B,SAAS;EAChB5B,QAAQ,EAAE4B,SAAS;EACnB3B,OAAO,EAAE,EAAE;EACXE,KAAK,EAAEyB;AACT,CAAC;AAAC,IAAA8B,QAAA,GAAAC,OAAA,CAAArB,OAAA,GAEaO,oBAAoB","ignoreList":[]}
@@ -7,20 +7,22 @@ Object.defineProperty(exports, "__esModule", {
7
7
  exports.default = void 0;
8
8
  var _propTypes = _interopRequireDefault(require("prop-types"));
9
9
  var _reactThemes = _interopRequireDefault(require("@dr.pogodin/react-themes"));
10
+ var _common = require("../common");
10
11
  var _jsxRuntime = require("react/jsx-runtime");
12
+ // Implements dropdown based on the native HTML <select> element.
11
13
  const defaultTheme = {
12
- "context": "-dr-pogodin-react-utils___src-shared-components-Dropdown-theme___context___haRIry",
13
- "ad": "-dr-pogodin-react-utils___src-shared-components-Dropdown-theme___ad___D4XHG2",
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",
16
- "arrow": "-dr-pogodin-react-utils___src-shared-components-Dropdown-theme___arrow___-zPK7Y",
17
- "container": "-dr-pogodin-react-utils___src-shared-components-Dropdown-theme___container___9CQpeA",
18
- "label": "-dr-pogodin-react-utils___src-shared-components-Dropdown-theme___label___Gv0kyu",
19
- "option": "-dr-pogodin-react-utils___src-shared-components-Dropdown-theme___option___xmsujA",
20
- "hiddenOption": "-dr-pogodin-react-utils___src-shared-components-Dropdown-theme___hiddenOption___RdW3yR",
21
- "select": "-dr-pogodin-react-utils___src-shared-components-Dropdown-theme___select___JXK1uw"
14
+ "context": "-dr-pogodin-react-utils___src-shared-components-selectors-NativeDropdown-theme___context___xHyZo4",
15
+ "ad": "-dr-pogodin-react-utils___src-shared-components-selectors-NativeDropdown-theme___ad___ADu59e",
16
+ "hoc": "-dr-pogodin-react-utils___src-shared-components-selectors-NativeDropdown-theme___hoc___FTP2bb",
17
+ "dropdown": "-dr-pogodin-react-utils___src-shared-components-selectors-NativeDropdown-theme___dropdown___kI9A9U",
18
+ "arrow": "-dr-pogodin-react-utils___src-shared-components-selectors-NativeDropdown-theme___arrow___DubGkT",
19
+ "container": "-dr-pogodin-react-utils___src-shared-components-selectors-NativeDropdown-theme___container___WtSZPd",
20
+ "active": "-dr-pogodin-react-utils___src-shared-components-selectors-NativeDropdown-theme___active___ayMn7O",
21
+ "label": "-dr-pogodin-react-utils___src-shared-components-selectors-NativeDropdown-theme___label___K7JYKw",
22
+ "option": "-dr-pogodin-react-utils___src-shared-components-selectors-NativeDropdown-theme___option___27pZ6W",
23
+ "hiddenOption": "-dr-pogodin-react-utils___src-shared-components-selectors-NativeDropdown-theme___hiddenOption___clAKFJ",
24
+ "select": "-dr-pogodin-react-utils___src-shared-components-selectors-NativeDropdown-theme___select___N0Fc14"
22
25
  };
23
- const validThemeKeys = ['arrow', 'container', 'dropdown', 'hiddenOption', 'label', 'option', 'select'];
24
26
  /**
25
27
  * Implements a themeable dropdown list. Internally it is rendered with help of
26
28
  * the standard HTML `<select>` element, thus the styling support is somewhat
@@ -44,30 +46,23 @@ const Dropdown = ({
44
46
  filter,
45
47
  label,
46
48
  onChange,
47
- options = [],
49
+ options,
48
50
  theme,
49
51
  value
50
52
  }) => {
53
+ if (!options) throw Error('Internal error');
51
54
  let isValidValue = false;
52
55
  const optionElements = [];
53
56
  for (let i = 0; i < options.length; ++i) {
54
57
  const option = options[i];
55
58
  if (!filter || filter(option)) {
56
- let optionValue;
57
- let optionName;
58
- if (typeof option === 'string') {
59
- optionName = option;
60
- optionValue = option;
61
- } else {
62
- optionName = option.name || option.value;
63
- optionValue = option.value;
64
- }
65
- isValidValue ||= optionValue === value;
59
+ const [iValue, iName] = (0, _common.optionValueName)(option);
60
+ isValidValue ||= iValue === value;
66
61
  optionElements.push( /*#__PURE__*/(0, _jsxRuntime.jsx)("option", {
67
62
  className: theme.option,
68
- value: optionValue,
69
- children: optionName
70
- }, optionValue));
63
+ value: iValue,
64
+ children: iName
65
+ }, iValue));
71
66
  }
72
67
  }
73
68
 
@@ -83,7 +78,7 @@ const Dropdown = ({
83
78
  }, "__reactUtilsHiddenOption");
84
79
  return /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
85
80
  className: theme.container,
86
- children: [label === undefined ? null : /*#__PURE__*/(0, _jsxRuntime.jsx)("p", {
81
+ children: [label === undefined ? null : /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
87
82
  className: theme.label,
88
83
  children: label
89
84
  }), /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
@@ -94,21 +89,17 @@ const Dropdown = ({
94
89
  value: value,
95
90
  children: [hiddenOption, optionElements]
96
91
  }), /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
97
- className: theme.arrow,
98
- children: "\u25BC"
92
+ className: theme.arrow
99
93
  })]
100
94
  })]
101
95
  });
102
96
  };
103
- const ThemedDropdown = (0, _reactThemes.default)(Dropdown, 'Dropdown', validThemeKeys, defaultTheme);
97
+ const ThemedDropdown = (0, _reactThemes.default)(Dropdown, 'Dropdown', _common.validThemeKeys, defaultTheme);
104
98
  Dropdown.propTypes = {
105
99
  filter: _propTypes.default.func,
106
- label: _propTypes.default.string,
100
+ label: _propTypes.default.node,
107
101
  onChange: _propTypes.default.func,
108
- options: _propTypes.default.arrayOf(_propTypes.default.oneOfType([_propTypes.default.shape({
109
- name: _propTypes.default.string,
110
- value: _propTypes.default.string.isRequired
111
- }), _propTypes.default.string]).isRequired),
102
+ options: _common.optionsValidator,
112
103
  theme: ThemedDropdown.themeType.isRequired,
113
104
  value: _propTypes.default.string
114
105
  };
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","names":["_propTypes","_interopRequireDefault","require","_reactThemes","_common","_jsxRuntime","defaultTheme","Dropdown","filter","label","onChange","options","theme","value","Error","isValidValue","optionElements","i","length","option","iValue","iName","optionValueName","push","jsx","className","children","hiddenOption","disabled","jsxs","container","undefined","dropdown","select","arrow","ThemedDropdown","themed","validThemeKeys","propTypes","PT","func","node","optionsValidator","themeType","isRequired","string","defaultProps","_default","exports","default"],"sources":["../../../../../../src/shared/components/selectors/NativeDropdown/index.tsx"],"sourcesContent":["// Implements dropdown based on the native HTML <select> element.\n\nimport PT from 'prop-types';\n\nimport themed from '@dr.pogodin/react-themes';\n\nimport defaultTheme from './theme.scss';\n\nimport {\n type PropsT,\n optionsValidator,\n optionValueName,\n validThemeKeys,\n} from '../common';\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<string>> = ({\n filter,\n label,\n onChange,\n options,\n theme,\n value,\n}) => {\n if (!options) throw Error('Internal error');\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 const [iValue, iName] = optionValueName(option);\n isValidValue ||= iValue === value;\n optionElements.push(\n <option className={theme.option} key={iValue} value={iValue}>\n {iName}\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 : <div className={theme.label}>{label}</div> }\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} />\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.node,\n onChange: PT.func,\n options: optionsValidator,\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":";;;;;;;AAEA,IAAAA,UAAA,GAAAC,sBAAA,CAAAC,OAAA;AAEA,IAAAC,YAAA,GAAAF,sBAAA,CAAAC,OAAA;AAIA,IAAAE,OAAA,GAAAF,OAAA;AAKmB,IAAAG,WAAA,GAAAH,OAAA;AAbnB;AAAA,MAAAI,YAAA;EAAA;EAAA;EAAA;EAAA;EAAA;EAAA;EAAA;EAAA;EAAA;EAAA;EAAA;AAAA;AAeA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAMC,QAAiD,GAAGA,CAAC;EACzDC,MAAM;EACNC,KAAK;EACLC,QAAQ;EACRC,OAAO;EACPC,KAAK;EACLC;AACF,CAAC,KAAK;EACJ,IAAI,CAACF,OAAO,EAAE,MAAMG,KAAK,CAAC,gBAAgB,CAAC;EAE3C,IAAIC,YAAY,GAAG,KAAK;EACxB,MAAMC,cAAc,GAAG,EAAE;EAEzB,KAAK,IAAIC,CAAC,GAAG,CAAC,EAAEA,CAAC,GAAGN,OAAO,CAACO,MAAM,EAAE,EAAED,CAAC,EAAE;IACvC,MAAME,MAAM,GAAGR,OAAO,CAACM,CAAC,CAAC;IACzB,IAAI,CAACT,MAAM,IAAIA,MAAM,CAACW,MAAM,CAAC,EAAE;MAC7B,MAAM,CAACC,MAAM,EAAEC,KAAK,CAAC,GAAG,IAAAC,uBAAe,EAACH,MAAM,CAAC;MAC/CJ,YAAY,KAAKK,MAAM,KAAKP,KAAK;MACjCG,cAAc,CAACO,IAAI,eACjB,IAAAlB,WAAA,CAAAmB,GAAA;QAAQC,SAAS,EAAEb,KAAK,CAACO,MAAO;QAAcN,KAAK,EAAEO,MAAO;QAAAM,QAAA,EACzDL;MAAK,GAD8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c,CAACQ,SAAS,CAACC,UAAU;EAC1C/B,KAAK,EAAE0B,kBAAE,CAACM;AACZ,CAAC;AAEDtC,QAAQ,CAACuC,YAAY,GAAG;EACtBtC,MAAM,EAAEuB,SAAS;EACjBtB,KAAK,EAAEsB,SAAS;EAChBrB,QAAQ,EAAEqB,SAAS;EACnBpB,OAAO,EAAE,EAAE;EACXE,KAAK,EAAE;AACT,CAAC;AAAC,IAAAkC,QAAA,GAAAC,OAAA,CAAAC,OAAA,GAEad,cAAc","ignoreList":[]}
@@ -0,0 +1,76 @@
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 _propTypes = _interopRequireDefault(require("prop-types"));
9
+ var _reactThemes = _interopRequireDefault(require("@dr.pogodin/react-themes"));
10
+ var _common = require("../common");
11
+ var _jsxRuntime = require("react/jsx-runtime");
12
+ const defaultTheme = {
13
+ "context": "-dr-pogodin-react-utils___src-shared-components-selectors-Switch-theme___context___VMHfnP",
14
+ "ad": "-dr-pogodin-react-utils___src-shared-components-selectors-Switch-theme___ad___HNliRC",
15
+ "hoc": "-dr-pogodin-react-utils___src-shared-components-selectors-Switch-theme___hoc___2Ue-db",
16
+ "container": "-dr-pogodin-react-utils___src-shared-components-selectors-Switch-theme___container___AWNvRj",
17
+ "option": "-dr-pogodin-react-utils___src-shared-components-selectors-Switch-theme___option___fUfIAd",
18
+ "selected": "-dr-pogodin-react-utils___src-shared-components-selectors-Switch-theme___selected___Wco-qk",
19
+ "switch": "-dr-pogodin-react-utils___src-shared-components-selectors-Switch-theme___switch___HR5LN5"
20
+ };
21
+ const validThemeKeys = ['container', 'label', 'option', 'selected', 'switch'];
22
+ const BaseSwitch = ({
23
+ label,
24
+ onChange,
25
+ options,
26
+ theme,
27
+ value
28
+ }) => {
29
+ if (!options || !theme.option) throw Error('Internal error');
30
+ const optionNodes = [];
31
+ for (let i = 0; i < options?.length; ++i) {
32
+ const [iValue, iName] = (0, _common.optionValueName)(options[i]);
33
+ let className = theme.option;
34
+ let onPress;
35
+ if (iValue === value) className += ` ${theme.selected}`;else if (onChange) onPress = () => onChange(iValue);
36
+ optionNodes.push(onPress ? /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
37
+ className: className,
38
+ onClick: onPress,
39
+ onKeyDown: e => {
40
+ if (onPress && e.key === 'Enter') onPress();
41
+ },
42
+ role: "button",
43
+ tabIndex: 0,
44
+ children: iName
45
+ }, iValue) : /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
46
+ className: className,
47
+ children: iName
48
+ }, iValue));
49
+ }
50
+ return /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
51
+ className: theme.container,
52
+ children: [label ? /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
53
+ className: theme.label,
54
+ children: label
55
+ }) : null, /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
56
+ className: theme.switch,
57
+ children: optionNodes
58
+ })]
59
+ });
60
+ };
61
+ const ThemedSwitch = (0, _reactThemes.default)(BaseSwitch, 'Switch', validThemeKeys, defaultTheme);
62
+ BaseSwitch.propTypes = {
63
+ label: _propTypes.default.node,
64
+ onChange: _propTypes.default.func,
65
+ options: _common.optionsValidator,
66
+ theme: ThemedSwitch.themeType.isRequired,
67
+ value: _propTypes.default.string
68
+ };
69
+ BaseSwitch.defaultProps = {
70
+ label: undefined,
71
+ onChange: undefined,
72
+ options: [],
73
+ value: undefined
74
+ };
75
+ var _default = exports.default = ThemedSwitch;
76
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","names":["_propTypes","_interopRequireDefault","require","_reactThemes","_common","_jsxRuntime","defaultTheme","validThemeKeys","BaseSwitch","label","onChange","options","theme","value","option","Error","optionNodes","i","length","iValue","iName","optionValueName","className","onPress","selected","push","jsx","onClick","onKeyDown","e","key","role","tabIndex","children","jsxs","container","switch","ThemedSwitch","themed","propTypes","PT","node","func","optionsValidator","themeType","isRequired","string","defaultProps","undefined","_default","exports","default"],"sources":["../../../../../../src/shared/components/selectors/Switch/index.tsx"],"sourcesContent":["import PT from 'prop-types';\nimport themed, { type Theme } from '@dr.pogodin/react-themes';\n\nimport { type OptionsT, optionsValidator, optionValueName } from '../common';\n\nimport defaultTheme from './theme.scss';\n\nconst validThemeKeys = [\n 'container',\n 'label',\n 'option',\n 'selected',\n 'switch',\n] as const;\n\ntype PropsT = {\n label?: React.ReactNode;\n onChange?: (value: string) => void;\n options?: Readonly<OptionsT<React.ReactNode>>;\n theme: Theme<typeof validThemeKeys>;\n value?: string;\n};\n\nconst BaseSwitch: React.FunctionComponent<PropsT> = ({\n label,\n onChange,\n options,\n theme,\n value,\n}) => {\n if (!options || !theme.option) throw Error('Internal error');\n\n const optionNodes: React.ReactNode[] = [];\n for (let i = 0; i < options?.length; ++i) {\n const [iValue, iName] = optionValueName(options[i]);\n\n let className: string = theme.option;\n let onPress: (() => void) | undefined;\n if (iValue === value) className += ` ${theme.selected}`;\n else if (onChange) onPress = () => onChange(iValue);\n\n optionNodes.push(\n onPress ? (\n <div\n className={className}\n onClick={onPress}\n onKeyDown={(e) => {\n if (onPress && e.key === 'Enter') onPress();\n }}\n key={iValue}\n role=\"button\"\n tabIndex={0}\n >\n {iName}\n </div>\n ) : (\n <div className={className} key={iValue}>{iName}</div>\n ),\n );\n }\n\n return (\n <div className={theme.container}>\n {label ? <div className={theme.label}>{label}</div> : null}\n <div className={theme.switch}>\n {optionNodes}\n </div>\n </div>\n );\n};\n\nconst ThemedSwitch = themed(\n BaseSwitch,\n 'Switch',\n validThemeKeys,\n defaultTheme,\n);\n\nBaseSwitch.propTypes = {\n label: PT.node,\n onChange: PT.func,\n options: optionsValidator,\n theme: ThemedSwitch.themeType.isRequired,\n value: PT.string,\n};\n\nBaseSwitch.defaultProps = {\n label: undefined,\n onChange: undefined,\n options: [],\n value: undefined,\n};\n\nexport default ThemedSwitch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3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports.optionValidator = void 0;
8
+ exports.optionValueName = optionValueName;
9
+ exports.validThemeKeys = exports.optionsValidator = void 0;
10
+ var _propTypes = _interopRequireDefault(require("prop-types"));
11
+ // The stuff common between different dropdown implementations.
12
+
13
+ const validThemeKeys = exports.validThemeKeys = ['active', 'arrow', 'container', 'dropdown', 'hiddenOption', 'label', 'option', 'select'];
14
+ const optionValidator = exports.optionValidator = _propTypes.default.oneOfType([_propTypes.default.shape({
15
+ name: _propTypes.default.string,
16
+ value: _propTypes.default.string.isRequired
17
+ }).isRequired, _propTypes.default.string.isRequired]);
18
+ const optionsValidator = exports.optionsValidator = _propTypes.default.arrayOf(optionValidator.isRequired);
19
+
20
+ /** Returns option value and name as a tuple. */
21
+ function optionValueName(option) {
22
+ return typeof option === 'string' ? [option, option] : [option.value, option.name ?? option.value];
23
+ }
24
+ //# sourceMappingURL=common.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"common.js","names":["_propTypes","_interopRequireDefault","require","validThemeKeys","exports","optionValidator","PT","oneOfType","shape","name","string","value","isRequired","optionsValidator","arrayOf","optionValueName","option"],"sources":["../../../../../src/shared/components/selectors/common.ts"],"sourcesContent":["// The stuff common between different dropdown implementations.\n\nimport PT from 'prop-types';\n\nimport type { Theme } from '@dr.pogodin/react-themes';\n\nexport const validThemeKeys = [\n 'active',\n 'arrow',\n 'container',\n 'dropdown',\n 'hiddenOption',\n 'label',\n 'option',\n 'select',\n] as const;\n\nexport type OptionT<NameT> = {\n name?: NameT | null;\n value: string;\n};\n\nexport type OptionsT<NameT> = Array<OptionT<NameT> | string>;\n\nexport type PropsT<\n NameT,\n OnChangeT = React.ChangeEventHandler<HTMLSelectElement>,\n> = {\n filter?: (item: OptionT<NameT> | string) => boolean;\n label?: React.ReactNode;\n onChange?: OnChangeT;\n options?: OptionsT<NameT>;\n theme: Theme<typeof validThemeKeys>;\n value?: string;\n};\n\nexport const optionValidator = PT.oneOfType([\n PT.shape({\n name: PT.string,\n value: PT.string.isRequired,\n }).isRequired,\n PT.string.isRequired,\n]);\n\nexport const optionsValidator = PT.arrayOf(optionValidator.isRequired);\n\n/** Returns option value and name as a tuple. */\nexport function optionValueName<NameT>(\n option: OptionT<NameT> | string,\n): [string, NameT | string] {\n return typeof option === 'string'\n ? [option, option]\n : [option.value, option.name ?? option.value];\n}\n"],"mappings":";;;;;;;;;AAEA,IAAAA,UAAA,GAAAC,sBAAA,CAAAC,OAAA;AAFA;;AAMO,MAAMC,cAAc,GAAAC,OAAA,CAAAD,cAAA,GAAG,CAC5B,QAAQ,EACR,OAAO,EACP,WAAW,EACX,UAAU,EACV,cAAc,EACd,OAAO,EACP,QAAQ,EACR,QAAQ,CACA;AAqBH,MAAME,eAAe,GAAAD,OAAA,CAAAC,eAAA,GAAGC,kBAAE,CAACC,SAAS,CAAC,CAC1CD,kBAAE,CAACE,KAAK,CAAC;EACPC,IAAI,EAAEH,kBAAE,CAACI,MAAM;EACfC,KAAK,EAAEL,kBAAE,CAACI,MAAM,CAACE;AACnB,CAAC,CAAC,CAACA,UAAU,EACbN,kBAAE,CAACI,MAAM,CAACE,UAAU,CACrB,CAAC;AAEK,MAAMC,gBAAgB,GAAAT,OAAA,CAAAS,gBAAA,GAAGP,kBAAE,CAACQ,OAAO,CAACT,eAAe,CAACO,UAAU,CAAC;;AAEtE;AACO,SAASG,eAAeA,CAC7BC,MAA+B,EACL;EAC1B,OAAO,OAAOA,MAAM,KAAK,QAAQ,GAC7B,CAACA,MAAM,EAAEA,MAAM,CAAC,GAChB,CAACA,MAAM,CAACL,KAAK,EAAEK,MAAM,CAACP,IAAI,IAAIO,MAAM,CAACL,KAAK,CAAC;AACjD","ignoreList":[]}
@@ -0,0 +1,28 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ Object.defineProperty(exports, "CustomDropdown", {
8
+ enumerable: true,
9
+ get: function () {
10
+ return _CustomDropdown.default;
11
+ }
12
+ });
13
+ Object.defineProperty(exports, "Dropdown", {
14
+ enumerable: true,
15
+ get: function () {
16
+ return _NativeDropdown.default;
17
+ }
18
+ });
19
+ Object.defineProperty(exports, "Switch", {
20
+ enumerable: true,
21
+ get: function () {
22
+ return _Switch.default;
23
+ }
24
+ });
25
+ var _CustomDropdown = _interopRequireDefault(require("./CustomDropdown"));
26
+ var _NativeDropdown = _interopRequireDefault(require("./NativeDropdown"));
27
+ var _Switch = _interopRequireDefault(require("./Switch"));
28
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","names":["_CustomDropdown","_interopRequireDefault","require","_NativeDropdown","_Switch"],"sources":["../../../../../src/shared/components/selectors/index.ts"],"sourcesContent":["export { default as CustomDropdown } from './CustomDropdown';\nexport { default as Dropdown } from './NativeDropdown';\nexport { default as Switch } from './Switch';\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAAA,IAAAA,eAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,eAAA,GAAAF,sBAAA,CAAAC,OAAA;AACA,IAAAE,OAAA,GAAAH,sBAAA,CAAAC,OAAA","ignoreList":[]}