@skbkontur/react-ui 4.16.0-next.9 → 4.16.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 (196) hide show
  1. package/CHANGELOG.md +30 -0
  2. package/cjs/components/Autocomplete/Autocomplete.js +1 -1
  3. package/cjs/components/Autocomplete/Autocomplete.js.map +1 -1
  4. package/cjs/components/Autocomplete/Autocomplete.md +17 -0
  5. package/cjs/components/Button/Button.js +2 -1
  6. package/cjs/components/Button/Button.js.map +1 -1
  7. package/cjs/components/Button/Button.styles.d.ts +1 -0
  8. package/cjs/components/Button/Button.styles.js +63 -59
  9. package/cjs/components/Button/Button.styles.js.map +1 -1
  10. package/cjs/components/ComboBox/ComboBox.d.ts +3 -2
  11. package/cjs/components/ComboBox/ComboBox.js +3 -1
  12. package/cjs/components/ComboBox/ComboBox.js.map +1 -1
  13. package/cjs/components/ComboBox/ComboBox.md +46 -2
  14. package/cjs/components/Dropdown/Dropdown.js +1 -0
  15. package/cjs/components/Dropdown/Dropdown.js.map +1 -1
  16. package/cjs/components/Dropdown/Dropdown.md +33 -0
  17. package/cjs/components/Link/Link.js +15 -2
  18. package/cjs/components/Link/Link.js.map +1 -1
  19. package/cjs/components/Link/Link.styles.d.ts +2 -0
  20. package/cjs/components/Link/Link.styles.js +63 -24
  21. package/cjs/components/Link/Link.styles.js.map +1 -1
  22. package/cjs/components/MenuFooter/MenuFooter.d.ts +26 -0
  23. package/cjs/components/MenuFooter/MenuFooter.js +79 -0
  24. package/cjs/components/MenuFooter/MenuFooter.js.map +1 -0
  25. package/cjs/components/MenuFooter/MenuFooter.md +27 -0
  26. package/cjs/components/MenuFooter/MenuFooter.mixins.d.ts +2 -0
  27. package/cjs/components/MenuFooter/MenuFooter.mixins.js +26 -0
  28. package/cjs/components/MenuFooter/MenuFooter.mixins.js.map +1 -0
  29. package/cjs/components/MenuFooter/MenuFooter.styles.d.ts +10 -0
  30. package/cjs/components/MenuFooter/MenuFooter.styles.js +65 -0
  31. package/cjs/components/MenuFooter/MenuFooter.styles.js.map +1 -0
  32. package/cjs/components/MenuFooter/index.d.ts +1 -0
  33. package/cjs/components/MenuFooter/index.js +1 -0
  34. package/cjs/components/MenuFooter/index.js.map +1 -0
  35. package/cjs/components/MenuHeader/MenuHeader.d.ts +4 -1
  36. package/cjs/components/MenuHeader/MenuHeader.js +31 -4
  37. package/cjs/components/MenuHeader/MenuHeader.js.map +1 -1
  38. package/cjs/components/MenuHeader/MenuHeader.md +12 -0
  39. package/cjs/components/MenuHeader/MenuHeader.mixins.d.ts +2 -0
  40. package/cjs/components/MenuHeader/MenuHeader.mixins.js +26 -0
  41. package/cjs/components/MenuHeader/MenuHeader.mixins.js.map +1 -0
  42. package/cjs/components/MenuHeader/MenuHeader.styles.d.ts +6 -1
  43. package/cjs/components/MenuHeader/MenuHeader.styles.js +54 -12
  44. package/cjs/components/MenuHeader/MenuHeader.styles.js.map +1 -1
  45. package/cjs/components/MenuItem/MenuItem.d.ts +9 -0
  46. package/cjs/components/MenuItem/MenuItem.js +59 -7
  47. package/cjs/components/MenuItem/MenuItem.js.map +1 -1
  48. package/cjs/components/MenuItem/MenuItem.md +12 -0
  49. package/cjs/components/MenuItem/MenuItem.mixins.d.ts +3 -0
  50. package/cjs/components/MenuItem/MenuItem.mixins.js +42 -0
  51. package/cjs/components/MenuItem/MenuItem.mixins.js.map +1 -0
  52. package/cjs/components/MenuItem/MenuItem.styles.d.ts +9 -1
  53. package/cjs/components/MenuItem/MenuItem.styles.js +80 -27
  54. package/cjs/components/MenuItem/MenuItem.styles.js.map +1 -1
  55. package/cjs/components/Select/Select.d.ts +2 -1
  56. package/cjs/components/Select/Select.js +16 -5
  57. package/cjs/components/Select/Select.js.map +1 -1
  58. package/cjs/components/Select/Select.md +17 -0
  59. package/cjs/components/Textarea/Textarea.md +2 -0
  60. package/cjs/components/Toggle/Toggle.md +2 -0
  61. package/cjs/components/Toggle/Toggle.styles.js +1 -1
  62. package/cjs/components/Toggle/Toggle.styles.js.map +1 -1
  63. package/cjs/internal/CustomComboBox/ComboBoxMenu.d.ts +7 -3
  64. package/cjs/internal/CustomComboBox/ComboBoxMenu.js +27 -2
  65. package/cjs/internal/CustomComboBox/ComboBoxMenu.js.map +1 -1
  66. package/cjs/internal/CustomComboBox/ComboBoxView.d.ts +3 -2
  67. package/cjs/internal/CustomComboBox/ComboBoxView.js +7 -3
  68. package/cjs/internal/CustomComboBox/ComboBoxView.js.map +1 -1
  69. package/cjs/internal/CustomComboBox/CustomComboBox.d.ts +5 -3
  70. package/cjs/internal/CustomComboBox/CustomComboBox.js +4 -2
  71. package/cjs/internal/CustomComboBox/CustomComboBox.js.map +1 -1
  72. package/cjs/internal/CustomComboBox/CustomComboBoxReducer.d.ts +2 -1
  73. package/cjs/internal/CustomComboBox/CustomComboBoxReducer.js +1 -0
  74. package/cjs/internal/CustomComboBox/CustomComboBoxReducer.js.map +1 -1
  75. package/cjs/internal/MenuMessage/MenuMessage.d.ts +2 -0
  76. package/cjs/internal/MenuMessage/MenuMessage.js +18 -3
  77. package/cjs/internal/MenuMessage/MenuMessage.js.map +1 -1
  78. package/cjs/internal/MenuMessage/MenuMessage.styles.d.ts +3 -0
  79. package/cjs/internal/MenuMessage/MenuMessage.styles.js +21 -6
  80. package/cjs/internal/MenuMessage/MenuMessage.styles.js.map +1 -1
  81. package/cjs/internal/ThemePlayground/darkTheme.d.ts +1 -1
  82. package/cjs/internal/ThemePlayground/darkTheme.js +1 -1
  83. package/cjs/internal/ThemePlayground/darkTheme.js.map +1 -1
  84. package/cjs/internal/ThemeShowcase/VariablesCollector.d.ts +1 -1
  85. package/cjs/internal/themes/DarkTheme.d.ts +2 -0
  86. package/cjs/internal/themes/DarkTheme.js +11 -3
  87. package/cjs/internal/themes/DarkTheme.js.map +1 -1
  88. package/cjs/internal/themes/DefaultTheme.d.ts +103 -1
  89. package/cjs/internal/themes/DefaultTheme.js +225 -15
  90. package/cjs/internal/themes/DefaultTheme.js.map +1 -1
  91. package/cjs/internal/themes/Theme2022.js +1 -1
  92. package/cjs/internal/themes/Theme2022.js.map +1 -1
  93. package/cjs/lib/rootNode/rootNodeDecorator.d.ts +5 -1
  94. package/cjs/lib/rootNode/rootNodeDecorator.js +7 -3
  95. package/cjs/lib/rootNode/rootNodeDecorator.js.map +1 -1
  96. package/components/Autocomplete/Autocomplete/Autocomplete.js +2 -1
  97. package/components/Autocomplete/Autocomplete/Autocomplete.js.map +1 -1
  98. package/components/Autocomplete/Autocomplete.md +17 -0
  99. package/components/Button/Button/Button.js +2 -1
  100. package/components/Button/Button/Button.js.map +1 -1
  101. package/components/Button/Button.styles/Button.styles.js +60 -57
  102. package/components/Button/Button.styles/Button.styles.js.map +1 -1
  103. package/components/Button/Button.styles.d.ts +1 -0
  104. package/components/ComboBox/ComboBox/ComboBox.js +1 -0
  105. package/components/ComboBox/ComboBox/ComboBox.js.map +1 -1
  106. package/components/ComboBox/ComboBox.d.ts +3 -2
  107. package/components/ComboBox/ComboBox.md +46 -2
  108. package/components/Dropdown/Dropdown/Dropdown.js +1 -0
  109. package/components/Dropdown/Dropdown/Dropdown.js.map +1 -1
  110. package/components/Dropdown/Dropdown.md +33 -0
  111. package/components/Link/Link/Link.js +8 -2
  112. package/components/Link/Link/Link.js.map +1 -1
  113. package/components/Link/Link.styles/Link.styles.js +38 -22
  114. package/components/Link/Link.styles/Link.styles.js.map +1 -1
  115. package/components/Link/Link.styles.d.ts +2 -0
  116. package/components/MenuFooter/MenuFooter/MenuFooter.js +70 -0
  117. package/components/MenuFooter/MenuFooter/MenuFooter.js.map +1 -0
  118. package/components/MenuFooter/MenuFooter/package.json +6 -0
  119. package/components/MenuFooter/MenuFooter.d.ts +26 -0
  120. package/components/MenuFooter/MenuFooter.md +27 -0
  121. package/components/MenuFooter/MenuFooter.mixins/MenuFooter.mixins.js +13 -0
  122. package/components/MenuFooter/MenuFooter.mixins/MenuFooter.mixins.js.map +1 -0
  123. package/components/MenuFooter/MenuFooter.mixins/package.json +6 -0
  124. package/components/MenuFooter/MenuFooter.mixins.d.ts +2 -0
  125. package/components/MenuFooter/MenuFooter.styles/MenuFooter.styles.js +29 -0
  126. package/components/MenuFooter/MenuFooter.styles/MenuFooter.styles.js.map +1 -0
  127. package/components/MenuFooter/MenuFooter.styles/package.json +6 -0
  128. package/components/MenuFooter/MenuFooter.styles.d.ts +10 -0
  129. package/components/MenuFooter/index/index.js +1 -0
  130. package/components/MenuFooter/index/index.js.map +1 -0
  131. package/components/MenuFooter/index/package.json +6 -0
  132. package/components/MenuFooter/index.d.ts +1 -0
  133. package/components/MenuFooter/package.json +6 -0
  134. package/components/MenuHeader/MenuHeader/MenuHeader.js +33 -2
  135. package/components/MenuHeader/MenuHeader/MenuHeader.js.map +1 -1
  136. package/components/MenuHeader/MenuHeader.d.ts +4 -1
  137. package/components/MenuHeader/MenuHeader.md +12 -0
  138. package/components/MenuHeader/MenuHeader.mixins/MenuHeader.mixins.js +13 -0
  139. package/components/MenuHeader/MenuHeader.mixins/MenuHeader.mixins.js.map +1 -0
  140. package/components/MenuHeader/MenuHeader.mixins/package.json +6 -0
  141. package/components/MenuHeader/MenuHeader.mixins.d.ts +2 -0
  142. package/components/MenuHeader/MenuHeader.styles/MenuHeader.styles.js +20 -6
  143. package/components/MenuHeader/MenuHeader.styles/MenuHeader.styles.js.map +1 -1
  144. package/components/MenuHeader/MenuHeader.styles.d.ts +6 -1
  145. package/components/MenuItem/MenuItem/MenuItem.js +49 -5
  146. package/components/MenuItem/MenuItem/MenuItem.js.map +1 -1
  147. package/components/MenuItem/MenuItem.d.ts +9 -0
  148. package/components/MenuItem/MenuItem.md +12 -0
  149. package/components/MenuItem/MenuItem.mixins/MenuItem.mixins.js +24 -0
  150. package/components/MenuItem/MenuItem.mixins/MenuItem.mixins.js.map +1 -0
  151. package/components/MenuItem/MenuItem.mixins/package.json +6 -0
  152. package/components/MenuItem/MenuItem.mixins.d.ts +3 -0
  153. package/components/MenuItem/MenuItem.styles/MenuItem.styles.js +39 -23
  154. package/components/MenuItem/MenuItem.styles/MenuItem.styles.js.map +1 -1
  155. package/components/MenuItem/MenuItem.styles.d.ts +9 -1
  156. package/components/Select/Select/Select.js +20 -6
  157. package/components/Select/Select/Select.js.map +1 -1
  158. package/components/Select/Select.d.ts +2 -1
  159. package/components/Select/Select.md +17 -0
  160. package/components/Textarea/Textarea.md +2 -0
  161. package/components/Toggle/Toggle.md +2 -0
  162. package/components/Toggle/Toggle.styles/Toggle.styles.js +1 -1
  163. package/components/Toggle/Toggle.styles/Toggle.styles.js.map +1 -1
  164. package/internal/CustomComboBox/ComboBoxMenu/ComboBoxMenu.js +28 -10
  165. package/internal/CustomComboBox/ComboBoxMenu/ComboBoxMenu.js.map +1 -1
  166. package/internal/CustomComboBox/ComboBoxMenu.d.ts +7 -3
  167. package/internal/CustomComboBox/ComboBoxView/ComboBoxView.js +6 -4
  168. package/internal/CustomComboBox/ComboBoxView/ComboBoxView.js.map +1 -1
  169. package/internal/CustomComboBox/ComboBoxView.d.ts +3 -2
  170. package/internal/CustomComboBox/CustomComboBox/CustomComboBox.js +3 -1
  171. package/internal/CustomComboBox/CustomComboBox/CustomComboBox.js.map +1 -1
  172. package/internal/CustomComboBox/CustomComboBox.d.ts +5 -3
  173. package/internal/CustomComboBox/CustomComboBoxReducer/CustomComboBoxReducer.js.map +1 -1
  174. package/internal/CustomComboBox/CustomComboBoxReducer.d.ts +2 -1
  175. package/internal/MenuMessage/MenuMessage/MenuMessage.js +19 -2
  176. package/internal/MenuMessage/MenuMessage/MenuMessage.js.map +1 -1
  177. package/internal/MenuMessage/MenuMessage.d.ts +2 -0
  178. package/internal/MenuMessage/MenuMessage.styles/MenuMessage.styles.js +11 -2
  179. package/internal/MenuMessage/MenuMessage.styles/MenuMessage.styles.js.map +1 -1
  180. package/internal/MenuMessage/MenuMessage.styles.d.ts +3 -0
  181. package/internal/ThemePlayground/darkTheme/darkTheme.js +1 -1
  182. package/internal/ThemePlayground/darkTheme/darkTheme.js.map +1 -1
  183. package/internal/ThemePlayground/darkTheme.d.ts +1 -1
  184. package/internal/ThemeShowcase/VariablesCollector.d.ts +1 -1
  185. package/internal/themes/DarkTheme/DarkTheme.js +13 -0
  186. package/internal/themes/DarkTheme/DarkTheme.js.map +1 -1
  187. package/internal/themes/DarkTheme.d.ts +2 -0
  188. package/internal/themes/DefaultTheme/DefaultTheme.js +251 -8
  189. package/internal/themes/DefaultTheme/DefaultTheme.js.map +1 -1
  190. package/internal/themes/DefaultTheme.d.ts +103 -1
  191. package/internal/themes/Theme2022/Theme2022.js +1 -1
  192. package/internal/themes/Theme2022/Theme2022.js.map +1 -1
  193. package/lib/rootNode/rootNodeDecorator/rootNodeDecorator.js +4 -3
  194. package/lib/rootNode/rootNodeDecorator/rootNodeDecorator.js.map +1 -1
  195. package/lib/rootNode/rootNodeDecorator.d.ts +5 -1
  196. package/package.json +3 -3
