@algolia/satellite 1.0.0-beta.164 → 1.0.0-beta.165

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 (494) hide show
  1. package/cjs/AnnouncementBadge/AnnouncementBadge.d.ts +3 -3
  2. package/cjs/AnnouncementBadge/AnnouncementBadge.js +4 -6
  3. package/cjs/AnnouncementBadge/index.js +2 -2
  4. package/cjs/AutoComplete/AutoComplete.d.ts +3 -49
  5. package/cjs/AutoComplete/AutoComplete.js +347 -516
  6. package/cjs/AutoComplete/AutoComplete.tailwind.d.ts +1 -1
  7. package/cjs/AutoComplete/components/AutoCompleteEmptyState.js +2 -4
  8. package/cjs/AutoComplete/components/AutocompleteContext.d.ts +5 -0
  9. package/cjs/AutoComplete/components/AutocompleteContext.js +19 -0
  10. package/cjs/AutoComplete/components/DefaultOptionItem.d.ts +2 -2
  11. package/cjs/AutoComplete/components/DefaultOptionItem.js +4 -5
  12. package/cjs/AutoComplete/index.d.ts +1 -0
  13. package/cjs/AutoComplete/index.js +14 -2
  14. package/cjs/AutoComplete/types.d.ts +1 -1
  15. package/cjs/AutoComplete/utils.d.ts +3 -0
  16. package/cjs/AutoComplete/utils.js +36 -6
  17. package/cjs/Avatars/ApplicationAvatar.js +2 -4
  18. package/cjs/Avatars/UserAvatar.js +4 -6
  19. package/cjs/Avatars/index.js +2 -2
  20. package/cjs/Avatars/utils.js +9 -13
  21. package/cjs/Badge/Badge.d.ts +0 -2
  22. package/cjs/Badge/Badge.js +4 -6
  23. package/cjs/Badge/index.js +2 -2
  24. package/cjs/Banners/Alert/Alert.d.ts +2 -2
  25. package/cjs/Banners/Alert/Alert.js +2 -4
  26. package/cjs/Banners/Alert/index.js +2 -2
  27. package/cjs/Banners/BigBertha/BigBertha.js +2 -4
  28. package/cjs/Banners/BigBertha/index.js +2 -2
  29. package/cjs/Banners/Promote/Promote.d.ts +0 -6
  30. package/cjs/Banners/Promote/Promote.js +2 -10
  31. package/cjs/Banners/Promote/index.js +2 -2
  32. package/cjs/Button/Button.js +4 -6
  33. package/cjs/Button/Button.tailwind.d.ts +1 -1
  34. package/cjs/Button/Button.tailwind.js +1 -1
  35. package/cjs/Button/ButtonGroup.d.ts +1 -1
  36. package/cjs/Button/ButtonGroup.js +2 -4
  37. package/cjs/Button/IconButton.d.ts +5 -0
  38. package/cjs/Button/IconButton.js +9 -6
  39. package/cjs/Button/PolymorphicButton.js +5 -6
  40. package/cjs/Button/PolymorphicIconButton.d.ts +5 -1
  41. package/cjs/Button/PolymorphicIconButton.js +12 -12
  42. package/cjs/Button/index.js +2 -2
  43. package/cjs/Button/styles.d.ts +1 -1
  44. package/cjs/Button/styles.js +8 -9
  45. package/cjs/Button/types.d.ts +3 -2
  46. package/cjs/Card/Card.d.ts +1 -1
  47. package/cjs/Card/Card.js +4 -6
  48. package/cjs/Card/Card.tailwind.d.ts +1 -1
  49. package/cjs/Card/components/CardHeader.js +4 -6
  50. package/cjs/Card/components/CardTitle.js +4 -6
  51. package/cjs/Card/index.js +2 -2
  52. package/cjs/Checkbox/Checkbox.d.ts +3 -3
  53. package/cjs/Checkbox/Checkbox.js +6 -8
  54. package/cjs/Checkbox/Checkbox.tailwind.d.ts +1 -1
  55. package/cjs/Checkbox/Checkbox.tailwind.js +5 -0
  56. package/cjs/Checkbox/index.js +2 -2
  57. package/cjs/ClickAwayContainer/ClickAwayContainer.js +5 -9
  58. package/cjs/DatePicker/DatePicker/DatePicker.d.ts +1 -1
  59. package/cjs/DatePicker/DatePicker/DatePicker.js +11 -12
  60. package/cjs/DatePicker/DatePicker/datePickerReducer.js +8 -11
  61. package/cjs/DatePicker/DatePicker/index.js +2 -2
  62. package/cjs/DatePicker/DatePicker.tailwind.d.ts +1 -1
  63. package/cjs/DatePicker/DateRangePicker/DateRangePicker.js +5 -7
  64. package/cjs/DatePicker/DateRangePicker/DateRangePickerDisplay.js +1 -2
  65. package/cjs/DatePicker/DateRangePicker/dateRangePickerReducer.js +8 -11
  66. package/cjs/DatePicker/DateRangePicker/dateRangePickerTimeRange.js +4 -7
  67. package/cjs/DatePicker/DateRangePicker/index.js +2 -2
  68. package/cjs/DatePicker/components/Calendar.js +3 -4
  69. package/cjs/DatePicker/components/Display.js +1 -2
  70. package/cjs/DatePicker/components/Footer.js +1 -2
  71. package/cjs/DatePicker/components/FooterActions.js +1 -2
  72. package/cjs/DatePicker/components/Modal.js +4 -6
  73. package/cjs/DatePicker/components/NavBar.js +3 -4
  74. package/cjs/DatePicker/components/SidePanel.js +1 -2
  75. package/cjs/DatePicker/index.d.ts +0 -1
  76. package/cjs/DatePicker/index.js +2 -17
  77. package/cjs/DatePicker/utils.js +3 -5
  78. package/cjs/Dropdown/Dropdown.js +5 -8
  79. package/cjs/Dropdown/DropdownButton.js +4 -6
  80. package/cjs/Dropdown/DropdownContext.js +3 -6
  81. package/cjs/Dropdown/components/DropdownButtonItem.d.ts +1 -1
  82. package/cjs/Dropdown/components/DropdownButtonItem.js +4 -6
  83. package/cjs/Dropdown/components/DropdownCollapsibleItem/DropdownCollapsibleItem.js +3 -5
  84. package/cjs/Dropdown/components/DropdownCollapsibleItem/DropdownCollapsibleItemsGroup.js +2 -3
  85. package/cjs/Dropdown/components/DropdownCollapsibleItem/DropdownCollapsibleItemsGroupContext.js +3 -5
  86. package/cjs/Dropdown/components/DropdownCollapsibleItem/DropdownCollapsibleItemsMultiGroup.js +2 -3
  87. package/cjs/Dropdown/components/DropdownCollapsibleItem/DropdownCollapsibleItemsSingleGroup.js +2 -3
  88. package/cjs/Dropdown/components/DropdownDivider.js +2 -4
  89. package/cjs/Dropdown/components/DropdownFooterItem.d.ts +1 -0
  90. package/cjs/Dropdown/components/DropdownFooterItem.js +4 -6
  91. package/cjs/Dropdown/components/DropdownLinkItem.js +4 -6
  92. package/cjs/Dropdown/components/DropdownRadioItem.js +4 -6
  93. package/cjs/Dropdown/components/DropdownTitle.js +4 -6
  94. package/cjs/Dropdown/components/DropdownToggleItem.js +4 -6
  95. package/cjs/Dropdown/index.js +2 -2
  96. package/cjs/Dropdown/useDropdownItemProps.js +4 -6
  97. package/cjs/Dropzone/Dropzone.js +6 -8
  98. package/cjs/Dropzone/index.js +2 -2
  99. package/cjs/EmptyState/EmptyState.js +26 -28
  100. package/cjs/EmptyState/EmptyState.tailwind.d.ts +1 -1
  101. package/cjs/EmptyState/index.js +2 -2
  102. package/cjs/EmptyState/types.d.ts +8 -23
  103. package/cjs/Field/Field.d.ts +0 -1
  104. package/cjs/Field/Field.js +4 -6
  105. package/cjs/Field/FieldStateContext.js +3 -6
  106. package/cjs/Field/index.js +2 -2
  107. package/cjs/Field/useFieldState.js +4 -6
  108. package/cjs/Flag/Flag.js +5 -7
  109. package/cjs/Flag/Flag.tailwind.d.ts +1 -1
  110. package/cjs/Flag/Flags.js +8 -9
  111. package/cjs/Flag/index.js +2 -2
  112. package/cjs/FlexGrid/FlexGrid.d.ts +1 -12
  113. package/cjs/FlexGrid/FlexGrid.js +2 -4
  114. package/cjs/FlexGrid/FlexGrid.tailwind.d.ts +1 -1
  115. package/cjs/FlexGrid/FlexGrid.tailwind.js +2 -2
  116. package/cjs/FlexGrid/index.js +2 -2
  117. package/cjs/HelpUnderline/HelpUnderline.js +4 -6
  118. package/cjs/HelpUnderline/HelpUnderline.tailwind.d.ts +1 -1
  119. package/cjs/HelpUnderline/index.js +2 -2
  120. package/cjs/Input/Input.d.ts +4 -1
  121. package/cjs/Input/Input.js +8 -10
  122. package/cjs/Input/Input.tailwind.d.ts +1 -1
  123. package/cjs/Input/index.js +2 -2
  124. package/cjs/Insert/Insert.js +2 -4
  125. package/cjs/Insert/index.js +2 -2
  126. package/cjs/InstantSearch/InstantSearch.tailwind.d.ts +1 -1
  127. package/cjs/KeyboardKey/KeyboardKey.js +2 -3
  128. package/cjs/KeyboardKey/KeyboardKey.tailwind.d.ts +1 -1
  129. package/cjs/Link/BaseLink.js +4 -6
  130. package/cjs/Link/ButtonLink.js +4 -6
  131. package/cjs/Link/IconButtonLink.js +4 -6
  132. package/cjs/Link/Link.d.ts +2 -2
  133. package/cjs/Link/Link.js +4 -6
  134. package/cjs/Link/index.js +2 -2
  135. package/cjs/Medallion/Medallion.d.ts +1 -0
  136. package/cjs/Medallion/Medallion.js +2 -4
  137. package/cjs/Medallion/Medallion.tailwind.d.ts +1 -1
  138. package/cjs/Medallion/index.js +2 -2
  139. package/cjs/Modal/Modal.js +12 -13
  140. package/cjs/Modal/Modal.tailwind.d.ts +1 -1
  141. package/cjs/Modal/components/ModalFooter.js +4 -6
  142. package/cjs/Modal/components/ModalSection.js +2 -4
  143. package/cjs/Modal/index.js +2 -2
  144. package/cjs/Pagination/CompactPagination/CompactPagination.js +6 -10
  145. package/cjs/Pagination/CompactPagination/index.js +2 -2
  146. package/cjs/Pagination/DotPagination/DotPagination.js +5 -7
  147. package/cjs/Pagination/DotPagination/index.js +2 -2
  148. package/cjs/Pagination/Pagination/Pagination.js +6 -8
  149. package/cjs/Pagination/Pagination/index.js +2 -2
  150. package/cjs/Pagination/index.js +2 -2
  151. package/cjs/Popover/Popover.d.ts +5 -0
  152. package/cjs/Popover/Popover.js +137 -0
  153. package/cjs/Popover/index.d.ts +3 -0
  154. package/cjs/Popover/index.js +36 -0
  155. package/cjs/Popover/types.d.ts +74 -0
  156. package/cjs/Popover/types.js +5 -0
  157. package/cjs/ProgressBar/ProgressBar.js +6 -7
  158. package/cjs/ProgressBar/ProgressBar.tailwind.d.ts +1 -1
  159. package/cjs/ProgressBar/index.js +2 -2
  160. package/cjs/ProgressSpinner/ProgressSpinner.js +4 -6
  161. package/cjs/ProgressSpinner/ProgressSpinner.tailwind.d.ts +1 -1
  162. package/cjs/ProgressSpinner/ProgressSpinner.tailwind.js +8 -0
  163. package/cjs/ProgressSpinner/index.js +2 -2
  164. package/cjs/RadioGroup/RadioButton.d.ts +1 -1
  165. package/cjs/RadioGroup/RadioButton.js +4 -6
  166. package/cjs/RadioGroup/RadioButton.tailwind.d.ts +1 -1
  167. package/cjs/RadioGroup/RadioButton.tailwind.js +3 -0
  168. package/cjs/RadioGroup/RadioGroup.d.ts +1 -0
  169. package/cjs/RadioGroup/RadioGroup.js +3 -6
  170. package/cjs/RadioGroup/RadiogroupContext.d.ts +1 -4
  171. package/cjs/RadioGroup/RadiogroupContext.js +3 -5
  172. package/cjs/RadioGroup/index.js +2 -2
  173. package/cjs/RangeSlider/RangeSlider.d.ts +2 -0
  174. package/cjs/RangeSlider/RangeSlider.js +4 -6
  175. package/cjs/RangeSlider/index.js +2 -2
  176. package/cjs/Satellite/Satellite.js +5 -7
  177. package/cjs/Satellite/SatelliteContext.js +5 -8
  178. package/cjs/Satellite/SatelliteRouter.js +2 -4
  179. package/cjs/Satellite/index.js +2 -2
  180. package/cjs/Satellite/locale.d.ts +2 -0
  181. package/cjs/Satellite/locale.js +2 -3
  182. package/cjs/Satellite/useCreatePortal.js +2 -3
  183. package/cjs/ScrollIndicator/ScrollIndicator.js +2 -4
  184. package/cjs/ScrollIndicator/ScrollIndicator.tailwind.d.ts +1 -1
  185. package/cjs/ScrollIndicator/index.js +2 -2
  186. package/cjs/Select/Select.js +4 -6
  187. package/cjs/Select/Select.tailwind.d.ts +1 -1
  188. package/cjs/Select/index.js +2 -2
  189. package/cjs/Separator/Separator.d.ts +1 -0
  190. package/cjs/Separator/Separator.js +21 -11
  191. package/cjs/Separator/Separator.tailwind.d.ts +1 -1
  192. package/cjs/Separator/Separator.tailwind.js +31 -2
  193. package/cjs/Separator/index.js +2 -2
  194. package/cjs/Sidebar/Sidebar.d.ts +1 -0
  195. package/cjs/Sidebar/Sidebar.js +4 -5
  196. package/cjs/Sidebar/SidebarButtonLink.js +4 -5
  197. package/cjs/Sidebar/SidebarContext.js +3 -5
  198. package/cjs/Sidebar/SidebarHeader.d.ts +1 -0
  199. package/cjs/Sidebar/SidebarHeader.js +2 -3
  200. package/cjs/Sidebar/SidebarHeading.d.ts +1 -0
  201. package/cjs/Sidebar/SidebarHeading.js +2 -3
  202. package/cjs/Sidebar/SidebarLink.js +4 -5
  203. package/cjs/Sidebar/SidebarLinksGroup/ActiveLinkIndicator.d.ts +1 -0
  204. package/cjs/Sidebar/SidebarLinksGroup/ActiveLinkIndicator.js +3 -4
  205. package/cjs/Sidebar/SidebarLinksGroup/SidebarGroupLink.js +4 -5
  206. package/cjs/Sidebar/SidebarLinksGroup/SidebarLinksGroup.d.ts +1 -0
  207. package/cjs/Sidebar/SidebarLinksGroup/SidebarLinksGroup.js +6 -7
  208. package/cjs/Sidebar/SidebarNav.d.ts +1 -0
  209. package/cjs/Sidebar/SidebarNav.js +2 -3
  210. package/cjs/Switch/Switch.d.ts +1 -0
  211. package/cjs/Switch/Switch.js +5 -5
  212. package/cjs/Switch/Switch.tailwind.d.ts +1 -1
  213. package/cjs/Switch/SwitchOption.js +5 -7
  214. package/cjs/Switch/index.js +2 -2
  215. package/cjs/Switch/utils.js +5 -9
  216. package/cjs/Tables/DataTable/DataTable.d.ts +8 -1
  217. package/cjs/Tables/DataTable/DataTable.js +6 -8
  218. package/cjs/Tables/DataTable/DataTable.tailwind.d.ts +1 -1
  219. package/cjs/Tables/DataTable/components/Body.js +4 -6
  220. package/cjs/Tables/DataTable/components/Footer.js +6 -8
  221. package/cjs/Tables/DataTable/components/Header.js +2 -4
  222. package/cjs/Tables/DataTable/components/HeaderCell.js +6 -8
  223. package/cjs/Tables/DataTable/components/Loader.d.ts +1 -0
  224. package/cjs/Tables/DataTable/components/Loader.js +3 -5
  225. package/cjs/Tables/DataTable/index.js +2 -2
  226. package/cjs/Tables/DataTable/types.d.ts +14 -0
  227. package/cjs/Tables/DataTable/utils.js +4 -7
  228. package/cjs/Tables/Table/Table.js +4 -6
  229. package/cjs/Tables/Table/Table.tailwind.d.ts +1 -1
  230. package/cjs/Tables/Table/components/TableFooter.js +2 -4
  231. package/cjs/Tables/Table/index.js +2 -2
  232. package/cjs/Tables/index.js +2 -2
  233. package/cjs/Tabs/ContentTabs.js +2 -4
  234. package/cjs/Tabs/LinkTabs.js +3 -6
  235. package/cjs/Tabs/Tabs.tailwind.d.ts +1 -1
  236. package/cjs/Tabs/Tabs.tailwind.js +20 -1
  237. package/cjs/Tabs/components/LinkTab.js +12 -14
  238. package/cjs/Tabs/index.js +2 -2
  239. package/cjs/Tabs/types.d.ts +0 -1
  240. package/cjs/Tabs/utils.js +2 -3
  241. package/cjs/Tag/Tag.d.ts +7 -17
  242. package/cjs/Tag/Tag.js +16 -12
  243. package/cjs/Tag/Tag.tailwind.d.ts +1 -1
  244. package/cjs/Tag/index.js +2 -2
  245. package/cjs/TextArea/TextArea.js +4 -6
  246. package/cjs/TextArea/TextArea.tailwind.d.ts +1 -1
  247. package/cjs/TextArea/index.js +2 -2
  248. package/cjs/TextWrap/TextWrap.js +4 -6
  249. package/cjs/TextWrap/index.js +2 -2
  250. package/cjs/Toggle/Toggle.d.ts +6 -2
  251. package/cjs/Toggle/Toggle.js +26 -13
  252. package/cjs/Toggle/Toggle.tailwind.d.ts +1 -1
  253. package/cjs/Toggle/Toggle.tailwind.js +18 -6
  254. package/cjs/Toggle/index.js +2 -2
  255. package/cjs/Tooltip/OverflowTooltipWrapper.js +4 -5
  256. package/cjs/Tooltip/Tooltip.d.ts +1 -1
  257. package/cjs/Tooltip/Tooltip.js +4 -6
  258. package/cjs/Tooltip/Tooltip.tailwind.d.ts +1 -1
  259. package/cjs/Tooltip/Tooltip.tailwind.js +1 -91
  260. package/cjs/Tooltip/TooltipWrapper.d.ts +2 -2
  261. package/cjs/Tooltip/TooltipWrapper.js +7 -8
  262. package/cjs/Tooltip/index.js +2 -2
  263. package/cjs/Tooltip/types.d.ts +15 -15
  264. package/cjs/Tooltip/utils.js +2 -3
  265. package/cjs/Typography/Typography.tailwind.d.ts +1 -1
  266. package/cjs/Typography/Typography.tailwind.js +2 -2
  267. package/cjs/UserContent/UserContent.d.ts +1 -0
  268. package/cjs/UserContent/UserContent.js +2 -4
  269. package/cjs/UserContent/UserContent.tailwind.d.ts +1 -1
  270. package/cjs/UserContent/UserContent.tailwind.js +2 -2
  271. package/cjs/styles/base.tailwind.d.ts +1 -1
  272. package/cjs/styles/helpers/makePurgeCssExtractor.js +1 -1
  273. package/cjs/styles/tailwind.config.js +3 -3
  274. package/cjs/styles/zIndexes.d.ts +1 -0
  275. package/cjs/styles/zIndexes.js +4 -3
  276. package/cjs/types.d.ts +2 -3
  277. package/cjs/utilities/overlay.tailwind.d.ts +5 -0
  278. package/cjs/utilities/overlay.tailwind.js +107 -0
  279. package/cjs/utilities/utilities.tailwind.d.ts +1 -1
  280. package/cjs/utils/genericChangeHandler.js +1 -2
  281. package/cjs/utils/hashCode.js +2 -4
  282. package/cjs/utils/isCssPropertySupported.d.ts +1 -1
  283. package/cjs/utils/isCssPropertySupported.js +1 -2
  284. package/cjs/utils/isNil.js +2 -4
  285. package/cjs/utils/isReactText.js +2 -3
  286. package/cjs/utils/isRenderedChild.js +1 -2
  287. package/cjs/utils/matchLocation.js +1 -2
  288. package/cjs/utils/onlyText.js +1 -2
  289. package/cjs/utils/parseUrl.js +2 -4
  290. package/cjs/utils/pluralize.js +1 -2
  291. package/cjs/utils/prefersReducedMotion.d.ts +6 -0
  292. package/cjs/utils/prefersReducedMotion.js +12 -0
  293. package/cjs/utils/range.js +1 -2
  294. package/cjs/utils/toSentenceCase.js +2 -4
  295. package/cjs/utils/uniqBy.js +1 -2
  296. package/cjs/utils/uniqueId.js +1 -2
  297. package/cjs/utils/useForwardedRef.js +1 -2
  298. package/cjs/utils/useLinkProps.js +2 -4
  299. package/cjs/utils/useTriggerInputChange.js +1 -2
  300. package/esm/AnnouncementBadge/AnnouncementBadge.d.ts +3 -3
  301. package/esm/AnnouncementBadge/AnnouncementBadge.js +2 -2
  302. package/esm/AutoComplete/AutoComplete.d.ts +3 -49
  303. package/esm/AutoComplete/AutoComplete.js +350 -517
  304. package/esm/AutoComplete/AutoComplete.tailwind.d.ts +1 -1
  305. package/esm/AutoComplete/components/AutocompleteContext.d.ts +5 -0
  306. package/esm/AutoComplete/components/AutocompleteContext.js +13 -0
  307. package/esm/AutoComplete/components/DefaultOptionItem.d.ts +2 -2
  308. package/esm/AutoComplete/components/DefaultOptionItem.js +2 -2
  309. package/esm/AutoComplete/index.d.ts +1 -0
  310. package/esm/AutoComplete/index.js +1 -0
  311. package/esm/AutoComplete/types.d.ts +1 -1
  312. package/esm/AutoComplete/utils.d.ts +3 -0
  313. package/esm/AutoComplete/utils.js +31 -1
  314. package/esm/Avatars/UserAvatar.js +2 -2
  315. package/esm/Avatars/utils.js +2 -2
  316. package/esm/Badge/Badge.d.ts +0 -2
  317. package/esm/Badge/Badge.js +2 -2
  318. package/esm/Banners/Alert/Alert.d.ts +2 -2
  319. package/esm/Banners/Promote/Promote.d.ts +0 -6
  320. package/esm/Banners/Promote/Promote.js +0 -6
  321. package/esm/Button/Button.js +2 -2
  322. package/esm/Button/Button.tailwind.d.ts +1 -1
  323. package/esm/Button/Button.tailwind.js +1 -1
  324. package/esm/Button/ButtonGroup.d.ts +1 -1
  325. package/esm/Button/IconButton.d.ts +5 -0
  326. package/esm/Button/IconButton.js +7 -2
  327. package/esm/Button/PolymorphicButton.js +2 -2
  328. package/esm/Button/PolymorphicIconButton.d.ts +5 -1
  329. package/esm/Button/PolymorphicIconButton.js +11 -10
  330. package/esm/Button/styles.d.ts +1 -1
  331. package/esm/Button/styles.js +3 -0
  332. package/esm/Button/types.d.ts +3 -2
  333. package/esm/Card/Card.d.ts +1 -1
  334. package/esm/Card/Card.js +2 -2
  335. package/esm/Card/Card.tailwind.d.ts +1 -1
  336. package/esm/Card/components/CardHeader.js +2 -2
  337. package/esm/Card/components/CardTitle.js +2 -2
  338. package/esm/Checkbox/Checkbox.d.ts +3 -3
  339. package/esm/Checkbox/Checkbox.js +4 -4
  340. package/esm/Checkbox/Checkbox.tailwind.d.ts +1 -1
  341. package/esm/Checkbox/Checkbox.tailwind.js +5 -0
  342. package/esm/ClickAwayContainer/ClickAwayContainer.js +1 -1
  343. package/esm/DatePicker/DatePicker/DatePicker.d.ts +1 -1
  344. package/esm/DatePicker/DatePicker/DatePicker.js +9 -9
  345. package/esm/DatePicker/DatePicker/datePickerReducer.js +5 -5
  346. package/esm/DatePicker/DatePicker.tailwind.d.ts +1 -1
  347. package/esm/DatePicker/DateRangePicker/DateRangePicker.js +3 -3
  348. package/esm/DatePicker/DateRangePicker/dateRangePickerReducer.js +5 -5
  349. package/esm/DatePicker/components/Calendar.js +2 -2
  350. package/esm/DatePicker/components/Modal.js +2 -2
  351. package/esm/DatePicker/components/NavBar.js +2 -2
  352. package/esm/DatePicker/index.d.ts +0 -1
  353. package/esm/DatePicker/index.js +0 -1
  354. package/esm/Dropdown/Dropdown.js +2 -2
  355. package/esm/Dropdown/DropdownButton.js +2 -2
  356. package/esm/Dropdown/components/DropdownButtonItem.d.ts +1 -1
  357. package/esm/Dropdown/components/DropdownButtonItem.js +2 -2
  358. package/esm/Dropdown/components/DropdownCollapsibleItem/DropdownCollapsibleItem.js +1 -1
  359. package/esm/Dropdown/components/DropdownFooterItem.d.ts +1 -0
  360. package/esm/Dropdown/components/DropdownFooterItem.js +2 -2
  361. package/esm/Dropdown/components/DropdownLinkItem.js +2 -2
  362. package/esm/Dropdown/components/DropdownRadioItem.js +2 -2
  363. package/esm/Dropdown/components/DropdownTitle.js +2 -2
  364. package/esm/Dropdown/components/DropdownToggleItem.js +2 -2
  365. package/esm/Dropdown/useDropdownItemProps.js +2 -2
  366. package/esm/Dropzone/Dropzone.js +4 -4
  367. package/esm/EmptyState/EmptyState.js +24 -24
  368. package/esm/EmptyState/EmptyState.tailwind.d.ts +1 -1
  369. package/esm/EmptyState/types.d.ts +8 -23
  370. package/esm/Field/Field.d.ts +0 -1
  371. package/esm/Flag/Flag.js +3 -3
  372. package/esm/Flag/Flag.tailwind.d.ts +1 -1
  373. package/esm/Flag/Flags.js +6 -5
  374. package/esm/FlexGrid/FlexGrid.d.ts +1 -12
  375. package/esm/FlexGrid/FlexGrid.tailwind.d.ts +1 -1
  376. package/esm/FlexGrid/FlexGrid.tailwind.js +2 -2
  377. package/esm/HelpUnderline/HelpUnderline.js +2 -2
  378. package/esm/HelpUnderline/HelpUnderline.tailwind.d.ts +1 -1
  379. package/esm/Input/Input.d.ts +4 -1
  380. package/esm/Input/Input.js +6 -6
  381. package/esm/Input/Input.tailwind.d.ts +1 -1
  382. package/esm/InstantSearch/InstantSearch.tailwind.d.ts +1 -1
  383. package/esm/KeyboardKey/KeyboardKey.tailwind.d.ts +1 -1
  384. package/esm/Link/BaseLink.js +2 -2
  385. package/esm/Link/ButtonLink.js +2 -2
  386. package/esm/Link/IconButtonLink.js +2 -2
  387. package/esm/Link/Link.d.ts +2 -2
  388. package/esm/Link/Link.js +2 -2
  389. package/esm/Medallion/Medallion.d.ts +1 -0
  390. package/esm/Medallion/Medallion.tailwind.d.ts +1 -1
  391. package/esm/Modal/Modal.js +8 -7
  392. package/esm/Modal/Modal.tailwind.d.ts +1 -1
  393. package/esm/Modal/components/ModalFooter.js +2 -2
  394. package/esm/Pagination/CompactPagination/CompactPagination.js +2 -2
  395. package/esm/Pagination/DotPagination/DotPagination.js +3 -3
  396. package/esm/Pagination/Pagination/Pagination.js +2 -2
  397. package/esm/Popover/Popover.d.ts +5 -0
  398. package/esm/Popover/Popover.js +129 -0
  399. package/esm/Popover/index.d.ts +3 -0
  400. package/esm/Popover/index.js +3 -0
  401. package/esm/Popover/types.d.ts +74 -0
  402. package/esm/Popover/types.js +1 -0
  403. package/esm/ProgressBar/ProgressBar.js +4 -3
  404. package/esm/ProgressBar/ProgressBar.tailwind.d.ts +1 -1
  405. package/esm/ProgressSpinner/ProgressSpinner.js +2 -2
  406. package/esm/ProgressSpinner/ProgressSpinner.tailwind.d.ts +1 -1
  407. package/esm/ProgressSpinner/ProgressSpinner.tailwind.js +8 -0
  408. package/esm/RadioGroup/RadioButton.d.ts +1 -1
  409. package/esm/RadioGroup/RadioButton.js +2 -2
  410. package/esm/RadioGroup/RadioButton.tailwind.d.ts +1 -1
  411. package/esm/RadioGroup/RadioButton.tailwind.js +3 -0
  412. package/esm/RadioGroup/RadioGroup.d.ts +1 -0
  413. package/esm/RadioGroup/RadiogroupContext.d.ts +1 -4
  414. package/esm/RangeSlider/RangeSlider.d.ts +2 -0
  415. package/esm/RangeSlider/RangeSlider.js +2 -2
  416. package/esm/Satellite/Satellite.js +4 -4
  417. package/esm/Satellite/SatelliteContext.js +2 -2
  418. package/esm/Satellite/locale.d.ts +2 -0
  419. package/esm/ScrollIndicator/ScrollIndicator.tailwind.d.ts +1 -1
  420. package/esm/Select/Select.js +2 -2
  421. package/esm/Select/Select.tailwind.d.ts +1 -1
  422. package/esm/Separator/Separator.d.ts +1 -0
  423. package/esm/Separator/Separator.js +17 -5
  424. package/esm/Separator/Separator.tailwind.d.ts +1 -1
  425. package/esm/Separator/Separator.tailwind.js +31 -2
  426. package/esm/Sidebar/Sidebar.d.ts +1 -0
  427. package/esm/Sidebar/Sidebar.js +2 -2
  428. package/esm/Sidebar/SidebarButtonLink.js +2 -2
  429. package/esm/Sidebar/SidebarHeader.d.ts +1 -0
  430. package/esm/Sidebar/SidebarHeading.d.ts +1 -0
  431. package/esm/Sidebar/SidebarLink.js +2 -2
  432. package/esm/Sidebar/SidebarLinksGroup/ActiveLinkIndicator.d.ts +1 -0
  433. package/esm/Sidebar/SidebarLinksGroup/ActiveLinkIndicator.js +1 -1
  434. package/esm/Sidebar/SidebarLinksGroup/SidebarGroupLink.js +2 -2
  435. package/esm/Sidebar/SidebarLinksGroup/SidebarLinksGroup.d.ts +1 -0
  436. package/esm/Sidebar/SidebarLinksGroup/SidebarLinksGroup.js +4 -4
  437. package/esm/Sidebar/SidebarNav.d.ts +1 -0
  438. package/esm/Switch/Switch.d.ts +1 -0
  439. package/esm/Switch/Switch.js +3 -1
  440. package/esm/Switch/Switch.tailwind.d.ts +1 -1
  441. package/esm/Switch/SwitchOption.js +3 -3
  442. package/esm/Tables/DataTable/DataTable.d.ts +8 -1
  443. package/esm/Tables/DataTable/DataTable.js +4 -4
  444. package/esm/Tables/DataTable/DataTable.tailwind.d.ts +1 -1
  445. package/esm/Tables/DataTable/components/Body.js +2 -2
  446. package/esm/Tables/DataTable/components/Footer.js +2 -2
  447. package/esm/Tables/DataTable/components/HeaderCell.js +4 -4
  448. package/esm/Tables/DataTable/components/Loader.d.ts +1 -0
  449. package/esm/Tables/DataTable/components/Loader.js +1 -1
  450. package/esm/Tables/DataTable/types.d.ts +14 -0
  451. package/esm/Tables/Table/Table.js +2 -2
  452. package/esm/Tables/Table/Table.tailwind.d.ts +1 -1
  453. package/esm/Tabs/Tabs.tailwind.d.ts +1 -1
  454. package/esm/Tabs/Tabs.tailwind.js +20 -1
  455. package/esm/Tabs/components/LinkTab.js +10 -10
  456. package/esm/Tabs/types.d.ts +0 -1
  457. package/esm/Tag/Tag.d.ts +7 -17
  458. package/esm/Tag/Tag.js +14 -8
  459. package/esm/Tag/Tag.tailwind.d.ts +1 -1
  460. package/esm/TextArea/TextArea.js +2 -2
  461. package/esm/TextArea/TextArea.tailwind.d.ts +1 -1
  462. package/esm/TextWrap/TextWrap.js +2 -2
  463. package/esm/Toggle/Toggle.d.ts +6 -2
  464. package/esm/Toggle/Toggle.js +24 -9
  465. package/esm/Toggle/Toggle.tailwind.d.ts +1 -1
  466. package/esm/Toggle/Toggle.tailwind.js +18 -6
  467. package/esm/Tooltip/OverflowTooltipWrapper.js +2 -2
  468. package/esm/Tooltip/Tooltip.d.ts +1 -1
  469. package/esm/Tooltip/Tooltip.js +2 -2
  470. package/esm/Tooltip/Tooltip.tailwind.d.ts +1 -1
  471. package/esm/Tooltip/Tooltip.tailwind.js +1 -90
  472. package/esm/Tooltip/TooltipWrapper.d.ts +2 -2
  473. package/esm/Tooltip/TooltipWrapper.js +3 -3
  474. package/esm/Tooltip/types.d.ts +15 -15
  475. package/esm/Typography/Typography.tailwind.d.ts +1 -1
  476. package/esm/Typography/Typography.tailwind.js +2 -2
  477. package/esm/UserContent/UserContent.d.ts +1 -0
  478. package/esm/UserContent/UserContent.tailwind.d.ts +1 -1
  479. package/esm/UserContent/UserContent.tailwind.js +2 -2
  480. package/esm/styles/base.tailwind.d.ts +1 -1
  481. package/esm/styles/helpers/makePurgeCssExtractor.js +1 -1
  482. package/esm/styles/tailwind.config.js +3 -3
  483. package/esm/styles/zIndexes.d.ts +1 -0
  484. package/esm/styles/zIndexes.js +4 -3
  485. package/esm/types.d.ts +2 -3
  486. package/esm/utilities/overlay.tailwind.d.ts +5 -0
  487. package/esm/utilities/overlay.tailwind.js +106 -0
  488. package/esm/utilities/utilities.tailwind.d.ts +1 -1
  489. package/esm/utils/isCssPropertySupported.d.ts +1 -1
  490. package/esm/utils/prefersReducedMotion.d.ts +6 -0
  491. package/esm/utils/prefersReducedMotion.js +6 -0
  492. package/package.json +9 -7
  493. package/satellite.min.css +1 -1
  494. package/scss/variables.scss +4 -3
