@wordpress/components 20.0.2-next.957ca95e4c.0 → 21.0.1

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 (895) hide show
  1. package/CHANGELOG.md +68 -1
  2. package/CONTRIBUTING.md +3 -54
  3. package/build/alignment-matrix-control/styles/alignment-matrix-control-styles.js +9 -9
  4. package/build/alignment-matrix-control/styles/alignment-matrix-control-styles.js.map +1 -1
  5. package/build/angle-picker-control/index.js +10 -0
  6. package/build/angle-picker-control/index.js.map +1 -1
  7. package/build/autocomplete/autocompleter-ui.js +3 -3
  8. package/build/autocomplete/autocompleter-ui.js.map +1 -1
  9. package/build/border-box-control/border-box-control/component.js +10 -7
  10. package/build/border-box-control/border-box-control/component.js.map +1 -1
  11. package/build/border-box-control/border-box-control-linked-button/component.js +1 -2
  12. package/build/border-box-control/border-box-control-linked-button/component.js.map +1 -1
  13. package/build/border-box-control/border-box-control-split-controls/component.js +10 -7
  14. package/build/border-box-control/border-box-control-split-controls/component.js.map +1 -1
  15. package/build/border-box-control/styles.js +7 -7
  16. package/build/border-box-control/styles.js.map +1 -1
  17. package/build/border-control/border-control-dropdown/component.js +2 -1
  18. package/build/border-control/border-control-dropdown/component.js.map +1 -1
  19. package/build/box-control/linked-button.js +3 -3
  20. package/build/box-control/linked-button.js.map +1 -1
  21. package/build/card/styles.js +17 -17
  22. package/build/card/styles.js.map +1 -1
  23. package/build/checkbox-control/index.js +3 -3
  24. package/build/checkbox-control/index.js.map +1 -1
  25. package/build/color-palette/index.js +1 -1
  26. package/build/color-palette/index.js.map +1 -1
  27. package/build/color-picker/input-with-slider.js +2 -1
  28. package/build/color-picker/input-with-slider.js.map +1 -1
  29. package/build/combobox-control/index.js +1 -1
  30. package/build/combobox-control/index.js.map +1 -1
  31. package/build/custom-gradient-picker/index.js +1 -1
  32. package/build/custom-gradient-picker/index.js.map +1 -1
  33. package/build/date-time/date/index.js +1 -1
  34. package/build/date-time/date/index.js.map +1 -1
  35. package/build/date-time/time/timezone.js +1 -1
  36. package/build/date-time/time/timezone.js.map +1 -1
  37. package/build/disabled/index.js +14 -6
  38. package/build/disabled/index.js.map +1 -1
  39. package/build/disabled/styles/disabled-styles.js +8 -18
  40. package/build/disabled/styles/disabled-styles.js.map +1 -1
  41. package/build/drop-zone/index.js +44 -9
  42. package/build/drop-zone/index.js.map +1 -1
  43. package/build/drop-zone/provider.js.map +1 -1
  44. package/build/drop-zone/types.js +6 -0
  45. package/build/drop-zone/types.js.map +1 -0
  46. package/build/dropdown/index.js +11 -4
  47. package/build/dropdown/index.js.map +1 -1
  48. package/build/flex/flex/hook.js +6 -30
  49. package/build/flex/flex/hook.js.map +1 -1
  50. package/build/focal-point-picker/controls.js +10 -5
  51. package/build/focal-point-picker/controls.js.map +1 -1
  52. package/build/focal-point-picker/focal-point.js.map +1 -1
  53. package/build/focal-point-picker/grid.js.map +1 -1
  54. package/build/focal-point-picker/index.js +83 -16
  55. package/build/focal-point-picker/index.js.map +1 -1
  56. package/build/focal-point-picker/media.js +4 -0
  57. package/build/focal-point-picker/media.js.map +1 -1
  58. package/build/focal-point-picker/styles/focal-point-picker-style.js +70 -41
  59. package/build/focal-point-picker/styles/focal-point-picker-style.js.map +1 -1
  60. package/build/focal-point-picker/styles/focal-point-style.js +12 -12
  61. package/build/focal-point-picker/styles/focal-point-style.js.map +1 -1
  62. package/build/focal-point-picker/types.js +6 -0
  63. package/build/focal-point-picker/types.js.map +1 -0
  64. package/build/focal-point-picker/utils.js +6 -6
  65. package/build/focal-point-picker/utils.js.map +1 -1
  66. package/build/font-size-picker/index.js +11 -0
  67. package/build/font-size-picker/index.js.map +1 -1
  68. package/build/font-size-picker/utils.js +1 -1
  69. package/build/font-size-picker/utils.js.map +1 -1
  70. package/build/form-file-upload/index.js +22 -2
  71. package/build/form-file-upload/index.js.map +1 -1
  72. package/build/form-file-upload/types.js +6 -0
  73. package/build/form-file-upload/types.js.map +1 -0
  74. package/build/form-toggle/index.js +1 -3
  75. package/build/form-toggle/index.js.map +1 -1
  76. package/build/form-token-field/index.js +4 -6
  77. package/build/form-token-field/index.js.map +1 -1
  78. package/build/form-token-field/suggestions-list.js +1 -3
  79. package/build/form-token-field/suggestions-list.js.map +1 -1
  80. package/build/gradient-picker/index.js +25 -26
  81. package/build/gradient-picker/index.js.map +1 -1
  82. package/build/icon/index.js +1 -2
  83. package/build/icon/index.js.map +1 -1
  84. package/build/input-control/input-base.js +3 -2
  85. package/build/input-control/input-base.js.map +1 -1
  86. package/build/input-control/label.js +2 -2
  87. package/build/input-control/label.js.map +1 -1
  88. package/build/input-control/styles/input-control-styles.js +41 -128
  89. package/build/input-control/styles/input-control-styles.js.map +1 -1
  90. package/build/modal/aria-helper.js +3 -10
  91. package/build/modal/aria-helper.js.map +1 -1
  92. package/build/navigable-container/container.js +5 -1
  93. package/build/navigable-container/container.js.map +1 -1
  94. package/build/navigable-container/menu.js +10 -12
  95. package/build/navigable-container/menu.js.map +1 -1
  96. package/build/navigable-container/tabbable.js +2 -4
  97. package/build/navigable-container/tabbable.js.map +1 -1
  98. package/build/navigation/menu/menu-title-search.js +2 -1
  99. package/build/navigation/menu/menu-title-search.js.map +1 -1
  100. package/build/navigation/menu/use-navigation-tree-menu.js +2 -1
  101. package/build/navigation/menu/use-navigation-tree-menu.js.map +1 -1
  102. package/build/navigator/navigator-button/hook.js +1 -1
  103. package/build/navigator/navigator-button/hook.js.map +1 -1
  104. package/build/navigator/navigator-screen/component.js +2 -2
  105. package/build/navigator/navigator-screen/component.js.map +1 -1
  106. package/build/number-control/index.js +29 -25
  107. package/build/number-control/index.js.map +1 -1
  108. package/build/number-control/types.js +6 -0
  109. package/build/number-control/types.js.map +1 -0
  110. package/build/placeholder/index.js +1 -3
  111. package/build/placeholder/index.js.map +1 -1
  112. package/build/popover/index.js +190 -160
  113. package/build/popover/index.js.map +1 -1
  114. package/build/popover/types.js +6 -0
  115. package/build/popover/types.js.map +1 -0
  116. package/build/popover/utils.js +125 -24
  117. package/build/popover/utils.js.map +1 -1
  118. package/build/radio-control/index.js +7 -4
  119. package/build/radio-control/index.js.map +1 -1
  120. package/build/range-control/index.js +4 -1
  121. package/build/range-control/index.js.map +1 -1
  122. package/build/range-control/styles/range-control-styles.js +33 -33
  123. package/build/range-control/styles/range-control-styles.js.map +1 -1
  124. package/build/sandbox/index.js +2 -2
  125. package/build/sandbox/index.js.map +1 -1
  126. package/build/search-control/index.js +38 -10
  127. package/build/search-control/index.js.map +1 -1
  128. package/build/search-control/types.js +6 -0
  129. package/build/search-control/types.js.map +1 -0
  130. package/build/select-control/index.native.js +2 -1
  131. package/build/select-control/index.native.js.map +1 -1
  132. package/build/tab-panel/index.js +48 -9
  133. package/build/tab-panel/index.js.map +1 -1
  134. package/build/tab-panel/types.js +6 -0
  135. package/build/tab-panel/types.js.map +1 -0
  136. package/build/text-control/index.js +2 -0
  137. package/build/text-control/index.js.map +1 -1
  138. package/build/textarea-control/index.js +3 -3
  139. package/build/textarea-control/index.js.map +1 -1
  140. package/build/toggle-control/index.js +44 -4
  141. package/build/toggle-control/index.js.map +1 -1
  142. package/build/toggle-control/types.js +6 -0
  143. package/build/toggle-control/types.js.map +1 -0
  144. package/build/toggle-group-control/toggle-group-control/component.js +2 -2
  145. package/build/toggle-group-control/toggle-group-control/component.js.map +1 -1
  146. package/build/toggle-group-control/toggle-group-control-option-icon/component.js +1 -1
  147. package/build/toggle-group-control/toggle-group-control-option-icon/component.js.map +1 -1
  148. package/build/tooltip/index.js +9 -7
  149. package/build/tooltip/index.js.map +1 -1
  150. package/build/ui/context/context-connect.js +31 -22
  151. package/build/ui/context/context-connect.js.map +1 -1
  152. package/build/ui/context/context-system-provider.js +4 -3
  153. package/build/ui/context/context-system-provider.js.map +1 -1
  154. package/build/unit-control/index.js +1 -1
  155. package/build/unit-control/index.js.map +1 -1
  156. package/build/unit-control/styles/unit-control-styles.js +9 -9
  157. package/build/unit-control/styles/unit-control-styles.js.map +1 -1
  158. package/build/utils/colors-values.js +2 -30
  159. package/build/utils/colors-values.js.map +1 -1
  160. package/build/utils/math.js +4 -4
  161. package/build/utils/math.js.map +1 -1
  162. package/build/utils/values.js +62 -6
  163. package/build/utils/values.js.map +1 -1
  164. package/build/view/component.js +6 -7
  165. package/build/view/component.js.map +1 -1
  166. package/build/view/types.js +6 -0
  167. package/build/view/types.js.map +1 -0
  168. package/build-module/alignment-matrix-control/styles/alignment-matrix-control-styles.js +9 -9
  169. package/build-module/alignment-matrix-control/styles/alignment-matrix-control-styles.js.map +1 -1
  170. package/build-module/angle-picker-control/index.js +9 -0
  171. package/build-module/angle-picker-control/index.js.map +1 -1
  172. package/build-module/autocomplete/autocompleter-ui.js +4 -4
  173. package/build-module/autocomplete/autocompleter-ui.js.map +1 -1
  174. package/build-module/border-box-control/border-box-control/component.js +11 -8
  175. package/build-module/border-box-control/border-box-control/component.js.map +1 -1
  176. package/build-module/border-box-control/border-box-control-linked-button/component.js +1 -2
  177. package/build-module/border-box-control/border-box-control-linked-button/component.js.map +1 -1
  178. package/build-module/border-box-control/border-box-control-split-controls/component.js +11 -8
  179. package/build-module/border-box-control/border-box-control-split-controls/component.js.map +1 -1
  180. package/build-module/border-box-control/styles.js +7 -7
  181. package/build-module/border-box-control/styles.js.map +1 -1
  182. package/build-module/border-control/border-control-dropdown/component.js +2 -1
  183. package/build-module/border-control/border-control-dropdown/component.js.map +1 -1
  184. package/build-module/box-control/linked-button.js +3 -3
  185. package/build-module/box-control/linked-button.js.map +1 -1
  186. package/build-module/card/styles.js +17 -17
  187. package/build-module/card/styles.js.map +1 -1
  188. package/build-module/checkbox-control/index.js +3 -3
  189. package/build-module/checkbox-control/index.js.map +1 -1
  190. package/build-module/color-palette/index.js +1 -1
  191. package/build-module/color-palette/index.js.map +1 -1
  192. package/build-module/color-picker/input-with-slider.js +2 -1
  193. package/build-module/color-picker/input-with-slider.js.map +1 -1
  194. package/build-module/combobox-control/index.js +1 -1
  195. package/build-module/combobox-control/index.js.map +1 -1
  196. package/build-module/custom-gradient-picker/index.js +1 -1
  197. package/build-module/custom-gradient-picker/index.js.map +1 -1
  198. package/build-module/date-time/date/index.js +2 -3
  199. package/build-module/date-time/date/index.js.map +1 -1
  200. package/build-module/date-time/time/timezone.js +1 -1
  201. package/build-module/date-time/time/timezone.js.map +1 -1
  202. package/build-module/disabled/index.js +16 -8
  203. package/build-module/disabled/index.js.map +1 -1
  204. package/build-module/disabled/styles/disabled-styles.js +6 -12
  205. package/build-module/disabled/styles/disabled-styles.js.map +1 -1
  206. package/build-module/drop-zone/index.js +40 -9
  207. package/build-module/drop-zone/index.js.map +1 -1
  208. package/build-module/drop-zone/provider.js.map +1 -1
  209. package/build-module/drop-zone/types.js +2 -0
  210. package/build-module/drop-zone/types.js.map +1 -0
  211. package/build-module/dropdown/index.js +10 -4
  212. package/build-module/dropdown/index.js.map +1 -1
  213. package/build-module/flex/flex/hook.js +7 -29
  214. package/build-module/flex/flex/hook.js.map +1 -1
  215. package/build-module/focal-point-picker/controls.js +11 -6
  216. package/build-module/focal-point-picker/controls.js.map +1 -1
  217. package/build-module/focal-point-picker/focal-point.js.map +1 -1
  218. package/build-module/focal-point-picker/grid.js.map +1 -1
  219. package/build-module/focal-point-picker/index.js +81 -16
  220. package/build-module/focal-point-picker/index.js.map +1 -1
  221. package/build-module/focal-point-picker/media.js +4 -0
  222. package/build-module/focal-point-picker/media.js.map +1 -1
  223. package/build-module/focal-point-picker/styles/focal-point-picker-style.js +68 -40
  224. package/build-module/focal-point-picker/styles/focal-point-picker-style.js.map +1 -1
  225. package/build-module/focal-point-picker/styles/focal-point-style.js +12 -12
  226. package/build-module/focal-point-picker/styles/focal-point-style.js.map +1 -1
  227. package/build-module/focal-point-picker/types.js +2 -0
  228. package/build-module/focal-point-picker/types.js.map +1 -0
  229. package/build-module/focal-point-picker/utils.js +6 -6
  230. package/build-module/focal-point-picker/utils.js.map +1 -1
  231. package/build-module/font-size-picker/index.js +10 -0
  232. package/build-module/font-size-picker/index.js.map +1 -1
  233. package/build-module/font-size-picker/utils.js +1 -1
  234. package/build-module/font-size-picker/utils.js.map +1 -1
  235. package/build-module/form-file-upload/index.js +21 -4
  236. package/build-module/form-file-upload/index.js.map +1 -1
  237. package/build-module/form-file-upload/types.js +2 -0
  238. package/build-module/form-file-upload/types.js.map +1 -0
  239. package/build-module/form-toggle/index.js +1 -3
  240. package/build-module/form-toggle/index.js.map +1 -1
  241. package/build-module/form-token-field/index.js +4 -5
  242. package/build-module/form-token-field/index.js.map +1 -1
  243. package/build-module/form-token-field/suggestions-list.js +1 -2
  244. package/build-module/form-token-field/suggestions-list.js.map +1 -1
  245. package/build-module/gradient-picker/index.js +25 -26
  246. package/build-module/gradient-picker/index.js.map +1 -1
  247. package/build-module/icon/index.js +1 -2
  248. package/build-module/icon/index.js.map +1 -1
  249. package/build-module/input-control/input-base.js +4 -3
  250. package/build-module/input-control/input-base.js.map +1 -1
  251. package/build-module/input-control/label.js +3 -3
  252. package/build-module/input-control/label.js.map +1 -1
  253. package/build-module/input-control/styles/input-control-styles.js +41 -127
  254. package/build-module/input-control/styles/input-control-styles.js.map +1 -1
  255. package/build-module/modal/aria-helper.js +3 -8
  256. package/build-module/modal/aria-helper.js.map +1 -1
  257. package/build-module/navigable-container/container.js +5 -1
  258. package/build-module/navigable-container/container.js.map +1 -1
  259. package/build-module/navigable-container/menu.js +10 -11
  260. package/build-module/navigable-container/menu.js.map +1 -1
  261. package/build-module/navigable-container/tabbable.js +2 -3
  262. package/build-module/navigable-container/tabbable.js.map +1 -1
  263. package/build-module/navigation/menu/menu-title-search.js +2 -1
  264. package/build-module/navigation/menu/menu-title-search.js.map +1 -1
  265. package/build-module/navigation/menu/use-navigation-tree-menu.js +2 -1
  266. package/build-module/navigation/menu/use-navigation-tree-menu.js.map +1 -1
  267. package/build-module/navigator/navigator-button/hook.js +1 -1
  268. package/build-module/navigator/navigator-button/hook.js.map +1 -1
  269. package/build-module/navigator/navigator-screen/component.js +2 -2
  270. package/build-module/navigator/navigator-screen/component.js.map +1 -1
  271. package/build-module/number-control/index.js +31 -23
  272. package/build-module/number-control/index.js.map +1 -1
  273. package/build-module/number-control/types.js +2 -0
  274. package/build-module/number-control/types.js.map +1 -0
  275. package/build-module/placeholder/index.js +1 -3
  276. package/build-module/placeholder/index.js.map +1 -1
  277. package/build-module/popover/index.js +192 -162
  278. package/build-module/popover/index.js.map +1 -1
  279. package/build-module/popover/types.js +2 -0
  280. package/build-module/popover/types.js.map +1 -0
  281. package/build-module/popover/utils.js +118 -23
  282. package/build-module/popover/utils.js.map +1 -1
  283. package/build-module/radio-control/index.js +7 -5
  284. package/build-module/radio-control/index.js.map +1 -1
  285. package/build-module/range-control/index.js +4 -1
  286. package/build-module/range-control/index.js.map +1 -1
  287. package/build-module/range-control/styles/range-control-styles.js +33 -33
  288. package/build-module/range-control/styles/range-control-styles.js.map +1 -1
  289. package/build-module/sandbox/index.js +2 -2
  290. package/build-module/sandbox/index.js.map +1 -1
  291. package/build-module/search-control/index.js +34 -7
  292. package/build-module/search-control/index.js.map +1 -1
  293. package/build-module/search-control/types.js +2 -0
  294. package/build-module/search-control/types.js.map +1 -0
  295. package/build-module/select-control/index.native.js +1 -1
  296. package/build-module/select-control/index.native.js.map +1 -1
  297. package/build-module/tab-panel/index.js +46 -10
  298. package/build-module/tab-panel/index.js.map +1 -1
  299. package/build-module/tab-panel/types.js +2 -0
  300. package/build-module/tab-panel/types.js.map +1 -0
  301. package/build-module/text-control/index.js +2 -0
  302. package/build-module/text-control/index.js.map +1 -1
  303. package/build-module/textarea-control/index.js +3 -3
  304. package/build-module/textarea-control/index.js.map +1 -1
  305. package/build-module/toggle-control/index.js +38 -4
  306. package/build-module/toggle-control/index.js.map +1 -1
  307. package/build-module/toggle-control/types.js +2 -0
  308. package/build-module/toggle-control/types.js.map +1 -0
  309. package/build-module/toggle-group-control/toggle-group-control/component.js +2 -2
  310. package/build-module/toggle-group-control/toggle-group-control/component.js.map +1 -1
  311. package/build-module/toggle-group-control/toggle-group-control-option-icon/component.js +1 -1
  312. package/build-module/toggle-group-control/toggle-group-control-option-icon/component.js.map +1 -1
  313. package/build-module/tooltip/index.js +10 -8
  314. package/build-module/tooltip/index.js.map +1 -1
  315. package/build-module/ui/context/context-connect.js +30 -23
  316. package/build-module/ui/context/context-connect.js.map +1 -1
  317. package/build-module/ui/context/context-system-provider.js +5 -4
  318. package/build-module/ui/context/context-system-provider.js.map +1 -1
  319. package/build-module/unit-control/index.js +1 -1
  320. package/build-module/unit-control/index.js.map +1 -1
  321. package/build-module/unit-control/styles/unit-control-styles.js +9 -9
  322. package/build-module/unit-control/styles/unit-control-styles.js.map +1 -1
  323. package/build-module/utils/colors-values.js +2 -30
  324. package/build-module/utils/colors-values.js.map +1 -1
  325. package/build-module/utils/math.js +4 -4
  326. package/build-module/utils/math.js.map +1 -1
  327. package/build-module/utils/values.js +48 -6
  328. package/build-module/utils/values.js.map +1 -1
  329. package/build-module/view/component.js +5 -8
  330. package/build-module/view/component.js.map +1 -1
  331. package/build-module/view/types.js +2 -0
  332. package/build-module/view/types.js.map +1 -0
  333. package/build-style/style-rtl.css +4 -31
  334. package/build-style/style.css +4 -31
  335. package/build-types/base-field/hook.d.ts +54 -55
  336. package/build-types/base-field/hook.d.ts.map +1 -1
  337. package/build-types/border-box-control/border-box-control/component.d.ts +10 -2
  338. package/build-types/border-box-control/border-box-control/component.d.ts.map +1 -1
  339. package/build-types/border-box-control/border-box-control/hook.d.ts +56 -57
  340. package/build-types/border-box-control/border-box-control/hook.d.ts.map +1 -1
  341. package/build-types/border-box-control/border-box-control-linked-button/component.d.ts +2 -1
  342. package/build-types/border-box-control/border-box-control-linked-button/component.d.ts.map +1 -1
  343. package/build-types/border-box-control/border-box-control-linked-button/hook.d.ts +55 -56
  344. package/build-types/border-box-control/border-box-control-linked-button/hook.d.ts.map +1 -1
  345. package/build-types/border-box-control/border-box-control-split-controls/component.d.ts +9 -2
  346. package/build-types/border-box-control/border-box-control-split-controls/component.d.ts.map +1 -1
  347. package/build-types/border-box-control/border-box-control-split-controls/hook.d.ts +56 -57
  348. package/build-types/border-box-control/border-box-control-split-controls/hook.d.ts.map +1 -1
  349. package/build-types/border-box-control/border-box-control-visualizer/component.d.ts +2 -1
  350. package/build-types/border-box-control/border-box-control-visualizer/component.d.ts.map +1 -1
  351. package/build-types/border-box-control/border-box-control-visualizer/hook.d.ts +55 -56
  352. package/build-types/border-box-control/border-box-control-visualizer/hook.d.ts.map +1 -1
  353. package/build-types/border-box-control/styles.d.ts.map +1 -1
  354. package/build-types/border-box-control/types.d.ts +5 -4
  355. package/build-types/border-box-control/types.d.ts.map +1 -1
  356. package/build-types/border-control/border-control/component.d.ts +14 -2
  357. package/build-types/border-control/border-control/component.d.ts.map +1 -1
  358. package/build-types/border-control/border-control/hook.d.ts +56 -57
  359. package/build-types/border-control/border-control/hook.d.ts.map +1 -1
  360. package/build-types/border-control/border-control-dropdown/component.d.ts +10 -2
  361. package/build-types/border-control/border-control-dropdown/component.d.ts.map +1 -1
  362. package/build-types/border-control/border-control-dropdown/hook.d.ts +56 -57
  363. package/build-types/border-control/border-control-dropdown/hook.d.ts.map +1 -1
  364. package/build-types/border-control/border-control-style-picker/component.d.ts +6 -2
  365. package/build-types/border-control/border-control-style-picker/component.d.ts.map +1 -1
  366. package/build-types/border-control/border-control-style-picker/hook.d.ts +55 -56
  367. package/build-types/border-control/border-control-style-picker/hook.d.ts.map +1 -1
  368. package/build-types/border-control/stories/index.d.ts +74 -6
  369. package/build-types/border-control/stories/index.d.ts.map +1 -1
  370. package/build-types/border-control/types.d.ts +6 -8
  371. package/build-types/border-control/types.d.ts.map +1 -1
  372. package/build-types/button-group/index.d.ts +1 -3
  373. package/build-types/button-group/index.d.ts.map +1 -1
  374. package/build-types/card/card/component.d.ts +9 -2
  375. package/build-types/card/card/component.d.ts.map +1 -1
  376. package/build-types/card/card/hook.d.ts +55 -56
  377. package/build-types/card/card/hook.d.ts.map +1 -1
  378. package/build-types/card/card-body/component.d.ts +9 -2
  379. package/build-types/card/card-body/component.d.ts.map +1 -1
  380. package/build-types/card/card-body/hook.d.ts +55 -56
  381. package/build-types/card/card-body/hook.d.ts.map +1 -1
  382. package/build-types/card/card-divider/component.d.ts +7 -2
  383. package/build-types/card/card-divider/component.d.ts.map +1 -1
  384. package/build-types/card/card-divider/hook.d.ts +55 -55
  385. package/build-types/card/card-footer/component.d.ts +11 -2
  386. package/build-types/card/card-footer/component.d.ts.map +1 -1
  387. package/build-types/card/card-footer/hook.d.ts +55 -56
  388. package/build-types/card/card-footer/hook.d.ts.map +1 -1
  389. package/build-types/card/card-header/component.d.ts +1 -1
  390. package/build-types/card/card-header/component.d.ts.map +1 -1
  391. package/build-types/card/card-header/hook.d.ts +55 -56
  392. package/build-types/card/card-header/hook.d.ts.map +1 -1
  393. package/build-types/card/card-media/component.d.ts +2 -1
  394. package/build-types/card/card-media/component.d.ts.map +1 -1
  395. package/build-types/card/card-media/hook.d.ts +55 -56
  396. package/build-types/card/card-media/hook.d.ts.map +1 -1
  397. package/build-types/checkbox-control/index.d.ts +1 -1
  398. package/build-types/checkbox-control/index.d.ts.map +1 -1
  399. package/build-types/checkbox-control/stories/index.d.ts.map +1 -1
  400. package/build-types/checkbox-control/types.d.ts +1 -1
  401. package/build-types/checkbox-control/types.d.ts.map +1 -1
  402. package/build-types/color-indicator/index.d.ts +1 -3
  403. package/build-types/color-indicator/index.d.ts.map +1 -1
  404. package/build-types/color-palette/styles.d.ts +1 -3
  405. package/build-types/color-palette/styles.d.ts.map +1 -1
  406. package/build-types/color-picker/component.d.ts +2 -1
  407. package/build-types/color-picker/component.d.ts.map +1 -1
  408. package/build-types/color-picker/input-with-slider.d.ts.map +1 -1
  409. package/build-types/color-picker/styles.d.ts +12 -25
  410. package/build-types/color-picker/styles.d.ts.map +1 -1
  411. package/build-types/confirm-dialog/component.d.ts +4 -8
  412. package/build-types/confirm-dialog/component.d.ts.map +1 -1
  413. package/build-types/date-time/date/styles.d.ts +4 -8
  414. package/build-types/date-time/date/styles.d.ts.map +1 -1
  415. package/build-types/date-time/date-time/styles.d.ts +4 -6
  416. package/build-types/date-time/date-time/styles.d.ts.map +1 -1
  417. package/build-types/date-time/time/styles.d.ts +21 -43
  418. package/build-types/date-time/time/styles.d.ts.map +1 -1
  419. package/build-types/disabled/index.d.ts +1 -1
  420. package/build-types/disabled/index.d.ts.map +1 -1
  421. package/build-types/disabled/styles/disabled-styles.d.ts +1 -5
  422. package/build-types/disabled/styles/disabled-styles.d.ts.map +1 -1
  423. package/build-types/divider/component.d.ts +7 -2
  424. package/build-types/divider/component.d.ts.map +1 -1
  425. package/build-types/drop-zone/index.d.ts +29 -0
  426. package/build-types/drop-zone/index.d.ts.map +1 -0
  427. package/build-types/drop-zone/provider.d.ts +5 -0
  428. package/build-types/drop-zone/provider.d.ts.map +1 -0
  429. package/build-types/drop-zone/stories/index.d.ts +12 -0
  430. package/build-types/drop-zone/stories/index.d.ts.map +1 -0
  431. package/build-types/drop-zone/types.d.ts +29 -0
  432. package/build-types/drop-zone/types.d.ts.map +1 -0
  433. package/build-types/dropdown/dropdown-content-wrapper.d.ts +2 -1
  434. package/build-types/dropdown/dropdown-content-wrapper.d.ts.map +1 -1
  435. package/build-types/dropdown/index.d.ts.map +1 -1
  436. package/build-types/elevation/component.d.ts +2 -1
  437. package/build-types/elevation/component.d.ts.map +1 -1
  438. package/build-types/elevation/hook.d.ts +54 -55
  439. package/build-types/elevation/hook.d.ts.map +1 -1
  440. package/build-types/external-link/index.d.ts +1 -1
  441. package/build-types/external-link/index.d.ts.map +1 -1
  442. package/build-types/external-link/styles/external-link-styles.d.ts +1 -1
  443. package/build-types/flex/flex/component.d.ts +2 -1
  444. package/build-types/flex/flex/component.d.ts.map +1 -1
  445. package/build-types/flex/flex/hook.d.ts +55 -56
  446. package/build-types/flex/flex/hook.d.ts.map +1 -1
  447. package/build-types/flex/flex-block/component.d.ts +2 -1
  448. package/build-types/flex/flex-block/component.d.ts.map +1 -1
  449. package/build-types/flex/flex-block/hook.d.ts +55 -56
  450. package/build-types/flex/flex-block/hook.d.ts.map +1 -1
  451. package/build-types/flex/flex-item/component.d.ts +2 -1
  452. package/build-types/flex/flex-item/component.d.ts.map +1 -1
  453. package/build-types/flex/flex-item/hook.d.ts +55 -56
  454. package/build-types/flex/flex-item/hook.d.ts.map +1 -1
  455. package/build-types/focal-point-picker/controls.d.ts +4 -0
  456. package/build-types/focal-point-picker/controls.d.ts.map +1 -0
  457. package/build-types/focal-point-picker/focal-point.d.ts +5 -0
  458. package/build-types/focal-point-picker/focal-point.d.ts.map +1 -0
  459. package/build-types/focal-point-picker/grid.d.ts +5 -0
  460. package/build-types/focal-point-picker/grid.d.ts.map +1 -0
  461. package/build-types/focal-point-picker/index.d.ts +51 -0
  462. package/build-types/focal-point-picker/index.d.ts.map +1 -0
  463. package/build-types/focal-point-picker/media.d.ts +4 -0
  464. package/build-types/focal-point-picker/media.d.ts.map +1 -0
  465. package/build-types/focal-point-picker/stories/index.d.ts +15 -0
  466. package/build-types/focal-point-picker/stories/index.d.ts.map +1 -0
  467. package/build-types/focal-point-picker/styles/focal-point-picker-style.d.ts +56 -0
  468. package/build-types/focal-point-picker/styles/focal-point-picker-style.d.ts.map +1 -0
  469. package/build-types/focal-point-picker/styles/focal-point-style.d.ts +19 -0
  470. package/build-types/focal-point-picker/styles/focal-point-style.d.ts.map +1 -0
  471. package/build-types/focal-point-picker/types.d.ts +79 -0
  472. package/build-types/focal-point-picker/types.d.ts.map +1 -0
  473. package/build-types/focal-point-picker/utils.d.ts +26 -0
  474. package/build-types/focal-point-picker/utils.d.ts.map +1 -0
  475. package/build-types/form-file-upload/index.d.ts +22 -0
  476. package/build-types/form-file-upload/index.d.ts.map +1 -0
  477. package/build-types/form-file-upload/stories/index.d.ts +23 -0
  478. package/build-types/form-file-upload/stories/index.d.ts.map +1 -0
  479. package/build-types/form-file-upload/test/index.d.ts +2 -0
  480. package/build-types/form-file-upload/test/index.d.ts.map +1 -0
  481. package/build-types/form-file-upload/types.d.ts +63 -0
  482. package/build-types/form-file-upload/types.d.ts.map +1 -0
  483. package/build-types/form-toggle/index.d.ts +1 -1
  484. package/build-types/form-toggle/index.d.ts.map +1 -1
  485. package/build-types/form-token-field/index.d.ts.map +1 -1
  486. package/build-types/form-token-field/styles.d.ts +1 -3
  487. package/build-types/form-token-field/styles.d.ts.map +1 -1
  488. package/build-types/form-token-field/suggestions-list.d.ts.map +1 -1
  489. package/build-types/form-token-field/token-input.d.ts +1 -3
  490. package/build-types/form-token-field/token-input.d.ts.map +1 -1
  491. package/build-types/grid/component.d.ts +2 -1
  492. package/build-types/grid/component.d.ts.map +1 -1
  493. package/build-types/grid/hook.d.ts +55 -56
  494. package/build-types/grid/hook.d.ts.map +1 -1
  495. package/build-types/h-stack/component.d.ts +5 -2
  496. package/build-types/h-stack/component.d.ts.map +1 -1
  497. package/build-types/h-stack/hook.d.ts +55 -56
  498. package/build-types/h-stack/hook.d.ts.map +1 -1
  499. package/build-types/heading/component.d.ts +4 -2
  500. package/build-types/heading/component.d.ts.map +1 -1
  501. package/build-types/heading/hook.d.ts +54 -55
  502. package/build-types/heading/hook.d.ts.map +1 -1
  503. package/build-types/input-control/index.d.ts +1 -1
  504. package/build-types/input-control/index.d.ts.map +1 -1
  505. package/build-types/input-control/input-base.d.ts.map +1 -1
  506. package/build-types/input-control/input-field.d.ts +1 -3
  507. package/build-types/input-control/input-field.d.ts.map +1 -1
  508. package/build-types/input-control/input-prefix-wrapper.d.ts +2 -1
  509. package/build-types/input-control/input-prefix-wrapper.d.ts.map +1 -1
  510. package/build-types/input-control/input-suffix-wrapper.d.ts +2 -1
  511. package/build-types/input-control/input-suffix-wrapper.d.ts.map +1 -1
  512. package/build-types/input-control/label.d.ts.map +1 -1
  513. package/build-types/input-control/stories/index.d.ts +5 -5
  514. package/build-types/input-control/stories/index.d.ts.map +1 -1
  515. package/build-types/input-control/styles/input-control-styles.d.ts +2 -6
  516. package/build-types/input-control/styles/input-control-styles.d.ts.map +1 -1
  517. package/build-types/input-control/types.d.ts +3 -0
  518. package/build-types/input-control/types.d.ts.map +1 -1
  519. package/build-types/item-group/item/component.d.ts +2 -1
  520. package/build-types/item-group/item/component.d.ts.map +1 -1
  521. package/build-types/item-group/item/hook.d.ts +54 -55
  522. package/build-types/item-group/item/hook.d.ts.map +1 -1
  523. package/build-types/item-group/item-group/component.d.ts +2 -1
  524. package/build-types/item-group/item-group/component.d.ts.map +1 -1
  525. package/build-types/item-group/item-group/hook.d.ts +54 -55
  526. package/build-types/item-group/item-group/hook.d.ts.map +1 -1
  527. package/build-types/modal/aria-helper.d.ts.map +1 -1
  528. package/build-types/navigable-container/menu.d.ts.map +1 -1
  529. package/build-types/navigable-container/tabbable.d.ts.map +1 -1
  530. package/build-types/navigator/navigator-back-button/component.d.ts +4 -2
  531. package/build-types/navigator/navigator-back-button/component.d.ts.map +1 -1
  532. package/build-types/navigator/navigator-back-button/hook.d.ts +59 -60
  533. package/build-types/navigator/navigator-back-button/hook.d.ts.map +1 -1
  534. package/build-types/navigator/navigator-button/component.d.ts +7 -2
  535. package/build-types/navigator/navigator-button/component.d.ts.map +1 -1
  536. package/build-types/navigator/navigator-button/hook.d.ts +59 -60
  537. package/build-types/navigator/navigator-button/hook.d.ts.map +1 -1
  538. package/build-types/navigator/navigator-provider/component.d.ts +2 -1
  539. package/build-types/navigator/navigator-provider/component.d.ts.map +1 -1
  540. package/build-types/navigator/navigator-screen/component.d.ts +1 -1
  541. package/build-types/navigator/navigator-screen/component.d.ts.map +1 -1
  542. package/build-types/number-control/index.d.ts +10 -28
  543. package/build-types/number-control/index.d.ts.map +1 -1
  544. package/build-types/number-control/styles/number-control-styles.d.ts +1 -1
  545. package/build-types/number-control/types.d.ts +72 -0
  546. package/build-types/number-control/types.d.ts.map +1 -0
  547. package/build-types/placeholder/index.d.ts +1 -1
  548. package/build-types/placeholder/index.d.ts.map +1 -1
  549. package/build-types/popover/index.d.ts +28 -24
  550. package/build-types/popover/index.d.ts.map +1 -1
  551. package/build-types/popover/stories/index.d.ts +12 -0
  552. package/build-types/popover/stories/index.d.ts.map +1 -0
  553. package/build-types/popover/types.d.ts +179 -0
  554. package/build-types/popover/types.d.ts.map +1 -0
  555. package/build-types/popover/utils.d.ts +42 -24
  556. package/build-types/popover/utils.d.ts.map +1 -1
  557. package/build-types/radio-control/index.d.ts +1 -1
  558. package/build-types/radio-control/index.d.ts.map +1 -1
  559. package/build-types/range-control/index.d.ts +2 -4
  560. package/build-types/range-control/index.d.ts.map +1 -1
  561. package/build-types/range-control/input-range.d.ts +2 -4
  562. package/build-types/range-control/input-range.d.ts.map +1 -1
  563. package/build-types/range-control/styles/range-control-styles.d.ts +5 -10
  564. package/build-types/range-control/styles/range-control-styles.d.ts.map +1 -1
  565. package/build-types/resizable-box/index.d.ts +1 -1
  566. package/build-types/resizable-box/resize-tooltip/index.d.ts +1 -1
  567. package/build-types/resizable-box/resize-tooltip/label.d.ts +1 -1
  568. package/build-types/resizable-box/resize-tooltip/styles/resize-tooltip.styles.d.ts +1 -3
  569. package/build-types/resizable-box/resize-tooltip/styles/resize-tooltip.styles.d.ts.map +1 -1
  570. package/build-types/scrollable/component.d.ts +2 -1
  571. package/build-types/scrollable/component.d.ts.map +1 -1
  572. package/build-types/scrollable/hook.d.ts +55 -56
  573. package/build-types/scrollable/hook.d.ts.map +1 -1
  574. package/build-types/search-control/index.d.ts +29 -0
  575. package/build-types/search-control/index.d.ts.map +1 -0
  576. package/build-types/search-control/stories/index.d.ts +47 -0
  577. package/build-types/search-control/stories/index.d.ts.map +1 -0
  578. package/build-types/search-control/types.d.ts +39 -0
  579. package/build-types/search-control/types.d.ts.map +1 -0
  580. package/build-types/select-control/index.d.ts +1 -3
  581. package/build-types/select-control/index.d.ts.map +1 -1
  582. package/build-types/select-control/stories/index.d.ts +2 -6
  583. package/build-types/select-control/stories/index.d.ts.map +1 -1
  584. package/build-types/select-control/styles/select-control-styles.d.ts +1 -3
  585. package/build-types/select-control/styles/select-control-styles.d.ts.map +1 -1
  586. package/build-types/spacer/component.d.ts +2 -1
  587. package/build-types/spacer/component.d.ts.map +1 -1
  588. package/build-types/spacer/hook.d.ts +55 -56
  589. package/build-types/spacer/hook.d.ts.map +1 -1
  590. package/build-types/spinner/index.d.ts +1 -3
  591. package/build-types/spinner/index.d.ts.map +1 -1
  592. package/build-types/surface/component.d.ts +2 -1
  593. package/build-types/surface/component.d.ts.map +1 -1
  594. package/build-types/surface/hook.d.ts +55 -56
  595. package/build-types/surface/hook.d.ts.map +1 -1
  596. package/build-types/tab-panel/index.d.ts +42 -0
  597. package/build-types/tab-panel/index.d.ts.map +1 -0
  598. package/build-types/tab-panel/stories/index.d.ts +12 -0
  599. package/build-types/tab-panel/stories/index.d.ts.map +1 -0
  600. package/build-types/tab-panel/test/index.d.ts +2 -0
  601. package/build-types/tab-panel/test/index.d.ts.map +1 -0
  602. package/build-types/tab-panel/types.d.ts +64 -0
  603. package/build-types/tab-panel/types.d.ts.map +1 -0
  604. package/build-types/text/component.d.ts +1 -1
  605. package/build-types/text/component.d.ts.map +1 -1
  606. package/build-types/text/hook.d.ts +55 -56
  607. package/build-types/text/hook.d.ts.map +1 -1
  608. package/build-types/text-control/index.d.ts +2 -4
  609. package/build-types/text-control/index.d.ts.map +1 -1
  610. package/build-types/text-control/types.d.ts +1 -1
  611. package/build-types/text-control/types.d.ts.map +1 -1
  612. package/build-types/textarea-control/index.d.ts +1 -1
  613. package/build-types/textarea-control/index.d.ts.map +1 -1
  614. package/build-types/textarea-control/types.d.ts +1 -1
  615. package/build-types/textarea-control/types.d.ts.map +1 -1
  616. package/build-types/toggle-control/index.d.ts +26 -0
  617. package/build-types/toggle-control/index.d.ts.map +1 -0
  618. package/build-types/toggle-control/stories/index.d.ts +13 -0
  619. package/build-types/toggle-control/stories/index.d.ts.map +1 -0
  620. package/build-types/toggle-control/test/index.d.ts +2 -0
  621. package/build-types/toggle-control/test/index.d.ts.map +1 -0
  622. package/build-types/toggle-control/types.d.ts +20 -0
  623. package/build-types/toggle-control/types.d.ts.map +1 -0
  624. package/build-types/toggle-group-control/stories/index.d.ts +4 -2
  625. package/build-types/toggle-group-control/stories/index.d.ts.map +1 -1
  626. package/build-types/toggle-group-control/toggle-group-control/component.d.ts +12 -2
  627. package/build-types/toggle-group-control/toggle-group-control/component.d.ts.map +1 -1
  628. package/build-types/toggle-group-control/toggle-group-control-option/component.d.ts +2 -4
  629. package/build-types/toggle-group-control/toggle-group-control-option/component.d.ts.map +1 -1
  630. package/build-types/toggle-group-control/toggle-group-control-option-base/component.d.ts +2 -1
  631. package/build-types/toggle-group-control/toggle-group-control-option-base/component.d.ts.map +1 -1
  632. package/build-types/toggle-group-control/toggle-group-control-option-icon/component.d.ts +3 -5
  633. package/build-types/toggle-group-control/toggle-group-control-option-icon/component.d.ts.map +1 -1
  634. package/build-types/toggle-group-control/types.d.ts +2 -2
  635. package/build-types/toggle-group-control/types.d.ts.map +1 -1
  636. package/build-types/tools-panel/tools-panel/component.d.ts +2 -1
  637. package/build-types/tools-panel/tools-panel/component.d.ts.map +1 -1
  638. package/build-types/tools-panel/tools-panel/hook.d.ts +55 -56
  639. package/build-types/tools-panel/tools-panel/hook.d.ts.map +1 -1
  640. package/build-types/tools-panel/tools-panel-header/component.d.ts +2 -1
  641. package/build-types/tools-panel/tools-panel-header/component.d.ts.map +1 -1
  642. package/build-types/tools-panel/tools-panel-header/hook.d.ts +55 -56
  643. package/build-types/tools-panel/tools-panel-header/hook.d.ts.map +1 -1
  644. package/build-types/tools-panel/tools-panel-item/component.d.ts +6 -2
  645. package/build-types/tools-panel/tools-panel-item/component.d.ts.map +1 -1
  646. package/build-types/tools-panel/tools-panel-item/hook.d.ts +55 -56
  647. package/build-types/tools-panel/tools-panel-item/hook.d.ts.map +1 -1
  648. package/build-types/tooltip/index.d.ts.map +1 -1
  649. package/build-types/truncate/component.d.ts +2 -1
  650. package/build-types/truncate/component.d.ts.map +1 -1
  651. package/build-types/truncate/hook.d.ts +55 -56
  652. package/build-types/truncate/hook.d.ts.map +1 -1
  653. package/build-types/ui/context/context-connect.d.ts +10 -9
  654. package/build-types/ui/context/context-connect.d.ts.map +1 -1
  655. package/build-types/ui/context/context-system-provider.d.ts.map +1 -1
  656. package/build-types/ui/context/test/context-connect.d.ts +2 -0
  657. package/build-types/ui/context/test/context-connect.d.ts.map +1 -0
  658. package/build-types/ui/context/test/wordpress-component.d.ts +2 -0
  659. package/build-types/ui/context/test/wordpress-component.d.ts.map +1 -0
  660. package/build-types/ui/context/wordpress-component.d.ts +8 -9
  661. package/build-types/ui/context/wordpress-component.d.ts.map +1 -1
  662. package/build-types/ui/control-group/component.d.ts +4 -1
  663. package/build-types/ui/control-group/component.d.ts.map +1 -1
  664. package/build-types/ui/control-group/hook.d.ts +55 -56
  665. package/build-types/ui/control-group/hook.d.ts.map +1 -1
  666. package/build-types/ui/control-label/component.d.ts +4 -1
  667. package/build-types/ui/control-label/component.d.ts.map +1 -1
  668. package/build-types/ui/control-label/hook.d.ts +55 -56
  669. package/build-types/ui/control-label/hook.d.ts.map +1 -1
  670. package/build-types/ui/form-group/form-group.d.ts +4 -8
  671. package/build-types/ui/form-group/form-group.d.ts.map +1 -1
  672. package/build-types/ui/form-group/use-form-group.d.ts +112 -114
  673. package/build-types/ui/form-group/use-form-group.d.ts.map +1 -1
  674. package/build-types/ui/shortcut/component.d.ts +2 -1
  675. package/build-types/ui/shortcut/component.d.ts.map +1 -1
  676. package/build-types/ui/spinner/component.d.ts +1 -1
  677. package/build-types/ui/tooltip/component.d.ts +11 -1
  678. package/build-types/ui/tooltip/component.d.ts.map +1 -1
  679. package/build-types/ui/tooltip/content.d.ts +7 -1
  680. package/build-types/ui/tooltip/styles.d.ts +1 -3
  681. package/build-types/ui/tooltip/styles.d.ts.map +1 -1
  682. package/build-types/unit-control/index.d.ts +2 -12
  683. package/build-types/unit-control/index.d.ts.map +1 -1
  684. package/build-types/unit-control/stories/index.d.ts.map +1 -1
  685. package/build-types/unit-control/styles/unit-control-styles.d.ts +5 -10
  686. package/build-types/unit-control/styles/unit-control-styles.d.ts.map +1 -1
  687. package/build-types/unit-control/types.d.ts +3 -35
  688. package/build-types/unit-control/types.d.ts.map +1 -1
  689. package/build-types/utils/colors-values.d.ts +0 -18
  690. package/build-types/utils/colors-values.d.ts.map +1 -1
  691. package/build-types/utils/math.d.ts +6 -6
  692. package/build-types/utils/math.d.ts.map +1 -1
  693. package/build-types/utils/values.d.ts +10 -8
  694. package/build-types/utils/values.d.ts.map +1 -1
  695. package/build-types/v-stack/component.d.ts +8 -2
  696. package/build-types/v-stack/component.d.ts.map +1 -1
  697. package/build-types/v-stack/hook.d.ts +55 -56
  698. package/build-types/v-stack/hook.d.ts.map +1 -1
  699. package/build-types/v-stack/stories/index.d.ts +8 -1
  700. package/build-types/v-stack/stories/index.d.ts.map +1 -1
  701. package/build-types/view/component.d.ts +8 -6
  702. package/build-types/view/component.d.ts.map +1 -1
  703. package/build-types/view/stories/index.d.ts +12 -0
  704. package/build-types/view/stories/index.d.ts.map +1 -0
  705. package/build-types/view/types.d.ts +8 -0
  706. package/build-types/view/types.d.ts.map +1 -0
  707. package/build-types/visually-hidden/component.d.ts +2 -1
  708. package/build-types/visually-hidden/component.d.ts.map +1 -1
  709. package/build-types/z-stack/component.d.ts +2 -1
  710. package/build-types/z-stack/component.d.ts.map +1 -1
  711. package/package.json +17 -17
  712. package/src/alignment-matrix-control/styles/alignment-matrix-control-styles.js +1 -1
  713. package/src/angle-picker-control/README.md +9 -1
  714. package/src/angle-picker-control/index.js +12 -0
  715. package/src/angle-picker-control/stories/index.js +3 -3
  716. package/src/autocomplete/autocompleter-ui.js +6 -3
  717. package/src/base-field/test/__snapshots__/index.js.snap +3 -5
  718. package/src/border-box-control/border-box-control/component.tsx +28 -12
  719. package/src/border-box-control/border-box-control-linked-button/component.tsx +1 -2
  720. package/src/border-box-control/border-box-control-split-controls/component.tsx +25 -11
  721. package/src/border-box-control/stories/index.js +1 -0
  722. package/src/border-box-control/styles.ts +2 -1
  723. package/src/border-box-control/types.ts +5 -4
  724. package/src/border-control/border-control-dropdown/component.tsx +3 -8
  725. package/src/border-control/types.ts +7 -9
  726. package/src/box-control/linked-button.js +3 -3
  727. package/src/box-control/test/index.js +5 -5
  728. package/src/button/style.scss +4 -3
  729. package/src/card/styles.ts +1 -1
  730. package/src/card/test/__snapshots__/index.tsx.snap +39 -51
  731. package/src/checkbox-control/index.tsx +3 -6
  732. package/src/checkbox-control/stories/index.tsx +6 -2
  733. package/src/checkbox-control/types.ts +4 -1
  734. package/src/color-palette/index.js +1 -1
  735. package/src/color-palette/test/__snapshots__/index.js.snap +67 -91
  736. package/src/color-picker/input-with-slider.tsx +1 -0
  737. package/src/combobox-control/index.js +1 -1
  738. package/src/combobox-control/test/index.js +311 -0
  739. package/src/custom-gradient-picker/index.js +1 -1
  740. package/src/date-time/date/index.tsx +2 -2
  741. package/src/date-time/time/timezone.tsx +1 -1
  742. package/src/dimension-control/test/__snapshots__/index.test.js.snap +1122 -164
  743. package/src/dimension-control/test/index.test.js +29 -38
  744. package/src/disabled/index.tsx +27 -9
  745. package/src/disabled/styles/disabled-styles.tsx +2 -2
  746. package/src/disabled/test/index.tsx +38 -0
  747. package/src/drop-zone/README.md +3 -3
  748. package/src/drop-zone/{index.js → index.tsx} +48 -13
  749. package/src/drop-zone/{provider.js → provider.ts} +5 -1
  750. package/src/drop-zone/stories/index.tsx +30 -0
  751. package/src/drop-zone/types.ts +29 -0
  752. package/src/dropdown/README.md +6 -4
  753. package/src/dropdown/index.js +15 -3
  754. package/src/dropdown/stories/index.js +1 -1
  755. package/src/flex/flex/hook.ts +5 -54
  756. package/src/flex/test/__snapshots__/index.tsx.snap +7 -15
  757. package/src/focal-point-picker/README.md +2 -2
  758. package/src/focal-point-picker/{controls.js → controls.tsx} +38 -10
  759. package/src/focal-point-picker/{focal-point.js → focal-point.tsx} +7 -1
  760. package/src/focal-point-picker/{grid.js → grid.tsx} +6 -1
  761. package/src/focal-point-picker/{index.js → index.tsx} +99 -15
  762. package/src/focal-point-picker/{media.js → media.tsx} +10 -4
  763. package/src/focal-point-picker/stories/index.tsx +93 -0
  764. package/src/focal-point-picker/styles/{focal-point-picker-style.js → focal-point-picker-style.ts} +31 -5
  765. package/src/focal-point-picker/styles/{focal-point-style.js → focal-point-style.ts} +2 -1
  766. package/src/focal-point-picker/test/index.js +27 -7
  767. package/src/focal-point-picker/types.ts +93 -0
  768. package/src/focal-point-picker/{utils.js → utils.ts} +9 -9
  769. package/src/font-size-picker/README.md +9 -0
  770. package/src/font-size-picker/index.js +9 -0
  771. package/src/font-size-picker/stories/index.js +3 -5
  772. package/src/font-size-picker/test/index.js +15 -2
  773. package/src/font-size-picker/test/utils.js +1 -2
  774. package/src/font-size-picker/utils.js +1 -1
  775. package/src/form-file-upload/README.md +6 -1
  776. package/src/form-file-upload/{index.js → index.tsx} +22 -4
  777. package/src/form-file-upload/stories/index.tsx +74 -0
  778. package/src/form-file-upload/test/{index.js → index.tsx} +7 -3
  779. package/src/form-file-upload/types.ts +63 -0
  780. package/src/form-toggle/index.tsx +1 -6
  781. package/src/form-token-field/index.tsx +4 -5
  782. package/src/form-token-field/suggestions-list.tsx +1 -2
  783. package/src/gradient-picker/index.js +41 -47
  784. package/src/gradient-picker/stories/index.js +10 -0
  785. package/src/h-stack/test/__snapshots__/index.tsx.snap +3 -12
  786. package/src/higher-order/with-filters/test/__snapshots__/index.js.snap +87 -0
  787. package/src/higher-order/with-filters/test/index.js +20 -74
  788. package/src/icon/index.tsx +1 -1
  789. package/src/icon/stories/index.js +18 -0
  790. package/src/icon/test/index.js +32 -83
  791. package/src/input-control/input-base.tsx +9 -11
  792. package/src/input-control/label.tsx +9 -4
  793. package/src/input-control/styles/input-control-styles.tsx +0 -43
  794. package/src/input-control/types.ts +3 -0
  795. package/src/isolated-event-container/test/index.js +53 -11
  796. package/src/item-group/test/__snapshots__/index.js.snap +16 -16
  797. package/src/keyboard-shortcuts/test/index.js +16 -31
  798. package/src/menu-item/test/__snapshots__/index.js.snap +60 -62
  799. package/src/menu-item/test/index.js +30 -22
  800. package/src/modal/aria-helper.js +3 -8
  801. package/src/modal/style.scss +3 -4
  802. package/src/navigable-container/README.md +2 -0
  803. package/src/navigable-container/container.js +8 -1
  804. package/src/navigable-container/menu.js +14 -11
  805. package/src/navigable-container/stories/navigable-menu.js +49 -0
  806. package/src/navigable-container/stories/tabbable-container.js +40 -0
  807. package/src/navigable-container/tabbable.js +2 -3
  808. package/src/navigable-container/test/navigable-menu.js +277 -0
  809. package/src/navigable-container/test/tababble-container.js +175 -0
  810. package/src/navigation/menu/menu-title-search.js +2 -0
  811. package/src/navigation/menu/use-navigation-tree-menu.js +2 -0
  812. package/src/navigator/navigator-button/hook.ts +1 -1
  813. package/src/navigator/navigator-screen/component.tsx +6 -1
  814. package/src/number-control/index.tsx +209 -0
  815. package/src/number-control/stories/index.js +6 -18
  816. package/src/number-control/types.ts +75 -0
  817. package/src/panel/README.md +1 -1
  818. package/src/panel/test/__snapshots__/header.js.snap +9 -0
  819. package/src/panel/test/__snapshots__/index.js.snap +17 -0
  820. package/src/panel/test/__snapshots__/row.js.snap +17 -0
  821. package/src/panel/test/header.js +30 -23
  822. package/src/panel/test/index.js +33 -25
  823. package/src/panel/test/row.js +18 -11
  824. package/src/placeholder/index.tsx +4 -5
  825. package/src/placeholder/style.scss +4 -0
  826. package/src/popover/README.md +128 -48
  827. package/src/popover/{index.js → index.tsx} +284 -182
  828. package/src/popover/stories/{index.js → index.tsx} +52 -54
  829. package/src/popover/test/index.js +7 -5
  830. package/src/popover/types.ts +192 -0
  831. package/src/popover/utils.ts +242 -0
  832. package/src/radio-control/index.tsx +28 -29
  833. package/src/radio-control/style.scss +0 -17
  834. package/src/range-control/index.tsx +4 -1
  835. package/src/range-control/styles/range-control-styles.ts +8 -8
  836. package/src/sandbox/index.js +2 -2
  837. package/src/search-control/README.md +5 -3
  838. package/src/search-control/{index.js → index.tsx} +35 -7
  839. package/src/search-control/stories/index.tsx +66 -0
  840. package/src/search-control/types.ts +43 -0
  841. package/src/select-control/index.native.js +1 -1
  842. package/src/slot-fill/test/index.js +69 -12
  843. package/src/style.scss +0 -1
  844. package/src/surface/test/__snapshots__/index.tsx.snap +10 -10
  845. package/src/tab-panel/README.md +1 -2
  846. package/src/tab-panel/{index.js → index.tsx} +58 -13
  847. package/src/tab-panel/stories/index.tsx +37 -0
  848. package/src/tab-panel/test/index.tsx +120 -0
  849. package/src/tab-panel/types.ts +65 -0
  850. package/src/text-control/index.tsx +2 -0
  851. package/src/text-control/types.ts +5 -1
  852. package/src/textarea-control/index.tsx +3 -6
  853. package/src/textarea-control/types.ts +1 -1
  854. package/src/toggle-control/index.tsx +97 -0
  855. package/src/toggle-control/stories/index.tsx +58 -0
  856. package/src/toggle-control/test/index.tsx +53 -0
  857. package/src/toggle-control/types.ts +28 -0
  858. package/src/toggle-group-control/stories/index.tsx +10 -3
  859. package/src/toggle-group-control/toggle-group-control/component.tsx +3 -3
  860. package/src/toggle-group-control/toggle-group-control-option-icon/README.md +1 -1
  861. package/src/toggle-group-control/toggle-group-control-option-icon/component.tsx +1 -1
  862. package/src/toggle-group-control/types.ts +2 -2
  863. package/src/tooltip/index.js +11 -7
  864. package/src/ui/context/context-connect.ts +58 -31
  865. package/src/ui/context/context-system-provider.js +5 -4
  866. package/src/ui/context/test/context-connect.tsx +55 -0
  867. package/src/ui/context/test/wordpress-component.tsx +36 -0
  868. package/src/ui/context/wordpress-component.ts +18 -12
  869. package/src/ui/control-group/test/__snapshots__/index.js.snap +1 -4
  870. package/src/unit-control/index.tsx +1 -1
  871. package/src/unit-control/stories/index.tsx +7 -16
  872. package/src/unit-control/styles/unit-control-styles.ts +2 -2
  873. package/src/unit-control/test/__snapshots__/index.tsx.snap +4 -6
  874. package/src/unit-control/types.ts +3 -44
  875. package/src/utils/colors-values.js +2 -24
  876. package/src/utils/math.js +4 -4
  877. package/src/utils/values.js +48 -6
  878. package/src/v-stack/test/__snapshots__/index.tsx.snap +3 -12
  879. package/src/view/{component.js → component.tsx} +13 -4
  880. package/src/view/stories/index.tsx +32 -0
  881. package/src/view/types.ts +6 -0
  882. package/tsconfig.json +1 -6
  883. package/tsconfig.tsbuildinfo +1 -1
  884. package/src/focal-point-picker/stories/index.js +0 -76
  885. package/src/navigable-container/test/menu.js +0 -310
  886. package/src/navigable-container/test/tabbable.js +0 -158
  887. package/src/number-control/index.js +0 -192
  888. package/src/popover/utils.js +0 -107
  889. package/src/search-control/stories/index.js +0 -39
  890. package/src/tab-panel/stories/index.js +0 -39
  891. package/src/tab-panel/test/index.js +0 -179
  892. package/src/toggle-control/index.js +0 -55
  893. package/src/toggle-control/stories/index.js +0 -64
  894. package/src/toggle-control/style.scss +0 -14
  895. package/src/toggle-control/test/index.js +0 -52
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/components/src/toggle-control/index.js"],"names":["classnames","useInstanceId","FormToggle","BaseControl","ToggleControl","label","checked","help","className","onChange","disabled","onChangeToggle","event","target","instanceId","id","describedBy","helpLabel"],"mappings":";;AAAA;AACA;AACA;AACA,OAAOA,UAAP,MAAuB,YAAvB;AAEA;AACA;AACA;;AACA,SAASC,aAAT,QAA8B,oBAA9B;AAEA;AACA;AACA;;AACA,OAAOC,UAAP,MAAuB,gBAAvB;AACA,OAAOC,WAAP,MAAwB,iBAAxB;AAEA,eAAe,SAASC,aAAT,OAOX;AAAA,MAPmC;AACtCC,IAAAA,KADsC;AAEtCC,IAAAA,OAFsC;AAGtCC,IAAAA,IAHsC;AAItCC,IAAAA,SAJsC;AAKtCC,IAAAA,QALsC;AAMtCC,IAAAA;AANsC,GAOnC;;AACH,WAASC,cAAT,CAAyBC,KAAzB,EAAiC;AAChCH,IAAAA,QAAQ,CAAEG,KAAK,CAACC,MAAN,CAAaP,OAAf,CAAR;AACA;;AACD,QAAMQ,UAAU,GAAGb,aAAa,CAAEG,aAAF,CAAhC;AACA,QAAMW,EAAE,GAAI,4BAA4BD,UAAY,EAApD;AAEA,MAAIE,WAAJ,EAAiBC,SAAjB;;AACA,MAAKV,IAAL,EAAY;AACXS,IAAAA,WAAW,GAAGD,EAAE,GAAG,QAAnB;AACAE,IAAAA,SAAS,GAAG,OAAOV,IAAP,KAAgB,UAAhB,GAA6BA,IAAI,CAAED,OAAF,CAAjC,GAA+CC,IAA3D;AACA;;AAED,SACC,cAAC,WAAD;AACC,IAAA,EAAE,EAAGQ,EADN;AAEC,IAAA,IAAI,EAAGE,SAFR;AAGC,IAAA,SAAS,EAAGjB,UAAU,CAAE,2BAAF,EAA+BQ,SAA/B;AAHvB,KAKC,cAAC,UAAD;AACC,IAAA,EAAE,EAAGO,EADN;AAEC,IAAA,OAAO,EAAGT,OAFX;AAGC,IAAA,QAAQ,EAAGK,cAHZ;AAIC,wBAAmBK,WAJpB;AAKC,IAAA,QAAQ,EAAGN;AALZ,IALD,EAYC;AAAO,IAAA,OAAO,EAAGK,EAAjB;AAAsB,IAAA,SAAS,EAAC;AAAhC,KACGV,KADH,CAZD,CADD;AAkBA","sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport { useInstanceId } from '@wordpress/compose';\n\n/**\n * Internal dependencies\n */\nimport FormToggle from '../form-toggle';\nimport BaseControl from '../base-control';\n\nexport default function ToggleControl( {\n\tlabel,\n\tchecked,\n\thelp,\n\tclassName,\n\tonChange,\n\tdisabled,\n} ) {\n\tfunction onChangeToggle( event ) {\n\t\tonChange( event.target.checked );\n\t}\n\tconst instanceId = useInstanceId( ToggleControl );\n\tconst id = `inspector-toggle-control-${ instanceId }`;\n\n\tlet describedBy, helpLabel;\n\tif ( help ) {\n\t\tdescribedBy = id + '__help';\n\t\thelpLabel = typeof help === 'function' ? help( checked ) : help;\n\t}\n\n\treturn (\n\t\t<BaseControl\n\t\t\tid={ id }\n\t\t\thelp={ helpLabel }\n\t\t\tclassName={ classnames( 'components-toggle-control', className ) }\n\t\t>\n\t\t\t<FormToggle\n\t\t\t\tid={ id }\n\t\t\t\tchecked={ checked }\n\t\t\t\tonChange={ onChangeToggle }\n\t\t\t\taria-describedby={ describedBy }\n\t\t\t\tdisabled={ disabled }\n\t\t\t/>\n\t\t\t<label htmlFor={ id } className=\"components-toggle-control__label\">\n\t\t\t\t{ label }\n\t\t\t</label>\n\t\t</BaseControl>\n\t);\n}\n"]}
1
+ {"version":3,"sources":["@wordpress/components/src/toggle-control/index.tsx"],"names":["css","useInstanceId","FormToggle","BaseControl","HStack","useCx","space","ToggleControl","__nextHasNoMarginBottom","label","checked","help","className","onChange","disabled","onChangeToggle","event","target","instanceId","id","cx","classes","marginBottom","describedBy","helpLabel"],"mappings":";;AAAA;AACA;AACA;AAEA,SAASA,GAAT,QAAoB,gBAApB;AAEA;AACA;AACA;;AACA,SAASC,aAAT,QAA8B,oBAA9B;AAEA;AACA;AACA;;AACA,OAAOC,UAAP,MAAuB,gBAAvB;AACA,OAAOC,WAAP,MAAwB,iBAAxB;AAGA,SAASC,MAAT,QAAuB,YAAvB;AACA,SAASC,KAAT,QAAsB,UAAtB;AACA,SAASC,KAAT,QAAsB,mBAAtB;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,SAASC,aAAT,OAQ4D;AAAA,MARpC;AAC9BC,IAAAA,uBAD8B;AAE9BC,IAAAA,KAF8B;AAG9BC,IAAAA,OAH8B;AAI9BC,IAAAA,IAJ8B;AAK9BC,IAAAA,SAL8B;AAM9BC,IAAAA,QAN8B;AAO9BC,IAAAA;AAP8B,GAQoC;;AAClE,WAASC,cAAT,CAAyBC,KAAzB,EAAkE;AACjEH,IAAAA,QAAQ,CAAEG,KAAK,CAACC,MAAN,CAAaP,OAAf,CAAR;AACA;;AACD,QAAMQ,UAAU,GAAGjB,aAAa,CAAEM,aAAF,CAAhC;AACA,QAAMY,EAAE,GAAI,4BAA4BD,UAAY,EAApD;AAEA,QAAME,EAAE,GAAGf,KAAK,EAAhB;AACA,QAAMgB,OAAO,GAAGD,EAAE,CACjB,2BADiB,EAEjBR,SAFiB,EAGjB,CAAEJ,uBAAF,iBAA6BR,GAAG,CAAE;AAAEsB,IAAAA,YAAY,EAAEhB,KAAK,CAAE,CAAF;AAArB,GAAF,qpHAHf,CAAlB;AAMA,MAAIiB,WAAJ,EAAiBC,SAAjB;;AACA,MAAKb,IAAL,EAAY;AACXY,IAAAA,WAAW,GAAGJ,EAAE,GAAG,QAAnB;AACAK,IAAAA,SAAS,GAAG,OAAOb,IAAP,KAAgB,UAAhB,GAA6BA,IAAI,CAAED,OAAF,CAAjC,GAA+CC,IAA3D;AACA;;AAED,SACC,cAAC,WAAD;AACC,IAAA,EAAE,EAAGQ,EADN;AAEC,IAAA,IAAI,EAAGK,SAFR;AAGC,IAAA,SAAS,EAAGH,OAHb;AAIC,IAAA,uBAAuB;AAJxB,KAMC,cAAC,MAAD;AAAQ,IAAA,OAAO,EAAC,YAAhB;AAA6B,IAAA,OAAO,EAAG;AAAvC,KACC,cAAC,UAAD;AACC,IAAA,EAAE,EAAGF,EADN;AAEC,IAAA,OAAO,EAAGT,OAFX;AAGC,IAAA,QAAQ,EAAGK,cAHZ;AAIC,wBAAmBQ,WAJpB;AAKC,IAAA,QAAQ,EAAGT;AALZ,IADD,EAQC;AACC,IAAA,OAAO,EAAGK,EADX;AAEC,IAAA,SAAS,EAAC;AAFX,KAIGV,KAJH,CARD,CAND,CADD;AAwBA;AAED,eAAeF,aAAf","sourcesContent":["/**\n * External dependencies\n */\nimport type { ChangeEvent } from 'react';\nimport { css } from '@emotion/react';\n\n/**\n * WordPress dependencies\n */\nimport { useInstanceId } from '@wordpress/compose';\n\n/**\n * Internal dependencies\n */\nimport FormToggle from '../form-toggle';\nimport BaseControl from '../base-control';\nimport type { WordPressComponentProps } from '../ui/context/wordpress-component';\nimport type { ToggleControlProps } from './types';\nimport { HStack } from '../h-stack';\nimport { useCx } from '../utils';\nimport { space } from '../ui/utils/space';\n\n/**\n * ToggleControl is used to generate a toggle user interface.\n *\n * ```jsx\n * import { ToggleControl } from '@wordpress/components';\n * import { useState } from '@wordpress/element';\n *\n * const MyToggleControl = () => {\n * const [ value, setValue ] = useState( false );\n *\n * return (\n * <ToggleControl\n * label=\"Fixed Background\"\n * checked={ value }\n * onChange={ () => setValue( ( state ) => ! state ) }\n * />\n * );\n * };\n * ```\n */\nexport function ToggleControl( {\n\t__nextHasNoMarginBottom,\n\tlabel,\n\tchecked,\n\thelp,\n\tclassName,\n\tonChange,\n\tdisabled,\n}: WordPressComponentProps< ToggleControlProps, 'input', false > ) {\n\tfunction onChangeToggle( event: ChangeEvent< HTMLInputElement > ) {\n\t\tonChange( event.target.checked );\n\t}\n\tconst instanceId = useInstanceId( ToggleControl );\n\tconst id = `inspector-toggle-control-${ instanceId }`;\n\n\tconst cx = useCx();\n\tconst classes = cx(\n\t\t'components-toggle-control',\n\t\tclassName,\n\t\t! __nextHasNoMarginBottom && css( { marginBottom: space( 3 ) } )\n\t);\n\n\tlet describedBy, helpLabel;\n\tif ( help ) {\n\t\tdescribedBy = id + '__help';\n\t\thelpLabel = typeof help === 'function' ? help( checked ) : help;\n\t}\n\n\treturn (\n\t\t<BaseControl\n\t\t\tid={ id }\n\t\t\thelp={ helpLabel }\n\t\t\tclassName={ classes }\n\t\t\t__nextHasNoMarginBottom\n\t\t>\n\t\t\t<HStack justify=\"flex-start\" spacing={ 3 }>\n\t\t\t\t<FormToggle\n\t\t\t\t\tid={ id }\n\t\t\t\t\tchecked={ checked }\n\t\t\t\t\tonChange={ onChangeToggle }\n\t\t\t\t\taria-describedby={ describedBy }\n\t\t\t\t\tdisabled={ disabled }\n\t\t\t\t/>\n\t\t\t\t<label\n\t\t\t\t\thtmlFor={ id }\n\t\t\t\t\tclassName=\"components-toggle-control__label\"\n\t\t\t\t>\n\t\t\t\t\t{ label }\n\t\t\t\t</label>\n\t\t\t</HStack>\n\t\t</BaseControl>\n\t);\n}\n\nexport default ToggleControl;\n"]}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"names":[],"mappings":"","sourcesContent":[]}
@@ -33,7 +33,7 @@ function UnconnectedToggleGroupControl(props, forwardedRef) {
33
33
  className,
34
34
  isAdaptiveWidth = false,
35
35
  isBlock = false,
36
- __experimentalIsIconGroup = false,
36
+ __experimentalIsBorderless = false,
37
37
  label,
38
38
  hideLabelFromVision = false,
39
39
  help,
@@ -68,7 +68,7 @@ function UnconnectedToggleGroupControl(props, forwardedRef) {
68
68
  }, [value]);
