@astryxdesign/core 0.7.7 → 0.7.8-canary.0d54fd3

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 (682) hide show
  1. package/dist/AlertDialog/AlertDialog.d.ts +4 -1
  2. package/dist/AlertDialog/AlertDialog.d.ts.map +1 -1
  3. package/dist/AlertDialog/AlertDialog.js +46 -6
  4. package/dist/AppShell/AppShell.d.ts.map +1 -1
  5. package/dist/AppShell/AppShell.js +11 -3
  6. package/dist/BottomSheet/BottomSheet.d.ts.map +1 -1
  7. package/dist/BottomSheet/BottomSheet.js +1 -0
  8. package/dist/BottomSheet/BottomSheetPanel.d.ts.map +1 -1
  9. package/dist/BottomSheet/BottomSheetPanel.js +25 -4
  10. package/dist/BottomSheet/BottomSheetSwitcher.d.ts.map +1 -1
  11. package/dist/BottomSheet/BottomSheetSwitcher.js +5 -0
  12. package/dist/BottomSheet/useMobileKeyboard.d.ts.map +1 -1
  13. package/dist/BottomSheet/useMobileKeyboard.js +6 -0
  14. package/dist/BottomSheet/useSheetGestures.d.ts.map +1 -1
  15. package/dist/BottomSheet/useSheetGestures.js +12 -1
  16. package/dist/Button/Button.d.ts.map +1 -1
  17. package/dist/Button/Button.js +17 -1
  18. package/dist/Calendar/Calendar.d.ts.map +1 -1
  19. package/dist/Calendar/Calendar.js +18 -22
  20. package/dist/Calendar/getWeekdayHeaderNames.d.ts +16 -0
  21. package/dist/Calendar/getWeekdayHeaderNames.d.ts.map +1 -0
  22. package/dist/Calendar/getWeekdayHeaderNames.js +70 -0
  23. package/dist/Calendar/hooks/useCalendarDays.d.ts.map +1 -1
  24. package/dist/Calendar/hooks/useCalendarDays.js +2 -10
  25. package/dist/Calendar/{standaloneShortWeekdayNames.generated.d.ts → weekdayHeaderNames.generated.d.ts} +14 -14
  26. package/dist/Calendar/weekdayHeaderNames.generated.d.ts.map +1 -0
  27. package/dist/Calendar/{standaloneShortWeekdayNames.generated.js → weekdayHeaderNames.generated.js} +12 -12
  28. package/dist/Carousel/Carousel.d.ts.map +1 -1
  29. package/dist/Carousel/Carousel.js +2 -0
  30. package/dist/Chat/ChatComposerInput.d.ts.map +1 -1
  31. package/dist/Chat/ChatComposerInput.js +6 -1
  32. package/dist/Chat/ChatMessageList.d.ts.map +1 -1
  33. package/dist/Chat/ChatMessageList.js +2 -1
  34. package/dist/Chat/useChatDictation.d.ts.map +1 -1
  35. package/dist/Chat/useChatDictation.js +2 -0
  36. package/dist/Chat/useChatNewMessages.js +1 -1
  37. package/dist/Chat/useChatStreamScroll.d.ts.map +1 -1
  38. package/dist/Chat/useChatStreamScroll.js +2 -0
  39. package/dist/Chat/useSpeechRecognition.d.ts.map +1 -1
  40. package/dist/Chat/useSpeechRecognition.js +3 -0
  41. package/dist/Chat/useTriggerMenu.js +1 -1
  42. package/dist/CheckboxInput/CheckboxInput.d.ts.map +1 -1
  43. package/dist/CheckboxInput/CheckboxInput.js +17 -12
  44. package/dist/CheckboxList/CheckboxList.d.ts +8 -1
  45. package/dist/CheckboxList/CheckboxList.d.ts.map +1 -1
  46. package/dist/CheckboxList/CheckboxList.js +2 -0
  47. package/dist/CodeBlock/CodeBlock.d.ts +10 -1
  48. package/dist/CodeBlock/CodeBlock.d.ts.map +1 -1
  49. package/dist/CodeBlock/CodeBlock.js +28 -11
  50. package/dist/CommandPalette/CommandPalette.d.ts.map +1 -1
  51. package/dist/CommandPalette/CommandPalette.js +2 -0
  52. package/dist/CommandPalette/CommandPaletteItem.d.ts.map +1 -1
  53. package/dist/CommandPalette/CommandPaletteItem.js +2 -0
  54. package/dist/ComplexSelector/ComplexSelector.d.ts +4 -1
  55. package/dist/ComplexSelector/ComplexSelector.d.ts.map +1 -1
  56. package/dist/ComplexSelector/ComplexSelector.js +14 -4
  57. package/dist/ContextMenu/ContextMenu.js +2 -2
  58. package/dist/DateInput/MonthScroller.d.ts.map +1 -1
  59. package/dist/DateInput/MonthScroller.js +5 -2
  60. package/dist/DateInput/PickerWheel.d.ts +19 -0
  61. package/dist/DateInput/PickerWheel.d.ts.map +1 -0
  62. package/dist/DateInput/PickerWheel.js +625 -0
  63. package/dist/DateInput/TouchDateField.d.ts.map +1 -1
  64. package/dist/DateInput/TouchDateField.js +9 -30
  65. package/dist/DateInput/Wheel.d.ts +18 -37
  66. package/dist/DateInput/Wheel.d.ts.map +1 -1
  67. package/dist/DateInput/Wheel.js +84 -113
  68. package/dist/DateInput/useOwnScrollGesture.d.ts +10 -0
  69. package/dist/DateInput/useOwnScrollGesture.d.ts.map +1 -1
  70. package/dist/DateInput/useOwnScrollGesture.js +16 -3
  71. package/dist/DateInput/usePointerDragScroll.d.ts.map +1 -1
  72. package/dist/DateInput/usePointerDragScroll.js +2 -0
  73. package/dist/DateInput/useScrollSettle.d.ts.map +1 -1
  74. package/dist/DateInput/useScrollSettle.js +3 -0
  75. package/dist/DateInput/useWheelListbox.d.ts +59 -0
  76. package/dist/DateInput/useWheelListbox.d.ts.map +1 -0
  77. package/dist/DateInput/useWheelListbox.js +88 -0
  78. package/dist/DateInput/wheelOptions.d.ts +74 -0
  79. package/dist/DateInput/wheelOptions.d.ts.map +1 -0
  80. package/dist/DateInput/wheelOptions.js +98 -0
  81. package/dist/DateInput/wheelPhysics.d.ts +127 -0
  82. package/dist/DateInput/wheelPhysics.d.ts.map +1 -0
  83. package/dist/DateInput/wheelPhysics.js +341 -0
  84. package/dist/DateInput/wheelStrip.d.ts +92 -0
  85. package/dist/DateInput/wheelStrip.d.ts.map +1 -0
  86. package/dist/DateInput/wheelStrip.js +258 -0
  87. package/dist/DateTimeInput/TouchDateTimeField.d.ts.map +1 -1
  88. package/dist/DateTimeInput/TouchDateTimeField.js +10 -10
  89. package/dist/Dialog/Dialog.d.ts.map +1 -1
  90. package/dist/Dialog/Dialog.js +9 -32
  91. package/dist/Drawer/useDrawerDialogPresence.d.ts.map +1 -1
  92. package/dist/Drawer/useDrawerDialogPresence.js +3 -0
  93. package/dist/DropdownMenu/useMenuOverflow.d.ts.map +1 -1
  94. package/dist/DropdownMenu/useMenuOverflow.js +5 -0
  95. package/dist/Field/Field.js +2 -2
  96. package/dist/FieldStatus/useFieldStatusAnnouncement.d.ts.map +1 -1
  97. package/dist/FieldStatus/useFieldStatusAnnouncement.js +1 -0
  98. package/dist/FormLayout/FormLayout.d.ts +5 -1
  99. package/dist/FormLayout/FormLayout.d.ts.map +1 -1
  100. package/dist/HoverCard/HoverCard.d.ts +6 -4
  101. package/dist/HoverCard/HoverCard.d.ts.map +1 -1
  102. package/dist/HoverCard/HoverCard.js +48 -3
  103. package/dist/HoverCard/useHoverCard.d.ts +5 -4
  104. package/dist/HoverCard/useHoverCard.d.ts.map +1 -1
  105. package/dist/HoverCard/useHoverCard.js +20 -33
  106. package/dist/Icon/Icon.d.ts +5 -1
  107. package/dist/Icon/Icon.d.ts.map +1 -1
  108. package/dist/Icon/Icon.js +5 -2
  109. package/dist/InfoTip/InfoTip.d.ts +5 -5
  110. package/dist/InfoTip/InfoTip.d.ts.map +1 -1
  111. package/dist/InfoTip/InfoTip.js +58 -19
  112. package/dist/Item/useSwipeAction.d.ts.map +1 -1
  113. package/dist/Item/useSwipeAction.js +3 -0
  114. package/dist/Layer/modalOutlet.d.ts.map +1 -1
  115. package/dist/Layer/modalOutlet.js +2 -0
  116. package/dist/Layer/outsidePress.d.ts.map +1 -1
  117. package/dist/Layer/outsidePress.js +1 -0
  118. package/dist/Layer/useLayer.d.ts.map +1 -1
  119. package/dist/Layer/useLayer.js +4 -1
  120. package/dist/Layer/useLayerDismissal.d.ts.map +1 -1
  121. package/dist/Layer/useLayerDismissal.js +3 -0
  122. package/dist/Layer/useTouchTrigger.d.ts +13 -7
  123. package/dist/Layer/useTouchTrigger.d.ts.map +1 -1
  124. package/dist/Layer/useTouchTrigger.js +20 -6
  125. package/dist/Layout/index.d.ts +1 -1
  126. package/dist/Layout/index.d.ts.map +1 -1
  127. package/dist/Layout/index.js +1 -1
  128. package/dist/Layout/layoutReset.js +1 -1
  129. package/dist/Layout/overlayPaddingReset.stylex.d.ts +68 -0
  130. package/dist/Layout/overlayPaddingReset.stylex.d.ts.map +1 -0
  131. package/dist/Layout/overlayPaddingReset.stylex.js +72 -0
  132. package/dist/Layout/padding.stylex.d.ts +5 -129
  133. package/dist/Layout/padding.stylex.d.ts.map +1 -1
  134. package/dist/Layout/padding.stylex.js +9 -143
  135. package/dist/Layout/paddingStyles.stylex.d.ts +83 -0
  136. package/dist/Layout/paddingStyles.stylex.d.ts.map +1 -0
  137. package/dist/Layout/paddingStyles.stylex.js +99 -0
  138. package/dist/Lightbox/Lightbox.d.ts.map +1 -1
  139. package/dist/Lightbox/Lightbox.js +20 -1
  140. package/dist/MobileNav/MobileNav.d.ts +3 -2
  141. package/dist/MobileNav/MobileNav.d.ts.map +1 -1
  142. package/dist/MobileNav/MobileNav.js +10 -26
  143. package/dist/MultiSelector/MultiSelector.d.ts.map +1 -1
  144. package/dist/MultiSelector/MultiSelector.js +2 -1
  145. package/dist/NumberInput/NumberInput.d.ts.map +1 -1
  146. package/dist/NumberInput/NumberInput.js +2 -1
  147. package/dist/Outline/useOutlineFromDOM.d.ts.map +1 -1
  148. package/dist/Outline/useOutlineFromDOM.js +3 -0
  149. package/dist/Outline/useScrollSpy.d.ts.map +1 -1
  150. package/dist/Outline/useScrollSpy.js +3 -0
  151. package/dist/OverflowList/OverflowList.d.ts.map +1 -1
  152. package/dist/OverflowList/OverflowList.js +3 -0
  153. package/dist/Popover/Popover.d.ts.map +1 -1
  154. package/dist/Popover/Popover.js +6 -0
  155. package/dist/Popover/usePopover.js +2 -2
  156. package/dist/PowerSearch/PowerSearch.d.ts +39 -4
  157. package/dist/PowerSearch/PowerSearch.d.ts.map +1 -1
  158. package/dist/PowerSearch/PowerSearch.js +441 -134
  159. package/dist/PowerSearch/PowerSearchBottomSheet.d.ts +102 -0
  160. package/dist/PowerSearch/PowerSearchBottomSheet.d.ts.map +1 -0
  161. package/dist/PowerSearch/PowerSearchBottomSheet.js +1919 -0
  162. package/dist/PowerSearch/PowerSearchEditPopover.d.ts +35 -2
  163. package/dist/PowerSearch/PowerSearchEditPopover.d.ts.map +1 -1
  164. package/dist/PowerSearch/PowerSearchEditPopover.js +43 -10
  165. package/dist/PowerSearch/PowerSearchFilterEditor.d.ts +1 -1
  166. package/dist/PowerSearch/PowerSearchFilterEditor.d.ts.map +1 -1
  167. package/dist/PowerSearch/PowerSearchFilterEditor.js +4 -2
  168. package/dist/PowerSearch/PowerSearchToken.d.ts +1 -1
  169. package/dist/PowerSearch/PowerSearchToken.d.ts.map +1 -1
  170. package/dist/PowerSearch/PowerSearchToken.js +3 -2
  171. package/dist/PowerSearch/PowerSearchValueEditor.d.ts +38 -3
  172. package/dist/PowerSearch/PowerSearchValueEditor.d.ts.map +1 -1
  173. package/dist/PowerSearch/PowerSearchValueEditor.js +273 -86
  174. package/dist/PowerSearch/formatFilterValue.d.ts +14 -7
  175. package/dist/PowerSearch/formatFilterValue.d.ts.map +1 -1
  176. package/dist/PowerSearch/formatFilterValue.js +31 -23
  177. package/dist/PowerSearch/formatTokenValue.d.ts +28 -0
  178. package/dist/PowerSearch/formatTokenValue.d.ts.map +1 -0
  179. package/dist/PowerSearch/formatTokenValue.js +161 -0
  180. package/dist/PowerSearch/index.d.ts +1 -1
  181. package/dist/PowerSearch/index.d.ts.map +1 -1
  182. package/dist/PowerSearch/powerSearchDateZone.d.ts +25 -0
  183. package/dist/PowerSearch/powerSearchDateZone.d.ts.map +1 -0
  184. package/dist/PowerSearch/powerSearchDateZone.js +57 -0
  185. package/dist/PowerSearch/powerSearchSheetUtils.d.ts +65 -0
  186. package/dist/PowerSearch/powerSearchSheetUtils.d.ts.map +1 -0
  187. package/dist/PowerSearch/powerSearchSheetUtils.js +168 -0
  188. package/dist/PowerSearch/types.d.ts +8 -1
  189. package/dist/PowerSearch/types.d.ts.map +1 -1
  190. package/dist/ProgressBar/ProgressBarTouch.d.ts.map +1 -1
  191. package/dist/ProgressBar/ProgressBarTouch.js +2 -0
  192. package/dist/RadioList/RadioList.d.ts.map +1 -1
  193. package/dist/RadioList/RadioList.js +3 -2
  194. package/dist/RadioList/RadioListItem.d.ts +1 -1
  195. package/dist/RadioList/RadioListItem.d.ts.map +1 -1
  196. package/dist/RadioList/RadioListItem.js +5 -3
  197. package/dist/Resizable/ResizeHandle.d.ts +2 -1
  198. package/dist/Resizable/ResizeHandle.d.ts.map +1 -1
  199. package/dist/Resizable/ResizeHandle.js +101 -77
  200. package/dist/Resizable/createResizable.d.ts +145 -0
  201. package/dist/Resizable/createResizable.d.ts.map +1 -0
  202. package/dist/Resizable/createResizable.js +575 -0
  203. package/dist/Resizable/useResizable.d.ts +3 -3
  204. package/dist/Resizable/useResizable.d.ts.map +1 -1
  205. package/dist/Resizable/useResizable.js +252 -459
  206. package/dist/SegmentedControl/useSegmentedSelectionMotion.d.ts.map +1 -1
  207. package/dist/SegmentedControl/useSegmentedSelectionMotion.js +3 -3
  208. package/dist/SelectableCard/SelectableCard.d.ts +2 -0
  209. package/dist/SelectableCard/SelectableCard.d.ts.map +1 -1
  210. package/dist/SelectableCard/SelectableCard.js +36 -11
  211. package/dist/SelectableCard/selectableCardInput.d.ts +12 -0
  212. package/dist/SelectableCard/selectableCardInput.d.ts.map +1 -0
  213. package/dist/SelectableCard/selectableCardInput.js +20 -0
  214. package/dist/Selector/Selector.d.ts.map +1 -1
  215. package/dist/Selector/Selector.js +7 -9
  216. package/dist/SideNav/SideNav.d.ts.map +1 -1
  217. package/dist/SideNav/SideNav.js +36 -5
  218. package/dist/Slider/Slider.d.ts.map +1 -1
  219. package/dist/Slider/Slider.js +16 -11
  220. package/dist/Slider/sliderTouchController.js +2 -2
  221. package/dist/Spinner/Spinner.d.ts +1 -1
  222. package/dist/Spinner/Spinner.d.ts.map +1 -1
  223. package/dist/Spinner/Spinner.js +60 -58
  224. package/dist/Stepper/Stepper.d.ts.map +1 -1
  225. package/dist/Stepper/Stepper.js +10 -15
  226. package/dist/Switch/Switch.d.ts.map +1 -1
  227. package/dist/Switch/Switch.js +4 -10
  228. package/dist/Switch/useSwitchTouch.js +4 -4
  229. package/dist/Table/BaseTable.d.ts.map +1 -1
  230. package/dist/Table/BaseTable.js +29 -8
  231. package/dist/Table/plugins/columnResize/useTableColumnResize.d.ts.map +1 -1
  232. package/dist/Table/plugins/columnResize/useTableColumnResize.js +3 -1
  233. package/dist/Table/plugins/filtering/useTableFiltering.d.ts.map +1 -1
  234. package/dist/Table/plugins/filtering/useTableFiltering.js +2 -1
  235. package/dist/Table/plugins/rowExpansion/useTableRowExpansion.d.ts.map +1 -1
  236. package/dist/Table/plugins/rowExpansion/useTableRowExpansion.js +4 -0
  237. package/dist/Table/plugins/stickyColumns/useTableStickyColumns.d.ts.map +1 -1
  238. package/dist/Table/plugins/stickyColumns/useTableStickyColumns.js +2 -0
  239. package/dist/TextArea/TextArea.d.ts.map +1 -1
  240. package/dist/TextArea/TextArea.js +2 -1
  241. package/dist/TextInput/TextInput.d.ts +2 -2
  242. package/dist/TextInput/TextInput.d.ts.map +1 -1
  243. package/dist/TextInput/TextInput.js +12 -8
  244. package/dist/TimeInput/TimeInput.d.ts.map +1 -1
  245. package/dist/TimeInput/TimeInput.js +2 -0
  246. package/dist/TimeInput/TouchTimeField.d.ts.map +1 -1
  247. package/dist/TimeInput/TouchTimeField.js +2 -0
  248. package/dist/Timer/Timer.d.ts.map +1 -1
  249. package/dist/Timer/Timer.js +2 -0
  250. package/dist/Timestamp/Timestamp.js +1 -1
  251. package/dist/Timestamp/formatInstant.d.ts.map +1 -1
  252. package/dist/Timestamp/formatInstant.js +1 -23
  253. package/dist/Toast/Toast.d.ts +11 -1
  254. package/dist/Toast/Toast.d.ts.map +1 -1
  255. package/dist/Toast/Toast.js +25 -15
  256. package/dist/Toast/ToastViewport.d.ts.map +1 -1
  257. package/dist/Toast/ToastViewport.js +97 -34
  258. package/dist/Toast/types.d.ts +9 -3
  259. package/dist/Toast/types.d.ts.map +1 -1
  260. package/dist/Toast/useToast.d.ts.map +1 -1
  261. package/dist/Toast/useToast.js +1 -0
  262. package/dist/Tokenizer/Tokenizer.d.ts +44 -46
  263. package/dist/Tokenizer/Tokenizer.d.ts.map +1 -1
  264. package/dist/Tokenizer/Tokenizer.js +20 -21
  265. package/dist/Tokenizer/TokenizerBottomSheet.d.ts +1 -1
  266. package/dist/Tokenizer/TokenizerBottomSheet.js +4 -6
  267. package/dist/Tokenizer/index.d.ts +1 -1
  268. package/dist/Tokenizer/index.d.ts.map +1 -1
  269. package/dist/Tooltip/Tooltip.d.ts +2 -23
  270. package/dist/Tooltip/Tooltip.d.ts.map +1 -1
  271. package/dist/Tooltip/Tooltip.js +5 -29
  272. package/dist/Tooltip/useTooltip.d.ts +23 -30
  273. package/dist/Tooltip/useTooltip.d.ts.map +1 -1
  274. package/dist/Tooltip/useTooltip.js +194 -108
  275. package/dist/Typeahead/BaseTypeahead.d.ts.map +1 -1
  276. package/dist/Typeahead/BaseTypeahead.js +27 -18
  277. package/dist/Typeahead/TypeaheadItem.d.ts +2 -1
  278. package/dist/Typeahead/TypeaheadItem.d.ts.map +1 -1
  279. package/dist/animator/createAnimator.d.ts +98 -0
  280. package/dist/animator/createAnimator.d.ts.map +1 -0
  281. package/dist/animator/createAnimator.js +259 -0
  282. package/dist/astryx.css +41 -7
  283. package/dist/gestures/GestureHost.d.ts +16 -1
  284. package/dist/gestures/GestureHost.d.ts.map +1 -1
  285. package/dist/gestures/GestureHost.js +1 -1
  286. package/dist/gestures/PressTracker.d.ts.map +1 -1
  287. package/dist/gestures/PressTracker.js +4 -3
  288. package/dist/hooks/ModalAnnounceProvider.d.ts.map +1 -1
  289. package/dist/hooks/ModalAnnounceProvider.js +1 -0
  290. package/dist/hooks/actionGroupTracker.d.ts +4 -1
  291. package/dist/hooks/actionGroupTracker.d.ts.map +1 -1
  292. package/dist/hooks/actionGroupTracker.js +13 -3
  293. package/dist/hooks/index.d.ts +1 -0
  294. package/dist/hooks/index.d.ts.map +1 -1
  295. package/dist/hooks/index.js +1 -0
  296. package/dist/hooks/longPressDetector.d.ts +66 -0
  297. package/dist/hooks/longPressDetector.d.ts.map +1 -0
  298. package/dist/hooks/longPressDetector.js +200 -0
  299. package/dist/hooks/pressGroupContext.d.ts +6 -0
  300. package/dist/hooks/pressGroupContext.d.ts.map +1 -0
  301. package/dist/hooks/pressGroupContext.js +20 -0
  302. package/dist/hooks/rootScrollStyles.d.ts +48 -0
  303. package/dist/hooks/rootScrollStyles.d.ts.map +1 -0
  304. package/dist/hooks/rootScrollStyles.js +207 -0
  305. package/dist/hooks/scrollLockTouchGuard.d.ts +13 -0
  306. package/dist/hooks/scrollLockTouchGuard.d.ts.map +1 -0
  307. package/dist/hooks/scrollLockTouchGuard.js +117 -0
  308. package/dist/hooks/scrollbarGutter.d.ts +4 -4
  309. package/dist/hooks/scrollbarGutter.d.ts.map +1 -1
  310. package/dist/hooks/scrollbarGutter.js +36 -23
  311. package/dist/hooks/useActionGroupTracking.d.ts +53 -0
  312. package/dist/hooks/useActionGroupTracking.d.ts.map +1 -0
  313. package/dist/hooks/useActionGroupTracking.js +174 -0
  314. package/dist/hooks/useAnimator.d.ts +41 -0
  315. package/dist/hooks/useAnimator.d.ts.map +1 -0
  316. package/dist/hooks/useAnimator.js +70 -0
  317. package/dist/hooks/useAnnounceRenderedText.d.ts.map +1 -1
  318. package/dist/hooks/useAnnounceRenderedText.js +1 -0
  319. package/dist/hooks/useAttachment.d.ts +1 -1
  320. package/dist/hooks/useAttachment.js +1 -1
  321. package/dist/hooks/useAutoMediaMode.d.ts.map +1 -1
  322. package/dist/hooks/useAutoMediaMode.js +1 -0
  323. package/dist/hooks/useBusyAnnouncement.d.ts.map +1 -1
  324. package/dist/hooks/useBusyAnnouncement.js +2 -0
  325. package/dist/hooks/useDevWarning.d.ts.map +1 -1
  326. package/dist/hooks/useDevWarning.js +2 -0
  327. package/dist/hooks/useFocusTrap.d.ts.map +1 -1
  328. package/dist/hooks/useFocusTrap.js +2 -0
  329. package/dist/hooks/useGridFocus.d.ts +8 -5
  330. package/dist/hooks/useGridFocus.d.ts.map +1 -1
  331. package/dist/hooks/useGridFocus.js +4 -3
  332. package/dist/hooks/useHotkeys.d.ts.map +1 -1
  333. package/dist/hooks/useHotkeys.js +3 -0
  334. package/dist/hooks/useImageMode.d.ts.map +1 -1
  335. package/dist/hooks/useImageMode.js +3 -0
  336. package/dist/hooks/useInputStatusIcon.d.ts +1 -1
  337. package/dist/hooks/useInputStatusIcon.d.ts.map +1 -1
  338. package/dist/hooks/useInputStatusIcon.js +2 -2
  339. package/dist/hooks/useIsomorphicLayoutEffect.d.ts +2 -2
  340. package/dist/hooks/useIsomorphicLayoutEffect.d.ts.map +1 -1
  341. package/dist/hooks/useKeyboardHint.js +1 -1
  342. package/dist/hooks/useLongPress.d.ts +8 -9
  343. package/dist/hooks/useLongPress.d.ts.map +1 -1
  344. package/dist/hooks/useLongPress.js +23 -106
  345. package/dist/hooks/useMenuHover.d.ts.map +1 -1
  346. package/dist/hooks/useMenuHover.js +2 -0
  347. package/dist/hooks/useMenuPress.d.ts.map +1 -1
  348. package/dist/hooks/useMenuPress.js +3 -0
  349. package/dist/hooks/useOverflow.d.ts.map +1 -1
  350. package/dist/hooks/useOverflow.js +2 -1
  351. package/dist/hooks/usePressFeedback.d.ts.map +1 -1
  352. package/dist/hooks/usePressFeedback.js +1 -0
  353. package/dist/hooks/useResolvedRequired.d.ts +3 -0
  354. package/dist/hooks/useResolvedRequired.d.ts.map +1 -1
  355. package/dist/hooks/useResolvedRequired.js +3 -0
  356. package/dist/hooks/useScrollLock.d.ts +8 -9
  357. package/dist/hooks/useScrollLock.d.ts.map +1 -1
  358. package/dist/hooks/useScrollLock.js +50 -48
  359. package/dist/hooks/useScrollableArea.d.ts.map +1 -1
  360. package/dist/hooks/useScrollableArea.js +5 -0
  361. package/dist/hooks/useStreamingText.d.ts.map +1 -1
  362. package/dist/hooks/useStreamingText.js +3 -0
  363. package/dist/i18n/generated-english/PowerSearch/PowerSearchBottomSheet.generated.d.ts +8 -0
  364. package/dist/i18n/generated-english/PowerSearch/PowerSearchBottomSheet.generated.d.ts.map +1 -0
  365. package/dist/i18n/generated-english/PowerSearch/PowerSearchBottomSheet.generated.js +42 -0
  366. package/dist/i18n/generated-english/PowerSearch/PowerSearchValueEditor.generated.d.ts.map +1 -1
  367. package/dist/i18n/generated-english/PowerSearch/PowerSearchValueEditor.generated.js +6 -0
  368. package/dist/i18n/generated-english/PowerSearch/formatTokenValue.generated.d.ts +8 -0
  369. package/dist/i18n/generated-english/PowerSearch/formatTokenValue.generated.d.ts.map +1 -0
  370. package/dist/i18n/generated-english/PowerSearch/formatTokenValue.generated.js +14 -0
  371. package/dist/i18n/generated-locales/en.generated.d.ts.map +1 -1
  372. package/dist/i18n/generated-locales/en.generated.js +30 -0
  373. package/dist/i18n/generated-locales/pseudo.generated.d.ts.map +1 -1
  374. package/dist/i18n/generated-locales/pseudo.generated.js +30 -0
  375. package/dist/index.d.ts +1 -0
  376. package/dist/index.d.ts.map +1 -1
  377. package/dist/index.js +4 -0
  378. package/dist/internal/indicatorPress.stylex.d.ts +20 -0
  379. package/dist/internal/indicatorPress.stylex.d.ts.map +1 -0
  380. package/dist/internal/indicatorPress.stylex.js +26 -0
  381. package/dist/internal/selectable-card.d.ts +21 -0
  382. package/dist/internal/selectable-card.d.ts.map +1 -0
  383. package/dist/internal/selectable-card.js +20 -0
  384. package/dist/internal/sheetDraft.d.ts +2 -2
  385. package/dist/internal/sheetDraft.js +2 -2
  386. package/dist/motion/animatedLayout.d.ts +8 -0
  387. package/dist/motion/animatedLayout.d.ts.map +1 -1
  388. package/dist/motion/animatedLayout.js +246 -53
  389. package/dist/motion/animator.d.ts +14 -14
  390. package/dist/motion/animator.d.ts.map +1 -1
  391. package/dist/motion/animator.js +45 -26
  392. package/dist/motion/frameBlock.d.ts +14 -0
  393. package/dist/motion/frameBlock.d.ts.map +1 -0
  394. package/dist/motion/frameBlock.js +16 -0
  395. package/dist/motion/progress.d.ts +88 -0
  396. package/dist/motion/progress.d.ts.map +1 -0
  397. package/dist/motion/progress.js +128 -0
  398. package/dist/motion/reducedMotion.d.ts.map +1 -1
  399. package/dist/motion/reducedMotion.js +3 -1
  400. package/dist/motion/uikit/alert.d.ts +41 -0
  401. package/dist/motion/uikit/alert.d.ts.map +1 -0
  402. package/dist/motion/uikit/alert.js +43 -0
  403. package/dist/motion/uikit/index.d.ts +4 -3
  404. package/dist/motion/uikit/index.d.ts.map +1 -1
  405. package/dist/motion/uikit/index.js +4 -3
  406. package/dist/motion/uikit/picker.d.ts +96 -0
  407. package/dist/motion/uikit/picker.d.ts.map +1 -0
  408. package/dist/motion/uikit/picker.js +117 -0
  409. package/dist/privateAttributes/pressGroupItem.stylex.d.ts +22 -0
  410. package/dist/privateAttributes/pressGroupItem.stylex.d.ts.map +1 -0
  411. package/dist/privateAttributes/pressGroupItem.stylex.js +36 -0
  412. package/dist/privateAttributes/reducedMotion.stylex.d.ts +23 -0
  413. package/dist/privateAttributes/reducedMotion.stylex.d.ts.map +1 -0
  414. package/dist/privateAttributes/reducedMotion.stylex.js +40 -0
  415. package/dist/theme/Theme.d.ts.map +1 -1
  416. package/dist/theme/Theme.js +29 -4
  417. package/dist/theme/generateThemeRules.d.ts.map +1 -1
  418. package/dist/theme/generateThemeRules.js +14 -13
  419. package/dist/theme/motionKnobs.d.ts +4 -3
  420. package/dist/theme/motionKnobs.d.ts.map +1 -1
  421. package/dist/theme/motionKnobs.js +3 -2
  422. package/dist/theme/themeMotion.d.ts +6 -0
  423. package/dist/theme/themeMotion.d.ts.map +1 -1
  424. package/dist/theme/themeMotion.js +15 -2
  425. package/dist/theme/tokens.stylex.d.ts +3 -0
  426. package/dist/theme/tokens.stylex.d.ts.map +1 -1
  427. package/dist/theme/tokens.stylex.js +4 -1
  428. package/dist/utils/dateParser.d.ts.map +1 -1
  429. package/dist/utils/dateParser.js +12 -0
  430. package/dist/utils/disabledInteraction.d.ts +10 -2
  431. package/dist/utils/disabledInteraction.d.ts.map +1 -1
  432. package/dist/utils/disabledInteraction.js +16 -2
  433. package/dist/utils/focusReturn.d.ts +22 -25
  434. package/dist/utils/focusReturn.d.ts.map +1 -1
  435. package/dist/utils/focusReturn.js +36 -29
  436. package/dist/utils/index.d.ts +1 -1
  437. package/dist/utils/index.d.ts.map +1 -1
  438. package/dist/utils/index.js +1 -1
  439. package/dist/utils/interactionModality.d.ts.map +1 -1
  440. package/dist/utils/interactionModality.js +4 -0
  441. package/dist/utils/interactionOverlay.stylex.d.ts +3 -2
  442. package/dist/utils/interactionOverlay.stylex.d.ts.map +1 -1
  443. package/dist/utils/interactionOverlay.stylex.js +3 -2
  444. package/dist/utils/isFocusDetached.d.ts +27 -0
  445. package/dist/utils/isFocusDetached.d.ts.map +1 -0
  446. package/dist/utils/isFocusDetached.js +32 -0
  447. package/dist/utils/plainDate.d.ts +31 -0
  448. package/dist/utils/plainDate.d.ts.map +1 -1
  449. package/dist/utils/plainDate.js +68 -4
  450. package/dist/utils/pressFeedback.d.ts.map +1 -1
  451. package/dist/utils/pressFeedback.js +20 -6
  452. package/dist/utils/triggerFocus.d.ts +36 -0
  453. package/dist/utils/triggerFocus.d.ts.map +1 -0
  454. package/dist/utils/triggerFocus.js +65 -0
  455. package/locales/en.json +120 -0
  456. package/locales/pseudo.json +90 -0
  457. package/package.json +14 -9
  458. package/src/AlertDialog/AlertDialog.doc.mjs +2 -2
  459. package/src/AlertDialog/AlertDialog.tsx +46 -5
  460. package/src/AppShell/AppShell.tsx +13 -4
  461. package/src/BottomSheet/BottomSheet.tsx +1 -0
  462. package/src/BottomSheet/BottomSheetPanel.tsx +39 -3
  463. package/src/BottomSheet/BottomSheetSwitcher.tsx +5 -0
  464. package/src/BottomSheet/useMobileKeyboard.ts +4 -0
  465. package/src/BottomSheet/useSheetGestures.ts +10 -1
  466. package/src/Button/Button.tsx +26 -4
  467. package/src/Calendar/Calendar.tsx +40 -32
  468. package/src/Calendar/getWeekdayHeaderNames.ts +88 -0
  469. package/src/Calendar/hooks/useCalendarDays.ts +5 -10
  470. package/src/Calendar/{standaloneShortWeekdayNames.generated.ts → weekdayHeaderNames.generated.ts} +14 -14
  471. package/src/Carousel/Carousel.tsx +1 -0
  472. package/src/Chat/ChatComposerInput.tsx +4 -7
  473. package/src/Chat/ChatMessageList.tsx +2 -1
  474. package/src/Chat/useChatDictation.ts +1 -0
  475. package/src/Chat/useChatNewMessages.ts +1 -1
  476. package/src/Chat/useChatStreamScroll.ts +2 -0
  477. package/src/Chat/useSpeechRecognition.ts +2 -0
  478. package/src/Chat/useTriggerMenu.tsx +1 -1
  479. package/src/CheckboxInput/CheckboxInput.doc.mjs +18 -0
  480. package/src/CheckboxInput/CheckboxInput.tsx +38 -15
  481. package/src/CheckboxList/CheckboxList.doc.mjs +7 -0
  482. package/src/CheckboxList/CheckboxList.tsx +9 -0
  483. package/src/CodeBlock/CodeBlock.doc.mjs +9 -1
  484. package/src/CodeBlock/CodeBlock.tsx +41 -4
  485. package/src/CommandPalette/CommandPalette.tsx +1 -0
  486. package/src/CommandPalette/CommandPaletteItem.tsx +1 -0
  487. package/src/ComplexSelector/ComplexSelector.tsx +20 -5
  488. package/src/ContextMenu/ContextMenu.tsx +2 -2
  489. package/src/DateInput/MonthScroller.tsx +8 -2
  490. package/src/DateInput/PickerWheel.tsx +765 -0
  491. package/src/DateInput/TouchDateField.tsx +6 -32
  492. package/src/DateInput/Wheel.tsx +94 -150
  493. package/src/DateInput/useOwnScrollGesture.ts +25 -3
  494. package/src/DateInput/usePointerDragScroll.ts +1 -0
  495. package/src/DateInput/useScrollSettle.ts +2 -0
  496. package/src/DateInput/useWheelListbox.ts +112 -0
  497. package/src/DateInput/wheelOptions.ts +155 -0
  498. package/src/DateInput/wheelPhysics.ts +406 -0
  499. package/src/DateInput/wheelStrip.ts +341 -0
  500. package/src/DateTimeInput/TouchDateTimeField.tsx +8 -13
  501. package/src/Dialog/Dialog.tsx +12 -32
  502. package/src/Drawer/useDrawerDialogPresence.ts +2 -0
  503. package/src/DropdownMenu/useMenuOverflow.ts +3 -0
  504. package/src/Field/Field.tsx +2 -2
  505. package/src/FieldStatus/useFieldStatusAnnouncement.ts +1 -0
  506. package/src/FormLayout/FormLayout.doc.mjs +181 -46
  507. package/src/FormLayout/FormLayout.tsx +5 -1
  508. package/src/HoverCard/HoverCard.doc.mjs +10 -8
  509. package/src/HoverCard/HoverCard.tsx +58 -6
  510. package/src/HoverCard/useHoverCard.doc.mjs +178 -36
  511. package/src/HoverCard/useHoverCard.tsx +49 -54
  512. package/src/Icon/Icon.doc.mjs +51 -10
  513. package/src/Icon/Icon.tsx +15 -7
  514. package/src/IconButton/IconButton.doc.mjs +141 -21
  515. package/src/InfoTip/InfoTip.tsx +72 -16
  516. package/src/Item/useSwipeAction.ts +2 -0
  517. package/src/Layer/modalOutlet.ts +2 -0
  518. package/src/Layer/outsidePress.ts +1 -0
  519. package/src/Layer/useLayer.tsx +3 -1
  520. package/src/Layer/useLayerDismissal.ts +2 -0
  521. package/src/Layer/useTouchTrigger.ts +19 -6
  522. package/src/Layout/index.ts +1 -1
  523. package/src/Layout/layoutReset.ts +1 -1
  524. package/src/Layout/overlayPaddingReset.stylex.ts +73 -0
  525. package/src/Layout/padding.stylex.ts +9 -133
  526. package/src/Layout/paddingStyles.stylex.ts +87 -0
  527. package/src/Lightbox/Lightbox.tsx +20 -1
  528. package/src/Lightbox/useLightbox.doc.mjs +167 -0
  529. package/src/MobileNav/MobileNav.tsx +10 -31
  530. package/src/MultiSelector/MultiSelector.tsx +2 -7
  531. package/src/NumberInput/NumberInput.tsx +2 -7
  532. package/src/Outline/useOutlineFromDOM.ts +2 -0
  533. package/src/Outline/useScrollSpy.ts +2 -0
  534. package/src/OverflowList/OverflowList.tsx +2 -0
  535. package/src/Popover/Popover.tsx +4 -0
  536. package/src/Popover/usePopover.tsx +2 -2
  537. package/src/PowerSearch/PowerSearch.doc.mjs +60 -8
  538. package/src/PowerSearch/PowerSearch.tsx +620 -157
  539. package/src/PowerSearch/PowerSearchBottomSheet.tsx +2525 -0
  540. package/src/PowerSearch/PowerSearchEditPopover.tsx +65 -9
  541. package/src/PowerSearch/PowerSearchFilterEditor.tsx +2 -0
  542. package/src/PowerSearch/PowerSearchToken.tsx +2 -0
  543. package/src/PowerSearch/PowerSearchValueEditor.tsx +340 -59
  544. package/src/PowerSearch/formatFilterValue.ts +49 -27
  545. package/src/PowerSearch/formatTokenValue.ts +220 -0
  546. package/src/PowerSearch/index.ts +5 -1
  547. package/src/PowerSearch/powerSearchDateZone.ts +95 -0
  548. package/src/PowerSearch/powerSearchSheetUtils.ts +224 -0
  549. package/src/PowerSearch/types.ts +8 -1
  550. package/src/ProgressBar/ProgressBarTouch.ts +2 -0
  551. package/src/RadioList/RadioList.tsx +3 -2
  552. package/src/RadioList/RadioListItem.tsx +5 -3
  553. package/src/Resizable/Resizable.doc.mjs +5 -4
  554. package/src/Resizable/ResizeHandle.tsx +169 -109
  555. package/src/Resizable/createResizable.ts +831 -0
  556. package/src/Resizable/useResizable.ts +292 -623
  557. package/src/SegmentedControl/useSegmentedSelectionMotion.ts +6 -3
  558. package/src/SelectableCard/SelectableCard.tsx +39 -10
  559. package/src/SelectableCard/selectableCardInput.ts +30 -0
  560. package/src/Selector/Selector.tsx +7 -19
  561. package/src/SideNav/SideNav.tsx +41 -5
  562. package/src/Slider/Slider.tsx +20 -11
  563. package/src/Slider/sliderTouchController.ts +2 -2
  564. package/src/Spinner/Spinner.tsx +77 -63
  565. package/src/Stepper/Stepper.tsx +10 -27
  566. package/src/Switch/Switch.tsx +2 -6
  567. package/src/Switch/useSwitchTouch.ts +4 -4
  568. package/src/Table/BaseTable.tsx +46 -12
  569. package/src/Table/plugins/columnResize/useTableColumnResize.tsx +2 -1
  570. package/src/Table/plugins/filtering/useTableFiltering.tsx +1 -0
  571. package/src/Table/plugins/rowExpansion/useTableRowExpansion.tsx +4 -0
  572. package/src/Table/plugins/stickyColumns/useTableStickyColumns.tsx +2 -0
  573. package/src/TextArea/TextArea.tsx +2 -7
  574. package/src/TextInput/TextInput.tsx +13 -17
  575. package/src/TimeInput/TimeInput.tsx +2 -0
  576. package/src/TimeInput/TouchTimeField.tsx +2 -0
  577. package/src/Timer/Timer.tsx +1 -0
  578. package/src/Timestamp/Timestamp.tsx +1 -1
  579. package/src/Timestamp/formatInstant.ts +1 -33
  580. package/src/Toast/Toast.doc.mjs +4 -3
  581. package/src/Toast/Toast.tsx +52 -32
  582. package/src/Toast/ToastViewport.tsx +123 -35
  583. package/src/Toast/types.ts +9 -3
  584. package/src/Toast/useToast.tsx +1 -0
  585. package/src/Tokenizer/Tokenizer.doc.mjs +10 -10
  586. package/src/Tokenizer/Tokenizer.tsx +61 -62
  587. package/src/Tokenizer/TokenizerBottomSheet.tsx +9 -11
  588. package/src/Tokenizer/index.ts +1 -0
  589. package/src/Tooltip/Tooltip.tsx +6 -42
  590. package/src/Tooltip/useTooltip.doc.mjs +24 -0
  591. package/src/Tooltip/useTooltip.tsx +237 -134
  592. package/src/Typeahead/BaseTypeahead.tsx +27 -17
  593. package/src/Typeahead/TypeaheadItem.doc.mjs +6 -3
  594. package/src/Typeahead/TypeaheadItem.tsx +2 -1
  595. package/src/animator/createAnimator.doc.mjs +153 -0
  596. package/src/animator/createAnimator.ts +324 -0
  597. package/src/gestures/GestureHost.ts +1 -1
  598. package/src/gestures/PressTracker.ts +4 -3
  599. package/src/gestures/README.md +10 -4
  600. package/src/hooks/ModalAnnounceProvider.tsx +1 -0
  601. package/src/hooks/actionGroupTracker.ts +20 -5
  602. package/src/hooks/index.ts +2 -0
  603. package/src/hooks/longPressDetector.ts +273 -0
  604. package/src/hooks/pressGroupContext.ts +21 -0
  605. package/src/hooks/rootScrollStyles.ts +247 -0
  606. package/src/hooks/scrollLockTouchGuard.ts +149 -0
  607. package/src/hooks/scrollbarGutter.ts +41 -26
  608. package/src/hooks/useActionGroupTracking.ts +224 -0
  609. package/src/hooks/useAnimator.doc.mjs +109 -0
  610. package/src/hooks/useAnimator.ts +67 -0
  611. package/src/hooks/useAnnounceRenderedText.ts +1 -0
  612. package/src/hooks/useAttachment.ts +1 -1
  613. package/src/hooks/useAutoMediaMode.ts +1 -0
  614. package/src/hooks/useBusyAnnouncement.ts +2 -0
  615. package/src/hooks/useDevWarning.ts +2 -0
  616. package/src/hooks/useFocusTrap.ts +2 -0
  617. package/src/hooks/useGridFocus.doc.mjs +6 -6
  618. package/src/hooks/useGridFocus.ts +10 -7
  619. package/src/hooks/useHotkeys.ts +2 -0
  620. package/src/hooks/useImageMode.ts +2 -0
  621. package/src/hooks/useInputStatusIcon.tsx +3 -2
  622. package/src/hooks/useKeyboardHint.tsx +1 -1
  623. package/src/hooks/useLongPress.doc.mjs +2 -2
  624. package/src/hooks/useLongPress.ts +32 -122
  625. package/src/hooks/useMenuHover.ts +1 -0
  626. package/src/hooks/useMenuPress.ts +2 -0
  627. package/src/hooks/useOverflow.ts +2 -1
  628. package/src/hooks/usePressFeedback.ts +1 -0
  629. package/src/hooks/useResolvedRequired.ts +3 -0
  630. package/src/hooks/useScrollLock.doc.mjs +51 -12
  631. package/src/hooks/useScrollLock.ts +53 -60
  632. package/src/hooks/useScrollableArea.ts +4 -0
  633. package/src/hooks/useStreamingText.ts +2 -0
  634. package/src/i18n/generated-english/PowerSearch/PowerSearchBottomSheet.generated.ts +43 -0
  635. package/src/i18n/generated-english/PowerSearch/PowerSearchValueEditor.generated.ts +6 -0
  636. package/src/i18n/generated-english/PowerSearch/formatTokenValue.generated.ts +15 -0
  637. package/src/i18n/generated-locales/en.generated.ts +41 -0
  638. package/src/i18n/generated-locales/pseudo.generated.ts +42 -0
  639. package/src/index.ts +13 -0
  640. package/src/internal/indicatorPress.stylex.ts +24 -0
  641. package/src/internal/selectable-card.ts +21 -0
  642. package/src/internal/sheetDraft.ts +2 -2
  643. package/src/motion/MEASUREMENTS.md +18 -0
  644. package/src/motion/README.md +10 -5
  645. package/src/motion/animatedLayout.ts +323 -60
  646. package/src/motion/animator.ts +66 -37
  647. package/src/motion/frameBlock.ts +16 -0
  648. package/src/motion/progress.ts +155 -0
  649. package/src/motion/reducedMotion.ts +3 -1
  650. package/src/motion/uikit/alert.ts +43 -0
  651. package/src/motion/uikit/index.ts +4 -3
  652. package/src/motion/uikit/picker.ts +116 -0
  653. package/src/privateAttributes/pressGroupItem.stylex.ts +44 -0
  654. package/src/privateAttributes/reducedMotion.stylex.ts +45 -0
  655. package/src/theme/Theme.tsx +37 -3
  656. package/src/theme/generateThemeRules.ts +14 -12
  657. package/src/theme/motionKnobs.ts +4 -3
  658. package/src/theme/themeMotion.ts +17 -2
  659. package/src/theme/tokens.stylex.ts +2 -0
  660. package/src/utils/dateParser.ts +16 -0
  661. package/src/utils/disabledInteraction.ts +23 -2
  662. package/src/utils/focusReturn.ts +38 -31
  663. package/src/utils/index.ts +1 -1
  664. package/src/utils/interactionModality.ts +4 -0
  665. package/src/utils/interactionOverlay.stylex.ts +3 -2
  666. package/src/utils/isFocusDetached.ts +34 -0
  667. package/src/utils/plainDate.ts +80 -4
  668. package/src/utils/pressFeedback.ts +24 -6
  669. package/src/utils/triggerFocus.ts +80 -0
  670. package/dist/Calendar/getStandaloneShortWeekdayNames.d.ts +0 -14
  671. package/dist/Calendar/getStandaloneShortWeekdayNames.d.ts.map +0 -1
  672. package/dist/Calendar/getStandaloneShortWeekdayNames.js +0 -26
  673. package/dist/Calendar/standaloneShortWeekdayNames.generated.d.ts.map +0 -1
  674. package/dist/Layer/usePressPin.d.ts +0 -93
  675. package/dist/Layer/usePressPin.d.ts.map +0 -1
  676. package/dist/Layer/usePressPin.js +0 -363
  677. package/dist/internal/touch-sheet.d.ts +0 -21
  678. package/dist/internal/touch-sheet.d.ts.map +0 -1
  679. package/dist/internal/touch-sheet.js +0 -19
  680. package/src/Calendar/getStandaloneShortWeekdayNames.ts +0 -38
  681. package/src/Layer/usePressPin.ts +0 -510
  682. package/src/internal/touch-sheet.ts +0 -21
