@procore/core-react 12.29.0 → 12.31.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (257) hide show
  1. package/CHANGELOG.md +26 -0
  2. package/dist/AnchorNavigation/AnchorNavigation.styles.js +3 -3
  3. package/dist/Avatar/Avatar.styles.js +5 -5
  4. package/dist/Avatar/Avatar.types.d.ts +1 -1
  5. package/dist/Avatar/Avatar.types.js.map +1 -1
  6. package/dist/AvatarStack/AvatarStack.styles.d.ts +76 -76
  7. package/dist/AvatarStack/AvatarStack.styles.js +7 -7
  8. package/dist/AvatarStack/AvatarStack.types.d.ts +0 -2
  9. package/dist/AvatarStack/AvatarStack.types.js.map +1 -1
  10. package/dist/Badge/Badge.styles.js +2 -2
  11. package/dist/BadgePill/BadgePill.styles.js +4 -4
  12. package/dist/Banner/Banner.styles.js +10 -10
  13. package/dist/Box/Box.styles.js +1 -1
  14. package/dist/Breadcrumbs/Breadcrumbs.styles.js +4 -4
  15. package/dist/Button/Button.styles.js +5 -5
  16. package/dist/Calendar/Calendar.styles.js +8 -8
  17. package/dist/Card/Card.styles.js +1 -1
  18. package/dist/Checkbox/Checkbox.styles.js +6 -6
  19. package/dist/Checkbox/CheckboxTooltip.js +1 -1
  20. package/dist/ComponentLifecycle.stories.mdx +130 -0
  21. package/dist/ContactItem/ContactItem.styles.js +5 -5
  22. package/dist/Content/Content.styles.js +2 -2
  23. package/dist/DateInput/DateInput.js +28 -0
  24. package/dist/DateInput/DateInput.js.map +1 -1
  25. package/dist/DateInput/DateInput.styles.js +6 -6
  26. package/dist/DetailPage/DetailPage.js +1 -1
  27. package/dist/DetailPage/DetailPage.js.map +1 -1
  28. package/dist/DetailPage/DetailPage.styles.js +7 -7
  29. package/dist/Dropdown/Dropdown.styles.js +3 -3
  30. package/dist/DropdownFlyout/DropdownFlyout.js +7 -2
  31. package/dist/DropdownFlyout/DropdownFlyout.js.map +1 -1
  32. package/dist/DropdownFlyout/DropdownFlyout.styles.js +4 -4
  33. package/dist/Dropzone/Dropzone.js +1 -1
  34. package/dist/Dropzone/Dropzone.styles.js +9 -9
  35. package/dist/EmptyState/EmptyState.styles.js +6 -6
  36. package/dist/Field/Field.styles.js +3 -3
  37. package/dist/FileList/FileList.styles.js +4 -4
  38. package/dist/FileSelect/FileExplorer/FileExplorer.styles.js +9 -9
  39. package/dist/FileSelect/FileExplorer/FileExplorerSidebar.styles.js +3 -3
  40. package/dist/FileSelect/FileSelect.styles.js +2 -2
  41. package/dist/FileSelect/FileSelectDropzone/FileSelectDropzone.styles.js +3 -3
  42. package/dist/FileSelect/FileTokenList/FileTokenList.styles.js +2 -2
  43. package/dist/FileSelect/GridSource/GridSource.styles.js +6 -6
  44. package/dist/FileSelect/LocalSource/LocalSource.styles.js +4 -4
  45. package/dist/FileSelect/SourceItem/SourceItem.styles.js +3 -3
  46. package/dist/FileSelect/ThumbnailList/ThumbnailList.styles.d.ts +1 -1
  47. package/dist/FileSelect/ThumbnailList/ThumbnailList.styles.js +6 -6
  48. package/dist/FileSelect/TreeSource/TreeSource.styles.js +1 -1
  49. package/dist/FileToken/FileToken.styles.js +4 -4
  50. package/dist/FilterToken/FilterToken.styles.js +5 -5
  51. package/dist/FlexList/FlexList.styles.js +1 -1
  52. package/dist/Form/Form.styles.js +14 -14
  53. package/dist/Form/StyledFormikForm.styles.d.ts +2 -2
  54. package/dist/Form/StyledFormikForm.styles.js +2 -2
  55. package/dist/GhostPlaceholder/GhostPlaceholder.styles.js +2 -2
  56. package/dist/Grid/Grid.styles.js +2 -2
  57. package/dist/GroupSelect/GroupSelect.styles.js +1 -1
  58. package/dist/Input/Input.styles.js +1 -1
  59. package/dist/Link/Link.styles.js +1 -1
  60. package/dist/ListPage/ListPage.styles.js +8 -8
  61. package/dist/Loader/Loader.styles.js +2 -2
  62. package/dist/MenuImperative/MenuImperative.d.ts +1 -16
  63. package/dist/MenuImperative/MenuImperative.js +1 -0
  64. package/dist/MenuImperative/MenuImperative.js.map +1 -1
  65. package/dist/MenuImperative/MenuImperative.styles.js +10 -10
  66. package/dist/MenuImperative/MenuImperative.types.d.ts +14 -0
  67. package/dist/MenuImperative/MenuImperative.types.js.map +1 -1
  68. package/dist/MenuImperative/index.d.ts +46 -3
  69. package/dist/MenuImperative/index.js +31 -2
  70. package/dist/MenuImperative/index.js.map +1 -1
  71. package/dist/Modal/Modal.js +5 -2
  72. package/dist/Modal/Modal.js.map +1 -1
  73. package/dist/Modal/Modal.styles.js +13 -13
  74. package/dist/MultiSelect/MultiSelect.styles.d.ts +1 -1
  75. package/dist/MultiSelect/MultiSelect.styles.js +6 -6
  76. package/dist/NextMenu/NextMenu.styles.js +3 -3
  77. package/dist/Notation/Notation.js +1 -1
  78. package/dist/NumberInput/NumberInput.styles.js +7 -7
  79. package/dist/Overlay/OverlayArrow.styles.js +1 -1
  80. package/dist/OverlayTrigger/a11yPresets.d.ts +6 -6
  81. package/dist/PageLayout/PageLayout.styles.d.ts +1 -1
  82. package/dist/PageLayout/PageLayout.styles.js +16 -16
  83. package/dist/PageTemplate/PageFooterTemplate/PageFooterTemplate.styles.js +1 -1
  84. package/dist/PageTemplate/PageHeaderTemplate/PageHeaderTemplate.styles.js +3 -3
  85. package/dist/PageTemplate/PagePaneTemplate/PagePaneTemplate.styles.js +2 -2
  86. package/dist/PageTemplate/PageTemplate/PageTemplate.styles.js +3 -3
  87. package/dist/PageTemplate/PageTemplate/PageTemplateCard.d.ts +3 -5
  88. package/dist/PageTemplate/PageTemplate/PageTemplateCard.js.map +1 -1
  89. package/dist/Pagination/Pagination.styles.js +5 -5
  90. package/dist/Panel/Panel.styles.js +11 -11
  91. package/dist/Pill/Pill.styles.js +3 -3
  92. package/dist/PillSelect/PillSelect.styles.js +4 -4
  93. package/dist/Popover/Popover.styles.js +2 -2
  94. package/dist/Portal/Portal.styles.js +1 -1
  95. package/dist/ProgressBar/ProgressBar.styles.js +2 -2
  96. package/dist/RadioButton/RadioButton.styles.js +3 -3
  97. package/dist/Required/Required.styles.js +3 -3
  98. package/dist/Search/Search.styles.js +5 -5
  99. package/dist/Section/Section.styles.js +7 -7
  100. package/dist/SegmentedController/SegmentedController.styles.js +4 -4
  101. package/dist/Select/Select.js +6 -3
  102. package/dist/Select/Select.js.map +1 -1
  103. package/dist/Select/Select.styles.js +7 -7
  104. package/dist/Semantic/Semantic.styles.d.ts +78 -78
  105. package/dist/Semantic/Semantic.styles.js +9 -9
  106. package/dist/Slider/Slider.styles.js +5 -5
  107. package/dist/Spinner/Spinner.styles.js +7 -7
  108. package/dist/SplitViewCard/SplitViewCard.styles.js +8 -8
  109. package/dist/SuperSelect/SuperSelect.components.js +1 -1
  110. package/dist/SuperSelect/SuperSelect.components.js.map +1 -1
  111. package/dist/SuperSelect/SuperSelect.presets.styles.js +1 -1
  112. package/dist/SuperSelect/SuperSelect.styles.js +38 -38
  113. package/dist/SuperSelect/useSuperSelect.js +377 -62
  114. package/dist/SuperSelect/useSuperSelect.js.map +1 -1
  115. package/dist/Switch/Switch.styles.js +4 -4
  116. package/dist/Table/Table.styles.js +28 -28
  117. package/dist/TableShelf/TableShelf.styles.js +5 -5
  118. package/dist/Tabs/Tabs.styles.js +15 -15
  119. package/dist/Tearsheet/Tearsheet.styles.js +5 -5
  120. package/dist/TextArea/TextArea.styles.js +1 -1
  121. package/dist/TextEditorOutput/TextEditorOutput.styles.js +1 -1
  122. package/dist/Thumbnail/Thumbnail.hooks.d.ts +68 -68
  123. package/dist/Thumbnail/Thumbnail.styles.js +17 -17
  124. package/dist/ThumbnailGrid/ThumbnailGrid.styles.d.ts +1 -1
  125. package/dist/ThumbnailGrid/ThumbnailGrid.styles.js +7 -7
  126. package/dist/TieredSelect/TieredSelect.styles.d.ts +4 -4
  127. package/dist/TieredSelect/TieredSelect.styles.js +9 -9
  128. package/dist/Tile/Tile.styles.js +8 -8
  129. package/dist/Title/Title.styles.js +7 -7
  130. package/dist/Toast/Toast.styles.js +3 -3
  131. package/dist/ToggleButton/ToggleButton.styles.js +1 -1
  132. package/dist/Token/Token.styles.js +3 -3
  133. package/dist/ToolHeader/ToolHeader.styles.js +6 -6
  134. package/dist/ToolLandingPage/ToolLandingPage.styles.js +3 -3
  135. package/dist/Tooltip/Tooltip.styles.js +2 -2
  136. package/dist/Tree/Tree.styles.js +9 -9
  137. package/dist/Typeahead/Typeahead.styles.js +3 -3
  138. package/dist/Typography/Typography.styles.js +1 -1
  139. package/dist/Typography/Typography.table.story.js +2 -2
  140. package/dist/UNSAFE_TEMPLATES_index.d.ts +15 -0
  141. package/dist/UNSAFE_TEMPLATES_index.js +9 -0
  142. package/dist/UNSAFE_TEMPLATES_index.js.map +1 -0
  143. package/dist/_hooks/I18n.d.ts +1207 -20
  144. package/dist/_hooks/I18n.js +9 -1
  145. package/dist/_hooks/I18n.js.map +1 -1
  146. package/dist/_locales/de-DE.json +2 -1
  147. package/dist/_locales/en-AU.json +2 -1
  148. package/dist/_locales/en-CA.json +2 -1
  149. package/dist/_locales/en-GB.json +2 -1
  150. package/dist/_locales/en.json +2 -1
  151. package/dist/_locales/es-ES.json +2 -1
  152. package/dist/_locales/es.json +3 -2
  153. package/dist/_locales/fr-CA.json +2 -1
  154. package/dist/_locales/fr-FR.json +2 -1
  155. package/dist/_locales/is-IS.json +2 -1
  156. package/dist/_locales/it-IT.json +2 -1
  157. package/dist/_locales/ja-JP.json +2 -1
  158. package/dist/_locales/nb-NO.json +1 -0
  159. package/dist/_locales/pl-PL.json +2 -1
  160. package/dist/_locales/pseudo.json +2 -1
  161. package/dist/_locales/pt-BR.json +2 -1
  162. package/dist/_locales/pt-PT.json +2 -1
  163. package/dist/_locales/th-TH.json +2 -1
  164. package/dist/_locales/zh-SG.json +2 -1
  165. package/dist/_locales/zh-TW.json +4 -3
  166. package/dist/_storyHelpers_/components/Deprecation.styles.js +1 -1
  167. package/dist/_storyHelpers_/components/StoryGrid.js +3 -3
  168. package/dist/_storyHelpers_/constants.js +1 -1
  169. package/dist/_storyHelpers_/constants.js.map +1 -1
  170. package/dist/_typedoc/AnchorNavigation/AnchorNavigation.types.json +3 -3
  171. package/dist/_typedoc/Avatar/Avatar.types.json +22 -22
  172. package/dist/_typedoc/AvatarStack/AvatarStack.types.json +25 -27
  173. package/dist/_typedoc/Badge/Badge.types.json +6 -6
  174. package/dist/_typedoc/Banner/Banner.types.json +13 -13
  175. package/dist/_typedoc/Box/Box.types.json +72 -72
  176. package/dist/_typedoc/Breadcrumbs/Breadcrumbs.types.json +10 -10
  177. package/dist/_typedoc/Button/Button.types.json +15 -15
  178. package/dist/_typedoc/Calendar/Calendar.types.json +80 -80
  179. package/dist/_typedoc/Card/Card.types.json +6 -6
  180. package/dist/_typedoc/Checkbox/Checkbox.types.json +8 -8
  181. package/dist/_typedoc/ContactItem/ContactItem.types.json +9 -9
  182. package/dist/_typedoc/DateInput/DateInput.types.json +35 -35
  183. package/dist/_typedoc/DateSelect/DateSelect.types.json +13 -13
  184. package/dist/_typedoc/DetailPage/DetailPage.types.json +5 -5
  185. package/dist/_typedoc/Dropdown/Dropdown.types.json +39 -39
  186. package/dist/_typedoc/DropdownFlyout/DropdownFlyout.types.json +30 -30
  187. package/dist/_typedoc/Dropzone/Dropzone.types.json +44 -44
  188. package/dist/_typedoc/EmptyState/EmptyState.types.json +16 -16
  189. package/dist/_typedoc/FileList/FileList.types.json +9 -9
  190. package/dist/_typedoc/FileSelect/FileSelect.types.json +27 -27
  191. package/dist/_typedoc/FileSelect/GridSource/GridSource.types.json +20 -20
  192. package/dist/_typedoc/FileSelect/LocalSource/LocalSource.types.json +14 -14
  193. package/dist/_typedoc/FileSelect/TreeSource/TreeSource.types.json +9 -9
  194. package/dist/_typedoc/Flex/Flex.types.json +27 -27
  195. package/dist/_typedoc/FlexList/FlexList.types.json +30 -30
  196. package/dist/_typedoc/Form/Form.types.json +815 -815
  197. package/dist/_typedoc/GhostPlaceholder/GhostPlaceholder.types.json +12 -12
  198. package/dist/_typedoc/Grid/Grid.types.json +8 -8
  199. package/dist/_typedoc/GroupSelect/GroupSelect.types.json +52 -52
  200. package/dist/_typedoc/Input/Input.types.json +2 -2
  201. package/dist/_typedoc/Link/Link.types.json +1 -1
  202. package/dist/_typedoc/ListPage/ListPage.types.json +13 -13
  203. package/dist/_typedoc/Menu/Menu.types.json +62 -62
  204. package/dist/_typedoc/MenuImperative/MenuImperative.types.json +116 -74
  205. package/dist/_typedoc/Modal/Modal.types.json +46 -46
  206. package/dist/_typedoc/MultiSelect/MultiSelect.types.json +31 -31
  207. package/dist/_typedoc/NextTile/NextTile.types.json +32 -32
  208. package/dist/_typedoc/Notation/Notation.types.json +4 -4
  209. package/dist/_typedoc/NumberInput/NumberInput.types.json +54 -54
  210. package/dist/_typedoc/OverlayTrigger/OverlayTrigger.types.json +32 -32
  211. package/dist/_typedoc/PageLayout/PageLayout.types.json +26 -26
  212. package/dist/_typedoc/Pagination/Pagination.types.json +7 -7
  213. package/dist/_typedoc/Panel/Panel.types.json +30 -30
  214. package/dist/_typedoc/Pill/Pill.types.json +2 -2
  215. package/dist/_typedoc/PillSelect/PillSelect.types.json +49 -49
  216. package/dist/_typedoc/Popover/Popover.types.json +15 -15
  217. package/dist/_typedoc/ProgressBar/ProgressBar.types.json +7 -7
  218. package/dist/_typedoc/RadioButton/RadioButton.types.json +6 -6
  219. package/dist/_typedoc/Required/Required.types.json +5 -5
  220. package/dist/_typedoc/Search/Search.types.json +18 -18
  221. package/dist/_typedoc/Section/Section.types.json +15 -15
  222. package/dist/_typedoc/SegmentedController/SegmentedController.types.json +21 -21
  223. package/dist/_typedoc/Select/Select.types.json +62 -62
  224. package/dist/_typedoc/SettingsPage/SettingsPage.types.json +10 -10
  225. package/dist/_typedoc/Slider/Slider.types.json +6 -6
  226. package/dist/_typedoc/Spinner/Spinner.types.json +9 -9
  227. package/dist/_typedoc/SplitViewCard/SplitViewCard.types.json +14 -14
  228. package/dist/_typedoc/Table/Table.types.json +101 -101
  229. package/dist/_typedoc/Tabs/Tabs.types.json +20 -20
  230. package/dist/_typedoc/Tearsheet/Tearsheet.types.json +17 -17
  231. package/dist/_typedoc/TextArea/TextArea.types.json +3 -3
  232. package/dist/_typedoc/TextEditor/TextEditor.types.json +9 -9
  233. package/dist/_typedoc/TextEditorOutput/TextEditorOutput.types.json +4 -4
  234. package/dist/_typedoc/Thumbnail/Thumbnail.types.json +19 -19
  235. package/dist/_typedoc/TieredDropdown/TieredDropdown.types.json +42 -42
  236. package/dist/_typedoc/TieredSelect/TieredSelect.types.json +28 -28
  237. package/dist/_typedoc/Tile/Tile.types.json +8 -8
  238. package/dist/_typedoc/Title/Title.types.json +3 -3
  239. package/dist/_typedoc/Toast/Toast.types.json +4 -4
  240. package/dist/_typedoc/ToggleButton/ToggleButton.types.json +4 -4
  241. package/dist/_typedoc/Token/Token.types.json +7 -7
  242. package/dist/_typedoc/ToolHeader/ToolHeader.types.json +10 -10
  243. package/dist/_typedoc/ToolLandingPage/ToolLandingPage.types.json +7 -7
  244. package/dist/_typedoc/Tooltip/Tooltip.types.json +13 -13
  245. package/dist/_typedoc/Tree/Tree.types.json +88 -88
  246. package/dist/_typedoc/Typeahead/Typeahead.types.json +2 -2
  247. package/dist/_typedoc/Typography/Typography.types.json +9 -9
  248. package/dist/_typedoc/_utils/types.json +3 -3
  249. package/dist/_typedoc/deprecations.json +1 -1
  250. package/dist/_utils/CalendarHelpers.js +6 -2
  251. package/dist/_utils/CalendarHelpers.js.map +1 -1
  252. package/dist/_utils/TinyMCE.js +5 -1
  253. package/dist/_utils/TinyMCE.js.map +1 -1
  254. package/dist/index.d.ts +6 -0
  255. package/dist/index.js +6 -0
  256. package/dist/index.js.map +1 -1
  257. package/package.json +4 -3
