@servicetitan/anvil2 3.0.5 → 3.0.6

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 (210) hide show
  1. package/CHANGELOG.md +18 -0
  2. package/dist/{AiMark-DjOf60tj.js → AiMark-BXL0sWIV.js} +2 -2
  3. package/dist/{AiMark-DjOf60tj.js.map → AiMark-BXL0sWIV.js.map} +1 -1
  4. package/dist/AiMark.js +1 -1
  5. package/dist/{Alert-BTesdKK7.js → Alert-BNH0UD2s.js} +2 -2
  6. package/dist/{Alert-BTesdKK7.js.map → Alert-BNH0UD2s.js.map} +1 -1
  7. package/dist/Alert.js +1 -1
  8. package/dist/{Breadcrumbs-DTi5RqT-.js → Breadcrumbs-Bzxbdu-S.js} +2 -2
  9. package/dist/{Breadcrumbs-DTi5RqT-.js.map → Breadcrumbs-Bzxbdu-S.js.map} +1 -1
  10. package/dist/Breadcrumbs.js +1 -1
  11. package/dist/{Calendar-ddGQKSGU.js → Calendar-BYNFAWpZ.js} +2 -2
  12. package/dist/{Calendar-ddGQKSGU.js.map → Calendar-BYNFAWpZ.js.map} +1 -1
  13. package/dist/{Calendar-CpCRxcue.js → Calendar-DS5eWpGF.js} +2 -2
  14. package/dist/{Calendar-CpCRxcue.js.map → Calendar-DS5eWpGF.js.map} +1 -1
  15. package/dist/Calendar.js +2 -2
  16. package/dist/{Checkbox-CJ8eYejR.js → Checkbox-BB3BDJsK.js} +4 -4
  17. package/dist/{Checkbox-CJ8eYejR.js.map → Checkbox-BB3BDJsK.js.map} +1 -1
  18. package/dist/{Checkbox-CVidv1sO.js → Checkbox-BeIzx_ZX.js} +2 -2
  19. package/dist/{Checkbox-CVidv1sO.js.map → Checkbox-BeIzx_ZX.js.map} +1 -1
  20. package/dist/Checkbox.css +40 -37
  21. package/dist/Checkbox.js +1 -1
  22. package/dist/Checkbox.module-CURNX27M.js +28 -0
  23. package/dist/Checkbox.module-CURNX27M.js.map +1 -0
  24. package/dist/{Chip-0-Yx9SGX.js → Chip-D2k5X_wX.js} +2 -2
  25. package/dist/{Chip-0-Yx9SGX.js.map → Chip-D2k5X_wX.js.map} +1 -1
  26. package/dist/Chip.js +1 -1
  27. package/dist/{Combobox-BXQFOwX4.js → Combobox-Cp7M4-4r.js} +5 -5
  28. package/dist/{Combobox-BXQFOwX4.js.map → Combobox-Cp7M4-4r.js.map} +1 -1
  29. package/dist/Combobox.js +1 -1
  30. package/dist/{DataTable-BFzj8cZG.js → DataTable-0kOuVgSB.js} +8 -8
  31. package/dist/{DataTable-BFzj8cZG.js.map → DataTable-0kOuVgSB.js.map} +1 -1
  32. package/dist/{DateFieldRange-CO2C776E.js → DateFieldRange-Be_I9GTp.js} +4 -4
  33. package/dist/{DateFieldRange-CO2C776E.js.map → DateFieldRange-Be_I9GTp.js.map} +1 -1
  34. package/dist/DateFieldRange.js +1 -1
  35. package/dist/{DateFieldSingle-DjmHpn1y.js → DateFieldSingle-CsrsY9i8.js} +4 -4
  36. package/dist/{DateFieldSingle-DjmHpn1y.js.map → DateFieldSingle-CsrsY9i8.js.map} +1 -1
  37. package/dist/DateFieldSingle.js +1 -1
  38. package/dist/{DateFieldYearless-CCJAopYd.js → DateFieldYearless-m_Hl2gMY.js} +5 -5
  39. package/dist/{DateFieldYearless-CCJAopYd.js.map → DateFieldYearless-m_Hl2gMY.js.map} +1 -1
  40. package/dist/DateFieldYearless.js +1 -1
  41. package/dist/{DateFieldYearlessRange-BUv1mGJg.js → DateFieldYearlessRange-DNqSTBDr.js} +4 -4
  42. package/dist/{DateFieldYearlessRange-BUv1mGJg.js.map → DateFieldYearlessRange-DNqSTBDr.js.map} +1 -1
  43. package/dist/DateFieldYearlessRange.js +1 -1
  44. package/dist/{DaysOfTheWeek-BihTU2No.js → DaysOfTheWeek-D58z_eF3.js} +10 -9
  45. package/dist/{DaysOfTheWeek-BihTU2No.js.map → DaysOfTheWeek-D58z_eF3.js.map} +1 -1
  46. package/dist/DaysOfTheWeek.css +10 -6
  47. package/dist/DaysOfTheWeek.js +1 -1
  48. package/dist/{Dialog-BZTo4hbX.js → Dialog-CD-SDfPT.js} +22 -20
  49. package/dist/{Dialog-BZTo4hbX.js.map → Dialog-CD-SDfPT.js.map} +1 -1
  50. package/dist/Dialog.css +43 -29
  51. package/dist/Dialog.js +1 -1
  52. package/dist/{Drawer-Dg35inxH.js → Drawer-s2y0xcgV.js} +3 -3
  53. package/dist/{Drawer-Dg35inxH.js.map → Drawer-s2y0xcgV.js.map} +1 -1
  54. package/dist/Drawer.js +1 -1
  55. package/dist/DrillDown.js +1 -1
  56. package/dist/{EditCard-BfNq-T8n.js → EditCard-B25pj0Jx.js} +2 -2
  57. package/dist/{EditCard-BfNq-T8n.js.map → EditCard-B25pj0Jx.js.map} +1 -1
  58. package/dist/EditCard.js +1 -1
  59. package/dist/{FieldLabel-xV6EdVwo.js → FieldLabel-D1qPAGtB.js} +3 -3
  60. package/dist/{FieldLabel-xV6EdVwo.js.map → FieldLabel-D1qPAGtB.js.map} +1 -1
  61. package/dist/FieldLabel.js +1 -1
  62. package/dist/{FilterBar-GjMlLOME.js → FilterBar-yysyZ-t1.js} +374 -19
  63. package/dist/FilterBar-yysyZ-t1.js.map +1 -0
  64. package/dist/FilterBar.js +1 -1
  65. package/dist/{InputMask-8rI6UIb8.js → InputMask-BDl09V4u.js} +3 -3
  66. package/dist/{InputMask-8rI6UIb8.js.map → InputMask-BDl09V4u.js.map} +1 -1
  67. package/dist/InputMask.js +1 -1
  68. package/dist/{ListView-CIa981KJ.js → ListView-CcRRh1ap.js} +2 -2
  69. package/dist/{ListView-CIa981KJ.js.map → ListView-CcRRh1ap.js.map} +1 -1
  70. package/dist/ListView.js +1 -1
  71. package/dist/{Listbox-DRznPBCr.js → Listbox-CvQHBFWb.js} +2 -2
  72. package/dist/{Listbox-DRznPBCr.js.map → Listbox-CvQHBFWb.js.map} +1 -1
  73. package/dist/Listbox.js +1 -1
  74. package/dist/MultiSelectField.js +1 -1
  75. package/dist/{MultiSelectFieldSync-BxyQiVPQ.js → MultiSelectFieldSync-BMVROOjy.js} +25 -25
  76. package/dist/{MultiSelectFieldSync-BxyQiVPQ.js.map → MultiSelectFieldSync-BMVROOjy.js.map} +1 -1
  77. package/dist/MultiSelectFieldSync.css +61 -57
  78. package/dist/MultiSelectMenu.js +1 -1
  79. package/dist/{MultiSelectMenuSync-BJfvZGf3.js → MultiSelectMenuSync-BNPp_2Bm.js} +4 -4
  80. package/dist/{MultiSelectMenuSync-BJfvZGf3.js.map → MultiSelectMenuSync-BNPp_2Bm.js.map} +1 -1
  81. package/dist/{NumberField-D7YYo4Rl.js → NumberField-BymFZhIJ.js} +4 -4
  82. package/dist/{NumberField-D7YYo4Rl.js.map → NumberField-BymFZhIJ.js.map} +1 -1
  83. package/dist/NumberField.js +1 -1
  84. package/dist/{Page-cELP59Hm.js → Page-SBy27-Wv.js} +8 -8
  85. package/dist/{Page-cELP59Hm.js.map → Page-SBy27-Wv.js.map} +1 -1
  86. package/dist/Page.js +1 -1
  87. package/dist/{Pagination-DTN4FovY.js → Pagination-Cm8-K6VH.js} +2 -2
  88. package/dist/{Pagination-DTN4FovY.js.map → Pagination-Cm8-K6VH.js.map} +1 -1
  89. package/dist/Pagination.js +1 -1
  90. package/dist/{Popover-B3Vw4lDW.js → Popover-8mTJoMy7.js} +2 -2
  91. package/dist/{Popover-B3Vw4lDW.js.map → Popover-8mTJoMy7.js.map} +1 -1
  92. package/dist/Popover.js +1 -1
  93. package/dist/{ProgressBar-kzCNhaCO.js → ProgressBar-C1CkQHV5.js} +2 -2
  94. package/dist/{ProgressBar-kzCNhaCO.js.map → ProgressBar-C1CkQHV5.js.map} +1 -1
  95. package/dist/ProgressBar.js +1 -1
  96. package/dist/{Radio-CSBetBV6.js → Radio-BcHMk8dD.js} +2 -2
  97. package/dist/{Radio-CSBetBV6.js.map → Radio-BcHMk8dD.js.map} +1 -1
  98. package/dist/{Radio-BDE1xGel.js → Radio-D5WyQN2i.js} +16 -16
  99. package/dist/{Radio-BDE1xGel.js.map → Radio-D5WyQN2i.js.map} +1 -1
  100. package/dist/Radio.css +40 -37
  101. package/dist/Radio.js +1 -1
  102. package/dist/{RichTextEditor-BFFXj0zS.js → RichTextEditor-DstVbYch.js} +8 -8
  103. package/dist/{RichTextEditor-BFFXj0zS.js.map → RichTextEditor-DstVbYch.js.map} +1 -1
  104. package/dist/RichTextEditor.js +1 -1
  105. package/dist/{SearchField-Dl7sh_M4.js → SearchField-3tUPU8hH.js} +2 -2
  106. package/dist/{SearchField-Dl7sh_M4.js.map → SearchField-3tUPU8hH.js.map} +1 -1
  107. package/dist/{SearchField-CO9BHCYB.js → SearchField-BcQZ5e0x.js} +2 -2
  108. package/dist/{SearchField-CO9BHCYB.js.map → SearchField-BcQZ5e0x.js.map} +1 -1
  109. package/dist/SearchField.js +1 -1
  110. package/dist/{SelectCard-CLCLIBoq.js → SelectCard-BN-LI14f.js} +3 -3
  111. package/dist/{SelectCard-CLCLIBoq.js.map → SelectCard-BN-LI14f.js.map} +1 -1
  112. package/dist/SelectCard.js +1 -1
  113. package/dist/SelectField.js +1 -1
  114. package/dist/{SelectFieldLabel-Db9w6O6r.js → SelectFieldLabel-UbQT7fDD.js} +2 -2
  115. package/dist/{SelectFieldLabel-Db9w6O6r.js.map → SelectFieldLabel-UbQT7fDD.js.map} +1 -1
  116. package/dist/{SelectFieldSync-z8b41JZz.js → SelectFieldSync-BeDYbJ2M.js} +6 -6
  117. package/dist/SelectFieldSync-BeDYbJ2M.js.map +1 -0
  118. package/dist/SelectMenu.js +1 -1
  119. package/dist/{SelectMenuSync-Cf1Zradm.js → SelectMenuSync-C-PFemsQ.js} +4 -4
  120. package/dist/{SelectMenuSync-Cf1Zradm.js.map → SelectMenuSync-C-PFemsQ.js.map} +1 -1
  121. package/dist/{SelectOptions-BgT1V6qp.js → SelectOptions-Tr11Ckqw.js} +2 -2
  122. package/dist/{SelectOptions-BgT1V6qp.js.map → SelectOptions-Tr11Ckqw.js.map} +1 -1
  123. package/dist/{SelectTrigger-37HzF-VI.js → SelectTrigger-DTz7V-Xx.js} +2 -2
  124. package/dist/{SelectTrigger-37HzF-VI.js.map → SelectTrigger-DTz7V-Xx.js.map} +1 -1
  125. package/dist/SelectTrigger.js +1 -1
  126. package/dist/{SelectTriggerBase-4o1cqEbR.js → SelectTriggerBase-Ds6I7Qbr.js} +4 -4
  127. package/dist/{SelectTriggerBase-4o1cqEbR.js.map → SelectTriggerBase-Ds6I7Qbr.js.map} +1 -1
  128. package/dist/SelectTriggerBase.css +46 -42
  129. package/dist/SelectTriggerBase.module-DsPvTQE7.js +37 -0
  130. package/dist/SelectTriggerBase.module-DsPvTQE7.js.map +1 -0
  131. package/dist/{Switch-p4yVJTNy.js → Switch-onmiKoRd.js} +2 -2
  132. package/dist/{Switch-p4yVJTNy.js.map → Switch-onmiKoRd.js.map} +1 -1
  133. package/dist/Switch.js +1 -1
  134. package/dist/Table.js +1 -1
  135. package/dist/{Text-BgPuOXJM.js → Text-BTzgTpqu.js} +2 -2
  136. package/dist/{Text-BgPuOXJM.js.map → Text-BTzgTpqu.js.map} +1 -1
  137. package/dist/Text.js +1 -1
  138. package/dist/{TextField-DzuM8vvd.js → TextField-WTYZJlX3.js} +2 -2
  139. package/dist/{TextField-DzuM8vvd.js.map → TextField-WTYZJlX3.js.map} +1 -1
  140. package/dist/{TextField-D7NyaKId.js → TextField-rVfctM1E.js} +4 -4
  141. package/dist/{TextField-D7NyaKId.js.map → TextField-rVfctM1E.js.map} +1 -1
  142. package/dist/TextField.css +22 -58
  143. package/dist/TextField.js +1 -1
  144. package/dist/TextField.module-C8FsjTpx.js +23 -0
  145. package/dist/TextField.module-C8FsjTpx.js.map +1 -0
  146. package/dist/{Textarea-Dks15Zt3.js → Textarea-PXjppEQ6.js} +3 -3
  147. package/dist/{Textarea-Dks15Zt3.js.map → Textarea-PXjppEQ6.js.map} +1 -1
  148. package/dist/Textarea.js +1 -1
  149. package/dist/{TimeField-lN_5V6-X.js → TimeField-BJPXIv6W.js} +4 -4
  150. package/dist/{TimeField-lN_5V6-X.js.map → TimeField-BJPXIv6W.js.map} +1 -1
  151. package/dist/TimeField.js +1 -1
  152. package/dist/Toast.js +2 -2
  153. package/dist/{Toaster-3GI_qJxj.js → Toaster-CoChsMD0.js} +3 -3
  154. package/dist/{Toaster-3GI_qJxj.js.map → Toaster-CoChsMD0.js.map} +1 -1
  155. package/dist/{Toaster-2pAMQXRk.js → Toaster-DXLc86VD.js} +2 -2
  156. package/dist/{Toaster-2pAMQXRk.js.map → Toaster-DXLc86VD.js.map} +1 -1
  157. package/dist/{Toolbar-B0WHsX9W.js → Toolbar-BUd9eNkq.js} +6 -6
  158. package/dist/{Toolbar-B0WHsX9W.js.map → Toolbar-BUd9eNkq.js.map} +1 -1
  159. package/dist/{Toolbar-BRQpvj9U.js → Toolbar-Bt3kShho.js} +4 -4
  160. package/dist/{Toolbar-BRQpvj9U.js.map → Toolbar-Bt3kShho.js.map} +1 -1
  161. package/dist/Toolbar.js +2 -2
  162. package/dist/{ToolbarButtonToggle-xvMWRxzC.js → ToolbarButtonToggle-C06cqJ6F.js} +2 -2
  163. package/dist/{ToolbarButtonToggle-xvMWRxzC.js.map → ToolbarButtonToggle-C06cqJ6F.js.map} +1 -1
  164. package/dist/{Tooltip-DGo3OWqL.js → Tooltip-yr1D06BE.js} +5 -5
  165. package/dist/{Tooltip-DGo3OWqL.js.map → Tooltip-yr1D06BE.js.map} +1 -1
  166. package/dist/Tooltip.css +6 -7
  167. package/dist/Tooltip.js +1 -1
  168. package/dist/{YearlessDateInputWithPicker-BhbR5F22.js → YearlessDateInputWithPicker-BIcVgz-J.js} +3 -3
  169. package/dist/{YearlessDateInputWithPicker-BhbR5F22.js.map → YearlessDateInputWithPicker-BIcVgz-J.js.map} +1 -1
  170. package/dist/assets/icons/st/batch.svg +1 -1
  171. package/dist/assets/icons/st/call.svg +1 -1
  172. package/dist/assets/icons/st/customer.svg +1 -1
  173. package/dist/assets/icons/st/enterprise_hub.svg +1 -1
  174. package/dist/assets/icons/st/equipment.svg +1 -1
  175. package/dist/assets/icons/st/estimate.svg +1 -1
  176. package/dist/assets/icons/st/full_fluid.svg +1 -1
  177. package/dist/assets/icons/st/gnav_titan_advisor_active.svg +1 -1
  178. package/dist/assets/icons/st/gnav_titan_advisor_inactive.svg +1 -1
  179. package/dist/assets/icons/st/job.svg +1 -1
  180. package/dist/assets/icons/st/leads.svg +1 -1
  181. package/dist/assets/icons/st/proposal.svg +1 -1
  182. package/dist/assets/icons/st/roofing.svg +1 -1
  183. package/dist/beta.js +12 -12
  184. package/dist/{index-B6Demgr-.js → index-DVYRUKtW.js} +2 -2
  185. package/dist/{index-B6Demgr-.js.map → index-DVYRUKtW.js.map} +1 -1
  186. package/dist/index.js +38 -38
  187. package/dist/src/beta/components/FilterBar/FilterButton.d.ts +6 -3
  188. package/dist/src/beta/components/FilterBar/FilterDateList.d.ts +37 -0
  189. package/dist/src/beta/components/FilterBar/index.d.ts +1 -1
  190. package/dist/src/beta/components/FilterBar/internal/types.d.ts +40 -2
  191. package/dist/src/beta/components/FilterBar/internal/utils/dateListLibraryOptions.d.ts +29 -0
  192. package/dist/src/beta/components/FilterBar/internal/utils/filter-state.d.ts +2 -0
  193. package/dist/src/beta/components/FilterBar/internal/utils/test.d.ts +2 -1
  194. package/dist/{stripInlineMarkdown-D_eHogvh.js → stripInlineMarkdown-C5DNxxwf.js} +2 -2
  195. package/dist/{stripInlineMarkdown-D_eHogvh.js.map → stripInlineMarkdown-C5DNxxwf.js.map} +1 -1
  196. package/dist/{syncFilterUtils-Dpp7gt05.js → syncFilterUtils-COxBIkt6.js} +357 -357
  197. package/dist/{syncFilterUtils-Dpp7gt05.js.map → syncFilterUtils-COxBIkt6.js.map} +1 -1
  198. package/dist/{useDrilldown-bIRsbg1m.js → useDrilldown-KZ9rRsXQ.js} +2 -2
  199. package/dist/{useDrilldown-bIRsbg1m.js.map → useDrilldown-KZ9rRsXQ.js.map} +1 -1
  200. package/dist/{useToggleSelection-DBqr4HwT.js → useToggleSelection-B5PnTuT2.js} +2 -2
  201. package/dist/{useToggleSelection-DBqr4HwT.js.map → useToggleSelection-B5PnTuT2.js.map} +1 -1
  202. package/package.json +3 -3
  203. package/dist/Checkbox.module-DVbXNsaN.js +0 -28
  204. package/dist/Checkbox.module-DVbXNsaN.js.map +0 -1
  205. package/dist/FilterBar-GjMlLOME.js.map +0 -1
  206. package/dist/SelectFieldSync-z8b41JZz.js.map +0 -1
  207. package/dist/SelectTriggerBase.module-BgZSNZfE.js +0 -37
  208. package/dist/SelectTriggerBase.module-BgZSNZfE.js.map +0 -1
  209. package/dist/TextField.module-DkZwywjf.js +0 -23
  210. package/dist/TextField.module-DkZwywjf.js.map +0 -1
