@wordpress/components 19.5.0 → 19.6.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 (633) hide show
  1. package/CHANGELOG.md +23 -5
  2. package/build/alignment-matrix-control/utils.js +1 -1
  3. package/build/alignment-matrix-control/utils.js.map +1 -1
  4. package/build/angle-picker-control/angle-circle.js +1 -1
  5. package/build/angle-picker-control/angle-circle.js.map +1 -1
  6. package/build/animation/index.js +0 -6
  7. package/build/animation/index.js.map +1 -1
  8. package/build/autocomplete/get-default-use-items.js +3 -3
  9. package/build/autocomplete/get-default-use-items.js.map +1 -1
  10. package/build/base-field/hook.js +1 -1
  11. package/build/base-field/hook.js.map +1 -1
  12. package/build/box-control/icon.js +1 -1
  13. package/build/box-control/icon.js.map +1 -1
  14. package/build/box-control/index.js +4 -4
  15. package/build/box-control/index.js.map +1 -1
  16. package/build/box-control/utils.js +12 -8
  17. package/build/box-control/utils.js.map +1 -1
  18. package/build/button/index.js +5 -5
  19. package/build/button/index.js.map +1 -1
  20. package/build/button/index.native.js +7 -7
  21. package/build/button/index.native.js.map +1 -1
  22. package/build/color-picker/color-display.js +1 -1
  23. package/build/color-picker/color-display.js.map +1 -1
  24. package/build/color-picker/styles.js +8 -8
  25. package/build/color-picker/styles.js.map +1 -1
  26. package/build/combobox-control/index.js +1 -1
  27. package/build/combobox-control/index.js.map +1 -1
  28. package/build/confirm-dialog/component.js +4 -2
  29. package/build/confirm-dialog/component.js.map +1 -1
  30. package/build/date-time/time.js +7 -4
  31. package/build/date-time/time.js.map +1 -1
  32. package/build/divider/component.js +5 -4
  33. package/build/divider/component.js.map +1 -1
  34. package/build/draggable/index.js +3 -3
  35. package/build/draggable/index.js.map +1 -1
  36. package/build/focal-point-picker/index.native.js +7 -7
  37. package/build/focal-point-picker/index.native.js.map +1 -1
  38. package/build/focal-point-picker/tooltip/index.native.js +1 -1
  39. package/build/focal-point-picker/tooltip/index.native.js.map +1 -1
  40. package/build/font-size-picker/index.js +1 -1
  41. package/build/font-size-picker/index.js.map +1 -1
  42. package/build/form-token-field/index.js +6 -6
  43. package/build/form-token-field/index.js.map +1 -1
  44. package/build/form-token-field/suggestions-list.js +2 -2
  45. package/build/form-token-field/suggestions-list.js.map +1 -1
  46. package/build/heading/component.js +6 -5
  47. package/build/heading/component.js.map +1 -1
  48. package/build/heading/hook.js +1 -1
  49. package/build/heading/hook.js.map +1 -1
  50. package/build/higher-order/with-notices/index.js +1 -1
  51. package/build/higher-order/with-notices/index.js.map +1 -1
  52. package/build/index.js +2 -2
  53. package/build/index.js.map +1 -1
  54. package/build/index.native.js.map +1 -1
  55. package/build/input-control/input-base.js +1 -1
  56. package/build/input-control/input-base.js.map +1 -1
  57. package/build/input-control/input-field.js +12 -10
  58. package/build/input-control/input-field.js.map +1 -1
  59. package/build/input-control/styles/input-control-styles.js +25 -25
  60. package/build/input-control/styles/input-control-styles.js.map +1 -1
  61. package/build/isolated-event-container/index.js +1 -1
  62. package/build/isolated-event-container/index.js.map +1 -1
  63. package/build/mobile/bottom-sheet/bottom-sheet-context.native.js +4 -4
  64. package/build/mobile/bottom-sheet/bottom-sheet-context.native.js.map +1 -1
  65. package/build/mobile/bottom-sheet/bottom-sheet-navigation/navigation-container.native.js +1 -1
  66. package/build/mobile/bottom-sheet/bottom-sheet-navigation/navigation-container.native.js.map +1 -1
  67. package/build/mobile/bottom-sheet/cell.native.js +1 -1
  68. package/build/mobile/bottom-sheet/cell.native.js.map +1 -1
  69. package/build/mobile/bottom-sheet/index.native.js +11 -11
  70. package/build/mobile/bottom-sheet/index.native.js.map +1 -1
  71. package/build/mobile/bottom-sheet/link-cell.native.js +1 -1
  72. package/build/mobile/bottom-sheet/link-cell.native.js.map +1 -1
  73. package/build/mobile/bottom-sheet/link-suggestion-item-cell.native.js +1 -1
  74. package/build/mobile/bottom-sheet/link-suggestion-item-cell.native.js.map +1 -1
  75. package/build/mobile/bottom-sheet/nav-bar/back-button.native.js +1 -1
  76. package/build/mobile/bottom-sheet/nav-bar/back-button.native.js.map +1 -1
  77. package/build/mobile/global-styles-context/utils.native.js +10 -10
  78. package/build/mobile/global-styles-context/utils.native.js.map +1 -1
  79. package/build/mobile/gradient/index.native.js +2 -2
  80. package/build/mobile/gradient/index.native.js.map +1 -1
  81. package/build/mobile/html-text-input/container.ios.js +3 -3
  82. package/build/mobile/html-text-input/container.ios.js.map +1 -1
  83. package/build/mobile/html-text-input/index.native.js +1 -1
  84. package/build/mobile/html-text-input/index.native.js.map +1 -1
  85. package/build/mobile/image/index.native.js +1 -1
  86. package/build/mobile/image/index.native.js.map +1 -1
  87. package/build/mobile/keyboard-aware-flat-list/index.android.js +1 -1
  88. package/build/mobile/keyboard-aware-flat-list/index.android.js.map +1 -1
  89. package/build/mobile/keyboard-aware-flat-list/index.ios.js +2 -2
  90. package/build/mobile/keyboard-aware-flat-list/index.ios.js.map +1 -1
  91. package/build/mobile/link-picker/index.native.js +3 -3
  92. package/build/mobile/link-picker/index.native.js.map +1 -1
  93. package/build/mobile/link-picker/link-picker-results.native.js +8 -8
  94. package/build/mobile/link-picker/link-picker-results.native.js.map +1 -1
  95. package/build/mobile/link-settings/image-link-destinations-screen.native.js +2 -2
  96. package/build/mobile/link-settings/image-link-destinations-screen.native.js.map +1 -1
  97. package/build/mobile/link-settings/index.native.js +1 -1
  98. package/build/mobile/link-settings/index.native.js.map +1 -1
  99. package/build/modal/aria-helper.js +1 -1
  100. package/build/modal/aria-helper.js.map +1 -1
  101. package/build/modal/index.js +2 -2
  102. package/build/modal/index.js.map +1 -1
  103. package/build/navigable-container/container.js +2 -2
  104. package/build/navigable-container/container.js.map +1 -1
  105. package/build/navigable-container/tabbable.js +1 -1
  106. package/build/navigable-container/tabbable.js.map +1 -1
  107. package/build/navigation/item/index.js +1 -1
  108. package/build/navigation/item/index.js.map +1 -1
  109. package/build/navigation/menu/index.js +1 -1
  110. package/build/navigation/menu/index.js.map +1 -1
  111. package/build/navigator/navigator-provider/component.js +2 -2
  112. package/build/navigator/navigator-provider/component.js.map +1 -1
  113. package/build/navigator/navigator-screen/component.js +1 -1
  114. package/build/navigator/navigator-screen/component.js.map +1 -1
  115. package/build/number-control/index.js +1 -1
  116. package/build/number-control/index.js.map +1 -1
  117. package/build/panel/body.js +2 -2
  118. package/build/panel/body.js.map +1 -1
  119. package/build/popover/index.js +3 -3
  120. package/build/popover/index.js.map +1 -1
  121. package/build/popover/utils.js +6 -6
  122. package/build/popover/utils.js.map +1 -1
  123. package/build/radio-group/index.js +1 -1
  124. package/build/radio-group/index.js.map +1 -1
  125. package/build/range-control/styles/range-control-styles.js +29 -29
  126. package/build/range-control/styles/range-control-styles.js.map +1 -1
  127. package/build/sandbox/index.js +5 -5
  128. package/build/sandbox/index.js.map +1 -1
  129. package/build/sandbox/index.native.js +1 -1
  130. package/build/sandbox/index.native.js.map +1 -1
  131. package/build/select-control/index.js +1 -1
  132. package/build/select-control/index.js.map +1 -1
  133. package/build/select-control/styles/select-control-styles.js +5 -5
  134. package/build/select-control/styles/select-control-styles.js.map +1 -1
  135. package/build/slot-fill/bubbles-virtually/slot-fill-provider.js +1 -1
  136. package/build/slot-fill/bubbles-virtually/slot-fill-provider.js.map +1 -1
  137. package/build/slot-fill/bubbles-virtually/slot.js +1 -1
  138. package/build/slot-fill/bubbles-virtually/slot.js.map +1 -1
  139. package/build/slot-fill/fill.js +1 -1
  140. package/build/slot-fill/fill.js.map +1 -1
  141. package/build/slot-fill/provider.js +1 -1
  142. package/build/slot-fill/provider.js.map +1 -1
  143. package/build/snackbar/index.js +1 -1
  144. package/build/snackbar/index.js.map +1 -1
  145. package/build/snackbar/list.js +1 -1
  146. package/build/snackbar/list.js.map +1 -1
  147. package/build/style-provider/index.js +2 -2
  148. package/build/style-provider/index.js.map +1 -1
  149. package/build/toggle-group-control/toggle-group-control/component.js +2 -2
  150. package/build/toggle-group-control/toggle-group-control/component.js.map +1 -1
  151. package/build/toggle-group-control/toggle-group-control-option/component.js +1 -4
  152. package/build/toggle-group-control/toggle-group-control-option/component.js.map +1 -1
  153. package/build/toggle-group-control/toggle-group-control-option/styles.js +12 -19
  154. package/build/toggle-group-control/toggle-group-control-option/styles.js.map +1 -1
  155. package/build/toolbar/index.js +1 -1
  156. package/build/toolbar/index.js.map +1 -1
  157. package/build/tooltip/index.js +3 -3
  158. package/build/tooltip/index.js.map +1 -1
  159. package/build/tooltip/index.native.js +7 -7
  160. package/build/tooltip/index.native.js.map +1 -1
  161. package/build/tree-grid/index.js +4 -1
  162. package/build/tree-grid/index.js.map +1 -1
  163. package/build/truncate/utils.js +1 -1
  164. package/build/truncate/utils.js.map +1 -1
  165. package/build/ui/context/context-connect.js +8 -15
  166. package/build/ui/context/context-connect.js.map +1 -1
  167. package/build/ui/context/context-system-provider.js +2 -2
  168. package/build/ui/context/context-system-provider.js.map +1 -1
  169. package/build/ui/context/index.js.map +1 -1
  170. package/build/ui/utils/colors.js +2 -2
  171. package/build/ui/utils/colors.js.map +1 -1
  172. package/build/ui/utils/space.js +2 -2
  173. package/build/ui/utils/space.js.map +1 -1
  174. package/build/unit-control/index.js +38 -29
  175. package/build/unit-control/index.js.map +1 -1
  176. package/build/unit-control/index.native.js +4 -2
  177. package/build/unit-control/index.native.js.map +1 -1
  178. package/build/unit-control/unit-select-control.js +1 -1
  179. package/build/unit-control/unit-select-control.js.map +1 -1
  180. package/build/unit-control/utils.js +96 -104
  181. package/build/unit-control/utils.js.map +1 -1
  182. package/build/utils/breakpoint-values.js +1 -1
  183. package/build/utils/breakpoint-values.js.map +1 -1
  184. package/build/utils/colors-values.js +1 -1
  185. package/build/utils/colors-values.js.map +1 -1
  186. package/build-module/alignment-matrix-control/utils.js +1 -1
  187. package/build-module/alignment-matrix-control/utils.js.map +1 -1
  188. package/build-module/angle-picker-control/angle-circle.js +1 -1
  189. package/build-module/angle-picker-control/angle-circle.js.map +1 -1
  190. package/build-module/animation/index.js +1 -1
  191. package/build-module/animation/index.js.map +1 -1
  192. package/build-module/autocomplete/get-default-use-items.js +3 -3
  193. package/build-module/autocomplete/get-default-use-items.js.map +1 -1
  194. package/build-module/base-field/hook.js +1 -1
  195. package/build-module/base-field/hook.js.map +1 -1
  196. package/build-module/box-control/icon.js +1 -1
  197. package/build-module/box-control/icon.js.map +1 -1
  198. package/build-module/box-control/index.js +5 -5
  199. package/build-module/box-control/index.js.map +1 -1
  200. package/build-module/box-control/utils.js +13 -9
  201. package/build-module/box-control/utils.js.map +1 -1
  202. package/build-module/button/index.js +5 -5
  203. package/build-module/button/index.js.map +1 -1
  204. package/build-module/button/index.native.js +7 -7
  205. package/build-module/button/index.native.js.map +1 -1
  206. package/build-module/color-picker/color-display.js +1 -1
  207. package/build-module/color-picker/color-display.js.map +1 -1
  208. package/build-module/color-picker/styles.js +8 -8
  209. package/build-module/color-picker/styles.js.map +1 -1
  210. package/build-module/combobox-control/index.js +1 -1
  211. package/build-module/combobox-control/index.js.map +1 -1
  212. package/build-module/confirm-dialog/component.js +4 -5
  213. package/build-module/confirm-dialog/component.js.map +1 -1
  214. package/build-module/date-time/time.js +7 -4
  215. package/build-module/date-time/time.js.map +1 -1
  216. package/build-module/divider/component.js +3 -3
  217. package/build-module/divider/component.js.map +1 -1
  218. package/build-module/draggable/index.js +3 -3
  219. package/build-module/draggable/index.js.map +1 -1
  220. package/build-module/focal-point-picker/index.native.js +7 -7
  221. package/build-module/focal-point-picker/index.native.js.map +1 -1
  222. package/build-module/focal-point-picker/tooltip/index.native.js +1 -1
  223. package/build-module/focal-point-picker/tooltip/index.native.js.map +1 -1
  224. package/build-module/font-size-picker/index.js +1 -1
  225. package/build-module/font-size-picker/index.js.map +1 -1
  226. package/build-module/form-token-field/index.js +6 -6
  227. package/build-module/form-token-field/index.js.map +1 -1
  228. package/build-module/form-token-field/suggestions-list.js +2 -2
  229. package/build-module/form-token-field/suggestions-list.js.map +1 -1
  230. package/build-module/heading/component.js +4 -4
  231. package/build-module/heading/component.js.map +1 -1
  232. package/build-module/heading/hook.js +1 -1
  233. package/build-module/heading/hook.js.map +1 -1
  234. package/build-module/higher-order/with-notices/index.js +1 -1
  235. package/build-module/higher-order/with-notices/index.js.map +1 -1
  236. package/build-module/index.js +4 -4
  237. package/build-module/index.js.map +1 -1
  238. package/build-module/index.native.js +4 -4
  239. package/build-module/index.native.js.map +1 -1
  240. package/build-module/input-control/input-base.js +1 -1
  241. package/build-module/input-control/input-base.js.map +1 -1
  242. package/build-module/input-control/input-field.js +13 -10
  243. package/build-module/input-control/input-field.js.map +1 -1
  244. package/build-module/input-control/styles/input-control-styles.js +25 -25
  245. package/build-module/input-control/styles/input-control-styles.js.map +1 -1
  246. package/build-module/isolated-event-container/index.js +1 -1
  247. package/build-module/isolated-event-container/index.js.map +1 -1
  248. package/build-module/mobile/bottom-sheet/bottom-sheet-context.native.js +4 -4
  249. package/build-module/mobile/bottom-sheet/bottom-sheet-context.native.js.map +1 -1
  250. package/build-module/mobile/bottom-sheet/bottom-sheet-navigation/navigation-container.native.js +1 -1
  251. package/build-module/mobile/bottom-sheet/bottom-sheet-navigation/navigation-container.native.js.map +1 -1
  252. package/build-module/mobile/bottom-sheet/cell.native.js +1 -1
  253. package/build-module/mobile/bottom-sheet/cell.native.js.map +1 -1
  254. package/build-module/mobile/bottom-sheet/index.native.js +11 -11
  255. package/build-module/mobile/bottom-sheet/index.native.js.map +1 -1
  256. package/build-module/mobile/bottom-sheet/link-cell.native.js +1 -1
  257. package/build-module/mobile/bottom-sheet/link-cell.native.js.map +1 -1
  258. package/build-module/mobile/bottom-sheet/link-suggestion-item-cell.native.js +1 -1
  259. package/build-module/mobile/bottom-sheet/link-suggestion-item-cell.native.js.map +1 -1
  260. package/build-module/mobile/bottom-sheet/nav-bar/back-button.native.js +1 -1
  261. package/build-module/mobile/bottom-sheet/nav-bar/back-button.native.js.map +1 -1
  262. package/build-module/mobile/global-styles-context/utils.native.js +10 -10
  263. package/build-module/mobile/global-styles-context/utils.native.js.map +1 -1
  264. package/build-module/mobile/gradient/index.native.js +2 -2
  265. package/build-module/mobile/gradient/index.native.js.map +1 -1
  266. package/build-module/mobile/html-text-input/container.ios.js +3 -3
  267. package/build-module/mobile/html-text-input/container.ios.js.map +1 -1
  268. package/build-module/mobile/html-text-input/index.native.js +1 -1
  269. package/build-module/mobile/html-text-input/index.native.js.map +1 -1
  270. package/build-module/mobile/image/index.native.js +1 -1
  271. package/build-module/mobile/image/index.native.js.map +1 -1
  272. package/build-module/mobile/keyboard-aware-flat-list/index.android.js +1 -1
  273. package/build-module/mobile/keyboard-aware-flat-list/index.android.js.map +1 -1
  274. package/build-module/mobile/keyboard-aware-flat-list/index.ios.js +2 -2
  275. package/build-module/mobile/keyboard-aware-flat-list/index.ios.js.map +1 -1
  276. package/build-module/mobile/link-picker/index.native.js +3 -3
  277. package/build-module/mobile/link-picker/index.native.js.map +1 -1
  278. package/build-module/mobile/link-picker/link-picker-results.native.js +8 -8
  279. package/build-module/mobile/link-picker/link-picker-results.native.js.map +1 -1
  280. package/build-module/mobile/link-settings/image-link-destinations-screen.native.js +2 -2
  281. package/build-module/mobile/link-settings/image-link-destinations-screen.native.js.map +1 -1
  282. package/build-module/mobile/link-settings/index.native.js +1 -1
  283. package/build-module/mobile/link-settings/index.native.js.map +1 -1
  284. package/build-module/modal/aria-helper.js +1 -1
  285. package/build-module/modal/aria-helper.js.map +1 -1
  286. package/build-module/modal/index.js +2 -2
  287. package/build-module/modal/index.js.map +1 -1
  288. package/build-module/navigable-container/container.js +2 -2
  289. package/build-module/navigable-container/container.js.map +1 -1
  290. package/build-module/navigable-container/tabbable.js +1 -1
  291. package/build-module/navigable-container/tabbable.js.map +1 -1
  292. package/build-module/navigation/item/index.js +1 -1
  293. package/build-module/navigation/item/index.js.map +1 -1
  294. package/build-module/navigation/menu/index.js +1 -1
  295. package/build-module/navigation/menu/index.js.map +1 -1
  296. package/build-module/navigator/navigator-provider/component.js +2 -2
  297. package/build-module/navigator/navigator-provider/component.js.map +1 -1
  298. package/build-module/navigator/navigator-screen/component.js +1 -1
  299. package/build-module/navigator/navigator-screen/component.js.map +1 -1
  300. package/build-module/number-control/index.js +1 -1
  301. package/build-module/number-control/index.js.map +1 -1
  302. package/build-module/panel/body.js +2 -2
  303. package/build-module/panel/body.js.map +1 -1
  304. package/build-module/popover/index.js +3 -3
  305. package/build-module/popover/index.js.map +1 -1
  306. package/build-module/popover/utils.js +6 -6
  307. package/build-module/popover/utils.js.map +1 -1
  308. package/build-module/radio-group/index.js +1 -1
  309. package/build-module/radio-group/index.js.map +1 -1
  310. package/build-module/range-control/styles/range-control-styles.js +29 -29
  311. package/build-module/range-control/styles/range-control-styles.js.map +1 -1
  312. package/build-module/sandbox/index.js +5 -5
  313. package/build-module/sandbox/index.js.map +1 -1
  314. package/build-module/sandbox/index.native.js +1 -1
  315. package/build-module/sandbox/index.native.js.map +1 -1
  316. package/build-module/select-control/index.js +1 -1
  317. package/build-module/select-control/index.js.map +1 -1
  318. package/build-module/select-control/styles/select-control-styles.js +5 -5
  319. package/build-module/select-control/styles/select-control-styles.js.map +1 -1
  320. package/build-module/slot-fill/bubbles-virtually/slot-fill-provider.js +1 -1
  321. package/build-module/slot-fill/bubbles-virtually/slot-fill-provider.js.map +1 -1
  322. package/build-module/slot-fill/bubbles-virtually/slot.js +1 -1
  323. package/build-module/slot-fill/bubbles-virtually/slot.js.map +1 -1
  324. package/build-module/slot-fill/fill.js +1 -1
  325. package/build-module/slot-fill/fill.js.map +1 -1
  326. package/build-module/slot-fill/provider.js +1 -1
  327. package/build-module/slot-fill/provider.js.map +1 -1
  328. package/build-module/snackbar/index.js +1 -1
  329. package/build-module/snackbar/index.js.map +1 -1
  330. package/build-module/snackbar/list.js +1 -1
  331. package/build-module/snackbar/list.js.map +1 -1
  332. package/build-module/style-provider/index.js +2 -2
  333. package/build-module/style-provider/index.js.map +1 -1
  334. package/build-module/toggle-group-control/toggle-group-control/component.js +2 -2
  335. package/build-module/toggle-group-control/toggle-group-control/component.js.map +1 -1
  336. package/build-module/toggle-group-control/toggle-group-control-option/component.js +1 -4
  337. package/build-module/toggle-group-control/toggle-group-control-option/component.js.map +1 -1
  338. package/build-module/toggle-group-control/toggle-group-control-option/styles.js +11 -17
  339. package/build-module/toggle-group-control/toggle-group-control-option/styles.js.map +1 -1
  340. package/build-module/toolbar/index.js +1 -1
  341. package/build-module/toolbar/index.js.map +1 -1
  342. package/build-module/tooltip/index.js +3 -3
  343. package/build-module/tooltip/index.js.map +1 -1
  344. package/build-module/tooltip/index.native.js +7 -7
  345. package/build-module/tooltip/index.native.js.map +1 -1
  346. package/build-module/tree-grid/index.js +4 -1
  347. package/build-module/tree-grid/index.js.map +1 -1
  348. package/build-module/truncate/utils.js +1 -1
  349. package/build-module/truncate/utils.js.map +1 -1
  350. package/build-module/ui/context/context-connect.js +9 -16
  351. package/build-module/ui/context/context-connect.js.map +1 -1
  352. package/build-module/ui/context/context-system-provider.js +2 -2
  353. package/build-module/ui/context/context-system-provider.js.map +1 -1
  354. package/build-module/ui/context/index.js.map +1 -1
  355. package/build-module/ui/utils/colors.js +2 -2
  356. package/build-module/ui/utils/colors.js.map +1 -1
  357. package/build-module/ui/utils/space.js +2 -2
  358. package/build-module/ui/utils/space.js.map +1 -1
  359. package/build-module/unit-control/index.js +39 -30
  360. package/build-module/unit-control/index.js.map +1 -1
  361. package/build-module/unit-control/index.native.js +5 -3
  362. package/build-module/unit-control/index.native.js.map +1 -1
  363. package/build-module/unit-control/unit-select-control.js +1 -1
  364. package/build-module/unit-control/unit-select-control.js.map +1 -1
  365. package/build-module/unit-control/utils.js +92 -100
  366. package/build-module/unit-control/utils.js.map +1 -1
  367. package/build-module/utils/breakpoint-values.js +1 -1
  368. package/build-module/utils/breakpoint-values.js.map +1 -1
  369. package/build-module/utils/colors-values.js +1 -1
  370. package/build-module/utils/colors-values.js.map +1 -1
  371. package/build-style/style-rtl.css +8 -0
  372. package/build-style/style.css +8 -0
  373. package/build-types/base-field/hook.d.ts +2 -1
  374. package/build-types/base-field/hook.d.ts.map +1 -1
  375. package/build-types/card/card/hook.d.ts +2 -1
  376. package/build-types/card/card/hook.d.ts.map +1 -1
  377. package/build-types/card/card-body/hook.d.ts +2 -1
  378. package/build-types/card/card-body/hook.d.ts.map +1 -1
  379. package/build-types/card/card-divider/hook.d.ts +2 -2
  380. package/build-types/card/card-footer/hook.d.ts +2 -1
  381. package/build-types/card/card-footer/hook.d.ts.map +1 -1
  382. package/build-types/card/card-header/hook.d.ts +2 -1
  383. package/build-types/card/card-header/hook.d.ts.map +1 -1
  384. package/build-types/card/card-media/hook.d.ts +2 -1
  385. package/build-types/card/card-media/hook.d.ts.map +1 -1
  386. package/build-types/color-picker/styles.d.ts +2 -2
  387. package/build-types/confirm-dialog/component.d.ts +8 -0
  388. package/build-types/confirm-dialog/component.d.ts.map +1 -1
  389. package/build-types/confirm-dialog/types.d.ts +2 -0
  390. package/build-types/confirm-dialog/types.d.ts.map +1 -1
  391. package/build-types/divider/component.d.ts +2 -2
  392. package/build-types/divider/component.d.ts.map +1 -1
  393. package/build-types/divider/stories/index.d.ts +10 -0
  394. package/build-types/divider/stories/index.d.ts.map +1 -0
  395. package/build-types/divider/types.d.ts +1 -1
  396. package/build-types/divider/types.d.ts.map +1 -1
  397. package/build-types/elevation/hook.d.ts +2 -1
  398. package/build-types/elevation/hook.d.ts.map +1 -1
  399. package/build-types/flex/flex/hook.d.ts +2 -1
  400. package/build-types/flex/flex/hook.d.ts.map +1 -1
  401. package/build-types/flex/flex-block/hook.d.ts +2 -1
  402. package/build-types/flex/flex-block/hook.d.ts.map +1 -1
  403. package/build-types/flex/flex-item/hook.d.ts +2 -1
  404. package/build-types/flex/flex-item/hook.d.ts.map +1 -1
  405. package/build-types/flyout/flyout/hook.d.ts +2 -1
  406. package/build-types/flyout/flyout/hook.d.ts.map +1 -1
  407. package/build-types/grid/hook.d.ts +2 -1
  408. package/build-types/grid/hook.d.ts.map +1 -1
  409. package/build-types/h-stack/hook.d.ts +3 -2
  410. package/build-types/h-stack/hook.d.ts.map +1 -1
  411. package/build-types/heading/component.d.ts +3 -3
  412. package/build-types/heading/component.d.ts.map +1 -1
  413. package/build-types/heading/hook.d.ts +2 -1
  414. package/build-types/heading/hook.d.ts.map +1 -1
  415. package/build-types/heading/stories/index.d.ts +12 -0
  416. package/build-types/heading/stories/index.d.ts.map +1 -0
  417. package/build-types/input-control/index.d.ts +1 -1
  418. package/build-types/input-control/index.d.ts.map +1 -1
  419. package/build-types/input-control/input-field.d.ts +1 -1
  420. package/build-types/input-control/input-field.d.ts.map +1 -1
  421. package/build-types/input-control/styles/input-control-styles.d.ts.map +1 -1
  422. package/build-types/item-group/item/hook.d.ts +2 -1
  423. package/build-types/item-group/item/hook.d.ts.map +1 -1
  424. package/build-types/item-group/item-group/hook.d.ts +2 -1
  425. package/build-types/item-group/item-group/hook.d.ts.map +1 -1
  426. package/build-types/navigator/navigator-back-button/hook.d.ts +2 -1
  427. package/build-types/navigator/navigator-back-button/hook.d.ts.map +1 -1
  428. package/build-types/navigator/navigator-button/hook.d.ts +2 -1
  429. package/build-types/navigator/navigator-button/hook.d.ts.map +1 -1
  430. package/build-types/number-control/styles/number-control-styles.d.ts +1 -1
  431. package/build-types/scrollable/hook.d.ts +2 -1
  432. package/build-types/scrollable/hook.d.ts.map +1 -1
  433. package/build-types/select-control/index.d.ts +1 -1
  434. package/build-types/select-control/index.d.ts.map +1 -1
  435. package/build-types/select-control/styles/select-control-styles.d.ts.map +1 -1
  436. package/build-types/spacer/hook.d.ts +2 -1
  437. package/build-types/spacer/hook.d.ts.map +1 -1
  438. package/build-types/surface/hook.d.ts +2 -1
  439. package/build-types/surface/hook.d.ts.map +1 -1
  440. package/build-types/text/hook.d.ts +2 -1
  441. package/build-types/text/hook.d.ts.map +1 -1
  442. package/build-types/text/types.d.ts +1 -2
  443. package/build-types/text/types.d.ts.map +1 -1
  444. package/build-types/toggle-group-control/toggle-group-control-option/component.d.ts.map +1 -1
  445. package/build-types/toggle-group-control/toggle-group-control-option/styles.d.ts +0 -4
  446. package/build-types/toggle-group-control/toggle-group-control-option/styles.d.ts.map +1 -1
  447. package/build-types/tools-panel/tools-panel/hook.d.ts +2 -1
  448. package/build-types/tools-panel/tools-panel/hook.d.ts.map +1 -1
  449. package/build-types/tools-panel/tools-panel-header/hook.d.ts +2 -1
  450. package/build-types/tools-panel/tools-panel-header/hook.d.ts.map +1 -1
  451. package/build-types/tools-panel/tools-panel-item/hook.d.ts +2 -1
  452. package/build-types/tools-panel/tools-panel-item/hook.d.ts.map +1 -1
  453. package/build-types/truncate/hook.d.ts +2 -1
  454. package/build-types/truncate/hook.d.ts.map +1 -1
  455. package/build-types/ui/context/context-connect.d.ts +18 -16
  456. package/build-types/ui/context/context-connect.d.ts.map +1 -1
  457. package/build-types/ui/context/index.d.ts +4 -4
  458. package/build-types/ui/context/index.d.ts.map +1 -1
  459. package/build-types/ui/context/wordpress-component.d.ts +1 -0
  460. package/build-types/ui/context/wordpress-component.d.ts.map +1 -1
  461. package/build-types/ui/control-group/hook.d.ts +2 -1
  462. package/build-types/ui/control-group/hook.d.ts.map +1 -1
  463. package/build-types/ui/control-label/hook.d.ts +2 -1
  464. package/build-types/ui/control-label/hook.d.ts.map +1 -1
  465. package/build-types/ui/form-group/use-form-group.d.ts +6 -4
  466. package/build-types/ui/form-group/use-form-group.d.ts.map +1 -1
  467. package/build-types/unit-control/index.d.ts +3 -3
  468. package/build-types/unit-control/index.d.ts.map +1 -1
  469. package/build-types/unit-control/types.d.ts +4 -6
  470. package/build-types/unit-control/types.d.ts.map +1 -1
  471. package/build-types/unit-control/utils.d.ts +47 -38
  472. package/build-types/unit-control/utils.d.ts.map +1 -1
  473. package/build-types/v-stack/hook.d.ts +2 -1
  474. package/build-types/v-stack/hook.d.ts.map +1 -1
  475. package/package.json +18 -18
  476. package/src/alignment-matrix-control/utils.js +1 -1
  477. package/src/angle-picker-control/angle-circle.js +1 -1
  478. package/src/animation/index.js +0 -1
  479. package/src/autocomplete/get-default-use-items.js +3 -3
  480. package/src/base-field/hook.js +1 -1
  481. package/src/box-control/icon.js +1 -1
  482. package/src/box-control/index.js +5 -5
  483. package/src/box-control/test/index.js +27 -7
  484. package/src/box-control/utils.js +13 -9
  485. package/src/button/index.js +5 -5
  486. package/src/button/index.native.js +7 -7
  487. package/src/button/style.scss +1 -0
  488. package/src/color-palette/style.scss +1 -0
  489. package/src/color-picker/color-display.tsx +1 -1
  490. package/src/color-picker/styles.ts +1 -1
  491. package/src/color-picker/test/index.js +1 -1
  492. package/src/combobox-control/index.js +1 -1
  493. package/src/combobox-control/style.scss +1 -0
  494. package/src/confirm-dialog/README.md +56 -45
  495. package/src/confirm-dialog/component.tsx +4 -2
  496. package/src/confirm-dialog/stories/index.js +19 -0
  497. package/src/confirm-dialog/test/index.js +28 -0
  498. package/src/confirm-dialog/types.ts +2 -0
  499. package/src/date-time/style.scss +4 -0
  500. package/src/date-time/time.js +16 -5
  501. package/src/dimension-control/test/index.test.js +1 -1
  502. package/src/disabled/test/index.js +1 -1
  503. package/src/divider/component.tsx +3 -3
  504. package/src/divider/stories/index.tsx +70 -0
  505. package/src/divider/types.ts +3 -1
  506. package/src/draggable/index.js +3 -3
  507. package/src/draggable/stories/index.js +1 -1
  508. package/src/flyout/flyout/README.md +1 -1
  509. package/src/flyout/test/index.js +1 -1
  510. package/src/focal-point-picker/index.native.js +7 -7
  511. package/src/focal-point-picker/tooltip/index.native.js +1 -1
  512. package/src/font-size-picker/README.md +1 -2
  513. package/src/font-size-picker/index.js +1 -1
  514. package/src/font-size-picker/stories/index.js +87 -108
  515. package/src/font-size-picker/test/index.js +0 -2
  516. package/src/form-token-field/index.js +6 -6
  517. package/src/form-token-field/style.scss +1 -0
  518. package/src/form-token-field/suggestions-list.js +2 -2
  519. package/src/form-token-field/test/index.js +6 -6
  520. package/src/heading/component.tsx +4 -4
  521. package/src/heading/hook.ts +1 -1
  522. package/src/heading/stories/index.tsx +37 -0
  523. package/src/higher-order/with-filters/test/index.js +1 -1
  524. package/src/higher-order/with-focus-outside/test/index.js +1 -1
  525. package/src/higher-order/with-notices/index.js +1 -1
  526. package/src/higher-order/with-notices/test/index.js +3 -3
  527. package/src/index.js +4 -4
  528. package/src/index.native.js +4 -4
  529. package/src/input-control/input-base.tsx +1 -1
  530. package/src/input-control/input-field.tsx +12 -9
  531. package/src/input-control/styles/input-control-styles.tsx +1 -0
  532. package/src/input-control/test/index.js +4 -4
  533. package/src/isolated-event-container/index.js +1 -1
  534. package/src/item-group/test/index.js +0 -1
  535. package/src/mobile/bottom-sheet/bottom-sheet-context.native.js +4 -4
  536. package/src/mobile/bottom-sheet/bottom-sheet-navigation/navigation-container.native.js +1 -1
  537. package/src/mobile/bottom-sheet/cell.native.js +1 -1
  538. package/src/mobile/bottom-sheet/index.native.js +11 -11
  539. package/src/mobile/bottom-sheet/link-cell.native.js +1 -1
  540. package/src/mobile/bottom-sheet/link-suggestion-item-cell.native.js +1 -1
  541. package/src/mobile/bottom-sheet/nav-bar/back-button.native.js +1 -1
  542. package/src/mobile/global-styles-context/utils.native.js +10 -10
  543. package/src/mobile/gradient/index.native.js +2 -2
  544. package/src/mobile/html-text-input/container.ios.js +3 -3
  545. package/src/mobile/html-text-input/index.native.js +1 -1
  546. package/src/mobile/html-text-input/test/index.native.js +14 -14
  547. package/src/mobile/image/index.native.js +1 -1
  548. package/src/mobile/image/style.native.scss +1 -0
  549. package/src/mobile/keyboard-aware-flat-list/index.android.js +1 -1
  550. package/src/mobile/keyboard-aware-flat-list/index.ios.js +2 -2
  551. package/src/mobile/link-picker/index.native.js +3 -3
  552. package/src/mobile/link-picker/link-picker-results.native.js +8 -8
  553. package/src/mobile/link-settings/image-link-destinations-screen.native.js +2 -2
  554. package/src/mobile/link-settings/index.native.js +1 -2
  555. package/src/mobile/link-settings/test/edit.native.js +15 -15
  556. package/src/modal/aria-helper.js +1 -1
  557. package/src/modal/index.js +2 -2
  558. package/src/navigable-container/container.js +2 -2
  559. package/src/navigable-container/tabbable.js +1 -1
  560. package/src/navigable-container/test/menu.js +5 -5
  561. package/src/navigable-container/test/tabbable.js +2 -2
  562. package/src/navigation/item/index.js +1 -1
  563. package/src/navigation/menu/index.js +1 -1
  564. package/src/navigation/stories/controlled-state.js +2 -2
  565. package/src/navigator/navigator-provider/component.tsx +1 -1
  566. package/src/navigator/navigator-screen/component.tsx +2 -2
  567. package/src/navigator/test/index.js +18 -19
  568. package/src/navigator/types.ts +1 -1
  569. package/src/number-control/index.js +1 -1
  570. package/src/panel/body.js +2 -2
  571. package/src/popover/index.js +3 -3
  572. package/src/popover/utils.js +6 -6
  573. package/src/radio-group/index.js +1 -1
  574. package/src/range-control/stories/index.js +1 -1
  575. package/src/range-control/styles/range-control-styles.js +1 -1
  576. package/src/range-control/test/index.js +2 -2
  577. package/src/sandbox/index.js +5 -5
  578. package/src/sandbox/index.native.js +1 -1
  579. package/src/select-control/index.tsx +1 -1
  580. package/src/select-control/styles/select-control-styles.ts +1 -0
  581. package/src/slot-fill/bubbles-virtually/slot-fill-provider.js +1 -1
  582. package/src/slot-fill/bubbles-virtually/slot.js +1 -2
  583. package/src/slot-fill/fill.js +1 -1
  584. package/src/slot-fill/provider.js +1 -1
  585. package/src/snackbar/index.js +1 -1
  586. package/src/snackbar/list.js +1 -1
  587. package/src/style-provider/index.js +2 -2
  588. package/src/tab-panel/test/index.js +1 -1
  589. package/src/text/test/index.js +2 -2
  590. package/src/text/types.ts +6 -8
  591. package/src/text-highlight/test/index.js +4 -4
  592. package/src/toggle-control/test/index.js +3 -3
  593. package/src/toggle-group-control/test/__snapshots__/index.js.snap +1 -27
  594. package/src/toggle-group-control/toggle-group-control/component.tsx +2 -2
  595. package/src/toggle-group-control/toggle-group-control-option/component.tsx +1 -4
  596. package/src/toggle-group-control/toggle-group-control-option/styles.ts +1 -12
  597. package/src/toolbar/index.js +1 -1
  598. package/src/toolbar-group/test/index.js +2 -2
  599. package/src/tooltip/index.js +3 -3
  600. package/src/tooltip/index.native.js +7 -7
  601. package/src/tooltip/test/index.js +2 -2
  602. package/src/tooltip/test/index.native.js +2 -2
  603. package/src/tree-grid/README.md +1 -1
  604. package/src/tree-grid/index.js +4 -0
  605. package/src/tree-grid/test/__snapshots__/index.js.snap +1 -1
  606. package/src/tree-grid/test/index.js +128 -52
  607. package/src/truncate/utils.js +1 -1
  608. package/src/ui/context/{context-connect.js → context-connect.ts} +27 -16
  609. package/src/ui/context/context-system-provider.js +2 -2
  610. package/src/ui/context/{index.js → index.ts} +0 -0
  611. package/src/ui/context/wordpress-component.ts +1 -0
  612. package/src/ui/tooltip/test/index.js +4 -4
  613. package/src/ui/utils/colors.js +2 -2
  614. package/src/ui/utils/space.ts +2 -2
  615. package/src/unit-control/README.md +1 -1
  616. package/src/unit-control/index.native.js +5 -3
  617. package/src/unit-control/index.tsx +64 -35
  618. package/src/unit-control/test/index.js +102 -3
  619. package/src/unit-control/test/utils.js +56 -15
  620. package/src/unit-control/types.ts +5 -8
  621. package/src/unit-control/unit-select-control.tsx +1 -1
  622. package/src/unit-control/utils.ts +128 -125
  623. package/src/utils/breakpoint-values.js +1 -1
  624. package/src/utils/colors-values.js +1 -1
  625. package/src/utils/hooks/test/use-controlled-state.js +1 -1
  626. package/src/utils/hooks/test/use-controlled-value.js +3 -3
  627. package/src/utils/hooks/test/use-latest-ref.js +1 -1
  628. package/src/utils/test/math.js +2 -2
  629. package/src/utils/test/rtl.js +12 -12
  630. package/tsconfig.json +1 -1
  631. package/tsconfig.tsbuildinfo +1 -1
  632. package/src/divider/stories/index.js +0 -64
  633. package/src/heading/stories/index.js +0 -24