@@ -3,6 +3,7 @@ function _toConsumableArray(r) { return _arrayWithoutHoles(r) || _iterableToArra
3
3
  function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
4
4
  function _iterableToArray(r) { if ("undefined" != typeof Symbol && null != r[Symbol.iterator] || null != r["@@iterator"]) return Array.from(r); }
5
5
  function _arrayWithoutHoles(r) { if (Array.isArray(r)) return _arrayLikeToArray(r); }
6
+ function _createForOfIteratorHelper(r, e) { var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (!t) { if (Array.isArray(r) || (t = _unsupportedIterableToArray(r)) || e && r && "number" == typeof r.length) { t && (r = t); var _n = 0, F = function F() {}; return { s: F, n: function n() { return _n >= r.length ? { done: !0 } : { done: !1, value: r[_n++] }; }, e: function e(r) { throw r; }, 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 o, a = !0, u = !1; return { s: function s() { t = t.call(r); }, n: function n() { var r = t.next(); return a = r.done, r; }, e: function e(r) { u = !0, o = r; }, f: function f() { try { a || null == t["return"] || t["return"](); } finally { if (u) throw o; } } }; }
6
7
  function _slicedToArray(r, e) { return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest(); }
7
8
  function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
8
9
  function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
@@ -17,7 +18,6 @@ function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e
17
18
  import { autoUpdate, flip, offset, size, useClick, useDismiss, useFloating, useInteractions, useListNavigation } from '@floating-ui/react';
18
19
  import { useId } from '@react-aria/utils';
19
20
  import debounce from 'lodash.debounce';
20
- import uniq from 'lodash.uniq';
21
21
  import React from 'react';
22
22
  import { ulid } from 'ulid';
23
23
  import { useI18nContext } from '../_hooks/I18n';
@@ -207,6 +207,32 @@ export function useSuperSelect(_ref3) {
207
207
  val = _React$useState2[0],
208
208
  setVal = _React$useState2[1];
209
209
  var value = value_ !== undefined ? value_ : val;
210
+
211
+ /**
212
+ * Tracks whether the "Select All" feature is currently active.
213
+ * When true, new options that appear will be automatically selected.
214
+ * This state is activated when all available options are selected and
215
+ * deactivated when any option is individually deselected.
216
+ */
217
+ var _React$useState3 = React.useState(false),
218
+ _React$useState4 = _slicedToArray(_React$useState3, 2),
219
+ isSelectAllActive = _React$useState4[0],
220
+ setIsSelectAllActive = _React$useState4[1];
221
+
222
+ /**
223
+ * Flag to prevent recursive auto-selection calls during state updates.
224
+ * Ensures that auto-selection logic doesn't trigger multiple times
225
+ * concurrently, which could cause performance issues or incorrect state.
226
+ */
227
+ var isProcessingAutoSelectionRef = React.useRef(false);
228
+
229
+ /**
230
+ * Stores a snapshot of previously available selectable options as a Map.
231
+ * Key: JSON stringified option value for fast lookups
232
+ * Value: The SuperSelectOption object
233
+ * Used to detect newly added options for auto-selection when Select All is active.
234
+ */
235
+ var previousSelectableOptionsRef = React.useRef(new Set());
210
236
  function setValue(v) {
211
237
  if (!value_) {
212
238
  setVal(v);
@@ -215,55 +241,202 @@ export function useSuperSelect(_ref3) {
215
241
  onChange(v);
216
242
  }
217
243
  }
244
+
245
+ /**
246
+ * Extracts all primitive values from an option, handling both single values and batch values.
247
+ * For batch options (arrays), returns all values flattened into a single array.
248
+ * For single options, wraps the value in an array for consistent processing.
249
+ *
250
+ * @param option - The option to extract values from
251
+ * @returns Array of primitive values contained in the option
252
+ */
253
+ var getOptionValuesFlat = React.useCallback(function (option) {
254
+ var optionValue = getOptionValue(option);
255
+ return Array.isArray(optionValue) ? optionValue : [optionValue];
256
+ }, [getOptionValue]);
257
+
258
+ /**
259
+ * Determines if all selectable options are currently selected.
260
+ * Uses early termination to improve performance when checking if all selectable options are selected.
261
+ *
262
+ * Performance optimizations:
263
+ * - Early exit if value count is less than options count
264
+ * - Uses early termination in the validation loop
265
+ *
266
+ * @param currentValue - Current selected values array
267
+ * @param currentSelectableOptions - Array of selectable options to check
268
+ * @returns true if all selectable options are selected, false otherwise
269
+ */
270
+ var checkIfAllSelectableOptionsSelected = React.useCallback(function (currentValue, currentSelectableOptions) {
271
+ if (!Array.isArray(currentValue) || currentSelectableOptions.length === 0) {
272
+ return false;
273
+ }
274
+
275
+ // Early exit if values count doesn't match options count
276
+ if (currentValue.length < currentSelectableOptions.length) {
277
+ return false;
278
+ }
279
+ var valueSet = new Set(currentValue);
280
+
281
+ // Use early termination for better performance
282
+ var _iterator = _createForOfIteratorHelper(currentSelectableOptions),
283
+ _step;
284
+ try {
285
+ for (_iterator.s(); !(_step = _iterator.n()).done;) {
286
+ var option = _step.value;
287
+ var optionValues = getOptionValuesFlat(option);
288
+ if (!optionValues.every(function (val) {
289
+ return valueSet.has(val);
290
+ })) {
291
+ return false;
292
+ }
293
+ }
294
+ } catch (err) {
295
+ _iterator.e(err);
296
+ } finally {
297
+ _iterator.f();
298
+ }
299
+ return true;
300
+ }, [getOptionValuesFlat]);
301
+
302
+ /**
303
+ * Performs automatic selection of newly added options when Select All is active.
304
+ *
305
+ * Algorithm:
306
+ * 1. Compares current options with previous snapshot to find new options
307
+ * 2. Automatically selects any newly detected options
308
+ * 3. Implements safeguards against recursive calls
309
+ *
310
+ * Performance considerations:
311
+ * - Single pass to build current options map and detect new ones
312
+ * - Set-based deduplication for efficient value management
313
+ *
314
+ * @param currentSelectableOptions - Current array of selectable options
315
+ * @param currentValue - Current selected values
316
+ */
317
+ var executeAutoSelection = React.useCallback(function (currentSelectableOptions, currentValue) {
318
+ // Early exit conditions for performance
319
+ if (!isSelectAllActive || !multiple || !Array.isArray(currentValue) || isProcessingAutoSelectionRef.current) {
320
+ return;
321
+ }
322
+ var currentOptionKeys = new Set();
323
+ var newlyAddedOptions = [];
324
+ var _iterator2 = _createForOfIteratorHelper(currentSelectableOptions),
325
+ _step2;
326
+ try {
327
+ for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
328
+ var _option = _step2.value;
329
+ var optionKey = JSON.stringify(getOptionValue(_option));
330
+ currentOptionKeys.add(optionKey);
331
+ if (!previousSelectableOptionsRef.current.has(optionKey)) {
332
+ newlyAddedOptions.push(_option);
333
+ }
334
+ }
335
+
336
+ // Update reference for next comparison
337
+ } catch (err) {
338
+ _iterator2.e(err);
339
+ } finally {
340
+ _iterator2.f();
341
+ }
342
+ previousSelectableOptionsRef.current = currentOptionKeys;
343
+
344
+ // No new options to auto-select
345
+ if (newlyAddedOptions.length === 0) {
346
+ return;
347
+ }
348
+
349
+ // Set processing flag to prevent recursive calls
350
+ isProcessingAutoSelectionRef.current = true;
351
+ var currentValueSet = new Set(currentValue);
352
+ var newValuesToAdd = [];
353
+
354
+ // Collect new values that aren't already selected
355
+ for (var _i = 0, _newlyAddedOptions = newlyAddedOptions; _i < _newlyAddedOptions.length; _i++) {
356
+ var option = _newlyAddedOptions[_i];
357
+ var optionValues = getOptionValuesFlat(option);
358
+ var _iterator3 = _createForOfIteratorHelper(optionValues),
359
+ _step3;
360
+ try {
361
+ for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
362
+ var _val = _step3.value;
363
+ if (!currentValueSet.has(_val)) {
364
+ newValuesToAdd.push(_val);
365
+ }
366
+ }
367
+ } catch (err) {
368
+ _iterator3.e(err);
369
+ } finally {
370
+ _iterator3.f();
371
+ }
372
+ }
373
+
374
+ // Only update if there are new values to add
375
+ if (newValuesToAdd.length > 0) {
376
+ // Use Set for efficient deduplication
377
+ var combinedValueSet = new Set([].concat(_toConsumableArray(currentValue), newValuesToAdd));
378
+ setValue(Array.from(combinedValueSet));
379
+ }
380
+
381
+ // Reset processing flag
382
+ isProcessingAutoSelectionRef.current = false;
383
+ }, [isSelectAllActive, multiple, setValue, getOptionValuesFlat]);
384
+
385
+ // Debounced auto-selection for handling rapid option changes
386
+ var debouncedAutoSelection = React.useMemo(function () {
387
+ return debounce(executeAutoSelection, 50);
388
+ },
389
+ // Optimized 50ms debounce
390
+ [executeAutoSelection]);
218
391
  var navigationList = React.useRef([]);
219
392
  var virtuoso = React.useRef(null);
220
393
  var searchRef = React.useRef(null);
221
394
  var overlayId = useId(); // TODO use React 18 useId
222
395
  var listId = useId(); // TODO use React 18 useId
223
396
 
224
- var _React$useState3 = React.useState(false),
225
- _React$useState4 = _slicedToArray(_React$useState3, 2),
226
- open = _React$useState4[0],
227
- setOpen = _React$useState4[1];
228
397
  var _React$useState5 = React.useState(false),
229
398
  _React$useState6 = _slicedToArray(_React$useState5, 2),
230
- pointer = _React$useState6[0],
231
- setPointer = _React$useState6[1];
232
- var _React$useState7 = React.useState(248),
399
+ open = _React$useState6[0],
400
+ setOpen = _React$useState6[1];
401
+ var _React$useState7 = React.useState(false),
233
402
  _React$useState8 = _slicedToArray(_React$useState7, 2),
234
- width = _React$useState8[0],
235
- setWidth = _React$useState8[1];
403
+ pointer = _React$useState8[0],
404
+ setPointer = _React$useState8[1];
236
405
  var _React$useState9 = React.useState(248),
237
406
  _React$useState0 = _slicedToArray(_React$useState9, 2),
238
- maxHeight = _React$useState0[0],
239
- setMaxHeight = _React$useState0[1];
240
- var _React$useState1 = React.useState(0),
407
+ width = _React$useState0[0],
408
+ setWidth = _React$useState0[1];
409
+ var _React$useState1 = React.useState(248),
241
410
  _React$useState10 = _slicedToArray(_React$useState1, 2),
242
- listHeight = _React$useState10[0],
243
- setListHeight = _React$useState10[1];
411
+ maxHeight = _React$useState10[0],
412
+ setMaxHeight = _React$useState10[1];
244
413
  var _React$useState11 = React.useState(0),
245
414
  _React$useState12 = _slicedToArray(_React$useState11, 2),
246
- searchHeight = _React$useState12[0],
247
- setSearchHeight = _React$useState12[1];
415
+ listHeight = _React$useState12[0],
416
+ setListHeight = _React$useState12[1];
248
417
  var _React$useState13 = React.useState(0),
249
418
  _React$useState14 = _slicedToArray(_React$useState13, 2),
250
- footerHeight = _React$useState14[0],
251
- setFooterHeight = _React$useState14[1];
252
- var listContainerHeight = Math.min(maxHeight - searchHeight - footerHeight + listContainerVerticalPadding, listHeight + listContainerVerticalPadding);
253
- var _React$useState15 = React.useState(''),
419
+ searchHeight = _React$useState14[0],
420
+ setSearchHeight = _React$useState14[1];
421
+ var _React$useState15 = React.useState(0),
254
422
  _React$useState16 = _slicedToArray(_React$useState15, 2),
255
- searchValue = _React$useState16[0],
256
- setSearchValue_ = _React$useState16[1];
423
+ footerHeight = _React$useState16[0],
424
+ setFooterHeight = _React$useState16[1];
425
+ var listContainerHeight = Math.min(maxHeight - searchHeight - footerHeight + listContainerVerticalPadding, listHeight + listContainerVerticalPadding);
426
+ var _React$useState17 = React.useState(''),
427
+ _React$useState18 = _slicedToArray(_React$useState17, 2),
428
+ searchValue = _React$useState18[0],
429
+ setSearchValue_ = _React$useState18[1];
257
430
  var setSearchValue = debounce(setSearchValue_, 250); // TODO use React 18 useDeferredValue
258
431
 
259
- var _React$useState17 = React.useState(null),
260
- _React$useState18 = _slicedToArray(_React$useState17, 2),
261
- activeMenuIndex = _React$useState18[0],
262
- setActiveMenuIndex = _React$useState18[1];
263
432
  var _React$useState19 = React.useState(null),
264
433
  _React$useState20 = _slicedToArray(_React$useState19, 2),
265
- activeTokenIndex = _React$useState20[0],
266
- setActiveTokenIndex = _React$useState20[1];
434
+ activeMenuIndex = _React$useState20[0],
435
+ setActiveMenuIndex = _React$useState20[1];
436
+ var _React$useState21 = React.useState(null),
437
+ _React$useState22 = _slicedToArray(_React$useState21, 2),
438
+ activeTokenIndex = _React$useState22[0],
439
+ setActiveTokenIndex = _React$useState22[1];
267
440
  var components = _objectSpread(_objectSpread({}, defaultComponents), customComponents || {});
268
441
 
269
442
  // TODO #memogetters: consider having getOption... getter functions memoized by consumers
@@ -340,6 +513,63 @@ export function useSuperSelect(_ref3) {
340
513
  },
341
514
  // skip `getOptionLabel`, refer to TODO #memogetters
342
515
  [groupAndSortAlgorithm, formatBatchOption, searchValue, sourceOptions]);
516
+
517
+ /**
518
+ * Filtered list of options that can be selected (excludes disabled options and optgroups).
519
+ * Used for auto-selection logic to determine which options should be automatically
520
+ * selected when Select All is active and new options appear.
521
+ */
522
+ var selectableOptions = React.useMemo(function () {
523
+ var result = [];
524
+ var _iterator4 = _createForOfIteratorHelper(options),
525
+ _step4;
526
+ try {
527
+ for (_iterator4.s(); !(_step4 = _iterator4.n()).done;) {
528
+ var option = _step4.value;
529
+ if (isSelectableOption(option)) {
530
+ result.push(option);
531
+ }
532
+ }
533
+ } catch (err) {
534
+ _iterator4.e(err);
535
+ } finally {
536
+ _iterator4.f();
537
+ }
538
+ return result;
539
+ }, [options]);
540
+
541
+ /**
542
+ * Effect function that triggers auto-selection when conditions are met.
543
+ * Calls the debounced auto-selection logic when:
544
+ * - Select All is enabled
545
+ * - Multiple selection mode is active
546
+ * - Select All state is currently active
547
+ * - Current value is an array (multiple selection)
548
+ *
549
+ * The debouncing helps handle rapid option changes efficiently.
550
+ */
551
+ var autoSelectionEffect = React.useCallback(function () {
552
+ if (selectAllEnabled && multiple && isSelectAllActive && Array.isArray(value)) {
553
+ debouncedAutoSelection(selectableOptions, value);
554
+ }
555
+ }, [selectAllEnabled, multiple, isSelectAllActive, value, debouncedAutoSelection, selectableOptions]);
556
+
557
+ /**
558
+ * Effect that manages auto-selection behavior and cleanup.
559
+ * - Triggers auto-selection when dependencies change
560
+ * - Runs on every render when auto-selection conditions might have changed
561
+ */
562
+ React.useEffect(function () {
563
+ autoSelectionEffect();
564
+ return function () {
565
+ var _debouncedAutoSelecti;
566
+ // Cleanup debounced function
567
+ (_debouncedAutoSelecti = debouncedAutoSelection.cancel) === null || _debouncedAutoSelecti === void 0 ? void 0 : _debouncedAutoSelecti.call(debouncedAutoSelection);
568
+
569
+ // Reset processing flag
570
+ isProcessingAutoSelectionRef.current = false;
571
+ };
572
+ }, [autoSelectionEffect, debouncedAutoSelection]);
343
573
  var selectAllOption = _defineProperty({
344
574
  label: i18n.t('core.select.selectAll'),
345
575
  id: 'selectAll'
@@ -350,10 +580,10 @@ export function useSuperSelect(_ref3) {
350
580
  }
351
581
  return [selectAllOption].concat(_toConsumableArray(options));
352
582
  }, [selectAllEnabled, multiple, selectAllOption, options]);
353
- var _React$useState21 = React.useState([]),
354
- _React$useState22 = _slicedToArray(_React$useState21, 2),
355
- draggableOptions = _React$useState22[0],
356
- setDraggableOptions = _React$useState22[1];
583
+ var _React$useState23 = React.useState([]),
584
+ _React$useState24 = _slicedToArray(_React$useState23, 2),
585
+ draggableOptions = _React$useState24[0],
586
+ setDraggableOptions = _React$useState24[1];
357
587
  React.useEffect(function () {
358
588
  if (!draggable) {
359
589
  return;
@@ -428,7 +658,109 @@ export function useSuperSelect(_ref3) {
428
658
  var baseOptions = options;
429
659
  return baseOptions.findIndex(isSelectableOption) + (selectAllEnabled && multiple ? 1 : 0);
430
660
  }
431
- function onSelect(option) {
661
+
662
+ // Helper functions for onSelect optimization
663
+ /**
664
+ * Handles the toggle behavior for the Select All option.
665
+ *
666
+ * Behavior:
667
+ * - If all options are selected: deselects all and deactivates Select All
668
+ * - If not all options are selected: selects all and activates Select All
669
+ *
670
+ * Performance optimizations:
671
+ * - Uses Set for efficient value deduplication
672
+ * - Leverages existing option checking logic
673
+ * - Calls optional onSelectAll callback for external handling
674
+ */
675
+ var handleSelectAllToggle = React.useCallback(function () {
676
+ var getIsSelected = getOptionIsSelected !== null && getOptionIsSelected !== void 0 ? getOptionIsSelected : defaultGetOptionIsSelected;
677
+ var allSelected = selectableOptions.every(function (opt) {
678
+ return getIsSelected(opt);
679
+ });
680
+ if (onSelectAll) {
681
+ onSelectAll(selectableOptions);
682
+ }
683
+ if (allSelected) {
684
+ setIsSelectAllActive(false);
685
+ setValue([]);
686
+ } else {
687
+ setIsSelectAllActive(true);
688
+ // Ensure we're working with an array for multiple selection
689
+ var currentValue = Array.isArray(value) ? value : [];
690
+ var valueSet = new Set(currentValue);
691
+ selectableOptions.forEach(function (opt) {
692
+ getOptionValuesFlat(opt).forEach(function (val) {
693
+ return valueSet.add(val);
694
+ });
695
+ });
696
+ setValue(Array.from(valueSet));
697
+ }
698
+ }, [getOptionIsSelected, selectableOptions, onSelectAll, setIsSelectAllActive, setValue, value, getOptionValuesFlat]);
699
+
700
+ /**
701
+ * Determines if Select All should be activated based on the new value.
702
+ * Select All activates when all selectable options become selected,
703
+ * but only if it wasn't already active (prevents unnecessary state changes).
704
+ *
705
+ * @param newValue - The new array of selected values to evaluate
706
+ * @returns true if Select All should be activated, false otherwise
707
+ */
708
+ var shouldActivateSelectAll = React.useCallback(function (newValue) {
709
+ return !isSelectAllActive && selectAllEnabled && newValue.length >= selectableOptions.length && checkIfAllSelectableOptionsSelected(newValue, selectableOptions);
710
+ }, [isSelectAllActive, selectAllEnabled, selectableOptions, checkIfAllSelectableOptionsSelected]);
711
+
712
+ /**
713
+ * Handles selection of batch options (options with multiple values).
714
+ * Adds all values from the batch option to the current selection
715
+ * and activates Select All if all options become selected.
716
+ *
717
+ * @param optionValue - Array of primitive values from the batch option
718
+ */
719
+ var handleBatchOptionSelection = React.useCallback(function (optionValue) {
720
+ // Ensure we're working with an array for multiple selection
721
+ var currentValue = Array.isArray(value) ? value : [];
722
+ var newValueSet = new Set([].concat(_toConsumableArray(currentValue), _toConsumableArray(optionValue)));
723
+ var newValue = Array.from(newValueSet);
724
+ setValue(newValue);
725
+ if (shouldActivateSelectAll(newValue)) {
726
+ setIsSelectAllActive(true);
727
+ }
728
+ }, [value, setValue, shouldActivateSelectAll, setIsSelectAllActive]);
729
+
730
+ /**
731
+ * Handles selection/deselection of individual options in multiple mode.
732
+ *
733
+ * Behavior:
734
+ * - If option is selected: removes it and deactivates Select All
735
+ * - If option is not selected: adds it and activates Select All if all options become selected
736
+ *
737
+ * @param optionValue - The primitive value of the option to toggle
738
+ */
739
+ var handleSingleOptionSelection = React.useCallback(function (optionValue) {
740
+ // Ensure we're working with an array for multiple selection
741
+ if (!Array.isArray(value)) {
742
+ return;
743
+ }
744
+ var valueIndex = value.indexOf(optionValue);
745
+ if (valueIndex >= 0) {
746
+ // Remove value
747
+ var newValue = value.filter(function (_, i) {
748
+ return i !== valueIndex;
749
+ });
750
+ setValue(newValue);
751
+ if (isSelectAllActive) {
752
+ setIsSelectAllActive(false);
753
+ }
754
+ } else {
755
+ // Add value
756
+ var _newValue = [].concat(_toConsumableArray(value), [optionValue]);
757
+ setValue(_newValue);
758
+ if (shouldActivateSelectAll(_newValue)) {
759
+ setIsSelectAllActive(true);
760
+ }
761
+ }
762
+ }, [value, setValue, isSelectAllActive, setIsSelectAllActive, shouldActivateSelectAll]);
763
+ var onSelect = React.useCallback(function (option) {
432
764
  if (getOptionIsDisabled(option)) {
433
765
  return;
434
766
  }
@@ -436,38 +768,16 @@ export function useSuperSelect(_ref3) {
436
768
  var isSelectAll = getOptionIsOptSelectAll(option);
437
769
  if (isMultiple(multiple, value)) {
438
770
  if (isSelectAll) {
439
- var selectableOptions = options.filter(function (opt) {
440
- return isSelectableOption(opt);
441
- });
442
-
443
- // Check if all options are already selected to determine if this is a deselect operation
444
- var allOptionsSelected = selectableOptions.every(function (opt) {
445
- var getIsSelected = getOptionIsSelected !== null && getOptionIsSelected !== void 0 ? getOptionIsSelected : defaultGetOptionIsSelected;
446
- return getIsSelected(opt);
447
- });
448
- if (onSelectAll) {
449
- onSelectAll(selectableOptions);
450
- }
451
-
452
- // Only add options if not all are selected (i.e., this is a select operation)
453
- // If all options are selected, this is a deselect operation and we should clear
454
- if (allOptionsSelected) {
455
- setValue([]);
456
- } else {
457
- var optionValues = selectableOptions.flatMap(getOptionValue);
458
- setValue(uniq([].concat(_toConsumableArray(value), _toConsumableArray(optionValues))));
459
- }
771
+ handleSelectAllToggle();
460
772
  } else if (Array.isArray(optionValue)) {
461
- setValue(uniq([].concat(_toConsumableArray(value), _toConsumableArray(optionValue))));
773
+ handleBatchOptionSelection(optionValue);
462
774
  } else {
463
- setValue(value.includes(optionValue) ? value.filter(function (val) {
464
- return val !== optionValue;
465
- }) : [].concat(_toConsumableArray(value), [optionValue]));
775
+ handleSingleOptionSelection(optionValue);
466
776
  }
467
777
  } else {
468
778
  setValue(optionValue);
469
779
  }
470
- }
780
+ }, [getOptionIsDisabled, getOptionValue, getOptionIsOptSelectAll, multiple, value, handleSelectAllToggle, handleBatchOptionSelection, handleSingleOptionSelection, setValue]);
471
781
  function onKeyboardSelect() {
472
782
  if (activeMenuIndex !== null) {
473
783
  // Select All must be included in the list for keyboard navigation to work properly.
@@ -686,6 +996,10 @@ export function useSuperSelect(_ref3) {
686
996
  setValue(value.filter(function (_, i) {
687
997
  return i !== index;
688
998
  }));
999
+ // Deactivate Select All if removing individual tokens while active
1000
+ if (isSelectAllActive) {
1001
+ setIsSelectAllActive(false);
1002
+ }
689
1003
  }
690
1004
  }
691
1005
  };
@@ -739,6 +1053,7 @@ export function useSuperSelect(_ref3) {
739
1053
  // prevent the menu from closing
740
1054
  e.stopPropagation();
741
1055
  setActiveTokenIndex(null);
1056
+ setIsSelectAllActive(false); // Reset Select All state when clearing
742
1057
  setValue(multiple ? [] : null);
743
1058
  setOpen(true);
744
1059
  }
@@ -948,10 +1263,10 @@ export function useSuperSelect(_ref3) {
948
1263
  value: getOptionValue,
949
1264
  selectAll: {
950
1265
  isSelectAllPartiallySelected: function isSelectAllPartiallySelected(options) {
951
- return defaultGetOptionIsSelectAllPartiallySelected(options.filter(isSelectableOption), getOptionIsSelected !== null && getOptionIsSelected !== void 0 ? getOptionIsSelected : defaultGetOptionIsSelected, getOptionIsPartiallySelected !== null && getOptionIsPartiallySelected !== void 0 ? getOptionIsPartiallySelected : defaultGetOptionIsPartiallySelected);
1266
+ return defaultGetOptionIsSelectAllPartiallySelected(options, getOptionIsSelected !== null && getOptionIsSelected !== void 0 ? getOptionIsSelected : defaultGetOptionIsSelected, getOptionIsPartiallySelected !== null && getOptionIsPartiallySelected !== void 0 ? getOptionIsPartiallySelected : defaultGetOptionIsPartiallySelected);
952
1267
  },
953
1268
  isSelectAllSelected: function isSelectAllSelected(options) {
954
- return defaultGetOptionIsSelectAllSelected(options.filter(isSelectableOption), getOptionIsSelected !== null && getOptionIsSelected !== void 0 ? getOptionIsSelected : defaultGetOptionIsSelected);
1269
+ return defaultGetOptionIsSelectAllSelected(options, getOptionIsSelected !== null && getOptionIsSelected !== void 0 ? getOptionIsSelected : defaultGetOptionIsSelected);
955
1270
  }
956
1271
  }
957
1272
  },