@wordpress/components 23.3.2 → 23.4.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 (710) hide show
  1. package/CHANGELOG.md +20 -5
  2. package/build/alignment-matrix-control/utils.js +4 -4
  3. package/build/alignment-matrix-control/utils.js.map +1 -1
  4. package/build/angle-picker-control/angle-circle.js +37 -29
  5. package/build/angle-picker-control/angle-circle.js.map +1 -1
  6. package/build/angle-picker-control/index.js +44 -9
  7. package/build/angle-picker-control/index.js.map +1 -1
  8. package/build/angle-picker-control/styles/angle-picker-control-styles.js +13 -13
  9. package/build/angle-picker-control/styles/angle-picker-control-styles.js.map +1 -1
  10. package/build/{base-field → angle-picker-control}/types.js +0 -0
  11. package/build/angle-picker-control/types.js.map +1 -0
  12. package/build/autocomplete/autocompleter-ui.native.js +1 -0
  13. package/build/autocomplete/autocompleter-ui.native.js.map +1 -1
  14. package/build/base-control/hooks.js +1 -1
  15. package/build/base-control/hooks.js.map +1 -1
  16. package/build/border-box-control/utils.js +1 -1
  17. package/build/border-box-control/utils.js.map +1 -1
  18. package/build/box-control/all-input-control.js +2 -2
  19. package/build/box-control/all-input-control.js.map +1 -1
  20. package/build/box-control/axial-input-controls.js +1 -1
  21. package/build/box-control/axial-input-controls.js.map +1 -1
  22. package/build/box-control/icon.js.map +1 -1
  23. package/build/box-control/index.js +32 -3
  24. package/build/box-control/index.js.map +1 -1
  25. package/build/box-control/input-controls.js +5 -5
  26. package/build/box-control/input-controls.js.map +1 -1
  27. package/build/box-control/linked-button.js.map +1 -1
  28. package/build/box-control/styles/box-control-icon-styles.js +28 -28
  29. package/build/box-control/styles/box-control-icon-styles.js.map +1 -1
  30. package/build/box-control/styles/box-control-styles.js +23 -23
  31. package/build/box-control/styles/box-control-styles.js.map +1 -1
  32. package/build/box-control/styles/box-control-visualizer-styles.js +19 -19
  33. package/build/box-control/styles/box-control-visualizer-styles.js.map +1 -1
  34. package/build/box-control/types.js +6 -0
  35. package/build/box-control/types.js.map +1 -0
  36. package/build/box-control/unit-control.js.map +1 -1
  37. package/build/box-control/utils.js +23 -23
  38. package/build/box-control/utils.js.map +1 -1
  39. package/build/color-palette/index.js +8 -3
  40. package/build/color-palette/index.js.map +1 -1
  41. package/build/combobox-control/index.js +68 -12
  42. package/build/combobox-control/index.js.map +1 -1
  43. package/build/combobox-control/styles.js +2 -2
  44. package/build/combobox-control/styles.js.map +1 -1
  45. package/build/combobox-control/types.js +6 -0
  46. package/build/combobox-control/types.js.map +1 -0
  47. package/build/custom-gradient-picker/index.js +0 -1
  48. package/build/custom-gradient-picker/index.js.map +1 -1
  49. package/build/date-time/time/index.js +1 -1
  50. package/build/date-time/time/index.js.map +1 -1
  51. package/build/date-time/utils.js +1 -1
  52. package/build/date-time/utils.js.map +1 -1
  53. package/build/draggable/index.js +2 -2
  54. package/build/draggable/index.js.map +1 -1
  55. package/build/focal-point-picker/utils.js +3 -3
  56. package/build/focal-point-picker/utils.js.map +1 -1
  57. package/build/font-size-picker/utils.js +2 -2
  58. package/build/font-size-picker/utils.js.map +1 -1
  59. package/build/gradient-picker/index.js +9 -4
  60. package/build/gradient-picker/index.js.map +1 -1
  61. package/build/input-control/reducer/reducer.js +5 -5
  62. package/build/input-control/reducer/reducer.js.map +1 -1
  63. package/build/input-control/utils.js +1 -1
  64. package/build/input-control/utils.js.map +1 -1
  65. package/build/menu-items-choice/index.js +40 -3
  66. package/build/menu-items-choice/index.js.map +1 -1
  67. package/build/menu-items-choice/types.js +6 -0
  68. package/build/menu-items-choice/types.js.map +1 -0
  69. package/build/modal/index.js +41 -3
  70. package/build/modal/index.js.map +1 -1
  71. package/build/palette-edit/index.js +4 -1
  72. package/build/palette-edit/index.js.map +1 -1
  73. package/build/panel/header.js +9 -0
  74. package/build/panel/header.js.map +1 -1
  75. package/build/panel/index.js +21 -3
  76. package/build/panel/index.js.map +1 -1
  77. package/build/panel/row.js +10 -4
  78. package/build/panel/row.js.map +1 -1
  79. package/build/panel/types.js +6 -0
  80. package/build/panel/types.js.map +1 -0
  81. package/build/popover/index.js +15 -3
  82. package/build/popover/index.js.map +1 -1
  83. package/build/popover/overlay-middlewares.js +46 -0
  84. package/build/popover/overlay-middlewares.js.map +1 -0
  85. package/build/popover/utils.js +45 -6
  86. package/build/popover/utils.js.map +1 -1
  87. package/build/query-controls/terms.js +1 -1
  88. package/build/query-controls/terms.js.map +1 -1
  89. package/build/range-control/utils.js +4 -4
  90. package/build/range-control/utils.js.map +1 -1
  91. package/build/resizable-box/resize-tooltip/styles/resize-tooltip.styles.js +12 -12
  92. package/build/resizable-box/resize-tooltip/styles/resize-tooltip.styles.js.map +1 -1
  93. package/build/resizable-box/resize-tooltip/utils.js +14 -14
  94. package/build/resizable-box/resize-tooltip/utils.js.map +1 -1
  95. package/build/snackbar/index.js +2 -2
  96. package/build/snackbar/index.js.map +1 -1
  97. package/build/toolbar/toolbar/index.js +25 -14
  98. package/build/toolbar/toolbar/index.js.map +1 -1
  99. package/build/toolbar/toolbar/toolbar-container.js +5 -4
  100. package/build/toolbar/toolbar/toolbar-container.js.map +1 -1
  101. package/build/toolbar/toolbar/types.js +6 -0
  102. package/build/toolbar/toolbar/types.js.map +1 -0
  103. package/build/toolbar/toolbar-button/index.js +2 -0
  104. package/build/toolbar/toolbar-button/index.js.map +1 -1
  105. package/build/toolbar/toolbar-button/toolbar-button-container.js +1 -0
  106. package/build/toolbar/toolbar-button/toolbar-button-container.js.map +1 -1
  107. package/build/toolbar/toolbar-context/index.js +2 -0
  108. package/build/toolbar/toolbar-context/index.js.map +1 -1
  109. package/build/toolbar/toolbar-dropdown-menu/index.js +2 -0
  110. package/build/toolbar/toolbar-dropdown-menu/index.js.map +1 -1
  111. package/build/toolbar/toolbar-group/index.js +2 -0
  112. package/build/toolbar/toolbar-group/index.js.map +1 -1
  113. package/build/toolbar/toolbar-group/toolbar-group-collapsed.js +2 -0
  114. package/build/toolbar/toolbar-group/toolbar-group-collapsed.js.map +1 -1
  115. package/build/toolbar/toolbar-group/toolbar-group-container.js +1 -0
  116. package/build/toolbar/toolbar-group/toolbar-group-container.js.map +1 -1
  117. package/build/toolbar/toolbar-item/index.js +2 -0
  118. package/build/toolbar/toolbar-item/index.js.map +1 -1
  119. package/build/tools-panel/tools-panel/component.js +61 -5
  120. package/build/tools-panel/tools-panel/component.js.map +1 -1
  121. package/build/tools-panel/tools-panel/hook.js +4 -2
  122. package/build/tools-panel/tools-panel/hook.js.map +1 -1
  123. package/build/tools-panel/tools-panel-header/component.js +2 -1
  124. package/build/tools-panel/tools-panel-header/component.js.map +1 -1
  125. package/build/tools-panel/tools-panel-header/hook.js +2 -0
  126. package/build/tools-panel/tools-panel-header/hook.js.map +1 -1
  127. package/build/tools-panel/tools-panel-item/component.js +5 -4
  128. package/build/tools-panel/tools-panel-item/component.js.map +1 -1
  129. package/build/tools-panel/tools-panel-item/hook.js +4 -2
  130. package/build/tools-panel/tools-panel-item/hook.js.map +1 -1
  131. package/build/tree-grid/cell.js +15 -4
  132. package/build/tree-grid/cell.js.map +1 -1
  133. package/build/tree-grid/index.js +81 -19
  134. package/build/tree-grid/index.js.map +1 -1
  135. package/build/tree-grid/item.js +14 -3
  136. package/build/tree-grid/item.js.map +1 -1
  137. package/build/tree-grid/roving-tab-index-context.js +1 -1
  138. package/build/tree-grid/roving-tab-index-context.js.map +1 -1
  139. package/build/tree-grid/roving-tab-index-item.js +13 -6
  140. package/build/tree-grid/roving-tab-index-item.js.map +1 -1
  141. package/build/tree-grid/roving-tab-index.js +0 -3
  142. package/build/tree-grid/roving-tab-index.js.map +1 -1
  143. package/build/tree-grid/row.js +20 -18
  144. package/build/tree-grid/row.js.map +1 -1
  145. package/build/tree-grid/types.js +6 -0
  146. package/build/tree-grid/types.js.map +1 -0
  147. package/build/ui/context/context-connect.js +7 -7
  148. package/build/ui/context/context-connect.js.map +1 -1
  149. package/build/ui/context/get-styled-class-name-from-key.js +1 -1
  150. package/build/ui/context/get-styled-class-name-from-key.js.map +1 -1
  151. package/build/ui/utils/get-valid-children.js +1 -1
  152. package/build/ui/utils/get-valid-children.js.map +1 -1
  153. package/build/ui/utils/space.js +1 -1
  154. package/build/ui/utils/space.js.map +1 -1
  155. package/build/unit-control/index.js +2 -2
  156. package/build/unit-control/index.js.map +1 -1
  157. package/build/unit-control/utils.js +20 -20
  158. package/build/unit-control/utils.js.map +1 -1
  159. package/build/utils/events.js +4 -4
  160. package/build/utils/events.js.map +1 -1
  161. package/build/utils/hooks/use-controlled-state.js +2 -2
  162. package/build/utils/hooks/use-controlled-state.js.map +1 -1
  163. package/build/utils/hooks/use-controlled-value.js +4 -4
  164. package/build/utils/hooks/use-controlled-value.js.map +1 -1
  165. package/build/utils/hooks/use-latest-ref.js +1 -1
  166. package/build/utils/hooks/use-latest-ref.js.map +1 -1
  167. package/build/utils/unit-values.js +3 -3
  168. package/build/utils/unit-values.js.map +1 -1
  169. package/build-module/alignment-matrix-control/utils.js +4 -4
  170. package/build-module/alignment-matrix-control/utils.js.map +1 -1
  171. package/build-module/angle-picker-control/angle-circle.js +37 -29
  172. package/build-module/angle-picker-control/angle-circle.js.map +1 -1
  173. package/build-module/angle-picker-control/index.js +42 -8
  174. package/build-module/angle-picker-control/index.js.map +1 -1
  175. package/build-module/angle-picker-control/styles/angle-picker-control-styles.js +13 -13
  176. package/build-module/angle-picker-control/styles/angle-picker-control-styles.js.map +1 -1
  177. package/build-module/{base-field → angle-picker-control}/types.js +0 -0
  178. package/build-module/{base-field → angle-picker-control}/types.js.map +0 -0
  179. package/build-module/autocomplete/autocompleter-ui.native.js +1 -0
  180. package/build-module/autocomplete/autocompleter-ui.native.js.map +1 -1
  181. package/build-module/base-control/hooks.js +1 -1
  182. package/build-module/base-control/hooks.js.map +1 -1
  183. package/build-module/border-box-control/utils.js +1 -1
  184. package/build-module/border-box-control/utils.js.map +1 -1
  185. package/build-module/box-control/all-input-control.js +2 -2
  186. package/build-module/box-control/all-input-control.js.map +1 -1
  187. package/build-module/box-control/axial-input-controls.js +1 -1
  188. package/build-module/box-control/axial-input-controls.js.map +1 -1
  189. package/build-module/box-control/icon.js.map +1 -1
  190. package/build-module/box-control/index.js +31 -3
  191. package/build-module/box-control/index.js.map +1 -1
  192. package/build-module/box-control/input-controls.js +5 -5
  193. package/build-module/box-control/input-controls.js.map +1 -1
  194. package/build-module/box-control/linked-button.js.map +1 -1
  195. package/build-module/box-control/styles/box-control-icon-styles.js +28 -28
  196. package/build-module/box-control/styles/box-control-icon-styles.js.map +1 -1
  197. package/build-module/box-control/styles/box-control-styles.js +23 -23
  198. package/build-module/box-control/styles/box-control-styles.js.map +1 -1
  199. package/build-module/box-control/styles/box-control-visualizer-styles.js +19 -19
  200. package/build-module/box-control/styles/box-control-visualizer-styles.js.map +1 -1
  201. package/build-module/box-control/types.js +2 -0
  202. package/{build/base-field → build-module/box-control}/types.js.map +0 -0
  203. package/build-module/box-control/unit-control.js.map +1 -1
  204. package/build-module/box-control/utils.js +23 -23
  205. package/build-module/box-control/utils.js.map +1 -1
  206. package/build-module/color-palette/index.js +8 -3
  207. package/build-module/color-palette/index.js.map +1 -1
  208. package/build-module/combobox-control/index.js +68 -12
  209. package/build-module/combobox-control/index.js.map +1 -1
  210. package/build-module/combobox-control/styles.js +2 -2
  211. package/build-module/combobox-control/styles.js.map +1 -1
  212. package/build-module/combobox-control/types.js +2 -0
  213. package/build-module/{resizable-box/styles/resizable-box.styles.js.map → combobox-control/types.js.map} +0 -0
  214. package/build-module/custom-gradient-picker/index.js +0 -1
  215. package/build-module/custom-gradient-picker/index.js.map +1 -1
  216. package/build-module/date-time/time/index.js +1 -1
  217. package/build-module/date-time/time/index.js.map +1 -1
  218. package/build-module/date-time/utils.js +1 -1
  219. package/build-module/date-time/utils.js.map +1 -1
  220. package/build-module/draggable/index.js +2 -2
  221. package/build-module/draggable/index.js.map +1 -1
  222. package/build-module/focal-point-picker/utils.js +3 -3
  223. package/build-module/focal-point-picker/utils.js.map +1 -1
  224. package/build-module/font-size-picker/utils.js +2 -2
  225. package/build-module/font-size-picker/utils.js.map +1 -1
  226. package/build-module/gradient-picker/index.js +9 -4
  227. package/build-module/gradient-picker/index.js.map +1 -1
  228. package/build-module/input-control/reducer/reducer.js +5 -5
  229. package/build-module/input-control/reducer/reducer.js.map +1 -1
  230. package/build-module/input-control/utils.js +1 -1
  231. package/build-module/input-control/utils.js.map +1 -1
  232. package/build-module/menu-items-choice/index.js +40 -4
  233. package/build-module/menu-items-choice/index.js.map +1 -1
  234. package/build-module/menu-items-choice/types.js +2 -0
  235. package/{build/resizable-box/styles/resizable-box.styles.js.map → build-module/menu-items-choice/types.js.map} +0 -0
  236. package/build-module/modal/index.js +41 -4
  237. package/build-module/modal/index.js.map +1 -1
  238. package/build-module/palette-edit/index.js +4 -1
  239. package/build-module/palette-edit/index.js.map +1 -1
  240. package/build-module/panel/header.js +9 -0
  241. package/build-module/panel/header.js.map +1 -1
  242. package/build-module/panel/index.js +20 -2
  243. package/build-module/panel/index.js.map +1 -1
  244. package/build-module/panel/row.js +9 -3
  245. package/build-module/panel/row.js.map +1 -1
  246. package/build-module/panel/types.js +2 -0
  247. package/build-module/panel/types.js.map +1 -0
  248. package/build-module/popover/index.js +14 -4
  249. package/build-module/popover/index.js.map +1 -1
  250. package/build-module/popover/overlay-middlewares.js +38 -0
  251. package/build-module/popover/overlay-middlewares.js.map +1 -0
  252. package/build-module/popover/utils.js +41 -5
  253. package/build-module/popover/utils.js.map +1 -1
  254. package/build-module/query-controls/terms.js +1 -1
  255. package/build-module/query-controls/terms.js.map +1 -1
  256. package/build-module/range-control/utils.js +4 -4
  257. package/build-module/range-control/utils.js.map +1 -1
  258. package/build-module/resizable-box/resize-tooltip/styles/resize-tooltip.styles.js +12 -12
  259. package/build-module/resizable-box/resize-tooltip/styles/resize-tooltip.styles.js.map +1 -1
  260. package/build-module/resizable-box/resize-tooltip/utils.js +14 -14
  261. package/build-module/resizable-box/resize-tooltip/utils.js.map +1 -1
  262. package/build-module/snackbar/index.js +2 -2
  263. package/build-module/snackbar/index.js.map +1 -1
  264. package/build-module/toolbar/toolbar/index.js +25 -13
  265. package/build-module/toolbar/toolbar/index.js.map +1 -1
  266. package/build-module/toolbar/toolbar/toolbar-container.js +4 -3
  267. package/build-module/toolbar/toolbar/toolbar-container.js.map +1 -1
  268. package/build-module/toolbar/toolbar/types.js +2 -0
  269. package/build-module/toolbar/toolbar/types.js.map +1 -0
  270. package/build-module/toolbar/toolbar-button/index.js +1 -0
  271. package/build-module/toolbar/toolbar-button/index.js.map +1 -1
  272. package/build-module/toolbar/toolbar-button/toolbar-button-container.js +1 -0
  273. package/build-module/toolbar/toolbar-button/toolbar-button-container.js.map +1 -1
  274. package/build-module/toolbar/toolbar-context/index.js +2 -0
  275. package/build-module/toolbar/toolbar-context/index.js.map +1 -1
  276. package/build-module/toolbar/toolbar-dropdown-menu/index.js +1 -0
  277. package/build-module/toolbar/toolbar-dropdown-menu/index.js.map +1 -1
  278. package/build-module/toolbar/toolbar-group/index.js +1 -0
  279. package/build-module/toolbar/toolbar-group/index.js.map +1 -1
  280. package/build-module/toolbar/toolbar-group/toolbar-group-collapsed.js +1 -0
  281. package/build-module/toolbar/toolbar-group/toolbar-group-collapsed.js.map +1 -1
  282. package/build-module/toolbar/toolbar-group/toolbar-group-container.js +1 -0
  283. package/build-module/toolbar/toolbar-group/toolbar-group-container.js.map +1 -1
  284. package/build-module/toolbar/toolbar-item/index.js +1 -0
  285. package/build-module/toolbar/toolbar-item/index.js.map +1 -1
  286. package/build-module/tools-panel/tools-panel/component.js +59 -4
  287. package/build-module/tools-panel/tools-panel/component.js.map +1 -1
  288. package/build-module/tools-panel/tools-panel/hook.js +4 -2
  289. package/build-module/tools-panel/tools-panel/hook.js.map +1 -1
  290. package/build-module/tools-panel/tools-panel-header/component.js +2 -1
  291. package/build-module/tools-panel/tools-panel-header/component.js.map +1 -1
  292. package/build-module/tools-panel/tools-panel-header/hook.js +2 -0
  293. package/build-module/tools-panel/tools-panel-header/hook.js.map +1 -1
  294. package/build-module/tools-panel/tools-panel-item/component.js +3 -3
  295. package/build-module/tools-panel/tools-panel-item/component.js.map +1 -1
  296. package/build-module/tools-panel/tools-panel-item/hook.js +5 -2
  297. package/build-module/tools-panel/tools-panel-item/hook.js.map +1 -1
  298. package/build-module/tree-grid/cell.js +16 -4
  299. package/build-module/tree-grid/cell.js.map +1 -1
  300. package/build-module/tree-grid/index.js +81 -21
  301. package/build-module/tree-grid/index.js.map +1 -1
  302. package/build-module/tree-grid/item.js +14 -2
  303. package/build-module/tree-grid/item.js.map +1 -1
  304. package/build-module/tree-grid/roving-tab-index-context.js +1 -1
  305. package/build-module/tree-grid/roving-tab-index-context.js.map +1 -1
  306. package/build-module/tree-grid/roving-tab-index-item.js +11 -4
  307. package/build-module/tree-grid/roving-tab-index-item.js.map +1 -1
  308. package/build-module/tree-grid/roving-tab-index.js +0 -3
  309. package/build-module/tree-grid/roving-tab-index.js.map +1 -1
  310. package/build-module/tree-grid/row.js +22 -17
  311. package/build-module/tree-grid/row.js.map +1 -1
  312. package/build-module/tree-grid/types.js +2 -0
  313. package/build-module/tree-grid/types.js.map +1 -0
  314. package/build-module/ui/context/context-connect.js +7 -7
  315. package/build-module/ui/context/context-connect.js.map +1 -1
  316. package/build-module/ui/context/get-styled-class-name-from-key.js +1 -1
  317. package/build-module/ui/context/get-styled-class-name-from-key.js.map +1 -1
  318. package/build-module/ui/utils/get-valid-children.js +1 -1
  319. package/build-module/ui/utils/get-valid-children.js.map +1 -1
  320. package/build-module/ui/utils/space.js +1 -1
  321. package/build-module/ui/utils/space.js.map +1 -1
  322. package/build-module/unit-control/index.js +2 -2
  323. package/build-module/unit-control/index.js.map +1 -1
  324. package/build-module/unit-control/utils.js +20 -20
  325. package/build-module/unit-control/utils.js.map +1 -1
  326. package/build-module/utils/events.js +4 -4
  327. package/build-module/utils/events.js.map +1 -1
  328. package/build-module/utils/hooks/use-controlled-state.js +2 -2
  329. package/build-module/utils/hooks/use-controlled-state.js.map +1 -1
  330. package/build-module/utils/hooks/use-controlled-value.js +4 -4
  331. package/build-module/utils/hooks/use-controlled-value.js.map +1 -1
  332. package/build-module/utils/hooks/use-latest-ref.js +1 -1
  333. package/build-module/utils/hooks/use-latest-ref.js.map +1 -1
  334. package/build-module/utils/unit-values.js +3 -3
  335. package/build-module/utils/unit-values.js.map +1 -1
  336. package/build-style/style-rtl.css +5 -0
  337. package/build-style/style.css +5 -0
  338. package/build-types/alignment-matrix-control/utils.d.ts +4 -4
  339. package/build-types/angle-picker-control/angle-circle.d.ts +6 -0
  340. package/build-types/angle-picker-control/angle-circle.d.ts.map +1 -0
  341. package/build-types/angle-picker-control/index.d.ts +29 -0
  342. package/build-types/angle-picker-control/index.d.ts.map +1 -0
  343. package/build-types/angle-picker-control/stories/index.d.ts +15 -0
  344. package/build-types/angle-picker-control/stories/index.d.ts.map +1 -0
  345. package/build-types/angle-picker-control/styles/angle-picker-control-styles.d.ts +20 -0
  346. package/build-types/angle-picker-control/styles/angle-picker-control-styles.d.ts.map +1 -0
  347. package/build-types/angle-picker-control/types.d.ts +26 -0
  348. package/build-types/angle-picker-control/types.d.ts.map +1 -0
  349. package/build-types/base-control/hooks.d.ts +1 -1
  350. package/build-types/border-box-control/border-box-control/component.d.ts +1 -1
  351. package/build-types/border-box-control/border-box-control/hook.d.ts +1 -1
  352. package/build-types/border-box-control/border-box-control-split-controls/component.d.ts +1 -1
  353. package/build-types/border-box-control/border-box-control-split-controls/hook.d.ts +1 -1
  354. package/build-types/border-box-control/stories/index.d.ts +1 -1
  355. package/build-types/{base-field → border-box-control}/test/index.d.ts +0 -0
  356. package/build-types/border-box-control/test/index.d.ts.map +1 -0
  357. package/build-types/border-box-control/test/utils.d.ts +2 -0
  358. package/build-types/border-box-control/test/utils.d.ts.map +1 -0
  359. package/build-types/box-control/all-input-control.d.ts +4 -0
  360. package/build-types/box-control/all-input-control.d.ts.map +1 -0
  361. package/build-types/box-control/axial-input-controls.d.ts +4 -0
  362. package/build-types/box-control/axial-input-controls.d.ts.map +1 -0
  363. package/build-types/box-control/icon.d.ts +8 -0
  364. package/build-types/box-control/icon.d.ts.map +1 -0
  365. package/build-types/box-control/index.d.ts +31 -0
  366. package/build-types/box-control/index.d.ts.map +1 -0
  367. package/build-types/box-control/input-controls.d.ts +4 -0
  368. package/build-types/box-control/input-controls.d.ts.map +1 -0
  369. package/build-types/box-control/linked-button.d.ts +9 -0
  370. package/build-types/box-control/linked-button.d.ts.map +1 -0
  371. package/build-types/box-control/styles/box-control-icon-styles.d.ts +42 -0
  372. package/build-types/box-control/styles/box-control-icon-styles.d.ts.map +1 -0
  373. package/build-types/box-control/styles/box-control-styles.d.ts +42 -0
  374. package/build-types/box-control/styles/box-control-styles.d.ts.map +1 -0
  375. package/build-types/box-control/styles/box-control-visualizer-styles.d.ts +46 -0
  376. package/build-types/box-control/styles/box-control-visualizer-styles.d.ts.map +1 -0
  377. package/build-types/box-control/test/index.d.ts +2 -0
  378. package/build-types/box-control/test/index.d.ts.map +1 -0
  379. package/build-types/box-control/types.d.ts +99 -0
  380. package/build-types/box-control/types.d.ts.map +1 -0
  381. package/build-types/box-control/unit-control.d.ts +4 -0
  382. package/build-types/box-control/unit-control.d.ts.map +1 -0
  383. package/build-types/box-control/utils.d.ts +84 -0
  384. package/build-types/box-control/utils.d.ts.map +1 -0
  385. package/build-types/color-palette/index.d.ts +3 -1
  386. package/build-types/color-palette/index.d.ts.map +1 -1
  387. package/build-types/color-palette/stories/index.d.ts +6 -2
  388. package/build-types/color-palette/stories/index.d.ts.map +1 -1
  389. package/build-types/color-palette/types.d.ts +8 -0
  390. package/build-types/color-palette/types.d.ts.map +1 -1
  391. package/build-types/combobox-control/index.d.ts +51 -0
  392. package/build-types/combobox-control/index.d.ts.map +1 -0
  393. package/build-types/combobox-control/stories/index.d.ts +18 -0
  394. package/build-types/combobox-control/stories/index.d.ts.map +1 -0
  395. package/build-types/combobox-control/styles.d.ts +8 -0
  396. package/build-types/combobox-control/styles.d.ts.map +1 -0
  397. package/build-types/combobox-control/test/index.d.ts +2 -0
  398. package/build-types/combobox-control/test/index.d.ts.map +1 -0
  399. package/build-types/combobox-control/types.d.ts +62 -0
  400. package/build-types/combobox-control/types.d.ts.map +1 -0
  401. package/build-types/date-time/utils.d.ts +1 -1
  402. package/build-types/focal-point-picker/styles/focal-point-picker-style.d.ts +1 -1
  403. package/build-types/focal-point-picker/utils.d.ts +3 -3
  404. package/build-types/font-size-picker/utils.d.ts +2 -2
  405. package/build-types/input-control/reducer/reducer.d.ts +3 -3
  406. package/build-types/input-control/utils.d.ts +1 -1
  407. package/build-types/menu-items-choice/index.d.ts +38 -0
  408. package/build-types/menu-items-choice/index.d.ts.map +1 -0
  409. package/build-types/menu-items-choice/stories/index.d.ts +12 -0
  410. package/build-types/menu-items-choice/stories/index.d.ts.map +1 -0
  411. package/build-types/menu-items-choice/types.d.ts +53 -0
  412. package/build-types/menu-items-choice/types.d.ts.map +1 -0
  413. package/build-types/modal/index.d.ts.map +1 -1
  414. package/build-types/modal/types.d.ts +2 -0
  415. package/build-types/modal/types.d.ts.map +1 -1
  416. package/build-types/panel/header.d.ts +13 -0
  417. package/build-types/panel/header.d.ts.map +1 -0
  418. package/build-types/panel/index.d.ts +21 -0
  419. package/build-types/panel/index.d.ts.map +1 -0
  420. package/build-types/panel/row.d.ts +12 -0
  421. package/build-types/panel/row.d.ts.map +1 -0
  422. package/build-types/panel/test/header.d.ts +2 -0
  423. package/build-types/panel/test/header.d.ts.map +1 -0
  424. package/build-types/panel/test/index.d.ts +2 -0
  425. package/build-types/{base-field → panel}/test/index.d.ts.map +1 -1
  426. package/build-types/panel/test/row.d.ts +2 -0
  427. package/build-types/panel/test/row.d.ts.map +1 -0
  428. package/build-types/panel/types.d.ts +38 -0
  429. package/build-types/panel/types.d.ts.map +1 -0
  430. package/build-types/popover/index.d.ts.map +1 -1
  431. package/build-types/popover/overlay-middlewares.d.ts +9 -0
  432. package/build-types/popover/overlay-middlewares.d.ts.map +1 -0
  433. package/build-types/popover/stories/index.d.ts.map +1 -1
  434. package/build-types/popover/types.d.ts +3 -2
  435. package/build-types/popover/types.d.ts.map +1 -1
  436. package/build-types/popover/utils.d.ts +12 -4
  437. package/build-types/popover/utils.d.ts.map +1 -1
  438. package/build-types/query-controls/terms.d.ts +1 -1
  439. package/build-types/range-control/utils.d.ts +4 -4
  440. package/build-types/resizable-box/resize-tooltip/styles/resize-tooltip.styles.d.ts +5 -4
  441. package/build-types/resizable-box/resize-tooltip/styles/resize-tooltip.styles.d.ts.map +1 -1
  442. package/build-types/resizable-box/resize-tooltip/utils.d.ts +6 -6
  443. package/build-types/toolbar/index.d.ts +7 -0
  444. package/build-types/toolbar/index.d.ts.map +1 -0
  445. package/build-types/toolbar/stories/index.d.ts +14 -0
  446. package/build-types/toolbar/stories/index.d.ts.map +1 -0
  447. package/build-types/toolbar/test/index.d.ts +2 -0
  448. package/build-types/toolbar/test/index.d.ts.map +1 -0
  449. package/build-types/toolbar/test/toolbar-group.d.ts +2 -0
  450. package/build-types/toolbar/test/toolbar-group.d.ts.map +1 -0
  451. package/build-types/toolbar/toolbar/index.d.ts +25 -0
  452. package/build-types/toolbar/toolbar/index.d.ts.map +1 -0
  453. package/build-types/toolbar/toolbar/toolbar-container.d.ts +5 -0
  454. package/build-types/toolbar/toolbar/toolbar-container.d.ts.map +1 -0
  455. package/build-types/toolbar/toolbar/types.d.ts +15 -0
  456. package/build-types/toolbar/toolbar/types.d.ts.map +1 -0
  457. package/build-types/toolbar/toolbar-button/index.d.ts +12 -0
  458. package/build-types/toolbar/toolbar-button/index.d.ts.map +1 -0
  459. package/build-types/toolbar/toolbar-button/toolbar-button-container.d.ts +3 -0
  460. package/build-types/toolbar/toolbar-button/toolbar-button-container.d.ts.map +1 -0
  461. package/build-types/toolbar/toolbar-context/index.d.ts +3 -0
  462. package/build-types/toolbar/toolbar-context/index.d.ts.map +1 -0
  463. package/build-types/toolbar/toolbar-dropdown-menu/index.d.ts +3 -0
  464. package/build-types/toolbar/toolbar-dropdown-menu/index.d.ts.map +1 -0
  465. package/build-types/toolbar/toolbar-group/index.d.ts +39 -0
  466. package/build-types/toolbar/toolbar-group/index.d.ts.map +1 -0
  467. package/build-types/toolbar/toolbar-group/toolbar-group-collapsed.d.ts +7 -0
  468. package/build-types/toolbar/toolbar-group/toolbar-group-collapsed.d.ts.map +1 -0
  469. package/build-types/toolbar/toolbar-group/toolbar-group-container.d.ts +7 -0
  470. package/build-types/toolbar/toolbar-group/toolbar-group-container.d.ts.map +1 -0
  471. package/build-types/toolbar/toolbar-item/index.d.ts +7 -0
  472. package/build-types/toolbar/toolbar-item/index.d.ts.map +1 -0
  473. package/build-types/tools-panel/stories/index.d.ts +17 -0
  474. package/build-types/tools-panel/stories/index.d.ts.map +1 -0
  475. package/build-types/tools-panel/tools-panel/component.d.ts +54 -2
  476. package/build-types/tools-panel/tools-panel/component.d.ts.map +1 -1
  477. package/build-types/tools-panel/tools-panel/hook.d.ts +2 -1
  478. package/build-types/tools-panel/tools-panel/hook.d.ts.map +1 -1
  479. package/build-types/tools-panel/tools-panel-header/component.d.ts.map +1 -1
  480. package/build-types/tools-panel/tools-panel-header/hook.d.ts +2 -1
  481. package/build-types/tools-panel/tools-panel-header/hook.d.ts.map +1 -1
  482. package/build-types/tools-panel/tools-panel-item/component.d.ts +2 -2
  483. package/build-types/tools-panel/tools-panel-item/component.d.ts.map +1 -1
  484. package/build-types/tools-panel/tools-panel-item/hook.d.ts.map +1 -1
  485. package/build-types/tools-panel/types.d.ts +42 -15
  486. package/build-types/tools-panel/types.d.ts.map +1 -1
  487. package/build-types/tree-grid/cell.d.ts +13 -0
  488. package/build-types/tree-grid/cell.d.ts.map +1 -0
  489. package/build-types/tree-grid/index.d.ts +70 -0
  490. package/build-types/tree-grid/index.d.ts.map +1 -0
  491. package/build-types/tree-grid/item.d.ts +12 -0
  492. package/build-types/tree-grid/item.d.ts.map +1 -0
  493. package/build-types/tree-grid/roving-tab-index-context.d.ts +10 -0
  494. package/build-types/tree-grid/roving-tab-index-context.d.ts.map +1 -0
  495. package/build-types/tree-grid/roving-tab-index-item.d.ts +5 -0
  496. package/build-types/tree-grid/roving-tab-index-item.d.ts.map +1 -0
  497. package/build-types/tree-grid/roving-tab-index.d.ts +10 -0
  498. package/build-types/tree-grid/roving-tab-index.d.ts.map +1 -0
  499. package/build-types/tree-grid/row.d.ts +12 -0
  500. package/build-types/tree-grid/row.d.ts.map +1 -0
  501. package/build-types/tree-grid/stories/index.d.ts +13 -0
  502. package/build-types/tree-grid/stories/index.d.ts.map +1 -0
  503. package/build-types/tree-grid/test/cell.d.ts +2 -0
  504. package/build-types/tree-grid/test/cell.d.ts.map +1 -0
  505. package/build-types/tree-grid/test/index.d.ts +2 -0
  506. package/build-types/tree-grid/test/index.d.ts.map +1 -0
  507. package/build-types/tree-grid/test/roving-tab-index-item.d.ts +2 -0
  508. package/build-types/tree-grid/test/roving-tab-index-item.d.ts.map +1 -0
  509. package/build-types/tree-grid/test/roving-tab-index.d.ts +2 -0
  510. package/build-types/tree-grid/test/roving-tab-index.d.ts.map +1 -0
  511. package/build-types/tree-grid/test/row.d.ts +2 -0
  512. package/build-types/tree-grid/test/row.d.ts.map +1 -0
  513. package/build-types/tree-grid/types.d.ts +109 -0
  514. package/build-types/tree-grid/types.d.ts.map +1 -0
  515. package/build-types/ui/context/context-connect.d.ts +7 -7
  516. package/build-types/ui/context/get-styled-class-name-from-key.d.ts +1 -1
  517. package/build-types/ui/utils/get-valid-children.d.ts +1 -1
  518. package/build-types/ui/utils/space.d.ts +1 -1
  519. package/build-types/unit-control/index.d.ts +1 -1
  520. package/build-types/unit-control/utils.d.ts +20 -20
  521. package/build-types/utils/events.d.ts +2 -2
  522. package/build-types/utils/hooks/use-controlled-state.d.ts +1 -1
  523. package/build-types/utils/hooks/use-controlled-state.d.ts.map +1 -1
  524. package/build-types/utils/hooks/use-controlled-value.d.ts +4 -4
  525. package/build-types/utils/hooks/use-latest-ref.d.ts +1 -1
  526. package/build-types/utils/unit-values.d.ts +3 -3
  527. package/package.json +19 -19
  528. package/src/alignment-matrix-control/utils.tsx +4 -4
  529. package/src/angle-picker-control/README.md +17 -14
  530. package/src/angle-picker-control/{angle-circle.js → angle-circle.tsx} +44 -12
  531. package/src/angle-picker-control/{index.js → index.tsx} +54 -10
  532. package/src/angle-picker-control/stories/index.tsx +57 -0
  533. package/src/angle-picker-control/styles/{angle-picker-control-styles.js → angle-picker-control-styles.tsx} +5 -1
  534. package/src/angle-picker-control/types.ts +29 -0
  535. package/src/autocomplete/autocompleter-ui.native.js +1 -0
  536. package/src/base-control/hooks.ts +1 -1
  537. package/src/border-box-control/test/{index.js → index.tsx} +76 -102
  538. package/src/border-box-control/test/{utils.js → utils.ts} +20 -0
  539. package/src/border-box-control/utils.ts +1 -1
  540. package/src/box-control/README.md +17 -26
  541. package/src/box-control/{all-input-control.js → all-input-control.tsx} +10 -6
  542. package/src/box-control/{axial-input-controls.js → axial-input-controls.tsx} +29 -24
  543. package/src/box-control/{icon.js → icon.tsx} +9 -4
  544. package/src/box-control/{index.js → index.tsx} +43 -8
  545. package/src/box-control/{input-controls.js → input-controls.tsx} +26 -16
  546. package/src/box-control/{linked-button.js → linked-button.tsx} +4 -1
  547. package/src/box-control/styles/{box-control-icon-styles.js → box-control-icon-styles.ts} +1 -1
  548. package/src/box-control/styles/{box-control-styles.js → box-control-styles.ts} +10 -2
  549. package/src/box-control/styles/{box-control-visualizer-styles.js → box-control-visualizer-styles.ts} +6 -2
  550. package/src/box-control/test/{index.js → index.tsx} +12 -9
  551. package/src/box-control/types.ts +121 -0
  552. package/src/box-control/{unit-control.js → unit-control.tsx} +9 -2
  553. package/src/box-control/{utils.js → utils.ts} +47 -38
  554. package/src/button/test/index.tsx +38 -30
  555. package/src/color-palette/README.md +7 -0
  556. package/src/color-palette/index.tsx +6 -1
  557. package/src/color-palette/types.ts +8 -0
  558. package/src/combobox-control/README.md +8 -15
  559. package/src/combobox-control/{index.js → index.tsx} +91 -19
  560. package/src/combobox-control/stories/index.tsx +114 -0
  561. package/src/combobox-control/styles.ts +4 -1
  562. package/src/combobox-control/test/{index.js → index.tsx} +9 -7
  563. package/src/combobox-control/types.ts +69 -0
  564. package/src/custom-gradient-picker/index.js +0 -1
  565. package/src/custom-select-control/stories/index.js +1 -1
  566. package/src/date-time/time/index.tsx +1 -1
  567. package/src/date-time/utils.ts +1 -1
  568. package/src/draggable/index.tsx +2 -2
  569. package/src/dropdown-menu/test/index.js +3 -11
  570. package/src/focal-point-picker/utils.ts +3 -3
  571. package/src/font-size-picker/utils.ts +2 -2
  572. package/src/gradient-picker/README.md +8 -0
  573. package/src/gradient-picker/index.js +6 -1
  574. package/src/input-control/reducer/reducer.ts +5 -5
  575. package/src/input-control/utils.ts +1 -1
  576. package/src/menu-items-choice/index.tsx +83 -0
  577. package/src/menu-items-choice/stories/index.tsx +79 -0
  578. package/src/menu-items-choice/types.ts +54 -0
  579. package/src/modal/index.tsx +45 -1
  580. package/src/modal/style.scss +8 -0
  581. package/src/modal/types.ts +2 -0
  582. package/src/palette-edit/index.js +4 -1
  583. package/src/panel/README.md +2 -2
  584. package/src/panel/header.tsx +20 -0
  585. package/src/panel/index.tsx +48 -0
  586. package/src/panel/row.tsx +37 -0
  587. package/src/panel/stories/index.js +22 -0
  588. package/src/panel/test/__snapshots__/{header.js.snap → header.tsx.snap} +0 -0
  589. package/src/panel/test/__snapshots__/{index.js.snap → index.tsx.snap} +0 -0
  590. package/src/panel/test/__snapshots__/{row.js.snap → row.tsx.snap} +0 -0
  591. package/src/panel/test/{header.js → header.tsx} +1 -1
  592. package/src/panel/test/{index.js → index.tsx} +6 -4
  593. package/src/panel/test/{row.js → row.tsx} +4 -2
  594. package/src/panel/types.ts +38 -0
  595. package/src/popover/README.md +4 -1
  596. package/src/popover/index.tsx +17 -1
  597. package/src/popover/overlay-middlewares.tsx +29 -0
  598. package/src/popover/stories/index.tsx +7 -1
  599. package/src/popover/test/index.tsx +29 -21
  600. package/src/popover/types.ts +4 -2
  601. package/src/popover/utils.ts +39 -3
  602. package/src/query-controls/terms.ts +1 -1
  603. package/src/range-control/utils.ts +4 -4
  604. package/src/resizable-box/resize-tooltip/styles/{resize-tooltip.styles.js → resize-tooltip.styles.ts} +0 -0
  605. package/src/resizable-box/resize-tooltip/utils.ts +14 -14
  606. package/src/snackbar/index.tsx +2 -2
  607. package/src/toolbar/stories/{index.js → index.tsx} +39 -26
  608. package/src/toolbar/test/{index.js → index.tsx} +0 -0
  609. package/src/toolbar/test/{toolbar-group.js → toolbar-group.tsx} +2 -2
  610. package/src/toolbar/toolbar/README.md +7 -2
  611. package/src/toolbar/toolbar/{index.js → index.tsx} +33 -12
  612. package/src/toolbar/toolbar/{toolbar-container.js → toolbar-container.tsx} +9 -2
  613. package/src/toolbar/toolbar/types.ts +15 -0
  614. package/src/toolbar/toolbar-button/index.js +2 -0
  615. package/src/toolbar/toolbar-button/toolbar-button-container.js +2 -0
  616. package/src/toolbar/toolbar-context/index.js +2 -0
  617. package/src/toolbar/toolbar-dropdown-menu/index.js +2 -0
  618. package/src/toolbar/toolbar-group/index.js +2 -0
  619. package/src/toolbar/toolbar-group/toolbar-group-collapsed.js +2 -0
  620. package/src/toolbar/toolbar-group/toolbar-group-container.js +2 -0
  621. package/src/toolbar/toolbar-item/index.js +2 -0
  622. package/src/tools-panel/stories/{index.js → index.tsx} +196 -95
  623. package/src/tools-panel/test/index.js +6 -6
  624. package/src/tools-panel/tools-panel/README.md +12 -4
  625. package/src/tools-panel/tools-panel/component.tsx +57 -3
  626. package/src/tools-panel/tools-panel/hook.ts +4 -2
  627. package/src/tools-panel/tools-panel-header/README.md +7 -0
  628. package/src/tools-panel/tools-panel-header/component.tsx +2 -1
  629. package/src/tools-panel/tools-panel-header/hook.ts +6 -4
  630. package/src/tools-panel/tools-panel-item/README.md +6 -4
  631. package/src/tools-panel/tools-panel-item/component.tsx +4 -4
  632. package/src/tools-panel/tools-panel-item/hook.ts +4 -2
  633. package/src/tools-panel/types.ts +43 -15
  634. package/src/tree-grid/README.md +18 -58
  635. package/src/tree-grid/cell.tsx +41 -0
  636. package/src/tree-grid/{index.js → index.tsx} +111 -35
  637. package/src/tree-grid/item.tsx +32 -0
  638. package/src/tree-grid/{roving-tab-index-context.js → roving-tab-index-context.ts} +9 -1
  639. package/src/tree-grid/roving-tab-index-item.tsx +50 -0
  640. package/src/tree-grid/{roving-tab-index.js → roving-tab-index.tsx} +7 -5
  641. package/src/tree-grid/row.tsx +47 -0
  642. package/src/tree-grid/stories/index.tsx +144 -0
  643. package/src/tree-grid/test/__snapshots__/{cell.js.snap → cell.tsx.snap} +0 -0
  644. package/src/tree-grid/test/__snapshots__/{index.js.snap → index.tsx.snap} +0 -0
  645. package/src/tree-grid/test/__snapshots__/{roving-tab-index-item.js.snap → roving-tab-index-item.tsx.snap} +0 -0
  646. package/src/tree-grid/test/__snapshots__/{roving-tab-index.js.snap → roving-tab-index.tsx.snap} +0 -0
  647. package/src/tree-grid/test/__snapshots__/{row.js.snap → row.tsx.snap} +0 -0
  648. package/src/tree-grid/test/{cell.js → cell.tsx} +7 -4
  649. package/src/tree-grid/test/{index.js → index.tsx} +13 -5
  650. package/src/tree-grid/test/{roving-tab-index-item.js → roving-tab-index-item.tsx} +7 -4
  651. package/src/tree-grid/test/{roving-tab-index.js → roving-tab-index.tsx} +0 -0
  652. package/src/tree-grid/test/{row.js → row.tsx} +4 -4
  653. package/src/tree-grid/types.ts +116 -0
  654. package/src/ui/context/context-connect.ts +7 -7
  655. package/src/ui/context/get-styled-class-name-from-key.ts +1 -1
  656. package/src/ui/utils/get-valid-children.ts +1 -1
  657. package/src/ui/utils/space.ts +1 -1
  658. package/src/unit-control/index.tsx +2 -2
  659. package/src/unit-control/utils.ts +20 -20
  660. package/src/utils/events.ts +4 -4
  661. package/src/utils/hooks/use-controlled-state.js +2 -2
  662. package/src/utils/hooks/use-controlled-value.ts +4 -4
  663. package/src/utils/hooks/use-latest-ref.ts +1 -1
  664. package/src/utils/unit-values.ts +3 -3
  665. package/tsconfig.json +1 -7
  666. package/tsconfig.tsbuildinfo +1 -1
  667. package/build/base-field/hook.js +0 -54
  668. package/build/base-field/hook.js.map +0 -1
  669. package/build/base-field/index.js +0 -14
  670. package/build/base-field/index.js.map +0 -1
  671. package/build/base-field/styles.js +0 -33
  672. package/build/base-field/styles.js.map +0 -1
  673. package/build/resizable-box/styles/resizable-box.styles.js +0 -2
  674. package/build-module/base-field/hook.js +0 -37
  675. package/build-module/base-field/hook.js.map +0 -1
  676. package/build-module/base-field/index.js +0 -2
  677. package/build-module/base-field/index.js.map +0 -1
  678. package/build-module/base-field/styles.js +0 -18
  679. package/build-module/base-field/styles.js.map +0 -1
  680. package/build-module/resizable-box/styles/resizable-box.styles.js +0 -2
  681. package/build-types/base-field/hook.d.ts +0 -270
  682. package/build-types/base-field/hook.d.ts.map +0 -1
  683. package/build-types/base-field/index.d.ts +0 -2
  684. package/build-types/base-field/index.d.ts.map +0 -1
  685. package/build-types/base-field/styles.d.ts +0 -6
  686. package/build-types/base-field/styles.d.ts.map +0 -1
  687. package/build-types/base-field/types.d.ts +0 -29
  688. package/build-types/base-field/types.d.ts.map +0 -1
  689. package/build-types/resizable-box/styles/resizable-box.styles.d.ts +0 -1
  690. package/build-types/resizable-box/styles/resizable-box.styles.d.ts.map +0 -1
  691. package/src/angle-picker-control/stories/index.js +0 -29
  692. package/src/base-field/README.md +0 -66
  693. package/src/base-field/hook.ts +0 -51
  694. package/src/base-field/index.ts +0 -1
  695. package/src/base-field/styles.ts +0 -86
  696. package/src/base-field/test/__snapshots__/index.tsx.snap +0 -141
  697. package/src/base-field/test/index.tsx +0 -84
  698. package/src/base-field/types.ts +0 -29
  699. package/src/combobox-control/stories/index.js +0 -339
  700. package/src/menu-items-choice/index.js +0 -43
  701. package/src/panel/header.js +0 -10
  702. package/src/panel/index.js +0 -26
  703. package/src/panel/row.js +0 -20
  704. package/src/resizable-box/styles/resizable-box.styles.js +0 -0
  705. package/src/tools-panel/stories/utils/tools-panel-with-item-group-slot.js +0 -246
  706. package/src/tree-grid/cell.js +0 -24
  707. package/src/tree-grid/item.js +0 -20
  708. package/src/tree-grid/roving-tab-index-item.js +0 -33
  709. package/src/tree-grid/row.js +0 -31
  710. package/src/tree-grid/stories/index.js +0 -106