@@ -8,109 +8,40 @@ exports["default"] = exports.AutoComplete = void 0;
8
8
  var _taggedTemplateLiteral2 = _interopRequireDefault(require("@babel/runtime/helpers/taggedTemplateLiteral"));
9
9
  var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
10
10
  var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
11
- var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
12
- var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
13
- var _assertThisInitialized2 = _interopRequireDefault(require("@babel/runtime/helpers/assertThisInitialized"));
14
- var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
15
- var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));
16
- var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
17
11
  var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
18
- var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));
19
12
  var _clsx = _interopRequireDefault(require("clsx"));
20
- var _downshift = _interopRequireDefault(require("downshift"));
13
+ var _downshift = require("downshift");
21
14
  var _react = require("react");
22
- var _reactDom = require("react-dom");
23
15
  var _reactFeather = require("react-feather");
24
16
  var _reactPopper = require("react-popper");
25
- var _Button = _interopRequireDefault(require("../Button"));
26
- var _Card = _interopRequireDefault(require("../Card"));
17
+ var _useMeasure3 = _interopRequireDefault(require("react-use/lib/useMeasure"));
18
+ var _Card = require("../Card");
27
19
  var _ClickAwayContainer = require("../ClickAwayContainer");
28
- var _FieldStateContext = require("../Field/FieldStateContext");
20
+ var _Field = require("../Field");
29
21
  var _Satellite = require("../Satellite");