@@ -0,0 +1,1919 @@
1
+ // Copyright (c) Meta Platforms, Inc. and affiliates.
2
+
3
+ 'use client';
4
+
5
+ /**
6
+ * @file PowerSearchBottomSheet.tsx
7
+ * @input The field's InternalConfig, filters, onChange, the field typeahead
8
+ * source, and the sheet options PowerSearch forwards; BottomSheet,
9
+ * Button, EmptyState, Heading, Icon, IconButton, Indicator, List,
10
+ * RadioList, Text, TextInput, PowerSearchValueEditor, the internal sheet
11
+ * confirmation and search-drag owners, i18n
12
+ * @output Exports PowerSearchBottomSheet — the touch surface of
13
+ * `PowerSearch presentation="bottom-sheet"`: a Filters sheet
14
+ * with editable rows and trailing remove actions, Add filter in its fixed
15
+ * header and Clear all / Done in its fixed footer, an Add filter sheet with
16
+ * grouped field rows or the content search with inline suggestions, and a
17
+ * value step that stages field → operator → value and confirms from its
18
+ * footer
19
+ * @position Internal presentation surface of PowerSearch. Loaded on demand by
20
+ * PowerSearch.tsx so the popover presentation never carries it. The
21
+ * trigger lives in PowerSearch.tsx.
22
+ *
23
+ * The three steps are sibling standalone BottomSheets that stack: each step
24
+ * opens above the sheet that led to it, which stays open beneath as a covered
25
+ * sheet, so no sheet needs a Back action. A dismissal closes only the top
26
+ * sheet and reveals the step beneath; dismissing the bottom sheet ends the
27
+ * flow. A list value's Tokenizer opens its own sheet above the value step, as
28
+ * the top sheet of the stack.
29
+ *
30
+ * The sheets pad their own content (`padding={0}` on BottomSheet). The
31
+ * Filters and Add filter sheets keep their header and footer fixed around a
32
+ * scroll viewport that reaches the sheet edge; its content publishes the
33
+ * padding as container padding so `edge="bleed"` lists run edge to edge with
34
+ * row text on the header's inset. The sheets are pinned tall: the field list
35
+ * resizes as it is searched and the editor changes with the operator, and
36
+ * only a fully expanded tall sheet gives mobile-keyboard accommodation.
37
+ *
38
+ * SYNC: When modified, update:
39
+ * - /packages/core/src/PowerSearch/PowerSearch.tsx (the trigger and the lazy host)
40
+ * - /docs/specs/components/PowerSearch/PowerSearch.spec.md (FR10–FR21, AR4–AR6, PR5)
41
+ */
42
+ import React, { useCallback, useEffect, useId, useLayoutEffect, useMemo, useRef, useState } from 'react';
43
+ import { flushSync } from 'react-dom';
44
+ import * as stylex from '@stylexjs/stylex';
45
+ import { BottomSheet } from "../BottomSheet/BottomSheet.js";
46
+ import { Button } from "../Button/Button.js";
47
+ import { EmptyState } from "../EmptyState/EmptyState.js";
48
+ import { Heading } from "../Heading/Heading.js";
49
+ import { Icon } from "../Icon/Icon.js";
50
+ import { IconButton } from "../IconButton/IconButton.js";
51
+ import { CheckboxIndicator } from "../Indicator/CheckboxIndicator.js";
52
+ import { RadioIndicator } from "../Indicator/RadioIndicator.js";
53
+ import { focusOutlineStyles } from "../utils/focusOutline.stylex.js";
54
+ import { isRenderable } from "../utils/isRenderable.js";
55
+ import { containerPaddingInlineVarStyles } from "../Layout/padding.stylex.js";
56
+ import { List } from "../List/List.js";
57
+ import { ListItem } from "../List/ListItem.js";
58
+ import { RadioList } from "../RadioList/RadioList.js";
59
+ import { RadioListItem } from "../RadioList/RadioListItem.js";
60
+ import { Text } from "../Text/Text.js";
61
+ import { TextInput } from "../TextInput/TextInput.js";
62
+ import { useAnnounce } from "../hooks/useAnnounce.js";
63
+ import { useListFormatter } from "../i18n/useListFormatter.js";
64
+ import { useLocale } from "../i18n/useLocale.js";
65
+ import { SheetConfirmation } from "../internal/SheetConfirmation.js";
66
+ import { useDismissSearchOnTouchDrag } from "../internal/useDismissSearchOnTouchDrag.js";
67
+ import "../theme/tokens.stylex.js";
68
+ import { colorVars, fontWeightVars, radiusVars, spacingVars } from "../theme/tokens.stylex.js";
69
+ import { isImeKeyEvent } from "../utils/ime.js";
70
+ import { rtlStyles } from "../utils/rtlStyles.js";
71
+ import { formatTokenValueText } from "./formatTokenValue.js";
72
+ function resolveRelativeDateLabel(operatorValue, value, t, buildRelativeDateOptions) {
73
+ return buildRelativeDateOptions(operatorValue, t).find(option => option.value === value)?.label ?? value;
74
+ }
75
+
76
+ // A placeholder the Filters row formats `labelValue` with, then splits on, so
77
+ // the value segment can render bold inside the catalog's ordering. A private
78
+ // use code point: never part of a label or value.
79
+ const ROW_VALUE_SLOT = '\uE000';
80
+ import { useAnnounceRenderedText } from "../hooks/useAnnounceRenderedText.js";
81
+ import { useInternalListFocus } from "../hooks/useListFocus.js";
82
+ import { useMergedRefs } from "../hooks/useMergedRefs.js";
83
+ import { groupItems } from "../utils/groupItems.js";
84
+ import { createSheetSuggestionSource, fieldMatchesQuery, createFilterIdentities, filterSignature, isSupportedOperator, nearestEditableIndex, resolveFilterIdentityIndex } from "./powerSearchSheetUtils.js";
85
+ import { resolveOperatorLabel } from "./resolveOperatorLabel.js";
86
+ import { registerEnglishFallback, useComponentTranslator } from "../i18n/useComponentTranslator.js";
87
+ import english from "../i18n/generated-english/PowerSearch/PowerSearchBottomSheet.generated.js";
88
+ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
89
+ registerEnglishFallback(english);
90
+
91
+ // =============================================================================
92
+ // Props
93
+ // =============================================================================
94
+
95
+ /**
96
+ * The popover presentation's editors, which the value step reuses. They come
97
+ * from PowerSearch.tsx, whose module graph already loads them for the popover
98
+ * presentation. Imported here, they and every component they reach would join
99
+ * this lazily imported graph, whose modules must import Core directly and
100
+ * never through a barrel.
101
+ */
102
+
103
+ // =============================================================================
104
+ // Styles
105
+ // =============================================================================
106
+
107
+ // The trailing plus a field row shows when choosing it adds the filter at
108
+ // once, and the Add filter actions' glyph. Core's default icon set has no plus.
109
+ function PlusIcon(props) {
110
+ return /*#__PURE__*/_jsxs("svg", {
111
+ viewBox: "0 0 24 24",
112
+ fill: "none",
113
+ stroke: "currentColor",
114
+ strokeWidth: 1.5,
115
+ strokeLinecap: "round",
116
+ strokeLinejoin: "round",
117
+ ...props,
118
+ children: [/*#__PURE__*/_jsx("path", {
119
+ d: "M5 12h14"
120
+ }), /*#__PURE__*/_jsx("path", {
121
+ d: "M12 5v14"
122
+ })]
123
+ });
124
+ }
125
+ const styles = {
126
+ touchAction: {
127
+ kAzted: "x1gg8mnh",
128
+ $$css: true
129
+ },
130
+ touchHitArea: {
131
+ "--_power-search-sheet-hit-inset": "x1o3f7l6 xhx5icg",
132
+ "--_power-search-sheet-hit-content": "x1bs45cr x73lxwv",
133
+ k5JduY: "x1oocgs0",
134
+ kwXMNM: "x1j6awrg",
135
+ kv0HGH: "xl7hj2y",
136
+ $$css: true
137
+ },
138
+ body: {
139
+ kzQI83: "x1iyjqo2",
140
+ k1xSpc: "x78zum5",
141
+ kXwgrk: "xdt5ytf",
142
+ kOIVth: "x18g69wz",
143
+ kg3NbH: "x1pzlopt",
144
+ kGO01o: "x1awphl8",
145
+ $$css: true
146
+ },
147
+ scrollContent: {
148
+ kAzted: "x1us19tq",
149
+ k1xSpc: "x78zum5",
150
+ kXwgrk: "xdt5ytf",
151
+ kOIVth: "x18g69wz",
152
+ kg3NbH: "x1pzlopt",
153
+ kGO01o: "x1awphl8",
154
+ $$css: true
155
+ },
156
+ footerEqualAction: {
157
+ kzQI83: "x1iyjqo2",
158
+ kCS8Yb: "x1r8uery",
159
+ k7Eaqz: "xeuugli",
160
+ kAzted: "x1gg8mnh",
161
+ $$css: true
162
+ },
163
+ footerSoleAction: {
164
+ kzQI83: "x1iyjqo2",
165
+ $$css: true
166
+ },
167
+ emptyState: {
168
+ kzQI83: "x1iyjqo2",
169
+ k1xSpc: "x78zum5",
170
+ kGNEyG: "x6s0dn4",
171
+ kjj79g: "xl56j7k",
172
+ $$css: true
173
+ },
174
+ controlSection: {
175
+ kmVPX3: "x1b2ylru",
176
+ kaIpWk: "x1hviunn",
177
+ kWkggS: "xwmxj5m",
178
+ $$css: true
179
+ },
180
+ trailingControlRow: {
181
+ kXwgrk: "x15zctf7",
182
+ $$css: true
183
+ },
184
+ nestedEditorContainer: {
185
+ k9g6sI: "x12h1iku",
186
+ kVQacm: "xb3r6kr",
187
+ $$css: true
188
+ },
189
+ choiceRow: {
190
+ k1xSpc: "x78zum5",
191
+ kGNEyG: "x6s0dn4",
192
+ kOIVth: "xjcht0a",
193
+ kzqmXN: "xh8yej3",
194
+ kAzted: "x1gg8mnh",
195
+ k8WAf4: "x8o8v82",
196
+ kZCmMZ: "x1ew2rer",
197
+ kwRFfy: "x19m2zy8",
198
+ kMzoRj: "xc342km",
199
+ kaIpWk: "x2u8bby",
200
+ kWkggS: "xjbqb8w",
201
+ kMwMTN: "x1tgivj0",
202
+ kMv6JI: "xjb2p0i",
203
+ k9WMMc: "x1yc453h",
204
+ kkrTdU: "x1ypdohk xvivl9a",
205
+ $$css: true
206
+ },
207
+ choiceRowDisabled: {
208
+ kMwMTN: "xv1l7n4 x1bhcspo",
209
+ $$css: true
210
+ },
211
+ choiceLabel: {
212
+ kzQI83: "x1iyjqo2",
213
+ k7Eaqz: "xeuugli",
214
+ $$css: true
215
+ }
216
+ };
217
+
218
+ // =============================================================================
219
+ // Draft state
220
+ // =============================================================================
221
+
222
+ function resolveDraftFilterIndex(filters, draft) {
223
+ if (draft.mode !== 'edit' || draft.filterIndex == null || draft.sourceFilter == null || draft.sourceSignature == null) {
224
+ return null;
225
+ }
226
+ return resolveFilterIdentityIndex(filters, draft.sourceFilter, draft.sourceSignature, draft.filterIndex);
227
+ }
228
+
229
+ // Below this many fields a search box is noise: the whole list is on screen.
230
+ const SEARCHABLE_FIELD_COUNT = 8;
231
+ // Empty-query browsing keeps the popover presentation's safety ceiling.
232
+ const MAX_BROWSE_MENU_ITEMS = 1000;
233
+
234
+ // =============================================================================
235
+ // Choice rows (enum, enum_list, date_relative)
236
+ // =============================================================================
237
+
238
+ /**
239
+ * Rendered inside a step's BottomSheet so that `useAnnounce` resolves the
240
+ * sheet's dialog as the enclosing modal; publishes that
241
+ * dialog's `announce` to the flow above through `onAnnounceChange` while
242
+ * mounted. Renders nothing.
243
+ */
244
+ function SheetAnnouncer({
245
+ onAnnounceChange
246
+ }) {
247
+ const announce = useAnnounce();
248
+ // Hands this dialog's announce function up; the cleanup withdraws it when
249
+ // the step changes or the flow closes.
250
+ useEffect(() => {
251
+ onAnnounceChange(announce);
252
+ return () => {
253
+ onAnnounceChange(null);
254
+ };
255
+ }, [announce, onAnnounceChange]);
256
+ return null;
257
+ }
258
+
259
+ /**
260
+ * The value step's "This filter is no longer available" message, rendered
261
+ * inside the step's dialog. The shared own-content module reads the rendered
262
+ * text and speaks it once per opened filter while the step is the open one.
263
+ * Called from inside the sheet's dialog, `useAnnounce` routes it into the
264
+ * dialog. The message is plain text, not an EmptyState, so nothing announces
265
+ * it a second time.
266
+ */
267
+ function SheetEmptyMessage({
268
+ id,
269
+ message,
270
+ occasion,
271
+ isShown
272
+ }) {
273
+ const ref = useRef(null);
274
+ useAnnounceRenderedText(ref, isShown, occasion);
275
+ return /*#__PURE__*/_jsx("div", {
276
+ ref: ref,
277
+ id: id,
278
+ ...{
279
+ className: "xq6koh6 x2b8uid"
280
+ },
281
+ children: /*#__PURE__*/_jsx(Text, {
282
+ type: "supporting",
283
+ color: "secondary",
284
+ children: message
285
+ })
286
+ });
287
+ }
288
+ // A radio group's one tab stop: the checked row, else the first.
289
+ function radioTabStopOrder(list) {
290
+ const rows = Array.from(list.querySelectorAll('[role="radio"]'));
291
+ const checked = rows.find(row => row.getAttribute('aria-checked') === 'true');
292
+ return checked == null ? rows : [checked, ...rows.filter(row => row !== checked)];
293
+ }
294
+
295
+ /**
296
+ * Closed vocabularies render as full-width rows with a trailing check instead
297
+ * of the popover presentation's Selector or Tokenizer: a dropdown layer inside
298
+ * a sheet stacks a second overlay on a surface the person is already inside.
299
+ */
300
+ function ChoiceRows({
301
+ items,
302
+ selected,
303
+ isDisabled,
304
+ isMultiple,
305
+ label,
306
+ onToggle
307
+ }) {
308
+ // The rows carry their state as state, not as a name suffix: `radio` rows
309
+ // in a `radiogroup` for a single choice, `checkbox` rows in a `group` for
310
+ // `enum_list`, each with `aria-checked`, as the Tokenizer's sheet rows do.
311
+ // Disabled rows stay focusable with `aria-disabled`.
312
+ //
313
+ // Keyboard: a radio group is one tab stop — the checked row, else the
314
+ // first — and the arrow keys move focus and check the row they land on,
315
+ // wrapping; Home and End move to and check the first and last row. The
316
+ // shared list focus owns the tab stop and the moves; a row that takes focus
317
+ // from an arrow, Home or End is checked here. Space and Enter check the
318
+ // focused radio row and toggle a checkbox row: each row is a native
319
+ // `button`, whose activation fires `onClick` for both keys. A checkbox row
320
+ // is its own tab stop.
321
+ const isKeyMoveRef = useRef(false);
322
+ const {
323
+ listRef,
324
+ handleKeyDown,
325
+ handleFocus
326
+ } = useInternalListFocus({
327
+ itemSelector: '[role="radio"]',
328
+ orientation: 'both',
329
+ hasRovingTabIndex: !isMultiple,
330
+ tabStopOrder: radioTabStopOrder
331
+ });
332
+ const handleRadioKeyDown = event => {
333
+ isKeyMoveRef.current = true;
334
+ try {
335
+ handleKeyDown(event);
336
+ } finally {
337
+ isKeyMoveRef.current = false;
338
+ }
339
+ };
340
+ const handleRadioFocus = event => {
341
+ handleFocus(event);
342
+ if (!isKeyMoveRef.current || isDisabled) {
343
+ return;
344
+ }
345
+ const value = event.target.closest('[role="radio"]')?.dataset.value;
346
+ if (value != null && !selected.has(value)) {
347
+ onToggle(value, false);
348
+ }
349
+ };
350
+ return /*#__PURE__*/_jsx("div", {
351
+ ref: listRef,
352
+ role: isMultiple ? 'group' : 'radiogroup',
353
+ "aria-label": label,
354
+ onKeyDown: isMultiple ? undefined : handleRadioKeyDown,
355
+ onFocus: isMultiple ? undefined : handleRadioFocus,
356
+ ...{
357
+ className: "x78zum5 xdt5ytf xojxgvx x1fcf3bl xx6qvi6"
358
+ },
359
+ children: items.map(item => {
360
+ const isSelected = selected.has(item.value);
361
+ return /*#__PURE__*/_jsxs("button", {
362
+ type: "button",
363
+ role: isMultiple ? 'checkbox' : 'radio',
364
+ "aria-checked": isSelected,
365
+ "aria-disabled": isDisabled || undefined,
366
+ "data-value": item.value,
367
+ onClick: () => {
368
+ if (!isDisabled) {
369
+ onToggle(item.value, isSelected);
370
+ }
371
+ },
372
+ ...stylex.props(focusOutlineStyles.focusVisible, styles.choiceRow, isDisabled && styles.choiceRowDisabled),
373
+ children: [isRenderable(item.icon) && /*#__PURE__*/_jsx("span", {
374
+ "aria-hidden": "true",
375
+ ...{
376
+ className: "x3nfvp2 x2lah0s"
377
+ },
378
+ children: item.icon
379
+ }), /*#__PURE__*/_jsx(Text, {
380
+ type: "body",
381
+ color: isDisabled ? 'inherit' : undefined,
382
+ xstyle: styles.choiceLabel,
383
+ children: item.label
384
+ }), isMultiple ? /*#__PURE__*/_jsx(CheckboxIndicator, {
385
+ state: isSelected ? 'checked' : 'unchecked',
386
+ size: "md",
387
+ isDisabled: isDisabled
388
+ }) : /*#__PURE__*/_jsx(RadioIndicator, {
389
+ state: isSelected ? 'checked' : 'unchecked',
390
+ size: "md",
391
+ isDisabled: isDisabled
392
+ })]
393
+ }, item.value);
394
+ })
395
+ });
396
+ }
397
+
398
+ /**
399
+ * The value control for one filter inside the value step. Closed vocabularies
400
+ * are rows here; every other type is the popover presentation's own editor in
401
+ * its sheet presentation.
402
+ */
403
+ function SheetValueEditor({
404
+ operatorValue,
405
+ filterValue,
406
+ onChange,
407
+ onUnstage,
408
+ config,
409
+ fieldLabel,
410
+ isDisabled,
411
+ maxMenuItems,
412
+ timezoneID,
413
+ editors
414
+ }) {
415
+ const {
416
+ buildRelativeDateOptions,
417
+ PowerSearchValueEditor
418
+ } = editors;
419
+ const t = useComponentTranslator();
420
+ const selectedValues = useMemo(() => {
421
+ if (filterValue?.type === 'enum' || filterValue?.type === 'date_relative') {
422
+ return new Set([filterValue.value]);
423
+ }
424
+ if (filterValue?.type === 'enum_list') {
425
+ return new Set(filterValue.value);
426
+ }
427
+ return new Set();
428
+ }, [filterValue]);
429
+ switch (operatorValue.type) {
430
+ case 'empty':
431
+ case 'nested':
432
+ return null;
433
+ case 'enum':
434
+ return /*#__PURE__*/_jsx(ChoiceRows, {
435
+ items: operatorValue.values,
436
+ selected: selectedValues,
437
+ isDisabled: isDisabled,
438
+ isMultiple: false,
439
+ label: fieldLabel,
440
+ onToggle: value => onChange({
441
+ type: 'enum',
442
+ value
443
+ })
444
+ });
445
+ case 'enum_list':
446
+ return /*#__PURE__*/_jsx(ChoiceRows, {
447
+ items: operatorValue.values,
448
+ selected: selectedValues,
449
+ isDisabled: isDisabled,
450
+ isMultiple: true,
451
+ label: fieldLabel,
452
+ onToggle: (value, isSelected) => {
453
+ const existing = filterValue?.type === 'enum_list' ? filterValue.value : [];
454
+ onChange({
455
+ type: 'enum_list',
456
+ value: isSelected ? existing.filter(v => v !== value) : [...existing, value]
457
+ });
458
+ }
459
+ });
460
+ case 'date_relative':
461
+ return /*#__PURE__*/_jsx(ChoiceRows, {
462
+ items: buildRelativeDateOptions(operatorValue, t),
463
+ selected: selectedValues,
464
+ isDisabled: isDisabled,
465
+ isMultiple: false,
466
+ label: fieldLabel,
467
+ onToggle: value => onChange({
468
+ type: 'date_relative',
469
+ value
470
+ })
471
+ });
472
+ case 'string':
473
+ case 'string_list':
474
+ case 'integer':
475
+ case 'float':
476
+ case 'time':
477
+ case 'date_absolute':
478
+ case 'date_range':
479
+ case 'entity_list':
480
+ case 'custom':
481
+ return /*#__PURE__*/_jsx("div", {
482
+ ...{
483
+ className: "xfsso4q"
484
+ },
485
+ children: /*#__PURE__*/_jsx(PowerSearchValueEditor, {
486
+ operatorValue: operatorValue,
487
+ filterValue: filterValue,
488
+ onChange: onChange,
489
+ onUnstage: onUnstage,
490
+ config: config,
491
+ maxMenuItems: maxMenuItems,
492
+ isDisabled: isDisabled,
493
+ presentation: "bottom-sheet",
494
+ fieldLabel: fieldLabel,
495
+ timezoneID: timezoneID
496
+ })
497
+ });
498
+ }
499
+ }
500
+
501
+ // =============================================================================
502
+ // Component
503
+ // =============================================================================
504
+
505
+ /**
506
+ * The sheet flow of PowerSearch's touch presentation: Filters, Add filter,
507
+ * and the value step, as standalone sheets that stack, each open beneath the
508
+ * step it led to.
509
+ */
510
+ export function PowerSearchBottomSheet({
511
+ isOpen,
512
+ onOpenChange,
513
+ finalFocusRef,
514
+ resultCountText,
515
+ config,
516
+ configProp,
517
+ filters,
518
+ onChange,
519
+ searchSource,
520
+ placeholder,
521
+ isReadOnly,
522
+ isDisabled,
523
+ hasClear,
524
+ maxOperatorMenuItems,
525
+ timezoneID,
526
+ maxSearchResults,
527
+ saveButtonLabel: saveButtonLabelFromProps,
528
+ components: componentOverrides,
529
+ editors
530
+ }) {
531
+ const {
532
+ NestedEditor
533
+ } = editors;
534
+ const t = useComponentTranslator();
535
+ const locale = useLocale();
536
+ const formatList = useListFormatter();
537
+ const isInteractive = !isDisabled && !isReadOnly;
538
+ const contentSearchFieldKey = config.config.contentSearchFieldKey;
539
+ const contentSearchOperator = contentSearchFieldKey == null ? undefined : config.getDefaultOperator(contentSearchFieldKey);
540
+ const hasContentSearch = contentSearchOperator?.value.type === 'string';
541
+ const suggestionSource = useMemo(() => createSheetSuggestionSource(config, searchSource), [config, searchSource]);
542
+ const contentResultsId = useId();
543
+ const managerAddButtonRef = useRef(null);
544
+ const contentSearchRef = useRef(null);
545
+ const fieldSearchRef = useRef(null);
546
+ // The Add filter sheet's panel: the fallback focus target when the control
547
+ // a step came from is gone — its first focusable control, which is the
548
+ // search field when one shows, else the first field row.
549
+ const fieldsSheetRef = useRef(null);
550
+ // The content search and its suggestion rows are one vertical list for the
551
+ // arrow keys: ArrowDown from the searchbox reaches the first suggestion,
552
+ // ArrowUp from the first suggestion returns to the searchbox, and the ends
553
+ // do not wrap. Home and End stay with the searchbox's caret.
554
+ const contentListFocus = useInternalListFocus({
555
+ itemSelector: `[role="searchbox"], [id="${contentResultsId}"] button`,
556
+ wrap: false,
557
+ hasHomeEnd: false
558
+ });
559
+ const fieldsSheetCallbackRef = useMergedRefs(fieldsSheetRef, contentListFocus.listRef);
560
+ const handleContentListKeyDown = event => {
561
+ if (!isImeKeyEvent(event.nativeEvent)) {
562
+ contentListFocus.handleKeyDown(event);
563
+ }
564
+ };
565
+ const manageSheetRef = useRef(null);
566
+ // Where focus was inside the Filters or Add filter sheet, read on every
567
+ // focus change there, so a controlled update that unmounts the focused
568
+ // control (a filter's row, a dropped field's row, Clear all after the last
569
+ // filter) can put focus on the nearest remaining row by that index, else
570
+ // the sheet's first control, else the sheet panel. A removed element
571
+ // fires no blur, so the position is what the effect below reads.
572
+ const lastSheetFocusRef = useRef(null);
573
+ // One index space for the record and the recovery: rows that are buttons
574
+ // (a plain read-only row is passed over, as the removal and Apply/Cancel
575
+ // rules pass it over), in document order.
576
+ const buttonRowsOf = panel => Array.from(panel.querySelectorAll('li')).map(row => row.querySelector('button')).filter(button => button != null);
577
+ const noteSheetFocus = useCallback(sheet => event => {
578
+ const row = event.target.closest('li');
579
+ const button = row?.querySelector('button') ?? null;
580
+ const rowIndex = button == null ? -1 : buttonRowsOf(event.currentTarget).indexOf(button);
581
+ lastSheetFocusRef.current = {
582
+ sheet,
583
+ rowIndex: rowIndex === -1 ? null : rowIndex
584
+ };
585
+ }, []);
586
+ const managerRowsRef = useRef(new Map());
587
+ const fieldRowsRef = useRef(new Map());
588
+ const latestFiltersRef = useRef(filters);
589
+ const pendingSheetFocusRef = useRef(null);
590
+ const pendingMutationFocusRef = useRef(false);
591
+
592
+ // The step an open starts on: Add filter directly when an interactive field
593
+ // has nothing to manage yet, otherwise Filters. Neither search field takes
594
+ // focus on open, so the software keyboard stays down until the person taps
595
+ // the search. Add filter opened directly is the flow's entry point: no
596
+ // Filters sheet beneath it, and Done in its footer.
597
+ const isEntryAddFilter = filters.length === 0 && isInteractive;
598
+ const [step, setStep] = useState(() => isOpen ? isEntryAddFilter ? 'fields' : 'manage' : null);
599
+ const [fieldPickerOrigin, setFieldPickerOrigin] = useState(() => isOpen && isEntryAddFilter ? 'trigger' : 'manage');
600
+ // The current step, read by the sheets' close reports and by a removal that
601
+ // decides where to speak.
602
+ const stepRef = useRef(step);
603
+ useLayoutEffect(() => {
604
+ stepRef.current = step;
605
+ }, [step]);
606
+ // The draft outlives a step change on purpose: a closing value step stays
607
+ // presented through its exit, and clearing the draft with the step would
608
+ // blank that sheet mid-transition.
609
+ const [draft, setDraft] = useState(null);
610
+ const draftGenerationRef = useRef(0);
611
+ const nextDraftGeneration = useCallback(() => {
612
+ draftGenerationRef.current += 1;
613
+ return draftGenerationRef.current;
614
+ }, []);
615
+ const [fieldQuery, setFieldQuery] = useState('');
616
+ const [contentQuery, setContentQuery] = useState('');
617
+ const [isClearConfirmationOpen, setIsClearConfirmationOpen] = useState(false);
618
+ const clearAllButtonRef = useRef(null);
619
+ // Set while Clear all commits, so the result count that changes in that
620
+ // commit is spoken with Clear all's outcome, as one message.
621
+ const isClearingRef = useRef(false);
622
+
623
+ // `useAnnounce` delivers inside the open Astryx modal that encloses its
624
+ // caller, and this component renders above the
625
+ // sheets, so it cannot call the hook itself. Each step's body renders a
626
+ // `SheetAnnouncer` inside its BottomSheet, which publishes the dialog's own
627
+ // `announce` here while that step is the active one; the effects below
628
+ // speak through it, so every message about a sheet's content is delivered
629
+ // in that sheet's dialog.
630
+ const announceRef = useRef(null);
631
+ const handleAnnounceChange = useCallback(next => {
632
+ announceRef.current = next;
633
+ }, []);
634
+ const announce = useCallback(message => {
635
+ announceRef.current?.(message);
636
+ }, []);
637
+ const pendingAnnouncementRef = useRef(null);
638
+
639
+ // The controlled `isOpen` opens and closes the flow; the step follows it in
640
+ // the render that sees the change, not an effect, so the entry step's sheet
641
+ // opens in the same commit as the flow (React's adjust-state-on-
642
+ // prop-change pattern). Closing from outside — the field became disabled —
643
+ // ends the flow wherever it was, the Clear all confirmation included.
644
+ const [wasOpen, setWasOpen] = useState(isOpen);
645
+ if (isOpen !== wasOpen) {
646
+ setWasOpen(isOpen);
647
+ if (isOpen) {
648
+ setFieldQuery('');
649
+ setContentQuery('');
650
+ setStep(isEntryAddFilter ? 'fields' : 'manage');
651
+ setFieldPickerOrigin(isEntryAddFilter ? 'trigger' : 'manage');
652
+ } else {
653
+ setStep(null);
654
+ setIsClearConfirmationOpen(false);
655
+ }
656
+ }
657
+ const closeFlow = useCallback(() => {
658
+ pendingSheetFocusRef.current = null;
659
+ setStep(null);
660
+ onOpenChange(false);
661
+ }, [onOpenChange]);
662
+
663
+ // Whether a Filters row is a button: the field interactive and the
664
+ // filter not read-only. The row opens the value step — the editor for its
665
+ // operator's value type, the built-in nested editor for a `nested` one, or
666
+ // for a filter the config no longer knows the unavailable state — and its
667
+ // trailing remove action removes it, as the popover's token has its × for
668
+ // it.
669
+ const isRowButton = useCallback(filter => !filter.isReadOnly && isInteractive, [isInteractive]);
670
+
671
+ // ------------------------------------------------------------------ focus --
672
+
673
+ // The control a step change named also becomes where the closing step
674
+ // sheets return focus when their exit ends: a closing sheet that held focus
675
+ // keeps it until then, and BottomSheet then returns it, so the named control
676
+ // receives it even when the first move could not land. With no control
677
+ // named, the closing steps return focus as the flow does.
678
+ const stepReturnTargetRef = useRef(null);
679
+ const stepFinalFocusRef = useMemo(() => ({
680
+ get current() {
681
+ return stepReturnTargetRef.current ?? finalFocusRef.current;
682
+ }
683
+ }), [finalFocusRef]);
684
+ const placeFocus = element => {
685
+ if (element == null) {
686
+ return;
687
+ }
688
+ stepReturnTargetRef.current = element;
689
+ element.focus({
690
+ preventScroll: true
691
+ });
692
+ };
693
+ const focusPendingSheetTarget = useCallback(() => {
694
+ const target = pendingSheetFocusRef.current;
695
+ if (target == null) {
696
+ return;
697
+ }
698
+ pendingSheetFocusRef.current = null;
699
+ if (target.type === 'manager-add') {
700
+ placeFocus(managerAddButtonRef.current);
701
+ return;
702
+ }
703
+ // Add filter's fallback: a controlled update may have removed the field
704
+ // whose row opened the step, or the content-search field itself; the
705
+ // sheet's first focusable control then takes focus — the search field
706
+ // when one shows, else the first field row.
707
+ const firstFieldsControl = () => {
708
+ const panel = fieldsSheetRef.current;
709
+ return panel?.querySelector('input') ?? panel?.querySelector('li button') ?? panel?.querySelector('button') ?? null;
710
+ };
711
+ if (target.type === 'content-search') {
712
+ placeFocus(contentSearchRef.current?.querySelector('input') ?? firstFieldsControl());
713
+ return;
714
+ }
715
+ if (target.type === 'field') {
716
+ placeFocus(fieldRowsRef.current.get(target.fieldKey)?.querySelector('button') ?? firstFieldsControl());
717
+ return;
718
+ }
719
+ // The row the step came from, followed across a controlled reorder or
720
+ // clone; when a controlled update removed it, or left two filters it
721
+ // could be, the nearest remaining row that is a button, as after a
722
+ // removal; else Add filter.
723
+ const index = resolveFilterIdentityIndex(latestFiltersRef.current, target.sourceFilter, target.sourceSignature, target.preferredIndex) ?? nearestEditableIndex(latestFiltersRef.current, target.preferredIndex, isRowButton);
724
+ const row = index == null ? null : managerRowsRef.current.get(index);
725
+ const rowButton = target.part === 'remove' ? row?.querySelector('[data-sheet-remove]') ?? row?.querySelector('button') : row?.querySelector('button');
726
+ placeFocus(rowButton ?? managerAddButtonRef.current);
727
+ }, [isRowButton]);
728
+
729
+ // A controlled update that unmounts the focused control of the Filters or
730
+ // Add filter sheet leaves focus on the page body inside the open modal.
731
+ // Read before paint on every commit of an open step: when focus is no
732
+ // longer inside the sheet's dialog, the nearest remaining row by the last
733
+ // focused index takes it, else the sheet's first control, else its panel.
734
+ // The pending-target effects below run after and win when a step
735
+ // change named a control.
736
+ useLayoutEffect(() => {
737
+ const last = lastSheetFocusRef.current;
738
+ if (step !== 'manage' && step !== 'fields') {
739
+ return;
740
+ }
741
+ if (last == null || last.sheet !== step) {
742
+ return;
743
+ }
744
+ const panel = step === 'manage' ? manageSheetRef.current : fieldsSheetRef.current;
745
+ const dialog = panel?.closest('dialog');
746
+ const active = document.activeElement;
747
+ if (panel == null || dialog == null || active != null && active !== document.body && dialog.contains(active)) {
748
+ return;
749
+ }
750
+ const rowButtons = buttonRowsOf(panel);
751
+ let target = null;
752
+ if (last.rowIndex != null && rowButtons.length > 0) {
753
+ // The following button row, else the last.
754
+ target = rowButtons[Math.min(last.rowIndex, rowButtons.length - 1)];
755
+ }
756
+ target ??= panel.querySelector('input') ?? rowButtons[0] ?? panel.querySelector('button') ?? null;
757
+ if (target != null) {
758
+ target.focus({
759
+ preventScroll: true
760
+ });
761
+ } else {
762
+ const focusable = dialog.querySelector('[tabindex="-1"]');
763
+ (focusable ?? dialog).focus({
764
+ preventScroll: true
765
+ });
766
+ }
767
+ });
768
+
769
+ // Both Effects move focus inside the entering sheet — the external system
770
+ // is the document's focus — to the control the step named. They run after
771
+ // the entering sheet's own
772
+ // panel focus (child effects commit first), so the intended control wins,
773
+ // and they acquire nothing, so they need no cleanup. The filters effect is
774
+ // declared first so a mutation that lands in the same commit as the step
775
+ // change resolves its row against the new filters.
776
+ useEffect(() => {
777
+ latestFiltersRef.current = filters;
778
+ if (step === 'manage' && pendingMutationFocusRef.current) {
779
+ pendingMutationFocusRef.current = false;
780
+ focusPendingSheetTarget();
781
+ }
782
+ }, [filters, focusPendingSheetTarget, step]);
783
+
784
+ // A target still pending when the flow closes, such as a commit that
785
+ // disabled the field, never carries into the next open.
786
+ useEffect(() => {
787
+ if (step == null) {
788
+ stepReturnTargetRef.current = null;
789
+ pendingSheetFocusRef.current = null;
790
+ return;
791
+ }
792
+ // A step that opens starts with no named return target; a return to
793
+ // Filters keeps the one its commit, or its removal, has just named.
794
+ if (step !== 'manage') {
795
+ stepReturnTargetRef.current = null;
796
+ }
797
+ focusPendingSheetTarget();
798
+ }, [focusPendingSheetTarget, step]);
799
+
800
+ // An announcement queued by a step change — a suggestion or a removal that
801
+ // changed the filters — is spoken in the commit that shows the next step,
802
+ // so it lands in that step's dialog region rather than the one about to
803
+ // close. It synchronizes the live region named above and acquires nothing.
804
+ useEffect(() => {
805
+ const message = pendingAnnouncementRef.current;
806
+ if (step != null && message != null) {
807
+ pendingAnnouncementRef.current = null;
808
+ announce(message);
809
+ }
810
+ }, [announce, step]);
811
+
812
+ // ----------------------------------------------------------------- fields --
813
+
814
+ // Every visible field lists: the value step edits every operator's value,
815
+ // `nested` through the popover's built-in editor.
816
+ const fields = useMemo(() => config.getVisibleFields(), [config]);
817
+ const normalizedFieldQuery = fieldQuery.trim().toLowerCase();
818
+ const matchingFields = useMemo(() => {
819
+ const matches = fields.filter(field => fieldMatchesQuery(field, normalizedFieldQuery));
820
+ return normalizedFieldQuery === '' ? matches : matches.slice(0, maxSearchResults);
821
+ }, [fields, maxSearchResults, normalizedFieldQuery]);
822
+
823
+ // Ungrouped fields first, then each group in first-appearance order — the
824
+ // same grouping the popover presentation's field suggestions use
825
+ // (`groupItems` with `ungroupedFirst`), so the two presentations
826
+ // list a config's fields in one order.
827
+ const groupedFields = useMemo(() => matchingFields.length === 0 ? [] : groupItems(matchingFields.map(field => ({
828
+ id: field.key,
829
+ label: field.label,
830
+ auxiliaryData: {
831
+ group: field.group
832
+ },
833
+ field
834
+ })), {
835
+ ungroupedFirst: true
836
+ }).map(group => [group.heading ?? '', group.items.map(item => item.field)]), [matchingFields]);
837
+ const isFieldSearchShown = fields.length >= SEARCHABLE_FIELD_COUNT;
838
+
839
+ // A field whose only operator takes an `empty` value is a one-tap filter:
840
+ // its row adds it with no value step, and shows a plus, not a chevron.
841
+ const isImmediateAddField = useCallback(field => {
842
+ const operators = config.getVisibleOperators(field.key);
843
+ return operators.length === 1 && operators[0].value.type === 'empty';
844
+ }, [config]);
845
+
846
+ // The steps stack: each opens above the sheet that led to it, which stays
847
+ // open beneath. Add filter entered directly has no Filters sheet beneath.
848
+ const isFieldPickerDirectEntry = fieldPickerOrigin === 'trigger';
849
+ const isManageSheetOpen = step === 'manage' || step === 'fields' && !isFieldPickerDirectEntry || step === 'value' && (draft?.mode === 'edit' || !isFieldPickerDirectEntry);
850
+ const isFieldsSheetOpen = step === 'fields' || step === 'value' && draft?.mode === 'create';
851
+
852
+ // The suggestions derive synchronously from the config, so a list never
853
+ // waits on a request: an empty list means an empty result, not a pending
854
+ // one. They stay listed while the value step covers Add filter.
855
+ const contentResults = useMemo(() => {
856
+ if (!isFieldsSheetOpen || !hasContentSearch || !isInteractive) {
857
+ return [];
858
+ }
859
+ const results = contentQuery.trim() === '' ? suggestionSource.bootstrap() : suggestionSource.search(contentQuery);
860
+ return results.slice(0, MAX_BROWSE_MENU_ITEMS);
861
+ }, [contentQuery, hasContentSearch, isFieldsSheetOpen, isInteractive, suggestionSource]);
862
+
863
+ // The field's result count, while a sheet is open: the owner's own Effect
864
+ // is quiet then, so the change is spoken here, inside the dialog. Only a
865
+ // change after the flow opened is spoken.
866
+ const announcedResultCountRef = useRef(resultCountText);
867
+ // The latest result count, for Clear all's handler to read after its
868
+ // commit has flushed.
869
+ const latestResultCountRef = useRef(resultCountText);
870
+ useLayoutEffect(() => {
871
+ latestResultCountRef.current = resultCountText;
872
+ }, [resultCountText]);
873
+ useEffect(() => {
874
+ if (isClearingRef.current || resultCountText === announcedResultCountRef.current) {
875
+ return;
876
+ }
877
+ announcedResultCountRef.current = resultCountText;
878
+ if (step != null && resultCountText != null) {
879
+ announce(resultCountText);
880
+ }
881
+ }, [announce, resultCountText, step]);
882
+
883
+ // ------------------------------------------------------------------ draft --
884
+
885
+ const draftField = draft ? config.getField(draft.field) : undefined;
886
+ const draftOperator = draft?.operator != null ? config.getOperator(draft.field, draft.operator) : undefined;
887
+ const draftOperators = useMemo(() => draft ? config.getVisibleOperators(draft.field) : [], [config, draft]);
888
+
889
+ // The two parts of a Filters row's text for `filter`: "{field} {operator}"
890
+ // as one catalog message, and the value as the popover presentation's
891
+ // token shows it — the same function, so the same words and the same zone
892
+ // handling, before the token's width budget. The rows render these, and
893
+ // the removal announcement joins them, so the three can never
894
+ // disagree.
895
+ const describeFilterParts = useCallback(filter => {
896
+ const field = config.getField(filter.field);
897
+ const operator = config.getOperator(filter.field, filter.operator);
898
+ // A filter whose field or operator the config no longer has still
899
+ // lists, by its raw keys, as its token does on the trigger; its row
900
+ // opens the unavailable step, and its trailing remove action removes
901
+ // it.
902
+ const fieldLabel = field?.label ?? filter.field;
903
+ const operatorLabel = operator == null ? filter.operator : resolveOperatorLabel(operator, t);
904
+ const label = operatorLabel ? t('@astryx.powersearch.sheet.fieldOperator', {
905
+ field: fieldLabel,
906
+ operator: operatorLabel
907
+ }) : fieldLabel;
908
+ if (operator == null) {
909
+ return {
910
+ label,
911
+ value: null
912
+ };
913
+ }
914
+ // A relative-date value is stored as a key (`3d_ago`); the row reads it
915
+ // as the value step's choice row does ("3 days ago"), through the
916
+ // catalog's relative-date messages, so the sheet agrees with itself. The popover token
917
+ // shows the stored key (a known gap of the record).
918
+ const value = operator.value.type === 'date_relative' && filter.value.type === 'date_relative' ? resolveRelativeDateLabel(operator.value, filter.value.value, t, editors.buildRelativeDateOptions) : formatTokenValueText(operator.value, filter.value, Number.MAX_SAFE_INTEGER, locale, t, formatList, timezoneID);
919
+ return {
920
+ label,
921
+ value
922
+ };
923
+ }, [config, editors, formatList, locale, t, timezoneID]);
924
+ const describeFilter = useCallback(filter => {
925
+ const parts = describeFilterParts(filter);
926
+ return parts.value ? t('@astryx.powersearch.sheet.labelValue', {
927
+ label: parts.label,
928
+ value: parts.value
929
+ }) : parts.label;
930
+ }, [describeFilterParts, t]);
931
+ const openFieldList = useCallback(() => {
932
+ if (!isInteractive) {
933
+ return;
934
+ }
935
+ setFieldPickerOrigin('manage');
936
+ setFieldQuery('');
937
+ setContentQuery('');
938
+ pendingSheetFocusRef.current = null;
939
+ setStep('fields');
940
+ }, [isInteractive]);
941
+ const queueManagerAddFocus = useCallback(() => {
942
+ pendingSheetFocusRef.current = {
943
+ type: 'manager-add'
944
+ };
945
+ }, []);
946
+ const commitSavedFilter = useCallback((next, filter) => {
947
+ if (!isInteractive) {
948
+ queueManagerAddFocus();
949
+ setStep('manage');
950
+ return;
951
+ }
952
+ if (next.mode === 'edit') {
953
+ const filterIndex = resolveDraftFilterIndex(filters, next);
954
+ const currentFilter = filterIndex == null ? undefined : filters[filterIndex];
955
+ if (filterIndex == null || currentFilter == null || currentFilter.isReadOnly) {
956
+ // A controlled update removed the edited filter, or left two it
957
+ // could be, or made it read-only: nothing is written, and focus
958
+ // returns to the nearest row that is a button around where it was,
959
+ // else Add filter.
960
+ pendingSheetFocusRef.current = next.sourceFilter != null && next.sourceSignature != null && next.filterIndex != null ? {
961
+ type: 'manager-filter',
962
+ sourceFilter: next.sourceFilter,
963
+ sourceSignature: next.sourceSignature,
964
+ preferredIndex: next.filterIndex
965
+ } : {
966
+ type: 'manager-add'
967
+ };
968
+ setStep('manage');
969
+ return;
970
+ }
971
+ pendingSheetFocusRef.current = {
972
+ type: 'manager-filter',
973
+ sourceFilter: filter,
974
+ sourceSignature: filterSignature(filter),
975
+ preferredIndex: filterIndex
976
+ };
977
+ const updated = [...filters];
978
+ updated[filterIndex] = filter;
979
+ onChange(updated, 'edit', filterIndex);
980
+ } else {
981
+ queueManagerAddFocus();
982
+ onChange([...filters, filter], 'add', filters.length);
983
+ }
984
+ setStep('manage');
985
+ }, [filters, isInteractive, onChange, queueManagerAddFocus]);
986
+
987
+ // Opening a new filter can come from a field row or a content-search
988
+ // suggestion. The origin is kept so Cancel returns to the control the person
989
+ // came from.
990
+ const openCreateEditor = useCallback((field, operator, returnFocus = 'field') => {
991
+ setDraft({
992
+ mode: 'create',
993
+ generation: nextDraftGeneration(),
994
+ returnFocus,
995
+ field: field.key,
996
+ operator: operator.key,
997
+ value: operator.value.type === 'empty' ? {
998
+ type: 'empty'
999
+ } : undefined
1000
+ });
1001
+ pendingSheetFocusRef.current = null;
1002
+ setStep('value');
1003
+ }, [nextDraftGeneration]);
1004
+ const handleFieldSelect = useCallback(field => {
1005
+ if (!isInteractive) {
1006
+ return;
1007
+ }
1008
+ // A one-tap filter has nothing to stage: choosing its field adds it
1009
+ // and returns to Filters.
1010
+ if (isImmediateAddField(field)) {
1011
+ const [operator] = config.getVisibleOperators(field.key);
1012
+ const nextFilter = {
1013
+ field: field.key,
1014
+ operator: operator.key,
1015
+ value: {
1016
+ type: 'empty'
1017
+ }
1018
+ };
1019
+ pendingSheetFocusRef.current = {
1020
+ type: 'manager-filter',
1021
+ sourceFilter: nextFilter,
1022
+ sourceSignature: filterSignature(nextFilter),
1023
+ preferredIndex: filters.length
1024
+ };
1025
+ pendingMutationFocusRef.current = true;
1026
+ onChange([...filters, nextFilter], 'add', filters.length);
1027
+ pendingAnnouncementRef.current = t('@astryx.tokenizer.tokenAdded', {
1028
+ label: describeFilter(nextFilter)
1029
+ });
1030
+ setStep('manage');
1031
+ return;
1032
+ }
1033
+ const operator = config.getDefaultOperator(field.key) ?? field.operators[0];
1034
+ if (operator == null) {
1035
+ return;
1036
+ }
1037
+ openCreateEditor(field, operator);
1038
+ }, [config, describeFilter, filters, isImmediateAddField, isInteractive, onChange, openCreateEditor, t]);
1039
+ const handleContentSuggestionSelect = useCallback(item => {
1040
+ if (!isInteractive || item?.auxiliaryData == null) {
1041
+ return;
1042
+ }
1043
+ const {
1044
+ fieldKey,
1045
+ filterValue,
1046
+ operatorKey
1047
+ } = item.auxiliaryData;
1048
+ const field = config.getField(fieldKey);
1049
+ const operator = operatorKey == null ? config.getDefaultOperator(fieldKey) : config.getOperator(fieldKey, operatorKey);
1050
+ if (field == null || operator == null) {
1051
+ return;
1052
+ }
1053
+ setContentQuery('');
1054
+ if (filterValue != null) {
1055
+ const nextFilter = {
1056
+ field: field.key,
1057
+ operator: operator.key,
1058
+ value: filterValue
1059
+ };
1060
+ pendingSheetFocusRef.current = {
1061
+ type: 'manager-filter',
1062
+ sourceFilter: nextFilter,
1063
+ sourceSignature: filterSignature(nextFilter),
1064
+ preferredIndex: filters.length
1065
+ };
1066
+ pendingMutationFocusRef.current = true;
1067
+ onChange([...filters, nextFilter], 'add', filters.length);
1068
+ // The same announcement the popover presentation's typeahead add
1069
+ // makes, so assistive technology hears one phrase for one outcome;
1070
+ // spoken once the Filters sheet is the open dialog.
1071
+ pendingAnnouncementRef.current = t('@astryx.tokenizer.tokenAdded', {
1072
+ label: item.label
1073
+ });
1074
+ setStep('manage');
1075
+ return;
1076
+ }
1077
+ openCreateEditor(field, operator, 'content-search');
1078
+ }, [config, filters, isInteractive, onChange, openCreateEditor, t]);
1079
+ const handleFilterEdit = useCallback(index => {
1080
+ const filter = filters[index];
1081
+ if (!isInteractive || filter == null || filter.isReadOnly) {
1082
+ return;
1083
+ }
1084
+ setDraft({
1085
+ mode: 'edit',
1086
+ generation: nextDraftGeneration(),
1087
+ filterIndex: index,
1088
+ sourceFilter: filter,
1089
+ sourceSignature: filterSignature(filter),
1090
+ field: filter.field,
1091
+ operator: filter.operator,
1092
+ value: filter.value
1093
+ });
1094
+ pendingSheetFocusRef.current = null;
1095
+ setStep('value');
1096
+ }, [filters, isInteractive, nextDraftGeneration]);
1097
+ const handleRemoveFilter = useCallback(index => {
1098
+ const filter = filters[index];
1099
+ if (!isInteractive || filter == null || filter.isReadOnly) {
1100
+ return;
1101
+ }
1102
+ const nextFilters = filters.filter((_, i) => i !== index);
1103
+ const nextIndex = nearestEditableIndex(nextFilters, index, isRowButton);
1104
+ if (nextIndex == null) {
1105
+ pendingSheetFocusRef.current = {
1106
+ type: 'manager-add'
1107
+ };
1108
+ } else {
1109
+ const nextFilter = nextFilters[nextIndex];
1110
+ pendingSheetFocusRef.current = {
1111
+ type: 'manager-filter',
1112
+ sourceFilter: nextFilter,
1113
+ sourceSignature: filterSignature(nextFilter),
1114
+ preferredIndex: nextIndex,
1115
+ part: 'remove'
1116
+ };
1117
+ }
1118
+ pendingMutationFocusRef.current = true;
1119
+ onChange(nextFilters, 'remove', index);
1120
+ // The popover presentation's token × announces the same phrase. A
1121
+ // removal from a Filters row stays in that sheet and speaks at once; a
1122
+ // caller's Editor that removes while returning to Filters speaks once
1123
+ // the Filters sheet is the open dialog.
1124
+ const message = t('@astryx.tokenizer.tokenRemoved', {
1125
+ label: describeFilter(filter)
1126
+ });
1127
+ if (stepRef.current === 'manage') {
1128
+ announce(message);
1129
+ } else {
1130
+ pendingAnnouncementRef.current = message;
1131
+ }
1132
+ }, [announce, describeFilter, filters, isInteractive, isRowButton, onChange, t]);
1133
+
1134
+ // Closing Clear all's confirmation. Kept, focus returns to Clear all.
1135
+ // Confirmed, Clear all removes the filters the person can edit and keeps
1136
+ // read-only ones, which are the consumer's: one `remove` at the first
1137
+ // removed index. The Filters sheet stays open for further editing. The
1138
+ // confirmation must be gone before focus moves into the sheet and the
1139
+ // outcome is routed into the sheet's region, so its close is flushed
1140
+ // first. The outcome is "Editable filters removed" while a read-only filter
1141
+ // remains, otherwise "All filters removed", joined with a result count that
1142
+ // changed in the same commit as one catalog message; focus moves to the
1143
+ // sheet's first remaining control: a kept read-only row has none, so Add
1144
+ // filter.
1145
+ const closeClearConfirmation = confirmed => {
1146
+ const kept = filters.filter(filter => filter.isReadOnly);
1147
+ const firstRemovedIndex = filters.findIndex(filter => !filter.isReadOnly);
1148
+ const isClearing = confirmed && isInteractive && firstRemovedIndex >= 0;
1149
+ isClearingRef.current = isClearing;
1150
+ try {
1151
+ // eslint-disable-next-line @eslint-react/dom-no-flush-sync -- the confirmation must be gone before focus moves into the sheet and the words are routed into it
1152
+ flushSync(() => {
1153
+ setIsClearConfirmationOpen(false);
1154
+ if (isClearing) {
1155
+ onChange(kept, 'remove', firstRemovedIndex);
1156
+ }
1157
+ });
1158
+ } finally {
1159
+ isClearingRef.current = false;
1160
+ }
1161
+ if (!isClearing) {
1162
+ clearAllButtonRef.current?.focus();
1163
+ return;
1164
+ }
1165
+ managerAddButtonRef.current?.focus({
1166
+ preventScroll: true
1167
+ });
1168
+ const resultCount = latestResultCountRef.current;
1169
+ const changedCount = resultCount !== announcedResultCountRef.current ? resultCount : null;
1170
+ announcedResultCountRef.current = resultCount;
1171
+ if (kept.length > 0) {
1172
+ announce(changedCount == null ? t('@astryx.powersearch.editableFiltersRemoved') : t('@astryx.powersearch.sheet.editableFiltersClearedWithCount', {
1173
+ resultCount: changedCount
1174
+ }));
1175
+ } else {
1176
+ announce(changedCount == null ? t('@astryx.powersearch.allFiltersRemoved') : t('@astryx.powersearch.sheet.filtersClearedWithCount', {
1177
+ resultCount: changedCount
1178
+ }));
1179
+ }
1180
+ };
1181
+ const handleOperatorSelect = useCallback(operator => {
1182
+ setDraft(current => {
1183
+ if (current == null) {
1184
+ return current;
1185
+ }
1186
+ // A value survives an operator change only when the new operator
1187
+ // reads the same value type.
1188
+ const keepsValue = current.value != null && current.value.type === operator.value.type;
1189
+ return {
1190
+ ...current,
1191
+ operator: operator.key,
1192
+ value: operator.value.type === 'empty' ? {
1193
+ type: 'empty'
1194
+ } : keepsValue ? current.value : undefined
1195
+ };
1196
+ });
1197
+ }, []);
1198
+ const handleDraftValueChange = useCallback(value => {
1199
+ setDraft(current => current == null ? current : {
1200
+ ...current,
1201
+ value
1202
+ });
1203
+ }, []);
1204
+ // The number input's draft was cleared or stopped parsing: nothing stands
1205
+ // to confirm, so the confirm action disables again.
1206
+ const handleDraftUnstage = useCallback(() => {
1207
+ setDraft(current => current == null ? current : {
1208
+ ...current,
1209
+ value: undefined
1210
+ });
1211
+ }, []);
1212
+ const handleSave = useCallback(() => {
1213
+ if (draft?.value == null || draft.operator == null) {
1214
+ return;
1215
+ }
1216
+ commitSavedFilter(draft, {
1217
+ field: draft.field,
1218
+ operator: draft.operator,
1219
+ value: draft.value
1220
+ });
1221
+ }, [commitSavedFilter, draft]);
1222
+ const returnFromValue = useCallback(() => {
1223
+ if (draft == null) {
1224
+ queueManagerAddFocus();
1225
+ setStep('manage');
1226
+ return;
1227
+ }
1228
+ if (draft.mode === 'edit' && draft.sourceFilter != null && draft.sourceSignature != null && draft.filterIndex != null) {
1229
+ pendingSheetFocusRef.current = {
1230
+ type: 'manager-filter',
1231
+ sourceFilter: draft.sourceFilter,
1232
+ sourceSignature: draft.sourceSignature,
1233
+ preferredIndex: resolveDraftFilterIndex(filters, draft) ?? draft.filterIndex
1234
+ };
1235
+ setStep('manage');
1236
+ return;
1237
+ }
1238
+ if (draft.returnFocus === 'content-search') {
1239
+ pendingSheetFocusRef.current = {
1240
+ type: 'content-search'
1241
+ };
1242
+ setStep('fields');
1243
+ return;
1244
+ }
1245
+ pendingSheetFocusRef.current = {
1246
+ type: 'field',
1247
+ fieldKey: draft.field
1248
+ };
1249
+ setStep('fields');
1250
+ }, [draft, filters, queueManagerAddFocus]);
1251
+ const handleRemove = useCallback(() => {
1252
+ if (draft?.mode !== 'edit') {
1253
+ return;
1254
+ }
1255
+ const filterIndex = resolveDraftFilterIndex(filters, draft);
1256
+ if (filterIndex == null || filters[filterIndex]?.isReadOnly) {
1257
+ queueManagerAddFocus();
1258
+ setStep('manage');
1259
+ return;
1260
+ }
1261
+ handleRemoveFilter(filterIndex);
1262
+ setStep('manage');
1263
+ }, [draft, filters, handleRemoveFilter, queueManagerAddFocus]);
1264
+
1265
+ // Each step sheet is controlled by `step`; a sheet only ever asks to close
1266
+ // (a dismissal its `purpose` allows: Escape, the scrim, a swipe, a platform
1267
+ // close request), which only the top sheet of the stack receives. Closing
1268
+ // the top step reveals the step beneath it; closing the bottom one ends the
1269
+ // flow. A stale report from a step that is no longer current is ignored.
1270
+ // Every step change goes through the handlers above.
1271
+ const handleManageOpenChange = useCallback(isSheetOpen => {
1272
+ if (!isSheetOpen && stepRef.current === 'manage') {
1273
+ closeFlow();
1274
+ }
1275
+ }, [closeFlow]);
1276
+ const handleFieldsOpenChange = useCallback(isSheetOpen => {
1277
+ if (isSheetOpen || stepRef.current !== 'fields') {
1278
+ return;
1279
+ }
1280
+ if (fieldPickerOrigin === 'trigger') {
1281
+ closeFlow();
1282
+ return;
1283
+ }
1284
+ queueManagerAddFocus();
1285
+ setStep('manage');
1286
+ }, [closeFlow, fieldPickerOrigin, queueManagerAddFocus]);
1287
+ const handleValueOpenChange = useCallback(isSheetOpen => {
1288
+ if (!isSheetOpen && stepRef.current === 'value') {
1289
+ returnFromValue();
1290
+ }
1291
+ }, [returnFromValue]);
1292
+
1293
+ // ---------------------------------------------------------------- render --
1294
+
1295
+ // Rows are keyed by filter identity, not position: a parent's reorder or a
1296
+ // removal above the focused row then moves elements instead of remounting
1297
+ // them, and focus stays on the same filter. Only a filter that is
1298
+ // itself removed loses its element, and the re-home effect above takes
1299
+ // over.
1300
+ const [filterIdentities] = useState(createFilterIdentities);
1301
+ const filterIds = filterIdentities.next(filters);
1302
+ const filterRows = filters.map((filter, index) => {
1303
+ const {
1304
+ label,
1305
+ value
1306
+ } = describeFilterParts(filter);
1307
+ const isEditable = isRowButton(filter);
1308
+ // The row reads from the same catalog message the removal announcement
1309
+ // uses (`labelValue`), so a locale that reorders it reorders both: the
1310
+ // message is formatted with a placeholder for the value, and the text
1311
+ // either side of that placeholder wraps the bold value.
1312
+ let displayLabel = label;
1313
+ if (value) {
1314
+ const [before, after] = t('@astryx.powersearch.sheet.labelValue', {
1315
+ label,
1316
+ value: ROW_VALUE_SLOT
1317
+ }).split(ROW_VALUE_SLOT);
1318
+ displayLabel = /*#__PURE__*/_jsxs(_Fragment, {
1319
+ children: [before, /*#__PURE__*/_jsx("span", {
1320
+ ...{
1321
+ className: "x1lvx875"
1322
+ },
1323
+ children: value
1324
+ }), after]
1325
+ });
1326
+ }
1327
+ return {
1328
+ displayLabel,
1329
+ filter,
1330
+ index,
1331
+ isEditable,
1332
+ key: `filter-${filterIds[index]}`
1333
+ };
1334
+ });
1335
+ const hasRemovableFilter = filters.some(filter => !filter.isReadOnly);
1336
+ const isClearAllShown = hasClear && isInteractive && hasRemovableFilter;
1337
+ const EditorOverride = draftOperator != null ? componentOverrides?.[draftOperator.value.type]?.Editor : undefined;
1338
+ const draftOperatorLabel = draftOperator == null ? '' : resolveOperatorLabel(draftOperator, t);
1339
+ // The title names the filter's own operator when the step offers no
1340
+ // Operator group: one visible operator, or an operator the config no longer
1341
+ // lists as visible. The step then never shows another operator's name.
1342
+ const showsOperatorGroup = draftOperators.length > 1 && draftOperator != null && draftOperators.includes(draftOperator);
1343
+ // The title — the dialog's name — reads the field and operator as
1344
+ // the Filters row does: by their labels, or, for a filter whose field or
1345
+ // operator the config no longer has, by the raw keys the row shows.
1346
+ const editorTitle = draft == null ? t('@astryx.powersearch.sheet.addFilter') : draftField == null || draftOperator == null && draft.operator != null ? t('@astryx.powersearch.sheet.fieldOperator', {
1347
+ field: draftField?.label ?? draft.field,
1348
+ operator: draftOperatorLabel !== '' ? draftOperatorLabel : draft.operator ?? ''
1349
+ }).trim() : !showsOperatorGroup && draftOperatorLabel !== '' ? t('@astryx.powersearch.sheet.fieldOperator', {
1350
+ field: draftField.label,
1351
+ operator: draftOperatorLabel
1352
+ }) : draftField.label;
1353
+ const saveButtonLabel = saveButtonLabelFromProps ?? (draft?.mode === 'edit' ? t('@astryx.powersearch.editor.apply') : t('@astryx.powersearch.sheet.addFilter'));
1354
+
1355
+ // Every sheet body: padded, and publishing that padding to its lists.
1356
+ const bodyProps = stylex.props(styles.body, containerPaddingInlineVarStyles[4]);
1357
+ const scrollContentProps = stylex.props(styles.scrollContent, containerPaddingInlineVarStyles[4]);
1358
+ const controlSectionProps = stylex.props(styles.controlSection, containerPaddingInlineVarStyles[3]);
1359
+
1360
+ // A vertical touch drag on the Add filter rows moves focus off a focused
1361
+ // search to the sheet, so the software keyboard leaves and the rows can be
1362
+ // read.
1363
+ const fieldPickerDragProps = useDismissSearchOnTouchDrag(() => [contentSearchRef.current?.querySelector('input'), fieldSearchRef.current?.querySelector('input')], () => fieldsSheetRef.current?.closest('[tabindex="-1"]'));
1364
+ const isEditorDisabled = isDisabled || isReadOnly;
1365
+ const isSaveDisabled = isEditorDisabled || draft?.operator == null || draft.value == null;
1366
+ // The step has something to edit when the field and operator still exist
1367
+ // (a controlled config update can remove either). A caller's `Editor`
1368
+ // override replaces the body for its value type with the props the popover
1369
+ // hands it; otherwise a `nested` value takes the popover's built-in
1370
+ // NestedEditor and every other type the sheet's own control.
1371
+ const isDraftRenderable = draft != null && draftField != null && draftOperator != null;
1372
+ const isDraftNested = isDraftRenderable && !isSupportedOperator(draftOperator);
1373
+ // A controlled config update that removes the field or operator being
1374
+ // edited replaces the step's body with the unavailable state while focus
1375
+ // may be on one of the body's controls, which unmount without a blur. Focus
1376
+ // then moves to Cancel, the way back to the Filters row whose remove action
1377
+ // is the removal path, so it never falls to the page body inside the open
1378
+ // sheet. The message itself is announced by its rendered element.
1379
+ const cancelButtonRef = useRef(null);
1380
+ const wasDraftRenderableRef = useRef(isDraftRenderable);
1381
+ useLayoutEffect(() => {
1382
+ const becameUnavailable = wasDraftRenderableRef.current && !isDraftRenderable && draft != null;
1383
+ wasDraftRenderableRef.current = isDraftRenderable;
1384
+ if (!becameUnavailable || step !== 'value') {
1385
+ return;
1386
+ }
1387
+ const active = document.activeElement;
1388
+ const dialog = cancelButtonRef.current?.closest('dialog');
1389
+ if (dialog != null && active != null && dialog.contains(active)) {
1390
+ return;
1391
+ }
1392
+ cancelButtonRef.current?.focus();
1393
+ }, [draft, isDraftRenderable, step]);
1394
+ // The operator group stays outside either editor, so switching operators
1395
+ // swaps the body — a `nested` operator beside a plain one included.
1396
+ const operatorGroup = isDraftRenderable && showsOperatorGroup && /*#__PURE__*/_jsx(RadioList, {
1397
+ label: t('@astryx.powersearch.editor.operator'),
1398
+ isLabelHidden: true,
1399
+ value: draft.operator ?? '',
1400
+ onChange: operatorKey => {
1401
+ const operator = draftOperators.find(candidate => candidate.key === operatorKey);
1402
+ if (operator != null) {
1403
+ handleOperatorSelect(operator);
1404
+ }
1405
+ },
1406
+ isDisabled: isEditorDisabled,
1407
+ children: draftOperators.map(operator => /*#__PURE__*/_jsx(RadioListItem, {
1408
+ label: t('@astryx.powersearch.sheet.fieldOperator', {
1409
+ field: draftField.label,
1410
+ operator: resolveOperatorLabel(operator, t)
1411
+ }),
1412
+ value: operator.key,
1413
+ xstyle: styles.trailingControlRow
1414
+ }, operator.key))
1415
+ });
1416
+ // The step's Operator group owns the operator choice, so the built-in
1417
+ // nested editor's root operator picker is hidden and its root shows the
1418
+ // checked operator's label.
1419
+ const nestedOperatorOptions = useMemo(() => draftOperator == null ? [] : [{
1420
+ value: draftOperator.key,
1421
+ label: resolveOperatorLabel(draftOperator, t)
1422
+ }], [draftOperator, t]);
1423
+ const handleNestedDraftChange = useCallback(next => {
1424
+ setDraft(current => current == null ? current : {
1425
+ ...current,
1426
+ value: next.value
1427
+ });
1428
+ }, []);
1429
+ const valueEditor = isDraftRenderable && (isDraftNested ? /*#__PURE__*/_jsx(NestedEditor, {
1430
+ config: config,
1431
+ partialFilter: {
1432
+ field: draft.field,
1433
+ operator: draft.operator,
1434
+ value: draft.value
1435
+ },
1436
+ operatorOptions: nestedOperatorOptions,
1437
+ hasRootOperatorPicker: false,
1438
+ onOperatorChange: () => {},
1439
+ onPartialFilterChange: handleNestedDraftChange,
1440
+ maxMenuItems: maxOperatorMenuItems,
1441
+ timezoneID: timezoneID,
1442
+ isReadOnly: isEditorDisabled,
1443
+ xstyle: styles.nestedEditorContainer
1444
+ }, `${draft.generation}-${draft.field}-${draft.operator}`) : /*#__PURE__*/_jsx(SheetValueEditor, {
1445
+ operatorValue: draftOperator.value,
1446
+ filterValue: draft.value,
1447
+ onChange: handleDraftValueChange,
1448
+ onUnstage: handleDraftUnstage,
1449
+ config: config,
1450
+ fieldLabel: draftField.label,
1451
+ isDisabled: isEditorDisabled,
1452
+ maxMenuItems: maxOperatorMenuItems,
1453
+ timezoneID: timezoneID,
1454
+ editors: editors
1455
+ }, `${draft.generation}-${draft.field}-${draft.operator}`));
1456
+ return /*#__PURE__*/_jsxs(_Fragment, {
1457
+ children: [/*#__PURE__*/_jsx(BottomSheet, {
1458
+ isOpen: isManageSheetOpen,
1459
+ onOpenChange: handleManageOpenChange,
1460
+ finalFocusRef: finalFocusRef,
1461
+ label: t('@astryx.powersearch.sheet.filtersTitle'),
1462
+ height: "tall",
1463
+ padding: 0,
1464
+ children: /*#__PURE__*/_jsxs("div", {
1465
+ ref: manageSheetRef,
1466
+ onFocus: noteSheetFocus('manage'),
1467
+ ...{
1468
+ className: "x78zum5 xdt5ytf x1us19tq xc8icb0 x5yr21d xb3r6kr"
1469
+ },
1470
+ children: [step === 'manage' && /*#__PURE__*/_jsx(SheetAnnouncer, {
1471
+ onAnnounceChange: handleAnnounceChange
1472
+ }), /*#__PURE__*/_jsx("div", {
1473
+ ...{
1474
+ className: "x7wzq59 x13vifvy x1vjfegm x78zum5 xdt5ytf xjcht0a x1adxfkp xvmdzux x1pzlopt x10xzikg"
1475
+ },
1476
+ children: /*#__PURE__*/_jsxs("div", {
1477
+ ...{
1478
+ className: "x78zum5 x6s0dn4 x1txdalj"
1479
+ },
1480
+ children: [/*#__PURE__*/_jsx("div", {
1481
+ ...{
1482
+ className: "xeuugli x1iyjqo2 x78zum5 xdt5ytf"
1483
+ },
1484
+ children: /*#__PURE__*/_jsx(Heading, {
1485
+ level: 3,
1486
+ children: t('@astryx.powersearch.sheet.filtersTitle')
1487
+ })
1488
+ }), isInteractive && filterRows.length > 0 && /*#__PURE__*/_jsx(Button, {
1489
+ ref: managerAddButtonRef,
1490
+ label: t('@astryx.powersearch.sheet.addFilter'),
1491
+ icon: /*#__PURE__*/_jsx(Icon, {
1492
+ icon: PlusIcon,
1493
+ size: "sm"
1494
+ }),
1495
+ isIconOnly: true,
1496
+ variant: "secondary",
1497
+ size: "md",
1498
+ xstyle: styles.touchHitArea,
1499
+ onClick: openFieldList
1500
+ })]
1501
+ })
1502
+ }), /*#__PURE__*/_jsx("div", {
1503
+ ...{
1504
+ className: "x1iyjqo2 x2lwn1j x1odjw0f x1e4zzel"
1505
+ },
1506
+ children: /*#__PURE__*/_jsx("div", {
1507
+ ...scrollContentProps,
1508
+ children: filterRows.length === 0 ?
1509
+ // With no filter the single thing to do is the only visible
1510
+ // action. Mounted only while the sheet is open, so its text
1511
+ // is spoken in this sheet when it appears.
1512
+ isManageSheetOpen && /*#__PURE__*/_jsx(EmptyState, {
1513
+ title: t('@astryx.powersearch.sheet.noFilters'),
1514
+ description: t('@astryx.powersearch.sheet.noFiltersDescription'),
1515
+ headingLevel: 4,
1516
+ icon: /*#__PURE__*/_jsx(Icon, {
1517
+ icon: "funnel",
1518
+ size: "lg",
1519
+ color: "secondary"
1520
+ }),
1521
+ xstyle: styles.emptyState,
1522
+ actions: isInteractive ? /*#__PURE__*/_jsx(Button, {
1523
+ ref: managerAddButtonRef,
1524
+ label: t('@astryx.powersearch.sheet.addFilter'),
1525
+ icon: /*#__PURE__*/_jsx(Icon, {
1526
+ icon: PlusIcon,
1527
+ size: "sm"
1528
+ }),
1529
+ variant: "primary",
1530
+ size: "lg",
1531
+ xstyle: styles.touchHitArea,
1532
+ onClick: openFieldList
1533
+ }) : undefined
1534
+ }) : /*#__PURE__*/_jsx(List, {
1535
+ hasDividers: true,
1536
+ density: "spacious",
1537
+ edge: "bleed",
1538
+ children: filterRows.map(row => {
1539
+ const operator = config.getOperator(row.filter.field, row.filter.operator);
1540
+ const fieldLabel = config.getField(row.filter.field)?.label ?? row.filter.field;
1541
+ // A one-tap filter has no value to edit: its row removes
1542
+ // it.
1543
+ const isOneTap = operator?.value.type === 'empty';
1544
+ const removeLabel = t('@astryx.powersearch.sheet.removeFilter', {
1545
+ field: fieldLabel
1546
+ });
1547
+ return /*#__PURE__*/_jsx(ListItem, {
1548
+ ref: node => {
1549
+ if (node == null) {
1550
+ managerRowsRef.current.delete(row.index);
1551
+ } else {
1552
+ managerRowsRef.current.set(row.index, node);
1553
+ }
1554
+ },
1555
+ label: row.displayLabel,
1556
+ onClick: row.isEditable ? isOneTap ? () => handleRemoveFilter(row.index) : () => handleFilterEdit(row.index) : undefined,
1557
+ endContent: row.isEditable ? /*#__PURE__*/_jsx(IconButton, {
1558
+ "data-sheet-remove": "",
1559
+ label: removeLabel,
1560
+ tooltip: removeLabel,
1561
+ icon: /*#__PURE__*/_jsx(Icon, {
1562
+ icon: "close",
1563
+ size: "sm"
1564
+ }),
1565
+ variant: "ghost",
1566
+ size: "md",
1567
+ xstyle: styles.touchHitArea,
1568
+ onClick: event => {
1569
+ event.stopPropagation();
1570
+ handleRemoveFilter(row.index);
1571
+ }
1572
+ }) : undefined
1573
+ }, row.key);
1574
+ })
1575
+ })
1576
+ })
1577
+ }), filterRows.length > 0 && /*#__PURE__*/_jsxs("div", {
1578
+ ...{
1579
+ className: "x1vjfegm x78zum5 x6s0dn4 x1qughib x1txdalj x8o8v82 x1pzlopt x10xzikg x1n2onr6 xdd4er5 x2lah0s"
1580
+ },
1581
+ children: [isClearAllShown && /*#__PURE__*/_jsx(Button, {
1582
+ ref: clearAllButtonRef,
1583
+ label: t('@astryx.powersearch.sheet.clearAll'),
1584
+ variant: "secondary",
1585
+ size: "lg",
1586
+ xstyle: styles.footerEqualAction,
1587
+ onClick: () => setIsClearConfirmationOpen(true)
1588
+ }), /*#__PURE__*/_jsx(Button, {
1589
+ label: t('@astryx.powersearch.sheet.done'),
1590
+ variant: "primary",
1591
+ size: "lg",
1592
+ xstyle: isClearAllShown ? styles.footerEqualAction : [styles.footerSoleAction, styles.touchHitArea],
1593
+ onClick: closeFlow,
1594
+ width: isClearAllShown ? undefined : '100%'
1595
+ })]
1596
+ })]
1597
+ })
1598
+ }), /*#__PURE__*/_jsx(BottomSheet, {
1599
+ isOpen: isFieldsSheetOpen,
1600
+ onOpenChange: handleFieldsOpenChange,
1601
+ finalFocusRef: stepFinalFocusRef,
1602
+ label: t('@astryx.powersearch.sheet.addFilter'),
1603
+ height: "tall",
1604
+ padding: 0,
1605
+ children: /*#__PURE__*/_jsxs("div", {
1606
+ ref: fieldsSheetCallbackRef,
1607
+ onFocus: noteSheetFocus('fields'),
1608
+ onKeyDown: hasContentSearch ? handleContentListKeyDown : undefined,
1609
+ ...{
1610
+ className: "x78zum5 xdt5ytf x1us19tq xc8icb0 x5yr21d xb3r6kr"
1611
+ },
1612
+ children: [step === 'fields' && /*#__PURE__*/_jsx(SheetAnnouncer, {
1613
+ onAnnounceChange: handleAnnounceChange
1614
+ }), /*#__PURE__*/_jsxs("div", {
1615
+ ...{
1616
+ className: "x7wzq59 x13vifvy x1vjfegm x78zum5 xdt5ytf xjcht0a x1adxfkp xvmdzux x1pzlopt x10xzikg"
1617
+ },
1618
+ children: [/*#__PURE__*/_jsx("div", {
1619
+ ...{
1620
+ className: "x78zum5 x6s0dn4 x1txdalj"
1621
+ },
1622
+ children: /*#__PURE__*/_jsx("div", {
1623
+ ...{
1624
+ className: "xeuugli x1iyjqo2 x78zum5 xdt5ytf"
1625
+ },
1626
+ children: /*#__PURE__*/_jsx(Heading, {
1627
+ level: 3,
1628
+ children: t('@astryx.powersearch.sheet.addFilter')
1629
+ })
1630
+ })
1631
+ }), hasContentSearch ? /*#__PURE__*/_jsx("div", {
1632
+ ref: contentSearchRef,
1633
+ children: /*#__PURE__*/_jsx(TextInput, {
1634
+ label: t('@astryx.powersearch.sheet.search'),
1635
+ isLabelHidden: true,
1636
+ role: "searchbox",
1637
+ "aria-controls": contentResultsId,
1638
+ value: contentQuery,
1639
+ onChange: setContentQuery,
1640
+ onKeyDown: event => {
1641
+ if (isImeKeyEvent(event.nativeEvent)) {
1642
+ return;
1643
+ }
1644
+ if (event.key === 'Enter' && contentResults[0] != null) {
1645
+ event.preventDefault();
1646
+ handleContentSuggestionSelect(contentResults[0]);
1647
+ }
1648
+ },
1649
+ placeholder: placeholder,
1650
+ hasClear: true,
1651
+ startIcon: /*#__PURE__*/_jsx(Icon, {
1652
+ icon: "search",
1653
+ size: "sm",
1654
+ color: "secondary"
1655
+ }),
1656
+ isDisabled: !isInteractive,
1657
+ size: "lg",
1658
+ width: "100%"
1659
+ })
1660
+ }) : isFieldSearchShown ? /*#__PURE__*/_jsx("div", {
1661
+ ref: fieldSearchRef,
1662
+ children: /*#__PURE__*/_jsx(TextInput, {
1663
+ label: t('@astryx.powersearch.sheet.searchFields'),
1664
+ isLabelHidden: true,
1665
+ placeholder: t('@astryx.powersearch.sheet.searchFieldsPlaceholder'),
1666
+ value: fieldQuery,
1667
+ onChange: setFieldQuery,
1668
+ startIcon: /*#__PURE__*/_jsx(Icon, {
1669
+ icon: "search",
1670
+ size: "sm",
1671
+ color: "secondary"
1672
+ }),
1673
+ isDisabled: !isInteractive,
1674
+ size: "lg",
1675
+ width: "100%"
1676
+ })
1677
+ }) : null]
1678
+ }), /*#__PURE__*/_jsx("div", {
1679
+ ...{
1680
+ className: "x1iyjqo2 x2lwn1j x1odjw0f x1e4zzel"
1681
+ },
1682
+ ...fieldPickerDragProps,
1683
+ children: /*#__PURE__*/_jsx("div", {
1684
+ ...scrollContentProps,
1685
+ children: hasContentSearch ? contentResults.length > 0 ? /*#__PURE__*/_jsx(List, {
1686
+ id: contentResultsId,
1687
+ "aria-label": t('@astryx.powersearch.sheet.searchResults'),
1688
+ hasDividers: true,
1689
+ density: "spacious",
1690
+ edge: "bleed",
1691
+ children: contentResults.map(item => /*#__PURE__*/_jsx(ListItem, {
1692
+ label: item.label,
1693
+ isDisabled: !isInteractive,
1694
+ onClick: () => handleContentSuggestionSelect(item)
1695
+ }, item.id))
1696
+ }) : contentQuery.trim() !== '' ?
1697
+ /*#__PURE__*/
1698
+ // The searchbox's `aria-controls` target while nothing
1699
+ // lists. The empty state mounts only while this step is the
1700
+ // open one and is spoken from its rendered text, once per
1701
+ // query that matches nothing.
1702
+ _jsx("div", {
1703
+ id: contentResultsId,
1704
+ children: step === 'fields' && /*#__PURE__*/_jsx(EmptyState, {
1705
+ icon: /*#__PURE__*/_jsx(Icon, {
1706
+ icon: "search",
1707
+ size: "lg",
1708
+ color: "secondary"
1709
+ }),
1710
+ title: t('@astryx.powersearch.sheet.noResults'),
1711
+ description: t('@astryx.powersearch.sheet.tryDifferentSearch'),
1712
+ headingLevel: 4,
1713
+ isCompact: true,
1714
+ xstyle: styles.emptyState
1715
+ }, contentQuery)
1716
+ }) :
1717
+ /*#__PURE__*/
1718
+ // An empty query with no bootstrap suggestion: the results
1719
+ // region exists, empty, so the searchbox's `aria-controls`
1720
+ // always names an element in the document.
1721
+ _jsx("div", {
1722
+ id: contentResultsId
1723
+ }) : groupedFields.length === 0 ?
1724
+ // A search outcome: only a non-empty query that matches
1725
+ // nothing shows it; a config with no field lists nothing.
1726
+ normalizedFieldQuery !== '' && step === 'fields' && /*#__PURE__*/_jsx(EmptyState, {
1727
+ icon: /*#__PURE__*/_jsx(Icon, {
1728
+ icon: "search",
1729
+ size: "lg",
1730
+ color: "secondary"
1731
+ }),
1732
+ title: t('@astryx.powersearch.sheet.noMatchingFields'),
1733
+ description: t('@astryx.powersearch.sheet.tryDifferentSearch'),
1734
+ headingLevel: 4,
1735
+ isCompact: true,
1736
+ xstyle: styles.emptyState
1737
+ }, normalizedFieldQuery) : groupedFields.map(([group, groupFields]) => /*#__PURE__*/_jsx(List, {
1738
+ hasDividers: true,
1739
+ density: "spacious",
1740
+ header: /*#__PURE__*/_jsx(Heading, {
1741
+ level: 4,
1742
+ children: group === '' ? t('@astryx.powersearch.sheet.ungroupedFields') : group
1743
+ }),
1744
+ edge: "bleed",
1745
+ children: groupFields.map(field => /*#__PURE__*/_jsx(ListItem, {
1746
+ ref: node => {
1747
+ if (node == null) {
1748
+ fieldRowsRef.current.delete(field.key);
1749
+ } else {
1750
+ fieldRowsRef.current.set(field.key, node);
1751
+ }
1752
+ },
1753
+ label: field.label,
1754
+ isDisabled: !isInteractive,
1755
+ startContent: field.icon,
1756
+ endContent: isImmediateAddField(field) ? /*#__PURE__*/_jsx(Icon, {
1757
+ icon: PlusIcon,
1758
+ size: "sm",
1759
+ color: "secondary"
1760
+ }) : /*#__PURE__*/_jsx(Icon, {
1761
+ icon: "chevronRight",
1762
+ size: "sm",
1763
+ color: "secondary",
1764
+ xstyle: rtlStyles.mirror
1765
+ }),
1766
+ onClick: () => handleFieldSelect(field)
1767
+ }, field.key))
1768
+ }, group))
1769
+ })
1770
+ }), isFieldPickerDirectEntry && /*#__PURE__*/_jsx("div", {
1771
+ ...{
1772
+ className: "x1vjfegm x78zum5 x6s0dn4 x1qughib x1txdalj x8o8v82 x1pzlopt x10xzikg x1n2onr6 xdd4er5 x2lah0s"
1773
+ },
1774
+ children: /*#__PURE__*/_jsx(Button, {
1775
+ label: t('@astryx.powersearch.sheet.done'),
1776
+ variant: "primary",
1777
+ width: "100%",
1778
+ xstyle: styles.touchAction,
1779
+ onClick: closeFlow
1780
+ })
1781
+ })]
1782
+ })
1783
+ }), /*#__PURE__*/_jsx(BottomSheet, {
1784
+ isOpen: step === 'value',
1785
+ onOpenChange: handleValueOpenChange,
1786
+ finalFocusRef: stepFinalFocusRef,
1787
+ label: editorTitle,
1788
+ height: "tall",
1789
+ padding: 0,
1790
+ purpose: "info",
1791
+ children: /*#__PURE__*/_jsxs("div", {
1792
+ ...{
1793
+ className: "x78zum5 xdt5ytf x1us19tq xc8icb0"
1794
+ },
1795
+ children: [/*#__PURE__*/_jsx("div", {
1796
+ ...{
1797
+ className: "x7wzq59 x13vifvy x1vjfegm x78zum5 xdt5ytf xjcht0a x1adxfkp xvmdzux x1pzlopt x10xzikg"
1798
+ },
1799
+ children: /*#__PURE__*/_jsx("div", {
1800
+ ...{
1801
+ className: "x78zum5 x6s0dn4 x1txdalj"
1802
+ },
1803
+ children: /*#__PURE__*/_jsx("div", {
1804
+ ...{
1805
+ className: "xeuugli x1iyjqo2 x78zum5 xdt5ytf"
1806
+ },
1807
+ children: /*#__PURE__*/_jsx(Heading, {
1808
+ level: 3,
1809
+ maxLines: 1,
1810
+ children: editorTitle
1811
+ })
1812
+ })
1813
+ })
1814
+ }), isDraftRenderable && EditorOverride != null ? /*#__PURE__*/_jsxs("div", {
1815
+ ...bodyProps,
1816
+ children: [step === 'value' && /*#__PURE__*/_jsx(SheetAnnouncer, {
1817
+ onAnnounceChange: handleAnnounceChange
1818
+ }), operatorGroup && /*#__PURE__*/_jsx("div", {
1819
+ ...controlSectionProps,
1820
+ children: operatorGroup
1821
+ }), /*#__PURE__*/_jsx(EditorOverride, {
1822
+ config: configProp,
1823
+ filter: {
1824
+ field: draft.field,
1825
+ operator: draft.operator,
1826
+ value: draft.value
1827
+ },
1828
+ mode: draft.mode,
1829
+ onSave: saved => {
1830
+ if (saved == null) {
1831
+ if (draft.mode === 'edit') {
1832
+ handleRemove();
1833
+ } else {
1834
+ queueManagerAddFocus();
1835
+ setStep('manage');
1836
+ }
1837
+ return;
1838
+ }
1839
+ commitSavedFilter(draft, saved);
1840
+ },
1841
+ onCancel: returnFromValue,
1842
+ saveButtonLabel: saveButtonLabel,
1843
+ isReadOnly: isEditorDisabled,
1844
+ timezoneID: timezoneID
1845
+ }, `${draft.generation}-${draft.field}-${draft.operator}`)]
1846
+ }) : /*#__PURE__*/_jsxs(_Fragment, {
1847
+ children: [/*#__PURE__*/_jsxs("div", {
1848
+ ...bodyProps,
1849
+ children: [step === 'value' && /*#__PURE__*/_jsx(SheetAnnouncer, {
1850
+ onAnnounceChange: handleAnnounceChange
1851
+ }), isDraftRenderable ?
1852
+ // A lone editor sits on the sheet's surface; with the
1853
+ // Operator group above it, each section is a muted
1854
+ // container.
1855
+ operatorGroup ? /*#__PURE__*/_jsxs(_Fragment, {
1856
+ children: [/*#__PURE__*/_jsx("div", {
1857
+ ...controlSectionProps,
1858
+ children: operatorGroup
1859
+ }), /*#__PURE__*/_jsx("div", {
1860
+ ...controlSectionProps,
1861
+ children: valueEditor
1862
+ })]
1863
+ }) : valueEditor :
1864
+ // A controlled config update removed the field or operator
1865
+ // being edited: say so (the element's rendered text is
1866
+ // announced, once per opened filter, while this step is the
1867
+ // open one) and keep a way out.
1868
+ draft != null && /*#__PURE__*/_jsx(SheetEmptyMessage, {
1869
+ message: t('@astryx.powersearch.sheet.filterUnavailable'),
1870
+ occasion: String(draft.generation),
1871
+ isShown: step === 'value'
1872
+ })]
1873
+ }), /*#__PURE__*/_jsx("div", {
1874
+ ...{
1875
+ className: "x7wzq59 x1ey2m1c x1vjfegm x78zum5 x6s0dn4 x1qughib x1txdalj x8o8v82 x1pzlopt x10xzikg"
1876
+ },
1877
+ children: isReadOnly ? /*#__PURE__*/_jsx(Button, {
1878
+ ref: cancelButtonRef,
1879
+ label: t('@astryx.powersearch.editor.cancel'),
1880
+ variant: "secondary",
1881
+ width: "100%",
1882
+ xstyle: [styles.footerSoleAction, styles.touchHitArea],
1883
+ onClick: returnFromValue
1884
+ }) : /*#__PURE__*/_jsxs(_Fragment, {
1885
+ children: [/*#__PURE__*/_jsx(Button, {
1886
+ ref: cancelButtonRef,
1887
+ label: t('@astryx.powersearch.editor.cancel'),
1888
+ variant: "secondary",
1889
+ size: "lg",
1890
+ xstyle: styles.footerEqualAction,
1891
+ onClick: returnFromValue
1892
+ }), isDraftRenderable && /*#__PURE__*/_jsx(Button, {
1893
+ label: saveButtonLabel,
1894
+ variant: "primary",
1895
+ size: "lg",
1896
+ isDisabled: isSaveDisabled,
1897
+ xstyle: styles.footerEqualAction,
1898
+ onClick: handleSave
1899
+ })]
1900
+ })
1901
+ })]
1902
+ })]
1903
+ })
1904
+ }), isClearConfirmationOpen && /*#__PURE__*/_jsx(SheetConfirmation, {
1905
+ isOpen: true,
1906
+ onOpenChange: isConfirmationOpen => {
1907
+ if (!isConfirmationOpen) {
1908
+ closeClearConfirmation(false);
1909
+ }
1910
+ },
1911
+ title: t('@astryx.powersearch.sheet.clearAllTitle'),
1912
+ description: t('@astryx.powersearch.sheet.clearAllDescription'),
1913
+ actionLabel: t('@astryx.powersearch.sheet.clearAllConfirm'),
1914
+ cancelLabel: t('@astryx.powersearch.sheet.clearAllCancel'),
1915
+ onAction: () => closeClearConfirmation(true)
1916
+ })]
1917
+ });
1918
+ }
1919
+ PowerSearchBottomSheet.displayName = 'PowerSearchBottomSheet';