@@ -96,7 +96,7 @@ const Tooltip = _ref => {
96
96
  const {
97
97
  onHandleScreenTouch
98
98
  } = (0, _element.useContext)(TooltipContext);
99
- const keyboardVisible = useKeyboardVisibility(); // Register callback to dismiss the tooltip whenever the screen is touched
99
+ const keyboardVisible = useKeyboardVisibility(); // Register callback to dismiss the tooltip whenever the screen is touched.
100
100
 
101
101
  (0, _element.useEffect)(() => {
102
102
  if (visible) {
@@ -107,21 +107,21 @@ const Tooltip = _ref => {
107
107
  }
108
108
 
109
109
  return () => onHandleScreenTouch(null);
110
- }, [visible]); // Manage visibility animation
110
+ }, [visible]); // Manage visibility animation.
111
111
 
112
112
  (0, _element.useEffect)(() => {
113
- if ( // Initial render and visibility enabled, animate show
113
+ if ( // Initial render and visibility enabled, animate show.
114
114
  typeof previousVisible === 'undefined' && visible || // Previously visible, animate hide
115
115
  previousVisible && previousVisible !== visible) {
116
116
  setAnimating(true);
117
117
  startAnimation();
118
118
  }
119
- }, [visible]); // Manage tooltip visibility and position in relation to keyboard
119
+ }, [visible]); // Manage tooltip visibility and position in relation to keyboard.
120
120
 
