@pega/cosmos-react-core 2.0.0-dev.11.0 → 2.0.0-dev.14.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 (455) hide show
  1. package/README.md +3 -3
  2. package/lib/components/Actions/Actions.js +1 -1
  3. package/lib/components/Actions/Actions.js.map +1 -1
  4. package/lib/components/AppShell/AppHeader.d.ts.map +1 -1
  5. package/lib/components/AppShell/AppHeader.js +1 -6
  6. package/lib/components/AppShell/AppHeader.js.map +1 -1
  7. package/lib/components/AppShell/AppShell.d.ts.map +1 -1
  8. package/lib/components/AppShell/AppShell.js +14 -32
  9. package/lib/components/AppShell/AppShell.js.map +1 -1
  10. package/lib/components/AppShell/AppShell.styles.d.ts +3 -2
  11. package/lib/components/AppShell/AppShell.styles.d.ts.map +1 -1
  12. package/lib/components/AppShell/AppShell.styles.js +36 -24
  13. package/lib/components/AppShell/AppShell.styles.js.map +1 -1
  14. package/lib/components/AppShell/AppShellList.js +10 -13
  15. package/lib/components/AppShell/AppShellList.js.map +1 -1
  16. package/lib/components/AppShell/Drawer.js +3 -6
  17. package/lib/components/AppShell/Drawer.js.map +1 -1
  18. package/lib/components/AppShell/Operator.js +1 -3
  19. package/lib/components/AppShell/Operator.js.map +1 -1
  20. package/lib/components/AppShell/SkipNavigation.js +2 -2
  21. package/lib/components/AppShell/SkipNavigation.js.map +1 -1
  22. package/lib/components/Avatar/Avatar.js +3 -4
  23. package/lib/components/Avatar/Avatar.js.map +1 -1
  24. package/lib/components/Backdrop/Backdrop.d.ts +1 -1
  25. package/lib/components/Backdrop/Backdrop.d.ts.map +1 -1
  26. package/lib/components/Backdrop/Backdrop.js +6 -5
  27. package/lib/components/Backdrop/Backdrop.js.map +1 -1
  28. package/lib/components/Badges/Selection.js +7 -8
  29. package/lib/components/Badges/Selection.js.map +1 -1
  30. package/lib/components/Banner/Banner.js +2 -6
  31. package/lib/components/Banner/Banner.js.map +1 -1
  32. package/lib/components/Boolean/BooleanDisplay.js +1 -2
  33. package/lib/components/Boolean/BooleanDisplay.js.map +1 -1
  34. package/lib/components/Breadcrumbs/Breadcrumbs.js +2 -5
  35. package/lib/components/Breadcrumbs/Breadcrumbs.js.map +1 -1
  36. package/lib/components/Button/Button.d.ts +5 -0
  37. package/lib/components/Button/Button.d.ts.map +1 -1
  38. package/lib/components/Button/Button.js +16 -9
  39. package/lib/components/Button/Button.js.map +1 -1
  40. package/lib/components/Card/Card.d.ts.map +1 -1
  41. package/lib/components/Card/Card.js +2 -1
  42. package/lib/components/Card/Card.js.map +1 -1
  43. package/lib/components/Card/CardContent.d.ts.map +1 -1
  44. package/lib/components/Card/CardContent.js +4 -3
  45. package/lib/components/Card/CardContent.js.map +1 -1
  46. package/lib/components/Card/CardFooter.d.ts.map +1 -1
  47. package/lib/components/Card/CardFooter.js +3 -2
  48. package/lib/components/Card/CardFooter.js.map +1 -1
  49. package/lib/components/Card/CardHeader.d.ts.map +1 -1
  50. package/lib/components/Card/CardHeader.js +5 -5
  51. package/lib/components/Card/CardHeader.js.map +1 -1
  52. package/lib/components/Card/CollapsibleCard.js +2 -6
  53. package/lib/components/Card/CollapsibleCard.js.map +1 -1
  54. package/lib/components/ColorPicker/ColorPicker.js +6 -9
  55. package/lib/components/ColorPicker/ColorPicker.js.map +1 -1
  56. package/lib/components/ComboBox/ComboBox.d.ts +1 -1
  57. package/lib/components/ComboBox/ComboBox.d.ts.map +1 -1
  58. package/lib/components/ComboBox/ComboBox.js +14 -20
  59. package/lib/components/ComboBox/ComboBox.js.map +1 -1
  60. package/lib/components/ComboBox/MultiSelectInput/MultiSelectInput.d.ts.map +1 -1
  61. package/lib/components/ComboBox/MultiSelectInput/MultiSelectInput.js +11 -19
  62. package/lib/components/ComboBox/MultiSelectInput/MultiSelectInput.js.map +1 -1
  63. package/lib/components/ComboBox/SingleSelectInput/SingleSelectInput.d.ts.map +1 -1
  64. package/lib/components/ComboBox/SingleSelectInput/SingleSelectInput.js +3 -3
  65. package/lib/components/ComboBox/SingleSelectInput/SingleSelectInput.js.map +1 -1
  66. package/lib/components/Configuration/Configuration.js +8 -10
  67. package/lib/components/Configuration/Configuration.js.map +1 -1
  68. package/lib/components/Currency/CurrencyInput.js +2 -2
  69. package/lib/components/Currency/CurrencyInput.js.map +1 -1
  70. package/lib/components/DateTime/Input/DateInput.d.ts.map +1 -1
  71. package/lib/components/DateTime/Input/DateInput.js +18 -23
  72. package/lib/components/DateTime/Input/DateInput.js.map +1 -1
  73. package/lib/components/DateTime/Input/DateRangeInput.d.ts.map +1 -1
  74. package/lib/components/DateTime/Input/DateRangeInput.js +10 -16
  75. package/lib/components/DateTime/Input/DateRangeInput.js.map +1 -1
  76. package/lib/components/DateTime/Input/DateTimeInput.d.ts.map +1 -1
  77. package/lib/components/DateTime/Input/DateTimeInput.js +27 -37
  78. package/lib/components/DateTime/Input/DateTimeInput.js.map +1 -1
  79. package/lib/components/DateTime/Input/DayOfWeekInput.d.ts.map +1 -1
  80. package/lib/components/DateTime/Input/DayOfWeekInput.js +6 -4
  81. package/lib/components/DateTime/Input/DayOfWeekInput.js.map +1 -1
  82. package/lib/components/DateTime/Input/Duration/DurationInput.d.ts.map +1 -1
  83. package/lib/components/DateTime/Input/Duration/DurationInput.js +2 -2
  84. package/lib/components/DateTime/Input/Duration/DurationInput.js.map +1 -1
  85. package/lib/components/DateTime/Input/Duration/NumberUnit.js +3 -4
  86. package/lib/components/DateTime/Input/Duration/NumberUnit.js.map +1 -1
  87. package/lib/components/DateTime/Input/Duration/Time.js +7 -10
  88. package/lib/components/DateTime/Input/Duration/Time.js.map +1 -1
  89. package/lib/components/DateTime/Input/MonthInput.js +9 -13
  90. package/lib/components/DateTime/Input/MonthInput.js.map +1 -1
  91. package/lib/components/DateTime/Input/PartInput.js +2 -3
  92. package/lib/components/DateTime/Input/PartInput.js.map +1 -1
  93. package/lib/components/DateTime/Input/TimeInput.js +16 -23
  94. package/lib/components/DateTime/Input/TimeInput.js.map +1 -1
  95. package/lib/components/DateTime/Input/WeekInput.d.ts.map +1 -1
  96. package/lib/components/DateTime/Input/WeekInput.js +16 -20
  97. package/lib/components/DateTime/Input/WeekInput.js.map +1 -1
  98. package/lib/components/DateTime/Input/useAutoFocusNextInput.js +4 -7
  99. package/lib/components/DateTime/Input/useAutoFocusNextInput.js.map +1 -1
  100. package/lib/components/DateTime/Input/usePickerButton.js +4 -4
  101. package/lib/components/DateTime/Input/usePickerButton.js.map +1 -1
  102. package/lib/components/DateTime/Input/utils.d.ts +2 -0
  103. package/lib/components/DateTime/Input/utils.d.ts.map +1 -1
  104. package/lib/components/DateTime/Input/utils.js +38 -10
  105. package/lib/components/DateTime/Input/utils.js.map +1 -1
  106. package/lib/components/DateTime/Picker/Calendar.d.ts.map +1 -1
  107. package/lib/components/DateTime/Picker/Calendar.js +24 -30
  108. package/lib/components/DateTime/Picker/Calendar.js.map +1 -1
  109. package/lib/components/DateTime/Picker/Calendar.styles.d.ts +2 -2
  110. package/lib/components/DateTime/Picker/Calendar.styles.d.ts.map +1 -1
  111. package/lib/components/DateTime/Picker/Calendar.styles.js +2 -2
  112. package/lib/components/DateTime/Picker/Calendar.styles.js.map +1 -1
  113. package/lib/components/DateTime/Picker/DatePicker.js +5 -10
  114. package/lib/components/DateTime/Picker/DatePicker.js.map +1 -1
  115. package/lib/components/DateTime/Picker/DateRangePicker.js +5 -10
  116. package/lib/components/DateTime/Picker/DateRangePicker.js.map +1 -1
  117. package/lib/components/DateTime/Picker/TimePicker.js +5 -6
  118. package/lib/components/DateTime/Picker/TimePicker.js.map +1 -1
  119. package/lib/components/DateTime/Picker/Weeks.js +7 -9
  120. package/lib/components/DateTime/Picker/Weeks.js.map +1 -1
  121. package/lib/components/Drawer/Drawer.js +5 -5
  122. package/lib/components/Drawer/Drawer.js.map +1 -1
  123. package/lib/components/EmojiPicker/EmojiDisplay.d.ts.map +1 -1
  124. package/lib/components/EmojiPicker/EmojiDisplay.js +1 -1
  125. package/lib/components/EmojiPicker/EmojiDisplay.js.map +1 -1
  126. package/lib/components/EmojiPicker/EmojiPicker.js +2 -3
  127. package/lib/components/EmojiPicker/EmojiPicker.js.map +1 -1
  128. package/lib/components/EmptyState/EmptyState.d.ts +14 -0
  129. package/lib/components/EmptyState/EmptyState.d.ts.map +1 -0
  130. package/lib/components/{NoItems/NoItems.js → EmptyState/EmptyState.js} +6 -7
  131. package/lib/components/EmptyState/EmptyState.js.map +1 -0
  132. package/lib/components/EmptyState/index.d.ts +4 -0
  133. package/lib/components/EmptyState/index.d.ts.map +1 -0
  134. package/lib/components/EmptyState/index.js +3 -0
  135. package/lib/components/EmptyState/index.js.map +1 -0
  136. package/lib/components/ErrorState/ErrorState.d.ts +2 -0
  137. package/lib/components/ErrorState/ErrorState.d.ts.map +1 -1
  138. package/lib/components/ErrorState/ErrorState.js +3 -3
  139. package/lib/components/ErrorState/ErrorState.js.map +1 -1
  140. package/lib/components/ExpandCollapse/ExpandCollapse.js +4 -4
  141. package/lib/components/ExpandCollapse/ExpandCollapse.js.map +1 -1
  142. package/lib/components/FieldGroup/FieldGroup.js +2 -5
  143. package/lib/components/FieldGroup/FieldGroup.js.map +1 -1
  144. package/lib/components/FieldGroup/FieldGroupList.js +1 -2
  145. package/lib/components/FieldGroup/FieldGroupList.js.map +1 -1
  146. package/lib/components/FieldValueList/FieldValueList.js +2 -4
  147. package/lib/components/FieldValueList/FieldValueList.js.map +1 -1
  148. package/lib/components/File/FileDisplay.d.ts +4 -1
  149. package/lib/components/File/FileDisplay.d.ts.map +1 -1
  150. package/lib/components/File/FileDisplay.js.map +1 -1
  151. package/lib/components/File/FileInput.d.ts +1 -1
  152. package/lib/components/File/FileInput.d.ts.map +1 -1
  153. package/lib/components/File/FileInput.js +7 -12
  154. package/lib/components/File/FileInput.js.map +1 -1
  155. package/lib/components/File/FileItem.js +2 -3
  156. package/lib/components/File/FileItem.js.map +1 -1
  157. package/lib/components/File/FileUploadItem.js +3 -3
  158. package/lib/components/File/FileUploadItem.js.map +1 -1
  159. package/lib/components/File/FileVisual.js +2 -4
  160. package/lib/components/File/FileVisual.js.map +1 -1
  161. package/lib/components/File/utils.js +1 -2
  162. package/lib/components/File/utils.js.map +1 -1
  163. package/lib/components/Flex/Flex.d.ts +2 -2
  164. package/lib/components/Flex/Flex.d.ts.map +1 -1
  165. package/lib/components/Flex/Flex.js.map +1 -1
  166. package/lib/components/Form/Form.js +1 -3
  167. package/lib/components/Form/Form.js.map +1 -1
  168. package/lib/components/FormControl/FormControl.d.ts +1 -1
  169. package/lib/components/FormControl/FormControl.d.ts.map +1 -1
  170. package/lib/components/FormField/FormField.js +5 -10
  171. package/lib/components/FormField/FormField.js.map +1 -1
  172. package/lib/components/Grid/Grid.d.ts +1 -1
  173. package/lib/components/Grid/Grid.d.ts.map +1 -1
  174. package/lib/components/Grid/Grid.js +5 -8
  175. package/lib/components/Grid/Grid.js.map +1 -1
  176. package/lib/components/Icon/Icon.js +2 -4
  177. package/lib/components/Icon/Icon.js.map +1 -1
  178. package/lib/components/Icon/icons/compass-solid.icon.js +1 -2
  179. package/lib/components/Icon/icons/compass-solid.icon.js.map +1 -1
  180. package/lib/components/Icon/icons/dataviz-table-with-bars.icon.js +1 -4
  181. package/lib/components/Icon/icons/dataviz-table-with-bars.icon.js.map +1 -1
  182. package/lib/components/Icon/icons/dataviz-table-with-cross.icon.js +1 -2
  183. package/lib/components/Icon/icons/dataviz-table-with-cross.icon.js.map +1 -1
  184. package/lib/components/Icon/icons/dataviz-waterfall.icon.js +1 -5
  185. package/lib/components/Icon/icons/dataviz-waterfall.icon.js.map +1 -1
  186. package/lib/components/Icon/icons/filetype-text.icon.js +1 -4
  187. package/lib/components/Icon/icons/filetype-text.icon.js.map +1 -1
  188. package/lib/components/Icon/icons/folder-dollar.icon.js +1 -2
  189. package/lib/components/Icon/icons/folder-dollar.icon.js.map +1 -1
  190. package/lib/components/Icon/icons/freeze-column.icon.js +1 -2
  191. package/lib/components/Icon/icons/freeze-column.icon.js.map +1 -1
  192. package/lib/components/Icon/icons/galaxy.icon.js +1 -3
  193. package/lib/components/Icon/icons/galaxy.icon.js.map +1 -1
  194. package/lib/components/Icon/icons/grad-solid.icon.js +1 -2
  195. package/lib/components/Icon/icons/grad-solid.icon.js.map +1 -1
  196. package/lib/components/Icon/icons/grad.icon.js +1 -5
  197. package/lib/components/Icon/icons/grad.icon.js.map +1 -1
  198. package/lib/components/Icon/icons/list-number.icon.js +1 -6
  199. package/lib/components/Icon/icons/list-number.icon.js.map +1 -1
  200. package/lib/components/Icon/icons/list.icon.js +1 -6
  201. package/lib/components/Icon/icons/list.icon.js.map +1 -1
  202. package/lib/components/Icon/icons/pin.icon.js +1 -2
  203. package/lib/components/Icon/icons/pin.icon.js.map +1 -1
  204. package/lib/components/Icon/icons/search-solid.icon.js +1 -2
  205. package/lib/components/Icon/icons/search-solid.icon.js.map +1 -1
  206. package/lib/components/Icon/icons/tracer.icon.js +1 -2
  207. package/lib/components/Icon/icons/tracer.icon.js.map +1 -1
  208. package/lib/components/Icon/icons/tribox-solid.icon.js +1 -3
  209. package/lib/components/Icon/icons/tribox-solid.icon.js.map +1 -1
  210. package/lib/components/Icon/icons/tribox.icon.js +1 -3
  211. package/lib/components/Icon/icons/tribox.icon.js.map +1 -1
  212. package/lib/components/Input/Input.js +2 -2
  213. package/lib/components/Input/Input.js.map +1 -1
  214. package/lib/components/Input/Input.styles.js +2 -2
  215. package/lib/components/Input/Input.styles.js.map +1 -1
  216. package/lib/components/Link/Link.js +5 -8
  217. package/lib/components/Link/Link.js.map +1 -1
  218. package/lib/components/Location/CurrentLocationButton.js +4 -6
  219. package/lib/components/Location/CurrentLocationButton.js.map +1 -1
  220. package/lib/components/Location/LocationDisplay.js +2 -3
  221. package/lib/components/Location/LocationDisplay.js.map +1 -1
  222. package/lib/components/Location/LocationInput.js +8 -9
  223. package/lib/components/Location/LocationInput.js.map +1 -1
  224. package/lib/components/Location/LocationView.js +8 -13
  225. package/lib/components/Location/LocationView.js.map +1 -1
  226. package/lib/components/Location/utils.js +11 -15
  227. package/lib/components/Location/utils.js.map +1 -1
  228. package/lib/components/Menu/FlyoutMenuList.d.ts.map +1 -1
  229. package/lib/components/Menu/FlyoutMenuList.js +11 -14
  230. package/lib/components/Menu/FlyoutMenuList.js.map +1 -1
  231. package/lib/components/Menu/Menu.js +18 -20
  232. package/lib/components/Menu/Menu.js.map +1 -1
  233. package/lib/components/Menu/Menu.styles.d.ts +10 -0
  234. package/lib/components/Menu/Menu.styles.d.ts.map +1 -1
  235. package/lib/components/Menu/Menu.styles.js +198 -3
  236. package/lib/components/Menu/Menu.styles.js.map +1 -1
  237. package/lib/components/Menu/Menu.types.d.ts +17 -8
  238. package/lib/components/Menu/Menu.types.d.ts.map +1 -1
  239. package/lib/components/Menu/Menu.types.js.map +1 -1
  240. package/lib/components/Menu/MenuGroup.d.ts +6 -0
  241. package/lib/components/Menu/MenuGroup.d.ts.map +1 -0
  242. package/lib/components/Menu/MenuGroup.js +17 -0
  243. package/lib/components/Menu/MenuGroup.js.map +1 -0
  244. package/lib/components/Menu/MenuItem.d.ts +0 -3
  245. package/lib/components/Menu/MenuItem.d.ts.map +1 -1
  246. package/lib/components/Menu/MenuItem.js +35 -151
  247. package/lib/components/Menu/MenuItem.js.map +1 -1
  248. package/lib/components/Menu/MenuList.d.ts.map +1 -1
  249. package/lib/components/Menu/MenuList.js +19 -23
  250. package/lib/components/Menu/MenuList.js.map +1 -1
  251. package/lib/components/Menu/MenuListHeader.d.ts +0 -1
  252. package/lib/components/Menu/MenuListHeader.d.ts.map +1 -1
  253. package/lib/components/Menu/MenuListHeader.js +5 -55
  254. package/lib/components/Menu/MenuListHeader.js.map +1 -1
  255. package/lib/components/Menu/NavItemsList.d.ts.map +1 -1
  256. package/lib/components/Menu/NavItemsList.js +2 -3
  257. package/lib/components/Menu/NavItemsList.js.map +1 -1
  258. package/lib/components/Menu/helpers.d.ts +13 -12
  259. package/lib/components/Menu/helpers.d.ts.map +1 -1
  260. package/lib/components/Menu/helpers.js +40 -36
  261. package/lib/components/Menu/helpers.js.map +1 -1
  262. package/lib/components/Menu/index.d.ts +2 -3
  263. package/lib/components/Menu/index.d.ts.map +1 -1
  264. package/lib/components/Menu/index.js +1 -2
  265. package/lib/components/Menu/index.js.map +1 -1
  266. package/lib/components/MenuButton/MenuButton.js +6 -10
  267. package/lib/components/MenuButton/MenuButton.js.map +1 -1
  268. package/lib/components/Modal/MinimizedModal.js +10 -13
  269. package/lib/components/Modal/MinimizedModal.js.map +1 -1
  270. package/lib/components/Modal/Modal.d.ts +1 -6
  271. package/lib/components/Modal/Modal.d.ts.map +1 -1
  272. package/lib/components/Modal/Modal.js +40 -137
  273. package/lib/components/Modal/Modal.js.map +1 -1
  274. package/lib/components/Modal/Modal.styles.d.ts +9 -0
  275. package/lib/components/Modal/Modal.styles.d.ts.map +1 -0
  276. package/lib/components/Modal/Modal.styles.js +133 -0
  277. package/lib/components/Modal/Modal.styles.js.map +1 -0
  278. package/lib/components/Modal/Modal.types.d.ts +19 -4
  279. package/lib/components/Modal/Modal.types.d.ts.map +1 -1
  280. package/lib/components/Modal/Modal.types.js.map +1 -1
  281. package/lib/components/Modal/ModalManager.js +12 -21
  282. package/lib/components/Modal/ModalManager.js.map +1 -1
  283. package/lib/components/MultiStep/MultiStep.js +3 -6
  284. package/lib/components/MultiStep/MultiStep.js.map +1 -1
  285. package/lib/components/MultiStep/MultiStep.styles.js +1 -1
  286. package/lib/components/MultiStep/MultiStep.styles.js.map +1 -1
  287. package/lib/components/Number/NumberInput.js +13 -19
  288. package/lib/components/Number/NumberInput.js.map +1 -1
  289. package/lib/components/Number/NumberInput.styles.d.ts +2 -2
  290. package/lib/components/Number/NumberInput.styles.d.ts.map +1 -1
  291. package/lib/components/Number/utils.js +2 -3
  292. package/lib/components/Number/utils.js.map +1 -1
  293. package/lib/components/PageTemplates/CategorySubPage.d.ts +1 -1
  294. package/lib/components/PageTemplates/CategorySubPage.d.ts.map +1 -1
  295. package/lib/components/PageTemplates/CategorySubPage.js +6 -16
  296. package/lib/components/PageTemplates/CategorySubPage.js.map +1 -1
  297. package/lib/components/PageTemplates/DashboardPage.js +3 -8
  298. package/lib/components/PageTemplates/DashboardPage.js.map +1 -1
  299. package/lib/components/PageTemplates/PageTemplates.d.ts +2 -0
  300. package/lib/components/PageTemplates/PageTemplates.d.ts.map +1 -1
  301. package/lib/components/PageTemplates/PageTemplates.js +22 -32
  302. package/lib/components/PageTemplates/PageTemplates.js.map +1 -1
  303. package/lib/components/Pagination/Pagination.js +2 -4
  304. package/lib/components/Pagination/Pagination.js.map +1 -1
  305. package/lib/components/Phone/PhoneDisplay.js +1 -2
  306. package/lib/components/Phone/PhoneDisplay.js.map +1 -1
  307. package/lib/components/Phone/PhoneInput.d.ts.map +1 -1
  308. package/lib/components/Phone/PhoneInput.js +12 -10
  309. package/lib/components/Phone/PhoneInput.js.map +1 -1
  310. package/lib/components/Phone/utils.js +2 -3
  311. package/lib/components/Phone/utils.js.map +1 -1
  312. package/lib/components/Popover/Popover.js +4 -7
  313. package/lib/components/Popover/Popover.js.map +1 -1
  314. package/lib/components/Progress/Bar.js +1 -1
  315. package/lib/components/Progress/Bar.js.map +1 -1
  316. package/lib/components/Progress/Ellipsis.js +1 -3
  317. package/lib/components/Progress/Ellipsis.js.map +1 -1
  318. package/lib/components/Progress/Progress.js +2 -3
  319. package/lib/components/Progress/Progress.js.map +1 -1
  320. package/lib/components/Progress/Ring.js +2 -3
  321. package/lib/components/Progress/Ring.js.map +1 -1
  322. package/lib/components/RadioCheck/RadioCheck.js +6 -7
  323. package/lib/components/RadioCheck/RadioCheck.js.map +1 -1
  324. package/lib/components/RadioCheckGroup/RadioCheckGroup.js +7 -6
  325. package/lib/components/RadioCheckGroup/RadioCheckGroup.js.map +1 -1
  326. package/lib/components/Rating/Rating.js +2 -6
  327. package/lib/components/Rating/Rating.js.map +1 -1
  328. package/lib/components/SearchInput/SearchInput.js +10 -12
  329. package/lib/components/SearchInput/SearchInput.js.map +1 -1
  330. package/lib/components/Select/Select.js +2 -2
  331. package/lib/components/Select/Select.js.map +1 -1
  332. package/lib/components/Sentiment/Sentiment.js +1 -2
  333. package/lib/components/Sentiment/Sentiment.js.map +1 -1
  334. package/lib/components/Slider/Slider.js +7 -13
  335. package/lib/components/Slider/Slider.js.map +1 -1
  336. package/lib/components/Slider/Slider.styles.d.ts +1 -1
  337. package/lib/components/Slider/Slider.styles.js +1 -1
  338. package/lib/components/Slider/Slider.styles.js.map +1 -1
  339. package/lib/components/Slider/SliderTicks.js +1 -2
  340. package/lib/components/Slider/SliderTicks.js.map +1 -1
  341. package/lib/components/Slider/utils.d.ts +0 -10
  342. package/lib/components/Slider/utils.d.ts.map +1 -1
  343. package/lib/components/Slider/utils.js +3 -15
  344. package/lib/components/Slider/utils.js.map +1 -1
  345. package/lib/components/SummaryItem/SummaryItem.js +1 -4
  346. package/lib/components/SummaryItem/SummaryItem.js.map +1 -1
  347. package/lib/components/SummaryList/SummaryList.d.ts +8 -2
  348. package/lib/components/SummaryList/SummaryList.d.ts.map +1 -1
  349. package/lib/components/SummaryList/SummaryList.js +9 -10
  350. package/lib/components/SummaryList/SummaryList.js.map +1 -1
  351. package/lib/components/SummaryList/ViewAll.d.ts +1 -1
  352. package/lib/components/SummaryList/ViewAll.d.ts.map +1 -1
  353. package/lib/components/SummaryList/ViewAll.js +7 -10
  354. package/lib/components/SummaryList/ViewAll.js.map +1 -1
  355. package/lib/components/Switch/Switch.d.ts.map +1 -1
  356. package/lib/components/Switch/Switch.js +39 -30
  357. package/lib/components/Switch/Switch.js.map +1 -1
  358. package/lib/components/Table/Table.js +3 -7
  359. package/lib/components/Table/Table.js.map +1 -1
  360. package/lib/components/Tabs/Tab.js +3 -6
  361. package/lib/components/Tabs/Tab.js.map +1 -1
  362. package/lib/components/Tabs/TabPanel.d.ts +10 -2
  363. package/lib/components/Tabs/TabPanel.d.ts.map +1 -1
  364. package/lib/components/Tabs/TabPanel.js +21 -8
  365. package/lib/components/Tabs/TabPanel.js.map +1 -1
  366. package/lib/components/Tabs/Tabs.js +7 -8
  367. package/lib/components/Tabs/Tabs.js.map +1 -1
  368. package/lib/components/Text/Text.d.ts +1 -1
  369. package/lib/components/Text/Text.d.ts.map +1 -1
  370. package/lib/components/Text/Text.js +1 -1
  371. package/lib/components/Text/Text.js.map +1 -1
  372. package/lib/components/TextArea/TextArea.js +3 -3
  373. package/lib/components/TextArea/TextArea.js.map +1 -1
  374. package/lib/components/Toaster/Toaster.js +6 -10
  375. package/lib/components/Toaster/Toaster.js.map +1 -1
  376. package/lib/components/Tree/StandardTree.d.ts.map +1 -1
  377. package/lib/components/Tree/StandardTree.js +10 -17
  378. package/lib/components/Tree/StandardTree.js.map +1 -1
  379. package/lib/components/Tree/StandardTree.styles.d.ts +1 -1
  380. package/lib/components/Tree/StandardTree.styles.d.ts.map +1 -1
  381. package/lib/components/Tree/StandardTree.styles.js +16 -11
  382. package/lib/components/Tree/StandardTree.styles.js.map +1 -1
  383. package/lib/components/Tree/Tree.d.ts +6 -0
  384. package/lib/components/Tree/Tree.d.ts.map +1 -1
  385. package/lib/components/Tree/Tree.js +3 -3
  386. package/lib/components/Tree/Tree.js.map +1 -1
  387. package/lib/components/Tree/helpers.js +4 -7
  388. package/lib/components/Tree/helpers.js.map +1 -1
  389. package/lib/hooks/index.d.ts +1 -0
  390. package/lib/hooks/index.d.ts.map +1 -1
  391. package/lib/hooks/index.js +1 -0
  392. package/lib/hooks/index.js.map +1 -1
  393. package/lib/hooks/useActiveDescendant.d.ts.map +1 -1
  394. package/lib/hooks/useActiveDescendant.js +28 -32
  395. package/lib/hooks/useActiveDescendant.js.map +1 -1
  396. package/lib/hooks/useBreakpoint.js +2 -4
  397. package/lib/hooks/useBreakpoint.js.map +1 -1
  398. package/lib/hooks/useFocusWithin.js +9 -9
  399. package/lib/hooks/useFocusWithin.js.map +1 -1
  400. package/lib/hooks/useI18n.d.ts +57 -1
  401. package/lib/hooks/useI18n.d.ts.map +1 -1
  402. package/lib/hooks/useLongPress.d.ts +16 -0
  403. package/lib/hooks/useLongPress.d.ts.map +1 -0
  404. package/lib/hooks/useLongPress.js +57 -0
  405. package/lib/hooks/useLongPress.js.map +1 -0
  406. package/lib/hooks/useOuterEvent.js +1 -1
  407. package/lib/hooks/useOuterEvent.js.map +1 -1
  408. package/lib/hooks/useOverride.js +1 -1
  409. package/lib/hooks/useOverride.js.map +1 -1
  410. package/lib/hooks/useScrollStick.js +14 -3
  411. package/lib/hooks/useScrollStick.js.map +1 -1
  412. package/lib/i18n/default.json +59 -3
  413. package/lib/i18n/i18n.d.ts +114 -2
  414. package/lib/i18n/i18n.d.ts.map +1 -1
  415. package/lib/i18n/index.d.ts +1 -0
  416. package/lib/i18n/index.d.ts.map +1 -1
  417. package/lib/i18n/index.js.map +1 -1
  418. package/lib/index.d.ts +2 -2
  419. package/lib/index.d.ts.map +1 -1
  420. package/lib/index.js +2 -2
  421. package/lib/index.js.map +1 -1
  422. package/lib/styles/GlobalStyle.d.ts.map +1 -1
  423. package/lib/styles/GlobalStyle.js +2 -26
  424. package/lib/styles/GlobalStyle.js.map +1 -1
  425. package/lib/theme/ThemeMachine.js +7 -1
  426. package/lib/theme/ThemeMachine.js.map +1 -1
  427. package/lib/theme/index.d.ts +1 -0
  428. package/lib/theme/index.d.ts.map +1 -1
  429. package/lib/theme/index.js +1 -0
  430. package/lib/theme/index.js.map +1 -1
  431. package/lib/theme/theme.d.ts +75 -45
  432. package/lib/theme/theme.d.ts.map +1 -1
  433. package/lib/theme/themeDefinition.json +50 -30
  434. package/lib/theme/themeOverrides.schema.json +15 -3
  435. package/lib/theme/themes/buildTheme.json +2 -39
  436. package/lib/theme/themes/legacyBuildTheme.json +50 -0
  437. package/lib/types/types.d.ts +4 -1
  438. package/lib/types/types.d.ts.map +1 -1
  439. package/lib/types/types.js.map +1 -1
  440. package/lib/utils/utils.d.ts +24 -0
  441. package/lib/utils/utils.d.ts.map +1 -1
  442. package/lib/utils/utils.js +36 -1
  443. package/lib/utils/utils.js.map +1 -1
  444. package/package.json +10 -10
  445. package/lib/components/DateTime/Input/useButtonAriaLabel.d.ts +0 -3
  446. package/lib/components/DateTime/Input/useButtonAriaLabel.d.ts.map +0 -1
  447. package/lib/components/DateTime/Input/useButtonAriaLabel.js +0 -33
  448. package/lib/components/DateTime/Input/useButtonAriaLabel.js.map +0 -1
  449. package/lib/components/NoItems/NoItems.d.ts +0 -14
  450. package/lib/components/NoItems/NoItems.d.ts.map +0 -1
  451. package/lib/components/NoItems/NoItems.js.map +0 -1
  452. package/lib/components/NoItems/index.d.ts +0 -4
  453. package/lib/components/NoItems/index.d.ts.map +0 -1
  454. package/lib/components/NoItems/index.js +0 -3
  455. package/lib/components/NoItems/index.js.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"LocationDisplay.js","sourceRoot":"","sources":["../../../src/components/Location/LocationDisplay.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,UAAU,EAA2C,UAAU,EAAE,MAAM,OAAO,CAAC;AAExF,OAAO,IAAI,MAAM,SAAS,CAAC;AAC3B,OAAO,IAAI,MAAM,SAAS,CAAC;AAG3B,OAAO,YAAY,MAAM,gBAAgB,CAAC;AAC1C,OAAO,WAAW,MAAM,eAAe,CAAC;AA2BxC,MAAM,eAAe,GAA2D,UAAU,CACxF,CACE,EACE,KAAK,GAAG,EAAE,EACV,WAAW,EACX,OAAO,GAAG,UAAU,EACpB,MAAM,GAAG,OAAO,EAChB,SAAS,GAAG,EAAE,EACd,GAAG,SAAS,EAC0B,EACxC,GAAgC,EAChC,EAAE;IACF,MAAM,EAAE,IAAI,EAAE,GAAG,UAAU,CAAC,WAAW,CAAC,CAAC;IAEzC,MAAM,WAAW,GACf,OAAO,KAAK,KAAK,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,GAAG,KAAK,aAAL,KAAK,uBAAL,KAAK,CAAE,QAAQ,KAAK,KAAK,aAAL,KAAK,uBAAL,KAAK,CAAE,SAAS,EAAE,CAAC;IAEhF,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CACd,KAAC,IAAI,kBAAC,GAAG,EAAE,GAA2B,IAAM,SAAS,mBAAc,MAAM,gBACvE,4CAAkB,MAAM,0CAAsB,YACzC,CACR,CAAC,CAAC,CAAC,CACF,8BACG,CAAC,OAAO,KAAK,MAAM,IAAI,OAAO,KAAK,UAAU,CAAC;gBAC7C,CAAC,IAAI,KAAK,QAAQ,CAAC,CAAC,CAAC,CACnB,KAAC,IAAI,kBACH,GAAG,EAAE,GAA6B,IAC9B,SAAS,IACb,MAAM,EAAC,QAAQ,EACf,GAAG,EAAC,qBAAqB,EACzB,IAAI,EAAE,mDAAmD,kBAAkB,CACzE,OAAO,KAAK,KAAK,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,GAAG,KAAK,aAAL,KAAK,uBAAL,KAAK,CAAE,QAAQ,KAAK,KAAK,aAAL,KAAK,uBAAL,KAAK,CAAE,SAAS,EAAE,CAC9E,EAAE,gBAEF,WAAW,IAAI,WAAW,YACtB,CACR,CAAC,CAAC,CAAC,CACF,KAAC,IAAI,kBAAC,GAAG,EAAE,GAA2B,IAAM,SAAS,cAClD,WAAW,IAAI,WAAW,YACtB,CACR,CAAC;YACH,CAAC,OAAO,KAAK,UAAU,IAAI,OAAO,KAAK,KAAK,CAAC,IAAI,CAChD,KAAC,YAAY,oBACP;gBACF,QAAQ,EAAE,KAAK;gBACf,iBAAiB,EAAE,IAAI;gBACvB,MAAM;gBACN,SAAS;aACV,UACD,CACH,YACA,CACJ,CAAC;AACJ,CAAC,CACF,CAAC;AAEF,eAAe,eAAe,CAAC","sourcesContent":["import { forwardRef, FunctionComponent, PropsWithoutRef, Ref, useContext } from 'react';\n\nimport Text from '../Text';\nimport Link from '../Link';\nimport { BaseProps, ForwardProps } from '../../types';\n\nimport LocationView from './LocationView';\nimport MapsContext from './MapsContext';\nimport { LatLng } from './types';\n\nexport interface LocationDisplayProps extends BaseProps {\n /** Location address or coordinates */\n value?: string | LatLng;\n /** The text to be displayed. */\n displayText?: string;\n /**\n * Controls styling of the field.\n * @default \"text-map\"\n */\n variant?: 'text-map' | 'text' | 'map';\n /**\n * Height of the map container.\n * @default '25rem'\n */\n height?: string;\n /**\n * How much the map should zoom.\n * @default 13\n */\n zoomLevel?: number;\n /** Ref for the wrapping element. */\n ref?: Ref<HTMLAnchorElement | HTMLSpanElement>;\n}\n\nconst LocationDisplay: FunctionComponent<LocationDisplayProps & ForwardProps> = forwardRef(\n (\n {\n value = '',\n displayText,\n variant = 'text-map',\n height = '25rem',\n zoomLevel = 13,\n ...restProps\n }: PropsWithoutRef<LocationDisplayProps>,\n ref: LocationDisplayProps['ref']\n ) => {\n const { name } = useContext(MapsContext);\n\n const valueString =\n typeof value === 'string' ? value : `${value?.latitude}, ${value?.longitude}`;\n\n return !value ? (\n <Text ref={ref as Ref<HTMLSpanElement>} {...restProps} aria-hidden='true'>\n <span aria-hidden='true'>&ndash;&ndash;</span>\n </Text>\n ) : (\n <>\n {(variant === 'text' || variant === 'text-map') &&\n (name === 'google' ? (\n <Link\n ref={ref as Ref<HTMLAnchorElement>}\n {...restProps}\n target='_blank'\n rel='noopener noreferrer'\n href={`https://www.google.com/maps/search/?api=1&query=${encodeURIComponent(\n typeof value === 'string' ? value : `${value?.latitude}, ${value?.longitude}`\n )}`}\n >\n {displayText || valueString}\n </Link>\n ) : (\n <Text ref={ref as Ref<HTMLSpanElement>} {...restProps}>\n {displayText || valueString}\n </Text>\n ))}\n {(variant === 'text-map' || variant === 'map') && (\n <LocationView\n {...{\n location: value,\n centerMapOnChange: true,\n height,\n zoomLevel\n }}\n />\n )}\n </>\n );\n }\n);\n\nexport default LocationDisplay;\n"]}