@@ -5,7 +5,7 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
5
5
  Object.defineProperty(exports, "__esModule", {
6
6
  value: true
7
7
  });
8
- exports.default = void 0;
8
+ exports.default = exports.ToolsPanelItem = void 0;
9
9
 
10
10
  var _element = require("@wordpress/element");
11
11
 
@@ -26,7 +26,7 @@ var _context = require("../../ui/context");
26
26
  */
27
27
  // This wraps controls to be conditionally displayed within a tools panel. It
28
28
  // prevents props being applied to HTML elements that would make them invalid.
29
- const ToolsPanelItem = (props, forwardedRef) => {
29
+ const UnconnectedToolsPanelItem = (props, forwardedRef) => {
30
30
  const {
31
31
  children,
32
32
  isShown,
@@ -45,7 +45,8 @@ const ToolsPanelItem = (props, forwardedRef) => {
45
45
  }), children);
46
46
  };
47
47
 
48
- const ConnectedToolsPanelItem = (0, _context.contextConnect)(ToolsPanelItem, 'ToolsPanelItem');
49
- var _default = ConnectedToolsPanelItem;
48
+ const ToolsPanelItem = (0, _context.contextConnect)(UnconnectedToolsPanelItem, 'ToolsPanelItem');
49
+ exports.ToolsPanelItem = ToolsPanelItem;
50
+ var _default = ToolsPanelItem;
50
51
  exports.default = _default;