121
121
  (0, _element.useEffect)(() => {
122
122
  if (!visible) {
123
123
  return;
124
- } // Update tooltip position if keyboard is visible
124
+ } // Update tooltip position if keyboard is visible.
125
125
 
126
126
 
127
127
  if (keyboardVisible) {
@@ -133,7 +133,7 @@ const Tooltip = _ref => {
133
133
  setAnimating(true);
134
134
  setVisible(false);
135
135
  }
136
- }, [visible, keyboardVisible]); // Manage tooltip position during keyboard frame changes
136
+ }, [visible, keyboardVisible]); // Manage tooltip position during keyboard frame changes.
137
137
 
138
138
  (0, _element.useEffect)(() => {
139
139
  const frameListener = _reactNative.Keyboard.addListener('keyboardWillChangeFrame', () => {
@@ -242,7 +242,7 @@ const TooltipSlot = _ref3 => {
242
242
  const [handleScreenTouch, setHandleScreenTouch] = (0, _element.useState)(null);
243
243
 
244
244
  const onHandleScreenTouch = callback => {
245
- // Must use function to set state below as `callback` is a function itself
245
+ // Must use function to set state below as `callback` is a function itself.
246
246
  setHandleScreenTouch(() => callback);
247
247
  };
248
248
 
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/components/src/tooltip/index.native.js"],"names":["RIGHT_ALIGN_ARROW_OFFSET","TOOLTIP_VERTICAL_OFFSET","TooltipContext","onHandleScreenTouch","Fill","Slot","useKeyboardVisibility","keyboardVisible","setKeyboardVisible","previousKeyboardVisible","showListener","Keyboard","addListener","keyboardHideEvent","Platform","select","android","ios","hideListener","remove","Tooltip","children","position","text","visible","initialVisible","referenceElementRef","animationValue","Animated","Value","current","horizontalPosition","split","setVisible","animating","setAnimating","hidden","previousVisible","referenceLayout","setReferenceLayout","height","width","x","y","tooltipLayout","setTooltipLayout","startAnimation","getReferenceElementPosition","frameListener","timing","toValue","duration","useNativeDriver","delay","easing","Easing","out","quad","start","tooltipStyles","styles","tooltip","left","Math","floor","top","tooltipBoxStyles","tooltip__box","elevation","opacity","shadowColor","tooltip__shadow","color","shadowOffset","shadowOpacity","shadowRadius","transform","translateY","interpolate","inputRange","outputRange","arrowStyles","tooltip__arrow","requestAnimationFrame","measure","_x","_y","pageX","pageY","getTooltipLayout","nativeEvent","layout","ref","onLayout","tooltip__text","TooltipSlot","rest","handleScreenTouch","setHandleScreenTouch","callback","handleTouchStart","value","undefined","StyleSheet","absoluteFill"],"mappings":";;;;;;;;;AAgBA;;AAbA;;AAsBA;;AAKA;;AACA;;AA/BA;AACA;AACA;;AAWA;AACA;AACA;;AAYA;AACA;AACA;AAIA,MAAMA,wBAAwB,GAAG,EAAjC;AACA,MAAMC,uBAAuB,GAAG,CAAhC;AAEA,MAAMC,cAAc,GAAG,4BAAe;AACrCC,EAAAA,mBAAmB,EAAE,MAAM,CAAE;AADQ,CAAf,CAAvB;AAGA,MAAM;AAAEC,EAAAA,IAAF;AAAQC,EAAAA;AAAR,IAAiB,8BAAgB,SAAhB,CAAvB;;AAEA,MAAMC,qBAAqB,GAAG,MAAM;AACnC,QAAM,CAAEC,eAAF,EAAmBC,kBAAnB,IAA0C,uBAAU,KAAV,CAAhD;AACA,QAAMC,uBAAuB,GAAG,0BAAaF,eAAb,CAAhC;AAEA,0BAAW,MAAM;AAChB,UAAMG,YAAY,GAAGC,sBAASC,WAAT,CAAsB,iBAAtB,EAAyC,MAAM;AACnE,UAAKH,uBAAuB,KAAK,IAAjC,EAAwC;AACvCD,QAAAA,kBAAkB,CAAE,IAAF,CAAlB;AACA;AACD,KAJoB,CAArB;;AAKA,UAAMK,i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B,QAAhB;AAAyB,IAAA,KAAK,EAAGkG;AAAjC,KACC,4BAAC,iBAAD;AACC,IAAA,YAAY,EACX,OAAOJ,iBAAP,KAA6B,UAA7B,GACGG,gBADH,GAEGE,SAJL;AAMC,IAAA,aAAa,EAAC,UANf;AAOC,IAAA,KAAK,EAAGC,wBAAWC,YAPpB;AAQC,IAAA,MAAM,EAAC;AARR,KAUGnF,QAVH,EAWC,4BAAC,IAAD,EAAW2E,IAAX,CAXD,CADD,CADD;AAiBA,CA9BD;;AAgCA5E,OAAO,CAACf,IAAR,GAAe0F,WAAf;eAEe3E,O","sourcesContent":["/**\n * External dependencies\n */\nimport {\n\tAnimated,\n\tEasing,\n\tKeyboard,\n\tPlatform,\n\tStyleSheet,\n\tText,\n\tView,\n} from 'react-native';\n\n/**\n * WordPress dependencies\n */\nimport {\n\tcloneElement,\n\tcreateContext,\n\tuseContext,\n\tuseEffect,\n\tuseMemo,\n\tuseRef,\n\tuseState,\n} from '@wordpress/element';\nimport { usePrevious } from '@wordpress/compose';\n\n/**\n * Internal dependencies\n */\nimport { createSlotFill } from '../slot-fill';\nimport styles from './style.scss';\n\nconst RIGHT_ALIGN_ARROW_OFFSET = 16;\nconst TOOLTIP_VERTICAL_OFFSET = 2;\n\nconst TooltipContext = createContext( {\n\tonHandleScreenTouch: () => {},\n} );\nconst { Fill, Slot } = createSlotFill( 'Tooltip' );\n\nconst useKeyboardVisibility = () => {\n\tconst [ keyboardVisible, setKeyboardVisible ] = useState( false );\n\tconst previousKeyboardVisible = usePrevious( keyboardVisible );\n\n\tuseEffect( () => {\n\t\tconst showListener = Keyboard.addListener( 'keyboardDidShow', () => {\n\t\t\tif ( previousKeyboardVisible !== true ) {\n\t\t\t\tsetKeyboardVisible( true );\n\t\t\t}\n\t\t} );\n\t\tconst keyboardHideEvent = Platform.select( {\n\t\t\tandroid: 'keyboardDidHide',\n\t\t\tios: 'keyboardWillHide',\n\t\t} );\n\t\tconst hideListener = Keyboard.addListener( keyboardHideEvent, () => {\n\t\t\tif ( previousKeyboardVisible !== false ) {\n\t\t\t\tsetKeyboardVisible( false );\n\t\t\t}\n\t\t} );\n\t\treturn () => {\n\t\t\tshowListener.remove();\n\t\t\thideListener.remove();\n\t\t};\n\t}, [] );\n\n\treturn keyboardVisible;\n};\n\nconst Tooltip = ( {\n\tchildren,\n\tposition = 'top',\n\ttext,\n\tvisible: initialVisible = false,\n} ) => {\n\tconst referenceElementRef = useRef( null );\n\tconst animationValue = useRef( new Animated.Value( 0 ) ).current;\n\tconst [ , horizontalPosition = 'center' ] = position.split( ' ' );\n\tconst [ visible, setVisible ] = useState( initialVisible );\n\tconst [ animating, setAnimating ] = useState( false );\n\tconst hidden = ! visible && ! animating;\n\tconst previousVisible = usePrevious( visible );\n\tconst [ referenceLayout, setReferenceLayout ] = useState( {\n\t\theight: 0,\n\t\twidth: 0,\n\t\tx: 0,\n\t\ty: 0,\n\t} );\n\tconst [ tooltipLayout, setTooltipLayout ] = useState( {\n\t\theight: 0,\n\t\twidth: 0,\n\t} );\n\tconst { onHandleScreenTouch } = useContext( TooltipContext );\n\tconst keyboardVisible = useKeyboardVisibility();\n\n\t// Register callback to dismiss the tooltip whenever the screen is touched\n\tuseEffect( () => {\n\t\tif ( visible ) {\n\t\t\tonHandleScreenTouch( () => {\n\t\t\t\tsetAnimating( true );\n\t\t\t\tsetVisible( false );\n\t\t\t} );\n\t\t}\n\t\treturn () => onHandleScreenTouch( null );\n\t}, [ visible ] );\n\n\t// Manage visibility animation\n\tuseEffect( () => {\n\t\tif (\n\t\t\t// Initial render and visibility enabled, animate show\n\t\t\t( typeof previousVisible === 'undefined' && visible ) ||\n\t\t\t// Previously visible, animate hide\n\t\t\t( previousVisible && previousVisible !== visible )\n\t\t) {\n\t\t\tsetAnimating( true );\n\t\t\tstartAnimation();\n\t\t}\n\t}, [ visible ] );\n\n\t// Manage tooltip visibility and position in relation to keyboard\n\tuseEffect( () => {\n\t\tif ( ! visible ) {\n\t\t\treturn;\n\t\t}\n\n\t\t// Update tooltip position if keyboard is visible\n\t\tif ( keyboardVisible ) {\n\t\t\tgetReferenceElementPosition();\n\t\t}\n\n\t\t// Hide tooltip if keyboard hides\n\t\tif ( typeof previousVisible !== 'undefined' && ! keyboardVisible ) {\n\t\t\tsetAnimating( true );\n\t\t\tsetVisible( false );\n\t\t}\n\t}, [ visible, keyboardVisible ] );\n\n\t// Manage tooltip position during keyboard frame changes\n\tuseEffect( () => {\n\t\tconst frameListener = Keyboard.addListener(\n\t\t\t'keyboardWillChangeFrame',\n\t\t\t() => {\n\t\t\t\tif ( visible ) {\n\t\t\t\t\tgetReferenceElementPosition();\n\t\t\t\t}\n\t\t\t}\n\t\t);\n\n\t\treturn () => {\n\t\t\tframeListener.remove();\n\t\t};\n\t}, [ visible ] );\n\n\tconst startAnimation = () => {\n\t\tAnimated.timing( animationValue, {\n\t\t\ttoValue: visible ? 1 : 0,\n\t\t\tduration: visible ? 300 : 150,\n\t\t\tuseNativeDriver: true,\n\t\t\tdelay: visible ? 500 : 0,\n\t\t\teasing: Easing.out( Easing.quad ),\n\t\t} ).start( () => {\n\t\t\tsetAnimating( false );\n\t\t} );\n\t};\n\n\tconst tooltipStyles = [\n\t\tstyles.tooltip,\n\t\t{\n\t\t\tleft:\n\t\t\t\treferenceLayout.x +\n\t\t\t\tMath.floor( referenceLayout.width / 2 ) -\n\t\t\t\t( horizontalPosition === 'right'\n\t\t\t\t\t? RIGHT_ALIGN_ARROW_OFFSET\n\t\t\t\t\t: Math.floor( tooltipLayout.width / 2 ) ),\n\t\t\ttop:\n\t\t\t\treferenceLayout.y -\n\t\t\t\ttooltipLayout.height -\n\t\t\t\tTOOLTIP_VERTICAL_OFFSET,\n\t\t},\n\t];\n\tconst tooltipBoxStyles = [\n\t\tstyles.tooltip__box,\n\t\thorizontalPosition === 'right' && styles[ 'tooltip--rightAlign' ],\n\t\t{\n\t\t\televation: 2,\n\t\t\topacity: animationValue,\n\t\t\tshadowColor: styles.tooltip__shadow?.color,\n\t\t\tshadowOffset: { height: 2, width: 0 },\n\t\t\tshadowOpacity: 0.25,\n\t\t\tshadowRadius: 2,\n\t\t\ttransform: [\n\t\t\t\t{\n\t\t\t\t\ttranslateY: animationValue.interpolate( {\n\t\t\t\t\t\tinputRange: [ 0, 1 ],\n\t\t\t\t\t\toutputRange: [ visible ? 4 : -8, -8 ],\n\t\t\t\t\t} ),\n\t\t\t\t},\n\t\t\t],\n\t\t},\n\t];\n\tconst arrowStyles = [\n\t\tstyles.tooltip__arrow,\n\t\thorizontalPosition === 'right' &&\n\t\t\tstyles[ 'tooltip__arrow--rightAlign' ],\n\t];\n\n\tconst getReferenceElementPosition = () => {\n\t\t// rAF allows render to complete before calculating layout\n\t\t// eslint-disable-next-line no-undef\n\t\trequestAnimationFrame( () => {\n\t\t\tif ( ! referenceElementRef.current ) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\treferenceElementRef.current.measure(\n\t\t\t\t( _x, _y, width, height, pageX, pageY ) => {\n\t\t\t\t\tsetReferenceLayout( {\n\t\t\t\t\t\theight,\n\t\t\t\t\t\twidth,\n\t\t\t\t\t\tx: pageX,\n\t\t\t\t\t\ty: pageY,\n\t\t\t\t\t} );\n\t\t\t\t}\n\t\t\t);\n\t\t} );\n\t};\n\tconst getTooltipLayout = ( { nativeEvent } ) => {\n\t\tconst { height, width } = nativeEvent.layout;\n\t\tsetTooltipLayout( { height, width } );\n\t};\n\n\tif ( hidden ) {\n\t\treturn children;\n\t}\n\n\treturn (\n\t\t<>\n\t\t\t{ cloneElement( children, {\n\t\t\t\tref: referenceElementRef,\n\t\t\t\tonLayout: getReferenceElementPosition,\n\t\t\t} ) }\n\t\t\t<Fill>\n\t\t\t\t<View onLayout={ getTooltipLayout } style={ tooltipStyles }>\n\t\t\t\t\t<Animated.View style={ tooltipBoxStyles }>\n\t\t\t\t\t\t<Text style={ styles.tooltip__text }>{ text }</Text>\n\t\t\t\t\t\t<View style={ arrowStyles } />\n\t\t\t\t\t</Animated.View>\n\t\t\t\t</View>\n\t\t\t</Fill>\n\t\t</>\n\t);\n};\n\nconst TooltipSlot = ( { children, ...rest } ) => {\n\tconst [ handleScreenTouch, setHandleScreenTouch ] = useState( null );\n\tconst onHandleScreenTouch = ( callback ) => {\n\t\t// Must use function to set state below as `callback` is a function itself\n\t\tsetHandleScreenTouch( () => callback );\n\t};\n\tconst handleTouchStart = () => {\n\t\thandleScreenTouch();\n\t\tsetHandleScreenTouch( null );\n\t};\n\t// Memoize context value to avoid unnecessary rerenders of the Provider's children\n\tconst value = useMemo( () => ( { onHandleScreenTouch } ) );\n\n\treturn (\n\t\t<TooltipContext.Provider value={ value }>\n\t\t\t<View\n\t\t\t\tonTouchStart={\n\t\t\t\t\ttypeof handleScreenTouch === 'function'\n\t\t\t\t\t\t? handleTouchStart\n\t\t\t\t\t\t: undefined\n\t\t\t\t}\n\t\t\t\tpointerEvents=\"box-none\"\n\t\t\t\tstyle={ StyleSheet.absoluteFill }\n\t\t\t\ttestID=\"tooltip-overlay\"\n\t\t\t>\n\t\t\t\t{ children }\n\t\t\t\t<Slot { ...rest } />\n\t\t\t</View>\n\t\t</TooltipContext.Provider>\n\t);\n};\n\nTooltip.Slot = TooltipSlot;\n\nexport default Tooltip;\n"]}
1
+ {"version":3,"sources":["@wordpress/components/src/tooltip/index.native.js"],"names":["RIGHT_ALIGN_ARROW_OFFSET","TOOLTIP_VERTICAL_OFFSET","TooltipContext","onHandleScreenTouch","Fill","Slot","useKeyboardVisibility","keyboardVisible","setKeyboardVisible","previousKeyboardVisible","showListener","Keyboard","addListener","keyboardHideEvent","Platform","select","android","ios","hideListener","remove","Tooltip","children","position","text","visible","initialVisible","referenceElementRef","animationValue","Animated","Value","current","horizontalPosition","split","setVisible","animating","setAnimating","hidden","previousVisible","referenceLayout","setReferenceLayout","height","width","x","y","tooltipLayout","setTooltipLayout","startAnimation","getReferenceElementPosition","frameListener","timing","toValue","duration","useNativeDriver","delay","easing","Easing","out","quad","start","tooltipStyles","styles","tooltip","left","Math","floor","top","tooltipBoxStyles","tooltip__box","elevation","opacity","shadowColor","tooltip__shadow","color","shadowOffset","shadowOpacity","shadowRadius","transform","translateY","interpolate","inputRange","outputRange","arrowStyles","tooltip__arrow","requestAnimationFrame","measure","_x","_y","pageX","pageY","getTooltipLayout","nativeEvent","layout","ref","onLayout","tooltip__text","TooltipSlot","rest","handleScreenTouch","setHandleScreenTouch","callback","handleTouchStart","value","undefined","StyleSheet","absoluteFill"],"mappings":";;;;;;;;;AAgBA;;AAbA;;AAsBA;;AAKA;;AACA;;AA/BA;AACA;AACA;;AAWA;AACA;AACA;;AAYA;AACA;AACA;AAIA,MAAMA,wBAAwB,GAAG,EAAjC;AACA,MAAMC,uBAAuB,GAAG,CAAhC;AAEA,MAAMC,cAAc,GAAG,4BAAe;AACrCC,EAAAA,mBAAmB,EAAE,MAAM,CAAE;AADQ,CAAf,CAAvB;AAGA,MAAM;AAAEC,EAAAA,IAAF;AAAQC,EAAAA;AAAR,IAAiB,8BAAgB,SAAhB,CAAvB;;AAEA,MAAMC,qBAAqB,GAAG,MAAM;AACnC,QAAM,CAAEC,eAAF,EAAmBC,kBAAnB,IAA0C,uBAAU,KAAV,CAAhD;AACA,QAAMC,uBAAuB,GAAG,0BAAaF,eAAb,CAAhC;AAEA,0BAAW,MAAM;AAChB,UAAMG,YAAY,GAAGC,sBAASC,WAAT,CAAsB,iBAAtB,EAAyC,MAAM;AACnE,UAAKH,uBAAuB,KAAK,IAAjC,EAAwC;AACvCD,QAAAA,kBAAkB,CAAE,IAAF,CAAlB;AACA;AACD,KAJoB,CAArB;;AAKA,UAAMK,iBAAiB,GAAGC,sBAASC,MAAT,CAAiB;AAC1CC,MAAAA,OAAO,EAAE,iBADiC;AAE1CC,MAAAA,GAAG,EAAE;AAFqC,KAAjB,CAA1B;;AAIA,UAAMC,YAAY,GAAGP,sBAASC,WAAT,CAAsBC,iBAAtB,EAAyC,MAAM;AACnE,UAAKJ,uBAAuB,KAAK,KAAjC,EAAyC;A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AARR,KAUGnF,QAVH,EAWC,4BAAC,IAAD,EAAW2E,IAAX,CAXD,CADD,CADD;AAiBA,CA9BD;;AAgCA5E,OAAO,CAACf,IAAR,GAAe0F,WAAf;eAEe3E,O","sourcesContent":["/**\n * External dependencies\n */\nimport {\n\tAnimated,\n\tEasing,\n\tKeyboard,\n\tPlatform,\n\tStyleSheet,\n\tText,\n\tView,\n} from 'react-native';\n\n/**\n * WordPress dependencies\n */\nimport {\n\tcloneElement,\n\tcreateContext,\n\tuseContext,\n\tuseEffect,\n\tuseMemo,\n\tuseRef,\n\tuseState,\n} from '@wordpress/element';\nimport { usePrevious } from '@wordpress/compose';\n\n/**\n * Internal dependencies\n */\nimport { createSlotFill } from '../slot-fill';\nimport styles from './style.scss';\n\nconst RIGHT_ALIGN_ARROW_OFFSET = 16;\nconst TOOLTIP_VERTICAL_OFFSET = 2;\n\nconst TooltipContext = createContext( {\n\tonHandleScreenTouch: () => {},\n} );\nconst { Fill, Slot } = createSlotFill( 'Tooltip' );\n\nconst useKeyboardVisibility = () => {\n\tconst [ keyboardVisible, setKeyboardVisible ] = useState( false );\n\tconst previousKeyboardVisible = usePrevious( keyboardVisible );\n\n\tuseEffect( () => {\n\t\tconst showListener = Keyboard.addListener( 'keyboardDidShow', () => {\n\t\t\tif ( previousKeyboardVisible !== true ) {\n\t\t\t\tsetKeyboardVisible( true );\n\t\t\t}\n\t\t} );\n\t\tconst keyboardHideEvent = Platform.select( {\n\t\t\tandroid: 'keyboardDidHide',\n\t\t\tios: 'keyboardWillHide',\n\t\t} );\n\t\tconst hideListener = Keyboard.addListener( keyboardHideEvent, () => {\n\t\t\tif ( previousKeyboardVisible !== false ) {\n\t\t\t\tsetKeyboardVisible( false );\n\t\t\t}\n\t\t} );\n\t\treturn () => {\n\t\t\tshowListener.remove();\n\t\t\thideListener.remove();\n\t\t};\n\t}, [] );\n\n\treturn keyboardVisible;\n};\n\nconst Tooltip = ( {\n\tchildren,\n\tposition = 'top',\n\ttext,\n\tvisible: initialVisible = false,\n} ) => {\n\tconst referenceElementRef = useRef( null );\n\tconst animationValue = useRef( new Animated.Value( 0 ) ).current;\n\tconst [ , horizontalPosition = 'center' ] = position.split( ' ' );\n\tconst [ visible, setVisible ] = useState( initialVisible );\n\tconst [ animating, setAnimating ] = useState( false );\n\tconst hidden = ! visible && ! animating;\n\tconst previousVisible = usePrevious( visible );\n\tconst [ referenceLayout, setReferenceLayout ] = useState( {\n\t\theight: 0,\n\t\twidth: 0,\n\t\tx: 0,\n\t\ty: 0,\n\t} );\n\tconst [ tooltipLayout, setTooltipLayout ] = useState( {\n\t\theight: 0,\n\t\twidth: 0,\n\t} );\n\tconst { onHandleScreenTouch } = useContext( TooltipContext );\n\tconst keyboardVisible = useKeyboardVisibility();\n\n\t// Register callback to dismiss the tooltip whenever the screen is touched.\n\tuseEffect( () => {\n\t\tif ( visible ) {\n\t\t\tonHandleScreenTouch( () => {\n\t\t\t\tsetAnimating( true );\n\t\t\t\tsetVisible( false );\n\t\t\t} );\n\t\t}\n\t\treturn () => onHandleScreenTouch( null );\n\t}, [ visible ] );\n\n\t// Manage visibility animation.\n\tuseEffect( () => {\n\t\tif (\n\t\t\t// Initial render and visibility enabled, animate show.\n\t\t\t( typeof previousVisible === 'undefined' && visible ) ||\n\t\t\t// Previously visible, animate hide\n\t\t\t( previousVisible && previousVisible !== visible )\n\t\t) {\n\t\t\tsetAnimating( true );\n\t\t\tstartAnimation();\n\t\t}\n\t}, [ visible ] );\n\n\t// Manage tooltip visibility and position in relation to keyboard.\n\tuseEffect( () => {\n\t\tif ( ! visible ) {\n\t\t\treturn;\n\t\t}\n\n\t\t// Update tooltip position if keyboard is visible.\n\t\tif ( keyboardVisible ) {\n\t\t\tgetReferenceElementPosition();\n\t\t}\n\n\t\t// Hide tooltip if keyboard hides\n\t\tif ( typeof previousVisible !== 'undefined' && ! keyboardVisible ) {\n\t\t\tsetAnimating( true );\n\t\t\tsetVisible( false );\n\t\t}\n\t}, [ visible, keyboardVisible ] );\n\n\t// Manage tooltip position during keyboard frame changes.\n\tuseEffect( () => {\n\t\tconst frameListener = Keyboard.addListener(\n\t\t\t'keyboardWillChangeFrame',\n\t\t\t() => {\n\t\t\t\tif ( visible ) {\n\t\t\t\t\tgetReferenceElementPosition();\n\t\t\t\t}\n\t\t\t}\n\t\t);\n\n\t\treturn () => {\n\t\t\tframeListener.remove();\n\t\t};\n\t}, [ visible ] );\n\n\tconst startAnimation = () => {\n\t\tAnimated.timing( animationValue, {\n\t\t\ttoValue: visible ? 1 : 0,\n\t\t\tduration: visible ? 300 : 150,\n\t\t\tuseNativeDriver: true,\n\t\t\tdelay: visible ? 500 : 0,\n\t\t\teasing: Easing.out( Easing.quad ),\n\t\t} ).start( () => {\n\t\t\tsetAnimating( false );\n\t\t} );\n\t};\n\n\tconst tooltipStyles = [\n\t\tstyles.tooltip,\n\t\t{\n\t\t\tleft:\n\t\t\t\treferenceLayout.x +\n\t\t\t\tMath.floor( referenceLayout.width / 2 ) -\n\t\t\t\t( horizontalPosition === 'right'\n\t\t\t\t\t? RIGHT_ALIGN_ARROW_OFFSET\n\t\t\t\t\t: Math.floor( tooltipLayout.width / 2 ) ),\n\t\t\ttop:\n\t\t\t\treferenceLayout.y -\n\t\t\t\ttooltipLayout.height -\n\t\t\t\tTOOLTIP_VERTICAL_OFFSET,\n\t\t},\n\t];\n\tconst tooltipBoxStyles = [\n\t\tstyles.tooltip__box,\n\t\thorizontalPosition === 'right' && styles[ 'tooltip--rightAlign' ],\n\t\t{\n\t\t\televation: 2,\n\t\t\topacity: animationValue,\n\t\t\tshadowColor: styles.tooltip__shadow?.color,\n\t\t\tshadowOffset: { height: 2, width: 0 },\n\t\t\tshadowOpacity: 0.25,\n\t\t\tshadowRadius: 2,\n\t\t\ttransform: [\n\t\t\t\t{\n\t\t\t\t\ttranslateY: animationValue.interpolate( {\n\t\t\t\t\t\tinputRange: [ 0, 1 ],\n\t\t\t\t\t\toutputRange: [ visible ? 4 : -8, -8 ],\n\t\t\t\t\t} ),\n\t\t\t\t},\n\t\t\t],\n\t\t},\n\t];\n\tconst arrowStyles = [\n\t\tstyles.tooltip__arrow,\n\t\thorizontalPosition === 'right' &&\n\t\t\tstyles[ 'tooltip__arrow--rightAlign' ],\n\t];\n\n\tconst getReferenceElementPosition = () => {\n\t\t// rAF allows render to complete before calculating layout\n\t\t// eslint-disable-next-line no-undef\n\t\trequestAnimationFrame( () => {\n\t\t\tif ( ! referenceElementRef.current ) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\treferenceElementRef.current.measure(\n\t\t\t\t( _x, _y, width, height, pageX, pageY ) => {\n\t\t\t\t\tsetReferenceLayout( {\n\t\t\t\t\t\theight,\n\t\t\t\t\t\twidth,\n\t\t\t\t\t\tx: pageX,\n\t\t\t\t\t\ty: pageY,\n\t\t\t\t\t} );\n\t\t\t\t}\n\t\t\t);\n\t\t} );\n\t};\n\tconst getTooltipLayout = ( { nativeEvent } ) => {\n\t\tconst { height, width } = nativeEvent.layout;\n\t\tsetTooltipLayout( { height, width } );\n\t};\n\n\tif ( hidden ) {\n\t\treturn children;\n\t}\n\n\treturn (\n\t\t<>\n\t\t\t{ cloneElement( children, {\n\t\t\t\tref: referenceElementRef,\n\t\t\t\tonLayout: getReferenceElementPosition,\n\t\t\t} ) }\n\t\t\t<Fill>\n\t\t\t\t<View onLayout={ getTooltipLayout } style={ tooltipStyles }>\n\t\t\t\t\t<Animated.View style={ tooltipBoxStyles }>\n\t\t\t\t\t\t<Text style={ styles.tooltip__text }>{ text }</Text>\n\t\t\t\t\t\t<View style={ arrowStyles } />\n\t\t\t\t\t</Animated.View>\n\t\t\t\t</View>\n\t\t\t</Fill>\n\t\t</>\n\t);\n};\n\nconst TooltipSlot = ( { children, ...rest } ) => {\n\tconst [ handleScreenTouch, setHandleScreenTouch ] = useState( null );\n\tconst onHandleScreenTouch = ( callback ) => {\n\t\t// Must use function to set state below as `callback` is a function itself.\n\t\tsetHandleScreenTouch( () => callback );\n\t};\n\tconst handleTouchStart = () => {\n\t\thandleScreenTouch();\n\t\tsetHandleScreenTouch( null );\n\t};\n\t// Memoize context value to avoid unnecessary rerenders of the Provider's children\n\tconst value = useMemo( () => ( { onHandleScreenTouch } ) );\n\n\treturn (\n\t\t<TooltipContext.Provider value={ value }>\n\t\t\t<View\n\t\t\t\tonTouchStart={\n\t\t\t\t\ttypeof handleScreenTouch === 'function'\n\t\t\t\t\t\t? handleTouchStart\n\t\t\t\t\t\t: undefined\n\t\t\t\t}\n\t\t\t\tpointerEvents=\"box-none\"\n\t\t\t\tstyle={ StyleSheet.absoluteFill }\n\t\t\t\ttestID=\"tooltip-overlay\"\n\t\t\t>\n\t\t\t\t{ children }\n\t\t\t\t<Slot { ...rest } />\n\t\t\t</View>\n\t\t</TooltipContext.Provider>\n\t);\n};\n\nTooltip.Slot = TooltipSlot;\n\nexport default Tooltip;\n"]}
@@ -282,7 +282,10 @@ function TreeGrid(_ref, ref) {
282
282
 
283
283
 
284
284
  const nextIndex = Math.min(currentColumnIndex, focusablesInNextRow.length - 1);
285
- focusablesInNextRow[nextIndex].focus(); // Prevent key use for anything else. This ensures Voiceover
285
+ focusablesInNextRow[nextIndex].focus(); // Let consumers know the row that was originally focused,
286
+ // and the row that is now in focus.
287
+
288
+ onFocusRow(event, activeRow, rows[nextRowIndex]); // Prevent key use for anything else. This ensures Voiceover
286
289
  // doesn't try to handle key navigation.
287
290
 
288
291
  event.preventDefault();
@@ -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","props","onKeyDown","event","keyCode","metaKey","ctrlKey","altKey","hasModifierKeyPressed","UP","DOWN","LEFT","RIGHT","HOME","END","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":";;;;;;;;;;;;;;;;;;;;;;;;;;;AASA;;;;AANA;;AAKA;;AAEA;;AAKA;;AAgSA;;AACA;;AACA;;AAjTA;AACA;AACA;;AAGA;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,SAASS,QAAT,OAQCC,GARD,EASE;AAAA,MARD;AACCC,IAAAA,QADD;AAECC,IAAAA,WAAW,GAAG,MAAM,CAAE,CAFvB;AAGCC,IAAAA,aAAa,GAAG,MAAM,CAAE,CAHzB;AAICC,IAAAA,UAAU,GAAG,MAAM,CAAE,CAJtB;AAKC,OAAGC;AALJ,GAQC;AACD,QAAMC,SAAS,GAAG,0BACfC,KAAF,IAAa;AACZ,UAAM;AAAEC,MAAAA,OAAF;AAAWC,MAAAA,OAAX;AAAoBC,MAAAA,OAApB;AAA6BC,MAAAA;AAA7B,QAAwCJ,KAA9C,CADY,CAGZ;AACA;;AACA,UAAMK,qBAAqB,GAAGH,OAAO,IAAIC,OAAX,IAAsBC,MAApD;;AAEA,QACCC,qBAAqB,IACrB,CAAE,sBAAU,CAAEC,YAAF,EAAMC,c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,SAAS,GAAGC,IAAI,CAACE,GAAL,CACjBR,kBADiB,EAEjBqB,mBAAmB,CAACnD,MAApB,GAA6B,CAFZ,CAAlB;AAIAmD,MAAAA,mBAAmB,CAAEhB,SAAF,CAAnB,CAAiCvC,KAAjC,GA1CgD,CA4ChD;AACA;;AACAe,MAAAA,KAAK,CAAC4B,cAAN;AACA;AACD,GA7NgB,EA8NjB,CAAEjC,WAAF,EAAeC,aAAf,EAA8BC,UAA9B,CA9NiB,CAAlB;AAiOA;;AACA;;AACA,SACC,4BAAC,uBAAD,QACC,gEACMC,KADN;AAEC,IAAA,IAAI,EAAC,UAFN;AAGC,IAAA,SAAS,EAAGC,SAHb;AAIC,IAAA,GAAG,EAAGN;AAJP,MAMC,2CAASC,QAAT,CAND,CADD,CADD;AAYA;AACA;;eAEc,yBAAYF,QAAZ,C","sourcesContent":["/**\n * External dependencies\n */\nimport { includes } from 'lodash';\n\n/**\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} 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 {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\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! includes( [ UP, DOWN, LEFT, RIGHT, HOME, END ], 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 ( includes( [ LEFT, RIGHT ], 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 rightmost 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[\n\t\t\t\t\t\t\t\tfocusableItems.length - 1\n\t\t\t\t\t\t\t]?.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 ( includes( [ UP, DOWN ], 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 ( includes( [ HOME, END ], 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// 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<table\n\t\t\t\t{ ...props }\n\t\t\t\trole=\"treegrid\"\n\t\t\t\tonKeyDown={ onKeyDown }\n\t\t\t\tref={ ref }\n\t\t\t>\n\t\t\t\t<tbody>{ children }</tbody>\n\t\t\t</table>\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.js"],"names":["getRowFocusables","rowElement","focusablesInRow","focus","focusable","find","sequential","length","filter","closest","TreeGrid","ref","children","onExpandRow","onCollapseRow","onFocusRow","props","onKeyDown","event","keyCode","metaKey","ctrlKey","altKey","hasModifierKeyPressed","UP","DOWN","LEFT","RIGHT","HOME","END","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":";;;;;;;;;;;;;;;;;;;;;;;;;;;AASA;;;;AANA;;AAKA;;AAEA;;AAKA;;AAoSA;;AACA;;AACA;;AArTA;AACA;AACA;;AAGA;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,IAAA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B,CAlOiB,CAAlB;AAqOA;;AACA;;AACA,SACC,4BAAC,uBAAD,QACC,gEACMC,KADN;AAEC,IAAA,IAAI,EAAC,UAFN;AAGC,IAAA,SAAS,EAAGC,SAHb;AAIC,IAAA,GAAG,EAAGN;AAJP,MAMC,2CAASC,QAAT,CAND,CADD,CADD;AAYA;AACA;;eAEc,yBAAYF,QAAZ,C","sourcesContent":["/**\n * External dependencies\n */\nimport { includes } from 'lodash';\n\n/**\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} 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 {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\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! includes( [ UP, DOWN, LEFT, RIGHT, HOME, END ], 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 ( includes( [ LEFT, RIGHT ], 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 rightmost 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[\n\t\t\t\t\t\t\t\tfocusableItems.length - 1\n\t\t\t\t\t\t\t]?.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 ( includes( [ UP, DOWN ], 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 ( includes( [ HOME, END ], 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<table\n\t\t\t\t{ ...props }\n\t\t\t\trole=\"treegrid\"\n\t\t\t\tonKeyDown={ onKeyDown }\n\t\t\t\tref={ ref }\n\t\t\t>\n\t\t\t\t<tbody>{ children }</tbody>\n\t\t\t</table>\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"]}
@@ -47,7 +47,7 @@ function truncateMiddle(word, headLength, tailLength, ellipsis) {
47
47
  const wordLength = word.length; // Setting default values
48
48
  // eslint-disable-next-line no-bitwise
49
49
 
50
- const frontLength = ~~headLength; // will cast to integer
50
+ const frontLength = ~~headLength; // Will cast to integer
51
51
  // eslint-disable-next-line no-bitwise
52
52
 
53
53
  const backLength = ~~tailLength;
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/components/src/truncate/utils.js"],"names":["TRUNCATE_ELLIPSIS","TRUNCATE_TYPE","auto","head","middle","tail","none","TRUNCATE_DEFAULT_PROPS","ellipsis","ellipsizeMode","limit","numberOfLines","truncateMiddle","word","headLength","tailLength","wordLength","length","frontLength","backLength","truncateStr","slice","truncateContent","words","props","mergedProps","truncateHead","truncateTail","Math","floor","truncatedContent"],"mappings":";;;;;;;;;AAGA;;AAHA;AACA;AACA;AAGO,MAAMA,iBAAiB,GAAG,GAA1B;;AACA,MAAMC,aAAa,GAAG;AAC5BC,EAAAA,IAAI,EAAE,MADsB;AAE5BC,EAAAA,IAAI,EAAE,MAFsB;AAG5BC,EAAAA,MAAM,EAAE,QAHoB;AAI5BC,EAAAA,IAAI,EAAE,MAJsB;AAK5BC,EAAAA,IAAI,EAAE;AALsB,CAAtB;;AAQA,MAAMC,sBAAsB,GAAG;AACrCC,EAAAA,QAAQ,EAAER,iBAD2B;AAErCS,EAAAA,aAAa,EAAER,aAAa,CAACC,IAFQ;AAGrCQ,EAAAA,KAA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e,WAA3C;;AAEA,MAAKhB,aAAa,KAAKR,aAAa,CAACK,IAArC,EAA4C;AAC3C,WAAOiB,KAAP;AACA;;AAED,MAAIG,YAAJ;AACA,MAAIC,YAAJ;;AAEA,UAASlB,aAAT;AACC,SAAKR,aAAa,CAACE,IAAnB;AACCuB,MAAAA,YAAY,GAAG,CAAf;AACAC,MAAAA,YAAY,GAAGjB,KAAf;AACA;;AACD,SAAKT,aAAa,CAACG,MAAnB;AACCsB,MAAAA,YAAY,GAAGE,IAAI,CAACC,KAAL,CAAYnB,KAAK,GAAG,CAApB,CAAf;AACAiB,MAAAA,YAAY,GAAGC,IAAI,CAACC,KAAL,CAAYnB,KAAK,GAAG,CAApB,CAAf;AACA;;AACD;AACCgB,MAAAA,YAAY,GAAGhB,KAAf;AACAiB,MAAAA,YAAY,GAAG,CAAf;AAXF;;AAcA,QAAMG,gBAAgB,GACrBrB,aAAa,KAAKR,aAAa,CAACC,IAAhC,GACGU,cAAc,CAAEW,KAAF,EAASG,YAAT,EAAuBC,YAAvB,EAAqCnB,QAArC,CADjB,GAEGe,KAHJ;AAKA,SAAOO,gBAAP;AACA","sourcesContent":["/**\n * External dependencies\n */\nimport { isNil } from 'lodash';\n\nexport const TRUNCATE_ELLIPSIS = '…';\nexport const TRUNCATE_TYPE = {\n\tauto: 'auto',\n\thead: 'head',\n\tmiddle: 'middle',\n\ttail: 'tail',\n\tnone: 'none',\n};\n\nexport const TRUNCATE_DEFAULT_PROPS = {\n\tellipsis: TRUNCATE_ELLIPSIS,\n\tellipsizeMode: TRUNCATE_TYPE.auto,\n\tlimit: 0,\n\tnumberOfLines: 0,\n};\n\n// Source\n// https://github.com/kahwee/truncate-middle\n/**\n * @param {string} word\n * @param {number} headLength\n * @param {number} tailLength\n * @param {string} ellipsis\n */\nexport function truncateMiddle( word, headLength, tailLength, ellipsis ) {\n\tif ( typeof word !== 'string' ) {\n\t\treturn '';\n\t}\n\tconst wordLength = word.length;\n\t// Setting default values\n\t// eslint-disable-next-line no-bitwise\n\tconst frontLength = ~~headLength; // will cast to integer\n\t// eslint-disable-next-line no-bitwise\n\tconst backLength = ~~tailLength;\n\t/* istanbul ignore next */\n\tconst truncateStr = ! isNil( ellipsis ) ? ellipsis : TRUNCATE_ELLIPSIS;\n\n\tif (\n\t\t( frontLength === 0 && backLength === 0 ) ||\n\t\tfrontLength >= wordLength ||\n\t\tbackLength >= wordLength ||\n\t\tfrontLength + backLength >= wordLength\n\t) {\n\t\treturn word;\n\t} else if ( backLength === 0 ) {\n\t\treturn word.slice( 0, frontLength ) + truncateStr;\n\t}\n\treturn (\n\t\tword.slice( 0, frontLength ) +\n\t\ttruncateStr +\n\t\tword.slice( wordLength - backLength )\n\t);\n}\n\n/**\n *\n * @param {string} words\n * @param {typeof TRUNCATE_DEFAULT_PROPS} props\n */\nexport function truncateContent( words = '', props ) {\n\tconst mergedProps = { ...TRUNCATE_DEFAULT_PROPS, ...props };\n\tconst { ellipsis, ellipsizeMode, limit } = mergedProps;\n\n\tif ( ellipsizeMode === TRUNCATE_TYPE.none ) {\n\t\treturn words;\n\t}\n\n\tlet truncateHead;\n\tlet truncateTail;\n\n\tswitch ( ellipsizeMode ) {\n\t\tcase TRUNCATE_TYPE.head:\n\t\t\ttruncateHead = 0;\n\t\t\ttruncateTail = limit;\n\t\t\tbreak;\n\t\tcase TRUNCATE_TYPE.middle:\n\t\t\ttruncateHead = Math.floor( limit / 2 );\n\t\t\ttruncateTail = Math.floor( limit / 2 );\n\t\t\tbreak;\n\t\tdefault:\n\t\t\ttruncateHead = limit;\n\t\t\ttruncateTail = 0;\n\t}\n\n\tconst truncatedContent =\n\t\tellipsizeMode !== TRUNCATE_TYPE.auto\n\t\t\t? truncateMiddle( words, truncateHead, truncateTail, ellipsis )\n\t\t\t: words;\n\n\treturn truncatedContent;\n}\n"]}
1
+ {"version":3,"sources":["@wordpress/components/src/truncate/utils.js"],"names":["TRUNCATE_ELLIPSIS","TRUNCATE_TYPE","auto","head","middle","tail","none","TRUNCATE_DEFAULT_PROPS","ellipsis","ellipsizeMode","limit","numberOfLines","truncateMiddle","word","headLength","tailLength","wordLength","length","frontLength","backLength","truncateStr","slice","truncateContent","words","props","mergedProps","truncateHead","truncateTail","Math","floor","truncatedContent"],"mappings":";;;;;;;;;AAGA;;AAHA;AACA;AACA;AAGO,MAAMA,iBAAiB,GAAG,GAA1B;;AACA,MAAMC,aAAa,GAAG;AAC5BC,EAAAA,IAAI,EAAE,MADsB;AAE5BC,EAAAA,IAAI,EAAE,MAFsB;AAG5BC,EAAAA,MAAM,EAAE,QAHoB;AAI5BC,EAAAA,IAAI,EAAE,MAJsB;AAK5BC,EAAAA,IAAI,EAAE;AALsB,CAAtB;;AAQA,MAAMC,sBAAsB,GAAG;AACrCC,EAAAA,QAAQ,EAAER,iBAD2B;AAErCS,EAAAA,aAAa,EAAER,aAAa,CAACC,IAFQ;AAGrCQ,EAAAA,KAAK,EAAE,CAH8B;AAIrCC,EAAAA,aAAa,EAAE;AAJsB,CAA/B,C,CAOP;AACA;;AACA;AACA;AACA;AACA;AACA;AACA;;;;AACO,SAASC,cAAT,CAAyBC,IAAzB,EAA+BC,UAA/B,EAA2CC,UAA3C,EAAuDP,QAAvD,EAAkE;AACxE,MAAK,OAAOK,IAAP,KAAgB,QAArB,EAAgC;AAC/B,WAAO,EAAP;AACA;;AACD,QAAMG,UAAU,GAAGH,IAAI,CAACI,MAAxB,CAJwE,CAKxE;AACA;;AACA,QAAMC,WAAW,GAAG,CAAC,CAACJ,UAAtB,CAPwE,CAOtC;AAClC;;AACA,QAAMK,UAAU,GAAG,CAAC,CAACJ,UAArB;AACA;;AACA,QAAMK,WAAW,GAAG,CAAE,mBAAOZ,QAAP,CAAF,GAAsBA,QAAtB,GAAiCR,iBAArD;;AAEA,MACGkB,WAAW,KAAK,CAAhB,IAAqBC,UAAU,KAAK,CAAtC,IACAD,WAAW,IAAIF,UADf,IAEAG,UAAU,IAAIH,UAFd,IAGAE,WAAW,GAAGC,UAAd,IAA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Ge,KAHJ;AAKA,SAAOO,gBAAP;AACA","sourcesContent":["/**\n * External dependencies\n */\nimport { isNil } from 'lodash';\n\nexport const TRUNCATE_ELLIPSIS = '…';\nexport const TRUNCATE_TYPE = {\n\tauto: 'auto',\n\thead: 'head',\n\tmiddle: 'middle',\n\ttail: 'tail',\n\tnone: 'none',\n};\n\nexport const TRUNCATE_DEFAULT_PROPS = {\n\tellipsis: TRUNCATE_ELLIPSIS,\n\tellipsizeMode: TRUNCATE_TYPE.auto,\n\tlimit: 0,\n\tnumberOfLines: 0,\n};\n\n// Source\n// https://github.com/kahwee/truncate-middle\n/**\n * @param {string} word\n * @param {number} headLength\n * @param {number} tailLength\n * @param {string} ellipsis\n */\nexport function truncateMiddle( word, headLength, tailLength, ellipsis ) {\n\tif ( typeof word !== 'string' ) {\n\t\treturn '';\n\t}\n\tconst wordLength = word.length;\n\t// Setting default values\n\t// eslint-disable-next-line no-bitwise\n\tconst frontLength = ~~headLength; // Will cast to integer\n\t// eslint-disable-next-line no-bitwise\n\tconst backLength = ~~tailLength;\n\t/* istanbul ignore next */\n\tconst truncateStr = ! isNil( ellipsis ) ? ellipsis : TRUNCATE_ELLIPSIS;\n\n\tif (\n\t\t( frontLength === 0 && backLength === 0 ) ||\n\t\tfrontLength >= wordLength ||\n\t\tbackLength >= wordLength ||\n\t\tfrontLength + backLength >= wordLength\n\t) {\n\t\treturn word;\n\t} else if ( backLength === 0 ) {\n\t\treturn word.slice( 0, frontLength ) + truncateStr;\n\t}\n\treturn (\n\t\tword.slice( 0, frontLength ) +\n\t\ttruncateStr +\n\t\tword.slice( wordLength - backLength )\n\t);\n}\n\n/**\n *\n * @param {string} words\n * @param {typeof TRUNCATE_DEFAULT_PROPS} props\n */\nexport function truncateContent( words = '', props ) {\n\tconst mergedProps = { ...TRUNCATE_DEFAULT_PROPS, ...props };\n\tconst { ellipsis, ellipsizeMode, limit } = mergedProps;\n\n\tif ( ellipsizeMode === TRUNCATE_TYPE.none ) {\n\t\treturn words;\n\t}\n\n\tlet truncateHead;\n\tlet truncateTail;\n\n\tswitch ( ellipsizeMode ) {\n\t\tcase TRUNCATE_TYPE.head:\n\t\t\ttruncateHead = 0;\n\t\t\ttruncateTail = limit;\n\t\t\tbreak;\n\t\tcase TRUNCATE_TYPE.middle:\n\t\t\ttruncateHead = Math.floor( limit / 2 );\n\t\t\ttruncateTail = Math.floor( limit / 2 );\n\t\t\tbreak;\n\t\tdefault:\n\t\t\ttruncateHead = limit;\n\t\t\ttruncateTail = 0;\n\t}\n\n\tconst truncatedContent =\n\t\tellipsizeMode !== TRUNCATE_TYPE.auto\n\t\t\t? truncateMiddle( words, truncateHead, truncateTail, ellipsis )\n\t\t\t: words;\n\n\treturn truncatedContent;\n}\n"]}
@@ -31,8 +31,6 @@ var _getStyledClassNameFromKey = require("./get-styled-class-name-from-key");
31
31
  * Internal dependencies
32
32
  */
33
33
 
34
- /* eslint-disable jsdoc/valid-types */
35
-
36
34
  /**
37
35
  * Forwards ref (React.ForwardRef) and "Connects" (or registers) a component
38
36
  * within the Context system under a specified namespace.
@@ -41,17 +39,13 @@ var _getStyledClassNameFromKey = require("./get-styled-class-name-from-key");
41
39
  * The hope is that we can improve render performance by removing functional
42
40
  * component wrappers.
43
41
  *
44
- * @template {import('./wordpress-component').WordPressComponentProps<{}, any, any>} P
45
- * @param {(props: P, ref: import('react').Ref<any>) => JSX.Element | null} Component The component to register into the Context system.
46
- * @param {string} namespace The namespace to register the component under.
47
- * @param {Object} options
48
- * @param {boolean} [options.memo=false]
49
- * @return {import('./wordpress-component').WordPressComponentFromProps<P>} The connected WordPressComponent
42
+ * @param Component The component to register into the Context system.
43
+ * @param namespace The namespace to register the component under.
44
+ * @param options
45
+ * @return The connected WordPressComponent
50
46
  */
51
47
  function contextConnect(Component, namespace) {
52
48
  let options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
53
-
54
- /* eslint-enable jsdoc/valid-types */
55
49
  const {
56
50
  memo: memoProp = false
57
51
  } = options;
@@ -91,8 +85,8 @@ function contextConnect(Component, namespace) {
91
85
  /**
92
86
  * Attempts to retrieve the connected namespace from a component.
93
87
  *
94
- * @param {import('react').ReactChild | undefined | {}} Component The component to retrieve a namespace from.
95
- * @return {Array<string>} The connected namespaces.
88
+ * @param Component The component to retrieve a namespace from.
89
+ * @return The connected namespaces.
96
90
  */
97
91
 
98
92
 
@@ -116,9 +110,8 @@ function getConnectNamespace(Component) {
116
110
  /**
117
111
  * Checks to see if a component is connected within the Context system.
118
112
  *
119
- * @param {import('react').ReactNode} Component The component to retrieve a namespace from.
120
- * @param {Array<string>|string} match The namespace to check.
121
- * @return {boolean} The result.
113
+ * @param Component The component to retrieve a namespace from.
114
+ * @param match The namespace to check.
122
115
  */
123
116
 
124
117
 
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/components/src/ui/context/context-connect.js"],"names":["contextConnect","Component","namespace","options","memo","memoProp","WrappedComponent","mergedNamespace","CONNECT_STATIC_NAMESPACE","Array","isArray","displayName","selector","getConnectNamespace","namespaces","type","hasConnectNamespace","match","includes","some","result"],"mappings":";;;;;;;;;;;AAGA;;AAKA;;AACA;;AAKA;;AACA;;AAfA;AACA;AACA;;AAGA;AACA;AACA;;AAIA;AACA;AACA;;AAIA;;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASA,cAAT,CAAyBC,SAAzB,EAAoCC,SAApC,EAA8D;AAAA,MAAfC,OAAe,uEAAL,EAAK;;AACpE;AACA,QAAM;AAAEC,IAAAA,IAAI,EAAEC,QAAQ,GAAG;AAAnB,MAA6BF,OAAnC;AAEA,MAAIG,gBAAgB,GAAG,yBAAYL,SAAZ,CAAvB;;AACA,MAAKI,QAAL,EAAgB;AACf;AACAC,IAAAA,gBAAgB,GAAG,mBAAMA,gBAAN,CAAnB;AACA;;AAED,MAAK,OAAOJ,SAAP,KAAqB,WAA1B,EAAwC;AACvC,mHAAM,4CAAN;AACA,GAZ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;AACvD,MAAK,CAAEhB,SAAP,EAAmB,OAAO,KAAP;;AAEnB,MAAK,OAAOgB,KAAP,KAAiB,QAAtB,EAAiC;AAChC,WAAOJ,mBAAmB,CAAEZ,SAAF,CAAnB,CAAiCiB,QAAjC,CAA2CD,KAA3C,CAAP;AACA;;AACD,MAAKR,KAAK,CAACC,OAAN,CAAeO,KAAf,CAAL,EAA8B;AAC7B,WAAOA,KAAK,CAACE,IAAN,CAAcC,MAAF,IAClBP,mBAAmB,CAAEZ,SAAF,CAAnB,CAAiCiB,QAAjC,CAA2CE,MAA3C,CADM,CAAP;AAGA;;AAED,SAAO,KAAP;AACA","sourcesContent":["/**\n * External dependencies\n */\nimport { uniq } from 'lodash';\n\n/**\n * WordPress dependencies\n */\nimport { forwardRef, memo } from '@wordpress/element';\nimport warn from '@wordpress/warning';\n\n/**\n * Internal dependencies\n */\nimport { CONNECT_STATIC_NAMESPACE } from './constants';\nimport { getStyledClassNameFromKey } from './get-styled-class-name-from-key';\n\n/* eslint-disable jsdoc/valid-types */\n/**\n * Forwards ref (React.ForwardRef) and \"Connects\" (or registers) a component\n * within the Context system under a specified namespace.\n *\n * This is an (experimental) evolution of the initial connect() HOC.\n * The hope is that we can improve render performance by removing functional\n * component wrappers.\n *\n * @template {import('./wordpress-component').WordPressComponentProps<{}, any, any>} P\n * @param {(props: P, ref: import('react').Ref<any>) => JSX.Element | null} Component The component to register into the Context system.\n * @param {string} namespace The namespace to register the component under.\n * @param {Object} options\n * @param {boolean} [options.memo=false]\n * @return {import('./wordpress-component').WordPressComponentFromProps<P>} The connected WordPressComponent\n */\nexport function contextConnect( Component, namespace, options = {} ) {\n\t/* eslint-enable jsdoc/valid-types */\n\tconst { memo: memoProp = false } = options;\n\n\tlet WrappedComponent = forwardRef( Component );\n\tif ( memoProp ) {\n\t\t// @ts-ignore\n\t\tWrappedComponent = memo( WrappedComponent );\n\t}\n\n\tif ( typeof namespace === 'undefined' ) {\n\t\twarn( 'contextConnect: Please provide a namespace' );\n\t}\n\n\t// @ts-ignore internal property\n\tlet mergedNamespace = WrappedComponent[ CONNECT_STATIC_NAMESPACE ] || [\n\t\tnamespace,\n\t];\n\n\t/**\n\t * Consolidate (merge) namespaces before attaching it to the WrappedComponent.\n\t */\n\tif ( Array.isArray( namespace ) ) {\n\t\tmergedNamespace = [ ...mergedNamespace, ...namespace ];\n\t}\n\tif ( typeof namespace === 'string' ) {\n\t\tmergedNamespace = [ ...mergedNamespace, namespace ];\n\t}\n\n\tWrappedComponent.displayName = namespace;\n\n\t// @ts-ignore internal property\n\tWrappedComponent[ CONNECT_STATIC_NAMESPACE ] = uniq( mergedNamespace );\n\n\t// @ts-ignore WordPressComponent property\n\tWrappedComponent.selector = `.${ getStyledClassNameFromKey( namespace ) }`;\n\n\t// @ts-ignore\n\treturn WrappedComponent;\n}\n\n/**\n * Attempts to retrieve the connected namespace from a component.\n *\n * @param {import('react').ReactChild | undefined | {}} Component The component to retrieve a namespace from.\n * @return {Array<string>} The connected namespaces.\n */\nexport function getConnectNamespace( Component ) {\n\tif ( ! Component ) return [];\n\n\tlet namespaces = [];\n\n\t// @ts-ignore internal property\n\tif ( Component[ CONNECT_STATIC_NAMESPACE ] ) {\n\t\t// @ts-ignore internal property\n\t\tnamespaces = Component[ CONNECT_STATIC_NAMESPACE ];\n\t}\n\n\t// @ts-ignore\n\tif ( Component.type && Component.type[ CONNECT_STATIC_NAMESPACE ] ) {\n\t\t// @ts-ignore\n\t\tnamespaces = Component.type[ CONNECT_STATIC_NAMESPACE ];\n\t}\n\n\treturn namespaces;\n}\n\n/**\n * Checks to see if a component is connected within the Context system.\n *\n * @param {import('react').ReactNode} Component The component to retrieve a namespace from.\n * @param {Array<string>|string} match The namespace to check.\n * @return {boolean} The result.\n */\nexport function hasConnectNamespace( Component, match ) {\n\tif ( ! Component ) return false;\n\n\tif ( typeof match === 'string' ) {\n\t\treturn getConnectNamespace( Component ).includes( match );\n\t}\n\tif ( Array.isArray( match ) ) {\n\t\treturn match.some( ( result ) =>\n\t\t\tgetConnectNamespace( Component ).includes( result )\n\t\t);\n\t}\n\n\treturn false;\n}\n"]}
1
+ {"version":3,"sources":["@wordpress/components/src/ui/context/context-connect.ts"],"names":["contextConnect","Component","namespace","options","memo","memoProp","WrappedComponent","mergedNamespace","CONNECT_STATIC_NAMESPACE","Array","isArray","displayName","selector","getConnectNamespace","namespaces","type","hasConnectNamespace","match","includes","some","result"],"mappings":";;;;;;;;;;;AAGA;;AAMA;;AACA;;AAKA;;AACA;;AAhBA;AACA;AACA;;AAIA;AACA;AACA;;AAIA;AACA;AACA;;AAUA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASA,cAAT,CACNC,SADM,EAENC,SAFM,EAI6B;AAAA,MADnCC,OACmC,uEADF,EACE;AACnC,QAAM;AAAEC,IAAAA,IAAI,EAAEC,QAAQ,GAAG;AAAnB,MAA6BF,OAAnC;AAEA,MAAIG,gBAAgB,GAAG,yBAAYL,SAAZ,CAAvB;;AACA,MAAKI,QAAL,EAAgB;AACf;AACAC,IAAAA,gBAAgB,GAAG,mBAAMA,gBAAN,CAAnB;AACA;;AAED,MAAK,OAAOJ,SAAP,KAAqB,WAA1B,EAAwC;AACvC,mHAAM,4CAAN;AACA,GAXkC,CAanC;;;AACA,MAAIK,eAAe,GAAGD,gBAAgB,CAAEE,mCAAF,CAAhB,IAAgD,CACrEN,SADqE,CAAtE;AAIA;AACD;AACA;;AACC,MAAKO,KAAK,CAACC,OAAN,CAAeR,SAAf,CAAL,EAAkC;AACjCK,IAAAA,eAAe,GAAG,CAAE,GAAGA,eAAL,EAAsB,GAAGL,SAAzB,CAAlB;AACA;;AACD,MAAK,OAAOA,SAAP,KAAqB,QAA1B,EAAqC;AACpCK,IAAAA,eAAe,GAAG,CAAE,GAAGA,eAAL,EAAsBL,SAAtB,CAAlB;AACA;;AAEDI,EAAAA,gBAAgB,CAACK,WAAjB,GAA+BT,SAA/B,CA5BmC,CA8BnC;;AACAI,EAAAA,gBAAgB,CAAEE,mCAAF,CAAhB,GAA+C,kBAAMD,eAAN,CAA/C,CA/BmC,CAiCnC;;AACAD,EAAAA,gBAAgB,CAACM,QAAjB,GAA6B,IAAI,0DAA2BV,SAA3B,CAAwC,EAAzE,CAlCmC,CAoCnC;;AACA,SAAOI,gBAAP;AACA;AAED;AACA;AACA;AACA;AACA;AACA;;;AACO,SAASO,mBAAT,CACNZ,SADM,EAEK;AACX,MAAK,CAAEA,SAAP,EAAmB,OAAO,EAAP;AAEnB,MAAIa,UAAU,GAAG,EAAjB,CAHW,CAKX;;AACA,MAAKb,SAAS,CAAEO,mCAAF,CAAd,EAA6C;AAC5C;AACAM,IAAAA,UAAU,GAAGb,SAAS,CAAEO,mCAAF,CAAtB;AACA,GATU,CAWX;;;AACA,MAAKP,SAAS,CAACc,IAAV,IAAkBd,SAAS,CAACc,IAAV,CAAgBP,mCAAhB,CAAvB,EAAoE;AACnE;AACAM,IAAAA,UAAU,GAAGb,SAAS,CAACc,IAAV,CAAgBP,mCAAhB,CAAb;AACA;;AAED,SAAOM,UAAP;AACA;AAED;AACA;AACA;AACA;AACA;AACA;;;AACO,SAASE,mBAAT,CACNf,SADM,EAENgB,KAFM,EAGI;AACV,MAAK,CAAEhB,SAAP,EAAmB,OAAO,KAAP;;AAEnB,MAAK,OAAOgB,KAAP,KAAiB,QAAtB,EAAiC;AAChC,WAAOJ,mBAAmB,CAAEZ,SAAF,CAAnB,CAAiCiB,QAAjC,CAA2CD,KAA3C,CAAP;AACA;;AACD,MAAKR,KAAK,CAACC,OAAN,CAAeO,KAAf,CAAL,EAA8B;AAC7B,WAAOA,KAAK,CAACE,IAAN,CAAcC,MAAF,IAClBP,mBAAmB,CAAEZ,SAAF,CAAnB,CAAiCiB,QAAjC,CAA2CE,MAA3C,CADM,CAAP;AAGA;;AAED,SAAO,KAAP;AACA","sourcesContent":["/**\n * External dependencies\n */\nimport { uniq } from 'lodash';\nimport type { ForwardedRef, ReactChild, ReactNode } from 'react';\n\n/**\n * WordPress dependencies\n */\nimport { forwardRef, memo } from '@wordpress/element';\nimport warn from '@wordpress/warning';\n\n/**\n * Internal dependencies\n */\nimport { CONNECT_STATIC_NAMESPACE } from './constants';\nimport { getStyledClassNameFromKey } from './get-styled-class-name-from-key';\nimport type { WordPressComponentFromProps } from '.';\n\ntype ContextConnectOptions = {\n\t/** Defaults to `false`. */\n\tmemo?: boolean;\n};\n\n/**\n * Forwards ref (React.ForwardRef) and \"Connects\" (or registers) a component\n * within the Context system under a specified namespace.\n *\n * This is an (experimental) evolution of the initial connect() HOC.\n * The hope is that we can improve render performance by removing functional\n * component wrappers.\n *\n * @param Component The component to register into the Context system.\n * @param namespace The namespace to register the component under.\n * @param options\n * @return The connected WordPressComponent\n */\nexport function contextConnect< P >(\n\tComponent: ( props: P, ref: ForwardedRef< any > ) => JSX.Element | null,\n\tnamespace: string,\n\toptions: ContextConnectOptions = {}\n): WordPressComponentFromProps< P > {\n\tconst { memo: memoProp = false } = options;\n\n\tlet WrappedComponent = forwardRef( Component );\n\tif ( memoProp ) {\n\t\t// @ts-ignore\n\t\tWrappedComponent = memo( WrappedComponent );\n\t}\n\n\tif ( typeof namespace === 'undefined' ) {\n\t\twarn( 'contextConnect: Please provide a namespace' );\n\t}\n\n\t// @ts-ignore internal property\n\tlet mergedNamespace = WrappedComponent[ CONNECT_STATIC_NAMESPACE ] || [\n\t\tnamespace,\n\t];\n\n\t/**\n\t * Consolidate (merge) namespaces before attaching it to the WrappedComponent.\n\t */\n\tif ( Array.isArray( namespace ) ) {\n\t\tmergedNamespace = [ ...mergedNamespace, ...namespace ];\n\t}\n\tif ( typeof namespace === 'string' ) {\n\t\tmergedNamespace = [ ...mergedNamespace, namespace ];\n\t}\n\n\tWrappedComponent.displayName = namespace;\n\n\t// @ts-ignore internal property\n\tWrappedComponent[ CONNECT_STATIC_NAMESPACE ] = uniq( mergedNamespace );\n\n\t// @ts-ignore WordPressComponent property\n\tWrappedComponent.selector = `.${ getStyledClassNameFromKey( namespace ) }`;\n\n\t// @ts-ignore\n\treturn WrappedComponent;\n}\n\n/**\n * Attempts to retrieve the connected namespace from a component.\n *\n * @param Component The component to retrieve a namespace from.\n * @return The connected namespaces.\n */\nexport function getConnectNamespace(\n\tComponent: ReactChild | undefined | {}\n): string[] {\n\tif ( ! Component ) return [];\n\n\tlet namespaces = [];\n\n\t// @ts-ignore internal property\n\tif ( Component[ CONNECT_STATIC_NAMESPACE ] ) {\n\t\t// @ts-ignore internal property\n\t\tnamespaces = Component[ CONNECT_STATIC_NAMESPACE ];\n\t}\n\n\t// @ts-ignore\n\tif ( Component.type && Component.type[ CONNECT_STATIC_NAMESPACE ] ) {\n\t\t// @ts-ignore\n\t\tnamespaces = Component.type[ CONNECT_STATIC_NAMESPACE ];\n\t}\n\n\treturn namespaces;\n}\n\n/**\n * Checks to see if a component is connected within the Context system.\n *\n * @param Component The component to retrieve a namespace from.\n * @param match The namespace to check.\n */\nexport function hasConnectNamespace(\n\tComponent: ReactNode,\n\tmatch: string[] | string\n): boolean {\n\tif ( ! Component ) return false;\n\n\tif ( typeof match === 'string' ) {\n\t\treturn getConnectNamespace( Component ).includes( match );\n\t}\n\tif ( Array.isArray( match ) ) {\n\t\treturn match.some( ( result ) =>\n\t\t\tgetConnectNamespace( Component ).includes( result )\n\t\t);\n\t}\n\n\treturn false;\n}\n"]}
@@ -65,8 +65,8 @@ function useContextSystemBridge(_ref) {
65
65
  const parentContext = useComponentsContext();
66
66
  const valueRef = (0, _element.useRef)(value);
67
67
  useUpdateEffect(() => {
68
- if ( // objects are equivalent
69
- (0, _lodash.isEqual)(valueRef.current, value) && // but not the same reference
68
+ if ( // Objects are equivalent.
69
+ (0, _lodash.isEqual)(valueRef.current, value) && // But not the same reference.
70
70
  valueRef.current !== value) {
71
71
  typeof process !== "undefined" && process.env && process.env.NODE_ENV !== "production" ? (0, _warning.default)(`Please memoize your context: ${JSON.stringify(value)}`) : void 0;
72
72
  }
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/components/src/ui/context/context-system-provider.js"],"names":["ComponentsContext","useComponentsContext","useUpdateEffect","effect","deps","mounted","current","undefined","useContextSystemBridge","value","parentContext","valueRef","JSON","stringify","config","BaseContextSystemProvider","children","contextValue","ContextSystemProvider"],"mappings":";;;;;;;;;AAQA;;AALA;;AAaA;;AAhBA;AACA;AACA;;AAGA;AACA;AACA;AAWO,MAAMA,iBAAiB,GAAG;AAChC;AAAqC,EADL,CAA1B;;;AAGA,MAAMC,oBAAoB,GAAG,MAAM,yBAAYD,iBAAZ,CAAnC;AAEP;AACA;AACA;AACA;AACA;AACA;;;;;AACA,SAASE,eAAT,CAA0BC,MAA1B,EAAkCC,IAAlC,EAAyC;AACxC,QAAMC,OAAO,GAAG,qBAAQ,KAAR,CAAhB;AACA,0BAAW,MAAM;AAChB,QAAKA,OAAO,CAACC,OAAb,EAAuB;AACtB,aAAOH,MAAM,EAAb;AACA;;AACDE,IAAAA,OAAO,CAACC,OAAR,GAAkB,IAAlB;AACA,WAAOC,SAAP;AACA,GAND,EAMGH,IANH;AAOA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AACA,SAASI,sBAAT,OAA6C;AAAA,MAAZ;AAAEC,IAAAA;AAAF,GAAY;AAC5C,QAAMC,aAAa,GAAGT,oBAAoB,EAA1C;AAEA,QAAMU,QAAQ,GAAG,qBAAQF,KAAR,CAAjB;AAEAP,EAAAA,eAAe,CAAE,MAAM;AACtB,SACC;AACA,yBAASS,QAAQ,CAACL,OAAlB,EAA2BG,KAA3B,KACA;AACAE,IAAAA,QAAQ,CAACL,OAAT,KAAqBG,KAJtB,EAKE;AACD,qHAAO,gCAAgCG,IAAI,CAACC,SAAL,CAAgBJ,KAAhB,CAAyB,EAAhE;AACA;AACD,GATc,EASZ,CAAEA,KAAF,CATY,CAAf,CAL4C,CAgB5C;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,QAAMK,MAAM,GAAG,sBAAS,MAAM;AAC7B,WAAO,mBAAO,uBAAWJ,aAAX,CAAP,EAAmCD,KAAnC,CAAP;AACA,GAFc,EAEZ,CAAEC,aAAF,EAAiBD,KAAjB,CAFY,CAAf;AAIA,SAAOK,MAAP;AACA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AACA,MAAMC,yBAAyB,GAAG,SAA2B;AAAA,MAAzB;AAAEC,IAAAA,QAAF;AAAYP,IAAAA;AAAZ,GAAyB;AAC5D,QAAMQ,YAAY,GAAGT,sBAAsB,CAAE;AAAEC,IAAAA;AAAF,GAAF,CAA3C;AAEA,SACC,4BAAC,iBAAD,CAAmB,QAAnB;AAA4B,IAAA,KAAK,EAAGQ;AAApC,KACGD,QADH,CADD;AAKA,CARD;;AAUO,MAAME,qBAAqB,GAAG,mBAAMH,yBAAN,CAA9B","sourcesContent":["/**\n * External dependencies\n */\nimport { isEqual, merge, cloneDeep } from 'lodash';\n\n/**\n * WordPress dependencies\n */\nimport {\n\tcreateContext,\n\tuseContext,\n\tuseRef,\n\tuseEffect,\n\tuseMemo,\n\tmemo,\n} from '@wordpress/element';\nimport warn from '@wordpress/warning';\n\nexport const ComponentsContext = createContext(\n\t/** @type {Record<string, any>} */ ( {} )\n);\nexport const useComponentsContext = () => useContext( ComponentsContext );\n\n/**\n * Runs an effect only on update (i.e., ignores the first render)\n *\n * @param {import('react').EffectCallback} effect\n * @param {import('react').DependencyList} deps\n */\nfunction useUpdateEffect( effect, deps ) {\n\tconst mounted = useRef( false );\n\tuseEffect( () => {\n\t\tif ( mounted.current ) {\n\t\t\treturn effect();\n\t\t}\n\t\tmounted.current = true;\n\t\treturn undefined;\n\t}, deps );\n}\n\n/**\n * Consolidates incoming ContextSystem values with a (potential) parent ContextSystem value.\n *\n * Note: This function will warn if it detects an un-memoized `value`\n *\n * @param {Object} props\n * @param {Record<string, any>} props.value\n * @return {Record<string, any>} The consolidated value.\n */\nfunction useContextSystemBridge( { value } ) {\n\tconst parentContext = useComponentsContext();\n\n\tconst valueRef = useRef( value );\n\n\tuseUpdateEffect( () => {\n\t\tif (\n\t\t\t// objects are equivalent\n\t\t\tisEqual( valueRef.current, value ) &&\n\t\t\t// but not the same reference\n\t\t\tvalueRef.current !== value\n\t\t) {\n\t\t\twarn( `Please memoize your context: ${ JSON.stringify( value ) }` );\n\t\t}\n\t}, [ value ] );\n\n\t// `parentContext` will always be memoized (i.e., the result of this hook itself)\n\t// or the default value from when the `ComponentsContext` was originally\n\t// initialized (which will never change, it's a static variable)\n\t// so this memoization will prevent `merge` and `cloneDeep` from rerunning unless\n\t// the references to `value` change OR the `parentContext` has an actual material change\n\t// (because again, it's guaranteed to be memoized or a static reference to the empty object\n\t// so we know that the only changes for `parentContext` are material ones... i.e., why we\n\t// don't have to warn in the `useUpdateEffect` hook above for `parentContext` and we only\n\t// need to bother with the `value`). The `useUpdateEffect` above will ensure that we are\n\t// correctly warning when the `value` isn't being properly memoized. All of that to say\n\t// that this should be super safe to assume that `useMemo` will only run on actual\n\t// changes to the two dependencies, therefore saving us calls to `merge` and `cloneDeep`!\n\tconst config = useMemo( () => {\n\t\treturn merge( cloneDeep( parentContext ), value );\n\t}, [ parentContext, value ] );\n\n\treturn config;\n}\n\n/**\n * A Provider component that can modify props for connected components within\n * the Context system.\n *\n * @example\n * ```jsx\n * <ContextSystemProvider value={{ Button: { size: 'small' }}}>\n * <Button>...</Button>\n * </ContextSystemProvider>\n * ```\n *\n * @template {Record<string, any>} T\n * @param {Object} options\n * @param {import('react').ReactNode} options.children Children to render.\n * @param {T} options.value Props to render into connected components.\n * @return {JSX.Element} A Provider wrapped component.\n */\nconst BaseContextSystemProvider = ( { children, value } ) => {\n\tconst contextValue = useContextSystemBridge( { value } );\n\n\treturn (\n\t\t<ComponentsContext.Provider value={ contextValue }>\n\t\t\t{ children }\n\t\t</ComponentsContext.Provider>\n\t);\n};\n\nexport const ContextSystemProvider = memo( BaseContextSystemProvider );\n"]}
1
+ {"version":3,"sources":["@wordpress/components/src/ui/context/context-system-provider.js"],"names":["ComponentsContext","useComponentsContext","useUpdateEffect","effect","deps","mounted","current","undefined","useContextSystemBridge","value","parentContext","valueRef","JSON","stringify","config","BaseContextSystemProvider","children","contextValue","ContextSystemProvider"],"mappings":";;;;;;;;;AAQA;;AALA;;AAaA;;AAhBA;AACA;AACA;;AAGA;AACA;AACA;AAWO,MAAMA,iBAAiB,GAAG;AAChC;AAAqC,EADL,CAA1B;;;AAGA,MAAMC,oBAAoB,GAAG,MAAM,yBAAYD,iBAAZ,CAAnC;AAEP;AACA;AACA;AACA;AACA;AACA;;;;;AACA,SAASE,eAAT,CAA0BC,MAA1B,EAAkCC,IAAlC,EAAyC;AACxC,QAAMC,OAAO,GAAG,qBAAQ,KAAR,CAAhB;AACA,0BAAW,MAAM;AAChB,QAAKA,OAAO,CAACC,OAAb,EAAuB;AACtB,aAAOH,MAAM,EAAb;AACA;;AACDE,IAAAA,OAAO,CAACC,OAAR,GAAkB,IAAlB;AACA,WAAOC,SAAP;AACA,GAND,EAMGH,IANH;AAOA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AACA,SAASI,sBAAT,OAA6C;AAAA,MAAZ;AAAEC,IAAAA;AAAF,GAAY;AAC5C,QAAMC,aAAa,GAAGT,oBAAoB,EAA1C;AAEA,QAAMU,QAAQ,GAAG,qBAAQF,KAAR,CAAjB;AAEAP,EAAAA,eAAe,CAAE,MAAM;AACtB,SACC;AACA,yBAASS,QAAQ,CAACL,OAAlB,EAA2BG,KAA3B,KACA;AACAE,IAAAA,QAAQ,CAACL,OAAT,KAAqBG,KAJtB,EAKE;AACD,qHAAO,gCAAgCG,IAAI,CAACC,SAAL,CAAgBJ,KAAhB,CAAyB,EAAhE;AACA;AACD,GATc,EASZ,CAAEA,KAAF,CATY,CAAf,CAL4C,CAgB5C;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,QAAMK,MAAM,GAAG,sBAAS,MAAM;AAC7B,WAAO,mBAAO,uBAAWJ,aAAX,CAAP,EAAmCD,KAAnC,CAAP;AACA,GAFc,EAEZ,CAAEC,aAAF,EAAiBD,KAAjB,CAFY,CAAf;AAIA,SAAOK,MAAP;AACA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AACA,MAAMC,yBAAyB,GAAG,SAA2B;AAAA,MAAzB;AAAEC,IAAAA,QAAF;AAAYP,IAAAA;AAAZ,GAAyB;AAC5D,QAAMQ,YAAY,GAAGT,sBAAsB,CAAE;AAAEC,IAAAA;AAAF,GAAF,CAA3C;AAEA,SACC,4BAAC,iBAAD,CAAmB,QAAnB;AAA4B,IAAA,KAAK,EAAGQ;AAApC,KACGD,QADH,CADD;AAKA,CARD;;AAUO,MAAME,qBAAqB,GAAG,mBAAMH,yBAAN,CAA9B","sourcesContent":["/**\n * External dependencies\n */\nimport { isEqual, merge, cloneDeep } from 'lodash';\n\n/**\n * WordPress dependencies\n */\nimport {\n\tcreateContext,\n\tuseContext,\n\tuseRef,\n\tuseEffect,\n\tuseMemo,\n\tmemo,\n} from '@wordpress/element';\nimport warn from '@wordpress/warning';\n\nexport const ComponentsContext = createContext(\n\t/** @type {Record<string, any>} */ ( {} )\n);\nexport const useComponentsContext = () => useContext( ComponentsContext );\n\n/**\n * Runs an effect only on update (i.e., ignores the first render)\n *\n * @param {import('react').EffectCallback} effect\n * @param {import('react').DependencyList} deps\n */\nfunction useUpdateEffect( effect, deps ) {\n\tconst mounted = useRef( false );\n\tuseEffect( () => {\n\t\tif ( mounted.current ) {\n\t\t\treturn effect();\n\t\t}\n\t\tmounted.current = true;\n\t\treturn undefined;\n\t}, deps );\n}\n\n/**\n * Consolidates incoming ContextSystem values with a (potential) parent ContextSystem value.\n *\n * Note: This function will warn if it detects an un-memoized `value`\n *\n * @param {Object} props\n * @param {Record<string, any>} props.value\n * @return {Record<string, any>} The consolidated value.\n */\nfunction useContextSystemBridge( { value } ) {\n\tconst parentContext = useComponentsContext();\n\n\tconst valueRef = useRef( value );\n\n\tuseUpdateEffect( () => {\n\t\tif (\n\t\t\t// Objects are equivalent.\n\t\t\tisEqual( valueRef.current, value ) &&\n\t\t\t// But not the same reference.\n\t\t\tvalueRef.current !== value\n\t\t) {\n\t\t\twarn( `Please memoize your context: ${ JSON.stringify( value ) }` );\n\t\t}\n\t}, [ value ] );\n\n\t// `parentContext` will always be memoized (i.e., the result of this hook itself)\n\t// or the default value from when the `ComponentsContext` was originally\n\t// initialized (which will never change, it's a static variable)\n\t// so this memoization will prevent `merge` and `cloneDeep` from rerunning unless\n\t// the references to `value` change OR the `parentContext` has an actual material change\n\t// (because again, it's guaranteed to be memoized or a static reference to the empty object\n\t// so we know that the only changes for `parentContext` are material ones... i.e., why we\n\t// don't have to warn in the `useUpdateEffect` hook above for `parentContext` and we only\n\t// need to bother with the `value`). The `useUpdateEffect` above will ensure that we are\n\t// correctly warning when the `value` isn't being properly memoized. All of that to say\n\t// that this should be super safe to assume that `useMemo` will only run on actual\n\t// changes to the two dependencies, therefore saving us calls to `merge` and `cloneDeep`!\n\tconst config = useMemo( () => {\n\t\treturn merge( cloneDeep( parentContext ), value );\n\t}, [ parentContext, value ] );\n\n\treturn config;\n}\n\n/**\n * A Provider component that can modify props for connected components within\n * the Context system.\n *\n * @example\n * ```jsx\n * <ContextSystemProvider value={{ Button: { size: 'small' }}}>\n * <Button>...</Button>\n * </ContextSystemProvider>\n * ```\n *\n * @template {Record<string, any>} T\n * @param {Object} options\n * @param {import('react').ReactNode} options.children Children to render.\n * @param {T} options.value Props to render into connected components.\n * @return {JSX.Element} A Provider wrapped component.\n */\nconst BaseContextSystemProvider = ( { children, value } ) => {\n\tconst contextValue = useContextSystemBridge( { value } );\n\n\treturn (\n\t\t<ComponentsContext.Provider value={ contextValue }>\n\t\t\t{ children }\n\t\t</ComponentsContext.Provider>\n\t);\n};\n\nexport const ContextSystemProvider = memo( BaseContextSystemProvider );\n"]}
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/components/src/ui/context/index.js"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;AAIA;;AAKA;;AACA;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA","sourcesContent":["export {\n\tContextSystemProvider,\n\tuseComponentsContext,\n} from './context-system-provider';\nexport {\n\tcontextConnect,\n\thasConnectNamespace,\n\tgetConnectNamespace,\n} from './context-connect';\nexport { useContextSystem } from './use-context-system';\nexport * from './wordpress-component';\n"]}
1
+ {"version":3,"sources":["@wordpress/components/src/ui/context/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;AAIA;;AAKA;;AACA;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA","sourcesContent":["export {\n\tContextSystemProvider,\n\tuseComponentsContext,\n} from './context-system-provider';\nexport {\n\tcontextConnect,\n\thasConnectNamespace,\n\tgetConnectNamespace,\n} from './context-connect';\nexport { useContextSystem } from './use-context-system';\nexport * from './wordpress-component';\n"]}
@@ -71,9 +71,9 @@ function _getComputedBackgroundColor(backgroundColor) {
71
71
 
72
72
  const el = getColorComputationNode();
73
73
  if (!el) return '';
74
- el.style.background = backgroundColor; // Grab the style
74
+ el.style.background = backgroundColor; // Grab the style.
75
75
 
76
- const computedColor = (_window = window) === null || _window === void 0 ? void 0 : _window.getComputedStyle(el).background; // Reset
76
+ const computedColor = (_window = window) === null || _window === void 0 ? void 0 : _window.getComputedStyle(el).background; // Reset.
77
77
 
78
78
  el.style.background = '';
79
79
  return computedColor || '';
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/components/src/ui/utils/colors.js"],"names":["colorComputationNode","namesPlugin","getColorComputationNode","document","el","createElement","setAttribute","body","appendChild","isColor","value","test","isValid","_getComputedBackgroundColor","backgroundColor","includes","style","background","computedColor","window","getComputedStyle","getComputedBackgroundColor","getOptimalTextColor","isLight","getOptimalTextShade","result"],"mappings":";;;;;;;;;;AAGA;;AACA;;AACA;;AALA;AACA;AACA;;AAKA;AACA,IAAIA,oBAAJ;AAEA,oBAAQ,CAAEC,cAAF,CAAR;AAEA;AACA;AACA;;AACA,SAASC,uBAAT,GAAmC;AAClC,MAAK,OAAOC,QAAP,KAAoB,WAAzB,EAAuC;;AAEvC,MAAK,CAAEH,oBAAP,EAA8B;AAC7B;AACA,UAAMI,EAAE,GAAGD,QAAQ,CAACE,aAAT,CAAwB,KAAxB,CAAX;AACAD,IAAAA,EAAE,CAACE,YAAH,CAAiB,gCAAjB,EAAmD,EAAnD,EAH6B,CAI7B;;AACAH,IAAAA,QAAQ,CAACI,IAAT,CAAcC,WAAd,CAA2BJ,EAA3B;AACAJ,IAAAA,oBAAoB,GAAGI,EAAvB;AACA;;AAED,SAAOJ,oBAAP;AACA;AAED;AACA;AACA;AACA;AACA;;;AACA,SAASS,OAAT,CAAkBC,KAAlB,EAA0B;AACzB,MAAK,OAAOA,KAAP,KAAiB,QAAtB,EAAiC,OAAO,KAAP;AACjC,QAAMC,IAAI,GAAG,oBAAQD,KAAR,CAAb;AAEA,SAAOC,IAAI,CAACC,OAAL,EAAP;AACA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AACA,SAASC,2BAAT,CAAsCC,eAAtC,EAAwD;AAAA;;AACvD,MAAK,OAAOA,eAAP,KAA2B,QAAhC,EAA2C,OAAO,EAAP;AAE3C,MAAKL,OAAO,CAAEK,eAAF,CAAZ,EAAkC,OAAOA,eAAP;AAElC,MAAK,CAAEA,eAAe,CAACC,QAAhB,CAA0B,MAA1B,CAAP,EAA4C,OAAO,EAAP;AAC5C,MAAK,OAAOZ,QAAP,KAAoB,WAAzB,EAAuC,OAAO,EAAP,CANgB,CAQvD;;AACA,QAAMC,EAAE,GAAGF,uBAAuB,EAAlC;AACA,MAAK,CAAEE,EAAP,EAAY,OAAO,EAAP;AAEZA,EAAAA,EAAE,CAACY,KAAH,CAASC,UAAT,GAAsBH,eAAtB,CAZuD,CAavD;;AACA,QAAMI,aAAa,cAAGC,MAAH,4CAAG,QAAQC,gBAAR,CAA0BhB,EAA1B,EAA+Ba,UAArD,CAduD,CAevD;;AACAb,EAAAA,EAAE,CAACY,KAAH,CAASC,UAAT,GAAsB,EAAtB;AAEA,SAAOC,aAAa,IAAI,EAAxB;AACA;;AAED,MAAMG,0BAA0B,GAAG,qBAASR,2BAAT,CAAnC;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AACO,SAASS,mBAAT,CAA8BR,eAA9B,EAAgD;AACtD,QAAMG,UAAU,GAAGI,0BAA0B,CAAEP,eAAF,CAA7C;AAEA,SAAO,oBAAQG,UAAR,EAAqBM,OAArB,KAAiC,SAAjC,GAA6C,SAApD;AACA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;;;AACO,SAASC,mBAAT,CAA8BV,eAA9B,EAAgD;AACtD,QAAMW,MAAM,GAAGH,mBAAmB,CAAER,eAAF,CAAlC;AAEA,SAAOW,MAAM,KAAK,SAAX,GAAuB,MAAvB,GAAgC,OAAvC;AACA","sourcesContent":["/**\n * External dependencies\n */\nimport memoize from 'memize';\nimport { colord, extend } from 'colord';\nimport namesPlugin from 'colord/plugins/names';\n\n/** @type {HTMLDivElement} */\nlet colorComputationNode;\n\nextend( [ namesPlugin ] );\n\n/**\n * @return {HTMLDivElement | undefined} The HTML element for color computation.\n */\nfunction getColorComputationNode() {\n\tif ( typeof document === 'undefined' ) return;\n\n\tif ( ! colorComputationNode ) {\n\t\t// Create a temporary element for style computation.\n\t\tconst el = document.createElement( 'div' );\n\t\tel.setAttribute( 'data-g2-color-computation-node', '' );\n\t\t// Inject for window computed style.\n\t\tdocument.body.appendChild( el );\n\t\tcolorComputationNode = el;\n\t}\n\n\treturn colorComputationNode;\n}\n\n/**\n * @param {string | unknown} value\n *\n * @return {boolean} Whether the value is a valid color.\n */\nfunction isColor( value ) {\n\tif ( typeof value !== 'string' ) return false;\n\tconst test = colord( value );\n\n\treturn test.isValid();\n}\n\n/**\n * Retrieves the computed background color. This is useful for getting the\n * value of a CSS variable color.\n *\n * @param {string | unknown} backgroundColor The background color to compute.\n *\n * @return {string} The computed background color.\n */\nfunction _getComputedBackgroundColor( backgroundColor ) {\n\tif ( typeof backgroundColor !== 'string' ) return '';\n\n\tif ( isColor( backgroundColor ) ) return backgroundColor;\n\n\tif ( ! backgroundColor.includes( 'var(' ) ) return '';\n\tif ( typeof document === 'undefined' ) return '';\n\n\t// Attempts to gracefully handle CSS variables color values.\n\tconst el = getColorComputationNode();\n\tif ( ! el ) return '';\n\n\tel.style.background = backgroundColor;\n\t// Grab the style\n\tconst computedColor = window?.getComputedStyle( el ).background;\n\t// Reset\n\tel.style.background = '';\n\n\treturn computedColor || '';\n}\n\nconst getComputedBackgroundColor = memoize( _getComputedBackgroundColor );\n\n/**\n * Get the text shade optimized for readability, based on a background color.\n *\n * @param {string | unknown} backgroundColor The background color.\n *\n * @return {string} The optimized text color (black or white).\n */\nexport function getOptimalTextColor( backgroundColor ) {\n\tconst background = getComputedBackgroundColor( backgroundColor );\n\n\treturn colord( background ).isLight() ? '#000000' : '#ffffff';\n}\n\n/**\n * Get the text shade optimized for readability, based on a background color.\n *\n * @param {string | unknown} backgroundColor The background color.\n *\n * @return {string} The optimized text shade (dark or light).\n */\nexport function getOptimalTextShade( backgroundColor ) {\n\tconst result = getOptimalTextColor( backgroundColor );\n\n\treturn result === '#000000' ? 'dark' : 'light';\n}\n"]}
1
+ {"version":3,"sources":["@wordpress/components/src/ui/utils/colors.js"],"names":["colorComputationNode","namesPlugin","getColorComputationNode","document","el","createElement","setAttribute","body","appendChild","isColor","value","test","isValid","_getComputedBackgroundColor","backgroundColor","includes","style","background","computedColor","window","getComputedStyle","getComputedBackgroundColor","getOptim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KAAH,CAASC,UAAT,GAAsBH,eAAtB,CAZuD,CAavD;;AACA,QAAMI,aAAa,cAAGC,MAAH,4CAAG,QAAQC,gBAAR,CAA0BhB,EAA1B,EAA+Ba,UAArD,CAduD,CAevD;;AACAb,EAAAA,EAAE,CAACY,KAAH,CAASC,UAAT,GAAsB,EAAtB;AAEA,SAAOC,aAAa,IAAI,EAAxB;AACA;;AAED,MAAMG,0BAA0B,GAAG,qBAASR,2BAAT,CAAnC;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AACO,SAASS,mBAAT,CAA8BR,eAA9B,EAAgD;AACtD,QAAMG,UAAU,GAAGI,0BAA0B,CAAEP,eAAF,CAA7C;AAEA,SAAO,oBAAQG,UAAR,EAAqBM,OAArB,KAAiC,SAAjC,GAA6C,SAApD;AACA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;;;AACO,SAASC,mBAAT,CAA8BV,eAA9B,EAAgD;AACtD,QAAMW,MAAM,GAAGH,mBAAmB,CAAER,eAAF,CAAlC;AAEA,SAAOW,MAAM,KAAK,SAAX,GAAuB,MAAvB,GAAgC,OAAvC;AACA","sourcesContent":["/**\n * External dependencies\n */\nimport memoize from 'memize';\nimport { colord, extend } from 'colord';\nimport namesPlugin from 'colord/plugins/names';\n\n/** @type {HTMLDivElement} */\nlet colorComputationNode;\n\nextend( [ namesPlugin ] );\n\n/**\n * @return {HTMLDivElement | undefined} The HTML element for color computation.\n */\nfunction getColorComputationNode() {\n\tif ( typeof document === 'undefined' ) return;\n\n\tif ( ! colorComputationNode ) {\n\t\t// Create a temporary element for style computation.\n\t\tconst el = document.createElement( 'div' );\n\t\tel.setAttribute( 'data-g2-color-computation-node', '' );\n\t\t// Inject for window computed style.\n\t\tdocument.body.appendChild( el );\n\t\tcolorComputationNode = el;\n\t}\n\n\treturn colorComputationNode;\n}\n\n/**\n * @param {string | unknown} value\n *\n * @return {boolean} Whether the value is a valid color.\n */\nfunction isColor( value ) {\n\tif ( typeof value !== 'string' ) return false;\n\tconst test = colord( value );\n\n\treturn test.isValid();\n}\n\n/**\n * Retrieves the computed background color. This is useful for getting the\n * value of a CSS variable color.\n *\n * @param {string | unknown} backgroundColor The background color to compute.\n *\n * @return {string} The computed background color.\n */\nfunction _getComputedBackgroundColor( backgroundColor ) {\n\tif ( typeof backgroundColor !== 'string' ) return '';\n\n\tif ( isColor( backgroundColor ) ) return backgroundColor;\n\n\tif ( ! backgroundColor.includes( 'var(' ) ) return '';\n\tif ( typeof document === 'undefined' ) return '';\n\n\t// Attempts to gracefully handle CSS variables color values.\n\tconst el = getColorComputationNode();\n\tif ( ! el ) return '';\n\n\tel.style.background = backgroundColor;\n\t// Grab the style.\n\tconst computedColor = window?.getComputedStyle( el ).background;\n\t// Reset.\n\tel.style.background = '';\n\n\treturn computedColor || '';\n}\n\nconst getComputedBackgroundColor = memoize( _getComputedBackgroundColor );\n\n/**\n * Get the text shade optimized for readability, based on a background color.\n *\n * @param {string | unknown} backgroundColor The background color.\n *\n * @return {string} The optimized text color (black or white).\n */\nexport function getOptimalTextColor( backgroundColor ) {\n\tconst background = getComputedBackgroundColor( backgroundColor );\n\n\treturn colord( background ).isLight() ? '#000000' : '#ffffff';\n}\n\n/**\n * Get the text shade optimized for readability, based on a background color.\n *\n * @param {string | unknown} backgroundColor The background color.\n *\n * @return {string} The optimized text shade (dark or light).\n */\nexport function getOptimalTextShade( backgroundColor ) {\n\tconst result = getOptimalTextColor( backgroundColor );\n\n\treturn result === '#000000' ? 'dark' : 'light';\n}\n"]}
@@ -26,14 +26,14 @@ function space(value) {
26
26
 
27
27
  if (typeof value === 'undefined') {
28
28
  return undefined;
29
- } // handle empty strings, if it's the number 0 this still works
29
+ } // Handle empty strings, if it's the number 0 this still works.
30
30
 
31
31
 
32
32
  if (!value) {
33
33
  return '0';
34
34
  }
35
35
 
36
- const asInt = typeof value === 'number' ? value : Number(value); // test if the input has a unit, was NaN, or was one of the named CSS values (like `auto`), in which case just use that value
36
+ const asInt = typeof value === 'number' ? value : Number(value); // Test if the input has a unit, was NaN, or was one of the named CSS values (like `auto`), in which case just use that value.
37
37
 
38
38
  if (typeof window !== 'undefined' && (_window$CSS = window.CSS) !== null && _window$CSS !== void 0 && (_window$CSS$supports = _window$CSS.supports) !== null && _window$CSS$supports !== void 0 && _window$CSS$supports.call(_window$CSS, 'margin', value.toString()) || Number.isNaN(asInt)) {
39
39
  return value.toString();
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/components/src/ui/utils/space.ts"],"names":["GRID_BASE","space","value","undefined","asInt","Number","window","CSS","supports","toString","isNaN"],"mappings":";;;;;;;AAAA;AACA;AACA;AAGA,MAAMA,SAAS,GAAG,KAAlB;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACO,SAASC,KAAT,CAAgBC,KAAhB,EAAyD;AAAA;;AAC/D,MAAK,OAAOA,KAAP,KAAiB,WAAtB,EAAoC;AACnC,WAAOC,SAAP;AACA,GAH8D,CAK/D;;;AACA,MAAK,CAAED,KAAP,EAAe;AACd,WAAO,GAAP;AACA;;AAED,QAAME,KAAK,GAAG,OAAOF,KAAP,KAAiB,QAAjB,GAA4BA,KAA5B,GAAoCG,MAAM,CAAEH,KAAF,CAAxD,CAV+D,CAY/D;;AACA,MACG,OAAOI,MAAP,KAAkB,WAAlB,mBACDA,MAAM,CAACC,GADN,gEACD,YAAYC,QADX,iDACD,uCAAwB,QAAxB,EAAkCN,KAAK,CAACO,QAAN,EAAlC,CADD,IAEAJ,MAAM,CAACK,KAAP,CAAcN,KAAd,CAHD,EAIE;AACD,WAAOF,KAAK,CAACO,QAAN,EAAP;AACA;;AAED,SAAQ,QAAQT,SAAW,MAAME,KAAO,GAAxC;AACA","sourcesContent":["/**\n * A real number or something parsable as a number\n */\nexport type SpaceInput = number | string;\n\nconst GRID_BASE = '4px';\n\n/**\n * A function that handles numbers, numeric strings, and unit values.\n *\n * When given a number or a numeric string, it will return the grid-based\n * value as a factor of GRID_BASE, defined above.\n *\n * When given a unit value or one of the named CSS values like `auto`,\n * it will simply return the value back.\n *\n * @param value A number, numeric string, or a unit value.\n */\nexport function space( value?: SpaceInput ): string | undefined {\n\tif ( typeof value === 'undefined' ) {\n\t\treturn undefined;\n\t}\n\n\t// handle empty strings, if it's the number 0 this still works\n\tif ( ! value ) {\n\t\treturn '0';\n\t}\n\n\tconst asInt = typeof value === 'number' ? value : Number( value );\n\n\t// test if the input has a unit, was NaN, or was one of the named CSS values (like `auto`), in which case just use that value\n\tif (\n\t\t( typeof window !== 'undefined' &&\n\t\t\twindow.CSS?.supports?.( 'margin', value.toString() ) ) ||\n\t\tNumber.isNaN( asInt )\n\t) {\n\t\treturn value.toString();\n\t}\n\n\treturn `calc(${ GRID_BASE } * ${ value })`;\n}\n"]}
1
+ {"version":3,"sources":["@wordpress/components/src/ui/utils/space.ts"],"names":["GRID_BASE","space","value","undefined","asInt","Number","window","CSS","supports","toString","isNaN"],"mappings":";;;;;;;AAAA;AACA;AACA;AAGA,MAAMA,SAAS,GAAG,KAAlB;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACO,SAASC,KAAT,CAAgBC,KAAhB,EAAyD;AAAA;;AAC/D,MAAK,OAAOA,KAAP,KAAiB,WAAtB,EAAoC;AACnC,WAAOC,SAAP;AACA,GAH8D,CAK/D;;;AACA,MAAK,CAAED,KAAP,EAAe;AACd,WAAO,GAAP;AACA;;AAED,QAAME,KAAK,GAAG,OAAOF,KAAP,KAAiB,QAAjB,GAA4BA,KAA5B,GAAoCG,MAAM,CAAEH,KAAF,CAAxD,CAV+D,CAY/D;;AACA,MACG,OAAOI,MAAP,KAAkB,WAAlB,mBACDA,MAAM,CAACC,GADN,gEACD,YAAYC,QADX,iDACD,uCAAwB,QAAxB,EAAkCN,KAAK,CAACO,QAAN,EAAlC,CADD,IAEAJ,MAAM,CAACK,KAAP,CAAcN,KAAd,CAHD,EAIE;AACD,WAAOF,KAAK,CAACO,QAAN,EAAP;AACA;;AAED,SAAQ,QAAQT,SAAW,MAAME,KAAO,GAAxC;AACA","sourcesContent":["/**\n * A real number or something parsable as a number\n */\nexport type SpaceInput = number | string;\n\nconst GRID_BASE = '4px';\n\n/**\n * A function that handles numbers, numeric strings, and unit values.\n *\n * When given a number or a numeric string, it will return the grid-based\n * value as a factor of GRID_BASE, defined above.\n *\n * When given a unit value or one of the named CSS values like `auto`,\n * it will simply return the value back.\n *\n * @param value A number, numeric string, or a unit value.\n */\nexport function space( value?: SpaceInput ): string | undefined {\n\tif ( typeof value === 'undefined' ) {\n\t\treturn undefined;\n\t}\n\n\t// Handle empty strings, if it's the number 0 this still works.\n\tif ( ! value ) {\n\t\treturn '0';\n\t}\n\n\tconst asInt = typeof value === 'number' ? value : Number( value );\n\n\t// Test if the input has a unit, was NaN, or was one of the named CSS values (like `auto`), in which case just use that value.\n\tif (\n\t\t( typeof window !== 'undefined' &&\n\t\t\twindow.CSS?.supports?.( 'margin', value.toString() ) ) ||\n\t\tNumber.isNaN( asInt )\n\t) {\n\t\treturn value.toString();\n\t}\n\n\treturn `calc(${ GRID_BASE } * ${ value })`;\n}\n"]}