primereact 10.0.0 → 10.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (319) hide show
  1. package/README.md +1 -1
  2. package/componentbase/componentbase.cjs.js +12 -7
  3. package/componentbase/componentbase.cjs.min.js +1 -1
  4. package/componentbase/componentbase.esm.min.mjs +1 -1
  5. package/componentbase/componentbase.esm.mjs +12 -7
  6. package/componentbase/componentbase.js +12 -7
  7. package/componentbase/componentbase.min.js +1 -1
  8. package/core/core.js +12 -7
  9. package/core/core.min.js +1 -1
  10. package/package.json +1 -1
  11. package/primereact.all.cjs.js +12 -7
  12. package/primereact.all.cjs.min.js +1 -1
  13. package/primereact.all.esm.min.mjs +1 -1
  14. package/primereact.all.esm.mjs +12 -7
  15. package/primereact.all.js +12 -7
  16. package/primereact.all.min.js +1 -1
  17. package/web-types.json +1 -1
  18. package/accordion/accordion.esm.js +0 -421
  19. package/accordion/accordion.esm.min.js +0 -1
  20. package/api/api.esm.js +0 -944
  21. package/api/api.esm.min.js +0 -1
  22. package/autocomplete/autocomplete.esm.js +0 -1127
  23. package/autocomplete/autocomplete.esm.min.js +0 -1
  24. package/avatar/avatar.esm.js +0 -245
  25. package/avatar/avatar.esm.min.js +0 -1
  26. package/avatargroup/avatargroup.esm.js +0 -55
  27. package/avatargroup/avatargroup.esm.min.js +0 -1
  28. package/badge/badge.esm.js +0 -110
  29. package/badge/badge.esm.min.js +0 -1
  30. package/blockui/blockui.esm.js +0 -265
  31. package/blockui/blockui.esm.min.js +0 -1
  32. package/breadcrumb/breadcrumb.esm.js +0 -351
  33. package/breadcrumb/breadcrumb.esm.min.js +0 -1
  34. package/button/button.esm.js +0 -295
  35. package/button/button.esm.min.js +0 -1
  36. package/calendar/calendar.esm.js +0 -3473
  37. package/calendar/calendar.esm.min.js +0 -1
  38. package/card/card.esm.js +0 -98
  39. package/card/card.esm.min.js +0 -1
  40. package/carousel/carousel.esm.js +0 -801
  41. package/carousel/carousel.esm.min.js +0 -1
  42. package/cascadeselect/cascadeselect.esm.js +0 -819
  43. package/cascadeselect/cascadeselect.esm.min.js +0 -1
  44. package/chart/chart.esm.js +0 -155
  45. package/chart/chart.esm.min.js +0 -1
  46. package/checkbox/checkbox.esm.js +0 -357
  47. package/checkbox/checkbox.esm.min.js +0 -1
  48. package/chip/chip.esm.js +0 -248
  49. package/chip/chip.esm.min.js +0 -1
  50. package/chips/chips.esm.js +0 -501
  51. package/chips/chips.esm.min.js +0 -1
  52. package/colorpicker/colorpicker.esm.js +0 -788
  53. package/colorpicker/colorpicker.esm.min.js +0 -1
  54. package/column/column.esm.js +0 -8
  55. package/column/column.esm.min.js +0 -1
  56. package/columngroup/columngroup.esm.js +0 -6
  57. package/columngroup/columngroup.esm.min.js +0 -1
  58. package/componentbase/componentbase.esm.js +0 -323
  59. package/componentbase/componentbase.esm.min.js +0 -1
  60. package/confirmdialog/confirmdialog.esm.js +0 -376
  61. package/confirmdialog/confirmdialog.esm.min.js +0 -1
  62. package/confirmpopup/confirmpopup.esm.js +0 -610
  63. package/confirmpopup/confirmpopup.esm.min.js +0 -1
  64. package/contextmenu/contextmenu.esm.js +0 -664
  65. package/contextmenu/contextmenu.esm.min.js +0 -1
  66. package/csstransition/csstransition.esm.js +0 -138
  67. package/csstransition/csstransition.esm.min.js +0 -1
  68. package/datascroller/datascroller.esm.js +0 -320
  69. package/datascroller/datascroller.esm.min.js +0 -1
  70. package/datatable/datatable.esm.js +0 -6636
  71. package/datatable/datatable.esm.min.js +0 -1
  72. package/dataview/dataview.esm.js +0 -506
  73. package/dataview/dataview.esm.min.js +0 -1
  74. package/deferredcontent/deferredcontent.esm.js +0 -133
  75. package/deferredcontent/deferredcontent.esm.min.js +0 -1
  76. package/dialog/dialog.esm.js +0 -983
  77. package/dialog/dialog.esm.min.js +0 -1
  78. package/divider/divider.esm.js +0 -79
  79. package/divider/divider.esm.min.js +0 -1
  80. package/dock/dock.esm.js +0 -348
  81. package/dock/dock.esm.min.js +0 -1
  82. package/dropdown/dropdown.esm.js +0 -1380
  83. package/dropdown/dropdown.esm.min.js +0 -1
  84. package/editor/editor.esm.js +0 -338
  85. package/editor/editor.esm.min.js +0 -1
  86. package/fieldset/fieldset.esm.js +0 -270
  87. package/fieldset/fieldset.esm.min.js +0 -1
  88. package/fileupload/fileupload.esm.js +0 -1005
  89. package/fileupload/fileupload.esm.min.js +0 -1
  90. package/galleria/galleria.esm.js +0 -1090
  91. package/galleria/galleria.esm.min.js +0 -1
  92. package/hooks/hooks.esm.js +0 -1042
  93. package/hooks/hooks.esm.min.js +0 -1
  94. package/iconbase/iconbase.esm.js +0 -33
  95. package/iconbase/iconbase.esm.min.js +0 -1
  96. package/icons/angledoubledown/index.esm.js +0 -39
  97. package/icons/angledoubledown/index.esm.min.js +0 -1
  98. package/icons/angledoubleleft/index.esm.js +0 -39
  99. package/icons/angledoubleleft/index.esm.min.js +0 -1
  100. package/icons/angledoubleright/index.esm.js +0 -39
  101. package/icons/angledoubleright/index.esm.min.js +0 -1
  102. package/icons/angledoubleup/index.esm.js +0 -39
  103. package/icons/angledoubleup/index.esm.min.js +0 -1
  104. package/icons/angledown/index.esm.js +0 -37
  105. package/icons/angledown/index.esm.min.js +0 -1
  106. package/icons/angleleft/index.esm.js +0 -37
  107. package/icons/angleleft/index.esm.min.js +0 -1
  108. package/icons/angleright/index.esm.js +0 -37
  109. package/icons/angleright/index.esm.min.js +0 -1
  110. package/icons/angleup/index.esm.js +0 -37
  111. package/icons/angleup/index.esm.min.js +0 -1
  112. package/icons/arrowdown/index.esm.js +0 -661
  113. package/icons/arrowdown/index.esm.min.js +0 -1
  114. package/icons/arrowup/index.esm.js +0 -661
  115. package/icons/arrowup/index.esm.min.js +0 -1
  116. package/icons/ban/index.esm.js +0 -659
  117. package/icons/ban/index.esm.min.js +0 -1
  118. package/icons/bars/index.esm.js +0 -39
  119. package/icons/bars/index.esm.min.js +0 -1
  120. package/icons/calendar/index.esm.js +0 -37
  121. package/icons/calendar/index.esm.min.js +0 -1
  122. package/icons/check/index.esm.js +0 -37
  123. package/icons/check/index.esm.min.js +0 -1
  124. package/icons/chevrondown/index.esm.js +0 -37
  125. package/icons/chevrondown/index.esm.min.js +0 -1
  126. package/icons/chevronleft/index.esm.js +0 -37
  127. package/icons/chevronleft/index.esm.min.js +0 -1
  128. package/icons/chevronright/index.esm.js +0 -37
  129. package/icons/chevronright/index.esm.min.js +0 -1
  130. package/icons/chevronup/index.esm.js +0 -37
  131. package/icons/chevronup/index.esm.min.js +0 -1
  132. package/icons/download/index.esm.js +0 -661
  133. package/icons/download/index.esm.min.js +0 -1
  134. package/icons/exclamationtriangle/index.esm.js +0 -665
  135. package/icons/exclamationtriangle/index.esm.min.js +0 -1
  136. package/icons/eye/index.esm.js +0 -39
  137. package/icons/eye/index.esm.min.js +0 -1
  138. package/icons/eyeslash/index.esm.js +0 -661
  139. package/icons/eyeslash/index.esm.min.js +0 -1
  140. package/icons/filter/index.esm.js +0 -659
  141. package/icons/filter/index.esm.min.js +0 -1
  142. package/icons/filterslash/index.esm.js +0 -661
  143. package/icons/filterslash/index.esm.min.js +0 -1
  144. package/icons/infocircle/index.esm.js +0 -661
  145. package/icons/infocircle/index.esm.min.js +0 -1
  146. package/icons/minus/index.esm.js +0 -37
  147. package/icons/minus/index.esm.min.js +0 -1
  148. package/icons/pencil/index.esm.js +0 -659
  149. package/icons/pencil/index.esm.min.js +0 -1
  150. package/icons/plus/index.esm.js +0 -659
  151. package/icons/plus/index.esm.min.js +0 -1
  152. package/icons/refresh/index.esm.js +0 -661
  153. package/icons/refresh/index.esm.min.js +0 -1
  154. package/icons/search/index.esm.js +0 -661
  155. package/icons/search/index.esm.min.js +0 -1
  156. package/icons/searchminus/index.esm.js +0 -661
  157. package/icons/searchminus/index.esm.min.js +0 -1
  158. package/icons/searchplus/index.esm.js +0 -661
  159. package/icons/searchplus/index.esm.min.js +0 -1
  160. package/icons/sortalt/index.esm.js +0 -668
  161. package/icons/sortalt/index.esm.min.js +0 -1
  162. package/icons/sortamountdown/index.esm.js +0 -674
  163. package/icons/sortamountdown/index.esm.min.js +0 -1
  164. package/icons/sortamountupalt/index.esm.js +0 -674
  165. package/icons/sortamountupalt/index.esm.min.js +0 -1
  166. package/icons/spinner/index.esm.js +0 -659
  167. package/icons/spinner/index.esm.min.js +0 -1
  168. package/icons/star/index.esm.js +0 -659
  169. package/icons/star/index.esm.min.js +0 -1
  170. package/icons/starfill/index.esm.js +0 -659
  171. package/icons/starfill/index.esm.min.js +0 -1
  172. package/icons/thlarge/index.esm.js +0 -661
  173. package/icons/thlarge/index.esm.min.js +0 -1
  174. package/icons/times/index.esm.js +0 -37
  175. package/icons/times/index.esm.min.js +0 -1
  176. package/icons/timescircle/index.esm.js +0 -661
  177. package/icons/timescircle/index.esm.min.js +0 -1
  178. package/icons/trash/index.esm.js +0 -661
  179. package/icons/trash/index.esm.min.js +0 -1
  180. package/icons/undo/index.esm.js +0 -661
  181. package/icons/undo/index.esm.min.js +0 -1
  182. package/icons/upload/index.esm.js +0 -661
  183. package/icons/upload/index.esm.min.js +0 -1
  184. package/icons/windowmaximize/index.esm.js +0 -661
  185. package/icons/windowmaximize/index.esm.min.js +0 -1
  186. package/icons/windowminimize/index.esm.js +0 -661
  187. package/icons/windowminimize/index.esm.min.js +0 -1
  188. package/image/image.esm.js +0 -1162
  189. package/image/image.esm.min.js +0 -1
  190. package/inplace/inplace.esm.js +0 -243
  191. package/inplace/inplace.esm.min.js +0 -1
  192. package/inputmask/inputmask.esm.js +0 -560
  193. package/inputmask/inputmask.esm.min.js +0 -1
  194. package/inputnumber/inputnumber.esm.js +0 -1209
  195. package/inputnumber/inputnumber.esm.min.js +0 -1
  196. package/inputswitch/inputswitch.esm.js +0 -291
  197. package/inputswitch/inputswitch.esm.min.js +0 -1
  198. package/inputtext/inputtext.esm.js +0 -171
  199. package/inputtext/inputtext.esm.min.js +0 -1
  200. package/inputtextarea/inputtextarea.esm.js +0 -220
  201. package/inputtextarea/inputtextarea.esm.min.js +0 -1
  202. package/keyfilter/keyfilter.esm.js +0 -108
  203. package/keyfilter/keyfilter.esm.min.js +0 -1
  204. package/knob/knob.esm.js +0 -318
  205. package/knob/knob.esm.min.js +0 -1
  206. package/listbox/listbox.esm.js +0 -810
  207. package/listbox/listbox.esm.min.js +0 -1
  208. package/megamenu/megamenu.esm.js +0 -716
  209. package/megamenu/megamenu.esm.min.js +0 -1
  210. package/mention/mention.esm.js +0 -771
  211. package/mention/mention.esm.min.js +0 -1
  212. package/menu/menu.esm.js +0 -485
  213. package/menu/menu.esm.min.js +0 -1
  214. package/menubar/menubar.esm.js +0 -584
  215. package/menubar/menubar.esm.min.js +0 -1
  216. package/message/message.esm.js +0 -169
  217. package/message/message.esm.min.js +0 -1
  218. package/messages/messages.esm.js +0 -439
  219. package/messages/messages.esm.min.js +0 -1
  220. package/multiselect/multiselect.esm.js +0 -1724
  221. package/multiselect/multiselect.esm.min.js +0 -1
  222. package/multistatecheckbox/multistatecheckbox.esm.js +0 -352
  223. package/multistatecheckbox/multistatecheckbox.esm.min.js +0 -1
  224. package/orderlist/orderlist.esm.js +0 -816
  225. package/orderlist/orderlist.esm.min.js +0 -1
  226. package/organizationchart/organizationchart.esm.js +0 -480
  227. package/organizationchart/organizationchart.esm.min.js +0 -1
  228. package/overlaypanel/overlaypanel.esm.js +0 -516
  229. package/overlaypanel/overlaypanel.esm.min.js +0 -1
  230. package/overlayservice/overlayservice.esm.js +0 -7
  231. package/overlayservice/overlayservice.esm.min.js +0 -1
  232. package/paginator/paginator.esm.js +0 -933
  233. package/paginator/paginator.esm.min.js +0 -1
  234. package/panel/panel.esm.js +0 -316
  235. package/panel/panel.esm.min.js +0 -1
  236. package/panelmenu/panelmenu.esm.js +0 -645
  237. package/panelmenu/panelmenu.esm.min.js +0 -1
  238. package/passthrough/index.esm.js +0 -71
  239. package/passthrough/index.esm.min.js +0 -1
  240. package/passthrough/tailwind/index.esm.js +0 -3509
  241. package/passthrough/tailwind/index.esm.min.js +0 -1
  242. package/password/password.esm.js +0 -567
  243. package/password/password.esm.min.js +0 -1
  244. package/picklist/picklist.esm.js +0 -1119
  245. package/picklist/picklist.esm.min.js +0 -1
  246. package/portal/portal.esm.js +0 -110
  247. package/portal/portal.esm.min.js +0 -1
  248. package/primereact.all.esm.js +0 -51646
  249. package/primereact.all.esm.min.js +0 -1
  250. package/progressbar/progressbar.esm.js +0 -190
  251. package/progressbar/progressbar.esm.min.js +0 -1
  252. package/progressspinner/progressspinner.esm.js +0 -88
  253. package/progressspinner/progressspinner.esm.min.js +0 -1
  254. package/radiobutton/radiobutton.esm.js +0 -329
  255. package/radiobutton/radiobutton.esm.min.js +0 -1
  256. package/rating/rating.esm.js +0 -273
  257. package/rating/rating.esm.min.js +0 -1
  258. package/ripple/ripple.esm.js +0 -100
  259. package/ripple/ripple.esm.min.js +0 -1
  260. package/row/row.esm.js +0 -36
  261. package/row/row.esm.min.js +0 -1
  262. package/scrollpanel/scrollpanel.esm.js +0 -210
  263. package/scrollpanel/scrollpanel.esm.min.js +0 -1
  264. package/scrolltop/scrolltop.esm.js +0 -269
  265. package/scrolltop/scrolltop.esm.min.js +0 -1
  266. package/selectbutton/selectbutton.esm.js +0 -327
  267. package/selectbutton/selectbutton.esm.min.js +0 -1
  268. package/sidebar/sidebar.esm.js +0 -543
  269. package/sidebar/sidebar.esm.min.js +0 -1
  270. package/skeleton/skeleton.esm.js +0 -125
  271. package/skeleton/skeleton.esm.min.js +0 -1
  272. package/slidemenu/slidemenu.esm.js +0 -689
  273. package/slidemenu/slidemenu.esm.min.js +0 -1
  274. package/slider/slider.esm.js +0 -478
  275. package/slider/slider.esm.min.js +0 -1
  276. package/speeddial/speeddial.esm.js +0 -521
  277. package/speeddial/speeddial.esm.min.js +0 -1
  278. package/splitbutton/splitbutton.esm.js +0 -545
  279. package/splitbutton/splitbutton.esm.min.js +0 -1
  280. package/splitter/splitter.esm.js +0 -466
  281. package/splitter/splitter.esm.min.js +0 -1
  282. package/steps/steps.esm.js +0 -294
  283. package/steps/steps.esm.min.js +0 -1
  284. package/styleclass/styleclass.esm.js +0 -269
  285. package/styleclass/styleclass.esm.min.js +0 -1
  286. package/tabmenu/tabmenu.esm.js +0 -332
  287. package/tabmenu/tabmenu.esm.min.js +0 -1
  288. package/tabview/tabview.esm.js +0 -678
  289. package/tabview/tabview.esm.min.js +0 -1
  290. package/tag/tag.esm.js +0 -117
  291. package/tag/tag.esm.min.js +0 -1
  292. package/terminal/terminal.esm.js +0 -280
  293. package/terminal/terminal.esm.min.js +0 -1
  294. package/terminalservice/terminalservice.esm.js +0 -7
  295. package/terminalservice/terminalservice.esm.min.js +0 -1
  296. package/tieredmenu/tieredmenu.esm.js +0 -699
  297. package/tieredmenu/tieredmenu.esm.min.js +0 -1
  298. package/timeline/timeline.esm.js +0 -164
  299. package/timeline/timeline.esm.min.js +0 -1
  300. package/toast/toast.esm.js +0 -739
  301. package/toast/toast.esm.min.js +0 -1
  302. package/togglebutton/togglebutton.esm.js +0 -217
  303. package/togglebutton/togglebutton.esm.min.js +0 -1
  304. package/toolbar/toolbar.esm.js +0 -79
  305. package/toolbar/toolbar.esm.min.js +0 -1
  306. package/tooltip/tooltip.esm.js +0 -696
  307. package/tooltip/tooltip.esm.min.js +0 -1
  308. package/tree/tree.esm.js +0 -1403
  309. package/tree/tree.esm.min.js +0 -1
  310. package/treeselect/treeselect.esm.js +0 -930
  311. package/treeselect/treeselect.esm.min.js +0 -1
  312. package/treetable/treetable.esm.js +0 -3094
  313. package/treetable/treetable.esm.min.js +0 -1
  314. package/tristatecheckbox/tristatecheckbox.esm.js +0 -292
  315. package/tristatecheckbox/tristatecheckbox.esm.min.js +0 -1
  316. package/utils/utils.esm.js +0 -2383
  317. package/utils/utils.esm.min.js +0 -1
  318. package/virtualscroller/virtualscroller.esm.js +0 -972
  319. package/virtualscroller/virtualscroller.esm.min.js +0 -1