51
52
  //# sourceMappingURL=component.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/components/src/tools-panel/tools-panel-item/component.tsx"],"names":["ToolsPanelItem","props","forwardedRef","children","isShown","shouldRenderPlaceholder","toolsPanelItemProps","ConnectedToolsPanelItem"],"mappings":";;;;;;;;;;;;;AAQA;;AACA;;AACA;;AAVA;AACA;AACA;;AAGA;AACA;AACA;AAMA;AACA;AACA,MAAMA,cAAc,GAAG,CACtBC,KADsB,EAEtBC,YAFsB,KAGlB;AACJ,QAAM;AACLC,IAAAA,QADK;AAELC,IAAAA,OAFK;AAGLC,IAAAA,uBAHK;AAIL,OAAGC;AAJE,MAKF,6BAAmBL,KAAnB,CALJ;;AAOA,MAAK,CAAEG,OAAP,EAAiB;AAChB,WAAOC,uBAAuB,GAC7B,4BAAC,UAAD,6BAAWC,mBAAX;AAAiC,MAAA,GAAG,EAAGJ;AAAvC,OAD6B,GAE1B,IAFJ;AAGA;;AAED,SACC,4BAAC,UAAD,6BAAWI,mBAAX;AAAiC,IAAA,GAAG,EAAGJ;AAAvC,MACGC,QADH,CADD;AAKA,CAtBD;;AAwBA,MAAMI,uBAAuB,GAAG,6BAC/BP,cAD+B,EAE/B,gBAF+B,CAAhC;eAKeO,uB","sourcesContent":["/**\n * External dependencies\n */\nimport type { ForwardedRef } from 'react';\n\n/**\n * Internal dependencies\n */\nimport { useToolsPanelItem } from './hook';\nimport { View } from '../../view';\nimport { contextConnect, WordPressComponentProps } from '../../ui/context';\nimport type { ToolsPanelItemProps } from '../types';\n\n// This wraps controls to be conditionally displayed within a tools panel. It\n// prevents props being applied to HTML elements that would make them invalid.\nconst ToolsPanelItem = (\n\tprops: WordPressComponentProps< ToolsPanelItemProps, 'div' >,\n\tforwardedRef: ForwardedRef< any >\n) => {\n\tconst {\n\t\tchildren,\n\t\tisShown,\n\t\tshouldRenderPlaceholder,\n\t\t...toolsPanelItemProps\n\t} = useToolsPanelItem( props );\n\n\tif ( ! isShown ) {\n\t\treturn shouldRenderPlaceholder ? (\n\t\t\t<View { ...toolsPanelItemProps } ref={ forwardedRef } />\n\t\t) : null;\n\t}\n\n\treturn (\n\t\t<View { ...toolsPanelItemProps } ref={ forwardedRef }>\n\t\t\t{ children }\n\t\t</View>\n\t);\n};\n\nconst ConnectedToolsPanelItem = contextConnect(\n\tToolsPanelItem,\n\t'ToolsPanelItem'\n);\n\nexport default ConnectedToolsPanelItem;\n"]}
1
+ {"version":3,"sources":["@wordpress/components/src/tools-panel/tools-panel-item/component.tsx"],"names":["UnconnectedToolsPanelItem","props","forwardedRef","children","isShown","shouldRenderPlaceholder","toolsPanelItemProps","ToolsPanelItem"],"mappings":";;;;;;;;;;;;;AAQA;;AACA;;AACA;;AAVA;AACA;AACA;;AAGA;AACA;AACA;AAMA;AACA;AACA,MAAMA,yBAAyB,GAAG,CACjCC,KADiC,EAEjCC,YAFiC,KAG7B;AACJ,QAAM;AACLC,IAAAA,QADK;AAELC,IAAAA,OAFK;AAGLC,IAAAA,uBAHK;AAIL,OAAGC;AAJE,MAKF,6BAAmBL,KAAnB,CALJ;;AAOA,MAAK,CAAEG,OAAP,EAAiB;AAChB,WAAOC,uBAAuB,GAC7B,4BAAC,UAAD,6BAAWC,mBAAX;AAAiC,MAAA,GAAG,EAAGJ;AAAvC,OAD6B,GAE1B,IAFJ;AAGA;;AAED,SACC,4BAAC,UAAD,6BAAWI,mBAAX;AAAiC,IAAA,GAAG,EAAGJ;AAAvC,MACGC,QADH,CADD;AAKA,CAtBD;;AAwBO,MAAMI,cAAc,GAAG,6BAC7BP,yBAD6B,EAE7B,gBAF6B,CAAvB;;eAKQO,c","sourcesContent":["/**\n * External dependencies\n */\nimport type { ForwardedRef } from 'react';\n\n/**\n * Internal dependencies\n */\nimport { useToolsPanelItem } from './hook';\nimport { View } from '../../view';\nimport { contextConnect, WordPressComponentProps } from '../../ui/context';\nimport type { ToolsPanelItemProps } from '../types';\n\n// This wraps controls to be conditionally displayed within a tools panel. It\n// prevents props being applied to HTML elements that would make them invalid.\nconst UnconnectedToolsPanelItem = (\n\tprops: WordPressComponentProps< ToolsPanelItemProps, 'div' >,\n\tforwardedRef: ForwardedRef< any >\n) => {\n\tconst {\n\t\tchildren,\n\t\tisShown,\n\t\tshouldRenderPlaceholder,\n\t\t...toolsPanelItemProps\n\t} = useToolsPanelItem( props );\n\n\tif ( ! isShown ) {\n\t\treturn shouldRenderPlaceholder ? (\n\t\t\t<View { ...toolsPanelItemProps } ref={ forwardedRef } />\n\t\t) : null;\n\t}\n\n\treturn (\n\t\t<View { ...toolsPanelItemProps } ref={ forwardedRef }>\n\t\t\t{ children }\n\t\t</View>\n\t);\n};\n\nexport const ToolsPanelItem = contextConnect(\n\tUnconnectedToolsPanelItem,\n\t'ToolsPanelItem'\n);\n\nexport default ToolsPanelItem;\n"]}
@@ -28,16 +28,18 @@ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj &&
28
28
  /**
29
29
  * Internal dependencies
30
30
  */
