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