@@ -1,1380 +0,0 @@
1
- 'use client';
2
-
3
- import * as React from 'react';
4
- import PrimeReact, { PrimeReactContext, localeOption, FilterService } from 'primereact/api';
5
- import { ComponentBase, useHandleStyle } from 'primereact/componentbase';
6
- import { useOverlayListener, useMountEffect, useUpdateEffect, useUnmountEffect } from 'primereact/hooks';
7
- import { ChevronDownIcon } from 'primereact/icons/chevrondown';
8
- import { TimesIcon } from 'primereact/icons/times';
9
- import { OverlayService } from 'primereact/overlayservice';
10
- import { Tooltip } from 'primereact/tooltip';
11
- import { classNames, ObjectUtils, mergeProps, DomHandler, IconUtils, ZIndexUtils } from 'primereact/utils';
12
- import { CSSTransition } from 'primereact/csstransition';
13
- import { SearchIcon } from 'primereact/icons/search';
14
- import { Portal } from 'primereact/portal';
15
- import { VirtualScroller } from 'primereact/virtualscroller';
16
- import { Ripple } from 'primereact/ripple';
17
-
18
- function _extends() {
19
- _extends = Object.assign ? Object.assign.bind() : function (target) {
20
- for (var i = 1; i < arguments.length; i++) {
21
- var source = arguments[i];
22
- for (var key in source) {
23
- if (Object.prototype.hasOwnProperty.call(source, key)) {
24
- target[key] = source[key];
25
- }
26
- }
27
- }
28
- return target;
29
- };
30
- return _extends.apply(this, arguments);
31
- }
32
-
33
- function _typeof(o) {
34
- "@babel/helpers - typeof";
35
-
36
- return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) {
37
- return typeof o;
38
- } : function (o) {
39
- return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o;
40
- }, _typeof(o);
41
- }
42
-
43
- function _toPrimitive(input, hint) {
44
- if (_typeof(input) !== "object" || input === null) return input;
45
- var prim = input[Symbol.toPrimitive];
46
- if (prim !== undefined) {
47
- var res = prim.call(input, hint || "default");
48
- if (_typeof(res) !== "object") return res;
49
- throw new TypeError("@@toPrimitive must return a primitive value.");
50
- }
51
- return (hint === "string" ? String : Number)(input);
52
- }
53
-
54
- function _toPropertyKey(arg) {
55
- var key = _toPrimitive(arg, "string");
56
- return _typeof(key) === "symbol" ? key : String(key);
57
- }
58
-
59
- function _defineProperty(obj, key, value) {
60
- key = _toPropertyKey(key);
61
- if (key in obj) {
62
- Object.defineProperty(obj, key, {
63
- value: value,
64
- enumerable: true,
65
- configurable: true,
66
- writable: true
67
- });
68
- } else {
69
- obj[key] = value;
70
- }
71
- return obj;
72
- }
73
-
74
- function _arrayWithHoles(arr) {
75
- if (Array.isArray(arr)) return arr;
76
- }
77
-
78
- function _iterableToArrayLimit(r, l) {
79
- var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"];
80
- if (null != t) {
81
- var e,
82
- n,
83
- i,
84
- u,
85
- a = [],
86
- f = !0,
87
- o = !1;
88
- try {
89
- if (i = (t = t.call(r)).next, 0 === l) {
90
- if (Object(t) !== t) return;
91
- f = !1;
92
- } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0);
93
- } catch (r) {
94
- o = !0, n = r;
95
- } finally {
96
- try {
97
- if (!f && null != t["return"] && (u = t["return"](), Object(u) !== u)) return;
98
- } finally {
99
- if (o) throw n;
100
- }
101
- }
102
- return a;
103
- }
104
- }
105
-
106
- function _arrayLikeToArray$1(arr, len) {
107
- if (len == null || len > arr.length) len = arr.length;
108
- for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i];
109
- return arr2;
110
- }
111
-
112
- function _unsupportedIterableToArray$1(o, minLen) {
113
- if (!o) return;
114
- if (typeof o === "string") return _arrayLikeToArray$1(o, minLen);
115
- var n = Object.prototype.toString.call(o).slice(8, -1);
116
- if (n === "Object" && o.constructor) n = o.constructor.name;
117
- if (n === "Map" || n === "Set") return Array.from(o);
118
- if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray$1(o, minLen);
119
- }
120
-
121
- function _nonIterableRest() {
122
- throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
123
- }
124
-
125
- function _slicedToArray(arr, i) {
126
- return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray$1(arr, i) || _nonIterableRest();
127
- }
128
-
129
- var classes = {
130
- root: function root(_ref) {
131
- var props = _ref.props,
132
- focusedState = _ref.focusedState,
133
- overlayVisibleState = _ref.overlayVisibleState;
134
- return classNames('p-dropdown p-component p-inputwrapper', {
135
- 'p-disabled': props.disabled,
136
- 'p-focus': focusedState,
137
- 'p-dropdown-clearable': props.showClear && !props.disabled,
138
- 'p-inputwrapper-filled': ObjectUtils.isNotEmpty(props.value),
139
- 'p-inputwrapper-focus': focusedState || overlayVisibleState
140
- });
141
- },
142
- input: function input(_ref2) {
143
- var props = _ref2.props,
144
- label = _ref2.label;
145
- return props.editable ? 'p-dropdown-label p-inputtext' : classNames('p-dropdown-label p-inputtext', {
146
- 'p-placeholder': label === null && props.placeholder,
147
- 'p-dropdown-label-empty': label === null && !props.placeholder
148
- });
149
- },
150
- trigger: 'p-dropdown-trigger',
151
- emptyMessage: 'p-dropdown-empty-message',
152
- itemGroup: 'p-dropdown-item-group',
153
- dropdownIcon: 'p-dropdown-trigger-icon p-clickable',
154
- clearIcon: 'p-dropdown-clear-icon p-clickable',
155
- filterIcon: 'p-dropdown-filter-icon',
156
- filterContainer: function filterContainer(_ref3) {
157
- var clearIcon = _ref3.clearIcon;
158
- return classNames('p-dropdown-filter-container', {
159
- 'p-dropdown-clearable-filter': !!clearIcon
160
- });
161
- },
162
- filterInput: 'p-dropdown-filter p-inputtext p-component',
163
- list: function list(_ref4) {
164
- var virtualScrollerOptions = _ref4.virtualScrollerOptions;
165
- return virtualScrollerOptions ? 'p-dropdown-items' : 'p-dropdown-items';
166
- },
167
- panel: function panel(_ref5) {
168
- var context = _ref5.context;
169
- return classNames('p-dropdown-panel p-component', {
170
- 'p-input-filled': context && context.inputStyle === 'filled' || PrimeReact.inputStyle === 'filled',
171
- 'p-ripple-disabled': context && context.ripple === false || PrimeReact.ripple === false
172
- });
173
- },
174
- item: function item(_ref6) {
175
- var selected = _ref6.selected,
176
- disabled = _ref6.disabled,
177
- label = _ref6.label;
178
- return classNames('p-dropdown-item', {
179
- 'p-highlight': selected,
180
- 'p-disabled': disabled,
181
- 'p-dropdown-item-empty': !label || label.length === 0
182
- });
183
- },
184
- wrapper: 'p-dropdown-items-wrapper',
185
- header: 'p-dropdown-header',
186
- footer: 'p-dropdown-footer',
187
- transition: 'p-connected-overlay'
188
- };
189
- var styles = "\n@layer primereact {\n .p-dropdown {\n display: inline-flex;\n cursor: pointer;\n position: relative;\n user-select: none;\n }\n \n .p-dropdown-trigger {\n display: flex;\n align-items: center;\n justify-content: center;\n flex-shrink: 0;\n }\n \n .p-dropdown-label {\n display: block;\n white-space: nowrap;\n overflow: hidden;\n flex: 1 1 auto;\n width: 1%;\n text-overflow: ellipsis;\n cursor: pointer;\n }\n \n .p-dropdown-label-empty {\n overflow: hidden;\n visibility: hidden;\n }\n \n input.p-dropdown-label {\n cursor: default;\n }\n \n .p-dropdown .p-dropdown-panel {\n min-width: 100%;\n }\n \n .p-dropdown-panel {\n position: absolute;\n top: 0;\n left: 0;\n }\n \n .p-dropdown-items-wrapper {\n overflow: auto;\n }\n \n .p-dropdown-item {\n cursor: pointer;\n font-weight: normal;\n white-space: nowrap;\n position: relative;\n overflow: hidden;\n }\n \n .p-dropdown-items {\n margin: 0;\n padding: 0;\n list-style-type: none;\n }\n \n .p-dropdown-filter {\n width: 100%;\n }\n \n .p-dropdown-filter-container {\n position: relative;\n }\n \n .p-dropdown-clear-icon,\n .p-dropdown-filter-icon,\n .p-dropdown-filter-clear-icon {\n position: absolute;\n top: 50%;\n margin-top: -.5rem;\n }\n \n .p-fluid .p-dropdown {\n display: flex;\n }\n \n .p-fluid .p-dropdown .p-dropdown-label {\n width: 1%;\n }\n}\n";
190
- var inlineStyles = {
191
- wrapper: function wrapper(_ref7) {
192
- var props = _ref7.props;
193
- return {
194
- maxHeight: props.scrollHeight || 'auto'
195
- };
196
- },
197
- panel: function panel(_ref8) {
198
- var props = _ref8.props;
199
- props.panelStyle;
200
- }
201
- };
202
- var DropdownBase = ComponentBase.extend({
203
- defaultProps: {
204
- __TYPE: 'Dropdown',
205
- __parentMetadata: null,
206
- appendTo: null,
207
- ariaLabel: null,
208
- ariaLabelledBy: null,
209
- autoFocus: false,
210
- children: undefined,
211
- className: null,
212
- clearIcon: null,
213
- dataKey: null,
214
- disabled: false,
215
- dropdownIcon: null,
216
- editable: false,
217
- emptyFilterMessage: null,
218
- emptyMessage: null,
219
- filter: false,
220
- filterBy: null,
221
- filterClearIcon: null,
222
- filterIcon: null,
223
- filterInputAutoFocus: true,
224
- filterLocale: undefined,
225
- filterMatchMode: 'contains',
226
- filterPlaceholder: null,
227
- filterTemplate: null,
228
- focusInputRef: null,
229
- id: null,
230
- inputId: null,
231
- inputRef: null,
232
- itemTemplate: null,
233
- maxLength: null,
234
- name: null,
235
- onBlur: null,
236
- onChange: null,
237
- onContextMenu: null,
238
- onFilter: null,
239
- onFocus: null,
240
- onHide: null,
241
- onMouseDown: null,
242
- onShow: null,
243
- optionDisabled: null,
244
- optionGroupChildren: 'items',
245
- optionGroupLabel: null,
246
- optionGroupTemplate: null,
247
- optionLabel: null,
248
- optionValue: null,
249
- options: null,
250
- panelClassName: null,
251
- panelFooterTemplate: null,
252
- panelStyle: null,
253
- placeholder: null,
254
- required: false,
255
- resetFilterOnHide: false,
256
- scrollHeight: '200px',
257
- showClear: false,
258
- showFilterClear: false,
259
- showOnFocus: false,
260
- style: null,
261
- tabIndex: null,
262
- tooltip: null,
263
- tooltipOptions: null,
264
- transitionOptions: null,
265
- value: null,
266
- valueTemplate: null,
267
- virtualScrollerOptions: null
268
- },
269
- css: {
270
- classes: classes,
271
- styles: styles,
272
- inlineStyles: inlineStyles
273
- }
274
- });
275
-
276
- var DropdownItem = /*#__PURE__*/React.memo(function (props) {
277
- var ptm = props.ptm,
278
- cx = props.cx,
279
- selected = props.selected,
280
- disabled = props.disabled,
281
- option = props.option,
282
- label = props.label;
283
- var getPTOptions = function getPTOptions(key) {
284
- return ptm(key, {
285
- context: {
286
- selected: selected,
287
- disabled: disabled
288
- }
289
- });
290
- };
291
- var _onClick = function onClick(event) {
292
- if (props.onClick) {
293
- props.onClick({
294
- originalEvent: event,
295
- option: option
296
- });
297
- }
298
- };
299
- var content = props.template ? ObjectUtils.getJSXElement(props.template, props.option) : props.label;
300
- var itemProps = mergeProps({
301
- role: 'option',
302
- key: props.label,
303
- className: classNames(option.className, cx('item')),
304
- style: props.style,
305
- onClick: function onClick(e) {
306
- return _onClick(e);
307
- },
308
- 'aria-label': label,
309
- 'aria-selected': selected,
310
- 'data-p-highlight': selected,
311
- 'data-p-disabled': disabled
312
- }, getPTOptions('item'));
313
- return /*#__PURE__*/React.createElement("li", itemProps, content, /*#__PURE__*/React.createElement(Ripple, null));
314
- });
315
- DropdownItem.displayName = 'DropdownItem';
316
-
317
- function ownKeys$1(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
318
- function _objectSpread$1(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys$1(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$1(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
319
- var DropdownPanel = /*#__PURE__*/React.memo( /*#__PURE__*/React.forwardRef(function (props, ref) {
320
- var ptm = props.ptm,
321
- cx = props.cx,
322
- sx = props.sx;
323
- var context = React.useContext(PrimeReactContext);
324
- React.useRef(null);
325
- var filterInputRef = React.useRef(null);
326
- var isEmptyFilter = !(props.visibleOptions && props.visibleOptions.length) && props.hasFilter;
327
- var filterOptions = {
328
- filter: function filter(e) {
329
- return onFilterInputChange(e);
330
- },
331
- reset: function reset() {
332
- return props.resetFilter();
333
- }
334
- };
335
- var getPTOptions = function getPTOptions(key, options) {
336
- return ptm(key, _objectSpread$1({
337
- hostName: props.hostName
338
- }, options));
339
- };
340
- var onEnter = function onEnter() {
341
- props.onEnter(function () {
342
- if (props.virtualScrollerRef.current) {
343
- var selectedIndex = props.getSelectedOptionIndex();
344
- if (selectedIndex !== -1) {
345
- setTimeout(function () {
346
- return props.virtualScrollerRef.current.scrollToIndex(selectedIndex);
347
- }, 0);
348
- }
349
- }
350
- });
351
- };
352
- var onEntered = function onEntered() {
353
- props.onEntered(function () {
354
- if (props.filter && props.filterInputAutoFocus) {
355
- DomHandler.focus(filterInputRef.current, false);
356
- }
357
- });
358
- };
359
- var onFilterInputChange = function onFilterInputChange(event) {
360
- props.virtualScrollerRef.current && props.virtualScrollerRef.current.scrollToIndex(0);
361
- props.onFilterInputChange && props.onFilterInputChange(event);
362
- };
363
- var createFooter = function createFooter() {
364
- if (props.panelFooterTemplate) {
365
- var content = ObjectUtils.getJSXElement(props.panelFooterTemplate, props, props.onOverlayHide);
366
- var footerProps = mergeProps({
367
- className: cx('footer')
368
- }, getPTOptions('footer'));
369
- return /*#__PURE__*/React.createElement("div", footerProps, content);
370
- }
371
- return null;
372
- };
373
- var createGroupChildren = function createGroupChildren(optionGroup, style) {
374
- var groupChildren = props.getOptionGroupChildren(optionGroup);
375
- return groupChildren.map(function (option, j) {
376
- var optionLabel = props.getOptionLabel(option);
377
- var optionKey = j + '_' + props.getOptionRenderKey(option);
378
- var disabled = props.isOptionDisabled(option);
379
- return /*#__PURE__*/React.createElement(DropdownItem, {
380
- key: optionKey,
381
- label: optionLabel,
382
- option: option,
383
- style: style,
384
- template: props.itemTemplate,
385
- selected: props.isSelected(option),
386
- disabled: disabled,
387
- onClick: props.onOptionClick,
388
- ptm: ptm,
389
- cx: cx
390
- });
391
- });
392
- };
393
- var createEmptyMessage = function createEmptyMessage(emptyMessage, isFilter) {
394
- var message = ObjectUtils.getJSXElement(emptyMessage, props) || localeOption(isFilter ? 'emptyFilterMessage' : 'emptyMessage');
395
- var emptyMessageProps = mergeProps({
396
- className: cx('emptyMessage')
397
- }, getPTOptions('emptyMessage'));
398
- return /*#__PURE__*/React.createElement("li", emptyMessageProps, message);
399
- };
400
- var createItem = function createItem(option, index) {
401
- var scrollerOptions = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
402
- var style = {
403
- height: scrollerOptions.props ? scrollerOptions.props.itemSize : undefined
404
- };
405
- style = _objectSpread$1(_objectSpread$1({}, style), option.style);
406
- if (props.optionGroupLabel) {
407
- var groupContent = props.optionGroupTemplate ? ObjectUtils.getJSXElement(props.optionGroupTemplate, option, index) : props.getOptionGroupLabel(option);
408
- var groupChildrenContent = createGroupChildren(option, style);
409
- var key = index + '_' + props.getOptionGroupRenderKey(option);
410
- var itemGroupProps = mergeProps({
411
- className: cx('itemGroup'),
412
- style: style
413
- }, getPTOptions('itemGroup'));
414
- return /*#__PURE__*/React.createElement(React.Fragment, {
415
- key: key
416
- }, /*#__PURE__*/React.createElement("li", itemGroupProps, groupContent), groupChildrenContent);
417
- } else {
418
- var optionLabel = props.getOptionLabel(option);
419
- var optionKey = index + '_' + props.getOptionRenderKey(option);
420
- var disabled = props.isOptionDisabled(option);
421
- return /*#__PURE__*/React.createElement(DropdownItem, {
422
- key: optionKey,
423
- label: optionLabel,
424
- option: option,
425
- style: style,
426
- template: props.itemTemplate,
427
- selected: props.isSelected(option),
428
- disabled: disabled,
429
- onClick: props.onOptionClick,
430
- ptm: ptm,
431
- cx: cx
432
- });
433
- }
434
- };
435
- var createItems = function createItems() {
436
- if (ObjectUtils.isNotEmpty(props.visibleOptions)) {
437
- return props.visibleOptions.map(createItem);
438
- } else if (props.hasFilter) {
439
- return createEmptyMessage(props.emptyFilterMessage, true);
440
- }
441
- return createEmptyMessage(props.emptyMessage);
442
- };
443
- var createFilterClearIcon = function createFilterClearIcon() {
444
- if (props.showFilterClear && props.filterValue) {
445
- var ariaLabel = localeOption('clear');
446
- var clearIconProps = mergeProps({
447
- className: cx('clearIcon'),
448
- 'aria-label': ariaLabel,
449
- onClick: function onClick() {
450
- return props.onFilterClearIconClick(function () {
451
- return DomHandler.focus(filterInputRef.current);
452
- });
453
- }
454
- }, getPTOptions('clearIcon'));
455
- var icon = props.filterClearIcon || /*#__PURE__*/React.createElement(TimesIcon, clearIconProps);
456
- var filterClearIcon = IconUtils.getJSXIcon(icon, _objectSpread$1({}, clearIconProps), {
457
- props: props
458
- });
459
- return filterClearIcon;
460
- }
461
- return null;
462
- };
463
- var createFilter = function createFilter() {
464
- if (props.filter) {
465
- var clearIcon = createFilterClearIcon();
466
- var filterIconProps = mergeProps({
467
- className: cx('filterIcon')
468
- }, getPTOptions('filterIcon'));
469
- var icon = props.filterIcon || /*#__PURE__*/React.createElement(SearchIcon, filterIconProps);
470
- var filterIcon = IconUtils.getJSXIcon(icon, _objectSpread$1({}, filterIconProps), {
471
- props: props
472
- });
473
- var filterContainerProps = mergeProps({
474
- className: cx('filterContainer', {
475
- clearIcon: clearIcon
476
- })
477
- }, getPTOptions('filterContainer'));
478
- var filterInputProps = mergeProps({
479
- ref: filterInputRef,
480
- type: 'text',
481
- autoComplete: 'off',
482
- className: cx('filterInput'),
483
- placeholder: props.filterPlaceholder,
484
- onKeyDown: props.onFilterInputKeyDown,
485
- onChange: function onChange(e) {
486
- return onFilterInputChange(e);
487
- },
488
- value: props.filterValue
489
- }, getPTOptions('filterInput'));
490
- var content = /*#__PURE__*/React.createElement("div", filterContainerProps, /*#__PURE__*/React.createElement("input", filterInputProps), clearIcon, filterIcon);
491
- if (props.filterTemplate) {
492
- var defaultContentOptions = {
493
- className: classNames('p-dropdown-filter-container', {
494
- 'p-dropdown-clearable-filter': !!clearIcon
495
- }),
496
- element: content,
497
- filterOptions: filterOptions,
498
- filterInputKeyDown: props.onFilterInputKeyDown,
499
- filterInputChange: onFilterInputChange,
500
- filterIconClassName: 'p-dropdown-filter-icon',
501
- clearIcon: clearIcon,
502
- props: props
503
- };
504
- content = ObjectUtils.getJSXElement(props.filterTemplate, defaultContentOptions);
505
- }
506
- var headerProps = mergeProps({
507
- className: cx('header')
508
- }, getPTOptions('header'));
509
- return /*#__PURE__*/React.createElement("div", headerProps, content);
510
- }
511
- return null;
512
- };
513
- var createContent = function createContent() {
514
- if (props.virtualScrollerOptions) {
515
- var virtualScrollerProps = _objectSpread$1(_objectSpread$1({}, props.virtualScrollerOptions), {
516
- style: _objectSpread$1(_objectSpread$1({}, props.virtualScrollerOptions.style), {
517
- height: props.scrollHeight
518
- }),
519
- className: classNames('p-dropdown-items-wrapper', props.virtualScrollerOptions.className),
520
- items: props.visibleOptions,
521
- autoSize: true,
522
- onLazyLoad: function onLazyLoad(event) {
523
- return props.virtualScrollerOptions.onLazyLoad(_objectSpread$1(_objectSpread$1({}, event), {
524
- filter: props.filterValue
525
- }));
526
- },
527
- itemTemplate: function itemTemplate(item, options) {
528
- return item && createItem(item, options.index, options);
529
- },
530
- contentTemplate: function contentTemplate(options) {
531
- var emptyMessage = props.hasFilter ? props.emptyFilterMessage : props.emptyMessage;
532
- var content = isEmptyFilter ? createEmptyMessage(emptyMessage) : options.children;
533
- var listProps = mergeProps({
534
- ref: options.contentRef,
535
- style: options.style,
536
- className: classNames(options.className, cx('list', {
537
- virtualScrollerProps: props.virtualScrollerOptions
538
- })),
539
- role: 'listbox'
540
- }, getPTOptions('list'));
541
- return /*#__PURE__*/React.createElement("ul", listProps, content);
542
- }
543
- });
544
- return /*#__PURE__*/React.createElement(VirtualScroller, _extends({
545
- ref: props.virtualScrollerRef
546
- }, virtualScrollerProps, {
547
- pt: ptm('virtualScroller')
548
- }));
549
- } else {
550
- var items = createItems();
551
- var wrapperProps = mergeProps({
552
- className: cx('wrapper'),
553
- style: sx('wrapper')
554
- }, getPTOptions('wrapper'));
555
- var listProps = mergeProps({
556
- className: cx('list'),
557
- role: 'listbox'
558
- }, getPTOptions('list'));
559
- return /*#__PURE__*/React.createElement("div", wrapperProps, /*#__PURE__*/React.createElement("ul", listProps, items));
560
- }
561
- };
562
- var createElement = function createElement() {
563
- var filter = createFilter();
564
- var content = createContent();
565
- var footer = createFooter();
566
- var panelProps = mergeProps({
567
- className: classNames(props.panelClassName, cx('panel', {
568
- context: context
569
- })),
570
- style: sx('panel'),
571
- onClick: props.onClick
572
- }, getPTOptions('panel'));
573
- var transitionProps = mergeProps({
574
- classNames: cx('transition'),
575
- "in": props["in"],
576
- timeout: {
577
- enter: 120,
578
- exit: 100
579
- },
580
- options: props.transitionOptions,
581
- unmountOnExit: true,
582
- onEnter: onEnter,
583
- onEntered: onEntered,
584
- onExit: props.onExit,
585
- onExited: props.onExited
586
- }, getPTOptions('transition'));
587
- return /*#__PURE__*/React.createElement(CSSTransition, _extends({
588
- nodeRef: ref
589
- }, transitionProps), /*#__PURE__*/React.createElement("div", _extends({
590
- ref: ref
591
- }, panelProps), filter, content, footer));
592
- };
593
- var element = createElement();
594
- return /*#__PURE__*/React.createElement(Portal, {
595
- element: element,
596
- appendTo: props.appendTo
597
- });
598
- }));
599
- DropdownPanel.displayName = 'DropdownPanel';
600
-
601
- function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it["return"] != null) it["return"](); } finally { if (didErr) throw err; } } }; }
602
- function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
603
- function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
604
- function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
605
- function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
606
- var Dropdown = /*#__PURE__*/React.memo( /*#__PURE__*/React.forwardRef(function (inProps, ref) {
607
- var context = React.useContext(PrimeReactContext);
608
- var props = DropdownBase.getProps(inProps, context);
609
- var _React$useState = React.useState(''),
610
- _React$useState2 = _slicedToArray(_React$useState, 2),
611
- filterState = _React$useState2[0],
612
- setFilterState = _React$useState2[1];
613
- var _React$useState3 = React.useState(false),
614
- _React$useState4 = _slicedToArray(_React$useState3, 2),
615
- focusedState = _React$useState4[0],
616
- setFocusedState = _React$useState4[1];
617
- var _React$useState5 = React.useState(false),
618
- _React$useState6 = _slicedToArray(_React$useState5, 2),
619
- overlayVisibleState = _React$useState6[0],
620
- setOverlayVisibleState = _React$useState6[1];
621
- var elementRef = React.useRef(null);
622
- var overlayRef = React.useRef(null);
623
- var inputRef = React.useRef(props.inputRef);
624
- var focusInputRef = React.useRef(props.focusInputRef);
625
- var virtualScrollerRef = React.useRef(null);
626
- var searchTimeout = React.useRef(null);
627
- var searchValue = React.useRef(null);
628
- var currentSearchChar = React.useRef(null);
629
- var isLazy = props.virtualScrollerOptions && props.virtualScrollerOptions.lazy;
630
- var hasFilter = ObjectUtils.isNotEmpty(filterState);
631
- var appendTo = props.appendTo || context && context.appendTo || PrimeReact.appendTo;
632
- var _DropdownBase$setMeta = DropdownBase.setMetaData(_objectSpread(_objectSpread({
633
- props: props
634
- }, props.__parentMetadata), {}, {
635
- state: {
636
- filter: filterState,
637
- focused: focusedState,
638
- overlayVisible: overlayVisibleState
639
- }
640
- })),
641
- ptm = _DropdownBase$setMeta.ptm,
642
- cx = _DropdownBase$setMeta.cx,
643
- sx = _DropdownBase$setMeta.sx,
644
- isUnstyled = _DropdownBase$setMeta.isUnstyled;
645
- useHandleStyle(DropdownBase.css.styles, isUnstyled, {
646
- name: 'dropdown'
647
- });
648
- var _useOverlayListener = useOverlayListener({
649
- target: elementRef,
650
- overlay: overlayRef,
651
- listener: function listener(event, _ref) {
652
- var type = _ref.type,
653
- valid = _ref.valid;
654
- if (valid) {
655
- type === 'outside' ? !isClearClicked(event) && hide() : hide();
656
- }
657
- },
658
- when: overlayVisibleState
659
- }),
660
- _useOverlayListener2 = _slicedToArray(_useOverlayListener, 2),
661
- bindOverlayListener = _useOverlayListener2[0],
662
- unbindOverlayListener = _useOverlayListener2[1];
663
- var getVisibleOptions = function getVisibleOptions() {
664
- if (hasFilter && !isLazy) {
665
- var filterValue = filterState.trim().toLocaleLowerCase(props.filterLocale);
666
- var searchFields = props.filterBy ? props.filterBy.split(',') : [props.optionLabel || 'label'];
667
- if (props.optionGroupLabel) {
668
- var filteredGroups = [];
669
- var _iterator = _createForOfIteratorHelper(props.options),
670
- _step;
671
- try {
672
- for (_iterator.s(); !(_step = _iterator.n()).done;) {
673
- var optgroup = _step.value;
674
- var filteredSubOptions = FilterService.filter(getOptionGroupChildren(optgroup), searchFields, filterValue, props.filterMatchMode, props.filterLocale);
675
- if (filteredSubOptions && filteredSubOptions.length) {
676
- filteredGroups.push(_objectSpread(_objectSpread({}, optgroup), _defineProperty({}, "".concat(props.optionGroupChildren), filteredSubOptions)));
677
- }
678
- }
679
- } catch (err) {
680
- _iterator.e(err);
681
- } finally {
682
- _iterator.f();
683
- }
684
- return filteredGroups;
685
- } else {
686
- return FilterService.filter(props.options, searchFields, filterValue, props.filterMatchMode, props.filterLocale);
687
- }
688
- } else {
689
- return props.options;
690
- }
691
- };
692
- var isClearClicked = function isClearClicked(event) {
693
- return DomHandler.hasClass(event.target, 'p-dropdown-clear-icon') || DomHandler.hasClass(event.target, 'p-dropdown-filter-clear-icon');
694
- };
695
- var _onClick = function onClick(event) {
696
- if (props.disabled) {
697
- return;
698
- }
699
- props.onClick && props.onClick(event);
700
-
701
- // do not continue if the user defined click wants to prevent it
702
- if (event.defaultPrevented) {
703
- return;
704
- }
705
- if (DomHandler.hasClass(event.target, 'p-dropdown-clear-icon') || event.target.tagName === 'INPUT') {
706
- return;
707
- } else if (!overlayRef.current || !(overlayRef.current && overlayRef.current.contains(event.target))) {
708
- DomHandler.focus(focusInputRef.current);
709
- overlayVisibleState ? hide() : show();
710
- }
711
- };
712
- var onInputFocus = function onInputFocus(event) {
713
- if (props.showOnFocus && !overlayVisibleState) {
714
- show();
715
- }
716
- setFocusedState(true);
717
- props.onFocus && props.onFocus(event);
718
- };
719
- var onInputBlur = function onInputBlur(event) {
720
- setFocusedState(false);
721
- if (props.onBlur) {
722
- setTimeout(function () {
723
- var currentValue = inputRef.current ? inputRef.current.value : undefined;
724
- props.onBlur({
725
- originalEvent: event.originalEvent,
726
- value: currentValue,
727
- stopPropagation: function stopPropagation() {
728
- event.originalEvent.stopPropagation();
729
- },
730
- preventDefault: function preventDefault() {
731
- event.originalEvent.preventDefault();
732
- },
733
- target: {
734
- name: props.name,
735
- id: props.id,
736
- value: currentValue
737
- }
738
- });
739
- }, 200);
740
- }
741
- };
742
- var onPanelClick = function onPanelClick(event) {
743
- OverlayService.emit('overlay-click', {
744
- originalEvent: event,
745
- target: elementRef.current
746
- });
747
- };
748
- var onInputKeyDown = function onInputKeyDown(event) {
749
- switch (event.which) {
750
- //down
751
- case 40:
752
- onDownKey(event);
753
- break;
754
-
755
- //up
756
- case 38:
757
- onUpKey(event);
758
- break;
759
-
760
- //space and enter
761
- case 32:
762
- case 13:
763
- overlayVisibleState ? hide() : show();
764
- event.preventDefault();
765
- break;
766
-
767
- //escape and tab
768
- case 27:
769
- case 9:
770
- hide();
771
- break;
772
- default:
773
- search(event);
774
- break;
775
- }
776
- };
777
- var onFilterInputKeyDown = function onFilterInputKeyDown(event) {
778
- switch (event.which) {
779
- //down
780
- case 40:
781
- onDownKey(event);
782
- break;
783
-
784
- //up
785
- case 38:
786
- onUpKey(event);
787
- break;
788
-
789
- //enter and escape
790
- case 13:
791
- case 27:
792
- hide();
793
- event.preventDefault();
794
- break;
795
- }
796
- };
797
- var onUpKey = function onUpKey(event) {
798
- if (visibleOptions) {
799
- var prevOption = findPrevOption(getSelectedOptionIndex());
800
- if (prevOption) {
801
- selectItem({
802
- originalEvent: event,
803
- option: prevOption
804
- });
805
- }
806
- }
807
- event.preventDefault();
808
- };
809
- var onDownKey = function onDownKey(event) {
810
- if (visibleOptions) {
811
- if (!overlayVisibleState && event.altKey) {
812
- show();
813
- } else {
814
- var nextOption = findNextOption(getSelectedOptionIndex());
815
- if (nextOption) {
816
- selectItem({
817
- originalEvent: event,
818
- option: nextOption
819
- });
820
- }
821
- }
822
- }
823
- event.preventDefault();
824
- };
825
- var findNextOption = function findNextOption(index) {
826
- if (props.optionGroupLabel) {
827
- var groupIndex = index === -1 ? 0 : index.group;
828
- var optionIndex = index === -1 ? -1 : index.option;
829
- var option = findNextOptionInList(getOptionGroupChildren(visibleOptions[groupIndex]), optionIndex);
830
- if (option) return option;else if (groupIndex + 1 !== visibleOptions.length) return findNextOption({
831
- group: groupIndex + 1,
832
- option: -1
833
- });else return null;
834
- }
835
- return findNextOptionInList(visibleOptions, index);
836
- };
837
- var findNextOptionInList = function findNextOptionInList(list, index) {
838
- var i = index + 1;
839
- if (i === list.length) {
840
- return null;
841
- }
842
- var option = list[i];
843
- return isOptionDisabled(option) ? findNextOptionInList(i) : option;
844
- };
845
- var findPrevOption = function findPrevOption(index) {
846
- if (index === -1) {
847
- return null;
848
- }
849
- if (props.optionGroupLabel) {
850
- var groupIndex = index.group;
851
- var optionIndex = index.option;
852
- var option = findPrevOptionInList(getOptionGroupChildren(visibleOptions[groupIndex]), optionIndex);
853
- if (option) return option;else if (groupIndex > 0) return findPrevOption({
854
- group: groupIndex - 1,
855
- option: getOptionGroupChildren(visibleOptions[groupIndex - 1]).length
856
- });else return null;
857
- }
858
- return findPrevOptionInList(visibleOptions, index);
859
- };
860
- var findPrevOptionInList = function findPrevOptionInList(list, index) {
861
- var i = index - 1;
862
- if (i < 0) {
863
- return null;
864
- }
865
- var option = list[i];
866
- return isOptionDisabled(option) ? findPrevOption(i) : option;
867
- };
868
- var search = function search(event) {
869
- if (searchTimeout.current) {
870
- clearTimeout(searchTimeout.current);
871
- }
872
- var _char = event.key;
873
- if (_char === 'Shift' || _char === 'Control' || _char === 'Alt') {
874
- return;
875
- }
876
- if (currentSearchChar.current === _char) searchValue.current = _char;else searchValue.current = searchValue.current ? searchValue.current + _char : _char;
877
- currentSearchChar.current = _char;
878
- if (searchValue.current) {
879
- var searchIndex = getSelectedOptionIndex();
880
- var newOption = props.optionGroupLabel ? searchOptionInGroup(searchIndex) : searchOption(searchIndex + 1);
881
- if (newOption) {
882
- selectItem({
883
- originalEvent: event,
884
- option: newOption
885
- });
886
- }
887
- }
888
- searchTimeout.current = setTimeout(function () {
889
- searchValue.current = null;
890
- }, 250);
891
- };
892
- var searchOption = function searchOption(index) {
893
- if (searchValue.current) {
894
- return searchOptionInRange(index, visibleOptions.length) || searchOptionInRange(0, index);
895
- }
896
- return null;
897
- };
898
- var searchOptionInRange = function searchOptionInRange(start, end) {
899
- for (var i = start; i < end; i++) {
900
- var opt = visibleOptions[i];
901
- if (matchesSearchValue(opt)) {
902
- return opt;
903
- }
904
- }
905
- return null;
906
- };
907
- var searchOptionInGroup = function searchOptionInGroup(index) {
908
- var searchIndex = index === -1 ? {
909
- group: 0,
910
- option: -1
911
- } : index;
912
- for (var i = searchIndex.group; i < visibleOptions.length; i++) {
913
- var groupOptions = getOptionGroupChildren(visibleOptions[i]);
914
- for (var j = searchIndex.group === i ? searchIndex.option + 1 : 0; j < groupOptions.length; j++) {
915
- if (matchesSearchValue(groupOptions[j])) {
916
- return groupOptions[j];
917
- }
918
- }
919
- }
920
- for (var _i = 0; _i <= searchIndex.group; _i++) {
921
- var _groupOptions = getOptionGroupChildren(visibleOptions[_i]);
922
- for (var _j = 0; _j < (searchIndex.group === _i ? searchIndex.option : _groupOptions.length); _j++) {
923
- if (matchesSearchValue(_groupOptions[_j])) {
924
- return _groupOptions[_j];
925
- }
926
- }
927
- }
928
- return null;
929
- };
930
- var matchesSearchValue = function matchesSearchValue(option) {
931
- var label = getOptionLabel(option);
932
- if (!label) {
933
- return false;
934
- }
935
- label = label.toLocaleLowerCase(props.filterLocale);
936
- return label.startsWith(searchValue.current.toLocaleLowerCase(props.filterLocale));
937
- };
938
- var onEditableInputChange = function onEditableInputChange(event) {
939
- if (props.onChange) {
940
- props.onChange({
941
- originalEvent: event.originalEvent,
942
- value: event.target.value,
943
- stopPropagation: function stopPropagation() {
944
- event.originalEvent.stopPropagation();
945
- },
946
- preventDefault: function preventDefault() {
947
- event.originalEvent.preventDefault();
948
- },
949
- target: {
950
- name: props.name,
951
- id: props.id,
952
- value: event.target.value
953
- }
954
- });
955
- }
956
- };
957
- var onEditableInputFocus = function onEditableInputFocus(event) {
958
- setFocusedState(true);
959
- hide();
960
- props.onFocus && props.onFocus(event);
961
- };
962
- var onOptionClick = function onOptionClick(event) {
963
- var option = event.option;
964
- if (!option.disabled) {
965
- selectItem(event);
966
- DomHandler.focus(focusInputRef.current);
967
- }
968
- hide();
969
- };
970
- var onFilterInputChange = function onFilterInputChange(event) {
971
- var filter = event.target.value;
972
- setFilterState(filter);
973
- if (props.onFilter) {
974
- props.onFilter({
975
- originalEvent: event,
976
- filter: filter
977
- });
978
- }
979
- };
980
- var onFilterClearIconClick = function onFilterClearIconClick(callback) {
981
- resetFilter(callback);
982
- };
983
- var resetFilter = function resetFilter(callback) {
984
- setFilterState('');
985
- props.onFilter && props.onFilter({
986
- filter: ''
987
- });
988
- callback && callback();
989
- };
990
- var clear = function clear(event) {
991
- if (props.onChange) {
992
- props.onChange({
993
- originalEvent: event,
994
- value: undefined,
995
- stopPropagation: function stopPropagation() {
996
- event.stopPropagation();
997
- },
998
- preventDefault: function preventDefault() {
999
- event.preventDefault();
1000
- },
1001
- target: {
1002
- name: props.name,
1003
- id: props.id,
1004
- value: undefined
1005
- }
1006
- });
1007
- }
1008
- updateEditableLabel();
1009
- };
1010
- var selectItem = function selectItem(event) {
1011
- if (selectedOption !== event.option) {
1012
- updateEditableLabel(event.option);
1013
- var optionValue = getOptionValue(event.option);
1014
- if (props.onChange) {
1015
- props.onChange({
1016
- originalEvent: event.originalEvent,
1017
- value: optionValue,
1018
- stopPropagation: function stopPropagation() {
1019
- event.originalEvent.stopPropagation();
1020
- },
1021
- preventDefault: function preventDefault() {
1022
- event.originalEvent.preventDefault();
1023
- },
1024
- target: {
1025
- name: props.name,
1026
- id: props.id,
1027
- value: optionValue
1028
- }
1029
- });
1030
- }
1031
- }
1032
- };
1033
- var getSelectedOptionIndex = function getSelectedOptionIndex(options) {
1034
- options = options || visibleOptions;
1035
- if (props.value != null && options) {
1036
- if (props.optionGroupLabel) {
1037
- for (var i = 0; i < options.length; i++) {
1038
- var selectedOptionIndex = findOptionIndexInList(props.value, getOptionGroupChildren(options[i]));
1039
- if (selectedOptionIndex !== -1) {
1040
- return {
1041
- group: i,
1042
- option: selectedOptionIndex
1043
- };
1044
- }
1045
- }
1046
- } else {
1047
- return findOptionIndexInList(props.value, options);
1048
- }
1049
- }
1050
- return -1;
1051
- };
1052
- var equalityKey = function equalityKey() {
1053
- return props.optionValue ? null : props.dataKey;
1054
- };
1055
- var findOptionIndexInList = function findOptionIndexInList(value, list) {
1056
- var key = equalityKey();
1057
- return list.findIndex(function (item) {
1058
- return ObjectUtils.equals(value, getOptionValue(item), key);
1059
- });
1060
- };
1061
- var isSelected = function isSelected(option) {
1062
- return ObjectUtils.equals(props.value, getOptionValue(option), equalityKey());
1063
- };
1064
- var show = function show() {
1065
- setOverlayVisibleState(true);
1066
- };
1067
- var hide = function hide() {
1068
- setOverlayVisibleState(false);
1069
- };
1070
- var onOverlayEnter = function onOverlayEnter(callback) {
1071
- ZIndexUtils.set('overlay', overlayRef.current, context && context.autoZIndex || PrimeReact.autoZIndex, context && context.zIndex['overlay'] || PrimeReact.zIndex['overlay']);
1072
- DomHandler.addStyles(overlayRef.current, {
1073
- position: 'absolute',
1074
- top: '0',
1075
- left: '0'
1076
- });
1077
- alignOverlay();
1078
- callback && callback();
1079
- };
1080
- var onOverlayEntered = function onOverlayEntered(callback) {
1081
- callback && callback();
1082
- bindOverlayListener();
1083
- props.onShow && props.onShow();
1084
- };
1085
- var onOverlayExit = function onOverlayExit() {
1086
- unbindOverlayListener();
1087
- };
1088
- var onOverlayExited = function onOverlayExited() {
1089
- if (props.filter && props.resetFilterOnHide) {
1090
- resetFilter();
1091
- }
1092
- ZIndexUtils.clear(overlayRef.current);
1093
- props.onHide && props.onHide();
1094
- };
1095
- var alignOverlay = function alignOverlay() {
1096
- DomHandler.alignOverlay(overlayRef.current, inputRef.current.parentElement, props.appendTo || context && context.appendTo || PrimeReact.appendTo);
1097
- };
1098
- var scrollInView = function scrollInView() {
1099
- var highlightItem = DomHandler.findSingle(overlayRef.current, 'li.p-highlight');
1100
- if (highlightItem && highlightItem.scrollIntoView) {
1101
- highlightItem.scrollIntoView({
1102
- block: 'nearest',
1103
- inline: 'nearest'
1104
- });
1105
- }
1106
- };
1107
- var updateEditableLabel = function updateEditableLabel(option) {
1108
- if (inputRef.current) {
1109
- inputRef.current.value = option ? getOptionLabel(option) : props.value || '';
1110
- }
1111
- };
1112
- var getOptionLabel = function getOptionLabel(option) {
1113
- return props.optionLabel ? ObjectUtils.resolveFieldData(option, props.optionLabel) : option && option['label'] !== undefined ? option['label'] : option;
1114
- };
1115
- var getOptionValue = function getOptionValue(option) {
1116
- return props.optionValue ? ObjectUtils.resolveFieldData(option, props.optionValue) : option && option['value'] !== undefined ? option['value'] : option;
1117
- };
1118
- var getOptionRenderKey = function getOptionRenderKey(option) {
1119
- return props.dataKey ? ObjectUtils.resolveFieldData(option, props.dataKey) : getOptionLabel(option);
1120
- };
1121
- var isOptionDisabled = function isOptionDisabled(option) {
1122
- if (props.optionDisabled) {
1123
- return ObjectUtils.isFunction(props.optionDisabled) ? props.optionDisabled(option) : ObjectUtils.resolveFieldData(option, props.optionDisabled);
1124
- }
1125
- return option && option['disabled'] !== undefined ? option['disabled'] : false;
1126
- };
1127
- var getOptionGroupRenderKey = function getOptionGroupRenderKey(optionGroup) {
1128
- return ObjectUtils.resolveFieldData(optionGroup, props.optionGroupLabel);
1129
- };
1130
- var getOptionGroupLabel = function getOptionGroupLabel(optionGroup) {
1131
- return ObjectUtils.resolveFieldData(optionGroup, props.optionGroupLabel);
1132
- };
1133
- var getOptionGroupChildren = function getOptionGroupChildren(optionGroup) {
1134
- return ObjectUtils.resolveFieldData(optionGroup, props.optionGroupChildren);
1135
- };
1136
- var updateInputField = function updateInputField() {
1137
- if (props.editable && inputRef.current) {
1138
- var label = selectedOption ? getOptionLabel(selectedOption) : null;
1139
- var value = label || props.value || '';
1140
- inputRef.current.value = value;
1141
- }
1142
- };
1143
- var getSelectedOption = function getSelectedOption() {
1144
- var index = getSelectedOptionIndex(props.options);
1145
- return index !== -1 ? props.optionGroupLabel ? getOptionGroupChildren(props.options[index.group])[index.option] : props.options[index] : null;
1146
- };
1147
- React.useImperativeHandle(ref, function () {
1148
- return {
1149
- props: props,
1150
- show: show,
1151
- hide: hide,
1152
- clear: clear,
1153
- focus: function focus() {
1154
- return DomHandler.focus(focusInputRef.current);
1155
- },
1156
- getElement: function getElement() {
1157
- return elementRef.current;
1158
- },
1159
- getOverlay: function getOverlay() {
1160
- return overlayRef.current;
1161
- },
1162
- getInput: function getInput() {
1163
- return inputRef.current;
1164
- },
1165
- getFocusInput: function getFocusInput() {
1166
- return focusInputRef.current;
1167
- },
1168
- getVirtualScroller: function getVirtualScroller() {
1169
- return virtualScrollerRef.current;
1170
- }
1171
- };
1172
- });
1173
- React.useEffect(function () {
1174
- ObjectUtils.combinedRefs(inputRef, props.inputRef);
1175
- ObjectUtils.combinedRefs(focusInputRef, props.focusInputRef);
1176
- }, [inputRef, props.inputRef, focusInputRef, props.focusInputRef]);
1177
- useMountEffect(function () {
1178
- if (props.autoFocus) {
1179
- DomHandler.focus(focusInputRef.current, props.autoFocus);
1180
- }
1181
- });
1182
- useUpdateEffect(function () {
1183
- if (overlayVisibleState && props.value) {
1184
- scrollInView();
1185
- }
1186
- }, [overlayVisibleState, props.value]);
1187
- useUpdateEffect(function () {
1188
- if (overlayVisibleState && filterState && props.filter) {
1189
- alignOverlay();
1190
- }
1191
- }, [overlayVisibleState, filterState, props.filter]);
1192
- useUpdateEffect(function () {
1193
- if (filterState && (!props.options || props.options.length === 0)) {
1194
- setFilterState('');
1195
- }
1196
- updateInputField();
1197
- if (inputRef.current) {
1198
- inputRef.current.selectedIndex = 1;
1199
- }
1200
- });
1201
- useUnmountEffect(function () {
1202
- ZIndexUtils.clear(overlayRef.current);
1203
- });
1204
- var createHiddenSelect = function createHiddenSelect() {
1205
- var option = {
1206
- value: '',
1207
- label: props.placeholder
1208
- };
1209
- if (selectedOption) {
1210
- var optionValue = getOptionValue(selectedOption);
1211
- option = {
1212
- value: _typeof(optionValue) === 'object' ? props.options.findIndex(function (o) {
1213
- return o === optionValue;
1214
- }) : optionValue,
1215
- label: getOptionLabel(selectedOption)
1216
- };
1217
- }
1218
- var hiddenSelectedMessageProps = mergeProps({
1219
- className: 'p-hidden-accessible p-dropdown-hidden-select'
1220
- }, ptm('hiddenSelectedMessage'));
1221
- var selectProps = mergeProps({
1222
- ref: inputRef,
1223
- required: props.required,
1224
- defaultValue: option.value,
1225
- name: props.name,
1226
- tabIndex: -1,
1227
- 'aria-hidden': 'true'
1228
- }, ptm('select'));
1229
- var optionProps = mergeProps({
1230
- value: option.value
1231
- }, ptm('option'));
1232
- return /*#__PURE__*/React.createElement("div", hiddenSelectedMessageProps, /*#__PURE__*/React.createElement("select", selectProps, /*#__PURE__*/React.createElement("option", optionProps, option.label)));
1233
- };
1234
- var createKeyboardHelper = function createKeyboardHelper() {
1235
- var hiddenSelectedMessageProps = mergeProps({
1236
- className: 'p-hidden-accessible'
1237
- }, ptm('hiddenSelectedMessage'));
1238
- var inputProps = mergeProps(_objectSpread({
1239
- ref: focusInputRef,
1240
- id: props.inputId,
1241
- type: 'text',
1242
- readOnly: true,
1243
- 'aria-haspopup': 'listbox',
1244
- onFocus: onInputFocus,
1245
- onBlur: onInputBlur,
1246
- onKeyDown: onInputKeyDown,
1247
- disabled: props.disabled,
1248
- tabIndex: props.tabIndex
1249
- }, ariaProps), ptm('input'));
1250
- return /*#__PURE__*/React.createElement("div", hiddenSelectedMessageProps, /*#__PURE__*/React.createElement("input", inputProps));
1251
- };
1252
- var createLabel = function createLabel() {
1253
- var label = ObjectUtils.isNotEmpty(selectedOption) ? getOptionLabel(selectedOption) : null;
1254
- if (props.editable) {
1255
- var value = label || props.value || '';
1256
- var inputProps = mergeProps(_objectSpread({
1257
- ref: inputRef,
1258
- type: 'text',
1259
- defaultValue: value,
1260
- className: cx('input', {
1261
- label: label
1262
- }),
1263
- disabled: props.disabled,
1264
- placeholder: props.placeholder,
1265
- maxLength: props.maxLength,
1266
- onInput: onEditableInputChange,
1267
- onFocus: onEditableInputFocus,
1268
- onBlur: onInputBlur,
1269
- 'aria-haspopup': 'listbox'
1270
- }, ariaProps), ptm('input'));
1271
- return /*#__PURE__*/React.createElement("input", inputProps);
1272
- } else {
1273
- var content = props.valueTemplate ? ObjectUtils.getJSXElement(props.valueTemplate, selectedOption, props) : label || props.placeholder || 'empty';
1274
- var _inputProps = mergeProps({
1275
- ref: inputRef,
1276
- className: cx('input', {
1277
- label: label
1278
- })
1279
- }, ptm('input'));
1280
- return /*#__PURE__*/React.createElement("span", _inputProps, content);
1281
- }
1282
- };
1283
- var createClearIcon = function createClearIcon() {
1284
- if (props.value != null && props.showClear && !props.disabled) {
1285
- var clearIconProps = mergeProps({
1286
- className: cx('clearIcon'),
1287
- onPointerUp: clear
1288
- }, ptm('clearIcon'));
1289
- var icon = props.clearIcon || /*#__PURE__*/React.createElement(TimesIcon, clearIconProps);
1290
- return IconUtils.getJSXIcon(icon, _objectSpread({}, clearIconProps), {
1291
- props: props
1292
- });
1293
- }
1294
- return null;
1295
- };
1296
- var createDropdownIcon = function createDropdownIcon() {
1297
- var dropdownIconProps = mergeProps({
1298
- className: cx('dropdownIcon')
1299
- }, ptm('dropdownIcon'));
1300
- var icon = props.dropdownIcon || /*#__PURE__*/React.createElement(ChevronDownIcon, dropdownIconProps);
1301
- var dropdownIcon = IconUtils.getJSXIcon(icon, _objectSpread({}, dropdownIconProps), {
1302
- props: props
1303
- });
1304
- var ariaLabel = props.placeholder || props.ariaLabel;
1305
- var triggerProps = mergeProps({
1306
- className: cx('trigger'),
1307
- role: 'button',
1308
- 'aria-haspopup': 'listbox',
1309
- 'aria-expanded': overlayVisibleState,
1310
- 'aria-label': ariaLabel
1311
- }, ptm('trigger'));
1312
- return /*#__PURE__*/React.createElement("div", triggerProps, dropdownIcon);
1313
- };
1314
- var visibleOptions = getVisibleOptions();
1315
- var selectedOption = getSelectedOption();
1316
- var hasTooltip = ObjectUtils.isNotEmpty(props.tooltip);
1317
- var otherProps = DropdownBase.getOtherProps(props);
1318
- var ariaProps = ObjectUtils.reduceKeys(otherProps, DomHandler.ARIA_PROPS);
1319
- var hiddenSelect = createHiddenSelect();
1320
- var keyboardHelper = createKeyboardHelper();
1321
- var labelElement = createLabel();
1322
- var dropdownIcon = createDropdownIcon();
1323
- var clearIcon = createClearIcon();
1324
- var rootProps = mergeProps({
1325
- id: props.id,
1326
- ref: elementRef,
1327
- className: classNames(props.className, cx('root', {
1328
- focusedState: focusedState,
1329
- overlayVisibleState: overlayVisibleState
1330
- })),
1331
- style: props.style,
1332
- onClick: function onClick(e) {
1333
- return _onClick(e);
1334
- },
1335
- onMouseDown: props.onMouseDown,
1336
- onContextMenu: props.onContextMenu,
1337
- 'data-p-disabled': props.disabled,
1338
- 'data-p-focus': focusedState
1339
- }, otherProps, ptm('root'));
1340
- return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("div", rootProps, keyboardHelper, hiddenSelect, labelElement, clearIcon, dropdownIcon, /*#__PURE__*/React.createElement(DropdownPanel, _extends({
1341
- hostName: "Dropdown",
1342
- ref: overlayRef,
1343
- visibleOptions: visibleOptions,
1344
- virtualScrollerRef: virtualScrollerRef
1345
- }, props, {
1346
- appendTo: appendTo,
1347
- onClick: onPanelClick,
1348
- onOptionClick: onOptionClick,
1349
- filterValue: filterState,
1350
- hasFilter: hasFilter,
1351
- onFilterClearIconClick: onFilterClearIconClick,
1352
- resetFilter: resetFilter,
1353
- onFilterInputKeyDown: onFilterInputKeyDown,
1354
- onFilterInputChange: onFilterInputChange,
1355
- getOptionLabel: getOptionLabel,
1356
- getOptionRenderKey: getOptionRenderKey,
1357
- isOptionDisabled: isOptionDisabled,
1358
- getOptionGroupChildren: getOptionGroupChildren,
1359
- getOptionGroupLabel: getOptionGroupLabel,
1360
- getOptionGroupRenderKey: getOptionGroupRenderKey,
1361
- isSelected: isSelected,
1362
- getSelectedOptionIndex: getSelectedOptionIndex,
1363
- "in": overlayVisibleState,
1364
- onEnter: onOverlayEnter,
1365
- onEntered: onOverlayEntered,
1366
- onExit: onOverlayExit,
1367
- onExited: onOverlayExited,
1368
- ptm: ptm,
1369
- cx: cx,
1370
- sx: sx
1371
- }))), hasTooltip && /*#__PURE__*/React.createElement(Tooltip, _extends({
1372
- target: elementRef,
1373
- content: props.tooltip
1374
- }, props.tooltipOptions, {
1375
- pt: ptm('tooltip')
1376
- })));
1377
- }));
1378
- Dropdown.displayName = 'Dropdown';
1379
-
1380
- export { Dropdown };