69
69
  const classes = useMemo(() => cx(styles.ToggleGroupControl({
70
70
  size
71
- }), !__experimentalIsIconGroup && styles.border, isBlock && styles.block, className), [className, cx, isBlock, __experimentalIsIconGroup, size]);
71
+ }), !__experimentalIsBorderless && styles.border, isBlock && styles.block, className), [className, cx, isBlock, __experimentalIsBorderless, size]);
72
72
  return createElement(BaseControl, {
73
73
  help: help,
74
74
  __nextHasNoMarginBottom: __nextHasNoMarginBottom
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/components/src/toggle-group-control/toggle-group-control/component.tsx"],"names":["RadioGroup","useRadioState","useRef","useMemo","useMergeRefs","useInstanceId","usePrevious","useResizeObserver","contextConnect","useContextSystem","useUpdateEffect","useCx","View","BaseControl","ToggleGroupControlBackdrop","ToggleGroupControlContext","VisualLabelWrapper","styles","noop","UnconnectedToggleGroupControl","props","forwardedRef","__nextHasNoMarginBottom","className","isAdaptiveWidth","isBlock","__experimentalIsIconGroup","label","hideLabelFromVision","help","onChange","size","value","children","otherProps","cx","containerRef","resizeListener","sizes","baseId","ToggleGroupControl","toString","radio","state","previousValue","setState","classes","border","block","width"],"mappings":";;;AAAA;AACA;AACA;AAEA;AACA,SAASA,UAAT,EAAqBC,aAArB,QAA0C,QAA1C;AAEA;AACA;AACA;;AAEA,SAASC,MAAT,EAAiBC,OAAjB,QAAgC,oBAAhC;AACA,SACCC,YADD,EAECC,aAFD,EAGCC,WAHD,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AG,EAAG9B,YAAY,CAAE,CAAEgC,YAAF,EAAgBf,YAAhB,CAAF;AANnB,MAQGgB,cARH,EASC,cAAC,0BAAD,eACMK,KADN;AAEC,IAAA,YAAY,EAAGN,YAFhB;AAGC,IAAA,cAAc,EAAGE,KAAK,CAACW,KAHxB;AAIC,IAAA,eAAe,EAAGzB;AAJnB,KATD,EAeGS,QAfH,CAVD,CAJD,CADD;AAmCA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AACA,OAAO,MAAMO,kBAAkB,GAAGhC,cAAc,CAC/CW,6BAD+C,EAE/C,oBAF+C,CAAzC;AAKP,eAAeqB,kBAAf","sourcesContent":["/**\n * External dependencies\n */\nimport type { ForwardedRef } from 'react';\n// eslint-disable-next-line no-restricted-imports\nimport { RadioGroup, useRadioState } from 'reakit';\n\n/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { useRef, useMemo } from '@wordpress/element';\nimport {\n\tuseMergeRefs,\n\tuseInstanceId,\n\tusePrevious,\n\tuseResizeObserver,\n} from '@wordpress/compose';\n\n/**\n * Internal dependencies\n */\nimport {\n\tcontextConnect,\n\tuseContextSystem,\n\tWordPressComponentProps,\n} from '../../ui/context';\nimport { useUpdateEffect, useCx } from '../../utils/hooks';\nimport { View } from '../../view';\nimport BaseControl from '../../base-control';\nimport type { ToggleGroupControlProps } from '../types';\nimport ToggleGroupControlBackdrop from './toggle-group-control-backdrop';\nimport ToggleGroupControlContext from '../context';\nimport { VisualLabelWrapper } from './styles';\nimport * as styles from './styles';\n\nconst noop = () => {};\n\nfunction UnconnectedToggleGroupControl(\n\tprops: WordPressComponentProps< ToggleGroupControlProps, 'input', false >,\n\tforwardedRef: ForwardedRef< any >\n) {\n\tconst {\n\t\t__nextHasNoMarginBottom = false,\n\t\tclassName,\n\t\tisAdaptiveWidth = false,\n\t\tisBlock = false,\n\t\t__experimentalIsIconGroup = false,\n\t\tlabel,\n\t\thideLabelFromVision = false,\n\t\thelp,\n\t\tonChange = noop,\n\t\tsize = 'default',\n\t\tvalue,\n\t\tchildren,\n\t\t...otherProps\n\t} = useContextSystem( props, 'ToggleGroupControl' );\n\tconst cx = useCx();\n\tconst containerRef = useRef();\n\tconst [ resizeListener, sizes ] = useResizeObserver();\n\tconst baseId = useInstanceId(\n\t\tToggleGroupControl,\n\t\t'toggle-group-control'\n\t).toString();\n\tconst radio = useRadioState( {\n\t\tbaseId,\n\t\tstate: value,\n\t} );\n\tconst previousValue = usePrevious( value );\n\n\t// Propagate radio.state change.\n\tuseUpdateEffect( () => {\n\t\t// Avoid calling onChange if radio state changed\n\t\t// from incoming value.\n\t\tif ( previousValue !== radio.state ) {\n\t\t\tonChange( radio.state );\n\t\t}\n\t}, [ radio.state ] );\n\n\t// Sync incoming value with radio.state.\n\tuseUpdateEffect( () => {\n\t\tif ( value !== radio.state ) {\n\t\t\tradio.setState( value );\n\t\t}\n\t}, [ value ] );\n\n\tconst classes = useMemo(\n\t\t() =>\n\t\t\tcx(\n\t\t\t\tstyles.ToggleGroupControl( { size } ),\n\t\t\t\t! __experimentalIsIconGroup && styles.border,\n\t\t\t\tisBlock && styles.block,\n\t\t\t\tclassName\n\t\t\t),\n\t\t[ className, cx, isBlock, __experimentalIsIconGroup, size ]\n\t);\n\treturn (\n\t\t<BaseControl\n\t\t\thelp={ help }\n\t\t\t__nextHasNoMarginBottom={ __nextHasNoMarginBottom }\n\t\t>\n\t\t\t<ToggleGroupControlContext.Provider\n\t\t\t\tvalue={ { ...radio, isBlock: ! isAdaptiveWidth, size } }\n\t\t\t>\n\t\t\t\t{ ! hideLabelFromVision && (\n\t\t\t\t\t<VisualLabelWrapper>\n\t\t\t\t\t\t<BaseControl.VisualLabel>\n\t\t\t\t\t\t\t{ label }\n\t\t\t\t\t\t</BaseControl.VisualLabel>\n\t\t\t\t\t</VisualLabelWrapper>\n\t\t\t\t) }\n\t\t\t\t<RadioGroup\n\t\t\t\t\t{ ...radio }\n\t\t\t\t\taria-label={ label }\n\t\t\t\t\tas={ View }\n\t\t\t\t\tclassName={ classes }\n\t\t\t\t\t{ ...otherProps }\n\t\t\t\t\tref={ useMergeRefs( [ containerRef, forwardedRef ] ) }\n\t\t\t\t>\n\t\t\t\t\t{ resizeListener }\n\t\t\t\t\t<ToggleGroupControlBackdrop\n\t\t\t\t\t\t{ ...radio }\n\t\t\t\t\t\tcontainerRef={ containerRef }\n\t\t\t\t\t\tcontainerWidth={ sizes.width }\n\t\t\t\t\t\tisAdaptiveWidth={ isAdaptiveWidth }\n\t\t\t\t\t/>\n\t\t\t\t\t{ children }\n\t\t\t\t</RadioGroup>\n\t\t\t</ToggleGroupControlContext.Provider>\n\t\t</BaseControl>\n\t);\n}\n\n/**\n * `ToggleGroupControl` is a form component that lets users choose options\n * represented in horizontal segments. To render options for this control use\n * `ToggleGroupControlOption` component.\n *\n * This component is intended for selecting a single persistent value from a set of options,\n * similar to a how a radio button group would work. If you simply want a toggle to switch between views,\n * use a `TabPanel` instead.\n *\n * Only use this control when you know for sure the labels of items inside won't\n * wrap. For items with longer labels, you can consider a `SelectControl` or a\n * `CustomSelectControl` component instead.\n *\n * ```jsx\n * import {\n * __experimentalToggleGroupControl as ToggleGroupControl,\n * __experimentalToggleGroupControlOption as ToggleGroupControlOption,\n * } from '@wordpress/components';\n *\n * function Example() {\n * return (\n * <ToggleGroupControl label=\"my label\" value=\"vertical\" isBlock>\n * <ToggleGroupControlOption value=\"horizontal\" label=\"Horizontal\" />\n * <ToggleGroupControlOption value=\"vertical\" label=\"Vertical\" />\n * </ToggleGroupControl>\n * );\n * }\n * ```\n */\nexport const ToggleGroupControl = contextConnect(\n\tUnconnectedToggleGroupControl,\n\t'ToggleGroupControl'\n);\n\nexport default ToggleGroupControl;\n"]}
1
+ {"version":3,"sources":["@wordpress/components/src/toggle-group-control/toggle-group-control/component.tsx"],"names":["RadioGroup","useRadioState","useRef","useMemo","useMergeRefs","useInstanceId","usePrevious","useResizeObserver","contextConnect","useContextSystem","useUpdateEffect","useCx","View","BaseControl","ToggleGroupControlBackdrop","ToggleGroupControlContext","VisualLabelWrapper","styles","noop","UnconnectedToggleGroupControl","props","forwardedRef","__nextHasNoMarginBottom","className","isAdaptiveWidth","isBlock","__experimentalIsBorderless","label","hideLabelFromVision","help","onChange","size","value","children","otherProps","cx","containerRef","resizeListener","sizes","baseId","ToggleGroupControl","toString","radio","state","previousValue","setState","classes","border","block","width"],"mappings":";;;AAAA;AACA;AACA;AAEA;AACA,SAASA,UAAT,EAAqBC,aAArB,QAA0C,QAA1C;AAEA;AACA;AACA;;AAEA,SAASC,MAAT,EAAiBC,OAAjB,QAAgC,oBAAhC;AACA,SACCC,YADD,EAECC,aAFD,EAGCC,WAHD,EAICC,iBAJD,QAKO,oBALP;AAOA;AACA;AACA;;AACA,SACCC,cADD,EAECC,gBAFD,QAIO,kBAJP;AAKA,SAASC,eAAT,EAA0BC,KAA1B,QAAuC,mBAAvC;AACA,SAASC,IAAT,QAAqB,YAArB;AACA,OAAOC,WAAP,MAAwB,oBAAxB;AAEA,OAAOC,0BAAP,MAAuC,iCAAvC;AACA,OAAOC,yBAAP,MAAsC,YAAtC;AACA,SAASC,kBAAT,QAAmC,UAAnC;AACA,OAAO,KAAKC,MAAZ,MAAwB,UAAxB;;AAEA,MAAMC,IAAI,GAAG,MAAM,CAAE,CAArB;;AAEA,SAASC,6BAAT,CACCC,KADD,EAECC,YAFD,EAGE;AACD,QAAM;AACLC,IAAAA,uBAAuB,GAAG,KADrB;AAELC,IAAAA,SAFK;AAGLC,IAAAA,eAAe,GAAG,KAHb;AAILC,IAAAA,OAAO,GAAG,KAJL;AAKLC,IAAAA,0BAA0B,GAAG,KALxB;AAMLC,IAAAA,KANK;AAOLC,IAAAA,mBAAmB,GAAG,KAPjB;AAQLC,IAAAA,IARK;AASLC,IAAAA,QAAQ,GAAGZ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AAaY,EAAb,EAAiBV,OAAjB,EAA0BC,0BAA1B,EAAsDK,IAAtD,CARsB,CAAvB;AAUA,SACC,cAAC,WAAD;AACC,IAAA,IAAI,EAAGF,IADR;AAEC,IAAA,uBAAuB,EAAGP;AAF3B,KAIC,cAAC,yBAAD,CAA2B,QAA3B;AACC,IAAA,KAAK,EAAG,EAAE,GAAGoB,KAAL;AAAYjB,MAAAA,OAAO,EAAE,CAAED,eAAvB;AAAwCO,MAAAA;AAAxC;AADT,KAGG,CAAEH,mBAAF,IACD,cAAC,kBAAD,QACC,cAAC,WAAD,CAAa,WAAb,QACGD,KADH,CADD,CAJF,EAUC,cAAC,UAAD,eACMe,KADN;AAEC,kBAAaf,KAFd;AAGC,IAAA,EAAE,EAAGf,IAHN;AAIC,IAAA,SAAS,EAAGkC;AAJb,KAKMZ,UALN;AAMC,IAAA,GAAG,EAAG9B,YAAY,CAAE,CAAEgC,YAAF,EAAgBf,YAAhB,CAAF;AANnB,MAQGgB,cARH,EASC,cAAC,0BAAD,eACMK,KADN;AAEC,IAAA,YAAY,EAAGN,YAFhB;AAGC,IAAA,cAAc,EAAGE,KAAK,CAACW,KAHxB;AAIC,IAAA,eAAe,EAAGzB;AAJnB,KATD,EAeGS,QAfH,CAVD,CAJD,CADD;AAmCA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AACA,OAAO,MAAMO,kBAAkB,GAAGhC,cAAc,CAC/CW,6BAD+C,EAE/C,oBAF+C,CAAzC;AAKP,eAAeqB,kBAAf","sourcesContent":["/**\n * External dependencies\n */\nimport type { ForwardedRef } from 'react';\n// eslint-disable-next-line no-restricted-imports\nimport { RadioGroup, useRadioState } from 'reakit';\n\n/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { useRef, useMemo } from '@wordpress/element';\nimport {\n\tuseMergeRefs,\n\tuseInstanceId,\n\tusePrevious,\n\tuseResizeObserver,\n} from '@wordpress/compose';\n\n/**\n * Internal dependencies\n */\nimport {\n\tcontextConnect,\n\tuseContextSystem,\n\tWordPressComponentProps,\n} from '../../ui/context';\nimport { useUpdateEffect, useCx } from '../../utils/hooks';\nimport { View } from '../../view';\nimport BaseControl from '../../base-control';\nimport type { ToggleGroupControlProps } from '../types';\nimport ToggleGroupControlBackdrop from './toggle-group-control-backdrop';\nimport ToggleGroupControlContext from '../context';\nimport { VisualLabelWrapper } from './styles';\nimport * as styles from './styles';\n\nconst noop = () => {};\n\nfunction UnconnectedToggleGroupControl(\n\tprops: WordPressComponentProps< ToggleGroupControlProps, 'input', false >,\n\tforwardedRef: ForwardedRef< any >\n) {\n\tconst {\n\t\t__nextHasNoMarginBottom = false,\n\t\tclassName,\n\t\tisAdaptiveWidth = false,\n\t\tisBlock = false,\n\t\t__experimentalIsBorderless = false,\n\t\tlabel,\n\t\thideLabelFromVision = false,\n\t\thelp,\n\t\tonChange = noop,\n\t\tsize = 'default',\n\t\tvalue,\n\t\tchildren,\n\t\t...otherProps\n\t} = useContextSystem( props, 'ToggleGroupControl' );\n\tconst cx = useCx();\n\tconst containerRef = useRef();\n\tconst [ resizeListener, sizes ] = useResizeObserver();\n\tconst baseId = useInstanceId(\n\t\tToggleGroupControl,\n\t\t'toggle-group-control'\n\t).toString();\n\tconst radio = useRadioState( {\n\t\tbaseId,\n\t\tstate: value,\n\t} );\n\tconst previousValue = usePrevious( value );\n\n\t// Propagate radio.state change.\n\tuseUpdateEffect( () => {\n\t\t// Avoid calling onChange if radio state changed\n\t\t// from incoming value.\n\t\tif ( previousValue !== radio.state ) {\n\t\t\tonChange( radio.state );\n\t\t}\n\t}, [ radio.state ] );\n\n\t// Sync incoming value with radio.state.\n\tuseUpdateEffect( () => {\n\t\tif ( value !== radio.state ) {\n\t\t\tradio.setState( value );\n\t\t}\n\t}, [ value ] );\n\n\tconst classes = useMemo(\n\t\t() =>\n\t\t\tcx(\n\t\t\t\tstyles.ToggleGroupControl( { size } ),\n\t\t\t\t! __experimentalIsBorderless && styles.border,\n\t\t\t\tisBlock && styles.block,\n\t\t\t\tclassName\n\t\t\t),\n\t\t[ className, cx, isBlock, __experimentalIsBorderless, size ]\n\t);\n\treturn (\n\t\t<BaseControl\n\t\t\thelp={ help }\n\t\t\t__nextHasNoMarginBottom={ __nextHasNoMarginBottom }\n\t\t>\n\t\t\t<ToggleGroupControlContext.Provider\n\t\t\t\tvalue={ { ...radio, isBlock: ! isAdaptiveWidth, size } }\n\t\t\t>\n\t\t\t\t{ ! hideLabelFromVision && (\n\t\t\t\t\t<VisualLabelWrapper>\n\t\t\t\t\t\t<BaseControl.VisualLabel>\n\t\t\t\t\t\t\t{ label }\n\t\t\t\t\t\t</BaseControl.VisualLabel>\n\t\t\t\t\t</VisualLabelWrapper>\n\t\t\t\t) }\n\t\t\t\t<RadioGroup\n\t\t\t\t\t{ ...radio }\n\t\t\t\t\taria-label={ label }\n\t\t\t\t\tas={ View }\n\t\t\t\t\tclassName={ classes }\n\t\t\t\t\t{ ...otherProps }\n\t\t\t\t\tref={ useMergeRefs( [ containerRef, forwardedRef ] ) }\n\t\t\t\t>\n\t\t\t\t\t{ resizeListener }\n\t\t\t\t\t<ToggleGroupControlBackdrop\n\t\t\t\t\t\t{ ...radio }\n\t\t\t\t\t\tcontainerRef={ containerRef }\n\t\t\t\t\t\tcontainerWidth={ sizes.width }\n\t\t\t\t\t\tisAdaptiveWidth={ isAdaptiveWidth }\n\t\t\t\t\t/>\n\t\t\t\t\t{ children }\n\t\t\t\t</RadioGroup>\n\t\t\t</ToggleGroupControlContext.Provider>\n\t\t</BaseControl>\n\t);\n}\n\n/**\n * `ToggleGroupControl` is a form component that lets users choose options\n * represented in horizontal segments. To render options for this control use\n * `ToggleGroupControlOption` component.\n *\n * This component is intended for selecting a single persistent value from a set of options,\n * similar to a how a radio button group would work. If you simply want a toggle to switch between views,\n * use a `TabPanel` instead.\n *\n * Only use this control when you know for sure the labels of items inside won't\n * wrap. For items with longer labels, you can consider a `SelectControl` or a\n * `CustomSelectControl` component instead.\n *\n * ```jsx\n * import {\n * __experimentalToggleGroupControl as ToggleGroupControl,\n * __experimentalToggleGroupControlOption as ToggleGroupControlOption,\n * } from '@wordpress/components';\n *\n * function Example() {\n * return (\n * <ToggleGroupControl label=\"my label\" value=\"vertical\" isBlock>\n * <ToggleGroupControlOption value=\"horizontal\" label=\"Horizontal\" />\n * <ToggleGroupControlOption value=\"vertical\" label=\"Vertical\" />\n * </ToggleGroupControl>\n * );\n * }\n * ```\n */\nexport const ToggleGroupControl = contextConnect(\n\tUnconnectedToggleGroupControl,\n\t'ToggleGroupControl'\n);\n\nexport default ToggleGroupControl;\n"]}
@@ -45,7 +45,7 @@ function UnforwardedToggleGroupControlOptionIcon(props, ref) {
45
45
  *
46
46
  * function Example() {
47
47
  * return (
48
- * <ToggleGroupControl __experimentalIsIconGroup>
48
+ * <ToggleGroupControl>
49
49
  * <ToggleGroupControlOptionIcon
50
50
  * value="uppercase"
51
51
  * label="Uppercase"
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/components/src/toggle-group-control/toggle-group-control-option-icon/component.tsx"],"names":["forwardRef","ToggleGroupControlOptionBase","Icon","UnforwardedToggleGroupControlOptionIcon","props","ref","icon","label","restProps","ToggleGroupControlOptionIcon"],"mappings":";;;AAAA;AACA;AACA;;AAGA;AACA;AACA;AACA,SAASA,UAAT,QAA2B,oBAA3B;AAEA;AACA;AACA;;AAGA,SAASC,4BAAT,QAA6C,qCAA7C;AACA,OAAOC,IAAP,MAAiB,YAAjB;;AAEA,SAASC,uCAAT,CACCC,KADD,EAMCC,GAND,EAOE;AACD,QAAM;AAAEC,IAAAA,IAAF;AAAQC,IAAAA,KAAR;AAAe,OAAGC;AAAlB,MAAgCJ,KAAtC;AACA,SACC,cAAC,4BAAD,eACMI,SADN;AAEC,IAAA,MAAM,MAFP;AAGC,kBAAaD,KAHd;AAIC,IAAA,WAAW,MAJZ;AAKC,IAAA,GAAG,EAAGF;AALP,MAOC,cAAC,IAAD;AAAM,IAAA,IAAI,EAAGC;AAAb,IAPD,CADD;AAWA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AACA,OAAO,MAAMG,4BAA4B,GAAGT,UAAU,CACrDG,uCADqD,CAA/C;AAIP,eAAeM,4BAAf","sourcesContent":["/**\n * External dependencies\n */\nimport type { ForwardedRef } from 'react';\n\n/**\n * WordPress dependencies\n */\nimport { forwardRef } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport type { WordPressComponentProps } from '../../ui/context';\nimport type { ToggleGroupControlOptionIconProps } from '../types';\nimport { ToggleGroupControlOptionBase } from '../toggle-group-control-option-base';\nimport Icon from '../../icon';\n\nfunction UnforwardedToggleGroupControlOptionIcon(\n\tprops: WordPressComponentProps<\n\t\tToggleGroupControlOptionIconProps,\n\t\t'button',\n\t\tfalse\n\t>,\n\tref: ForwardedRef< any >\n) {\n\tconst { icon, label, ...restProps } = props;\n\treturn (\n\t\t<ToggleGroupControlOptionBase\n\t\t\t{ ...restProps }\n\t\t\tisIcon\n\t\t\taria-label={ label }\n\t\t\tshowTooltip\n\t\t\tref={ ref }\n\t\t>\n\t\t\t<Icon icon={ icon } />\n\t\t</ToggleGroupControlOptionBase>\n\t);\n}\n\n/**\n * `ToggleGroupControlOptionIcon` is a form component which is meant to be used as a\n * child of `ToggleGroupControl` and displays an icon.\n *\n * ```jsx\n *\n * import {\n *\t__experimentalToggleGroupControl as ToggleGroupControl,\n *\t__experimentalToggleGroupControlOptionIcon as ToggleGroupControlOptionIcon,\n * from '@wordpress/components';\n * import { formatLowercase, formatUppercase } from '@wordpress/icons';\n *\n * function Example() {\n *\treturn (\n *\t\t<ToggleGroupControl __experimentalIsIconGroup>\n *\t\t\t<ToggleGroupControlOptionIcon\n *\t\t\t\tvalue=\"uppercase\"\n *\t\t\t\tlabel=\"Uppercase\"\n *\t\t\t\ticon={ formatUppercase }\n *\t\t\t/>\n *\t\t\t<ToggleGroupControlOptionIcon\n *\t\t\t\tvalue=\"lowercase\"\n *\t\t\t\tlabel=\"Lowercase\"\n *\t\t\t\ticon={ formatLowercase }\n *\t\t\t/>\n *\t\t</ToggleGroupControl>\n *\t);\n * }\n * ```\n */\nexport const ToggleGroupControlOptionIcon = forwardRef(\n\tUnforwardedToggleGroupControlOptionIcon\n);\n\nexport default ToggleGroupControlOptionIcon;\n"]}
1
+ {"version":3,"sources":["@wordpress/components/src/toggle-group-control/toggle-group-control-option-icon/component.tsx"],"names":["forwardRef","ToggleGroupControlOptionBase","Icon","UnforwardedToggleGroupControlOptionIcon","props","ref","icon","label","restProps","ToggleGroupControlOptionIcon"],"mappings":";;;AAAA;AACA;AACA;;AAGA;AACA;AACA;AACA,SAASA,UAAT,QAA2B,oBAA3B;AAEA;AACA;AACA;;AAGA,SAASC,4BAAT,QAA6C,qCAA7C;AACA,OAAOC,IAAP,MAAiB,YAAjB;;AAEA,SAASC,uCAAT,CACCC,KADD,EAMCC,GAND,EAOE;AACD,QAAM;AAAEC,IAAAA,IAAF;AAAQC,IAAAA,KAAR;AAAe,OAAGC;AAAlB,MAAgCJ,KAAtC;AACA,SACC,cAAC,4BAAD,eACMI,SADN;AAEC,IAAA,MAAM,MAFP;AAGC,kBAAaD,KAHd;AAIC,IAAA,WAAW,MAJZ;AAKC,IAAA,GAAG,EAAGF;AALP,MAOC,cAAC,IAAD;AAAM,IAAA,IAAI,EAAGC;AAAb,IAPD,CADD;AAWA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AACA,OAAO,MAAMG,4BAA4B,GAAGT,UAAU,CACrDG,uCADqD,CAA/C;AAIP,eAAeM,4BAAf","sourcesContent":["/**\n * External dependencies\n */\nimport type { ForwardedRef } from 'react';\n\n/**\n * WordPress dependencies\n */\nimport { forwardRef } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport type { WordPressComponentProps } from '../../ui/context';\nimport type { ToggleGroupControlOptionIconProps } from '../types';\nimport { ToggleGroupControlOptionBase } from '../toggle-group-control-option-base';\nimport Icon from '../../icon';\n\nfunction UnforwardedToggleGroupControlOptionIcon(\n\tprops: WordPressComponentProps<\n\t\tToggleGroupControlOptionIconProps,\n\t\t'button',\n\t\tfalse\n\t>,\n\tref: ForwardedRef< any >\n) {\n\tconst { icon, label, ...restProps } = props;\n\treturn (\n\t\t<ToggleGroupControlOptionBase\n\t\t\t{ ...restProps }\n\t\t\tisIcon\n\t\t\taria-label={ label }\n\t\t\tshowTooltip\n\t\t\tref={ ref }\n\t\t>\n\t\t\t<Icon icon={ icon } />\n\t\t</ToggleGroupControlOptionBase>\n\t);\n}\n\n/**\n * `ToggleGroupControlOptionIcon` is a form component which is meant to be used as a\n * child of `ToggleGroupControl` and displays an icon.\n *\n * ```jsx\n *\n * import {\n *\t__experimentalToggleGroupControl as ToggleGroupControl,\n *\t__experimentalToggleGroupControlOptionIcon as ToggleGroupControlOptionIcon,\n * from '@wordpress/components';\n * import { formatLowercase, formatUppercase } from '@wordpress/icons';\n *\n * function Example() {\n *\treturn (\n *\t\t<ToggleGroupControl>\n *\t\t\t<ToggleGroupControlOptionIcon\n *\t\t\t\tvalue=\"uppercase\"\n *\t\t\t\tlabel=\"Uppercase\"\n *\t\t\t\ticon={ formatUppercase }\n *\t\t\t/>\n *\t\t\t<ToggleGroupControlOptionIcon\n *\t\t\t\tvalue=\"lowercase\"\n *\t\t\t\tlabel=\"Lowercase\"\n *\t\t\t\ticon={ formatLowercase }\n *\t\t\t/>\n *\t\t</ToggleGroupControl>\n *\t);\n * }\n * ```\n */\nexport const ToggleGroupControlOptionIcon = forwardRef(\n\tUnforwardedToggleGroupControlOptionIcon\n);\n\nexport default ToggleGroupControlOptionIcon;\n"]}
@@ -4,7 +4,7 @@ import { createElement } from "@wordpress/element";
4
4
  /**
5
5
  * WordPress dependencies
6
6
  */
7
- import { Children, cloneElement, concatChildren, useEffect, useState, useRef } from '@wordpress/element';
7
+ import { Children, cloneElement, concatChildren, useEffect, useState } from '@wordpress/element';
8
8
  import { useDebounce, useMergeRefs } from '@wordpress/compose';
9
9
  /**
10
10
  * Internal dependencies
@@ -54,7 +54,7 @@ const getRegularElement = _ref2 => {
54
54
 
55
55
  const addPopoverToGrandchildren = _ref3 => {
56
56
  let {
57
- anchorRef,
57
+ anchor,
58
58
  grandchildren,
59
59
  isOver,
60
60
  offset,
@@ -69,8 +69,8 @@ const addPopoverToGrandchildren = _ref3 => {
69
69
  "aria-hidden": "true",
70
70
  animate: false,
71
71
  offset: offset,
72
- anchorRef: anchorRef,
73
- __unstableShift: true
72
+ anchor: anchor,
73
+ shift: true
74
74
  }, text, createElement(Shortcut, {
75
75
  className: "components-tooltip__shortcut",
76
76
  shortcut: shortcut
@@ -112,13 +112,15 @@ function Tooltip(props) {
112
112
 
113
113
  const [isMouseDown, setIsMouseDown] = useState(false);
114
114
  const [isOver, setIsOver] = useState(false);
115
- const delayedSetIsOver = useDebounce(setIsOver, delay); // Create a reference to the Tooltip's child, to be passed to the Popover
115
+ const delayedSetIsOver = useDebounce(setIsOver, delay); // Using internal state (instead of a ref) for the popover anchor to make sure
116
+ // that the component re-renders when the anchor updates.
117
+
118
+ const [popoverAnchor, setPopoverAnchor] = useState(null); // Create a reference to the Tooltip's child, to be passed to the Popover
116
119
  // so that the Tooltip can be correctly positioned. Also, merge with the
117
120
  // existing ref for the first child, so that its ref is preserved.
118
121
 
119
- const childRef = useRef(null);
120
122
  const existingChildRef = (_Children$toArray$ = Children.toArray(children)[0]) === null || _Children$toArray$ === void 0 ? void 0 : _Children$toArray$.ref;
121
- const mergedChildRefs = useMergeRefs([childRef, existingChildRef]);
123
+ const mergedChildRefs = useMergeRefs([setPopoverAnchor, existingChildRef]);
122
124
 
123
125
  const createMouseDown = event => {
124
126
  // In firefox, the mouse down event is also fired when the select
@@ -239,7 +241,7 @@ function Tooltip(props) {
239
241
  } = child.props;
240
242
  const getElementWithPopover = disabled ? getDisabledElement : getRegularElement;
241
243
  const popoverData = {
242
- anchorRef: childRef,
244
+ anchor: popoverAnchor,
243
245
  isOver,
244
246
  offset: 4,
245
247
  position,
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/components/src/tooltip/index.js"],"names":["Children","cloneElement","concatChildren","useEffect","useState","useRef","useDebounce","useMergeRefs","Popover","Shortcut","TOOLTIP_DELAY","eventCatcher","getDisabledElement","eventHandlers","child","childrenWithPopover","mergedRefs","children","ref","getRegularElement","addPopoverToGrandchildren","anchorRef","grandchildren","isOver","offset","position","shortcut","text","emitToChild","eventName","event","count","only","props","disabled","Tooltip","delay","isMouseDown","setIsMouseDown","setIsOver","delayedSetIsOver","childRef","existingChildRef","toArray","mergedChildRefs","createMouseDown","target","tagName","document","addEventListener","cancelIsMouseDown","createMouseUp","removeEventListener","createMouseEvent","type","createToggleIsOver","isDelayed","currentTarget","cancel","_isOver","includes","clearOnUnmount","process","env","NODE_ENV","console","error","onMouseEnter","onMouseLeave","onClick","onFocus","onBlur","onMouseDown","getElementWithPopover","popoverData"],"mappings":";AAAA;;AAEA;AACA;AACA;AACA,SACCA,QADD,EAECC,YAFD,EAGCC,cAHD,EAICC,SAJD,EAKCC,QALD,EAMCC,MAND,QAOO,oBAPP;AAQA,SAASC,WAAT,EAAsBC,YAAtB,QAA0C,oBAA1C;AAEA;AACA;AACA;;AACA,OAAOC,OAAP,MAAoB,YAApB;AACA,OAAOC,QAAP,MAAqB,aAArB;AAEA;AACA;AACA;AACA;AACA;;AACA,OAAO,MAAMC,aAAa,GAAG,GAAtB;AAEP,MAAMC,YAAY,GAAG;AAAK,EAAA,SAAS,EAAC;AAAf,EA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AF,CAJN;AAKrBgB,IAAAA,MAAM,EAAEhB,kBAAkB,CAAE,QAAF,CALL;AAMrBiB,IAAAA,WAAW,EAAEnB,gBAAgB,CAAE,WAAF;AANR,GAAtB;AASA,QAAMvC,KAAK,GAAGd,QAAQ,CAACgC,IAAT,CAAef,QAAf,CAAd;AACA,QAAM;AAAEA,IAAAA,QAAQ,EAAEK,aAAZ;AAA2BY,IAAAA;AAA3B,MAAwCpB,KAAK,CAACmB,KAApD;AACA,QAAMwC,qBAAqB,GAAGvC,QAAQ,GACnCtB,kBADmC,GAEnCO,iBAFH;AAIA,QAAMuD,WAAW,GAAG;AACnBrD,IAAAA,SAAS,EAAEoB,QADQ;AAEnBlB,IAAAA,MAFmB;AAGnBC,IAAAA,MAAM,EAAE,CAHW;AAInBC,IAAAA,QAJmB;AAKnBC,IAAAA,QALmB;AAMnBC,IAAAA;AANmB,GAApB;AAQA,QAAMZ,mBAAmB,GAAGK,yBAAyB,CAAE;AACtDE,IAAAA,aADsD;AAEtD,OAAGoD;AAFmD,GAAF,CAArD;AAKA,SAAOD,qBAAqB,CAAE;AAC7B3D,IAAAA,KAD6B;AAE7BD,IAAAA,aAF6B;AAG7BE,IAAAA,mBAH6B;AAI7BC,IAAAA,UAAU,EAAE4B;AAJiB,GAAF,CAA5B;AAMA;;AAED,eAAeT,OAAf","sourcesContent":["// @ts-nocheck\n\n/**\n * WordPress dependencies\n */\nimport {\n\tChildren,\n\tcloneElement,\n\tconcatChildren,\n\tuseEffect,\n\tuseState,\n\tuseRef,\n} from '@wordpress/element';\nimport { useDebounce, useMergeRefs } from '@wordpress/compose';\n\n/**\n * Internal dependencies\n */\nimport Popover from '../popover';\nimport Shortcut from '../shortcut';\n\n/**\n * Time over children to wait before showing tooltip\n *\n * @type {number}\n */\nexport const TOOLTIP_DELAY = 700;\n\nconst eventCatcher = <div className=\"event-catcher\" />;\n\nconst getDisabledElement = ( {\n\teventHandlers,\n\tchild,\n\tchildrenWithPopover,\n\tmergedRefs,\n} ) => {\n\treturn cloneElement(\n\t\t<span className=\"disabled-element-wrapper\">\n\t\t\t{ cloneElement( eventCatcher, eventHandlers ) }\n\t\t\t{ cloneElement( child, {\n\t\t\t\tchildren: childrenWithPopover,\n\t\t\t\tref: mergedRefs,\n\t\t\t} ) }\n\t\t</span>,\n\t\t{ ...eventHandlers }\n\t);\n};\n\nconst getRegularElement = ( {\n\tchild,\n\teventHandlers,\n\tchildrenWithPopover,\n\tmergedRefs,\n} ) => {\n\treturn cloneElement( child, {\n\t\t...eventHandlers,\n\t\tchildren: childrenWithPopover,\n\t\tref: mergedRefs,\n\t} );\n};\n\nconst addPopoverToGrandchildren = ( {\n\tanchorRef,\n\tgrandchildren,\n\tisOver,\n\toffset,\n\tposition,\n\tshortcut,\n\ttext,\n} ) =>\n\tconcatChildren(\n\t\tgrandchildren,\n\t\tisOver && (\n\t\t\t<Popover\n\t\t\t\tfocusOnMount={ false }\n\t\t\t\tposition={ position }\n\t\t\t\tclassName=\"components-tooltip\"\n\t\t\t\taria-hidden=\"true\"\n\t\t\t\tanimate={ false }\n\t\t\t\toffset={ offset }\n\t\t\t\tanchorRef={ anchorRef }\n\t\t\t\t__unstableShift\n\t\t\t>\n\t\t\t\t{ text }\n\t\t\t\t<Shortcut\n\t\t\t\t\tclassName=\"components-tooltip__shortcut\"\n\t\t\t\t\tshortcut={ shortcut }\n\t\t\t\t/>\n\t\t\t</Popover>\n\t\t)\n\t);\n\nconst emitToChild = ( children, eventName, event ) => {\n\tif ( Children.count( children ) !== 1 ) {\n\t\treturn;\n\t}\n\n\tconst child = Children.only( children );\n\n\t// If the underlying element is disabled, do not emit the event.\n\tif ( child.props.disabled ) {\n\t\treturn;\n\t}\n\n\tif ( typeof child.props[ eventName ] === 'function' ) {\n\t\tchild.props[ eventName ]( event );\n\t}\n};\n\nfunction Tooltip( props ) {\n\tconst {\n\t\tchildren,\n\t\tposition = 'bottom middle',\n\t\ttext,\n\t\tshortcut,\n\t\tdelay = TOOLTIP_DELAY,\n\t} = props;\n\t/**\n\t * Whether a mouse is currently pressed, used in determining whether\n\t * to handle a focus event as displaying the tooltip immediately.\n\t *\n\t * @type {boolean}\n\t */\n\tconst [ isMouseDown, setIsMouseDown ] = useState( false );\n\tconst [ isOver, setIsOver ] = useState( false );\n\tconst delayedSetIsOver = useDebounce( setIsOver, delay );\n\n\t// Create a reference to the Tooltip's child, to be passed to the Popover\n\t// so that the Tooltip can be correctly positioned. Also, merge with the\n\t// existing ref for the first child, so that its ref is preserved.\n\tconst childRef = useRef( null );\n\tconst existingChildRef = Children.toArray( children )[ 0 ]?.ref;\n\tconst mergedChildRefs = useMergeRefs( [ childRef, existingChildRef ] );\n\n\tconst createMouseDown = ( event ) => {\n\t\t// In firefox, the mouse down event is also fired when the select\n\t\t// list is chosen.\n\t\t// Cancel further processing because re-rendering of child components\n\t\t// causes onChange to be triggered with the old value.\n\t\t// See https://github.com/WordPress/gutenberg/pull/42483\n\t\tif ( event.target.tagName === 'OPTION' ) {\n\t\t\treturn;\n\t\t}\n\n\t\t// Preserve original child callback behavior.\n\t\temitToChild( children, 'onMouseDown', event );\n\n\t\t// On mouse down, the next `mouseup` should revert the value of the\n\t\t// instance property and remove its own event handler. The bind is\n\t\t// made on the document since the `mouseup` might not occur within\n\t\t// the bounds of the element.\n\t\tdocument.addEventListener( 'mouseup', cancelIsMouseDown );\n\t\tsetIsMouseDown( true );\n\t};\n\n\tconst createMouseUp = ( event ) => {\n\t\t// In firefox, the mouse up event is also fired when the select\n\t\t// list is chosen.\n\t\t// Cancel further processing because re-rendering of child components\n\t\t// causes onChange to be triggered with the old value.\n\t\t// See https://github.com/WordPress/gutenberg/pull/42483\n\t\tif ( event.target.tagName === 'OPTION' ) {\n\t\t\treturn;\n\t\t}\n\n\t\temitToChild( children, 'onMouseUp', event );\n\t\tdocument.removeEventListener( 'mouseup', cancelIsMouseDown );\n\t\tsetIsMouseDown( false );\n\t};\n\n\tconst createMouseEvent = ( type ) => {\n\t\tif ( type === 'mouseUp' ) return createMouseUp;\n\t\tif ( type === 'mouseDown' ) return createMouseDown;\n\t};\n\n\t/**\n\t * Prebound `isInMouseDown` handler, created as a constant reference to\n\t * assure ability to remove in component unmount.\n\t *\n\t * @type {Function}\n\t */\n\tconst cancelIsMouseDown = createMouseEvent( 'mouseUp' );\n\n\tconst createToggleIsOver = ( eventName, isDelayed ) => {\n\t\treturn ( event ) => {\n\t\t\t// Preserve original child callback behavior.\n\t\t\temitToChild( children, eventName, event );\n\n\t\t\t// Mouse events behave unreliably in React for disabled elements,\n\t\t\t// firing on mouseenter but not mouseleave. Further, the default\n\t\t\t// behavior for disabled elements in some browsers is to ignore\n\t\t\t// mouse events. Don't bother trying to handle them.\n\t\t\t//\n\t\t\t// See: https://github.com/facebook/react/issues/4251\n\t\t\tif ( event.currentTarget.disabled ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\t// A focus event will occur as a result of a mouse click, but it\n\t\t\t// should be disambiguated between interacting with the button and\n\t\t\t// using an explicit focus shift as a cue to display the tooltip.\n\t\t\tif ( 'focus' === event.type && isMouseDown ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\t// Needed in case unsetting is over while delayed set pending, i.e.\n\t\t\t// quickly blur/mouseleave before delayedSetIsOver is called.\n\t\t\tdelayedSetIsOver.cancel();\n\n\t\t\tconst _isOver = [ 'focus', 'mouseenter' ].includes( event.type );\n\t\t\tif ( _isOver === isOver ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tif ( isDelayed ) {\n\t\t\t\tdelayedSetIsOver( _isOver );\n\t\t\t} else {\n\t\t\t\tsetIsOver( _isOver );\n\t\t\t}\n\t\t};\n\t};\n\tconst clearOnUnmount = () => {\n\t\tdelayedSetIsOver.cancel();\n\t\tdocument.removeEventListener( 'mouseup', cancelIsMouseDown );\n\t};\n\n\tuseEffect( () => clearOnUnmount, [] );\n\n\tif ( Children.count( children ) !== 1 ) {\n\t\tif ( 'development' === process.env.NODE_ENV ) {\n\t\t\t// eslint-disable-next-line no-console\n\t\t\tconsole.error(\n\t\t\t\t'Tooltip should be called with only a single child element.'\n\t\t\t);\n\t\t}\n\n\t\treturn children;\n\t}\n\n\tconst eventHandlers = {\n\t\tonMouseEnter: createToggleIsOver( 'onMouseEnter', true ),\n\t\tonMouseLeave: createToggleIsOver( 'onMouseLeave' ),\n\t\tonClick: createToggleIsOver( 'onClick' ),\n\t\tonFocus: createToggleIsOver( 'onFocus' ),\n\t\tonBlur: createToggleIsOver( 'onBlur' ),\n\t\tonMouseDown: createMouseEvent( 'mouseDown' ),\n\t};\n\n\tconst child = Children.only( children );\n\tconst { children: grandchildren, disabled } = child.props;\n\tconst getElementWithPopover = disabled\n\t\t? getDisabledElement\n\t\t: getRegularElement;\n\n\tconst popoverData = {\n\t\tanchorRef: childRef,\n\t\tisOver,\n\t\toffset: 4,\n\t\tposition,\n\t\tshortcut,\n\t\ttext,\n\t};\n\tconst childrenWithPopover = addPopoverToGrandchildren( {\n\t\tgrandchildren,\n\t\t...popoverData,\n\t} );\n\n\treturn getElementWithPopover( {\n\t\tchild,\n\t\teventHandlers,\n\t\tchildrenWithPopover,\n\t\tmergedRefs: mergedChildRefs,\n\t} );\n}\n\nexport default Tooltip;\n"]}
1
+ {"version":3,"sources":["@wordpress/components/src/tooltip/index.js"],"names":["Children","cloneElement","concatChildren","useEffect","useState","useDebounce","useMergeRefs","Popover","Shortcut","TOOLTIP_DELAY","eventCatcher","getDisabledElement","eventHandlers","child","childrenWithPopover","mergedRefs","children","ref","getRegularElement","addPopoverToGrandchildren","anchor","grandchildren","isOver","offset","position","shortcut","text","emitToChild","eventName","event","count","only","props","disabled","Tooltip","delay","isMouseDown","setIsMouseDown","setIsOver","delayedSetIsOver","popoverAnchor","setPopoverAnchor","existingChildRef","toArray","mergedChildRefs","createMouseDown","target","tagName","document","addEventListener","cancelIsMouseDown","createMouseUp","removeEventListener","createMouseEvent","type","createToggleIsOver","isDelayed","currentTarget","cancel","_isOver","includes","clearOnUnmount","process","env","NODE_ENV","console","error","onMouseEnter","onMouseLeave","onClick","onFocus","onBlur","onMouseDown","getElementWithPopover","popoverData"],"mappings":";AAAA;;AAEA;AACA;AACA;AACA,SACCA,QADD,EAECC,YAFD,EAGCC,cAHD,EAICC,SAJD,EAKCC,QALD,QAMO,oBANP;AAOA,SAASC,WAAT,EAAsBC,YAAtB,QAA0C,oBAA1C;AAEA;AACA;AACA;;AACA,OAAOC,OAAP,MAAoB,YAApB;AACA,OAAOC,QAAP,MAAqB,aAArB;AAEA;AACA;AACA;AACA;AACA;;AACA,OAAO,MAAMC,aAAa,GAAG,GAAtB;AAEP,MAAMC,YAAY,GAAG;AAAK,EAAA,SAAS,EAAC;AAAf,EAArB;;AAEA,MAAMC,kBAAkB,GAAG,QAKpB;AAAA,MALsB;AAC5BC,IAAAA,aAD4B;AAE5BC,IAAAA,KAF4B;AAG5BC,IAAAA,mBAH4B;AAI5BC,IAAAA;AAJ4B,GAKtB;AACN,SAAOd,YAAY,CAClB;AAAM,IAAA,SAAS,EAAC;AAAhB,KACGA,YAAY,CAAES,YAAF,EAAgBE,aAAhB,CADf,EAEGX,YAAY,CAAEY,KAAF,EAAS;AACtBG,IAAAA,QAAQ,EAAEF,mBADY;AAEtBG,IAAAA,GAAG,EAAEF;AAFiB,GAAT,CAFf,CADkB,EAQlB,EAAE,GAAGH;AAAL,GARkB,CAAnB;AAUA,CAhBD;;AAkBA,MAAMM,iBAAiB,GAAG,SAKnB;AAAA,MALqB;AAC3BL,IAAAA,KAD2B;AAE3BD,IAAAA,aAF2B;AAG3BE,IAAAA,mBAH2B;AAI3BC,IAAAA;AAJ2B,GAKrB;AACN,SAAOd,YAAY,CAAEY,KAAF,EAAS,EAC3B,GAAGD,aADwB;AAE3BI,IAAAA,QAAQ,EAAEF,mBAFiB;AAG3BG,IAAAA,GAAG,EAAEF;AAHsB,GAAT,CAAnB;AAKA,CAXD;;AAaA,MAAMI,yBAAyB,GAAG;AAAA,MAAE;AACnCC,IAAAA,MADmC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;AAI7BC,IAAAA,UAAU,EAAE6B;AAJiB,GAAF,CAA5B;AAMA;;AAED,eAAeV,OAAf","sourcesContent":["// @ts-nocheck\n\n/**\n * WordPress dependencies\n */\nimport {\n\tChildren,\n\tcloneElement,\n\tconcatChildren,\n\tuseEffect,\n\tuseState,\n} from '@wordpress/element';\nimport { useDebounce, useMergeRefs } from '@wordpress/compose';\n\n/**\n * Internal dependencies\n */\nimport Popover from '../popover';\nimport Shortcut from '../shortcut';\n\n/**\n * Time over children to wait before showing tooltip\n *\n * @type {number}\n */\nexport const TOOLTIP_DELAY = 700;\n\nconst eventCatcher = <div className=\"event-catcher\" />;\n\nconst getDisabledElement = ( {\n\teventHandlers,\n\tchild,\n\tchildrenWithPopover,\n\tmergedRefs,\n} ) => {\n\treturn cloneElement(\n\t\t<span className=\"disabled-element-wrapper\">\n\t\t\t{ cloneElement( eventCatcher, eventHandlers ) }\n\t\t\t{ cloneElement( child, {\n\t\t\t\tchildren: childrenWithPopover,\n\t\t\t\tref: mergedRefs,\n\t\t\t} ) }\n\t\t</span>,\n\t\t{ ...eventHandlers }\n\t);\n};\n\nconst getRegularElement = ( {\n\tchild,\n\teventHandlers,\n\tchildrenWithPopover,\n\tmergedRefs,\n} ) => {\n\treturn cloneElement( child, {\n\t\t...eventHandlers,\n\t\tchildren: childrenWithPopover,\n\t\tref: mergedRefs,\n\t} );\n};\n\nconst addPopoverToGrandchildren = ( {\n\tanchor,\n\tgrandchildren,\n\tisOver,\n\toffset,\n\tposition,\n\tshortcut,\n\ttext,\n} ) =>\n\tconcatChildren(\n\t\tgrandchildren,\n\t\tisOver && (\n\t\t\t<Popover\n\t\t\t\tfocusOnMount={ false }\n\t\t\t\tposition={ position }\n\t\t\t\tclassName=\"components-tooltip\"\n\t\t\t\taria-hidden=\"true\"\n\t\t\t\tanimate={ false }\n\t\t\t\toffset={ offset }\n\t\t\t\tanchor={ anchor }\n\t\t\t\tshift\n\t\t\t>\n\t\t\t\t{ text }\n\t\t\t\t<Shortcut\n\t\t\t\t\tclassName=\"components-tooltip__shortcut\"\n\t\t\t\t\tshortcut={ shortcut }\n\t\t\t\t/>\n\t\t\t</Popover>\n\t\t)\n\t);\n\nconst emitToChild = ( children, eventName, event ) => {\n\tif ( Children.count( children ) !== 1 ) {\n\t\treturn;\n\t}\n\n\tconst child = Children.only( children );\n\n\t// If the underlying element is disabled, do not emit the event.\n\tif ( child.props.disabled ) {\n\t\treturn;\n\t}\n\n\tif ( typeof child.props[ eventName ] === 'function' ) {\n\t\tchild.props[ eventName ]( event );\n\t}\n};\n\nfunction Tooltip( props ) {\n\tconst {\n\t\tchildren,\n\t\tposition = 'bottom middle',\n\t\ttext,\n\t\tshortcut,\n\t\tdelay = TOOLTIP_DELAY,\n\t} = props;\n\t/**\n\t * Whether a mouse is currently pressed, used in determining whether\n\t * to handle a focus event as displaying the tooltip immediately.\n\t *\n\t * @type {boolean}\n\t */\n\tconst [ isMouseDown, setIsMouseDown ] = useState( false );\n\tconst [ isOver, setIsOver ] = useState( false );\n\tconst delayedSetIsOver = useDebounce( setIsOver, delay );\n\t// Using internal state (instead of a ref) for the popover anchor to make sure\n\t// that the component re-renders when the anchor updates.\n\tconst [ popoverAnchor, setPopoverAnchor ] = useState( null );\n\n\t// Create a reference to the Tooltip's child, to be passed to the Popover\n\t// so that the Tooltip can be correctly positioned. Also, merge with the\n\t// existing ref for the first child, so that its ref is preserved.\n\tconst existingChildRef = Children.toArray( children )[ 0 ]?.ref;\n\tconst mergedChildRefs = useMergeRefs( [\n\t\tsetPopoverAnchor,\n\t\texistingChildRef,\n\t] );\n\n\tconst createMouseDown = ( event ) => {\n\t\t// In firefox, the mouse down event is also fired when the select\n\t\t// list is chosen.\n\t\t// Cancel further processing because re-rendering of child components\n\t\t// causes onChange to be triggered with the old value.\n\t\t// See https://github.com/WordPress/gutenberg/pull/42483\n\t\tif ( event.target.tagName === 'OPTION' ) {\n\t\t\treturn;\n\t\t}\n\n\t\t// Preserve original child callback behavior.\n\t\temitToChild( children, 'onMouseDown', event );\n\n\t\t// On mouse down, the next `mouseup` should revert the value of the\n\t\t// instance property and remove its own event handler. The bind is\n\t\t// made on the document since the `mouseup` might not occur within\n\t\t// the bounds of the element.\n\t\tdocument.addEventListener( 'mouseup', cancelIsMouseDown );\n\t\tsetIsMouseDown( true );\n\t};\n\n\tconst createMouseUp = ( event ) => {\n\t\t// In firefox, the mouse up event is also fired when the select\n\t\t// list is chosen.\n\t\t// Cancel further processing because re-rendering of child components\n\t\t// causes onChange to be triggered with the old value.\n\t\t// See https://github.com/WordPress/gutenberg/pull/42483\n\t\tif ( event.target.tagName === 'OPTION' ) {\n\t\t\treturn;\n\t\t}\n\n\t\temitToChild( children, 'onMouseUp', event );\n\t\tdocument.removeEventListener( 'mouseup', cancelIsMouseDown );\n\t\tsetIsMouseDown( false );\n\t};\n\n\tconst createMouseEvent = ( type ) => {\n\t\tif ( type === 'mouseUp' ) return createMouseUp;\n\t\tif ( type === 'mouseDown' ) return createMouseDown;\n\t};\n\n\t/**\n\t * Prebound `isInMouseDown` handler, created as a constant reference to\n\t * assure ability to remove in component unmount.\n\t *\n\t * @type {Function}\n\t */\n\tconst cancelIsMouseDown = createMouseEvent( 'mouseUp' );\n\n\tconst createToggleIsOver = ( eventName, isDelayed ) => {\n\t\treturn ( event ) => {\n\t\t\t// Preserve original child callback behavior.\n\t\t\temitToChild( children, eventName, event );\n\n\t\t\t// Mouse events behave unreliably in React for disabled elements,\n\t\t\t// firing on mouseenter but not mouseleave. Further, the default\n\t\t\t// behavior for disabled elements in some browsers is to ignore\n\t\t\t// mouse events. Don't bother trying to handle them.\n\t\t\t//\n\t\t\t// See: https://github.com/facebook/react/issues/4251\n\t\t\tif ( event.currentTarget.disabled ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\t// A focus event will occur as a result of a mouse click, but it\n\t\t\t// should be disambiguated between interacting with the button and\n\t\t\t// using an explicit focus shift as a cue to display the tooltip.\n\t\t\tif ( 'focus' === event.type && isMouseDown ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\t// Needed in case unsetting is over while delayed set pending, i.e.\n\t\t\t// quickly blur/mouseleave before delayedSetIsOver is called.\n\t\t\tdelayedSetIsOver.cancel();\n\n\t\t\tconst _isOver = [ 'focus', 'mouseenter' ].includes( event.type );\n\t\t\tif ( _isOver === isOver ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tif ( isDelayed ) {\n\t\t\t\tdelayedSetIsOver( _isOver );\n\t\t\t} else {\n\t\t\t\tsetIsOver( _isOver );\n\t\t\t}\n\t\t};\n\t};\n\tconst clearOnUnmount = () => {\n\t\tdelayedSetIsOver.cancel();\n\t\tdocument.removeEventListener( 'mouseup', cancelIsMouseDown );\n\t};\n\n\tuseEffect( () => clearOnUnmount, [] );\n\n\tif ( Children.count( children ) !== 1 ) {\n\t\tif ( 'development' === process.env.NODE_ENV ) {\n\t\t\t// eslint-disable-next-line no-console\n\t\t\tconsole.error(\n\t\t\t\t'Tooltip should be called with only a single child element.'\n\t\t\t);\n\t\t}\n\n\t\treturn children;\n\t}\n\n\tconst eventHandlers = {\n\t\tonMouseEnter: createToggleIsOver( 'onMouseEnter', true ),\n\t\tonMouseLeave: createToggleIsOver( 'onMouseLeave' ),\n\t\tonClick: createToggleIsOver( 'onClick' ),\n\t\tonFocus: createToggleIsOver( 'onFocus' ),\n\t\tonBlur: createToggleIsOver( 'onBlur' ),\n\t\tonMouseDown: createMouseEvent( 'mouseDown' ),\n\t};\n\n\tconst child = Children.only( children );\n\tconst { children: grandchildren, disabled } = child.props;\n\tconst getElementWithPopover = disabled\n\t\t? getDisabledElement\n\t\t: getRegularElement;\n\n\tconst popoverData = {\n\t\tanchor: popoverAnchor,\n\t\tisOver,\n\t\toffset: 4,\n\t\tposition,\n\t\tshortcut,\n\t\ttext,\n\t};\n\tconst childrenWithPopover = addPopoverToGrandchildren( {\n\t\tgrandchildren,\n\t\t...popoverData,\n\t} );\n\n\treturn getElementWithPopover( {\n\t\tchild,\n\t\teventHandlers,\n\t\tchildrenWithPopover,\n\t\tmergedRefs: mergedChildRefs,\n\t} );\n}\n\nexport default Tooltip;\n"]}
@@ -5,7 +5,7 @@
5
5
  /**
6
6
  * WordPress dependencies
7
7
  */
8
- import { forwardRef, memo } from '@wordpress/element';
8
+ import { forwardRef } from '@wordpress/element';
9
9
  import warn from '@wordpress/warning';
10
10
  /**
11
11
  * Internal dependencies
@@ -18,30 +18,36 @@ import { getStyledClassNameFromKey } from './get-styled-class-name-from-key';
18
18
  * Forwards ref (React.ForwardRef) and "Connects" (or registers) a component
19
19
  * within the Context system under a specified namespace.
20
20
  *
21
- * This is an (experimental) evolution of the initial connect() HOC.
22
- * The hope is that we can improve render performance by removing functional
23
- * component wrappers.
24
- *
25
21
  * @param Component The component to register into the Context system.
26
22
  * @param namespace The namespace to register the component under.
27
- * @param options
28
23
  * @return The connected WordPressComponent
29
24
  */
30
25
  export function contextConnect(Component, namespace) {
31
- let options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
32
- const {
33
- memo: memoProp = false
34
- } = options;
35
- let WrappedComponent = forwardRef(Component);
26
+ return _contextConnect(Component, namespace, {
27
+ forwardsRef: true
28
+ });
29
+ }
30
+ /**
31
+ * "Connects" (or registers) a component within the Context system under a specified namespace.
32
+ * Does not forward a ref.
33
+ *
34
+ * @param Component The component to register into the Context system.
35
+ * @param namespace The namespace to register the component under.
36
+ * @return The connected WordPressComponent
37
+ */
36
38
 
37
- if (memoProp) {
38
- // @ts-ignore
39
- WrappedComponent = memo(WrappedComponent);
40
- }
39
+ export function contextConnectWithoutRef(Component, namespace) {
40
+ return _contextConnect(Component, namespace);
41
+ } // This is an (experimental) evolution of the initial connect() HOC.
42
+ // The hope is that we can improve render performance by removing functional
43
+ // component wrappers.
44
+
45
+ function _contextConnect(Component, namespace, options) {
46
+ const WrappedComponent = options !== null && options !== void 0 && options.forwardsRef ? forwardRef(Component) : Component;
41
47
 
42
48
  if (typeof namespace === 'undefined') {
43
49
  typeof process !== "undefined" && process.env && process.env.NODE_ENV !== "production" ? warn('contextConnect: Please provide a namespace') : void 0;
44
- } // @ts-ignore internal property
50
+ } // @ts-expect-error internal property
45
51
 
46
52
 
47
53
  let mergedNamespace = WrappedComponent[CONNECT_STATIC_NAMESPACE] || [namespace];
@@ -55,15 +61,15 @@ export function contextConnect(Component, namespace) {
55
61
 
56
62
  if (typeof namespace === 'string') {
57
63
  mergedNamespace = [...mergedNamespace, namespace];
58
- }
64
+ } // @ts-expect-error We can't rely on inferred types here because of the
65
+ // `as` prop polymorphism we're handling in https://github.com/WordPress/gutenberg/blob/9620bae6fef4fde7cc2b7833f416e240207cda29/packages/components/src/ui/context/wordpress-component.ts#L32-L33
59
66
 
60
- WrappedComponent.displayName = namespace; // @ts-ignore internal property
61
67
 
62
- WrappedComponent[CONNECT_STATIC_NAMESPACE] = [...new Set(mergedNamespace)]; // @ts-ignore WordPressComponent property
63
-
64
- WrappedComponent.selector = `.${getStyledClassNameFromKey(namespace)}`; // @ts-ignore
65
-
66
- return WrappedComponent;
68
+ return Object.assign(WrappedComponent, {
69
+ [CONNECT_STATIC_NAMESPACE]: [...new Set(mergedNamespace)],
70
+ displayName: namespace,
71
+ selector: `.${getStyledClassNameFromKey(namespace)}`
72
+ });
67
73
  }
68
74
  /**
69
75
  * Attempts to retrieve the connected namespace from a component.
@@ -72,6 +78,7 @@ export function contextConnect(Component, namespace) {
72
78
  * @return The connected namespaces.
73
79
  */
74
80
 
81
+
75
82
  export function getConnectNamespace(Component) {
76
83
  if (!Component) return [];
77
84
  let namespaces = []; // @ts-ignore internal property
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/components/src/ui/context/context-connect.ts"],"names":["forwardRef","memo","warn","CONNECT_STATIC_NAMESPACE","getStyledClassNameFromKey","contextConnect","Component","namespace","options","memoProp","WrappedComponent","mergedNamespace","Array","isArray","displayName","Set","selector","getConnectNamespace","namespaces","type","hasConnectNamespace","match","includes","some","result"],"mappings":"AAAA;AAC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A,gBAAgB,CAACM,QAAjB,GAA6B,IAAIZ,yBAAyB,CAAEG,SAAF,CAAe,EAAzE,CApCmC,CAsCnC;;AACA,SAAOG,gBAAP;AACA;AAED;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,SAASO,mBAAT,CACNX,SADM,EAEK;AACX,MAAK,CAAEA,SAAP,EAAmB,OAAO,EAAP;AAEnB,MAAIY,UAAU,GAAG,EAAjB,CAHW,CAKX;;AACA,MAAKZ,SAAS,CAAEH,wBAAF,CAAd,EAA6C;AAC5C;AACAe,IAAAA,UAAU,GAAGZ,SAAS,CAAEH,wBAAF,CAAtB;AACA,GATU,CAWX;;;AACA,MAAKG,SAAS,CAACa,IAAV,IAAkBb,SAAS,CAACa,IAAV,CAAgBhB,wBAAhB,CAAvB,EAAoE;AACnE;AACAe,IAAAA,UAAU,GAAGZ,SAAS,CAACa,IAAV,CAAgBhB,wBAAhB,CAAb;AACA;;AAED,SAAOe,UAAP;AACA;AAED;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,SAASE,mBAAT,CACNd,SADM,EAENe,KAFM,EAGI;AACV,MAAK,CAAEf,SAAP,EAAmB,OAAO,KAAP;;AAEnB,MAAK,OAAOe,KAAP,KAAiB,QAAtB,EAAiC;AAChC,WAAOJ,mBAAmB,CAAEX,SAAF,CAAnB,CAAiCgB,QAAjC,CAA2CD,KAA3C,CAAP;AACA;;AACD,MAAKT,KAAK,CAACC,OAAN,CAAeQ,KAAf,CAAL,EAA8B;AAC7B,WAAOA,KAAK,CAACE,IAAN,CAAcC,MAAF,IAClBP,mBAAmB,CAAEX,SAAF,CAAnB,CAAiCgB,QAAjC,CAA2CE,MAA3C,CADM,CAAP;AAGA;;AAED,SAAO,KAAP;AACA","sourcesContent":["/**\n * External dependencies\n */\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 ] = [\n\t\t...new Set( mergedNamespace ),\n\t];\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"]}
1
+ {"version":3,"sources":["@wordpress/components/src/ui/context/context-connect.ts"],"names":["forwardRef","warn","CONNECT_STATIC_NAMESPACE","getStyledClassNameFromKey","contextConnect","Component","namespace","_contextConnect","forwardsRef","contextConnectWithoutRef","options","WrappedComponent","mergedNamespace","Array","isArray","Object","assign","Set","displayName","selector","getConnectNamespace","namespaces","type","hasConnectNamespace","match","includes","some","result"],"mappings":"AAAA;AACA;AACA;;AAGA;AACA;AACA;AACA,SAASA,UAAT,QAA2B,oBAA3B;AACA,OAAOC,IAAP,MAAiB,oBAAjB;AAEA;AACA;AACA;;AACA,SAASC,wBAAT,QAAyC,aAAzC;AACA,SAASC,yBAAT,QAA0C,kCAA1C;;AAYA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;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AHhB,GAAjC,CAAP;AAKA;AAED;AACA;AACA;AACA;AACA;AACA;;;AACA,OAAO,SAASc,mBAAT,CACNf,SADM,EAEK;AACX,MAAK,CAAEA,SAAP,EAAmB,OAAO,EAAP;AAEnB,MAAIgB,UAAU,GAAG,EAAjB,CAHW,CAKX;;AACA,MAAKhB,SAAS,CAAEH,wBAAF,CAAd,EAA6C;AAC5C;AACAmB,IAAAA,UAAU,GAAGhB,SAAS,CAAEH,wBAAF,CAAtB;AACA,GATU,CAWX;;;AACA,MAAKG,SAAS,CAACiB,IAAV,IAAkBjB,SAAS,CAACiB,IAAV,CAAgBpB,wBAAhB,CAAvB,EAAoE;AACnE;AACAmB,IAAAA,UAAU,GAAGhB,SAAS,CAACiB,IAAV,CAAgBpB,wBAAhB,CAAb;AACA;;AAED,SAAOmB,UAAP;AACA;AAED;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,SAASE,mBAAT,CACNlB,SADM,EAENmB,KAFM,EAGI;AACV,MAAK,CAAEnB,SAAP,EAAmB,OAAO,KAAP;;AAEnB,MAAK,OAAOmB,KAAP,KAAiB,QAAtB,EAAiC;AAChC,WAAOJ,mBAAmB,CAAEf,SAAF,CAAnB,CAAiCoB,QAAjC,CAA2CD,KAA3C,CAAP;AACA;;AACD,MAAKX,KAAK,CAACC,OAAN,CAAeU,KAAf,CAAL,EAA8B;AAC7B,WAAOA,KAAK,CAACE,IAAN,CAAcC,MAAF,IAClBP,mBAAmB,CAAEf,SAAF,CAAnB,CAAiCoB,QAAjC,CAA2CE,MAA3C,CADM,CAAP;AAGA;;AAED,SAAO,KAAP;AACA","sourcesContent":["/**\n * External dependencies\n */\nimport type { ForwardedRef, ReactChild, ReactNode } from 'react';\n\n/**\n * WordPress dependencies\n */\nimport { forwardRef } 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 AcceptsTwoArgs<\n\tF extends ( ...args: any ) => any,\n\tErrorMessage = never\n> = Parameters< F >[ 'length' ] extends 2 ? {} : ErrorMessage;\n\ntype ContextConnectOptions = {\n\tforwardsRef?: 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 * @param Component The component to register into the Context system.\n * @param namespace The namespace to register the component under.\n * @return The connected WordPressComponent\n */\nexport function contextConnect<\n\tC extends ( props: any, ref: ForwardedRef< any > ) => JSX.Element | null\n>(\n\tComponent: C &\n\t\tAcceptsTwoArgs<\n\t\t\tC,\n\t\t\t'Warning: Your component function does not take a ref as the second argument. Did you mean to use `contextConnectWithoutRef`?'\n\t\t>,\n\tnamespace: string\n) {\n\treturn _contextConnect( Component, namespace, { forwardsRef: true } );\n}\n\n/**\n * \"Connects\" (or registers) a component within the Context system under a specified namespace.\n * Does not forward a ref.\n *\n * @param Component The component to register into the Context system.\n * @param namespace The namespace to register the component under.\n * @return The connected WordPressComponent\n */\nexport function contextConnectWithoutRef< P >(\n\tComponent: ( props: P ) => JSX.Element | null,\n\tnamespace: string\n) {\n\treturn _contextConnect( Component, namespace );\n}\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.\nfunction _contextConnect<\n\tC extends ( props: any, ref: ForwardedRef< any > ) => JSX.Element | null,\n\tO extends ContextConnectOptions\n>(\n\tComponent: C,\n\tnamespace: string,\n\toptions?: O\n): WordPressComponentFromProps<\n\tParameters< C >[ 0 ],\n\tO[ 'forwardsRef' ] extends true ? true : false\n> {\n\tconst WrappedComponent = options?.forwardsRef\n\t\t? forwardRef< any, Parameters< C >[ 0 ] >( Component )\n\t\t: Component;\n\n\tif ( typeof namespace === 'undefined' ) {\n\t\twarn( 'contextConnect: Please provide a namespace' );\n\t}\n\n\t// @ts-expect-error 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\t// @ts-expect-error We can't rely on inferred types here because of the\n\t// `as` prop polymorphism we're handling in https://github.com/WordPress/gutenberg/blob/9620bae6fef4fde7cc2b7833f416e240207cda29/packages/components/src/ui/context/wordpress-component.ts#L32-L33\n\treturn Object.assign( WrappedComponent, {\n\t\t[ CONNECT_STATIC_NAMESPACE ]: [ ...new Set( mergedNamespace ) ],\n\t\tdisplayName: namespace,\n\t\tselector: `.${ getStyledClassNameFromKey( namespace ) }`,\n\t} );\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"]}
@@ -3,7 +3,7 @@ import { createElement } from "@wordpress/element";
3
3
  /**
4
4
  * External dependencies
5
5
  */
6
- import { isEqual, merge, cloneDeep } from 'lodash';
6
+ import { isEqual, merge } from 'lodash';
7
7
  /**
8
8
  * WordPress dependencies
9
9
  */
@@ -58,7 +58,7 @@ function useContextSystemBridge(_ref) {
58
58
  }, [value]); // `parentContext` will always be memoized (i.e., the result of this hook itself)
59
59
  // or the default value from when the `ComponentsContext` was originally
60
60
  // initialized (which will never change, it's a static variable)
61
- // so this memoization will prevent `merge` and `cloneDeep` from rerunning unless
61
+ // so this memoization will prevent `merge` and `JSON.parse/stringify` from rerunning unless
62
62
  // the references to `value` change OR the `parentContext` has an actual material change
63
63
  // (because again, it's guaranteed to be memoized or a static reference to the empty object
64
64
  // so we know that the only changes for `parentContext` are material ones... i.e., why we
@@ -66,10 +66,11 @@ function useContextSystemBridge(_ref) {
66
66
  // need to bother with the `value`). The `useUpdateEffect` above will ensure that we are
67
67
  // correctly warning when the `value` isn't being properly memoized. All of that to say
68
68
  // that this should be super safe to assume that `useMemo` will only run on actual
69
- // changes to the two dependencies, therefore saving us calls to `merge` and `cloneDeep`!
69
+ // changes to the two dependencies, therefore saving us calls to `merge` and `JSON.parse/stringify`!
70
70
 
71
71
  const config = useMemo(() => {
72
- return merge(cloneDeep(parentContext), value);
72
+ // Deep clone `parentContext` to avoid mutating it later.
73
+ return merge(JSON.parse(JSON.stringify(parentContext)), value);
73
74
  }, [parentContext, value]);
74
75
  return config;
75
76
  }
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/components/src/ui/context/context-system-provider.js"],"names":["isEqual","merge","cloneDeep","createContext","useContext","useRef","useEffect","useMemo","memo","warn","ComponentsContext","useComponentsContext","useUpdateEffect","effect","deps","mounted","current","undefined","useContextSystemBridge","value","parentContext","valueRef","JSON","stringify","config","BaseContextSystemProvider","children","contextValue","ContextSystemProvider"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,OAAT,EAAkBC,KAAlB,EAAyBC,SAAzB,QAA0C,QAA1C;AAEA;AACA;AACA;;AACA,SACCC,aADD,EAECC,UAFD,EAGCC,MAHD,EAICC,SAJD,EAKCC,OALD,EAMCC,IAND,QAOO,oBAPP;AAQA,OAAOC,IAAP,MAAiB,oBAAjB;AAEA,OAAO,MAAMC,iBAAiB,GAAGP,aAAa;AAC7C;AAAqC,EADQ,CAAvC;AAGP,OAAO,MAAMQ,oBAAoB,GAAG,MAAMP,UAAU,CAAEM,iBAAF,CAA7C;AAEP;AACA;AACA;AACA;AACA;AACA;;AACA,SAASE,eAAT,CAA0BC,MAA1B,EAAkCC,IAAlC,EAAyC;AACxC,QAAMC,OAAO,GAAGV,MAAM,CAAE,KAAF,CAAtB;AACAC,EAAAA,SAAS,CAAE,MAAM;AAChB,QAAKS,OAAO,CAACC,OAAb,EAAuB;AACtB,aAAOH,MAAM,EAAb;AACA;;AACDE,IAAAA,OAAO,CAACC,OAAR,GAAkB,IAAlB;AACA,WAAOC,SAAP;AACA,GANQ,EAMNH,IANM,CAAT;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,GAAGhB,MAAM,CAAEc,KAAF,CAAvB;AAEAP,EAAAA,eAAe,CAAE,MAAM;AACtB,SACC;AACAZ,IAAAA,OAAO,CAAEqB,QAAQ,CAACL,OAAX,EAAoBG,KAApB,CAAP,IACA;AACAE,IAAAA,QAAQ,CAACL,OAAT,KAAqBG,KAJtB,EAKE;AACD,+FAAAV,IAAI,CAAG,gCAAgCa,IAAI,CAACC,SAAL,CAAgBJ,KAAhB,CAAyB,EAA5D,CAAJ;AACA;AACD,GATc,EASZ,CAAEA,KAAF,CATY,CAAf,CAL4C,CAgB5C;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,QAAMK,MAAM,GAAGjB,OAAO,CAAE,MAAM;AAC7B,WAAON,KAAK,CAAEC,SAAS,CAAEkB,aAAF,CAAX,EAA8BD,KAA9B,CAAZ;AACA,GAFqB,EAEnB,CAAEC,aAAF,EAAiBD,KAAjB,CAFmB,CAAtB;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,cAAC,iBAAD,CAAmB,QAAnB;AAA4B,IAAA,KAAK,EAAGQ;AAApC,KACGD,QADH,CADD;AAKA,CARD;;AAUA,OAAO,MAAME,qBAAqB,GAAGpB,IAAI,CAAEiB,yBAAF,CAAlC","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":["isEqual","merge","createContext","useContext","useRef","useEffect","useMemo","memo","warn","ComponentsContext","useComponentsContext","useUpdateEffect","effect","deps","mounted","current","undefined","useContextSystemBridge","value","parentContext","valueRef","JSON","stringify","config","parse","BaseContextSystemProvider","children","contextValue","ContextSystemProvider"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,OAAT,EAAkBC,KAAlB,QAA+B,QAA/B;AAEA;AACA;AACA;;AACA,SACCC,aADD,EAECC,UAFD,EAGCC,MAHD,EAICC,SAJD,EAKCC,OALD,EAMCC,IAND,QAOO,oBAPP;AAQA,OAAOC,IAAP,MAAiB,oBAAjB;AAEA,OAAO,MAAMC,iBAAiB,GAAGP,aAAa;AAC7C;AAAqC,EADQ,CAAvC;AAGP,OAAO,MAAMQ,oBAAoB,GAAG,MAAMP,UAAU,CAAEM,iBAAF,CAA7C;AAEP;AACA;AACA;AACA;AACA;AACA;;AACA,SAASE,eAAT,CAA0BC,MAA1B,EAAkCC,IAAlC,EAAyC;AACxC,QAAMC,OAAO,GAAGV,MAAM,CAAE,KAAF,CAAtB;AACAC,EAAAA,SAAS,CAAE,MAAM;AAChB,QAAKS,OAAO,CAACC,OAAb,EAAuB;AACtB,aAAOH,MAAM,EAAb;AACA;;AACDE,IAAAA,OAAO,CAACC,OAAR,GAAkB,IAAlB;AACA,WAAOC,SAAP;AACA,GANQ,EAMNH,IANM,CAAT;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,GAAGhB,MAAM,CAAEc,KAAF,CAAvB;AAEAP,EAAAA,eAAe,CAAE,MAAM;AACtB,SACC;AACAX,IAAAA,OAAO,CAAEoB,QAAQ,CAACL,OAAX,EAAoBG,KAApB,CAAP,IACA;AACAE,IAAAA,QAAQ,CAACL,OAAT,KAAqBG,KAJtB,EAKE;AACD,+FAAAV,IAAI,CAAG,gCAAgCa,IAAI,CAACC,SAAL,CAAgBJ,KAAhB,CAAyB,EAA5D,CAAJ;AACA;AACD,GATc,EASZ,CAAEA,KAAF,CATY,CAAf,CAL4C,CAgB5C;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,QAAMK,MAAM,GAAGjB,OAAO,CAAE,MAAM;AAC7B;AACA,WAAOL,KAAK,CAAEoB,IAAI,CAACG,KAAL,CAAYH,IAAI,CAACC,SAAL,CAAgBH,aAAhB,CAAZ,CAAF,EAAiDD,KAAjD,CAAZ;AACA,GAHqB,EAGnB,CAAEC,aAAF,EAAiBD,KAAjB,CAHmB,CAAtB;AAKA,SAAOK,MAAP;AACA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AACA,MAAME,yBAAyB,GAAG,SAA2B;AAAA,MAAzB;AAAEC,IAAAA,QAAF;AAAYR,IAAAA;AAAZ,GAAyB;AAC5D,QAAMS,YAAY,GAAGV,sBAAsB,CAAE;AAAEC,IAAAA;AAAF,GAAF,CAA3C;AAEA,SACC,cAAC,iBAAD,CAAmB,QAAnB;AAA4B,IAAA,KAAK,EAAGS;AAApC,KACGD,QADH,CADD;AAKA,CARD;;AAUA,OAAO,MAAME,qBAAqB,GAAGrB,IAAI,CAAEkB,yBAAF,CAAlC","sourcesContent":["/**\n * External dependencies\n */\nimport { isEqual, merge } 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 `JSON.parse/stringify` 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 `JSON.parse/stringify`!\n\tconst config = useMemo( () => {\n\t\t// Deep clone `parentContext` to avoid mutating it later.\n\t\treturn merge( JSON.parse( JSON.stringify( 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"]}
@@ -26,6 +26,7 @@ function UnforwardedUnitControl(unitControlProps, forwardedRef) {
26
26
  const {
27
27
  __unstableStateReducer: stateReducerProp,
28
28
  autoComplete = 'off',
29
+ // @ts-expect-error Ensure that children is omitted from restProps
29
30
  children,
30
31
  className,
31
32
  disabled = false,
@@ -205,7 +206,6 @@ function UnforwardedUnitControl(unitControlProps, forwardedRef) {
205
206
  className: "components-unit-control-wrapper",
206
207
  style: style
207
208
  }, createElement(ValueInput, _extends({
208
- "aria-label": label,
209
209
  type: isPressEnterToChange ? 'text' : 'number'
210
210
  }, props, {
211
211
  autoComplete: autoComplete,
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/components/src/unit-control/index.tsx"],"names":["classnames","deprecated","forwardRef","useMemo","useRef","useEffect","__","inputControlActionTypes","Root","ValueInput","UnitSelectControl","CSS_UNITS","getParsedQuantityAndUnit","getUnitsWithCurrentUnit","getValidParsedQuantityAndUnit","useControlledState","UnforwardedUnitControl","unitControlProps","forwardedRef","__unstableStateReducer","stateReducerProp","autoComplete","children","className","disabled","disableUnits","isPressEnterToChange","isResetValueOnUnitChange","isUnitSelectTabbable","label","onChange","onChangeProp","onUnitChange","size","style","unit","unitProp","units","unitsProp","value","valueProp","onBlur","onBlurProp","props","since","hint","version","nonNullValueProp","undefined","parsedQuantity","parsedUnit","setUnit","length","initial","fallback","refParsedQuantity","classes","handleOnQuantityChange","nextQuantityValue","changeProps","onChangeValue","join","handleOnUnitChange","nextUnitValue","data","nextValue","default","mayUpdateUnit","event","isNaN","Number","currentTarget","current","validParsedQuantity","validParsedUnit","Array","isArray","find","option","handleOnBlur","handleOnKeyDown","key","unitControlStateReducer","state","action","nextState","type","COMMIT","toString","stateReducer","baseState","inputSuffix","step","activeUnit","UnitControl","parseQuantityAndUnitFromRawValue","useCustomUnits"],"mappings":";;;AAAA;AACA;AACA;AASA,OAAOA,UAAP,MAAuB,YAAvB;AAEA;AACA;AACA;;AACA,OAAOC,UAAP,MAAuB,uBAAvB;AACA,SAASC,UAAT,EAAqBC,OAArB,EAA8BC,MAA9B,EAAsCC,SAAtC,QAAuD,oBAAvD;AACA,SAASC,EAAT,QAAmB,iBAAnB;AAEA;AACA;AACA;;AAEA,OAAO,KAAKC,uBAAZ,MAAyC,kCAAzC;AACA,SAASC,IAAT,EAAeC,UAAf,QAAiC,8BAAjC;AACA,OAAOC,iBAAP,MAA8B,uBAA9B;AACA,SACCC,SADD,EAECC,wBAFD,EAGCC,uBAHD,EAICC,6BAJD,QAKO,SALP;AAMA,SAASC,kBAAT,QAAmC,gBAAnC;;AAIA,SAASC,sBAAT,CACCC,gBADD,EAMCC,YAND,EAOE;AACD,QAAM;AACLC,IAAAA,sBAAsB,EAAEC,gBADnB;AAELC,IAAAA,YAAY,GAAG,KAFV;AAGLC,IAAAA,QAHK;AAILC,IAAAA,SAJK;AAKLC,IAAAA,QAAQ,GAAG,KALN;AAMLC,IAAAA,YAAY,GAAG,KANV;AAOLC,IAAAA,oBAAoB,GAAG,KAPlB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I,EAAG2C,IAjBR;AAkBC,IAAA,sBAAsB,EAAGH;AAlB1B,KADD,CADD;AAwBA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AACA,OAAO,MAAMK,WAAW,GAAG5F,UAAU,CAAEc,sBAAF,CAA9B;AAEP,SAAS+E,gCAAT,EAA2CC,cAA3C,QAAiE,SAAjE;AACA,eAAeF,WAAf","sourcesContent":["/**\n * External dependencies\n */\nimport type {\n\tFocusEventHandler,\n\tKeyboardEvent,\n\tForwardedRef,\n\tSyntheticEvent,\n\tChangeEvent,\n\tPointerEvent,\n} from 'react';\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport deprecated from '@wordpress/deprecated';\nimport { forwardRef, useMemo, useRef, useEffect } from '@wordpress/element';\nimport { __ } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport type { WordPressComponentProps } from '../ui/context';\nimport * as inputControlActionTypes from '../input-control/reducer/actions';\nimport { Root, ValueInput } from './styles/unit-control-styles';\nimport UnitSelectControl from './unit-select-control';\nimport {\n\tCSS_UNITS,\n\tgetParsedQuantityAndUnit,\n\tgetUnitsWithCurrentUnit,\n\tgetValidParsedQuantityAndUnit,\n} from './utils';\nimport { useControlledState } from '../utils/hooks';\nimport type { UnitControlProps, UnitControlOnChangeCallback } from './types';\nimport type { StateReducer } from '../input-control/reducer/state';\n\nfunction UnforwardedUnitControl(\n\tunitControlProps: WordPressComponentProps<\n\t\tUnitControlProps,\n\t\t'input',\n\t\tfalse\n\t>,\n\tforwardedRef: ForwardedRef< any >\n) {\n\tconst {\n\t\t__unstableStateReducer: stateReducerProp,\n\t\tautoComplete = 'off',\n\t\tchildren,\n\t\tclassName,\n\t\tdisabled = false,\n\t\tdisableUnits = false,\n\t\tisPressEnterToChange = false,\n\t\tisResetValueOnUnitChange = false,\n\t\tisUnitSelectTabbable = true,\n\t\tlabel,\n\t\tonChange: onChangeProp,\n\t\tonUnitChange,\n\t\tsize = 'default',\n\t\tstyle,\n\t\tunit: unitProp,\n\t\tunits: unitsProp = CSS_UNITS,\n\t\tvalue: valueProp,\n\t\tonBlur: onBlurProp,\n\t\t...props\n\t} = unitControlProps;\n\n\tif ( 'unit' in unitControlProps ) {\n\t\tdeprecated( 'UnitControl unit prop', {\n\t\t\tsince: '5.6',\n\t\t\thint: 'The unit should be provided within the `value` prop.',\n\t\t\tversion: '6.2',\n\t\t} );\n\t}\n\n\t// The `value` prop, in theory, should not be `null`, but the following line\n\t// ensures it fallback to `undefined` in case a consumer of `UnitControl`\n\t// still passes `null` as a `value`.\n\tconst nonNullValueProp = valueProp ?? undefined;\n\tconst units = useMemo(\n\t\t() => getUnitsWithCurrentUnit( nonNullValueProp, unitProp, unitsProp ),\n\t\t[ nonNullValueProp, unitProp, unitsProp ]\n\t);\n\tconst [ parsedQuantity, parsedUnit ] = getParsedQuantityAndUnit(\n\t\tnonNullValueProp,\n\t\tunitProp,\n\t\tunits\n\t);\n\n\tconst [ unit, setUnit ] = useControlledState< string | undefined >(\n\t\tunits.length === 1 ? units[ 0 ].value : unitProp,\n\t\t{\n\t\t\tinitial: parsedUnit,\n\t\t\tfallback: '',\n\t\t}\n\t);\n\n\tuseEffect( () => {\n\t\tif ( parsedUnit !== undefined ) {\n\t\t\tsetUnit( parsedUnit );\n\t\t}\n\t}, [ parsedUnit ] );\n\n\t// Stores parsed value for hand-off in state reducer.\n\tconst refParsedQuantity = useRef< number | undefined >( undefined );\n\n\tconst classes = classnames( 'components-unit-control', className );\n\n\tconst handleOnQuantityChange = (\n\t\tnextQuantityValue: number | string | undefined,\n\t\tchangeProps: {\n\t\t\tevent:\n\t\t\t\t| ChangeEvent< HTMLInputElement >\n\t\t\t\t| PointerEvent< HTMLInputElement >;\n\t\t}\n\t) => {\n\t\tif (\n\t\t\tnextQuantityValue === '' ||\n\t\t\ttypeof nextQuantityValue === 'undefined' ||\n\t\t\tnextQuantityValue === null\n\t\t) {\n\t\t\tonChangeProp?.( '', changeProps );\n\t\t\treturn;\n\t\t}\n\n\t\t/*\n\t\t * Customizing the onChange callback.\n\t\t * This allows as to broadcast a combined value+unit to onChange.\n\t\t */\n\t\tconst onChangeValue = getValidParsedQuantityAndUnit(\n\t\t\tnextQuantityValue,\n\t\t\tunits,\n\t\t\tparsedQuantity,\n\t\t\tunit\n\t\t).join( '' );\n\n\t\tonChangeProp?.( onChangeValue, changeProps );\n\t};\n\n\tconst handleOnUnitChange: UnitControlOnChangeCallback = (\n\t\tnextUnitValue,\n\t\tchangeProps\n\t) => {\n\t\tconst { data } = changeProps;\n\n\t\tlet nextValue = `${ parsedQuantity ?? '' }${ nextUnitValue }`;\n\n\t\tif ( isResetValueOnUnitChange && data?.default !== undefined ) {\n\t\t\tnextValue = `${ data.default }${ nextUnitValue }`;\n\t\t}\n\n\t\tonChangeProp?.( nextValue, changeProps );\n\t\tonUnitChange?.( nextUnitValue, changeProps );\n\n\t\tsetUnit( nextUnitValue );\n\t};\n\n\tconst mayUpdateUnit = ( event: SyntheticEvent< HTMLInputElement > ) => {\n\t\tif ( ! isNaN( Number( event.currentTarget.value ) ) ) {\n\t\t\trefParsedQuantity.current = undefined;\n\t\t\treturn;\n\t\t}\n\t\tconst [ validParsedQuantity, validParsedUnit ] =\n\t\t\tgetValidParsedQuantityAndUnit(\n\t\t\t\tevent.currentTarget.value,\n\t\t\t\tunits,\n\t\t\t\tparsedQuantity,\n\t\t\t\tunit\n\t\t\t);\n\n\t\trefParsedQuantity.current = validParsedQuantity;\n\n\t\tif ( isPressEnterToChange && validParsedUnit !== unit ) {\n\t\t\tconst data = Array.isArray( units )\n\t\t\t\t? units.find( ( option ) => option.value === validParsedUnit )\n\t\t\t\t: undefined;\n\t\t\tconst changeProps = { event, data };\n\n\t\t\t// The `onChange` callback already gets called, no need to call it explicitely.\n\t\t\tonUnitChange?.( validParsedUnit, changeProps );\n\n\t\t\tsetUnit( validParsedUnit );\n\t\t}\n\t};\n\n\tconst handleOnBlur: FocusEventHandler< HTMLInputElement > = ( event ) => {\n\t\tmayUpdateUnit( event );\n\t\tonBlurProp?.( event );\n\t};\n\n\tconst handleOnKeyDown = ( event: KeyboardEvent< HTMLInputElement > ) => {\n\t\tconst { key } = event;\n\t\tif ( key === 'Enter' ) {\n\t\t\tmayUpdateUnit( event );\n\t\t}\n\t};\n\n\t/**\n\t * \"Middleware\" function that intercepts updates from InputControl.\n\t * This allows us to tap into actions to transform the (next) state for\n\t * InputControl.\n\t *\n\t * @param state State from InputControl\n\t * @param action Action triggering state change\n\t * @return The updated state to apply to InputControl\n\t */\n\tconst unitControlStateReducer: StateReducer = ( state, action ) => {\n\t\tconst nextState = { ...state };\n\n\t\t/*\n\t\t * On commits (when pressing ENTER and on blur if\n\t\t * isPressEnterToChange is true), if a parse has been performed\n\t\t * then use that result to update the state.\n\t\t */\n\t\tif ( action.type === inputControlActionTypes.COMMIT ) {\n\t\t\tif ( refParsedQuantity.current !== undefined ) {\n\t\t\t\tnextState.value = (\n\t\t\t\t\trefParsedQuantity.current ?? ''\n\t\t\t\t).toString();\n\t\t\t\trefParsedQuantity.current = undefined;\n\t\t\t}\n\t\t}\n\n\t\treturn nextState;\n\t};\n\n\tlet stateReducer: StateReducer = unitControlStateReducer;\n\tif ( stateReducerProp ) {\n\t\tstateReducer = ( state, action ) => {\n\t\t\tconst baseState = unitControlStateReducer( state, action );\n\t\t\treturn stateReducerProp( baseState, action );\n\t\t};\n\t}\n\n\tconst inputSuffix = ! disableUnits ? (\n\t\t<UnitSelectControl\n\t\t\taria-label={ __( 'Select unit' ) }\n\t\t\tdisabled={ disabled }\n\t\t\tisUnitSelectTabbable={ isUnitSelectTabbable }\n\t\t\tonChange={ handleOnUnitChange }\n\t\t\tsize={ size }\n\t\t\tunit={ unit }\n\t\t\tunits={ units }\n\t\t\tonBlur={ onBlurProp }\n\t\t/>\n\t) : null;\n\n\tlet step = props.step;\n\n\t/*\n\t * If no step prop has been passed, lookup the active unit and\n\t * try to get step from `units`, or default to a value of `1`\n\t */\n\tif ( ! step && units ) {\n\t\tconst activeUnit = units.find( ( option ) => option.value === unit );\n\t\tstep = activeUnit?.step ?? 1;\n\t}\n\n\treturn (\n\t\t<Root className=\"components-unit-control-wrapper\" style={ style }>\n\t\t\t<ValueInput\n\t\t\t\taria-label={ label }\n\t\t\t\ttype={ isPressEnterToChange ? 'text' : 'number' }\n\t\t\t\t{ ...props }\n\t\t\t\tautoComplete={ autoComplete }\n\t\t\t\tclassName={ classes }\n\t\t\t\tdisabled={ disabled }\n\t\t\t\tdisableUnits={ disableUnits }\n\t\t\t\tisPressEnterToChange={ isPressEnterToChange }\n\t\t\t\tlabel={ label }\n\t\t\t\tonBlur={ handleOnBlur }\n\t\t\t\tonKeyDown={ handleOnKeyDown }\n\t\t\t\tonChange={ handleOnQuantityChange }\n\t\t\t\tref={ forwardedRef }\n\t\t\t\tsize={ size }\n\t\t\t\tsuffix={ inputSuffix }\n\t\t\t\tvalue={ parsedQuantity ?? '' }\n\t\t\t\tstep={ step }\n\t\t\t\t__unstableStateReducer={ stateReducer }\n\t\t\t/>\n\t\t</Root>\n\t);\n}\n\n/**\n * `UnitControl` allows the user to set a numeric quantity as well as a unit (e.g. `px`).\n *\n *\n * @example\n * ```jsx\n * import { __experimentalUnitControl as UnitControl } from '@wordpress/components';\n * import { useState } from '@wordpress/element';\n *\n * const Example = () => {\n * const [ value, setValue ] = useState( '10px' );\n *\n * return <UnitControl onChange={ setValue } value={ value } />;\n * };\n * ```\n */\nexport const UnitControl = forwardRef( UnforwardedUnitControl );\n\nexport { parseQuantityAndUnitFromRawValue, useCustomUnits } from './utils';\nexport default UnitControl;\n"]}
1
+ {"version":3,"sources":["@wordpress/components/src/unit-control/index.tsx"],"names":["classnames","deprecated","forwardRef","useMemo","useRef","useEffect","__","inputControlActionTypes","Root","ValueInput","UnitSelectControl","CSS_UNITS","getParsedQuantityAndUnit","getUnitsWithCurrentUnit","getValidParsedQuantityAndUnit","useControlledState","UnforwardedUnitControl","unitControlProps","forwardedRef","__unstableStateReducer","stateReducerProp","autoComplete","children","className","disabled","disableUnits","isPressEnterToChange","isResetValueOnUnitChange","isUnitSelectTabbable","label","onChange","onChangeProp","onUnitChange","size","style","unit","unitProp","units","unitsProp","value","valueProp","onBlur","onBlurProp","props","since","hint","version","nonNullValueProp","undefined","parsedQuantity","parsedUnit","setUnit","length","initial","fallback","refParsedQuantity","classes","handleOnQuantityChange","nextQuantityValue","changeProps","onChangeValue","join","handleOnUnitChange","nextUnitValue","data","nextValue","default","mayUpdateUnit","event","isNaN","Number","currentTarget","current","validParsedQuantity","validParsedUnit","Array","isArray","find","option","handleOnBlur","handleOnKeyDown","key","unitControlStateReducer","state","action","nextState","type","COMMIT","toString","stateReducer","baseState","inputSuffix","step","activeUnit","UnitControl","parseQuantityAndUnitFromRawValue","useCustomUnits"],"mappings":";;;AAAA;AACA;AACA;AASA,OAAOA,UAAP,MAAuB,YAAvB;AAEA;AACA;AACA;;AACA,OAAOC,UAAP,MAAuB,uBAAvB;AACA,SAASC,UAAT,EAAqBC,OAArB,EAA8BC,MAA9B,EAAsCC,SAAtC,QAAuD,oBAAvD;AACA,SAASC,EAAT,QAAmB,iBAAnB;AAEA;AACA;AACA;;AAEA,OAAO,KAAKC,uBAAZ,MAAyC,kCAAzC;AACA,SAASC,IAAT,EAAeC,UAAf,QAAiC,8BAAjC;AACA,OAAOC,iBAAP,MAA8B,uBAA9B;AACA,SACCC,SADD,EAECC,wBAFD,EAGCC,uBAHD,EAICC,6BAJD,QAKO,SALP;AAMA,SAASC,kBAAT,QAAmC,gBAAnC;;AAIA,SAASC,sBAAT,CACCC,gBADD,EAMCC,YAND,EAOE;AACD,QAAM;AACLC,IAAAA,sBAAsB,EAAEC,gBADnB;AAELC,IAAAA,YAAY,GAAG,KAFV;AAGL;AACAC,IAAAA,QAJK;AAKLC,IAAAA,SALK;AAMLC,IAAAA,QAAQ,GAAG,KANN;AAOLC,IAAAA,YAAY,GAAG,KAPV;AAQLC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AA,IAAI,EAAG2C,IAhBR;AAiBC,IAAA,sBAAsB,EAAGH;AAjB1B,KADD,CADD;AAuBA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AACA,OAAO,MAAMK,WAAW,GAAG5F,UAAU,CAAEc,sBAAF,CAA9B;AAEP,SAAS+E,gCAAT,EAA2CC,cAA3C,QAAiE,SAAjE;AACA,eAAeF,WAAf","sourcesContent":["/**\n * External dependencies\n */\nimport type {\n\tFocusEventHandler,\n\tKeyboardEvent,\n\tForwardedRef,\n\tSyntheticEvent,\n\tChangeEvent,\n\tPointerEvent,\n} from 'react';\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport deprecated from '@wordpress/deprecated';\nimport { forwardRef, useMemo, useRef, useEffect } from '@wordpress/element';\nimport { __ } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport type { WordPressComponentProps } from '../ui/context';\nimport * as inputControlActionTypes from '../input-control/reducer/actions';\nimport { Root, ValueInput } from './styles/unit-control-styles';\nimport UnitSelectControl from './unit-select-control';\nimport {\n\tCSS_UNITS,\n\tgetParsedQuantityAndUnit,\n\tgetUnitsWithCurrentUnit,\n\tgetValidParsedQuantityAndUnit,\n} from './utils';\nimport { useControlledState } from '../utils/hooks';\nimport type { UnitControlProps, UnitControlOnChangeCallback } from './types';\nimport type { StateReducer } from '../input-control/reducer/state';\n\nfunction UnforwardedUnitControl(\n\tunitControlProps: WordPressComponentProps<\n\t\tUnitControlProps,\n\t\t'input',\n\t\tfalse\n\t>,\n\tforwardedRef: ForwardedRef< any >\n) {\n\tconst {\n\t\t__unstableStateReducer: stateReducerProp,\n\t\tautoComplete = 'off',\n\t\t// @ts-expect-error Ensure that children is omitted from restProps\n\t\tchildren,\n\t\tclassName,\n\t\tdisabled = false,\n\t\tdisableUnits = false,\n\t\tisPressEnterToChange = false,\n\t\tisResetValueOnUnitChange = false,\n\t\tisUnitSelectTabbable = true,\n\t\tlabel,\n\t\tonChange: onChangeProp,\n\t\tonUnitChange,\n\t\tsize = 'default',\n\t\tstyle,\n\t\tunit: unitProp,\n\t\tunits: unitsProp = CSS_UNITS,\n\t\tvalue: valueProp,\n\t\tonBlur: onBlurProp,\n\t\t...props\n\t} = unitControlProps;\n\n\tif ( 'unit' in unitControlProps ) {\n\t\tdeprecated( 'UnitControl unit prop', {\n\t\t\tsince: '5.6',\n\t\t\thint: 'The unit should be provided within the `value` prop.',\n\t\t\tversion: '6.2',\n\t\t} );\n\t}\n\n\t// The `value` prop, in theory, should not be `null`, but the following line\n\t// ensures it fallback to `undefined` in case a consumer of `UnitControl`\n\t// still passes `null` as a `value`.\n\tconst nonNullValueProp = valueProp ?? undefined;\n\tconst units = useMemo(\n\t\t() => getUnitsWithCurrentUnit( nonNullValueProp, unitProp, unitsProp ),\n\t\t[ nonNullValueProp, unitProp, unitsProp ]\n\t);\n\tconst [ parsedQuantity, parsedUnit ] = getParsedQuantityAndUnit(\n\t\tnonNullValueProp,\n\t\tunitProp,\n\t\tunits\n\t);\n\n\tconst [ unit, setUnit ] = useControlledState< string | undefined >(\n\t\tunits.length === 1 ? units[ 0 ].value : unitProp,\n\t\t{\n\t\t\tinitial: parsedUnit,\n\t\t\tfallback: '',\n\t\t}\n\t);\n\n\tuseEffect( () => {\n\t\tif ( parsedUnit !== undefined ) {\n\t\t\tsetUnit( parsedUnit );\n\t\t}\n\t}, [ parsedUnit ] );\n\n\t// Stores parsed value for hand-off in state reducer.\n\tconst refParsedQuantity = useRef< number | undefined >( undefined );\n\n\tconst classes = classnames( 'components-unit-control', className );\n\n\tconst handleOnQuantityChange = (\n\t\tnextQuantityValue: number | string | undefined,\n\t\tchangeProps: {\n\t\t\tevent:\n\t\t\t\t| ChangeEvent< HTMLInputElement >\n\t\t\t\t| PointerEvent< HTMLInputElement >;\n\t\t}\n\t) => {\n\t\tif (\n\t\t\tnextQuantityValue === '' ||\n\t\t\ttypeof nextQuantityValue === 'undefined' ||\n\t\t\tnextQuantityValue === null\n\t\t) {\n\t\t\tonChangeProp?.( '', changeProps );\n\t\t\treturn;\n\t\t}\n\n\t\t/*\n\t\t * Customizing the onChange callback.\n\t\t * This allows as to broadcast a combined value+unit to onChange.\n\t\t */\n\t\tconst onChangeValue = getValidParsedQuantityAndUnit(\n\t\t\tnextQuantityValue,\n\t\t\tunits,\n\t\t\tparsedQuantity,\n\t\t\tunit\n\t\t).join( '' );\n\n\t\tonChangeProp?.( onChangeValue, changeProps );\n\t};\n\n\tconst handleOnUnitChange: UnitControlOnChangeCallback = (\n\t\tnextUnitValue,\n\t\tchangeProps\n\t) => {\n\t\tconst { data } = changeProps;\n\n\t\tlet nextValue = `${ parsedQuantity ?? '' }${ nextUnitValue }`;\n\n\t\tif ( isResetValueOnUnitChange && data?.default !== undefined ) {\n\t\t\tnextValue = `${ data.default }${ nextUnitValue }`;\n\t\t}\n\n\t\tonChangeProp?.( nextValue, changeProps );\n\t\tonUnitChange?.( nextUnitValue, changeProps );\n\n\t\tsetUnit( nextUnitValue );\n\t};\n\n\tconst mayUpdateUnit = ( event: SyntheticEvent< HTMLInputElement > ) => {\n\t\tif ( ! isNaN( Number( event.currentTarget.value ) ) ) {\n\t\t\trefParsedQuantity.current = undefined;\n\t\t\treturn;\n\t\t}\n\t\tconst [ validParsedQuantity, validParsedUnit ] =\n\t\t\tgetValidParsedQuantityAndUnit(\n\t\t\t\tevent.currentTarget.value,\n\t\t\t\tunits,\n\t\t\t\tparsedQuantity,\n\t\t\t\tunit\n\t\t\t);\n\n\t\trefParsedQuantity.current = validParsedQuantity;\n\n\t\tif ( isPressEnterToChange && validParsedUnit !== unit ) {\n\t\t\tconst data = Array.isArray( units )\n\t\t\t\t? units.find( ( option ) => option.value === validParsedUnit )\n\t\t\t\t: undefined;\n\t\t\tconst changeProps = { event, data };\n\n\t\t\t// The `onChange` callback already gets called, no need to call it explicitely.\n\t\t\tonUnitChange?.( validParsedUnit, changeProps );\n\n\t\t\tsetUnit( validParsedUnit );\n\t\t}\n\t};\n\n\tconst handleOnBlur: FocusEventHandler< HTMLInputElement > = ( event ) => {\n\t\tmayUpdateUnit( event );\n\t\tonBlurProp?.( event );\n\t};\n\n\tconst handleOnKeyDown = ( event: KeyboardEvent< HTMLInputElement > ) => {\n\t\tconst { key } = event;\n\t\tif ( key === 'Enter' ) {\n\t\t\tmayUpdateUnit( event );\n\t\t}\n\t};\n\n\t/**\n\t * \"Middleware\" function that intercepts updates from InputControl.\n\t * This allows us to tap into actions to transform the (next) state for\n\t * InputControl.\n\t *\n\t * @param state State from InputControl\n\t * @param action Action triggering state change\n\t * @return The updated state to apply to InputControl\n\t */\n\tconst unitControlStateReducer: StateReducer = ( state, action ) => {\n\t\tconst nextState = { ...state };\n\n\t\t/*\n\t\t * On commits (when pressing ENTER and on blur if\n\t\t * isPressEnterToChange is true), if a parse has been performed\n\t\t * then use that result to update the state.\n\t\t */\n\t\tif ( action.type === inputControlActionTypes.COMMIT ) {\n\t\t\tif ( refParsedQuantity.current !== undefined ) {\n\t\t\t\tnextState.value = (\n\t\t\t\t\trefParsedQuantity.current ?? ''\n\t\t\t\t).toString();\n\t\t\t\trefParsedQuantity.current = undefined;\n\t\t\t}\n\t\t}\n\n\t\treturn nextState;\n\t};\n\n\tlet stateReducer: StateReducer = unitControlStateReducer;\n\tif ( stateReducerProp ) {\n\t\tstateReducer = ( state, action ) => {\n\t\t\tconst baseState = unitControlStateReducer( state, action );\n\t\t\treturn stateReducerProp( baseState, action );\n\t\t};\n\t}\n\n\tconst inputSuffix = ! disableUnits ? (\n\t\t<UnitSelectControl\n\t\t\taria-label={ __( 'Select unit' ) }\n\t\t\tdisabled={ disabled }\n\t\t\tisUnitSelectTabbable={ isUnitSelectTabbable }\n\t\t\tonChange={ handleOnUnitChange }\n\t\t\tsize={ size }\n\t\t\tunit={ unit }\n\t\t\tunits={ units }\n\t\t\tonBlur={ onBlurProp }\n\t\t/>\n\t) : null;\n\n\tlet step = props.step;\n\n\t/*\n\t * If no step prop has been passed, lookup the active unit and\n\t * try to get step from `units`, or default to a value of `1`\n\t */\n\tif ( ! step && units ) {\n\t\tconst activeUnit = units.find( ( option ) => option.value === unit );\n\t\tstep = activeUnit?.step ?? 1;\n\t}\n\n\treturn (\n\t\t<Root className=\"components-unit-control-wrapper\" style={ style }>\n\t\t\t<ValueInput\n\t\t\t\ttype={ isPressEnterToChange ? 'text' : 'number' }\n\t\t\t\t{ ...props }\n\t\t\t\tautoComplete={ autoComplete }\n\t\t\t\tclassName={ classes }\n\t\t\t\tdisabled={ disabled }\n\t\t\t\tdisableUnits={ disableUnits }\n\t\t\t\tisPressEnterToChange={ isPressEnterToChange }\n\t\t\t\tlabel={ label }\n\t\t\t\tonBlur={ handleOnBlur }\n\t\t\t\tonKeyDown={ handleOnKeyDown }\n\t\t\t\tonChange={ handleOnQuantityChange }\n\t\t\t\tref={ forwardedRef }\n\t\t\t\tsize={ size }\n\t\t\t\tsuffix={ inputSuffix }\n\t\t\t\tvalue={ parsedQuantity ?? '' }\n\t\t\t\tstep={ step }\n\t\t\t\t__unstableStateReducer={ stateReducer }\n\t\t\t/>\n\t\t</Root>\n\t);\n}\n\n/**\n * `UnitControl` allows the user to set a numeric quantity as well as a unit (e.g. `px`).\n *\n *\n * @example\n * ```jsx\n * import { __experimentalUnitControl as UnitControl } from '@wordpress/components';\n * import { useState } from '@wordpress/element';\n *\n * const Example = () => {\n * const [ value, setValue ] = useState( '10px' );\n *\n * return <UnitControl onChange={ setValue } value={ value } />;\n * };\n * ```\n */\nexport const UnitControl = forwardRef( UnforwardedUnitControl );\n\nexport { parseQuantityAndUnitFromRawValue, useCustomUnits } from './utils';\nexport default UnitControl;\n"]}