@@ -4,14 +4,14 @@ import { B as Button } from './Button-C_V2xQAs.js';
4
4
  import { c as cx } from './index-De1g9FRV.js';
5
5
  import { useState, useRef, useCallback, useEffect, useMemo, forwardRef, useId, useImperativeHandle } from 'react';
6
6
  import { u as useIntersectionObserver } from './useIntersectionObserver-BEmMDO3P.js';
7
- import { T as Text } from './Text-BgPuOXJM.js';
7
+ import { T as Text } from './Text-BTzgTpqu.js';
8
8
  import { D as Divider } from './Divider-CxtTyw8_.js';
9
9
  import { u as useMergeRefs } from './useMergeRefs-Dfmtq9cI.js';
10
10
  import { S as SrOnly } from './SrOnly-pnf8ajnh.js';
11
11
  import { F as Flex } from './Flex-_orhvoxS.js';
12
12
  import { I as Icon } from './Icon-feeG7gXA.js';
13
13
  import { A as Avatar } from './Avatar-B_cRQqKR.js';
14
- import { C as Chip } from './Chip-0-Yx9SGX.js';
14
+ import { C as Chip } from './Chip-D2k5X_wX.js';
15
15
  import { S as SvgCheckBox, a as SvgCheckBoxOutlineBlank } from './check_box-0U1tbEAd.js';
