@alma-oss/spirit-web-react 4.4.2 → 4.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (417) hide show
  1. package/CHANGELOG.md +51 -0
  2. package/DEPRECATIONS.md +2 -2
  3. package/README.md +135 -6
  4. package/dist/bundles/web-react.umd.js +1731 -624
  5. package/dist/bundles/web-react.umd.js.map +1 -1
  6. package/dist/bundles/web-react.umd.min.js +1 -1
  7. package/dist/bundles/web-react.umd.min.js.map +1 -1
  8. package/dist/components/Button/Button.cjs +1 -1
  9. package/dist/components/Button/Button.cjs.map +1 -1
  10. package/dist/components/Button/Button.js +19 -19
  11. package/dist/components/Button/Button.js.map +1 -1
  12. package/dist/components/ButtonLink/ButtonLink.cjs +1 -1
  13. package/dist/components/ButtonLink/ButtonLink.cjs.map +1 -1
  14. package/dist/components/ButtonLink/ButtonLink.d.ts +2 -2
  15. package/dist/components/ButtonLink/ButtonLink.js +23 -18
  16. package/dist/components/ButtonLink/ButtonLink.js.map +1 -1
  17. package/dist/components/ButtonLink/useButtonLinkStyleProps.cjs.map +1 -1
  18. package/dist/components/ButtonLink/useButtonLinkStyleProps.d.ts +9 -9
  19. package/dist/components/ButtonLink/useButtonLinkStyleProps.js.map +1 -1
  20. package/dist/components/Card/CardLink.cjs +1 -1
  21. package/dist/components/Card/CardLink.cjs.map +1 -1
  22. package/dist/components/Card/CardLink.d.ts +2 -2
  23. package/dist/components/Card/CardLink.js +10 -15
  24. package/dist/components/Card/CardLink.js.map +1 -1
  25. package/dist/components/CharacterCounter/CharacterCounter.cjs +2 -0
  26. package/dist/components/CharacterCounter/CharacterCounter.cjs.map +1 -0
  27. package/dist/components/CharacterCounter/CharacterCounter.d.ts +7 -0
  28. package/dist/components/CharacterCounter/CharacterCounter.js +23 -0
  29. package/dist/components/CharacterCounter/CharacterCounter.js.map +1 -0
  30. package/dist/components/CharacterCounter/constants.cjs +2 -0
  31. package/dist/components/CharacterCounter/constants.cjs.map +1 -0
  32. package/dist/components/CharacterCounter/constants.d.ts +1 -0
  33. package/dist/components/CharacterCounter/constants.js +5 -0
  34. package/dist/components/CharacterCounter/constants.js.map +1 -0
  35. package/dist/components/CharacterCounter/index.cjs +2 -0
  36. package/dist/components/CharacterCounter/index.d.ts +3 -0
  37. package/dist/components/CharacterCounter/index.js +7 -0
  38. package/dist/components/{UNSTABLE_Attachment → CharacterCounter}/index.js.map +1 -1
  39. package/dist/components/CharacterCounter/types.d.ts +6 -0
  40. package/dist/components/CharacterCounter/useCharacterCounterState.cjs +2 -0
  41. package/dist/components/CharacterCounter/useCharacterCounterState.cjs.map +1 -0
  42. package/dist/components/CharacterCounter/useCharacterCounterState.d.ts +25 -0
  43. package/dist/components/CharacterCounter/useCharacterCounterState.js +66 -0
  44. package/dist/components/CharacterCounter/useCharacterCounterState.js.map +1 -0
  45. package/dist/components/CharacterCounter.d.ts +2 -0
  46. package/dist/components/Checkbox/Checkbox.cjs +1 -1
  47. package/dist/components/Checkbox/Checkbox.cjs.map +1 -1
  48. package/dist/components/Checkbox/Checkbox.js +58 -54
  49. package/dist/components/Checkbox/Checkbox.js.map +1 -1
  50. package/dist/components/ControlButton/useControlButtonStyleProps.cjs.map +1 -1
  51. package/dist/components/ControlButton/useControlButtonStyleProps.js.map +1 -1
  52. package/dist/components/Dropdown/DropdownPopover.cjs.map +1 -1
  53. package/dist/components/Dropdown/DropdownPopover.d.ts +2 -2
  54. package/dist/components/Dropdown/DropdownPopover.js.map +1 -1
  55. package/dist/components/Field/index.cjs +1 -1
  56. package/dist/components/Field/index.d.ts +0 -2
  57. package/dist/components/Field/index.js +2 -4
  58. package/dist/components/Field/index.js.map +1 -1
  59. package/dist/components/Field/types.d.ts +1 -1
  60. package/dist/components/FieldGroup/FieldGroup.cjs +1 -1
  61. package/dist/components/FieldGroup/FieldGroup.cjs.map +1 -1
  62. package/dist/components/FieldGroup/FieldGroup.js +15 -16
  63. package/dist/components/FieldGroup/FieldGroup.js.map +1 -1
  64. package/dist/components/FileUploader/FileUploaderInput.cjs +1 -1
  65. package/dist/components/FileUploader/FileUploaderInput.cjs.map +1 -1
  66. package/dist/components/FileUploader/FileUploaderInput.js +36 -35
  67. package/dist/components/FileUploader/FileUploaderInput.js.map +1 -1
  68. package/dist/components/Header/HeaderDialogLink.cjs +1 -1
  69. package/dist/components/Header/HeaderDialogLink.cjs.map +1 -1
  70. package/dist/components/Header/HeaderDialogLink.js +18 -17
  71. package/dist/components/Header/HeaderDialogLink.js.map +1 -1
  72. package/dist/components/Header/HeaderLink.cjs +1 -1
  73. package/dist/components/Header/HeaderLink.cjs.map +1 -1
  74. package/dist/components/Header/HeaderLink.js +16 -15
  75. package/dist/components/Header/HeaderLink.js.map +1 -1
  76. package/dist/components/InputDetails/InputDetails.cjs +2 -0
  77. package/dist/components/InputDetails/InputDetails.cjs.map +1 -0
  78. package/dist/components/InputDetails/InputDetails.d.ts +7 -0
  79. package/dist/components/InputDetails/InputDetails.js +21 -0
  80. package/dist/components/InputDetails/InputDetails.js.map +1 -0
  81. package/dist/components/InputDetails/index.cjs +2 -0
  82. package/dist/components/InputDetails/index.cjs.map +1 -0
  83. package/dist/components/InputDetails/index.d.ts +2 -0
  84. package/dist/components/InputDetails/index.js +7 -0
  85. package/dist/components/InputDetails/index.js.map +1 -0
  86. package/dist/components/InputDetails/useInputDetailsStyleProps.cjs +2 -0
  87. package/dist/components/InputDetails/useInputDetailsStyleProps.cjs.map +1 -0
  88. package/dist/components/InputDetails/useInputDetailsStyleProps.d.ts +7 -0
  89. package/dist/components/InputDetails/useInputDetailsStyleProps.js +11 -0
  90. package/dist/components/InputDetails/useInputDetailsStyleProps.js.map +1 -0
  91. package/dist/components/InputDetails.d.ts +2 -0
  92. package/dist/components/Link/Link.cjs +1 -1
  93. package/dist/components/Link/Link.cjs.map +1 -1
  94. package/dist/components/Link/Link.js +10 -9
  95. package/dist/components/Link/Link.js.map +1 -1
  96. package/dist/components/Link/useLinkStyleProps.cjs.map +1 -1
  97. package/dist/components/Link/useLinkStyleProps.d.ts +1 -1
  98. package/dist/components/Link/useLinkStyleProps.js.map +1 -1
  99. package/dist/components/Pagination/PaginationLink.cjs +1 -1
  100. package/dist/components/Pagination/PaginationLink.cjs.map +1 -1
  101. package/dist/components/Pagination/PaginationLink.js +29 -18
  102. package/dist/components/Pagination/PaginationLink.js.map +1 -1
  103. package/dist/components/Radio/Radio.cjs +1 -1
  104. package/dist/components/Radio/Radio.cjs.map +1 -1
  105. package/dist/components/Radio/Radio.js +24 -25
  106. package/dist/components/Radio/Radio.js.map +1 -1
  107. package/dist/components/ScrollView/useScrollPosition.js +4 -4
  108. package/dist/components/Select/Select.cjs +1 -1
  109. package/dist/components/Select/Select.cjs.map +1 -1
  110. package/dist/components/Select/Select.js +28 -29
  111. package/dist/components/Select/Select.js.map +1 -1
  112. package/dist/components/Slider/Slider.cjs +1 -1
  113. package/dist/components/Slider/Slider.cjs.map +1 -1
  114. package/dist/components/Slider/Slider.js +23 -24
  115. package/dist/components/Slider/Slider.js.map +1 -1
  116. package/dist/components/Tabs/TabLink.cjs +1 -1
  117. package/dist/components/Tabs/TabLink.cjs.map +1 -1
  118. package/dist/components/Tabs/TabLink.js +18 -17
  119. package/dist/components/Tabs/TabLink.js.map +1 -1
  120. package/dist/components/Tag/constants.cjs +1 -1
  121. package/dist/components/Tag/constants.cjs.map +1 -1
  122. package/dist/components/Tag/constants.d.ts +1 -0
  123. package/dist/components/Tag/constants.js +4 -3
  124. package/dist/components/Tag/constants.js.map +1 -1
  125. package/dist/components/Tag/useTagStyleProps.cjs +1 -1
  126. package/dist/components/Tag/useTagStyleProps.cjs.map +1 -1
  127. package/dist/components/Tag/useTagStyleProps.js +25 -10
  128. package/dist/components/Tag/useTagStyleProps.js.map +1 -1
  129. package/dist/components/TextArea/TextArea.cjs +1 -1
  130. package/dist/components/TextArea/TextArea.cjs.map +1 -1
  131. package/dist/components/TextArea/TextArea.js +57 -21
  132. package/dist/components/TextArea/TextArea.js.map +1 -1
  133. package/dist/components/TextArea/constants.cjs +2 -0
  134. package/dist/components/TextArea/constants.cjs.map +1 -0
  135. package/dist/components/TextArea/constants.d.ts +1 -0
  136. package/dist/components/TextArea/constants.js +5 -0
  137. package/dist/components/TextArea/constants.js.map +1 -0
  138. package/dist/components/TextFieldBase/TextFieldBase.cjs +1 -1
  139. package/dist/components/TextFieldBase/TextFieldBase.cjs.map +1 -1
  140. package/dist/components/TextFieldBase/TextFieldBase.js +69 -59
  141. package/dist/components/TextFieldBase/TextFieldBase.js.map +1 -1
  142. package/dist/components/TextFieldBase/useTextFieldBaseStyleProps.cjs +1 -1
  143. package/dist/components/TextFieldBase/useTextFieldBaseStyleProps.cjs.map +1 -1
  144. package/dist/components/TextFieldBase/useTextFieldBaseStyleProps.d.ts +1 -0
  145. package/dist/components/TextFieldBase/useTextFieldBaseStyleProps.js +11 -10
  146. package/dist/components/TextFieldBase/useTextFieldBaseStyleProps.js.map +1 -1
  147. package/dist/components/Toggle/Toggle.cjs +1 -1
  148. package/dist/components/Toggle/Toggle.cjs.map +1 -1
  149. package/dist/components/Toggle/Toggle.js +59 -55
  150. package/dist/components/Toggle/Toggle.js.map +1 -1
  151. package/dist/components/UNSTABLE_File/UNSTABLE_File.cjs +2 -0
  152. package/dist/components/UNSTABLE_File/UNSTABLE_File.cjs.map +1 -0
  153. package/dist/components/UNSTABLE_File/UNSTABLE_File.d.ts +8 -0
  154. package/dist/components/UNSTABLE_File/UNSTABLE_File.js +88 -0
  155. package/dist/components/UNSTABLE_File/UNSTABLE_File.js.map +1 -0
  156. package/dist/components/UNSTABLE_File/UNSTABLE_FileImagePreview.cjs +2 -0
  157. package/dist/components/UNSTABLE_File/UNSTABLE_FileImagePreview.cjs.map +1 -0
  158. package/dist/components/UNSTABLE_File/UNSTABLE_FileImagePreview.d.ts +8 -0
  159. package/dist/components/UNSTABLE_File/UNSTABLE_FileImagePreview.js +29 -0
  160. package/dist/components/UNSTABLE_File/UNSTABLE_FileImagePreview.js.map +1 -0
  161. package/dist/components/UNSTABLE_File/constants.cjs +2 -0
  162. package/dist/components/UNSTABLE_File/constants.cjs.map +1 -0
  163. package/dist/components/UNSTABLE_File/constants.d.ts +9 -0
  164. package/dist/components/UNSTABLE_File/constants.js +13 -0
  165. package/dist/components/UNSTABLE_File/constants.js.map +1 -0
  166. package/dist/components/UNSTABLE_File/index.cjs +2 -0
  167. package/dist/components/UNSTABLE_File/index.cjs.map +1 -0
  168. package/dist/components/UNSTABLE_File/index.d.ts +6 -0
  169. package/dist/components/UNSTABLE_File/index.js +16 -0
  170. package/dist/components/UNSTABLE_File/index.js.map +1 -0
  171. package/dist/components/UNSTABLE_File/types.d.ts +48 -0
  172. package/dist/components/UNSTABLE_File/useFileImageStyles.cjs +2 -0
  173. package/dist/components/UNSTABLE_File/useFileImageStyles.cjs.map +1 -0
  174. package/dist/components/UNSTABLE_File/useFileImageStyles.d.ts +19 -0
  175. package/dist/components/UNSTABLE_File/useFileImageStyles.js +21 -0
  176. package/dist/components/UNSTABLE_File/useFileImageStyles.js.map +1 -0
  177. package/dist/components/UNSTABLE_File/useFileStyleProps.cjs +2 -0
  178. package/dist/components/UNSTABLE_File/useFileStyleProps.cjs.map +1 -0
  179. package/dist/components/UNSTABLE_File/useFileStyleProps.d.ts +20 -0
  180. package/dist/components/UNSTABLE_File/useFileStyleProps.js +29 -0
  181. package/dist/components/UNSTABLE_File/useFileStyleProps.js.map +1 -0
  182. package/dist/components/UNSTABLE_File.d.ts +2 -0
  183. package/dist/components/UNSTABLE_FileUpload/UNSTABLE_FileUpload.cjs +1 -1
  184. package/dist/components/UNSTABLE_FileUpload/UNSTABLE_FileUpload.cjs.map +1 -1
  185. package/dist/components/UNSTABLE_FileUpload/UNSTABLE_FileUpload.js +129 -112
  186. package/dist/components/UNSTABLE_FileUpload/UNSTABLE_FileUpload.js.map +1 -1
  187. package/dist/components/UNSTABLE_FileUpload/types.d.ts +6 -3
  188. package/dist/components/UNSTABLE_FileUpload/useFileUploadStyleProps.cjs +1 -1
  189. package/dist/components/UNSTABLE_FileUpload/useFileUploadStyleProps.cjs.map +1 -1
  190. package/dist/components/UNSTABLE_FileUpload/useFileUploadStyleProps.d.ts +2 -3
  191. package/dist/components/UNSTABLE_FileUpload/useFileUploadStyleProps.js +18 -16
  192. package/dist/components/UNSTABLE_FileUpload/useFileUploadStyleProps.js.map +1 -1
  193. package/dist/components/UNSTABLE_Picker/PickerContext.cjs +2 -0
  194. package/dist/components/UNSTABLE_Picker/PickerContext.cjs.map +1 -0
  195. package/dist/components/UNSTABLE_Picker/PickerContext.d.ts +3 -0
  196. package/dist/components/UNSTABLE_Picker/PickerContext.js +9 -0
  197. package/dist/components/UNSTABLE_Picker/PickerContext.js.map +1 -0
  198. package/dist/components/UNSTABLE_Picker/PickerPopoverContext.cjs +2 -0
  199. package/dist/components/UNSTABLE_Picker/PickerPopoverContext.cjs.map +1 -0
  200. package/dist/components/UNSTABLE_Picker/PickerPopoverContext.d.ts +3 -0
  201. package/dist/components/UNSTABLE_Picker/PickerPopoverContext.js +16 -0
  202. package/dist/components/UNSTABLE_Picker/PickerPopoverContext.js.map +1 -0
  203. package/dist/components/UNSTABLE_Picker/UNSTABLE_Picker.cjs +2 -0
  204. package/dist/components/UNSTABLE_Picker/UNSTABLE_Picker.cjs.map +1 -0
  205. package/dist/components/UNSTABLE_Picker/UNSTABLE_Picker.d.ts +4 -0
  206. package/dist/components/UNSTABLE_Picker/UNSTABLE_Picker.js +204 -0
  207. package/dist/components/UNSTABLE_Picker/UNSTABLE_Picker.js.map +1 -0
  208. package/dist/components/UNSTABLE_Picker/UNSTABLE_PickerGroup.cjs +2 -0
  209. package/dist/components/UNSTABLE_Picker/UNSTABLE_PickerGroup.cjs.map +1 -0
  210. package/dist/components/UNSTABLE_Picker/UNSTABLE_PickerGroup.d.ts +7 -0
  211. package/dist/components/UNSTABLE_Picker/UNSTABLE_PickerGroup.js +14 -0
  212. package/dist/components/UNSTABLE_Picker/UNSTABLE_PickerGroup.js.map +1 -0
  213. package/dist/components/UNSTABLE_Picker/UNSTABLE_PickerItem.cjs +2 -0
  214. package/dist/components/UNSTABLE_Picker/UNSTABLE_PickerItem.cjs.map +1 -0
  215. package/dist/components/UNSTABLE_Picker/UNSTABLE_PickerItem.d.ts +7 -0
  216. package/dist/components/UNSTABLE_Picker/UNSTABLE_PickerItem.js +32 -0
  217. package/dist/components/UNSTABLE_Picker/UNSTABLE_PickerItem.js.map +1 -0
  218. package/dist/components/UNSTABLE_Picker/UNSTABLE_PickerTag.cjs +2 -0
  219. package/dist/components/UNSTABLE_Picker/UNSTABLE_PickerTag.cjs.map +1 -0
  220. package/dist/components/UNSTABLE_Picker/UNSTABLE_PickerTag.d.ts +7 -0
  221. package/dist/components/UNSTABLE_Picker/UNSTABLE_PickerTag.js +64 -0
  222. package/dist/components/UNSTABLE_Picker/UNSTABLE_PickerTag.js.map +1 -0
  223. package/dist/components/UNSTABLE_Picker/UNSTABLE_UncontrolledPicker.cjs +2 -0
  224. package/dist/components/UNSTABLE_Picker/UNSTABLE_UncontrolledPicker.cjs.map +1 -0
  225. package/dist/components/UNSTABLE_Picker/UNSTABLE_UncontrolledPicker.d.ts +4 -0
  226. package/dist/components/UNSTABLE_Picker/UNSTABLE_UncontrolledPicker.js +40 -0
  227. package/dist/components/UNSTABLE_Picker/UNSTABLE_UncontrolledPicker.js.map +1 -0
  228. package/dist/components/UNSTABLE_Picker/constants.cjs +2 -0
  229. package/dist/components/UNSTABLE_Picker/constants.cjs.map +1 -0
  230. package/dist/components/UNSTABLE_Picker/constants.d.ts +6 -0
  231. package/dist/components/UNSTABLE_Picker/constants.js +11 -0
  232. package/dist/components/UNSTABLE_Picker/constants.js.map +1 -0
  233. package/dist/components/UNSTABLE_Picker/index.cjs +2 -0
  234. package/dist/components/UNSTABLE_Picker/index.cjs.map +1 -0
  235. package/dist/components/UNSTABLE_Picker/index.d.ts +11 -0
  236. package/dist/components/UNSTABLE_Picker/index.js +26 -0
  237. package/dist/components/UNSTABLE_Picker/index.js.map +1 -0
  238. package/dist/components/UNSTABLE_Picker/types.d.ts +91 -0
  239. package/dist/components/UNSTABLE_Picker/usePickerId.cjs +2 -0
  240. package/dist/components/UNSTABLE_Picker/usePickerId.cjs.map +1 -0
  241. package/dist/components/UNSTABLE_Picker/usePickerId.d.ts +8 -0
  242. package/dist/components/UNSTABLE_Picker/usePickerId.js +15 -0
  243. package/dist/components/UNSTABLE_Picker/usePickerId.js.map +1 -0
  244. package/dist/components/UNSTABLE_Picker/usePickerPopoverTabOutToTrigger.cjs +2 -0
  245. package/dist/components/UNSTABLE_Picker/usePickerPopoverTabOutToTrigger.cjs.map +1 -0
  246. package/dist/components/UNSTABLE_Picker/usePickerPopoverTabOutToTrigger.d.ts +11 -0
  247. package/dist/components/UNSTABLE_Picker/usePickerPopoverTabOutToTrigger.js +27 -0
  248. package/dist/components/UNSTABLE_Picker/usePickerPopoverTabOutToTrigger.js.map +1 -0
  249. package/dist/components/UNSTABLE_Picker/usePickerSelectionGridKeyboard.cjs +2 -0
  250. package/dist/components/UNSTABLE_Picker/usePickerSelectionGridKeyboard.cjs.map +1 -0
  251. package/dist/components/UNSTABLE_Picker/usePickerSelectionGridKeyboard.d.ts +13 -0
  252. package/dist/components/UNSTABLE_Picker/usePickerSelectionGridKeyboard.js +95 -0
  253. package/dist/components/UNSTABLE_Picker/usePickerSelectionGridKeyboard.js.map +1 -0
  254. package/dist/components/UNSTABLE_Picker/usePickerStyleProps.cjs +2 -0
  255. package/dist/components/UNSTABLE_Picker/usePickerStyleProps.cjs.map +1 -0
  256. package/dist/components/UNSTABLE_Picker/usePickerStyleProps.d.ts +21 -0
  257. package/dist/components/UNSTABLE_Picker/usePickerStyleProps.js +29 -0
  258. package/dist/components/UNSTABLE_Picker/usePickerStyleProps.js.map +1 -0
  259. package/dist/components/UNSTABLE_Picker/utils.cjs +2 -0
  260. package/dist/components/UNSTABLE_Picker/utils.cjs.map +1 -0
  261. package/dist/components/UNSTABLE_Picker/utils.d.ts +10 -0
  262. package/dist/components/UNSTABLE_Picker/utils.js +41 -0
  263. package/dist/components/UNSTABLE_Picker/utils.js.map +1 -0
  264. package/dist/components/UNSTABLE_Picker.d.ts +2 -0
  265. package/dist/components/index.cjs +1 -1
  266. package/dist/components/index.d.ts +4 -1
  267. package/dist/components/index.js +523 -498
  268. package/dist/components/index.js.map +1 -1
  269. package/dist/constants/index.cjs +1 -1
  270. package/dist/constants/index.d.ts +1 -0
  271. package/dist/constants/index.js +43 -40
  272. package/dist/constants/index.js.map +1 -1
  273. package/dist/constants/selection.cjs +2 -0
  274. package/dist/constants/selection.cjs.map +1 -0
  275. package/dist/constants/selection.d.ts +2 -0
  276. package/dist/constants/selection.js +6 -0
  277. package/dist/constants/selection.js.map +1 -0
  278. package/dist/context/RouterContext.cjs +2 -0
  279. package/dist/context/RouterContext.cjs.map +1 -0
  280. package/dist/context/RouterContext.d.ts +16 -0
  281. package/dist/context/RouterContext.js +12 -0
  282. package/dist/context/RouterContext.js.map +1 -0
  283. package/dist/context/index.cjs +1 -1
  284. package/dist/context/index.d.ts +1 -0
  285. package/dist/context/index.js +11 -7
  286. package/dist/context/index.js.map +1 -1
  287. package/dist/hooks/index.cjs +1 -1
  288. package/dist/hooks/index.d.ts +5 -1
  289. package/dist/hooks/index.js +54 -40
  290. package/dist/hooks/index.js.map +1 -1
  291. package/dist/hooks/useAriaIdRefs.cjs +2 -0
  292. package/dist/hooks/useAriaIdRefs.cjs.map +1 -0
  293. package/dist/hooks/useAriaIdRefs.d.ts +11 -0
  294. package/dist/hooks/useAriaIdRefs.js +23 -0
  295. package/dist/hooks/useAriaIdRefs.js.map +1 -0
  296. package/dist/hooks/useControlledModeGuard.cjs +2 -0
  297. package/dist/hooks/useControlledModeGuard.cjs.map +1 -0
  298. package/dist/hooks/useControlledModeGuard.d.ts +10 -0
  299. package/dist/hooks/useControlledModeGuard.js +33 -0
  300. package/dist/hooks/useControlledModeGuard.js.map +1 -0
  301. package/dist/hooks/useDebouncedValue.cjs +2 -0
  302. package/dist/hooks/useDebouncedValue.cjs.map +1 -0
  303. package/dist/hooks/useDebouncedValue.d.ts +1 -0
  304. package/dist/hooks/useDebouncedValue.js +17 -0
  305. package/dist/hooks/useDebouncedValue.js.map +1 -0
  306. package/dist/hooks/useLinkClick.cjs +2 -0
  307. package/dist/hooks/useLinkClick.cjs.map +1 -0
  308. package/dist/hooks/useLinkClick.d.ts +4 -0
  309. package/dist/hooks/useLinkClick.js +15 -0
  310. package/dist/hooks/useLinkClick.js.map +1 -0
  311. package/dist/hooks/useSelectionState.cjs +2 -0
  312. package/dist/hooks/useSelectionState.cjs.map +1 -0
  313. package/dist/hooks/useSelectionState.d.ts +17 -0
  314. package/dist/hooks/useSelectionState.js +41 -0
  315. package/dist/hooks/useSelectionState.js.map +1 -0
  316. package/dist/index.cjs +1 -1
  317. package/dist/index.js +722 -673
  318. package/dist/index.js.map +1 -1
  319. package/dist/translations/defaults.cjs +1 -1
  320. package/dist/translations/defaults.cjs.map +1 -1
  321. package/dist/translations/defaults.d.ts +17 -0
  322. package/dist/translations/defaults.js +17 -0
  323. package/dist/translations/defaults.js.map +1 -1
  324. package/dist/types/button.d.ts +3 -2
  325. package/dist/types/card.cjs.map +1 -1
  326. package/dist/types/card.d.ts +5 -7
  327. package/dist/types/card.js.map +1 -1
  328. package/dist/types/checkbox.d.ts +2 -2
  329. package/dist/types/controlButton.d.ts +2 -3
  330. package/dist/types/header.d.ts +3 -3
  331. package/dist/types/index.d.ts +1 -0
  332. package/dist/types/inputDetails.d.ts +9 -0
  333. package/dist/types/link.cjs.map +1 -1
  334. package/dist/types/link.d.ts +2 -2
  335. package/dist/types/link.js.map +1 -1
  336. package/dist/types/pagination.d.ts +4 -4
  337. package/dist/types/shared/index.cjs.map +1 -1
  338. package/dist/types/shared/index.d.ts +1 -0
  339. package/dist/types/shared/index.js.map +1 -1
  340. package/dist/types/shared/inputs.d.ts +3 -0
  341. package/dist/types/shared/router.d.ts +3 -0
  342. package/dist/types/tabs.d.ts +2 -2
  343. package/dist/types/tag.d.ts +1 -0
  344. package/dist/types/textArea.d.ts +26 -5
  345. package/dist/types/textFieldBase.d.ts +5 -2
  346. package/dist/types/toggle.d.ts +2 -2
  347. package/dist/utils/debounce.cjs +1 -1
  348. package/dist/utils/debounce.cjs.map +1 -1
  349. package/dist/utils/debounce.d.ts +4 -1
  350. package/dist/utils/debounce.js +11 -8
  351. package/dist/utils/debounce.js.map +1 -1
  352. package/dist/utils/index.cjs +1 -1
  353. package/dist/utils/index.d.ts +1 -0
  354. package/dist/utils/index.js +36 -33
  355. package/dist/utils/index.js.map +1 -1
  356. package/dist/utils/router.cjs +2 -0
  357. package/dist/utils/router.cjs.map +1 -0
  358. package/dist/utils/router.d.ts +12 -0
  359. package/dist/utils/router.js +10 -0
  360. package/dist/utils/router.js.map +1 -0
  361. package/dist/utils/string.cjs +1 -1
  362. package/dist/utils/string.cjs.map +1 -1
  363. package/dist/utils/string.d.ts +1 -0
  364. package/dist/utils/string.js +10 -9
  365. package/dist/utils/string.js.map +1 -1
  366. package/package.json +38 -23
  367. package/dist/components/Field/useAriaIds.cjs +0 -2
  368. package/dist/components/Field/useAriaIds.cjs.map +0 -1
  369. package/dist/components/Field/useAriaIds.d.ts +0 -8
  370. package/dist/components/Field/useAriaIds.js +0 -15
  371. package/dist/components/Field/useAriaIds.js.map +0 -1
  372. package/dist/components/UNSTABLE_Attachment/UNSTABLE_Attachment.cjs +0 -2
  373. package/dist/components/UNSTABLE_Attachment/UNSTABLE_Attachment.cjs.map +0 -1
  374. package/dist/components/UNSTABLE_Attachment/UNSTABLE_Attachment.d.ts +0 -8
  375. package/dist/components/UNSTABLE_Attachment/UNSTABLE_Attachment.js +0 -42
  376. package/dist/components/UNSTABLE_Attachment/UNSTABLE_Attachment.js.map +0 -1
  377. package/dist/components/UNSTABLE_Attachment/UNSTABLE_AttachmentActionButton.cjs +0 -2
  378. package/dist/components/UNSTABLE_Attachment/UNSTABLE_AttachmentActionButton.cjs.map +0 -1
  379. package/dist/components/UNSTABLE_Attachment/UNSTABLE_AttachmentActionButton.d.ts +0 -8
  380. package/dist/components/UNSTABLE_Attachment/UNSTABLE_AttachmentActionButton.js +0 -30
  381. package/dist/components/UNSTABLE_Attachment/UNSTABLE_AttachmentActionButton.js.map +0 -1
  382. package/dist/components/UNSTABLE_Attachment/UNSTABLE_AttachmentDismissButton.cjs +0 -2
  383. package/dist/components/UNSTABLE_Attachment/UNSTABLE_AttachmentDismissButton.cjs.map +0 -1
  384. package/dist/components/UNSTABLE_Attachment/UNSTABLE_AttachmentDismissButton.d.ts +0 -8
  385. package/dist/components/UNSTABLE_Attachment/UNSTABLE_AttachmentDismissButton.js +0 -29
  386. package/dist/components/UNSTABLE_Attachment/UNSTABLE_AttachmentDismissButton.js.map +0 -1
  387. package/dist/components/UNSTABLE_Attachment/UNSTABLE_AttachmentImagePreview.cjs +0 -2
  388. package/dist/components/UNSTABLE_Attachment/UNSTABLE_AttachmentImagePreview.cjs.map +0 -1
  389. package/dist/components/UNSTABLE_Attachment/UNSTABLE_AttachmentImagePreview.d.ts +0 -8
  390. package/dist/components/UNSTABLE_Attachment/UNSTABLE_AttachmentImagePreview.js +0 -29
  391. package/dist/components/UNSTABLE_Attachment/UNSTABLE_AttachmentImagePreview.js.map +0 -1
  392. package/dist/components/UNSTABLE_Attachment/constants.cjs +0 -2
  393. package/dist/components/UNSTABLE_Attachment/constants.cjs.map +0 -1
  394. package/dist/components/UNSTABLE_Attachment/constants.d.ts +0 -9
  395. package/dist/components/UNSTABLE_Attachment/constants.js +0 -13
  396. package/dist/components/UNSTABLE_Attachment/constants.js.map +0 -1
  397. package/dist/components/UNSTABLE_Attachment/index.cjs +0 -2
  398. package/dist/components/UNSTABLE_Attachment/index.d.ts +0 -8
  399. package/dist/components/UNSTABLE_Attachment/index.js +0 -20
  400. package/dist/components/UNSTABLE_Attachment/types.d.ts +0 -42
  401. package/dist/components/UNSTABLE_Attachment/useAttachmentImageStyles.cjs +0 -2
  402. package/dist/components/UNSTABLE_Attachment/useAttachmentImageStyles.cjs.map +0 -1
  403. package/dist/components/UNSTABLE_Attachment/useAttachmentImageStyles.d.ts +0 -18
  404. package/dist/components/UNSTABLE_Attachment/useAttachmentImageStyles.js +0 -22
  405. package/dist/components/UNSTABLE_Attachment/useAttachmentImageStyles.js.map +0 -1
  406. package/dist/components/UNSTABLE_Attachment/useAttachmentStyleProps.cjs +0 -2
  407. package/dist/components/UNSTABLE_Attachment/useAttachmentStyleProps.cjs.map +0 -1
  408. package/dist/components/UNSTABLE_Attachment/useAttachmentStyleProps.d.ts +0 -21
  409. package/dist/components/UNSTABLE_Attachment/useAttachmentStyleProps.js +0 -24
  410. package/dist/components/UNSTABLE_Attachment/useAttachmentStyleProps.js.map +0 -1
  411. package/dist/components/UNSTABLE_Attachment.d.ts +0 -2
  412. package/dist/hooks/useAriaDescribedBy.cjs +0 -2
  413. package/dist/hooks/useAriaDescribedBy.cjs.map +0 -1
  414. package/dist/hooks/useAriaDescribedBy.d.ts +0 -5
  415. package/dist/hooks/useAriaDescribedBy.js +0 -7
  416. package/dist/hooks/useAriaDescribedBy.js.map +0 -1
  417. /package/dist/components/{UNSTABLE_Attachment → CharacterCounter}/index.cjs.map +0 -0