@@ -11,6 +11,8 @@ import { Spinner } from "../../../components/Spinner";
11
11
  import { MenuSeparator } from "../../../components/MenuSeparator";
12
12
  import { createPropsGetter } from "../../../lib/createPropsGetter";
13
13
  import { MenuMessage } from "../../MenuMessage";
14
+ import { ThemeContext } from "../../../lib/theming/ThemeContext";
15
+ import { MenuFooter } from "../../../components/MenuFooter";
14
16
  import { ComboBoxRequestStatus } from "../CustomComboBoxTypes";
15
17
  import { CustomComboBoxLocaleHelper } from "../locale";
16
18
  export var ComboBoxMenuDataTids = {
@@ -41,7 +43,7 @@ export var ComboBoxMenu = (_dec = locale('ComboBox', CustomComboBoxLocaleHelper)
41
43
  onValueChange = _this$props.onValueChange,
42
44
  itemWrapper = _this$props.itemWrapper;
43
45
 
44
- if (isFunction(item) || /*#__PURE__*/React.isValidElement(item)) {
46
+ if (!isSimpleItem(item)) {
45
47
  var element = isFunction(item) ? item() : item;
46
48
  var props = Object.assign({
47
49
  key: index,
@@ -59,6 +61,7 @@ export var ComboBoxMenu = (_dec = locale('ComboBox', CustomComboBoxLocaleHelper)
59
61
  return onValueChange(item);
60
62
  },
61
63
  key: index,
64
+ size: _this.props.size,
62
65
  isMobile: _this.props.isMobile
63
66
  }, function (state) {
64
67
  return renderItem(item, state);
@@ -71,6 +74,17 @@ export var ComboBoxMenu = (_dec = locale('ComboBox', CustomComboBoxLocaleHelper)
71
74
  var _proto = ComboBoxMenu.prototype;
72
75
 
73
76
  _proto.render = function render() {
77
+ var _this2 = this;
78
+
79
+ return /*#__PURE__*/React.createElement(ThemeContext.Consumer, null, function (theme) {
80
+ _this2.theme = theme;
81
+ return /*#__PURE__*/React.createElement(ThemeContext.Provider, {
82
+ value: _this2.theme
83
+ }, _this2.renderMain());
84
+ });
85
+ };
86
+
87
+ _proto.renderMain = function renderMain() {
74
88
  var _this$props2 = this.props,
75
89
  opened = _this$props2.opened,
76
90
  items = _this$props2.items,
@@ -110,6 +124,7 @@ export var ComboBoxMenu = (_dec = locale('ComboBox', CustomComboBoxLocaleHelper)
110
124
  id: this.props.menuId,
111
125
  "data-tid": ComboBoxMenuDataTids.loading
112
126
  }, /*#__PURE__*/React.createElement(MenuMessage, {
127
+ size: this.props.size,
113
128
  as: "div"
114
129
  }, /*#__PURE__*/React.createElement(Spinner, {
115
130
  type: "mini",
@@ -125,6 +140,7 @@ export var ComboBoxMenu = (_dec = locale('ComboBox', CustomComboBoxLocaleHelper)
125
140
  id: this.props.menuId,
126
141
  "data-tid": ComboBoxMenuDataTids.failed
127
142
  }, /*#__PURE__*/React.createElement(MenuMessage, {
143
+ size: this.props.size,
128
144
  key: "message"
129
145
  }, /*#__PURE__*/React.createElement("div", {
130
146
  style: {
@@ -134,6 +150,7 @@ export var ComboBoxMenu = (_dec = locale('ComboBox', CustomComboBoxLocaleHelper)
134
150
  }, errorNetworkMessage)), /*#__PURE__*/React.createElement(MenuItem, {
135
151
  link: true,
136
152
  onClick: this.getProps().repeatRequest,
153
+ size: this.props.size,
137
154
  key: "retry",
138
155
  isMobile: isMobile
139
156
  }, errorNetworkButton));
@@ -158,6 +175,7 @@ export var ComboBoxMenu = (_dec = locale('ComboBox', CustomComboBoxLocaleHelper)
158
175
  ref: refMenu,
159
176
  disableScrollContainer: isMobile
160
177
  }, /*#__PURE__*/React.createElement(MenuMessage, {
178
+ size: this.props.size,
161
179
  "data-tid": ComboBoxMenuDataTids.notFound
162
180
  }, notFoundValue));
163
181
  }
@@ -173,14 +191,10 @@ export var ComboBoxMenu = (_dec = locale('ComboBox', CustomComboBoxLocaleHelper)
173
191
  var countItems = menuItems == null ? void 0 : menuItems.length;
174
192
 
175
193
  if (countItems && renderTotalCount && totalCount && countItems < totalCount) {
176
- total = /*#__PURE__*/React.createElement(MenuMessage, {
177
- key: "total",
178
- as: "div"
179
- }, /*#__PURE__*/React.createElement("div", {
180
- style: {
181
- fontSize: 12
182
- }
183
- }, renderTotalCount(countItems, totalCount)));
194
+ total = /*#__PURE__*/React.createElement(MenuFooter, {
195
+ size: this.props.size,
196
+ key: "total"
197
+ }, /*#__PURE__*/React.createElement("div", null, renderTotalCount(countItems, totalCount)));
184
198
  }
185
199
 
186
200
  return /*#__PURE__*/React.createElement(Menu, {
@@ -200,4 +214,8 @@ export var ComboBoxMenu = (_dec = locale('ComboBox', CustomComboBoxLocaleHelper)
200
214
  return undefined;
201
215
  },
202
216
  requestStatus: ComboBoxRequestStatus.Unknown
203
- }, _temp)) || _class);
217
+ }, _temp)) || _class);
218
+
219
+ function isSimpleItem(item) {
220
+ return !isFunction(item) && ! /*#__PURE__*/React.isValidElement(item);
221
+ }
@@ -1 +1 @@
1
- {"version":3,"sources":["ComboBoxMenu.tsx"],"names":["React","isFunction","isNullable","locale","Menu","isMenuItem","MenuItem","Spinner","MenuSeparator","createPropsGetter","MenuMessage","ComboBoxRequestStatus","CustomComboBoxLocaleHelper","ComboBoxMenuDataTids","loading","failed","notFound","items","item","ComboBoxMenu","getProps","defaultProps","renderItem","index","props","onValueChange","itemWrapper","isValidElement","element","Object","assign","key","onClick","cloneElement","isMobile","state","render","opened","totalCount","refMenu","renderNotFound","renderTotalCount","maxMenuHeight","requestStatus","errorNetworkButton","errorNetworkMessage","renderAddButton","maxHeight","length","menuId","Failed","maxWidth","whiteSpace","repeatRequest","notFoundValue","total","renderedItems","map","menuItems","filter","countItems","fontSize","Component","__KONTUR_REACT_UI__","undefined","Unknown"],"mappings":"uGAAA,OAAOA,KAAP,MAAkB,OAAlB;;AAEA,SAASC,UAAT,EAAqBC,UAArB,QAAuC,iBAAvC;AACA,SAASC,MAAT,QAAuB,6BAAvB;AACA,SAASC,IAAT,QAAqB,SAArB;AACA,SAASC,UAAT,EAAqBC,QAArB,QAAoD,2BAApD;AACA,SAASC,OAAT,QAAwB,0BAAxB;;AAEA,SAASC,aAAT,QAA8B,gCAA9B;AACA,SAASC,iBAAT,QAAkC,6BAAlC;AACA,SAASC,WAAT,QAA4B,gBAA5B;;AAEA,SAASC,qBAAT,QAAsC,uBAAtC;AACA,SAAyBC,0BAAzB,QAA2D,UAA3D;;;;;;;;;;;;;;;;;;;;;;AAsBA,OAAO,IAAMC,oBAAoB,GAAG;AAClCC,EAAAA,OAAO,EAAE,uBADyB;AAElCC,EAAAA,MAAM,EAAE,sBAF0B;AAGlCC,EAAAA,QAAQ,EAAE,wBAHwB;AAIlCC,EAAAA,KAAK,EAAE,qBAJ2B;AAKlCC,EAAAA,IAAI,EAAE,oBAL4B,EAA7B;;;;;;AAWP,WAAaC,YAAb,WADChB,MAAM,CAAC,UAAD,EAAaS,0BAAb,CACP;;;;;;;;AAQUQ,IAAAA,QARV,GAQqBX,iBAAiB,CAACU,YAAY,CAACE,YAAd,CARtC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA8HUC,IAAAA,UA9HV,GA8HuB,UAACJ,IAAD,EAAUK,KAAV,EAA6C;AAChE;AACA;AACA,wBAAmD,MAAKC,KAAxD,CAAQF,UAAR,eAAQA,UAAR,C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GAAGtB,UAAjE,EAA6E,CAC3EiB,KAAK,gBACH,oBAAC,WAAD,IAAa,GAAG,EAAC,OAAjB,EAAyB,EAAE,EAAC,KAA5B,iBACE,6BAAK,KAAK,EAAE,EAAEM,QAAQ,EAAE,EAAZ,EAAZ,IAA+BpB,gBAAgB,CAACmB,UAAD,EAAatB,UAAb,CAA/C,CADF,CADF,CAKD,CAED,oBACE,oBAAC,IAAD,IACE,EAAE,EAAE,KAAKd,KAAL,CAAWyB,MADjB,EAEE,YAAUpC,oBAAoB,CAACI,KAFjC,EAGE,GAAG,EAAEsB,OAHP,EAIE,SAAS,EAAEQ,SAJb,EAKE,sBAAsB,EAAEb,QAL1B,IAOGsB,aAPH,EAQGD,KARH,EASGT,eAAe,IAAI,cAAC,oBAAC,aAAD,IAAe,GAAG,EAAC,WAAnB,GAAD,EAAoCA,eAApC,CATtB,CADF,CAaD,CA5HH,uBAAqC9C,KAAK,CAAC8D,SAA3C,WACgBC,mBADhB,GACsC,cADtC,UAGgB1C,YAHhB,GAGsD,EAClDgC,aAAa,EAAE,iCAAMW,SAAN,EADmC,EAElDrB,aAAa,EAAEhC,qBAAqB,CAACsD,OAFa,EAHtD","sourcesContent":["import React from 'react';\n\nimport { isFunction, isNullable } from '../../lib/utils';\nimport { locale } from '../../lib/locale/decorators';\nimport { Menu } from '../Menu';\nimport { isMenuItem, MenuItem, MenuItemState } from '../../components/MenuItem';\nimport { Spinner } from '../../components/Spinner';\nimport { Nullable } from '../../typings/utility-types';\nimport { MenuSeparator } from '../../components/MenuSeparator';\nimport { createPropsGetter } from '../../lib/createPropsGetter';\nimport { MenuMessage } from '../MenuMessage';\n\nimport { ComboBoxRequestStatus } from './CustomComboBoxTypes';\nimport { ComboBoxLocale, CustomComboBoxLocaleHelper } from './locale';\n\nexport interface ComboBoxMenuProps<T> {\n opened?: boolean;\n items?: Nullable<T[]>;\n totalCount?: number;\n loading?: boolean;\n maxMenuHeight?: number | string;\n refMenu?: (menu: Nullable<Menu>) => void;\n renderNotFound?: () => React.ReactNode;\n renderTotalCount?: (found: number, total: number) => React.ReactNode;\n renderItem: (item: T, state: MenuItemState) => React.ReactNode;\n itemWrapper?: (item?: T) => React.ComponentType<unknown>;\n onValueChange: (value: T) => any;\n renderAddButton?: () => React.ReactNode;\n caption?: React.ReactNode;\n repeatRequest?: () => void;\n requestStatus?: ComboBoxRequestStatus;\n isMobile?: boolean;\n menuId?: string;\n}\n\nexport const ComboBoxMenuDataTids = {\n loading: 'ComboBoxMenu__loading',\n failed: 'ComboBoxMenu__failed',\n notFound: 'ComboBoxMenu__notFound',\n items: 'ComboBoxMenu__items',\n item: 'ComboBoxMenu__item',\n} as const;\n\ntype DefaultProps<T> = Required<Pick<ComboBoxMenuProps<T>, 'repeatRequest' | 'requestStatus'>>;\n\n@locale('ComboBox', CustomComboBoxLocaleHelper)\nexport class ComboBoxMenu<T> extends React.Component<ComboBoxMenuProps<T>> {\n public static __KONTUR_REACT_UI__ = 'ComboBoxMenu';\n\n public static defaultProps: DefaultProps<unknown> = {\n repeatRequest: () => undefined,\n requestStatus: ComboBoxRequestStatus.Unknown,\n };\n\n private getProps = createPropsGetter(ComboBoxMenu.defaultProps);\n\n private readonly locale!: ComboBoxLocale;\n\n public render() {\n const {\n opened,\n items,\n totalCount,\n loading,\n refMenu,\n renderNotFound = () => notFound,\n renderTotalCount,\n maxMenuHeight,\n isMobile,\n } = this.props;\n\n const requestStatus = this.getProps().requestStatus;\n\n const { notFound, errorNetworkButton, errorNetworkMessage } = this.locale;\n\n if (!opened) {\n return null;\n }\n\n let renderAddButton = null;\n if (this.props.renderAddButton) {\n renderAddButton = this.props.renderAddButton();\n }\n\n const maxHeight = isMobile ? 'auto' : maxMenuHeight;\n\n if (loading && (!items || !items.length)) {\n return (\n <Menu\n maxHeight={maxHeight}\n ref={refMenu}\n disableScrollContainer={isMobile}\n id={this.props.menuId}\n data-tid={ComboBoxMenuDataTids.loading}\n >\n <MenuMessage as=\"div\">\n <Spinner type=\"mini\" dimmed />\n </MenuMessage>\n </Menu>\n );\n }\n\n if (items === null && requestStatus === ComboBoxRequestStatus.Failed) {\n return (\n <Menu\n ref={refMenu}\n maxHeight={maxHeight}\n disableScrollContainer={isMobile}\n id={this.props.menuId}\n data-tid={ComboBoxMenuDataTids.failed}\n >\n <MenuMessage key=\"message\">\n <div style={{ maxWidth: 300, whiteSpace: 'normal' }}>{errorNetworkMessage}</div>\n </MenuMessage>\n <MenuItem link onClick={this.getProps().repeatRequest} key=\"retry\" isMobile={isMobile}>\n {errorNetworkButton}\n </MenuItem>\n </Menu>\n );\n }\n\n if ((isNullable(items) || items.length === 0) && renderNotFound) {\n const notFoundValue = renderNotFound();\n if (renderAddButton) {\n return (\n <Menu id={this.props.menuId} maxHeight={maxHeight} ref={refMenu} disableScrollContainer={isMobile}>\n {renderAddButton}\n </Menu>\n );\n }\n\n if (notFoundValue) {\n return (\n <Menu id={this.props.menuId} maxHeight={maxHeight} ref={refMenu} disableScrollContainer={isMobile}>\n <MenuMessage data-tid={ComboBoxMenuDataTids.notFound}>{notFoundValue}</MenuMessage>\n </Menu>\n );\n }\n\n return null;\n }\n\n let total = null;\n const renderedItems = items && items.map(this.renderItem);\n const menuItems = renderedItems?.filter((item) => {\n return isMenuItem(item);\n });\n const countItems = menuItems?.length;\n\n if (countItems && renderTotalCount && totalCount && countItems < totalCount) {\n total = (\n <MenuMessage key=\"total\" as=\"div\">\n <div style={{ fontSize: 12 }}>{renderTotalCount(countItems, totalCount)}</div>\n </MenuMessage>\n );\n }\n\n return (\n <Menu\n id={this.props.menuId}\n data-tid={ComboBoxMenuDataTids.items}\n ref={refMenu}\n maxHeight={maxHeight}\n disableScrollContainer={isMobile}\n >\n {renderedItems}\n {total}\n {renderAddButton && [<MenuSeparator key=\"separator\" />, renderAddButton]}\n </Menu>\n );\n }\n\n private renderItem = (item: T, index: number): React.ReactNode => {\n // NOTE this is undesireable feature, better\n // to remove it from further versions\n const { renderItem, onValueChange, itemWrapper } = this.props;\n if (isFunction(item) || React.isValidElement(item)) {\n const element = isFunction(item) ? item() : item;\n const props = Object.assign(\n {\n key: index,\n onClick: () => onValueChange(element.props),\n },\n element.props,\n );\n return React.cloneElement(element, props);\n }\n\n return (\n <MenuItem\n component={itemWrapper?.(item)}\n data-tid={ComboBoxMenuDataTids.item}\n onClick={() => onValueChange(item)}\n key={index}\n isMobile={this.props.isMobile}\n >\n {(state) => renderItem(item, state)}\n </MenuItem>\n );\n };\n}\n"]}
1
+ {"version":3,"sources":["ComboBoxMenu.tsx"],"names":["React","isFunction","isNullable","locale","Menu","isMenuItem","MenuItem","Spinner","MenuSeparator","createPropsGetter","MenuMessage","ThemeContext","MenuFooter","ComboBoxRequestStatus","CustomComboBoxLocaleHelper","ComboBoxMenuDataTids","loading","failed","notFound","items","item","ComboBoxMenu","getProps","defaultProps","renderItem","index","props","onValueChange","itemWrapper","isSimpleItem","element","Object","assign","key","onClick","cloneElement","size","isMobile","state","render","theme","renderMain","opened","totalCount","refMenu","renderNotFound","renderTotalCount","maxMenuHeight","requestStatus","errorNetworkButton","errorNetworkMessage","renderAddButton","maxHeight","length","menuId","Failed","maxWidth","whiteSpace","repeatRequest","notFoundValue","total","renderedItems","map","menuItems","filter","countItems","Component","__KONTUR_REACT_UI__","undefined","Unknown","isValidElement"],"mappings":"uGAAA,OAAOA,KAAP,MAAkB,OAAlB;;AAEA,SAASC,UAAT,EAAqBC,UAArB,QAAuC,iBAAvC;AACA,SAASC,MAAT,QAAuB,6BAAvB;AACA,SAASC,IAAT,QAAqB,SAArB;AACA,SAASC,UAAT,EAAqBC,QAArB,QAAoD,2BAApD;AACA,SAASC,OAAT,QAAwB,0BAAxB;;AAEA,SAASC,aAAT,QAA8B,gCAA9B;AACA,SAASC,iBAAT,QAAkC,6BAAlC;AACA,SAASC,WAAT,QAA4B,gBAA5B;;;AAGA,SAASC,YAAT,QAA6B,gCAA7B;AACA,SAASC,UAAT,QAA2B,6BAA3B;;AAEA,SAASC,qBAAT,QAAsC,uBA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AAC,UAAD,IAAY,IAAI,EAAE,KAAKlC,KAAL,CAAWU,IAA7B,EAAmC,GAAG,EAAC,OAAvC,iBACE,iCAAMU,gBAAgB,CAACmB,UAAD,EAAatB,UAAb,CAAtB,CADF,CADF,CAKD,CAED,oBACE,oBAAC,IAAD,IACE,EAAE,EAAE,KAAKjB,KAAL,CAAW4B,MADjB,EAEE,YAAUvC,oBAAoB,CAACI,KAFjC,EAGE,GAAG,EAAEyB,OAHP,EAIE,SAAS,EAAEQ,SAJb,EAKE,sBAAsB,EAAEf,QAL1B,IAOGwB,aAPH,EAQGD,KARH,EASGT,eAAe,IAAI,cAAC,oBAAC,aAAD,IAAe,GAAG,EAAC,WAAnB,GAAD,EAAoCA,eAApC,CATtB,CADF,CAaD,CAzIH,uBAAqCnD,KAAK,CAACkE,SAA3C,WACgBC,mBADhB,GACsC,cADtC,UAGgB5C,YAHhB,GAGsD,EAClDmC,aAAa,EAAE,iCAAMU,SAAN,EADmC,EAElDpB,aAAa,EAAEnC,qBAAqB,CAACwD,OAFa,EAHtD;;;AA2KA,SAASxC,YAAT,CAAyBT,IAAzB,EAAmE;AACjE,SAAO,CAACnB,UAAU,CAACmB,IAAD,CAAX,IAAqB,eAACpB,KAAK,CAACsE,cAAN,CAAqBlD,IAArB,CAA7B;AACD","sourcesContent":["import React from 'react';\n\nimport { isFunction, isNullable } from '../../lib/utils';\nimport { locale } from '../../lib/locale/decorators';\nimport { Menu } from '../Menu';\nimport { isMenuItem, MenuItem, MenuItemState } from '../../components/MenuItem';\nimport { Spinner } from '../../components/Spinner';\nimport { Nullable } from '../../typings/utility-types';\nimport { MenuSeparator } from '../../components/MenuSeparator';\nimport { createPropsGetter } from '../../lib/createPropsGetter';\nimport { MenuMessage } from '../MenuMessage';\nimport { ComboBoxExtendedItem } from '../../components/ComboBox';\nimport { Theme } from '../../lib/theming/Theme';\nimport { ThemeContext } from '../../lib/theming/ThemeContext';\nimport { MenuFooter } from '../../components/MenuFooter';\n\nimport { ComboBoxRequestStatus } from './CustomComboBoxTypes';\nimport { ComboBoxLocale, CustomComboBoxLocaleHelper } from './locale';\n\nexport interface ComboBoxMenuProps<T> {\n opened?: boolean;\n items?: Nullable<Array<ComboBoxExtendedItem<T>>>;\n totalCount?: number;\n loading?: boolean;\n maxMenuHeight?: number | string;\n refMenu?: (menu: Nullable<Menu>) => void;\n renderNotFound?: () => React.ReactNode;\n renderTotalCount?: (found: number, total: number) => React.ReactNode;\n renderItem: (item: T, state: MenuItemState) => React.ReactNode;\n itemWrapper?: (item: T) => React.ComponentType<unknown>;\n onValueChange: (value: T) => any;\n renderAddButton?: () => React.ReactNode;\n caption?: React.ReactNode;\n repeatRequest?: () => void;\n requestStatus?: ComboBoxRequestStatus;\n isMobile?: boolean;\n menuId?: string;\n size?: 'small' | 'medium' | 'large';\n}\n\nexport const ComboBoxMenuDataTids = {\n loading: 'ComboBoxMenu__loading',\n failed: 'ComboBoxMenu__failed',\n notFound: 'ComboBoxMenu__notFound',\n items: 'ComboBoxMenu__items',\n item: 'ComboBoxMenu__item',\n} as const;\n\ntype DefaultProps<T> = Required<Pick<ComboBoxMenuProps<T>, 'repeatRequest' | 'requestStatus'>>;\n\n@locale('ComboBox', CustomComboBoxLocaleHelper)\nexport class ComboBoxMenu<T> extends React.Component<ComboBoxMenuProps<T>> {\n public static __KONTUR_REACT_UI__ = 'ComboBoxMenu';\n\n public static defaultProps: DefaultProps<unknown> = {\n repeatRequest: () => undefined,\n requestStatus: ComboBoxRequestStatus.Unknown,\n };\n\n private getProps = createPropsGetter(ComboBoxMenu.defaultProps);\n\n private readonly locale!: ComboBoxLocale;\n\n private theme!: Theme;\n public render() {\n return (\n <ThemeContext.Consumer>\n {(theme) => {\n this.theme = theme;\n return <ThemeContext.Provider value={this.theme}>{this.renderMain()}</ThemeContext.Provider>;\n }}\n </ThemeContext.Consumer>\n );\n }\n\n public renderMain() {\n const {\n opened,\n items,\n totalCount,\n loading,\n refMenu,\n renderNotFound = () => notFound,\n renderTotalCount,\n maxMenuHeight,\n isMobile,\n } = this.props;\n\n const requestStatus = this.getProps().requestStatus;\n\n const { notFound, errorNetworkButton, errorNetworkMessage } = this.locale;\n\n if (!opened) {\n return null;\n }\n\n let renderAddButton = null;\n if (this.props.renderAddButton) {\n renderAddButton = this.props.renderAddButton();\n }\n\n const maxHeight = isMobile ? 'auto' : maxMenuHeight;\n\n if (loading && (!items || !items.length)) {\n return (\n <Menu\n maxHeight={maxHeight}\n ref={refMenu}\n disableScrollContainer={isMobile}\n id={this.props.menuId}\n data-tid={ComboBoxMenuDataTids.loading}\n >\n <MenuMessage size={this.props.size} as=\"div\">\n <Spinner type=\"mini\" dimmed />\n </MenuMessage>\n </Menu>\n );\n }\n\n if (items === null && requestStatus === ComboBoxRequestStatus.Failed) {\n return (\n <Menu\n ref={refMenu}\n maxHeight={maxHeight}\n disableScrollContainer={isMobile}\n id={this.props.menuId}\n data-tid={ComboBoxMenuDataTids.failed}\n >\n <MenuMessage size={this.props.size} key=\"message\">\n <div style={{ maxWidth: 300, whiteSpace: 'normal' }}>{errorNetworkMessage}</div>\n </MenuMessage>\n <MenuItem link onClick={this.getProps().repeatRequest} size={this.props.size} key=\"retry\" isMobile={isMobile}>\n {errorNetworkButton}\n </MenuItem>\n </Menu>\n );\n }\n\n if ((isNullable(items) || items.length === 0) && renderNotFound) {\n const notFoundValue = renderNotFound();\n if (renderAddButton) {\n return (\n <Menu id={this.props.menuId} maxHeight={maxHeight} ref={refMenu} disableScrollContainer={isMobile}>\n {renderAddButton}\n </Menu>\n );\n }\n\n if (notFoundValue) {\n return (\n <Menu id={this.props.menuId} maxHeight={maxHeight} ref={refMenu} disableScrollContainer={isMobile}>\n <MenuMessage size={this.props.size} data-tid={ComboBoxMenuDataTids.notFound}>\n {notFoundValue}\n </MenuMessage>\n </Menu>\n );\n }\n\n return null;\n }\n\n let total = null;\n const renderedItems = items && items.map(this.renderItem);\n const menuItems = renderedItems?.filter((item) => {\n return isMenuItem(item);\n });\n const countItems = menuItems?.length;\n if (countItems && renderTotalCount && totalCount && countItems < totalCount) {\n total = (\n <MenuFooter size={this.props.size} key=\"total\">\n <div>{renderTotalCount(countItems, totalCount)}</div>\n </MenuFooter>\n );\n }\n\n return (\n <Menu\n id={this.props.menuId}\n data-tid={ComboBoxMenuDataTids.items}\n ref={refMenu}\n maxHeight={maxHeight}\n disableScrollContainer={isMobile}\n >\n {renderedItems}\n {total}\n {renderAddButton && [<MenuSeparator key=\"separator\" />, renderAddButton]}\n </Menu>\n );\n }\n\n private renderItem = (item: ComboBoxExtendedItem<T>, index: number): React.ReactNode => {\n // NOTE this is undesireable feature, better\n // to remove it from further versions\n const { renderItem, onValueChange, itemWrapper } = this.props;\n\n if (!isSimpleItem<T>(item)) {\n const element = isFunction(item) ? item() : item;\n const props = Object.assign(\n {\n key: index,\n onClick: () => onValueChange(element.props),\n },\n element.props,\n );\n return React.cloneElement(element, props);\n }\n\n return (\n <MenuItem\n component={itemWrapper?.(item)}\n data-tid={ComboBoxMenuDataTids.item}\n onClick={() => onValueChange(item)}\n key={index}\n size={this.props.size}\n isMobile={this.props.isMobile}\n >\n {(state) => renderItem(item, state)}\n </MenuItem>\n );\n };\n}\n\nfunction isSimpleItem<T>(item: ComboBoxExtendedItem<T>): item is T {\n return !isFunction(item) && !React.isValidElement(item);\n}\n"]}
@@ -2,10 +2,11 @@ import React from 'react';
2
2
  import { Menu } from '../Menu';
3
3
  import { MenuItemState } from '../../components/MenuItem';
4
4
  import { Nullable } from '../../typings/utility-types';
5
+ import { ComboBoxExtendedItem } from '../../components/ComboBox';
5
6
  import { ComboBoxRequestStatus } from './CustomComboBoxTypes';
6
7
  export interface ComboBoxMenuProps<T> {
7
8
  opened?: boolean;
8
- items?: Nullable<T[]>;
9
+ items?: Nullable<Array<ComboBoxExtendedItem<T>>>;
9
10
  totalCount?: number;
10
11
  loading?: boolean;
11
12
  maxMenuHeight?: number | string;
@@ -13,7 +14,7 @@ export interface ComboBoxMenuProps<T> {
13
14
  renderNotFound?: () => React.ReactNode;
14
15
  renderTotalCount?: (found: number, total: number) => React.ReactNode;
15
16
  renderItem: (item: T, state: MenuItemState) => React.ReactNode;
16
- itemWrapper?: (item?: T) => React.ComponentType<unknown>;
17
+ itemWrapper?: (item: T) => React.ComponentType<unknown>;
17
18
  onValueChange: (value: T) => any;
18
19
  renderAddButton?: () => React.ReactNode;
19
20
  caption?: React.ReactNode;
@@ -21,6 +22,7 @@ export interface ComboBoxMenuProps<T> {
21
22
  requestStatus?: ComboBoxRequestStatus;
22
23
  isMobile?: boolean;
23
24
  menuId?: string;
25
+ size?: 'small' | 'medium' | 'large';
24
26
  }
25
27
  export declare const ComboBoxMenuDataTids: {
26
28
  readonly loading: "ComboBoxMenu__loading";
@@ -35,7 +37,9 @@ export declare class ComboBoxMenu<T> extends React.Component<ComboBoxMenuProps<T
35
37
  static defaultProps: DefaultProps<unknown>;
36
38
  private getProps;
37
39
  private readonly locale;
38
- render(): JSX.Element | null;
40
+ private theme;
41
+ render(): JSX.Element;
42
+ renderMain(): JSX.Element | null;
39
43
  private renderItem;
40
44
  }
41
45
  export {};
@@ -57,7 +57,8 @@ export var ComboBoxView = responsiveLayout(_class = rootNode(_class = (_temp = _
57
57
  maxMenuHeight = _this$props.maxMenuHeight,
58
58
  renderTotalCount = _this$props.renderTotalCount,
59
59
  renderNotFound = _this$props.renderNotFound,
60
- totalCount = _this$props.totalCount;
60
+ totalCount = _this$props.totalCount,
61
+ size = _this$props.size;
61
62
 
62
63
  var _this$getProps = _this.getProps(),
63
64
  repeatRequest = _this$getProps.repeatRequest,
@@ -81,7 +82,8 @@ export var ComboBoxView = responsiveLayout(_class = rootNode(_class = (_temp = _
81
82
  repeatRequest: repeatRequest,
82
83
  requestStatus: requestStatus,
83
84
  totalCount: totalCount,
84
- isMobile: _this.isMobileLayout
85
+ isMobile: _this.isMobileLayout,
86
+ size: size
85
87
  });
86
88
  };
87
89
 
@@ -307,12 +309,12 @@ export var ComboBoxView = responsiveLayout(_class = rootNode(_class = (_temp = _
307
309
  refInputLikeText = _this$props6.refInputLikeText,
308
310
  leftIcon = _this$props6.leftIcon,
309
311
  inputMode = _this$props6.inputMode,
312
+ size = _this$props6.size,
310
313
  ariaDescribedby = _this$props6['aria-describedby'],
311
314
  ariaLabel = _this$props6['aria-label'];
312
315
 
313
316
  var _this$getProps3 = this.getProps(),
314
- renderValue = _this$getProps3.renderValue,
315
- size = _this$getProps3.size;
317
+ renderValue = _this$getProps3.renderValue;
316
318
 
317
319
  var rightIcon = this.getRightIcon();
318
320
 
@@ -1 +1 @@
1
- {"version":3,"sources":["ComboBoxView.tsx"],"names":["React","getRandomID","isNonNullable","DropdownContainer","Input","InputLikeText","RenderLayer","Spinner","ArrowChevronDownIcon","CommonWrapper","MobilePopup","responsiveLayout","rootNode","getRootNode","createPropsGetter","isTheme2022","ThemeContext","LoadingIcon","ArrowDownIcon","ComboBoxMenu","ComboBoxRequestStatus","styles","CustomComboBoxDataTids","getComboBoxTheme","ComboBoxViewIds","menu","ComboBoxView","getProps","defaultProps","mobileInput","dropdownContainerRef","createRef","menuId","state","isMobileOpened","getComboBoxMenu","props","items","loading","opened","refMenu","maxMenuHeight","renderTotalCount","renderNotFound","totalCount","repeatRequest","requestStatus","renderItem","itemWrapper","handleItemSelect","renderAddButton","isMobileLayout","renderMenu","menuAlign","menuPos","getParent","disablePortal","renderMobileMenu","rightIcon","length","renderSpinner","inputProps","autoFocus","width","onFocus","onValueChange","onInputValueChange","value","textValue","placeholder","refMobileInput","handleCloseMobile","setState","onInputBlur","handleFocusMobile","focus","item","refInput","input","spinnerWrapper","getRightIcon","drawArrow","size","theme","rightIconWrapper","componentDidMount","current","position","componentDidUpdate","prevProps","editing","render","renderMain","onMouseEnter","onMouseLeave","onMouseOver","onClickOutside","onFocusOutside","isMobile","renderInput","comboBoxView","root","setRootNode","align","borderless","disabled","error","onInputFocus","onInputClick","onInputKeyDown","warning","refInputLikeText","leftIcon","inputMode","ariaDescribedby","ariaLabel","renderValue","max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KlF,MAdtB,IAgBG9B,aAAa,CAACiE,KAAD,CAAb,IAAwBiD,WAAxB,GAAsCA,WAAW,CAACjD,KAAD,CAAjD,GAA2D,IAhB9D,CADF,CAoBD,CAjQH,uBAAqCnE,KAAK,CAACuH,SAA3C,WACgBC,mBADhB,GACsC,cADtC,UAGgB5F,YAHhB,GAGsD,EAClDmB,UAAU,EAAE,oBAAC6B,IAAD,UAAeA,IAAf,EADsC,EAElDwC,WAAW,EAAE,qBAACxC,IAAD,UAAeA,IAAf,EAFqC,EAGlD1B,eAAe,EAAE,mCAAM,IAAN,EAHiC,EAIlDL,aAAa,EAAE,iCAAMyE,SAAN,EAJmC,EAKlDxE,aAAa,EAAE1B,qBAAqB,CAACqG,OALa,EAMlDzB,cAAc,EAAE,0BAAM,CACpB,IACD,CARiD,EASlDC,cAAc,EAAE,0BAAM,CACpB,IACD,CAXiD,EAYlDf,IAAI,EAAE,OAZ4C,EAalDnB,KAAK,EAAE,GAb2C,EAHtD","sourcesContent":["import React, { AriaAttributes } from 'react';\n\nimport { getRandomID, isNonNullable } from '../../lib/utils';\nimport { DropdownContainer, DropdownContainerProps } from '../DropdownContainer';\nimport { Input, InputIconType, InputProps } from '../../components/Input';\nimport { InputLikeText } from '../InputLikeText';\nimport { Menu } from '../Menu';\nimport { MenuItemState } from '../../components/MenuItem';\nimport { RenderLayer } from '../RenderLayer';\nimport { Spinner } from '../../components/Spinner';\nimport { Nullable } from '../../typings/utility-types';\nimport { ArrowChevronDownIcon } from '../icons/16px';\nimport { CommonProps, CommonWrapper } from '../../internal/CommonWrapper';\nimport { MobilePopup } from '../MobilePopup';\nimport { responsiveLayout } from '../../components/ResponsiveLayout/decorator';\nimport { rootNode, getRootNode, TSetRootNode } from '../../lib/rootNode';\nimport { createPropsGetter } from '../../lib/createPropsGetter';\nimport { isTheme2022 } from '../../lib/theming/ThemeHelpers';\nimport { ThemeContext } from '../../lib/theming/ThemeContext';\nimport { Theme } from '../../lib/theming/Theme';\nimport { LoadingIcon } from '../icons2022/LoadingIcon';\n\nimport { ArrowDownIcon } from './ArrowDownIcon';\nimport { ComboBoxMenu } from './ComboBoxMenu';\nimport { ComboBoxRequestStatus } from './CustomComboBoxTypes';\nimport { styles } from './CustomComboBox.styles';\nimport { CustomComboBoxDataTids } from './CustomComboBox';\nimport { getComboBoxTheme } from './getComboBoxTheme';\n\ninterface ComboBoxViewProps<T>\n extends Pick<DropdownContainerProps, 'menuPos'>,\n Pick<AriaAttributes, 'aria-describedby' | 'aria-label'>,\n CommonProps {\n align?: 'left' | 'center' | 'right';\n autoFocus?: boolean;\n borderless?: boolean;\n disablePortal?: boolean;\n disabled?: boolean;\n editing?: boolean;\n /**\n * Cостояние валидации при ошибке.\n */\n error?: boolean;\n items?: Nullable<T[]>;\n loading?: boolean;\n menuAlign?: 'left' | 'right';\n opened?: boolean;\n drawArrow?: boolean;\n placeholder?: string;\n size?: 'small' | 'medium' | 'large';\n textValue?: string;\n totalCount?: number;\n value?: Nullable<T>;\n /**\n * Cостояние валидации при предупреждении.\n */\n warning?: boolean;\n width?: string | number;\n maxLength?: number;\n maxMenuHeight?: number | string;\n leftIcon?: InputIconType;\n rightIcon?: InputIconType;\n inputMode?: React.HTMLAttributes<HTMLInputElement>['inputMode'];\n\n onValueChange?: (value: T) => void;\n onClickOutside?: (e: Event) => void;\n onFocus?: () => void;\n onFocusOutside?: () => void;\n onInputBlur?: () => void;\n onInputValueChange?: (value: string) => void;\n onInputFocus?: () => void;\n onInputClick?: () => void;\n onInputKeyDown?: (e: React.KeyboardEvent) => void;\n onMouseEnter?: (e: React.MouseEvent) => void;\n onMouseOver?: (e: React.MouseEvent) => void;\n onMouseLeave?: (e: React.MouseEvent) => void;\n renderItem?: (item: T, state: MenuItemState) => React.ReactNode;\n itemWrapper?: (item?: T) => React.ComponentType<unknown>;\n renderNotFound?: () => React.ReactNode;\n renderTotalCount?: (found: number, total: number) => React.ReactNode;\n renderValue?: (item: T) => React.ReactNode;\n renderAddButton?: (query?: string) => React.ReactNode;\n repeatRequest?: () => void;\n requestStatus?: ComboBoxRequestStatus;\n refInput?: (input: Nullable<Input>) => void;\n refMenu?: (menu: Nullable<Menu>) => void;\n refInputLikeText?: (inputLikeText: Nullable<InputLikeText>) => void;\n}\n\ninterface ComboBoxViewState {\n isMobileOpened: boolean;\n}\n\ntype DefaultProps<T> = Required<\n Pick<\n ComboBoxViewProps<T>,\n | 'renderItem'\n | 'renderValue'\n | 'renderAddButton'\n | 'repeatRequest'\n | 'requestStatus'\n | 'onClickOutside'\n | 'onFocusOutside'\n | 'size'\n | 'width'\n >\n>;\n\nexport const ComboBoxViewIds = {\n menu: 'ComboBoxView__menu',\n};\n\n@responsiveLayout\n@rootNode\nexport class ComboBoxView<T> extends React.Component<ComboBoxViewProps<T>, ComboBoxViewState> {\n public static __KONTUR_REACT_UI__ = 'ComboBoxView';\n\n public static defaultProps: DefaultProps<unknown> = {\n renderItem: (item: any) => item,\n renderValue: (item: any) => item,\n renderAddButton: () => null,\n repeatRequest: () => undefined,\n requestStatus: ComboBoxRequestStatus.Unknown,\n onClickOutside: () => {\n /**/\n },\n onFocusOutside: () => {\n /**/\n },\n size: 'small',\n width: 250,\n };\n\n private getProps = createPropsGetter(ComboBoxView.defaultProps);\n\n private input: Nullable<Input>;\n private setRootNode!: TSetRootNode;\n private mobileInput: Nullable<Input> = null;\n private isMobileLayout!: boolean;\n private dropdownContainerRef = React.createRef<DropdownContainer>();\n private theme!: Theme;\n private menuId = ComboBoxViewIds.menu + getRandomID();\n\n public componentDidMount() {\n if (this.props.autoFocus && this.props.onFocus) {\n this.props.onFocus();\n }\n this.props.opened && this.dropdownContainerRef.current?.position();\n }\n\n public state: ComboBoxViewState = {\n isMobileOpened: false,\n };\n\n public componentDidUpdate(prevProps: ComboBoxViewProps<T>) {\n const { input, props } = this;\n\n if (props.editing && !prevProps.editing && input) {\n input.focus();\n }\n }\n\n public render() {\n return (\n <ThemeContext.Consumer>\n {(theme) => {\n this.theme = getComboBoxTheme(theme);\n return <ThemeContext.Provider value={this.theme}>{this.renderMain()}</ThemeContext.Provider>;\n }}\n </ThemeContext.Consumer>\n );\n }\n\n public renderMain() {\n const { onMouseEnter, onMouseLeave, onMouseOver, opened } = this.props;\n const { onClickOutside, onFocusOutside, width } = this.getProps();\n\n const isMobile = this.isMobileLayout;\n\n const input = this.renderInput();\n\n return (\n <CommonWrapper {...this.props}>\n <RenderLayer onClickOutside={onClickOutside} onFocusOutside={onFocusOutside} active={opened}>\n <span\n data-tid={CustomComboBoxDataTids.comboBoxView}\n style={{ width }}\n className={styles.root()}\n onMouseEnter={onMouseEnter}\n onMouseLeave={onMouseLeave}\n onMouseOver={onMouseOver}\n ref={this.setRootNode}\n >\n {input}\n {isMobile ? this.renderMobileMenu() : this.renderMenu()}\n </span>\n </RenderLayer>\n </CommonWrapper>\n );\n }\n\n private getComboBoxMenu = () => {\n const { items, loading, opened, refMenu, maxMenuHeight, renderTotalCount, renderNotFound, totalCount } = this.props;\n\n const { repeatRequest, requestStatus, renderItem, itemWrapper } = this.getProps();\n return (\n <ComboBoxMenu\n menuId={this.menuId}\n items={items}\n loading={loading}\n maxMenuHeight={maxMenuHeight}\n onValueChange={this.handleItemSelect}\n opened={opened}\n refMenu={refMenu}\n renderTotalCount={renderTotalCount}\n renderItem={renderItem}\n renderNotFound={renderNotFound}\n itemWrapper={itemWrapper}\n renderAddButton={this.renderAddButton}\n repeatRequest={repeatRequest}\n requestStatus={requestStatus}\n totalCount={totalCount}\n isMobile={this.isMobileLayout}\n />\n );\n };\n\n private renderMenu = () => {\n const { menuAlign, opened, menuPos } = this.props;\n\n return (\n opened && (\n <DropdownContainer\n menuPos={menuPos}\n align={menuAlign}\n getParent={this.getParent}\n disablePortal={this.props.disablePortal}\n ref={this.dropdownContainerRef}\n >\n {this.getComboBoxMenu()}\n </DropdownContainer>\n )\n );\n };\n\n private renderMobileMenu = () => {\n let rightIcon = null;\n\n const { loading, items } = this.props;\n if (loading && items && !!items.length) {\n rightIcon = this.renderSpinner();\n }\n\n const inputProps: InputProps = {\n autoFocus: true,\n width: '100%',\n onFocus: this.props.onFocus,\n onValueChange: this.props.onInputValueChange,\n value: this.props.textValue,\n placeholder: this.props.placeholder,\n rightIcon,\n };\n\n return (\n <MobilePopup\n headerChildComponent={<Input ref={this.refMobileInput} {...inputProps} />}\n onCloseRequest={this.handleCloseMobile}\n opened={this.state.isMobileOpened}\n >\n {this.getComboBoxMenu()}\n </MobilePopup>\n );\n };\n\n private handleCloseMobile = () => {\n this.setState({\n isMobileOpened: false,\n });\n\n if (this.props.onInputBlur) {\n this.props.onInputBlur();\n }\n };\n\n private getParent = () => {\n return getRootNode(this);\n };\n\n private renderAddButton = (): React.ReactNode => {\n return this.getProps().renderAddButton(this.props.textValue);\n };\n\n private renderInput(): React.ReactNode {\n const isMobile = this.isMobileLayout;\n\n const {\n align,\n borderless,\n disabled,\n editing,\n error,\n onFocus,\n onInputBlur,\n onInputValueChange,\n onInputFocus,\n onInputClick,\n onInputKeyDown,\n placeholder,\n textValue,\n value,\n warning,\n refInputLikeText,\n leftIcon,\n inputMode,\n 'aria-describedby': ariaDescribedby,\n 'aria-label': ariaLabel,\n } = this.props;\n\n const { renderValue, size } = this.getProps();\n\n const rightIcon = this.getRightIcon();\n\n if (editing) {\n return (\n <Input\n align={align}\n borderless={borderless}\n disabled={disabled}\n error={error}\n maxLength={this.props.maxLength}\n onBlur={isMobile ? undefined : onInputBlur}\n onValueChange={onInputValueChange}\n onFocus={isMobile ? this.handleFocusMobile : onInputFocus}\n onClick={isMobile ? this.handleFocusMobile : onInputClick}\n leftIcon={leftIcon}\n rightIcon={rightIcon}\n value={textValue || ''}\n onKeyDown={onInputKeyDown}\n placeholder={placeholder}\n width=\"100%\"\n size={size}\n ref={this.refInput}\n warning={warning}\n inputMode={inputMode}\n aria-describedby={ariaDescribedby}\n aria-controls={this.menuId}\n aria-label={ariaLabel}\n />\n );\n }\n\n return (\n <InputLikeText\n align={align}\n borderless={borderless}\n error={error}\n onFocus={onFocus}\n leftIcon={leftIcon}\n rightIcon={rightIcon}\n disabled={disabled}\n warning={warning}\n placeholder={placeholder}\n size={size}\n width=\"100%\"\n ref={refInputLikeText}\n aria-describedby={ariaDescribedby}\n aria-controls={this.menuId}\n >\n {isNonNullable(value) && renderValue ? renderValue(value) : null}\n </InputLikeText>\n );\n }\n\n private handleFocusMobile = () => {\n this.setState({\n isMobileOpened: true,\n });\n\n if (this.mobileInput) {\n this.mobileInput.focus();\n }\n };\n\n private handleItemSelect = (item: T) => {\n if (this.props.onValueChange) {\n this.props.onValueChange(item);\n }\n\n if (this.isMobileLayout) {\n this.handleCloseMobile();\n }\n };\n\n private refInput = (input: Nullable<Input>) => {\n if (this.props.refInput) {\n this.props.refInput(input);\n }\n this.input = input;\n };\n\n private renderSpinner = () => (\n <span className={styles.spinnerWrapper()}>\n <Spinner type=\"mini\" caption=\"\" dimmed />\n </span>\n );\n\n private getRightIcon = () => {\n const { loading, items, drawArrow, rightIcon, size } = this.props;\n\n if (loading && items && !!items.length) {\n if (isTheme2022(this.theme)) {\n return <LoadingIcon size={size} />;\n }\n return this.renderSpinner();\n }\n\n if (rightIcon || drawArrow) {\n if (isTheme2022(this.theme)) {\n return rightIcon || <ArrowDownIcon size={size} />;\n }\n return <span className={styles.rightIconWrapper()}>{rightIcon ?? <ArrowChevronDownIcon />}</span>;\n }\n\n return null;\n };\n\n private refMobileInput = (input: Nullable<Input>) => {\n this.mobileInput = input;\n };\n}\n"]}
1
+ {"version":3,"sources":["ComboBoxView.tsx"],"names":["React","getRandomID","isNonNullable","DropdownContainer","Input","InputLikeText","RenderLayer","Spinner","ArrowChevronDownIcon","CommonWrapper","MobilePopup","responsiveLayout","rootNode","getRootNode","createPropsGetter","isTheme2022","ThemeContext","LoadingIcon","ArrowDownIcon","ComboBoxMenu","ComboBoxRequestStatus","styles","CustomComboBoxDataTids","getComboBoxTheme","ComboBoxViewIds","menu","ComboBoxView","getProps","defaultProps","mobileInput","dropdownContainerRef","createRef","menuId","state","isMobileOpened","getComboBoxMenu","props","items","loading","opened","refMenu","maxMenuHeight","renderTotalCount","renderNotFound","totalCount","size","repeatRequest","requestStatus","renderItem","itemWrapper","handleItemSelect","renderAddButton","isMobileLayout","renderMenu","menuAlign","menuPos","getParent","disablePortal","renderMobileMenu","rightIcon","length","renderSpinner","inputProps","autoFocus","width","onFocus","onValueChange","onInputValueChange","value","textValue","placeholder","refMobileInput","handleCloseMobile","setState","onInputBlur","handleFocusMobile","focus","item","refInput","input","spinnerWrapper","getRightIcon","drawArrow","theme","rightIconWrapper","componentDidMount","current","position","componentDidUpdate","prevProps","editing","render","renderMain","onMouseEnter","onMouseLeave","onMouseOver","onClickOutside","onFocusOutside","isMobile","renderInput","comboBoxView","root","setRootNode","align","borderless","disabled","error","onInputFocus","onInputClick","onInputKeyDown","warning","refInputLikeText","leftIcon","inputMode","ariaDescribedby","ariaLabel","renderValue","maxLength","undefined","Component","__KONTUR_REACT_UI__","Unknown"],"mappings":"iPAAA,OAAOA,KAAP,MAAsC,OAAtC;;AAEA,SAASC,WAAT,EAAsBC,aAAtB,QAA2C,iBAA3C;AACA,SAASC,iBAAT,QAA0D,sBAA1D;AACA,SAASC,KAAT,QAAiD,wBAAjD;AACA,SAASC,aAAT,QAA8B,kBAA9B;;;AAGA,SAASC,WAAT,QAA4B,gBAA5B;AACA,SAASC,OAAT,QAAwB,0BAAxB;;AAEA,SAASC,oBAAT,QAAqC,eAArC;AACA,SAAsBC,aAAtB,QAA2C,8BAA3C;AACA,SAASC,WAAT,QAA4B,gBAA5B;AACA,SAASC,gBAAT,QAAiC,6CAAjC;AACA,SAASC,QAAT,EAAmBC,WAAnB,QAAoD,oBAApD;AACA,SAASC,iBAAT,QAAkC,6BAAlC;AACA,SAASC,WAAT,QAA4B,gCAA5B;AACA,SAASC,YAAT,QAA6B,gCAA7B;;AAEA,SAASC,WAAT,QAA4B,0BAA5B;;;AAGA,SAASC,aAAT,QAA8B,iBAA9B;AACA,SAASC,YAAT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b2C,EAHtD","sourcesContent":["import React, { AriaAttributes } from 'react';\n\nimport { getRandomID, isNonNullable } from '../../lib/utils';\nimport { DropdownContainer, DropdownContainerProps } from '../DropdownContainer';\nimport { Input, InputIconType, InputProps } from '../../components/Input';\nimport { InputLikeText } from '../InputLikeText';\nimport { Menu } from '../Menu';\nimport { MenuItemState } from '../../components/MenuItem';\nimport { RenderLayer } from '../RenderLayer';\nimport { Spinner } from '../../components/Spinner';\nimport { Nullable } from '../../typings/utility-types';\nimport { ArrowChevronDownIcon } from '../icons/16px';\nimport { CommonProps, CommonWrapper } from '../../internal/CommonWrapper';\nimport { MobilePopup } from '../MobilePopup';\nimport { responsiveLayout } from '../../components/ResponsiveLayout/decorator';\nimport { rootNode, getRootNode, TSetRootNode } from '../../lib/rootNode';\nimport { createPropsGetter } from '../../lib/createPropsGetter';\nimport { isTheme2022 } from '../../lib/theming/ThemeHelpers';\nimport { ThemeContext } from '../../lib/theming/ThemeContext';\nimport { Theme } from '../../lib/theming/Theme';\nimport { LoadingIcon } from '../icons2022/LoadingIcon';\nimport { ComboBoxExtendedItem } from '../../components/ComboBox';\n\nimport { ArrowDownIcon } from './ArrowDownIcon';\nimport { ComboBoxMenu } from './ComboBoxMenu';\nimport { ComboBoxRequestStatus } from './CustomComboBoxTypes';\nimport { styles } from './CustomComboBox.styles';\nimport { CustomComboBoxDataTids } from './CustomComboBox';\nimport { getComboBoxTheme } from './getComboBoxTheme';\n\ninterface ComboBoxViewProps<T>\n extends Pick<DropdownContainerProps, 'menuPos'>,\n Pick<AriaAttributes, 'aria-describedby' | 'aria-label'>,\n CommonProps {\n align?: 'left' | 'center' | 'right';\n autoFocus?: boolean;\n borderless?: boolean;\n disablePortal?: boolean;\n disabled?: boolean;\n editing?: boolean;\n /**\n * Cостояние валидации при ошибке.\n */\n error?: boolean;\n items?: Nullable<Array<ComboBoxExtendedItem<T>>>;\n loading?: boolean;\n menuAlign?: 'left' | 'right';\n opened?: boolean;\n drawArrow?: boolean;\n placeholder?: string;\n size?: 'small' | 'medium' | 'large';\n textValue?: string;\n totalCount?: number;\n value?: Nullable<T>;\n /**\n * Cостояние валидации при предупреждении.\n */\n warning?: boolean;\n width?: string | number;\n maxLength?: number;\n maxMenuHeight?: number | string;\n leftIcon?: InputIconType;\n rightIcon?: InputIconType;\n inputMode?: React.HTMLAttributes<HTMLInputElement>['inputMode'];\n\n onValueChange?: (value: T) => void;\n onClickOutside?: (e: Event) => void;\n onFocus?: () => void;\n onFocusOutside?: () => void;\n onInputBlur?: () => void;\n onInputValueChange?: (value: string) => void;\n onInputFocus?: () => void;\n onInputClick?: () => void;\n onInputKeyDown?: (e: React.KeyboardEvent) => void;\n onMouseEnter?: (e: React.MouseEvent) => void;\n onMouseOver?: (e: React.MouseEvent) => void;\n onMouseLeave?: (e: React.MouseEvent) => void;\n renderItem?: (item: T, state: MenuItemState) => React.ReactNode;\n itemWrapper?: (item: T) => React.ComponentType<unknown>;\n renderNotFound?: () => React.ReactNode;\n renderTotalCount?: (found: number, total: number) => React.ReactNode;\n renderValue?: (item: T) => React.ReactNode;\n renderAddButton?: (query?: string) => React.ReactNode;\n repeatRequest?: () => void;\n requestStatus?: ComboBoxRequestStatus;\n refInput?: (input: Nullable<Input>) => void;\n refMenu?: (menu: Nullable<Menu>) => void;\n refInputLikeText?: (inputLikeText: Nullable<InputLikeText>) => void;\n}\n\ninterface ComboBoxViewState {\n isMobileOpened: boolean;\n}\n\ntype DefaultProps<T> = Required<\n Pick<\n ComboBoxViewProps<T>,\n | 'renderItem'\n | 'renderValue'\n | 'renderAddButton'\n | 'repeatRequest'\n | 'requestStatus'\n | 'onClickOutside'\n | 'onFocusOutside'\n | 'size'\n | 'width'\n >\n>;\n\nexport const ComboBoxViewIds = {\n menu: 'ComboBoxView__menu',\n};\n\n@responsiveLayout\n@rootNode\nexport class ComboBoxView<T> extends React.Component<ComboBoxViewProps<T>, ComboBoxViewState> {\n public static __KONTUR_REACT_UI__ = 'ComboBoxView';\n\n public static defaultProps: DefaultProps<unknown> = {\n renderItem: (item: any) => item,\n renderValue: (item: any) => item,\n renderAddButton: () => null,\n repeatRequest: () => undefined,\n requestStatus: ComboBoxRequestStatus.Unknown,\n onClickOutside: () => {\n /**/\n },\n onFocusOutside: () => {\n /**/\n },\n size: 'small',\n width: 250,\n };\n\n private getProps = createPropsGetter(ComboBoxView.defaultProps);\n\n private input: Nullable<Input>;\n private setRootNode!: TSetRootNode;\n private mobileInput: Nullable<Input> = null;\n private isMobileLayout!: boolean;\n private dropdownContainerRef = React.createRef<DropdownContainer>();\n private theme!: Theme;\n private menuId = ComboBoxViewIds.menu + getRandomID();\n\n public componentDidMount() {\n if (this.props.autoFocus && this.props.onFocus) {\n this.props.onFocus();\n }\n this.props.opened && this.dropdownContainerRef.current?.position();\n }\n\n public state: ComboBoxViewState = {\n isMobileOpened: false,\n };\n\n public componentDidUpdate(prevProps: ComboBoxViewProps<T>) {\n const { input, props } = this;\n\n if (props.editing && !prevProps.editing && input) {\n input.focus();\n }\n }\n\n public render() {\n return (\n <ThemeContext.Consumer>\n {(theme) => {\n this.theme = getComboBoxTheme(theme);\n return <ThemeContext.Provider value={this.theme}>{this.renderMain()}</ThemeContext.Provider>;\n }}\n </ThemeContext.Consumer>\n );\n }\n\n public renderMain() {\n const { onMouseEnter, onMouseLeave, onMouseOver, opened } = this.props;\n const { onClickOutside, onFocusOutside, width } = this.getProps();\n\n const isMobile = this.isMobileLayout;\n\n const input = this.renderInput();\n\n return (\n <CommonWrapper {...this.props}>\n <RenderLayer onClickOutside={onClickOutside} onFocusOutside={onFocusOutside} active={opened}>\n <span\n data-tid={CustomComboBoxDataTids.comboBoxView}\n style={{ width }}\n className={styles.root()}\n onMouseEnter={onMouseEnter}\n onMouseLeave={onMouseLeave}\n onMouseOver={onMouseOver}\n ref={this.setRootNode}\n >\n {input}\n {isMobile ? this.renderMobileMenu() : this.renderMenu()}\n </span>\n </RenderLayer>\n </CommonWrapper>\n );\n }\n\n private getComboBoxMenu = () => {\n const { items, loading, opened, refMenu, maxMenuHeight, renderTotalCount, renderNotFound, totalCount, size } =\n this.props;\n\n const { repeatRequest, requestStatus, renderItem, itemWrapper } = this.getProps();\n return (\n <ComboBoxMenu\n menuId={this.menuId}\n items={items}\n loading={loading}\n maxMenuHeight={maxMenuHeight}\n onValueChange={this.handleItemSelect}\n opened={opened}\n refMenu={refMenu}\n renderTotalCount={renderTotalCount}\n renderItem={renderItem}\n renderNotFound={renderNotFound}\n itemWrapper={itemWrapper}\n renderAddButton={this.renderAddButton}\n repeatRequest={repeatRequest}\n requestStatus={requestStatus}\n totalCount={totalCount}\n isMobile={this.isMobileLayout}\n size={size}\n />\n );\n };\n\n private renderMenu = () => {\n const { menuAlign, opened, menuPos } = this.props;\n\n return (\n opened && (\n <DropdownContainer\n menuPos={menuPos}\n align={menuAlign}\n getParent={this.getParent}\n disablePortal={this.props.disablePortal}\n ref={this.dropdownContainerRef}\n >\n {this.getComboBoxMenu()}\n </DropdownContainer>\n )\n );\n };\n\n private renderMobileMenu = () => {\n let rightIcon = null;\n\n const { loading, items } = this.props;\n if (loading && items && !!items.length) {\n rightIcon = this.renderSpinner();\n }\n\n const inputProps: InputProps = {\n autoFocus: true,\n width: '100%',\n onFocus: this.props.onFocus,\n onValueChange: this.props.onInputValueChange,\n value: this.props.textValue,\n placeholder: this.props.placeholder,\n rightIcon,\n };\n\n return (\n <MobilePopup\n headerChildComponent={<Input ref={this.refMobileInput} {...inputProps} />}\n onCloseRequest={this.handleCloseMobile}\n opened={this.state.isMobileOpened}\n >\n {this.getComboBoxMenu()}\n </MobilePopup>\n );\n };\n\n private handleCloseMobile = () => {\n this.setState({\n isMobileOpened: false,\n });\n\n if (this.props.onInputBlur) {\n this.props.onInputBlur();\n }\n };\n\n private getParent = () => {\n return getRootNode(this);\n };\n\n private renderAddButton = (): React.ReactNode => {\n return this.getProps().renderAddButton(this.props.textValue);\n };\n\n private renderInput(): React.ReactNode {\n const isMobile = this.isMobileLayout;\n\n const {\n align,\n borderless,\n disabled,\n editing,\n error,\n onFocus,\n onInputBlur,\n onInputValueChange,\n onInputFocus,\n onInputClick,\n onInputKeyDown,\n placeholder,\n textValue,\n value,\n warning,\n refInputLikeText,\n leftIcon,\n inputMode,\n size,\n 'aria-describedby': ariaDescribedby,\n 'aria-label': ariaLabel,\n } = this.props;\n\n const { renderValue } = this.getProps();\n\n const rightIcon = this.getRightIcon();\n\n if (editing) {\n return (\n <Input\n align={align}\n borderless={borderless}\n disabled={disabled}\n error={error}\n maxLength={this.props.maxLength}\n onBlur={isMobile ? undefined : onInputBlur}\n onValueChange={onInputValueChange}\n onFocus={isMobile ? this.handleFocusMobile : onInputFocus}\n onClick={isMobile ? this.handleFocusMobile : onInputClick}\n leftIcon={leftIcon}\n rightIcon={rightIcon}\n value={textValue || ''}\n onKeyDown={onInputKeyDown}\n placeholder={placeholder}\n width=\"100%\"\n size={size}\n ref={this.refInput}\n warning={warning}\n inputMode={inputMode}\n aria-describedby={ariaDescribedby}\n aria-controls={this.menuId}\n aria-label={ariaLabel}\n />\n );\n }\n\n return (\n <InputLikeText\n align={align}\n borderless={borderless}\n error={error}\n onFocus={onFocus}\n leftIcon={leftIcon}\n rightIcon={rightIcon}\n disabled={disabled}\n warning={warning}\n placeholder={placeholder}\n size={size}\n width=\"100%\"\n ref={refInputLikeText}\n aria-describedby={ariaDescribedby}\n aria-controls={this.menuId}\n >\n {isNonNullable(value) && renderValue ? renderValue(value) : null}\n </InputLikeText>\n );\n }\n\n private handleFocusMobile = () => {\n this.setState({\n isMobileOpened: true,\n });\n\n if (this.mobileInput) {\n this.mobileInput.focus();\n }\n };\n\n private handleItemSelect = (item: T) => {\n if (this.props.onValueChange) {\n this.props.onValueChange(item);\n }\n\n if (this.isMobileLayout) {\n this.handleCloseMobile();\n }\n };\n\n private refInput = (input: Nullable<Input>) => {\n if (this.props.refInput) {\n this.props.refInput(input);\n }\n this.input = input;\n };\n\n private renderSpinner = () => (\n <span className={styles.spinnerWrapper()}>\n <Spinner type=\"mini\" caption=\"\" dimmed />\n </span>\n );\n\n private getRightIcon = () => {\n const { loading, items, drawArrow, rightIcon, size } = this.props;\n\n if (loading && items && !!items.length) {\n if (isTheme2022(this.theme)) {\n return <LoadingIcon size={size} />;\n }\n return this.renderSpinner();\n }\n\n if (rightIcon || drawArrow) {\n if (isTheme2022(this.theme)) {\n return rightIcon || <ArrowDownIcon size={size} />;\n }\n return <span className={styles.rightIconWrapper()}>{rightIcon ?? <ArrowChevronDownIcon />}</span>;\n }\n\n return null;\n };\n\n private refMobileInput = (input: Nullable<Input>) => {\n this.mobileInput = input;\n };\n}\n"]}
@@ -6,6 +6,7 @@ import { Menu } from '../Menu';
6
6
  import { MenuItemState } from '../../components/MenuItem';
7
7
  import { Nullable } from '../../typings/utility-types';
8
8
  import { CommonProps } from '../../internal/CommonWrapper';
9
+ import { ComboBoxExtendedItem } from '../../components/ComboBox';
9
10
  import { ComboBoxRequestStatus } from './CustomComboBoxTypes';
10
11
  interface ComboBoxViewProps<T> extends Pick<DropdownContainerProps, 'menuPos'>, Pick<AriaAttributes, 'aria-describedby' | 'aria-label'>, CommonProps {
11
12
  align?: 'left' | 'center' | 'right';
@@ -18,7 +19,7 @@ interface ComboBoxViewProps<T> extends Pick<DropdownContainerProps, 'menuPos'>,
18
19
  * Cостояние валидации при ошибке.
19
20
  */
20
21
  error?: boolean;
21
- items?: Nullable<T[]>;
22
+ items?: Nullable<Array<ComboBoxExtendedItem<T>>>;
22
23
  loading?: boolean;
23
24
  menuAlign?: 'left' | 'right';
24
25
  opened?: boolean;
@@ -51,7 +52,7 @@ interface ComboBoxViewProps<T> extends Pick<DropdownContainerProps, 'menuPos'>,
51
52
  onMouseOver?: (e: React.MouseEvent) => void;
52
53
  onMouseLeave?: (e: React.MouseEvent) => void;
53
54
  renderItem?: (item: T, state: MenuItemState) => React.ReactNode;
54
- itemWrapper?: (item?: T) => React.ComponentType<unknown>;
55
+ itemWrapper?: (item: T) => React.ComponentType<unknown>;
55
56
  renderNotFound?: () => React.ReactNode;
56
57
  renderTotalCount?: (found: number, total: number) => React.ReactNode;
57
58
  renderValue?: (item: T) => React.ReactNode;
@@ -29,7 +29,8 @@ export var DefaultState = {
29
29
  repeatRequest: function repeatRequest() {
30
30
  return undefined;
31
31
  },
32
- requestStatus: ComboBoxRequestStatus.Unknown
32
+ requestStatus: ComboBoxRequestStatus.Unknown,
33
+ size: 'small'
33
34
  };
34
35
  export var CustomComboBoxDataTids = {
35
36
  comboBoxView: 'ComboBoxView__root'
@@ -425,6 +426,7 @@ export var CustomComboBox = responsiveLayout(_class = rootNode(_class = (_temp =
425
426
  }
426
427
  };
427
428
  return /*#__PURE__*/React.createElement(CommonWrapper, this.props, /*#__PURE__*/React.createElement(ComboBoxView, _extends({}, viewProps, {
429
+ size: this.props.size,
428
430
  ref: this.setRootNode
429
431
  })));
430
432
  };
@@ -1 +1 @@
1
- {"version":3,"sources":["CustomComboBox.tsx"],"names":["React","ReactDOM","CancelationError","taskWithDelay","fixClickFocusIE","CommonWrapper","responsiveLayout","rootNode","ComboBoxRequestStatus","reducer","ComboBoxView","DELAY_BEFORE_SHOW_LOADER","LOADER_SHOW_TIME","DefaultState","inputChanged","editing","items","loading","opened","focused","textValue","repeatRequest","undefined","requestStatus","Unknown","CustomComboBoxDataTids","comboBoxView","CustomComboBox","state","requestId","cancelationToken","cancelLoaderDelay","focus","props","disabled","input","inputLikeText","selectInputText","selectAll","blur","handleBlur","dispatch","action","sync","updateState","effects","nextState","setState","stateAndEffect","Array","forEach","handleEffect","version","search","flushSync","effect","getState","getProps","handleValueChange","value","type","keepFocus","isMobileLayout","handleFocus","handleClickOutside","e","close","setTimeout","handleInputBlur","handleInputClick","query","getItems","cancelPromise","Promise","_","reject","expectingId","loaderShowDelay","resolve","cancelLoader","race","code","cancelSearch","open","render","viewProps","align","borderless","disablePortal","error","menuAlign","drawArrow","menuPos","placeholder","size","totalCount","warning","width","maxLength","maxMenuHeight","leftIcon","rightIcon","inputMode","onValueChange","onClickOutside","onFocus","onFocusOutside","onInputBlur","onInputValueChange","onInputFocus","onInputClick","onInputKeyDown","event","persist","onMouseEnter","onMouseOver","onMouseLeave","renderItem","renderNotFound","itemWrapper","renderValue","renderTotalCount","renderAddButton","refInput","refMenu","menu","refInputLikeText","setRootNode","componentDidMount","autoFocus","componentDidUpdate","prevProps","prevState","reset","PureComponent","__KONTUR_REACT_UI__"],"mappings":"0XAAA,OAAOA,KAAP,MAAsC,OAAtC;AACA,OAAOC,QAAP,MAAqB,WAArB;;;;;;;AAOA,SAASC,gBAAT,EAA2BC,aAA3B,QAAgD,iBAAhD;AACA,SAASC,eAAT,QAAgC,kCAAhC;AACA,SAAsBC,aAAtB,QAA2C,8BAA3C;AACA,SAASC,gBAAT,QAAiC,6CAAjC;AACA,SAASC,QAAT,QAAuC,oBAAvC;;;AAGA,SAASC,qBAAT,QAAsC,uBAAtC;AACA,SAAqDC,OAArD,QAAoE,yBAApE;AACA,SAASC,YAAT,QAA6B,gBAA7B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAgEA,OAAO,IAAMC,wBAAwB,GAAG,GAAjC;AACP,OAAO,IAAMC,gBAAgB,GAAG,IAAzB;;AAEP,OAAO,IAAMC,YAAY,GAAG;AAC1BC,EAAAA,YAAY,EAAE,KADY;AAE1BC,EAAAA,OAAO,EAAE,KAFiB;AAG1BC,EAAAA,KAAK,EAAE,IAHmB;AAI1BC,EAAAA,OAAO,EAAE,KAJiB;AAK1BC,EAAAA,MAAM,EAAE,KALkB;AAM1BC,EAAAA,OAAO,EAAE,KANiB;AAO1BC,EAAAA,SAAS,EAAE,EAPe;AAQ1BC,EAAAA,aAAa,EAAE,iCAAMC,SAAN,EARW;AAS1BC,EAAAA,aAAa,EAAEf,qBAAqB,CAACgB,OATX,EAArB;;;AAYP,OAAO,IAAMC,sBAAsB,GAAG;AACpCC,EAAAA,YAAY,EAAE,oBADsB,EAA/B;;;;;A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EmB,IAAI,EAAE,OAAR,EAAd,EAAiC,KAAjC,EACA,IAAI,KAAK3B,KAAL,CAAWgG,SAAf,EAA0B,CACxB,KAAKjG,KAAL,GACD,CACF,CAxNH,QA0NSkG,kBA1NT,GA0NE,4BAA0BC,SAA1B,EAA6DC,SAA7D,EAAgG,CAC9F,IAAIA,SAAS,CAACrH,OAAV,IAAqB,CAAC,KAAKa,KAAL,CAAWb,OAArC,EAA8C,CAC5C,KAAKyB,UAAL,GACD,CACD,KAAKC,QAAL,CAAc,EAAEmB,IAAI,EAAE,WAAR,EAAqBuE,SAAS,EAATA,SAArB,EAAgCC,SAAS,EAATA,SAAhC,EAAd,EAA2D,KAA3D,EACD,CA/NH,CAiOE;AACF;AACA,KAnOA,QAoOSC,KApOT,GAoOE,iBAAe,CACb,KAAK5F,QAAL,CAAc,EAAEmB,IAAI,EAAE,OAAR,EAAd,EACD,CAtOH,yBAAuC5D,KAAK,CAACsI,aAA7C,WACgBC,mBADhB,GACsC,gBADtC","sourcesContent":["import React, { AriaAttributes } from 'react';\nimport ReactDOM from 'react-dom';\n\nimport { Nullable } from '../../typings/utility-types';\nimport { Input, InputIconType } from '../../components/Input';\nimport { Menu } from '../Menu';\nimport { InputLikeText } from '../InputLikeText';\nimport { MenuItemState } from '../../components/MenuItem';\nimport { CancelationError, taskWithDelay } from '../../lib/utils';\nimport { fixClickFocusIE } from '../../lib/events/fixClickFocusIE';\nimport { CommonProps, CommonWrapper } from '../../internal/CommonWrapper';\nimport { responsiveLayout } from '../../components/ResponsiveLayout/decorator';\nimport { rootNode, TSetRootNode } from '../../lib/rootNode';\nimport { DropdownContainerProps } from '../DropdownContainer';\n\nimport { ComboBoxRequestStatus } from './CustomComboBoxTypes';\nimport { CustomComboBoxAction, CustomComboBoxEffect, reducer } from './CustomComboBoxReducer';\nimport { ComboBoxView } from './ComboBoxView';\n\nexport interface CustomComboBoxProps<T>\n extends Pick<DropdownContainerProps, 'menuPos'>,\n Pick<AriaAttributes, 'aria-describedby' | 'aria-label'>,\n CommonProps {\n align?: 'left' | 'center' | 'right';\n autoFocus?: boolean;\n borderless?: boolean;\n disablePortal?: boolean;\n disabled?: boolean;\n /**\n * Cостояние валидации при ошибке.\n */\n error?: boolean;\n maxLength?: number;\n menuAlign?: 'left' | 'right';\n drawArrow?: boolean;\n leftIcon?: InputIconType;\n rightIcon?: InputIconType;\n searchOnFocus?: boolean;\n onValueChange?: (value: T) => void;\n onInputValueChange?: (value: string) => Nullable<string> | void;\n onUnexpectedInput?: (value: string) => void | null | T;\n onFocus?: () => void;\n onBlur?: () => void;\n onMouseEnter?: (e: React.MouseEvent) => void;\n onMouseOver?: (e: React.MouseEvent) => void;\n onMouseLeave?: (e: React.MouseEvent) => void;\n onInputKeyDown?: (e: React.KeyboardEvent<HTMLElement>) => void;\n placeholder?: string;\n size?: 'small' | 'medium' | 'large';\n totalCount?: number;\n value?: Nullable<T>;\n /**\n * Cостояние валидации при предупреждении.\n */\n warning?: boolean;\n width?: string | number;\n maxMenuHeight?: number | string;\n renderNotFound?: () => React.ReactNode;\n renderTotalCount?: (found: number, total: number) => React.ReactNode;\n renderItem: (item: T, state?: MenuItemState) => React.ReactNode;\n itemWrapper?: (item?: T) => React.ComponentType<unknown>;\n renderValue: (value: T) => React.ReactNode;\n renderAddButton?: (query?: string) => React.ReactNode;\n valueToString: (value: T) => string;\n itemToValue: (item: T) => string | number;\n getItems: (query: string) => Promise<T[]>;\n inputMode?: React.HTMLAttributes<HTMLInputElement>['inputMode'];\n}\n\nexport interface CustomComboBoxState<T> {\n editing: boolean;\n loading: boolean;\n opened: boolean;\n textValue: string;\n items: Nullable<T[]>;\n inputChanged: boolean;\n focused: boolean;\n repeatRequest: () => void;\n requestStatus: ComboBoxRequestStatus;\n}\n\nexport const DELAY_BEFORE_SHOW_LOADER = 300;\nexport const LOADER_SHOW_TIME = 1000;\n\nexport const DefaultState = {\n inputChanged: false,\n editing: false,\n items: null,\n loading: false,\n opened: false,\n focused: false,\n textValue: '',\n repeatRequest: () => undefined,\n requestStatus: ComboBoxRequestStatus.Unknown,\n};\n\nexport const CustomComboBoxDataTids = {\n comboBoxView: 'ComboBoxView__root',\n} as const;\n\n@responsiveLayout\n@rootNode\nexport class CustomComboBox<T> extends React.PureComponent<CustomComboBoxProps<T>, CustomComboBoxState<T>> {\n public static __KONTUR_REACT_UI__ = 'CustomComboBox';\n\n public state: CustomComboBoxState<T> = DefaultState;\n public input: Nullable<Input>;\n public menu: Nullable<Menu>;\n public inputLikeText: Nullable<InputLikeText>;\n public requestId = 0;\n public loaderShowDelay: Nullable<Promise<void>>;\n private focused = false;\n private cancelationToken: Nullable<(reason?: Error) => void> = null;\n private isMobileLayout!: boolean;\n\n private reducer = reducer;\n public cancelLoaderDelay: () => void = () => null;\n\n /**\n * @public\n */\n public focus = () => {\n if (this.props.disabled) {\n return;\n }\n\n if (this.input) {\n this.input.focus();\n } else if (this.inputLikeText) {\n this.inputLikeText.focus();\n }\n };\n\n /**\n * @public\n */\n public selectInputText = () => {\n if (this.props.disabled) {\n return;\n }\n if (this.input) {\n this.input.selectAll();\n }\n };\n\n /**\n * @public\n */\n public blur = () => {\n if (this.props.disabled) {\n return;\n }\n\n this.handleBlur();\n };\n private setRootNode!: TSetRootNode;\n\n /**\n * @public\n */\n public async search(query: string = this.state.textValue) {\n const { getItems } = this.props;\n\n const cancelPromise: Promise<never> = new Promise((_, reject) => (this.cancelationToken = reject));\n this.requestId += 1;\n const expectingId = this.requestId;\n\n if (!this.loaderShowDelay) {\n this.loaderShowDelay = new Promise<void>((resolve) => {\n const cancelLoader = taskWithDelay(() => {\n this.dispatch({ type: 'RequestItems' });\n setTimeout(resolve, LOADER_SHOW_TIME);\n }, DELAY_BEFORE_SHOW_LOADER);\n\n cancelPromise.catch(() => cancelLoader());\n\n this.cancelLoaderDelay = () => {\n cancelLoader();\n resolve();\n };\n });\n }\n\n try {\n const items = await Promise.race([getItems(query), cancelPromise]);\n if (this.state.loading) {\n await Promise.race([this.loaderShowDelay, cancelPromise]);\n }\n if (expectingId === this.requestId) {\n this.dispatch({\n type: 'ReceiveItems',\n items,\n });\n }\n } catch (error) {\n if (error && error.code === 'CancelationError') {\n this.dispatch({ type: 'CancelRequest' });\n } else if (expectingId === this.requestId) {\n this.dispatch({\n type: 'RequestFailure',\n repeatRequest: () => {\n this.search(query);\n if (this.input) {\n this.input.focus();\n }\n },\n });\n }\n } finally {\n if (expectingId === this.requestId) {\n if (!this.state.loading) {\n this.cancelLoaderDelay();\n }\n this.cancelationToken = null;\n this.loaderShowDelay = null;\n }\n }\n }\n\n /**\n * @public\n */\n public cancelSearch() {\n if (this.cancelationToken) {\n this.cancelationToken(new CancelationError());\n }\n }\n\n /**\n * @public\n */\n public open() {\n this.dispatch({ type: 'Open' });\n }\n\n /**\n * @public\n */\n public close() {\n this.dispatch({ type: 'Close' });\n }\n\n public render() {\n const viewProps = {\n align: this.props.align,\n borderless: this.props.borderless,\n disabled: this.props.disabled,\n disablePortal: this.props.disablePortal,\n editing: this.state.editing,\n error: this.props.error,\n items: this.state.items,\n loading: this.state.loading,\n menuAlign: this.props.menuAlign,\n opened: this.state.opened,\n drawArrow: this.props.drawArrow,\n menuPos: this.props.menuPos,\n placeholder: this.props.placeholder,\n size: this.props.size,\n textValue: this.state.textValue,\n totalCount: this.props.totalCount,\n value: this.props.value,\n warning: this.props.warning,\n 'aria-describedby': this.props['aria-describedby'],\n 'aria-label': this.props['aria-label'],\n width: this.props.width,\n maxLength: this.props.maxLength,\n maxMenuHeight: this.props.maxMenuHeight,\n leftIcon: this.props.leftIcon,\n rightIcon: this.props.rightIcon,\n inputMode: this.props.inputMode,\n\n onValueChange: this.handleValueChange,\n onClickOutside: this.handleClickOutside,\n onFocus: this.handleFocus,\n onFocusOutside: this.handleBlur,\n onInputBlur: this.handleInputBlur,\n onInputValueChange: (value: string) => this.dispatch({ type: 'TextChange', value }),\n onInputFocus: this.handleFocus,\n onInputClick: this.handleInputClick,\n onInputKeyDown: (event: React.KeyboardEvent) => {\n event.persist();\n this.dispatch({ type: 'KeyPress', event });\n },\n onMouseEnter: this.props.onMouseEnter,\n onMouseOver: this.props.onMouseOver,\n onMouseLeave: this.props.onMouseLeave,\n renderItem: this.props.renderItem,\n renderNotFound: this.props.renderNotFound,\n itemWrapper: this.props.itemWrapper,\n renderValue: this.props.renderValue,\n renderTotalCount: this.props.renderTotalCount,\n renderAddButton: this.props.renderAddButton,\n repeatRequest: this.state.repeatRequest,\n requestStatus: this.state.requestStatus,\n\n refInput: (input: Nullable<Input>) => {\n this.input = input;\n },\n refMenu: (menu: Nullable<Menu>) => {\n this.menu = menu;\n },\n refInputLikeText: (inputLikeText: Nullable<InputLikeText>) => {\n this.inputLikeText = inputLikeText;\n },\n };\n\n return (\n <CommonWrapper {...this.props}>\n <ComboBoxView {...viewProps} ref={this.setRootNode} />\n </CommonWrapper>\n );\n }\n\n public componentDidMount() {\n this.dispatch({ type: 'Mount' }, false);\n if (this.props.autoFocus) {\n this.focus();\n }\n }\n\n public componentDidUpdate(prevProps: CustomComboBoxProps<T>, prevState: CustomComboBoxState<T>) {\n if (prevState.editing && !this.state.editing) {\n this.handleBlur();\n }\n this.dispatch({ type: 'DidUpdate', prevProps, prevState }, false);\n }\n\n /**\n * @public\n */\n public reset() {\n this.dispatch({ type: 'Reset' });\n }\n\n private dispatch = (action: CustomComboBoxAction<T>, sync = true) => {\n const updateState = (action: CustomComboBoxAction<T>) => {\n let effects: Array<CustomComboBoxEffect<T>>;\n let nextState: Pick<CustomComboBoxState<T>, never>;\n\n this.setState(\n (state) => {\n const stateAndEffect = this.reducer(state, this.props, action);\n [nextState, effects] = stateAndEffect instanceof Array ? stateAndEffect : [stateAndEffect, []];\n return nextState;\n },\n () => {\n effects.forEach(this.handleEffect);\n },\n );\n };\n\n // Auto-batching React@18 creates problems that are fixed with flushSync\n // https://github.com/skbkontur/retail-ui/pull/3144#issuecomment-1535235366\n if (sync && React.version.search('18') === 0) {\n ReactDOM.flushSync(() => updateState(action));\n } else {\n updateState(action);\n }\n };\n\n private handleEffect = (effect: CustomComboBoxEffect<T>) => {\n effect(this.dispatch, this.getState, this.getProps, () => this);\n };\n\n private getProps = () => this.props;\n\n private getState = () => this.state;\n\n private handleValueChange = (value: T) => {\n this.dispatch({\n type: 'ValueChange',\n value,\n keepFocus: !this.isMobileLayout,\n });\n };\n\n private handleFocus = () => {\n if (this.focused) {\n return;\n }\n this.focused = true;\n this.dispatch({ type: 'Focus' });\n };\n\n private handleClickOutside = (e: Event) => {\n fixClickFocusIE(e);\n this.handleBlur();\n };\n\n private handleBlur = () => {\n if (!this.focused) {\n if (this.state.opened) {\n this.close();\n }\n return;\n }\n\n this.focused = false;\n // workaround for the similar bug with focusout\n // in Firefox, Chrome and IE\n // https://bugzilla.mozilla.org/show_bug.cgi?id=1363964\n setTimeout(() => {\n this.dispatch({ type: 'Blur' });\n });\n };\n\n private handleInputBlur = () => {\n // If menu opened, RenderLayer is active and\n // it would call handleFocusOutside\n // In that way handleBlur would be called\n\n // TODO: add check for mobile layout, to call `handleBlur`\n\n if (this.state.opened) {\n return;\n }\n this.handleBlur();\n };\n\n private handleInputClick = () => {\n if (!this.cancelationToken) {\n this.dispatch({ type: 'InputClick' });\n }\n };\n}\n"]}
1
+ {"version":3,"sources":["CustomComboBox.tsx"],"names":["React","ReactDOM","CancelationError","taskWithDelay","fixClickFocusIE","CommonWrapper","responsiveLayout","rootNode","ComboBoxRequestStatus","reducer","ComboBoxView","DELAY_BEFORE_SHOW_LOADER","LOADER_SHOW_TIME","DefaultState","inputChanged","editing","items","loading","opened","focused","textValue","repeatRequest","undefined","requestStatus","Unknown","size","CustomComboBoxDataTids","comboBoxView","CustomComboBox","state","requestId","cancelationToken","cancelLoaderDelay","focus","props","disabled","input","inputLikeText","selectInputText","selectAll","blur","handleBlur","dispatch","action","sync","updateState","effects","nextState","setState","stateAndEffect","Array","forEach","handleEffect","version","search","flushSync","effect","getState","getProps","handleValueChange","value","type","keepFocus","isMobileLayout","handleFocus","handleClickOutside","e","close","setTimeout","handleInputBlur","handleInputClick","query","getItems","cancelPromise","Promise","_","reject","expectingId","loaderShowDelay","resolve","cancelLoader","race","code","cancelSearch","open","render","viewProps","align","borderless","disablePortal","error","menuAlign","drawArrow","menuPos","placeholder","totalCount","warning","width","maxLength","maxMenuHeight","leftIcon","rightIcon","inputMode","onValueChange","onClickOutside","onFocus","onFocusOutside","onInputBlur","onInputValueChange","onInputFocus","onInputClick","onInputKeyDown","event","persist","onMouseEnter","onMouseOver","onMouseLeave","renderItem","renderNotFound","itemWrapper","renderValue","renderTotalCount","renderAddButton","refInput","refMenu","menu","refInputLikeText","setRootNode","componentDidMount","autoFocus","componentDidUpdate","prevProps","prevState","reset","PureComponent","__KONTUR_REACT_UI__"],"mappings":"0XAAA,OAAOA,KAAP,MAAsC,OAAtC;AACA,OAAOC,QAAP,MAAqB,WAArB;;;;;;;AAOA,SAASC,gBAAT,EAA2BC,aAA3B,QAAgD,iBAAhD;AACA,SAASC,eAAT,QAAgC,kCAAhC;AACA,SAAsBC,aAAtB,QAA2C,8BAA3C;AACA,SAASC,gBAAT,QAAiC,6CAAjC;AACA,SAASC,QAAT,QAAuC,oBAAvC;;;;AAIA,SAASC,qBAAT,QAAsC,uBAAtC;AACA,SAAqDC,OAArD,QAAoE,yBAApE;AACA,SAASC,YAAT,QAA6B,gBAA7B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAgEA,OAAO,IAAMC,wBAAwB,GAAG,GAAjC;AACP,OAAO,IAAMC,gBAAgB,GAAG,IAAzB;;AAEP,OAAO,IAAMC,YAAY,GAAG;AAC1BC,EAAAA,YAAY,EAAE,KADY;AAE1BC,EAAAA,OAAO,EAAE,KAFiB;AAG1BC,EAAAA,KAAK,EAAE,IAHmB;AAI1BC,EAAAA,OAAO,EAAE,KAJiB;AAK1BC,EAAAA,MAAM,EAAE,KALkB;AAM1BC,EAAAA,OAAO,EAAE,KANiB;AA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D,MAAI,CAACA,aAAL,GAAqBA,aAArB,CACD,CA5De,EAAlB,CA+DA,oBACE,oBAAC,aAAD,EAAmB,KAAKH,KAAxB,eACE,oBAAC,YAAD,eAAkBoD,SAAlB,IAA6B,IAAI,EAAE,KAAKpD,KAAL,CAAWT,IAA9C,EAAoD,GAAG,EAAE,KAAKsG,WAA9D,IADF,CADF,CAKD,CAjNH,QAmNSC,iBAnNT,GAmNE,6BAA2B,CACzB,KAAKtF,QAAL,CAAc,EAAEmB,IAAI,EAAE,OAAR,EAAd,EAAiC,KAAjC,EACA,IAAI,KAAK3B,KAAL,CAAW+F,SAAf,EAA0B,CACxB,KAAKhG,KAAL,GACD,CACF,CAxNH,QA0NSiG,kBA1NT,GA0NE,4BAA0BC,SAA1B,EAA6DC,SAA7D,EAAgG,CAC9F,IAAIA,SAAS,CAACrH,OAAV,IAAqB,CAAC,KAAKc,KAAL,CAAWd,OAArC,EAA8C,CAC5C,KAAK0B,UAAL,GACD,CACD,KAAKC,QAAL,CAAc,EAAEmB,IAAI,EAAE,WAAR,EAAqBsE,SAAS,EAATA,SAArB,EAAgCC,SAAS,EAATA,SAAhC,EAAd,EAA2D,KAA3D,EACD,CA/NH,CAiOE;AACF;AACA,KAnOA,QAoOSC,KApOT,GAoOE,iBAAe,CACb,KAAK3F,QAAL,CAAc,EAAEmB,IAAI,EAAE,OAAR,EAAd,EACD,CAtOH,yBAAuC7D,KAAK,CAACsI,aAA7C,WACgBC,mBADhB,GACsC,gBADtC","sourcesContent":["import React, { AriaAttributes } from 'react';\nimport ReactDOM from 'react-dom';\n\nimport { Nullable } from '../../typings/utility-types';\nimport { Input, InputIconType } from '../../components/Input';\nimport { Menu } from '../Menu';\nimport { InputLikeText } from '../InputLikeText';\nimport { MenuItemState } from '../../components/MenuItem';\nimport { CancelationError, taskWithDelay } from '../../lib/utils';\nimport { fixClickFocusIE } from '../../lib/events/fixClickFocusIE';\nimport { CommonProps, CommonWrapper } from '../../internal/CommonWrapper';\nimport { responsiveLayout } from '../../components/ResponsiveLayout/decorator';\nimport { rootNode, TSetRootNode } from '../../lib/rootNode';\nimport { DropdownContainerProps } from '../DropdownContainer';\nimport { ComboBoxExtendedItem } from '../../components/ComboBox';\n\nimport { ComboBoxRequestStatus } from './CustomComboBoxTypes';\nimport { CustomComboBoxAction, CustomComboBoxEffect, reducer } from './CustomComboBoxReducer';\nimport { ComboBoxView } from './ComboBoxView';\n\nexport interface CustomComboBoxProps<T>\n extends Pick<DropdownContainerProps, 'menuPos'>,\n Pick<AriaAttributes, 'aria-describedby' | 'aria-label'>,\n CommonProps {\n align?: 'left' | 'center' | 'right';\n autoFocus?: boolean;\n borderless?: boolean;\n disablePortal?: boolean;\n disabled?: boolean;\n /**\n * Cостояние валидации при ошибке.\n */\n error?: boolean;\n maxLength?: number;\n menuAlign?: 'left' | 'right';\n drawArrow?: boolean;\n leftIcon?: InputIconType;\n rightIcon?: InputIconType;\n searchOnFocus?: boolean;\n onValueChange?: (value: T) => void;\n onInputValueChange?: (value: string) => Nullable<string> | void;\n onUnexpectedInput?: (value: string) => void | null | T;\n onFocus?: () => void;\n onBlur?: () => void;\n onMouseEnter?: (e: React.MouseEvent) => void;\n onMouseOver?: (e: React.MouseEvent) => void;\n onMouseLeave?: (e: React.MouseEvent) => void;\n onInputKeyDown?: (e: React.KeyboardEvent<HTMLElement>) => void;\n placeholder?: string;\n size?: 'small' | 'medium' | 'large';\n totalCount?: number;\n value?: Nullable<T>;\n /**\n * Cостояние валидации при предупреждении.\n */\n warning?: boolean;\n width?: string | number;\n maxMenuHeight?: number | string;\n renderNotFound?: () => React.ReactNode;\n renderTotalCount?: (found: number, total: number) => React.ReactNode;\n renderItem: (item: T, state?: MenuItemState) => React.ReactNode;\n itemWrapper?: (item: T) => React.ComponentType<unknown>;\n renderValue: (value: T) => React.ReactNode;\n renderAddButton?: (query?: string) => React.ReactNode;\n valueToString: (value: T) => string;\n itemToValue: (item: T) => string | number;\n getItems: (query: string) => Promise<Array<ComboBoxExtendedItem<T>>>;\n inputMode?: React.HTMLAttributes<HTMLInputElement>['inputMode'];\n}\n\nexport interface CustomComboBoxState<T> {\n editing: boolean;\n loading: boolean;\n opened: boolean;\n textValue: string;\n items: Nullable<Array<ComboBoxExtendedItem<T>>>;\n inputChanged: boolean;\n focused: boolean;\n repeatRequest: () => void;\n requestStatus: ComboBoxRequestStatus;\n}\n\nexport const DELAY_BEFORE_SHOW_LOADER = 300;\nexport const LOADER_SHOW_TIME = 1000;\n\nexport const DefaultState = {\n inputChanged: false,\n editing: false,\n items: null,\n loading: false,\n opened: false,\n focused: false,\n textValue: '',\n repeatRequest: () => undefined,\n requestStatus: ComboBoxRequestStatus.Unknown,\n size: 'small',\n};\n\nexport const CustomComboBoxDataTids = {\n comboBoxView: 'ComboBoxView__root',\n} as const;\n\n@responsiveLayout\n@rootNode\nexport class CustomComboBox<T> extends React.PureComponent<CustomComboBoxProps<T>, CustomComboBoxState<T>> {\n public static __KONTUR_REACT_UI__ = 'CustomComboBox';\n\n public state: CustomComboBoxState<T> = DefaultState;\n public input: Nullable<Input>;\n public menu: Nullable<Menu>;\n public inputLikeText: Nullable<InputLikeText>;\n public requestId = 0;\n public loaderShowDelay: Nullable<Promise<void>>;\n private focused = false;\n private cancelationToken: Nullable<(reason?: Error) => void> = null;\n private isMobileLayout!: boolean;\n\n private reducer = reducer;\n public cancelLoaderDelay: () => void = () => null;\n\n /**\n * @public\n */\n public focus = () => {\n if (this.props.disabled) {\n return;\n }\n\n if (this.input) {\n this.input.focus();\n } else if (this.inputLikeText) {\n this.inputLikeText.focus();\n }\n };\n\n /**\n * @public\n */\n public selectInputText = () => {\n if (this.props.disabled) {\n return;\n }\n if (this.input) {\n this.input.selectAll();\n }\n };\n\n /**\n * @public\n */\n public blur = () => {\n if (this.props.disabled) {\n return;\n }\n\n this.handleBlur();\n };\n private setRootNode!: TSetRootNode;\n\n /**\n * @public\n */\n public async search(query: string = this.state.textValue) {\n const { getItems } = this.props;\n\n const cancelPromise: Promise<never> = new Promise((_, reject) => (this.cancelationToken = reject));\n this.requestId += 1;\n const expectingId = this.requestId;\n\n if (!this.loaderShowDelay) {\n this.loaderShowDelay = new Promise<void>((resolve) => {\n const cancelLoader = taskWithDelay(() => {\n this.dispatch({ type: 'RequestItems' });\n setTimeout(resolve, LOADER_SHOW_TIME);\n }, DELAY_BEFORE_SHOW_LOADER);\n\n cancelPromise.catch(() => cancelLoader());\n\n this.cancelLoaderDelay = () => {\n cancelLoader();\n resolve();\n };\n });\n }\n\n try {\n const items = await Promise.race([getItems(query), cancelPromise]);\n if (this.state.loading) {\n await Promise.race([this.loaderShowDelay, cancelPromise]);\n }\n if (expectingId === this.requestId) {\n this.dispatch({\n type: 'ReceiveItems',\n items,\n });\n }\n } catch (error) {\n if (error && error.code === 'CancelationError') {\n this.dispatch({ type: 'CancelRequest' });\n } else if (expectingId === this.requestId) {\n this.dispatch({\n type: 'RequestFailure',\n repeatRequest: () => {\n this.search(query);\n if (this.input) {\n this.input.focus();\n }\n },\n });\n }\n } finally {\n if (expectingId === this.requestId) {\n if (!this.state.loading) {\n this.cancelLoaderDelay();\n }\n this.cancelationToken = null;\n this.loaderShowDelay = null;\n }\n }\n }\n\n /**\n * @public\n */\n public cancelSearch() {\n if (this.cancelationToken) {\n this.cancelationToken(new CancelationError());\n }\n }\n\n /**\n * @public\n */\n public open() {\n this.dispatch({ type: 'Open' });\n }\n\n /**\n * @public\n */\n public close() {\n this.dispatch({ type: 'Close' });\n }\n\n public render() {\n const viewProps = {\n align: this.props.align,\n borderless: this.props.borderless,\n disabled: this.props.disabled,\n disablePortal: this.props.disablePortal,\n editing: this.state.editing,\n error: this.props.error,\n items: this.state.items,\n loading: this.state.loading,\n menuAlign: this.props.menuAlign,\n opened: this.state.opened,\n drawArrow: this.props.drawArrow,\n menuPos: this.props.menuPos,\n placeholder: this.props.placeholder,\n size: this.props.size,\n textValue: this.state.textValue,\n totalCount: this.props.totalCount,\n value: this.props.value,\n warning: this.props.warning,\n 'aria-describedby': this.props['aria-describedby'],\n 'aria-label': this.props['aria-label'],\n width: this.props.width,\n maxLength: this.props.maxLength,\n maxMenuHeight: this.props.maxMenuHeight,\n leftIcon: this.props.leftIcon,\n rightIcon: this.props.rightIcon,\n inputMode: this.props.inputMode,\n\n onValueChange: this.handleValueChange,\n onClickOutside: this.handleClickOutside,\n onFocus: this.handleFocus,\n onFocusOutside: this.handleBlur,\n onInputBlur: this.handleInputBlur,\n onInputValueChange: (value: string) => this.dispatch({ type: 'TextChange', value }),\n onInputFocus: this.handleFocus,\n onInputClick: this.handleInputClick,\n onInputKeyDown: (event: React.KeyboardEvent) => {\n event.persist();\n this.dispatch({ type: 'KeyPress', event });\n },\n onMouseEnter: this.props.onMouseEnter,\n onMouseOver: this.props.onMouseOver,\n onMouseLeave: this.props.onMouseLeave,\n renderItem: this.props.renderItem,\n renderNotFound: this.props.renderNotFound,\n itemWrapper: this.props.itemWrapper,\n renderValue: this.props.renderValue,\n renderTotalCount: this.props.renderTotalCount,\n renderAddButton: this.props.renderAddButton,\n repeatRequest: this.state.repeatRequest,\n requestStatus: this.state.requestStatus,\n\n refInput: (input: Nullable<Input>) => {\n this.input = input;\n },\n refMenu: (menu: Nullable<Menu>) => {\n this.menu = menu;\n },\n refInputLikeText: (inputLikeText: Nullable<InputLikeText>) => {\n this.inputLikeText = inputLikeText;\n },\n };\n\n return (\n <CommonWrapper {...this.props}>\n <ComboBoxView {...viewProps} size={this.props.size} ref={this.setRootNode} />\n </CommonWrapper>\n );\n }\n\n public componentDidMount() {\n this.dispatch({ type: 'Mount' }, false);\n if (this.props.autoFocus) {\n this.focus();\n }\n }\n\n public componentDidUpdate(prevProps: CustomComboBoxProps<T>, prevState: CustomComboBoxState<T>) {\n if (prevState.editing && !this.state.editing) {\n this.handleBlur();\n }\n this.dispatch({ type: 'DidUpdate', prevProps, prevState }, false);\n }\n\n /**\n * @public\n */\n public reset() {\n this.dispatch({ type: 'Reset' });\n }\n\n private dispatch = (action: CustomComboBoxAction<T>, sync = true) => {\n const updateState = (action: CustomComboBoxAction<T>) => {\n let effects: Array<CustomComboBoxEffect<T>>;\n let nextState: Pick<CustomComboBoxState<T>, never>;\n\n this.setState(\n (state) => {\n const stateAndEffect = this.reducer(state, this.props, action);\n [nextState, effects] = stateAndEffect instanceof Array ? stateAndEffect : [stateAndEffect, []];\n return nextState;\n },\n () => {\n effects.forEach(this.handleEffect);\n },\n );\n };\n\n // Auto-batching React@18 creates problems that are fixed with flushSync\n // https://github.com/skbkontur/retail-ui/pull/3144#issuecomment-1535235366\n if (sync && React.version.search('18') === 0) {\n ReactDOM.flushSync(() => updateState(action));\n } else {\n updateState(action);\n }\n };\n\n private handleEffect = (effect: CustomComboBoxEffect<T>) => {\n effect(this.dispatch, this.getState, this.getProps, () => this);\n };\n\n private getProps = () => this.props;\n\n private getState = () => this.state;\n\n private handleValueChange = (value: T) => {\n this.dispatch({\n type: 'ValueChange',\n value,\n keepFocus: !this.isMobileLayout,\n });\n };\n\n private handleFocus = () => {\n if (this.focused) {\n return;\n }\n this.focused = true;\n this.dispatch({ type: 'Focus' });\n };\n\n private handleClickOutside = (e: Event) => {\n fixClickFocusIE(e);\n this.handleBlur();\n };\n\n private handleBlur = () => {\n if (!this.focused) {\n if (this.state.opened) {\n this.close();\n }\n return;\n }\n\n this.focused = false;\n // workaround for the similar bug with focusout\n // in Firefox, Chrome and IE\n // https://bugzilla.mozilla.org/show_bug.cgi?id=1363964\n setTimeout(() => {\n this.dispatch({ type: 'Blur' });\n });\n };\n\n private handleInputBlur = () => {\n // If menu opened, RenderLayer is active and\n // it would call handleFocusOutside\n // In that way handleBlur would be called\n\n // TODO: add check for mobile layout, to call `handleBlur`\n\n if (this.state.opened) {\n return;\n }\n this.handleBlur();\n };\n\n private handleInputClick = () => {\n if (!this.cancelationToken) {\n this.dispatch({ type: 'InputClick' });\n }\n };\n}\n"]}
@@ -6,6 +6,7 @@ import { InputLikeText } from '../InputLikeText';
6
6
  import { MenuItemState } from '../../components/MenuItem';
7
7
  import { CommonProps } from '../../internal/CommonWrapper';
8
8
  import { DropdownContainerProps } from '../DropdownContainer';
9
+ import { ComboBoxExtendedItem } from '../../components/ComboBox';
9
10
  import { ComboBoxRequestStatus } from './CustomComboBoxTypes';
10
11
  export interface CustomComboBoxProps<T> extends Pick<DropdownContainerProps, 'menuPos'>, Pick<AriaAttributes, 'aria-describedby' | 'aria-label'>, CommonProps {
11
12
  align?: 'left' | 'center' | 'right';
@@ -45,12 +46,12 @@ export interface CustomComboBoxProps<T> extends Pick<DropdownContainerProps, 'me
45
46
  renderNotFound?: () => React.ReactNode;
46
47
  renderTotalCount?: (found: number, total: number) => React.ReactNode;
47
48
  renderItem: (item: T, state?: MenuItemState) => React.ReactNode;
48
- itemWrapper?: (item?: T) => React.ComponentType<unknown>;
49
+ itemWrapper?: (item: T) => React.ComponentType<unknown>;
49
50
  renderValue: (value: T) => React.ReactNode;
50
51
  renderAddButton?: (query?: string) => React.ReactNode;
51
52
  valueToString: (value: T) => string;
52
53
  itemToValue: (item: T) => string | number;
53
- getItems: (query: string) => Promise<T[]>;
54
+ getItems: (query: string) => Promise<Array<ComboBoxExtendedItem<T>>>;
54
55
  inputMode?: React.HTMLAttributes<HTMLInputElement>['inputMode'];
55
56
  }
56
57
  export interface CustomComboBoxState<T> {
@@ -58,7 +59,7 @@ export interface CustomComboBoxState<T> {
58
59
  loading: boolean;
59
60
  opened: boolean;
60
61
  textValue: string;
61
- items: Nullable<T[]>;
62
+ items: Nullable<Array<ComboBoxExtendedItem<T>>>;
62
63
  inputChanged: boolean;
63
64
  focused: boolean;
64
65
  repeatRequest: () => void;
@@ -76,6 +77,7 @@ export declare const DefaultState: {
76
77
  textValue: string;
77
78
  repeatRequest: () => undefined;
78
79
  requestStatus: ComboBoxRequestStatus;
80
+ size: string;
79
81
  };
80
82
  export declare const CustomComboBoxDataTids: {
81
83
  readonly comboBoxView: "ComboBoxView__root";