@pedidopago/ui 1.7.26 → 1.8.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 (341) hide show
  1. package/dist/components/Alert/alert.test.js +1 -85
  2. package/dist/components/Alert/index.js +1 -63
  3. package/dist/components/Alert/styles.js +1 -32
  4. package/dist/components/Avatar/avatar.test.js +1 -67
  5. package/dist/components/Avatar/index.js +1 -94
  6. package/dist/components/Avatar/styles.js +1 -51
  7. package/dist/components/Badge/badge.test.js +1 -71
  8. package/dist/components/Badge/index.js +2 -43
  9. package/dist/components/Badge/styles.js +1 -33
  10. package/dist/components/Button/Button.test.js +1 -154
  11. package/dist/components/Button/index.js +1 -87
  12. package/dist/components/Button/styles.js +1 -112
  13. package/dist/components/Card/card.test.js +1 -30
  14. package/dist/components/Card/index.js +1 -44
  15. package/dist/components/Card/styles.js +1 -16
  16. package/dist/components/CheckboxInput/checkbox-input.test.js +1 -170
  17. package/dist/components/CheckboxInput/components/MultipleCheckbox.js +1 -205
  18. package/dist/components/CheckboxInput/index.js +1 -94
  19. package/dist/components/CheckboxInput/styles.js +1 -34
  20. package/dist/components/ChoiceList/index.d.ts +6 -0
  21. package/dist/components/ChoiceList/index.d.ts.map +1 -0
  22. package/dist/components/ChoiceList/index.js +1 -0
  23. package/dist/components/ChoiceList/styles.d.ts +22 -0
  24. package/dist/components/ChoiceList/styles.d.ts.map +1 -0
  25. package/dist/components/ChoiceList/styles.js +1 -0
  26. package/dist/components/ChoiceList/types.d.ts +24 -0
  27. package/dist/components/ChoiceList/types.d.ts.map +1 -0
  28. package/dist/components/ChoiceList/types.js +1 -0
  29. package/dist/components/CollapseCard/ExpandButton/index.js +1 -40
  30. package/dist/components/CollapseCard/ExpandButton/styles.js +1 -16
  31. package/dist/components/CollapseCard/expand-button.test.js +1 -161
  32. package/dist/components/CollapseCard/index.js +1 -98
  33. package/dist/components/CollapseCard/styles.js +1 -26
  34. package/dist/components/ColorPicker/colorpicker.test.js +1 -64
  35. package/dist/components/ColorPicker/components/ColorHue.js +1 -44
  36. package/dist/components/ColorPicker/components/ColorInput.js +1 -63
  37. package/dist/components/ColorPicker/components/ColorPickerBox.js +1 -52
  38. package/dist/components/ColorPicker/components/ColorPointer.js +1 -25
  39. package/dist/components/ColorPicker/components/ColorSelector.js +1 -107
  40. package/dist/components/ColorPicker/hooks/useCachedCallback.js +1 -16
  41. package/dist/components/ColorPicker/hooks/useHsva.js +1 -53
  42. package/dist/components/ColorPicker/index.js +1 -93
  43. package/dist/components/ColorPicker/styles.js +1 -46
  44. package/dist/components/ColorPicker/utils/checkers.js +1 -55
  45. package/dist/components/ColorPicker/utils/conversors.js +2 -243
  46. package/dist/components/ColorPicker/utils/parsers.js +10 -108
  47. package/dist/components/ComposeIcon/index.js +2 -48
  48. package/dist/components/ComposeIcon/styles.js +1 -53
  49. package/dist/components/DateInput/DateInput-example.js +7 -45
  50. package/dist/components/DateInput/components/ModalWrapper/index.js +1 -35
  51. package/dist/components/DateInput/components/ModalWrapper/styles.js +1 -21
  52. package/dist/components/DateInput/dateInput.test.js +2 -43
  53. package/dist/components/DateInput/index.js +2 -104
  54. package/dist/components/DateInput/styles.js +1 -18
  55. package/dist/components/DatePicker/components/DatePickerContent.js +2 -222
  56. package/dist/components/DatePicker/components/DateYearPicker.js +1 -102
  57. package/dist/components/DatePicker/datepicker.test.js +1 -120
  58. package/dist/components/DatePicker/index.js +1 -236
  59. package/dist/components/DatePicker/styles.js +1 -88
  60. package/dist/components/DatePicker/utils/getMonthName.js +1 -11
  61. package/dist/components/Dialog/dialog-example.js +1 -46
  62. package/dist/components/Dialog/dialog.test.js +1 -68
  63. package/dist/components/Dialog/index.js +2 -100
  64. package/dist/components/Dialog/styles.js +1 -31
  65. package/dist/components/Dropzone/dropzone.test.js +1 -69
  66. package/dist/components/Dropzone/index.js +1 -289
  67. package/dist/components/Dropzone/styles.js +1 -75
  68. package/dist/components/Dropzone/utils/accepts.js +2 -27
  69. package/dist/components/EmojiPicker/Emote/index.js +2 -24
  70. package/dist/components/EmojiPicker/Emote/styles.js +1 -27
  71. package/dist/components/EmojiPicker/EmotePickerData/constants.js +1 -51
  72. package/dist/components/EmojiPicker/EmotePickerData/index.js +2 -159
  73. package/dist/components/EmojiPicker/EmotePickerData/styles.js +1 -57
  74. package/dist/components/EmojiPicker/EmotePickerData/utils.js +1 -41
  75. package/dist/components/EmojiPicker/Example/EmotePickerExample.js +1 -43
  76. package/dist/components/EmojiPicker/animation.js +1 -43
  77. package/dist/components/EmojiPicker/index.js +1 -169
  78. package/dist/components/EmojiPicker/styles.js +1 -21
  79. package/dist/components/Flex/flex.test.js +1 -336
  80. package/dist/components/Flex/index.js +1 -49
  81. package/dist/components/Flex/styles.js +1 -25
  82. package/dist/components/Grid/grid.test.js +1 -134
  83. package/dist/components/Grid/index.js +1 -51
  84. package/dist/components/Grid/styles.js +1 -48
  85. package/dist/components/Icon/data/beauty.js +2 -206
  86. package/dist/components/Icon/data/dash.js +2 -2
  87. package/dist/components/Icon/data/ecommerce.js +2 -94
  88. package/dist/components/Icon/data/form.js +2 -248
  89. package/dist/components/Icon/data/health.js +2 -255
  90. package/dist/components/Icon/data/illustrations.js +2 -318
  91. package/dist/components/Icon/data/men.js +2 -52
  92. package/dist/components/Icon/data/payment.js +2 -94
  93. package/dist/components/Icon/data/pedidoPago.js +2 -45
  94. package/dist/components/Icon/data/physicalPerfomance.js +2 -283
  95. package/dist/components/Icon/data/social.js +2 -24
  96. package/dist/components/Icon/data/status.js +2 -115
  97. package/dist/components/Icon/data/summer.js +2 -52
  98. package/dist/components/Icon/data/woman.js +2 -80
  99. package/dist/components/Icon/icon.test.js +1 -57
  100. package/dist/components/Icon/index.js +1 -53
  101. package/dist/components/Icon/scripts/build.js +9 -104
  102. package/dist/components/Icon/scripts/extractor.js +2 -33
  103. package/dist/components/Icon/scripts/run-build.js +2 -7
  104. package/dist/components/Icon/scripts/writers.js +3 -34
  105. package/dist/components/Icon/styles.js +1 -22
  106. package/dist/components/Icon/utils/allIcons.js +1 -28
  107. package/dist/components/Icon/utils/iconExists.js +1 -13
  108. package/dist/components/IconItem/IconItem.test.js +1 -58
  109. package/dist/components/IconItem/index.js +1 -52
  110. package/dist/components/IconItem/styles.js +1 -43
  111. package/dist/components/Illustration/illustration.test.js +4 -50
  112. package/dist/components/Illustration/index.js +2 -65
  113. package/dist/components/Illustration/styles.js +1 -65
  114. package/dist/components/ImageItem/imageFake.js +1 -25
  115. package/dist/components/ImageItem/index.js +2 -66
  116. package/dist/components/ImageItem/input.test.js +1 -85
  117. package/dist/components/ImageItem/styles.js +1 -61
  118. package/dist/components/Input/index.js +1 -163
  119. package/dist/components/Input/input.test.js +1 -120
  120. package/dist/components/Input/styles.js +1 -177
  121. package/dist/components/Label/index.js +1 -45
  122. package/dist/components/Label/label.test.js +1 -83
  123. package/dist/components/Label/styles.js +1 -21
  124. package/dist/components/List/index.js +1 -39
  125. package/dist/components/List/list.test.js +1 -64
  126. package/dist/components/List/styles.js +1 -23
  127. package/dist/components/Modal/ModalExample.js +1 -70
  128. package/dist/components/Modal/index.js +1 -145
  129. package/dist/components/Modal/modal.test.js +1 -179
  130. package/dist/components/Modal/styles.js +1 -33
  131. package/dist/components/MultipleSelect/MultipleSelect.test.js +1 -334
  132. package/dist/components/MultipleSelect/animations.js +1 -25
  133. package/dist/components/MultipleSelect/components/InputWrapper/index.js +1 -26
  134. package/dist/components/MultipleSelect/components/OptionsArea/index.js +1 -244
  135. package/dist/components/MultipleSelect/components/OptionsArea/styles.js +1 -68
  136. package/dist/components/MultipleSelect/components/SelectArea/ButtonsArea.js +1 -27
  137. package/dist/components/MultipleSelect/components/SelectArea/SelectAreaWrapper.js +1 -37
  138. package/dist/components/MultipleSelect/components/SelectArea/SelectedOptionsArea.js +1 -49
  139. package/dist/components/MultipleSelect/components/SelectArea/index.js +1 -100
  140. package/dist/components/MultipleSelect/components/SelectArea/styles.js +1 -36
  141. package/dist/components/MultipleSelect/components/index.js +1 -38
  142. package/dist/components/MultipleSelect/index.js +1 -209
  143. package/dist/components/NewSelect/Examples/constants.js +1 -56
  144. package/dist/components/NewSelect/Examples/index.js +1 -161
  145. package/dist/components/NewSelect/components/Chip/index.js +1 -36
  146. package/dist/components/NewSelect/components/Chip/styles.js +1 -24
  147. package/dist/components/NewSelect/components/OptionsSelect/styles.js +1 -21
  148. package/dist/components/NewSelect/components/SelectInputSearch/index.js +1 -24
  149. package/dist/components/NewSelect/components/SelectItem/index.js +1 -22
  150. package/dist/components/NewSelect/components/SelectItem/styles.js +1 -24
  151. package/dist/components/NewSelect/index.js +1 -18
  152. package/dist/components/NewSelect/multiple/index.js +1 -246
  153. package/dist/components/NewSelect/newSelect.test.js +1 -108
  154. package/dist/components/NewSelect/single/index.js +1 -183
  155. package/dist/components/NewSelect/styles.js +1 -44
  156. package/dist/components/Observer/index.js +1 -59
  157. package/dist/components/Observer/observer.test.js +2 -43
  158. package/dist/components/Pagination/hooks/usePagination.js +1 -57
  159. package/dist/components/Pagination/index.js +1 -174
  160. package/dist/components/Pagination/pagination.test.js +1 -118
  161. package/dist/components/Pagination/styles.js +1 -78
  162. package/dist/components/Progress/Circle/index.js +1 -102
  163. package/dist/components/Progress/Circle/styles.js +1 -69
  164. package/dist/components/Progress/Linear/index.js +1 -62
  165. package/dist/components/Progress/Linear/styles.js +1 -66
  166. package/dist/components/Progress/getSteps.js +1 -17
  167. package/dist/components/Progress/index.js +1 -39
  168. package/dist/components/Progress/progress.test.js +1 -109
  169. package/dist/components/Radio/components/RadioGroup/index.d.ts +5 -0
  170. package/dist/components/Radio/components/RadioGroup/index.d.ts.map +1 -0
  171. package/dist/components/Radio/components/RadioGroup/index.js +1 -0
  172. package/dist/components/Radio/components/RadioGroup/styles.d.ts +19 -0
  173. package/dist/components/Radio/components/RadioGroup/styles.d.ts.map +1 -0
  174. package/dist/components/Radio/components/RadioGroup/styles.js +1 -0
  175. package/dist/components/Radio/components/RadioGroup/types.d.ts +17 -0
  176. package/dist/components/Radio/components/RadioGroup/types.d.ts.map +1 -0
  177. package/dist/components/Radio/components/RadioGroup/types.js +1 -0
  178. package/dist/components/Radio/index.d.ts +5 -0
  179. package/dist/components/Radio/index.d.ts.map +1 -0
  180. package/dist/components/Radio/index.js +1 -0
  181. package/dist/components/Radio/styles.d.ts +10 -0
  182. package/dist/components/Radio/styles.d.ts.map +1 -0
  183. package/dist/components/Radio/styles.js +1 -0
  184. package/dist/components/Radio/types.d.ts +6 -0
  185. package/dist/components/Radio/types.d.ts.map +1 -0
  186. package/dist/components/Radio/types.js +1 -0
  187. package/dist/components/Rating/index.js +1 -133
  188. package/dist/components/Rating/rating.test.js +1 -63
  189. package/dist/components/Rating/styles.js +1 -27
  190. package/dist/components/ReactPortal/index.js +1 -43
  191. package/dist/components/ReactPortal/reactPortal.test.js +1 -21
  192. package/dist/components/ReactPortal/utils/createWrapperAndApprendToBody.js +1 -12
  193. package/dist/components/Select/components/OptionsSelect/index.js +1 -73
  194. package/dist/components/Select/components/OptionsSelect/styles.js +1 -21
  195. package/dist/components/Select/index.js +4 -247
  196. package/dist/components/Select/select.test.js +1 -58
  197. package/dist/components/Select/styles.js +1 -46
  198. package/dist/components/Skeleton/index.js +1 -28
  199. package/dist/components/Skeleton/skeleton.test.js +1 -90
  200. package/dist/components/Skeleton/styles.js +1 -27
  201. package/dist/components/Slider/SliderExample.js +1 -52
  202. package/dist/components/Slider/components/SliderPointer.js +1 -39
  203. package/dist/components/Slider/components/SliderRail.js +1 -116
  204. package/dist/components/Slider/components/SliderSelector.js +1 -173
  205. package/dist/components/Slider/hooks/useEventCallback.js +1 -16
  206. package/dist/components/Slider/index.js +1 -137
  207. package/dist/components/Slider/slider.test.js +1 -121
  208. package/dist/components/Slider/styles.js +1 -69
  209. package/dist/components/Spinner/index.js +1 -26
  210. package/dist/components/Spinner/spinner.test.js +1 -45
  211. package/dist/components/Spinner/styles.js +1 -23
  212. package/dist/components/Steps/components/StepIcon/index.js +1 -50
  213. package/dist/components/Steps/components/StepIcon/styles.js +1 -42
  214. package/dist/components/Steps/components/StepIcon/utils.js +1 -22
  215. package/dist/components/Steps/index.js +1 -116
  216. package/dist/components/Steps/steps.test.js +1 -53
  217. package/dist/components/Steps/styles.js +1 -96
  218. package/dist/components/Steps/utils.js +1 -15
  219. package/dist/components/Switch/index.js +1 -73
  220. package/dist/components/Switch/styles.js +1 -58
  221. package/dist/components/Switch/switch.test.js +2 -115
  222. package/dist/components/Table/components/MenuItem.js +1 -59
  223. package/dist/components/Table/components/TableSkeleton.js +1 -39
  224. package/dist/components/Table/components/animations.js +1 -24
  225. package/dist/components/Table/index.js +2 -253
  226. package/dist/components/Table/styles.js +1 -49
  227. package/dist/components/Table/table.test.js +1 -114
  228. package/dist/components/Tabs/TabsExample.js +1 -64
  229. package/dist/components/Tabs/components/Tab.js +1 -49
  230. package/dist/components/Tabs/components/TabPanel.js +1 -25
  231. package/dist/components/Tabs/components/Tabs.js +1 -107
  232. package/dist/components/Tabs/index.js +1 -26
  233. package/dist/components/Tabs/styles.js +1 -61
  234. package/dist/components/Tabs/tabs.test.js +1 -146
  235. package/dist/components/Tag/index.js +1 -53
  236. package/dist/components/Tag/styles.js +1 -34
  237. package/dist/components/Tag/tag.test.js +1 -64
  238. package/dist/components/TextAreaInput/index.js +1 -74
  239. package/dist/components/TextAreaInput/styles.js +1 -53
  240. package/dist/components/TextAreaInput/text-area-input.test.js +1 -81
  241. package/dist/components/Thumbnail/index.js +1 -125
  242. package/dist/components/Thumbnail/styles.js +1 -47
  243. package/dist/components/Thumbnail/thumbnail.test.js +1 -66
  244. package/dist/components/Thumbnail/utils/index.js +1 -27
  245. package/dist/components/Thumbnail/utils/validate-file-size.js +1 -10
  246. package/dist/components/Thumbnail/utils/validate-file-type.js +1 -9
  247. package/dist/components/TimeInput/constants.js +1 -29
  248. package/dist/components/TimeInput/index.js +1 -288
  249. package/dist/components/TimeInput/styles.js +1 -34
  250. package/dist/components/TimeInput/utils.js +1 -94
  251. package/dist/components/Timeline/components/Timeline.js +1 -17
  252. package/dist/components/Timeline/components/TimelineContent.js +1 -61
  253. package/dist/components/Timeline/components/TimelineItem.js +1 -25
  254. package/dist/components/Timeline/components/TimelineSeparator.js +1 -20
  255. package/dist/components/Timeline/index.js +1 -33
  256. package/dist/components/Timeline/styles.js +1 -37
  257. package/dist/components/Timeline/timeline.test.js +1 -138
  258. package/dist/components/Toast/button-example.js +1 -31
  259. package/dist/components/Toast/components/Toast.js +1 -79
  260. package/dist/components/Toast/contexts/ToastProvider.js +1 -72
  261. package/dist/components/Toast/hooks/useToast.js +1 -18
  262. package/dist/components/Toast/index.js +1 -111
  263. package/dist/components/Toast/styles.js +1 -36
  264. package/dist/components/Toast/toast.test.js +1 -129
  265. package/dist/components/Tooltip/components/TooltipLabel.js +1 -71
  266. package/dist/components/Tooltip/example.js +1 -27
  267. package/dist/components/Tooltip/index.js +1 -187
  268. package/dist/components/Tooltip/styles.js +1 -20
  269. package/dist/components/Typography/index.js +1 -37
  270. package/dist/components/Typography/styles.js +1 -15
  271. package/dist/components/Typography/typography.test.js +1 -288
  272. package/dist/index.d.ts +5 -2
  273. package/dist/index.d.ts.map +1 -1
  274. package/dist/index.js +1 -548
  275. package/dist/shared/animations/opacityAnimation.js +1 -21
  276. package/dist/shared/assets/emotes.js +1 -1
  277. package/dist/shared/components/FocusLock/index.js +5 -86
  278. package/dist/shared/formatters/format-number.js +5 -41
  279. package/dist/shared/global.js +1 -8
  280. package/dist/shared/hooks/devices.js +1 -14
  281. package/dist/shared/hooks/useBreakpoints.js +2 -95
  282. package/dist/shared/hooks/useDebounce.js +1 -35
  283. package/dist/shared/hooks/useDevices.js +2 -42
  284. package/dist/shared/hooks/useDisableBodyScroll.js +5 -52
  285. package/dist/shared/hooks/useDraggableScroll/index.js +5 -65
  286. package/dist/shared/hooks/useKeyPress.js +1 -18
  287. package/dist/shared/hooks/useObserver.js +2 -29
  288. package/dist/shared/hooks/useOnClickOutside.js +1 -30
  289. package/dist/shared/hooks/useReposition/index.js +2 -53
  290. package/dist/shared/hooks/useSystemTheme.js +1 -38
  291. package/dist/shared/hooks/useWindowSize.js +1 -36
  292. package/dist/shared/tests/test-utils.js +1 -31
  293. package/dist/shared/theme/button-example.js +1 -31
  294. package/dist/shared/theme/contexts/ThemeContext.js +1 -90
  295. package/dist/shared/theme/hooks/useColorMode.js +1 -18
  296. package/dist/shared/theme/hooks/useColorModeValue.js +1 -13
  297. package/dist/shared/theme/hooks/useTheme.js +1 -17
  298. package/dist/shared/theme/index.js +1 -67
  299. package/dist/shared/theme/objects/breakpoints.js +1 -15
  300. package/dist/shared/theme/objects/colors.js +1 -177
  301. package/dist/shared/theme/objects/shadows.js +1 -19
  302. package/dist/shared/theme/objects/sizes.js +6 -33
  303. package/dist/shared/theme/objects/spaces.js +1 -75
  304. package/dist/shared/theme/objects/transitions.js +1 -10
  305. package/dist/shared/theme/objects/typography.js +1 -20
  306. package/dist/shared/theme/objects/z-indexes.js +1 -20
  307. package/dist/shared/theme/theme.js +1 -36
  308. package/dist/shared/theme/theme.test.js +1 -94
  309. package/dist/shared/theme/utils/extendTheme.js +1 -25
  310. package/dist/shared/theme/utils/localStorageController.js +1 -21
  311. package/dist/styled.d.js +1 -3
  312. package/dist/utils/GenerateKey.js +3 -18
  313. package/dist/utils/brightnessColorChange.js +2 -17
  314. package/dist/utils/colorCheck.js +6 -64
  315. package/dist/utils/colorFunctions.js +1 -39
  316. package/dist/utils/colorToGray.js +2 -64
  317. package/dist/utils/customColorMode.js +1 -11
  318. package/dist/utils/file.js +5 -124
  319. package/dist/utils/formatters/bytes.js +2 -17
  320. package/dist/utils/formatters/capitalize.js +2 -11
  321. package/dist/utils/formatters/cep.js +3 -18
  322. package/dist/utils/formatters/cnpj.js +4 -38
  323. package/dist/utils/formatters/color.js +12 -101
  324. package/dist/utils/formatters/cpf.js +16 -85
  325. package/dist/utils/formatters/credit-card.js +5 -54
  326. package/dist/utils/formatters/email.js +1 -8
  327. package/dist/utils/formatters/index.js +1 -170
  328. package/dist/utils/formatters/name.js +4 -31
  329. package/dist/utils/formatters/number.js +5 -14
  330. package/dist/utils/formatters/passport.js +5 -33
  331. package/dist/utils/formatters/phone.js +17 -214
  332. package/dist/utils/formatters/price.js +3 -21
  333. package/dist/utils/formatters/rg.js +3 -18
  334. package/dist/utils/formatters/strings.js +4 -27
  335. package/dist/utils/fuctionsColors.js +1 -39
  336. package/dist/utils/generateUUID.js +1 -13
  337. package/dist/utils/getColorValue.js +2 -23
  338. package/dist/utils/getSvg.js +1 -17
  339. package/dist/utils/getValuesBySize.js +1 -9
  340. package/dist/utils/invertColor.js +4 -40
  341. package/package.json +2 -1