30
22
  var _ScrollIndicator = _interopRequireDefault(require("../ScrollIndicator"));
31
23
  var _satellitePrefixer = _interopRequireDefault(require("../styles/helpers/satellitePrefixer"));
32
24
  var _Tag = _interopRequireDefault(require("../Tag"));
33
25
  var _uniqBy = _interopRequireDefault(require("../utils/uniqBy"));
26
+ var _AutocompleteContext = require("./components/AutocompleteContext");
34
27
  var _AutoCompleteEmptyState = _interopRequireDefault(require("./components/AutoCompleteEmptyState"));
35
- var _DefaultOptionItem = _interopRequireDefault(require("./components/DefaultOptionItem"));
28
+ var _DefaultOptionItem = require("./components/DefaultOptionItem");
36
29
  var _utils = require("./utils");
37
30
  var _jsxRuntime = require("react/jsx-runtime");
38
- var _templateObject, _templateObject2, _templateObject3, _templateObject4, _templateObject5, _templateObject6, _templateObject7, _templateObject8, _templateObject9, _templateObject10, _templateObject11, _templateObject12, _templateObject13, _templateObject14, _templateObject15, _templateObject16, _templateObject17;
39
- var _excluded = ["optionItemPrefix"],
40
- _excluded2 = ["ref"];
41
- function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = (0, _getPrototypeOf2["default"])(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = (0, _getPrototypeOf2["default"])(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return (0, _possibleConstructorReturn2["default"])(this, result); }; }
42
- function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
43
- function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
44
- function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { (0, _defineProperty2["default"])(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
45
- function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it["return"] != null) it["return"](); } finally { if (didErr) throw err; } } }; }
46
- function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
47
- function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
48
- function optionToString(option) {
49
- return option ? option.label : "";
50
- }
51
- function makeNeedles(itemValue) {
52
- return itemValue.toLowerCase().trim().split(/\s+/);
53
- }
54
- function needlesMatch(needles, option) {
55
- var labels = (option.metadata || []).concat(option.label);
56
- return needles.every(function (needle) {
57
- return labels.some(function (label) {
58
- return String(label || "").trim().toLowerCase().includes(needle);
59
- });
60
- });
61
- }
62
- function filter(options, selectedItems, itemValue) {
63
- var needles = makeNeedles(itemValue);
64
- var selectedValues = selectedItems.map(function (option) {
65
- return option.value;
66
- });
67
- var results = [];
68
- var _iterator = _createForOfIteratorHelper(options),
69
- _step;
70
- try {
71
- for (_iterator.s(); !(_step = _iterator.n()).done;) {
72
- var option = _step.value;
73
- if (selectedValues.includes(option.value)) {
74
- continue;
75
- } else if (option.bypassNeedleMatch || needlesMatch(needles, option)) {
76
- results.push(option);
77
- }
78
- }
79
- } catch (err) {
80
- _iterator.e(err);
81
- } finally {
82
- _iterator.f();
83
- }
84
- return results;
85
- }
86
- function inputValueFromProps(props) {
87
- if (props.inputValue !== undefined) {
88
- return props.inputValue;
89
- }
90
- return !(0, _utils.isAutoCompleteMultiProps)(props) && props.value ? optionToString(props.value) : "";
91
- }
92
- var MENU_POPPER_MODFIERS = [{
93
- name: "offset",
94
- options: {
95
- offset: [0, 8]
96
- }
97
- }];
98
- /** @ignore */
99
- var DefaultEmptyState = function DefaultEmptyState(_ref) {
100
- var emptyStateTitle = _ref.emptyStateTitle;
101
- return /*#__PURE__*/(0, _jsxRuntime.jsx)(_AutoCompleteEmptyState["default"], {
102
- title: emptyStateTitle
103
- });
104
- };
105
- var DefaultOption = function DefaultOption(_ref2) {
106
- var optionItemPrefix = _ref2.optionItemPrefix,
107
- props = (0, _objectWithoutProperties2["default"])(_ref2, _excluded);
108
- return /*#__PURE__*/(0, _jsxRuntime.jsx)(_DefaultOptionItem["default"], _objectSpread(_objectSpread({}, props), {}, {
109
- locale: {
110
- optionItemPrefix: optionItemPrefix !== null && optionItemPrefix !== void 0 ? optionItemPrefix : _utils.DEFAULT_AUTOCOMPLETE_LOCALE.optionItemPrefix
31
+ var _templateObject, _templateObject2, _templateObject3, _templateObject4, _templateObject5, _templateObject6, _templateObject7, _templateObject8, _templateObject9, _templateObject10, _templateObject11, _templateObject12, _templateObject13, _templateObject14, _templateObject15, _templateObject16, _templateObject17, _templateObject18, _templateObject19, _templateObject20, _templateObject21, _templateObject22, _templateObject23, _templateObject24, _templateObject25, _templateObject26, _templateObject27, _templateObject28;
32
+ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
33
+ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0, _defineProperty2["default"])(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
34
+ var MENU_POPPER_OPTIONS = {
35
+ strategy: "fixed",
36
+ placement: "bottom-start",
37
+ modifiers: [{
38
+ name: "offset",
39
+ options: {
40
+ offset: [0, 8]
111
41
  }
112
- }));
42
+ }]
113
43
  };
44
+ var SHOW_ALL_ITEMS_ID = "__stl_extra_results_option__";
114
45
 
115
46
  /**
116
47
  * Autocomplete is a search-as-you-type function that matches what a person types, usually the beginning of a word, or a prefix, with a word list. Not to be confused with auto-suggestion that predicts the end of a query.
@@ -128,466 +59,366 @@ var DefaultOption = function DefaultOption(_ref2) {
128
59
  * - Provide matching results quickly
129
60
  * - Style different data
130
61
  */
131
- var AutoComplete = /*#__PURE__*/function (_Component) {
132
- (0, _inherits2["default"])(AutoComplete, _Component);
133
- var _super = _createSuper(AutoComplete);
134
- function AutoComplete() {
135
- var _this;
136
- (0, _classCallCheck2["default"])(this, AutoComplete);
137
- for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
138
- args[_key] = arguments[_key];
62
+ var AutoComplete = exports.AutoComplete = function AutoComplete(_ref) {
63
+ var localeProp = _ref.locale,
64
+ id = _ref.id,
65
+ name = _ref.name,
66
+ placeholder = _ref.placeholder,
67
+ autoFocus = _ref.autoFocus,
68
+ inputValueProp = _ref.inputValue,
69
+ onTextChange = _ref.onTextChange,
70
+ _onFocus = _ref.onFocus,
71
+ _onBlur = _ref.onBlur,
72
+ disabled = _ref.disabled,
73
+ clearable = _ref.clearable,
74
+ renderValueTemplate = _ref.renderValueTemplate,
75
+ noWrap = _ref.noWrap,
76
+ separatorKeys = _ref.separatorKeys,
77
+ multiple = _ref.multiple,
78
+ value = _ref.value,
79
+ selectOnBlur = _ref.selectOnBlur,
80
+ onChange = _ref.onChange,
81
+ options = _ref.options,
82
+ optionItemComponent = _ref.optionItemComponent,
83
+ creatable = _ref.creatable,
84
+ _ref$createFromInputV = _ref.createFromInputValue,
85
+ createFromInputValue = _ref$createFromInputV === void 0 ? _utils.defaultCreateFromInputValue : _ref$createFromInputV,
86
+ emptyState = _ref.emptyState,
87
+ _ref$maxResults = _ref.maxResults,
88
+ maxItems = _ref$maxResults === void 0 ? 7 : _ref$maxResults,
89
+ menuFooter = _ref.menuFooter,
90
+ menuSize = _ref.menuSize,
91
+ variant = _ref.variant,
92
+ Icon = _ref.icon,
93
+ endItem = _ref.endItem,
94
+ className = _ref.className,
95
+ menuClassName = _ref.menuClassName,
96
+ valuesClassName = _ref.valuesClassName;
97
+ var createPortal = (0, _Satellite.useCreatePortal)();
98
+ var _useFieldState = (0, _Field.useFieldState)(),
99
+ status = _useFieldState.status;
100
+ var localeContext = (0, _Satellite.useLocale)("autoComplete");
101
+ var locale = (0, _react.useMemo)(function () {
102
+ return _objectSpread(_objectSpread(_objectSpread({}, _utils.DEFAULT_AUTOCOMPLETE_LOCALE), localeContext), localeProp);
103
+ }, [localeContext, localeProp]);
104
+ var inputRef = (0, _react.useRef)(null);
105
+ var _useState = (0, _react.useState)(false),
106
+ _useState2 = (0, _slicedToArray2["default"])(_useState, 2),
107
+ inputFocused = _useState2[0],
108
+ setInputFocused = _useState2[1];
109
+ var _useState3 = (0, _react.useState)(function () {
110
+ return (inputValueProp !== null && inputValueProp !== void 0 ? inputValueProp : multiple) ? "" : value ? (0, _utils.optionToString)(value) : "";
111
+ }),
112
+ _useState4 = (0, _slicedToArray2["default"])(_useState3, 2),
113
+ internalInputValue = _useState4[0],
114
+ setInternalInputValue = _useState4[1];
115
+ var inputValue = inputValueProp !== null && inputValueProp !== void 0 ? inputValueProp : internalInputValue;
116
+ var _useState5 = (0, _react.useState)(null),
117
+ _useState6 = (0, _slicedToArray2["default"])(_useState5, 2),
118
+ containerElement = _useState6[0],
119
+ setContainerElement = _useState6[1];
120
+ var _useMeasure = (0, _useMeasure3["default"])(),
121
+ _useMeasure2 = (0, _slicedToArray2["default"])(_useMeasure, 2),
122
+ setContainerMeasureRef = _useMeasure2[0],
123
+ containerWidth = _useMeasure2[1].width;
124
+ var menuRef = (0, _react.useRef)(null);
125
+ var menuPopper = (0, _reactPopper.usePopper)(containerElement, menuRef.current, MENU_POPPER_OPTIONS);
126
+ var _useState7 = (0, _react.useState)(false),
127
+ _useState8 = (0, _slicedToArray2["default"])(_useState7, 2),
128
+ showAllItems = _useState8[0],
129
+ setShowAllItems = _useState8[1];
130
+ var selectedItems = (0, _react.useMemo)(function () {
131
+ return !value ? [] : Array.isArray(value) ? value : [value];
132
+ }, [value]);
133
+ var items = (0, _react.useMemo)(function () {
134
+ var results = (0, _utils.filter)(options !== null && options !== void 0 ? options : [], multiple ? selectedItems : [], inputValue);
135
+ var emptyInputValue = !inputValue || inputValue.trim().length === 0;
136
+ if (creatable && !emptyInputValue) {
137
+ results.unshift.apply(results, (0, _toConsumableArray2["default"])(createFromInputValue(options, inputValue)));
139
138
  }
140
- _this = _super.call.apply(_super, [this].concat(args));
141
- (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "state", {
142
- inputFocused: false,
143
- inputValue: inputValueFromProps(_this.props),
144
- showAllResults: false
145
- });
146
- (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "inputContainerRef", null);
147
- (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "inputRef", null);
148
- (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "menuWrapperRef", null);
149
- (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "handleClearClick", function () {
150
- return _this.setState({
151
- inputValue: ""
152
- }, function () {
153
- return _this.props.onChange(null);
139
+ if (!showAllItems && results.length > maxItems) {
140
+ var extraResults = results.length - maxItems;
141
+ var label = locale.showMoreButton(extraResults);
142
+ results.splice(maxItems, results.length, {
143
+ value: SHOW_ALL_ITEMS_ID,
144
+ label: label
154
145
  });
155
- });
156
- (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "handleFakeInputClick", function () {
157
- return _this.inputRef && _this.inputRef.focus();
158
- });
159
- (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "handleInputBlur", function (state) {
160
- return function (evt) {
161
- var _this$props = _this.props,
162
- selectOnBlur = _this$props.selectOnBlur,
163
- onBlur = _this$props.onBlur;
164
- var inputValue = state.inputValue,
165
- highlightedIndex = state.highlightedIndex,
166
- selectItemAtIndex = state.selectItemAtIndex;
167
- var newInputValue;
168
- if (selectOnBlur && inputValue && highlightedIndex !== null) {
169
- newInputValue = (0, _utils.isAutoCompleteMultiProps)(_this.props) ? "" : optionToString(_this.props.value);
170
- selectItemAtIndex(highlightedIndex);
171
- } else if ((0, _utils.isAutoCompleteMultiProps)(_this.props)) {
172
- newInputValue = inputValue;
173
- } else {
174
- newInputValue = optionToString(_this.props.value);
175
- }
176
- if (onBlur) {
177
- onBlur(evt);
178
- }
179
- _this.setState({
180
- inputValue: newInputValue || "",
181
- inputFocused: false,
182
- showAllResults: false
183
- });
184
- };
185
- });
186
- (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "handleInputChange", function (evt) {
187
- var inputValue = evt.target.value;
188
- _this.setState({
189
- inputValue: inputValue
190
- });
191
- if (_this.props.onTextChange) {
192
- _this.props.onTextChange(inputValue);
193
- }
194
- if (!_this.props.multiple && _this.props.value && !inputValue) {
195
- _this.props.onChange(null);
196
- }
197
- });
198
- (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "handleInputContainerRefUpdate", function (el) {
199
- _this.inputContainerRef = el;
200
- if (el) {
201
- _this.updateInputWidth();
202
- }
203
- });
204
- (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "updateInputWidth", function () {
205
- var _this$inputContainerR, _this$inputContainerR2;
206
- var inputWidth = _this.state.inputWidth;
207
- var newInputWidth = (_this$inputContainerR = (_this$inputContainerR2 = _this.inputContainerRef) === null || _this$inputContainerR2 === void 0 ? void 0 : _this$inputContainerR2.getBoundingClientRect().width) !== null && _this$inputContainerR !== void 0 ? _this$inputContainerR : inputWidth;
208
- if (newInputWidth !== inputWidth) {
209
- _this.setState({
210
- inputWidth: newInputWidth
211
- });
212
- }
213
- });
214
- (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "handleKeyDown", function (state) {
215
- return function (evt) {
216
- if (!(0, _utils.isAutoCompleteMultiProps)(_this.props)) return;
217
- var _this$props2 = _this.props,
218
- _this$props2$value = _this$props2.value,
219
- value = _this$props2$value === void 0 ? [] : _this$props2$value,
220
- _this$props2$separato = _this$props2.separatorKeys,
221
- separatorKeys = _this$props2$separato === void 0 ? AutoComplete.defaultProps.separatorKeys : _this$props2$separato,
222
- creatable = _this$props2.creatable,
223
- _this$props2$createFr = _this$props2.createFromInputValue,
224
- createFromInputValue = _this$props2$createFr === void 0 ? AutoComplete.defaultProps.createFromInputValue : _this$props2$createFr,
225
- options = _this$props2.options,
226
- onChange = _this$props2.onChange;
227
- var inputValue = state.inputValue || "";
228
- var canCreate = creatable && inputValue.trim().length > 0;
229
- if (evt.key === "Backspace" && !inputValue.length) {
230
- onChange(value.slice(0, -1));
231
- } else if (canCreate && separatorKeys.includes(evt.key)) {
232
- evt.preventDefault();
233
- var _createFromInputValue = createFromInputValue(options, inputValue),
234
- _createFromInputValue2 = (0, _slicedToArray2["default"])(_createFromInputValue, 1),
235
- newOption = _createFromInputValue2[0];
236
- if (newOption && !newOption.disabled) {
237
- state.selectItem(newOption);
238
- }
239
- }
240
- };
241
- });
242
- (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "handleChange", function (option) {
243
- if (option.disabled) return;
244
- option = option ? _objectSpread(_objectSpread({}, option), {}, {
245
- "new": undefined
246
- }) : option;
247
- if ((0, _utils.isAutoCompleteMultiProps)(_this.props)) {
248
- var arrayValue = Array.isArray(_this.props.value) ? _this.props.value : [];
249
- var newValue = (0, _uniqBy["default"])([].concat((0, _toConsumableArray2["default"])(arrayValue), [option]), function (o) {
250
- return o.value;
251
- });
252
- _this.props.onChange(newValue);
253
- _this.setState({
254
- inputValue: "",
255
- showAllResults: false
256
- });
146
+ }
147
+ return results;
148
+ }, [creatable, createFromInputValue, inputValue, locale, maxItems, multiple, options, selectedItems, showAllItems]);
149
+ var hasValue = !!selectedItems.length;
150
+ var showClearButton = !disabled && clearable && hasValue;
151
+ var multipleSelection = (0, _downshift.useMultipleSelection)({
152
+ selectedItems: selectedItems,
153
+ onSelectedItemsChange: function onSelectedItemsChange(changes) {
154
+ if (typeof changes.selectedItems === "undefined") {
155
+ onChange(null);
156
+ } else if (multiple) {
157
+ onChange((0, _uniqBy["default"])(changes.selectedItems, function (i) {
158
+ return i.value;
159
+ }));
257
160
  } else {
258
- _this.props.onChange(option);
259
- _this.setState({
260
- inputValue: option ? option.label : "",
261
- showAllResults: false
262
- });
161
+ var _changes$selectedItem;
162
+ onChange((_changes$selectedItem = changes.selectedItems[0]) !== null && _changes$selectedItem !== void 0 ? _changes$selectedItem : null);
263
163
  }
264
- });
265
- (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "handleShowAllResults", function (evt) {
266
- evt.preventDefault();
267
- evt.stopPropagation();
268
- _this.setState({
269
- showAllResults: true
270
- });
271
- });
272
- (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "removeValue", function (removedOption) {
273
- if (!(0, _utils.isAutoCompleteMultiProps)(_this.props)) return;
274
- var currentOptions = _this.props.value || [];
275
- var newOptions = currentOptions.filter(function (option) {
276
- return option.value !== removedOption.value;
164
+ }
165
+ });
166
+ var combobox = (0, _downshift.useCombobox)({
167
+ items: items,
168
+ itemToString: _utils.optionToString,
169
+ scrollIntoView: function scrollIntoView(node) {
170
+ var _node$scrollIntoView;
171
+ return node === null || node === void 0 || (_node$scrollIntoView = node.scrollIntoView) === null || _node$scrollIntoView === void 0 ? void 0 : _node$scrollIntoView.call(node, {
172
+ block: "nearest"
277
173
  });
278
- _this.props.onChange(newOptions);
279
- });
280
- (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "getA11yStatusMessage", function (options) {
281
- if (!options.isOpen) {
174
+ },
175
+ defaultHighlightedIndex: 0,
176
+ getA11yStatusMessage: function getA11yStatusMessage(_ref2) {
177
+ var isOpen = _ref2.isOpen,
178
+ resultCount = _ref2.resultCount,
179
+ previousResultCount = _ref2.previousResultCount;
180
+ if (!isOpen) {
282
181
  return "";
283
182
  }
284
- if (!options.resultCount) {
285
- return _this.locale.emptyStateTitle;
183
+ if (!resultCount) {
184
+ return locale.emptyStateTitle;
286
185
  }
287
- if (options.resultCount > 0) {
288
- return _this.locale.itemsAvailable(options.resultCount);
186
+ if (resultCount !== previousResultCount) {
187
+ return locale.itemsAvailable(resultCount);
289
188
  }
290
189
  return "";
291
- });
292
- (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "renderInput", function (autocompleteHelpers, fieldState) {
293
- var _this$props3 = _this.props,
294
- id = _this$props3.id,
295
- placeholder = _this$props3.placeholder,
296
- name = _this$props3.name,
297
- valuesClassName = _this$props3.valuesClassName,
298
- disabled = _this$props3.disabled,
299
- autoFocus = _this$props3.autoFocus,
300
- clearable = _this$props3.clearable,
301
- value = _this$props3.value,
302
- multiple = _this$props3.multiple,
303
- _this$props3$variant = _this$props3.variant,
304
- variant = _this$props3$variant === void 0 ? "medium" : _this$props3$variant,
305
- renderValueTemplate = _this$props3.renderValueTemplate,
306
- Icon = _this$props3.icon,
307
- _this$props3$noWrap = _this$props3.noWrap,
308
- noWrap = _this$props3$noWrap === void 0 ? false : _this$props3$noWrap,
309
- endItem = _this$props3.endItem,
310
- _onFocus = _this$props3.onFocus;
311
- var inputFocused = _this.state.inputFocused;
312
- var getInputProps = autocompleteHelpers.getInputProps;
313
- var hasValue = Boolean(value && (!Array.isArray(value) || value.length > 0));
314
- var showClearButton = !disabled && clearable && hasValue;
315
- var shouldRenderCustomTemplate = Boolean(!multiple && !inputFocused && value && renderValueTemplate);
316
- var status = fieldState.status;
317
- var inputContainerClassName = (0, _satellitePrefixer["default"])(_templateObject || (_templateObject = (0, _taggedTemplateLiteral2["default"])(["\n autocomplete-container\n ", "\n ", "\n ", "\n ", "\n ", "\n "])), variant === "large" && "autocomplete-large py-1", inputFocused && "autocomplete-focused", disabled && "autocomplete-disabled", status === "invalid" && "autocomplete-invalid", noWrap && "autocomplete-nowrap");
318
- var inputClassName = (0, _satellitePrefixer["default"])(_templateObject2 || (_templateObject2 = (0, _taggedTemplateLiteral2["default"])(["\n autocomplete-input py-1.5\n ", "\n ", "\n "])), multiple && "ml-1", shouldRenderCustomTemplate && hasValue && "h-0 w-0 opacity-0");
319
- var inputProps = getInputProps({
320
- id: id,
321
- name: name,
322
- disabled: disabled,
323
- className: inputClassName,
324
- type: "text",
325
- placeholder: hasValue ? undefined : placeholder,
326
- ref: function ref(input) {
327
- return _this.inputRef = input;
328
- },
329
- onChange: _this.handleInputChange,
330
- onFocus: function onFocus(evt) {
331
- _onFocus === null || _onFocus === void 0 ? void 0 : _onFocus(evt);
332
- if (evt.defaultPrevented) {
333
- return;
190
+ },
191
+ getA11ySelectionMessage: function getA11ySelectionMessage(_ref3) {
192
+ var selectedItem = _ref3.selectedItem;
193
+ return locale.selectionMessage((0, _utils.optionToString)(selectedItem), selectedItem);
194
+ },
195
+ selectedItem: null,
196
+ inputValue: inputValue,
197
+ onStateChange: function onStateChange(changes) {
198
+ switch (changes.type) {
199
+ case _downshift.useCombobox.stateChangeTypes.InputBlur:
200
+ case _downshift.useCombobox.stateChangeTypes.InputKeyDownEnter:
201
+ case _downshift.useCombobox.stateChangeTypes.ItemClick:
202
+ {
203
+ var selectedItem = selectOnBlur && changes.type === _downshift.useCombobox.stateChangeTypes.InputBlur && combobox.highlightedIndex >= 0 ? items[combobox.highlightedIndex] : changes.selectedItem;
204
+ if (!selectedItem || selectedItem.disabled) return;
205
+ if (changes.type !== _downshift.useCombobox.stateChangeTypes.InputBlur && selectedItem.value === SHOW_ALL_ITEMS_ID) {
206
+ setShowAllItems(true);
207
+ combobox.openMenu();
208
+ combobox.setHighlightedIndex(maxItems);
209
+ } else if (multiple) {
210
+ multipleSelection.addSelectedItem(selectedItem);
211
+ combobox.setInputValue("");
212
+ setShowAllItems(false);
213
+ } else {
214
+ multipleSelection.setSelectedItems([selectedItem]);
215
+ combobox.setInputValue((0, _utils.optionToString)(selectedItem));
216
+ setShowAllItems(false);
217
+ }
218
+ break;
334
219
  }
335
- _this.setState({
336
- inputFocused: true
337
- });
338
-
339
- // Doesn't work without the setTimeout :/
340
- setTimeout(function () {
341
- _this.updateInputWidth();
342
- autocompleteHelpers.openMenu();
343
- });
220
+ case _downshift.useCombobox.stateChangeTypes.FunctionSetInputValue:
221
+ case _downshift.useCombobox.stateChangeTypes.InputChange:
222
+ {
223
+ var _changes$inputValue, _menuPopper$update;
224
+ var newInputValue = (_changes$inputValue = changes.inputValue) !== null && _changes$inputValue !== void 0 ? _changes$inputValue : "";
225
+ setInternalInputValue(newInputValue);
226
+ onTextChange === null || onTextChange === void 0 || onTextChange(newInputValue);
227
+ if (!multiple && value && !newInputValue) {
228
+ multipleSelection.setSelectedItems([]);
229
+ }
230
+ (_menuPopper$update = menuPopper.update) === null || _menuPopper$update === void 0 || _menuPopper$update.call(menuPopper);
231
+ break;
232
+ }
233
+ case _downshift.useCombobox.stateChangeTypes.InputKeyDownEscape:
234
+ {
235
+ if (!combobox.isOpen) {
236
+ combobox.setInputValue("");
237
+ multipleSelection.setSelectedItems([]);
238
+ }
239
+ break;
240
+ }
241
+ }
242
+ },
243
+ isItemDisabled: function isItemDisabled(item) {
244
+ return Boolean(item.disabled);
245
+ }
246
+ });
247
+ var inputProps = combobox.getInputProps(multipleSelection.getDropdownProps({
248
+ ref: inputRef,
249
+ autoFocus: autoFocus,
250
+ disabled: disabled,
251
+ // We need to make sure to define event handlers here so that they can be composed properly
252
+ onFocus: function onFocus(evt) {
253
+ var _menuPopper$update2;
254
+ _onFocus === null || _onFocus === void 0 || _onFocus(evt);
255
+ if (evt.defaultPrevented) return;
256
+ setInputFocused(true);
257
+ (_menuPopper$update2 = menuPopper.update) === null || _menuPopper$update2 === void 0 || _menuPopper$update2.call(menuPopper);
258
+ },
259
+ onBlur: function onBlur(evt) {
260
+ _onBlur === null || _onBlur === void 0 || _onBlur(evt);
261
+ setInputFocused(false);
262
+ },
263
+ onKeyDown: function onKeyDown(evt) {
264
+ if (combobox.isOpen && ["ArrowLeft", "ArrowRight"].includes(evt.key)) {
265
+ // @ts-expect-error
266
+ evt.nativeEvent.preventDownshiftDefault = true;
267
+ }
268
+ if (multiple && creatable && inputValue.trim().length > 0 && separatorKeys !== null && separatorKeys !== void 0 && separatorKeys.includes(evt.key)) {
269
+ evt.preventDefault();
270
+ var _createFromInputValue = createFromInputValue(options, inputValue),
271
+ _createFromInputValue2 = (0, _slicedToArray2["default"])(_createFromInputValue, 1),
272
+ newOption = _createFromInputValue2[0];
273
+ if (newOption && !newOption.disabled) {
274
+ multipleSelection.addSelectedItem(newOption);
275
+ combobox.setInputValue("");
276
+ }
277
+ }
278
+ }
279
+ }));
280
+ (0, _react.useEffect)(function () {
281
+ if (!combobox.isOpen) return;
282
+ if (items.length === 0 && combobox.highlightedIndex >= 0) {
283
+ combobox.setHighlightedIndex(-1);
284
+ } else if (items.length > 0 && combobox.highlightedIndex < 0) {
285
+ combobox.setHighlightedIndex(0);
286
+ }
287
+ }, [combobox, items.length]);
288
+ var shouldRenderCustomTemplate = Boolean(!multiple && !inputFocused && value && renderValueTemplate);
289
+ var shouldShowDefaultEmptyState = emptyState === undefined && !!inputValue.length;
290
+ var shouldShowEmptyState = !!emptyState;
291
+ var hideMenu = !combobox.isOpen || items.length === 0 && !shouldShowEmptyState && !shouldShowDefaultEmptyState;
292
+ var OptionItem = (0, _react.useMemo)(function () {
293
+ return optionItemComponent !== null && optionItemComponent !== void 0 ? optionItemComponent : function (props) {
294
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)(_DefaultOptionItem.DefaultOptionItem, _objectSpread(_objectSpread({}, props), {}, {
295
+ locale: locale
296
+ }));
297
+ };
298
+ }, [optionItemComponent, locale]);
299
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)(_AutocompleteContext.AutocompleteProvider, {
300
+ children: /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
301
+ className: (0, _clsx["default"])((0, _satellitePrefixer["default"])(_templateObject || (_templateObject = (0, _taggedTemplateLiteral2["default"])(["flex"]))), className),
302
+ ref: function ref(el) {
303
+ setContainerElement(el);
304
+ // @ts-expect-error
305
+ setContainerMeasureRef(el);
306
+ },
307
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
308
+ className: (0, _clsx["default"])((0, _satellitePrefixer["default"])(_templateObject2 || (_templateObject2 = (0, _taggedTemplateLiteral2["default"])(["autocomplete-container"]))), variant === "large" && (0, _satellitePrefixer["default"])(_templateObject3 || (_templateObject3 = (0, _taggedTemplateLiteral2["default"])(["autocomplete-large py-1"]))), inputFocused && (0, _satellitePrefixer["default"])(_templateObject4 || (_templateObject4 = (0, _taggedTemplateLiteral2["default"])(["autocomplete-focused"]))), disabled && (0, _satellitePrefixer["default"])(_templateObject5 || (_templateObject5 = (0, _taggedTemplateLiteral2["default"])(["autocomplete-disabled"]))), status === "invalid" && (0, _satellitePrefixer["default"])(_templateObject6 || (_templateObject6 = (0, _taggedTemplateLiteral2["default"])(["autocomplete-invalid"]))), noWrap && (0, _satellitePrefixer["default"])(_templateObject7 || (_templateObject7 = (0, _taggedTemplateLiteral2["default"])(["autocomplete-nowrap"])))),
309
+ onClick: function onClick() {
310
+ var _inputRef$current;
311
+ return (_inputRef$current = inputRef.current) === null || _inputRef$current === void 0 ? void 0 : _inputRef$current.focus();
344
312
  },
345
- onBlur: _this.handleInputBlur(autocompleteHelpers),
346
- onKeyDown: _this.handleKeyDown(autocompleteHelpers),
347
- autoComplete: "off",
348
- autoFocus: autoFocus
349
- });
350
- return /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
351
- className: inputContainerClassName,
352
- onClick: _this.handleFakeInputClick,
353
- ref: _this.handleInputContainerRefUpdate,
354
313
  children: [Icon && /*#__PURE__*/(0, _jsxRuntime.jsx)(Icon, {
355
- className: (0, _satellitePrefixer["default"])(_templateObject3 || (_templateObject3 = (0, _taggedTemplateLiteral2["default"])(["mr-4 shrink-0 ", ""])), disabled ? "text-grey-200" : inputFocused ? "text-accent-600" : "text-grey-500"),
314
+ className: (0, _clsx["default"])((0, _satellitePrefixer["default"])(_templateObject8 || (_templateObject8 = (0, _taggedTemplateLiteral2["default"])(["mr-4 shrink-0"]))), (0, _satellitePrefixer["default"])(_templateObject9 || (_templateObject9 = (0, _taggedTemplateLiteral2["default"])(["", ""])), disabled ? "text-grey-200" : inputFocused ? "text-accent-600" : "text-grey-500")),
356
315
  size: "1rem"
357
316
  }), /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
358
- className: (0, _clsx["default"])((0, _satellitePrefixer["default"])(_templateObject4 || (_templateObject4 = (0, _taggedTemplateLiteral2["default"])(["flex items-center flex-1 max-h-full ", " ", ""])), !noWrap && "flex-wrap overflow-y-scroll no-scrollbar", multiple && "-ml-1"), valuesClassName),
359
- children: [multiple && Array.isArray(value) && value.map(function (option) {
360
- return renderValueTemplate ? renderValueTemplate({
361
- option: option,
362
- key: String(option.value),
363
- editable: !disabled
364
- }) : /*#__PURE__*/(0, _jsxRuntime.jsx)(_Tag["default"], {
365
- onRemove: disabled ? undefined : function () {
366
- return _this.removeValue(option);
317
+ className: (0, _clsx["default"])((0, _satellitePrefixer["default"])(_templateObject10 || (_templateObject10 = (0, _taggedTemplateLiteral2["default"])(["flex items-center flex-1 max-h-full"]))), !noWrap && (0, _satellitePrefixer["default"])(_templateObject11 || (_templateObject11 = (0, _taggedTemplateLiteral2["default"])(["flex-wrap overflow-y-scroll no-scrollbar"]))), multiple && (0, _satellitePrefixer["default"])(_templateObject12 || (_templateObject12 = (0, _taggedTemplateLiteral2["default"])(["-ml-1"]))), valuesClassName),
318
+ children: [multiple && selectedItems.map(function (option, index) {
319
+ return renderValueTemplate ? /*#__PURE__*/(0, _jsxRuntime.jsx)("span", _objectSpread(_objectSpread({}, multipleSelection.getSelectedItemProps({
320
+ selectedItem: option,
321
+ index: index
322
+ })), {}, {
323
+ children: renderValueTemplate({
324
+ option: option,
325
+ editable: !disabled
326
+ })
327
+ }), String(option.value)) : /*#__PURE__*/(0, _jsxRuntime.jsx)(_Tag["default"], _objectSpread(_objectSpread({
328
+ onRemove: disabled ? undefined : function (evt) {
329
+ evt.stopPropagation();
330
+ multipleSelection.removeSelectedItem(option);
367
331
  },
368
- className: (0, _satellitePrefixer["default"])(_templateObject5 || (_templateObject5 = (0, _taggedTemplateLiteral2["default"])(["m-1 max-w-48 ", ""])), disabled && "opacity-50"),
332
+ className: (0, _satellitePrefixer["default"])(_templateObject13 || (_templateObject13 = (0, _taggedTemplateLiteral2["default"])(["m-1 max-w-48 ", ""])), disabled && "opacity-50")
333
+ }, multipleSelection.getSelectedItemProps({
334
+ selectedItem: option,
335
+ index: index
336
+ })), {}, {
369
337
  children: option.label
370
- }, String(option.value));
338
+ }), String(option.value));
371
339
  }), shouldRenderCustomTemplate && renderValueTemplate({
372
340
  option: value,
373
- key: String(value),
374
341
  editable: !disabled
375
- }), /*#__PURE__*/(0, _jsxRuntime.jsx)("input", _objectSpread(_objectSpread({}, inputProps), {}, {
342
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)("input", _objectSpread(_objectSpread({
376
343
  "data-lpignore": true
344
+ }, inputProps), {}, {
345
+ id: id,
346
+ name: name,
347
+ type: "text",
348
+ placeholder: hasValue ? "" : placeholder,
349
+ autoComplete: "off",
350
+ className: (0, _clsx["default"])((0, _satellitePrefixer["default"])(_templateObject14 || (_templateObject14 = (0, _taggedTemplateLiteral2["default"])(["autocomplete-input py-1.5"]))), multiple && (0, _satellitePrefixer["default"])(_templateObject15 || (_templateObject15 = (0, _taggedTemplateLiteral2["default"])(["ml-1"]))), shouldRenderCustomTemplate && hasValue && (0, _satellitePrefixer["default"])(_templateObject16 || (_templateObject16 = (0, _taggedTemplateLiteral2["default"])(["h-0 w-0 opacity-0"]))))
377
351
  }))]
378
- }), (showClearButton || !!endItem) && /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
379
- className: (0, _clsx["default"])(showClearButton && endItem && (0, _satellitePrefixer["default"])(_templateObject6 || (_templateObject6 = (0, _taggedTemplateLiteral2["default"])(["my-2 flex self-end space-x-4"])))),
352
+ }), Boolean(showClearButton || endItem) && /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
353
+ className: (0, _clsx["default"])(showClearButton && endItem && (0, _satellitePrefixer["default"])(_templateObject17 || (_templateObject17 = (0, _taggedTemplateLiteral2["default"])(["my-2 flex self-end space-x-4"])))),
380
354
  children: [!!endItem && /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
381
- className: (0, _satellitePrefixer["default"])(_templateObject7 || (_templateObject7 = (0, _taggedTemplateLiteral2["default"])(["text-grey-700 my-auto"]))),
355
+ className: (0, _satellitePrefixer["default"])(_templateObject18 || (_templateObject18 = (0, _taggedTemplateLiteral2["default"])(["text-grey-700 my-auto"]))),
382
356
  children: endItem
383
357
  }), showClearButton && /*#__PURE__*/(0, _jsxRuntime.jsx)("button", {
384
358
  type: "button",
385
- className: (0, _satellitePrefixer["default"])(_templateObject8 || (_templateObject8 = (0, _taggedTemplateLiteral2["default"])(["w-6 flex items-center justify-center text-grey-500"]))),
386
- onClick: _this.handleClearClick,
387
- "aria-label": _this.locale.clearInputButton,
359
+ className: (0, _satellitePrefixer["default"])(_templateObject19 || (_templateObject19 = (0, _taggedTemplateLiteral2["default"])(["w-6 h-6 flex items-center justify-center text-grey-500"]))),
360
+ onClick: function onClick(evt) {
361
+ evt.stopPropagation();
362
+ combobox.setInputValue("");
363
+ multipleSelection.setSelectedItems([]);
364
+ },
365
+ "aria-label": locale.clearInputButton,
388
366
  children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactFeather.X, {
389
367
  size: ".75rem"
390
368
  })
391
369
  })]
392
370
  })]
393
- });
394
- });
395
- (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "renderMenu", function (results, autocompleteHelpers) {
396
- var _this$inputContainerR3;
397
- var getItemProps = autocompleteHelpers.getItemProps,
398
- getMenuProps = autocompleteHelpers.getMenuProps,
399
- highlightedIndex = autocompleteHelpers.highlightedIndex,
400
- inputValue = autocompleteHelpers.inputValue,
401
- isOpen = autocompleteHelpers.isOpen;
402
- var defaultEmptyState = /*#__PURE__*/(0, _jsxRuntime.jsx)(DefaultEmptyState, {
403
- emptyStateTitle: _this.locale.emptyStateTitle
404
- });
405
- var _this$props4 = _this.props,
406
- menuClassName = _this$props4.menuClassName,
407
- menuSize = _this$props4.menuSize,
408
- menuFooter = _this$props4.menuFooter,
409
- _this$props4$emptySta = _this$props4.emptyState,
410
- emptyState = _this$props4$emptySta === void 0 ? defaultEmptyState : _this$props4$emptySta,
411
- _this$props4$maxResul = _this$props4.maxResults,
412
- maxResults = _this$props4$maxResul === void 0 ? AutoComplete.defaultProps.maxResults : _this$props4$maxResul,
413
- _this$props4$multiple = _this$props4.multiple,
414
- multiple = _this$props4$multiple === void 0 ? AutoComplete.defaultProps.multiple : _this$props4$multiple,
415
- _this$props4$optionIt = _this$props4.optionItemComponent,
416
- OptionItem = _this$props4$optionIt === void 0 ? AutoComplete.defaultProps.optionItemComponent : _this$props4$optionIt;
417
- var _this$state = _this.state,
418
- inputWidth = _this$state.inputWidth,
419
- showAllResults = _this$state.showAllResults;
420
- var dropdownStyle = inputWidth ? {
421
- minWidth: inputWidth,
422
- maxWidth: "42vw"
423
- } : undefined;
424
- var optionItemProps = {
425
- multiple: multiple,
426
- inputValue: inputValue || ""
427
- };
428
- var extraResults = results.length - maxResults;
429
- var shouldShowDefaultEmptyState = emptyState === defaultEmptyState && results.length === 0 && !!(inputValue !== null && inputValue !== void 0 && inputValue.length);
430
- var shouldShowEmptyState = emptyState !== defaultEmptyState && !!emptyState && results.length === 0;
431
- var showResults = results.length > 0;
432
- if (!isOpen || !showResults && !shouldShowEmptyState && !shouldShowDefaultEmptyState) {
433
- return /*#__PURE__*/(0, _jsxRuntime.jsx)("ul", _objectSpread(_objectSpread({}, getMenuProps()), {}, {
434
- className: (0, _satellitePrefixer["default"])(_templateObject9 || (_templateObject9 = (0, _taggedTemplateLiteral2["default"])(["hidden h-0"])))
435
- }));
436
- }
437
- return /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactPopper.Popper, {
438
- placement: "bottom-start",
439
- strategy: "fixed",
440
- referenceElement: (_this$inputContainerR3 = _this.inputContainerRef) !== null && _this$inputContainerR3 !== void 0 ? _this$inputContainerR3 : undefined,
441
- modifiers: MENU_POPPER_MODFIERS,
442
- innerRef: function innerRef(wrapperEl) {
443
- return _this.menuWrapperRef = wrapperEl;
444
- },
445
- children: function children(popper) {
446
- var _getMenuProps = getMenuProps({
447
- ref: popper.ref
448
- }),
449
- menuRef = _getMenuProps.ref,
450
- menuProps = (0, _objectWithoutProperties2["default"])(_getMenuProps, _excluded2);
451
- return /*#__PURE__*/(0, _jsxRuntime.jsx)(_ClickAwayContainer.ClickAwayContainer, {
452
- element: _this.menuWrapperRef,
371
+ }), createPortal( /*#__PURE__*/(0, _jsxRuntime.jsx)(_ClickAwayContainer.ClickAwayContainer, {
372
+ element: menuRef.current,
373
+ children: /*#__PURE__*/(0, _jsxRuntime.jsxs)(_Card.Card, _objectSpread(_objectSpread({}, menuPopper.attributes), {}, {
374
+ className: (0, _clsx["default"])((0, _satellitePrefixer["default"])(_templateObject20 || (_templateObject20 = (0, _taggedTemplateLiteral2["default"])(["z-dropdown"]))), menuClassName),
375
+ style: _objectSpread(_objectSpread(_objectSpread({}, menuPopper.styles.popper), hideMenu && {
376
+ display: "none"
377
+ }), {}, {
378
+ minWidth: containerWidth,
379
+ maxWidth: "42vw"
380
+ }),
381
+ ref: menuRef,
382
+ elevation: "300",
383
+ fullBleed: true,
384
+ children: [items.length === 0 ? /*#__PURE__*/(0, _jsxRuntime.jsx)("div", _objectSpread(_objectSpread({}, combobox.getMenuProps({
385
+ className: (0, _satellitePrefixer["default"])(_templateObject21 || (_templateObject21 = (0, _taggedTemplateLiteral2["default"])(["min-h-10"])))
386
+ })), {}, {
453
387
  children: /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
454
- /**
455
- * We put the `menuRef` on a different element than the menu props so that Downshift correctly includes
456
- * the entire Popper element when identifying a click outside. We keep the rest of the`menuProps` on the
457
- * `ul` itself for accessibility reasons (it needs to be the direct parent of menu item elements).
458
- * While a bit hackish, we made sure that Downshift only uses the ref to compute click outside and not
459
- * anything else:
460
- * https://github.com/downshift-js/downshift/blob/3fb0ed21278c5f1d0a077ed9b1d0dfd55a75c71b/src/downshift.js#L951
461
- */
462
- ref: menuRef,
463
- className: (0, _clsx["default"])((0, _satellitePrefixer["default"])(_templateObject10 || (_templateObject10 = (0, _taggedTemplateLiteral2["default"])(["z-dropdown"]))), menuClassName),
464
- style: _objectSpread(_objectSpread({}, popper.style), dropdownStyle),
465
- "data-popper-placement": popper.placement,
466
- children: /*#__PURE__*/(0, _jsxRuntime.jsxs)(_Card["default"], {
467
- fullBleed: true,
468
- elevation: "300",
469
- children: [results.length === 0 ? /*#__PURE__*/(0, _jsxRuntime.jsx)("div", _objectSpread(_objectSpread({}, menuProps), {}, {
470
- className: (0, _satellitePrefixer["default"])(_templateObject11 || (_templateObject11 = (0, _taggedTemplateLiteral2["default"])(["min-h-10"]))),
471
- children: emptyState
472
- })) : /*#__PURE__*/(0, _jsxRuntime.jsx)(_ScrollIndicator["default"], {
473
- className: menuSize === "large" ? (0, _satellitePrefixer["default"])(_templateObject12 || (_templateObject12 = (0, _taggedTemplateLiteral2["default"])(["max-h-96"]))) : (0, _satellitePrefixer["default"])(_templateObject13 || (_templateObject13 = (0, _taggedTemplateLiteral2["default"])(["max-h-64"]))),
474
- children: /*#__PURE__*/(0, _jsxRuntime.jsxs)("ul", _objectSpread(_objectSpread({}, menuProps), {}, {
475
- children: [results.slice(0, showAllResults ? Number.MAX_SAFE_INTEGER : maxResults).map(function (result, index) {
476
- return /*#__PURE__*/(0, _jsxRuntime.jsx)("li", _objectSpread(_objectSpread({}, getItemProps({
477
- item: result,
478
- disabled: result.disabled,
479
- className: (0, _satellitePrefixer["default"])(_templateObject14 || (_templateObject14 = (0, _taggedTemplateLiteral2["default"])(["\n autocomplete-result\n flex items-center min-h-10 px-4 cursor-pointer\n ", "\n ", "\n "])), index === highlightedIndex && "bg-grey-100", result.disabled && "cursor-not-allowed")
480
- })), {}, {
481
- children: /*#__PURE__*/(0, _jsxRuntime.jsx)(OptionItem, _objectSpread(_objectSpread({}, optionItemProps), {}, {
482
- highlighted: index === highlightedIndex,
483
- option: result,
484
- optionItemPrefix: _this.locale.optionItemPrefix
485
- }))
486
- }), result.value);
487
- }), extraResults > 0 && !showAllResults && /*#__PURE__*/(0, _jsxRuntime.jsx)("li", {
488
- className: (0, _satellitePrefixer["default"])(_templateObject15 || (_templateObject15 = (0, _taggedTemplateLiteral2["default"])(["p-2 text-right"]))),
489
- children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_Button["default"], {
490
- variant: "subtle",
491
- size: "small",
492
- onMouseDown: _this.handleShowAllResults,
493
- children: _this.locale.showMoreButton(extraResults)
494
- })
495
- })]
496
- }))
497
- }), !!menuFooter && /*#__PURE__*/(0, _jsxRuntime.jsx)("footer", {
498
- className: (0, _satellitePrefixer["default"])(_templateObject16 || (_templateObject16 = (0, _taggedTemplateLiteral2["default"])(["flex items-center justify-center min-h-12 p-4 bg-grey-100 border-t border-grey-200 text-grey-600"]))),
499
- children: menuFooter
500
- })]
388
+ role: "option",
389
+ "aria-disabled": "true",
390
+ "aria-selected": "false",
391
+ children: emptyState !== null && emptyState !== void 0 ? emptyState : /*#__PURE__*/(0, _jsxRuntime.jsx)(_AutoCompleteEmptyState["default"], {
392
+ title: locale.emptyStateTitle
501
393
  })
502
394
  })
503
- });
504
- }
505
- });
506
- });
507
- (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "renderSelect", function (autocompleteHelpers, fieldState) {
508
- var _this$context$portalT;
509
- var _this$props5 = _this.props,
510
- className = _this$props5.className,
511
- options = _this$props5.options,
512
- value = _this$props5.value,
513
- creatable = _this$props5.creatable,
514
- _this$props5$createFr = _this$props5.createFromInputValue,
515
- createFromInputValue = _this$props5$createFr === void 0 ? AutoComplete.defaultProps.createFromInputValue : _this$props5$createFr;
516
- var inputValue = autocompleteHelpers.inputValue || "";
517
- var results = options ? filter(options, Array.isArray(value) ? value : [], inputValue) : [];
518
- var emptyInputValue = !inputValue || inputValue.trim().length === 0;
519
- if (creatable && !emptyInputValue) {
520
- results.unshift.apply(results, (0, _toConsumableArray2["default"])(createFromInputValue(options, inputValue)));
521
- }
522
- return /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
523
- className: (0, _clsx["default"])((0, _satellitePrefixer["default"])(_templateObject17 || (_templateObject17 = (0, _taggedTemplateLiteral2["default"])(["flex"]))), className),
524
- children: [_this.renderInput(autocompleteHelpers, fieldState), _this.inputContainerRef && /*#__PURE__*/(0, _reactDom.createPortal)(_this.renderMenu(results, autocompleteHelpers), (_this$context$portalT = _this.context["portalTarget"]) !== null && _this$context$portalT !== void 0 ? _this$context$portalT : document.body)]
525
- });
526
- });
527
- return _this;
528
- }
529
- (0, _createClass2["default"])(AutoComplete, [{
530
- key: "componentDidUpdate",
531
- value: function componentDidUpdate(prevProps) {
532
- // Only interested in updating inputValue from props for now
533
- // (which should only happen when this.props.multiple === false)
534
- if (this.props.multiple) return;
535
- var prevPropsInputValue = inputValueFromProps(prevProps);
536
- var propsInputValue = inputValueFromProps(this.props);
537
- var shouldUpdateInputValueFromProps = prevPropsInputValue !== propsInputValue && this.state.inputValue !== propsInputValue;
538
- if (shouldUpdateInputValueFromProps) {
539
- this.setState({
540
- inputValue: propsInputValue
541
- });
542
- }
543
- }
544
- }, {
545
- key: "locale",
546
- get: function get() {
547
- return _objectSpread(_objectSpread(_objectSpread({}, _utils.DEFAULT_AUTOCOMPLETE_LOCALE), this.context["locales"]), this.props.locale);
548
- }
549
- }, {
550
- key: "render",
551
- value: function render() {
552
- var _this2 = this;
553
- var inputValue = (this.props.inputValue !== undefined ? this.props.inputValue : this.state.inputValue) || "";
554
- return /*#__PURE__*/(0, _jsxRuntime.jsx)(_FieldStateContext.FieldStateContext.Consumer, {
555
- children: function children(fieldState) {
556
- return /*#__PURE__*/(0, _jsxRuntime.jsx)(_downshift["default"], {
557
- inputValue: inputValue
558
- /*
559
- * See https://github.com/algolia/AlgoliaWeb/issues/9045
560
- * See multi-select example
561
- * https://github.com/downshift-js/downshift#examples
562
- * https://codesandbox.io/s/github/kentcdodds/downshift-examples/tree/master/?module=/src/ordered-examples/04-multi-select.js&moduleview=1&file=/src/ordered-examples/04-multi-select.js:2482-2509
563
- */,
564
- selectedItem: null,
565
- getA11yStatusMessage: _this2.getA11yStatusMessage,
566
- onChange: _this2.handleChange,
567
- itemToString: optionToString,
568
- defaultHighlightedIndex: 0,
569
- children: function children(autocompleteHelpers) {
570
- return _this2.renderSelect(autocompleteHelpers, fieldState);
571
- }
572
- });
573
- }
574
- });
575
- }
576
- }]);
577
- return AutoComplete;
578
- }(_react.Component);
579
- exports.AutoComplete = AutoComplete;
580
- (0, _defineProperty2["default"])(AutoComplete, "contextType", _Satellite.SatelliteContext);
581
- (0, _defineProperty2["default"])(AutoComplete, "defaultProps", {
582
- clearable: false,
583
- creatable: false,
584
- multiple: false,
585
- maxResults: 7,
586
- createFromInputValue: _utils.defaultCreateFromInputValue,
587
- options: [],
588
- separatorKeys: [],
589
- optionItemComponent: DefaultOption,
590
- noWrap: false
591
- });
592
- var _default = AutoComplete;
593
- exports["default"] = _default;
395
+ })) : /*#__PURE__*/(0, _jsxRuntime.jsx)(_ScrollIndicator["default"], {
396
+ className: menuSize === "large" ? (0, _satellitePrefixer["default"])(_templateObject22 || (_templateObject22 = (0, _taggedTemplateLiteral2["default"])(["max-h-96"]))) : (0, _satellitePrefixer["default"])(_templateObject23 || (_templateObject23 = (0, _taggedTemplateLiteral2["default"])(["max-h-64"]))),
397
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)("ul", _objectSpread(_objectSpread({}, combobox.getMenuProps()), {}, {
398
+ children: items.map(function (item, index) {
399
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)("li", _objectSpread(_objectSpread({}, combobox.getItemProps({
400
+ item: item,
401
+ className: (0, _clsx["default"])((0, _satellitePrefixer["default"])(_templateObject24 || (_templateObject24 = (0, _taggedTemplateLiteral2["default"])(["autocomplete-result flex items-center min-h-10 px-4 cursor-pointer"]))), index === combobox.highlightedIndex && (0, _satellitePrefixer["default"])(_templateObject25 || (_templateObject25 = (0, _taggedTemplateLiteral2["default"])(["bg-grey-100"]))), item.disabled && (0, _satellitePrefixer["default"])(_templateObject26 || (_templateObject26 = (0, _taggedTemplateLiteral2["default"])(["cursor-not-allowed"]))))
402
+ })), {}, {
403
+ children: item.value === SHOW_ALL_ITEMS_ID ? /*#__PURE__*/(0, _jsxRuntime.jsx)("span", {
404
+ className: (0, _satellitePrefixer["default"])(_templateObject27 || (_templateObject27 = (0, _taggedTemplateLiteral2["default"])(["w-full py-2 truncate text-center text-grey-900"]))),
405
+ children: item.label
406
+ }, item.value) : /*#__PURE__*/(0, _jsxRuntime.jsx)(OptionItem, {
407
+ multiple: Boolean(multiple),
408
+ inputValue: inputValue,
409
+ highlighted: index === combobox.highlightedIndex,
410
+ option: item
411
+ })
412
+ }), String(item.value));
413
+ })
414
+ }))
415
+ }), !!menuFooter && /*#__PURE__*/(0, _jsxRuntime.jsx)("footer", {
416
+ className: (0, _satellitePrefixer["default"])(_templateObject28 || (_templateObject28 = (0, _taggedTemplateLiteral2["default"])(["flex items-center justify-center min-h-12 p-4 bg-grey-100 border-t border-grey-200 text-grey-600"]))),
417
+ children: menuFooter
418
+ })]
419
+ }))
420
+ }))]
421
+ })
422
+ });
423
+ };
424
+ var _default = exports["default"] = AutoComplete;