@wordpress/components 28.6.0 → 28.8.1-next.5368f64a9.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 (644) hide show
  1. package/CHANGELOG.md +107 -0
  2. package/CONTRIBUTING.md +42 -19
  3. package/build/alignment-matrix-control/cell.js +4 -7
  4. package/build/alignment-matrix-control/cell.js.map +1 -1
  5. package/build/alignment-matrix-control/icon.js +31 -19
  6. package/build/alignment-matrix-control/icon.js.map +1 -1
  7. package/build/alignment-matrix-control/index.js +55 -51
  8. package/build/alignment-matrix-control/index.js.map +1 -1
  9. package/build/alignment-matrix-control/styles.js +73 -0
  10. package/build/alignment-matrix-control/styles.js.map +1 -0
  11. package/build/alignment-matrix-control/types.js.map +1 -1
  12. package/build/angle-picker-control/angle-circle.js +9 -9
  13. package/build/angle-picker-control/angle-circle.js.map +1 -1
  14. package/build/border-control/border-control/component.js +18 -13
  15. package/build/border-control/border-control/component.js.map +1 -1
  16. package/build/circular-option-picker/circular-option-picker-option.js +15 -9
  17. package/build/circular-option-picker/circular-option-picker-option.js.map +1 -1
  18. package/build/circular-option-picker/circular-option-picker.js +15 -12
  19. package/build/circular-option-picker/circular-option-picker.js.map +1 -1
  20. package/build/circular-option-picker/types.js.map +1 -1
  21. package/build/clipboard-button/index.js +6 -6
  22. package/build/clipboard-button/index.js.map +1 -1
  23. package/build/color-palette/utils.js +1 -2
  24. package/build/color-palette/utils.js.map +1 -1
  25. package/build/color-picker/color-copy-button.js +8 -8
  26. package/build/color-picker/color-copy-button.js.map +1 -1
  27. package/build/color-picker/hex-input.js +8 -8
  28. package/build/color-picker/hex-input.js.map +1 -1
  29. package/build/color-picker/input-with-slider.js +8 -8
  30. package/build/color-picker/input-with-slider.js.map +1 -1
  31. package/build/color-picker/styles.js +8 -8
  32. package/build/color-picker/styles.js.map +1 -1
  33. package/build/combobox-control/types.js.map +1 -1
  34. package/build/composite/context.js +1 -1
  35. package/build/composite/context.js.map +1 -1
  36. package/build/composite/group-label.js +33 -0
  37. package/build/composite/group-label.js.map +1 -0
  38. package/build/composite/group.js +33 -0
  39. package/build/composite/group.js.map +1 -0
  40. package/build/composite/hover.js +33 -0
  41. package/build/composite/hover.js.map +1 -0
  42. package/build/composite/index.js +63 -118
  43. package/build/composite/index.js.map +1 -1
  44. package/build/composite/item.js +33 -0
  45. package/build/composite/item.js.map +1 -0
  46. package/build/composite/legacy/index.js +59 -7
  47. package/build/composite/legacy/index.js.map +1 -1
  48. package/build/composite/row.js +33 -0
  49. package/build/composite/row.js.map +1 -0
  50. package/build/composite/typeahead.js +33 -0
  51. package/build/composite/typeahead.js.map +1 -0
  52. package/build/composite/types.js.map +1 -1
  53. package/build/custom-gradient-picker/gradient-bar/control-points.js +8 -8
  54. package/build/custom-gradient-picker/gradient-bar/control-points.js.map +1 -1
  55. package/build/custom-select-control-v2/styles.js +12 -14
  56. package/build/custom-select-control-v2/styles.js.map +1 -1
  57. package/build/date-time/date/index.js +1 -1
  58. package/build/date-time/date/index.js.map +1 -1
  59. package/build/date-time/date/styles.js +37 -26
  60. package/build/date-time/date/styles.js.map +1 -1
  61. package/build/date-time/date/use-lilius/index.js +163 -0
  62. package/build/date-time/date/use-lilius/index.js.map +1 -0
  63. package/build/date-time/time/time-input/index.js +17 -19
  64. package/build/date-time/time/time-input/index.js.map +1 -1
  65. package/build/dimension-control/index.js +6 -1
  66. package/build/dimension-control/index.js.map +1 -1
  67. package/build/draggable/index.js +4 -4
  68. package/build/draggable/index.js.map +1 -1
  69. package/build/dropdown-menu-v2/checkbox-item.js +69 -0
  70. package/build/dropdown-menu-v2/checkbox-item.js.map +1 -0
  71. package/build/dropdown-menu-v2/context.js +17 -0
  72. package/build/dropdown-menu-v2/context.js.map +1 -0
  73. package/build/dropdown-menu-v2/group-label.js +40 -0
  74. package/build/dropdown-menu-v2/group-label.js.map +1 -0
  75. package/build/dropdown-menu-v2/group.js +29 -0
  76. package/build/dropdown-menu-v2/group.js.map +1 -0
  77. package/build/dropdown-menu-v2/index.js +58 -146
  78. package/build/dropdown-menu-v2/index.js.map +1 -1
  79. package/build/dropdown-menu-v2/item-help-text.js +27 -0
  80. package/build/dropdown-menu-v2/item-help-text.js.map +1 -0
  81. package/build/dropdown-menu-v2/item-label.js +27 -0
  82. package/build/dropdown-menu-v2/item-label.js.map +1 -0
  83. package/build/dropdown-menu-v2/item.js +53 -0
  84. package/build/dropdown-menu-v2/item.js.map +1 -0
  85. package/build/dropdown-menu-v2/radio-item.js +79 -0
  86. package/build/dropdown-menu-v2/radio-item.js.map +1 -0
  87. package/build/dropdown-menu-v2/separator.js +30 -0
  88. package/build/dropdown-menu-v2/separator.js.map +1 -0
  89. package/build/dropdown-menu-v2/styles.js +54 -78
  90. package/build/dropdown-menu-v2/styles.js.map +1 -1
  91. package/build/dropdown-menu-v2/types.js.map +1 -1
  92. package/build/dropdown-menu-v2/use-temporary-focus-visible-fix.js +27 -0
  93. package/build/dropdown-menu-v2/use-temporary-focus-visible-fix.js.map +1 -0
  94. package/build/focal-point-picker/styles/focal-point-style.js +7 -2
  95. package/build/focal-point-picker/styles/focal-point-style.js.map +1 -1
  96. package/build/form-token-field/types.js.map +1 -1
  97. package/build/index.js +13 -0
  98. package/build/index.js.map +1 -1
  99. package/build/input-control/index.js +2 -2
  100. package/build/input-control/index.js.map +1 -1
  101. package/build/input-control/input-base.js +5 -10
  102. package/build/input-control/input-base.js.map +1 -1
  103. package/build/input-control/input-prefix-wrapper.js +3 -3
  104. package/build/input-control/input-prefix-wrapper.js.map +1 -1
  105. package/build/input-control/input-suffix-wrapper.js +2 -3
  106. package/build/input-control/input-suffix-wrapper.js.map +1 -1
  107. package/build/input-control/reducer/reducer.js +8 -8
  108. package/build/input-control/reducer/reducer.js.map +1 -1
  109. package/build/input-control/styles/input-control-styles.js +75 -45
  110. package/build/input-control/styles/input-control-styles.js.map +1 -1
  111. package/build/input-control/types.js.map +1 -1
  112. package/build/input-control/utils.js +3 -3
  113. package/build/input-control/utils.js.map +1 -1
  114. package/build/item-group/styles.js +10 -10
  115. package/build/item-group/styles.js.map +1 -1
  116. package/build/modal/index.js +16 -9
  117. package/build/modal/index.js.map +1 -1
  118. package/build/navigation/index.js +4 -4
  119. package/build/navigation/index.js.map +1 -1
  120. package/build/navigation/styles/navigation-styles.js +13 -13
  121. package/build/navigation/styles/navigation-styles.js.map +1 -1
  122. package/build/navigator/index.js +12 -13
  123. package/build/navigator/index.js.map +1 -1
  124. package/build/navigator/navigator-back-button/hook.js +2 -2
  125. package/build/navigator/navigator-back-button/hook.js.map +1 -1
  126. package/build/navigator/navigator-button/hook.js +2 -2
  127. package/build/navigator/navigator-button/hook.js.map +1 -1
  128. package/build/navigator/navigator-provider/component.js +99 -67
  129. package/build/navigator/navigator-provider/component.js.map +1 -1
  130. package/build/navigator/navigator-screen/component.js +5 -0
  131. package/build/navigator/navigator-screen/component.js.map +1 -1
  132. package/build/navigator/navigator-to-parent-button/component.js +2 -2
  133. package/build/navigator/navigator-to-parent-button/component.js.map +1 -1
  134. package/build/navigator/types.js.map +1 -1
  135. package/build/navigator/use-navigator.js +1 -2
  136. package/build/navigator/use-navigator.js.map +1 -1
  137. package/build/palette-edit/index.js +2 -2
  138. package/build/palette-edit/index.js.map +1 -1
  139. package/build/private-apis.js +1 -14
  140. package/build/private-apis.js.map +1 -1
  141. package/build/range-control/styles/range-control-styles.js +30 -30
  142. package/build/range-control/styles/range-control-styles.js.map +1 -1
  143. package/build/resizable-box/resize-tooltip/styles/resize-tooltip.styles.js +4 -4
  144. package/build/resizable-box/resize-tooltip/styles/resize-tooltip.styles.js.map +1 -1
  145. package/build/select-control/styles/select-control-styles.js +12 -12
  146. package/build/select-control/styles/select-control-styles.js.map +1 -1
  147. package/build/slot-fill/bubbles-virtually/fill.js +4 -4
  148. package/build/slot-fill/bubbles-virtually/fill.js.map +1 -1
  149. package/build/slot-fill/index.js +1 -0
  150. package/build/slot-fill/index.js.map +1 -1
  151. package/build/snackbar/index.js +4 -4
  152. package/build/snackbar/index.js.map +1 -1
  153. package/build/tabs/index.js +4 -4
  154. package/build/tabs/index.js.map +1 -1
  155. package/build/tabs/styles.js +3 -3
  156. package/build/tabs/styles.js.map +1 -1
  157. package/build/tabs/tablist.js +5 -4
  158. package/build/tabs/tablist.js.map +1 -1
  159. package/build/toggle-group-control/toggle-group-control/utils.js +6 -6
  160. package/build/toggle-group-control/toggle-group-control/utils.js.map +1 -1
  161. package/build/tools-panel/tools-panel/hook.js +6 -6
  162. package/build/tools-panel/tools-panel/hook.js.map +1 -1
  163. package/build/unit-control/styles/unit-control-styles.js +7 -7
  164. package/build/unit-control/styles/unit-control-styles.js.map +1 -1
  165. package/build/utils/config-values.js +6 -4
  166. package/build/utils/config-values.js.map +1 -1
  167. package/build/utils/element-rect.js +73 -105
  168. package/build/utils/element-rect.js.map +1 -1
  169. package/build/utils/hooks/use-update-effect.js +4 -4
  170. package/build/utils/hooks/use-update-effect.js.map +1 -1
  171. package/build-module/alignment-matrix-control/cell.js +2 -5
  172. package/build-module/alignment-matrix-control/cell.js.map +1 -1
  173. package/build-module/alignment-matrix-control/icon.js +31 -19
  174. package/build-module/alignment-matrix-control/icon.js.map +1 -1
  175. package/build-module/alignment-matrix-control/index.js +55 -50
  176. package/build-module/alignment-matrix-control/index.js.map +1 -1
  177. package/build-module/alignment-matrix-control/styles.js +70 -0
  178. package/build-module/alignment-matrix-control/styles.js.map +1 -0
  179. package/build-module/alignment-matrix-control/types.js.map +1 -1
  180. package/build-module/angle-picker-control/angle-circle.js +9 -9
  181. package/build-module/angle-picker-control/angle-circle.js.map +1 -1
  182. package/build-module/border-control/border-control/component.js +18 -13
  183. package/build-module/border-control/border-control/component.js.map +1 -1
  184. package/build-module/circular-option-picker/circular-option-picker-option.js +16 -10
  185. package/build-module/circular-option-picker/circular-option-picker-option.js.map +1 -1
  186. package/build-module/circular-option-picker/circular-option-picker.js +16 -13
  187. package/build-module/circular-option-picker/circular-option-picker.js.map +1 -1
  188. package/build-module/circular-option-picker/types.js.map +1 -1
  189. package/build-module/clipboard-button/index.js +6 -6
  190. package/build-module/clipboard-button/index.js.map +1 -1
  191. package/build-module/color-palette/utils.js +1 -2
  192. package/build-module/color-palette/utils.js.map +1 -1
  193. package/build-module/color-picker/color-copy-button.js +8 -8
  194. package/build-module/color-picker/color-copy-button.js.map +1 -1
  195. package/build-module/color-picker/hex-input.js +7 -8
  196. package/build-module/color-picker/hex-input.js.map +1 -1
  197. package/build-module/color-picker/input-with-slider.js +7 -8
  198. package/build-module/color-picker/input-with-slider.js.map +1 -1
  199. package/build-module/color-picker/styles.js +8 -8
  200. package/build-module/color-picker/styles.js.map +1 -1
  201. package/build-module/combobox-control/types.js.map +1 -1
  202. package/build-module/composite/context.js +1 -1
  203. package/build-module/composite/context.js.map +1 -1
  204. package/build-module/composite/group-label.js +25 -0
  205. package/build-module/composite/group-label.js.map +1 -0
  206. package/build-module/composite/group.js +25 -0
  207. package/build-module/composite/group.js.map +1 -0
  208. package/build-module/composite/hover.js +25 -0
  209. package/build-module/composite/hover.js.map +1 -0
  210. package/build-module/composite/index.js +64 -118
  211. package/build-module/composite/index.js.map +1 -1
  212. package/build-module/composite/item.js +25 -0
  213. package/build-module/composite/item.js.map +1 -0
  214. package/build-module/composite/legacy/index.js +57 -8
  215. package/build-module/composite/legacy/index.js.map +1 -1
  216. package/build-module/composite/row.js +25 -0
  217. package/build-module/composite/row.js.map +1 -0
  218. package/build-module/composite/typeahead.js +25 -0
  219. package/build-module/composite/typeahead.js.map +1 -0
  220. package/build-module/composite/types.js.map +1 -1
  221. package/build-module/custom-gradient-picker/gradient-bar/control-points.js +8 -8
  222. package/build-module/custom-gradient-picker/gradient-bar/control-points.js.map +1 -1
  223. package/build-module/custom-select-control-v2/styles.js +12 -14
  224. package/build-module/custom-select-control-v2/styles.js.map +1 -1
  225. package/build-module/date-time/date/index.js +1 -2
  226. package/build-module/date-time/date/index.js.map +1 -1
  227. package/build-module/date-time/date/styles.js +33 -26
  228. package/build-module/date-time/date/styles.js.map +1 -1
  229. package/build-module/date-time/date/use-lilius/index.js +158 -0
  230. package/build-module/date-time/date/use-lilius/index.js.map +1 -0
  231. package/build-module/date-time/time/time-input/index.js +17 -19
  232. package/build-module/date-time/time/time-input/index.js.map +1 -1
  233. package/build-module/dimension-control/index.js +6 -1
  234. package/build-module/dimension-control/index.js.map +1 -1
  235. package/build-module/draggable/index.js +4 -4
  236. package/build-module/draggable/index.js.map +1 -1
  237. package/build-module/dropdown-menu-v2/checkbox-item.js +62 -0
  238. package/build-module/dropdown-menu-v2/checkbox-item.js.map +1 -0
  239. package/build-module/dropdown-menu-v2/context.js +11 -0
  240. package/build-module/dropdown-menu-v2/context.js.map +1 -0
  241. package/build-module/dropdown-menu-v2/group-label.js +32 -0
  242. package/build-module/dropdown-menu-v2/group-label.js.map +1 -0
  243. package/build-module/dropdown-menu-v2/group.js +21 -0
  244. package/build-module/dropdown-menu-v2/group.js.map +1 -0
  245. package/build-module/dropdown-menu-v2/index.js +57 -144
  246. package/build-module/dropdown-menu-v2/index.js.map +1 -1
  247. package/build-module/dropdown-menu-v2/item-help-text.js +19 -0
  248. package/build-module/dropdown-menu-v2/item-help-text.js.map +1 -0
  249. package/build-module/dropdown-menu-v2/item-label.js +19 -0
  250. package/build-module/dropdown-menu-v2/item-label.js.map +1 -0
  251. package/build-module/dropdown-menu-v2/item.js +46 -0
  252. package/build-module/dropdown-menu-v2/item.js.map +1 -0
  253. package/build-module/dropdown-menu-v2/radio-item.js +72 -0
  254. package/build-module/dropdown-menu-v2/radio-item.js.map +1 -0
  255. package/build-module/dropdown-menu-v2/separator.js +22 -0
  256. package/build-module/dropdown-menu-v2/separator.js.map +1 -0
  257. package/build-module/dropdown-menu-v2/styles.js +54 -78
  258. package/build-module/dropdown-menu-v2/styles.js.map +1 -1
  259. package/build-module/dropdown-menu-v2/types.js.map +1 -1
  260. package/build-module/dropdown-menu-v2/use-temporary-focus-visible-fix.js +20 -0
  261. package/build-module/dropdown-menu-v2/use-temporary-focus-visible-fix.js.map +1 -0
  262. package/build-module/focal-point-picker/styles/focal-point-style.js +6 -2
  263. package/build-module/focal-point-picker/styles/focal-point-style.js.map +1 -1
  264. package/build-module/form-token-field/types.js.map +1 -1
  265. package/build-module/index.js +3 -1
  266. package/build-module/index.js.map +1 -1
  267. package/build-module/input-control/index.js +2 -2
  268. package/build-module/input-control/index.js.map +1 -1
  269. package/build-module/input-control/input-base.js +6 -11
  270. package/build-module/input-control/input-base.js.map +1 -1
  271. package/build-module/input-control/input-prefix-wrapper.js +4 -3
  272. package/build-module/input-control/input-prefix-wrapper.js.map +1 -1
  273. package/build-module/input-control/input-suffix-wrapper.js +3 -3
  274. package/build-module/input-control/input-suffix-wrapper.js.map +1 -1
  275. package/build-module/input-control/reducer/reducer.js +8 -8
  276. package/build-module/input-control/reducer/reducer.js.map +1 -1
  277. package/build-module/input-control/styles/input-control-styles.js +74 -44
  278. package/build-module/input-control/styles/input-control-styles.js.map +1 -1
  279. package/build-module/input-control/types.js.map +1 -1
  280. package/build-module/input-control/utils.js +3 -3
  281. package/build-module/input-control/utils.js.map +1 -1
  282. package/build-module/item-group/styles.js +10 -10
  283. package/build-module/item-group/styles.js.map +1 -1
  284. package/build-module/modal/index.js +17 -9
  285. package/build-module/modal/index.js.map +1 -1
  286. package/build-module/navigation/index.js +4 -4
  287. package/build-module/navigation/index.js.map +1 -1
  288. package/build-module/navigation/styles/navigation-styles.js +14 -14
  289. package/build-module/navigation/styles/navigation-styles.js.map +1 -1
  290. package/build-module/navigator/index.js +6 -6
  291. package/build-module/navigator/index.js.map +1 -1
  292. package/build-module/navigator/navigator-back-button/hook.js +1 -1
  293. package/build-module/navigator/navigator-back-button/hook.js.map +1 -1
  294. package/build-module/navigator/navigator-button/hook.js +1 -1
  295. package/build-module/navigator/navigator-button/hook.js.map +1 -1
  296. package/build-module/navigator/navigator-provider/component.js +99 -67
  297. package/build-module/navigator/navigator-provider/component.js.map +1 -1
  298. package/build-module/navigator/navigator-screen/component.js +4 -0
  299. package/build-module/navigator/navigator-screen/component.js.map +1 -1
  300. package/build-module/navigator/navigator-to-parent-button/component.js +1 -1
  301. package/build-module/navigator/navigator-to-parent-button/component.js.map +1 -1
  302. package/build-module/navigator/types.js.map +1 -1
  303. package/build-module/navigator/use-navigator.js +1 -2
  304. package/build-module/navigator/use-navigator.js.map +1 -1
  305. package/build-module/palette-edit/index.js +2 -2
  306. package/build-module/palette-edit/index.js.map +1 -1
  307. package/build-module/private-apis.js +1 -14
  308. package/build-module/private-apis.js.map +1 -1
  309. package/build-module/range-control/styles/range-control-styles.js +31 -31
  310. package/build-module/range-control/styles/range-control-styles.js.map +1 -1
  311. package/build-module/resizable-box/resize-tooltip/styles/resize-tooltip.styles.js +5 -5
  312. package/build-module/resizable-box/resize-tooltip/styles/resize-tooltip.styles.js.map +1 -1
  313. package/build-module/select-control/styles/select-control-styles.js +13 -13
  314. package/build-module/select-control/styles/select-control-styles.js.map +1 -1
  315. package/build-module/slot-fill/bubbles-virtually/fill.js +4 -4
  316. package/build-module/slot-fill/bubbles-virtually/fill.js.map +1 -1
  317. package/build-module/slot-fill/index.js +1 -0
  318. package/build-module/slot-fill/index.js.map +1 -1
  319. package/build-module/snackbar/index.js +4 -4
  320. package/build-module/snackbar/index.js.map +1 -1
  321. package/build-module/tabs/index.js +4 -4
  322. package/build-module/tabs/index.js.map +1 -1
  323. package/build-module/tabs/styles.js +4 -4
  324. package/build-module/tabs/styles.js.map +1 -1
  325. package/build-module/tabs/tablist.js +5 -4
  326. package/build-module/tabs/tablist.js.map +1 -1
  327. package/build-module/toggle-group-control/toggle-group-control/utils.js +6 -6
  328. package/build-module/toggle-group-control/toggle-group-control/utils.js.map +1 -1
  329. package/build-module/tools-panel/tools-panel/hook.js +6 -6
  330. package/build-module/tools-panel/tools-panel/hook.js.map +1 -1
  331. package/build-module/unit-control/styles/unit-control-styles.js +7 -7
  332. package/build-module/unit-control/styles/unit-control-styles.js.map +1 -1
  333. package/build-module/utils/config-values.js +6 -4
  334. package/build-module/utils/config-values.js.map +1 -1
  335. package/build-module/utils/element-rect.js +74 -105
  336. package/build-module/utils/element-rect.js.map +1 -1
  337. package/build-module/utils/hooks/use-update-effect.js +4 -4
  338. package/build-module/utils/hooks/use-update-effect.js.map +1 -1
  339. package/build-style/style-rtl.css +11 -27
  340. package/build-style/style.css +11 -27
  341. package/build-types/alignment-matrix-control/cell.d.ts +1 -1
  342. package/build-types/alignment-matrix-control/cell.d.ts.map +1 -1
  343. package/build-types/alignment-matrix-control/icon.d.ts +1 -1
  344. package/build-types/alignment-matrix-control/icon.d.ts.map +1 -1
  345. package/build-types/alignment-matrix-control/index.d.ts +16 -6
  346. package/build-types/alignment-matrix-control/index.d.ts.map +1 -1
  347. package/build-types/alignment-matrix-control/stories/index.story.d.ts.map +1 -1
  348. package/build-types/alignment-matrix-control/{styles/alignment-matrix-control-styles.d.ts → styles.d.ts} +9 -10
  349. package/build-types/alignment-matrix-control/styles.d.ts.map +1 -0
  350. package/build-types/alignment-matrix-control/types.d.ts +12 -1
  351. package/build-types/alignment-matrix-control/types.d.ts.map +1 -1
  352. package/build-types/angle-picker-control/angle-circle.d.ts.map +1 -1
  353. package/build-types/border-control/border-control/component.d.ts.map +1 -1
  354. package/build-types/box-control/stories/index.story.d.ts.map +1 -1
  355. package/build-types/circular-option-picker/circular-option-picker-option.d.ts.map +1 -1
  356. package/build-types/circular-option-picker/circular-option-picker.d.ts.map +1 -1
  357. package/build-types/circular-option-picker/types.d.ts +2 -2
  358. package/build-types/circular-option-picker/types.d.ts.map +1 -1
  359. package/build-types/color-palette/utils.d.ts.map +1 -1
  360. package/build-types/color-picker/color-copy-button.d.ts.map +1 -1
  361. package/build-types/color-picker/hex-input.d.ts.map +1 -1
  362. package/build-types/color-picker/input-with-slider.d.ts.map +1 -1
  363. package/build-types/color-picker/styles.d.ts.map +1 -1
  364. package/build-types/combobox-control/types.d.ts +1 -0
  365. package/build-types/combobox-control/types.d.ts.map +1 -1
  366. package/build-types/composite/context.d.ts.map +1 -1
  367. package/build-types/composite/group-label.d.ts +3 -0
  368. package/build-types/composite/group-label.d.ts.map +1 -0
  369. package/build-types/composite/group.d.ts +3 -0
  370. package/build-types/composite/group.d.ts.map +1 -0
  371. package/build-types/composite/hover.d.ts +3 -0
  372. package/build-types/composite/hover.d.ts.map +1 -0
  373. package/build-types/composite/index.d.ts +63 -47
  374. package/build-types/composite/index.d.ts.map +1 -1
  375. package/build-types/composite/item.d.ts +3 -0
  376. package/build-types/composite/item.d.ts.map +1 -0
  377. package/build-types/composite/legacy/index.d.ts +23 -3
  378. package/build-types/composite/legacy/index.d.ts.map +1 -1
  379. package/build-types/composite/legacy/stories/index.story.d.ts.map +1 -1
  380. package/build-types/composite/row.d.ts +3 -0
  381. package/build-types/composite/row.d.ts.map +1 -0
  382. package/build-types/composite/stories/index.story.d.ts +9 -8
  383. package/build-types/composite/stories/index.story.d.ts.map +1 -1
  384. package/build-types/composite/typeahead.d.ts +3 -0
  385. package/build-types/composite/typeahead.d.ts.map +1 -0
  386. package/build-types/composite/types.d.ts +12 -11
  387. package/build-types/composite/types.d.ts.map +1 -1
  388. package/build-types/date-time/date/index.d.ts +0 -3
  389. package/build-types/date-time/date/index.d.ts.map +1 -1
  390. package/build-types/date-time/date/styles.d.ts.map +1 -1
  391. package/build-types/date-time/date/test/use-lilius.d.ts +2 -0
  392. package/build-types/date-time/date/test/use-lilius.d.ts.map +1 -0
  393. package/build-types/date-time/date/use-lilius/index.d.ts +169 -0
  394. package/build-types/date-time/date/use-lilius/index.d.ts.map +1 -0
  395. package/build-types/date-time/time/time-input/index.d.ts.map +1 -1
  396. package/build-types/dimension-control/index.d.ts +1 -1
  397. package/build-types/dimension-control/index.d.ts.map +1 -1
  398. package/build-types/dimension-control/stories/index.story.d.ts +5 -0
  399. package/build-types/dimension-control/stories/index.story.d.ts.map +1 -1
  400. package/build-types/dropdown-menu-v2/checkbox-item.d.ts +3 -0
  401. package/build-types/dropdown-menu-v2/checkbox-item.d.ts.map +1 -0
  402. package/build-types/dropdown-menu-v2/context.d.ts +6 -0
  403. package/build-types/dropdown-menu-v2/context.d.ts.map +1 -0
  404. package/build-types/dropdown-menu-v2/group-label.d.ts +3 -0
  405. package/build-types/dropdown-menu-v2/group-label.d.ts.map +1 -0
  406. package/build-types/dropdown-menu-v2/group.d.ts +3 -0
  407. package/build-types/dropdown-menu-v2/group.d.ts.map +1 -0
  408. package/build-types/dropdown-menu-v2/index.d.ts +39 -18
  409. package/build-types/dropdown-menu-v2/index.d.ts.map +1 -1
  410. package/build-types/dropdown-menu-v2/item-help-text.d.ts +6 -0
  411. package/build-types/dropdown-menu-v2/item-help-text.d.ts.map +1 -0
  412. package/build-types/dropdown-menu-v2/item-label.d.ts +6 -0
  413. package/build-types/dropdown-menu-v2/item-label.d.ts.map +1 -0
  414. package/build-types/dropdown-menu-v2/item.d.ts +3 -0
  415. package/build-types/dropdown-menu-v2/item.d.ts.map +1 -0
  416. package/build-types/dropdown-menu-v2/radio-item.d.ts +3 -0
  417. package/build-types/dropdown-menu-v2/radio-item.d.ts.map +1 -0
  418. package/build-types/dropdown-menu-v2/separator.d.ts +3 -0
  419. package/build-types/dropdown-menu-v2/separator.d.ts.map +1 -0
  420. package/build-types/dropdown-menu-v2/stories/index.story.d.ts +10 -10
  421. package/build-types/dropdown-menu-v2/stories/index.story.d.ts.map +1 -1
  422. package/build-types/dropdown-menu-v2/styles.d.ts +14 -6
  423. package/build-types/dropdown-menu-v2/styles.d.ts.map +1 -1
  424. package/build-types/dropdown-menu-v2/types.d.ts +6 -0
  425. package/build-types/dropdown-menu-v2/types.d.ts.map +1 -1
  426. package/build-types/dropdown-menu-v2/use-temporary-focus-visible-fix.d.ts +8 -0
  427. package/build-types/dropdown-menu-v2/use-temporary-focus-visible-fix.d.ts.map +1 -0
  428. package/build-types/focal-point-picker/styles/focal-point-style.d.ts.map +1 -1
  429. package/build-types/form-token-field/types.d.ts +1 -0
  430. package/build-types/form-token-field/types.d.ts.map +1 -1
  431. package/build-types/index.d.ts +4 -1
  432. package/build-types/index.d.ts.map +1 -1
  433. package/build-types/input-control/input-base.d.ts.map +1 -1
  434. package/build-types/input-control/input-prefix-wrapper.d.ts +2 -2
  435. package/build-types/input-control/input-prefix-wrapper.d.ts.map +1 -1
  436. package/build-types/input-control/input-suffix-wrapper.d.ts +2 -2
  437. package/build-types/input-control/input-suffix-wrapper.d.ts.map +1 -1
  438. package/build-types/input-control/reducer/reducer.d.ts.map +1 -1
  439. package/build-types/input-control/stories/index.story.d.ts +9 -0
  440. package/build-types/input-control/stories/index.story.d.ts.map +1 -1
  441. package/build-types/input-control/styles/input-control-styles.d.ts +15 -9
  442. package/build-types/input-control/styles/input-control-styles.d.ts.map +1 -1
  443. package/build-types/input-control/types.d.ts +23 -6
  444. package/build-types/input-control/types.d.ts.map +1 -1
  445. package/build-types/modal/index.d.ts.map +1 -1
  446. package/build-types/modal/stories/index.story.d.ts +3 -0
  447. package/build-types/modal/stories/index.story.d.ts.map +1 -1
  448. package/build-types/navigation/styles/navigation-styles.d.ts.map +1 -1
  449. package/build-types/navigator/index.d.ts +6 -6
  450. package/build-types/navigator/index.d.ts.map +1 -1
  451. package/build-types/navigator/navigator-provider/component.d.ts.map +1 -1
  452. package/build-types/navigator/navigator-screen/component.d.ts.map +1 -1
  453. package/build-types/navigator/stories/index.story.d.ts +1 -1
  454. package/build-types/navigator/stories/index.story.d.ts.map +1 -1
  455. package/build-types/navigator/types.d.ts +3 -1
  456. package/build-types/navigator/types.d.ts.map +1 -1
  457. package/build-types/navigator/use-navigator.d.ts +1 -2
  458. package/build-types/navigator/use-navigator.d.ts.map +1 -1
  459. package/build-types/private-apis.d.ts.map +1 -1
  460. package/build-types/range-control/styles/range-control-styles.d.ts.map +1 -1
  461. package/build-types/resizable-box/resize-tooltip/styles/resize-tooltip.styles.d.ts.map +1 -1
  462. package/build-types/select-control/styles/select-control-styles.d.ts +1 -1
  463. package/build-types/select-control/styles/select-control-styles.d.ts.map +1 -1
  464. package/build-types/slot-fill/index.d.ts +3 -0
  465. package/build-types/slot-fill/index.d.ts.map +1 -1
  466. package/build-types/tabs/index.d.ts.map +1 -1
  467. package/build-types/tabs/styles.d.ts.map +1 -1
  468. package/build-types/tabs/tablist.d.ts.map +1 -1
  469. package/build-types/unit-control/styles/unit-control-styles.d.ts.map +1 -1
  470. package/build-types/utils/config-values.d.ts +3 -3
  471. package/build-types/utils/element-rect.d.ts +32 -74
  472. package/build-types/utils/element-rect.d.ts.map +1 -1
  473. package/package.json +19 -20
  474. package/src/alignment-matrix-control/README.md +1 -5
  475. package/src/alignment-matrix-control/cell.tsx +3 -9
  476. package/src/alignment-matrix-control/icon.tsx +48 -30
  477. package/src/alignment-matrix-control/index.tsx +60 -50
  478. package/src/alignment-matrix-control/stories/index.story.tsx +3 -12
  479. package/src/alignment-matrix-control/styles.ts +113 -0
  480. package/src/alignment-matrix-control/types.ts +12 -1
  481. package/src/angle-picker-control/angle-circle.tsx +11 -9
  482. package/src/border-control/border-control/component.tsx +23 -16
  483. package/src/circular-option-picker/circular-option-picker-option.tsx +16 -19
  484. package/src/circular-option-picker/circular-option-picker.tsx +26 -12
  485. package/src/circular-option-picker/types.ts +2 -2
  486. package/src/clipboard-button/index.tsx +6 -6
  487. package/src/color-palette/test/utils.ts +21 -2
  488. package/src/color-palette/utils.ts +1 -3
  489. package/src/color-picker/color-copy-button.tsx +10 -8
  490. package/src/color-picker/hex-input.tsx +6 -10
  491. package/src/color-picker/input-with-slider.tsx +6 -10
  492. package/src/color-picker/styles.ts +1 -1
  493. package/src/combobox-control/types.ts +1 -0
  494. package/src/composite/README.md +5 -24
  495. package/src/composite/{context.ts → context.tsx} +1 -2
  496. package/src/composite/group-label.tsx +30 -0
  497. package/src/composite/group.tsx +30 -0
  498. package/src/composite/hover.tsx +30 -0
  499. package/src/composite/index.tsx +71 -166
  500. package/src/composite/item.tsx +30 -0
  501. package/src/composite/legacy/index.tsx +73 -11
  502. package/src/composite/legacy/stories/index.story.tsx +2 -1
  503. package/src/composite/legacy/test/index.tsx +57 -1
  504. package/src/composite/row.tsx +30 -0
  505. package/src/composite/stories/index.story.tsx +254 -365
  506. package/src/composite/typeahead.tsx +30 -0
  507. package/src/composite/types.ts +14 -16
  508. package/src/custom-gradient-picker/gradient-bar/control-points.tsx +10 -10
  509. package/src/custom-gradient-picker/style.scss +2 -21
  510. package/src/custom-select-control-v2/styles.ts +4 -4
  511. package/src/date-time/date/index.tsx +1 -1
  512. package/src/date-time/date/styles.ts +33 -13
  513. package/src/date-time/date/test/use-lilius.ts +417 -0
  514. package/src/date-time/date/use-lilius/index.ts +394 -0
  515. package/src/date-time/time/test/index.tsx +3 -6
  516. package/src/date-time/time/time-input/index.tsx +25 -25
  517. package/src/date-time/time/time-input/test/index.tsx +6 -7
  518. package/src/dimension-control/README.md +4 -0
  519. package/src/dimension-control/index.tsx +7 -1
  520. package/src/dimension-control/stories/index.story.tsx +7 -2
  521. package/src/dimension-control/test/__snapshots__/index.test.js.snap +16 -16
  522. package/src/dimension-control/test/index.test.js +1 -0
  523. package/src/draggable/index.tsx +4 -4
  524. package/src/dropdown-menu-v2/README.md +73 -60
  525. package/src/dropdown-menu-v2/checkbox-item.tsx +63 -0
  526. package/src/dropdown-menu-v2/context.tsx +13 -0
  527. package/src/dropdown-menu-v2/group-label.tsx +37 -0
  528. package/src/dropdown-menu-v2/group.tsx +26 -0
  529. package/src/dropdown-menu-v2/index.tsx +57 -197
  530. package/src/dropdown-menu-v2/item-help-text.tsx +23 -0
  531. package/src/dropdown-menu-v2/item-label.tsx +23 -0
  532. package/src/dropdown-menu-v2/item.tsx +50 -0
  533. package/src/dropdown-menu-v2/radio-item.tsx +70 -0
  534. package/src/dropdown-menu-v2/separator.tsx +27 -0
  535. package/src/dropdown-menu-v2/stories/index.story.tsx +295 -262
  536. package/src/dropdown-menu-v2/styles.ts +102 -66
  537. package/src/dropdown-menu-v2/test/index.tsx +159 -132
  538. package/src/dropdown-menu-v2/types.ts +7 -0
  539. package/src/dropdown-menu-v2/use-temporary-focus-visible-fix.ts +22 -0
  540. package/src/focal-point-picker/styles/focal-point-style.ts +6 -1
  541. package/src/form-toggle/style.scss +1 -1
  542. package/src/form-token-field/style.scss +2 -3
  543. package/src/form-token-field/types.ts +1 -0
  544. package/src/index.ts +6 -1
  545. package/src/input-control/index.tsx +2 -2
  546. package/src/input-control/input-base.tsx +4 -14
  547. package/src/input-control/input-prefix-wrapper.tsx +8 -4
  548. package/src/input-control/input-suffix-wrapper.tsx +4 -6
  549. package/src/input-control/reducer/reducer.ts +13 -10
  550. package/src/input-control/stories/index.story.tsx +31 -12
  551. package/src/input-control/styles/input-control-styles.tsx +42 -11
  552. package/src/input-control/types.ts +23 -7
  553. package/src/input-control/utils.ts +3 -3
  554. package/src/item-group/styles.ts +3 -3
  555. package/src/item-group/test/__snapshots__/index.js.snap +3 -3
  556. package/src/modal/index.tsx +21 -12
  557. package/src/modal/stories/index.story.tsx +8 -14
  558. package/src/modal/style.scss +5 -9
  559. package/src/navigation/index.tsx +4 -4
  560. package/src/navigation/styles/navigation-styles.tsx +3 -3
  561. package/src/navigator/index.ts +6 -6
  562. package/src/navigator/navigator-back-button/hook.ts +1 -1
  563. package/src/navigator/navigator-button/hook.ts +1 -1
  564. package/src/navigator/navigator-provider/README.md +2 -3
  565. package/src/navigator/navigator-provider/component.tsx +97 -82
  566. package/src/navigator/navigator-screen/component.tsx +7 -0
  567. package/src/navigator/navigator-to-parent-button/component.tsx +1 -1
  568. package/src/navigator/stories/index.story.tsx +82 -253
  569. package/src/navigator/test/index.tsx +8 -0
  570. package/src/navigator/types.ts +3 -1
  571. package/src/navigator/use-navigator.ts +1 -3
  572. package/src/palette-edit/index.tsx +2 -2
  573. package/src/private-apis.ts +1 -23
  574. package/src/range-control/styles/range-control-styles.ts +7 -7
  575. package/src/resizable-box/resize-tooltip/styles/resize-tooltip.styles.ts +2 -2
  576. package/src/resizable-box/style.scss +2 -2
  577. package/src/select-control/README.md +2 -2
  578. package/src/select-control/styles/select-control-styles.ts +5 -5
  579. package/src/slot-fill/bubbles-virtually/fill.tsx +4 -4
  580. package/src/slot-fill/index.tsx +1 -0
  581. package/src/snackbar/index.tsx +4 -4
  582. package/src/tab-panel/style.scss +0 -1
  583. package/src/tabs/index.tsx +8 -4
  584. package/src/tabs/styles.ts +42 -14
  585. package/src/tabs/tablist.tsx +5 -4
  586. package/src/text-control/style.scss +3 -2
  587. package/src/toggle-group-control/toggle-group-control/utils.ts +7 -7
  588. package/src/tools-panel/tools-panel/hook.ts +6 -6
  589. package/src/unit-control/styles/unit-control-styles.ts +2 -1
  590. package/src/utils/config-values.js +6 -4
  591. package/src/utils/element-rect.ts +93 -130
  592. package/src/utils/hooks/use-update-effect.js +4 -4
  593. package/tsconfig.tsbuildinfo +1 -1
  594. package/build/alignment-matrix-control/styles/alignment-matrix-control-icon-styles.js +0 -66
  595. package/build/alignment-matrix-control/styles/alignment-matrix-control-icon-styles.js.map +0 -1
  596. package/build/alignment-matrix-control/styles/alignment-matrix-control-styles.js +0 -77
  597. package/build/alignment-matrix-control/styles/alignment-matrix-control-styles.js.map +0 -1
  598. package/build/navigator/navigator-back-button/index.js +0 -14
  599. package/build/navigator/navigator-back-button/index.js.map +0 -1
  600. package/build/navigator/navigator-button/index.js +0 -14
  601. package/build/navigator/navigator-button/index.js.map +0 -1
  602. package/build/navigator/navigator-provider/index.js +0 -14
  603. package/build/navigator/navigator-provider/index.js.map +0 -1
  604. package/build/navigator/navigator-screen/index.js +0 -14
  605. package/build/navigator/navigator-screen/index.js.map +0 -1
  606. package/build/navigator/navigator-to-parent-button/index.js +0 -14
  607. package/build/navigator/navigator-to-parent-button/index.js.map +0 -1
  608. package/build-module/alignment-matrix-control/styles/alignment-matrix-control-icon-styles.js +0 -63
  609. package/build-module/alignment-matrix-control/styles/alignment-matrix-control-icon-styles.js.map +0 -1
  610. package/build-module/alignment-matrix-control/styles/alignment-matrix-control-styles.js +0 -72
  611. package/build-module/alignment-matrix-control/styles/alignment-matrix-control-styles.js.map +0 -1
  612. package/build-module/navigator/navigator-back-button/index.js +0 -2
  613. package/build-module/navigator/navigator-back-button/index.js.map +0 -1
  614. package/build-module/navigator/navigator-button/index.js +0 -2
  615. package/build-module/navigator/navigator-button/index.js.map +0 -1
  616. package/build-module/navigator/navigator-provider/index.js +0 -2
  617. package/build-module/navigator/navigator-provider/index.js.map +0 -1
  618. package/build-module/navigator/navigator-screen/index.js +0 -2
  619. package/build-module/navigator/navigator-screen/index.js.map +0 -1
  620. package/build-module/navigator/navigator-to-parent-button/index.js +0 -2
  621. package/build-module/navigator/navigator-to-parent-button/index.js.map +0 -1
  622. package/build-types/alignment-matrix-control/styles/alignment-matrix-control-icon-styles.d.ts +0 -18
  623. package/build-types/alignment-matrix-control/styles/alignment-matrix-control-icon-styles.d.ts.map +0 -1
  624. package/build-types/alignment-matrix-control/styles/alignment-matrix-control-styles.d.ts.map +0 -1
  625. package/build-types/composite/stories/utils.d.ts +0 -29
  626. package/build-types/composite/stories/utils.d.ts.map +0 -1
  627. package/build-types/navigator/navigator-back-button/index.d.ts +0 -2
  628. package/build-types/navigator/navigator-back-button/index.d.ts.map +0 -1
  629. package/build-types/navigator/navigator-button/index.d.ts +0 -2
  630. package/build-types/navigator/navigator-button/index.d.ts.map +0 -1
  631. package/build-types/navigator/navigator-provider/index.d.ts +0 -2
  632. package/build-types/navigator/navigator-provider/index.d.ts.map +0 -1
  633. package/build-types/navigator/navigator-screen/index.d.ts +0 -2
  634. package/build-types/navigator/navigator-screen/index.d.ts.map +0 -1
  635. package/build-types/navigator/navigator-to-parent-button/index.d.ts +0 -2
  636. package/build-types/navigator/navigator-to-parent-button/index.d.ts.map +0 -1
  637. package/src/alignment-matrix-control/styles/alignment-matrix-control-icon-styles.ts +0 -77
  638. package/src/alignment-matrix-control/styles/alignment-matrix-control-styles.ts +0 -102
  639. package/src/composite/stories/utils.tsx +0 -76
  640. package/src/navigator/navigator-back-button/index.ts +0 -1
  641. package/src/navigator/navigator-button/index.ts +0 -1
  642. package/src/navigator/navigator-provider/index.ts +0 -1
  643. package/src/navigator/navigator-screen/index.ts +0 -1
  644. package/src/navigator/navigator-to-parent-button/index.ts +0 -1
