@wordpress/components 19.5.0 → 19.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (633) hide show
  1. package/CHANGELOG.md +23 -5
  2. package/build/alignment-matrix-control/utils.js +1 -1
  3. package/build/alignment-matrix-control/utils.js.map +1 -1
  4. package/build/angle-picker-control/angle-circle.js +1 -1
  5. package/build/angle-picker-control/angle-circle.js.map +1 -1
  6. package/build/animation/index.js +0 -6
  7. package/build/animation/index.js.map +1 -1
  8. package/build/autocomplete/get-default-use-items.js +3 -3
  9. package/build/autocomplete/get-default-use-items.js.map +1 -1
  10. package/build/base-field/hook.js +1 -1
  11. package/build/base-field/hook.js.map +1 -1
  12. package/build/box-control/icon.js +1 -1
  13. package/build/box-control/icon.js.map +1 -1
  14. package/build/box-control/index.js +4 -4
  15. package/build/box-control/index.js.map +1 -1
  16. package/build/box-control/utils.js +12 -8
  17. package/build/box-control/utils.js.map +1 -1
  18. package/build/button/index.js +5 -5
  19. package/build/button/index.js.map +1 -1
  20. package/build/button/index.native.js +7 -7
  21. package/build/button/index.native.js.map +1 -1
  22. package/build/color-picker/color-display.js +1 -1
  23. package/build/color-picker/color-display.js.map +1 -1
  24. package/build/color-picker/styles.js +8 -8
  25. package/build/color-picker/styles.js.map +1 -1
  26. package/build/combobox-control/index.js +1 -1
  27. package/build/combobox-control/index.js.map +1 -1
  28. package/build/confirm-dialog/component.js +4 -2
  29. package/build/confirm-dialog/component.js.map +1 -1
  30. package/build/date-time/time.js +7 -4
  31. package/build/date-time/time.js.map +1 -1
  32. package/build/divider/component.js +5 -4
  33. package/build/divider/component.js.map +1 -1
  34. package/build/draggable/index.js +3 -3
  35. package/build/draggable/index.js.map +1 -1
  36. package/build/focal-point-picker/index.native.js +7 -7
  37. package/build/focal-point-picker/index.native.js.map +1 -1
  38. package/build/focal-point-picker/tooltip/index.native.js +1 -1
  39. package/build/focal-point-picker/tooltip/index.native.js.map +1 -1
  40. package/build/font-size-picker/index.js +1 -1
  41. package/build/font-size-picker/index.js.map +1 -1
  42. package/build/form-token-field/index.js +6 -6
  43. package/build/form-token-field/index.js.map +1 -1
  44. package/build/form-token-field/suggestions-list.js +2 -2
  45. package/build/form-token-field/suggestions-list.js.map +1 -1
  46. package/build/heading/component.js +6 -5
  47. package/build/heading/component.js.map +1 -1
  48. package/build/heading/hook.js +1 -1
  49. package/build/heading/hook.js.map +1 -1
  50. package/build/higher-order/with-notices/index.js +1 -1
  51. package/build/higher-order/with-notices/index.js.map +1 -1
  52. package/build/index.js +2 -2
  53. package/build/index.js.map +1 -1
  54. package/build/index.native.js.map +1 -1
  55. package/build/input-control/input-base.js +1 -1
  56. package/build/input-control/input-base.js.map +1 -1
  57. package/build/input-control/input-field.js +12 -10
  58. package/build/input-control/input-field.js.map +1 -1
  59. package/build/input-control/styles/input-control-styles.js +25 -25
  60. package/build/input-control/styles/input-control-styles.js.map +1 -1
  61. package/build/isolated-event-container/index.js +1 -1
  62. package/build/isolated-event-container/index.js.map +1 -1
  63. package/build/mobile/bottom-sheet/bottom-sheet-context.native.js +4 -4
  64. package/build/mobile/bottom-sheet/bottom-sheet-context.native.js.map +1 -1
  65. package/build/mobile/bottom-sheet/bottom-sheet-navigation/navigation-container.native.js +1 -1
  66. package/build/mobile/bottom-sheet/bottom-sheet-navigation/navigation-container.native.js.map +1 -1
  67. package/build/mobile/bottom-sheet/cell.native.js +1 -1
  68. package/build/mobile/bottom-sheet/cell.native.js.map +1 -1
  69. package/build/mobile/bottom-sheet/index.native.js +11 -11
  70. package/build/mobile/bottom-sheet/index.native.js.map +1 -1
  71. package/build/mobile/bottom-sheet/link-cell.native.js +1 -1
  72. package/build/mobile/bottom-sheet/link-cell.native.js.map +1 -1
  73. package/build/mobile/bottom-sheet/link-suggestion-item-cell.native.js +1 -1
  74. package/build/mobile/bottom-sheet/link-suggestion-item-cell.native.js.map +1 -1
  75. package/build/mobile/bottom-sheet/nav-bar/back-button.native.js +1 -1
  76. package/build/mobile/bottom-sheet/nav-bar/back-button.native.js.map +1 -1
  77. package/build/mobile/global-styles-context/utils.native.js +10 -10
  78. package/build/mobile/global-styles-context/utils.native.js.map +1 -1
  79. package/build/mobile/gradient/index.native.js +2 -2
  80. package/build/mobile/gradient/index.native.js.map +1 -1
  81. package/build/mobile/html-text-input/container.ios.js +3 -3
  82. package/build/mobile/html-text-input/container.ios.js.map +1 -1
  83. package/build/mobile/html-text-input/index.native.js +1 -1
  84. package/build/mobile/html-text-input/index.native.js.map +1 -1
  85. package/build/mobile/image/index.native.js +1 -1
  86. package/build/mobile/image/index.native.js.map +1 -1
  87. package/build/mobile/keyboard-aware-flat-list/index.android.js +1 -1
  88. package/build/mobile/keyboard-aware-flat-list/index.android.js.map +1 -1
  89. package/build/mobile/keyboard-aware-flat-list/index.ios.js +2 -2
  90. package/build/mobile/keyboard-aware-flat-list/index.ios.js.map +1 -1
  91. package/build/mobile/link-picker/index.native.js +3 -3
  92. package/build/mobile/link-picker/index.native.js.map +1 -1
  93. package/build/mobile/link-picker/link-picker-results.native.js +8 -8
  94. package/build/mobile/link-picker/link-picker-results.native.js.map +1 -1
  95. package/build/mobile/link-settings/image-link-destinations-screen.native.js +2 -2
  96. package/build/mobile/link-settings/image-link-destinations-screen.native.js.map +1 -1
  97. package/build/mobile/link-settings/index.native.js +1 -1
  98. package/build/mobile/link-settings/index.native.js.map +1 -1
  99. package/build/modal/aria-helper.js +1 -1
  100. package/build/modal/aria-helper.js.map +1 -1
  101. package/build/modal/index.js +2 -2
  102. package/build/modal/index.js.map +1 -1
  103. package/build/navigable-container/container.js +2 -2
  104. package/build/navigable-container/container.js.map +1 -1
  105. package/build/navigable-container/tabbable.js +1 -1
  106. package/build/navigable-container/tabbable.js.map +1 -1
  107. package/build/navigation/item/index.js +1 -1
  108. package/build/navigation/item/index.js.map +1 -1
  109. package/build/navigation/menu/index.js +1 -1
  110. package/build/navigation/menu/index.js.map +1 -1
  111. package/build/navigator/navigator-provider/component.js +2 -2
  112. package/build/navigator/navigator-provider/component.js.map +1 -1
  113. package/build/navigator/navigator-screen/component.js +1 -1
  114. package/build/navigator/navigator-screen/component.js.map +1 -1
  115. package/build/number-control/index.js +1 -1
  116. package/build/number-control/index.js.map +1 -1
  117. package/build/panel/body.js +2 -2
  118. package/build/panel/body.js.map +1 -1
  119. package/build/popover/index.js +3 -3
  120. package/build/popover/index.js.map +1 -1
  121. package/build/popover/utils.js +6 -6
  122. package/build/popover/utils.js.map +1 -1
  123. package/build/radio-group/index.js +1 -1
  124. package/build/radio-group/index.js.map +1 -1
  125. package/build/range-control/styles/range-control-styles.js +29 -29
  126. package/build/range-control/styles/range-control-styles.js.map +1 -1
  127. package/build/sandbox/index.js +5 -5
  128. package/build/sandbox/index.js.map +1 -1
  129. package/build/sandbox/index.native.js +1 -1
  130. package/build/sandbox/index.native.js.map +1 -1
  131. package/build/select-control/index.js +1 -1
  132. package/build/select-control/index.js.map +1 -1
  133. package/build/select-control/styles/select-control-styles.js +5 -5
  134. package/build/select-control/styles/select-control-styles.js.map +1 -1
  135. package/build/slot-fill/bubbles-virtually/slot-fill-provider.js +1 -1
  136. package/build/slot-fill/bubbles-virtually/slot-fill-provider.js.map +1 -1
  137. package/build/slot-fill/bubbles-virtually/slot.js +1 -1
  138. package/build/slot-fill/bubbles-virtually/slot.js.map +1 -1
  139. package/build/slot-fill/fill.js +1 -1
  140. package/build/slot-fill/fill.js.map +1 -1
  141. package/build/slot-fill/provider.js +1 -1
  142. package/build/slot-fill/provider.js.map +1 -1
  143. package/build/snackbar/index.js +1 -1
  144. package/build/snackbar/index.js.map +1 -1
  145. package/build/snackbar/list.js +1 -1
  146. package/build/snackbar/list.js.map +1 -1
  147. package/build/style-provider/index.js +2 -2
  148. package/build/style-provider/index.js.map +1 -1
  149. package/build/toggle-group-control/toggle-group-control/component.js +2 -2
  150. package/build/toggle-group-control/toggle-group-control/component.js.map +1 -1
  151. package/build/toggle-group-control/toggle-group-control-option/component.js +1 -4
  152. package/build/toggle-group-control/toggle-group-control-option/component.js.map +1 -1
  153. package/build/toggle-group-control/toggle-group-control-option/styles.js +12 -19
  154. package/build/toggle-group-control/toggle-group-control-option/styles.js.map +1 -1
  155. package/build/toolbar/index.js +1 -1
  156. package/build/toolbar/index.js.map +1 -1
  157. package/build/tooltip/index.js +3 -3
  158. package/build/tooltip/index.js.map +1 -1
  159. package/build/tooltip/index.native.js +7 -7
  160. package/build/tooltip/index.native.js.map +1 -1
  161. package/build/tree-grid/index.js +4 -1
  162. package/build/tree-grid/index.js.map +1 -1
  163. package/build/truncate/utils.js +1 -1
  164. package/build/truncate/utils.js.map +1 -1
  165. package/build/ui/context/context-connect.js +8 -15
  166. package/build/ui/context/context-connect.js.map +1 -1
  167. package/build/ui/context/context-system-provider.js +2 -2
  168. package/build/ui/context/context-system-provider.js.map +1 -1
  169. package/build/ui/context/index.js.map +1 -1
  170. package/build/ui/utils/colors.js +2 -2
  171. package/build/ui/utils/colors.js.map +1 -1
  172. package/build/ui/utils/space.js +2 -2
  173. package/build/ui/utils/space.js.map +1 -1
  174. package/build/unit-control/index.js +38 -29
  175. package/build/unit-control/index.js.map +1 -1
  176. package/build/unit-control/index.native.js +4 -2
  177. package/build/unit-control/index.native.js.map +1 -1
  178. package/build/unit-control/unit-select-control.js +1 -1
  179. package/build/unit-control/unit-select-control.js.map +1 -1
  180. package/build/unit-control/utils.js +96 -104
  181. package/build/unit-control/utils.js.map +1 -1
  182. package/build/utils/breakpoint-values.js +1 -1
  183. package/build/utils/breakpoint-values.js.map +1 -1
  184. package/build/utils/colors-values.js +1 -1
  185. package/build/utils/colors-values.js.map +1 -1
  186. package/build-module/alignment-matrix-control/utils.js +1 -1
  187. package/build-module/alignment-matrix-control/utils.js.map +1 -1
  188. package/build-module/angle-picker-control/angle-circle.js +1 -1
  189. package/build-module/angle-picker-control/angle-circle.js.map +1 -1
  190. package/build-module/animation/index.js +1 -1
  191. package/build-module/animation/index.js.map +1 -1
  192. package/build-module/autocomplete/get-default-use-items.js +3 -3
  193. package/build-module/autocomplete/get-default-use-items.js.map +1 -1
  194. package/build-module/base-field/hook.js +1 -1
  195. package/build-module/base-field/hook.js.map +1 -1
  196. package/build-module/box-control/icon.js +1 -1
  197. package/build-module/box-control/icon.js.map +1 -1
  198. package/build-module/box-control/index.js +5 -5
  199. package/build-module/box-control/index.js.map +1 -1
  200. package/build-module/box-control/utils.js +13 -9
  201. package/build-module/box-control/utils.js.map +1 -1
  202. package/build-module/button/index.js +5 -5
  203. package/build-module/button/index.js.map +1 -1
  204. package/build-module/button/index.native.js +7 -7
  205. package/build-module/button/index.native.js.map +1 -1
  206. package/build-module/color-picker/color-display.js +1 -1
  207. package/build-module/color-picker/color-display.js.map +1 -1
  208. package/build-module/color-picker/styles.js +8 -8
  209. package/build-module/color-picker/styles.js.map +1 -1
  210. package/build-module/combobox-control/index.js +1 -1
  211. package/build-module/combobox-control/index.js.map +1 -1
  212. package/build-module/confirm-dialog/component.js +4 -5
  213. package/build-module/confirm-dialog/component.js.map +1 -1
  214. package/build-module/date-time/time.js +7 -4
  215. package/build-module/date-time/time.js.map +1 -1
  216. package/build-module/divider/component.js +3 -3
  217. package/build-module/divider/component.js.map +1 -1
  218. package/build-module/draggable/index.js +3 -3
  219. package/build-module/draggable/index.js.map +1 -1
  220. package/build-module/focal-point-picker/index.native.js +7 -7
  221. package/build-module/focal-point-picker/index.native.js.map +1 -1
  222. package/build-module/focal-point-picker/tooltip/index.native.js +1 -1
  223. package/build-module/focal-point-picker/tooltip/index.native.js.map +1 -1
  224. package/build-module/font-size-picker/index.js +1 -1
  225. package/build-module/font-size-picker/index.js.map +1 -1
  226. package/build-module/form-token-field/index.js +6 -6
  227. package/build-module/form-token-field/index.js.map +1 -1
  228. package/build-module/form-token-field/suggestions-list.js +2 -2
  229. package/build-module/form-token-field/suggestions-list.js.map +1 -1
  230. package/build-module/heading/component.js +4 -4
  231. package/build-module/heading/component.js.map +1 -1
  232. package/build-module/heading/hook.js +1 -1
  233. package/build-module/heading/hook.js.map +1 -1
  234. package/build-module/higher-order/with-notices/index.js +1 -1
  235. package/build-module/higher-order/with-notices/index.js.map +1 -1
  236. package/build-module/index.js +4 -4
  237. package/build-module/index.js.map +1 -1
  238. package/build-module/index.native.js +4 -4
  239. package/build-module/index.native.js.map +1 -1
  240. package/build-module/input-control/input-base.js +1 -1
  241. package/build-module/input-control/input-base.js.map +1 -1
  242. package/build-module/input-control/input-field.js +13 -10
  243. package/build-module/input-control/input-field.js.map +1 -1
  244. package/build-module/input-control/styles/input-control-styles.js +25 -25
  245. package/build-module/input-control/styles/input-control-styles.js.map +1 -1
  246. package/build-module/isolated-event-container/index.js +1 -1
  247. package/build-module/isolated-event-container/index.js.map +1 -1
  248. package/build-module/mobile/bottom-sheet/bottom-sheet-context.native.js +4 -4
  249. package/build-module/mobile/bottom-sheet/bottom-sheet-context.native.js.map +1 -1
  250. package/build-module/mobile/bottom-sheet/bottom-sheet-navigation/navigation-container.native.js +1 -1
  251. package/build-module/mobile/bottom-sheet/bottom-sheet-navigation/navigation-container.native.js.map +1 -1
  252. package/build-module/mobile/bottom-sheet/cell.native.js +1 -1
  253. package/build-module/mobile/bottom-sheet/cell.native.js.map +1 -1
  254. package/build-module/mobile/bottom-sheet/index.native.js +11 -11
  255. package/build-module/mobile/bottom-sheet/index.native.js.map +1 -1
  256. package/build-module/mobile/bottom-sheet/link-cell.native.js +1 -1
  257. package/build-module/mobile/bottom-sheet/link-cell.native.js.map +1 -1
  258. package/build-module/mobile/bottom-sheet/link-suggestion-item-cell.native.js +1 -1
  259. package/build-module/mobile/bottom-sheet/link-suggestion-item-cell.native.js.map +1 -1
  260. package/build-module/mobile/bottom-sheet/nav-bar/back-button.native.js +1 -1
  261. package/build-module/mobile/bottom-sheet/nav-bar/back-button.native.js.map +1 -1
  262. package/build-module/mobile/global-styles-context/utils.native.js +10 -10
  263. package/build-module/mobile/global-styles-context/utils.native.js.map +1 -1
  264. package/build-module/mobile/gradient/index.native.js +2 -2
  265. package/build-module/mobile/gradient/index.native.js.map +1 -1
  266. package/build-module/mobile/html-text-input/container.ios.js +3 -3
  267. package/build-module/mobile/html-text-input/container.ios.js.map +1 -1
  268. package/build-module/mobile/html-text-input/index.native.js +1 -1
  269. package/build-module/mobile/html-text-input/index.native.js.map +1 -1
  270. package/build-module/mobile/image/index.native.js +1 -1
  271. package/build-module/mobile/image/index.native.js.map +1 -1
  272. package/build-module/mobile/keyboard-aware-flat-list/index.android.js +1 -1
  273. package/build-module/mobile/keyboard-aware-flat-list/index.android.js.map +1 -1
  274. package/build-module/mobile/keyboard-aware-flat-list/index.ios.js +2 -2
  275. package/build-module/mobile/keyboard-aware-flat-list/index.ios.js.map +1 -1
  276. package/build-module/mobile/link-picker/index.native.js +3 -3
  277. package/build-module/mobile/link-picker/index.native.js.map +1 -1
  278. package/build-module/mobile/link-picker/link-picker-results.native.js +8 -8
  279. package/build-module/mobile/link-picker/link-picker-results.native.js.map +1 -1
  280. package/build-module/mobile/link-settings/image-link-destinations-screen.native.js +2 -2
  281. package/build-module/mobile/link-settings/image-link-destinations-screen.native.js.map +1 -1
  282. package/build-module/mobile/link-settings/index.native.js +1 -1
  283. package/build-module/mobile/link-settings/index.native.js.map +1 -1
  284. package/build-module/modal/aria-helper.js +1 -1
  285. package/build-module/modal/aria-helper.js.map +1 -1
  286. package/build-module/modal/index.js +2 -2
  287. package/build-module/modal/index.js.map +1 -1
  288. package/build-module/navigable-container/container.js +2 -2
  289. package/build-module/navigable-container/container.js.map +1 -1
  290. package/build-module/navigable-container/tabbable.js +1 -1
  291. package/build-module/navigable-container/tabbable.js.map +1 -1
  292. package/build-module/navigation/item/index.js +1 -1
  293. package/build-module/navigation/item/index.js.map +1 -1
  294. package/build-module/navigation/menu/index.js +1 -1
  295. package/build-module/navigation/menu/index.js.map +1 -1
  296. package/build-module/navigator/navigator-provider/component.js +2 -2
  297. package/build-module/navigator/navigator-provider/component.js.map +1 -1
  298. package/build-module/navigator/navigator-screen/component.js +1 -1
  299. package/build-module/navigator/navigator-screen/component.js.map +1 -1
  300. package/build-module/number-control/index.js +1 -1
  301. package/build-module/number-control/index.js.map +1 -1
  302. package/build-module/panel/body.js +2 -2
  303. package/build-module/panel/body.js.map +1 -1
  304. package/build-module/popover/index.js +3 -3
  305. package/build-module/popover/index.js.map +1 -1
  306. package/build-module/popover/utils.js +6 -6
  307. package/build-module/popover/utils.js.map +1 -1
  308. package/build-module/radio-group/index.js +1 -1
  309. package/build-module/radio-group/index.js.map +1 -1
  310. package/build-module/range-control/styles/range-control-styles.js +29 -29
  311. package/build-module/range-control/styles/range-control-styles.js.map +1 -1
  312. package/build-module/sandbox/index.js +5 -5
  313. package/build-module/sandbox/index.js.map +1 -1
  314. package/build-module/sandbox/index.native.js +1 -1
  315. package/build-module/sandbox/index.native.js.map +1 -1
  316. package/build-module/select-control/index.js +1 -1
  317. package/build-module/select-control/index.js.map +1 -1
  318. package/build-module/select-control/styles/select-control-styles.js +5 -5
  319. package/build-module/select-control/styles/select-control-styles.js.map +1 -1
  320. package/build-module/slot-fill/bubbles-virtually/slot-fill-provider.js +1 -1
  321. package/build-module/slot-fill/bubbles-virtually/slot-fill-provider.js.map +1 -1
  322. package/build-module/slot-fill/bubbles-virtually/slot.js +1 -1
  323. package/build-module/slot-fill/bubbles-virtually/slot.js.map +1 -1
  324. package/build-module/slot-fill/fill.js +1 -1
  325. package/build-module/slot-fill/fill.js.map +1 -1
  326. package/build-module/slot-fill/provider.js +1 -1
  327. package/build-module/slot-fill/provider.js.map +1 -1
  328. package/build-module/snackbar/index.js +1 -1
  329. package/build-module/snackbar/index.js.map +1 -1
  330. package/build-module/snackbar/list.js +1 -1
  331. package/build-module/snackbar/list.js.map +1 -1
  332. package/build-module/style-provider/index.js +2 -2
  333. package/build-module/style-provider/index.js.map +1 -1
  334. package/build-module/toggle-group-control/toggle-group-control/component.js +2 -2
  335. package/build-module/toggle-group-control/toggle-group-control/component.js.map +1 -1
  336. package/build-module/toggle-group-control/toggle-group-control-option/component.js +1 -4
  337. package/build-module/toggle-group-control/toggle-group-control-option/component.js.map +1 -1
  338. package/build-module/toggle-group-control/toggle-group-control-option/styles.js +11 -17
  339. package/build-module/toggle-group-control/toggle-group-control-option/styles.js.map +1 -1
  340. package/build-module/toolbar/index.js +1 -1
  341. package/build-module/toolbar/index.js.map +1 -1
  342. package/build-module/tooltip/index.js +3 -3
  343. package/build-module/tooltip/index.js.map +1 -1
  344. package/build-module/tooltip/index.native.js +7 -7
  345. package/build-module/tooltip/index.native.js.map +1 -1
  346. package/build-module/tree-grid/index.js +4 -1
  347. package/build-module/tree-grid/index.js.map +1 -1
  348. package/build-module/truncate/utils.js +1 -1
  349. package/build-module/truncate/utils.js.map +1 -1
  350. package/build-module/ui/context/context-connect.js +9 -16
  351. package/build-module/ui/context/context-connect.js.map +1 -1
  352. package/build-module/ui/context/context-system-provider.js +2 -2
  353. package/build-module/ui/context/context-system-provider.js.map +1 -1
  354. package/build-module/ui/context/index.js.map +1 -1
  355. package/build-module/ui/utils/colors.js +2 -2
  356. package/build-module/ui/utils/colors.js.map +1 -1
  357. package/build-module/ui/utils/space.js +2 -2
  358. package/build-module/ui/utils/space.js.map +1 -1
  359. package/build-module/unit-control/index.js +39 -30
  360. package/build-module/unit-control/index.js.map +1 -1
  361. package/build-module/unit-control/index.native.js +5 -3
  362. package/build-module/unit-control/index.native.js.map +1 -1
  363. package/build-module/unit-control/unit-select-control.js +1 -1
  364. package/build-module/unit-control/unit-select-control.js.map +1 -1
  365. package/build-module/unit-control/utils.js +92 -100
  366. package/build-module/unit-control/utils.js.map +1 -1
  367. package/build-module/utils/breakpoint-values.js +1 -1
  368. package/build-module/utils/breakpoint-values.js.map +1 -1
  369. package/build-module/utils/colors-values.js +1 -1
  370. package/build-module/utils/colors-values.js.map +1 -1
  371. package/build-style/style-rtl.css +8 -0
  372. package/build-style/style.css +8 -0
  373. package/build-types/base-field/hook.d.ts +2 -1
  374. package/build-types/base-field/hook.d.ts.map +1 -1
  375. package/build-types/card/card/hook.d.ts +2 -1
  376. package/build-types/card/card/hook.d.ts.map +1 -1
  377. package/build-types/card/card-body/hook.d.ts +2 -1
  378. package/build-types/card/card-body/hook.d.ts.map +1 -1
  379. package/build-types/card/card-divider/hook.d.ts +2 -2
  380. package/build-types/card/card-footer/hook.d.ts +2 -1
  381. package/build-types/card/card-footer/hook.d.ts.map +1 -1
  382. package/build-types/card/card-header/hook.d.ts +2 -1
  383. package/build-types/card/card-header/hook.d.ts.map +1 -1
  384. package/build-types/card/card-media/hook.d.ts +2 -1
  385. package/build-types/card/card-media/hook.d.ts.map +1 -1
  386. package/build-types/color-picker/styles.d.ts +2 -2
  387. package/build-types/confirm-dialog/component.d.ts +8 -0
  388. package/build-types/confirm-dialog/component.d.ts.map +1 -1
  389. package/build-types/confirm-dialog/types.d.ts +2 -0
  390. package/build-types/confirm-dialog/types.d.ts.map +1 -1
  391. package/build-types/divider/component.d.ts +2 -2
  392. package/build-types/divider/component.d.ts.map +1 -1
  393. package/build-types/divider/stories/index.d.ts +10 -0
  394. package/build-types/divider/stories/index.d.ts.map +1 -0
  395. package/build-types/divider/types.d.ts +1 -1
  396. package/build-types/divider/types.d.ts.map +1 -1
  397. package/build-types/elevation/hook.d.ts +2 -1
  398. package/build-types/elevation/hook.d.ts.map +1 -1
  399. package/build-types/flex/flex/hook.d.ts +2 -1
  400. package/build-types/flex/flex/hook.d.ts.map +1 -1
  401. package/build-types/flex/flex-block/hook.d.ts +2 -1
  402. package/build-types/flex/flex-block/hook.d.ts.map +1 -1
  403. package/build-types/flex/flex-item/hook.d.ts +2 -1
  404. package/build-types/flex/flex-item/hook.d.ts.map +1 -1
  405. package/build-types/flyout/flyout/hook.d.ts +2 -1
  406. package/build-types/flyout/flyout/hook.d.ts.map +1 -1
  407. package/build-types/grid/hook.d.ts +2 -1
  408. package/build-types/grid/hook.d.ts.map +1 -1
  409. package/build-types/h-stack/hook.d.ts +3 -2
  410. package/build-types/h-stack/hook.d.ts.map +1 -1
  411. package/build-types/heading/component.d.ts +3 -3
  412. package/build-types/heading/component.d.ts.map +1 -1
  413. package/build-types/heading/hook.d.ts +2 -1
  414. package/build-types/heading/hook.d.ts.map +1 -1
  415. package/build-types/heading/stories/index.d.ts +12 -0
  416. package/build-types/heading/stories/index.d.ts.map +1 -0
  417. package/build-types/input-control/index.d.ts +1 -1
  418. package/build-types/input-control/index.d.ts.map +1 -1
  419. package/build-types/input-control/input-field.d.ts +1 -1
  420. package/build-types/input-control/input-field.d.ts.map +1 -1
  421. package/build-types/input-control/styles/input-control-styles.d.ts.map +1 -1
  422. package/build-types/item-group/item/hook.d.ts +2 -1
  423. package/build-types/item-group/item/hook.d.ts.map +1 -1
  424. package/build-types/item-group/item-group/hook.d.ts +2 -1
  425. package/build-types/item-group/item-group/hook.d.ts.map +1 -1
  426. package/build-types/navigator/navigator-back-button/hook.d.ts +2 -1
  427. package/build-types/navigator/navigator-back-button/hook.d.ts.map +1 -1
  428. package/build-types/navigator/navigator-button/hook.d.ts +2 -1
  429. package/build-types/navigator/navigator-button/hook.d.ts.map +1 -1
  430. package/build-types/number-control/styles/number-control-styles.d.ts +1 -1
  431. package/build-types/scrollable/hook.d.ts +2 -1
  432. package/build-types/scrollable/hook.d.ts.map +1 -1
  433. package/build-types/select-control/index.d.ts +1 -1
  434. package/build-types/select-control/index.d.ts.map +1 -1
  435. package/build-types/select-control/styles/select-control-styles.d.ts.map +1 -1
  436. package/build-types/spacer/hook.d.ts +2 -1
  437. package/build-types/spacer/hook.d.ts.map +1 -1
  438. package/build-types/surface/hook.d.ts +2 -1
  439. package/build-types/surface/hook.d.ts.map +1 -1
  440. package/build-types/text/hook.d.ts +2 -1
  441. package/build-types/text/hook.d.ts.map +1 -1
  442. package/build-types/text/types.d.ts +1 -2
  443. package/build-types/text/types.d.ts.map +1 -1
  444. package/build-types/toggle-group-control/toggle-group-control-option/component.d.ts.map +1 -1
  445. package/build-types/toggle-group-control/toggle-group-control-option/styles.d.ts +0 -4
  446. package/build-types/toggle-group-control/toggle-group-control-option/styles.d.ts.map +1 -1
  447. package/build-types/tools-panel/tools-panel/hook.d.ts +2 -1
  448. package/build-types/tools-panel/tools-panel/hook.d.ts.map +1 -1
  449. package/build-types/tools-panel/tools-panel-header/hook.d.ts +2 -1
  450. package/build-types/tools-panel/tools-panel-header/hook.d.ts.map +1 -1
  451. package/build-types/tools-panel/tools-panel-item/hook.d.ts +2 -1
  452. package/build-types/tools-panel/tools-panel-item/hook.d.ts.map +1 -1
  453. package/build-types/truncate/hook.d.ts +2 -1
  454. package/build-types/truncate/hook.d.ts.map +1 -1
  455. package/build-types/ui/context/context-connect.d.ts +18 -16
  456. package/build-types/ui/context/context-connect.d.ts.map +1 -1
  457. package/build-types/ui/context/index.d.ts +4 -4
  458. package/build-types/ui/context/index.d.ts.map +1 -1
  459. package/build-types/ui/context/wordpress-component.d.ts +1 -0
  460. package/build-types/ui/context/wordpress-component.d.ts.map +1 -1
  461. package/build-types/ui/control-group/hook.d.ts +2 -1
  462. package/build-types/ui/control-group/hook.d.ts.map +1 -1
  463. package/build-types/ui/control-label/hook.d.ts +2 -1
  464. package/build-types/ui/control-label/hook.d.ts.map +1 -1
  465. package/build-types/ui/form-group/use-form-group.d.ts +6 -4
  466. package/build-types/ui/form-group/use-form-group.d.ts.map +1 -1
  467. package/build-types/unit-control/index.d.ts +3 -3
  468. package/build-types/unit-control/index.d.ts.map +1 -1
  469. package/build-types/unit-control/types.d.ts +4 -6
  470. package/build-types/unit-control/types.d.ts.map +1 -1
  471. package/build-types/unit-control/utils.d.ts +47 -38
  472. package/build-types/unit-control/utils.d.ts.map +1 -1
  473. package/build-types/v-stack/hook.d.ts +2 -1
  474. package/build-types/v-stack/hook.d.ts.map +1 -1
  475. package/package.json +18 -18
  476. package/src/alignment-matrix-control/utils.js +1 -1
  477. package/src/angle-picker-control/angle-circle.js +1 -1
  478. package/src/animation/index.js +0 -1
  479. package/src/autocomplete/get-default-use-items.js +3 -3
  480. package/src/base-field/hook.js +1 -1
  481. package/src/box-control/icon.js +1 -1
  482. package/src/box-control/index.js +5 -5
  483. package/src/box-control/test/index.js +27 -7
  484. package/src/box-control/utils.js +13 -9
  485. package/src/button/index.js +5 -5
  486. package/src/button/index.native.js +7 -7
  487. package/src/button/style.scss +1 -0
  488. package/src/color-palette/style.scss +1 -0
  489. package/src/color-picker/color-display.tsx +1 -1
  490. package/src/color-picker/styles.ts +1 -1
  491. package/src/color-picker/test/index.js +1 -1
  492. package/src/combobox-control/index.js +1 -1
  493. package/src/combobox-control/style.scss +1 -0
  494. package/src/confirm-dialog/README.md +56 -45
  495. package/src/confirm-dialog/component.tsx +4 -2
  496. package/src/confirm-dialog/stories/index.js +19 -0
  497. package/src/confirm-dialog/test/index.js +28 -0
  498. package/src/confirm-dialog/types.ts +2 -0
  499. package/src/date-time/style.scss +4 -0
  500. package/src/date-time/time.js +16 -5
  501. package/src/dimension-control/test/index.test.js +1 -1
  502. package/src/disabled/test/index.js +1 -1
  503. package/src/divider/component.tsx +3 -3
  504. package/src/divider/stories/index.tsx +70 -0
  505. package/src/divider/types.ts +3 -1
  506. package/src/draggable/index.js +3 -3
  507. package/src/draggable/stories/index.js +1 -1
  508. package/src/flyout/flyout/README.md +1 -1
  509. package/src/flyout/test/index.js +1 -1
  510. package/src/focal-point-picker/index.native.js +7 -7
  511. package/src/focal-point-picker/tooltip/index.native.js +1 -1
  512. package/src/font-size-picker/README.md +1 -2
  513. package/src/font-size-picker/index.js +1 -1
  514. package/src/font-size-picker/stories/index.js +87 -108
  515. package/src/font-size-picker/test/index.js +0 -2
  516. package/src/form-token-field/index.js +6 -6
  517. package/src/form-token-field/style.scss +1 -0
  518. package/src/form-token-field/suggestions-list.js +2 -2
  519. package/src/form-token-field/test/index.js +6 -6
  520. package/src/heading/component.tsx +4 -4
  521. package/src/heading/hook.ts +1 -1
  522. package/src/heading/stories/index.tsx +37 -0
  523. package/src/higher-order/with-filters/test/index.js +1 -1
  524. package/src/higher-order/with-focus-outside/test/index.js +1 -1
  525. package/src/higher-order/with-notices/index.js +1 -1
  526. package/src/higher-order/with-notices/test/index.js +3 -3
  527. package/src/index.js +4 -4
  528. package/src/index.native.js +4 -4
  529. package/src/input-control/input-base.tsx +1 -1
  530. package/src/input-control/input-field.tsx +12 -9
  531. package/src/input-control/styles/input-control-styles.tsx +1 -0
  532. package/src/input-control/test/index.js +4 -4
  533. package/src/isolated-event-container/index.js +1 -1
  534. package/src/item-group/test/index.js +0 -1
  535. package/src/mobile/bottom-sheet/bottom-sheet-context.native.js +4 -4
  536. package/src/mobile/bottom-sheet/bottom-sheet-navigation/navigation-container.native.js +1 -1
  537. package/src/mobile/bottom-sheet/cell.native.js +1 -1
  538. package/src/mobile/bottom-sheet/index.native.js +11 -11
  539. package/src/mobile/bottom-sheet/link-cell.native.js +1 -1
  540. package/src/mobile/bottom-sheet/link-suggestion-item-cell.native.js +1 -1
  541. package/src/mobile/bottom-sheet/nav-bar/back-button.native.js +1 -1
  542. package/src/mobile/global-styles-context/utils.native.js +10 -10
  543. package/src/mobile/gradient/index.native.js +2 -2
  544. package/src/mobile/html-text-input/container.ios.js +3 -3
  545. package/src/mobile/html-text-input/index.native.js +1 -1
  546. package/src/mobile/html-text-input/test/index.native.js +14 -14
  547. package/src/mobile/image/index.native.js +1 -1
  548. package/src/mobile/image/style.native.scss +1 -0
  549. package/src/mobile/keyboard-aware-flat-list/index.android.js +1 -1
  550. package/src/mobile/keyboard-aware-flat-list/index.ios.js +2 -2
  551. package/src/mobile/link-picker/index.native.js +3 -3
  552. package/src/mobile/link-picker/link-picker-results.native.js +8 -8
  553. package/src/mobile/link-settings/image-link-destinations-screen.native.js +2 -2
  554. package/src/mobile/link-settings/index.native.js +1 -2
  555. package/src/mobile/link-settings/test/edit.native.js +15 -15
  556. package/src/modal/aria-helper.js +1 -1
  557. package/src/modal/index.js +2 -2
  558. package/src/navigable-container/container.js +2 -2
  559. package/src/navigable-container/tabbable.js +1 -1
  560. package/src/navigable-container/test/menu.js +5 -5
  561. package/src/navigable-container/test/tabbable.js +2 -2
  562. package/src/navigation/item/index.js +1 -1
  563. package/src/navigation/menu/index.js +1 -1
  564. package/src/navigation/stories/controlled-state.js +2 -2
  565. package/src/navigator/navigator-provider/component.tsx +1 -1
  566. package/src/navigator/navigator-screen/component.tsx +2 -2
  567. package/src/navigator/test/index.js +18 -19
  568. package/src/navigator/types.ts +1 -1
  569. package/src/number-control/index.js +1 -1
  570. package/src/panel/body.js +2 -2
  571. package/src/popover/index.js +3 -3
  572. package/src/popover/utils.js +6 -6
  573. package/src/radio-group/index.js +1 -1
  574. package/src/range-control/stories/index.js +1 -1
  575. package/src/range-control/styles/range-control-styles.js +1 -1
  576. package/src/range-control/test/index.js +2 -2
  577. package/src/sandbox/index.js +5 -5
  578. package/src/sandbox/index.native.js +1 -1
  579. package/src/select-control/index.tsx +1 -1
  580. package/src/select-control/styles/select-control-styles.ts +1 -0
  581. package/src/slot-fill/bubbles-virtually/slot-fill-provider.js +1 -1
  582. package/src/slot-fill/bubbles-virtually/slot.js +1 -2
  583. package/src/slot-fill/fill.js +1 -1
  584. package/src/slot-fill/provider.js +1 -1
  585. package/src/snackbar/index.js +1 -1
  586. package/src/snackbar/list.js +1 -1
  587. package/src/style-provider/index.js +2 -2
  588. package/src/tab-panel/test/index.js +1 -1
  589. package/src/text/test/index.js +2 -2
  590. package/src/text/types.ts +6 -8
  591. package/src/text-highlight/test/index.js +4 -4
  592. package/src/toggle-control/test/index.js +3 -3
  593. package/src/toggle-group-control/test/__snapshots__/index.js.snap +1 -27
  594. package/src/toggle-group-control/toggle-group-control/component.tsx +2 -2
  595. package/src/toggle-group-control/toggle-group-control-option/component.tsx +1 -4
  596. package/src/toggle-group-control/toggle-group-control-option/styles.ts +1 -12
  597. package/src/toolbar/index.js +1 -1
  598. package/src/toolbar-group/test/index.js +2 -2
  599. package/src/tooltip/index.js +3 -3
  600. package/src/tooltip/index.native.js +7 -7
  601. package/src/tooltip/test/index.js +2 -2
  602. package/src/tooltip/test/index.native.js +2 -2
  603. package/src/tree-grid/README.md +1 -1
  604. package/src/tree-grid/index.js +4 -0
  605. package/src/tree-grid/test/__snapshots__/index.js.snap +1 -1
  606. package/src/tree-grid/test/index.js +128 -52
  607. package/src/truncate/utils.js +1 -1
  608. package/src/ui/context/{context-connect.js → context-connect.ts} +27 -16
  609. package/src/ui/context/context-system-provider.js +2 -2
  610. package/src/ui/context/{index.js → index.ts} +0 -0
  611. package/src/ui/context/wordpress-component.ts +1 -0
  612. package/src/ui/tooltip/test/index.js +4 -4
  613. package/src/ui/utils/colors.js +2 -2
  614. package/src/ui/utils/space.ts +2 -2
  615. package/src/unit-control/README.md +1 -1
  616. package/src/unit-control/index.native.js +5 -3
  617. package/src/unit-control/index.tsx +64 -35
  618. package/src/unit-control/test/index.js +102 -3
  619. package/src/unit-control/test/utils.js +56 -15
  620. package/src/unit-control/types.ts +5 -8
  621. package/src/unit-control/unit-select-control.tsx +1 -1
  622. package/src/unit-control/utils.ts +128 -125
  623. package/src/utils/breakpoint-values.js +1 -1
  624. package/src/utils/colors-values.js +1 -1
  625. package/src/utils/hooks/test/use-controlled-state.js +1 -1
  626. package/src/utils/hooks/test/use-controlled-value.js +3 -3
  627. package/src/utils/hooks/test/use-latest-ref.js +1 -1
  628. package/src/utils/test/math.js +2 -2
  629. package/src/utils/test/rtl.js +12 -12
  630. package/tsconfig.json +1 -1
  631. package/tsconfig.tsbuildinfo +1 -1
  632. package/src/divider/stories/index.js +0 -64
  633. package/src/heading/stories/index.js +0 -24