@@ -1,246 +1 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.NewMultipleSelect = NewMultipleSelect;
7
- var _react = require("react");
8
- var _classnames = _interopRequireDefault(require("classnames"));
9
- var _Flex = _interopRequireDefault(require("../../Flex"));
10
- var _Icon = _interopRequireDefault(require("../../Icon"));
11
- var _ReactPortal = require("../../ReactPortal");
12
- var _styles = require("../components/OptionsSelect/styles");
13
- var _useReposition = require("../../../shared/hooks/useReposition");
14
- var _useOnClickOutside = require("../../../shared/hooks/useOnClickOutside");
15
- var _styles2 = require("../styles");
16
- var _SelectItem = require("../components/SelectItem");
17
- var _jsxRuntime = require("react/jsx-runtime");
18
- var _excluded = ["label", "placeholder", "alert", "helperText", "variant", "children", "value", "onClose", "onOpen", "renderOptions", "onChange"];
19
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
20
- function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
21
- function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
22
- function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
23
- function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
24
- function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
25
- function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
26
- 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); }
27
- 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; }
28
- function _iterableToArrayLimit(arr, i) { var _i = null == arr ? null : "undefined" != typeof Symbol && arr[Symbol.iterator] || arr["@@iterator"]; if (null != _i) { var _s, _e, _x, _r, _arr = [], _n = !0, _d = !1; try { if (_x = (_i = _i.call(arr)).next, 0 === i) { if (Object(_i) !== _i) return; _n = !1; } else for (; !(_n = (_s = _x.call(_i)).done) && (_arr.push(_s.value), _arr.length !== i); _n = !0); } catch (err) { _d = !0, _e = err; } finally { try { if (!_n && null != _i.return && (_r = _i.return(), Object(_r) !== _r)) return; } finally { if (_d) throw _e; } } return _arr; } }
29
- function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
30
- function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
31
- function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
32
- function NewMultipleSelect(_ref) {
33
- var _containerRef$current;
34
- var _ref$label = _ref.label,
35
- label = _ref$label === void 0 ? '' : _ref$label,
36
- _ref$placeholder = _ref.placeholder,
37
- placeholder = _ref$placeholder === void 0 ? '' : _ref$placeholder,
38
- alert = _ref.alert,
39
- helperText = _ref.helperText,
40
- variant = _ref.variant,
41
- children = _ref.children,
42
- value = _ref.value,
43
- onClose = _ref.onClose,
44
- onOpen = _ref.onOpen,
45
- renderOptions = _ref.renderOptions,
46
- onChange = _ref.onChange,
47
- rest = _objectWithoutProperties(_ref, _excluded);
48
- var containerRef = (0, _react.useRef)(null);
49
- var selectRef = (0, _react.useRef)(null);
50
- var _useState = (0, _react.useState)(false),
51
- _useState2 = _slicedToArray(_useState, 2),
52
- isOpenOptions = _useState2[0],
53
- setIsOpenOptions = _useState2[1];
54
- var _useState3 = (0, _react.useState)([]),
55
- _useState4 = _slicedToArray(_useState3, 2),
56
- selectedOptions = _useState4[0],
57
- setSelectedOptions = _useState4[1];
58
- var multipleSelectValues = selectedOptions.map(function (option) {
59
- return option.value;
60
- });
61
- var optionsModalRef = (0, _react.useRef)(null);
62
- var _useState5 = (0, _react.useState)([]),
63
- _useState6 = _slicedToArray(_useState5, 2),
64
- options = _useState6[0],
65
- setOptions = _useState6[1];
66
- (0, _react.useEffect)(function () {
67
- var _optionsModalRef$curr;
68
- var childs = (_optionsModalRef$curr = optionsModalRef.current) === null || _optionsModalRef$curr === void 0 ? void 0 : _optionsModalRef$curr.childNodes;
69
- var newOptions = [];
70
- _react.Children.forEach(children, function (child, index) {
71
- var _childs$index, _childs$index$classLi;
72
- if (childs !== null && childs !== void 0 && (_childs$index = childs[index]) !== null && _childs$index !== void 0 && (_childs$index$classLi = _childs$index.classList) !== null && _childs$index$classLi !== void 0 && _childs$index$classLi.contains('select-item')) {
73
- var _child$props, _childs$index2;
74
- newOptions.push({
75
- value: child === null || child === void 0 ? void 0 : (_child$props = child.props) === null || _child$props === void 0 ? void 0 : _child$props.value,
76
- label: childs === null || childs === void 0 ? void 0 : (_childs$index2 = childs[index]) === null || _childs$index2 === void 0 ? void 0 : _childs$index2.innerText
77
- });
78
- }
79
- });
80
- setOptions(newOptions);
81
- }, [children, optionsModalRef.current]);
82
- function changeMultipleOption(valueOption) {
83
- if (valueOption === undefined) {
84
- setSelectedOptions([]);
85
- setIsOpenOptions(false);
86
- return;
87
- }
88
- var findOption = selectedOptions.find(function (option) {
89
- return option.value === valueOption;
90
- });
91
- if (findOption) {
92
- removeOption(valueOption);
93
- } else {
94
- var newOption = options.find(function (option) {
95
- return option.value === valueOption;
96
- });
97
- if (newOption) {
98
- setSelectedOptions([].concat(_toConsumableArray(selectedOptions), [newOption]));
99
- }
100
- onChange === null || onChange === void 0 ? void 0 : onChange([].concat(_toConsumableArray(multipleSelectValues), [valueOption]));
101
- }
102
- }
103
- (0, _react.useEffect)(function () {
104
- function handler() {
105
- setIsOpenOptions(false);
106
- }
107
- if (isOpenOptions) {
108
- var _document;
109
- onOpen === null || onOpen === void 0 ? void 0 : onOpen();
110
- (_document = document) === null || _document === void 0 ? void 0 : _document.addEventListener('scroll', handler);
111
- } else {
112
- var _document2;
113
- onClose === null || onClose === void 0 ? void 0 : onClose();
114
- (_document2 = document) === null || _document2 === void 0 ? void 0 : _document2.removeEventListener('scroll', handler);
115
- }
116
- return function () {
117
- var _document3;
118
- return (_document3 = document) === null || _document3 === void 0 ? void 0 : _document3.removeEventListener('scroll', handler);
119
- };
120
- }, [isOpenOptions]);
121
- (0, _useOnClickOutside.useOnClickOutside)([containerRef, optionsModalRef], function () {
122
- if (isOpenOptions) {
123
- setIsOpenOptions(false);
124
- }
125
- });
126
- var positionsSelect = (0, _useReposition.useReposition)({
127
- containerRef: optionsModalRef,
128
- triggerRef: selectRef
129
- }, [children]);
130
- function removeOption(optionToRemove) {
131
- var newSelectedOptions = selectedOptions === null || selectedOptions === void 0 ? void 0 : selectedOptions.filter(function (option) {
132
- return option.value !== optionToRemove;
133
- });
134
- var newSelectedValues = newSelectedOptions.map(function (option) {
135
- return option.value;
136
- });
137
- setSelectedOptions(newSelectedOptions);
138
- onChange === null || onChange === void 0 ? void 0 : onChange(newSelectedValues);
139
- }
140
- var SelectedOptionsWithCustomComponent = function SelectedOptionsWithCustomComponent(_ref2) {
141
- var option = _ref2.option;
142
- return /*#__PURE__*/(0, _jsxRuntime.jsx)(_jsxRuntime.Fragment, {
143
- children: renderOptions === null || renderOptions === void 0 ? void 0 : renderOptions(option, function () {
144
- return removeOption(option.value);
145
- })
146
- });
147
- };
148
- (0, _react.useEffect)(function () {
149
- var newOptions = options.filter(function (option) {
150
- return value === null || value === void 0 ? void 0 : value.includes(option.value);
151
- });
152
- var newSelectedOptions = selectedOptions.filter(function (selectedOption) {
153
- return newOptions.every(function (newOption) {
154
- return newOption.value !== selectedOption.value;
155
- });
156
- });
157
- setSelectedOptions([].concat(_toConsumableArray(newSelectedOptions), _toConsumableArray(newOptions)));
158
- }, [value, options]);
159
- return /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
160
- ref: selectRef,
161
- style: {
162
- width: '100%'
163
- },
164
- children: /*#__PURE__*/(0, _jsxRuntime.jsxs)(_Flex.default, {
165
- direction: "column",
166
- style: {
167
- width: '100%'
168
- },
169
- children: [/*#__PURE__*/(0, _jsxRuntime.jsxs)(_styles2.SelectContainer, {
170
- "data-disabled": rest.disabled,
171
- "data-variant": variant,
172
- "data-label-in-top": !!(selectedOptions !== null && selectedOptions !== void 0 && selectedOptions[0]) || !!placeholder,
173
- alert: alert,
174
- tabIndex: rest.disabled ? -1 : 0,
175
- onClick: function onClick() {
176
- return setIsOpenOptions(!isOpenOptions);
177
- },
178
- className: rest.className,
179
- style: rest.style,
180
- ref: containerRef,
181
- children: [label && variant !== 'unstyled' && /*#__PURE__*/(0, _jsxRuntime.jsx)("label", {
182
- title: label,
183
- children: label
184
- }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_Flex.default, {
185
- spacing: "0.5rem",
186
- wrap: "wrap",
187
- style: {
188
- paddingBlock: '0.5rem'
189
- },
190
- children: selectedOptions !== null && selectedOptions !== void 0 && selectedOptions[0] ? selectedOptions.map(function (option, index) {
191
- return typeof renderOptions === 'function' ? /*#__PURE__*/(0, _jsxRuntime.jsx)(SelectedOptionsWithCustomComponent, {
192
- option: option
193
- }, "custom-option-selected-".concat(index)) : /*#__PURE__*/(0, _jsxRuntime.jsxs)(_styles2.SelectedOptionSpan, {
194
- hasSelectedOption: true,
195
- children: [option.label, selectedOptions.length > 1 && index < selectedOptions.length - 1 && ',']
196
- }, index);
197
- }) : /*#__PURE__*/(0, _jsxRuntime.jsx)(_styles2.SelectedOptionSpan, {
198
- title: "placeholder",
199
- children: placeholder
200
- })
201
- }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_Flex.default, {
202
- className: "select_container_icon",
203
- children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_Icon.default, {
204
- name: "chevron-down"
205
- })
206
- })]
207
- }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_ReactPortal.ReactPortal, {
208
- wrapperId: "portal-root",
209
- children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_styles.OptionsContainer, {
210
- ref: optionsModalRef,
211
- open: isOpenOptions,
212
- style: {
213
- maxWidth: "".concat((_containerRef$current = containerRef.current) === null || _containerRef$current === void 0 ? void 0 : _containerRef$current.getBoundingClientRect().width, "px"),
214
- left: positionsSelect.left,
215
- top: positionsSelect.top
216
- },
217
- children: _react.Children.map(children, function (child) {
218
- var isSelectItemElement = child.type === _SelectItem.SelectItem;
219
- if (! /*#__PURE__*/(0, _react.isValidElement)(child) || !isSelectItemElement) return /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
220
- children: child
221
- });
222
- var childElement = child;
223
- var isSelectedOption = selectedOptions.find(function (option) {
224
- var _childElement$props;
225
- return option.value === ((_childElement$props = childElement.props) === null || _childElement$props === void 0 ? void 0 : _childElement$props.value);
226
- });
227
- var className = (0, _classnames.default)('select-item', {
228
- selected: isSelectedOption
229
- });
230
- return /*#__PURE__*/(0, _react.cloneElement)(childElement, {
231
- onClick: function onClick(event) {
232
- if (event.currentTarget.classList.contains('select-item')) {
233
- changeMultipleOption(childElement.props.value);
234
- }
235
- },
236
- className: className
237
- });
238
- })
239
- })
240
- }), !!helperText && /*#__PURE__*/(0, _jsxRuntime.jsx)(_styles2.HelperText, {
241
- alert: alert,
242
- children: helperText
243
- })]
244
- })
245
- });
246
- }
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.NewMultipleSelect=NewMultipleSelect;var _react=require("react"),_classnames=_interopRequireDefault(require("classnames")),_Flex=_interopRequireDefault(require("../../Flex")),_Icon=_interopRequireDefault(require("../../Icon")),_ReactPortal=require("../../ReactPortal"),_styles=require("../components/OptionsSelect/styles"),_useReposition=require("../../../shared/hooks/useReposition"),_useOnClickOutside=require("../../../shared/hooks/useOnClickOutside"),_styles2=require("../styles"),_SelectItem=require("../components/SelectItem"),_jsxRuntime=require("react/jsx-runtime"),_excluded=["label","placeholder","alert","helperText","variant","children","value","onClose","onOpen","renderOptions","onChange"];function _interopRequireDefault(obj){return obj&&obj.__esModule?obj:{default:obj}}function _toConsumableArray(arr){return _arrayWithoutHoles(arr)||_iterableToArray(arr)||_unsupportedIterableToArray(arr)||_nonIterableSpread()}function _nonIterableSpread(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function _iterableToArray(iter){if("undefined"!=typeof Symbol&&null!=iter[Symbol.iterator]||null!=iter["@@iterator"])return Array.from(iter)}function _arrayWithoutHoles(arr){if(Array.isArray(arr))return _arrayLikeToArray(arr)}function _slicedToArray(arr,i){return _arrayWithHoles(arr)||_iterableToArrayLimit(arr,i)||_unsupportedIterableToArray(arr,i)||_nonIterableRest()}function _nonIterableRest(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function _unsupportedIterableToArray(o,minLen){if(o){if("string"==typeof o)return _arrayLikeToArray(o,minLen);var n=Object.prototype.toString.call(o).slice(8,-1);return"Object"===n&&o.constructor&&(n=o.constructor.name),"Map"===n||"Set"===n?Array.from(o):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?_arrayLikeToArray(o,minLen):void 0}}function _arrayLikeToArray(arr,len){(null==len||len>arr.length)&&(len=arr.length);for(var i=0,arr2=Array(len);i<len;i++)arr2[i]=arr[i];return arr2}function _iterableToArrayLimit(arr,i){var _i=null==arr?null:"undefined"!=typeof Symbol&&arr[Symbol.iterator]||arr["@@iterator"];if(null!=_i){var _s,_e,_x,_r,_arr=[],_n=!0,_d=!1;try{if(_x=(_i=_i.call(arr)).next,0===i){if(Object(_i)!==_i)return;_n=!1}else for(;!(_n=(_s=_x.call(_i)).done)&&(_arr.push(_s.value),_arr.length!==i);_n=!0);}catch(err){_d=!0,_e=err}finally{try{if(!_n&&null!=_i.return&&(_r=_i.return(),Object(_r)!==_r))return}finally{if(_d)throw _e}}return _arr}}function _arrayWithHoles(arr){if(Array.isArray(arr))return arr}function _objectWithoutProperties(source,excluded){if(null==source)return{};var key,i,target=_objectWithoutPropertiesLoose(source,excluded);if(Object.getOwnPropertySymbols){var sourceSymbolKeys=Object.getOwnPropertySymbols(source);for(i=0;i<sourceSymbolKeys.length;i++)key=sourceSymbolKeys[i],0<=excluded.indexOf(key)||Object.prototype.propertyIsEnumerable.call(source,key)&&(target[key]=source[key])}return target}function _objectWithoutPropertiesLoose(source,excluded){if(null==source)return{};var key,i,target={},sourceKeys=Object.keys(source);for(i=0;i<sourceKeys.length;i++)key=sourceKeys[i],0<=excluded.indexOf(key)||(target[key]=source[key]);return target}function NewMultipleSelect(_ref){function changeMultipleOption(valueOption){if(void 0===valueOption)return setSelectedOptions([]),void setIsOpenOptions(!1);var findOption=selectedOptions.find(function(option){return option.value===valueOption});if(findOption)removeOption(valueOption);else{var newOption=options.find(function(option){return option.value===valueOption});newOption&&setSelectedOptions([].concat(_toConsumableArray(selectedOptions),[newOption])),null===onChange||void 0===onChange?void 0:onChange([].concat(_toConsumableArray(multipleSelectValues),[valueOption]))}}function removeOption(optionToRemove){var newSelectedOptions=null===selectedOptions||void 0===selectedOptions?void 0:selectedOptions.filter(function(option){return option.value!==optionToRemove}),newSelectedValues=newSelectedOptions.map(function(option){return option.value});setSelectedOptions(newSelectedOptions),null===onChange||void 0===onChange?void 0:onChange(newSelectedValues)}var _containerRef$current,_ref$label=_ref.label,label=void 0===_ref$label?"":_ref$label,_ref$placeholder=_ref.placeholder,placeholder=void 0===_ref$placeholder?"":_ref$placeholder,alert=_ref.alert,helperText=_ref.helperText,variant=_ref.variant,children=_ref.children,value=_ref.value,onClose=_ref.onClose,onOpen=_ref.onOpen,renderOptions=_ref.renderOptions,onChange=_ref.onChange,rest=_objectWithoutProperties(_ref,_excluded),containerRef=(0,_react.useRef)(null),selectRef=(0,_react.useRef)(null),_useState=(0,_react.useState)(!1),_useState2=_slicedToArray(_useState,2),isOpenOptions=_useState2[0],setIsOpenOptions=_useState2[1],_useState3=(0,_react.useState)([]),_useState4=_slicedToArray(_useState3,2),selectedOptions=_useState4[0],setSelectedOptions=_useState4[1],multipleSelectValues=selectedOptions.map(function(option){return option.value}),optionsModalRef=(0,_react.useRef)(null),_useState5=(0,_react.useState)([]),_useState6=_slicedToArray(_useState5,2),options=_useState6[0],setOptions=_useState6[1];(0,_react.useEffect)(function(){var _optionsModalRef$curr,childs=null===(_optionsModalRef$curr=optionsModalRef.current)||void 0===_optionsModalRef$curr?void 0:_optionsModalRef$curr.childNodes,newOptions=[];_react.Children.forEach(children,function(child,index){var _childs$index,_childs$index$classLi;if(null!==childs&&void 0!==childs&&null!==(_childs$index=childs[index])&&void 0!==_childs$index&&null!==(_childs$index$classLi=_childs$index.classList)&&void 0!==_childs$index$classLi&&_childs$index$classLi.contains("select-item")){var _child$props,_childs$index2;newOptions.push({value:null===child||void 0===child||null===(_child$props=child.props)||void 0===_child$props?void 0:_child$props.value,label:null===childs||void 0===childs||null===(_childs$index2=childs[index])||void 0===_childs$index2?void 0:_childs$index2.innerText})}}),setOptions(newOptions)},[children,optionsModalRef.current]),(0,_react.useEffect)(function(){function handler(){setIsOpenOptions(!1)}if(isOpenOptions){var _document;null===onOpen||void 0===onOpen?void 0:onOpen(),null===(_document=document)||void 0===_document?void 0:_document.addEventListener("scroll",handler)}else{var _document2;null===onClose||void 0===onClose?void 0:onClose(),null===(_document2=document)||void 0===_document2?void 0:_document2.removeEventListener("scroll",handler)}return function(){var _document3;return null===(_document3=document)||void 0===_document3?void 0:_document3.removeEventListener("scroll",handler)}},[isOpenOptions]),(0,_useOnClickOutside.useOnClickOutside)([containerRef,optionsModalRef],function(){isOpenOptions&&setIsOpenOptions(!1)});var positionsSelect=(0,_useReposition.useReposition)({containerRef:optionsModalRef,triggerRef:selectRef},[children]),SelectedOptionsWithCustomComponent=function(_ref2){var option=_ref2.option;return/*#__PURE__*/(0,_jsxRuntime.jsx)(_jsxRuntime.Fragment,{children:null===renderOptions||void 0===renderOptions?void 0:renderOptions(option,function(){return removeOption(option.value)})})};return(0,_react.useEffect)(function(){var newOptions=options.filter(function(option){return null===value||void 0===value?void 0:value.includes(option.value)}),newSelectedOptions=selectedOptions.filter(function(selectedOption){return newOptions.every(function(newOption){return newOption.value!==selectedOption.value})});setSelectedOptions([].concat(_toConsumableArray(newSelectedOptions),_toConsumableArray(newOptions)))},[value,options]),/*#__PURE__*/(0,_jsxRuntime.jsx)("div",{ref:selectRef,style:{width:"100%"},children:/*#__PURE__*/(0,_jsxRuntime.jsxs)(_Flex.default,{direction:"column",style:{width:"100%"},children:[/*#__PURE__*/(0,_jsxRuntime.jsxs)(_styles2.SelectContainer,{"data-disabled":rest.disabled,"data-variant":variant,"data-label-in-top":!!(null!==selectedOptions&&void 0!==selectedOptions&&selectedOptions[0])||!!placeholder,alert:alert,tabIndex:rest.disabled?-1:0,onClick:function onClick(){return setIsOpenOptions(!isOpenOptions)},className:rest.className,style:rest.style,ref:containerRef,children:[label&&"unstyled"!==variant&&/*#__PURE__*/(0,_jsxRuntime.jsx)("label",{title:label,children:label}),/*#__PURE__*/(0,_jsxRuntime.jsx)(_Flex.default,{spacing:"0.5rem",wrap:"wrap",style:{paddingBlock:"0.5rem"},children:null!==selectedOptions&&void 0!==selectedOptions&&selectedOptions[0]?selectedOptions.map(function(option,index){return"function"==typeof renderOptions?/*#__PURE__*/(0,_jsxRuntime.jsx)(SelectedOptionsWithCustomComponent,{option:option},"custom-option-selected-".concat(index)):/*#__PURE__*/(0,_jsxRuntime.jsxs)(_styles2.SelectedOptionSpan,{hasSelectedOption:!0,children:[option.label,1<selectedOptions.length&&index<selectedOptions.length-1&&","]},index)}):/*#__PURE__*/(0,_jsxRuntime.jsx)(_styles2.SelectedOptionSpan,{title:"placeholder",children:placeholder})}),/*#__PURE__*/(0,_jsxRuntime.jsx)(_Flex.default,{className:"select_container_icon",children:/*#__PURE__*/(0,_jsxRuntime.jsx)(_Icon.default,{name:"chevron-down"})})]}),/*#__PURE__*/(0,_jsxRuntime.jsx)(_ReactPortal.ReactPortal,{wrapperId:"portal-root",children:/*#__PURE__*/(0,_jsxRuntime.jsx)(_styles.OptionsContainer,{ref:optionsModalRef,open:isOpenOptions,style:{maxWidth:"".concat(null===(_containerRef$current=containerRef.current)||void 0===_containerRef$current?void 0:_containerRef$current.getBoundingClientRect().width,"px"),left:positionsSelect.left,top:positionsSelect.top},children:_react.Children.map(children,function(child){var isSelectItemElement=(null===child||void 0===child?void 0:child.type)===_SelectItem.SelectItem;if(!/*#__PURE__*/(0,_react.isValidElement)(child)||!isSelectItemElement)return/*#__PURE__*/(0,_jsxRuntime.jsx)("div",{children:child});var childElement=child,isSelectedOption=selectedOptions.find(function(option){var _childElement$props;return option.value===(null===(_childElement$props=childElement.props)||void 0===_childElement$props?void 0:_childElement$props.value)}),className=(0,_classnames.default)("select-item",{selected:isSelectedOption});return/*#__PURE__*/(0,_react.cloneElement)(childElement,{onClick:function onClick(event){event.currentTarget.classList.contains("select-item")&&changeMultipleOption(childElement.props.value)},className:className})})})}),!!helperText&&/*#__PURE__*/(0,_jsxRuntime.jsx)(_styles2.HelperText,{alert:alert,children:helperText})]})})}
@@ -1,108 +1 @@
1
- "use strict";
2
-
3
- var _react = require("@testing-library/react");
4
- var _ = require(".");
5
- var _SelectItem = require("./components/SelectItem");
6
- var _testUtils = require("../../shared/tests/test-utils");
7
- var _jsxRuntime = require("react/jsx-runtime");
8
- var optionsSelect = [{
9
- label: 'Opção 1',
10
- value: 'option1'
11
- }, {
12
- label: 'Opção 2',
13
- value: 'option2'
14
- }];
15
- describe('Select', function () {
16
- test('Change option', function () {
17
- var handleClick = jest.fn();
18
- var _render = (0, _testUtils.render)( /*#__PURE__*/(0, _jsxRuntime.jsx)(_.NewSelect, {
19
- value: "option1",
20
- onChange: handleClick,
21
- children: optionsSelect.map(function (option) {
22
- return /*#__PURE__*/(0, _jsxRuntime.jsx)(_SelectItem.SelectItem, {
23
- value: option.value,
24
- children: option.label
25
- }, option.value);
26
- })
27
- })),
28
- getByRole = _render.getByRole,
29
- getByTestId = _render.getByTestId;
30
- var button = getByRole('button', {
31
- name: /opção 1/i
32
- });
33
- _react.fireEvent.click(button);
34
- var spanOfSelectedOption = getByTestId('span-selected-option');
35
- var textOfSpan = spanOfSelectedOption.textContent;
36
- expect(textOfSpan).toEqual('Opção 1');
37
- expect(handleClick).toHaveBeenCalledTimes(1);
38
- });
39
- test('Default value', function () {
40
- var handleClick = jest.fn();
41
- var _render2 = (0, _testUtils.render)( /*#__PURE__*/(0, _jsxRuntime.jsx)(_.NewSelect, {
42
- value: "option1",
43
- onChange: handleClick,
44
- children: optionsSelect.map(function (option) {
45
- return /*#__PURE__*/(0, _jsxRuntime.jsx)(_SelectItem.SelectItem, {
46
- value: option.value,
47
- children: option.label
48
- }, option.value);
49
- })
50
- })),
51
- getByTestId = _render2.getByTestId;
52
- var spanOfSelectedOption = getByTestId('span-selected-option');
53
- var textOfSpan = spanOfSelectedOption.textContent;
54
- expect(textOfSpan).toEqual('Opção 1');
55
- });
56
- });
57
- describe('MultipleSelect', function () {
58
- test('Change option ', function () {
59
- var _containerOfMultipleO;
60
- var handleClick = jest.fn();
61
- var _render3 = (0, _testUtils.render)( /*#__PURE__*/(0, _jsxRuntime.jsx)(_.NewSelect, {
62
- value: ['option1'],
63
- multiple: true,
64
- onChange: handleClick,
65
- children: optionsSelect.map(function (option) {
66
- return /*#__PURE__*/(0, _jsxRuntime.jsx)(_SelectItem.SelectItem, {
67
- value: option.value,
68
- children: option.label
69
- }, option.value);
70
- })
71
- })),
72
- getByTestId = _render3.getByTestId,
73
- getByRole = _render3.getByRole;
74
- var buttonFirstOption = getByRole('button', {
75
- name: /opção 1/i
76
- });
77
- var buttonSecondOption = getByRole('button', {
78
- name: /opção 2/i
79
- });
80
- _react.fireEvent.click(buttonSecondOption);
81
- expect(handleClick).toBeCalled();
82
- _react.fireEvent.click(buttonFirstOption);
83
- expect(handleClick).toBeCalled();
84
- var containerOfMultipleOptions = getByTestId('container-multiple-options');
85
- var firstOptionText = (_containerOfMultipleO = containerOfMultipleOptions.children[0]) === null || _containerOfMultipleO === void 0 ? void 0 : _containerOfMultipleO.textContent;
86
- expect(firstOptionText).toEqual('Opção 1');
87
- });
88
- test('default value', function () {
89
- var handleClick = jest.fn();
90
- var _render4 = (0, _testUtils.render)( /*#__PURE__*/(0, _jsxRuntime.jsx)(_.NewSelect, {
91
- value: ['option1', 'option2'],
92
- multiple: true,
93
- onChange: handleClick,
94
- children: optionsSelect.map(function (option) {
95
- return /*#__PURE__*/(0, _jsxRuntime.jsx)(_SelectItem.SelectItem, {
96
- value: option.value,
97
- children: option.label
98
- }, option.value);
99
- })
100
- })),
101
- getByTestId = _render4.getByTestId;
102
- var containerOfMultipleOptions = getByTestId('container-multiple-options');
103
- var firstOptionText = containerOfMultipleOptions.children[0].textContent;
104
- var secondOptionText = containerOfMultipleOptions.children[1].textContent;
105
- expect(firstOptionText).toEqual('Opção 1,');
106
- expect(secondOptionText).toEqual('Opção 2');
107
- });
108
- });
1
+ "use strict";var _react=require("@testing-library/react"),_=require("."),_SelectItem=require("./components/SelectItem"),_testUtils=require("../../shared/tests/test-utils"),_jsxRuntime=require("react/jsx-runtime"),optionsSelect=[{label:"Op\xE7\xE3o 1",value:"option1"},{label:"Op\xE7\xE3o 2",value:"option2"}];describe("Select",function(){test("Change option",function(){var handleClick=jest.fn(),_render=(0,_testUtils.render)(/*#__PURE__*/(0,_jsxRuntime.jsx)(_.NewSelect,{value:"option1",onChange:handleClick,children:optionsSelect.map(function(option){return/*#__PURE__*/(0,_jsxRuntime.jsx)(_SelectItem.SelectItem,{value:option.value,children:option.label},option.value)})})),getByRole=_render.getByRole,getByTestId=_render.getByTestId,button=getByRole("button",{name:/opção 1/i});_react.fireEvent.click(button);var spanOfSelectedOption=getByTestId("span-selected-option"),textOfSpan=spanOfSelectedOption.textContent;expect(textOfSpan).toEqual("Op\xE7\xE3o 1"),expect(handleClick).toHaveBeenCalledTimes(1)}),test("Default value",function(){var handleClick=jest.fn(),_render2=(0,_testUtils.render)(/*#__PURE__*/(0,_jsxRuntime.jsx)(_.NewSelect,{value:"option1",onChange:handleClick,children:optionsSelect.map(function(option){return/*#__PURE__*/(0,_jsxRuntime.jsx)(_SelectItem.SelectItem,{value:option.value,children:option.label},option.value)})})),getByTestId=_render2.getByTestId,spanOfSelectedOption=getByTestId("span-selected-option"),textOfSpan=spanOfSelectedOption.textContent;expect(textOfSpan).toEqual("Op\xE7\xE3o 1")})}),describe("MultipleSelect",function(){test("Change option ",function(){var _containerOfMultipleO,handleClick=jest.fn(),_render3=(0,_testUtils.render)(/*#__PURE__*/(0,_jsxRuntime.jsx)(_.NewSelect,{value:["option1"],multiple:!0,onChange:handleClick,children:optionsSelect.map(function(option){return/*#__PURE__*/(0,_jsxRuntime.jsx)(_SelectItem.SelectItem,{value:option.value,children:option.label},option.value)})})),getByTestId=_render3.getByTestId,getByRole=_render3.getByRole,buttonFirstOption=getByRole("button",{name:/opção 1/i}),buttonSecondOption=getByRole("button",{name:/opção 2/i});_react.fireEvent.click(buttonSecondOption),expect(handleClick).toBeCalled(),_react.fireEvent.click(buttonFirstOption),expect(handleClick).toBeCalled();var containerOfMultipleOptions=getByTestId("container-multiple-options"),firstOptionText=null===(_containerOfMultipleO=containerOfMultipleOptions.children[0])||void 0===_containerOfMultipleO?void 0:_containerOfMultipleO.textContent;expect(firstOptionText).toEqual("Op\xE7\xE3o 1")}),test("default value",function(){var handleClick=jest.fn(),_render4=(0,_testUtils.render)(/*#__PURE__*/(0,_jsxRuntime.jsx)(_.NewSelect,{value:["option1","option2"],multiple:!0,onChange:handleClick,children:optionsSelect.map(function(option){return/*#__PURE__*/(0,_jsxRuntime.jsx)(_SelectItem.SelectItem,{value:option.value,children:option.label},option.value)})})),getByTestId=_render4.getByTestId,containerOfMultipleOptions=getByTestId("container-multiple-options"),firstOptionText=containerOfMultipleOptions.children[0].textContent,secondOptionText=containerOfMultipleOptions.children[1].textContent;expect(firstOptionText).toEqual("Op\xE7\xE3o 1,"),expect(secondOptionText).toEqual("Op\xE7\xE3o 2")})});
@@ -1,183 +1 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.NewSingleSelect = NewSingleSelect;
7
- var _react = require("react");
8
- var _Flex = _interopRequireDefault(require("../../Flex"));
9
- var _Icon = _interopRequireDefault(require("../../Icon"));
10
- var _ReactPortal = require("../../ReactPortal");
11
- var _SelectItem = require("../components/SelectItem");
12
- var _useReposition = require("../../../shared/hooks/useReposition");
13
- var _useOnClickOutside = require("../../../shared/hooks/useOnClickOutside");
14
- var _styles = require("../components/OptionsSelect/styles");
15
- var _styles2 = require("../styles");
16
- var _jsxRuntime = require("react/jsx-runtime");
17
- var _excluded = ["label", "placeholder", "alert", "helperText", "variant", "children", "value", "onClose", "onOpen", "onChange", "renderOptions"];
18
- /* eslint-disable no-console */
19
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
20
- function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
21
- function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
22
- 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); }
23
- 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; }
24
- function _iterableToArrayLimit(arr, i) { var _i = null == arr ? null : "undefined" != typeof Symbol && arr[Symbol.iterator] || arr["@@iterator"]; if (null != _i) { var _s, _e, _x, _r, _arr = [], _n = !0, _d = !1; try { if (_x = (_i = _i.call(arr)).next, 0 === i) { if (Object(_i) !== _i) return; _n = !1; } else for (; !(_n = (_s = _x.call(_i)).done) && (_arr.push(_s.value), _arr.length !== i); _n = !0); } catch (err) { _d = !0, _e = err; } finally { try { if (!_n && null != _i.return && (_r = _i.return(), Object(_r) !== _r)) return; } finally { if (_d) throw _e; } } return _arr; } }
25
- function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
26
- function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
27
- function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
28
- function NewSingleSelect(_ref) {
29
- var _containerRef$current;
30
- var _ref$label = _ref.label,
31
- label = _ref$label === void 0 ? '' : _ref$label,
32
- _ref$placeholder = _ref.placeholder,
33
- placeholder = _ref$placeholder === void 0 ? '' : _ref$placeholder,
34
- alert = _ref.alert,
35
- helperText = _ref.helperText,
36
- variant = _ref.variant,
37
- children = _ref.children,
38
- value = _ref.value,
39
- onClose = _ref.onClose,
40
- onOpen = _ref.onOpen,
41
- onChange = _ref.onChange,
42
- renderOptions = _ref.renderOptions,
43
- rest = _objectWithoutProperties(_ref, _excluded);
44
- var containerRef = (0, _react.useRef)(null);
45
- var selectRef = (0, _react.useRef)(null);
46
- var _useState = (0, _react.useState)(false),
47
- _useState2 = _slicedToArray(_useState, 2),
48
- isOpenOptions = _useState2[0],
49
- setIsOpenOptions = _useState2[1];
50
- var _useState3 = (0, _react.useState)(),
51
- _useState4 = _slicedToArray(_useState3, 2),
52
- selectedOption = _useState4[0],
53
- setSelectedOption = _useState4[1];
54
- var optionsModalRef = (0, _react.useRef)(null);
55
- var _useState5 = (0, _react.useState)([]),
56
- _useState6 = _slicedToArray(_useState5, 2),
57
- options = _useState6[0],
58
- setOptions = _useState6[1];
59
- var findOption = options.find(function (option) {
60
- return option.value === selectedOption;
61
- });
62
- var isFalseOptions = (findOption === null || findOption === void 0 ? void 0 : findOption.value) === false;
63
- var textPlaceholder = findOption !== null && findOption !== void 0 && findOption.value || isFalseOptions ? findOption === null || findOption === void 0 ? void 0 : findOption.label : placeholder;
64
- (0, _react.useEffect)(function () {
65
- var _options$, _optionsModalRef$curr;
66
- if (options !== null && options !== void 0 && (_options$ = options[0]) !== null && _options$ !== void 0 && _options$.value) return;
67
- var childs = (_optionsModalRef$curr = optionsModalRef.current) === null || _optionsModalRef$curr === void 0 ? void 0 : _optionsModalRef$curr.childNodes;
68
- var newOptions = [];
69
- _react.Children.forEach(children, function (child, index) {
70
- var _childs$index, _childs$index$classLi;
71
- if (childs !== null && childs !== void 0 && (_childs$index = childs[index]) !== null && _childs$index !== void 0 && (_childs$index$classLi = _childs$index.classList) !== null && _childs$index$classLi !== void 0 && _childs$index$classLi.contains('select-item')) {
72
- var _child$props, _childs$index2;
73
- newOptions.push({
74
- value: child === null || child === void 0 ? void 0 : (_child$props = child.props) === null || _child$props === void 0 ? void 0 : _child$props.value,
75
- label: childs === null || childs === void 0 ? void 0 : (_childs$index2 = childs[index]) === null || _childs$index2 === void 0 ? void 0 : _childs$index2.innerText
76
- });
77
- }
78
- });
79
- setOptions(newOptions);
80
- }, [children, optionsModalRef.current, containerRef.current]);
81
- (0, _react.useEffect)(function () {
82
- function handler() {
83
- setIsOpenOptions(false);
84
- }
85
- if (isOpenOptions) {
86
- var _document;
87
- onOpen === null || onOpen === void 0 ? void 0 : onOpen();
88
- (_document = document) === null || _document === void 0 ? void 0 : _document.addEventListener('scroll', handler);
89
- } else {
90
- var _document2;
91
- onClose === null || onClose === void 0 ? void 0 : onClose();
92
- (_document2 = document) === null || _document2 === void 0 ? void 0 : _document2.removeEventListener('scroll', handler);
93
- }
94
- return function () {
95
- var _document3;
96
- return (_document3 = document) === null || _document3 === void 0 ? void 0 : _document3.removeEventListener('scroll', handler);
97
- };
98
- }, [isOpenOptions]);
99
- (0, _useOnClickOutside.useOnClickOutside)([containerRef, optionsModalRef], function () {
100
- if (isOpenOptions) {
101
- setIsOpenOptions(false);
102
- }
103
- });
104
- var positionsSelect = (0, _useReposition.useReposition)({
105
- containerRef: optionsModalRef,
106
- triggerRef: selectRef
107
- }, [children]);
108
- var SelectedOptionsWithCustomComponent = function SelectedOptionsWithCustomComponent() {
109
- return /*#__PURE__*/(0, _jsxRuntime.jsx)(_jsxRuntime.Fragment, {
110
- children: renderOptions === null || renderOptions === void 0 ? void 0 : renderOptions(selectedOption)
111
- });
112
- };
113
- (0, _react.useEffect)(function () {
114
- setSelectedOption(value);
115
- }, [value]);
116
- return /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
117
- ref: selectRef,
118
- style: {
119
- width: '100%'
120
- },
121
- children: /*#__PURE__*/(0, _jsxRuntime.jsxs)(_Flex.default, {
122
- direction: "column",
123
- style: {
124
- width: '100%'
125
- },
126
- children: [/*#__PURE__*/(0, _jsxRuntime.jsxs)(_styles2.SelectContainer, {
127
- "data-disabled": rest.disabled,
128
- "data-variant": variant,
129
- "data-label-in-top": !!textPlaceholder || !!placeholder,
130
- alert: alert,
131
- tabIndex: rest.disabled ? -1 : 0,
132
- onClick: function onClick() {
133
- return setIsOpenOptions(!isOpenOptions);
134
- },
135
- className: rest.className,
136
- style: rest.style,
137
- ref: containerRef,
138
- children: [label && variant !== 'unstyled' && /*#__PURE__*/(0, _jsxRuntime.jsx)("label", {
139
- children: label
140
- }), typeof renderOptions === 'function' && selectedOption ? /*#__PURE__*/(0, _jsxRuntime.jsx)(SelectedOptionsWithCustomComponent, {}, "custom-option-selected-".concat(textPlaceholder)) : /*#__PURE__*/(0, _jsxRuntime.jsx)(_styles2.SelectedOptionSpan, {
141
- hasSelectedOption: !!selectedOption || isFalseOptions,
142
- children: textPlaceholder
143
- }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_Flex.default, {
144
- className: "select_container_icon",
145
- children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_Icon.default, {
146
- name: "chevron-down",
147
- color: "neutral.neutral5"
148
- })
149
- })]
150
- }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_ReactPortal.ReactPortal, {
151
- wrapperId: "portal-root",
152
- children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_styles.OptionsContainer, {
153
- ref: optionsModalRef,
154
- open: isOpenOptions,
155
- style: {
156
- maxWidth: "".concat((_containerRef$current = containerRef.current) === null || _containerRef$current === void 0 ? void 0 : _containerRef$current.getBoundingClientRect().width, "px"),
157
- left: positionsSelect.left,
158
- top: positionsSelect.top
159
- },
160
- children: _react.Children.map(children, function (child) {
161
- var isSelectItemElement = child.type === _SelectItem.SelectItem;
162
- if (! /*#__PURE__*/(0, _react.isValidElement)(child) || !isSelectItemElement) return /*#__PURE__*/(0, _jsxRuntime.jsx)(_jsxRuntime.Fragment, {
163
- children: child
164
- });
165
- var childElement = child;
166
- return /*#__PURE__*/(0, _react.cloneElement)(childElement, {
167
- onClick: function onClick(event) {
168
- if (event.currentTarget.classList.contains('select-item')) {
169
- setIsOpenOptions(false);
170
- setSelectedOption(childElement.props.value);
171
- onChange === null || onChange === void 0 ? void 0 : onChange(childElement.props.value);
172
- }
173
- }
174
- });
175
- })
176
- })
177
- }), !!helperText && /*#__PURE__*/(0, _jsxRuntime.jsx)(_styles2.HelperText, {
178
- alert: alert,
179
- children: helperText
180
- })]
181
- })
182
- });
183
- }
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.NewSingleSelect=NewSingleSelect;var _react=require("react"),_Flex=_interopRequireDefault(require("../../Flex")),_Icon=_interopRequireDefault(require("../../Icon")),_ReactPortal=require("../../ReactPortal"),_SelectItem=require("../components/SelectItem"),_useReposition=require("../../../shared/hooks/useReposition"),_useOnClickOutside=require("../../../shared/hooks/useOnClickOutside"),_styles=require("../components/OptionsSelect/styles"),_styles2=require("../styles"),_jsxRuntime=require("react/jsx-runtime"),_excluded=["label","placeholder","alert","helperText","variant","children","value","onClose","onOpen","onChange","renderOptions"];/* eslint-disable no-console */function _interopRequireDefault(obj){return obj&&obj.__esModule?obj:{default:obj}}function _slicedToArray(arr,i){return _arrayWithHoles(arr)||_iterableToArrayLimit(arr,i)||_unsupportedIterableToArray(arr,i)||_nonIterableRest()}function _nonIterableRest(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function _unsupportedIterableToArray(o,minLen){if(o){if("string"==typeof o)return _arrayLikeToArray(o,minLen);var n=Object.prototype.toString.call(o).slice(8,-1);return"Object"===n&&o.constructor&&(n=o.constructor.name),"Map"===n||"Set"===n?Array.from(o):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?_arrayLikeToArray(o,minLen):void 0}}function _arrayLikeToArray(arr,len){(null==len||len>arr.length)&&(len=arr.length);for(var i=0,arr2=Array(len);i<len;i++)arr2[i]=arr[i];return arr2}function _iterableToArrayLimit(arr,i){var _i=null==arr?null:"undefined"!=typeof Symbol&&arr[Symbol.iterator]||arr["@@iterator"];if(null!=_i){var _s,_e,_x,_r,_arr=[],_n=!0,_d=!1;try{if(_x=(_i=_i.call(arr)).next,0===i){if(Object(_i)!==_i)return;_n=!1}else for(;!(_n=(_s=_x.call(_i)).done)&&(_arr.push(_s.value),_arr.length!==i);_n=!0);}catch(err){_d=!0,_e=err}finally{try{if(!_n&&null!=_i.return&&(_r=_i.return(),Object(_r)!==_r))return}finally{if(_d)throw _e}}return _arr}}function _arrayWithHoles(arr){if(Array.isArray(arr))return arr}function _objectWithoutProperties(source,excluded){if(null==source)return{};var key,i,target=_objectWithoutPropertiesLoose(source,excluded);if(Object.getOwnPropertySymbols){var sourceSymbolKeys=Object.getOwnPropertySymbols(source);for(i=0;i<sourceSymbolKeys.length;i++)key=sourceSymbolKeys[i],0<=excluded.indexOf(key)||Object.prototype.propertyIsEnumerable.call(source,key)&&(target[key]=source[key])}return target}function _objectWithoutPropertiesLoose(source,excluded){if(null==source)return{};var key,i,target={},sourceKeys=Object.keys(source);for(i=0;i<sourceKeys.length;i++)key=sourceKeys[i],0<=excluded.indexOf(key)||(target[key]=source[key]);return target}function NewSingleSelect(_ref){var _containerRef$current,_ref$label=_ref.label,label=void 0===_ref$label?"":_ref$label,_ref$placeholder=_ref.placeholder,placeholder=void 0===_ref$placeholder?"":_ref$placeholder,alert=_ref.alert,helperText=_ref.helperText,variant=_ref.variant,children=_ref.children,value=_ref.value,onClose=_ref.onClose,onOpen=_ref.onOpen,onChange=_ref.onChange,renderOptions=_ref.renderOptions,rest=_objectWithoutProperties(_ref,_excluded),containerRef=(0,_react.useRef)(null),selectRef=(0,_react.useRef)(null),_useState=(0,_react.useState)(!1),_useState2=_slicedToArray(_useState,2),isOpenOptions=_useState2[0],setIsOpenOptions=_useState2[1],_useState3=(0,_react.useState)(),_useState4=_slicedToArray(_useState3,2),selectedOption=_useState4[0],setSelectedOption=_useState4[1],optionsModalRef=(0,_react.useRef)(null),_useState5=(0,_react.useState)([]),_useState6=_slicedToArray(_useState5,2),options=_useState6[0],setOptions=_useState6[1],findOption=options.find(function(option){return option.value===selectedOption}),isFalseOptions=!1===(null===findOption||void 0===findOption?void 0:findOption.value),textPlaceholder=null!==findOption&&void 0!==findOption&&findOption.value||isFalseOptions?null===findOption||void 0===findOption?void 0:findOption.label:placeholder;(0,_react.useEffect)(function(){var _options$,_optionsModalRef$curr;if(!(null!==options&&void 0!==options&&null!==(_options$=options[0])&&void 0!==_options$&&_options$.value)){var childs=null===(_optionsModalRef$curr=optionsModalRef.current)||void 0===_optionsModalRef$curr?void 0:_optionsModalRef$curr.childNodes,newOptions=[];_react.Children.forEach(children,function(child,index){var _childs$index,_childs$index$classLi;if(null!==childs&&void 0!==childs&&null!==(_childs$index=childs[index])&&void 0!==_childs$index&&null!==(_childs$index$classLi=_childs$index.classList)&&void 0!==_childs$index$classLi&&_childs$index$classLi.contains("select-item")){var _child$props,_childs$index2;newOptions.push({value:null===child||void 0===child||null===(_child$props=child.props)||void 0===_child$props?void 0:_child$props.value,label:null===childs||void 0===childs||null===(_childs$index2=childs[index])||void 0===_childs$index2?void 0:_childs$index2.innerText})}}),setOptions(newOptions)}},[children,optionsModalRef.current,containerRef.current]),(0,_react.useEffect)(function(){function handler(){setIsOpenOptions(!1)}if(isOpenOptions){var _document;null===onOpen||void 0===onOpen?void 0:onOpen(),null===(_document=document)||void 0===_document?void 0:_document.addEventListener("scroll",handler)}else{var _document2;null===onClose||void 0===onClose?void 0:onClose(),null===(_document2=document)||void 0===_document2?void 0:_document2.removeEventListener("scroll",handler)}return function(){var _document3;return null===(_document3=document)||void 0===_document3?void 0:_document3.removeEventListener("scroll",handler)}},[isOpenOptions]),(0,_useOnClickOutside.useOnClickOutside)([containerRef,optionsModalRef],function(){isOpenOptions&&setIsOpenOptions(!1)});var positionsSelect=(0,_useReposition.useReposition)({containerRef:optionsModalRef,triggerRef:selectRef},[children]);return(0,_react.useEffect)(function(){setSelectedOption(value)},[value]),/*#__PURE__*/(0,_jsxRuntime.jsx)("div",{ref:selectRef,style:{width:"100%"},children:/*#__PURE__*/(0,_jsxRuntime.jsxs)(_Flex.default,{direction:"column",style:{width:"100%"},children:[/*#__PURE__*/(0,_jsxRuntime.jsxs)(_styles2.SelectContainer,{"data-disabled":rest.disabled,"data-variant":variant,"data-label-in-top":!!textPlaceholder||!!placeholder,alert:alert,tabIndex:rest.disabled?-1:0,onClick:function onClick(){return setIsOpenOptions(!isOpenOptions)},className:rest.className,style:rest.style,ref:containerRef,children:[label&&"unstyled"!==variant&&/*#__PURE__*/(0,_jsxRuntime.jsx)("label",{children:label}),"function"==typeof renderOptions&&selectedOption?/*#__PURE__*/(0,_jsxRuntime.jsx)(function SelectedOptionsWithCustomComponent(){return/*#__PURE__*/(0,_jsxRuntime.jsx)(_jsxRuntime.Fragment,{children:null===renderOptions||void 0===renderOptions?void 0:renderOptions(selectedOption)})},{},"custom-option-selected-".concat(textPlaceholder)):/*#__PURE__*/(0,_jsxRuntime.jsx)(_styles2.SelectedOptionSpan,{hasSelectedOption:!!selectedOption||isFalseOptions,children:textPlaceholder}),/*#__PURE__*/(0,_jsxRuntime.jsx)(_Flex.default,{className:"select_container_icon",children:/*#__PURE__*/(0,_jsxRuntime.jsx)(_Icon.default,{name:"chevron-down",color:"neutral.neutral5"})})]}),/*#__PURE__*/(0,_jsxRuntime.jsx)(_ReactPortal.ReactPortal,{wrapperId:"portal-root",children:/*#__PURE__*/(0,_jsxRuntime.jsx)(_styles.OptionsContainer,{ref:optionsModalRef,open:isOpenOptions,style:{maxWidth:"".concat(null===(_containerRef$current=containerRef.current)||void 0===_containerRef$current?void 0:_containerRef$current.getBoundingClientRect().width,"px"),left:positionsSelect.left,top:positionsSelect.top},children:_react.Children.map(children,function(child){var isSelectItemElement=(null===child||void 0===child?void 0:child.type)===_SelectItem.SelectItem;if(!/*#__PURE__*/(0,_react.isValidElement)(child)||!isSelectItemElement)return/*#__PURE__*/(0,_jsxRuntime.jsx)(_jsxRuntime.Fragment,{children:child});var childElement=child;return/*#__PURE__*/(0,_react.cloneElement)(childElement,{onClick:function onClick(event){event.currentTarget.classList.contains("select-item")&&(setIsOpenOptions(!1),setSelectedOption(childElement.props.value),null===onChange||void 0===onChange?void 0:onChange(childElement.props.value))}})})})}),!!helperText&&/*#__PURE__*/(0,_jsxRuntime.jsx)(_styles2.HelperText,{alert:alert,children:helperText})]})})}