@@ -6,8 +6,8 @@ Object.defineProperty(exports, "__esModule", {
6
6
  exports.NULL_ELEMENT_OFFSET_RECT = void 0;
7
7
  exports.getElementOffsetRect = getElementOffsetRect;
8
8
  exports.useTrackElementOffsetRect = useTrackElementOffsetRect;
9
- exports.useTrackElementRectUpdates = useTrackElementRectUpdates;
10
9
  var _element = require("@wordpress/element");
10
+ var _compose = require("@wordpress/compose");
11
11
  var _useEvent = require("./hooks/use-event");
12
12
  /* eslint-disable jsdoc/require-param */
13
13
  /**
@@ -18,92 +18,6 @@ var _useEvent = require("./hooks/use-event");
18
18
  * Internal dependencies
19
19
  */
20
20
 
21
- /**
22
- * `useTrackElementRectUpdates` options.
23
- */
24
-
25
- /**
26
- * Tracks an element's "rect" (size and position) and fires `onRect` for all
27
- * of its discrete values. The element can be changed dynamically and **it
28
- * must not be stored in a ref**. Instead, it should be stored in a React
29
- * state or equivalent.
30
- *
31
- * By default, `onRect` is called initially for the target element (including
32
- * when the target element changes), not only on size or position updates.
33
- * This allows consumers of the hook to always be in sync with all rect values
34
- * of the target element throughout its lifetime. This behavior can be
35
- * disabled by setting the `fireOnElementInit` option to `false`.
36
- *
37
- * Under the hood, it sets up a `ResizeObserver` that tracks the element. The
38
- * target element can be changed dynamically, and the observer will be
39
- * updated accordingly.
40
- *
41
- * @example
42
- *
43
- * ```tsx
44
- * const [ targetElement, setTargetElement ] = useState< HTMLElement | null >();
45
- *
46
- * useTrackElementRectUpdates( targetElement, ( element ) => {
47
- * console.log( 'Element resized:', element );
48
- * } );
49
- *
50
- * <div ref={ setTargetElement } />;
51
- * ```
52
- */
53
- function useTrackElementRectUpdates(
54
- /**
55
- * The target element to observe. It can be changed dynamically.
56
- */
57
- targetElement,
58
- /**
59
- * Callback to fire when the element is resized. It will also be
60
- * called when the observer is set up, unless `fireOnElementInit` is
61
- * set to `false`.
62
- */
63
- onRect, {
64
- fireOnElementInit = true
65
- } = {}) {
66
- const onRectEvent = (0, _useEvent.useEvent)(onRect);
67
- const observedElementRef = (0, _element.useRef)();
68
- const resizeObserverRef = (0, _element.useRef)();
69
-
70
- // TODO: could this be a layout effect?
71
- (0, _element.useEffect)(() => {
72
- if (targetElement === observedElementRef.current) {
73
- return;
74
- }
75
- observedElementRef.current = targetElement;
76
-
77
- // Set up a ResizeObserver.
78
- if (!resizeObserverRef.current) {
79
- resizeObserverRef.current = new ResizeObserver(entries => {
80
- if (observedElementRef.current) {
81
- onRectEvent(observedElementRef.current, entries);
82
- }
83
- });
84
- }
85
- const {
86
- current: resizeObserver
87
- } = resizeObserverRef;
88
-
89
- // Observe new element.
90
- if (targetElement) {
91
- if (fireOnElementInit) {
92
- // TODO: investigate if this can be removed,
93
- // see: https://stackoverflow.com/a/60026394
94
- onRectEvent(targetElement);
95
- }
96
- resizeObserver.observe(targetElement);
97
- }
98
- return () => {
99
- // Unobserve previous element.
100
- if (observedElementRef.current) {
101
- resizeObserver.unobserve(observedElementRef.current);
102
- }
103
- };
104
- }, [fireOnElementInit, onRectEvent, targetElement]);
105
- }
106
-
107
21
  /**
108
22
  * The position and dimensions of an element, relative to its offset parent.
109
23
  */
@@ -112,44 +26,98 @@ onRect, {
112
26
  * An `ElementOffsetRect` object with all values set to zero.
113
27
  */
114
28
  const NULL_ELEMENT_OFFSET_RECT = exports.NULL_ELEMENT_OFFSET_RECT = {
115
- left: 0,
116
29
  top: 0,
30
+ right: 0,
31
+ bottom: 0,
32
+ left: 0,
117
33
  width: 0,
118
34
  height: 0
119
35
  };
120
36
 
121
37
  /**
122
38
  * Returns the position and dimensions of an element, relative to its offset
123
- * parent. This is useful in contexts where `getBoundingClientRect` is not
124
- * suitable, such as when the element is transformed.
39
+ * parent, with subpixel precision. Values reflect the real measures before any
40
+ * potential scaling distortions along the X and Y axes.
125
41
  *
126
- * **Note:** the `left` and `right` values are adjusted due to a limitation
127
- * in the way the browser calculates the offset position of the element,
128
- * which can cause unwanted scrollbars to appear. This adjustment makes the
129
- * values potentially inaccurate within a range of 1 pixel.
42
+ * Useful in contexts where plain `getBoundingClientRect` calls or `ResizeObserver`
43
+ * entries are not suitable, such as when the element is transformed, and when
44
+ * `element.offset<Top|Left|Width|Height>` methods are not precise enough.
45
+ *
46
+ * **Note:** in some contexts, like when the scale is 0, this method will fail
47
+ * because it's impossible to calculate a scaling ratio. When that happens, it
48
+ * will return `undefined`.
130
49
  */
131
50
  function getElementOffsetRect(element) {
51
+ var _element$offsetParent;
52
+ // Position and dimension values computed with `getBoundingClientRect` have
53
+ // subpixel precision, but are affected by distortions since they represent
54
+ // the "real" measures, or in other words, the actual final values as rendered
55
+ // by the browser.
56
+ const rect = element.getBoundingClientRect();
57
+ if (rect.width === 0 || rect.height === 0) {
58
+ return;
59
+ }
60
+ const offsetParentRect = (_element$offsetParent = element.offsetParent?.getBoundingClientRect()) !== null && _element$offsetParent !== void 0 ? _element$offsetParent : NULL_ELEMENT_OFFSET_RECT;
61
+
62
+ // Computed widths and heights have subpixel precision, and are not affected
63
+ // by distortions.
64
+ const computedWidth = parseFloat(getComputedStyle(element).width);
65
+ const computedHeight = parseFloat(getComputedStyle(element).height);
66
+
67
+ // We can obtain the current scale factor for the element by comparing "computed"
68
+ // dimensions with the "real" ones.
69
+ const scaleX = computedWidth / rect.width;
70
+ const scaleY = computedHeight / rect.height;
132
71
  return {
133
- // The adjustments mentioned in the documentation above are necessary
134
- // because `offsetLeft` and `offsetTop` are rounded to the nearest pixel,
135
- // which can result in a position mismatch that causes unwanted overflow.
136
- // For context, see: https://github.com/WordPress/gutenberg/pull/61979
137
- left: Math.max(element.offsetLeft - 1, 0),
138
- top: Math.max(element.offsetTop - 1, 0),
139
- // This is a workaround to obtain these values with a sub-pixel precision,
140
- // since `offsetWidth` and `offsetHeight` are rounded to the nearest pixel.
141
- width: parseFloat(getComputedStyle(element).width),
142
- height: parseFloat(getComputedStyle(element).height)
72
+ // To obtain the adjusted values for the position:
73
+ // 1. Compute the element's position relative to the offset parent.
74
+ // 2. Correct for the scale factor.
75
+ top: (rect.top - offsetParentRect?.top) * scaleY,
76
+ right: (offsetParentRect?.right - rect.right) * scaleX,
77
+ bottom: (offsetParentRect?.bottom - rect.bottom) * scaleY,
78
+ left: (rect.left - offsetParentRect?.left) * scaleX,
79
+ // Computed dimensions don't need any adjustments.
80
+ width: computedWidth,
81
+ height: computedHeight
143
82
  };
144
83
  }
84
+ const POLL_RATE = 100;
145
85
 
146
86
  /**
147
87
  * Tracks the position and dimensions of an element, relative to its offset
148
88
  * parent. The element can be changed dynamically.
89
+ *
90
+ * **Note:** sometimes, the measurement will fail (see `getElementOffsetRect`'s
91
+ * documentation for more details). When that happens, this hook will attempt
92
+ * to measure again after a frame, and if that fails, it will poll every 100
93
+ * milliseconds until it succeeds.
149
94
  */
150
95
  function useTrackElementOffsetRect(targetElement) {
151
96
  const [indicatorPosition, setIndicatorPosition] = (0, _element.useState)(NULL_ELEMENT_OFFSET_RECT);
152
- useTrackElementRectUpdates(targetElement, element => setIndicatorPosition(getElementOffsetRect(element)));
97
+ const intervalRef = (0, _element.useRef)();
98
+ const measure = (0, _useEvent.useEvent)(() => {
99
+ if (targetElement) {
100
+ const elementOffsetRect = getElementOffsetRect(targetElement);
101
+ if (elementOffsetRect) {
102
+ setIndicatorPosition(elementOffsetRect);
103
+ clearInterval(intervalRef.current);
104
+ return true;
105
+ }
106
+ } else {
107
+ clearInterval(intervalRef.current);
108
+ }
109
+ return false;
110
+ });
111
+ const setElement = (0, _compose.useResizeObserver)(() => {
112
+ if (!measure()) {
113
+ requestAnimationFrame(() => {
114
+ if (!measure()) {
115
+ intervalRef.current = setInterval(measure, POLL_RATE);
116
+ }
117
+ });
118
+ }
119
+ });
120
+ (0, _element.useLayoutEffect)(() => setElement(targetElement), [setElement, targetElement]);
153
121
  return indicatorPosition;
154
122
  }
155
123
 
@@ -1 +1 @@
1
- {"version":3,"names":["_element","require","_useEvent","useTrackElementRectUpdates","targetElement","onRect","fireOnElementInit","onRectEvent","useEvent","observedElementRef","useRef","resizeObserverRef","useEffect","current","ResizeObserver","entries","resizeObserver","observe","unobserve","NULL_ELEMENT_OFFSET_RECT","exports","left","top","width","height","getElementOffsetRect","element","Math","max","offsetLeft","offsetTop","parseFloat","getComputedStyle","useTrackElementOffsetRect","indicatorPosition","setIndicatorPosition","useState"],"sources":["@wordpress/components/src/utils/element-rect.ts"],"sourcesContent":["/* eslint-disable jsdoc/require-param */\n/**\n * WordPress dependencies\n */\nimport { useRef, useEffect, useState } from '@wordpress/element';\n/**\n * Internal dependencies\n */\nimport { useEvent } from './hooks/use-event';\n\n/**\n * `useTrackElementRectUpdates` options.\n */\nexport type UseTrackElementRectUpdatesOptions = {\n\t/**\n\t * Whether to trigger the callback when an element's ResizeObserver is\n\t * first set up, including when the target element changes.\n\t *\n\t * @default true\n\t */\n\tfireOnElementInit?: boolean;\n};\n\n/**\n * Tracks an element's \"rect\" (size and position) and fires `onRect` for all\n * of its discrete values. The element can be changed dynamically and **it\n * must not be stored in a ref**. Instead, it should be stored in a React\n * state or equivalent.\n *\n * By default, `onRect` is called initially for the target element (including\n * when the target element changes), not only on size or position updates.\n * This allows consumers of the hook to always be in sync with all rect values\n * of the target element throughout its lifetime. This behavior can be\n * disabled by setting the `fireOnElementInit` option to `false`.\n *\n * Under the hood, it sets up a `ResizeObserver` that tracks the element. The\n * target element can be changed dynamically, and the observer will be\n * updated accordingly.\n *\n * @example\n *\n * ```tsx\n * const [ targetElement, setTargetElement ] = useState< HTMLElement | null >();\n *\n * useTrackElementRectUpdates( targetElement, ( element ) => {\n * console.log( 'Element resized:', element );\n * } );\n *\n * <div ref={ setTargetElement } />;\n * ```\n */\nexport function useTrackElementRectUpdates(\n\t/**\n\t * The target element to observe. It can be changed dynamically.\n\t */\n\ttargetElement: HTMLElement | undefined | null,\n\t/**\n\t * Callback to fire when the element is resized. It will also be\n\t * called when the observer is set up, unless `fireOnElementInit` is\n\t * set to `false`.\n\t */\n\tonRect: (\n\t\t/**\n\t\t * The element being tracked at the time of this update.\n\t\t */\n\t\telement: HTMLElement,\n\t\t/**\n\t\t * The list of\n\t\t * [`ResizeObserverEntry`](https://developer.mozilla.org/en-US/docs/Web/API/ResizeObserverEntry)\n\t\t * objects passed to the `ResizeObserver.observe` callback. This list\n\t\t * won't be available when the observer is set up, and only on updates.\n\t\t */\n\t\tresizeObserverEntries?: ResizeObserverEntry[]\n\t) => void,\n\t{ fireOnElementInit = true }: UseTrackElementRectUpdatesOptions = {}\n) {\n\tconst onRectEvent = useEvent( onRect );\n\n\tconst observedElementRef = useRef< HTMLElement | null >();\n\tconst resizeObserverRef = useRef< ResizeObserver >();\n\n\t// TODO: could this be a layout effect?\n\tuseEffect( () => {\n\t\tif ( targetElement === observedElementRef.current ) {\n\t\t\treturn;\n\t\t}\n\n\t\tobservedElementRef.current = targetElement;\n\n\t\t// Set up a ResizeObserver.\n\t\tif ( ! resizeObserverRef.current ) {\n\t\t\tresizeObserverRef.current = new ResizeObserver( ( entries ) => {\n\t\t\t\tif ( observedElementRef.current ) {\n\t\t\t\t\tonRectEvent( observedElementRef.current, entries );\n\t\t\t\t}\n\t\t\t} );\n\t\t}\n\t\tconst { current: resizeObserver } = resizeObserverRef;\n\n\t\t// Observe new element.\n\t\tif ( targetElement ) {\n\t\t\tif ( fireOnElementInit ) {\n\t\t\t\t// TODO: investigate if this can be removed,\n\t\t\t\t// see: https://stackoverflow.com/a/60026394\n\t\t\t\tonRectEvent( targetElement );\n\t\t\t}\n\t\t\tresizeObserver.observe( targetElement );\n\t\t}\n\n\t\treturn () => {\n\t\t\t// Unobserve previous element.\n\t\t\tif ( observedElementRef.current ) {\n\t\t\t\tresizeObserver.unobserve( observedElementRef.current );\n\t\t\t}\n\t\t};\n\t}, [ fireOnElementInit, onRectEvent, targetElement ] );\n}\n\n/**\n * The position and dimensions of an element, relative to its offset parent.\n */\nexport type ElementOffsetRect = {\n\t/**\n\t * The distance from the left edge of the offset parent to the left edge of\n\t * the element.\n\t */\n\tleft: number;\n\t/**\n\t * The distance from the top edge of the offset parent to the top edge of\n\t * the element.\n\t */\n\ttop: number;\n\t/**\n\t * The width of the element.\n\t */\n\twidth: number;\n\t/**\n\t * The height of the element.\n\t */\n\theight: number;\n};\n\n/**\n * An `ElementOffsetRect` object with all values set to zero.\n */\nexport const NULL_ELEMENT_OFFSET_RECT = {\n\tleft: 0,\n\ttop: 0,\n\twidth: 0,\n\theight: 0,\n} satisfies ElementOffsetRect;\n\n/**\n * Returns the position and dimensions of an element, relative to its offset\n * parent. This is useful in contexts where `getBoundingClientRect` is not\n * suitable, such as when the element is transformed.\n *\n * **Note:** the `left` and `right` values are adjusted due to a limitation\n * in the way the browser calculates the offset position of the element,\n * which can cause unwanted scrollbars to appear. This adjustment makes the\n * values potentially inaccurate within a range of 1 pixel.\n */\nexport function getElementOffsetRect(\n\telement: HTMLElement\n): ElementOffsetRect {\n\treturn {\n\t\t// The adjustments mentioned in the documentation above are necessary\n\t\t// because `offsetLeft` and `offsetTop` are rounded to the nearest pixel,\n\t\t// which can result in a position mismatch that causes unwanted overflow.\n\t\t// For context, see: https://github.com/WordPress/gutenberg/pull/61979\n\t\tleft: Math.max( element.offsetLeft - 1, 0 ),\n\t\ttop: Math.max( element.offsetTop - 1, 0 ),\n\t\t// This is a workaround to obtain these values with a sub-pixel precision,\n\t\t// since `offsetWidth` and `offsetHeight` are rounded to the nearest pixel.\n\t\twidth: parseFloat( getComputedStyle( element ).width ),\n\t\theight: parseFloat( getComputedStyle( element ).height ),\n\t};\n}\n\n/**\n * Tracks the position and dimensions of an element, relative to its offset\n * parent. The element can be changed dynamically.\n */\nexport function useTrackElementOffsetRect(\n\ttargetElement: HTMLElement | undefined | null\n) {\n\tconst [ indicatorPosition, setIndicatorPosition ] =\n\t\tuseState< ElementOffsetRect >( NULL_ELEMENT_OFFSET_RECT );\n\n\tuseTrackElementRectUpdates( targetElement, ( element ) =>\n\t\tsetIndicatorPosition( getElementOffsetRect( element ) )\n\t);\n\n\treturn indicatorPosition;\n}\n\n/* eslint-enable jsdoc/require-param */\n"],"mappings":"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","ignoreList":[]}
1
+ {"version":3,"names":["_element","require","_compose","_useEvent","NULL_ELEMENT_OFFSET_RECT","exports","top","right","bottom","left","width","height","getElementOffsetRect","element","_element$offsetParent","rect","getBoundingClientRect","offsetParentRect","offsetParent","computedWidth","parseFloat","getComputedStyle","computedHeight","scaleX","scaleY","POLL_RATE","useTrackElementOffsetRect","targetElement","indicatorPosition","setIndicatorPosition","useState","intervalRef","useRef","measure","useEvent","elementOffsetRect","clearInterval","current","setElement","useResizeObserver","requestAnimationFrame","setInterval","useLayoutEffect"],"sources":["@wordpress/components/src/utils/element-rect.ts"],"sourcesContent":["/* eslint-disable jsdoc/require-param */\n/**\n * WordPress dependencies\n */\nimport { useLayoutEffect, useRef, useState } from '@wordpress/element';\nimport { useResizeObserver } from '@wordpress/compose';\n/**\n * Internal dependencies\n */\nimport { useEvent } from './hooks/use-event';\n\n/**\n * The position and dimensions of an element, relative to its offset parent.\n */\nexport type ElementOffsetRect = {\n\t/**\n\t * The distance from the top edge of the offset parent to the top edge of\n\t * the element.\n\t */\n\ttop: number;\n\t/**\n\t * The distance from the right edge of the offset parent to the right edge\n\t * of the element.\n\t */\n\tright: number;\n\t/**\n\t * The distance from the bottom edge of the offset parent to the bottom edge\n\t * of the element.\n\t */\n\tbottom: number;\n\t/**\n\t * The distance from the left edge of the offset parent to the left edge of\n\t * the element.\n\t */\n\tleft: number;\n\t/**\n\t * The width of the element.\n\t */\n\twidth: number;\n\t/**\n\t * The height of the element.\n\t */\n\theight: number;\n};\n\n/**\n * An `ElementOffsetRect` object with all values set to zero.\n */\nexport const NULL_ELEMENT_OFFSET_RECT = {\n\ttop: 0,\n\tright: 0,\n\tbottom: 0,\n\tleft: 0,\n\twidth: 0,\n\theight: 0,\n} satisfies ElementOffsetRect;\n\n/**\n * Returns the position and dimensions of an element, relative to its offset\n * parent, with subpixel precision. Values reflect the real measures before any\n * potential scaling distortions along the X and Y axes.\n *\n * Useful in contexts where plain `getBoundingClientRect` calls or `ResizeObserver`\n * entries are not suitable, such as when the element is transformed, and when\n * `element.offset<Top|Left|Width|Height>` methods are not precise enough.\n *\n * **Note:** in some contexts, like when the scale is 0, this method will fail\n * because it's impossible to calculate a scaling ratio. When that happens, it\n * will return `undefined`.\n */\nexport function getElementOffsetRect(\n\telement: HTMLElement\n): ElementOffsetRect | undefined {\n\t// Position and dimension values computed with `getBoundingClientRect` have\n\t// subpixel precision, but are affected by distortions since they represent\n\t// the \"real\" measures, or in other words, the actual final values as rendered\n\t// by the browser.\n\tconst rect = element.getBoundingClientRect();\n\tif ( rect.width === 0 || rect.height === 0 ) {\n\t\treturn;\n\t}\n\tconst offsetParentRect =\n\t\telement.offsetParent?.getBoundingClientRect() ??\n\t\tNULL_ELEMENT_OFFSET_RECT;\n\n\t// Computed widths and heights have subpixel precision, and are not affected\n\t// by distortions.\n\tconst computedWidth = parseFloat( getComputedStyle( element ).width );\n\tconst computedHeight = parseFloat( getComputedStyle( element ).height );\n\n\t// We can obtain the current scale factor for the element by comparing \"computed\"\n\t// dimensions with the \"real\" ones.\n\tconst scaleX = computedWidth / rect.width;\n\tconst scaleY = computedHeight / rect.height;\n\n\treturn {\n\t\t// To obtain the adjusted values for the position:\n\t\t// 1. Compute the element's position relative to the offset parent.\n\t\t// 2. Correct for the scale factor.\n\t\ttop: ( rect.top - offsetParentRect?.top ) * scaleY,\n\t\tright: ( offsetParentRect?.right - rect.right ) * scaleX,\n\t\tbottom: ( offsetParentRect?.bottom - rect.bottom ) * scaleY,\n\t\tleft: ( rect.left - offsetParentRect?.left ) * scaleX,\n\t\t// Computed dimensions don't need any adjustments.\n\t\twidth: computedWidth,\n\t\theight: computedHeight,\n\t};\n}\n\nconst POLL_RATE = 100;\n\n/**\n * Tracks the position and dimensions of an element, relative to its offset\n * parent. The element can be changed dynamically.\n *\n * **Note:** sometimes, the measurement will fail (see `getElementOffsetRect`'s\n * documentation for more details). When that happens, this hook will attempt\n * to measure again after a frame, and if that fails, it will poll every 100\n * milliseconds until it succeeds.\n */\nexport function useTrackElementOffsetRect(\n\ttargetElement: HTMLElement | undefined | null\n) {\n\tconst [ indicatorPosition, setIndicatorPosition ] =\n\t\tuseState< ElementOffsetRect >( NULL_ELEMENT_OFFSET_RECT );\n\tconst intervalRef = useRef< ReturnType< typeof setInterval > >();\n\n\tconst measure = useEvent( () => {\n\t\tif ( targetElement ) {\n\t\t\tconst elementOffsetRect = getElementOffsetRect( targetElement );\n\t\t\tif ( elementOffsetRect ) {\n\t\t\t\tsetIndicatorPosition( elementOffsetRect );\n\t\t\t\tclearInterval( intervalRef.current );\n\t\t\t\treturn true;\n\t\t\t}\n\t\t} else {\n\t\t\tclearInterval( intervalRef.current );\n\t\t}\n\t\treturn false;\n\t} );\n\n\tconst setElement = useResizeObserver( () => {\n\t\tif ( ! measure() ) {\n\t\t\trequestAnimationFrame( () => {\n\t\t\t\tif ( ! measure() ) {\n\t\t\t\t\tintervalRef.current = setInterval( measure, POLL_RATE );\n\t\t\t\t}\n\t\t\t} );\n\t\t}\n\t} );\n\n\tuseLayoutEffect(\n\t\t() => setElement( targetElement ),\n\t\t[ setElement, targetElement ]\n\t);\n\n\treturn indicatorPosition;\n}\n\n/* eslint-enable jsdoc/require-param */\n"],"mappings":"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","ignoreList":[]}
@@ -18,12 +18,12 @@ var _element = require("@wordpress/element");
18
18
  * @param {import('react').DependencyList} deps
19
19
  */
20
20
  function useUpdateEffect(effect, deps) {
21
- const mounted = (0, _element.useRef)(false);
21
+ const mountedRef = (0, _element.useRef)(false);
22
22
  (0, _element.useEffect)(() => {
23
- if (mounted.current) {
23
+ if (mountedRef.current) {
24
24
  return effect();
25
25
  }
26
- mounted.current = true;
26
+ mountedRef.current = true;
27
27
  return undefined;
28
28
  // Disable reasons:
29
29
  // 1. This hook needs to pass a dep list that isn't an array literal
@@ -32,7 +32,7 @@ function useUpdateEffect(effect, deps) {
32
32
  // eslint-disable-next-line react-hooks/exhaustive-deps
33
33
  }, deps);
34
34
  (0, _element.useEffect)(() => () => {
35
- mounted.current = false;
35
+ mountedRef.current = false;
36
36
  }, []);
37
37
  }
38
38
  var _default = exports.default = useUpdateEffect;
@@ -1 +1 @@
1
- {"version":3,"names":["_element","require","useUpdateEffect","effect","deps","mounted","useRef","useEffect","current","undefined","_default","exports","default"],"sources":["@wordpress/components/src/utils/hooks/use-update-effect.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useRef, useEffect } from '@wordpress/element';\n\n/**\n * A `React.useEffect` that will not run on the first render.\n * Source:\n * https://github.com/ariakit/ariakit/blob/main/packages/ariakit-react-core/src/utils/hooks.ts\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\t// Disable reasons:\n\t\t// 1. This hook needs to pass a dep list that isn't an array literal\n\t\t// 2. `effect` is missing from the array, and will need to be added carefully to avoid additional warnings\n\t\t// see https://github.com/WordPress/gutenberg/pull/41166\n\t\t// eslint-disable-next-line react-hooks/exhaustive-deps\n\t}, deps );\n\n\tuseEffect(\n\t\t() => () => {\n\t\t\tmounted.current = false;\n\t\t},\n\t\t[]\n\t);\n}\n\nexport default useUpdateEffect;\n"],"mappings":";;;;;;AAGA,IAAAA,QAAA,GAAAC,OAAA;AAHA;AACA;AACA;;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAASC,eAAeA,CAAEC,MAAM,EAAEC,IAAI,EAAG;EACxC,MAAMC,OAAO,GAAG,IAAAC,eAAM,EAAE,KAAM,CAAC;EAC/B,IAAAC,kBAAS,EAAE,MAAM;IAChB,IAAKF,OAAO,CAACG,OAAO,EAAG;MACtB,OAAOL,MAAM,CAAC,CAAC;IAChB;IACAE,OAAO,CAACG,OAAO,GAAG,IAAI;IACtB,OAAOC,SAAS;IAChB;IACA;IACA;IACA;IACA;EACD,CAAC,EAAEL,IAAK,CAAC;EAET,IAAAG,kBAAS,EACR,MAAM,MAAM;IACXF,OAAO,CAACG,OAAO,GAAG,KAAK;EACxB,CAAC,EACD,EACD,CAAC;AACF;AAAC,IAAAE,QAAA,GAAAC,OAAA,CAAAC,OAAA,GAEcV,eAAe","ignoreList":[]}
1
+ {"version":3,"names":["_element","require","useUpdateEffect","effect","deps","mountedRef","useRef","useEffect","current","undefined","_default","exports","default"],"sources":["@wordpress/components/src/utils/hooks/use-update-effect.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useRef, useEffect } from '@wordpress/element';\n\n/**\n * A `React.useEffect` that will not run on the first render.\n * Source:\n * https://github.com/ariakit/ariakit/blob/main/packages/ariakit-react-core/src/utils/hooks.ts\n *\n * @param {import('react').EffectCallback} effect\n * @param {import('react').DependencyList} deps\n */\nfunction useUpdateEffect( effect, deps ) {\n\tconst mountedRef = useRef( false );\n\tuseEffect( () => {\n\t\tif ( mountedRef.current ) {\n\t\t\treturn effect();\n\t\t}\n\t\tmountedRef.current = true;\n\t\treturn undefined;\n\t\t// Disable reasons:\n\t\t// 1. This hook needs to pass a dep list that isn't an array literal\n\t\t// 2. `effect` is missing from the array, and will need to be added carefully to avoid additional warnings\n\t\t// see https://github.com/WordPress/gutenberg/pull/41166\n\t\t// eslint-disable-next-line react-hooks/exhaustive-deps\n\t}, deps );\n\n\tuseEffect(\n\t\t() => () => {\n\t\t\tmountedRef.current = false;\n\t\t},\n\t\t[]\n\t);\n}\n\nexport default useUpdateEffect;\n"],"mappings":";;;;;;AAGA,IAAAA,QAAA,GAAAC,OAAA;AAHA;AACA;AACA;;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAASC,eAAeA,CAAEC,MAAM,EAAEC,IAAI,EAAG;EACxC,MAAMC,UAAU,GAAG,IAAAC,eAAM,EAAE,KAAM,CAAC;EAClC,IAAAC,kBAAS,EAAE,MAAM;IAChB,IAAKF,UAAU,CAACG,OAAO,EAAG;MACzB,OAAOL,MAAM,CAAC,CAAC;IAChB;IACAE,UAAU,CAACG,OAAO,GAAG,IAAI;IACzB,OAAOC,SAAS;IAChB;IACA;IACA;IACA;IACA;EACD,CAAC,EAAEL,IAAK,CAAC;EAET,IAAAG,kBAAS,EACR,MAAM,MAAM;IACXF,UAAU,CAACG,OAAO,GAAG,KAAK;EAC3B,CAAC,EACD,EACD,CAAC;AACF;AAAC,IAAAE,QAAA,GAAAC,OAAA,CAAAC,OAAA,GAEcV,eAAe","ignoreList":[]}
@@ -9,18 +9,16 @@ import { VisuallyHidden } from '../visually-hidden';
9
9
  * Internal dependencies
10
10
  */
11
11
  import { ALIGNMENT_LABEL } from './utils';
12
- import { Cell as CellView, Point } from './styles/alignment-matrix-control-styles';
12
+ import { Cell as CellView, Point } from './styles';
13
13
  import { jsx as _jsx } from "react/jsx-runtime";
14
14
  import { jsxs as _jsxs } from "react/jsx-runtime";
15
15
  export default function Cell({
16
16
  id,
17
- isActive = false,
18
17
  value,
19
18
  ...props
20
19
  }) {
21
- const tooltipText = ALIGNMENT_LABEL[value];
22
20
  return /*#__PURE__*/_jsx(Tooltip, {
23
- text: tooltipText,
21
+ text: ALIGNMENT_LABEL[value],
24
22
  children: /*#__PURE__*/_jsxs(Composite.Item, {
25
23
  id: id,
26
24
  render: /*#__PURE__*/_jsx(CellView, {
@@ -30,7 +28,6 @@ export default function Cell({
30
28
  children: [/*#__PURE__*/_jsx(VisuallyHidden, {
31
29
  children: value
32
30
  }), /*#__PURE__*/_jsx(Point, {
33
- isActive: isActive,
34
31
  role: "presentation"
35
32
  })]
36
33
  })
@@ -1 +1 @@
1
- {"version":3,"names":["Composite","Tooltip","VisuallyHidden","ALIGNMENT_LABEL","Cell","CellView","Point","jsx","_jsx","jsxs","_jsxs","id","isActive","value","props","tooltipText","text","children","Item","render","role"],"sources":["@wordpress/components/src/alignment-matrix-control/cell.tsx"],"sourcesContent":["/**\n * Internal dependencies\n */\nimport { Composite } from '../composite';\nimport Tooltip from '../tooltip';\nimport { VisuallyHidden } from '../visually-hidden';\n\n/**\n * Internal dependencies\n */\nimport { ALIGNMENT_LABEL } from './utils';\nimport {\n\tCell as CellView,\n\tPoint,\n} from './styles/alignment-matrix-control-styles';\nimport type { AlignmentMatrixControlCellProps } from './types';\nimport type { WordPressComponentProps } from '../context';\n\nexport default function Cell( {\n\tid,\n\tisActive = false,\n\tvalue,\n\t...props\n}: WordPressComponentProps< AlignmentMatrixControlCellProps, 'span', false > ) {\n\tconst tooltipText = ALIGNMENT_LABEL[ value ];\n\n\treturn (\n\t\t<Tooltip text={ tooltipText }>\n\t\t\t<Composite.Item\n\t\t\t\tid={ id }\n\t\t\t\trender={ <CellView { ...props } role=\"gridcell\" /> }\n\t\t\t>\n\t\t\t\t{ /* VoiceOver needs a text content to be rendered within grid cell,\n\t\t\totherwise it'll announce the content as \"blank\". So we use a visually\n\t\t\thidden element instead of aria-label. */ }\n\t\t\t\t<VisuallyHidden>{ value }</VisuallyHidden>\n\t\t\t\t<Point isActive={ isActive } role=\"presentation\" />\n\t\t\t</Composite.Item>\n\t\t</Tooltip>\n\t);\n}\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,SAAS,QAAQ,cAAc;AACxC,OAAOC,OAAO,MAAM,YAAY;AAChC,SAASC,cAAc,QAAQ,oBAAoB;;AAEnD;AACA;AACA;AACA,SAASC,eAAe,QAAQ,SAAS;AACzC,SACCC,IAAI,IAAIC,QAAQ,EAChBC,KAAK,QACC,0CAA0C;AAAC,SAAAC,GAAA,IAAAC,IAAA;AAAA,SAAAC,IAAA,IAAAC,KAAA;AAIlD,eAAe,SAASN,IAAIA,CAAE;EAC7BO,EAAE;EACFC,QAAQ,GAAG,KAAK;EAChBC,KAAK;EACL,GAAGC;AACuE,CAAC,EAAG;EAC9E,MAAMC,WAAW,GAAGZ,eAAe,CAAEU,KAAK,CAAE;EAE5C,oBACCL,IAAA,CAACP,OAAO;IAACe,IAAI,EAAGD,WAAa;IAAAE,QAAA,eAC5BP,KAAA,CAACV,SAAS,CAACkB,IAAI;MACdP,EAAE,EAAGA,EAAI;MACTQ,MAAM,eAAGX,IAAA,CAACH,QAAQ;QAAA,GAAMS,KAAK;QAAGM,IAAI,EAAC;MAAU,CAAE,CAAG;MAAAH,QAAA,gBAKpDT,IAAA,CAACN,cAAc;QAAAe,QAAA,EAAGJ;MAAK,CAAkB,CAAC,eAC1CL,IAAA,CAACF,KAAK;QAACM,QAAQ,EAAGA,QAAU;QAACQ,IAAI,EAAC;MAAc,CAAE,CAAC;IAAA,CACpC;EAAC,CACT,CAAC;AAEZ","ignoreList":[]}
1
+ {"version":3,"names":["Composite","Tooltip","VisuallyHidden","ALIGNMENT_LABEL","Cell","CellView","Point","jsx","_jsx","jsxs","_jsxs","id","value","props","text","children","Item","render","role"],"sources":["@wordpress/components/src/alignment-matrix-control/cell.tsx"],"sourcesContent":["/**\n * Internal dependencies\n */\nimport { Composite } from '../composite';\nimport Tooltip from '../tooltip';\nimport { VisuallyHidden } from '../visually-hidden';\n\n/**\n * Internal dependencies\n */\nimport { ALIGNMENT_LABEL } from './utils';\nimport { Cell as CellView, Point } from './styles';\nimport type { AlignmentMatrixControlCellProps } from './types';\nimport type { WordPressComponentProps } from '../context';\n\nexport default function Cell( {\n\tid,\n\tvalue,\n\t...props\n}: WordPressComponentProps< AlignmentMatrixControlCellProps, 'span', false > ) {\n\treturn (\n\t\t<Tooltip text={ ALIGNMENT_LABEL[ value ] }>\n\t\t\t<Composite.Item\n\t\t\t\tid={ id }\n\t\t\t\trender={ <CellView { ...props } role=\"gridcell\" /> }\n\t\t\t>\n\t\t\t\t{ /* VoiceOver needs a text content to be rendered within grid cell,\n\t\t\totherwise it'll announce the content as \"blank\". So we use a visually\n\t\t\thidden element instead of aria-label. */ }\n\t\t\t\t<VisuallyHidden>{ value }</VisuallyHidden>\n\t\t\t\t<Point role=\"presentation\" />\n\t\t\t</Composite.Item>\n\t\t</Tooltip>\n\t);\n}\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,SAAS,QAAQ,cAAc;AACxC,OAAOC,OAAO,MAAM,YAAY;AAChC,SAASC,cAAc,QAAQ,oBAAoB;;AAEnD;AACA;AACA;AACA,SAASC,eAAe,QAAQ,SAAS;AACzC,SAASC,IAAI,IAAIC,QAAQ,EAAEC,KAAK,QAAQ,UAAU;AAAC,SAAAC,GAAA,IAAAC,IAAA;AAAA,SAAAC,IAAA,IAAAC,KAAA;AAInD,eAAe,SAASN,IAAIA,CAAE;EAC7BO,EAAE;EACFC,KAAK;EACL,GAAGC;AACuE,CAAC,EAAG;EAC9E,oBACCL,IAAA,CAACP,OAAO;IAACa,IAAI,EAAGX,eAAe,CAAES,KAAK,CAAI;IAAAG,QAAA,eACzCL,KAAA,CAACV,SAAS,CAACgB,IAAI;MACdL,EAAE,EAAGA,EAAI;MACTM,MAAM,eAAGT,IAAA,CAACH,QAAQ;QAAA,GAAMQ,KAAK;QAAGK,IAAI,EAAC;MAAU,CAAE,CAAG;MAAAH,QAAA,gBAKpDP,IAAA,CAACN,cAAc;QAAAa,QAAA,EAAGH;MAAK,CAAkB,CAAC,eAC1CJ,IAAA,CAACF,KAAK;QAACY,IAAI,EAAC;MAAc,CAAE,CAAC;IAAA,CACd;EAAC,CACT,CAAC;AAEZ","ignoreList":[]}
@@ -3,40 +3,52 @@
3
3
  */
4
4
  import clsx from 'clsx';
5
5
 
6
+ /**
7
+ * WordPress dependencies
8
+ */
9
+ import { Rect, SVG } from '@wordpress/primitives';
10
+
6
11
  /**
7
12
  * Internal dependencies
8
13
  */
9
14
  import { ALIGNMENTS, getAlignmentIndex } from './utils';
10
- import { Root, Cell, Point } from './styles/alignment-matrix-control-icon-styles';
11
15
  import { jsx as _jsx } from "react/jsx-runtime";
12
16
  const BASE_SIZE = 24;
17
+ const GRID_CELL_SIZE = 7;
18
+ const GRID_PADDING = (BASE_SIZE - 3 * GRID_CELL_SIZE) / 2;
19
+ const DOT_SIZE = 2;
20
+ const DOT_SIZE_SELECTED = 4;
13
21
  function AlignmentMatrixControlIcon({
14
22
  className,
15
23
  disablePointerEvents = true,
16
- size = BASE_SIZE,
24
+ size,
25
+ width,
26
+ height,
17
27
  style = {},
18
28
  value = 'center',
19
29
  ...props
20
30
  }) {
21
- const alignIndex = getAlignmentIndex(value);
22
- const scale = (size / BASE_SIZE).toFixed(2);
23
- const classes = clsx('component-alignment-matrix-control-icon', className);
24
- const styles = {
25
- ...style,
26
- transform: `scale(${scale})`
27
- };
28
- return /*#__PURE__*/_jsx(Root, {
29
- ...props,
30
- className: classes,
31
- disablePointerEvents: disablePointerEvents,
31
+ var _ref, _ref2;
32
+ return /*#__PURE__*/_jsx(SVG, {
33
+ xmlns: "http://www.w3.org/2000/svg",
34
+ viewBox: `0 0 ${BASE_SIZE} ${BASE_SIZE}`,
35
+ width: (_ref = size !== null && size !== void 0 ? size : width) !== null && _ref !== void 0 ? _ref : BASE_SIZE,
36
+ height: (_ref2 = size !== null && size !== void 0 ? size : height) !== null && _ref2 !== void 0 ? _ref2 : BASE_SIZE,
32
37
  role: "presentation",
33
- style: styles,
38
+ className: clsx('component-alignment-matrix-control-icon', className),
39
+ style: {
40
+ pointerEvents: disablePointerEvents ? 'none' : undefined,
41
+ ...style
42
+ },
43
+ ...props,
34
44
  children: ALIGNMENTS.map((align, index) => {
35
- const isActive = alignIndex === index;
36
- return /*#__PURE__*/_jsx(Cell, {
37
- children: /*#__PURE__*/_jsx(Point, {
38
- isActive: isActive
39
- })
45
+ const dotSize = getAlignmentIndex(value) === index ? DOT_SIZE_SELECTED : DOT_SIZE;
46
+ return /*#__PURE__*/_jsx(Rect, {
47
+ x: GRID_PADDING + index % 3 * GRID_CELL_SIZE + (GRID_CELL_SIZE - dotSize) / 2,
48
+ y: GRID_PADDING + Math.floor(index / 3) * GRID_CELL_SIZE + (GRID_CELL_SIZE - dotSize) / 2,
49
+ width: dotSize,
50
+ height: dotSize,
51
+ fill: "currentColor"
40
52
  }, align);
41
53
  })
42
54
  });
@@ -1 +1 @@
1
- {"version":3,"names":["clsx","ALIGNMENTS","getAlignmentIndex","Root","Cell","Point","jsx","_jsx","BASE_SIZE","AlignmentMatrixControlIcon","className","disablePointerEvents","size","style","value","props","alignIndex","scale","toFixed","classes","styles","transform","role","children","map","align","index","isActive"],"sources":["@wordpress/components/src/alignment-matrix-control/icon.tsx"],"sourcesContent":["/**\n * External dependencies\n */\nimport clsx from 'clsx';\n\n/**\n * Internal dependencies\n */\nimport { ALIGNMENTS, getAlignmentIndex } from './utils';\nimport {\n\tRoot,\n\tCell,\n\tPoint,\n} from './styles/alignment-matrix-control-icon-styles';\nimport type { AlignmentMatrixControlIconProps } from './types';\nimport type { WordPressComponentProps } from '../context';\n\nconst BASE_SIZE = 24;\n\nfunction AlignmentMatrixControlIcon( {\n\tclassName,\n\tdisablePointerEvents = true,\n\tsize = BASE_SIZE,\n\tstyle = {},\n\tvalue = 'center',\n\t...props\n}: WordPressComponentProps< AlignmentMatrixControlIconProps, 'div', false > ) {\n\tconst alignIndex = getAlignmentIndex( value );\n\tconst scale = ( size / BASE_SIZE ).toFixed( 2 );\n\n\tconst classes = clsx(\n\t\t'component-alignment-matrix-control-icon',\n\t\tclassName\n\t);\n\n\tconst styles = {\n\t\t...style,\n\t\ttransform: `scale(${ scale })`,\n\t};\n\n\treturn (\n\t\t<Root\n\t\t\t{ ...props }\n\t\t\tclassName={ classes }\n\t\t\tdisablePointerEvents={ disablePointerEvents }\n\t\t\trole=\"presentation\"\n\t\t\tstyle={ styles }\n\t\t>\n\t\t\t{ ALIGNMENTS.map( ( align, index ) => {\n\t\t\t\tconst isActive = alignIndex === index;\n\n\t\t\t\treturn (\n\t\t\t\t\t<Cell key={ align }>\n\t\t\t\t\t\t<Point isActive={ isActive } />\n\t\t\t\t\t</Cell>\n\t\t\t\t);\n\t\t\t} ) }\n\t\t</Root>\n\t);\n}\n\nexport default AlignmentMatrixControlIcon;\n"],"mappings":"AAAA;AACA;AACA;AACA,OAAOA,IAAI,MAAM,MAAM;;AAEvB;AACA;AACA;AACA,SAASC,UAAU,EAAEC,iBAAiB,QAAQ,SAAS;AACvD,SACCC,IAAI,EACJC,IAAI,EACJC,KAAK,QACC,+CAA+C;AAAC,SAAAC,GAAA,IAAAC,IAAA;AAIvD,MAAMC,SAAS,GAAG,EAAE;AAEpB,SAASC,0BAA0BA,CAAE;EACpCC,SAAS;EACTC,oBAAoB,GAAG,IAAI;EAC3BC,IAAI,GAAGJ,SAAS;EAChBK,KAAK,GAAG,CAAC,CAAC;EACVC,KAAK,GAAG,QAAQ;EAChB,GAAGC;AACsE,CAAC,EAAG;EAC7E,MAAMC,UAAU,GAAGd,iBAAiB,CAAEY,KAAM,CAAC;EAC7C,MAAMG,KAAK,GAAG,CAAEL,IAAI,GAAGJ,SAAS,EAAGU,OAAO,CAAE,CAAE,CAAC;EAE/C,MAAMC,OAAO,GAAGnB,IAAI,CACnB,yCAAyC,EACzCU,SACD,CAAC;EAED,MAAMU,MAAM,GAAG;IACd,GAAGP,KAAK;IACRQ,SAAS,EAAG,SAASJ,KAAO;EAC7B,CAAC;EAED,oBACCV,IAAA,CAACJ,IAAI;IAAA,GACCY,KAAK;IACVL,SAAS,EAAGS,OAAS;IACrBR,oBAAoB,EAAGA,oBAAsB;IAC7CW,IAAI,EAAC,cAAc;IACnBT,KAAK,EAAGO,MAAQ;IAAAG,QAAA,EAEdtB,UAAU,CAACuB,GAAG,CAAE,CAAEC,KAAK,EAAEC,KAAK,KAAM;MACrC,MAAMC,QAAQ,GAAGX,UAAU,KAAKU,KAAK;MAErC,oBACCnB,IAAA,CAACH,IAAI;QAAAmB,QAAA,eACJhB,IAAA,CAACF,KAAK;UAACsB,QAAQ,EAAGA;QAAU,CAAE;MAAC,GADpBF,KAEN,CAAC;IAET,CAAE;EAAC,CACE,CAAC;AAET;AAEA,eAAehB,0BAA0B","ignoreList":[]}
1
+ {"version":3,"names":["clsx","Rect","SVG","ALIGNMENTS","getAlignmentIndex","jsx","_jsx","BASE_SIZE","GRID_CELL_SIZE","GRID_PADDING","DOT_SIZE","DOT_SIZE_SELECTED","AlignmentMatrixControlIcon","className","disablePointerEvents","size","width","height","style","value","props","_ref","_ref2","xmlns","viewBox","role","pointerEvents","undefined","children","map","align","index","dotSize","x","y","Math","floor","fill"],"sources":["@wordpress/components/src/alignment-matrix-control/icon.tsx"],"sourcesContent":["/**\n * External dependencies\n */\nimport clsx from 'clsx';\n\n/**\n * WordPress dependencies\n */\nimport { Rect, SVG } from '@wordpress/primitives';\n\n/**\n * Internal dependencies\n */\nimport { ALIGNMENTS, getAlignmentIndex } from './utils';\nimport type { AlignmentMatrixControlIconProps } from './types';\nimport type { WordPressComponentProps } from '../context';\n\nconst BASE_SIZE = 24;\nconst GRID_CELL_SIZE = 7;\nconst GRID_PADDING = ( BASE_SIZE - 3 * GRID_CELL_SIZE ) / 2;\nconst DOT_SIZE = 2;\nconst DOT_SIZE_SELECTED = 4;\n\nfunction AlignmentMatrixControlIcon( {\n\tclassName,\n\tdisablePointerEvents = true,\n\tsize,\n\twidth,\n\theight,\n\tstyle = {},\n\tvalue = 'center',\n\t...props\n}: WordPressComponentProps< AlignmentMatrixControlIconProps, 'svg', false > ) {\n\treturn (\n\t\t<SVG\n\t\t\txmlns=\"http://www.w3.org/2000/svg\"\n\t\t\tviewBox={ `0 0 ${ BASE_SIZE } ${ BASE_SIZE }` }\n\t\t\twidth={ size ?? width ?? BASE_SIZE }\n\t\t\theight={ size ?? height ?? BASE_SIZE }\n\t\t\trole=\"presentation\"\n\t\t\tclassName={ clsx(\n\t\t\t\t'component-alignment-matrix-control-icon',\n\t\t\t\tclassName\n\t\t\t) }\n\t\t\tstyle={ {\n\t\t\t\tpointerEvents: disablePointerEvents ? 'none' : undefined,\n\t\t\t\t...style,\n\t\t\t} }\n\t\t\t{ ...props }\n\t\t>\n\t\t\t{ ALIGNMENTS.map( ( align, index ) => {\n\t\t\t\tconst dotSize =\n\t\t\t\t\tgetAlignmentIndex( value ) === index\n\t\t\t\t\t\t? DOT_SIZE_SELECTED\n\t\t\t\t\t\t: DOT_SIZE;\n\n\t\t\t\treturn (\n\t\t\t\t\t<Rect\n\t\t\t\t\t\tkey={ align }\n\t\t\t\t\t\tx={\n\t\t\t\t\t\t\tGRID_PADDING +\n\t\t\t\t\t\t\t( index % 3 ) * GRID_CELL_SIZE +\n\t\t\t\t\t\t\t( GRID_CELL_SIZE - dotSize ) / 2\n\t\t\t\t\t\t}\n\t\t\t\t\t\ty={\n\t\t\t\t\t\t\tGRID_PADDING +\n\t\t\t\t\t\t\tMath.floor( index / 3 ) * GRID_CELL_SIZE +\n\t\t\t\t\t\t\t( GRID_CELL_SIZE - dotSize ) / 2\n\t\t\t\t\t\t}\n\t\t\t\t\t\twidth={ dotSize }\n\t\t\t\t\t\theight={ dotSize }\n\t\t\t\t\t\tfill=\"currentColor\"\n\t\t\t\t\t/>\n\t\t\t\t);\n\t\t\t} ) }\n\t\t</SVG>\n\t);\n}\n\nexport default AlignmentMatrixControlIcon;\n"],"mappings":"AAAA;AACA;AACA;AACA,OAAOA,IAAI,MAAM,MAAM;;AAEvB;AACA;AACA;AACA,SAASC,IAAI,EAAEC,GAAG,QAAQ,uBAAuB;;AAEjD;AACA;AACA;AACA,SAASC,UAAU,EAAEC,iBAAiB,QAAQ,SAAS;AAAC,SAAAC,GAAA,IAAAC,IAAA;AAIxD,MAAMC,SAAS,GAAG,EAAE;AACpB,MAAMC,cAAc,GAAG,CAAC;AACxB,MAAMC,YAAY,GAAG,CAAEF,SAAS,GAAG,CAAC,GAAGC,cAAc,IAAK,CAAC;AAC3D,MAAME,QAAQ,GAAG,CAAC;AAClB,MAAMC,iBAAiB,GAAG,CAAC;AAE3B,SAASC,0BAA0BA,CAAE;EACpCC,SAAS;EACTC,oBAAoB,GAAG,IAAI;EAC3BC,IAAI;EACJC,KAAK;EACLC,MAAM;EACNC,KAAK,GAAG,CAAC,CAAC;EACVC,KAAK,GAAG,QAAQ;EAChB,GAAGC;AACsE,CAAC,EAAG;EAAA,IAAAC,IAAA,EAAAC,KAAA;EAC7E,oBACChB,IAAA,CAACJ,GAAG;IACHqB,KAAK,EAAC,4BAA4B;IAClCC,OAAO,EAAI,OAAOjB,SAAW,IAAIA,SAAW,EAAG;IAC/CS,KAAK,GAAAK,IAAA,GAAGN,IAAI,aAAJA,IAAI,cAAJA,IAAI,GAAIC,KAAK,cAAAK,IAAA,cAAAA,IAAA,GAAId,SAAW;IACpCU,MAAM,GAAAK,KAAA,GAAGP,IAAI,aAAJA,IAAI,cAAJA,IAAI,GAAIE,MAAM,cAAAK,KAAA,cAAAA,KAAA,GAAIf,SAAW;IACtCkB,IAAI,EAAC,cAAc;IACnBZ,SAAS,EAAGb,IAAI,CACf,yCAAyC,EACzCa,SACD,CAAG;IACHK,KAAK,EAAG;MACPQ,aAAa,EAAEZ,oBAAoB,GAAG,MAAM,GAAGa,SAAS;MACxD,GAAGT;IACJ,CAAG;IAAA,GACEE,KAAK;IAAAQ,QAAA,EAERzB,UAAU,CAAC0B,GAAG,CAAE,CAAEC,KAAK,EAAEC,KAAK,KAAM;MACrC,MAAMC,OAAO,GACZ5B,iBAAiB,CAAEe,KAAM,CAAC,KAAKY,KAAK,GACjCpB,iBAAiB,GACjBD,QAAQ;MAEZ,oBACCJ,IAAA,CAACL,IAAI;QAEJgC,CAAC,EACAxB,YAAY,GACVsB,KAAK,GAAG,CAAC,GAAKvB,cAAc,GAC9B,CAAEA,cAAc,GAAGwB,OAAO,IAAK,CAC/B;QACDE,CAAC,EACAzB,YAAY,GACZ0B,IAAI,CAACC,KAAK,CAAEL,KAAK,GAAG,CAAE,CAAC,GAAGvB,cAAc,GACxC,CAAEA,cAAc,GAAGwB,OAAO,IAAK,CAC/B;QACDhB,KAAK,EAAGgB,OAAS;QACjBf,MAAM,EAAGe,OAAS;QAClBK,IAAI,EAAC;MAAc,GAbbP,KAcN,CAAC;IAEJ,CAAE;EAAC,CACC,CAAC;AAER;AAEA,eAAelB,0BAA0B","ignoreList":[]}
@@ -2,44 +2,24 @@
2
2
  * External dependencies
3
3
  */
4
4
  import clsx from 'clsx';
5
- import { useStoreState } from '@ariakit/react';
6
5
 
7
6
  /**
8
7
  * WordPress dependencies
9
8
  */
10
9
  import { __, isRTL } from '@wordpress/i18n';
11
10
  import { useInstanceId } from '@wordpress/compose';
11
+ import { useCallback } from '@wordpress/element';
12
12
 
13
13
  /**
14
14
  * Internal dependencies
15
15
  */
16
16
  import Cell from './cell';
17
- import { Composite, useCompositeStore } from '../composite';
18
- import { Root, Row } from './styles/alignment-matrix-control-styles';
17
+ import { Composite } from '../composite';
18
+ import { GridContainer, GridRow } from './styles';
19
19
  import AlignmentMatrixControlIcon from './icon';
20
20
  import { GRID, getItemId, getItemValue } from './utils';
21
21
  import { jsx as _jsx } from "react/jsx-runtime";
22
- /**
23
- *
24
- * AlignmentMatrixControl components enable adjustments to horizontal and vertical alignments for UI.
25
- *
26
- * ```jsx
27
- * import { __experimentalAlignmentMatrixControl as AlignmentMatrixControl } from '@wordpress/components';
28
- * import { useState } from '@wordpress/element';
29
- *
30
- * const Example = () => {
31
- * const [ alignment, setAlignment ] = useState( 'center center' );
32
- *
33
- * return (
34
- * <AlignmentMatrixControl
35
- * value={ alignment }
36
- * onChange={ setAlignment }
37
- * />
38
- * );
39
- * };
40
- * ```
41
- */
42
- export function AlignmentMatrixControl({
22
+ function UnforwardedAlignmentMatrixControl({
43
23
  className,
44
24
  id,
45
25
  label = __('Alignment Matrix Control'),
@@ -49,23 +29,20 @@ export function AlignmentMatrixControl({
49
29
  width = 92,
50
30
  ...props
51
31
  }) {
52
- const baseId = useInstanceId(AlignmentMatrixControl, 'alignment-matrix-control', id);
53
- const compositeStore = useCompositeStore({
54
- defaultActiveId: getItemId(baseId, defaultValue),
55
- activeId: getItemId(baseId, value),
56
- setActiveId: nextActiveId => {
57
- const nextValue = getItemValue(baseId, nextActiveId);
58
- if (nextValue) {
59
- onChange?.(nextValue);
60
- }
61
- },
62
- rtl: isRTL()
63
- });
64
- const activeId = useStoreState(compositeStore, 'activeId');
32
+ const baseId = useInstanceId(UnforwardedAlignmentMatrixControl, 'alignment-matrix-control', id);
33
+ const setActiveId = useCallback(nextActiveId => {
34
+ const nextValue = getItemValue(baseId, nextActiveId);
35
+ if (nextValue) {
36
+ onChange?.(nextValue);
37
+ }
38
+ }, [baseId, onChange]);
65
39
  const classes = clsx('component-alignment-matrix-control', className);
66
40
  return /*#__PURE__*/_jsx(Composite, {
67
- store: compositeStore,
68
- render: /*#__PURE__*/_jsx(Root, {
41
+ defaultActiveId: getItemId(baseId, defaultValue),
42
+ activeId: getItemId(baseId, value),
43
+ setActiveId: setActiveId,
44
+ rtl: isRTL(),
45
+ render: /*#__PURE__*/_jsx(GridContainer, {
69
46
  ...props,
70
47
  "aria-label": label,
71
48
  className: classes,
@@ -74,21 +51,49 @@ export function AlignmentMatrixControl({
74
51
  size: width
75
52
  }),
76
53
  children: GRID.map((cells, index) => /*#__PURE__*/_jsx(Composite.Row, {
77
- render: /*#__PURE__*/_jsx(Row, {
54
+ render: /*#__PURE__*/_jsx(GridRow, {
78
55
  role: "row"
79
56
  }),
80
- children: cells.map(cell => {
81
- const cellId = getItemId(baseId, cell);
82
- const isActive = cellId === activeId;
83
- return /*#__PURE__*/_jsx(Cell, {
84
- id: cellId,
85
- isActive: isActive,
86
- value: cell
87
- }, cell);
88
- })
57
+ children: cells.map(cell => /*#__PURE__*/_jsx(Cell, {
58
+ id: getItemId(baseId, cell),
59
+ value: cell
60
+ }, cell))
89
61
  }, index))
90
62
  });
91
63
  }
92
- AlignmentMatrixControl.Icon = AlignmentMatrixControlIcon;
64
+
65
+ /**
66
+ * AlignmentMatrixControl components enable adjustments to horizontal and vertical alignments for UI.
67
+ *
68
+ * ```jsx
69
+ * import { AlignmentMatrixControl } from '@wordpress/components';
70
+ * import { useState } from '@wordpress/element';
71
+ *
72
+ * const Example = () => {
73
+ * const [ alignment, setAlignment ] = useState( 'center center' );
74
+ *
75
+ * return (
76
+ * <AlignmentMatrixControl
77
+ * value={ alignment }
78
+ * onChange={ setAlignment }
79
+ * />
80
+ * );
81
+ * };
82
+ * ```
83
+ */
84
+ export const AlignmentMatrixControl = Object.assign(UnforwardedAlignmentMatrixControl, {
85
+ /**
86
+ * Render an alignment matrix as an icon.
87
+ *
88
+ * ```jsx
89
+ * import { AlignmentMatrixControl } from '@wordpress/components';
90
+ *
91
+ * <Icon icon={<AlignmentMatrixControl.Icon value="top left" />} />
92
+ * ```
93
+ */
94
+ Icon: Object.assign(AlignmentMatrixControlIcon, {
95
+ displayName: 'AlignmentMatrixControl.Icon'
96
+ })
97
+ });
93
98
  export default AlignmentMatrixControl;
94
99
  //# sourceMappingURL=index.js.map