@@ -7,7 +7,7 @@ import { Platform } from '@wordpress/element';
7
7
  /**
8
8
  * Internal dependencies
9
9
  */
10
- import type { Value, WPUnitControlUnit, WPUnitControlUnitList } from './types';
10
+ import type { WPUnitControlUnit } from './types';
11
11
 
12
12
  const isWeb = Platform.OS === 'web';
13
13
 
@@ -15,105 +15,90 @@ const allUnits: Record< string, WPUnitControlUnit > = {
15
15
  px: {
16
16
  value: 'px',
17
17
  label: isWeb ? 'px' : __( 'Pixels (px)' ),
18
- default: '',
19
18
  a11yLabel: __( 'Pixels (px)' ),
20
19
  step: 1,
21
20
  },
22
21
  '%': {
23
22
  value: '%',
24
23
  label: isWeb ? '%' : __( 'Percentage (%)' ),
25
- default: '',
26
24
  a11yLabel: __( 'Percent (%)' ),
27
25
  step: 0.1,
28
26
  },
29
27
  em: {
30
28
  value: 'em',
31
29
  label: isWeb ? 'em' : __( 'Relative to parent font size (em)' ),
32
- default: '',
33
30
  a11yLabel: _x( 'ems', 'Relative to parent font size (em)' ),
34
31
  step: 0.01,
35
32
  },
36
33
  rem: {
37
34
  value: 'rem',
38
35
  label: isWeb ? 'rem' : __( 'Relative to root font size (rem)' ),
39
- default: '',
40
36
  a11yLabel: _x( 'rems', 'Relative to root font size (rem)' ),
41
37
  step: 0.01,
42
38
  },
43
39
  vw: {
44
40
  value: 'vw',
45
41
  label: isWeb ? 'vw' : __( 'Viewport width (vw)' ),
46
- default: '',
47
42
  a11yLabel: __( 'Viewport width (vw)' ),
48
43
  step: 0.1,
49
44
  },
50
45
  vh: {
51
46
  value: 'vh',
52
47
  label: isWeb ? 'vh' : __( 'Viewport height (vh)' ),
53
- default: '',
54
48
  a11yLabel: __( 'Viewport height (vh)' ),
55
49
  step: 0.1,
56
50
  },
57
51
  vmin: {
58
52
  value: 'vmin',
59
53
  label: isWeb ? 'vmin' : __( 'Viewport smallest dimension (vmin)' ),
60
- default: '',
61
54
  a11yLabel: __( 'Viewport smallest dimension (vmin)' ),
62
55
  step: 0.1,
63
56
  },
64
57
  vmax: {
65
58
  value: 'vmax',
66
59
  label: isWeb ? 'vmax' : __( 'Viewport largest dimension (vmax)' ),
67
- default: '',
68
60
  a11yLabel: __( 'Viewport largest dimension (vmax)' ),
69
61
  step: 0.1,
70
62
  },
71
63
  ch: {
72
64
  value: 'ch',
73
65
  label: isWeb ? 'ch' : __( 'Width of the zero (0) character (ch)' ),
74
- default: '',
75
66
  a11yLabel: __( 'Width of the zero (0) character (ch)' ),
76
67
  step: 0.01,
77
68
  },
78
69
  ex: {
79
70
  value: 'ex',
80
71
  label: isWeb ? 'ex' : __( 'x-height of the font (ex)' ),
81
- default: '',
82
72
  a11yLabel: __( 'x-height of the font (ex)' ),
83
73
  step: 0.01,
84
74
  },
85
75
  cm: {
86
76
  value: 'cm',
87
77
  label: isWeb ? 'cm' : __( 'Centimeters (cm)' ),
88
- default: '',
89
78
  a11yLabel: __( 'Centimeters (cm)' ),
90
79
  step: 0.001,
91
80
  },
92
81
  mm: {
93
82
  value: 'mm',
94
83
  label: isWeb ? 'mm' : __( 'Millimeters (mm)' ),
95
- default: '',
96
84
  a11yLabel: __( 'Millimeters (mm)' ),
97
85
  step: 0.1,
98
86
  },
99
87
  in: {
100
88
  value: 'in',
101
89
  label: isWeb ? 'in' : __( 'Inches (in)' ),
102
- default: '',
103
90
  a11yLabel: __( 'Inches (in)' ),
104
91
  step: 0.001,
105
92
  },
106
93
  pc: {
107
94
  value: 'pc',
108
95
  label: isWeb ? 'pc' : __( 'Picas (pc)' ),
109
- default: '',
110
96
  a11yLabel: __( 'Picas (pc)' ),
111
97
  step: 1,
112
98
  },
113
99
  pt: {
114
100
  value: 'pt',
115
101
  label: isWeb ? 'pt' : __( 'Points (pt)' ),
116
- default: '',
117
102
  a11yLabel: __( 'Points (pt)' ),
118
103
  step: 1,
119
104
  },
@@ -145,130 +130,148 @@ export const DEFAULT_UNIT = allUnits.px;
145
130
  * Moving forward, ideally the value should be a string that contains both
146
131
  * the value and unit, example: '10px'
147
132
  *
148
- * @param value Value
149
- * @param unit Unit value
150
- * @param units Units to derive from.
151
- * @return The extracted number and unit.
133
+ * @param rawValue The raw value as a string (may or may not contain the unit)
134
+ * @param fallbackUnit The unit used as a fallback, if not unit is detected in the `value`
135
+ * @param allowedUnits Units to derive from.
136
+ * @return The extracted quantity and unit. The quantity can be `undefined` in case the raw value
137
+ * could not be parsed to a number correctly. The unit can be `undefined` in case the unit parse
138
+ * from the raw value could not be matched against the list of allowed units.
152
139
  */
153
- export function getParsedValue(
154
- value: Value,
155
- unit?: string,
156
- units?: WPUnitControlUnitList
157
- ): [ Value, string | undefined ] {
158
- const initialValue = unit ? `${ value }${ unit }` : value;
140
+ export function getParsedQuantityAndUnit(
141
+ rawValue?: string | number,
142
+ fallbackUnit?: string,
143
+ allowedUnits?: WPUnitControlUnit[]
144
+ ): [ number | undefined, string | undefined ] {
145
+ const initialValue = fallbackUnit
146
+ ? `${ rawValue ?? '' }${ fallbackUnit }`
147
+ : rawValue;
159
148
 
160
- return parseUnit( initialValue, units );
149
+ return parseQuantityAndUnitFromRawValue( initialValue, allowedUnits );
161
150
  }
162
151
 
163
152
  /**
164
153
  * Checks if units are defined.
165
154
  *
166
- * @param units Units to check.
167
- * @return Whether units are defined.
155
+ * @param units List of units.
156
+ * @return Whether the list actually contains any units.
168
157
  */
169
- export function hasUnits( units: WPUnitControlUnitList ): boolean {
158
+ export function hasUnits( units?: WPUnitControlUnit[] ): boolean {
159
+ // Although the `isArray` check shouldn't be necessary (given the signature of
160
+ // this typed function), it's better to stay on the side of caution, since
161
+ // this function may be called from un-typed environments.
170
162
  return Array.isArray( units ) && !! units.length;
171
163
  }
172
164
 
173
165
  /**
174
- * Parses a number and unit from a value.
166
+ * Parses a quantity and unit from a raw string value, given a list of allowed
167
+ * units and otherwise falling back to the default unit.
175
168
  *
176
- * @param initialValue Value to parse
177
- * @param units Units to derive from.
178
- * @return The extracted number and unit.
169
+ * @param rawValue The raw value as a string (may or may not contain the unit)
170
+ * @param allowedUnits Units to derive from.
171
+ * @return The extracted quantity and unit. The quantity can be `undefined` in case the raw value
172
+ * could not be parsed to a number correctly. The unit can be `undefined` in case the unit parsed
173
+ * from the raw value could not be matched against the list of allowed units.
179
174
  */
180
- export function parseUnit(
181
- initialValue: Value | undefined,
182
- units: WPUnitControlUnitList = ALL_CSS_UNITS
183
- ): [ Value, string | undefined ] {
184
- const value = String( initialValue ).trim();
175
+ export function parseQuantityAndUnitFromRawValue(
176
+ rawValue?: string | number,
177
+ allowedUnits: WPUnitControlUnit[] = ALL_CSS_UNITS
178
+ ): [ number | undefined, string | undefined ] {
179
+ let trimmedValue;
180
+ let quantityToReturn;
185
181
 
186
- let num: Value = parseFloat( value );
187
- num = isNaN( num ) ? '' : num;
188
-
189
- const unitMatch = value.match( /[\d.\-\+]*\s*(.*)/ );
190
-
191
- let unit: string | undefined =
192
- unitMatch?.[ 1 ] !== undefined ? unitMatch[ 1 ] : '';
193
- unit = unit.toLowerCase();
182
+ if ( typeof rawValue !== 'undefined' || rawValue === null ) {
183
+ trimmedValue = `${ rawValue }`.trim();
184
+ const parsedQuantity = parseFloat( trimmedValue );
185
+ quantityToReturn = ! isFinite( parsedQuantity )
186
+ ? undefined
187
+ : parsedQuantity;
188
+ }
194
189
 
195
- if ( hasUnits( units ) && units !== false ) {
196
- const match = units.find( ( item ) => item.value === unit );
197
- unit = match?.value;
190
+ const unitMatch = trimmedValue?.match( /[\d.\-\+]*\s*(.*)/ );
191
+ const matchedUnit = unitMatch?.[ 1 ]?.toLowerCase();
192
+ let unitToReturn: string | undefined;
193
+ if ( hasUnits( allowedUnits ) ) {
194
+ const match = allowedUnits.find(
195
+ ( item ) => item.value === matchedUnit
196
+ );
197
+ unitToReturn = match?.value;
198
198
  } else {
199
- unit = DEFAULT_UNIT.value;
199
+ unitToReturn = DEFAULT_UNIT.value;
200
200
  }
201
201
 
202
- return [ num, unit ];
202
+ return [ quantityToReturn, unitToReturn ];
203
203
  }
204
204
 
205
205
  /**
206
- * Parses a number and unit from a value. Validates parsed value, using fallback
206
+ * Parses quantity and unit from a raw value. Validates parsed value, using fallback
207
207
  * value if invalid.
208
208
  *
209
- * @param next The next value.
210
- * @param units Units to derive from.
211
- * @param fallbackValue The fallback value.
212
- * @param fallbackUnit The fallback value.
213
- * @return The extracted value and unit.
209
+ * @param rawValue The next value.
210
+ * @param allowedUnits Units to derive from.
211
+ * @param fallbackQuantity The fallback quantity, used in case it's not possible to parse a valid quantity from the raw value.
212
+ * @param fallbackUnit The fallback unit, used in case it's not possible to parse a valid unit from the raw value.
213
+ * @return The extracted quantity and unit. The quantity can be `undefined` in case the raw value
214
+ * could not be parsed to a number correctly, and the `fallbackQuantity` was also `undefined`. The
215
+ * unit can be `undefined` only if the unit parsed from the raw value could not be matched against
216
+ * the list of allowed units, the `fallbackQuantity` is also `undefined` and the list of
217
+ * `allowedUnits` is passed empty.
214
218
  */
215
- export function getValidParsedUnit(
216
- next: Value | undefined,
217
- units: WPUnitControlUnitList,
218
- fallbackValue: Value,
219
- fallbackUnit: string | undefined
220
- ): [ Value, string | undefined ] {
221
- const [ parsedValue, parsedUnit ] = parseUnit( next, units );
222
- let baseValue = parsedValue;
223
- let baseUnit: string | undefined;
219
+ export function getValidParsedQuantityAndUnit(
220
+ rawValue: string | number,
221
+ allowedUnits: WPUnitControlUnit[],
222
+ fallbackQuantity?: number,
223
+ fallbackUnit?: string
224
+ ): [ number | undefined, string | undefined ] {
225
+ const [ parsedQuantity, parsedUnit ] = parseQuantityAndUnitFromRawValue(
226
+ rawValue,
227
+ allowedUnits
228
+ );
224
229
 
225
- // The parsed value from `parseUnit` should now be either a
226
- // real number or an empty string. If not, use the fallback value.
227
- if ( ! Number.isFinite( parsedValue ) || parsedValue === '' ) {
228
- baseValue = fallbackValue;
229
- }
230
+ // The parsed value from `parseQuantityAndUnitFromRawValue` should now be
231
+ // either a real number or undefined. If undefined, use the fallback value.
232
+ const quantityToReturn = parsedQuantity ?? fallbackQuantity;
230
233
 
231
- baseUnit = parsedUnit || fallbackUnit;
234
+ // If no unit is parsed from the raw value, or if the fallback unit is not
235
+ // defined, use the first value from the list of allowed units as fallback.
236
+ let unitToReturn = parsedUnit || fallbackUnit;
232
237
 
233
- /**
234
- * If no unit is found, attempt to use the first value from the collection
235
- * of units as a default fallback.
236
- */
237
- if ( Array.isArray( units ) && hasUnits( units ) && ! baseUnit ) {
238
- baseUnit = units[ 0 ]?.value;
238
+ if ( ! unitToReturn && hasUnits( allowedUnits ) ) {
239
+ unitToReturn = allowedUnits[ 0 ].value;
239
240
  }
240
241
 
241
- return [ baseValue, baseUnit ];
242
+ return [ quantityToReturn, unitToReturn ];
242
243
  }
243
244
 
244
245
  /**
245
246
  * Takes a unit value and finds the matching accessibility label for the
246
247
  * unit abbreviation.
247
248
  *
248
- * @param unit Unit value (example: px)
249
+ * @param unit Unit value (example: `px`)
249
250
  * @return a11y label for the unit abbreviation
250
251
  */
251
- export function parseA11yLabelForUnit( unit: string ): string | undefined {
252
+ export function getAccessibleLabelForUnit( unit: string ): string | undefined {
252
253
  const match = ALL_CSS_UNITS.find( ( item ) => item.value === unit );
253
254
  return match?.a11yLabel ? match?.a11yLabel : match?.value;
254
255
  }
255
256
 
256
257
  /**
257
- * Filters available units based on values defined by the unit setting/property.
258
+ * Filters available units based on values defined a list of allowed unit values.
258
259
  *
259
- * @param unitSetting Collection of preferred unit value strings.
260
- * @param units Collection of available unit objects.
261
- *
262
- * @return Filtered units based on settings.
260
+ * @param allowedUnitValues Collection of allowed unit value strings.
261
+ * @param availableUnits Collection of available unit objects.
262
+ * @return Filtered units.
263
263
  */
264
264
  export function filterUnitsWithSettings(
265
- unitSetting: Array< string > = [],
266
- units: WPUnitControlUnitList
267
- ): Array< WPUnitControlUnit > {
268
- return Array.isArray( units )
269
- ? units.filter( ( unit ) => {
270
- return unitSetting.includes( unit.value );
271
- } )
265
+ allowedUnitValues: string[] = [],
266
+ availableUnits: WPUnitControlUnit[]
267
+ ): WPUnitControlUnit[] {
268
+ // Although the `isArray` check shouldn't be necessary (given the signature of
269
+ // this typed function), it's better to stay on the side of caution, since
270
+ // this function may be called from un-typed environments.
271
+ return Array.isArray( availableUnits )
272
+ ? availableUnits.filter( ( unit ) =>
273
+ allowedUnitValues.includes( unit.value )
274
+ )
272
275
  : [];
273
276
  }
274
277
 
@@ -280,34 +283,38 @@ export function filterUnitsWithSettings(
280
283
  * @param args An object containing units, settingPath & defaultUnits.
281
284
  * @param args.units Collection of all potentially available units.
282
285
  * @param args.availableUnits Collection of unit value strings for filtering available units.
283
- * @param args.defaultValues Collection of default values for defined units. Example: { px: '350', em: '15' }.
286
+ * @param args.defaultValues Collection of default values for defined units. Example: `{ px: 350, em: 15 }`.
284
287
  *
285
- * @return Filtered units based on settings.
288
+ * @return Filtered list of units, with their default values updated following the `defaultValues`
289
+ * argument's property.
286
290
  */
287
291
  export const useCustomUnits = ( {
288
- units,
289
- availableUnits,
292
+ units = ALL_CSS_UNITS,
293
+ availableUnits = [],
290
294
  defaultValues,
291
295
  }: {
292
- units?: WPUnitControlUnitList;
293
- availableUnits?: Array< string >;
294
- defaultValues: Record< string, Value >;
295
- } ): WPUnitControlUnitList => {
296
- units = units || ALL_CSS_UNITS;
297
- const usedUnits = filterUnitsWithSettings(
298
- ! availableUnits ? [] : availableUnits,
296
+ units?: WPUnitControlUnit[];
297
+ availableUnits?: string[];
298
+ defaultValues: Record< string, number >;
299
+ } ): WPUnitControlUnit[] => {
300
+ const customUnitsToReturn = filterUnitsWithSettings(
301
+ availableUnits,
299
302
  units
300
303
  );
301
304
 
302
305
  if ( defaultValues ) {
303
- usedUnits.forEach( ( unit, i ) => {
306
+ customUnitsToReturn.forEach( ( unit, i ) => {
304
307
  if ( defaultValues[ unit.value ] ) {
305
- usedUnits[ i ].default = defaultValues[ unit.value ];
308
+ const [ parsedDefaultValue ] = parseQuantityAndUnitFromRawValue(
309
+ defaultValues[ unit.value ]
310
+ );
311
+
312
+ customUnitsToReturn[ i ].default = parsedDefaultValue;
306
313
  }
307
314
  } );
308
315
  }
309
316
 
310
- return usedUnits.length === 0 ? false : usedUnits;
317
+ return customUnitsToReturn;
311
318
  };
312
319
 
313
320
  /**
@@ -318,36 +325,32 @@ export const useCustomUnits = ( {
318
325
  * accurately displayed in the UI, even if the intention is to hide
319
326
  * the availability of that unit.
320
327
  *
321
- * @param currentValue Selected value to parse.
322
- * @param legacyUnit Legacy unit value, if currentValue needs it appended.
323
- * @param units List of available units.
328
+ * @param rawValue Selected value to parse.
329
+ * @param legacyUnit Legacy unit value, if rawValue needs it appended.
330
+ * @param units List of available units.
324
331
  *
325
332
  * @return A collection of units containing the unit for the current value.
326
333
  */
327
334
  export function getUnitsWithCurrentUnit(
328
- currentValue: Value,
329
- legacyUnit: string | undefined,
330
- units: WPUnitControlUnitList = ALL_CSS_UNITS
331
- ): WPUnitControlUnitList {
332
- if ( ! Array.isArray( units ) ) {
333
- return units;
334
- }
335
-
336
- const unitsWithCurrentUnit = [ ...units ];
337
- const [ , currentUnit ] = getParsedValue(
338
- currentValue,
335
+ rawValue?: string | number,
336
+ legacyUnit?: string,
337
+ units: WPUnitControlUnit[] = ALL_CSS_UNITS
338
+ ): WPUnitControlUnit[] {
339
+ const unitsToReturn = Array.isArray( units ) ? [ ...units ] : [];
340
+ const [ , currentUnit ] = getParsedQuantityAndUnit(
341
+ rawValue,
339
342
  legacyUnit,
340
343
  ALL_CSS_UNITS
341
344
  );
342
345
 
343
346
  if (
344
347
  currentUnit &&
345
- ! unitsWithCurrentUnit.some( ( unit ) => unit.value === currentUnit )
348
+ ! unitsToReturn.some( ( unit ) => unit.value === currentUnit )
346
349
  ) {
347
350
  if ( allUnits[ currentUnit ] ) {
348
- unitsWithCurrentUnit.unshift( allUnits[ currentUnit ] );
351
+ unitsToReturn.unshift( allUnits[ currentUnit ] );
349
352
  }
350
353
  }
351
354
 
352
- return unitsWithCurrentUnit;
355
+ return unitsToReturn;
353
356
  }
@@ -3,7 +3,7 @@ export default {
3
3
  wide: '1280px',
4
4
  'x-large': '1080px',
5
5
  large: '960px', // admin sidebar auto folds
6
- medium: '782px', // adminbar goes big
6
+ medium: '782px', // Adminbar goes big.
7
7
  small: '600px',
8
8
  mobile: '480px',
9
9
  'zoomed-in': '280px',
@@ -150,7 +150,7 @@ export const ADMIN = {
150
150
  themeDark10: `var( --wp-admin-theme-color-darker-10, ${ BLUE.medium.focus })`,
151
151
  };
152
152
 
153
- // Namespaced values for raw colors hex codes
153
+ // Namespaced values for raw colors hex codes.
154
154
  export const UI = {
155
155
  theme: ADMIN.theme,
156
156
  background: BASE.white,
@@ -117,7 +117,7 @@ describe( 'hooks', () => {
117
117
  expect( input.value ).toBe( 'There' );
118
118
  expect( spy ).toHaveBeenCalledWith( 'There' );
119
119
 
120
- // Input is now controlled
120
+ // Input is now controlled.
121
121
  rerender( <Example value="New Value" /> );
122
122
  expect( input.value ).toBe( 'New Value' );
123
123
 
@@ -83,9 +83,9 @@ describe( 'useControlledValue', () => {
83
83
 
84
84
  expect( getInput() ).toHaveValue( 'Code is Poetry' );
85
85
 
86
- // primarily this proves that the hook doesn't break if no onChange is passed but
86
+ // Primarily this proves that the hook doesn't break if no onChange is passed but
87
87
  // value turns into a controlled state, for example if the value needs to be set
88
- // to a constant in certain conditions but no change listening needs to happen
88
+ // to a constant in certain conditions but no change listening needs to happen.
89
89
  fireEvent.change( getInput(), { target: { value: 'WordPress.org' } } );
90
90
 
91
91
  // If `value` is passed then we expect the value to be fully controlled
@@ -93,7 +93,7 @@ describe( 'useControlledValue', () => {
93
93
  // we're managing internal state.
94
94
  expect( getInput() ).toHaveValue( 'Code is Poetry' );
95
95
 
96
- // Next we un-set the value to uncover the internal state which was still maintained
96
+ // Next we un-set the value to uncover the internal state which was still maintained.
97
97
  rerender( <Input /> );
98
98
 
99
99
  expect( getInput() ).toHaveValue( 'WordPress.org' );
@@ -71,7 +71,7 @@ function incrementCountDebouncedRef() {
71
71
 
72
72
  describe( 'useLatestRef', () => {
73
73
  describe( 'Example', () => {
74
- // prove the example works as expected
74
+ // Prove the example works as expected.
75
75
  it( 'should start at 0', () => {
76
76
  render( <Example /> );
77
77
  expect( getCount() ).toEqual( 'Count: 0' );
@@ -10,7 +10,7 @@ describe( 'add', () => {
10
10
  expect( add( '105', 30 ) ).toBe( 135 );
11
11
  expect( add( 105, '30' ) ).toBe( 135 );
12
12
 
13
- // Negative values
13
+ // Negative values.
14
14
  expect( add( 100, '-30' ) ).toBe( 70 );
15
15
  expect( add( -100, '-30' ) ).toBe( -130 );
16
16
  } );
@@ -27,7 +27,7 @@ describe( 'subtract', () => {
27
27
  expect( subtract( '105', 30 ) ).toBe( 75 );
28
28
  expect( subtract( 105, '30' ) ).toBe( 75 );
29
29
 
30
- // Negative values
30
+ // Negative values.
31
31
  expect( subtract( 100, '-30' ) ).toBe( 130 );
32
32
  expect( subtract( -100, '-30' ) ).toBe( -70 );
33
33
  } );
@@ -6,7 +6,7 @@ import { convertLTRToRTL } from '../rtl';
6
6
  describe( 'convertLTRToRTL', () => {
7
7
  it( 'converts (*)Left <-> (*)Right', () => {
8
8
  const style = {
9
- // left values
9
+ // Left values.
10
10
  borderLeft: '10px solid red',
11
11
  borderLeftColor: 'red',
12
12
  borderLeftStyle: 'solid',
@@ -15,7 +15,7 @@ describe( 'convertLTRToRTL', () => {
15
15
  marginLeft: 10,
16
16
  scrollMarginLeft: 10,
17
17
  scrollPaddingLeft: 10,
18
- // right values
18
+ // Right values.
19
19
  paddingLeft: 10,
20
20
  borderRight: '20px solid blue',
21
21
  borderRightColor: 'blue',
@@ -26,7 +26,7 @@ describe( 'convertLTRToRTL', () => {
26
26
  paddingRight: 20,
27
27
  scrollMarginRight: 20,
28
28
  scrollPaddingRight: 20,
29
- // edge cases
29
+ // Edge cases.
30
30
  textCombineUpright: 'none',
31
31
  };
32
32
  const nextStyle = convertLTRToRTL( style );
@@ -35,7 +35,7 @@ describe( 'convertLTRToRTL', () => {
35
35
  Object.keys( nextStyle ).length
36
36
  );
37
37
 
38
- // Left -> Right
38
+ // Left -> Right.
39
39
  expect( nextStyle.borderRight ).toBe( '10px solid red' );
40
40
  expect( nextStyle.borderRightColor ).toBe( 'red' );
41
41
  expect( nextStyle.borderRightStyle ).toBe( 'solid' );
@@ -46,7 +46,7 @@ describe( 'convertLTRToRTL', () => {
46
46
  expect( nextStyle.scrollMarginRight ).toBe( 10 );
47
47
  expect( nextStyle.scrollPaddingRight ).toBe( 10 );
48
48
 
49
- // Right -> Left
49
+ // Right -> Left.
50
50
  expect( nextStyle.borderLeft ).toBe( '20px solid blue' );
51
51
  expect( nextStyle.borderLeftColor ).toBe( 'blue' );
52
52
  expect( nextStyle.borderLeftStyle ).toBe( 'dashed' );
@@ -57,13 +57,13 @@ describe( 'convertLTRToRTL', () => {
57
57
  expect( nextStyle.scrollMarginLeft ).toBe( 20 );
58
58
  expect( nextStyle.scrollPaddingLeft ).toBe( 20 );
59
59
 
60
- // Edge cases
60
+ // Edge cases.
61
61
  expect( nextStyle.textCombineUpright ).toBe( 'none' );
62
62
  } );
63
63
 
64
64
  it( 'converts (*)left <-> (*)right', () => {
65
65
  const style = {
66
- // left values
66
+ // Left values.
67
67
  'border-left': '10px solid red',
68
68
  'border-left-color': 'red',
69
69
  'border-left-style': 'solid',
@@ -74,7 +74,7 @@ describe( 'convertLTRToRTL', () => {
74
74
  'scroll-margin-left': 10,
75
75
  'scroll-padding-left': 10,
76
76
  left: 10,
77
- // right values
77
+ // Right values.
78
78
  'border-right': '20px solid blue',
79
79
  'border-right-color': 'blue',
80
80
  'border-right-style': 'dashed',
@@ -85,7 +85,7 @@ describe( 'convertLTRToRTL', () => {
85
85
  'scroll-margin-right': 20,
86
86
  'scroll-padding-right': 20,
87
87
  right: 20,
88
- // edge cases
88
+ // Edge cases.
89
89
  'text-combine-upright': 'none',
90
90
  };
91
91
  const nextStyle = convertLTRToRTL( style );
@@ -94,7 +94,7 @@ describe( 'convertLTRToRTL', () => {
94
94
  Object.keys( nextStyle ).length
95
95
  );
96
96
 
97
- // left -> right
97
+ // Left -> right.
98
98
  expect( nextStyle[ 'border-right' ] ).toBe( '10px solid red' );
99
99
  expect( nextStyle[ 'border-right-color' ] ).toBe( 'red' );
100
100
  expect( nextStyle[ 'border-right-style' ] ).toBe( 'solid' );
@@ -106,7 +106,7 @@ describe( 'convertLTRToRTL', () => {
106
106
  expect( nextStyle[ 'scroll-padding-right' ] ).toBe( 10 );
107
107
  expect( nextStyle.right ).toBe( 10 );
108
108
 
109
- // right -> left
109
+ // Right -> left.
110
110
  expect( nextStyle[ 'border-left' ] ).toBe( '20px solid blue' );
111
111
  expect( nextStyle[ 'border-left-color' ] ).toBe( 'blue' );
112
112
  expect( nextStyle[ 'border-left-style' ] ).toBe( 'dashed' );
@@ -118,7 +118,7 @@ describe( 'convertLTRToRTL', () => {
118
118
  expect( nextStyle[ 'scroll-padding-left' ] ).toBe( 20 );
119
119
  expect( nextStyle.left ).toBe( 20 );
120
120
 
121
- // Edge cases
121
+ // Edge cases.
122
122
  expect( nextStyle[ 'text-combine-upright' ] ).toBe( 'none' );
123
123
  } );
124
124
  } );
package/tsconfig.json CHANGED
@@ -86,7 +86,7 @@
86
86
  "src/**/*.ios.js",
87
87
  "src/**/*.native.js",
88
88
  "src/**/react-native-*",
89
- "src/**/stories",
89
+ "src/**/stories/**.js", // only exclude js files, tsx files should be checked
90
90
  "src/**/test",
91
91
  "src/ui/__storybook-utils",
92
92
  "src/ui/font-size-control"