1
+ {"version":3,"file":"LocationDisplay.js","sourceRoot":"","sources":["../../../src/components/Location/LocationDisplay.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,UAAU,EAA2C,UAAU,EAAE,MAAM,OAAO,CAAC;AAExF,OAAO,IAAI,MAAM,SAAS,CAA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AAW,YACtB,CACR,CAAC,EACH,CAAC,OAAO,KAAK,UAAU,IAAI,OAAO,KAAK,KAAK,CAAC,IAAI,CAChD,KAAC,YAAY,oBACP;gBACF,QAAQ,EAAE,KAAK;gBACf,iBAAiB,EAAE,IAAI;gBACvB,MAAM;gBACN,SAAS;aACV,UACD,CACH,YACA,CACJ,CAAC;AACJ,CAAC,CACF,CAAC;AAEF,eAAe,eAAe,CAAC","sourcesContent":["import { forwardRef, FunctionComponent, PropsWithoutRef, Ref, useContext } from 'react';\n\nimport Text from '../Text';\nimport Link from '../Link';\nimport { BaseProps, ForwardProps } from '../../types';\n\nimport LocationView from './LocationView';\nimport MapsContext from './MapsContext';\nimport { LatLng } from './types';\n\nexport interface LocationDisplayProps extends BaseProps {\n /** Location address or coordinates */\n value?: string | LatLng;\n /** The text to be displayed. */\n displayText?: string;\n /**\n * Controls styling of the field.\n * @default \"text-map\"\n */\n variant?: 'text-map' | 'text' | 'map';\n /**\n * Height of the map container.\n * @default '25rem'\n */\n height?: string;\n /**\n * How much the map should zoom.\n * @default 13\n */\n zoomLevel?: number;\n /** Ref for the wrapping element. */\n ref?: Ref<HTMLAnchorElement | HTMLSpanElement>;\n}\n\nconst LocationDisplay: FunctionComponent<LocationDisplayProps & ForwardProps> = forwardRef(\n (\n {\n value = '',\n displayText,\n variant = 'text-map',\n height = '25rem',\n zoomLevel = 13,\n ...restProps\n }: PropsWithoutRef<LocationDisplayProps>,\n ref: LocationDisplayProps['ref']\n ) => {\n const { name } = useContext(MapsContext);\n\n const valueString =\n typeof value === 'string' ? value : `${value?.latitude}, ${value?.longitude}`;\n\n return !value ? (\n <Text ref={ref as Ref<HTMLSpanElement>} {...restProps} aria-hidden='true'>\n <span aria-hidden='true'>&ndash;&ndash;</span>\n </Text>\n ) : (\n <>\n {(variant === 'text' || variant === 'text-map') &&\n (name === 'google' ? (\n <Link\n ref={ref as Ref<HTMLAnchorElement>}\n {...restProps}\n target='_blank'\n rel='noopener noreferrer'\n href={`https://www.google.com/maps/search/?api=1&query=${encodeURIComponent(\n typeof value === 'string' ? value : `${value?.latitude}, ${value?.longitude}`\n )}`}\n >\n {displayText || valueString}\n </Link>\n ) : (\n <Text ref={ref as Ref<HTMLSpanElement>} {...restProps}>\n {displayText || valueString}\n </Text>\n ))}\n {(variant === 'text-map' || variant === 'map') && (\n <LocationView\n {...{\n location: value,\n centerMapOnChange: true,\n height,\n zoomLevel\n }}\n />\n )}\n </>\n );\n }\n);\n\nexport default LocationDisplay;\n"]}
@@ -24,7 +24,7 @@ const LocationInput = forwardRef((props, ref) => {
24
24
  const [placePredictionMenu, setPlacePredictionMenu] = useState({ items: [] });
25
25
  const [filterValue, setFilterValue] = useState('');
26
26
  useEffect(() => {
27
- const mapApiPromise = loadMapsAPI(name, providerOpts).catch(error => onError === null || onError === void 0 ? void 0 : onError(error));
27
+ const mapApiPromise = loadMapsAPI(name, providerOpts).catch(error => onError?.(error));
28
28
  if (filterValue) {
29
29
  mapApiPromise
30
30
  .then(() => getPlacePredictions(filterValue, bias))
@@ -38,13 +38,13 @@ const LocationInput = forwardRef((props, ref) => {
38
38
  emptyText: t('location_not_found_text'),
39
39
  onItemClick: itemId => getPlaceById(itemId, token).then(arg => {
40
40
  setFilterValue('');
41
- onSelect === null || onSelect === void 0 ? void 0 : onSelect(arg);
41
+ onSelect?.(arg);
42
42
  })
43
43
  });
44
44
  })
45
45
  .catch(error => {
46
46
  setPlacePredictionMenu({ items: [] });
47
- onError === null || onError === void 0 ? void 0 : onError(error);
47
+ onError?.(error);
48
48
  });
49
49
  }
50
50
  else {
@@ -53,11 +53,11 @@ const LocationInput = forwardRef((props, ref) => {
53
53
  }, [filterValue, bias, onError, onSelect]);
54
54
  const onInputChange = useCallback((e) => {
55
55
  setFilterValue(e.target.value);
56
- onChange === null || onChange === void 0 ? void 0 : onChange(e.target.value);
56
+ onChange?.(e.target.value);
57
57
  }, [onChange]);
58
58
  const onMapClick = useCallback((placeInfo) => {
59
- onSelect === null || onSelect === void 0 ? void 0 : onSelect(placeInfo);
60
- onClick === null || onClick === void 0 ? void 0 : onClick(placeInfo);
59
+ onSelect?.(placeInfo);
60
+ onClick?.(placeInfo);
61
61
  }, [onSelect, onClick]);
62
62
  const Comp = (_jsxs(_Fragment, { children: [_jsx(ComboBox, Object.assign({ placeholder: t('location_input_placeholder'), menu: filterValue
63
63
  ? {
@@ -73,15 +73,14 @@ const LocationInput = forwardRef((props, ref) => {
73
73
  : undefined, actions: !disabled &&
74
74
  !readOnly && (_jsx(CurrentLocationButton, Object.assign({}, { defaultToCurrentLocation, onError, onChange: onSelect }), void 0)), onChange: onInputChange, onBlur: () => {
75
75
  setFilterValue('');
76
- onBlur === null || onBlur === void 0 ? void 0 : onBlur(value);
76
+ onBlur?.(value);
77
77
  }, value: value }, {
78
78
  required,
79
79
  disabled,
80
80
  readOnly,
81
81
  status,
82
82
  ...restProps
83
- }), void 0),
84
- showMap && (_jsx(StyledLocationMap, { children: _jsx(LocationView, Object.assign({}, {
83
+ }), void 0), showMap && (_jsx(StyledLocationMap, { children: _jsx(LocationView, Object.assign({}, {
85
84
  location,
86
85
  onClick: onMapClick,
87
86
  onError,
@@ -1 +1 @@
1
- {"version":3,"file":"LocationInput.js","sourceRoot":"","sources":["../../../src/components/Location/LocationInput.tsx"],"names":[],"mappings":";AAAA,OAAO,EAGL,UAAU,EAGV,WAAW,EACX,UAAU,EACV,SAAS,EACT,QAAQ,EACT,MAAM,OAAO,CAAC;AACf,OAAO,MAAM,MAAM,mBAAmB,CAAC;AAEvC,OAAO,QAAQ,MAAM,aAAa,CAAC;AAEnC,OAAO,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AACtC,OAAO,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAC9C,OAAO,SAAS,MAAM,cAAc,CAAC;AAGrC,OAAO,IAAI,MAAM,SAAS,CAAC;AAE3B,OAAO,oBAAoB,MAAM,wBAAwB,CAAC;AAC1D,OAAO,qBAAqB,MAAM,yBAAyB,C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,CAAC;gBAClB,CAAC,EACD,KAAK,EAAE,KAAK,IACR;gBACF,QAAQ;gBACR,QAAQ;gBACR,QAAQ;gBACR,MAAM;gBACN,GAAG,SAAS;aACb,UACD;YACD,OAAO,IAAI,CACV,KAAC,iBAAiB,cAChB,KAAC,YAAY,oBACP;oBACF,QAAQ;oBACR,OAAO,EAAE,UAAU;oBACnB,OAAO;oBACP,IAAI;oBACJ,QAAQ;oBACR,QAAQ;oBACR,iBAAiB;oBACjB,MAAM;oBACN,SAAS;iBACV,UACD,WACgB,CACrB,YACA,CACJ,CAAC;IAEF,OAAO,KAAK,CAAC,CAAC,CAAC,CACb,KAAC,SAAS,oBAAK,EAAE,KAAK,EAAE,WAAW,EAAE,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE,GAAG,EAAE,QAAQ,EAAE,QAAQ,EAAE,cAC7E,IAAI,YACK,CACb,CAAC,CAAC,CAAC,CACF,IAAI,CACL,CAAC;AACJ,CAAC,CACF,CAAC;AAEF,eAAe,aAAa,CAAC","sourcesContent":["import {\n ChangeEvent,\n FC,\n forwardRef,\n PropsWithoutRef,\n Ref,\n useCallback,\n useContext,\n useEffect,\n useState\n} from 'react';\nimport styled from 'styled-components';\n\nimport ComboBox from '../ComboBox';\nimport { MenuProps } from '../Menu';\nimport { useI18n } from '../../hooks';\nimport { createUID } from '../../utils/utils';\nimport FormField from '../FormField';\nimport { FormControlProps } from '../FormControl';\nimport { BaseProps, ForwardProps } from '../../types';\nimport Flex from '../Flex';\n\nimport PoweredByGoogleImage from './PoweredByGoogleImage';\nimport CurrentLocationButton from './CurrentLocationButton';\nimport MapsContext from './MapsContext';\nimport { getPlaceById, getPlacePredictions, loadMapsAPI } from './utils';\nimport BaseLocationProps from './Location.types';\nimport { LatLng } from './types';\nimport LocationView, { LocationViewProps, StyledLocationView } from './LocationView';\n\nexport interface LocationInputProps\n extends LocationViewProps,\n BaseLocationProps,\n BaseProps,\n FormControlProps {\n /**\n * Get user current location on component first render.\n * @default false\n */\n defaultToCurrentLocation?: boolean;\n /** The value of the location field. */\n value?: string;\n /**\n * Callback fired on every change of the location input.\n * The argument passed back is the component's value prop.\n */\n onChange?: (value: string) => void;\n /**\n * Callback fired when the control's input loses focus.\n * The argument passed back is the component's value prop.\n */\n onBlur?: (value: string) => void;\n /**\n * Set to true renders the map view below input.\n * @default false\n */\n showMap?: boolean;\n /** Location coordinates used for the map view. */\n location?: LatLng | string;\n /** Callback fired when user chooses location from the dropdown of suggestions or submits input value. */\n onSelect?: (value: {\n name: string;\n address?: string;\n latitude?: number;\n longitude?: number;\n }) => void;\n}\n\nconst StyledLocationMap = styled.div`\n ${StyledLocationView} {\n border-top-left-radius: 0;\n border-top-right-radius: 0;\n }\n`;\n\nconst LocationInput: FC<LocationInputProps & ForwardProps> = forwardRef(\n (props: PropsWithoutRef<LocationInputProps>, ref: Ref<HTMLInputElement>) => {\n const {\n label,\n labelHidden,\n id = createUID(),\n location = '',\n value = '',\n info,\n status,\n required,\n readOnly,\n disabled,\n onSelect,\n onError,\n onChange,\n bias,\n showMap,\n defaultToCurrentLocation,\n centerMapOnChange,\n height,\n zoomLevel,\n onClick,\n onBlur,\n ...restProps\n } = props;\n const { name, ...providerOpts } = useContext(MapsContext);\n const t = useI18n();\n const [placePredictionMenu, setPlacePredictionMenu] = useState<MenuProps>({ items: [] });\n const [filterValue, setFilterValue] = useState('');\n\n useEffect(() => {\n const mapApiPromise = loadMapsAPI(name, providerOpts).catch(error => onError?.(error));\n\n if (filterValue) {\n mapApiPromise\n .then(() => getPlacePredictions(filterValue, bias))\n .then(({ placePredictions, token }) => {\n setPlacePredictionMenu({\n items: placePredictions.map(item => ({\n id: item.place_id,\n primary: item.structured_formatting.main_text,\n secondary: [item.structured_formatting.secondary_text]\n })),\n emptyText: t('location_not_found_text'),\n onItemClick: itemId =>\n getPlaceById(itemId, token).then(arg => {\n setFilterValue('');\n onSelect?.(arg);\n })\n });\n })\n .catch(error => {\n setPlacePredictionMenu({ items: [] });\n onError?.(error);\n });\n } else {\n setPlacePredictionMenu({ items: [] });\n }\n }, [filterValue, bias, onError, onSelect]);\n\n const onInputChange = useCallback(\n (e: ChangeEvent<HTMLInputElement>) => {\n setFilterValue(e.target.value);\n onChange?.(e.target.value);\n },\n [onChange]\n );\n\n const onMapClick = useCallback(\n (placeInfo: { latitude: number; longitude: number; name: string; address?: string }) => {\n onSelect?.(placeInfo);\n onClick?.(placeInfo);\n },\n [onSelect, onClick]\n );\n\n const Comp = (\n <>\n <ComboBox\n placeholder={t('location_input_placeholder')}\n menu={\n filterValue\n ? {\n ...placePredictionMenu,\n items: placePredictionMenu.items.concat({\n id: createUID(),\n primary: t('use_input_value', `\"${filterValue}\"`)\n }),\n mode: 'action',\n emptyText: t('location_not_found_text'),\n footer: !showMap && (\n <Flex container={{ justify: 'end' }}>\n <PoweredByGoogleImage />\n </Flex>\n )\n }\n : undefined\n }\n actions={\n !disabled &&\n !readOnly && (\n <CurrentLocationButton\n {...{ defaultToCurrentLocation, onError, onChange: onSelect }}\n />\n )\n }\n onChange={onInputChange}\n onBlur={() => {\n setFilterValue('');\n onBlur?.(value);\n }}\n value={value}\n {...{\n required,\n disabled,\n readOnly,\n status,\n ...restProps\n }}\n />\n {showMap && (\n <StyledLocationMap>\n <LocationView\n {...{\n location,\n onClick: onMapClick,\n onError,\n bias,\n disabled,\n readOnly,\n centerMapOnChange,\n height,\n zoomLevel\n }}\n />\n </StyledLocationMap>\n )}\n </>\n );\n\n return label ? (\n <FormField {...{ label, labelHidden, id, info, status, ref, required, disabled }}>\n {Comp}\n </FormField>\n ) : (\n Comp\n );\n }\n);\n\nexport default LocationInput;\n"]}
1
+ {"version":3,"file":"LocationInput.js","sourceRoot":"","sources":["../../../src/components/Location/LocationInput.tsx"],"names":[],"mappings":";AAAA,OAAO,EAGL,UAAU,EAGV,WAAW,EACX,UAAU,EACV,SAAS,EACT,QAAQ,EACT,MAAM,OAAO,CAAC;AACf,OAAO,MAAM,MAAM,mBAAmB,CAAC;AAEv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EAAE,UAC7D,CACH,EAEH,QAAQ,EAAE,aAAa,EACvB,MAAM,EAAE,GAAG,EAAE;oBACX,cAAc,CAAC,EAAE,CAAC,CAAC;oBACnB,MAAM,EAAE,CAAC,KAAK,CAAC,CAAC;gBAClB,CAAC,EACD,KAAK,EAAE,KAAK,IACR;gBACF,QAAQ;gBACR,QAAQ;gBACR,QAAQ;gBACR,MAAM;gBACN,GAAG,SAAS;aACb,UACD,EACD,OAAO,IAAI,CACV,KAAC,iBAAiB,cAChB,KAAC,YAAY,oBACP;oBACF,QAAQ;oBACR,OAAO,EAAE,UAAU;oBACnB,OAAO;oBACP,IAAI;oBACJ,QAAQ;oBACR,QAAQ;oBACR,iBAAiB;oBACjB,MAAM;oBACN,SAAS;iBACV,UACD,WACgB,CACrB,YACA,CACJ,CAAC;IAEF,OAAO,KAAK,CAAC,CAAC,CAAC,CACb,KAAC,SAAS,oBAAK,EAAE,KAAK,EAAE,WAAW,EAAE,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE,GAAG,EAAE,QAAQ,EAAE,QAAQ,EAAE,cAC7E,IAAI,YACK,CACb,CAAC,CAAC,CAAC,CACF,IAAI,CACL,CAAC;AACJ,CAAC,CACF,CAAC;AAEF,eAAe,aAAa,CAAC","sourcesContent":["import {\n ChangeEvent,\n FC,\n forwardRef,\n PropsWithoutRef,\n Ref,\n useCallback,\n useContext,\n useEffect,\n useState\n} from 'react';\nimport styled from 'styled-components';\n\nimport ComboBox from '../ComboBox';\nimport { MenuProps } from '../Menu';\nimport { useI18n } from '../../hooks';\nimport { createUID } from '../../utils/utils';\nimport FormField from '../FormField';\nimport { FormControlProps } from '../FormControl';\nimport { BaseProps, ForwardProps } from '../../types';\nimport Flex from '../Flex';\n\nimport PoweredByGoogleImage from './PoweredByGoogleImage';\nimport CurrentLocationButton from './CurrentLocationButton';\nimport MapsContext from './MapsContext';\nimport { getPlaceById, getPlacePredictions, loadMapsAPI } from './utils';\nimport BaseLocationProps from './Location.types';\nimport { LatLng } from './types';\nimport LocationView, { LocationViewProps, StyledLocationView } from './LocationView';\n\nexport interface LocationInputProps\n extends LocationViewProps,\n BaseLocationProps,\n BaseProps,\n FormControlProps {\n /**\n * Get user current location on component first render.\n * @default false\n */\n defaultToCurrentLocation?: boolean;\n /** The value of the location field. */\n value?: string;\n /**\n * Callback fired on every change of the location input.\n * The argument passed back is the component's value prop.\n */\n onChange?: (value: string) => void;\n /**\n * Callback fired when the control's input loses focus.\n * The argument passed back is the component's value prop.\n */\n onBlur?: (value: string) => void;\n /**\n * Set to true renders the map view below input.\n * @default false\n */\n showMap?: boolean;\n /** Location coordinates used for the map view. */\n location?: LatLng | string;\n /** Callback fired when user chooses location from the dropdown of suggestions or submits input value. */\n onSelect?: (value: {\n name: string;\n address?: string;\n latitude?: number;\n longitude?: number;\n }) => void;\n}\n\nconst StyledLocationMap = styled.div`\n ${StyledLocationView} {\n border-top-left-radius: 0;\n border-top-right-radius: 0;\n }\n`;\n\nconst LocationInput: FC<LocationInputProps & ForwardProps> = forwardRef(\n (props: PropsWithoutRef<LocationInputProps>, ref: Ref<HTMLInputElement>) => {\n const {\n label,\n labelHidden,\n id = createUID(),\n location = '',\n value = '',\n info,\n status,\n required,\n readOnly,\n disabled,\n onSelect,\n onError,\n onChange,\n bias,\n showMap,\n defaultToCurrentLocation,\n centerMapOnChange,\n height,\n zoomLevel,\n onClick,\n onBlur,\n ...restProps\n } = props;\n const { name, ...providerOpts } = useContext(MapsContext);\n const t = useI18n();\n const [placePredictionMenu, setPlacePredictionMenu] = useState<MenuProps>({ items: [] });\n const [filterValue, setFilterValue] = useState('');\n\n useEffect(() => {\n const mapApiPromise = loadMapsAPI(name, providerOpts).catch(error => onError?.(error));\n\n if (filterValue) {\n mapApiPromise\n .then(() => getPlacePredictions(filterValue, bias))\n .then(({ placePredictions, token }) => {\n setPlacePredictionMenu({\n items: placePredictions.map(item => ({\n id: item.place_id,\n primary: item.structured_formatting.main_text,\n secondary: [item.structured_formatting.secondary_text]\n })),\n emptyText: t('location_not_found_text'),\n onItemClick: itemId =>\n getPlaceById(itemId, token).then(arg => {\n setFilterValue('');\n onSelect?.(arg);\n })\n });\n })\n .catch(error => {\n setPlacePredictionMenu({ items: [] });\n onError?.(error);\n });\n } else {\n setPlacePredictionMenu({ items: [] });\n }\n }, [filterValue, bias, onError, onSelect]);\n\n const onInputChange = useCallback(\n (e: ChangeEvent<HTMLInputElement>) => {\n setFilterValue(e.target.value);\n onChange?.(e.target.value);\n },\n [onChange]\n );\n\n const onMapClick = useCallback(\n (placeInfo: { latitude: number; longitude: number; name: string; address?: string }) => {\n onSelect?.(placeInfo);\n onClick?.(placeInfo);\n },\n [onSelect, onClick]\n );\n\n const Comp = (\n <>\n <ComboBox\n placeholder={t('location_input_placeholder')}\n menu={\n filterValue\n ? {\n ...placePredictionMenu,\n items: placePredictionMenu.items.concat({\n id: createUID(),\n primary: t('use_input_value', `\"${filterValue}\"`)\n }),\n mode: 'action',\n emptyText: t('location_not_found_text'),\n footer: !showMap && (\n <Flex container={{ justify: 'end' }}>\n <PoweredByGoogleImage />\n </Flex>\n )\n }\n : undefined\n }\n actions={\n !disabled &&\n !readOnly && (\n <CurrentLocationButton\n {...{ defaultToCurrentLocation, onError, onChange: onSelect }}\n />\n )\n }\n onChange={onInputChange}\n onBlur={() => {\n setFilterValue('');\n onBlur?.(value);\n }}\n value={value}\n {...{\n required,\n disabled,\n readOnly,\n status,\n ...restProps\n }}\n />\n {showMap && (\n <StyledLocationMap>\n <LocationView\n {...{\n location,\n onClick: onMapClick,\n onError,\n bias,\n disabled,\n readOnly,\n centerMapOnChange,\n height,\n zoomLevel\n }}\n />\n </StyledLocationMap>\n )}\n </>\n );\n\n return label ? (\n <FormField {...{ label, labelHidden, id, info, status, ref, required, disabled }}>\n {Comp}\n </FormField>\n ) : (\n Comp\n );\n }\n);\n\nexport default LocationInput;\n"]}
@@ -56,7 +56,6 @@ const LocationView = (props) => {
56
56
  const map = useRef();
57
57
  const marker = useRef();
58
58
  function initialize() {
59
- var _a;
60
59
  if (mapElemRef.current) {
61
60
  const position = toGoogleLatLng({ latitude: 0, longitude: 0 });
62
61
  map.current = new google.maps.Map(mapElemRef.current, {
@@ -68,11 +67,11 @@ const LocationView = (props) => {
68
67
  map: map.current,
69
68
  position
70
69
  });
71
- (_a = marker.current) === null || _a === void 0 ? void 0 : _a.setVisible(false);
70
+ marker.current?.setVisible(false);
72
71
  if (onClick)
73
72
  map.current.addListener('click', event => {
74
73
  if (hasProp(event, 'placeId')) {
75
- getPlaceById(event.placeId).then(placeInfo => onClick === null || onClick === void 0 ? void 0 : onClick({
74
+ getPlaceById(event.placeId).then(placeInfo => onClick?.({
76
75
  ...placeInfo,
77
76
  latitude: event.latLng.lat(),
78
77
  longitude: event.latLng.lng()
@@ -93,7 +92,7 @@ const LocationView = (props) => {
93
92
  .catch((error) => {
94
93
  setStatus(LoadStatus.Error);
95
94
  setEMessage(error.message);
96
- onError === null || onError === void 0 ? void 0 : onError(error);
95
+ onError?.(error);
97
96
  });
98
97
  return () => {
99
98
  unMounted = true;
@@ -104,14 +103,13 @@ const LocationView = (props) => {
104
103
  useEffect(() => {
105
104
  getCoords(location)
106
105
  .then(coords => {
107
- var _a, _b;
108
106
  if (map.current) {
109
107
  map.current.setOptions({
110
108
  zoom: zoomLevel,
111
109
  draggable: !disabled
112
110
  });
113
- (_a = marker.current) === null || _a === void 0 ? void 0 : _a.setPosition(toGoogleLatLng(coords));
114
- (_b = marker.current) === null || _b === void 0 ? void 0 : _b.setVisible(true);
111
+ marker.current?.setPosition(toGoogleLatLng(coords));
112
+ marker.current?.setVisible(true);
115
113
  if (centerMapOnChange)
116
114
  map.current.setCenter(toGoogleLatLng(coords));
117
115
  if (status !== LoadStatus.Ready)
@@ -119,17 +117,14 @@ const LocationView = (props) => {
119
117
  }
120
118
  })
121
119
  .catch((error) => {
122
- var _a;
123
120
  if (status !== LoadStatus.Error)
124
121
  setStatus(LoadStatus.Error);
125
- (_a = marker.current) === null || _a === void 0 ? void 0 : _a.setVisible(false);
122
+ marker.current?.setVisible(false);
126
123
  setEMessage(error.message);
127
- onError === null || onError === void 0 ? void 0 : onError(error);
124
+ onError?.(error);
128
125
  });
129
126
  }, [location, status, zoomLevel, disabled, centerMapOnChange, onError]);
130
- return (_jsxs(StyledLocationView, Object.assign({ height: height }, { children: [_jsx(Flex, Object.assign({ as: StyledMap, ref: mapElemRef, height: height, disabled: disabled, status: status, eMessage: eMessage }, restProps), void 0),
131
- status === LoadStatus.Init && _jsx(Progress, { placement: 'local' }, void 0),
132
- status === LoadStatus.Error && eMessage && (_jsx(Status, Object.assign({ as: StyledLocationError, "aria-label": eMessage, variant: 'info' }, { children: eMessage }), void 0))] }), void 0));
127
+ return (_jsxs(StyledLocationView, Object.assign({ height: height }, { children: [_jsx(Flex, Object.assign({ as: StyledMap, ref: mapElemRef, height: height, disabled: disabled, status: status, eMessage: eMessage }, restProps), void 0), status === LoadStatus.Init && _jsx(Progress, { placement: 'local' }, void 0), status === LoadStatus.Error && eMessage && (_jsx(Status, Object.assign({ as: StyledLocationError, "aria-label": eMessage, variant: 'info' }, { children: eMessage }), void 0))] }), void 0));
133
128
  };
134
129
  export default LocationView;
135
130
  //# sourceMappingURL=LocationView.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"LocationView.js","sourceRoot":"","sources":["../../../src/components/Location/LocationView.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAM,UAAU,EAAE,MAAM,EAAE,QAAQ,EAAE,SAAS,EAAO,MAAM,OAAO,CAAC;AACzE,OAAO,MAAM,EAAE,EAAE,GAAG,EAAE,MAAM,mBAAmB,CAAC;AAGhD,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAC/C,OAAO,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AACtC,OAAO,QAAQ,MAAM,aAAa,CAAC;AACnC,OAAO,IAAI,MAAM,SAAS,CAAC;AAC3B,OAAO,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;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MAAM,kBAAC,EAAE,EAAE,mBAAmB,gBAAc,QAAQ,EAAE,OAAO,EAAC,MAAM,gBAClE,QAAQ,YACF,CACV,aACkB,CACtB,CAAC;AACJ,CAAC,CAAC;AAEF,eAAe,YAAY,CAAC","sourcesContent":["import { FC, useContext, useRef, useState, useEffect, Ref } from 'react';\nimport styled, { css } from 'styled-components';\n\nimport { BaseProps } from '../../types';\nimport { defaultThemeProp } from '../../theme';\nimport { hasProp } from '../../utils';\nimport Progress from '../Progress';\nimport Flex from '../Flex';\nimport { Status } from '../Badges';\n\nimport { LatLng } from './types';\nimport { loadMapsAPI, getCoords, toGoogleLatLng, getPlaceById } from './utils';\nimport BaseLocationProps from './Location.types';\nimport MapsContext from './MapsContext';\n\nexport const StyledLocationError = styled.div`\n position: absolute;\n top: 40%;\n left: 50%;\n transform: translate(-50%, -50%);\n`;\n\nStyledLocationError.defaultProps = defaultThemeProp;\n\nexport const StyledLocationView = styled.div<{ height?: string }>(props => {\n const { height, theme } = props;\n\n return css`\n height: ${height};\n position: relative;\n flex: auto;\n border-radius: ${theme.base['border-radius']};\n mask-image: radial-gradient(white, black);\n -webkit-mask-image: radial-gradient(white, black);\n `;\n});\n\nStyledLocationView.defaultProps = defaultThemeProp;\n\nconst StyledMap = styled.div<{\n height?: string;\n status: string;\n disabled: boolean;\n eMessage: string;\n}>(\n ({\n height,\n disabled,\n status,\n eMessage,\n theme: {\n base: { 'disabled-opacity': disabledOpacity }\n }\n }) => {\n return css`\n height: ${height};\n ${disabled &&\n css`\n opacity: ${disabledOpacity};\n `}\n ${status === 'error' &&\n eMessage &&\n css`\n opacity: ${disabledOpacity};\n `}\n `;\n }\n);\n\nexport interface LocationViewProps extends BaseLocationProps, BaseProps {\n /**\n * Location string as either coordinates, name of a place, or 'current' for the current location.\n * @default 'current'\n */\n location?: LatLng | string | 'current';\n /**\n * Set to true to always center the map when the selected location changes. Toggling this from false to true will re-center map on the last pinned location.\n * @default false\n */\n centerMapOnChange?: boolean;\n /**\n * Height of the map container.\n * @default '25rem'\n */\n height?: string;\n /**\n * How much the map should zoom.\n * @default 13\n */\n zoomLevel?: number;\n /** Callback fired when user clicks on a location on the map. This function will be passed the coordinates of the location that was clicked. */\n onClick?: (coords: {\n latitude: number;\n longitude: number;\n name: string;\n address?: string;\n }) => void;\n}\n\nenum LoadStatus {\n Init = 'init',\n Ready = 'ready',\n Error = 'error'\n}\n\nconst LocationView: FC<LocationViewProps> = (props: LocationViewProps) => {\n const {\n location = 'current',\n zoomLevel = 13,\n height = '25rem',\n centerMapOnChange = false,\n onClick,\n onError,\n disabled = false,\n ...restProps\n } = props;\n const { name, ...providerOpts } = useContext(MapsContext);\n const [status, setStatus] = useState<LoadStatus>(LoadStatus.Init);\n const [eMessage, setEMessage] = useState('');\n const mapElemRef = useRef<HTMLDivElement>();\n const map = useRef<google.maps.Map<HTMLDivElement>>();\n const marker = useRef<google.maps.Marker>();\n\n function initialize(): void {\n if (mapElemRef.current) {\n const position = toGoogleLatLng({ latitude: 0, longitude: 0 });\n map.current = new google.maps.Map(mapElemRef.current!, {\n center: position,\n zoom: 2,\n draggable: !disabled\n });\n marker.current = new google.maps.Marker({\n map: map.current,\n position\n });\n marker.current?.setVisible(false);\n if (onClick)\n map.current.addListener<'click'>('click', event => {\n if (hasProp(event, 'placeId')) {\n getPlaceById(event.placeId).then(placeInfo =>\n onClick?.({\n ...placeInfo,\n latitude: event.latLng.lat(),\n longitude: event.latLng.lng()\n })\n );\n }\n });\n }\n }\n\n useEffect(() => {\n let unMounted = false;\n loadMapsAPI(name, providerOpts)\n .then(() => {\n if (!unMounted) {\n initialize();\n setStatus(LoadStatus.Ready);\n }\n })\n .catch((error: Error) => {\n setStatus(LoadStatus.Error);\n setEMessage(error.message);\n onError?.(error);\n });\n\n return () => {\n unMounted = true;\n if (map.current) google.maps.event.clearInstanceListeners(map.current);\n };\n }, []);\n\n useEffect(() => {\n getCoords(location!)\n .then(coords => {\n if (map.current) {\n map.current.setOptions({\n zoom: zoomLevel,\n draggable: !disabled\n });\n marker.current?.setPosition(toGoogleLatLng(coords));\n marker.current?.setVisible(true);\n if (centerMapOnChange) map.current.setCenter(toGoogleLatLng(coords));\n if (status !== LoadStatus.Ready) setStatus(LoadStatus.Ready);\n }\n })\n .catch((error: Error) => {\n if (status !== LoadStatus.Error) setStatus(LoadStatus.Error);\n marker.current?.setVisible(false);\n setEMessage(error.message);\n onError?.(error);\n });\n }, [location, status, zoomLevel, disabled, centerMapOnChange, onError]);\n\n return (\n <StyledLocationView height={height}>\n <Flex\n as={StyledMap}\n ref={mapElemRef as Ref<Element>}\n height={height}\n disabled={disabled}\n status={status}\n eMessage={eMessage}\n {...restProps}\n />\n {status === LoadStatus.Init && <Progress placement='local' />}\n {status === LoadStatus.Error && eMessage && (\n <Status as={StyledLocationError} aria-label={eMessage} variant='info'>\n {eMessage}\n </Status>\n )}\n </StyledLocationView>\n );\n};\n\nexport default LocationView;\n"]}
1
+ {"version":3,"file":"LocationView.js","sourceRoot":"","sources":["../../../src/components/Location/LocationView.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAM,UAAU,EAAE,MAAM,EAAE,QAAQ,EAAE,SAAS,EAAO,MAAM,OAAO,CAAC;AACzE,OAAO,MAAM,EAAE,EAAE,GAAG,EAAE,MAAM,mBAAmB,CAAC;AAGhD,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAC/C,OAAO,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AACtC,OAAO,QAAQ,MAAM,aAAa,CAAC;AACnC,OAAO,IAAI,MAAM,SAAS,CAAC;AAC3B,OAAO,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;AAGnC,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,cAAc,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAE/E,OAAO,WAAW,MAAM,eAAe,CAAC;AAExC,MAAM,CAAC,MAAM,mBAAmB,GAAG,MAAM,CAAC,GAAG,CAAA;;;;;CAK5C,CAA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AC,CAAC;gBACrE,IAAI,MAAM,KAAK,UAAU,CAAC,KAAK;oBAAE,SAAS,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC;aAC9D;QACH,CAAC,CAAC;aACD,KAAK,CAAC,CAAC,KAAY,EAAE,EAAE;YACtB,IAAI,MAAM,KAAK,UAAU,CAAC,KAAK;gBAAE,SAAS,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC;YAC7D,MAAM,CAAC,OAAO,EAAE,UAAU,CAAC,KAAK,CAAC,CAAC;YAClC,WAAW,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;YAC3B,OAAO,EAAE,CAAC,KAAK,CAAC,CAAC;QACnB,CAAC,CAAC,CAAC;IACP,CAAC,EAAE,CAAC,QAAQ,EAAE,MAAM,EAAE,SAAS,EAAE,QAAQ,EAAE,iBAAiB,EAAE,OAAO,CAAC,CAAC,CAAC;IAExE,OAAO,CACL,MAAC,kBAAkB,kBAAC,MAAM,EAAE,MAAM,iBAChC,KAAC,IAAI,kBACH,EAAE,EAAE,SAAS,EACb,GAAG,EAAE,UAA0B,EAC/B,MAAM,EAAE,MAAM,EACd,QAAQ,EAAE,QAAQ,EAClB,MAAM,EAAE,MAAM,EACd,QAAQ,EAAE,QAAQ,IACd,SAAS,UACb,EACD,MAAM,KAAK,UAAU,CAAC,IAAI,IAAI,KAAC,QAAQ,IAAC,SAAS,EAAC,OAAO,WAAG,EAC5D,MAAM,KAAK,UAAU,CAAC,KAAK,IAAI,QAAQ,IAAI,CAC1C,KAAC,MAAM,kBAAC,EAAE,EAAE,mBAAmB,gBAAc,QAAQ,EAAE,OAAO,EAAC,MAAM,gBAClE,QAAQ,YACF,CACV,aACkB,CACtB,CAAC;AACJ,CAAC,CAAC;AAEF,eAAe,YAAY,CAAC","sourcesContent":["import { FC, useContext, useRef, useState, useEffect, Ref } from 'react';\nimport styled, { css } from 'styled-components';\n\nimport { BaseProps } from '../../types';\nimport { defaultThemeProp } from '../../theme';\nimport { hasProp } from '../../utils';\nimport Progress from '../Progress';\nimport Flex from '../Flex';\nimport { Status } from '../Badges';\n\nimport { LatLng } from './types';\nimport { loadMapsAPI, getCoords, toGoogleLatLng, getPlaceById } from './utils';\nimport BaseLocationProps from './Location.types';\nimport MapsContext from './MapsContext';\n\nexport const StyledLocationError = styled.div`\n position: absolute;\n top: 40%;\n left: 50%;\n transform: translate(-50%, -50%);\n`;\n\nStyledLocationError.defaultProps = defaultThemeProp;\n\nexport const StyledLocationView = styled.div<{ height?: string }>(props => {\n const { height, theme } = props;\n\n return css`\n height: ${height};\n position: relative;\n flex: auto;\n border-radius: ${theme.base['border-radius']};\n mask-image: radial-gradient(white, black);\n -webkit-mask-image: radial-gradient(white, black);\n `;\n});\n\nStyledLocationView.defaultProps = defaultThemeProp;\n\nconst StyledMap = styled.div<{\n height?: string;\n status: string;\n disabled: boolean;\n eMessage: string;\n}>(\n ({\n height,\n disabled,\n status,\n eMessage,\n theme: {\n base: { 'disabled-opacity': disabledOpacity }\n }\n }) => {\n return css`\n height: ${height};\n ${disabled &&\n css`\n opacity: ${disabledOpacity};\n `}\n ${status === 'error' &&\n eMessage &&\n css`\n opacity: ${disabledOpacity};\n `}\n `;\n }\n);\n\nexport interface LocationViewProps extends BaseLocationProps, BaseProps {\n /**\n * Location string as either coordinates, name of a place, or 'current' for the current location.\n * @default 'current'\n */\n location?: LatLng | string | 'current';\n /**\n * Set to true to always center the map when the selected location changes. Toggling this from false to true will re-center map on the last pinned location.\n * @default false\n */\n centerMapOnChange?: boolean;\n /**\n * Height of the map container.\n * @default '25rem'\n */\n height?: string;\n /**\n * How much the map should zoom.\n * @default 13\n */\n zoomLevel?: number;\n /** Callback fired when user clicks on a location on the map. This function will be passed the coordinates of the location that was clicked. */\n onClick?: (coords: {\n latitude: number;\n longitude: number;\n name: string;\n address?: string;\n }) => void;\n}\n\nenum LoadStatus {\n Init = 'init',\n Ready = 'ready',\n Error = 'error'\n}\n\nconst LocationView: FC<LocationViewProps> = (props: LocationViewProps) => {\n const {\n location = 'current',\n zoomLevel = 13,\n height = '25rem',\n centerMapOnChange = false,\n onClick,\n onError,\n disabled = false,\n ...restProps\n } = props;\n const { name, ...providerOpts } = useContext(MapsContext);\n const [status, setStatus] = useState<LoadStatus>(LoadStatus.Init);\n const [eMessage, setEMessage] = useState('');\n const mapElemRef = useRef<HTMLDivElement>();\n const map = useRef<google.maps.Map<HTMLDivElement>>();\n const marker = useRef<google.maps.Marker>();\n\n function initialize(): void {\n if (mapElemRef.current) {\n const position = toGoogleLatLng({ latitude: 0, longitude: 0 });\n map.current = new google.maps.Map(mapElemRef.current!, {\n center: position,\n zoom: 2,\n draggable: !disabled\n });\n marker.current = new google.maps.Marker({\n map: map.current,\n position\n });\n marker.current?.setVisible(false);\n if (onClick)\n map.current.addListener<'click'>('click', event => {\n if (hasProp(event, 'placeId')) {\n getPlaceById(event.placeId).then(placeInfo =>\n onClick?.({\n ...placeInfo,\n latitude: event.latLng.lat(),\n longitude: event.latLng.lng()\n })\n );\n }\n });\n }\n }\n\n useEffect(() => {\n let unMounted = false;\n loadMapsAPI(name, providerOpts)\n .then(() => {\n if (!unMounted) {\n initialize();\n setStatus(LoadStatus.Ready);\n }\n })\n .catch((error: Error) => {\n setStatus(LoadStatus.Error);\n setEMessage(error.message);\n onError?.(error);\n });\n\n return () => {\n unMounted = true;\n if (map.current) google.maps.event.clearInstanceListeners(map.current);\n };\n }, []);\n\n useEffect(() => {\n getCoords(location!)\n .then(coords => {\n if (map.current) {\n map.current.setOptions({\n zoom: zoomLevel,\n draggable: !disabled\n });\n marker.current?.setPosition(toGoogleLatLng(coords));\n marker.current?.setVisible(true);\n if (centerMapOnChange) map.current.setCenter(toGoogleLatLng(coords));\n if (status !== LoadStatus.Ready) setStatus(LoadStatus.Ready);\n }\n })\n .catch((error: Error) => {\n if (status !== LoadStatus.Error) setStatus(LoadStatus.Error);\n marker.current?.setVisible(false);\n setEMessage(error.message);\n onError?.(error);\n });\n }, [location, status, zoomLevel, disabled, centerMapOnChange, onError]);\n\n return (\n <StyledLocationView height={height}>\n <Flex\n as={StyledMap}\n ref={mapElemRef as Ref<Element>}\n height={height}\n disabled={disabled}\n status={status}\n eMessage={eMessage}\n {...restProps}\n />\n {status === LoadStatus.Init && <Progress placement='local' />}\n {status === LoadStatus.Error && eMessage && (\n <Status as={StyledLocationError} aria-label={eMessage} variant='info'>\n {eMessage}\n </Status>\n )}\n </StyledLocationView>\n );\n};\n\nexport default LocationView;\n"]}
@@ -35,13 +35,12 @@ const providers = {
35
35
  }
36
36
  };
37
37
  export async function loadMapsAPI(name = '', opts) {
38
- var _a;
39
38
  if (typeof opts !== 'object' || !opts) {
40
39
  throw new Error(IsNotAnObjectError);
41
40
  }
42
- const provider = (_a = providers[name]) !== null && _a !== void 0 ? _a : providers.undefined;
43
- if (!provider.loadedPromise || provider.loadedApiKey !== (opts === null || opts === void 0 ? void 0 : opts.apiKey)) {
44
- provider.loadedApiKey = opts === null || opts === void 0 ? void 0 : opts.apiKey;
41
+ const provider = providers[name] ?? providers.undefined;
42
+ if (!provider.loadedPromise || provider.loadedApiKey !== opts?.apiKey) {
43
+ provider.loadedApiKey = opts?.apiKey;
45
44
  provider.loadedPromise = provider.loadAPI(opts);
46
45
  }
47
46
  return provider.loadedPromise;
@@ -67,8 +66,8 @@ export function toGoogleLatLng(coords) {
67
66
  export async function getPlacePredictions(location, bias = {}) {
68
67
  const autocompleteService = new google.maps.places.AutocompleteService();
69
68
  const optionalParams = {};
70
- if (bias === null || bias === void 0 ? void 0 : bias.location) {
71
- if ((bias === null || bias === void 0 ? void 0 : bias.location.center) === 'current') {
69
+ if (bias?.location) {
70
+ if (bias?.location.center === 'current') {
72
71
  await getNavigatorPosition()
73
72
  .then(coords => {
74
73
  optionalParams.location = toGoogleLatLng(coords);
@@ -82,7 +81,7 @@ export async function getPlacePredictions(location, bias = {}) {
82
81
  optionalParams.radius = bias.location.radius;
83
82
  }
84
83
  }
85
- if (bias === null || bias === void 0 ? void 0 : bias.bounds) {
84
+ if (bias?.bounds) {
86
85
  const [sw, ne] = bias.bounds;
87
86
  optionalParams.bounds = new google.maps.LatLngBounds(toGoogleLatLng(sw), toGoogleLatLng(ne));
88
87
  }
@@ -107,13 +106,11 @@ export async function getPlace(location, mapElement = document.createElement('di
107
106
  const placesService = new google.maps.places.PlacesService(mapElement);
108
107
  const { placePredictions, token } = await getPlacePredictions(location);
109
108
  return new Promise((resolve, reject) => {
110
- var _a;
111
- placesService.getDetails({ placeId: (_a = placePredictions[0]) === null || _a === void 0 ? void 0 : _a.place_id, fields: QUERY_FIELDS, sessionToken: token }, (place, pStatus) => {
112
- var _a, _b;
109
+ placesService.getDetails({ placeId: placePredictions[0]?.place_id, fields: QUERY_FIELDS, sessionToken: token }, (place, pStatus) => {
113
110
  if (pStatus === google.maps.places.PlacesServiceStatus.OK) {
114
111
  resolve({
115
- latitude: ((_a = place.geometry) === null || _a === void 0 ? void 0 : _a.location.lat()) || NaN,
116
- longitude: ((_b = place.geometry) === null || _b === void 0 ? void 0 : _b.location.lng()) || NaN
112
+ latitude: place.geometry?.location.lat() || NaN,
113
+ longitude: place.geometry?.location.lng() || NaN
117
114
  });
118
115
  }
119
116
  else {
@@ -126,13 +123,12 @@ export async function getPlaceById(placeId, sessionToken = new google.maps.place
126
123
  const placesService = new google.maps.places.PlacesService(mapElement);
127
124
  return new Promise((resolve, reject) => {
128
125
  placesService.getDetails({ placeId, fields: QUERY_FIELDS, sessionToken }, (place, pStatus) => {
129
- var _a, _b;
130
126
  if (pStatus === google.maps.places.PlacesServiceStatus.OK) {
131
127
  resolve({
132
128
  name: place.name,
133
129
  address: place.formatted_address,
134
- latitude: ((_a = place.geometry) === null || _a === void 0 ? void 0 : _a.location.lat()) || NaN,
135
- longitude: ((_b = place.geometry) === null || _b === void 0 ? void 0 : _b.location.lng()) || NaN
130
+ latitude: place.geometry?.location.lat() || NaN,
131
+ longitude: place.geometry?.location.lng() || NaN
136
132
  });
137
133
  }
138
134
  else {
@@ -1 +1 @@
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AM,CAAC,IAAI,KAAK,CAAC,GAAG,mBAAmB,KAAK,MAAM,EAAE,CAAC,CAAC,CAAC;aACxD;QACH,CAAC,CACF,CAAC;IACJ,CAAC,CAAC,CAAC;AACL,CAAC","sourcesContent":["import { loadScript } from '../../utils';\n\nimport {\n Bias,\n CoordsCannotBeParsedError,\n GeocoderFailedError,\n GeolocationUnsupportedError,\n GoogleMapsAPINotFoundError,\n IsNotAnObjectError,\n LatLng,\n LocationNotFoundError,\n MapsProvider,\n ProviderNotSupportedError,\n ProviderOpts,\n QUERY_FIELDS,\n QUERY_TYPES\n} from './types';\n\nconst GOOGLE_MAPS_SCRIPT_ID = 'google-map';\n\nconst providers: {\n [key: string]: MapsProvider;\n} = {\n google: {\n name: 'Google',\n loadedPromise: null,\n loadedApiKey: '',\n loadAPI(opts) {\n const params = new URLSearchParams(\n Object.entries({\n key: opts.apiKey,\n region: opts.region,\n language: opts.language,\n libraries: 'places'\n }).filter(([, value]) => value !== undefined)\n ).toString();\n\n const loadedScript = document.getElementById(GOOGLE_MAPS_SCRIPT_ID);\n if (loadedScript) {\n loadedScript.remove();\n // https://stackoverflow.com/questions/29930274/fixing-you-have-included-the-google-maps-api-multiple-times-on-this-page-this\n delete (window as any).google;\n }\n\n return new Promise((resolve, reject) => {\n loadScript(\n `https://maps.googleapis.com/maps/api/js?${params}`,\n function onLoad(this: HTMLScriptElement) {\n this.id = GOOGLE_MAPS_SCRIPT_ID;\n return resolve();\n },\n () => reject(new Error(GoogleMapsAPINotFoundError))\n );\n });\n }\n },\n undefined: {\n name: 'undefined',\n loadedPromise: null,\n loadedApiKey: '',\n loadAPI: data => Promise.reject(new Error(`${ProviderNotSupportedError}: ${data.name}`))\n }\n};\n\nexport async function loadMapsAPI(name: string = '', opts?: ProviderOpts): Promise<void> {\n if (typeof opts !== 'object' || !opts) {\n throw new Error(IsNotAnObjectError);\n }\n\n const provider = providers[name] ?? providers.undefined;\n\n if (!provider.loadedPromise || provider.loadedApiKey !== opts?.apiKey) {\n provider.loadedApiKey = opts?.apiKey;\n provider.loadedPromise = provider.loadAPI(opts);\n }\n return provider.loadedPromise;\n}\n\nexport async function getNavigatorPosition(): Promise<LatLng> {\n if (!navigator.geolocation) throw new Error(GeolocationUnsupportedError);\n\n return new Promise((resolve, reject) => {\n navigator.geolocation.getCurrentPosition(\n currentLocation => {\n resolve({\n latitude: currentLocation.coords.latitude,\n longitude: currentLocation.coords.longitude\n });\n },\n error => reject(new Error(error.message))\n );\n });\n}\n\nexport function toGoogleLatLng(coords: LatLng): google.maps.LatLng {\n return new google.maps.LatLng(coords.latitude, coords.longitude);\n}\n\n/** Returns an array of place prediction objects ('place' can be an establishment, geographic location, or prominent point of interest)\n * and session token (valid for multiple queries, followed by one place selection).\n */\nexport async function getPlacePredictions(\n location: string,\n bias: Bias = {}\n): Promise<{\n placePredictions: google.maps.places.AutocompletePrediction[];\n token: google.maps.places.AutocompleteSessionToken;\n}> {\n const autocompleteService = new google.maps.places.AutocompleteService();\n const optionalParams: Partial<google.maps.places.AutocompletionRequest> = {};\n if (bias?.location) {\n if (bias?.location.center === 'current') {\n await getNavigatorPosition()\n .then(coords => {\n optionalParams.location = toGoogleLatLng(coords);\n optionalParams.radius = bias.location!.radius;\n })\n // no-op user didn't allow location\n .catch(() => {});\n } else {\n optionalParams.location = toGoogleLatLng(bias.location.center);\n optionalParams.radius = bias.location.radius;\n }\n }\n\n if (bias?.bounds) {\n const [sw, ne] = bias.bounds;\n optionalParams.bounds = new google.maps.LatLngBounds(toGoogleLatLng(sw), toGoogleLatLng(ne));\n }\n return new Promise((resolve, reject) => {\n const token = new google.maps.places.AutocompleteSessionToken();\n autocompleteService.getPlacePredictions(\n {\n input: location,\n types: QUERY_TYPES,\n sessionToken: token,\n ...optionalParams\n },\n (placePredictions, status) => {\n if (status === google.maps.places.PlacesServiceStatus.OK) {\n resolve({ placePredictions, token });\n } else {\n reject(new Error(LocationNotFoundError));\n }\n }\n );\n });\n}\n\nexport async function getPlace(\n location: string,\n mapElement: HTMLDivElement = document.createElement('div')\n): Promise<LatLng> {\n const placesService = new google.maps.places.PlacesService(mapElement);\n const { placePredictions, token } = await getPlacePredictions(location);\n return new Promise((resolve, reject) => {\n placesService.getDetails(\n { placeId: placePredictions[0]?.place_id, fields: QUERY_FIELDS, sessionToken: token },\n (place, pStatus) => {\n if (pStatus === google.maps.places.PlacesServiceStatus.OK) {\n resolve({\n latitude: place.geometry?.location.lat() || NaN,\n longitude: place.geometry?.location.lng() || NaN\n });\n } else {\n reject(new Error(LocationNotFoundError));\n }\n }\n );\n });\n}\n\nexport async function getPlaceById(\n placeId: string,\n sessionToken: google.maps.places.AutocompleteSessionToken = new google.maps.places.AutocompleteSessionToken(),\n mapElement: HTMLDivElement = document.createElement('div')\n): Promise<{ name: string; address?: string; latitude?: number; longitude?: number }> {\n const placesService = new google.maps.places.PlacesService(mapElement);\n return new Promise((resolve, reject) => {\n placesService.getDetails({ placeId, fields: QUERY_FIELDS, sessionToken }, (place, pStatus) => {\n if (pStatus === google.maps.places.PlacesServiceStatus.OK) {\n resolve({\n name: place.name,\n address: place.formatted_address,\n latitude: place.geometry?.location.lat() || NaN,\n longitude: place.geometry?.location.lng() || NaN\n });\n } else {\n reject(new Error(LocationNotFoundError));\n }\n });\n });\n}\n\n/** Returns coordinations for given input: either coords, address or current position. */\nexport async function getCoords(\n coords: string | LatLng,\n mapElement?: HTMLDivElement\n): Promise<LatLng> {\n if (coords === '' || coords === undefined) throw new Error();\n if (coords === 'current') return getNavigatorPosition();\n\n let location: LatLng;\n if (typeof coords === 'string') {\n const [lat, lng] = coords.split(',', 2).map(Number);\n if (Number.isNaN(lat) || Number.isNaN(lng) || lat === undefined || lng === undefined)\n return getPlace(coords, mapElement);\n location = { latitude: lat, longitude: lng };\n } else {\n location = coords;\n }\n\n if (Number.isFinite(location.latitude) && Number.isFinite(location.longitude)) return location;\n\n throw new Error(CoordsCannotBeParsedError);\n}\n\nexport async function getAddress(\n coords: LatLng\n): Promise<{ name: string; address?: string; latitude?: number; longitude?: number }> {\n const location = {\n lat: coords.latitude,\n lng: coords.longitude\n };\n const geocoder = new google.maps.Geocoder();\n return new Promise((resolve, reject) => {\n geocoder.geocode(\n { location },\n (results: google.maps.GeocoderResult[], status: google.maps.GeocoderStatus) => {\n if (status === 'OK') {\n const [result] = results;\n if (result) {\n resolve({\n name: result.formatted_address,\n address: result.formatted_address,\n ...(result.geometry && {\n latitude: result.geometry.location.lat(),\n longitude: result.geometry.location.lng()\n })\n });\n } else {\n resolve({\n name: `${coords.latitude}, ${coords.longitude}`,\n latitude: coords.latitude,\n longitude: coords.longitude\n });\n }\n } else {\n reject(new Error(`${GeocoderFailedError}: ${status}`));\n }\n }\n );\n });\n}\n"]}
1
+ {"version":3,"file":"utils.js","sourceRoot":"","sources":["../../../src/components/Location/utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAEzC,OAAO,EAEL,yBAAyB,EACzB,mBAAmB,EACnB,2BAA2B,EAC3B,0BAA0B,EAC1B,kBAAkB,EAElB,qBAAqB,EAErB,yBAAyB,EAEzB,YAAY,EACZ,WAAW,EACZ,MAAM,SAAS,CAAC;AAEjB,MAAM,qBAAqB,GAAG,YAAY,CAAC;AAE3C,MAAM,SAAS,GAEX;IACF,MAAM,EAAE;QACN,IAAI,EAAE,QAAQ;QACd,aAAa,EAAE,IAAI;QACnB,YAAY,EAAE,EAAE;QAChB,OAAO,CAAC,IAAI;YACV,MAAM,MAAM,GAAG,IAAI,eAAe,CAChC,MAAM,CAAC,OAAO,CAAC;gBACb,GAAG,EAAE,IAAI,CAAC,MAAM;gBAChB,MAAM,EAAE,IAAI,CAAC,MAAM;gBACnB,QAAQ,EAAE,IAAI,CAAC,QAAQ;gBACvB,SAAS,EAAE,QAAQ;aACpB,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,KAAK,CAAC,EAAE,EAAE,CAAC,KAAK,KAAK,SAAS,CAAC,CAC9C,CA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BACJ;qBAAM;oBACL,OAAO,CAAC;wBACN,IAAI,EAAE,GAAG,MAAM,CAAC,QAAQ,KAAK,MAAM,CAAC,SAAS,EAAE;wBAC/C,QAAQ,EAAE,MAAM,CAAC,QAAQ;wBACzB,SAAS,EAAE,MAAM,CAAC,SAAS;qBAC5B,CAAC,CAAC;iBACJ;aACF;iBAAM;gBACL,MAAM,CAAC,IAAI,KAAK,CAAC,GAAG,mBAAmB,KAAK,MAAM,EAAE,CAAC,CAAC,CAAC;aACxD;QACH,CAAC,CACF,CAAC;IACJ,CAAC,CAAC,CAAC;AACL,CAAC","sourcesContent":["import { loadScript } from '../../utils';\n\nimport {\n Bias,\n CoordsCannotBeParsedError,\n GeocoderFailedError,\n GeolocationUnsupportedError,\n GoogleMapsAPINotFoundError,\n IsNotAnObjectError,\n LatLng,\n LocationNotFoundError,\n MapsProvider,\n ProviderNotSupportedError,\n ProviderOpts,\n QUERY_FIELDS,\n QUERY_TYPES\n} from './types';\n\nconst GOOGLE_MAPS_SCRIPT_ID = 'google-map';\n\nconst providers: {\n [key: string]: MapsProvider;\n} = {\n google: {\n name: 'Google',\n loadedPromise: null,\n loadedApiKey: '',\n loadAPI(opts) {\n const params = new URLSearchParams(\n Object.entries({\n key: opts.apiKey,\n region: opts.region,\n language: opts.language,\n libraries: 'places'\n }).filter(([, value]) => value !== undefined)\n ).toString();\n\n const loadedScript = document.getElementById(GOOGLE_MAPS_SCRIPT_ID);\n if (loadedScript) {\n loadedScript.remove();\n // https://stackoverflow.com/questions/29930274/fixing-you-have-included-the-google-maps-api-multiple-times-on-this-page-this\n delete (window as any).google;\n }\n\n return new Promise((resolve, reject) => {\n loadScript(\n `https://maps.googleapis.com/maps/api/js?${params}`,\n function onLoad(this: HTMLScriptElement) {\n this.id = GOOGLE_MAPS_SCRIPT_ID;\n return resolve();\n },\n () => reject(new Error(GoogleMapsAPINotFoundError))\n );\n });\n }\n },\n undefined: {\n name: 'undefined',\n loadedPromise: null,\n loadedApiKey: '',\n loadAPI: data => Promise.reject(new Error(`${ProviderNotSupportedError}: ${data.name}`))\n }\n};\n\nexport async function loadMapsAPI(name: string = '', opts?: ProviderOpts): Promise<void> {\n if (typeof opts !== 'object' || !opts) {\n throw new Error(IsNotAnObjectError);\n }\n\n const provider = providers[name] ?? providers.undefined;\n\n if (!provider.loadedPromise || provider.loadedApiKey !== opts?.apiKey) {\n provider.loadedApiKey = opts?.apiKey;\n provider.loadedPromise = provider.loadAPI(opts);\n }\n return provider.loadedPromise;\n}\n\nexport async function getNavigatorPosition(): Promise<LatLng> {\n if (!navigator.geolocation) throw new Error(GeolocationUnsupportedError);\n\n return new Promise((resolve, reject) => {\n navigator.geolocation.getCurrentPosition(\n currentLocation => {\n resolve({\n latitude: currentLocation.coords.latitude,\n longitude: currentLocation.coords.longitude\n });\n },\n error => reject(new Error(error.message))\n );\n });\n}\n\nexport function toGoogleLatLng(coords: LatLng): google.maps.LatLng {\n return new google.maps.LatLng(coords.latitude, coords.longitude);\n}\n\n/** Returns an array of place prediction objects ('place' can be an establishment, geographic location, or prominent point of interest)\n * and session token (valid for multiple queries, followed by one place selection).\n */\nexport async function getPlacePredictions(\n location: string,\n bias: Bias = {}\n): Promise<{\n placePredictions: google.maps.places.AutocompletePrediction[];\n token: google.maps.places.AutocompleteSessionToken;\n}> {\n const autocompleteService = new google.maps.places.AutocompleteService();\n const optionalParams: Partial<google.maps.places.AutocompletionRequest> = {};\n if (bias?.location) {\n if (bias?.location.center === 'current') {\n await getNavigatorPosition()\n .then(coords => {\n optionalParams.location = toGoogleLatLng(coords);\n optionalParams.radius = bias.location!.radius;\n })\n // no-op user didn't allow location\n .catch(() => {});\n } else {\n optionalParams.location = toGoogleLatLng(bias.location.center);\n optionalParams.radius = bias.location.radius;\n }\n }\n\n if (bias?.bounds) {\n const [sw, ne] = bias.bounds;\n optionalParams.bounds = new google.maps.LatLngBounds(toGoogleLatLng(sw), toGoogleLatLng(ne));\n }\n return new Promise((resolve, reject) => {\n const token = new google.maps.places.AutocompleteSessionToken();\n autocompleteService.getPlacePredictions(\n {\n input: location,\n types: QUERY_TYPES,\n sessionToken: token,\n ...optionalParams\n },\n (placePredictions, status) => {\n if (status === google.maps.places.PlacesServiceStatus.OK) {\n resolve({ placePredictions, token });\n } else {\n reject(new Error(LocationNotFoundError));\n }\n }\n );\n });\n}\n\nexport async function getPlace(\n location: string,\n mapElement: HTMLDivElement = document.createElement('div')\n): Promise<LatLng> {\n const placesService = new google.maps.places.PlacesService(mapElement);\n const { placePredictions, token } = await getPlacePredictions(location);\n return new Promise((resolve, reject) => {\n placesService.getDetails(\n { placeId: placePredictions[0]?.place_id, fields: QUERY_FIELDS, sessionToken: token },\n (place, pStatus) => {\n if (pStatus === google.maps.places.PlacesServiceStatus.OK) {\n resolve({\n latitude: place.geometry?.location.lat() || NaN,\n longitude: place.geometry?.location.lng() || NaN\n });\n } else {\n reject(new Error(LocationNotFoundError));\n }\n }\n );\n });\n}\n\nexport async function getPlaceById(\n placeId: string,\n sessionToken: google.maps.places.AutocompleteSessionToken = new google.maps.places.AutocompleteSessionToken(),\n mapElement: HTMLDivElement = document.createElement('div')\n): Promise<{ name: string; address?: string; latitude?: number; longitude?: number }> {\n const placesService = new google.maps.places.PlacesService(mapElement);\n return new Promise((resolve, reject) => {\n placesService.getDetails({ placeId, fields: QUERY_FIELDS, sessionToken }, (place, pStatus) => {\n if (pStatus === google.maps.places.PlacesServiceStatus.OK) {\n resolve({\n name: place.name,\n address: place.formatted_address,\n latitude: place.geometry?.location.lat() || NaN,\n longitude: place.geometry?.location.lng() || NaN\n });\n } else {\n reject(new Error(LocationNotFoundError));\n }\n });\n });\n}\n\n/** Returns coordinations for given input: either coords, address or current position. */\nexport async function getCoords(\n coords: string | LatLng,\n mapElement?: HTMLDivElement\n): Promise<LatLng> {\n if (coords === '' || coords === undefined) throw new Error();\n if (coords === 'current') return getNavigatorPosition();\n\n let location: LatLng;\n if (typeof coords === 'string') {\n const [lat, lng] = coords.split(',', 2).map(Number);\n if (Number.isNaN(lat) || Number.isNaN(lng) || lat === undefined || lng === undefined)\n return getPlace(coords, mapElement);\n location = { latitude: lat, longitude: lng };\n } else {\n location = coords;\n }\n\n if (Number.isFinite(location.latitude) && Number.isFinite(location.longitude)) return location;\n\n throw new Error(CoordsCannotBeParsedError);\n}\n\nexport async function getAddress(\n coords: LatLng\n): Promise<{ name: string; address?: string; latitude?: number; longitude?: number }> {\n const location = {\n lat: coords.latitude,\n lng: coords.longitude\n };\n const geocoder = new google.maps.Geocoder();\n return new Promise((resolve, reject) => {\n geocoder.geocode(\n { location },\n (results: google.maps.GeocoderResult[], status: google.maps.GeocoderStatus) => {\n if (status === 'OK') {\n const [result] = results;\n if (result) {\n resolve({\n name: result.formatted_address,\n address: result.formatted_address,\n ...(result.geometry && {\n latitude: result.geometry.location.lat(),\n longitude: result.geometry.location.lng()\n })\n });\n } else {\n resolve({\n name: `${coords.latitude}, ${coords.longitude}`,\n latitude: coords.latitude,\n longitude: coords.longitude\n });\n }\n } else {\n reject(new Error(`${GeocoderFailedError}: ${status}`));\n }\n }\n );\n });\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"FlyoutMenuList.d.ts","sourceRoot":"","sources":["../../../src/components/Menu/FlyoutMenuList.tsx"],"names":[],"mappings":"AAAA,OAAO,EAEL,iBAAiB,EAUlB,MAAM,OAAO,CAAC;AAEf,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAM3C,OAAO,EAAE,aAAa,EAAuB,MAAM,cAAc,CAAC;AAMlE,QAAA,MAAM,cAAc,EAAE,iBAAiB,CAAC,aAAa,GAAG,YAAY,CA6HnE,CAAC;AAEF,eAAe,cAAc,CAAC"}
1
+ {"version":3,"file":"FlyoutMenuList.d.ts","sourceRoot":"","sources":["../../../src/components/Menu/FlyoutMenuList.tsx"],"names":[],"mappings":"AAAA,OAAO,EAEL,iBAAiB,EAUlB,MAAM,OAAO,CAAC;AAEf,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAM3C,OAAO,EAAE,aAAa,EAAuB,MAAM,cAAc,CAAC;AAQlE,QAAA,MAAM,cAAc,EAAE,iBAAiB,CAAC,aAAa,GAAG,YAAY,CA+HnE,CAAC;AAEF,eAAe,cAAc,CAAC"}
@@ -3,12 +3,14 @@ import { createElement as _createElement } from "react";
3
3
  import { forwardRef, useContext, useEffect, useRef, useState, useMemo, useCallback, useLayoutEffect } from 'react';
4
4
  import { useAfterInitialEffect, useConsolidatedRef, useItemIntersection } from '../../hooks';
5
5
  import Progress from '../Progress';
6
- import NoItems from '../NoItems';
6
+ import EmptyState from '../EmptyState';
7
7
  import Popover from '../Popover';
8
8
  import MenuContext from './Menu.context';
9
9
  import MenuItem from './MenuItem';
10
10
  import { StyledLoadingItem, StyledMenuList, StyledFlyoutMenuListContainer } from './Menu.styles';
11
11
  import { resizeRootEl } from './NavItemsList';
12
+ import helpers from './helpers';
13
+ import MenuGroup from './MenuGroup';
12
14
  const FlyoutMenuList = forwardRef(({ items, parent }, ref) => {
13
15
  const selfRef = useConsolidatedRef(ref);
14
16
  const ulRef = useRef(null);
@@ -17,8 +19,7 @@ const FlyoutMenuList = forwardRef(({ items, parent }, ref) => {
17
19
  const [expandedItem, setExpandedItem] = useState();
18
20
  const { componentId, loadMore, loading, scrollAt, emptyText, onItemExpand, pushFlyoutId, flyOutActiveIdStack } = useContext(MenuContext);
19
21
  useItemIntersection(ulRef, items.length - 1, () => {
20
- var _a;
21
- loadMore === null || loadMore === void 0 ? void 0 : loadMore((_a = parent === null || parent === void 0 ? void 0 : parent.item) === null || _a === void 0 ? void 0 : _a.id);
22
+ loadMore?.(parent?.item?.id);
22
23
  });
23
24
  useAfterInitialEffect(() => {
24
25
  if (expandedItem) {
@@ -37,30 +38,27 @@ const FlyoutMenuList = forwardRef(({ items, parent }, ref) => {
37
38
  const listContent = useMemo(() => {
38
39
  if (items.length) {
39
40
  return items.map(item => {
40
- return (_createElement(MenuItem, { ...item, key: item.id, "aria-haspopup": !!item.items, "aria-expanded": item.id === (expandedItem === null || expandedItem === void 0 ? void 0 : expandedItem.id), onExpand: (id, e) => {
41
- var _a;
41
+ return helpers.isItem(item) ? (_createElement(MenuItem, { ...item, key: item.id, "aria-haspopup": !!item.items, "aria-expanded": item.id === expandedItem?.id, onExpand: (id, e) => {
42
42
  if (item.items) {
43
43
  returnFocusRef.current = e.currentTarget;
44
44
  setExpandedItem(item); // FIXME
45
- (_a = item === null || item === void 0 ? void 0 : item.onExpand) === null || _a === void 0 ? void 0 : _a.call(// FIXME
46
- item, id, e);
47
- onItemExpand === null || onItemExpand === void 0 ? void 0 : onItemExpand(id, e);
45
+ item?.onExpand?.(id, e);
46
+ onItemExpand?.(id, e);
48
47
  pushFlyoutId(item.id || componentId);
49
48
  }
50
49
  else {
51
50
  returnFocusRef.current = null;
52
51
  setExpandedItem(undefined);
53
52
  }
54
- } }));
53
+ } })) : (_createElement(MenuGroup, { ...item, key: item.id }));
55
54
  });
56
55
  }
57
56
  if (!loading) {
58
- return _jsx(NoItems, { message: emptyText, forwardedAs: 'li' }, void 0);
57
+ return _jsx(EmptyState, { message: emptyText, forwardedAs: 'li' }, void 0);
59
58
  }
60
59
  return null;
61
60
  }, [items, loading, emptyText, expandedItem]);
62
- const list = (_jsxs(StyledMenuList, Object.assign({ ref: ulRef }, { children: [listContent,
63
- loading && !expandedItem && (_jsx(StyledLoadingItem, { children: _jsx(Progress, { placement: 'local' }, void 0) }, void 0))] }), void 0));
61
+ const list = (_jsxs(StyledMenuList, Object.assign({ ref: ulRef }, { children: [listContent, loading && !expandedItem && (_jsx(StyledLoadingItem, { children: _jsx(Progress, { placement: 'local' }, void 0) }, void 0))] }), void 0));
64
62
  useLayoutEffect(() => {
65
63
  setExpandedItem(undefined);
66
64
  if (selfRef.current) {
@@ -73,8 +71,7 @@ const FlyoutMenuList = forwardRef(({ items, parent }, ref) => {
73
71
  setExpandedItem(undefined);
74
72
  }
75
73
  }, [expandedItem]);
76
- return (_jsxs(_Fragment, { children: [_jsx(StyledFlyoutMenuListContainer, Object.assign({ ref: selfRef, onScroll: handleMenuListScroll, "data-flyout-menu-parent-id": componentId, "data-flyout-menu-id": (parent === null || parent === void 0 ? void 0 : parent.item.id) || componentId }, { children: list }), void 0),
77
- expandedItem && selfRef.current && (_jsx(Popover, Object.assign({ target: returnFocusRef.current, show: true, strategy: 'fixed', placement: 'right-start' }, { children: _jsx(FlyoutMenuList, { items: expandedItem.items, parent: {
74
+ return (_jsxs(_Fragment, { children: [_jsx(StyledFlyoutMenuListContainer, Object.assign({ ref: selfRef, onScroll: handleMenuListScroll, "data-flyout-menu-parent-id": componentId, "data-flyout-menu-id": parent?.item.id || componentId }, { children: list }), void 0), expandedItem && selfRef.current && (_jsx(Popover, Object.assign({ target: returnFocusRef.current, show: true, strategy: 'fixed', placement: 'right-start' }, { children: _jsx(FlyoutMenuList, { items: expandedItem.items, parent: {
78
75
  el: selfRef.current,
79
76
  item: expandedItem,
80
77
  siblingItems: items,
@@ -1 +1 @@
1
- {"version":3,"file":"FlyoutMenuList.js","sourceRoot":"","sources":["../../../src/components/Menu/FlyoutMenuList.tsx"],"names":[],"mappings":";;AAAA,OAAO,EACL,UAAU,EAIV,UAAU,EACV,SAAS,EACT,MAAM,EACN,QAAQ,EACR,OAAO,EACP,WAAW,EACX,eAAe,EAChB,MAAM,OAAO,CAAC;AAGf,OAAO,EAAE,qBAAqB,EAAE,kBAAkB,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC;AAC7F,OAAO,QAAQ,MAAM,aAAa,CAAC;AACnC,OAAO,OAAO,MAAM,YAAY,CAAC;AACjC,OAAO,OAAO,MAAM,YAAY,CAAC;AAGjC,OAAO,WAAW,MAAM,gBAAgB,CAAC;AACzC,OAAO,QAAQ,MAAM,YAAY,CAAC;AAClC,OAAO,EAAE,iBAAiB,EAAE,cAAc,EAAE,6BAA6B,EAAE,MAAM,eAAe,CAAC;AACjG,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC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AK,EAAE,YAAY,CAAC,KAAK,EACzB,MAAM,EAAE;wBACN,EAAE,EAAE,OAAO,CAAC,OAAO;wBACnB,IAAI,EAAE,YAAY;wBAClB,YAAY,EAAE,KAAK;wBACnB,eAAe;wBACf,cAAc;qBACf,WACD,YACM,CACX,YACA,CACJ,CAAC;AACJ,CAAC,CACF,CAAC;AAEF,eAAe,cAAc,CAAC","sourcesContent":["import {\n forwardRef,\n FunctionComponent,\n MutableRefObject,\n PropsWithoutRef,\n useContext,\n useEffect,\n useRef,\n useState,\n useMemo,\n useCallback,\n useLayoutEffect\n} from 'react';\n\nimport { ForwardProps } from '../../types';\nimport { useAfterInitialEffect, useConsolidatedRef, useItemIntersection } from '../../hooks';\nimport Progress from '../Progress';\nimport NoItems from '../NoItems';\nimport Popover from '../Popover';\n\nimport { MenuListProps, ParentMenuItemProps } from './Menu.types';\nimport MenuContext from './Menu.context';\nimport MenuItem from './MenuItem';\nimport { StyledLoadingItem, StyledMenuList, StyledFlyoutMenuListContainer } from './Menu.styles';\nimport { resizeRootEl } from './NavItemsList';\n\nconst FlyoutMenuList: FunctionComponent<MenuListProps & ForwardProps> = forwardRef(\n ({ items, parent }: PropsWithoutRef<MenuListProps>, ref: MenuListProps['ref']) => {\n const selfRef = useConsolidatedRef(ref);\n const ulRef = useRef<HTMLUListElement>(null);\n const menuListWrapperRef: MutableRefObject<HTMLElement | null> = useRef(null);\n const returnFocusRef: MutableRefObject<HTMLButtonElement | null> = useRef(null);\n const [expandedItem, setExpandedItem] = useState<ParentMenuItemProps>();\n const {\n componentId,\n loadMore,\n loading,\n scrollAt,\n emptyText,\n onItemExpand,\n pushFlyoutId,\n flyOutActiveIdStack\n } = useContext(MenuContext);\n\n useItemIntersection(ulRef, items.length - 1, () => {\n loadMore?.(parent?.item?.id);\n });\n\n useAfterInitialEffect(() => {\n if (expandedItem) {\n setExpandedItem(items.find(item => item.id === expandedItem.id) as ParentMenuItemProps); // FIXME\n }\n }, [expandedItem, items]);\n\n useEffect(() => {\n const hasExpanded = items.some(item => {\n return flyOutActiveIdStack.includes(item.id);\n });\n\n if (!hasExpanded) {\n returnFocusRef.current = null;\n setExpandedItem(undefined);\n }\n }, [flyOutActiveIdStack]);\n\n const listContent = useMemo(() => {\n if (items.length) {\n return items.map(item => {\n return (\n <MenuItem\n {...item}\n key={item.id}\n aria-haspopup={!!item.items}\n aria-expanded={item.id === expandedItem?.id}\n onExpand={(id, e) => {\n if (item.items) {\n returnFocusRef.current = e.currentTarget as HTMLButtonElement;\n setExpandedItem(item as ParentMenuItemProps); // FIXME\n item?.onExpand?.(id, e);\n onItemExpand?.(id, e);\n pushFlyoutId(item.id || componentId);\n } else {\n returnFocusRef.current = null;\n setExpandedItem(undefined);\n }\n }}\n />\n );\n });\n }\n\n if (!loading) {\n return <NoItems message={emptyText} forwardedAs='li' />;\n }\n\n return null;\n }, [items, loading, emptyText, expandedItem]);\n\n const list = (\n <StyledMenuList ref={ulRef}>\n {listContent}\n {loading && !expandedItem && (\n <StyledLoadingItem>\n <Progress placement='local' />\n </StyledLoadingItem>\n )}\n </StyledMenuList>\n );\n\n useLayoutEffect(() => {\n setExpandedItem(undefined);\n if (selfRef.current) {\n menuListWrapperRef.current = selfRef.current.parentElement;\n resizeRootEl(selfRef.current, selfRef.current, items.length, scrollAt);\n }\n }, [items]);\n\n const handleMenuListScroll = useCallback(() => {\n if (expandedItem) {\n setExpandedItem(undefined);\n }\n }, [expandedItem]);\n\n return (\n <>\n <StyledFlyoutMenuListContainer\n ref={selfRef}\n onScroll={handleMenuListScroll}\n data-flyout-menu-parent-id={componentId}\n data-flyout-menu-id={parent?.item.id || componentId}\n >\n {list}\n </StyledFlyoutMenuListContainer>\n\n {expandedItem && selfRef.current && (\n <Popover target={returnFocusRef.current} show strategy='fixed' placement='right-start'>\n <FlyoutMenuList\n items={expandedItem.items}\n parent={{\n el: selfRef.current,\n item: expandedItem,\n siblingItems: items,\n setExpandedItem,\n returnFocusRef\n }}\n />\n </Popover>\n )}\n </>\n );\n }\n);\n\nexport default FlyoutMenuList;\n"]}
1
+ {"version":3,"file":"FlyoutMenuList.js","sourceRoot":"","sources":["../../../src/components/Menu/FlyoutMenuList.tsx"],"names":[],"mappings":";;AAAA,OAAO,EACL,UAAU,EAIV,UAAU,EACV,SAAS,EACT,MAAM,EACN,QAAQ,EACR,OAAO,EACP,WAAW,EACX,eAAe,EAChB,MAAM,OAAO,CAAC;AAGf,OAAO,EAAE,qBAAqB,EAAE,kBAAkB,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC;AAC7F,OAAO,QAAQ,MAAM,aAAa,CAAC;AACnC,OAAO,UAAU,MAAM,eAAe,CAAC;AACvC,OAAO,OAAO,MAAM,YAAY,CAAC;AAGjC,OAAO,WAAW,MAAM,gBAAgB,CAAC;AACzC,OAAO,QAAQ,MAAM,YAAY,CAAC;AAClC,OAAO,EAAE,iBAAiB,EAAE,cAAc,EAAE,6BAA6B,EAAE,MAAM,eAAe,CAAC;AACjG,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,OAAO,MAAM,WAAW,CAAC;AAChC,OAAO,SAAS,MAAM,aAAa,CAAC;AAEpC,MAAM,cAAc,GAAoD,UAAU,CAChF,CAAC,EAAE,KAAK,EAAE,MAAM,EAAkC,EAAE,GAAyB,EAAE,EAAE;IAC/E,MAAM,OAAO,GAAG,kBAAkB,CAAC,GAAG,CAAC,CAAC;IACxC,MAAM,KAAK,GAAG,MAAM,CAAmB,IAAI,CAAC,CAAC;IAC7C,MAAM,kBAAkB,GAAyC,MAAM,CAAC,IAAI,CAAC,CAAC;IAC9E,MAAM,cAAc,GAA+C,MAAM,CAAC,IAAI,CAAC,CAAC;IAChF,MAAM,CAAC,YAAY,EAAE,eAAe,CAAC,GAAG,QAAQ,EAAuB,CAAC;IACxE,MAAM,EACJ,WAAW,EACX,QAAQ,EACR,OAAO,EACP,QAAQ,EACR,SAAS,EACT,YAAY,EACZ,YAAY,EACZ,mBAAmB,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Y,CAAC,OAAO,CAAC,OAAO,EAAE,OAAO,CAAC,OAAO,EAAE,KAAK,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC;SACxE;IACH,CAAC,EAAE,CAAC,KAAK,CAAC,CAAC,CAAC;IAEZ,MAAM,oBAAoB,GAAG,WAAW,CAAC,GAAG,EAAE;QAC5C,IAAI,YAAY,EAAE;YAChB,eAAe,CAAC,SAAS,CAAC,CAAC;SAC5B;IACH,CAAC,EAAE,CAAC,YAAY,CAAC,CAAC,CAAC;IAEnB,OAAO,CACL,8BACE,KAAC,6BAA6B,kBAC5B,GAAG,EAAE,OAAO,EACZ,QAAQ,EAAE,oBAAoB,gCACF,WAAW,yBAClB,MAAM,EAAE,IAAI,CAAC,EAAE,IAAI,WAAW,gBAElD,IAAI,YACyB,EAE/B,YAAY,IAAI,OAAO,CAAC,OAAO,IAAI,CAClC,KAAC,OAAO,kBAAC,MAAM,EAAE,cAAc,CAAC,OAAO,EAAE,IAAI,QAAC,QAAQ,EAAC,OAAO,EAAC,SAAS,EAAC,aAAa,gBACpF,KAAC,cAAc,IACb,KAAK,EAAE,YAAY,CAAC,KAAK,EACzB,MAAM,EAAE;wBACN,EAAE,EAAE,OAAO,CAAC,OAAO;wBACnB,IAAI,EAAE,YAAY;wBAClB,YAAY,EAAE,KAAK;wBACnB,eAAe;wBACf,cAAc;qBACf,WACD,YACM,CACX,YACA,CACJ,CAAC;AACJ,CAAC,CACF,CAAC;AAEF,eAAe,cAAc,CAAC","sourcesContent":["import {\n forwardRef,\n FunctionComponent,\n MutableRefObject,\n PropsWithoutRef,\n useContext,\n useEffect,\n useRef,\n useState,\n useMemo,\n useCallback,\n useLayoutEffect\n} from 'react';\n\nimport { ForwardProps } from '../../types';\nimport { useAfterInitialEffect, useConsolidatedRef, useItemIntersection } from '../../hooks';\nimport Progress from '../Progress';\nimport EmptyState from '../EmptyState';\nimport Popover from '../Popover';\n\nimport { MenuListProps, ParentMenuItemProps } from './Menu.types';\nimport MenuContext from './Menu.context';\nimport MenuItem from './MenuItem';\nimport { StyledLoadingItem, StyledMenuList, StyledFlyoutMenuListContainer } from './Menu.styles';\nimport { resizeRootEl } from './NavItemsList';\nimport helpers from './helpers';\nimport MenuGroup from './MenuGroup';\n\nconst FlyoutMenuList: FunctionComponent<MenuListProps & ForwardProps> = forwardRef(\n ({ items, parent }: PropsWithoutRef<MenuListProps>, ref: MenuListProps['ref']) => {\n const selfRef = useConsolidatedRef(ref);\n const ulRef = useRef<HTMLUListElement>(null);\n const menuListWrapperRef: MutableRefObject<HTMLElement | null> = useRef(null);\n const returnFocusRef: MutableRefObject<HTMLButtonElement | null> = useRef(null);\n const [expandedItem, setExpandedItem] = useState<ParentMenuItemProps>();\n const {\n componentId,\n loadMore,\n loading,\n scrollAt,\n emptyText,\n onItemExpand,\n pushFlyoutId,\n flyOutActiveIdStack\n } = useContext(MenuContext);\n\n useItemIntersection(ulRef, items.length - 1, () => {\n loadMore?.(parent?.item?.id);\n });\n\n useAfterInitialEffect(() => {\n if (expandedItem) {\n setExpandedItem(items.find(item => item.id === expandedItem.id) as ParentMenuItemProps); // FIXME\n }\n }, [expandedItem, items]);\n\n useEffect(() => {\n const hasExpanded = items.some(item => {\n return flyOutActiveIdStack.includes(item.id);\n });\n\n if (!hasExpanded) {\n returnFocusRef.current = null;\n setExpandedItem(undefined);\n }\n }, [flyOutActiveIdStack]);\n\n const listContent = useMemo(() => {\n if (items.length) {\n return items.map(item => {\n return helpers.isItem(item) ? (\n <MenuItem\n {...item}\n key={item.id}\n aria-haspopup={!!item.items}\n aria-expanded={item.id === expandedItem?.id}\n onExpand={(id, e) => {\n if (item.items) {\n returnFocusRef.current = e.currentTarget as HTMLButtonElement;\n setExpandedItem(item as ParentMenuItemProps); // FIXME\n item?.onExpand?.(id, e);\n onItemExpand?.(id, e);\n pushFlyoutId(item.id || componentId);\n } else {\n returnFocusRef.current = null;\n setExpandedItem(undefined);\n }\n }}\n />\n ) : (\n <MenuGroup {...item} key={item.id} />\n );\n });\n }\n\n if (!loading) {\n return <EmptyState message={emptyText} forwardedAs='li' />;\n }\n\n return null;\n }, [items, loading, emptyText, expandedItem]);\n\n const list = (\n <StyledMenuList ref={ulRef}>\n {listContent}\n {loading && !expandedItem && (\n <StyledLoadingItem>\n <Progress placement='local' />\n </StyledLoadingItem>\n )}\n </StyledMenuList>\n );\n\n useLayoutEffect(() => {\n setExpandedItem(undefined);\n if (selfRef.current) {\n menuListWrapperRef.current = selfRef.current.parentElement;\n resizeRootEl(selfRef.current, selfRef.current, items.length, scrollAt);\n }\n }, [items]);\n\n const handleMenuListScroll = useCallback(() => {\n if (expandedItem) {\n setExpandedItem(undefined);\n }\n }, [expandedItem]);\n\n return (\n <>\n <StyledFlyoutMenuListContainer\n ref={selfRef}\n onScroll={handleMenuListScroll}\n data-flyout-menu-parent-id={componentId}\n data-flyout-menu-id={parent?.item.id || componentId}\n >\n {list}\n </StyledFlyoutMenuListContainer>\n\n {expandedItem && selfRef.current && (\n <Popover target={returnFocusRef.current} show strategy='fixed' placement='right-start'>\n <FlyoutMenuList\n items={expandedItem.items}\n parent={{\n el: selfRef.current,\n item: expandedItem,\n siblingItems: items,\n setExpandedItem,\n returnFocusRef\n }}\n />\n </Popover>\n )}\n </>\n );\n }\n);\n\nexport default FlyoutMenuList;\n"]}