@@ -0,0 +1,11 @@
1
+ export { default as UNSTABLE_Picker } from './UNSTABLE_Picker';
2
+ export { default as UNSTABLE_PickerGroup } from './UNSTABLE_PickerGroup';
3
+ export { default as UNSTABLE_PickerItem } from './UNSTABLE_PickerItem';
4
+ export { default as UNSTABLE_PickerTag } from './UNSTABLE_PickerTag';
5
+ export { default as UNSTABLE_UncontrolledPicker } from './UNSTABLE_UncontrolledPicker';
6
+ export { PickerPopoverContextProvider, usePickerPopoverContext } from './PickerPopoverContext';
7
+ export * from './types';
8
+ export * from './usePickerId';
9
+ export * from './usePickerPopoverTabOutToTrigger';
10
+ export * from './usePickerSelectionGridKeyboard';
11
+ export * from './usePickerStyleProps';
@@ -0,0 +1,26 @@
1
+ import { default as o } from "./UNSTABLE_Picker.js";
2
+ import { default as P } from "./UNSTABLE_PickerGroup.js";
3
+ import { default as c } from "./UNSTABLE_PickerItem.js";
4
+ import { default as f } from "./UNSTABLE_PickerTag.js";
5
+ import { default as a } from "./UNSTABLE_UncontrolledPicker.js";
6
+ import { PickerPopoverContextProvider as k, usePickerPopoverContext as m } from "./PickerPopoverContext.js";
7
+ import { usePickerId as l } from "./usePickerId.js";
8
+ import { PICKER_POPOVER_FOCUSABLE_SELECTOR as d, getPickerPopoverFocusableElements as T, usePickerPopoverTabOutToTrigger as S } from "./usePickerPopoverTabOutToTrigger.js";
9
+ import { usePickerSelectionGridKeyboard as L } from "./usePickerSelectionGridKeyboard.js";
10
+ import { usePickerStyleProps as n } from "./usePickerStyleProps.js";
11
+ export {
12
+ d as PICKER_POPOVER_FOCUSABLE_SELECTOR,
13
+ k as PickerPopoverContextProvider,
14
+ o as UNSTABLE_Picker,
15
+ P as UNSTABLE_PickerGroup,
16
+ c as UNSTABLE_PickerItem,
17
+ f as UNSTABLE_PickerTag,
18
+ a as UNSTABLE_UncontrolledPicker,
19
+ T as getPickerPopoverFocusableElements,
20
+ l as usePickerId,
21
+ m as usePickerPopoverContext,
22
+ S as usePickerPopoverTabOutToTrigger,
23
+ L as usePickerSelectionGridKeyboard,
24
+ n as usePickerStyleProps
25
+ };
26
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;"}
@@ -0,0 +1,91 @@
1
+ import { FocusEvent, KeyboardEvent, ReactNode } from 'react';
2
+ import { SelectionMode } from '../../hooks';
3
+ import { HelperTextProps, SizesDictionaryType, SpiritCheckboxProps, SpiritDivElementProps, SpiritFieldGroupProps, SpiritTagProps, Validation, ValidationTextProp } from '../../types';
4
+ export type UnstablePickerSelectionMode = SelectionMode;
5
+ export interface UnstablePickerSelectionGridRowProps {
6
+ tabIndex: 0 | -1;
7
+ onKeyDown: (event: KeyboardEvent<HTMLElement>) => void;
8
+ onFocusCapture: (event: FocusEvent<HTMLElement>) => void;
9
+ onBlurCapture: (event: FocusEvent<HTMLElement>) => void;
10
+ removeButtonTabIndex: 0 | -1;
11
+ }
12
+ export interface UnstablePickerTranslations {
13
+ addButtonLabel?: string;
14
+ closeButtonLabel?: string;
15
+ emptySelectionLabel?: string;
16
+ removeAllLabel?: string;
17
+ removeItemLabel?: string;
18
+ selectionAriaLabel?: string;
19
+ tagDescriptionText?: string;
20
+ }
21
+ export interface UnstablePickerRenderTagsOptions {
22
+ getKeyboardGridRowProps: (index: number) => UnstablePickerSelectionGridRowProps;
23
+ onRemove: (key: string) => void;
24
+ removeTagAtIndex: (index: number) => void;
25
+ }
26
+ export interface UnstablePickerBaseProps<S = void> extends Omit<SpiritDivElementProps, 'children' | 'ref' | 'id'>, HelperTextProps, Validation, ValidationTextProp, UnstablePickerTranslations {
27
+ children: ReactNode;
28
+ id: string;
29
+ isAggregated?: boolean;
30
+ isDisabled?: boolean;
31
+ isFluid?: boolean;
32
+ isLabelHidden?: boolean;
33
+ isRequired?: boolean;
34
+ label: string;
35
+ renderTags?: (options: UnstablePickerRenderTagsOptions) => ReactNode;
36
+ selectionMode?: UnstablePickerSelectionMode;
37
+ size?: SizesDictionaryType<S>;
38
+ }
39
+ export interface UnstablePickerProps<S = void> extends UnstablePickerBaseProps<S> {
40
+ isOpen: boolean;
41
+ onSelectionChange: (keys: string[]) => void;
42
+ onToggle: () => void;
43
+ selectedKeys: string[];
44
+ }
45
+ export interface UnstableUncontrolledPickerProps<S = void> extends UnstablePickerBaseProps<S> {
46
+ defaultIsOpen?: boolean;
47
+ defaultSelectedKeys?: string[];
48
+ onSelectionChange?: (keys: string[]) => void;
49
+ }
50
+ export interface UnstablePickerTagProps extends Omit<SpiritTagProps<'div'>, 'color' | 'elementType' | 'size' | 'children' | 'role' | 'tabIndex' | 'aria-label' | 'aria-describedby'> {
51
+ children?: ReactNode;
52
+ tagKeyboardProps?: UnstablePickerSelectionGridRowProps;
53
+ isDisabled?: boolean;
54
+ label: ReactNode;
55
+ onRemove: () => void;
56
+ removeLabel?: string;
57
+ }
58
+ export interface UnstablePickerGroupProps extends Omit<SpiritFieldGroupProps, 'id' | 'isFluid' | 'isLabelHidden'> {
59
+ children: ReactNode;
60
+ label: string;
61
+ }
62
+ export interface UnstablePickerItemProps extends Omit<SpiritCheckboxProps, 'id' | 'label' | 'isChecked' | 'isDisabled' | 'value' | 'onChange' | 'inputPosition' | 'isItem' | 'name'> {
63
+ children: ReactNode;
64
+ value: string;
65
+ }
66
+ export type UnstablePickerItemData = {
67
+ label: ReactNode;
68
+ value: string;
69
+ };
70
+ export interface UnstablePickerRef {
71
+ close: () => void;
72
+ selectedKeys: string[];
73
+ }
74
+ export interface UnstablePickerContextType {
75
+ size: SizesDictionaryType;
76
+ tagDescriptionId?: string;
77
+ }
78
+ export interface UnstablePickerPopoverContextValue {
79
+ id: string;
80
+ isDisabled: boolean;
81
+ onSelectionChange: (keys: string[]) => void;
82
+ selectedKeys: string[];
83
+ selectionMode: UnstablePickerSelectionMode;
84
+ }
85
+ export type SpiritUnstablePickerProps<S = void> = UnstablePickerProps<S>;
86
+ export type SpiritUnstableUncontrolledPickerProps<S = void> = UnstableUncontrolledPickerProps<S>;
87
+ export type SpiritUnstablePickerRenderTagsOptions = UnstablePickerRenderTagsOptions;
88
+ export type SpiritUnstablePickerGroupProps = UnstablePickerGroupProps;
89
+ export type SpiritUnstablePickerTagProps = UnstablePickerTagProps;
90
+ export type SpiritUnstablePickerItemProps = UnstablePickerItemProps;
91
+ export type SpiritUnstablePickerRef = UnstablePickerRef;
@@ -0,0 +1,2 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("react"),o=t=>r.useMemo(()=>{const e=`picker-${t}`;return{pickerId:e,labelId:`${e}-label`,popoverId:`${e}-popover`,selectionId:`${e}-selection`,tagDescriptionId:`${e}-tag-description`}},[t]);exports.usePickerId=o;
2
+ //# sourceMappingURL=usePickerId.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"usePickerId.cjs","sources":["../../../src/components/UNSTABLE_Picker/usePickerId.ts"],"sourcesContent":["import { useMemo } from 'react';\n\nexport interface UnstablePickerId {\n labelId: string;\n pickerId: string;\n popoverId: string;\n selectionId: string;\n tagDescriptionId: string;\n}\n\nexport const usePickerId = (id: string): UnstablePickerId =>\n useMemo(() => {\n const pickerId = `picker-${id}`;\n\n return {\n pickerId,\n labelId: `${pickerId}-label`,\n popoverId: `${pickerId}-popover`,\n selectionId: `${pickerId}-selection`,\n tagDescriptionId: `${pickerId}-tag-description`,\n };\n }, [id]);\n"],"names":["usePickerId","id","useMemo","pickerId"],"mappings":"yGAUaA,EAAeC,GAC1BC,EAAAA,QAAQ,IAAM,CACZ,MAAMC,EAAW,UAAUF,CAAE,GAE7B,MAAO,CACL,SAAAE,EACA,QAAS,GAAGA,CAAQ,SACpB,UAAW,GAAGA,CAAQ,WACtB,YAAa,GAAGA,CAAQ,aACxB,iBAAkB,GAAGA,CAAQ,kBAAA,CAEjC,EAAG,CAACF,CAAE,CAAC"}
@@ -0,0 +1,8 @@
1
+ export interface UnstablePickerId {
2
+ labelId: string;
3
+ pickerId: string;
4
+ popoverId: string;
5
+ selectionId: string;
6
+ tagDescriptionId: string;
7
+ }
8
+ export declare const usePickerId: (id: string) => UnstablePickerId;
@@ -0,0 +1,15 @@
1
+ import { useMemo as r } from "react";
2
+ const c = (o) => r(() => {
3
+ const e = `picker-${o}`;
4
+ return {
5
+ pickerId: e,
6
+ labelId: `${e}-label`,
7
+ popoverId: `${e}-popover`,
8
+ selectionId: `${e}-selection`,
9
+ tagDescriptionId: `${e}-tag-description`
10
+ };
11
+ }, [o]);
12
+ export {
13
+ c as usePickerId
14
+ };
15
+ //# sourceMappingURL=usePickerId.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"usePickerId.js","sources":["../../../src/components/UNSTABLE_Picker/usePickerId.ts"],"sourcesContent":["import { useMemo } from 'react';\n\nexport interface UnstablePickerId {\n labelId: string;\n pickerId: string;\n popoverId: string;\n selectionId: string;\n tagDescriptionId: string;\n}\n\nexport const usePickerId = (id: string): UnstablePickerId =>\n useMemo(() => {\n const pickerId = `picker-${id}`;\n\n return {\n pickerId,\n labelId: `${pickerId}-label`,\n popoverId: `${pickerId}-popover`,\n selectionId: `${pickerId}-selection`,\n tagDescriptionId: `${pickerId}-tag-description`,\n };\n }, [id]);\n"],"names":["usePickerId","id","useMemo","pickerId"],"mappings":";AAUO,MAAMA,IAAc,CAACC,MAC1BC,EAAQ,MAAM;AACZ,QAAMC,IAAW,UAAUF,CAAE;AAE7B,SAAO;AAAA,IACL,UAAAE;AAAA,IACA,SAAS,GAAGA,CAAQ;AAAA,IACpB,WAAW,GAAGA,CAAQ;AAAA,IACtB,aAAa,GAAGA,CAAQ;AAAA,IACxB,kBAAkB,GAAGA,CAAQ;AAAA,EAAA;AAEjC,GAAG,CAACF,CAAE,CAAC;"}
@@ -0,0 +1,2 @@
1
+ "use strict";"use client";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const P=require("react"),c="input:not([disabled]), button:not([disabled]), select:not([disabled]), textarea:not([disabled]), a[href]",l=r=>Array.from(r.querySelectorAll(c)),b=({isOpen:r,onClose:n,getLastPopoverFocusable:a})=>({onPopoverKeyDownCapture:P.useCallback(e=>{if(e.key!=="Tab"||e.shiftKey||!r)return;const s=e.currentTarget;let t=a?.()??null;if(!t){const o=l(s);t=o.length>0?o[o.length-1]:null}const u=e.target instanceof Node?e.target:null,i=document.activeElement;!t||u!==t&&i!==t||(e.preventDefault(),n())},[a,r,n])});exports.PICKER_POPOVER_FOCUSABLE_SELECTOR=c;exports.getPickerPopoverFocusableElements=l;exports.usePickerPopoverTabOutToTrigger=b;
2
+ //# sourceMappingURL=usePickerPopoverTabOutToTrigger.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"usePickerPopoverTabOutToTrigger.cjs","sources":["../../../src/components/UNSTABLE_Picker/usePickerPopoverTabOutToTrigger.ts"],"sourcesContent":["'use client';\n\nimport { type KeyboardEvent, type KeyboardEventHandler, useCallback } from 'react';\n\n/**\n * Matches interactive controls inside the picker popover (dialog), in document order.\n * Used to detect Tab from the last focusable (non-modal anchored dropdown pattern).\n */\nexport const PICKER_POPOVER_FOCUSABLE_SELECTOR =\n 'input:not([disabled]), button:not([disabled]), select:not([disabled]), textarea:not([disabled]), a[href]';\n\nexport const getPickerPopoverFocusableElements = (container: HTMLElement): HTMLElement[] =>\n Array.from(container.querySelectorAll<HTMLElement>(PICKER_POPOVER_FOCUSABLE_SELECTOR));\n\nexport interface UsePickerPopoverTabOutToTriggerOptions {\n /** Optional focus registry from `PickerPopoverContext`; falls back to DOM query when missing. */\n getLastPopoverFocusable?: () => HTMLElement | null;\n isOpen: boolean;\n /**\n * Close the popover and restore focus to the trigger (e.g. picker’s imperative `close()`).\n * If you only pass `toggleOpen`, focus will not move to the trigger.\n */\n onClose: () => void;\n}\n\n/**\n * When the popover is open, Tab from the last focusable closes it via `onClose` (caller handles focus).\n *\n * @param options - Hook configuration.\n * @param options.isOpen - Whether the popover is open.\n * @param options.onClose - Close the popover and restore focus to the trigger (e.g. picker `close()`).\n * @param options.getLastPopoverFocusable - Optional; last focusable in the popover (registry or omit to query DOM).\n * @returns {{ onPopoverKeyDownCapture: KeyboardEventHandler<HTMLDivElement> }} Attach `onPopoverKeyDownCapture` to the popover content root.\n */\nexport const usePickerPopoverTabOutToTrigger = ({\n isOpen,\n onClose,\n getLastPopoverFocusable,\n}: UsePickerPopoverTabOutToTriggerOptions): {\n onPopoverKeyDownCapture: KeyboardEventHandler<HTMLDivElement>;\n} => {\n const onPopoverKeyDownCapture = useCallback(\n (event: KeyboardEvent<HTMLDivElement>) => {\n if (event.key !== 'Tab' || event.shiftKey || !isOpen) {\n return;\n }\n\n const container = event.currentTarget;\n let lastFocusable = getLastPopoverFocusable?.() ?? null;\n if (!lastFocusable) {\n const focusables = getPickerPopoverFocusableElements(container);\n lastFocusable = focusables.length > 0 ? focusables[focusables.length - 1]! : null;\n }\n const target = event.target instanceof Node ? event.target : null;\n const active = document.activeElement;\n\n if (!lastFocusable || (target !== lastFocusable && active !== lastFocusable)) {\n return;\n }\n\n event.preventDefault();\n onClose();\n },\n [getLastPopoverFocusable, isOpen, onClose],\n );\n\n return { onPopoverKeyDownCapture };\n};\n"],"names":["PICKER_POPOVER_FOCUSABLE_SELECTOR","getPickerPopoverFocusableElements","container","usePickerPopoverTabOutToTrigger","isOpen","onClose","getLastPopoverFocusable","useCallback","event","lastFocusable","focusables","target","active"],"mappings":"sHAQaA,EACX,2GAEWC,EAAqCC,GAChD,MAAM,KAAKA,EAAU,iBAA8BF,CAAiC,CAAC,EAsB1EG,EAAkC,CAAC,CAC9C,OAAAC,EACA,QAAAC,EACA,wBAAAC,CACF,KA4BS,CAAE,wBAzBuBC,EAAAA,YAC7BC,GAAyC,CACxC,GAAIA,EAAM,MAAQ,OAASA,EAAM,UAAY,CAACJ,EAC5C,OAGF,MAAMF,EAAYM,EAAM,cACxB,IAAIC,EAAgBH,OAA+B,KACnD,GAAI,CAACG,EAAe,CAClB,MAAMC,EAAaT,EAAkCC,CAAS,EAC9DO,EAAgBC,EAAW,OAAS,EAAIA,EAAWA,EAAW,OAAS,CAAC,EAAK,IAC/E,CACA,MAAMC,EAASH,EAAM,kBAAkB,KAAOA,EAAM,OAAS,KACvDI,EAAS,SAAS,cAEpB,CAACH,GAAkBE,IAAWF,GAAiBG,IAAWH,IAI9DD,EAAM,eAAA,EACNH,EAAA,EACF,EACA,CAACC,EAAyBF,EAAQC,CAAO,CAAA,CAGlC"}
@@ -0,0 +1,11 @@
1
+ import { KeyboardEventHandler } from 'react';
2
+ export declare const PICKER_POPOVER_FOCUSABLE_SELECTOR = "input:not([disabled]), button:not([disabled]), select:not([disabled]), textarea:not([disabled]), a[href]";
3
+ export declare const getPickerPopoverFocusableElements: (container: HTMLElement) => HTMLElement[];
4
+ export interface UsePickerPopoverTabOutToTriggerOptions {
5
+ getLastPopoverFocusable?: () => HTMLElement | null;
6
+ isOpen: boolean;
7
+ onClose: () => void;
8
+ }
9
+ export declare const usePickerPopoverTabOutToTrigger: ({ isOpen, onClose, getLastPopoverFocusable, }: UsePickerPopoverTabOutToTriggerOptions) => {
10
+ onPopoverKeyDownCapture: KeyboardEventHandler<HTMLDivElement>;
11
+ };
@@ -0,0 +1,27 @@
1
+ "use client";
2
+ import { useCallback as u } from "react";
3
+ const i = "input:not([disabled]), button:not([disabled]), select:not([disabled]), textarea:not([disabled]), a[href]", b = (r) => Array.from(r.querySelectorAll(i)), g = ({
4
+ isOpen: r,
5
+ onClose: n,
6
+ getLastPopoverFocusable: a
7
+ }) => ({ onPopoverKeyDownCapture: u(
8
+ (t) => {
9
+ if (t.key !== "Tab" || t.shiftKey || !r)
10
+ return;
11
+ const l = t.currentTarget;
12
+ let e = a?.() ?? null;
13
+ if (!e) {
14
+ const o = b(l);
15
+ e = o.length > 0 ? o[o.length - 1] : null;
16
+ }
17
+ const c = t.target instanceof Node ? t.target : null, s = document.activeElement;
18
+ !e || c !== e && s !== e || (t.preventDefault(), n());
19
+ },
20
+ [a, r, n]
21
+ ) });
22
+ export {
23
+ i as PICKER_POPOVER_FOCUSABLE_SELECTOR,
24
+ b as getPickerPopoverFocusableElements,
25
+ g as usePickerPopoverTabOutToTrigger
26
+ };
27
+ //# sourceMappingURL=usePickerPopoverTabOutToTrigger.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"usePickerPopoverTabOutToTrigger.js","sources":["../../../src/components/UNSTABLE_Picker/usePickerPopoverTabOutToTrigger.ts"],"sourcesContent":["'use client';\n\nimport { type KeyboardEvent, type KeyboardEventHandler, useCallback } from 'react';\n\n/**\n * Matches interactive controls inside the picker popover (dialog), in document order.\n * Used to detect Tab from the last focusable (non-modal anchored dropdown pattern).\n */\nexport const PICKER_POPOVER_FOCUSABLE_SELECTOR =\n 'input:not([disabled]), button:not([disabled]), select:not([disabled]), textarea:not([disabled]), a[href]';\n\nexport const getPickerPopoverFocusableElements = (container: HTMLElement): HTMLElement[] =>\n Array.from(container.querySelectorAll<HTMLElement>(PICKER_POPOVER_FOCUSABLE_SELECTOR));\n\nexport interface UsePickerPopoverTabOutToTriggerOptions {\n /** Optional focus registry from `PickerPopoverContext`; falls back to DOM query when missing. */\n getLastPopoverFocusable?: () => HTMLElement | null;\n isOpen: boolean;\n /**\n * Close the popover and restore focus to the trigger (e.g. picker’s imperative `close()`).\n * If you only pass `toggleOpen`, focus will not move to the trigger.\n */\n onClose: () => void;\n}\n\n/**\n * When the popover is open, Tab from the last focusable closes it via `onClose` (caller handles focus).\n *\n * @param options - Hook configuration.\n * @param options.isOpen - Whether the popover is open.\n * @param options.onClose - Close the popover and restore focus to the trigger (e.g. picker `close()`).\n * @param options.getLastPopoverFocusable - Optional; last focusable in the popover (registry or omit to query DOM).\n * @returns {{ onPopoverKeyDownCapture: KeyboardEventHandler<HTMLDivElement> }} Attach `onPopoverKeyDownCapture` to the popover content root.\n */\nexport const usePickerPopoverTabOutToTrigger = ({\n isOpen,\n onClose,\n getLastPopoverFocusable,\n}: UsePickerPopoverTabOutToTriggerOptions): {\n onPopoverKeyDownCapture: KeyboardEventHandler<HTMLDivElement>;\n} => {\n const onPopoverKeyDownCapture = useCallback(\n (event: KeyboardEvent<HTMLDivElement>) => {\n if (event.key !== 'Tab' || event.shiftKey || !isOpen) {\n return;\n }\n\n const container = event.currentTarget;\n let lastFocusable = getLastPopoverFocusable?.() ?? null;\n if (!lastFocusable) {\n const focusables = getPickerPopoverFocusableElements(container);\n lastFocusable = focusables.length > 0 ? focusables[focusables.length - 1]! : null;\n }\n const target = event.target instanceof Node ? event.target : null;\n const active = document.activeElement;\n\n if (!lastFocusable || (target !== lastFocusable && active !== lastFocusable)) {\n return;\n }\n\n event.preventDefault();\n onClose();\n },\n [getLastPopoverFocusable, isOpen, onClose],\n );\n\n return { onPopoverKeyDownCapture };\n};\n"],"names":["PICKER_POPOVER_FOCUSABLE_SELECTOR","getPickerPopoverFocusableElements","container","usePickerPopoverTabOutToTrigger","isOpen","onClose","getLastPopoverFocusable","useCallback","event","lastFocusable","focusables","target","active"],"mappings":";;AAQO,MAAMA,IACX,4GAEWC,IAAoC,CAACC,MAChD,MAAM,KAAKA,EAAU,iBAA8BF,CAAiC,CAAC,GAsB1EG,IAAkC,CAAC;AAAA,EAC9C,QAAAC;AAAA,EACA,SAAAC;AAAA,EACA,yBAAAC;AACF,OA4BS,EAAE,yBAzBuBC;AAAA,EAC9B,CAACC,MAAyC;AACxC,QAAIA,EAAM,QAAQ,SAASA,EAAM,YAAY,CAACJ;AAC5C;AAGF,UAAMF,IAAYM,EAAM;AACxB,QAAIC,IAAgBH,SAA+B;AACnD,QAAI,CAACG,GAAe;AAClB,YAAMC,IAAaT,EAAkCC,CAAS;AAC9D,MAAAO,IAAgBC,EAAW,SAAS,IAAIA,EAAWA,EAAW,SAAS,CAAC,IAAK;AAAA,IAC/E;AACA,UAAMC,IAASH,EAAM,kBAAkB,OAAOA,EAAM,SAAS,MACvDI,IAAS,SAAS;AAExB,IAAI,CAACH,KAAkBE,MAAWF,KAAiBG,MAAWH,MAI9DD,EAAM,eAAA,GACNH,EAAA;AAAA,EACF;AAAA,EACA,CAACC,GAAyBF,GAAQC,CAAO;AAAA,EAGlC;"}
@@ -0,0 +1,2 @@
1
+ "use strict";"use client";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("react"),I=require("../../hooks/useIsomorphicLayoutEffect.cjs"),m=(n,a)=>{if(!n?.current)return;n.current.querySelectorAll('[role="row"]').item(a)?.focus()},R=({onRemoveAtIndex:n,selectionRef:a,tagCount:e,isPopoverOpen:u=!1,isDisabled:b=!1})=>{const[i,s]=o.useState(0),[y,w]=o.useState(null),f=o.useRef(null),l=o.useRef(null);I.useIsomorphicLayoutEffect(()=>{const r=f.current;if(r===null){f.current=e,e>0&&s(e-1);return}if(e===0){f.current=0;return}const c=e-1,t=e-r;t>0?(s(c),u||(l.current=c)):t<0&&s(k=>Math.min(k,c)),f.current=e},[u,e]),I.useIsomorphicLayoutEffect(()=>{const r=l.current;r===null||e===0||u||(l.current=null,m(a,r))},[i,u,a,e]);const d=o.useCallback(r=>{const c=e-1;if(c>0){const t=r<c?r:r-1;s(t),u||(l.current=t)}w(null),n(r)},[u,n,e]);return{getKeyboardGridRowProps:o.useCallback(r=>u||b?{tabIndex:-1,removeButtonTabIndex:-1,onFocusCapture:()=>{},onBlurCapture:()=>{},onKeyDown:()=>{}}:{tabIndex:r===i?0:-1,removeButtonTabIndex:y===r?0:-1,onFocusCapture:()=>{s(r),w(r)},onBlurCapture:c=>{c.currentTarget.contains(c.relatedTarget)||w(null)},onKeyDown:c=>{if(e===0)return;if(c.key==="Delete"||c.key==="Backspace"){c.preventDefault(),d(r);return}let t=-1;switch(c.key){case"ArrowRight":case"ArrowDown":t=(r+1)%e;break;case"ArrowLeft":case"ArrowUp":t=(r-1+e)%e;break;case"Home":t=0;break;case"End":t=e-1;break}t>=0&&(c.preventDefault(),s(t),l.current=t)}},[i,y,b,u,d,e]),removeTagAtIndex:d}};exports.usePickerSelectionGridKeyboard=R;
2
+ //# sourceMappingURL=usePickerSelectionGridKeyboard.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"usePickerSelectionGridKeyboard.cjs","sources":["../../../src/components/UNSTABLE_Picker/usePickerSelectionGridKeyboard.ts"],"sourcesContent":["'use client';\n\nimport { type RefObject, useCallback, useRef, useState } from 'react';\nimport { useIsomorphicLayoutEffect } from '../../hooks';\nimport type { UnstablePickerSelectionGridRowProps } from './types';\n\nexport interface UnstablePickerSelectionKeyboardProps {\n /** Number of tag rows in the selection grid */\n tagCount: number;\n /** Called with the index of the tag to remove (keyboard or remove button) */\n onRemoveAtIndex: (index: number) => void;\n /** The selection element (`role=\"grid\"`) — used to focus tag rows after arrow navigation or removal */\n selectionRef?: RefObject<HTMLElement | null>;\n /**\n * When the picker popover is open, the dialog owns focus — do not move focus to tags and take tags\n * out of the tab order until the popover closes (matches web picker demo).\n */\n isPopoverOpen?: boolean;\n /** Disable row keyboard interaction and tab stops when picker is disabled */\n isDisabled?: boolean;\n}\n\n/**\n * Keyboard and roving tabindex behaviour for the Picker selection grid (`role=\"grid\"`)\n * one tab stop per row, arrow / Home / End navigation, Delete & Backspace\n * to remove, and the remove control participating in the tab order while the row contains focus.\n *\n * @param selectionRef Selection container (`role=\"grid\"`)\n * @param rowIndex Index of the tag row to focus\n */\nconst focusTagRow = (selectionRef: RefObject<HTMLElement | null> | undefined, rowIndex: number) => {\n if (!selectionRef?.current) {\n return;\n }\n\n const rows = selectionRef.current.querySelectorAll<HTMLElement>('[role=\"row\"]');\n\n rows.item(rowIndex)?.focus();\n};\n\nexport const usePickerSelectionGridKeyboard = ({\n onRemoveAtIndex,\n selectionRef,\n tagCount,\n isPopoverOpen = false,\n isDisabled = false,\n}: UnstablePickerSelectionKeyboardProps): {\n getKeyboardGridRowProps: (index: number) => UnstablePickerSelectionGridRowProps;\n removeTagAtIndex: (index: number) => void;\n} => {\n const [activeTagIndex, setActiveTagIndex] = useState(0);\n const [focusedRowIndex, setFocusedRowIndex] = useState<number | null>(null);\n const prevTagCountRef = useRef<number | null>(null);\n const pendingFocusRowRef = useRef<number | null>(null);\n\n useIsomorphicLayoutEffect(() => {\n const previousCount = prevTagCountRef.current;\n\n if (previousCount === null) {\n prevTagCountRef.current = tagCount;\n\n if (tagCount > 0) {\n setActiveTagIndex(tagCount - 1);\n }\n\n return;\n }\n\n if (tagCount === 0) {\n prevTagCountRef.current = 0;\n\n return;\n }\n\n const lastRowIndex = tagCount - 1;\n const tagCountDifference = tagCount - previousCount;\n\n if (tagCountDifference > 0) {\n setActiveTagIndex(lastRowIndex);\n\n if (!isPopoverOpen) {\n pendingFocusRowRef.current = lastRowIndex;\n }\n } else if (tagCountDifference < 0) {\n setActiveTagIndex((current) => Math.min(current, lastRowIndex));\n }\n\n prevTagCountRef.current = tagCount;\n }, [isPopoverOpen, tagCount]);\n\n useIsomorphicLayoutEffect(() => {\n const rowIndex = pendingFocusRowRef.current;\n\n if (rowIndex === null || tagCount === 0 || isPopoverOpen) {\n return;\n }\n\n pendingFocusRowRef.current = null;\n focusTagRow(selectionRef, rowIndex);\n }, [activeTagIndex, isPopoverOpen, selectionRef, tagCount]);\n\n const removeAt = useCallback(\n (index: number) => {\n const nextCount = tagCount - 1;\n\n if (nextCount > 0) {\n const nextActive = index < nextCount ? index : index - 1;\n\n setActiveTagIndex(nextActive);\n\n if (!isPopoverOpen) {\n pendingFocusRowRef.current = nextActive;\n }\n }\n\n setFocusedRowIndex(null);\n onRemoveAtIndex(index);\n },\n [isPopoverOpen, onRemoveAtIndex, tagCount],\n );\n\n const getKeyboardGridRowProps = useCallback(\n (index: number): UnstablePickerSelectionGridRowProps => {\n if (isPopoverOpen || isDisabled) {\n return {\n tabIndex: -1,\n removeButtonTabIndex: -1,\n onFocusCapture: () => {},\n onBlurCapture: () => {},\n onKeyDown: () => {},\n };\n }\n\n return {\n tabIndex: index === activeTagIndex ? 0 : -1,\n removeButtonTabIndex: focusedRowIndex === index ? 0 : -1,\n onFocusCapture: () => {\n setActiveTagIndex(index);\n setFocusedRowIndex(index);\n },\n onBlurCapture: (event) => {\n if (!event.currentTarget.contains(event.relatedTarget as Node)) {\n setFocusedRowIndex(null);\n }\n },\n onKeyDown: (event) => {\n if (tagCount === 0) {\n return;\n }\n\n if (event.key === 'Delete' || event.key === 'Backspace') {\n event.preventDefault();\n removeAt(index);\n\n return;\n }\n\n let nextIndex = -1;\n\n switch (event.key) {\n case 'ArrowRight':\n case 'ArrowDown':\n nextIndex = (index + 1) % tagCount;\n break;\n case 'ArrowLeft':\n case 'ArrowUp':\n nextIndex = (index - 1 + tagCount) % tagCount;\n break;\n case 'Home':\n nextIndex = 0;\n break;\n case 'End':\n nextIndex = tagCount - 1;\n break;\n default:\n break;\n }\n\n if (nextIndex >= 0) {\n event.preventDefault();\n setActiveTagIndex(nextIndex);\n pendingFocusRowRef.current = nextIndex;\n }\n },\n };\n },\n [activeTagIndex, focusedRowIndex, isDisabled, isPopoverOpen, removeAt, tagCount],\n );\n\n return { getKeyboardGridRowProps, removeTagAtIndex: removeAt };\n};\n"],"names":["focusTagRow","selectionRef","rowIndex","usePickerSelectionGridKeyboard","onRemoveAtIndex","tagCount","isPopoverOpen","isDisabled","activeTagIndex","setActiveTagIndex","useState","focusedRowIndex","setFocusedRowIndex","prevTagCountRef","useRef","pendingFocusRowRef","useIsomorphicLayoutEffect","previousCount","lastRowIndex","tagCountDifference","current","removeAt","useCallback","index","nextCount","nextActive","event","nextIndex"],"mappings":"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"}
@@ -0,0 +1,13 @@
1
+ import { RefObject } from 'react';
2
+ import { UnstablePickerSelectionGridRowProps } from './types';
3
+ export interface UnstablePickerSelectionKeyboardProps {
4
+ tagCount: number;
5
+ onRemoveAtIndex: (index: number) => void;
6
+ selectionRef?: RefObject<HTMLElement | null>;
7
+ isPopoverOpen?: boolean;
8
+ isDisabled?: boolean;
9
+ }
10
+ export declare const usePickerSelectionGridKeyboard: ({ onRemoveAtIndex, selectionRef, tagCount, isPopoverOpen, isDisabled, }: UnstablePickerSelectionKeyboardProps) => {
11
+ getKeyboardGridRowProps: (index: number) => UnstablePickerSelectionGridRowProps;
12
+ removeTagAtIndex: (index: number) => void;
13
+ };
@@ -0,0 +1,95 @@
1
+ "use client";
2
+ import { useState as b, useRef as m, useCallback as k } from "react";
3
+ import { useIsomorphicLayoutEffect as y } from "../../hooks/useIsomorphicLayoutEffect.js";
4
+ const A = (o, l) => {
5
+ if (!o?.current)
6
+ return;
7
+ o.current.querySelectorAll('[role="row"]').item(l)?.focus();
8
+ }, B = ({
9
+ onRemoveAtIndex: o,
10
+ selectionRef: l,
11
+ tagCount: r,
12
+ isPopoverOpen: n = !1,
13
+ isDisabled: d = !1
14
+ }) => {
15
+ const [a, u] = b(0), [I, w] = b(null), f = m(null), s = m(null);
16
+ y(() => {
17
+ const e = f.current;
18
+ if (e === null) {
19
+ f.current = r, r > 0 && u(r - 1);
20
+ return;
21
+ }
22
+ if (r === 0) {
23
+ f.current = 0;
24
+ return;
25
+ }
26
+ const c = r - 1, t = r - e;
27
+ t > 0 ? (u(c), n || (s.current = c)) : t < 0 && u((T) => Math.min(T, c)), f.current = r;
28
+ }, [n, r]), y(() => {
29
+ const e = s.current;
30
+ e === null || r === 0 || n || (s.current = null, A(l, e));
31
+ }, [a, n, l, r]);
32
+ const i = k(
33
+ (e) => {
34
+ const c = r - 1;
35
+ if (c > 0) {
36
+ const t = e < c ? e : e - 1;
37
+ u(t), n || (s.current = t);
38
+ }
39
+ w(null), o(e);
40
+ },
41
+ [n, o, r]
42
+ );
43
+ return { getKeyboardGridRowProps: k(
44
+ (e) => n || d ? {
45
+ tabIndex: -1,
46
+ removeButtonTabIndex: -1,
47
+ onFocusCapture: () => {
48
+ },
49
+ onBlurCapture: () => {
50
+ },
51
+ onKeyDown: () => {
52
+ }
53
+ } : {
54
+ tabIndex: e === a ? 0 : -1,
55
+ removeButtonTabIndex: I === e ? 0 : -1,
56
+ onFocusCapture: () => {
57
+ u(e), w(e);
58
+ },
59
+ onBlurCapture: (c) => {
60
+ c.currentTarget.contains(c.relatedTarget) || w(null);
61
+ },
62
+ onKeyDown: (c) => {
63
+ if (r === 0)
64
+ return;
65
+ if (c.key === "Delete" || c.key === "Backspace") {
66
+ c.preventDefault(), i(e);
67
+ return;
68
+ }
69
+ let t = -1;
70
+ switch (c.key) {
71
+ case "ArrowRight":
72
+ case "ArrowDown":
73
+ t = (e + 1) % r;
74
+ break;
75
+ case "ArrowLeft":
76
+ case "ArrowUp":
77
+ t = (e - 1 + r) % r;
78
+ break;
79
+ case "Home":
80
+ t = 0;
81
+ break;
82
+ case "End":
83
+ t = r - 1;
84
+ break;
85
+ }
86
+ t >= 0 && (c.preventDefault(), u(t), s.current = t);
87
+ }
88
+ },
89
+ [a, I, d, n, i, r]
90
+ ), removeTagAtIndex: i };
91
+ };
92
+ export {
93
+ B as usePickerSelectionGridKeyboard
94
+ };
95
+ //# sourceMappingURL=usePickerSelectionGridKeyboard.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"usePickerSelectionGridKeyboard.js","sources":["../../../src/components/UNSTABLE_Picker/usePickerSelectionGridKeyboard.ts"],"sourcesContent":["'use client';\n\nimport { type RefObject, useCallback, useRef, useState } from 'react';\nimport { useIsomorphicLayoutEffect } from '../../hooks';\nimport type { UnstablePickerSelectionGridRowProps } from './types';\n\nexport interface UnstablePickerSelectionKeyboardProps {\n /** Number of tag rows in the selection grid */\n tagCount: number;\n /** Called with the index of the tag to remove (keyboard or remove button) */\n onRemoveAtIndex: (index: number) => void;\n /** The selection element (`role=\"grid\"`) — used to focus tag rows after arrow navigation or removal */\n selectionRef?: RefObject<HTMLElement | null>;\n /**\n * When the picker popover is open, the dialog owns focus — do not move focus to tags and take tags\n * out of the tab order until the popover closes (matches web picker demo).\n */\n isPopoverOpen?: boolean;\n /** Disable row keyboard interaction and tab stops when picker is disabled */\n isDisabled?: boolean;\n}\n\n/**\n * Keyboard and roving tabindex behaviour for the Picker selection grid (`role=\"grid\"`)\n * one tab stop per row, arrow / Home / End navigation, Delete & Backspace\n * to remove, and the remove control participating in the tab order while the row contains focus.\n *\n * @param selectionRef Selection container (`role=\"grid\"`)\n * @param rowIndex Index of the tag row to focus\n */\nconst focusTagRow = (selectionRef: RefObject<HTMLElement | null> | undefined, rowIndex: number) => {\n if (!selectionRef?.current) {\n return;\n }\n\n const rows = selectionRef.current.querySelectorAll<HTMLElement>('[role=\"row\"]');\n\n rows.item(rowIndex)?.focus();\n};\n\nexport const usePickerSelectionGridKeyboard = ({\n onRemoveAtIndex,\n selectionRef,\n tagCount,\n isPopoverOpen = false,\n isDisabled = false,\n}: UnstablePickerSelectionKeyboardProps): {\n getKeyboardGridRowProps: (index: number) => UnstablePickerSelectionGridRowProps;\n removeTagAtIndex: (index: number) => void;\n} => {\n const [activeTagIndex, setActiveTagIndex] = useState(0);\n const [focusedRowIndex, setFocusedRowIndex] = useState<number | null>(null);\n const prevTagCountRef = useRef<number | null>(null);\n const pendingFocusRowRef = useRef<number | null>(null);\n\n useIsomorphicLayoutEffect(() => {\n const previousCount = prevTagCountRef.current;\n\n if (previousCount === null) {\n prevTagCountRef.current = tagCount;\n\n if (tagCount > 0) {\n setActiveTagIndex(tagCount - 1);\n }\n\n return;\n }\n\n if (tagCount === 0) {\n prevTagCountRef.current = 0;\n\n return;\n }\n\n const lastRowIndex = tagCount - 1;\n const tagCountDifference = tagCount - previousCount;\n\n if (tagCountDifference > 0) {\n setActiveTagIndex(lastRowIndex);\n\n if (!isPopoverOpen) {\n pendingFocusRowRef.current = lastRowIndex;\n }\n } else if (tagCountDifference < 0) {\n setActiveTagIndex((current) => Math.min(current, lastRowIndex));\n }\n\n prevTagCountRef.current = tagCount;\n }, [isPopoverOpen, tagCount]);\n\n useIsomorphicLayoutEffect(() => {\n const rowIndex = pendingFocusRowRef.current;\n\n if (rowIndex === null || tagCount === 0 || isPopoverOpen) {\n return;\n }\n\n pendingFocusRowRef.current = null;\n focusTagRow(selectionRef, rowIndex);\n }, [activeTagIndex, isPopoverOpen, selectionRef, tagCount]);\n\n const removeAt = useCallback(\n (index: number) => {\n const nextCount = tagCount - 1;\n\n if (nextCount > 0) {\n const nextActive = index < nextCount ? index : index - 1;\n\n setActiveTagIndex(nextActive);\n\n if (!isPopoverOpen) {\n pendingFocusRowRef.current = nextActive;\n }\n }\n\n setFocusedRowIndex(null);\n onRemoveAtIndex(index);\n },\n [isPopoverOpen, onRemoveAtIndex, tagCount],\n );\n\n const getKeyboardGridRowProps = useCallback(\n (index: number): UnstablePickerSelectionGridRowProps => {\n if (isPopoverOpen || isDisabled) {\n return {\n tabIndex: -1,\n removeButtonTabIndex: -1,\n onFocusCapture: () => {},\n onBlurCapture: () => {},\n onKeyDown: () => {},\n };\n }\n\n return {\n tabIndex: index === activeTagIndex ? 0 : -1,\n removeButtonTabIndex: focusedRowIndex === index ? 0 : -1,\n onFocusCapture: () => {\n setActiveTagIndex(index);\n setFocusedRowIndex(index);\n },\n onBlurCapture: (event) => {\n if (!event.currentTarget.contains(event.relatedTarget as Node)) {\n setFocusedRowIndex(null);\n }\n },\n onKeyDown: (event) => {\n if (tagCount === 0) {\n return;\n }\n\n if (event.key === 'Delete' || event.key === 'Backspace') {\n event.preventDefault();\n removeAt(index);\n\n return;\n }\n\n let nextIndex = -1;\n\n switch (event.key) {\n case 'ArrowRight':\n case 'ArrowDown':\n nextIndex = (index + 1) % tagCount;\n break;\n case 'ArrowLeft':\n case 'ArrowUp':\n nextIndex = (index - 1 + tagCount) % tagCount;\n break;\n case 'Home':\n nextIndex = 0;\n break;\n case 'End':\n nextIndex = tagCount - 1;\n break;\n default:\n break;\n }\n\n if (nextIndex >= 0) {\n event.preventDefault();\n setActiveTagIndex(nextIndex);\n pendingFocusRowRef.current = nextIndex;\n }\n },\n };\n },\n [activeTagIndex, focusedRowIndex, isDisabled, isPopoverOpen, removeAt, tagCount],\n );\n\n return { getKeyboardGridRowProps, removeTagAtIndex: removeAt };\n};\n"],"names":["focusTagRow","selectionRef","rowIndex","usePickerSelectionGridKeyboard","onRemoveAtIndex","tagCount","isPopoverOpen","isDisabled","activeTagIndex","setActiveTagIndex","useState","focusedRowIndex","setFocusedRowIndex","prevTagCountRef","useRef","pendingFocusRowRef","useIsomorphicLayoutEffect","previousCount","lastRowIndex","tagCountDifference","current","removeAt","useCallback","index","nextCount","nextActive","event","nextIndex"],"mappings":"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"}
@@ -0,0 +1,2 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const l=require("classnames"),x=require("../../hooks/useClassNamePrefix.cjs"),m=r=>{const{isDisabled:a,isFluid:c,isLabelHidden:n,isRequired:o,size:i,validationState:t}=r,e=x.useClassNamePrefix("UNSTABLE_Picker"),p=`${e}--disabled`,d=`${e}--fluid`,u=`${e}--${i}`,C=`${e}--${t}`,s=`${e}__label`,k=`${s}--hidden`,_=`${s}--required`,$=`${e}__inputContainer`,b=`${e}__selection`,P=`${e}__selectionEmpty`,S=`${e}__trigger`,T=`${e}__helperText`,g=`${e}__validationText`;return{classProps:{root:l(e,{[p]:a,[d]:c,[u]:i,[C]:t}),label:l(s,{[k]:n,[_]:o}),inputContainer:$,selection:b,selectionEmpty:P,trigger:S,helperText:T,validationText:g}}};exports.usePickerStyleProps=m;
2
+ //# sourceMappingURL=usePickerStyleProps.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"usePickerStyleProps.cjs","sources":["../../../src/components/UNSTABLE_Picker/usePickerStyleProps.ts"],"sourcesContent":["import classNames from 'classnames';\nimport { useClassNamePrefix } from '../../hooks';\nimport { type SizesDictionaryType, type Validation } from '../../types';\n\nexport interface UnstablePickerStyleProps<S = void> extends Validation {\n isDisabled?: boolean;\n isFluid?: boolean;\n isLabelHidden?: boolean;\n isRequired?: boolean;\n size?: SizesDictionaryType<S>;\n}\n\nexport interface UnstablePickerStyle {\n /** className props */\n classProps: {\n helperText: string;\n inputContainer: string;\n label: string;\n root: string;\n selection: string;\n selectionEmpty: string;\n trigger: string;\n validationText: string;\n };\n}\n\nexport const usePickerStyleProps = (props: UnstablePickerStyleProps): UnstablePickerStyle => {\n const { isDisabled, isFluid, isLabelHidden, isRequired, size, validationState } = props;\n const pickerClass = useClassNamePrefix('UNSTABLE_Picker');\n const pickerDisabledClass = `${pickerClass}--disabled`;\n const pickerFluidClass = `${pickerClass}--fluid`;\n const pickerSizeClass = `${pickerClass}--${size}`;\n const pickerValidationClass = `${pickerClass}--${validationState}`;\n const pickerLabelClass = `${pickerClass}__label`;\n const pickerLabelHiddenClass = `${pickerLabelClass}--hidden`;\n const pickerLabelRequiredClass = `${pickerLabelClass}--required`;\n const pickerInputContainerClass = `${pickerClass}__inputContainer`;\n const pickerSelectionClass = `${pickerClass}__selection`;\n const pickerSelectionEmptyClass = `${pickerClass}__selectionEmpty`;\n const pickerTriggerClass = `${pickerClass}__trigger`;\n const pickerHelperTextClass = `${pickerClass}__helperText`;\n const pickerValidationTextClass = `${pickerClass}__validationText`;\n\n return {\n classProps: {\n root: classNames(pickerClass, {\n [pickerDisabledClass]: isDisabled,\n [pickerFluidClass]: isFluid,\n [pickerSizeClass]: size,\n [pickerValidationClass]: validationState,\n }),\n label: classNames(pickerLabelClass, {\n [pickerLabelHiddenClass]: isLabelHidden,\n [pickerLabelRequiredClass]: isRequired,\n }),\n inputContainer: pickerInputContainerClass,\n selection: pickerSelectionClass,\n selectionEmpty: pickerSelectionEmptyClass,\n trigger: pickerTriggerClass,\n helperText: pickerHelperTextClass,\n validationText: pickerValidationTextClass,\n },\n };\n};\n"],"names":["usePickerStyleProps","props","isDisabled","isFluid","isLabelHidden","isRequired","size","validationState","pickerClass","useClassNamePrefix","pickerDisabledClass","pickerFluidClass","pickerSizeClass","pickerValidationClass","pickerLabelClass","pickerLabelHiddenClass","pickerLabelRequiredClass","pickerInputContainerClass","pickerSelectionClass","pickerSelectionEmptyClass","pickerTriggerClass","pickerHelperTextClass","pickerValidationTextClass","classNames"],"mappings":"8JA0BaA,EAAuBC,GAAyD,CAC3F,KAAM,CAAE,WAAAC,EAAY,QAAAC,EAAS,cAAAC,EAAe,WAAAC,EAAY,KAAAC,EAAM,gBAAAC,GAAoBN,EAC5EO,EAAcC,EAAAA,mBAAmB,iBAAiB,EAClDC,EAAsB,GAAGF,CAAW,aACpCG,EAAmB,GAAGH,CAAW,UACjCI,EAAkB,GAAGJ,CAAW,KAAKF,CAAI,GACzCO,EAAwB,GAAGL,CAAW,KAAKD,CAAe,GAC1DO,EAAmB,GAAGN,CAAW,UACjCO,EAAyB,GAAGD,CAAgB,WAC5CE,EAA2B,GAAGF,CAAgB,aAC9CG,EAA4B,GAAGT,CAAW,mBAC1CU,EAAuB,GAAGV,CAAW,cACrCW,EAA4B,GAAGX,CAAW,mBAC1CY,EAAqB,GAAGZ,CAAW,YACnCa,EAAwB,GAAGb,CAAW,eACtCc,EAA4B,GAAGd,CAAW,mBAEhD,MAAO,CACL,WAAY,CACV,KAAMe,EAAWf,EAAa,CAC5B,CAACE,CAAmB,EAAGR,EACvB,CAACS,CAAgB,EAAGR,EACpB,CAACS,CAAe,EAAGN,EACnB,CAACO,CAAqB,EAAGN,CAAA,CAC1B,EACD,MAAOgB,EAAWT,EAAkB,CAClC,CAACC,CAAsB,EAAGX,EAC1B,CAACY,CAAwB,EAAGX,CAAA,CAC7B,EACD,eAAgBY,EAChB,UAAWC,EACX,eAAgBC,EAChB,QAASC,EACT,WAAYC,EACZ,eAAgBC,CAAA,CAClB,CAEJ"}
@@ -0,0 +1,21 @@
1
+ import { SizesDictionaryType, Validation } from '../../types';
2
+ export interface UnstablePickerStyleProps<S = void> extends Validation {
3
+ isDisabled?: boolean;
4
+ isFluid?: boolean;
5
+ isLabelHidden?: boolean;
6
+ isRequired?: boolean;
7
+ size?: SizesDictionaryType<S>;
8
+ }
9
+ export interface UnstablePickerStyle {
10
+ classProps: {
11
+ helperText: string;
12
+ inputContainer: string;
13
+ label: string;
14
+ root: string;
15
+ selection: string;
16
+ selectionEmpty: string;
17
+ trigger: string;
18
+ validationText: string;
19
+ };
20
+ }
21
+ export declare const usePickerStyleProps: (props: UnstablePickerStyleProps) => UnstablePickerStyle;
@@ -0,0 +1,29 @@
1
+ import l from "classnames";
2
+ import { useClassNamePrefix as S } from "../../hooks/useClassNamePrefix.js";
3
+ const f = (r) => {
4
+ const { isDisabled: a, isFluid: c, isLabelHidden: n, isRequired: o, size: i, validationState: t } = r, e = S("UNSTABLE_Picker"), p = `${e}--disabled`, d = `${e}--fluid`, C = `${e}--${i}`, k = `${e}--${t}`, s = `${e}__label`, _ = `${s}--hidden`, $ = `${s}--required`, u = `${e}__inputContainer`, b = `${e}__selection`, m = `${e}__selectionEmpty`, x = `${e}__trigger`, T = `${e}__helperText`, g = `${e}__validationText`;
5
+ return {
6
+ classProps: {
7
+ root: l(e, {
8
+ [p]: a,
9
+ [d]: c,
10
+ [C]: i,
11
+ [k]: t
12
+ }),
13
+ label: l(s, {
14
+ [_]: n,
15
+ [$]: o
16
+ }),
17
+ inputContainer: u,
18
+ selection: b,
19
+ selectionEmpty: m,
20
+ trigger: x,
21
+ helperText: T,
22
+ validationText: g
23
+ }
24
+ };
25
+ };
26
+ export {
27
+ f as usePickerStyleProps
28
+ };
29
+ //# sourceMappingURL=usePickerStyleProps.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"usePickerStyleProps.js","sources":["../../../src/components/UNSTABLE_Picker/usePickerStyleProps.ts"],"sourcesContent":["import classNames from 'classnames';\nimport { useClassNamePrefix } from '../../hooks';\nimport { type SizesDictionaryType, type Validation } from '../../types';\n\nexport interface UnstablePickerStyleProps<S = void> extends Validation {\n isDisabled?: boolean;\n isFluid?: boolean;\n isLabelHidden?: boolean;\n isRequired?: boolean;\n size?: SizesDictionaryType<S>;\n}\n\nexport interface UnstablePickerStyle {\n /** className props */\n classProps: {\n helperText: string;\n inputContainer: string;\n label: string;\n root: string;\n selection: string;\n selectionEmpty: string;\n trigger: string;\n validationText: string;\n };\n}\n\nexport const usePickerStyleProps = (props: UnstablePickerStyleProps): UnstablePickerStyle => {\n const { isDisabled, isFluid, isLabelHidden, isRequired, size, validationState } = props;\n const pickerClass = useClassNamePrefix('UNSTABLE_Picker');\n const pickerDisabledClass = `${pickerClass}--disabled`;\n const pickerFluidClass = `${pickerClass}--fluid`;\n const pickerSizeClass = `${pickerClass}--${size}`;\n const pickerValidationClass = `${pickerClass}--${validationState}`;\n const pickerLabelClass = `${pickerClass}__label`;\n const pickerLabelHiddenClass = `${pickerLabelClass}--hidden`;\n const pickerLabelRequiredClass = `${pickerLabelClass}--required`;\n const pickerInputContainerClass = `${pickerClass}__inputContainer`;\n const pickerSelectionClass = `${pickerClass}__selection`;\n const pickerSelectionEmptyClass = `${pickerClass}__selectionEmpty`;\n const pickerTriggerClass = `${pickerClass}__trigger`;\n const pickerHelperTextClass = `${pickerClass}__helperText`;\n const pickerValidationTextClass = `${pickerClass}__validationText`;\n\n return {\n classProps: {\n root: classNames(pickerClass, {\n [pickerDisabledClass]: isDisabled,\n [pickerFluidClass]: isFluid,\n [pickerSizeClass]: size,\n [pickerValidationClass]: validationState,\n }),\n label: classNames(pickerLabelClass, {\n [pickerLabelHiddenClass]: isLabelHidden,\n [pickerLabelRequiredClass]: isRequired,\n }),\n inputContainer: pickerInputContainerClass,\n selection: pickerSelectionClass,\n selectionEmpty: pickerSelectionEmptyClass,\n trigger: pickerTriggerClass,\n helperText: pickerHelperTextClass,\n validationText: pickerValidationTextClass,\n },\n };\n};\n"],"names":["usePickerStyleProps","props","isDisabled","isFluid","isLabelHidden","isRequired","size","validationState","pickerClass","useClassNamePrefix","pickerDisabledClass","pickerFluidClass","pickerSizeClass","pickerValidationClass","pickerLabelClass","pickerLabelHiddenClass","pickerLabelRequiredClass","pickerInputContainerClass","pickerSelectionClass","pickerSelectionEmptyClass","pickerTriggerClass","pickerHelperTextClass","pickerValidationTextClass","classNames"],"mappings":";;AA0BO,MAAMA,IAAsB,CAACC,MAAyD;AAC3F,QAAM,EAAE,YAAAC,GAAY,SAAAC,GAAS,eAAAC,GAAe,YAAAC,GAAY,MAAAC,GAAM,iBAAAC,MAAoBN,GAC5EO,IAAcC,EAAmB,iBAAiB,GAClDC,IAAsB,GAAGF,CAAW,cACpCG,IAAmB,GAAGH,CAAW,WACjCI,IAAkB,GAAGJ,CAAW,KAAKF,CAAI,IACzCO,IAAwB,GAAGL,CAAW,KAAKD,CAAe,IAC1DO,IAAmB,GAAGN,CAAW,WACjCO,IAAyB,GAAGD,CAAgB,YAC5CE,IAA2B,GAAGF,CAAgB,cAC9CG,IAA4B,GAAGT,CAAW,oBAC1CU,IAAuB,GAAGV,CAAW,eACrCW,IAA4B,GAAGX,CAAW,oBAC1CY,IAAqB,GAAGZ,CAAW,aACnCa,IAAwB,GAAGb,CAAW,gBACtCc,IAA4B,GAAGd,CAAW;AAEhD,SAAO;AAAA,IACL,YAAY;AAAA,MACV,MAAMe,EAAWf,GAAa;AAAA,QAC5B,CAACE,CAAmB,GAAGR;AAAA,QACvB,CAACS,CAAgB,GAAGR;AAAA,QACpB,CAACS,CAAe,GAAGN;AAAA,QACnB,CAACO,CAAqB,GAAGN;AAAA,MAAA,CAC1B;AAAA,MACD,OAAOgB,EAAWT,GAAkB;AAAA,QAClC,CAACC,CAAsB,GAAGX;AAAA,QAC1B,CAACY,CAAwB,GAAGX;AAAA,MAAA,CAC7B;AAAA,MACD,gBAAgBY;AAAA,MAChB,WAAWC;AAAA,MACX,gBAAgBC;AAAA,MAChB,SAASC;AAAA,MACT,YAAYC;AAAA,MACZ,gBAAgBC;AAAA,IAAA;AAAA,EAClB;AAEJ;"}
@@ -0,0 +1,2 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("react"),l=e=>o.isValidElement(e)&&e.type?.spiritComponent==="UNSTABLE_PickerItem",s=e=>e.replace(/\s+/g," ").trim(),c=e=>{const t=[],r=i=>{o.Children.forEach(i,n=>{if(o.isValidElement(n)){if(l(n)){t.push({label:n.props.children,value:n.props.value});return}n.props?.children&&r(n.props.children)}})};return r(e),t},a=e=>{const t={};for(const r of e)t[r.value]=r.label;return t},g=(e,t)=>e.map(r=>({label:t[r]??r,value:r})),p=e=>{const t=i=>i==null||typeof i=="boolean"?"":typeof i=="string"||typeof i=="number"?String(i):Array.isArray(i)?i.map(t).filter(Boolean).join(" "):o.isValidElement(i)?t(i.props.children):"",r=t(e);return s(r)},u=(e,t)=>t.length>1?`${e} (${t.length})`:t[0]?.label??e,f=(e,t)=>{const{isAggregated:r}=t;return e===0?0:r?1:e};exports.collectPickerItems=c;exports.getAggregatedTagLabel=u;exports.getNodeText=p;exports.getPickerItemLabelMap=a;exports.getPickerSelectionGridKeyboardRowCount=f;exports.getSelectedItems=g;
2
+ //# sourceMappingURL=utils.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.cjs","sources":["../../../src/components/UNSTABLE_Picker/utils.ts"],"sourcesContent":["import { Children, type ReactNode, isValidElement } from 'react';\nimport type { UnstablePickerItemData } from './types';\n\nconst isPickerItem = (node: ReactNode) =>\n isValidElement(node) && (node.type as { spiritComponent?: string })?.spiritComponent === 'UNSTABLE_PickerItem';\n\nconst normalizeWhitespace = (text: string) => text.replace(/\\s+/g, ' ').trim();\n\nexport const collectPickerItems = (children: ReactNode): UnstablePickerItemData[] => {\n const items: UnstablePickerItemData[] = [];\n\n const traverse = (node: ReactNode) => {\n Children.forEach(node, (child) => {\n if (!isValidElement(child)) {\n return;\n }\n\n if (isPickerItem(child)) {\n items.push({\n label: child.props.children as ReactNode,\n value: child.props.value as string,\n });\n\n return;\n }\n\n if (child.props?.children) {\n traverse(child.props.children);\n }\n });\n };\n\n traverse(children);\n\n return items;\n};\n\nexport const getPickerItemLabelMap = (items: UnstablePickerItemData[]): Record<string, ReactNode> => {\n const labelsMap: Record<string, ReactNode> = {};\n\n for (const item of items) {\n labelsMap[item.value] = item.label;\n }\n\n return labelsMap;\n};\n\nexport const getSelectedItems = (keys: string[], labels: Record<string, ReactNode>): UnstablePickerItemData[] =>\n keys.map((value) => ({\n label: labels[value] ?? value,\n value,\n }));\n\nexport const getNodeText = (value: ReactNode): string => {\n const collect = (node: ReactNode): string => {\n if (node == null || typeof node === 'boolean') {\n return '';\n }\n\n if (typeof node === 'string' || typeof node === 'number') {\n return String(node);\n }\n\n if (Array.isArray(node)) {\n return node.map(collect).filter(Boolean).join(' ');\n }\n\n if (isValidElement(node)) {\n return collect(node.props.children as ReactNode);\n }\n\n return '';\n };\n\n const text = collect(value);\n\n return normalizeWhitespace(text);\n};\n\nexport const getAggregatedTagLabel = (label: string, selectedItems: UnstablePickerItemData[]): ReactNode => {\n if (selectedItems.length > 1) {\n return `${label} (${selectedItems.length})`;\n }\n\n return selectedItems[0]?.label ?? label;\n};\n\n/**\n * How many `role=\"row\"` tags participate in selection-grid keyboard navigation\n * (`usePickerSelectionGridKeyboard`). Returns `0` when nothing is selected.\n * Custom `renderTags` should use one `UNSTABLE_PickerTag` (row) per count, or behaviour will not match.\n *\n * @param selectedItemCount\n * @param options\n * @param options.isAggregated\n */\nexport const getPickerSelectionGridKeyboardRowCount = (\n selectedItemCount: number,\n options: { isAggregated: boolean },\n): number => {\n const { isAggregated } = options;\n\n if (selectedItemCount === 0) {\n return 0;\n }\n\n return isAggregated ? 1 : selectedItemCount;\n};\n"],"names":["isPickerItem","node","isValidElement","normalizeWhitespace","text","collectPickerItems","children","items","traverse","Children","child","getPickerItemLabelMap","labelsMap","item","getSelectedItems","keys","labels","value","getNodeText","collect","getAggregatedTagLabel","label","selectedItems","getPickerSelectionGridKeyboardRowCount","selectedItemCount","options","isAggregated"],"mappings":"yGAGMA,EAAgBC,GACpBC,iBAAeD,CAAI,GAAMA,EAAK,MAAuC,kBAAoB,sBAErFE,EAAuBC,GAAiBA,EAAK,QAAQ,OAAQ,GAAG,EAAE,KAAA,EAE3DC,EAAsBC,GAAkD,CACnF,MAAMC,EAAkC,CAAA,EAElCC,EAAYP,GAAoB,CACpCQ,EAAAA,SAAS,QAAQR,EAAOS,GAAU,CAChC,GAAKR,EAAAA,eAAeQ,CAAK,EAIzB,IAAIV,EAAaU,CAAK,EAAG,CACvBH,EAAM,KAAK,CACT,MAAOG,EAAM,MAAM,SACnB,MAAOA,EAAM,MAAM,KAAA,CACpB,EAED,MACF,CAEIA,EAAM,OAAO,UACfF,EAASE,EAAM,MAAM,QAAQ,EAEjC,CAAC,CACH,EAEA,OAAAF,EAASF,CAAQ,EAEVC,CACT,EAEaI,EAAyBJ,GAA+D,CACnG,MAAMK,EAAuC,CAAA,EAE7C,UAAWC,KAAQN,EACjBK,EAAUC,EAAK,KAAK,EAAIA,EAAK,MAG/B,OAAOD,CACT,EAEaE,EAAmB,CAACC,EAAgBC,IAC/CD,EAAK,IAAKE,IAAW,CACnB,MAAOD,EAAOC,CAAK,GAAKA,EACxB,MAAAA,CACF,EAAE,EAESC,EAAeD,GAA6B,CACvD,MAAME,EAAWlB,GACXA,GAAQ,MAAQ,OAAOA,GAAS,UAC3B,GAGL,OAAOA,GAAS,UAAY,OAAOA,GAAS,SACvC,OAAOA,CAAI,EAGhB,MAAM,QAAQA,CAAI,EACbA,EAAK,IAAIkB,CAAO,EAAE,OAAO,OAAO,EAAE,KAAK,GAAG,EAG/CjB,EAAAA,eAAeD,CAAI,EACdkB,EAAQlB,EAAK,MAAM,QAAqB,EAG1C,GAGHG,EAAOe,EAAQF,CAAK,EAE1B,OAAOd,EAAoBC,CAAI,CACjC,EAEagB,EAAwB,CAACC,EAAeC,IAC/CA,EAAc,OAAS,EAClB,GAAGD,CAAK,KAAKC,EAAc,MAAM,IAGnCA,EAAc,CAAC,GAAG,OAASD,EAYvBE,EAAyC,CACpDC,EACAC,IACW,CACX,KAAM,CAAE,aAAAC,GAAiBD,EAEzB,OAAID,IAAsB,EACjB,EAGFE,EAAe,EAAIF,CAC5B"}
@@ -0,0 +1,10 @@
1
+ import { ReactNode } from 'react';
2
+ import { UnstablePickerItemData } from './types';
3
+ export declare const collectPickerItems: (children: ReactNode) => UnstablePickerItemData[];
4
+ export declare const getPickerItemLabelMap: (items: UnstablePickerItemData[]) => Record<string, ReactNode>;
5
+ export declare const getSelectedItems: (keys: string[], labels: Record<string, ReactNode>) => UnstablePickerItemData[];
6
+ export declare const getNodeText: (value: ReactNode) => string;
7
+ export declare const getAggregatedTagLabel: (label: string, selectedItems: UnstablePickerItemData[]) => ReactNode;
8
+ export declare const getPickerSelectionGridKeyboardRowCount: (selectedItemCount: number, options: {
9
+ isAggregated: boolean;
10
+ }) => number;
@@ -0,0 +1,41 @@
1
+ import { isValidElement as o, Children as s } from "react";
2
+ const c = (r) => o(r) && r.type?.spiritComponent === "UNSTABLE_PickerItem", a = (r) => r.replace(/\s+/g, " ").trim(), p = (r) => {
3
+ const t = [], e = (n) => {
4
+ s.forEach(n, (i) => {
5
+ if (o(i)) {
6
+ if (c(i)) {
7
+ t.push({
8
+ label: i.props.children,
9
+ value: i.props.value
10
+ });
11
+ return;
12
+ }
13
+ i.props?.children && e(i.props.children);
14
+ }
15
+ });
16
+ };
17
+ return e(r), t;
18
+ }, u = (r) => {
19
+ const t = {};
20
+ for (const e of r)
21
+ t[e.value] = e.label;
22
+ return t;
23
+ }, f = (r, t) => r.map((e) => ({
24
+ label: t[e] ?? e,
25
+ value: e
26
+ })), g = (r) => {
27
+ const t = (n) => n == null || typeof n == "boolean" ? "" : typeof n == "string" || typeof n == "number" ? String(n) : Array.isArray(n) ? n.map(t).filter(Boolean).join(" ") : o(n) ? t(n.props.children) : "", e = t(r);
28
+ return a(e);
29
+ }, m = (r, t) => t.length > 1 ? `${r} (${t.length})` : t[0]?.label ?? r, b = (r, t) => {
30
+ const { isAggregated: e } = t;
31
+ return r === 0 ? 0 : e ? 1 : r;
32
+ };
33
+ export {
34
+ p as collectPickerItems,
35
+ m as getAggregatedTagLabel,
36
+ g as getNodeText,
37
+ u as getPickerItemLabelMap,
38
+ b as getPickerSelectionGridKeyboardRowCount,
39
+ f as getSelectedItems
40
+ };
41
+ //# sourceMappingURL=utils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.js","sources":["../../../src/components/UNSTABLE_Picker/utils.ts"],"sourcesContent":["import { Children, type ReactNode, isValidElement } from 'react';\nimport type { UnstablePickerItemData } from './types';\n\nconst isPickerItem = (node: ReactNode) =>\n isValidElement(node) && (node.type as { spiritComponent?: string })?.spiritComponent === 'UNSTABLE_PickerItem';\n\nconst normalizeWhitespace = (text: string) => text.replace(/\\s+/g, ' ').trim();\n\nexport const collectPickerItems = (children: ReactNode): UnstablePickerItemData[] => {\n const items: UnstablePickerItemData[] = [];\n\n const traverse = (node: ReactNode) => {\n Children.forEach(node, (child) => {\n if (!isValidElement(child)) {\n return;\n }\n\n if (isPickerItem(child)) {\n items.push({\n label: child.props.children as ReactNode,\n value: child.props.value as string,\n });\n\n return;\n }\n\n if (child.props?.children) {\n traverse(child.props.children);\n }\n });\n };\n\n traverse(children);\n\n return items;\n};\n\nexport const getPickerItemLabelMap = (items: UnstablePickerItemData[]): Record<string, ReactNode> => {\n const labelsMap: Record<string, ReactNode> = {};\n\n for (const item of items) {\n labelsMap[item.value] = item.label;\n }\n\n return labelsMap;\n};\n\nexport const getSelectedItems = (keys: string[], labels: Record<string, ReactNode>): UnstablePickerItemData[] =>\n keys.map((value) => ({\n label: labels[value] ?? value,\n value,\n }));\n\nexport const getNodeText = (value: ReactNode): string => {\n const collect = (node: ReactNode): string => {\n if (node == null || typeof node === 'boolean') {\n return '';\n }\n\n if (typeof node === 'string' || typeof node === 'number') {\n return String(node);\n }\n\n if (Array.isArray(node)) {\n return node.map(collect).filter(Boolean).join(' ');\n }\n\n if (isValidElement(node)) {\n return collect(node.props.children as ReactNode);\n }\n\n return '';\n };\n\n const text = collect(value);\n\n return normalizeWhitespace(text);\n};\n\nexport const getAggregatedTagLabel = (label: string, selectedItems: UnstablePickerItemData[]): ReactNode => {\n if (selectedItems.length > 1) {\n return `${label} (${selectedItems.length})`;\n }\n\n return selectedItems[0]?.label ?? label;\n};\n\n/**\n * How many `role=\"row\"` tags participate in selection-grid keyboard navigation\n * (`usePickerSelectionGridKeyboard`). Returns `0` when nothing is selected.\n * Custom `renderTags` should use one `UNSTABLE_PickerTag` (row) per count, or behaviour will not match.\n *\n * @param selectedItemCount\n * @param options\n * @param options.isAggregated\n */\nexport const getPickerSelectionGridKeyboardRowCount = (\n selectedItemCount: number,\n options: { isAggregated: boolean },\n): number => {\n const { isAggregated } = options;\n\n if (selectedItemCount === 0) {\n return 0;\n }\n\n return isAggregated ? 1 : selectedItemCount;\n};\n"],"names":["isPickerItem","node","isValidElement","normalizeWhitespace","text","collectPickerItems","children","items","traverse","Children","child","getPickerItemLabelMap","labelsMap","item","getSelectedItems","keys","labels","value","getNodeText","collect","getAggregatedTagLabel","label","selectedItems","getPickerSelectionGridKeyboardRowCount","selectedItemCount","options","isAggregated"],"mappings":";AAGA,MAAMA,IAAe,CAACC,MACpBC,EAAeD,CAAI,KAAMA,EAAK,MAAuC,oBAAoB,uBAErFE,IAAsB,CAACC,MAAiBA,EAAK,QAAQ,QAAQ,GAAG,EAAE,KAAA,GAE3DC,IAAqB,CAACC,MAAkD;AACnF,QAAMC,IAAkC,CAAA,GAElCC,IAAW,CAACP,MAAoB;AACpC,IAAAQ,EAAS,QAAQR,GAAM,CAACS,MAAU;AAChC,UAAKR,EAAeQ,CAAK,GAIzB;AAAA,YAAIV,EAAaU,CAAK,GAAG;AACvB,UAAAH,EAAM,KAAK;AAAA,YACT,OAAOG,EAAM,MAAM;AAAA,YACnB,OAAOA,EAAM,MAAM;AAAA,UAAA,CACpB;AAED;AAAA,QACF;AAEA,QAAIA,EAAM,OAAO,YACfF,EAASE,EAAM,MAAM,QAAQ;AAAA;AAAA,IAEjC,CAAC;AAAA,EACH;AAEA,SAAAF,EAASF,CAAQ,GAEVC;AACT,GAEaI,IAAwB,CAACJ,MAA+D;AACnG,QAAMK,IAAuC,CAAA;AAE7C,aAAWC,KAAQN;AACjB,IAAAK,EAAUC,EAAK,KAAK,IAAIA,EAAK;AAG/B,SAAOD;AACT,GAEaE,IAAmB,CAACC,GAAgBC,MAC/CD,EAAK,IAAI,CAACE,OAAW;AAAA,EACnB,OAAOD,EAAOC,CAAK,KAAKA;AAAA,EACxB,OAAAA;AACF,EAAE,GAESC,IAAc,CAACD,MAA6B;AACvD,QAAME,IAAU,CAAClB,MACXA,KAAQ,QAAQ,OAAOA,KAAS,YAC3B,KAGL,OAAOA,KAAS,YAAY,OAAOA,KAAS,WACvC,OAAOA,CAAI,IAGhB,MAAM,QAAQA,CAAI,IACbA,EAAK,IAAIkB,CAAO,EAAE,OAAO,OAAO,EAAE,KAAK,GAAG,IAG/CjB,EAAeD,CAAI,IACdkB,EAAQlB,EAAK,MAAM,QAAqB,IAG1C,IAGHG,IAAOe,EAAQF,CAAK;AAE1B,SAAOd,EAAoBC,CAAI;AACjC,GAEagB,IAAwB,CAACC,GAAeC,MAC/CA,EAAc,SAAS,IAClB,GAAGD,CAAK,KAAKC,EAAc,MAAM,MAGnCA,EAAc,CAAC,GAAG,SAASD,GAYvBE,IAAyC,CACpDC,GACAC,MACW;AACX,QAAM,EAAE,cAAAC,MAAiBD;AAEzB,SAAID,MAAsB,IACjB,IAGFE,IAAe,IAAIF;AAC5B;"}
@@ -0,0 +1,2 @@
1
+ export * from './UNSTABLE_Picker/index'
2
+ export {}