16
16
  import { S as SvgIndeterminateCheckBox } from './indeterminate_check_box-jjLG4UY6.js';
17
17
  import { S as SvgCheck } from './check-Cf67OWrZ.js';
@@ -903,6 +903,278 @@ function useDebouncedCallback(callback, delay = 300) {
903
903
  return debouncedCallback;
904
904
  }
905
905
 
906
+ const DEFAULT_CACHE_SIZE = 15;
907
+ const STATIC_CACHE_KEY = "__static__";
908
+ function cacheSet(sectionCache, key, value, maxSize) {
909
+ if (sectionCache.has(key)) {
910
+ sectionCache.delete(key);
911
+ }
912
+ sectionCache.set(key, value);
913
+ while (sectionCache.size > maxSize) {
914
+ const oldest = sectionCache.keys().next().value;
915
+ if (oldest !== void 0) {
916
+ sectionCache.delete(oldest);
917
+ }
918
+ }
919
+ }
920
+ function usePinnedOptions(pinned, searchValue) {
921
+ const [dynamicResults, setDynamicResults] = useState({});
922
+ const [loadingSet, setLoadingSet] = useState(/* @__PURE__ */ new Set());
923
+ const latestSearchValueRef = useRef(searchValue);
924
+ latestSearchValueRef.current = searchValue;
925
+ const cacheRef = useRef(
926
+ /* @__PURE__ */ new Map()
927
+ );
928
+ const nonReactiveTriggeredRef = useRef(/* @__PURE__ */ new Set());
929
+ const sections = useMemo(() => {
930
+ if (!pinned) return [];
931
+ return Array.isArray(pinned) ? pinned : [pinned];
932
+ }, [pinned]);
933
+ const sectionConfig = useMemo(() => {
934
+ return sections.map((section) => {
935
+ const isDynamic = typeof section.options === "function";
936
+ return {
937
+ label: section.label,
938
+ isDynamic,
939
+ searchReactive: section.searchReactive ?? true,
940
+ cacheSize: section.cacheSize ?? DEFAULT_CACHE_SIZE,
941
+ staticOptions: isDynamic ? void 0 : section.options,
942
+ loader: isDynamic ? section.options : void 0
943
+ };
944
+ });
945
+ }, [sections]);
946
+ useEffect(() => {
947
+ cacheRef.current = /* @__PURE__ */ new Map();
948
+ nonReactiveTriggeredRef.current = /* @__PURE__ */ new Set();
949
+ }, [sectionConfig]);
950
+ const getSectionCache = useCallback(
951
+ (index) => {
952
+ let sectionCache = cacheRef.current.get(index);
953
+ if (!sectionCache) {
954
+ sectionCache = /* @__PURE__ */ new Map();
955
+ cacheRef.current.set(index, sectionCache);
956
+ }
957
+ return sectionCache;
958
+ },
959
+ []
960
+ );
961
+ const loadSection = useCallback(
962
+ (config, index, loaderArg) => {
963
+ const cacheKey = config.searchReactive ? loaderArg : STATIC_CACHE_KEY;
964
+ const handleResult = (options) => {
965
+ if (!config.searchReactive || latestSearchValueRef.current === loaderArg) {
966
+ const sectionCache = getSectionCache(index);
967
+ cacheSet(sectionCache, cacheKey, options, config.cacheSize);
968
+ setDynamicResults((prev) => ({ ...prev, [index]: options }));
969
+ setLoadingSet((prev) => {
970
+ const next = new Set(prev);
971
+ next.delete(index);
972
+ return next;
973
+ });
974
+ }
975
+ };
976
+ const handleError = (error) => {
977
+ console.error("Failed to load pinned options:", error);
978
+ if (!config.searchReactive || latestSearchValueRef.current === loaderArg) {
979
+ setDynamicResults((prev) => ({ ...prev, [index]: [] }));
980
+ setLoadingSet((prev) => {
981
+ const next = new Set(prev);
982
+ next.delete(index);
983
+ return next;
984
+ });
985
+ }
986
+ };
987
+ try {
988
+ Promise.resolve(config.loader(loaderArg)).then(handleResult).catch(handleError);
989
+ } catch (error) {
990
+ handleError(error);
991
+ }
992
+ },
993
+ [getSectionCache]
994
+ );
995
+ useEffect(() => {
996
+ const dynamicEntries = sectionConfig.map((config, index) => ({ config, index })).filter(({ config }) => config.isDynamic);
997
+ if (dynamicEntries.length === 0) return;
998
+ const toLoad = [];
999
+ const preResolved = {};
1000
+ dynamicEntries.forEach(({ config, index }) => {
1001
+ const sectionCache = getSectionCache(index);
1002
+ if (config.searchReactive) {
1003
+ const cached = sectionCache.get(searchValue);
1004
+ if (cached) {
1005
+ preResolved[index] = cached;
1006
+ } else {
1007
+ toLoad.push({ config, index });
1008
+ }
1009
+ } else {
1010
+ const cached = sectionCache.get(STATIC_CACHE_KEY);
1011
+ if (cached) {
1012
+ preResolved[index] = cached;
1013
+ } else if (!nonReactiveTriggeredRef.current.has(index)) {
1014
+ nonReactiveTriggeredRef.current.add(index);
1015
+ toLoad.push({ config, index });
1016
+ }
1017
+ }
1018
+ });
1019
+ if (toLoad.length === 0) {
1020
+ setDynamicResults(preResolved);
1021
+ setLoadingSet(/* @__PURE__ */ new Set());
1022
+ return;
1023
+ }
1024
+ const loadingIndices = toLoad.map(({ index }) => index);
1025
+ setDynamicResults(preResolved);
1026
+ setLoadingSet(new Set(loadingIndices));
1027
+ toLoad.forEach(({ config, index }) => {
1028
+ const loaderArg = config.searchReactive ? searchValue : "";
1029
+ loadSection(config, index, loaderArg);
1030
+ });
1031
+ }, [sectionConfig, searchValue, loadSection, getSectionCache]);
1032
+ const pinnedSections = useMemo(() => {
1033
+ return sectionConfig.map((config, index) => {
1034
+ if (!config.isDynamic) {
1035
+ return { label: config.label, options: config.staticOptions };
1036
+ }
1037
+ if (!loadingSet.has(index) && index in dynamicResults) {
1038
+ return {
1039
+ label: config.label,
1040
+ options: dynamicResults[index]
1041
+ };
1042
+ }
1043
+ return { label: config.label, options: [], loading: true };
1044
+ });
1045
+ }, [sectionConfig, dynamicResults, loadingSet]);
1046
+ return { pinnedSections };
1047
+ }
1048
+
1049
+ function useGroupedOptions(options, groupToString) {
1050
+ return useMemo(() => {
1051
+ const groupedItems = [];
1052
+ const ungroupedItems = [];
1053
+ const groupSections = [];
1054
+ const groupMap = /* @__PURE__ */ new Map();
1055
+ options.forEach((option) => {
1056
+ if (option.group !== void 0) {
1057
+ const groupValue = option.group;
1058
+ if (!groupMap.has(groupValue)) {
1059
+ const label = groupToString ? groupToString(groupValue) : String(groupValue);
1060
+ groupMap.set(groupValue, { label, options: [] });
1061
+ }
1062
+ groupMap.get(groupValue).options.push(option);
1063
+ groupedItems.push({
1064
+ id: option.id,
1065
+ type: "grouped-option",
1066
+ original: option,
1067
+ disabled: option.disabled ?? false
1068
+ });
1069
+ } else {
1070
+ ungroupedItems.push({
1071
+ id: option.id,
1072
+ type: "option",
1073
+ original: option,
1074
+ disabled: option.disabled ?? false
1075
+ });
1076
+ }
1077
+ });
1078
+ groupMap.forEach(({ label, options: groupOptions }) => {
1079
+ groupSections.push({ label, options: groupOptions });
1080
+ });
1081
+ return { groupedItems, ungroupedItems, groupSections };
1082
+ }, [options, groupToString]);
1083
+ }
1084
+ function sortGroupSections(sections, groupSorter) {
1085
+ return [...sections].sort((a, b) => {
1086
+ const groupA = a.options[0]?.group;
1087
+ const groupB = b.options[0]?.group;
1088
+ if (groupA === void 0 || groupB === void 0) return 0;
1089
+ return groupSorter(groupA, groupB);
1090
+ });
1091
+ }
1092
+
1093
+ const useProcessedOptions = ({
1094
+ options,
1095
+ pinned,
1096
+ searchValue,
1097
+ groupToString,
1098
+ groupSorter
1099
+ }) => {
1100
+ const { pinnedSections } = usePinnedOptions(pinned, searchValue);
1101
+ const { ungroupedItems, groupSections: rawGroupSections } = useGroupedOptions(
1102
+ options,
1103
+ groupToString
1104
+ );
1105
+ const groupSections = useMemo(() => {
1106
+ if (groupSorter && rawGroupSections.length > 0) {
1107
+ return sortGroupSections(rawGroupSections, groupSorter);
1108
+ }
1109
+ return rawGroupSections;
1110
+ }, [rawGroupSections, groupSorter]);
1111
+ return { pinnedSections, ungroupedItems, groupSections };
1112
+ };
1113
+
1114
+ function toSelectItem(option) {
1115
+ return {
1116
+ id: option.id,
1117
+ type: "option",
1118
+ disabled: option.disabled ?? false,
1119
+ original: option
1120
+ };
1121
+ }
1122
+ function buildSelectItems({
1123
+ prefixItems,
1124
+ pinnedSections,
1125
+ groupSections,
1126
+ ungroupedItems
1127
+ }) {
1128
+ const items = [];
1129
+ const meta = [];
1130
+ if (prefixItems) {
1131
+ items.push(...prefixItems);
1132
+ }
1133
+ pinnedSections.forEach((section) => {
1134
+ const startIndex = items.length;
1135
+ section.options.forEach((option) => {
1136
+ items.push({
1137
+ id: option.id + "-pinned",
1138
+ type: "pinned-option",
1139
+ original: option,
1140
+ disabled: option.disabled ?? false
1141
+ });
1142
+ });
1143
+ const endIndex = items.length;
1144
+ if (endIndex > startIndex || section.loading) {
1145
+ meta.push({
1146
+ type: "pinned",
1147
+ label: section.label,
1148
+ startIndex,
1149
+ endIndex,
1150
+ loading: section.loading
1151
+ });
1152
+ }
1153
+ });
1154
+ groupSections.forEach((section) => {
1155
+ const startIndex = items.length;
1156
+ section.options.forEach((option) => {
1157
+ items.push({
1158
+ id: option.id,
1159
+ type: "grouped-option",
1160
+ original: option,
1161
+ disabled: option.disabled ?? false
1162
+ });
1163
+ });
1164
+ const endIndex = items.length;
1165
+ if (endIndex > startIndex) {
1166
+ meta.push({
1167
+ type: "group",
1168
+ label: section.label,
1169
+ startIndex,
1170
+ endIndex
1171
+ });
1172
+ }
1173
+ });
1174
+ items.push(...ungroupedItems);
1175
+ return { items, sectionsMeta: meta };
1176
+ }
1177
+
906
1178
  const styles$1 = {
907
1179
  "options-popover": "_options-popover_1a8y0_2",
908
1180
  "options-popover-body": "_options-popover-body_1a8y0_39",
@@ -1068,369 +1340,97 @@ const OptionsDialog = ({
1068
1340
  (focusable) => focusable.dataset.anv !== "dialog-cancel-button"
1069
1341
  ) || focusables[0];
1070
1342
  },
1071
- [initialFocusResolver]
1072
- );
1073
- useEffect(() => {
1074
- if (isOpen) {
1075
- elRef.current?.showModal();
1076
- if (elRef.current) {
1077
- computeFocus(tabbable(elRef.current)).focus();
1078
- }
1079
- } else {
1080
- elRef.current?.close();
1081
- }
1082
- }, [isOpen]);
1083
- useEffect(() => {
1084
- if (isOpen) {
1085
- const handleResize = () => {
1086
- if (!visualViewportHeightRef.current) return;
1087
- visualViewportHeightRef.current.style.height = `${window.visualViewport?.height ?? 0}px`;
1088
- visualViewportHeightRef.current.style.maxHeight = `${window.visualViewport?.height ?? 0}px`;
1089
- };
1090
- window.visualViewport?.addEventListener("resize", handleResize);
1091
- return () => {
1092
- window.visualViewport?.removeEventListener("resize", handleResize);
1093
- };
1094
- }
1095
- }, [isOpen]);
1096
- return /* @__PURE__ */ jsx(
1097
- "dialog",
1098
- {
1099
- ref: elRef,
1100
- id,
1101
- "data-anv": "field-dialog",
1102
- className: styles["field-dialog"],
1103
- onKeyDown: (e) => {
1104
- if (e.code === "Escape") {
1105
- e.preventDefault();
1106
- onClose();
1107
- }
1108
- },
1109
- children: /* @__PURE__ */ jsxs(
1110
- "div",
1111
- {
1112
- className: styles["field-dialog-visual-viewport-height"],
1113
- ref: visualViewportHeightRef,
1114
- children: [
1115
- /* @__PURE__ */ jsxs(Flex, { direction: "row", className: styles["header"], children: [
1116
- /* @__PURE__ */ jsx(Text, { variant: "headline", el: "h1", children: title }),
1117
- /* @__PURE__ */ jsx("span", { className: styles["close-container"], children: /* @__PURE__ */ jsx(DialogContext.Provider, { value: { close: onClose }, children: /* @__PURE__ */ jsx(
1118
- DialogCancelButton,
1119
- {
1120
- className: styles["close-button"],
1121
- size: "small",
1122
- appearance: "ghost",
1123
- "aria-label": "Close dialog",
1124
- icon: SvgClose
1125
- }
1126
- ) }) })
1127
- ] }),
1128
- field ? /* @__PURE__ */ jsx(Flex, { direction: "column", className: styles["field"], children: field }) : null,
1129
- /* @__PURE__ */ jsx(Flex, { direction: "column", className: styles["content"], children }),
1130
- footer ? /* @__PURE__ */ jsx("div", { className: styles["footer"], children: footer }) : null
1131
- ]
1132
- }
1133
- )
1134
- }
1135
- );
1136
- };
1137
-
1138
- const AddNewItemButton = ({
1139
- searchText,
1140
- addItemLabel,
1141
- onAddNewItem,
1142
- onCloseMenu
1143
- }) => {
1144
- if (!onAddNewItem) return null;
1145
- const resolvedLabel = typeof addItemLabel === "function" ? addItemLabel(searchText) : addItemLabel ?? "Add new item";
1146
- return /* @__PURE__ */ jsx(
1147
- Button,
1148
- {
1149
- appearance: "secondary",
1150
- size: "small",
1151
- icon: { before: SvgAdd },
1152
- onClick: () => {
1153
- onCloseMenu?.();
1154
- onAddNewItem(searchText);
1155
- },
1156
- style: { width: "100%" },
1157
- children: resolvedLabel
1158
- }
1159
- );
1160
- };
1161
- AddNewItemButton.displayName = "AddNewItemButton";
1162
-
1163
- const DEFAULT_CACHE_SIZE = 15;
1164
- const STATIC_CACHE_KEY = "__static__";
1165
- function cacheSet(sectionCache, key, value, maxSize) {
1166
- if (sectionCache.has(key)) {
1167
- sectionCache.delete(key);
1168
- }
1169
- sectionCache.set(key, value);
1170
- while (sectionCache.size > maxSize) {
1171
- const oldest = sectionCache.keys().next().value;
1172
- if (oldest !== void 0) {
1173
- sectionCache.delete(oldest);
1174
- }
1175
- }
1176
- }
1177
- function usePinnedOptions(pinned, searchValue) {
1178
- const [dynamicResults, setDynamicResults] = useState({});
1179
- const [loadingSet, setLoadingSet] = useState(/* @__PURE__ */ new Set());
1180
- const latestSearchValueRef = useRef(searchValue);
1181
- latestSearchValueRef.current = searchValue;
1182
- const cacheRef = useRef(
1183
- /* @__PURE__ */ new Map()
1184
- );
1185
- const nonReactiveTriggeredRef = useRef(/* @__PURE__ */ new Set());
1186
- const sections = useMemo(() => {
1187
- if (!pinned) return [];
1188
- return Array.isArray(pinned) ? pinned : [pinned];
1189
- }, [pinned]);
1190
- const sectionConfig = useMemo(() => {
1191
- return sections.map((section) => {
1192
- const isDynamic = typeof section.options === "function";
1193
- return {
1194
- label: section.label,
1195
- isDynamic,
1196
- searchReactive: section.searchReactive ?? true,
1197
- cacheSize: section.cacheSize ?? DEFAULT_CACHE_SIZE,
1198
- staticOptions: isDynamic ? void 0 : section.options,
1199
- loader: isDynamic ? section.options : void 0
1200
- };
1201
- });
1202
- }, [sections]);
1203
- useEffect(() => {
1204
- cacheRef.current = /* @__PURE__ */ new Map();
1205
- nonReactiveTriggeredRef.current = /* @__PURE__ */ new Set();
1206
- }, [sectionConfig]);
1207
- const getSectionCache = useCallback(
1208
- (index) => {
1209
- let sectionCache = cacheRef.current.get(index);
1210
- if (!sectionCache) {
1211
- sectionCache = /* @__PURE__ */ new Map();
1212
- cacheRef.current.set(index, sectionCache);
1213
- }
1214
- return sectionCache;
1215
- },
1216
- []
1217
- );
1218
- const loadSection = useCallback(
1219
- (config, index, loaderArg) => {
1220
- const cacheKey = config.searchReactive ? loaderArg : STATIC_CACHE_KEY;
1221
- const handleResult = (options) => {
1222
- if (!config.searchReactive || latestSearchValueRef.current === loaderArg) {
1223
- const sectionCache = getSectionCache(index);
1224
- cacheSet(sectionCache, cacheKey, options, config.cacheSize);
1225
- setDynamicResults((prev) => ({ ...prev, [index]: options }));
1226
- setLoadingSet((prev) => {
1227
- const next = new Set(prev);
1228
- next.delete(index);
1229
- return next;
1230
- });
1231
- }
1232
- };
1233
- const handleError = (error) => {
1234
- console.error("Failed to load pinned options:", error);
1235
- if (!config.searchReactive || latestSearchValueRef.current === loaderArg) {
1236
- setDynamicResults((prev) => ({ ...prev, [index]: [] }));
1237
- setLoadingSet((prev) => {
1238
- const next = new Set(prev);
1239
- next.delete(index);
1240
- return next;
1241
- });
1242
- }
1243
- };
1244
- try {
1245
- Promise.resolve(config.loader(loaderArg)).then(handleResult).catch(handleError);
1246
- } catch (error) {
1247
- handleError(error);
1248
- }
1249
- },
1250
- [getSectionCache]
1343
+ [initialFocusResolver]
1251
1344
  );
1252
1345
  useEffect(() => {
1253
- const dynamicEntries = sectionConfig.map((config, index) => ({ config, index })).filter(({ config }) => config.isDynamic);
1254
- if (dynamicEntries.length === 0) return;
1255
- const toLoad = [];
1256
- const preResolved = {};
1257
- dynamicEntries.forEach(({ config, index }) => {
1258
- const sectionCache = getSectionCache(index);
1259
- if (config.searchReactive) {
1260
- const cached = sectionCache.get(searchValue);
1261
- if (cached) {
1262
- preResolved[index] = cached;
1263
- } else {
1264
- toLoad.push({ config, index });
1265
- }
1266
- } else {
1267
- const cached = sectionCache.get(STATIC_CACHE_KEY);
1268
- if (cached) {
1269
- preResolved[index] = cached;
1270
- } else if (!nonReactiveTriggeredRef.current.has(index)) {
1271
- nonReactiveTriggeredRef.current.add(index);
1272
- toLoad.push({ config, index });
1273
- }
1346
+ if (isOpen) {
1347
+ elRef.current?.showModal();
1348
+ if (elRef.current) {
1349
+ computeFocus(tabbable(elRef.current)).focus();
1274
1350
  }
1275
- });
1276
- if (toLoad.length === 0) {
1277
- setDynamicResults(preResolved);
1278
- setLoadingSet(/* @__PURE__ */ new Set());
1279
- return;
1351
+ } else {
1352
+ elRef.current?.close();
1280
1353
  }
1281
- const loadingIndices = toLoad.map(({ index }) => index);
1282
- setDynamicResults(preResolved);
1283
- setLoadingSet(new Set(loadingIndices));
1284
- toLoad.forEach(({ config, index }) => {
1285
- const loaderArg = config.searchReactive ? searchValue : "";
1286
- loadSection(config, index, loaderArg);
1287
- });
1288
- }, [sectionConfig, searchValue, loadSection, getSectionCache]);
1289
- const pinnedSections = useMemo(() => {
1290
- return sectionConfig.map((config, index) => {
1291
- if (!config.isDynamic) {
1292
- return { label: config.label, options: config.staticOptions };
1293
- }
1294
- if (!loadingSet.has(index) && index in dynamicResults) {
1295
- return {
1296
- label: config.label,
1297
- options: dynamicResults[index]
1298
- };
1299
- }
1300
- return { label: config.label, options: [], loading: true };
1301
- });
1302
- }, [sectionConfig, dynamicResults, loadingSet]);
1303
- return { pinnedSections };
1304
- }
1305
-
1306
- function useGroupedOptions(options, groupToString) {
1307
- return useMemo(() => {
1308
- const groupedItems = [];
1309
- const ungroupedItems = [];
1310
- const groupSections = [];
1311
- const groupMap = /* @__PURE__ */ new Map();
1312
- options.forEach((option) => {
1313
- if (option.group !== void 0) {
1314
- const groupValue = option.group;
1315
- if (!groupMap.has(groupValue)) {
1316
- const label = groupToString ? groupToString(groupValue) : String(groupValue);
1317
- groupMap.set(groupValue, { label, options: [] });
1354
+ }, [isOpen]);
1355
+ useEffect(() => {
1356
+ if (isOpen) {
1357
+ const handleResize = () => {
1358
+ if (!visualViewportHeightRef.current) return;
1359
+ visualViewportHeightRef.current.style.height = `${window.visualViewport?.height ?? 0}px`;
1360
+ visualViewportHeightRef.current.style.maxHeight = `${window.visualViewport?.height ?? 0}px`;
1361
+ };
1362
+ window.visualViewport?.addEventListener("resize", handleResize);
1363
+ return () => {
1364
+ window.visualViewport?.removeEventListener("resize", handleResize);
1365
+ };
1366
+ }
1367
+ }, [isOpen]);
1368
+ return /* @__PURE__ */ jsx(
1369
+ "dialog",
1370
+ {
1371
+ ref: elRef,
1372
+ id,
1373
+ "data-anv": "field-dialog",
1374
+ className: styles["field-dialog"],
1375
+ onKeyDown: (e) => {
1376
+ if (e.code === "Escape") {
1377
+ e.preventDefault();
1378
+ onClose();
1318
1379
  }
1319
- groupMap.get(groupValue).options.push(option);
1320
- groupedItems.push({
1321
- id: option.id,
1322
- type: "grouped-option",
1323
- original: option,
1324
- disabled: option.disabled ?? false
1325
- });
1326
- } else {
1327
- ungroupedItems.push({
1328
- id: option.id,
1329
- type: "option",
1330
- original: option,
1331
- disabled: option.disabled ?? false
1332
- });
1333
- }
1334
- });
1335
- groupMap.forEach(({ label, options: groupOptions }) => {
1336
- groupSections.push({ label, options: groupOptions });
1337
- });
1338
- return { groupedItems, ungroupedItems, groupSections };
1339
- }, [options, groupToString]);
1340
- }
1341
- function sortGroupSections(sections, groupSorter) {
1342
- return [...sections].sort((a, b) => {
1343
- const groupA = a.options[0]?.group;
1344
- const groupB = b.options[0]?.group;
1345
- if (groupA === void 0 || groupB === void 0) return 0;
1346
- return groupSorter(groupA, groupB);
1347
- });
1348
- }
1349
-
1350
- const useProcessedOptions = ({
1351
- options,
1352
- pinned,
1353
- searchValue,
1354
- groupToString,
1355
- groupSorter
1356
- }) => {
1357
- const { pinnedSections } = usePinnedOptions(pinned, searchValue);
1358
- const { ungroupedItems, groupSections: rawGroupSections } = useGroupedOptions(
1359
- options,
1360
- groupToString
1361
- );
1362
- const groupSections = useMemo(() => {
1363
- if (groupSorter && rawGroupSections.length > 0) {
1364
- return sortGroupSections(rawGroupSections, groupSorter);
1380
+ },
1381
+ children: /* @__PURE__ */ jsxs(
1382
+ "div",
1383
+ {
1384
+ className: styles["field-dialog-visual-viewport-height"],
1385
+ ref: visualViewportHeightRef,
1386
+ children: [
1387
+ /* @__PURE__ */ jsxs(Flex, { direction: "row", className: styles["header"], children: [
1388
+ /* @__PURE__ */ jsx(Text, { variant: "headline", el: "h1", children: title }),
1389
+ /* @__PURE__ */ jsx("span", { className: styles["close-container"], children: /* @__PURE__ */ jsx(DialogContext.Provider, { value: { close: onClose }, children: /* @__PURE__ */ jsx(
1390
+ DialogCancelButton,
1391
+ {
1392
+ className: styles["close-button"],
1393
+ size: "small",
1394
+ appearance: "ghost",
1395
+ "aria-label": "Close dialog",
1396
+ icon: SvgClose
1397
+ }
1398
+ ) }) })
1399
+ ] }),
1400
+ field ? /* @__PURE__ */ jsx(Flex, { direction: "column", className: styles["field"], children: field }) : null,
1401
+ /* @__PURE__ */ jsx(Flex, { direction: "column", className: styles["content"], children }),
1402
+ footer ? /* @__PURE__ */ jsx("div", { className: styles["footer"], children: footer }) : null
1403
+ ]
1404
+ }
1405
+ )
1365
1406
  }
1366
- return rawGroupSections;
1367
- }, [rawGroupSections, groupSorter]);
1368
- return { pinnedSections, ungroupedItems, groupSections };
1407
+ );
1369
1408
  };
1370
1409
 
1371
- function toSelectItem(option) {
1372
- return {
1373
- id: option.id,
1374
- type: "option",
1375
- disabled: option.disabled ?? false,
1376
- original: option
1377
- };
1378
- }
1379
- function buildSelectItems({
1380
- prefixItems,
1381
- pinnedSections,
1382
- groupSections,
1383
- ungroupedItems
1384
- }) {
1385
- const items = [];
1386
- const meta = [];
1387
- if (prefixItems) {
1388
- items.push(...prefixItems);
1389
- }
1390
- pinnedSections.forEach((section) => {
1391
- const startIndex = items.length;
1392
- section.options.forEach((option) => {
1393
- items.push({
1394
- id: option.id + "-pinned",
1395
- type: "pinned-option",
1396
- original: option,
1397
- disabled: option.disabled ?? false
1398
- });
1399
- });
1400
- const endIndex = items.length;
1401
- if (endIndex > startIndex || section.loading) {
1402
- meta.push({
1403
- type: "pinned",
1404
- label: section.label,
1405
- startIndex,
1406
- endIndex,
1407
- loading: section.loading
1408
- });
1409
- }
1410
- });
1411
- groupSections.forEach((section) => {
1412
- const startIndex = items.length;
1413
- section.options.forEach((option) => {
1414
- items.push({
1415
- id: option.id,
1416
- type: "grouped-option",
1417
- original: option,
1418
- disabled: option.disabled ?? false
1419
- });
1420
- });
1421
- const endIndex = items.length;
1422
- if (endIndex > startIndex) {
1423
- meta.push({
1424
- type: "group",
1425
- label: section.label,
1426
- startIndex,
1427
- endIndex
1428
- });
1410
+ const AddNewItemButton = ({
1411
+ searchText,
1412
+ addItemLabel,
1413
+ onAddNewItem,
1414
+ onCloseMenu
1415
+ }) => {
1416
+ if (!onAddNewItem) return null;
1417
+ const resolvedLabel = typeof addItemLabel === "function" ? addItemLabel(searchText) : addItemLabel ?? "Add new item";
1418
+ return /* @__PURE__ */ jsx(
1419
+ Button,
1420
+ {
1421
+ appearance: "secondary",
1422
+ size: "small",
1423
+ icon: { before: SvgAdd },
1424
+ onClick: () => {
1425
+ onCloseMenu?.();
1426
+ onAddNewItem(searchText);
1427
+ },
1428
+ style: { width: "100%" },
1429
+ children: resolvedLabel
1429
1430
  }
1430
- });
1431
- items.push(...ungroupedItems);
1432
- return { items, sectionsMeta: meta };
1433
- }
1431
+ );
1432
+ };
1433
+ AddNewItemButton.displayName = "AddNewItemButton";
1434
1434
 
1435
1435
  function detectCoarsePointer() {
1436
1436
  if (typeof window === "undefined" || !window.matchMedia) {
@@ -1574,4 +1574,4 @@ const sortByGroup = (options, groupSorter) => {
1574
1574
  };
1575
1575
 
1576
1576
  export { AddNewItemButton as A, OptionsPanel as O, VirtualizedOptionsPanel as V, useSelectOrchestration as a, useProcessedOptions as b, buildSelectItems as c, useDebouncedCallback as d, OptionsDialog as e, OptionsPopover as f, defaultSyncFilter as g, toSelectItem as h, sortByGroup as s, toSyncFilterFn as t, useAdaptiveView as u };
1577
- //# sourceMappingURL=syncFilterUtils-Dpp7gt05.js.map
1577
+ //# sourceMappingURL=syncFilterUtils-COxBIkt6.js.map