31
+ const noop = () => {};
32
+
31
33
  function useToolsPanelItem(props) {
32
34
  var _menuItems$menuGroup, _menuItems$menuGroup2, _menuItems$menuGroup3;
33
35
 
34
36
  const {
35
37
  className,
36
38
  hasValue,
37
- isShownByDefault,
39
+ isShownByDefault = false,
38
40
  label,
39
41
  panelId,
40
- resetAllFilter,
42
+ resetAllFilter = noop,
41
43
  onDeselect,
42
44
  onSelect,
43
45
  ...otherProps
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/components/src/tools-panel/tools-panel-item/hook.ts"],"names":["useToolsPanelItem","props","className","hasValue","isShownByDefault","label","panelId","resetAllFilter","onDeselect","onSelect","otherProps","currentPanelId","menuItems","registerPanelItem","deregisterPanelItem","flagItemCustomization","isResetting","shouldRenderPlaceholderItems","shouldRenderPlaceholder","firstDisplayedItem","lastDisplayedItem","__experimentalFirstVisibleItemClass","__experimentalLastVisibleItemClass","hasValueCallback","resetAllFilterCallback","previousPanelId","hasMatchingPanel","menuGroup","isMenuItemChecked","wasMenuItemChecked","isRegistered","undefined","isValueSet","wasValueSet","newValueSet","isShown","cx","classes","placeholderStyle","styles","ToolsPanelItemPlaceholder","firstItemStyle","lastItemStyle","ToolsPanelItem"],"mappings":";;;;;;;AAGA;;AACA;;AAKA;;AACA;;AACA;;AACA;;;;;;AAZA;AACA;AACA;;AAIA;AACA;AACA;AAOO,SAASA,iBAAT,CACNC,KADM,EAEL;AAAA;;AACD,QAAM;AACLC,IAAAA,SADK;AAELC,IAAAA,QAFK;AAGLC,IAAAA,gBAHK;AAILC,IAAAA,KAJK;AAKLC,I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CAAEmB,iBAAF,IAAuBC,kBAA5B,EAAiD;AAChDrB,MAAAA,UAAU,SAAV,IAAAA,UAAU,WAAV,YAAAA,UAAU;AACV;AACD,GAfD,EAeG,CACFkB,gBADE,EAEFE,iBAFE,EAGFE,YAHE,EAIFd,WAJE,EAKFgB,UALE,EAMFH,kBANE,EAOFpB,QAPE,EAQFD,UARE,CAfH,EA3GC,CAqID;AACA;AACA;;AACA,QAAM2B,OAAO,GAAG/B,gBAAgB,GAC7B,CAAAQ,SAAS,SAAT,IAAAA,SAAS,WAAT,qCAAAA,SAAS,CAAIe,SAAJ,CAAT,gFAA4BtB,KAA5B,OAAwC0B,SADX,GAE7BH,iBAFH;AAIA,QAAMQ,EAAE,GAAG,mBAAX;AACA,QAAMC,OAAO,GAAG,sBAAS,MAAM;AAC9B,UAAMC,gBAAgB,GACrBpB,uBAAuB,IACvB,CAAEiB,OADF,IAEAI,MAAM,CAACC,yBAHR;AAIA,UAAMC,cAAc,GACnBtB,kBAAkB,KAAKd,KAAvB,IAAgCgB,mCADjC;AAEA,UAAMqB,aAAa,GAClBtB,iBAAiB,KAAKf,KAAtB,IAA+BiB,kCADhC;AAEA,WAAOc,EAAE,CACRG,MAAM,CAACI,cADC,EAERL,gBAFQ,EAGRpC,SAHQ,EAIRuC,cAJQ,EAKRC,aALQ,CAAT;AAOA,GAhBe,EAgBb,CACFP,OADE,EAEFjB,uBAFE,EAGFhB,SAHE,EAIFkC,EAJE,EAKFjB,kBALE,EAMFC,iBANE,EAOFC,mCAPE,EAQFC,kCARE,EASFjB,KATE,CAhBa,CAAhB;AA4BA,SAAO,EACN,GAAGK,UADG;AAENyB,IAAAA,OAFM;AAGNjB,IAAAA,uBAHM;AAINhB,IAAAA,SAAS,EAAEmC;AAJL,GAAP;AAMA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { usePrevious } from '@wordpress/compose';\nimport { useCallback, useEffect, useMemo } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport * as styles from '../styles';\nimport { useToolsPanelContext } from '../context';\nimport { useContextSystem, WordPressComponentProps } from '../../ui/context';\nimport { useCx } from '../../utils/hooks/use-cx';\nimport type { ToolsPanelItemProps } from '../types';\n\nexport function useToolsPanelItem(\n\tprops: WordPressComponentProps< ToolsPanelItemProps, 'div' >\n) {\n\tconst {\n\t\tclassName,\n\t\thasValue,\n\t\tisShownByDefault,\n\t\tlabel,\n\t\tpanelId,\n\t\tresetAllFilter,\n\t\tonDeselect,\n\t\tonSelect,\n\t\t...otherProps\n\t} = useContextSystem( props, 'ToolsPanelItem' );\n\n\tconst {\n\t\tpanelId: currentPanelId,\n\t\tmenuItems,\n\t\tregisterPanelItem,\n\t\tderegisterPanelItem,\n\t\tflagItemCustomization,\n\t\tisResetting,\n\t\tshouldRenderPlaceholderItems: shouldRenderPlaceholder,\n\t\tfirstDisplayedItem,\n\t\tlastDisplayedItem,\n\t\t__experimentalFirstVisibleItemClass,\n\t\t__experimentalLastVisibleItemClass,\n\t} = useToolsPanelContext();\n\n\tconst hasValueCallback = useCallback( hasValue, [ panelId, hasValue ] );\n\tconst resetAllFilterCallback = useCallback( resetAllFilter, [\n\t\tpanelId,\n\t\tresetAllFilter,\n\t] );\n\tconst previousPanelId = usePrevious( currentPanelId );\n\n\tconst hasMatchingPanel =\n\t\tcurrentPanelId === panelId || currentPanelId === null;\n\n\t// Registering the panel item allows the panel to include it in its\n\t// automatically generated menu and determine its initial checked status.\n\tuseEffect( () => {\n\t\tif ( hasMatchingPanel && previousPanelId !== null ) {\n\t\t\tregisterPanelItem( {\n\t\t\t\thasValue: hasValueCallback,\n\t\t\t\tisShownByDefault,\n\t\t\t\tlabel,\n\t\t\t\tresetAllFilter: resetAllFilterCallback,\n\t\t\t\tpanelId,\n\t\t\t} );\n\t\t}\n\n\t\treturn () => {\n\t\t\tif (\n\t\t\t\t( previousPanelId === null && !! currentPanelId ) ||\n\t\t\t\tcurrentPanelId === panelId\n\t\t\t) {\n\t\t\t\tderegisterPanelItem( label );\n\t\t\t}\n\t\t};\n\t}, [\n\t\tcurrentPanelId,\n\t\thasMatchingPanel,\n\t\tisShownByDefault,\n\t\tlabel,\n\t\thasValueCallback,\n\t\tpanelId,\n\t\tpreviousPanelId,\n\t\tresetAllFilterCallback,\n\t\tregisterPanelItem,\n\t\tderegisterPanelItem,\n\t] );\n\n\t// Note: `label` is used as a key when building menu item state in\n\t// `ToolsPanel`.\n\tconst menuGroup = isShownByDefault ? 'default' : 'optional';\n\tconst isMenuItemChecked = menuItems?.[ menuGroup ]?.[ label ];\n\tconst wasMenuItemChecked = usePrevious( isMenuItemChecked );\n\tconst isRegistered = menuItems?.[ menuGroup ]?.[ label ] !== undefined;\n\n\tconst isValueSet = hasValue();\n\tconst wasValueSet = usePrevious( isValueSet );\n\tconst newValueSet = isValueSet && ! wasValueSet;\n\n\t// Notify the panel when an item's value has been set.\n\t//\n\t// 1. For default controls, this is so \"reset\" appears beside its menu item.\n\t// 2. For optional controls, when the panel ID is `null`, it allows the\n\t// panel to ensure the item is toggled on for display in the menu, given the\n\t// value has been set external to the control.\n\tuseEffect( () => {\n\t\tif ( ! newValueSet ) {\n\t\t\treturn;\n\t\t}\n\n\t\tif ( isShownByDefault || currentPanelId === null ) {\n\t\t\tflagItemCustomization( label, menuGroup );\n\t\t}\n\t}, [\n\t\tcurrentPanelId,\n\t\tnewValueSet,\n\t\tisShownByDefault,\n\t\tmenuGroup,\n\t\tlabel,\n\t\tflagItemCustomization,\n\t] );\n\n\t// Determine if the panel item's corresponding menu is being toggled and\n\t// trigger appropriate callback if it is.\n\tuseEffect( () => {\n\t\t// We check whether this item is currently registered as items rendered\n\t\t// via fills can persist through the parent panel being remounted.\n\t\t// See: https://github.com/WordPress/gutenberg/pull/45673\n\t\tif ( ! isRegistered || isResetting || ! hasMatchingPanel ) {\n\t\t\treturn;\n\t\t}\n\n\t\tif ( isMenuItemChecked && ! isValueSet && ! wasMenuItemChecked ) {\n\t\t\tonSelect?.();\n\t\t}\n\n\t\tif ( ! isMenuItemChecked && wasMenuItemChecked ) {\n\t\t\tonDeselect?.();\n\t\t}\n\t}, [\n\t\thasMatchingPanel,\n\t\tisMenuItemChecked,\n\t\tisRegistered,\n\t\tisResetting,\n\t\tisValueSet,\n\t\twasMenuItemChecked,\n\t\tonSelect,\n\t\tonDeselect,\n\t] );\n\n\t// The item is shown if it is a default control regardless of whether it\n\t// has a value. Optional items are shown when they are checked or have\n\t// a value.\n\tconst isShown = isShownByDefault\n\t\t? menuItems?.[ menuGroup ]?.[ label ] !== undefined\n\t\t: isMenuItemChecked;\n\n\tconst cx = useCx();\n\tconst classes = useMemo( () => {\n\t\tconst placeholderStyle =\n\t\t\tshouldRenderPlaceholder &&\n\t\t\t! isShown &&\n\t\t\tstyles.ToolsPanelItemPlaceholder;\n\t\tconst firstItemStyle =\n\t\t\tfirstDisplayedItem === label && __experimentalFirstVisibleItemClass;\n\t\tconst lastItemStyle =\n\t\t\tlastDisplayedItem === label && __experimentalLastVisibleItemClass;\n\t\treturn cx(\n\t\t\tstyles.ToolsPanelItem,\n\t\t\tplaceholderStyle,\n\t\t\tclassName,\n\t\t\tfirstItemStyle,\n\t\t\tlastItemStyle\n\t\t);\n\t}, [\n\t\tisShown,\n\t\tshouldRenderPlaceholder,\n\t\tclassName,\n\t\tcx,\n\t\tfirstDisplayedItem,\n\t\tlastDisplayedItem,\n\t\t__experimentalFirstVisibleItemClass,\n\t\t__experimentalLastVisibleItemClass,\n\t\tlabel,\n\t] );\n\n\treturn {\n\t\t...otherProps,\n\t\tisShown,\n\t\tshouldRenderPlaceholder,\n\t\tclassName: classes,\n\t};\n}\n"]}
1
+ {"version":3,"sources":["@wordpress/components/src/tools-panel/tools-panel-item/hook.ts"],"names":["noop","useToolsPanelItem","props","className","hasValue","isShownByDefault","label","panelId","resetAllFilter","onDeselect","onSelect","otherProps","currentPanelId","menuItems","registerPanelItem","deregisterPanelItem","flagItemCustomization","isResetting","shouldRenderPlaceholderItems","shouldRenderPlaceholder","firstDisplayedItem","lastDisplayedItem","__experimentalFirstVisibleItemClass","__experimentalLastVisibleItemClass","hasValueCallback","resetAllFilterCallback","previousPanelId","hasMatchingPanel","menuGroup","isMenuItemChecked","wasMenuItemChecked","isRegistered","undefined","isValueSet","wasValueSet","newValueSet","isShown","cx","classes","placeholderStyle","styles","ToolsPanelItemPlaceholder","firstItemStyle","lastItemStyle","ToolsPanelItem"],"mappings":";;;;;;;AAGA;;AACA;;AAKA;;AACA;;AACA;;AACA;;;;;;AAZA;AACA;AACA;;AAIA;AACA;AACA;AAOA,MAAMA,IAAI,GAAG,MAAM,CAAE,CAArB;;AAEO,SAASC,iBAAT,CACNC,KADM,EAEL;AAAA;;AACD,QAAM;AACLC,IAAAA,SADK;AAELC,IAAAA,QAFK;AAGLC,IAAAA,gBAAgB,GAAG,KAHd;AAILC,IAAAA,KAJK;AAKLC,IAAAA,OALK;AAMLC,IAAAA,cAAc,GAAGR,IANZ;AAOLS,IAAAA,UAPK;AAQLC,IAAAA,QARK;AASL,OAAGC;AATE,MAUF,gCAAkBT,KAAlB,EAAyB,gBAAzB,CAVJ;AAYA,QAAM;AACLK,IAAAA,OAAO,EAAEK,cADJ;AAELC,IAAAA,SAFK;AAGLC,IAAAA,iBAHK;AAILC,IAAAA,mBAJK;AAKLC,IAAAA,qBALK;AAMLC,IAAAA,WANK;AAOLC,IAAAA,4BAA4B,EAAEC,uBAPzB;AAQLC,IAAAA,kBARK;AASLC,IAAAA,iBATK;AAULC,IAAAA,mCAVK;AAWLC,IAAAA;AAXK,MAYF,oCAZJ;AAcA,QAAMC,gBAAgB,GAAG,0BAAapB,QAAb,EAAuB,CAAEG,OAAF,EAAWH,QAAX,CAAvB,CAAzB;AACA,QAAMqB,sBAAsB,GAAG,0BAAajB,cAAb,EAA6B,CAC3DD,OAD2D,EAE3DC,cAF2D,CAA7B,CAA/B;AAIA,QAAMkB,eAAe,GAAG,0BAAad,cAAb,CAAxB;AAEA,QAAMe,gBAAgB,GACrBf,cAAc,KAAKL,OA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AKf,KAAtB,IAA+BiB,kCADhC;AAEA,WAAOc,EAAE,CACRG,MAAM,CAACI,cADC,EAERL,gBAFQ,EAGRpC,SAHQ,EAIRuC,cAJQ,EAKRC,aALQ,CAAT;AAOA,GAhBe,EAgBb,CACFP,OADE,EAEFjB,uBAFE,EAGFhB,SAHE,EAIFkC,EAJE,EAKFjB,kBALE,EAMFC,iBANE,EAOFC,mCAPE,EAQFC,kCARE,EASFjB,KATE,CAhBa,CAAhB;AA4BA,SAAO,EACN,GAAGK,UADG;AAENyB,IAAAA,OAFM;AAGNjB,IAAAA,uBAHM;AAINhB,IAAAA,SAAS,EAAEmC;AAJL,GAAP;AAMA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { usePrevious } from '@wordpress/compose';\nimport { useCallback, useEffect, useMemo } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport * as styles from '../styles';\nimport { useToolsPanelContext } from '../context';\nimport { useContextSystem, WordPressComponentProps } from '../../ui/context';\nimport { useCx } from '../../utils/hooks/use-cx';\nimport type { ToolsPanelItemProps } from '../types';\n\nconst noop = () => {};\n\nexport function useToolsPanelItem(\n\tprops: WordPressComponentProps< ToolsPanelItemProps, 'div' >\n) {\n\tconst {\n\t\tclassName,\n\t\thasValue,\n\t\tisShownByDefault = false,\n\t\tlabel,\n\t\tpanelId,\n\t\tresetAllFilter = noop,\n\t\tonDeselect,\n\t\tonSelect,\n\t\t...otherProps\n\t} = useContextSystem( props, 'ToolsPanelItem' );\n\n\tconst {\n\t\tpanelId: currentPanelId,\n\t\tmenuItems,\n\t\tregisterPanelItem,\n\t\tderegisterPanelItem,\n\t\tflagItemCustomization,\n\t\tisResetting,\n\t\tshouldRenderPlaceholderItems: shouldRenderPlaceholder,\n\t\tfirstDisplayedItem,\n\t\tlastDisplayedItem,\n\t\t__experimentalFirstVisibleItemClass,\n\t\t__experimentalLastVisibleItemClass,\n\t} = useToolsPanelContext();\n\n\tconst hasValueCallback = useCallback( hasValue, [ panelId, hasValue ] );\n\tconst resetAllFilterCallback = useCallback( resetAllFilter, [\n\t\tpanelId,\n\t\tresetAllFilter,\n\t] );\n\tconst previousPanelId = usePrevious( currentPanelId );\n\n\tconst hasMatchingPanel =\n\t\tcurrentPanelId === panelId || currentPanelId === null;\n\n\t// Registering the panel item allows the panel to include it in its\n\t// automatically generated menu and determine its initial checked status.\n\tuseEffect( () => {\n\t\tif ( hasMatchingPanel && previousPanelId !== null ) {\n\t\t\tregisterPanelItem( {\n\t\t\t\thasValue: hasValueCallback,\n\t\t\t\tisShownByDefault,\n\t\t\t\tlabel,\n\t\t\t\tresetAllFilter: resetAllFilterCallback,\n\t\t\t\tpanelId,\n\t\t\t} );\n\t\t}\n\n\t\treturn () => {\n\t\t\tif (\n\t\t\t\t( previousPanelId === null && !! currentPanelId ) ||\n\t\t\t\tcurrentPanelId === panelId\n\t\t\t) {\n\t\t\t\tderegisterPanelItem( label );\n\t\t\t}\n\t\t};\n\t}, [\n\t\tcurrentPanelId,\n\t\thasMatchingPanel,\n\t\tisShownByDefault,\n\t\tlabel,\n\t\thasValueCallback,\n\t\tpanelId,\n\t\tpreviousPanelId,\n\t\tresetAllFilterCallback,\n\t\tregisterPanelItem,\n\t\tderegisterPanelItem,\n\t] );\n\n\t// Note: `label` is used as a key when building menu item state in\n\t// `ToolsPanel`.\n\tconst menuGroup = isShownByDefault ? 'default' : 'optional';\n\tconst isMenuItemChecked = menuItems?.[ menuGroup ]?.[ label ];\n\tconst wasMenuItemChecked = usePrevious( isMenuItemChecked );\n\tconst isRegistered = menuItems?.[ menuGroup ]?.[ label ] !== undefined;\n\n\tconst isValueSet = hasValue();\n\tconst wasValueSet = usePrevious( isValueSet );\n\tconst newValueSet = isValueSet && ! wasValueSet;\n\n\t// Notify the panel when an item's value has been set.\n\t//\n\t// 1. For default controls, this is so \"reset\" appears beside its menu item.\n\t// 2. For optional controls, when the panel ID is `null`, it allows the\n\t// panel to ensure the item is toggled on for display in the menu, given the\n\t// value has been set external to the control.\n\tuseEffect( () => {\n\t\tif ( ! newValueSet ) {\n\t\t\treturn;\n\t\t}\n\n\t\tif ( isShownByDefault || currentPanelId === null ) {\n\t\t\tflagItemCustomization( label, menuGroup );\n\t\t}\n\t}, [\n\t\tcurrentPanelId,\n\t\tnewValueSet,\n\t\tisShownByDefault,\n\t\tmenuGroup,\n\t\tlabel,\n\t\tflagItemCustomization,\n\t] );\n\n\t// Determine if the panel item's corresponding menu is being toggled and\n\t// trigger appropriate callback if it is.\n\tuseEffect( () => {\n\t\t// We check whether this item is currently registered as items rendered\n\t\t// via fills can persist through the parent panel being remounted.\n\t\t// See: https://github.com/WordPress/gutenberg/pull/45673\n\t\tif ( ! isRegistered || isResetting || ! hasMatchingPanel ) {\n\t\t\treturn;\n\t\t}\n\n\t\tif ( isMenuItemChecked && ! isValueSet && ! wasMenuItemChecked ) {\n\t\t\tonSelect?.();\n\t\t}\n\n\t\tif ( ! isMenuItemChecked && wasMenuItemChecked ) {\n\t\t\tonDeselect?.();\n\t\t}\n\t}, [\n\t\thasMatchingPanel,\n\t\tisMenuItemChecked,\n\t\tisRegistered,\n\t\tisResetting,\n\t\tisValueSet,\n\t\twasMenuItemChecked,\n\t\tonSelect,\n\t\tonDeselect,\n\t] );\n\n\t// The item is shown if it is a default control regardless of whether it\n\t// has a value. Optional items are shown when they are checked or have\n\t// a value.\n\tconst isShown = isShownByDefault\n\t\t? menuItems?.[ menuGroup ]?.[ label ] !== undefined\n\t\t: isMenuItemChecked;\n\n\tconst cx = useCx();\n\tconst classes = useMemo( () => {\n\t\tconst placeholderStyle =\n\t\t\tshouldRenderPlaceholder &&\n\t\t\t! isShown &&\n\t\t\tstyles.ToolsPanelItemPlaceholder;\n\t\tconst firstItemStyle =\n\t\t\tfirstDisplayedItem === label && __experimentalFirstVisibleItemClass;\n\t\tconst lastItemStyle =\n\t\t\tlastDisplayedItem === label && __experimentalLastVisibleItemClass;\n\t\treturn cx(\n\t\t\tstyles.ToolsPanelItem,\n\t\t\tplaceholderStyle,\n\t\t\tclassName,\n\t\t\tfirstItemStyle,\n\t\t\tlastItemStyle\n\t\t);\n\t}, [\n\t\tisShown,\n\t\tshouldRenderPlaceholder,\n\t\tclassName,\n\t\tcx,\n\t\tfirstDisplayedItem,\n\t\tlastDisplayedItem,\n\t\t__experimentalFirstVisibleItemClass,\n\t\t__experimentalLastVisibleItemClass,\n\t\tlabel,\n\t] );\n\n\treturn {\n\t\t...otherProps,\n\t\tisShown,\n\t\tshouldRenderPlaceholder,\n\t\tclassName: classes,\n\t};\n}\n"]}
@@ -5,7 +5,7 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
5
5
  Object.defineProperty(exports, "__esModule", {
6
6
  value: true
7
7
  });
8
- exports.default = void 0;
8
+ exports.default = exports.TreeGridCell = void 0;
9
9
 
10
10
  var _element = require("@wordpress/element");
11
11
 
@@ -20,7 +20,7 @@ var _item = _interopRequireDefault(require("./item"));
20
20
  /**
21
21
  * Internal dependencies
22
22
  */
23
- var _default = (0, _element.forwardRef)(function TreeGridCell(_ref, ref) {
23
+ function UnforwardedTreeGridCell(_ref, ref) {
24
24
  let {
25
25
  children,
26
26
  withoutGridItem = false,
@@ -28,10 +28,21 @@ var _default = (0, _element.forwardRef)(function TreeGridCell(_ref, ref) {
28
28
  } = _ref;
29
29
  return (0, _element.createElement)("td", (0, _extends2.default)({}, props, {
30
30
  role: "gridcell"
31
- }), withoutGridItem ? children : (0, _element.createElement)(_item.default, {
31
+ }), withoutGridItem ? (0, _element.createElement)(_element.Fragment, null, children) : (0, _element.createElement)(_item.default, {
32
32
  ref: ref
33
33
  }, children));
34
- });
34
+ }
35
+ /**
36
+ * `TreeGridCell` is used to create a tree hierarchy.
37
+ * It is not a visually styled component, but instead helps with adding
38
+ * keyboard navigation and roving tab index behaviors to tree grid structures.
39
+ *
40
+ * @see {@link https://www.w3.org/TR/wai-aria-practices/examples/treegrid/treegrid-1.html}
41
+ */
42
+
35
43
 
44
+ const TreeGridCell = (0, _element.forwardRef)(UnforwardedTreeGridCell);
45
+ exports.TreeGridCell = TreeGridCell;
46
+ var _default = TreeGridCell;
36
47
  exports.default = _default;
37
48
  //# sourceMappingURL=cell.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/components/src/tree-grid/cell.js"],"names":["TreeGridCell","ref","children","withoutGridItem","props"],"mappings":";;;;;;;;;AAGA;;;;AAKA;;AARA;AACA;AACA;;AAGA;AACA;AACA;eAGe,yBAAY,SAASA,YAAT,OAE1BC,GAF0B,EAGzB;AAAA,MAFD;AAAEC,IAAAA,QAAF;AAAYC,IAAAA,eAAe,GAAG,KAA9B;AAAqC,OAAGC;AAAxC,GAEC;AACD,SACC,6DAASA,KAAT;AAAiB,IAAA,IAAI,EAAC;AAAtB,MACGD,eAAe,GAChBD,QADgB,GAGhB,4BAAC,aAAD;AAAc,IAAA,GAAG,EAAGD;AAApB,KAA4BC,QAA5B,CAJF,CADD;AASA,CAbc,C","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { forwardRef } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport TreeGridItem from './item';\n\nexport default forwardRef( function TreeGridCell(\n\t{ children, withoutGridItem = false, ...props },\n\tref\n) {\n\treturn (\n\t\t<td { ...props } role=\"gridcell\">\n\t\t\t{ withoutGridItem ? (\n\t\t\t\tchildren\n\t\t\t) : (\n\t\t\t\t<TreeGridItem ref={ ref }>{ children }</TreeGridItem>\n\t\t\t) }\n\t\t</td>\n\t);\n} );\n"]}
1
+ {"version":3,"sources":["@wordpress/components/src/tree-grid/cell.tsx"],"names":["UnforwardedTreeGridCell","ref","children","withoutGridItem","props","TreeGridCell"],"mappings":";;;;;;;;;AAGA;;;;AAKA;;AARA;AACA;AACA;;AAGA;AACA;AACA;AAKA,SAASA,uBAAT,OAMCC,GAND,EAOE;AAAA,MAND;AACCC,IAAAA,QADD;AAECC,IAAAA,eAAe,GAAG,KAFnB;AAGC,OAAGC;AAHJ,GAMC;AACD,SACC,6DAASA,KAAT;AAAiB,IAAA,IAAI,EAAC;AAAtB,MACGD,eAAe,GAChB,qDAAID,QAAJ,CADgB,GAGhB,4BAAC,aAAD;AAAc,IAAA,GAAG,EAAGD;AAApB,KAA4BC,QAA5B,CAJF,CADD;AASA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;;;AACO,MAAMG,YAAY,GAAG,yBAAYL,uBAAZ,CAArB;;eAEQK,Y","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { forwardRef } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport TreeGridItem from './item';\nimport type { WordPressComponentProps } from '../ui/context';\nimport type { TreeGridCellProps } from './types';\n\nfunction UnforwardedTreeGridCell(\n\t{\n\t\tchildren,\n\t\twithoutGridItem = false,\n\t\t...props\n\t}: WordPressComponentProps< TreeGridCellProps, 'td', false >,\n\tref: React.ForwardedRef< any >\n) {\n\treturn (\n\t\t<td { ...props } role=\"gridcell\">\n\t\t\t{ withoutGridItem ? (\n\t\t\t\t<>{ children }</>\n\t\t\t) : (\n\t\t\t\t<TreeGridItem ref={ ref }>{ children }</TreeGridItem>\n\t\t\t) }\n\t\t</td>\n\t);\n}\n\n/**\n * `TreeGridCell` is used to create a tree hierarchy.\n * It is not a visually styled component, but instead helps with adding\n * keyboard navigation and roving tab index behaviors to tree grid structures.\n *\n * @see {@link https://www.w3.org/TR/wai-aria-practices/examples/treegrid/treegrid-1.html}\n */\nexport const TreeGridCell = forwardRef( UnforwardedTreeGridCell );\n\nexport default TreeGridCell;\n"]}
@@ -5,6 +5,7 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
5
5
  Object.defineProperty(exports, "__esModule", {
6
6
  value: true
7
7
  });
8
+ exports.TreeGrid = void 0;
8
9
  Object.defineProperty(exports, "TreeGridCell", {
9
10
  enumerable: true,
10
11
  get: function () {
@@ -53,19 +54,15 @@ var _item = _interopRequireDefault(require("./item"));
53
54
  * Return focusables in a row element, excluding those from other branches
54
55
  * nested within the row.
55
56
  *
56
- * @param {Element} rowElement The DOM element representing the row.
57
+ * @param rowElement The DOM element representing the row.
57
58
  *
58
- * @return {Array | undefined} The array of focusables in the row.
59
+ * @return The array of focusables in the row.
59
60
  */
60
61
  function getRowFocusables(rowElement) {
61
62
  const focusablesInRow = _dom.focus.focusable.find(rowElement, {
62
63
  sequential: true
63
64
  });
64
65
 
65
- if (!focusablesInRow || !focusablesInRow.length) {
66
- return;
67
- }
68
-
69
66
  return focusablesInRow.filter(focusable => {
70
67
  return focusable.closest('[role="row"]') === rowElement;
71
68
  });
@@ -73,18 +70,12 @@ function getRowFocusables(rowElement) {
73
70
  /**
74
71
  * Renders both a table and tbody element, used to create a tree hierarchy.
75
72
  *
76
- * @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/components/src/tree-grid/README.md
77
- * @param {Object} props Component props.
78
- * @param {WPElement} props.children Children to be rendered.
79
- * @param {Function} props.onExpandRow Callback to fire when row is expanded.
80
- * @param {Function} props.onCollapseRow Callback to fire when row is collapsed.
81
- * @param {Function} props.onFocusRow Callback to fire when moving focus to a different row.
82
- * @param {string} props.applicationAriaLabel Label to use for the application role.
83
- * @param {Object} ref A ref to the underlying DOM table element.
84
73
  */
85
74
 
86
75
 
87
- function TreeGrid(_ref, ref) {
76
+ function UnforwardedTreeGrid(_ref,
77
+ /** A ref to the underlying DOM table element. */
78
+ ref) {
88
79
  let {
89
80
  children,
90
81
  onExpandRow = () => {},
@@ -117,12 +108,17 @@ function TreeGrid(_ref, ref) {
117
108
  currentTarget: treeGridElement
118
109
  } = event;
119
110
 
120
- if (!treeGridElement.contains(activeElement)) {
111
+ if (!activeElement || !treeGridElement.contains(activeElement)) {
121
112
  return;
122
113
  } // Calculate the columnIndex of the active element.
123
114
 
124
115
 
125
116
  const activeRow = activeElement.closest('[role="row"]');
117
+
118
+ if (!activeRow) {
119
+ return;
120
+ }
121
+
126
122
  const focusablesInRow = getRowFocusables(activeRow);
127
123
  const currentColumnIndex = focusablesInRow.indexOf(activeElement);
128
124
  const canExpandCollapse = 0 === currentColumnIndex;
@@ -153,13 +149,15 @@ function TreeGrid(_ref, ref) {
153
149
  } // If a row is focused, and it is collapsed, moves to the parent row (if there is one).
154
150
 
155
151
 
156
- const level = Math.max(parseInt((_activeRow$getAttribu = activeRow === null || activeRow === void 0 ? void 0 : activeRow.getAttribute('aria-level')) !== null && _activeRow$getAttribu !== void 0 ? _activeRow$getAttribu : 1, 10) - 1, 1);
152
+ const level = Math.max(parseInt((_activeRow$getAttribu = activeRow === null || activeRow === void 0 ? void 0 : activeRow.getAttribute('aria-level')) !== null && _activeRow$getAttribu !== void 0 ? _activeRow$getAttribu : '1', 10) - 1, 1);
157
153
  const rows = Array.from(treeGridElement.querySelectorAll('[role="row"]'));
158
154
  let parentRow = activeRow;
159
155
  const currentRowIndex = rows.indexOf(activeRow);
160
156
 
161
157
  for (let i = currentRowIndex; i >= 0; i--) {
162
- if (parseInt(rows[i].getAttribute('aria-level'), 10) === level) {
158
+ const ariaLevel = rows[i].getAttribute('aria-level');
159
+
160
+ if (ariaLevel !== null && parseInt(ariaLevel, 10) === level) {
163
161
  parentRow = rows[i];
164
162
  break;
165
163
  }
@@ -301,8 +299,72 @@ function TreeGrid(_ref, ref) {
301
299
  }), (0, _element.createElement)("tbody", null, children))));
302
300
  /* eslint-enable jsx-a11y/no-noninteractive-element-to-interactive-role */
303
301
  }
302
+ /**
303
+ * `TreeGrid` is used to create a tree hierarchy.
304
+ * It is not a visually styled component, but instead helps with adding
305
+ * keyboard navigation and roving tab index behaviors to tree grid structures.
306
+ *
307
+ * A tree grid is a hierarchical 2 dimensional UI component, for example it could be
308
+ * used to implement a file system browser.
309
+ *
310
+ * A tree grid allows the user to navigate using arrow keys.
311
+ * Up/down to navigate vertically across rows, and left/right to navigate horizontally
312
+ * between focusables in a row.
313
+ *
314
+ * The `TreeGrid` renders both a `table` and `tbody` element, and is intended to be used
315
+ * with `TreeGridRow` (`tr`) and `TreeGridCell` (`td`) to build out a grid.
316
+ *
317
+ * ```jsx
318
+ * function TreeMenu() {
319
+ * return (
320
+ * <TreeGrid>
321
+ * <TreeGridRow level={ 1 } positionInSet={ 1 } setSize={ 2 }>
322
+ * <TreeGridCell>
323
+ * { ( props ) => (
324
+ * <Button onClick={ onSelect } { ...props }>Select</Button>
325
+ * ) }
326
+ * </TreeGridCell>
327
+ * <TreeGridCell>
328
+ * { ( props ) => (
329
+ * <Button onClick={ onMove } { ...props }>Move</Button>
330
+ * ) }
331
+ * </TreeGridCell>
332
+ * </TreeGridRow>
333
+ * <TreeGridRow level={ 1 } positionInSet={ 2 } setSize={ 2 }>
334
+ * <TreeGridCell>
335
+ * { ( props ) => (
336
+ * <Button onClick={ onSelect } { ...props }>Select</Button>
337
+ * ) }
338
+ * </TreeGridCell>
339
+ * <TreeGridCell>
340
+ * { ( props ) => (
341
+ * <Button onClick={ onMove } { ...props }>Move</Button>
342
+ * ) }
343
+ * </TreeGridCell>
344
+ * </TreeGridRow>
345
+ * <TreeGridRow level={ 2 } positionInSet={ 1 } setSize={ 1 }>
346
+ * <TreeGridCell>
347
+ * { ( props ) => (
348
+ * <Button onClick={ onSelect } { ...props }>Select</Button>
349
+ * ) }
350
+ * </TreeGridCell>
351
+ * <TreeGridCell>
352
+ * { ( props ) => (
353
+ * <Button onClick={ onMove } { ...props }>Move</Button>
354
+ * ) }
355
+ * </TreeGridCell>
356
+ * </TreeGridRow>
357
+ * </TreeGrid>
358
+ * );
359
+ * }
360
+ * ```
361
+ *
362
+ * @see {@link https://www.w3.org/TR/wai-aria-practices/examples/treegrid/treegrid-1.html}
363
+ */
304
364
 
305
- var _default = (0, _element.forwardRef)(TreeGrid);
306
365
 
366
+ const TreeGrid = (0, _element.forwardRef)(UnforwardedTreeGrid);
367
+ exports.TreeGrid = TreeGrid;
368
+ var _default = TreeGrid;
307
369
  exports.default = _default;
308
370
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/components/src/tree-grid/index.js"],"names":["getRowFocusables","rowElement","focusablesInRow","focus","focusable","find","sequential","length","filter","closest","TreeGrid","ref","children","onExpandRow","onCollapseRow","onFocusRow","applicationAriaLabel","props","onKeyDown","event","keyCode","metaKey","ctrlKey","altKey","hasModifierKeyPressed","UP","DOWN","LEFT","RIGHT","HOME","END","includes","stopPropagation","activeElement","document","currentTarget","treeGridElement","contains","activeRow","currentColumnIndex","indexOf","canExpandCollapse","cannotFocusNextColumn","getAttribute","nextIndex","Math","max","min","preventDefault","level","parseInt","rows","Array","from","querySelectorAll","parentRow","currentRowIndex","i","focusableItems","nextRowIndex","focusablesInNextRow"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AAIA;;;;AADA;;AAEA;;AAKA;;AA2SA;;AACA;;AACA;;AAvTA;AACA;AACA;;AAKA;AACA;AACA;;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAASA,gBAAT,CAA2BC,UAA3B,EAAwC;AACvC,QAAMC,eAAe,GAAGC,WAAMC,SAAN,CAAgBC,IAAhB,CAAsBJ,UAAtB,EAAkC;AACzDK,IAAAA,UAAU,EAAE;AAD6C,GAAlC,CAAxB;;AAIA,MAAK,CAAEJ,eAAF,IAAqB,CAAEA,eAAe,CAACK,MAA5C,EAAqD;AACpD;AACA;;AAED,SAAOL,eAAe,CAACM,MAAhB,CAA0BJ,SAAF,IAAiB;AAC/C,WAAOA,SAAS,CAACK,OAAV,CAAmB,cAAnB,MAAwCR,UAA/C;AACA,GAFM,CAAP;AAGA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AACA,SAASS,QAAT,OASCC,GATD,EAUE;AAAA,MATD;AACCC,IAAAA,QADD;AAECC,IAAAA,WAAW,GAAG,MAAM,CAAE,CAFvB;AAGCC,IAAAA,aAAa,GAAG,MAAM,CAAE,CAHzB;AAICC,IAAAA,UAAU,GAAG,MAAM,CAAE,CAJtB;AAKCC,IAAAA,oBALD;AAMC,OAAGC;AANJ,GASC;AACD,QAAMC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A,OArB8C,CAuB/C;;;AACA,YAAMY,mBAAmB,GAAG5D,gBAAgB,CAC3CmD,IAAI,CAAEQ,YAAF,CADuC,CAA5C,CAxB+C,CA4B/C;;AACA,UAAK,CAAEC,mBAAF,IAAyB,CAAEA,mBAAmB,CAACrD,MAApD,EAA6D;AAC5D;AACA;AACA;AACAY,QAAAA,KAAK,CAAC6B,cAAN;AACA;AACA,OAnC8C,CAqC/C;;;AACA,YAAMJ,SAAS,GAAGC,IAAI,CAACE,GAAL,CACjBR,kBADiB,EAEjBqB,mBAAmB,CAACrD,MAApB,GAA6B,CAFZ,CAAlB;AAIAqD,MAAAA,mBAAmB,CAAEhB,SAAF,CAAnB,CAAiCzC,KAAjC,GA1C+C,CA4C/C;AACA;;AACAY,MAAAA,UAAU,CAAEI,KAAF,EAASmB,SAAT,EAAoBa,IAAI,CAAEQ,YAAF,CAAxB,CAAV,CA9C+C,CAgD/C;AACA;;AACAxC,MAAAA,KAAK,CAAC6B,cAAN;AACA;AACD,GA/NgB,EAgOjB,CAAEnC,WAAF,EAAeC,aAAf,EAA8BC,UAA9B,CAhOiB,CAAlB;AAmOA;;AACA;;AACA,SACC,4BAAC,uBAAD,QAMC;AAAK,IAAA,IAAI,EAAC,aAAV;AAAwB,kBAAaC;AAArC,KACC,gEACMC,KADN;AAEC,IAAA,IAAI,EAAC,UAFN;AAGC,IAAA,SAAS,EAAGC,SAHb;AAIC,IAAA,GAAG,EAAGP;AAJP,MAMC,2CAASC,QAAT,CAND,CADD,CAND,CADD;AAmBA;AACA;;eAEc,yBAAYF,QAAZ,C","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { focus } from '@wordpress/dom';\nimport { forwardRef, useCallback } from '@wordpress/element';\nimport { UP, DOWN, LEFT, RIGHT, HOME, END } from '@wordpress/keycodes';\n\n/**\n * Internal dependencies\n */\nimport RovingTabIndexContainer from './roving-tab-index';\n\n/**\n * Return focusables in a row element, excluding those from other branches\n * nested within the row.\n *\n * @param {Element} rowElement The DOM element representing the row.\n *\n * @return {Array | undefined} The array of focusables in the row.\n */\nfunction getRowFocusables( rowElement ) {\n\tconst focusablesInRow = focus.focusable.find( rowElement, {\n\t\tsequential: true,\n\t} );\n\n\tif ( ! focusablesInRow || ! focusablesInRow.length ) {\n\t\treturn;\n\t}\n\n\treturn focusablesInRow.filter( ( focusable ) => {\n\t\treturn focusable.closest( '[role=\"row\"]' ) === rowElement;\n\t} );\n}\n\n/**\n * Renders both a table and tbody element, used to create a tree hierarchy.\n *\n * @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/components/src/tree-grid/README.md\n * @param {Object} props Component props.\n * @param {WPElement} props.children Children to be rendered.\n * @param {Function} props.onExpandRow Callback to fire when row is expanded.\n * @param {Function} props.onCollapseRow Callback to fire when row is collapsed.\n * @param {Function} props.onFocusRow Callback to fire when moving focus to a different row.\n * @param {string} props.applicationAriaLabel Label to use for the application role.\n * @param {Object} ref A ref to the underlying DOM table element.\n */\nfunction TreeGrid(\n\t{\n\t\tchildren,\n\t\tonExpandRow = () => {},\n\t\tonCollapseRow = () => {},\n\t\tonFocusRow = () => {},\n\t\tapplicationAriaLabel,\n\t\t...props\n\t},\n\tref\n) {\n\tconst onKeyDown = useCallback(\n\t\t( event ) => {\n\t\t\tconst { keyCode, metaKey, ctrlKey, altKey } = event;\n\n\t\t\t// The shift key is intentionally absent from the following list,\n\t\t\t// to enable shift + up/down to select items from the list.\n\t\t\tconst hasModifierKeyPressed = metaKey || ctrlKey || altKey;\n\n\t\t\tif (\n\t\t\t\thasModifierKeyPressed ||\n\t\t\t\t! [ UP, DOWN, LEFT, RIGHT, HOME, END ].includes( keyCode )\n\t\t\t) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\t// The event will be handled, stop propagation.\n\t\t\tevent.stopPropagation();\n\n\t\t\tconst { activeElement } = document;\n\t\t\tconst { currentTarget: treeGridElement } = event;\n\t\t\tif ( ! treeGridElement.contains( activeElement ) ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\t// Calculate the columnIndex of the active element.\n\t\t\tconst activeRow = activeElement.closest( '[role=\"row\"]' );\n\t\t\tconst focusablesInRow = getRowFocusables( activeRow );\n\t\t\tconst currentColumnIndex = focusablesInRow.indexOf( activeElement );\n\t\t\tconst canExpandCollapse = 0 === currentColumnIndex;\n\t\t\tconst cannotFocusNextColumn =\n\t\t\t\tcanExpandCollapse &&\n\t\t\t\tactiveRow.getAttribute( 'aria-expanded' ) === 'false' &&\n\t\t\t\tkeyCode === RIGHT;\n\n\t\t\tif ( [ LEFT, RIGHT ].includes( keyCode ) ) {\n\t\t\t\t// Calculate to the next element.\n\t\t\t\tlet nextIndex;\n\t\t\t\tif ( keyCode === LEFT ) {\n\t\t\t\t\tnextIndex = Math.max( 0, currentColumnIndex - 1 );\n\t\t\t\t} else {\n\t\t\t\t\tnextIndex = Math.min(\n\t\t\t\t\t\tcurrentColumnIndex + 1,\n\t\t\t\t\t\tfocusablesInRow.length - 1\n\t\t\t\t\t);\n\t\t\t\t}\n\n\t\t\t\t// Focus is at the left most column.\n\t\t\t\tif ( canExpandCollapse ) {\n\t\t\t\t\tif ( keyCode === LEFT ) {\n\t\t\t\t\t\t// Left:\n\t\t\t\t\t\t// If a row is focused, and it is expanded, collapses the current row.\n\t\t\t\t\t\tif (\n\t\t\t\t\t\t\tactiveRow.getAttribute( 'aria-expanded' ) === 'true'\n\t\t\t\t\t\t) {\n\t\t\t\t\t\t\tonCollapseRow( activeRow );\n\t\t\t\t\t\t\tevent.preventDefault();\n\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t}\n\t\t\t\t\t\t// If a row is focused, and it is collapsed, moves to the parent row (if there is one).\n\t\t\t\t\t\tconst level = Math.max(\n\t\t\t\t\t\t\tparseInt(\n\t\t\t\t\t\t\t\tactiveRow?.getAttribute( 'aria-level' ) ?? 1,\n\t\t\t\t\t\t\t\t10\n\t\t\t\t\t\t\t) - 1,\n\t\t\t\t\t\t\t1\n\t\t\t\t\t\t);\n\t\t\t\t\t\tconst rows = Array.from(\n\t\t\t\t\t\t\ttreeGridElement.querySelectorAll( '[role=\"row\"]' )\n\t\t\t\t\t\t);\n\t\t\t\t\t\tlet parentRow = activeRow;\n\t\t\t\t\t\tconst currentRowIndex = rows.indexOf( activeRow );\n\t\t\t\t\t\tfor ( let i = currentRowIndex; i >= 0; i-- ) {\n\t\t\t\t\t\t\tif (\n\t\t\t\t\t\t\t\tparseInt(\n\t\t\t\t\t\t\t\t\trows[ i ].getAttribute( 'aria-level' ),\n\t\t\t\t\t\t\t\t\t10\n\t\t\t\t\t\t\t\t) === level\n\t\t\t\t\t\t\t) {\n\t\t\t\t\t\t\t\tparentRow = rows[ i ];\n\t\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t\tgetRowFocusables( parentRow )?.[ 0 ]?.focus();\n\t\t\t\t\t}\n\t\t\t\t\tif ( keyCode === RIGHT ) {\n\t\t\t\t\t\t// Right:\n\t\t\t\t\t\t// If a row is focused, and it is collapsed, expands the current row.\n\t\t\t\t\t\tif (\n\t\t\t\t\t\t\tactiveRow.getAttribute( 'aria-expanded' ) ===\n\t\t\t\t\t\t\t'false'\n\t\t\t\t\t\t) {\n\t\t\t\t\t\t\tonExpandRow( activeRow );\n\t\t\t\t\t\t\tevent.preventDefault();\n\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t}\n\t\t\t\t\t\t// If a row is focused, and it is expanded, focuses the next cell in the row.\n\t\t\t\t\t\tconst focusableItems = getRowFocusables( activeRow );\n\t\t\t\t\t\tif ( focusableItems.length > 0 ) {\n\t\t\t\t\t\t\tfocusableItems[ nextIndex ]?.focus();\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\t// Prevent key use for anything else. For example, Voiceover\n\t\t\t\t\t// will start reading text on continued use of left/right arrow\n\t\t\t\t\t// keys.\n\t\t\t\t\tevent.preventDefault();\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\t// Focus the next element. If at most left column and row is collapsed, moving right is not allowed as this will expand. However, if row is collapsed, moving left is allowed.\n\t\t\t\tif ( cannotFocusNextColumn ) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tfocusablesInRow[ nextIndex ].focus();\n\n\t\t\t\t// Prevent key use for anything else. This ensures Voiceover\n\t\t\t\t// doesn't try to handle key navigation.\n\t\t\t\tevent.preventDefault();\n\t\t\t} else if ( [ UP, DOWN ].includes( keyCode ) ) {\n\t\t\t\t// Calculate the rowIndex of the next row.\n\t\t\t\tconst rows = Array.from(\n\t\t\t\t\ttreeGridElement.querySelectorAll( '[role=\"row\"]' )\n\t\t\t\t);\n\t\t\t\tconst currentRowIndex = rows.indexOf( activeRow );\n\t\t\t\tlet nextRowIndex;\n\n\t\t\t\tif ( keyCode === UP ) {\n\t\t\t\t\tnextRowIndex = Math.max( 0, currentRowIndex - 1 );\n\t\t\t\t} else {\n\t\t\t\t\tnextRowIndex = Math.min(\n\t\t\t\t\t\tcurrentRowIndex + 1,\n\t\t\t\t\t\trows.length - 1\n\t\t\t\t\t);\n\t\t\t\t}\n\n\t\t\t\t// Focus is either at the top or bottom edge of the grid. Do nothing.\n\t\t\t\tif ( nextRowIndex === currentRowIndex ) {\n\t\t\t\t\t// Prevent key use for anything else. For example, Voiceover\n\t\t\t\t\t// will start navigating horizontally when reaching the vertical\n\t\t\t\t\t// bounds of a table.\n\t\t\t\t\tevent.preventDefault();\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\t// Get the focusables in the next row.\n\t\t\t\tconst focusablesInNextRow = getRowFocusables(\n\t\t\t\t\trows[ nextRowIndex ]\n\t\t\t\t);\n\n\t\t\t\t// If for some reason there are no focusables in the next row, do nothing.\n\t\t\t\tif ( ! focusablesInNextRow || ! focusablesInNextRow.length ) {\n\t\t\t\t\t// Prevent key use for anything else. For example, Voiceover\n\t\t\t\t\t// will still focus text when using arrow keys, while this\n\t\t\t\t\t// component should limit navigation to focusables.\n\t\t\t\t\tevent.preventDefault();\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\t// Try to focus the element in the next row that's at a similar column to the activeElement.\n\t\t\t\tconst nextIndex = Math.min(\n\t\t\t\t\tcurrentColumnIndex,\n\t\t\t\t\tfocusablesInNextRow.length - 1\n\t\t\t\t);\n\t\t\t\tfocusablesInNextRow[ nextIndex ].focus();\n\n\t\t\t\t// Let consumers know the row that was originally focused,\n\t\t\t\t// and the row that is now in focus.\n\t\t\t\tonFocusRow( event, activeRow, rows[ nextRowIndex ] );\n\n\t\t\t\t// Prevent key use for anything else. This ensures Voiceover\n\t\t\t\t// doesn't try to handle key navigation.\n\t\t\t\tevent.preventDefault();\n\t\t\t} else if ( [ HOME, END ].includes( keyCode ) ) {\n\t\t\t\t// Calculate the rowIndex of the next row.\n\t\t\t\tconst rows = Array.from(\n\t\t\t\t\ttreeGridElement.querySelectorAll( '[role=\"row\"]' )\n\t\t\t\t);\n\t\t\t\tconst currentRowIndex = rows.indexOf( activeRow );\n\t\t\t\tlet nextRowIndex;\n\n\t\t\t\tif ( keyCode === HOME ) {\n\t\t\t\t\tnextRowIndex = 0;\n\t\t\t\t} else {\n\t\t\t\t\tnextRowIndex = rows.length - 1;\n\t\t\t\t}\n\n\t\t\t\t// Focus is either at the top or bottom edge of the grid. Do nothing.\n\t\t\t\tif ( nextRowIndex === currentRowIndex ) {\n\t\t\t\t\t// Prevent key use for anything else. For example, Voiceover\n\t\t\t\t\t// will start navigating horizontally when reaching the vertical\n\t\t\t\t\t// bounds of a table.\n\t\t\t\t\tevent.preventDefault();\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\t// Get the focusables in the next row.\n\t\t\t\tconst focusablesInNextRow = getRowFocusables(\n\t\t\t\t\trows[ nextRowIndex ]\n\t\t\t\t);\n\n\t\t\t\t// If for some reason there are no focusables in the next row, do nothing.\n\t\t\t\tif ( ! focusablesInNextRow || ! focusablesInNextRow.length ) {\n\t\t\t\t\t// Prevent key use for anything else. For example, Voiceover\n\t\t\t\t\t// will still focus text when using arrow keys, while this\n\t\t\t\t\t// component should limit navigation to focusables.\n\t\t\t\t\tevent.preventDefault();\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\t// Try to focus the element in the next row that's at a similar column to the activeElement.\n\t\t\t\tconst nextIndex = Math.min(\n\t\t\t\t\tcurrentColumnIndex,\n\t\t\t\t\tfocusablesInNextRow.length - 1\n\t\t\t\t);\n\t\t\t\tfocusablesInNextRow[ nextIndex ].focus();\n\n\t\t\t\t// Let consumers know the row that was originally focused,\n\t\t\t\t// and the row that is now in focus.\n\t\t\t\tonFocusRow( event, activeRow, rows[ nextRowIndex ] );\n\n\t\t\t\t// Prevent key use for anything else. This ensures Voiceover\n\t\t\t\t// doesn't try to handle key navigation.\n\t\t\t\tevent.preventDefault();\n\t\t\t}\n\t\t},\n\t\t[ onExpandRow, onCollapseRow, onFocusRow ]\n\t);\n\n\t/* Disable reason: A treegrid is implemented using a table element. */\n\t/* eslint-disable jsx-a11y/no-noninteractive-element-to-interactive-role */\n\treturn (\n\t\t<RovingTabIndexContainer>\n\t\t\t{\n\t\t\t\t// Prevent browser mode from triggering in NVDA by wrapping List View\n\t\t\t\t// in a role=application wrapper.\n\t\t\t\t// see: https://github.com/WordPress/gutenberg/issues/43729\n\t\t\t }\n\t\t\t<div role=\"application\" aria-label={ applicationAriaLabel }>\n\t\t\t\t<table\n\t\t\t\t\t{ ...props }\n\t\t\t\t\trole=\"treegrid\"\n\t\t\t\t\tonKeyDown={ onKeyDown }\n\t\t\t\t\tref={ ref }\n\t\t\t\t>\n\t\t\t\t\t<tbody>{ children }</tbody>\n\t\t\t\t</table>\n\t\t\t</div>\n\t\t</RovingTabIndexContainer>\n\t);\n\t/* eslint-enable jsx-a11y/no-noninteractive-element-to-interactive-role */\n}\n\nexport default forwardRef( TreeGrid );\nexport { default as TreeGridRow } from './row';\nexport { default as TreeGridCell } from './cell';\nexport { default as TreeGridItem } from './item';\n"]}
1
+ {"version":3,"sources":["@wordpress/components/src/tree-grid/index.tsx"],"names":["getRowFocusables","rowElement","focusablesInRow","focus","focusable","find","sequential","filter","closest","UnforwardedTreeGrid","ref","children","onExpandRow","onCollapseRow","onFocusRow","applicationAriaLabel","props","onKeyDown","event","keyCode","metaKey","ctrlKey","altKey","hasModifierKeyPressed","UP","DOWN","LEFT","RIGHT","HOME","END","includes","stopPropagation","activeElement","document","currentTarget","treeGridElement","contains","activeRow","currentColumnIndex","indexOf","canExpandCollapse","cannotFocusNextColumn","getAttribute","nextIndex","Math","max","min","length","preventDefault","level","parseInt","rows","Array","from","querySelectorAll","parentRow","currentRowIndex","i","ariaLevel","focusableItems","nextRowIndex","focusablesInNextRow","TreeGrid"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAIA;;;;AADA;;AAEA;;AAKA;;AAuXA;;AACA;;AACA;;AAnYA;AACA;AACA;;AAKA;AACA;AACA;;AAKA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAASA,gBAAT,CAA2BC,UAA3B,EAAqD;AACpD,QAAMC,eAAe,GAAGC,WAAMC,SAAN,CAAgBC,IAAhB,CAAsBJ,UAAtB,EAAkC;AACzDK,IAAAA,UAAU,EAAE;AAD6C,GAAlC,CAAxB;;AAIA,SAAOJ,eAAe,CAACK,MAAhB,CAA0BH,SAAF,IAAiB;AAC/C,WAAOA,SAAS,CAACI,OAAV,CAAmB,cAAnB,MAAwCP,UAA/C;AACA,GAFM,CAAP;AAGA;AAED;AACA;AACA;AACA;;;AACA,SAASQ,mBAAT;AASC;AACAC,GAVD,EAWE;AAAA,MAVD;AACCC,IAAAA,QADD;AAECC,IAAAA,WAAW,GAAG,MAAM,CAAE,CAFvB;AAGCC,IAAAA,aAAa,GAAG,MAAM,CAAE,CAHzB;AAICC,IAAAA,UAAU,GAAG,MAAM,CAAE,CAJtB;AAKCC,IAAAA,oBALD;AAMC,OAAGC;AANJ,GAUC;AACD,QAAMC,SAAS,GAAG,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AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AACO,MAAMmD,QAAQ,GAAG,yBAAYrD,mBAAZ,CAAjB;;eAEQqD,Q","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { focus } from '@wordpress/dom';\nimport { forwardRef, useCallback } from '@wordpress/element';\nimport { UP, DOWN, LEFT, RIGHT, HOME, END } from '@wordpress/keycodes';\n\n/**\n * Internal dependencies\n */\nimport RovingTabIndexContainer from './roving-tab-index';\nimport type { TreeGridProps } from './types';\nimport type { WordPressComponentProps } from '../ui/context';\n\n/**\n * Return focusables in a row element, excluding those from other branches\n * nested within the row.\n *\n * @param rowElement The DOM element representing the row.\n *\n * @return The array of focusables in the row.\n */\nfunction getRowFocusables( rowElement: HTMLElement ) {\n\tconst focusablesInRow = focus.focusable.find( rowElement, {\n\t\tsequential: true,\n\t} );\n\n\treturn focusablesInRow.filter( ( focusable ) => {\n\t\treturn focusable.closest( '[role=\"row\"]' ) === rowElement;\n\t} );\n}\n\n/**\n * Renders both a table and tbody element, used to create a tree hierarchy.\n *\n */\nfunction UnforwardedTreeGrid(\n\t{\n\t\tchildren,\n\t\tonExpandRow = () => {},\n\t\tonCollapseRow = () => {},\n\t\tonFocusRow = () => {},\n\t\tapplicationAriaLabel,\n\t\t...props\n\t}: WordPressComponentProps< TreeGridProps, 'table', false >,\n\t/** A ref to the underlying DOM table element. */\n\tref: React.ForwardedRef< HTMLTableElement >\n) {\n\tconst onKeyDown = useCallback(\n\t\t( event: React.KeyboardEvent< HTMLTableElement > ) => {\n\t\t\tconst { keyCode, metaKey, ctrlKey, altKey } = event;\n\n\t\t\t// The shift key is intentionally absent from the following list,\n\t\t\t// to enable shift + up/down to select items from the list.\n\t\t\tconst hasModifierKeyPressed = metaKey || ctrlKey || altKey;\n\n\t\t\tif (\n\t\t\t\thasModifierKeyPressed ||\n\t\t\t\t! ( [ UP, DOWN, LEFT, RIGHT, HOME, END ] as number[] ).includes(\n\t\t\t\t\tkeyCode\n\t\t\t\t)\n\t\t\t) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\t// The event will be handled, stop propagation.\n\t\t\tevent.stopPropagation();\n\n\t\t\tconst { activeElement } = document;\n\t\t\tconst { currentTarget: treeGridElement } = event;\n\n\t\t\tif (\n\t\t\t\t! activeElement ||\n\t\t\t\t! treeGridElement.contains( activeElement )\n\t\t\t) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\t// Calculate the columnIndex of the active element.\n\t\t\tconst activeRow =\n\t\t\t\tactiveElement.closest< HTMLElement >( '[role=\"row\"]' );\n\n\t\t\tif ( ! activeRow ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst focusablesInRow = getRowFocusables( activeRow );\n\t\t\tconst currentColumnIndex = focusablesInRow.indexOf(\n\t\t\t\tactiveElement as HTMLElement\n\t\t\t);\n\t\t\tconst canExpandCollapse = 0 === currentColumnIndex;\n\t\t\tconst cannotFocusNextColumn =\n\t\t\t\tcanExpandCollapse &&\n\t\t\t\tactiveRow.getAttribute( 'aria-expanded' ) === 'false' &&\n\t\t\t\tkeyCode === RIGHT;\n\n\t\t\tif ( ( [ LEFT, RIGHT ] as number[] ).includes( keyCode ) ) {\n\t\t\t\t// Calculate to the next element.\n\t\t\t\tlet nextIndex;\n\t\t\t\tif ( keyCode === LEFT ) {\n\t\t\t\t\tnextIndex = Math.max( 0, currentColumnIndex - 1 );\n\t\t\t\t} else {\n\t\t\t\t\tnextIndex = Math.min(\n\t\t\t\t\t\tcurrentColumnIndex + 1,\n\t\t\t\t\t\tfocusablesInRow.length - 1\n\t\t\t\t\t);\n\t\t\t\t}\n\n\t\t\t\t// Focus is at the left most column.\n\t\t\t\tif ( canExpandCollapse ) {\n\t\t\t\t\tif ( keyCode === LEFT ) {\n\t\t\t\t\t\t// Left:\n\t\t\t\t\t\t// If a row is focused, and it is expanded, collapses the current row.\n\t\t\t\t\t\tif (\n\t\t\t\t\t\t\tactiveRow.getAttribute( 'aria-expanded' ) === 'true'\n\t\t\t\t\t\t) {\n\t\t\t\t\t\t\tonCollapseRow( activeRow );\n\t\t\t\t\t\t\tevent.preventDefault();\n\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t}\n\t\t\t\t\t\t// If a row is focused, and it is collapsed, moves to the parent row (if there is one).\n\t\t\t\t\t\tconst level = Math.max(\n\t\t\t\t\t\t\tparseInt(\n\t\t\t\t\t\t\t\tactiveRow?.getAttribute( 'aria-level' ) ?? '1',\n\t\t\t\t\t\t\t\t10\n\t\t\t\t\t\t\t) - 1,\n\t\t\t\t\t\t\t1\n\t\t\t\t\t\t);\n\t\t\t\t\t\tconst rows = Array.from(\n\t\t\t\t\t\t\ttreeGridElement.querySelectorAll< HTMLElement >(\n\t\t\t\t\t\t\t\t'[role=\"row\"]'\n\t\t\t\t\t\t\t)\n\t\t\t\t\t\t);\n\t\t\t\t\t\tlet parentRow = activeRow;\n\t\t\t\t\t\tconst currentRowIndex = rows.indexOf( activeRow );\n\t\t\t\t\t\tfor ( let i = currentRowIndex; i >= 0; i-- ) {\n\t\t\t\t\t\t\tconst ariaLevel =\n\t\t\t\t\t\t\t\trows[ i ].getAttribute( 'aria-level' );\n\n\t\t\t\t\t\t\tif (\n\t\t\t\t\t\t\t\tariaLevel !== null &&\n\t\t\t\t\t\t\t\tparseInt( ariaLevel, 10 ) === level\n\t\t\t\t\t\t\t) {\n\t\t\t\t\t\t\t\tparentRow = rows[ i ];\n\t\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t\tgetRowFocusables( parentRow )?.[ 0 ]?.focus();\n\t\t\t\t\t}\n\t\t\t\t\tif ( keyCode === RIGHT ) {\n\t\t\t\t\t\t// Right:\n\t\t\t\t\t\t// If a row is focused, and it is collapsed, expands the current row.\n\t\t\t\t\t\tif (\n\t\t\t\t\t\t\tactiveRow.getAttribute( 'aria-expanded' ) ===\n\t\t\t\t\t\t\t'false'\n\t\t\t\t\t\t) {\n\t\t\t\t\t\t\tonExpandRow( activeRow );\n\t\t\t\t\t\t\tevent.preventDefault();\n\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t}\n\t\t\t\t\t\t// If a row is focused, and it is expanded, focuses the next cell in the row.\n\t\t\t\t\t\tconst focusableItems = getRowFocusables( activeRow );\n\t\t\t\t\t\tif ( focusableItems.length > 0 ) {\n\t\t\t\t\t\t\tfocusableItems[ nextIndex ]?.focus();\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\t// Prevent key use for anything else. For example, Voiceover\n\t\t\t\t\t// will start reading text on continued use of left/right arrow\n\t\t\t\t\t// keys.\n\t\t\t\t\tevent.preventDefault();\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\t// Focus the next element. If at most left column and row is collapsed, moving right is not allowed as this will expand. However, if row is collapsed, moving left is allowed.\n\t\t\t\tif ( cannotFocusNextColumn ) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tfocusablesInRow[ nextIndex ].focus();\n\n\t\t\t\t// Prevent key use for anything else. This ensures Voiceover\n\t\t\t\t// doesn't try to handle key navigation.\n\t\t\t\tevent.preventDefault();\n\t\t\t} else if ( ( [ UP, DOWN ] as number[] ).includes( keyCode ) ) {\n\t\t\t\t// Calculate the rowIndex of the next row.\n\t\t\t\tconst rows = Array.from(\n\t\t\t\t\ttreeGridElement.querySelectorAll< HTMLElement >(\n\t\t\t\t\t\t'[role=\"row\"]'\n\t\t\t\t\t)\n\t\t\t\t);\n\t\t\t\tconst currentRowIndex = rows.indexOf( activeRow );\n\t\t\t\tlet nextRowIndex;\n\n\t\t\t\tif ( keyCode === UP ) {\n\t\t\t\t\tnextRowIndex = Math.max( 0, currentRowIndex - 1 );\n\t\t\t\t} else {\n\t\t\t\t\tnextRowIndex = Math.min(\n\t\t\t\t\t\tcurrentRowIndex + 1,\n\t\t\t\t\t\trows.length - 1\n\t\t\t\t\t);\n\t\t\t\t}\n\n\t\t\t\t// Focus is either at the top or bottom edge of the grid. Do nothing.\n\t\t\t\tif ( nextRowIndex === currentRowIndex ) {\n\t\t\t\t\t// Prevent key use for anything else. For example, Voiceover\n\t\t\t\t\t// will start navigating horizontally when reaching the vertical\n\t\t\t\t\t// bounds of a table.\n\t\t\t\t\tevent.preventDefault();\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\t// Get the focusables in the next row.\n\t\t\t\tconst focusablesInNextRow = getRowFocusables(\n\t\t\t\t\trows[ nextRowIndex ]\n\t\t\t\t);\n\n\t\t\t\t// If for some reason there are no focusables in the next row, do nothing.\n\t\t\t\tif ( ! focusablesInNextRow || ! focusablesInNextRow.length ) {\n\t\t\t\t\t// Prevent key use for anything else. For example, Voiceover\n\t\t\t\t\t// will still focus text when using arrow keys, while this\n\t\t\t\t\t// component should limit navigation to focusables.\n\t\t\t\t\tevent.preventDefault();\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\t// Try to focus the element in the next row that's at a similar column to the activeElement.\n\t\t\t\tconst nextIndex = Math.min(\n\t\t\t\t\tcurrentColumnIndex,\n\t\t\t\t\tfocusablesInNextRow.length - 1\n\t\t\t\t);\n\t\t\t\tfocusablesInNextRow[ nextIndex ].focus();\n\n\t\t\t\t// Let consumers know the row that was originally focused,\n\t\t\t\t// and the row that is now in focus.\n\t\t\t\tonFocusRow( event, activeRow, rows[ nextRowIndex ] );\n\n\t\t\t\t// Prevent key use for anything else. This ensures Voiceover\n\t\t\t\t// doesn't try to handle key navigation.\n\t\t\t\tevent.preventDefault();\n\t\t\t} else if ( ( [ HOME, END ] as number[] ).includes( keyCode ) ) {\n\t\t\t\t// Calculate the rowIndex of the next row.\n\t\t\t\tconst rows = Array.from(\n\t\t\t\t\ttreeGridElement.querySelectorAll< HTMLElement >(\n\t\t\t\t\t\t'[role=\"row\"]'\n\t\t\t\t\t)\n\t\t\t\t);\n\t\t\t\tconst currentRowIndex = rows.indexOf( activeRow );\n\t\t\t\tlet nextRowIndex;\n\n\t\t\t\tif ( keyCode === HOME ) {\n\t\t\t\t\tnextRowIndex = 0;\n\t\t\t\t} else {\n\t\t\t\t\tnextRowIndex = rows.length - 1;\n\t\t\t\t}\n\n\t\t\t\t// Focus is either at the top or bottom edge of the grid. Do nothing.\n\t\t\t\tif ( nextRowIndex === currentRowIndex ) {\n\t\t\t\t\t// Prevent key use for anything else. For example, Voiceover\n\t\t\t\t\t// will start navigating horizontally when reaching the vertical\n\t\t\t\t\t// bounds of a table.\n\t\t\t\t\tevent.preventDefault();\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\t// Get the focusables in the next row.\n\t\t\t\tconst focusablesInNextRow = getRowFocusables(\n\t\t\t\t\trows[ nextRowIndex ]\n\t\t\t\t);\n\n\t\t\t\t// If for some reason there are no focusables in the next row, do nothing.\n\t\t\t\tif ( ! focusablesInNextRow || ! focusablesInNextRow.length ) {\n\t\t\t\t\t// Prevent key use for anything else. For example, Voiceover\n\t\t\t\t\t// will still focus text when using arrow keys, while this\n\t\t\t\t\t// component should limit navigation to focusables.\n\t\t\t\t\tevent.preventDefault();\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\t// Try to focus the element in the next row that's at a similar column to the activeElement.\n\t\t\t\tconst nextIndex = Math.min(\n\t\t\t\t\tcurrentColumnIndex,\n\t\t\t\t\tfocusablesInNextRow.length - 1\n\t\t\t\t);\n\t\t\t\tfocusablesInNextRow[ nextIndex ].focus();\n\n\t\t\t\t// Let consumers know the row that was originally focused,\n\t\t\t\t// and the row that is now in focus.\n\t\t\t\tonFocusRow( event, activeRow, rows[ nextRowIndex ] );\n\n\t\t\t\t// Prevent key use for anything else. This ensures Voiceover\n\t\t\t\t// doesn't try to handle key navigation.\n\t\t\t\tevent.preventDefault();\n\t\t\t}\n\t\t},\n\t\t[ onExpandRow, onCollapseRow, onFocusRow ]\n\t);\n\n\t/* Disable reason: A treegrid is implemented using a table element. */\n\t/* eslint-disable jsx-a11y/no-noninteractive-element-to-interactive-role */\n\treturn (\n\t\t<RovingTabIndexContainer>\n\t\t\t{\n\t\t\t\t// Prevent browser mode from triggering in NVDA by wrapping List View\n\t\t\t\t// in a role=application wrapper.\n\t\t\t\t// see: https://github.com/WordPress/gutenberg/issues/43729\n\t\t\t }\n\t\t\t<div role=\"application\" aria-label={ applicationAriaLabel }>\n\t\t\t\t<table\n\t\t\t\t\t{ ...props }\n\t\t\t\t\trole=\"treegrid\"\n\t\t\t\t\tonKeyDown={ onKeyDown }\n\t\t\t\t\tref={ ref }\n\t\t\t\t>\n\t\t\t\t\t<tbody>{ children }</tbody>\n\t\t\t\t</table>\n\t\t\t</div>\n\t\t</RovingTabIndexContainer>\n\t);\n\t/* eslint-enable jsx-a11y/no-noninteractive-element-to-interactive-role */\n}\n\n/**\n * `TreeGrid` is used to create a tree hierarchy.\n * It is not a visually styled component, but instead helps with adding\n * keyboard navigation and roving tab index behaviors to tree grid structures.\n *\n * A tree grid is a hierarchical 2 dimensional UI component, for example it could be\n * used to implement a file system browser.\n *\n * A tree grid allows the user to navigate using arrow keys.\n * Up/down to navigate vertically across rows, and left/right to navigate horizontally\n * between focusables in a row.\n *\n * The `TreeGrid` renders both a `table` and `tbody` element, and is intended to be used\n * with `TreeGridRow` (`tr`) and `TreeGridCell` (`td`) to build out a grid.\n *\n * ```jsx\n * function TreeMenu() {\n * \treturn (\n * \t\t<TreeGrid>\n * \t\t\t<TreeGridRow level={ 1 } positionInSet={ 1 } setSize={ 2 }>\n * \t\t\t\t<TreeGridCell>\n * \t\t\t\t\t{ ( props ) => (\n * \t\t\t\t\t\t<Button onClick={ onSelect } { ...props }>Select</Button>\n * \t\t\t\t\t) }\n * \t\t\t\t</TreeGridCell>\n * \t\t\t\t<TreeGridCell>\n * \t\t\t\t\t{ ( props ) => (\n * \t\t\t\t\t\t<Button onClick={ onMove } { ...props }>Move</Button>\n * \t\t\t\t\t) }\n * \t\t\t\t</TreeGridCell>\n * \t\t\t</TreeGridRow>\n * \t\t\t<TreeGridRow level={ 1 } positionInSet={ 2 } setSize={ 2 }>\n * \t\t\t\t<TreeGridCell>\n * \t\t\t\t\t{ ( props ) => (\n * \t\t\t\t\t\t<Button onClick={ onSelect } { ...props }>Select</Button>\n * \t\t\t\t\t) }\n * \t\t\t\t</TreeGridCell>\n * \t\t\t\t<TreeGridCell>\n * \t\t\t\t\t{ ( props ) => (\n * \t\t\t\t\t\t<Button onClick={ onMove } { ...props }>Move</Button>\n * \t\t\t\t\t) }\n * \t\t\t\t</TreeGridCell>\n * \t\t\t</TreeGridRow>\n * \t\t\t<TreeGridRow level={ 2 } positionInSet={ 1 } setSize={ 1 }>\n * \t\t\t\t<TreeGridCell>\n * \t\t\t\t\t{ ( props ) => (\n * \t\t\t\t\t\t<Button onClick={ onSelect } { ...props }>Select</Button>\n * \t\t\t\t\t) }\n * \t\t\t\t</TreeGridCell>\n * \t\t\t\t<TreeGridCell>\n * \t\t\t\t\t{ ( props ) => (\n * \t\t\t\t\t\t<Button onClick={ onMove } { ...props }>Move</Button>\n * \t\t\t\t\t) }\n * \t\t\t\t</TreeGridCell>\n * \t\t\t</TreeGridRow>\n * \t\t</TreeGrid>\n * \t);\n * }\n * ```\n *\n * @see {@link https://www.w3.org/TR/wai-aria-practices/examples/treegrid/treegrid-1.html}\n */\nexport const TreeGrid = forwardRef( UnforwardedTreeGrid );\n\nexport default TreeGrid;\nexport { default as TreeGridRow } from './row';\nexport { default as TreeGridCell } from './cell';\nexport { default as TreeGridItem } from './item';\n"]}
@@ -5,7 +5,7 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
5
5
  Object.defineProperty(exports, "__esModule", {
6
6
  value: true
7
7
  });
8
- exports.default = void 0;
8
+ exports.default = exports.TreeGridItem = void 0;
9
9
 
10
10
  var _element = require("@wordpress/element");
11
11
 
@@ -20,7 +20,7 @@ var _rovingTabIndexItem = _interopRequireDefault(require("./roving-tab-index-ite
20
20
  /**
21
21
  * Internal dependencies
22
22
  */
23
- var _default = (0, _element.forwardRef)(function TreeGridItem(_ref, ref) {
23
+ function UnforwardedTreeGridItem(_ref, ref) {
24
24
  let {
25
25
  children,
26
26
  ...props
@@ -28,7 +28,18 @@ var _default = (0, _element.forwardRef)(function TreeGridItem(_ref, ref) {
28
28
  return (0, _element.createElement)(_rovingTabIndexItem.default, (0, _extends2.default)({
29
29
  ref: ref
30
30
  }, props), children);
31
- });
31
+ }
32
+ /**
33
+ * `TreeGridItem` is used to create a tree hierarchy.
34
+ * It is not a visually styled component, but instead helps with adding
35
+ * keyboard navigation and roving tab index behaviors to tree grid structures.
36
+ *
37
+ * @see {@link https://www.w3.org/TR/wai-aria-practices/examples/treegrid/treegrid-1.html}
38
+ */
39
+
32
40
 
41
+ const TreeGridItem = (0, _element.forwardRef)(UnforwardedTreeGridItem);
42
+ exports.TreeGridItem = TreeGridItem;
43
+ var _default = TreeGridItem;
33
44
  exports.default = _default;
34
45
  //# sourceMappingURL=item.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/components/src/tree-grid/item.js"],"names":["TreeGridItem","ref","children","props"],"mappings":";;;;;;;;;AAGA;;;;AAKA;;AARA;AACA;AACA;;AAGA;AACA;AACA;eAGe,yBAAY,SAASA,YAAT,OAE1BC,GAF0B,EAGzB;AAAA,MAFD;AAAEC,IAAAA,QAAF;AAAY,OAAGC;AAAf,GAEC;AACD,SACC,4BAAC,2BAAD;AAAoB,IAAA,GAAG,EAAGF;AAA1B,KAAqCE,KAArC,GACGD,QADH,CADD;AAKA,CATc,C","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { forwardRef } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport RovingTabIndexItem from './roving-tab-index-item';\n\nexport default forwardRef( function TreeGridItem(\n\t{ children, ...props },\n\tref\n) {\n\treturn (\n\t\t<RovingTabIndexItem ref={ ref } { ...props }>\n\t\t\t{ children }\n\t\t</RovingTabIndexItem>\n\t);\n} );\n"]}
1
+ {"version":3,"sources":["@wordpress/components/src/tree-grid/item.tsx"],"names":["UnforwardedTreeGridItem","ref","children","props","TreeGridItem"],"mappings":";;;;;;;;;AAGA;;;;AAKA;;AARA;AACA;AACA;;AAGA;AACA;AACA;AAIA,SAASA,uBAAT,OAECC,GAFD,EAGE;AAAA,MAFD;AAAEC,IAAAA,QAAF;AAAY,OAAGC;AAAf,GAEC;AACD,SACC,4BAAC,2BAAD;AAAoB,IAAA,GAAG,EAAGF;AAA1B,KAAqCE,KAArC,GACGD,QADH,CADD;AAKA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;;;AACO,MAAME,YAAY,GAAG,yBAAYJ,uBAAZ,CAArB;;eAEQI,Y","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { forwardRef } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport RovingTabIndexItem from './roving-tab-index-item';\nimport type { RovingTabIndexItemProps } from './types';\n\nfunction UnforwardedTreeGridItem(\n\t{ children, ...props }: RovingTabIndexItemProps,\n\tref: React.ForwardedRef< any >\n) {\n\treturn (\n\t\t<RovingTabIndexItem ref={ ref } { ...props }>\n\t\t\t{ children }\n\t\t</RovingTabIndexItem>\n\t);\n}\n\n/**\n * `TreeGridItem` is used to create a tree hierarchy.\n * It is not a visually styled component, but instead helps with adding\n * keyboard navigation and roving tab index behaviors to tree grid structures.\n *\n * @see {@link https://www.w3.org/TR/wai-aria-practices/examples/treegrid/treegrid-1.html}\n */\nexport const TreeGridItem = forwardRef( UnforwardedTreeGridItem );\n\nexport default TreeGridItem;\n"]}
@@ -10,7 +10,7 @@ var _element = require("@wordpress/element");
10
10
  /**
11
11
  * WordPress dependencies
12
12
  */
13
- const RovingTabIndexContext = (0, _element.createContext)();
13
+ const RovingTabIndexContext = (0, _element.createContext)(undefined);
14
14
 
15
15
  const useRovingTabIndexContext = () => (0, _element.useContext)(RovingTabIndexContext);
16
16
 
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/components/src/tree-grid/roving-tab-index-context.js"],"names":["RovingTabIndexContext","useRovingTabIndexContext","RovingTabIndexProvider","Provider"],"mappings":";;;;;;;AAGA;;AAHA;AACA;AACA;AAGA,MAAMA,qBAAqB,GAAG,6BAA9B;;AACO,MAAMC,wBAAwB,GAAG,MACvC,yBAAYD,qBAAZ,CADM;;;AAEA,MAAME,sBAAsB,GAAGF,qBAAqB,CAACG,QAArD","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { createContext, useContext } from '@wordpress/element';\n\nconst RovingTabIndexContext = createContext();\nexport const useRovingTabIndexContext = () =>\n\tuseContext( RovingTabIndexContext );\nexport const RovingTabIndexProvider = RovingTabIndexContext.Provider;\n"]}
1
+ {"version":3,"sources":["@wordpress/components/src/tree-grid/roving-tab-index-context.ts"],"names":["RovingTabIndexContext","undefined","useRovingTabIndexContext","RovingTabIndexProvider","Provider"],"mappings":";;;;;;;AAGA;;AAHA;AACA;AACA;AAGA,MAAMA,qBAAqB,GAAG,4BAQ3BC,SAR2B,CAA9B;;AASO,MAAMC,wBAAwB,GAAG,MACvC,yBAAYF,qBAAZ,CADM;;;AAEA,MAAMG,sBAAsB,GAAGH,qBAAqB,CAACI,QAArD","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { createContext, useContext } from '@wordpress/element';\n\nconst RovingTabIndexContext = createContext<\n\t| {\n\t\t\tlastFocusedElement: HTMLElement | undefined;\n\t\t\tsetLastFocusedElement: React.Dispatch<\n\t\t\t\tReact.SetStateAction< HTMLElement | undefined >\n\t\t\t>;\n\t }\n\t| undefined\n>( undefined );\nexport const useRovingTabIndexContext = () =>\n\tuseContext( RovingTabIndexContext );\nexport const RovingTabIndexProvider = RovingTabIndexContext.Provider;\n"]}
@@ -3,7 +3,7 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.default = void 0;
6
+ exports.default = exports.RovingTabIndexItem = void 0;
7
7
 
8
8
  var _element = require("@wordpress/element");
9
9
 
@@ -16,14 +16,15 @@ var _rovingTabIndexContext = require("./roving-tab-index-context");
16
16
  /**
17
17
  * Internal dependencies
18
18
  */
19
- var _default = (0, _element.forwardRef)(function RovingTabIndexItem(_ref, forwardedRef) {
19
+ const RovingTabIndexItem = (0, _element.forwardRef)(function UnforwardedRovingTabIndexItem(_ref, forwardedRef) {
20
20
  let {
21
21
  children,
22
22
  as: Component,
23
23
  ...props
24
24
  } = _ref;
25
25
  const localRef = (0, _element.useRef)();
26
- const ref = forwardedRef || localRef;
26
+ const ref = forwardedRef || localRef; // @ts-expect-error - We actually want to throw an error if this is undefined.
27
+
27
28
  const {
28
29
  lastFocusedElement,
29
30
  setLastFocusedElement
@@ -31,10 +32,14 @@ var _default = (0, _element.forwardRef)(function RovingTabIndexItem(_ref, forwar
31
32
  let tabIndex;
32
33
 
33
34
  if (lastFocusedElement) {
34
- tabIndex = lastFocusedElement === ref.current ? 0 : -1;
35
+ tabIndex = lastFocusedElement === ( // TODO: The original implementation simply used `ref.current` here, assuming
36
+ // that a forwarded ref would always be an object, which is not necessarily true.
37
+ // This workaround maintains the original runtime behavior in a type-safe way,
38
+ // but should be revisited.
39
+ 'current' in ref ? ref.current : undefined) ? 0 : -1;
35
40
  }
36
41
 
37
- const onFocus = event => setLastFocusedElement(event.target);
42
+ const onFocus = event => setLastFocusedElement === null || setLastFocusedElement === void 0 ? void 0 : setLastFocusedElement(event.target);
38
43
 
39
44
  const allProps = {
40
45
  ref,
@@ -47,8 +52,10 @@ var _default = (0, _element.forwardRef)(function RovingTabIndexItem(_ref, forwar
47
52
  return children(allProps);
48
53
  }
49
54
 
55
+ if (!Component) return null;
50
56
  return (0, _element.createElement)(Component, allProps, children);
51
57
  });
52
-
58
+ exports.RovingTabIndexItem = RovingTabIndexItem;
59
+ var _default = RovingTabIndexItem;
53
60
  exports.default = _default;
54
61
  //# sourceMappingURL=roving-tab-index-item.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/components/src/tree-grid/roving-tab-index-item.js"],"names":["RovingTabIndexItem","forwardedRef","children","as","Component","props","localRef","ref","lastFocusedElement","setLastFocusedElement","tabIndex","current","onFocus","event","target","allProps"],"mappings":";;;;;;;AAGA;;AAKA;;AARA;AACA;AACA;;AAGA;AACA;AACA;eAGe,yBAAY,SAASA,kBAAT,OAE1BC,YAF0B,EAGzB;AAAA,MAFD;AAAEC,IAAAA,QAAF;AAAYC,IAAAA,EAAE,EAAEC,SAAhB;AAA2B,OAAGC;AAA9B,GAEC;AACD,QAAMC,QAAQ,GAAG,sBAAjB;AACA,QAAMC,GAAG,GAAGN,YAAY,IAAIK,QAA5B;AACA,QAAM;AAAEE,IAAAA,kBAAF;AAAsBC,IAAAA;AAAtB,MACL,sDADD;AAEA,MAAIC,QAAJ;;AAEA,MAAKF,kBAAL,EAA0B;AACzBE,IAAAA,QAAQ,GAAGF,kBAAkB,KAAKD,GAAG,CAACI,OAA3B,GAAqC,CAArC,GAAyC,CAAC,CAArD;AACA;;AAED,QAAMC,OAAO,GAAKC,KAAF,IAAaJ,qBAAqB,CAAEI,KAAK,CAACC,MAAR,CAAlD;;AACA,QAAMC,QAAQ,GAAG;AAAER,IAAAA,GAAF;AAAOG,IAAAA,QAAP;AAAiBE,IAAAA,OAAjB;AAA0B,OAAGP;AAA7B,GAAjB;;AAEA,MAAK,OAAOH,QAAP,KAAoB,UAAzB,EAAsC;AACrC,WAAOA,QAAQ,CAAEa,QAAF,CAAf;AACA;;AAED,SAAO,4BAAC,SAAD,EAAgBA,QAAhB,EAA6Bb,QAA7B,CAAP;AACA,CAtBc,C","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useRef, forwardRef } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport { useRovingTabIndexContext } from './roving-tab-index-context';\n\nexport default forwardRef( function RovingTabIndexItem(\n\t{ children, as: Component, ...props },\n\tforwardedRef\n) {\n\tconst localRef = useRef();\n\tconst ref = forwardedRef || localRef;\n\tconst { lastFocusedElement, setLastFocusedElement } =\n\t\tuseRovingTabIndexContext();\n\tlet tabIndex;\n\n\tif ( lastFocusedElement ) {\n\t\ttabIndex = lastFocusedElement === ref.current ? 0 : -1;\n\t}\n\n\tconst onFocus = ( event ) => setLastFocusedElement( event.target );\n\tconst allProps = { ref, tabIndex, onFocus, ...props };\n\n\tif ( typeof children === 'function' ) {\n\t\treturn children( allProps );\n\t}\n\n\treturn <Component { ...allProps }>{ children }</Component>;\n} );\n"]}
1
+ {"version":3,"sources":["@wordpress/components/src/tree-grid/roving-tab-index-item.tsx"],"names":["RovingTabIndexItem","UnforwardedRovingTabIndexItem","forwardedRef","children","as","Component","props","localRef","ref","lastFocusedElement","setLastFocusedElement","tabIndex","current","undefined","onFocus","event","target","allProps"],"mappings":";;;;;;;AAGA;;AAKA;;AARA;AACA;AACA;;AAGA;AACA;AACA;AAIO,MAAMA,kBAAkB,GAAG,yBACjC,SAASC,6BAAT,OAECC,YAFD,EAGE;AAAA,MAFD;AAAEC,IAAAA,QAAF;AAAYC,IAAAA,EAAE,EAAEC,SAAhB;AAA2B,OAAGC;AAA9B,GAEC;AACD,QAAMC,QAAQ,GAAG,sBAAjB;AACA,QAAMC,GAAG,GAAGN,YAAY,IAAIK,QAA5B,CAFC,CAGD;;AACA,QAAM;AAAEE,IAAAA,kBAAF;AAAsBC,IAAAA;AAAtB,MACL,sDADD;AAEA,MAAIC,QAAJ;;AAEA,MAAKF,kBAAL,EAA0B;AACzBE,IAAAA,QAAQ,GACPF,kBAAkB,OAClB;AACA;AACA;AACA;AACE,iBAAaD,GAAb,GAAmBA,GAAG,CAACI,OAAvB,GAAiCC,SALjB,CAAlB,GAMG,CANH,GAOG,CAAC,CARL;AASA;;AAED,QAAMC,OAA+C,GAAKC,KAAF,IACvDL,qBADuD,aACvDA,qBADuD,uBACvDA,qBAAqB,CAAIK,KAAK,CAACC,MAAV,CADtB;;AAEA,QAAMC,QAAQ,GAAG;AAAET,IAAAA,GAAF;AAAOG,IAAAA,QAAP;AAAiBG,IAAAA,OAAjB;AAA0B,OAAGR;AAA7B,GAAjB;;AAEA,MAAK,OAAOH,QAAP,KAAoB,UAAzB,EAAsC;AACrC,WAAOA,QAAQ,CAAEc,QAAF,CAAf;AACA;;AAED,MAAK,CAAEZ,SAAP,EAAmB,OAAO,IAAP;AAEnB,SAAO,4BAAC,SAAD,EAAgBY,QAAhB,EAA6Bd,QAA7B,CAAP;AACA,CAnCgC,CAA3B;;eAsCQH,kB","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useRef, forwardRef } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport { useRovingTabIndexContext } from './roving-tab-index-context';\nimport type { RovingTabIndexItemProps } from './types';\n\nexport const RovingTabIndexItem = forwardRef(\n\tfunction UnforwardedRovingTabIndexItem(\n\t\t{ children, as: Component, ...props }: RovingTabIndexItemProps,\n\t\tforwardedRef: React.ForwardedRef< any >\n\t) {\n\t\tconst localRef = useRef< any >();\n\t\tconst ref = forwardedRef || localRef;\n\t\t// @ts-expect-error - We actually want to throw an error if this is undefined.\n\t\tconst { lastFocusedElement, setLastFocusedElement } =\n\t\t\tuseRovingTabIndexContext();\n\t\tlet tabIndex;\n\n\t\tif ( lastFocusedElement ) {\n\t\t\ttabIndex =\n\t\t\t\tlastFocusedElement ===\n\t\t\t\t// TODO: The original implementation simply used `ref.current` here, assuming\n\t\t\t\t// that a forwarded ref would always be an object, which is not necessarily true.\n\t\t\t\t// This workaround maintains the original runtime behavior in a type-safe way,\n\t\t\t\t// but should be revisited.\n\t\t\t\t( 'current' in ref ? ref.current : undefined )\n\t\t\t\t\t? 0\n\t\t\t\t\t: -1;\n\t\t}\n\n\t\tconst onFocus: React.FocusEventHandler< HTMLElement > = ( event ) =>\n\t\t\tsetLastFocusedElement?.( event.target );\n\t\tconst allProps = { ref, tabIndex, onFocus, ...props };\n\n\t\tif ( typeof children === 'function' ) {\n\t\t\treturn children( allProps );\n\t\t}\n\n\t\tif ( ! Component ) return null;\n\n\t\treturn <Component { ...allProps }>{ children }</Component>;\n\t}\n);\n\nexport default RovingTabIndexItem;\n"]}
@@ -21,9 +21,6 @@ var _rovingTabIndexContext = require("./roving-tab-index-context");
21
21
  * Provider for adding roving tab index behaviors to tree grid structures.
22
22
  *
23
23
  * @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/components/src/tree-grid/README.md
24
- *
25
- * @param {Object} props Component props.
26
- * @param {WPElement} props.children Children to be rendered
27
24
  */
28
25
  function RovingTabIndex(_ref) {
29
26
  let {
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/components/src/tree-grid/roving-tab-index.js"],"names":["RovingTabIndex","children","lastFocusedElement","setLastFocusedElement","providerValue"],"mappings":";;;;;;;AAGA;;AAKA;;AARA;AACA;AACA;;AAGA;AACA;AACA;;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACe,SAASA,cAAT,OAAwC;AAAA,MAAf;AAAEC,IAAAA;AAAF,GAAe;AACtD,QAAM,CAAEC,kBAAF,EAAsBC,qBAAtB,IAAgD,wBAAtD,CADsD,CAGtD;AACA;AACA;;AACA,QAAMC,aAAa,GAAG,sBACrB,OAAQ;AAAEF,IAAAA,kBAAF;AAAsBC,IAAAA;AAAtB,GAAR,CADqB,EAErB,CAAED,kBAAF,CAFqB,CAAtB;AAKA,SACC,4BAAC,6CAAD;AAAwB,IAAA,KAAK,EAAGE;AAAhC,KACGH,QADH,CADD;AAKA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useState, useMemo } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport { RovingTabIndexProvider } from './roving-tab-index-context';\n\n/**\n * Provider for adding roving tab index behaviors to tree grid structures.\n *\n * @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/components/src/tree-grid/README.md\n *\n * @param {Object} props Component props.\n * @param {WPElement} props.children Children to be rendered\n */\nexport default function RovingTabIndex( { children } ) {\n\tconst [ lastFocusedElement, setLastFocusedElement ] = useState();\n\n\t// Use `useMemo` to avoid creation of a new object for the providerValue\n\t// on every render. Only create a new object when the `lastFocusedElement`\n\t// value changes.\n\tconst providerValue = useMemo(\n\t\t() => ( { lastFocusedElement, setLastFocusedElement } ),\n\t\t[ lastFocusedElement ]\n\t);\n\n\treturn (\n\t\t<RovingTabIndexProvider value={ providerValue }>\n\t\t\t{ children }\n\t\t</RovingTabIndexProvider>\n\t);\n}\n"]}
1
+ {"version":3,"sources":["@wordpress/components/src/tree-grid/roving-tab-index.tsx"],"names":["RovingTabIndex","children","lastFocusedElement","setLastFocusedElement","providerValue"],"mappings":";;;;;;;AAGA;;AAKA;;AARA;AACA;AACA;;AAGA;AACA;AACA;;AAGA;AACA;AACA;AACA;AACA;AACe,SAASA,cAAT,OAIX;AAAA,MAJoC;AACvCC,IAAAA;AADuC,GAIpC;AACH,QAAM,CAAEC,kBAAF,EAAsBC,qBAAtB,IACL,wBADD,CADG,CAIH;AACA;AACA;;AACA,QAAMC,aAAa,GAAG,sBACrB,OAAQ;AAAEF,IAAAA,kBAAF;AAAsBC,IAAAA;AAAtB,GAAR,CADqB,EAErB,CAAED,kBAAF,CAFqB,CAAtB;AAKA,SACC,4BAAC,6CAAD;AAAwB,IAAA,KAAK,EAAGE;AAAhC,KACGH,QADH,CADD;AAKA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useState, useMemo } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport { RovingTabIndexProvider } from './roving-tab-index-context';\n\n/**\n * Provider for adding roving tab index behaviors to tree grid structures.\n *\n * @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/components/src/tree-grid/README.md\n */\nexport default function RovingTabIndex( {\n\tchildren,\n}: {\n\tchildren: React.ReactNode;\n} ) {\n\tconst [ lastFocusedElement, setLastFocusedElement ] =\n\t\tuseState< HTMLElement >();\n\n\t// Use `useMemo` to avoid creation of a new object for the providerValue\n\t// on every render. Only create a new object when the `lastFocusedElement`\n\t// value changes.\n\tconst providerValue = useMemo(\n\t\t() => ( { lastFocusedElement, setLastFocusedElement } ),\n\t\t[ lastFocusedElement ]\n\t);\n\n\treturn (\n\t\t<RovingTabIndexProvider value={ providerValue }>\n\t\t\t{ children }\n\t\t</RovingTabIndexProvider>\n\t);\n}\n"]}