@wordpress/components 19.5.0 → 19.6.1-next.a55ed9455a.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 (618) hide show
  1. package/CHANGELOG.md +21 -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/styles.js +8 -8
  152. package/build/toggle-group-control/toggle-group-control-option/styles.js.map +1 -1
  153. package/build/toolbar/index.js +1 -1
  154. package/build/toolbar/index.js.map +1 -1
  155. package/build/tooltip/index.js +3 -3
  156. package/build/tooltip/index.js.map +1 -1
  157. package/build/tooltip/index.native.js +7 -7
  158. package/build/tooltip/index.native.js.map +1 -1
  159. package/build/truncate/utils.js +1 -1
  160. package/build/truncate/utils.js.map +1 -1
  161. package/build/ui/context/context-connect.js +8 -15
  162. package/build/ui/context/context-connect.js.map +1 -1
  163. package/build/ui/context/context-system-provider.js +2 -2
  164. package/build/ui/context/context-system-provider.js.map +1 -1
  165. package/build/ui/context/index.js.map +1 -1
  166. package/build/ui/utils/colors.js +2 -2
  167. package/build/ui/utils/colors.js.map +1 -1
  168. package/build/ui/utils/space.js +2 -2
  169. package/build/ui/utils/space.js.map +1 -1
  170. package/build/unit-control/index.js +38 -29
  171. package/build/unit-control/index.js.map +1 -1
  172. package/build/unit-control/index.native.js +4 -2
  173. package/build/unit-control/index.native.js.map +1 -1
  174. package/build/unit-control/unit-select-control.js +1 -1
  175. package/build/unit-control/unit-select-control.js.map +1 -1
  176. package/build/unit-control/utils.js +96 -104
  177. package/build/unit-control/utils.js.map +1 -1
  178. package/build/utils/breakpoint-values.js +1 -1
  179. package/build/utils/breakpoint-values.js.map +1 -1
  180. package/build/utils/colors-values.js +1 -1
  181. package/build/utils/colors-values.js.map +1 -1
  182. package/build-module/alignment-matrix-control/utils.js +1 -1
  183. package/build-module/alignment-matrix-control/utils.js.map +1 -1
  184. package/build-module/angle-picker-control/angle-circle.js +1 -1
  185. package/build-module/angle-picker-control/angle-circle.js.map +1 -1
  186. package/build-module/animation/index.js +1 -1
  187. package/build-module/animation/index.js.map +1 -1
  188. package/build-module/autocomplete/get-default-use-items.js +3 -3
  189. package/build-module/autocomplete/get-default-use-items.js.map +1 -1
  190. package/build-module/base-field/hook.js +1 -1
  191. package/build-module/base-field/hook.js.map +1 -1
  192. package/build-module/box-control/icon.js +1 -1
  193. package/build-module/box-control/icon.js.map +1 -1
  194. package/build-module/box-control/index.js +5 -5
  195. package/build-module/box-control/index.js.map +1 -1
  196. package/build-module/box-control/utils.js +13 -9
  197. package/build-module/box-control/utils.js.map +1 -1
  198. package/build-module/button/index.js +5 -5
  199. package/build-module/button/index.js.map +1 -1
  200. package/build-module/button/index.native.js +7 -7
  201. package/build-module/button/index.native.js.map +1 -1
  202. package/build-module/color-picker/color-display.js +1 -1
  203. package/build-module/color-picker/color-display.js.map +1 -1
  204. package/build-module/color-picker/styles.js +8 -8
  205. package/build-module/color-picker/styles.js.map +1 -1
  206. package/build-module/combobox-control/index.js +1 -1
  207. package/build-module/combobox-control/index.js.map +1 -1
  208. package/build-module/confirm-dialog/component.js +4 -5
  209. package/build-module/confirm-dialog/component.js.map +1 -1
  210. package/build-module/date-time/time.js +7 -4
  211. package/build-module/date-time/time.js.map +1 -1
  212. package/build-module/divider/component.js +3 -3
  213. package/build-module/divider/component.js.map +1 -1
  214. package/build-module/draggable/index.js +3 -3
  215. package/build-module/draggable/index.js.map +1 -1
  216. package/build-module/focal-point-picker/index.native.js +7 -7
  217. package/build-module/focal-point-picker/index.native.js.map +1 -1
  218. package/build-module/focal-point-picker/tooltip/index.native.js +1 -1
  219. package/build-module/focal-point-picker/tooltip/index.native.js.map +1 -1
  220. package/build-module/font-size-picker/index.js +1 -1
  221. package/build-module/font-size-picker/index.js.map +1 -1
  222. package/build-module/form-token-field/index.js +6 -6
  223. package/build-module/form-token-field/index.js.map +1 -1
  224. package/build-module/form-token-field/suggestions-list.js +2 -2
  225. package/build-module/form-token-field/suggestions-list.js.map +1 -1
  226. package/build-module/heading/component.js +4 -4
  227. package/build-module/heading/component.js.map +1 -1
  228. package/build-module/heading/hook.js +1 -1
  229. package/build-module/heading/hook.js.map +1 -1
  230. package/build-module/higher-order/with-notices/index.js +1 -1
  231. package/build-module/higher-order/with-notices/index.js.map +1 -1
  232. package/build-module/index.js +4 -4
  233. package/build-module/index.js.map +1 -1
  234. package/build-module/index.native.js +4 -4
  235. package/build-module/index.native.js.map +1 -1
  236. package/build-module/input-control/input-base.js +1 -1
  237. package/build-module/input-control/input-base.js.map +1 -1
  238. package/build-module/input-control/input-field.js +13 -10
  239. package/build-module/input-control/input-field.js.map +1 -1
  240. package/build-module/input-control/styles/input-control-styles.js +25 -25
  241. package/build-module/input-control/styles/input-control-styles.js.map +1 -1
  242. package/build-module/isolated-event-container/index.js +1 -1
  243. package/build-module/isolated-event-container/index.js.map +1 -1
  244. package/build-module/mobile/bottom-sheet/bottom-sheet-context.native.js +4 -4
  245. package/build-module/mobile/bottom-sheet/bottom-sheet-context.native.js.map +1 -1
  246. package/build-module/mobile/bottom-sheet/bottom-sheet-navigation/navigation-container.native.js +1 -1
  247. package/build-module/mobile/bottom-sheet/bottom-sheet-navigation/navigation-container.native.js.map +1 -1
  248. package/build-module/mobile/bottom-sheet/cell.native.js +1 -1
  249. package/build-module/mobile/bottom-sheet/cell.native.js.map +1 -1
  250. package/build-module/mobile/bottom-sheet/index.native.js +11 -11
  251. package/build-module/mobile/bottom-sheet/index.native.js.map +1 -1
  252. package/build-module/mobile/bottom-sheet/link-cell.native.js +1 -1
  253. package/build-module/mobile/bottom-sheet/link-cell.native.js.map +1 -1
  254. package/build-module/mobile/bottom-sheet/link-suggestion-item-cell.native.js +1 -1
  255. package/build-module/mobile/bottom-sheet/link-suggestion-item-cell.native.js.map +1 -1
  256. package/build-module/mobile/bottom-sheet/nav-bar/back-button.native.js +1 -1
  257. package/build-module/mobile/bottom-sheet/nav-bar/back-button.native.js.map +1 -1
  258. package/build-module/mobile/global-styles-context/utils.native.js +10 -10
  259. package/build-module/mobile/global-styles-context/utils.native.js.map +1 -1
  260. package/build-module/mobile/gradient/index.native.js +2 -2
  261. package/build-module/mobile/gradient/index.native.js.map +1 -1
  262. package/build-module/mobile/html-text-input/container.ios.js +3 -3
  263. package/build-module/mobile/html-text-input/container.ios.js.map +1 -1
  264. package/build-module/mobile/html-text-input/index.native.js +1 -1
  265. package/build-module/mobile/html-text-input/index.native.js.map +1 -1
  266. package/build-module/mobile/image/index.native.js +1 -1
  267. package/build-module/mobile/image/index.native.js.map +1 -1
  268. package/build-module/mobile/keyboard-aware-flat-list/index.android.js +1 -1
  269. package/build-module/mobile/keyboard-aware-flat-list/index.android.js.map +1 -1
  270. package/build-module/mobile/keyboard-aware-flat-list/index.ios.js +2 -2
  271. package/build-module/mobile/keyboard-aware-flat-list/index.ios.js.map +1 -1
  272. package/build-module/mobile/link-picker/index.native.js +3 -3
  273. package/build-module/mobile/link-picker/index.native.js.map +1 -1
  274. package/build-module/mobile/link-picker/link-picker-results.native.js +8 -8
  275. package/build-module/mobile/link-picker/link-picker-results.native.js.map +1 -1
  276. package/build-module/mobile/link-settings/image-link-destinations-screen.native.js +2 -2
  277. package/build-module/mobile/link-settings/image-link-destinations-screen.native.js.map +1 -1
  278. package/build-module/mobile/link-settings/index.native.js +1 -1
  279. package/build-module/mobile/link-settings/index.native.js.map +1 -1
  280. package/build-module/modal/aria-helper.js +1 -1
  281. package/build-module/modal/aria-helper.js.map +1 -1
  282. package/build-module/modal/index.js +2 -2
  283. package/build-module/modal/index.js.map +1 -1
  284. package/build-module/navigable-container/container.js +2 -2
  285. package/build-module/navigable-container/container.js.map +1 -1
  286. package/build-module/navigable-container/tabbable.js +1 -1
  287. package/build-module/navigable-container/tabbable.js.map +1 -1
  288. package/build-module/navigation/item/index.js +1 -1
  289. package/build-module/navigation/item/index.js.map +1 -1
  290. package/build-module/navigation/menu/index.js +1 -1
  291. package/build-module/navigation/menu/index.js.map +1 -1
  292. package/build-module/navigator/navigator-provider/component.js +2 -2
  293. package/build-module/navigator/navigator-provider/component.js.map +1 -1
  294. package/build-module/navigator/navigator-screen/component.js +1 -1
  295. package/build-module/navigator/navigator-screen/component.js.map +1 -1
  296. package/build-module/number-control/index.js +1 -1
  297. package/build-module/number-control/index.js.map +1 -1
  298. package/build-module/panel/body.js +2 -2
  299. package/build-module/panel/body.js.map +1 -1
  300. package/build-module/popover/index.js +3 -3
  301. package/build-module/popover/index.js.map +1 -1
  302. package/build-module/popover/utils.js +6 -6
  303. package/build-module/popover/utils.js.map +1 -1
  304. package/build-module/radio-group/index.js +1 -1
  305. package/build-module/radio-group/index.js.map +1 -1
  306. package/build-module/range-control/styles/range-control-styles.js +29 -29
  307. package/build-module/range-control/styles/range-control-styles.js.map +1 -1
  308. package/build-module/sandbox/index.js +5 -5
  309. package/build-module/sandbox/index.js.map +1 -1
  310. package/build-module/sandbox/index.native.js +1 -1
  311. package/build-module/sandbox/index.native.js.map +1 -1
  312. package/build-module/select-control/index.js +1 -1
  313. package/build-module/select-control/index.js.map +1 -1
  314. package/build-module/select-control/styles/select-control-styles.js +5 -5
  315. package/build-module/select-control/styles/select-control-styles.js.map +1 -1
  316. package/build-module/slot-fill/bubbles-virtually/slot-fill-provider.js +1 -1
  317. package/build-module/slot-fill/bubbles-virtually/slot-fill-provider.js.map +1 -1
  318. package/build-module/slot-fill/bubbles-virtually/slot.js +1 -1
  319. package/build-module/slot-fill/bubbles-virtually/slot.js.map +1 -1
  320. package/build-module/slot-fill/fill.js +1 -1
  321. package/build-module/slot-fill/fill.js.map +1 -1
  322. package/build-module/slot-fill/provider.js +1 -1
  323. package/build-module/slot-fill/provider.js.map +1 -1
  324. package/build-module/snackbar/index.js +1 -1
  325. package/build-module/snackbar/index.js.map +1 -1
  326. package/build-module/snackbar/list.js +1 -1
  327. package/build-module/snackbar/list.js.map +1 -1
  328. package/build-module/style-provider/index.js +2 -2
  329. package/build-module/style-provider/index.js.map +1 -1
  330. package/build-module/toggle-group-control/toggle-group-control/component.js +2 -2
  331. package/build-module/toggle-group-control/toggle-group-control/component.js.map +1 -1
  332. package/build-module/toggle-group-control/toggle-group-control-option/styles.js +8 -8
  333. package/build-module/toggle-group-control/toggle-group-control-option/styles.js.map +1 -1
  334. package/build-module/toolbar/index.js +1 -1
  335. package/build-module/toolbar/index.js.map +1 -1
  336. package/build-module/tooltip/index.js +3 -3
  337. package/build-module/tooltip/index.js.map +1 -1
  338. package/build-module/tooltip/index.native.js +7 -7
  339. package/build-module/tooltip/index.native.js.map +1 -1
  340. package/build-module/truncate/utils.js +1 -1
  341. package/build-module/truncate/utils.js.map +1 -1
  342. package/build-module/ui/context/context-connect.js +9 -16
  343. package/build-module/ui/context/context-connect.js.map +1 -1
  344. package/build-module/ui/context/context-system-provider.js +2 -2
  345. package/build-module/ui/context/context-system-provider.js.map +1 -1
  346. package/build-module/ui/context/index.js.map +1 -1
  347. package/build-module/ui/utils/colors.js +2 -2
  348. package/build-module/ui/utils/colors.js.map +1 -1
  349. package/build-module/ui/utils/space.js +2 -2
  350. package/build-module/ui/utils/space.js.map +1 -1
  351. package/build-module/unit-control/index.js +39 -30
  352. package/build-module/unit-control/index.js.map +1 -1
  353. package/build-module/unit-control/index.native.js +5 -3
  354. package/build-module/unit-control/index.native.js.map +1 -1
  355. package/build-module/unit-control/unit-select-control.js +1 -1
  356. package/build-module/unit-control/unit-select-control.js.map +1 -1
  357. package/build-module/unit-control/utils.js +92 -100
  358. package/build-module/unit-control/utils.js.map +1 -1
  359. package/build-module/utils/breakpoint-values.js +1 -1
  360. package/build-module/utils/breakpoint-values.js.map +1 -1
  361. package/build-module/utils/colors-values.js +1 -1
  362. package/build-module/utils/colors-values.js.map +1 -1
  363. package/build-style/style-rtl.css +8 -0
  364. package/build-style/style.css +8 -0
  365. package/build-types/base-field/hook.d.ts +2 -1
  366. package/build-types/base-field/hook.d.ts.map +1 -1
  367. package/build-types/card/card/hook.d.ts +2 -1
  368. package/build-types/card/card/hook.d.ts.map +1 -1
  369. package/build-types/card/card-body/hook.d.ts +2 -1
  370. package/build-types/card/card-body/hook.d.ts.map +1 -1
  371. package/build-types/card/card-divider/hook.d.ts +2 -2
  372. package/build-types/card/card-footer/hook.d.ts +2 -1
  373. package/build-types/card/card-footer/hook.d.ts.map +1 -1
  374. package/build-types/card/card-header/hook.d.ts +2 -1
  375. package/build-types/card/card-header/hook.d.ts.map +1 -1
  376. package/build-types/card/card-media/hook.d.ts +2 -1
  377. package/build-types/card/card-media/hook.d.ts.map +1 -1
  378. package/build-types/color-picker/styles.d.ts +2 -2
  379. package/build-types/confirm-dialog/component.d.ts +8 -0
  380. package/build-types/confirm-dialog/component.d.ts.map +1 -1
  381. package/build-types/confirm-dialog/types.d.ts +2 -0
  382. package/build-types/confirm-dialog/types.d.ts.map +1 -1
  383. package/build-types/divider/component.d.ts +2 -2
  384. package/build-types/divider/component.d.ts.map +1 -1
  385. package/build-types/divider/stories/index.d.ts +10 -0
  386. package/build-types/divider/stories/index.d.ts.map +1 -0
  387. package/build-types/divider/types.d.ts +1 -1
  388. package/build-types/divider/types.d.ts.map +1 -1
  389. package/build-types/elevation/hook.d.ts +2 -1
  390. package/build-types/elevation/hook.d.ts.map +1 -1
  391. package/build-types/flex/flex/hook.d.ts +2 -1
  392. package/build-types/flex/flex/hook.d.ts.map +1 -1
  393. package/build-types/flex/flex-block/hook.d.ts +2 -1
  394. package/build-types/flex/flex-block/hook.d.ts.map +1 -1
  395. package/build-types/flex/flex-item/hook.d.ts +2 -1
  396. package/build-types/flex/flex-item/hook.d.ts.map +1 -1
  397. package/build-types/flyout/flyout/hook.d.ts +2 -1
  398. package/build-types/flyout/flyout/hook.d.ts.map +1 -1
  399. package/build-types/grid/hook.d.ts +2 -1
  400. package/build-types/grid/hook.d.ts.map +1 -1
  401. package/build-types/h-stack/hook.d.ts +3 -2
  402. package/build-types/h-stack/hook.d.ts.map +1 -1
  403. package/build-types/heading/component.d.ts +3 -3
  404. package/build-types/heading/component.d.ts.map +1 -1
  405. package/build-types/heading/hook.d.ts +2 -1
  406. package/build-types/heading/hook.d.ts.map +1 -1
  407. package/build-types/heading/stories/index.d.ts +12 -0
  408. package/build-types/heading/stories/index.d.ts.map +1 -0
  409. package/build-types/input-control/index.d.ts +1 -1
  410. package/build-types/input-control/index.d.ts.map +1 -1
  411. package/build-types/input-control/input-field.d.ts +1 -1
  412. package/build-types/input-control/input-field.d.ts.map +1 -1
  413. package/build-types/input-control/styles/input-control-styles.d.ts.map +1 -1
  414. package/build-types/item-group/item/hook.d.ts +2 -1
  415. package/build-types/item-group/item/hook.d.ts.map +1 -1
  416. package/build-types/item-group/item-group/hook.d.ts +2 -1
  417. package/build-types/item-group/item-group/hook.d.ts.map +1 -1
  418. package/build-types/navigator/navigator-back-button/hook.d.ts +2 -1
  419. package/build-types/navigator/navigator-back-button/hook.d.ts.map +1 -1
  420. package/build-types/navigator/navigator-button/hook.d.ts +2 -1
  421. package/build-types/navigator/navigator-button/hook.d.ts.map +1 -1
  422. package/build-types/number-control/styles/number-control-styles.d.ts +1 -1
  423. package/build-types/scrollable/hook.d.ts +2 -1
  424. package/build-types/scrollable/hook.d.ts.map +1 -1
  425. package/build-types/select-control/index.d.ts +1 -1
  426. package/build-types/select-control/index.d.ts.map +1 -1
  427. package/build-types/select-control/styles/select-control-styles.d.ts.map +1 -1
  428. package/build-types/spacer/hook.d.ts +2 -1
  429. package/build-types/spacer/hook.d.ts.map +1 -1
  430. package/build-types/surface/hook.d.ts +2 -1
  431. package/build-types/surface/hook.d.ts.map +1 -1
  432. package/build-types/text/hook.d.ts +2 -1
  433. package/build-types/text/hook.d.ts.map +1 -1
  434. package/build-types/text/types.d.ts +1 -2
  435. package/build-types/text/types.d.ts.map +1 -1
  436. package/build-types/toggle-group-control/toggle-group-control-option/styles.d.ts.map +1 -1
  437. package/build-types/tools-panel/tools-panel/hook.d.ts +2 -1
  438. package/build-types/tools-panel/tools-panel/hook.d.ts.map +1 -1
  439. package/build-types/tools-panel/tools-panel-header/hook.d.ts +2 -1
  440. package/build-types/tools-panel/tools-panel-header/hook.d.ts.map +1 -1
  441. package/build-types/tools-panel/tools-panel-item/hook.d.ts +2 -1
  442. package/build-types/tools-panel/tools-panel-item/hook.d.ts.map +1 -1
  443. package/build-types/truncate/hook.d.ts +2 -1
  444. package/build-types/truncate/hook.d.ts.map +1 -1
  445. package/build-types/ui/context/context-connect.d.ts +18 -16
  446. package/build-types/ui/context/context-connect.d.ts.map +1 -1
  447. package/build-types/ui/context/index.d.ts +4 -4
  448. package/build-types/ui/context/index.d.ts.map +1 -1
  449. package/build-types/ui/context/wordpress-component.d.ts +1 -0
  450. package/build-types/ui/context/wordpress-component.d.ts.map +1 -1
  451. package/build-types/ui/control-group/hook.d.ts +2 -1
  452. package/build-types/ui/control-group/hook.d.ts.map +1 -1
  453. package/build-types/ui/control-label/hook.d.ts +2 -1
  454. package/build-types/ui/control-label/hook.d.ts.map +1 -1
  455. package/build-types/ui/form-group/use-form-group.d.ts +6 -4
  456. package/build-types/ui/form-group/use-form-group.d.ts.map +1 -1
  457. package/build-types/unit-control/index.d.ts +3 -3
  458. package/build-types/unit-control/index.d.ts.map +1 -1
  459. package/build-types/unit-control/types.d.ts +4 -6
  460. package/build-types/unit-control/types.d.ts.map +1 -1
  461. package/build-types/unit-control/utils.d.ts +47 -38
  462. package/build-types/unit-control/utils.d.ts.map +1 -1
  463. package/build-types/v-stack/hook.d.ts +2 -1
  464. package/build-types/v-stack/hook.d.ts.map +1 -1
  465. package/package.json +18 -18
  466. package/src/alignment-matrix-control/utils.js +1 -1
  467. package/src/angle-picker-control/angle-circle.js +1 -1
  468. package/src/animation/index.js +0 -1
  469. package/src/autocomplete/get-default-use-items.js +3 -3
  470. package/src/base-field/hook.js +1 -1
  471. package/src/box-control/icon.js +1 -1
  472. package/src/box-control/index.js +5 -5
  473. package/src/box-control/test/index.js +27 -7
  474. package/src/box-control/utils.js +13 -9
  475. package/src/button/index.js +5 -5
  476. package/src/button/index.native.js +7 -7
  477. package/src/button/style.scss +1 -0
  478. package/src/color-palette/style.scss +1 -0
  479. package/src/color-picker/color-display.tsx +1 -1
  480. package/src/color-picker/styles.ts +1 -1
  481. package/src/color-picker/test/index.js +1 -1
  482. package/src/combobox-control/index.js +1 -1
  483. package/src/combobox-control/style.scss +1 -0
  484. package/src/confirm-dialog/README.md +56 -45
  485. package/src/confirm-dialog/component.tsx +4 -2
  486. package/src/confirm-dialog/stories/index.js +19 -0
  487. package/src/confirm-dialog/test/index.js +28 -0
  488. package/src/confirm-dialog/types.ts +2 -0
  489. package/src/date-time/style.scss +4 -0
  490. package/src/date-time/time.js +16 -5
  491. package/src/dimension-control/test/index.test.js +1 -1
  492. package/src/disabled/test/index.js +1 -1
  493. package/src/divider/component.tsx +3 -3
  494. package/src/divider/stories/index.tsx +70 -0
  495. package/src/divider/types.ts +3 -1
  496. package/src/draggable/index.js +3 -3
  497. package/src/draggable/stories/index.js +1 -1
  498. package/src/flyout/flyout/README.md +1 -1
  499. package/src/flyout/test/index.js +1 -1
  500. package/src/focal-point-picker/index.native.js +7 -7
  501. package/src/focal-point-picker/tooltip/index.native.js +1 -1
  502. package/src/font-size-picker/README.md +1 -2
  503. package/src/font-size-picker/index.js +1 -1
  504. package/src/font-size-picker/stories/index.js +87 -108
  505. package/src/form-token-field/index.js +6 -6
  506. package/src/form-token-field/style.scss +1 -0
  507. package/src/form-token-field/suggestions-list.js +2 -2
  508. package/src/form-token-field/test/index.js +6 -6
  509. package/src/heading/component.tsx +4 -4
  510. package/src/heading/hook.ts +1 -1
  511. package/src/heading/stories/index.tsx +37 -0
  512. package/src/higher-order/with-filters/test/index.js +1 -1
  513. package/src/higher-order/with-focus-outside/test/index.js +1 -1
  514. package/src/higher-order/with-notices/index.js +1 -1
  515. package/src/higher-order/with-notices/test/index.js +3 -3
  516. package/src/index.js +4 -4
  517. package/src/index.native.js +4 -4
  518. package/src/input-control/input-base.tsx +1 -1
  519. package/src/input-control/input-field.tsx +12 -9
  520. package/src/input-control/styles/input-control-styles.tsx +1 -0
  521. package/src/input-control/test/index.js +4 -4
  522. package/src/isolated-event-container/index.js +1 -1
  523. package/src/item-group/test/index.js +0 -1
  524. package/src/mobile/bottom-sheet/bottom-sheet-context.native.js +4 -4
  525. package/src/mobile/bottom-sheet/bottom-sheet-navigation/navigation-container.native.js +1 -1
  526. package/src/mobile/bottom-sheet/cell.native.js +1 -1
  527. package/src/mobile/bottom-sheet/index.native.js +11 -11
  528. package/src/mobile/bottom-sheet/link-cell.native.js +1 -1
  529. package/src/mobile/bottom-sheet/link-suggestion-item-cell.native.js +1 -1
  530. package/src/mobile/bottom-sheet/nav-bar/back-button.native.js +1 -1
  531. package/src/mobile/global-styles-context/utils.native.js +10 -10
  532. package/src/mobile/gradient/index.native.js +2 -2
  533. package/src/mobile/html-text-input/container.ios.js +3 -3
  534. package/src/mobile/html-text-input/index.native.js +1 -1
  535. package/src/mobile/html-text-input/test/index.native.js +14 -14
  536. package/src/mobile/image/index.native.js +1 -1
  537. package/src/mobile/keyboard-aware-flat-list/index.android.js +1 -1
  538. package/src/mobile/keyboard-aware-flat-list/index.ios.js +2 -2
  539. package/src/mobile/link-picker/index.native.js +3 -3
  540. package/src/mobile/link-picker/link-picker-results.native.js +8 -8
  541. package/src/mobile/link-settings/image-link-destinations-screen.native.js +2 -2
  542. package/src/mobile/link-settings/index.native.js +1 -2
  543. package/src/mobile/link-settings/test/edit.native.js +15 -15
  544. package/src/modal/aria-helper.js +1 -1
  545. package/src/modal/index.js +2 -2
  546. package/src/navigable-container/container.js +2 -2
  547. package/src/navigable-container/tabbable.js +1 -1
  548. package/src/navigable-container/test/menu.js +5 -5
  549. package/src/navigable-container/test/tabbable.js +2 -2
  550. package/src/navigation/item/index.js +1 -1
  551. package/src/navigation/menu/index.js +1 -1
  552. package/src/navigation/stories/controlled-state.js +2 -2
  553. package/src/navigator/navigator-provider/component.tsx +1 -1
  554. package/src/navigator/navigator-screen/component.tsx +2 -2
  555. package/src/navigator/test/index.js +18 -19
  556. package/src/navigator/types.ts +1 -1
  557. package/src/number-control/index.js +1 -1
  558. package/src/panel/body.js +2 -2
  559. package/src/popover/index.js +3 -3
  560. package/src/popover/utils.js +6 -6
  561. package/src/radio-group/index.js +1 -1
  562. package/src/range-control/stories/index.js +1 -1
  563. package/src/range-control/styles/range-control-styles.js +1 -1
  564. package/src/range-control/test/index.js +2 -2
  565. package/src/sandbox/index.js +5 -5
  566. package/src/sandbox/index.native.js +1 -1
  567. package/src/select-control/index.tsx +1 -1
  568. package/src/select-control/styles/select-control-styles.ts +1 -0
  569. package/src/slot-fill/bubbles-virtually/slot-fill-provider.js +1 -1
  570. package/src/slot-fill/bubbles-virtually/slot.js +1 -2
  571. package/src/slot-fill/fill.js +1 -1
  572. package/src/slot-fill/provider.js +1 -1
  573. package/src/snackbar/index.js +1 -1
  574. package/src/snackbar/list.js +1 -1
  575. package/src/style-provider/index.js +2 -2
  576. package/src/tab-panel/test/index.js +1 -1
  577. package/src/text/test/index.js +2 -2
  578. package/src/text/types.ts +6 -8
  579. package/src/text-highlight/test/index.js +4 -4
  580. package/src/toggle-control/test/index.js +3 -3
  581. package/src/toggle-group-control/test/__snapshots__/index.js.snap +1 -0
  582. package/src/toggle-group-control/toggle-group-control/component.tsx +2 -2
  583. package/src/toggle-group-control/toggle-group-control-option/styles.ts +1 -0
  584. package/src/toolbar/index.js +1 -1
  585. package/src/toolbar-group/test/index.js +2 -2
  586. package/src/tooltip/index.js +3 -3
  587. package/src/tooltip/index.native.js +7 -7
  588. package/src/tooltip/test/index.js +2 -2
  589. package/src/tooltip/test/index.native.js +2 -2
  590. package/src/tree-grid/test/__snapshots__/index.js.snap +1 -1
  591. package/src/tree-grid/test/index.js +71 -39
  592. package/src/truncate/utils.js +1 -1
  593. package/src/ui/context/{context-connect.js → context-connect.ts} +27 -16
  594. package/src/ui/context/context-system-provider.js +2 -2
  595. package/src/ui/context/{index.js → index.ts} +0 -0
  596. package/src/ui/context/wordpress-component.ts +1 -0
  597. package/src/ui/tooltip/test/index.js +4 -4
  598. package/src/ui/utils/colors.js +2 -2
  599. package/src/ui/utils/space.ts +2 -2
  600. package/src/unit-control/README.md +1 -1
  601. package/src/unit-control/index.native.js +5 -3
  602. package/src/unit-control/index.tsx +64 -35
  603. package/src/unit-control/test/index.js +102 -3
  604. package/src/unit-control/test/utils.js +56 -15
  605. package/src/unit-control/types.ts +5 -8
  606. package/src/unit-control/unit-select-control.tsx +1 -1
  607. package/src/unit-control/utils.ts +128 -125
  608. package/src/utils/breakpoint-values.js +1 -1
  609. package/src/utils/colors-values.js +1 -1
  610. package/src/utils/hooks/test/use-controlled-state.js +1 -1
  611. package/src/utils/hooks/test/use-controlled-value.js +3 -3
  612. package/src/utils/hooks/test/use-latest-ref.js +1 -1
  613. package/src/utils/test/math.js +2 -2
  614. package/src/utils/test/rtl.js +12 -12
  615. package/tsconfig.json +1 -1
  616. package/tsconfig.tsbuildinfo +1 -1
  617. package/src/divider/stories/index.js +0 -64
  618. package/src/heading/stories/index.js +0 -24
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/components/src/tooltip/index.native.js"],"names":["RIGHT_ALIGN_ARROW_OFFSET","TOOLTIP_VERTICAL_OFFSET","TooltipContext","onHandleScreenTouch","Fill","Slot","useKeyboardVisibility","keyboardVisible","setKeyboardVisible","previousKeyboardVisible","showListener","Keyboard","addListener","keyboardHideEvent","Platform","select","android","ios","hideListener","remove","Tooltip","children","position","text","visible","initialVisible","referenceElementRef","animationValue","Animated","Value","current","horizontalPosition","split","setVisible","animating","setAnimating","hidden","previousVisible","referenceLayout","setReferenceLayout","height","width","x","y","tooltipLayout","setTooltipLayout","startAnimation","getReferenceElementPosition","frameListener","timing","toValue","duration","useNativeDriver","delay","easing","Easing","out","quad","start","tooltipStyles","styles","tooltip","left","Math","floor","top","tooltipBoxStyles","tooltip__box","elevation","opacity","shadowColor","tooltip__shadow","color","shadowOffset","shadowOpacity","shadowRadius","transform","translateY","interpolate","inputRange","outputRange","arrowStyles","tooltip__arrow","requestAnimationFrame","measure","_x","_y","pageX","pageY","getTooltipLayout","nativeEvent","layout","ref","onLayout","tooltip__text","TooltipSlot","rest","handleScreenTouch","setHandleScreenTouch","callback","handleTouchStart","value","undefined","StyleSheet","absoluteFill"],"mappings":";;;;;;;;;AAgBA;;AAbA;;AAsBA;;AAKA;;AACA;;AA/BA;AACA;A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K,EAAGN,eAAOkC;AAArB,KAAuCvE,IAAvC,CADD,EAEC,4BAAC,iBAAD;AAAM,IAAA,KAAK,EAAG0D;AAAd,IAFD,CADD,CADD,CALD,CADD;AAgBA,CArLD;;AAuLA,MAAMc,WAAW,GAAG,SAA6B;AAAA,MAA3B;AAAE1E,IAAAA,QAAF;AAAY,OAAG2E;AAAf,GAA2B;AAChD,QAAM,CAAEC,iBAAF,EAAqBC,oBAArB,IAA8C,uBAAU,IAAV,CAApD;;AACA,QAAM/F,mBAAmB,GAAKgG,QAAF,IAAgB;AAC3C;AACAD,IAAAA,oBAAoB,CAAE,MAAMC,QAAR,CAApB;AACA,GAHD;;AAIA,QAAMC,gBAAgB,GAAG,MAAM;AAC9BH,IAAAA,iBAAiB;AACjBC,IAAAA,oBAAoB,CAAE,IAAF,CAApB;AACA,GAHD,CANgD,CAUhD;;;AACA,QAAMG,KAAK,GAAG,sBAAS,OAAQ;AAAElG,IAAAA;AAAF,GAAR,CAAT,CAAd;AAEA,SACC,4BAAC,cAAD,CAAgB,QAAhB;AAAyB,IAAA,KAAK,EAAGkG;AAAjC,KACC,4BAAC,iBAAD;AACC,IAAA,YAAY,EACX,OAAOJ,iBAAP,KAA6B,UAA7B,GACGG,gBADH,GAEGE,SAJL;AAMC,IAAA,aAAa,EAAC,UANf;AAOC,IAAA,KAAK,EAAGC,wBAAWC,YAPpB;AAQC,IAAA,MAAM,EAAC;AARR,KAUGnF,QAVH,EAWC,4BAAC,IAAD,EAAW2E,IAAX,CAXD,CADD,CADD;AAiBA,CA9BD;;AAgCA5E,OAAO,CAACf,IAAR,GAAe0F,WAAf;eAEe3E,O","sourcesContent":["/**\n * External dependencies\n */\nimport {\n\tAnimated,\n\tEasing,\n\tKeyboard,\n\tPlatform,\n\tStyleSheet,\n\tText,\n\tView,\n} from 'react-native';\n\n/**\n * WordPress dependencies\n */\nimport {\n\tcloneElement,\n\tcreateContext,\n\tuseContext,\n\tuseEffect,\n\tuseMemo,\n\tuseRef,\n\tuseState,\n} from '@wordpress/element';\nimport { usePrevious } from '@wordpress/compose';\n\n/**\n * Internal dependencies\n */\nimport { createSlotFill } from '../slot-fill';\nimport styles from './style.scss';\n\nconst RIGHT_ALIGN_ARROW_OFFSET = 16;\nconst TOOLTIP_VERTICAL_OFFSET = 2;\n\nconst TooltipContext = createContext( {\n\tonHandleScreenTouch: () => {},\n} );\nconst { Fill, Slot } = createSlotFill( 'Tooltip' );\n\nconst useKeyboardVisibility = () => {\n\tconst [ keyboardVisible, setKeyboardVisible ] = useState( false );\n\tconst previousKeyboardVisible = usePrevious( keyboardVisible );\n\n\tuseEffect( () => {\n\t\tconst showListener = Keyboard.addListener( 'keyboardDidShow', () => {\n\t\t\tif ( previousKeyboardVisible !== true ) {\n\t\t\t\tsetKeyboardVisible( true );\n\t\t\t}\n\t\t} );\n\t\tconst keyboardHideEvent = Platform.select( {\n\t\t\tandroid: 'keyboardDidHide',\n\t\t\tios: 'keyboardWillHide',\n\t\t} );\n\t\tconst hideListener = Keyboard.addListener( keyboardHideEvent, () => {\n\t\t\tif ( previousKeyboardVisible !== false ) {\n\t\t\t\tsetKeyboardVisible( false );\n\t\t\t}\n\t\t} );\n\t\treturn () => {\n\t\t\tshowListener.remove();\n\t\t\thideListener.remove();\n\t\t};\n\t}, [] );\n\n\treturn keyboardVisible;\n};\n\nconst Tooltip = ( {\n\tchildren,\n\tposition = 'top',\n\ttext,\n\tvisible: initialVisible = false,\n} ) => {\n\tconst referenceElementRef = useRef( null );\n\tconst animationValue = useRef( new Animated.Value( 0 ) ).current;\n\tconst [ , horizontalPosition = 'center' ] = position.split( ' ' );\n\tconst [ visible, setVisible ] = useState( initialVisible );\n\tconst [ animating, setAnimating ] = useState( false );\n\tconst hidden = ! visible && ! animating;\n\tconst previousVisible = usePrevious( visible );\n\tconst [ referenceLayout, setReferenceLayout ] = useState( {\n\t\theight: 0,\n\t\twidth: 0,\n\t\tx: 0,\n\t\ty: 0,\n\t} );\n\tconst [ tooltipLayout, setTooltipLayout ] = useState( {\n\t\theight: 0,\n\t\twidth: 0,\n\t} );\n\tconst { onHandleScreenTouch } = useContext( TooltipContext );\n\tconst keyboardVisible = useKeyboardVisibility();\n\n\t// Register callback to dismiss the tooltip whenever the screen is touched\n\tuseEffect( () => {\n\t\tif ( visible ) {\n\t\t\tonHandleScreenTouch( () => {\n\t\t\t\tsetAnimating( true );\n\t\t\t\tsetVisible( false );\n\t\t\t} );\n\t\t}\n\t\treturn () => onHandleScreenTouch( null );\n\t}, [ visible ] );\n\n\t// Manage visibility animation\n\tuseEffect( () => {\n\t\tif (\n\t\t\t// Initial render and visibility enabled, animate show\n\t\t\t( typeof previousVisible === 'undefined' && visible ) ||\n\t\t\t// Previously visible, animate hide\n\t\t\t( previousVisible && previousVisible !== visible )\n\t\t) {\n\t\t\tsetAnimating( true );\n\t\t\tstartAnimation();\n\t\t}\n\t}, [ visible ] );\n\n\t// Manage tooltip visibility and position in relation to keyboard\n\tuseEffect( () => {\n\t\tif ( ! visible ) {\n\t\t\treturn;\n\t\t}\n\n\t\t// Update tooltip position if keyboard is visible\n\t\tif ( keyboardVisible ) {\n\t\t\tgetReferenceElementPosition();\n\t\t}\n\n\t\t// Hide tooltip if keyboard hides\n\t\tif ( typeof previousVisible !== 'undefined' && ! keyboardVisible ) {\n\t\t\tsetAnimating( true );\n\t\t\tsetVisible( false );\n\t\t}\n\t}, [ visible, keyboardVisible ] );\n\n\t// Manage tooltip position during keyboard frame changes\n\tuseEffect( () => {\n\t\tconst frameListener = Keyboard.addListener(\n\t\t\t'keyboardWillChangeFrame',\n\t\t\t() => {\n\t\t\t\tif ( visible ) {\n\t\t\t\t\tgetReferenceElementPosition();\n\t\t\t\t}\n\t\t\t}\n\t\t);\n\n\t\treturn () => {\n\t\t\tframeListener.remove();\n\t\t};\n\t}, [ visible ] );\n\n\tconst startAnimation = () => {\n\t\tAnimated.timing( animationValue, {\n\t\t\ttoValue: visible ? 1 : 0,\n\t\t\tduration: visible ? 300 : 150,\n\t\t\tuseNativeDriver: true,\n\t\t\tdelay: visible ? 500 : 0,\n\t\t\teasing: Easing.out( Easing.quad ),\n\t\t} ).start( () => {\n\t\t\tsetAnimating( false );\n\t\t} );\n\t};\n\n\tconst tooltipStyles = [\n\t\tstyles.tooltip,\n\t\t{\n\t\t\tleft:\n\t\t\t\treferenceLayout.x +\n\t\t\t\tMath.floor( referenceLayout.width / 2 ) -\n\t\t\t\t( horizontalPosition === 'right'\n\t\t\t\t\t? RIGHT_ALIGN_ARROW_OFFSET\n\t\t\t\t\t: Math.floor( tooltipLayout.width / 2 ) ),\n\t\t\ttop:\n\t\t\t\treferenceLayout.y -\n\t\t\t\ttooltipLayout.height -\n\t\t\t\tTOOLTIP_VERTICAL_OFFSET,\n\t\t},\n\t];\n\tconst tooltipBoxStyles = [\n\t\tstyles.tooltip__box,\n\t\thorizontalPosition === 'right' && styles[ 'tooltip--rightAlign' ],\n\t\t{\n\t\t\televation: 2,\n\t\t\topacity: animationValue,\n\t\t\tshadowColor: styles.tooltip__shadow?.color,\n\t\t\tshadowOffset: { height: 2, width: 0 },\n\t\t\tshadowOpacity: 0.25,\n\t\t\tshadowRadius: 2,\n\t\t\ttransform: [\n\t\t\t\t{\n\t\t\t\t\ttranslateY: animationValue.interpolate( {\n\t\t\t\t\t\tinputRange: [ 0, 1 ],\n\t\t\t\t\t\toutputRange: [ visible ? 4 : -8, -8 ],\n\t\t\t\t\t} ),\n\t\t\t\t},\n\t\t\t],\n\t\t},\n\t];\n\tconst arrowStyles = [\n\t\tstyles.tooltip__arrow,\n\t\thorizontalPosition === 'right' &&\n\t\t\tstyles[ 'tooltip__arrow--rightAlign' ],\n\t];\n\n\tconst getReferenceElementPosition = () => {\n\t\t// rAF allows render to complete before calculating layout\n\t\t// eslint-disable-next-line no-undef\n\t\trequestAnimationFrame( () => {\n\t\t\tif ( ! referenceElementRef.current ) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\treferenceElementRef.current.measure(\n\t\t\t\t( _x, _y, width, height, pageX, pageY ) => {\n\t\t\t\t\tsetReferenceLayout( {\n\t\t\t\t\t\theight,\n\t\t\t\t\t\twidth,\n\t\t\t\t\t\tx: pageX,\n\t\t\t\t\t\ty: pageY,\n\t\t\t\t\t} );\n\t\t\t\t}\n\t\t\t);\n\t\t} );\n\t};\n\tconst getTooltipLayout = ( { nativeEvent } ) => {\n\t\tconst { height, width } = nativeEvent.layout;\n\t\tsetTooltipLayout( { height, width } );\n\t};\n\n\tif ( hidden ) {\n\t\treturn children;\n\t}\n\n\treturn (\n\t\t<>\n\t\t\t{ cloneElement( children, {\n\t\t\t\tref: referenceElementRef,\n\t\t\t\tonLayout: getReferenceElementPosition,\n\t\t\t} ) }\n\t\t\t<Fill>\n\t\t\t\t<View onLayout={ getTooltipLayout } style={ tooltipStyles }>\n\t\t\t\t\t<Animated.View style={ tooltipBoxStyles }>\n\t\t\t\t\t\t<Text style={ styles.tooltip__text }>{ text }</Text>\n\t\t\t\t\t\t<View style={ arrowStyles } />\n\t\t\t\t\t</Animated.View>\n\t\t\t\t</View>\n\t\t\t</Fill>\n\t\t</>\n\t);\n};\n\nconst TooltipSlot = ( { children, ...rest } ) => {\n\tconst [ handleScreenTouch, setHandleScreenTouch ] = useState( null );\n\tconst onHandleScreenTouch = ( callback ) => {\n\t\t// Must use function to set state below as `callback` is a function itself\n\t\tsetHandleScreenTouch( () => callback );\n\t};\n\tconst handleTouchStart = () => {\n\t\thandleScreenTouch();\n\t\tsetHandleScreenTouch( null );\n\t};\n\t// Memoize context value to avoid unnecessary rerenders of the Provider's children\n\tconst value = useMemo( () => ( { onHandleScreenTouch } ) );\n\n\treturn (\n\t\t<TooltipContext.Provider value={ value }>\n\t\t\t<View\n\t\t\t\tonTouchStart={\n\t\t\t\t\ttypeof handleScreenTouch === 'function'\n\t\t\t\t\t\t? handleTouchStart\n\t\t\t\t\t\t: undefined\n\t\t\t\t}\n\t\t\t\tpointerEvents=\"box-none\"\n\t\t\t\tstyle={ StyleSheet.absoluteFill }\n\t\t\t\ttestID=\"tooltip-overlay\"\n\t\t\t>\n\t\t\t\t{ children }\n\t\t\t\t<Slot { ...rest } />\n\t\t\t</View>\n\t\t</TooltipContext.Provider>\n\t);\n};\n\nTooltip.Slot = TooltipSlot;\n\nexport default Tooltip;\n"]}
1
+ {"version":3,"sources":["@wordpress/components/src/tooltip/index.native.js"],"names":["RIGHT_ALIGN_ARROW_OFFSET","TOOLTIP_VERTICAL_OFFSET","TooltipContext","onHandleScreenTouch","Fill","Slot","useKeyboardVisibility","keyboardVisible","setKeyboardVisible","previousKeyboardVisible","showListener","Keyboard","addListener","keyboardHideEvent","Platform","select","android","ios","hideListener","remove","Tooltip","children","position","text","visible","initialVisible","referenceElementRef","animationValue","Animated","Value","current","horizontalPosition","split","setVisible","animating","setAnimating","hidden","previousVisible","referenceLayout","setReferenceLayout","height","width","x","y","tooltipLayout","setTooltipLayout","startAnimation","getReferenceElementPosition","frameListener","timing","toValue","duration","useNativeDriver","delay","easing","Easing","out","quad","start","tooltipStyles","styles","tooltip","left","Math","floor","top","tooltipBoxStyles","tooltip__box","elevation","opacity","shadowColor","tooltip__shadow","color","shadowOffset","shadowOpacity","shadowRadius","transform","translateY","interpolate","inputRange","outputRange","arrowStyles","tooltip__arrow","requestAnimationFrame","measure","_x","_y","pageX","pageY","getTooltipLayout","nativeEvent","layout","ref","onLayout","tooltip__text","TooltipSlot","rest","handleScreenTouch","setHandleScreenTouch","callback","handleTouchStart","value","undefined","StyleSheet","absoluteFill"],"mappings":";;;;;;;;;AAgBA;;AAbA;;AAsBA;;AAKA;;AACA;;AA/BA;AACA;AACA;;AAWA;AACA;AACA;;AAYA;AACA;AACA;AAIA,MAAMA,wBAAwB,GAAG,EAAjC;AACA,MAAMC,uBAAuB,GAAG,CAAhC;AAEA,MAAMC,cAAc,GAAG,4BAAe;AACrCC,EAAAA,mBAAmB,EAAE,MAAM,CAAE;AADQ,CAAf,CAAvB;AAGA,MAAM;AAAEC,EAAAA,IAAF;AAA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AAChD,QAAM,CAAEC,iBAAF,EAAqBC,oBAArB,IAA8C,uBAAU,IAAV,CAApD;;AACA,QAAM/F,mBAAmB,GAAKgG,QAAF,IAAgB;AAC3C;AACAD,IAAAA,oBAAoB,CAAE,MAAMC,QAAR,CAApB;AACA,GAHD;;AAIA,QAAMC,gBAAgB,GAAG,MAAM;AAC9BH,IAAAA,iBAAiB;AACjBC,IAAAA,oBAAoB,CAAE,IAAF,CAApB;AACA,GAHD,CANgD,CAUhD;;;AACA,QAAMG,KAAK,GAAG,sBAAS,OAAQ;AAAElG,IAAAA;AAAF,GAAR,CAAT,CAAd;AAEA,SACC,4BAAC,cAAD,CAAgB,QAAhB;AAAyB,IAAA,KAAK,EAAGkG;AAAjC,KACC,4BAAC,iBAAD;AACC,IAAA,YAAY,EACX,OAAOJ,iBAAP,KAA6B,UAA7B,GACGG,gBADH,GAEGE,SAJL;AAMC,IAAA,aAAa,EAAC,UANf;AAOC,IAAA,KAAK,EAAGC,wBAAWC,YAPpB;AAQC,IAAA,MAAM,EAAC;AARR,KAUGnF,QAVH,EAWC,4BAAC,IAAD,EAAW2E,IAAX,CAXD,CADD,CADD;AAiBA,CA9BD;;AAgCA5E,OAAO,CAACf,IAAR,GAAe0F,WAAf;eAEe3E,O","sourcesContent":["/**\n * External dependencies\n */\nimport {\n\tAnimated,\n\tEasing,\n\tKeyboard,\n\tPlatform,\n\tStyleSheet,\n\tText,\n\tView,\n} from 'react-native';\n\n/**\n * WordPress dependencies\n */\nimport {\n\tcloneElement,\n\tcreateContext,\n\tuseContext,\n\tuseEffect,\n\tuseMemo,\n\tuseRef,\n\tuseState,\n} from '@wordpress/element';\nimport { usePrevious } from '@wordpress/compose';\n\n/**\n * Internal dependencies\n */\nimport { createSlotFill } from '../slot-fill';\nimport styles from './style.scss';\n\nconst RIGHT_ALIGN_ARROW_OFFSET = 16;\nconst TOOLTIP_VERTICAL_OFFSET = 2;\n\nconst TooltipContext = createContext( {\n\tonHandleScreenTouch: () => {},\n} );\nconst { Fill, Slot } = createSlotFill( 'Tooltip' );\n\nconst useKeyboardVisibility = () => {\n\tconst [ keyboardVisible, setKeyboardVisible ] = useState( false );\n\tconst previousKeyboardVisible = usePrevious( keyboardVisible );\n\n\tuseEffect( () => {\n\t\tconst showListener = Keyboard.addListener( 'keyboardDidShow', () => {\n\t\t\tif ( previousKeyboardVisible !== true ) {\n\t\t\t\tsetKeyboardVisible( true );\n\t\t\t}\n\t\t} );\n\t\tconst keyboardHideEvent = Platform.select( {\n\t\t\tandroid: 'keyboardDidHide',\n\t\t\tios: 'keyboardWillHide',\n\t\t} );\n\t\tconst hideListener = Keyboard.addListener( keyboardHideEvent, () => {\n\t\t\tif ( previousKeyboardVisible !== false ) {\n\t\t\t\tsetKeyboardVisible( false );\n\t\t\t}\n\t\t} );\n\t\treturn () => {\n\t\t\tshowListener.remove();\n\t\t\thideListener.remove();\n\t\t};\n\t}, [] );\n\n\treturn keyboardVisible;\n};\n\nconst Tooltip = ( {\n\tchildren,\n\tposition = 'top',\n\ttext,\n\tvisible: initialVisible = false,\n} ) => {\n\tconst referenceElementRef = useRef( null );\n\tconst animationValue = useRef( new Animated.Value( 0 ) ).current;\n\tconst [ , horizontalPosition = 'center' ] = position.split( ' ' );\n\tconst [ visible, setVisible ] = useState( initialVisible );\n\tconst [ animating, setAnimating ] = useState( false );\n\tconst hidden = ! visible && ! animating;\n\tconst previousVisible = usePrevious( visible );\n\tconst [ referenceLayout, setReferenceLayout ] = useState( {\n\t\theight: 0,\n\t\twidth: 0,\n\t\tx: 0,\n\t\ty: 0,\n\t} );\n\tconst [ tooltipLayout, setTooltipLayout ] = useState( {\n\t\theight: 0,\n\t\twidth: 0,\n\t} );\n\tconst { onHandleScreenTouch } = useContext( TooltipContext );\n\tconst keyboardVisible = useKeyboardVisibility();\n\n\t// Register callback to dismiss the tooltip whenever the screen is touched.\n\tuseEffect( () => {\n\t\tif ( visible ) {\n\t\t\tonHandleScreenTouch( () => {\n\t\t\t\tsetAnimating( true );\n\t\t\t\tsetVisible( false );\n\t\t\t} );\n\t\t}\n\t\treturn () => onHandleScreenTouch( null );\n\t}, [ visible ] );\n\n\t// Manage visibility animation.\n\tuseEffect( () => {\n\t\tif (\n\t\t\t// Initial render and visibility enabled, animate show.\n\t\t\t( typeof previousVisible === 'undefined' && visible ) ||\n\t\t\t// Previously visible, animate hide\n\t\t\t( previousVisible && previousVisible !== visible )\n\t\t) {\n\t\t\tsetAnimating( true );\n\t\t\tstartAnimation();\n\t\t}\n\t}, [ visible ] );\n\n\t// Manage tooltip visibility and position in relation to keyboard.\n\tuseEffect( () => {\n\t\tif ( ! visible ) {\n\t\t\treturn;\n\t\t}\n\n\t\t// Update tooltip position if keyboard is visible.\n\t\tif ( keyboardVisible ) {\n\t\t\tgetReferenceElementPosition();\n\t\t}\n\n\t\t// Hide tooltip if keyboard hides\n\t\tif ( typeof previousVisible !== 'undefined' && ! keyboardVisible ) {\n\t\t\tsetAnimating( true );\n\t\t\tsetVisible( false );\n\t\t}\n\t}, [ visible, keyboardVisible ] );\n\n\t// Manage tooltip position during keyboard frame changes.\n\tuseEffect( () => {\n\t\tconst frameListener = Keyboard.addListener(\n\t\t\t'keyboardWillChangeFrame',\n\t\t\t() => {\n\t\t\t\tif ( visible ) {\n\t\t\t\t\tgetReferenceElementPosition();\n\t\t\t\t}\n\t\t\t}\n\t\t);\n\n\t\treturn () => {\n\t\t\tframeListener.remove();\n\t\t};\n\t}, [ visible ] );\n\n\tconst startAnimation = () => {\n\t\tAnimated.timing( animationValue, {\n\t\t\ttoValue: visible ? 1 : 0,\n\t\t\tduration: visible ? 300 : 150,\n\t\t\tuseNativeDriver: true,\n\t\t\tdelay: visible ? 500 : 0,\n\t\t\teasing: Easing.out( Easing.quad ),\n\t\t} ).start( () => {\n\t\t\tsetAnimating( false );\n\t\t} );\n\t};\n\n\tconst tooltipStyles = [\n\t\tstyles.tooltip,\n\t\t{\n\t\t\tleft:\n\t\t\t\treferenceLayout.x +\n\t\t\t\tMath.floor( referenceLayout.width / 2 ) -\n\t\t\t\t( horizontalPosition === 'right'\n\t\t\t\t\t? RIGHT_ALIGN_ARROW_OFFSET\n\t\t\t\t\t: Math.floor( tooltipLayout.width / 2 ) ),\n\t\t\ttop:\n\t\t\t\treferenceLayout.y -\n\t\t\t\ttooltipLayout.height -\n\t\t\t\tTOOLTIP_VERTICAL_OFFSET,\n\t\t},\n\t];\n\tconst tooltipBoxStyles = [\n\t\tstyles.tooltip__box,\n\t\thorizontalPosition === 'right' && styles[ 'tooltip--rightAlign' ],\n\t\t{\n\t\t\televation: 2,\n\t\t\topacity: animationValue,\n\t\t\tshadowColor: styles.tooltip__shadow?.color,\n\t\t\tshadowOffset: { height: 2, width: 0 },\n\t\t\tshadowOpacity: 0.25,\n\t\t\tshadowRadius: 2,\n\t\t\ttransform: [\n\t\t\t\t{\n\t\t\t\t\ttranslateY: animationValue.interpolate( {\n\t\t\t\t\t\tinputRange: [ 0, 1 ],\n\t\t\t\t\t\toutputRange: [ visible ? 4 : -8, -8 ],\n\t\t\t\t\t} ),\n\t\t\t\t},\n\t\t\t],\n\t\t},\n\t];\n\tconst arrowStyles = [\n\t\tstyles.tooltip__arrow,\n\t\thorizontalPosition === 'right' &&\n\t\t\tstyles[ 'tooltip__arrow--rightAlign' ],\n\t];\n\n\tconst getReferenceElementPosition = () => {\n\t\t// rAF allows render to complete before calculating layout\n\t\t// eslint-disable-next-line no-undef\n\t\trequestAnimationFrame( () => {\n\t\t\tif ( ! referenceElementRef.current ) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\treferenceElementRef.current.measure(\n\t\t\t\t( _x, _y, width, height, pageX, pageY ) => {\n\t\t\t\t\tsetReferenceLayout( {\n\t\t\t\t\t\theight,\n\t\t\t\t\t\twidth,\n\t\t\t\t\t\tx: pageX,\n\t\t\t\t\t\ty: pageY,\n\t\t\t\t\t} );\n\t\t\t\t}\n\t\t\t);\n\t\t} );\n\t};\n\tconst getTooltipLayout = ( { nativeEvent } ) => {\n\t\tconst { height, width } = nativeEvent.layout;\n\t\tsetTooltipLayout( { height, width } );\n\t};\n\n\tif ( hidden ) {\n\t\treturn children;\n\t}\n\n\treturn (\n\t\t<>\n\t\t\t{ cloneElement( children, {\n\t\t\t\tref: referenceElementRef,\n\t\t\t\tonLayout: getReferenceElementPosition,\n\t\t\t} ) }\n\t\t\t<Fill>\n\t\t\t\t<View onLayout={ getTooltipLayout } style={ tooltipStyles }>\n\t\t\t\t\t<Animated.View style={ tooltipBoxStyles }>\n\t\t\t\t\t\t<Text style={ styles.tooltip__text }>{ text }</Text>\n\t\t\t\t\t\t<View style={ arrowStyles } />\n\t\t\t\t\t</Animated.View>\n\t\t\t\t</View>\n\t\t\t</Fill>\n\t\t</>\n\t);\n};\n\nconst TooltipSlot = ( { children, ...rest } ) => {\n\tconst [ handleScreenTouch, setHandleScreenTouch ] = useState( null );\n\tconst onHandleScreenTouch = ( callback ) => {\n\t\t// Must use function to set state below as `callback` is a function itself.\n\t\tsetHandleScreenTouch( () => callback );\n\t};\n\tconst handleTouchStart = () => {\n\t\thandleScreenTouch();\n\t\tsetHandleScreenTouch( null );\n\t};\n\t// Memoize context value to avoid unnecessary rerenders of the Provider's children\n\tconst value = useMemo( () => ( { onHandleScreenTouch } ) );\n\n\treturn (\n\t\t<TooltipContext.Provider value={ value }>\n\t\t\t<View\n\t\t\t\tonTouchStart={\n\t\t\t\t\ttypeof handleScreenTouch === 'function'\n\t\t\t\t\t\t? handleTouchStart\n\t\t\t\t\t\t: undefined\n\t\t\t\t}\n\t\t\t\tpointerEvents=\"box-none\"\n\t\t\t\tstyle={ StyleSheet.absoluteFill }\n\t\t\t\ttestID=\"tooltip-overlay\"\n\t\t\t>\n\t\t\t\t{ children }\n\t\t\t\t<Slot { ...rest } />\n\t\t\t</View>\n\t\t</TooltipContext.Provider>\n\t);\n};\n\nTooltip.Slot = TooltipSlot;\n\nexport default Tooltip;\n"]}
@@ -47,7 +47,7 @@ function truncateMiddle(word, headLength, tailLength, ellipsis) {
47
47
  const wordLength = word.length; // Setting default values
48
48
  // eslint-disable-next-line no-bitwise
49
49
 
50
- const frontLength = ~~headLength; // will cast to integer
50
+ const frontLength = ~~headLength; // Will cast to integer
51
51
  // eslint-disable-next-line no-bitwise
52
52
 
53
53
  const backLength = ~~tailLength;
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/components/src/truncate/utils.js"],"names":["TRUNCATE_ELLIPSIS","TRUNCATE_TYPE","auto","head","middle","tail","none","TRUNCATE_DEFAULT_PROPS","ellipsis","ellipsizeMode","limit","numberOfLines","truncateMiddle","word","headLength","tailLength","wordLength","length","frontLength","backLength","truncateStr","slice","truncateContent","words","props","mergedProps","truncateHead","truncateTail","Math","floor","truncatedContent"],"mappings":";;;;;;;;;AAGA;;AAHA;AACA;AACA;AAGO,MAAMA,iBAAiB,GAAG,GAA1B;;AACA,MAAMC,aAAa,GAAG;AAC5BC,EAAAA,IAAI,EAAE,MADsB;AAE5BC,EAAAA,IAAI,EAAE,MAFsB;AAG5BC,EAAAA,MAAM,EAAE,QAHoB;AAI5BC,EAAAA,IAAI,EAAE,MAJsB;AAK5BC,EAAAA,IAAI,EAAE;AALsB,CAAtB;;AAQA,MAAMC,sBAAsB,GAAG;AACrCC,EAAAA,QAAQ,EAAER,iBAD2B;AAErCS,EAAAA,aAAa,EAAER,aAAa,CAACC,IAFQ;AAGrCQ,EAAAA,KAAK,EAAE,CAH8B;AAIrCC,EAAAA,aAAa,EAAE;AAJsB,CAA/B,C,CAOP;AACA;;AACA;AACA;AACA;AACA;AACA;AACA;;;;AACO,SAASC,cAAT,CAAyBC,IAAzB,EAA+BC,UAA/B,EAA2CC,UAA3C,EAAuDP,QAAvD,EAAkE;AACxE,MAAK,OAAOK,IAAP,KAAgB,QAArB,EAAgC;AAC/B,WAAO,EAAP;AACA;;AACD,QAAMG,UAAU,GAAGH,IAAI,CAACI,MAAxB,CAJwE,CAKxE;AACA;;AACA,QAAMC,WAAW,GAAG,CAAC,CAACJ,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ACAiB,MAAAA,YAAY,GAAGC,IAAI,CAACC,KAAL,CAAYnB,KAAK,GAAG,CAApB,CAAf;AACA;;AACD;AACCgB,MAAAA,YAAY,GAAGhB,KAAf;AACAiB,MAAAA,YAAY,GAAG,CAAf;AAXF;;AAcA,QAAMG,gBAAgB,GACrBrB,aAAa,KAAKR,aAAa,CAACC,IAAhC,GACGU,cAAc,CAAEW,KAAF,EAASG,YAAT,EAAuBC,YAAvB,EAAqCnB,QAArC,CADjB,GAEGe,KAHJ;AAKA,SAAOO,gBAAP;AACA","sourcesContent":["/**\n * External dependencies\n */\nimport { isNil } from 'lodash';\n\nexport const TRUNCATE_ELLIPSIS = '…';\nexport const TRUNCATE_TYPE = {\n\tauto: 'auto',\n\thead: 'head',\n\tmiddle: 'middle',\n\ttail: 'tail',\n\tnone: 'none',\n};\n\nexport const TRUNCATE_DEFAULT_PROPS = {\n\tellipsis: TRUNCATE_ELLIPSIS,\n\tellipsizeMode: TRUNCATE_TYPE.auto,\n\tlimit: 0,\n\tnumberOfLines: 0,\n};\n\n// Source\n// https://github.com/kahwee/truncate-middle\n/**\n * @param {string} word\n * @param {number} headLength\n * @param {number} tailLength\n * @param {string} ellipsis\n */\nexport function truncateMiddle( word, headLength, tailLength, ellipsis ) {\n\tif ( typeof word !== 'string' ) {\n\t\treturn '';\n\t}\n\tconst wordLength = word.length;\n\t// Setting default values\n\t// eslint-disable-next-line no-bitwise\n\tconst frontLength = ~~headLength; // will cast to integer\n\t// eslint-disable-next-line no-bitwise\n\tconst backLength = ~~tailLength;\n\t/* istanbul ignore next */\n\tconst truncateStr = ! isNil( ellipsis ) ? ellipsis : TRUNCATE_ELLIPSIS;\n\n\tif (\n\t\t( frontLength === 0 && backLength === 0 ) ||\n\t\tfrontLength >= wordLength ||\n\t\tbackLength >= wordLength ||\n\t\tfrontLength + backLength >= wordLength\n\t) {\n\t\treturn word;\n\t} else if ( backLength === 0 ) {\n\t\treturn word.slice( 0, frontLength ) + truncateStr;\n\t}\n\treturn (\n\t\tword.slice( 0, frontLength ) +\n\t\ttruncateStr +\n\t\tword.slice( wordLength - backLength )\n\t);\n}\n\n/**\n *\n * @param {string} words\n * @param {typeof TRUNCATE_DEFAULT_PROPS} props\n */\nexport function truncateContent( words = '', props ) {\n\tconst mergedProps = { ...TRUNCATE_DEFAULT_PROPS, ...props };\n\tconst { ellipsis, ellipsizeMode, limit } = mergedProps;\n\n\tif ( ellipsizeMode === TRUNCATE_TYPE.none ) {\n\t\treturn words;\n\t}\n\n\tlet truncateHead;\n\tlet truncateTail;\n\n\tswitch ( ellipsizeMode ) {\n\t\tcase TRUNCATE_TYPE.head:\n\t\t\ttruncateHead = 0;\n\t\t\ttruncateTail = limit;\n\t\t\tbreak;\n\t\tcase TRUNCATE_TYPE.middle:\n\t\t\ttruncateHead = Math.floor( limit / 2 );\n\t\t\ttruncateTail = Math.floor( limit / 2 );\n\t\t\tbreak;\n\t\tdefault:\n\t\t\ttruncateHead = limit;\n\t\t\ttruncateTail = 0;\n\t}\n\n\tconst truncatedContent =\n\t\tellipsizeMode !== TRUNCATE_TYPE.auto\n\t\t\t? truncateMiddle( words, truncateHead, truncateTail, ellipsis )\n\t\t\t: words;\n\n\treturn truncatedContent;\n}\n"]}
1
+ {"version":3,"sources":["@wordpress/components/src/truncate/utils.js"],"names":["TRUNCATE_ELLIPSIS","TRUNCATE_TYPE","auto","head","middle","tail","none","TRUNCATE_DEFAULT_PROPS","ellipsis","ellipsizeMode","limit","numberOfLines","truncateMiddle","word","headLength","tailLength","wordLength","length","frontLength","backLength","truncateStr","slice","truncateContent","words","props","mergedProps","truncateHead","truncateTail","Math","floor","truncatedContent"],"mappings":";;;;;;;;;AAGA;;AAHA;AACA;AACA;AAGO,MAAMA,iBAAiB,GAAG,GAA1B;;AACA,MAAMC,aAAa,GAAG;AAC5BC,EAAAA,IAAI,EAAE,MADsB;AAE5BC,EAAAA,IAAI,EAAE,MAFsB;AAG5BC,EAAAA,MAAM,EAAE,QAHoB;AAI5BC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KAAoB,uEAAZ,EAAY;AAAA,MAARC,KAAQ;AACpD,QAAMC,WAAW,GAAG,EAAE,GAAGlB,sBAAL;AAA6B,OAAGiB;AAAhC,GAApB;AACA,QAAM;AAAEhB,IAAAA,QAAF;AAAYC,IAAAA,aAAZ;AAA2BC,IAAAA;AAA3B,MAAqCe,WAA3C;;AAEA,MAAKhB,aAAa,KAAKR,aAAa,CAACK,IAArC,EAA4C;AAC3C,WAAOiB,KAAP;AACA;;AAED,MAAIG,YAAJ;AACA,MAAIC,YAAJ;;AAEA,UAASlB,aAAT;AACC,SAAKR,aAAa,CAACE,IAAnB;AACCuB,MAAAA,YAAY,GAAG,CAAf;AACAC,MAAAA,YAAY,GAAGjB,KAAf;AACA;;AACD,SAAKT,aAAa,CAACG,MAAnB;AACCsB,MAAAA,YAAY,GAAGE,IAAI,CAACC,KAAL,CAAYnB,KAAK,GAAG,CAApB,CAAf;AACAiB,MAAAA,YAAY,GAAGC,IAAI,CAACC,KAAL,CAAYnB,KAAK,GAAG,CAApB,CAAf;AACA;;AACD;AACCgB,MAAAA,YAAY,GAAGhB,KAAf;AACAiB,MAAAA,YAAY,GAAG,CAAf;AAXF;;AAcA,QAAMG,gBAAgB,GACrBrB,aAAa,KAAKR,aAAa,CAACC,IAAhC,GACGU,cAAc,CAAEW,KAAF,EAASG,YAAT,EAAuBC,YAAvB,EAAqCnB,QAArC,CADjB,GAEGe,KAHJ;AAKA,SAAOO,gBAAP;AACA","sourcesContent":["/**\n * External dependencies\n */\nimport { isNil } from 'lodash';\n\nexport const TRUNCATE_ELLIPSIS = '…';\nexport const TRUNCATE_TYPE = {\n\tauto: 'auto',\n\thead: 'head',\n\tmiddle: 'middle',\n\ttail: 'tail',\n\tnone: 'none',\n};\n\nexport const TRUNCATE_DEFAULT_PROPS = {\n\tellipsis: TRUNCATE_ELLIPSIS,\n\tellipsizeMode: TRUNCATE_TYPE.auto,\n\tlimit: 0,\n\tnumberOfLines: 0,\n};\n\n// Source\n// https://github.com/kahwee/truncate-middle\n/**\n * @param {string} word\n * @param {number} headLength\n * @param {number} tailLength\n * @param {string} ellipsis\n */\nexport function truncateMiddle( word, headLength, tailLength, ellipsis ) {\n\tif ( typeof word !== 'string' ) {\n\t\treturn '';\n\t}\n\tconst wordLength = word.length;\n\t// Setting default values\n\t// eslint-disable-next-line no-bitwise\n\tconst frontLength = ~~headLength; // Will cast to integer\n\t// eslint-disable-next-line no-bitwise\n\tconst backLength = ~~tailLength;\n\t/* istanbul ignore next */\n\tconst truncateStr = ! isNil( ellipsis ) ? ellipsis : TRUNCATE_ELLIPSIS;\n\n\tif (\n\t\t( frontLength === 0 && backLength === 0 ) ||\n\t\tfrontLength >= wordLength ||\n\t\tbackLength >= wordLength ||\n\t\tfrontLength + backLength >= wordLength\n\t) {\n\t\treturn word;\n\t} else if ( backLength === 0 ) {\n\t\treturn word.slice( 0, frontLength ) + truncateStr;\n\t}\n\treturn (\n\t\tword.slice( 0, frontLength ) +\n\t\ttruncateStr +\n\t\tword.slice( wordLength - backLength )\n\t);\n}\n\n/**\n *\n * @param {string} words\n * @param {typeof TRUNCATE_DEFAULT_PROPS} props\n */\nexport function truncateContent( words = '', props ) {\n\tconst mergedProps = { ...TRUNCATE_DEFAULT_PROPS, ...props };\n\tconst { ellipsis, ellipsizeMode, limit } = mergedProps;\n\n\tif ( ellipsizeMode === TRUNCATE_TYPE.none ) {\n\t\treturn words;\n\t}\n\n\tlet truncateHead;\n\tlet truncateTail;\n\n\tswitch ( ellipsizeMode ) {\n\t\tcase TRUNCATE_TYPE.head:\n\t\t\ttruncateHead = 0;\n\t\t\ttruncateTail = limit;\n\t\t\tbreak;\n\t\tcase TRUNCATE_TYPE.middle:\n\t\t\ttruncateHead = Math.floor( limit / 2 );\n\t\t\ttruncateTail = Math.floor( limit / 2 );\n\t\t\tbreak;\n\t\tdefault:\n\t\t\ttruncateHead = limit;\n\t\t\ttruncateTail = 0;\n\t}\n\n\tconst truncatedContent =\n\t\tellipsizeMode !== TRUNCATE_TYPE.auto\n\t\t\t? truncateMiddle( words, truncateHead, truncateTail, ellipsis )\n\t\t\t: words;\n\n\treturn truncatedContent;\n}\n"]}
@@ -31,8 +31,6 @@ var _getStyledClassNameFromKey = require("./get-styled-class-name-from-key");
31
31
  * Internal dependencies
32
32
  */
33
33
 
34
- /* eslint-disable jsdoc/valid-types */
35
-
36
34
  /**
37
35
  * Forwards ref (React.ForwardRef) and "Connects" (or registers) a component
38
36
  * within the Context system under a specified namespace.
@@ -41,17 +39,13 @@ var _getStyledClassNameFromKey = require("./get-styled-class-name-from-key");
41
39
  * The hope is that we can improve render performance by removing functional
42
40
  * component wrappers.
43
41
  *
44
- * @template {import('./wordpress-component').WordPressComponentProps<{}, any, any>} P
45
- * @param {(props: P, ref: import('react').Ref<any>) => JSX.Element | null} Component The component to register into the Context system.
46
- * @param {string} namespace The namespace to register the component under.
47
- * @param {Object} options
48
- * @param {boolean} [options.memo=false]
49
- * @return {import('./wordpress-component').WordPressComponentFromProps<P>} The connected WordPressComponent
42
+ * @param Component The component to register into the Context system.
43
+ * @param namespace The namespace to register the component under.
44
+ * @param options
45
+ * @return The connected WordPressComponent
50
46
  */
51
47
  function contextConnect(Component, namespace) {
52
48
  let options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
53
-
54
- /* eslint-enable jsdoc/valid-types */
55
49
  const {
56
50
  memo: memoProp = false
57
51
  } = options;
@@ -91,8 +85,8 @@ function contextConnect(Component, namespace) {
91
85
  /**
92
86
  * Attempts to retrieve the connected namespace from a component.
93
87
  *
94
- * @param {import('react').ReactChild | undefined | {}} Component The component to retrieve a namespace from.
95
- * @return {Array<string>} The connected namespaces.
88
+ * @param Component The component to retrieve a namespace from.
89
+ * @return The connected namespaces.
96
90
  */
97
91
 
98
92
 
@@ -116,9 +110,8 @@ function getConnectNamespace(Component) {
116
110
  /**
117
111
  * Checks to see if a component is connected within the Context system.
118
112
  *
119
- * @param {import('react').ReactNode} Component The component to retrieve a namespace from.
120
- * @param {Array<string>|string} match The namespace to check.
121
- * @return {boolean} The result.
113
+ * @param Component The component to retrieve a namespace from.
114
+ * @param match The namespace to check.
122
115
  */
123
116
 
124
117
 
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/components/src/ui/context/context-connect.js"],"names":["contextConnect","Component","namespace","options","memo","memoProp","WrappedComponent","mergedNamespace","CONNECT_STATIC_NAMESPACE","Array","isArray","displayName","selector","getConnectNamespace","namespaces","type","hasConnectNamespace","match","includes","some","result"],"mappings":";;;;;;;;;;;AAGA;;AAKA;;AACA;;AAKA;;AACA;;AAfA;AACA;AACA;;AAGA;AACA;AACA;;AAIA;AACA;AACA;;AAIA;;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASA,cAAT,CAAyBC,SAAzB,EAAoCC,SAApC,EAA8D;AAAA,MAAfC,OAAe,uEAAL,EAAK;;AACpE;AACA,QAAM;AAAEC,IAAAA,IAAI,EAAEC,QAAQ,GAAG;AAAnB,MAA6BF,OAAnC;AAEA,MAAIG,gBAAgB,GAAG,yBAAYL,SAAZ,CAAvB;;AACA,MAAKI,QAAL,EAAgB;AACf;AACAC,IAAAA,gBAAgB,GAAG,mBAAMA,gBAAN,CAAnB;AACA;;AAED,MAAK,OAAOJ,SAAP,KAAqB,WAA1B,EAAwC;AACvC,mHAAM,4CAAN;AACA,GAZmE,CAcpE;;;AACA,MAAIK,eAAe,GAAGD,gBAAgB,CAAEE,mCAAF,CAAhB,IAAgD,CACrEN,SADqE,CAAtE;AAIA;AACD;AACA;;AACC,MAAKO,KAAK,CAACC,OAAN,CAAeR,SAAf,CAAL,EAAkC;AACjCK,IAAAA,eAAe,GAAG,CAAE,GAAGA,eAAL,EAAsB,GAAGL,SAAzB,CAAlB;AACA;;AACD,MAAK,OAAOA,SAAP,KAAqB,QAA1B,EAAqC;AACpCK,IAAAA,eAAe,GAAG,CAAE,GAAGA,eAAL,EAAsBL,SAAtB,CAAlB;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AAP;AAGA;;AAED,SAAO,KAAP;AACA","sourcesContent":["/**\n * External dependencies\n */\nimport { uniq } from 'lodash';\n\n/**\n * WordPress dependencies\n */\nimport { forwardRef, memo } from '@wordpress/element';\nimport warn from '@wordpress/warning';\n\n/**\n * Internal dependencies\n */\nimport { CONNECT_STATIC_NAMESPACE } from './constants';\nimport { getStyledClassNameFromKey } from './get-styled-class-name-from-key';\n\n/* eslint-disable jsdoc/valid-types */\n/**\n * Forwards ref (React.ForwardRef) and \"Connects\" (or registers) a component\n * within the Context system under a specified namespace.\n *\n * This is an (experimental) evolution of the initial connect() HOC.\n * The hope is that we can improve render performance by removing functional\n * component wrappers.\n *\n * @template {import('./wordpress-component').WordPressComponentProps<{}, any, any>} P\n * @param {(props: P, ref: import('react').Ref<any>) => JSX.Element | null} Component The component to register into the Context system.\n * @param {string} namespace The namespace to register the component under.\n * @param {Object} options\n * @param {boolean} [options.memo=false]\n * @return {import('./wordpress-component').WordPressComponentFromProps<P>} The connected WordPressComponent\n */\nexport function contextConnect( Component, namespace, options = {} ) {\n\t/* eslint-enable jsdoc/valid-types */\n\tconst { memo: memoProp = false } = options;\n\n\tlet WrappedComponent = forwardRef( Component );\n\tif ( memoProp ) {\n\t\t// @ts-ignore\n\t\tWrappedComponent = memo( WrappedComponent );\n\t}\n\n\tif ( typeof namespace === 'undefined' ) {\n\t\twarn( 'contextConnect: Please provide a namespace' );\n\t}\n\n\t// @ts-ignore internal property\n\tlet mergedNamespace = WrappedComponent[ CONNECT_STATIC_NAMESPACE ] || [\n\t\tnamespace,\n\t];\n\n\t/**\n\t * Consolidate (merge) namespaces before attaching it to the WrappedComponent.\n\t */\n\tif ( Array.isArray( namespace ) ) {\n\t\tmergedNamespace = [ ...mergedNamespace, ...namespace ];\n\t}\n\tif ( typeof namespace === 'string' ) {\n\t\tmergedNamespace = [ ...mergedNamespace, namespace ];\n\t}\n\n\tWrappedComponent.displayName = namespace;\n\n\t// @ts-ignore internal property\n\tWrappedComponent[ CONNECT_STATIC_NAMESPACE ] = uniq( mergedNamespace );\n\n\t// @ts-ignore WordPressComponent property\n\tWrappedComponent.selector = `.${ getStyledClassNameFromKey( namespace ) }`;\n\n\t// @ts-ignore\n\treturn WrappedComponent;\n}\n\n/**\n * Attempts to retrieve the connected namespace from a component.\n *\n * @param {import('react').ReactChild | undefined | {}} Component The component to retrieve a namespace from.\n * @return {Array<string>} The connected namespaces.\n */\nexport function getConnectNamespace( Component ) {\n\tif ( ! Component ) return [];\n\n\tlet namespaces = [];\n\n\t// @ts-ignore internal property\n\tif ( Component[ CONNECT_STATIC_NAMESPACE ] ) {\n\t\t// @ts-ignore internal property\n\t\tnamespaces = Component[ CONNECT_STATIC_NAMESPACE ];\n\t}\n\n\t// @ts-ignore\n\tif ( Component.type && Component.type[ CONNECT_STATIC_NAMESPACE ] ) {\n\t\t// @ts-ignore\n\t\tnamespaces = Component.type[ CONNECT_STATIC_NAMESPACE ];\n\t}\n\n\treturn namespaces;\n}\n\n/**\n * Checks to see if a component is connected within the Context system.\n *\n * @param {import('react').ReactNode} Component The component to retrieve a namespace from.\n * @param {Array<string>|string} match The namespace to check.\n * @return {boolean} The result.\n */\nexport function hasConnectNamespace( Component, match ) {\n\tif ( ! Component ) return false;\n\n\tif ( typeof match === 'string' ) {\n\t\treturn getConnectNamespace( Component ).includes( match );\n\t}\n\tif ( Array.isArray( match ) ) {\n\t\treturn match.some( ( result ) =>\n\t\t\tgetConnectNamespace( Component ).includes( result )\n\t\t);\n\t}\n\n\treturn false;\n}\n"]}
1
+ {"version":3,"sources":["@wordpress/components/src/ui/context/context-connect.ts"],"names":["contextConnect","Component","namespace","options","memo","memoProp","WrappedComponent","mergedNamespace","CONNECT_STATIC_NAMESPACE","Array","isArray","displayName","selector","getConnectNamespace","namespaces","type","hasConnectNamespace","match","includes","some","result"],"mappings":";;;;;;;;;;;AAGA;;AAMA;;AACA;;AAKA;;AACA;;AAhBA;AACA;AACA;;AAIA;AACA;AACA;;AAIA;AACA;AACA;;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CAKX;;AACA,MAAKb,SAAS,CAAEO,mCAAF,CAAd,EAA6C;AAC5C;AACAM,IAAAA,UAAU,GAAGb,SAAS,CAAEO,mCAAF,CAAtB;AACA,GATU,CAWX;;;AACA,MAAKP,SAAS,CAACc,IAAV,IAAkBd,SAAS,CAACc,IAAV,CAAgBP,mCAAhB,CAAvB,EAAoE;AACnE;AACAM,IAAAA,UAAU,GAAGb,SAAS,CAACc,IAAV,CAAgBP,mCAAhB,CAAb;AACA;;AAED,SAAOM,UAAP;AACA;AAED;AACA;AACA;AACA;AACA;AACA;;;AACO,SAASE,mBAAT,CACNf,SADM,EAENgB,KAFM,EAGI;AACV,MAAK,CAAEhB,SAAP,EAAmB,OAAO,KAAP;;AAEnB,MAAK,OAAOgB,KAAP,KAAiB,QAAtB,EAAiC;AAChC,WAAOJ,mBAAmB,CAAEZ,SAAF,CAAnB,CAAiCiB,QAAjC,CAA2CD,KAA3C,CAAP;AACA;;AACD,MAAKR,KAAK,CAACC,OAAN,CAAeO,KAAf,CAAL,EAA8B;AAC7B,WAAOA,KAAK,CAACE,IAAN,CAAcC,MAAF,IAClBP,mBAAmB,CAAEZ,SAAF,CAAnB,CAAiCiB,QAAjC,CAA2CE,MAA3C,CADM,CAAP;AAGA;;AAED,SAAO,KAAP;AACA","sourcesContent":["/**\n * External dependencies\n */\nimport { uniq } from 'lodash';\nimport type { ForwardedRef, ReactChild, ReactNode } from 'react';\n\n/**\n * WordPress dependencies\n */\nimport { forwardRef, memo } from '@wordpress/element';\nimport warn from '@wordpress/warning';\n\n/**\n * Internal dependencies\n */\nimport { CONNECT_STATIC_NAMESPACE } from './constants';\nimport { getStyledClassNameFromKey } from './get-styled-class-name-from-key';\nimport type { WordPressComponentFromProps } from '.';\n\ntype ContextConnectOptions = {\n\t/** Defaults to `false`. */\n\tmemo?: boolean;\n};\n\n/**\n * Forwards ref (React.ForwardRef) and \"Connects\" (or registers) a component\n * within the Context system under a specified namespace.\n *\n * This is an (experimental) evolution of the initial connect() HOC.\n * The hope is that we can improve render performance by removing functional\n * component wrappers.\n *\n * @param Component The component to register into the Context system.\n * @param namespace The namespace to register the component under.\n * @param options\n * @return The connected WordPressComponent\n */\nexport function contextConnect< P >(\n\tComponent: ( props: P, ref: ForwardedRef< any > ) => JSX.Element | null,\n\tnamespace: string,\n\toptions: ContextConnectOptions = {}\n): WordPressComponentFromProps< P > {\n\tconst { memo: memoProp = false } = options;\n\n\tlet WrappedComponent = forwardRef( Component );\n\tif ( memoProp ) {\n\t\t// @ts-ignore\n\t\tWrappedComponent = memo( WrappedComponent );\n\t}\n\n\tif ( typeof namespace === 'undefined' ) {\n\t\twarn( 'contextConnect: Please provide a namespace' );\n\t}\n\n\t// @ts-ignore internal property\n\tlet mergedNamespace = WrappedComponent[ CONNECT_STATIC_NAMESPACE ] || [\n\t\tnamespace,\n\t];\n\n\t/**\n\t * Consolidate (merge) namespaces before attaching it to the WrappedComponent.\n\t */\n\tif ( Array.isArray( namespace ) ) {\n\t\tmergedNamespace = [ ...mergedNamespace, ...namespace ];\n\t}\n\tif ( typeof namespace === 'string' ) {\n\t\tmergedNamespace = [ ...mergedNamespace, namespace ];\n\t}\n\n\tWrappedComponent.displayName = namespace;\n\n\t// @ts-ignore internal property\n\tWrappedComponent[ CONNECT_STATIC_NAMESPACE ] = uniq( mergedNamespace );\n\n\t// @ts-ignore WordPressComponent property\n\tWrappedComponent.selector = `.${ getStyledClassNameFromKey( namespace ) }`;\n\n\t// @ts-ignore\n\treturn WrappedComponent;\n}\n\n/**\n * Attempts to retrieve the connected namespace from a component.\n *\n * @param Component The component to retrieve a namespace from.\n * @return The connected namespaces.\n */\nexport function getConnectNamespace(\n\tComponent: ReactChild | undefined | {}\n): string[] {\n\tif ( ! Component ) return [];\n\n\tlet namespaces = [];\n\n\t// @ts-ignore internal property\n\tif ( Component[ CONNECT_STATIC_NAMESPACE ] ) {\n\t\t// @ts-ignore internal property\n\t\tnamespaces = Component[ CONNECT_STATIC_NAMESPACE ];\n\t}\n\n\t// @ts-ignore\n\tif ( Component.type && Component.type[ CONNECT_STATIC_NAMESPACE ] ) {\n\t\t// @ts-ignore\n\t\tnamespaces = Component.type[ CONNECT_STATIC_NAMESPACE ];\n\t}\n\n\treturn namespaces;\n}\n\n/**\n * Checks to see if a component is connected within the Context system.\n *\n * @param Component The component to retrieve a namespace from.\n * @param match The namespace to check.\n */\nexport function hasConnectNamespace(\n\tComponent: ReactNode,\n\tmatch: string[] | string\n): boolean {\n\tif ( ! Component ) return false;\n\n\tif ( typeof match === 'string' ) {\n\t\treturn getConnectNamespace( Component ).includes( match );\n\t}\n\tif ( Array.isArray( match ) ) {\n\t\treturn match.some( ( result ) =>\n\t\t\tgetConnectNamespace( Component ).includes( result )\n\t\t);\n\t}\n\n\treturn false;\n}\n"]}
@@ -65,8 +65,8 @@ function useContextSystemBridge(_ref) {
65
65
  const parentContext = useComponentsContext();
66
66
  const valueRef = (0, _element.useRef)(value);
67
67
  useUpdateEffect(() => {
68
- if ( // objects are equivalent
69
- (0, _lodash.isEqual)(valueRef.current, value) && // but not the same reference
68
+ if ( // Objects are equivalent.
69
+ (0, _lodash.isEqual)(valueRef.current, value) && // But not the same reference.
70
70
  valueRef.current !== value) {
71
71
  typeof process !== "undefined" && process.env && process.env.NODE_ENV !== "production" ? (0, _warning.default)(`Please memoize your context: ${JSON.stringify(value)}`) : void 0;
72
72
  }
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/components/src/ui/context/context-system-provider.js"],"names":["ComponentsContext","useComponentsContext","useUpdateEffect","effect","deps","mounted","current","undefined","useContextSystemBridge","value","parentContext","valueRef","JSON","stringify","config","BaseContextSystemProvider","children","contextValue","ContextSystemProvider"],"mappings":";;;;;;;;;AAQA;;AALA;;AAaA;;AAhBA;AACA;AACA;;AAGA;AACA;AACA;AAWO,MAAMA,iBAAiB,GAAG;AAChC;AAAqC,EADL,CAA1B;;;AAGA,MAAMC,oBAAoB,GAAG,MAAM,yBAAYD,iBAAZ,CAAnC;AAE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AAY,GAAGT,sBAAsB,CAAE;AAAEC,IAAAA;AAAF,GAAF,CAA3C;AAEA,SACC,4BAAC,iBAAD,CAAmB,QAAnB;AAA4B,IAAA,KAAK,EAAGQ;AAApC,KACGD,QADH,CADD;AAKA,CARD;;AAUO,MAAME,qBAAqB,GAAG,mBAAMH,yBAAN,CAA9B","sourcesContent":["/**\n * External dependencies\n */\nimport { isEqual, merge, cloneDeep } from 'lodash';\n\n/**\n * WordPress dependencies\n */\nimport {\n\tcreateContext,\n\tuseContext,\n\tuseRef,\n\tuseEffect,\n\tuseMemo,\n\tmemo,\n} from '@wordpress/element';\nimport warn from '@wordpress/warning';\n\nexport const ComponentsContext = createContext(\n\t/** @type {Record<string, any>} */ ( {} )\n);\nexport const useComponentsContext = () => useContext( ComponentsContext );\n\n/**\n * Runs an effect only on update (i.e., ignores the first render)\n *\n * @param {import('react').EffectCallback} effect\n * @param {import('react').DependencyList} deps\n */\nfunction useUpdateEffect( effect, deps ) {\n\tconst mounted = useRef( false );\n\tuseEffect( () => {\n\t\tif ( mounted.current ) {\n\t\t\treturn effect();\n\t\t}\n\t\tmounted.current = true;\n\t\treturn undefined;\n\t}, deps );\n}\n\n/**\n * Consolidates incoming ContextSystem values with a (potential) parent ContextSystem value.\n *\n * Note: This function will warn if it detects an un-memoized `value`\n *\n * @param {Object} props\n * @param {Record<string, any>} props.value\n * @return {Record<string, any>} The consolidated value.\n */\nfunction useContextSystemBridge( { value } ) {\n\tconst parentContext = useComponentsContext();\n\n\tconst valueRef = useRef( value );\n\n\tuseUpdateEffect( () => {\n\t\tif (\n\t\t\t// objects are equivalent\n\t\t\tisEqual( valueRef.current, value ) &&\n\t\t\t// but not the same reference\n\t\t\tvalueRef.current !== value\n\t\t) {\n\t\t\twarn( `Please memoize your context: ${ JSON.stringify( value ) }` );\n\t\t}\n\t}, [ value ] );\n\n\t// `parentContext` will always be memoized (i.e., the result of this hook itself)\n\t// or the default value from when the `ComponentsContext` was originally\n\t// initialized (which will never change, it's a static variable)\n\t// so this memoization will prevent `merge` and `cloneDeep` from rerunning unless\n\t// the references to `value` change OR the `parentContext` has an actual material change\n\t// (because again, it's guaranteed to be memoized or a static reference to the empty object\n\t// so we know that the only changes for `parentContext` are material ones... i.e., why we\n\t// don't have to warn in the `useUpdateEffect` hook above for `parentContext` and we only\n\t// need to bother with the `value`). The `useUpdateEffect` above will ensure that we are\n\t// correctly warning when the `value` isn't being properly memoized. All of that to say\n\t// that this should be super safe to assume that `useMemo` will only run on actual\n\t// changes to the two dependencies, therefore saving us calls to `merge` and `cloneDeep`!\n\tconst config = useMemo( () => {\n\t\treturn merge( cloneDeep( parentContext ), value );\n\t}, [ parentContext, value ] );\n\n\treturn config;\n}\n\n/**\n * A Provider component that can modify props for connected components within\n * the Context system.\n *\n * @example\n * ```jsx\n * <ContextSystemProvider value={{ Button: { size: 'small' }}}>\n * <Button>...</Button>\n * </ContextSystemProvider>\n * ```\n *\n * @template {Record<string, any>} T\n * @param {Object} options\n * @param {import('react').ReactNode} options.children Children to render.\n * @param {T} options.value Props to render into connected components.\n * @return {JSX.Element} A Provider wrapped component.\n */\nconst BaseContextSystemProvider = ( { children, value } ) => {\n\tconst contextValue = useContextSystemBridge( { value } );\n\n\treturn (\n\t\t<ComponentsContext.Provider value={ contextValue }>\n\t\t\t{ children }\n\t\t</ComponentsContext.Provider>\n\t);\n};\n\nexport const ContextSystemProvider = memo( BaseContextSystemProvider );\n"]}
1
+ {"version":3,"sources":["@wordpress/components/src/ui/context/context-system-provider.js"],"names":["ComponentsContext","useComponentsContext","useUpdateEffect","effect","deps","mounted","current","undefined","useContextSystemBridge","value","parentContext","valueRef","JSON","stringify","config","BaseContextSystemProvider","children","contextValue","ContextSystemProvider"],"mappings":";;;;;;;;;AAQA;;AALA;;AAaA;;AAhBA;AACA;AACA;;AAGA;AACA;AACA;AAWO,MAAMA,iBAAiB,GAAG;AAChC;AAAqC,EADL,CAA1B;;;AAGA,MAAMC,oBAAoB,GAAG,MAAM,yBAAY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AyB;AAC5D,QAAMQ,YAAY,GAAGT,sBAAsB,CAAE;AAAEC,IAAAA;AAAF,GAAF,CAA3C;AAEA,SACC,4BAAC,iBAAD,CAAmB,QAAnB;AAA4B,IAAA,KAAK,EAAGQ;AAApC,KACGD,QADH,CADD;AAKA,CARD;;AAUO,MAAME,qBAAqB,GAAG,mBAAMH,yBAAN,CAA9B","sourcesContent":["/**\n * External dependencies\n */\nimport { isEqual, merge, cloneDeep } from 'lodash';\n\n/**\n * WordPress dependencies\n */\nimport {\n\tcreateContext,\n\tuseContext,\n\tuseRef,\n\tuseEffect,\n\tuseMemo,\n\tmemo,\n} from '@wordpress/element';\nimport warn from '@wordpress/warning';\n\nexport const ComponentsContext = createContext(\n\t/** @type {Record<string, any>} */ ( {} )\n);\nexport const useComponentsContext = () => useContext( ComponentsContext );\n\n/**\n * Runs an effect only on update (i.e., ignores the first render)\n *\n * @param {import('react').EffectCallback} effect\n * @param {import('react').DependencyList} deps\n */\nfunction useUpdateEffect( effect, deps ) {\n\tconst mounted = useRef( false );\n\tuseEffect( () => {\n\t\tif ( mounted.current ) {\n\t\t\treturn effect();\n\t\t}\n\t\tmounted.current = true;\n\t\treturn undefined;\n\t}, deps );\n}\n\n/**\n * Consolidates incoming ContextSystem values with a (potential) parent ContextSystem value.\n *\n * Note: This function will warn if it detects an un-memoized `value`\n *\n * @param {Object} props\n * @param {Record<string, any>} props.value\n * @return {Record<string, any>} The consolidated value.\n */\nfunction useContextSystemBridge( { value } ) {\n\tconst parentContext = useComponentsContext();\n\n\tconst valueRef = useRef( value );\n\n\tuseUpdateEffect( () => {\n\t\tif (\n\t\t\t// Objects are equivalent.\n\t\t\tisEqual( valueRef.current, value ) &&\n\t\t\t// But not the same reference.\n\t\t\tvalueRef.current !== value\n\t\t) {\n\t\t\twarn( `Please memoize your context: ${ JSON.stringify( value ) }` );\n\t\t}\n\t}, [ value ] );\n\n\t// `parentContext` will always be memoized (i.e., the result of this hook itself)\n\t// or the default value from when the `ComponentsContext` was originally\n\t// initialized (which will never change, it's a static variable)\n\t// so this memoization will prevent `merge` and `cloneDeep` from rerunning unless\n\t// the references to `value` change OR the `parentContext` has an actual material change\n\t// (because again, it's guaranteed to be memoized or a static reference to the empty object\n\t// so we know that the only changes for `parentContext` are material ones... i.e., why we\n\t// don't have to warn in the `useUpdateEffect` hook above for `parentContext` and we only\n\t// need to bother with the `value`). The `useUpdateEffect` above will ensure that we are\n\t// correctly warning when the `value` isn't being properly memoized. All of that to say\n\t// that this should be super safe to assume that `useMemo` will only run on actual\n\t// changes to the two dependencies, therefore saving us calls to `merge` and `cloneDeep`!\n\tconst config = useMemo( () => {\n\t\treturn merge( cloneDeep( parentContext ), value );\n\t}, [ parentContext, value ] );\n\n\treturn config;\n}\n\n/**\n * A Provider component that can modify props for connected components within\n * the Context system.\n *\n * @example\n * ```jsx\n * <ContextSystemProvider value={{ Button: { size: 'small' }}}>\n * <Button>...</Button>\n * </ContextSystemProvider>\n * ```\n *\n * @template {Record<string, any>} T\n * @param {Object} options\n * @param {import('react').ReactNode} options.children Children to render.\n * @param {T} options.value Props to render into connected components.\n * @return {JSX.Element} A Provider wrapped component.\n */\nconst BaseContextSystemProvider = ( { children, value } ) => {\n\tconst contextValue = useContextSystemBridge( { value } );\n\n\treturn (\n\t\t<ComponentsContext.Provider value={ contextValue }>\n\t\t\t{ children }\n\t\t</ComponentsContext.Provider>\n\t);\n};\n\nexport const ContextSystemProvider = memo( BaseContextSystemProvider );\n"]}
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/components/src/ui/context/index.js"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;AAIA;;AAKA;;AACA;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA","sourcesContent":["export {\n\tContextSystemProvider,\n\tuseComponentsContext,\n} from './context-system-provider';\nexport {\n\tcontextConnect,\n\thasConnectNamespace,\n\tgetConnectNamespace,\n} from './context-connect';\nexport { useContextSystem } from './use-context-system';\nexport * from './wordpress-component';\n"]}
1
+ {"version":3,"sources":["@wordpress/components/src/ui/context/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;AAIA;;AAKA;;AACA;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA","sourcesContent":["export {\n\tContextSystemProvider,\n\tuseComponentsContext,\n} from './context-system-provider';\nexport {\n\tcontextConnect,\n\thasConnectNamespace,\n\tgetConnectNamespace,\n} from './context-connect';\nexport { useContextSystem } from './use-context-system';\nexport * from './wordpress-component';\n"]}
@@ -71,9 +71,9 @@ function _getComputedBackgroundColor(backgroundColor) {
71
71
 
72
72
  const el = getColorComputationNode();
73
73
  if (!el) return '';
74
- el.style.background = backgroundColor; // Grab the style
74
+ el.style.background = backgroundColor; // Grab the style.
75
75
 
76
- const computedColor = (_window = window) === null || _window === void 0 ? void 0 : _window.getComputedStyle(el).background; // Reset
76
+ const computedColor = (_window = window) === null || _window === void 0 ? void 0 : _window.getComputedStyle(el).background; // Reset.
77
77
 
78
78
  el.style.background = '';
79
79
  return computedColor || '';
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/components/src/ui/utils/colors.js"],"names":["colorComputationNode","namesPlugin","getColorComputationNode","document","el","createElement","setAttribute","body","appendChild","isColor","value","test","isValid","_getComputedBackgroundColor","backgroundColor","includes","style","background","computedColor","window","getComputedStyle","getComputedBackgroundColor","getOptimalTextColor","isLight","getOptimalTextShade","result"],"mappings":";;;;;;;;;;AAGA;;AACA;;AACA;;AALA;AACA;AACA;;AAKA;AACA,IAAIA,oBAAJ;AAEA,oBAAQ,CAAEC,cAAF,CAAR;AAEA;AACA;AACA;;AACA,SAASC,uBAAT,GAAmC;AAClC,MAAK,OAAOC,QAAP,KAAoB,WAAzB,EAAuC;;AAEvC,MAAK,CAAEH,o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G,0BAA0B,GAAG,qBAASR,2BAAT,CAAnC;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AACO,SAASS,mBAAT,CAA8BR,eAA9B,EAAgD;AACtD,QAAMG,UAAU,GAAGI,0BAA0B,CAAEP,eAAF,CAA7C;AAEA,SAAO,oBAAQG,UAAR,EAAqBM,OAArB,KAAiC,SAAjC,GAA6C,SAApD;AACA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;;;AACO,SAASC,mBAAT,CAA8BV,eAA9B,EAAgD;AACtD,QAAMW,MAAM,GAAGH,mBAAmB,CAAER,eAAF,CAAlC;AAEA,SAAOW,MAAM,KAAK,SAAX,GAAuB,MAAvB,GAAgC,OAAvC;AACA","sourcesContent":["/**\n * External dependencies\n */\nimport memoize from 'memize';\nimport { colord, extend } from 'colord';\nimport namesPlugin from 'colord/plugins/names';\n\n/** @type {HTMLDivElement} */\nlet colorComputationNode;\n\nextend( [ namesPlugin ] );\n\n/**\n * @return {HTMLDivElement | undefined} The HTML element for color computation.\n */\nfunction getColorComputationNode() {\n\tif ( typeof document === 'undefined' ) return;\n\n\tif ( ! colorComputationNode ) {\n\t\t// Create a temporary element for style computation.\n\t\tconst el = document.createElement( 'div' );\n\t\tel.setAttribute( 'data-g2-color-computation-node', '' );\n\t\t// Inject for window computed style.\n\t\tdocument.body.appendChild( el );\n\t\tcolorComputationNode = el;\n\t}\n\n\treturn colorComputationNode;\n}\n\n/**\n * @param {string | unknown} value\n *\n * @return {boolean} Whether the value is a valid color.\n */\nfunction isColor( value ) {\n\tif ( typeof value !== 'string' ) return false;\n\tconst test = colord( value );\n\n\treturn test.isValid();\n}\n\n/**\n * Retrieves the computed background color. This is useful for getting the\n * value of a CSS variable color.\n *\n * @param {string | unknown} backgroundColor The background color to compute.\n *\n * @return {string} The computed background color.\n */\nfunction _getComputedBackgroundColor( backgroundColor ) {\n\tif ( typeof backgroundColor !== 'string' ) return '';\n\n\tif ( isColor( backgroundColor ) ) return backgroundColor;\n\n\tif ( ! backgroundColor.includes( 'var(' ) ) return '';\n\tif ( typeof document === 'undefined' ) return '';\n\n\t// Attempts to gracefully handle CSS variables color values.\n\tconst el = getColorComputationNode();\n\tif ( ! el ) return '';\n\n\tel.style.background = backgroundColor;\n\t// Grab the style\n\tconst computedColor = window?.getComputedStyle( el ).background;\n\t// Reset\n\tel.style.background = '';\n\n\treturn computedColor || '';\n}\n\nconst getComputedBackgroundColor = memoize( _getComputedBackgroundColor );\n\n/**\n * Get the text shade optimized for readability, based on a background color.\n *\n * @param {string | unknown} backgroundColor The background color.\n *\n * @return {string} The optimized text color (black or white).\n */\nexport function getOptimalTextColor( backgroundColor ) {\n\tconst background = getComputedBackgroundColor( backgroundColor );\n\n\treturn colord( background ).isLight() ? '#000000' : '#ffffff';\n}\n\n/**\n * Get the text shade optimized for readability, based on a background color.\n *\n * @param {string | unknown} backgroundColor The background color.\n *\n * @return {string} The optimized text shade (dark or light).\n */\nexport function getOptimalTextShade( backgroundColor ) {\n\tconst result = getOptimalTextColor( backgroundColor );\n\n\treturn result === '#000000' ? 'dark' : 'light';\n}\n"]}
1
+ {"version":3,"sources":["@wordpress/components/src/ui/utils/colors.js"],"names":["colorComputationNode","namesPlugin","getColorComputationNode","document","el","createElement","setAttribute","body","appendChild","isColor","value","test","isValid","_getComputedBackgroundColor","backgroundColor","includes","style","background","computedColor","window","getComputedStyle","getComputedBackgroundColor","getOptimalTextColor","isLight","getOptimalTextShade","result"],"mappings":";;;;;;;;;;AAGA;;AACA;;AACA;;AALA;AACA;AACA;;AAKA;AACA,IAAIA,oBAAJ;AAEA,oBAAQ,CAAEC,cAAF,CAAR;AAEA;AACA;AACA;;AACA,SAASC,uBAAT,GAAmC;AAClC,MAAK,OAAOC,QAAP,KAAoB,WAAzB,EAAuC;;AAEvC,MAAK,CAAEH,oBAAP,EAA8B;AAC7B;AACA,UAAMI,EAAE,GAAGD,QAAQ,CAACE,aAAT,CAAwB,KAAxB,CAAX;AACAD,IAAAA,EAAE,CAACE,Y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gD;AACtD,QAAMG,UAAU,GAAGI,0BAA0B,CAAEP,eAAF,CAA7C;AAEA,SAAO,oBAAQG,UAAR,EAAqBM,OAArB,KAAiC,SAAjC,GAA6C,SAApD;AACA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;;;AACO,SAASC,mBAAT,CAA8BV,eAA9B,EAAgD;AACtD,QAAMW,MAAM,GAAGH,mBAAmB,CAAER,eAAF,CAAlC;AAEA,SAAOW,MAAM,KAAK,SAAX,GAAuB,MAAvB,GAAgC,OAAvC;AACA","sourcesContent":["/**\n * External dependencies\n */\nimport memoize from 'memize';\nimport { colord, extend } from 'colord';\nimport namesPlugin from 'colord/plugins/names';\n\n/** @type {HTMLDivElement} */\nlet colorComputationNode;\n\nextend( [ namesPlugin ] );\n\n/**\n * @return {HTMLDivElement | undefined} The HTML element for color computation.\n */\nfunction getColorComputationNode() {\n\tif ( typeof document === 'undefined' ) return;\n\n\tif ( ! colorComputationNode ) {\n\t\t// Create a temporary element for style computation.\n\t\tconst el = document.createElement( 'div' );\n\t\tel.setAttribute( 'data-g2-color-computation-node', '' );\n\t\t// Inject for window computed style.\n\t\tdocument.body.appendChild( el );\n\t\tcolorComputationNode = el;\n\t}\n\n\treturn colorComputationNode;\n}\n\n/**\n * @param {string | unknown} value\n *\n * @return {boolean} Whether the value is a valid color.\n */\nfunction isColor( value ) {\n\tif ( typeof value !== 'string' ) return false;\n\tconst test = colord( value );\n\n\treturn test.isValid();\n}\n\n/**\n * Retrieves the computed background color. This is useful for getting the\n * value of a CSS variable color.\n *\n * @param {string | unknown} backgroundColor The background color to compute.\n *\n * @return {string} The computed background color.\n */\nfunction _getComputedBackgroundColor( backgroundColor ) {\n\tif ( typeof backgroundColor !== 'string' ) return '';\n\n\tif ( isColor( backgroundColor ) ) return backgroundColor;\n\n\tif ( ! backgroundColor.includes( 'var(' ) ) return '';\n\tif ( typeof document === 'undefined' ) return '';\n\n\t// Attempts to gracefully handle CSS variables color values.\n\tconst el = getColorComputationNode();\n\tif ( ! el ) return '';\n\n\tel.style.background = backgroundColor;\n\t// Grab the style.\n\tconst computedColor = window?.getComputedStyle( el ).background;\n\t// Reset.\n\tel.style.background = '';\n\n\treturn computedColor || '';\n}\n\nconst getComputedBackgroundColor = memoize( _getComputedBackgroundColor );\n\n/**\n * Get the text shade optimized for readability, based on a background color.\n *\n * @param {string | unknown} backgroundColor The background color.\n *\n * @return {string} The optimized text color (black or white).\n */\nexport function getOptimalTextColor( backgroundColor ) {\n\tconst background = getComputedBackgroundColor( backgroundColor );\n\n\treturn colord( background ).isLight() ? '#000000' : '#ffffff';\n}\n\n/**\n * Get the text shade optimized for readability, based on a background color.\n *\n * @param {string | unknown} backgroundColor The background color.\n *\n * @return {string} The optimized text shade (dark or light).\n */\nexport function getOptimalTextShade( backgroundColor ) {\n\tconst result = getOptimalTextColor( backgroundColor );\n\n\treturn result === '#000000' ? 'dark' : 'light';\n}\n"]}
@@ -26,14 +26,14 @@ function space(value) {
26
26
 
27
27
  if (typeof value === 'undefined') {
28
28
  return undefined;
29
- } // handle empty strings, if it's the number 0 this still works
29
+ } // Handle empty strings, if it's the number 0 this still works.
30
30
 
31
31
 
32
32
  if (!value) {
33
33
  return '0';
34
34
  }
35
35
 
36
- const asInt = typeof value === 'number' ? value : Number(value); // test if the input has a unit, was NaN, or was one of the named CSS values (like `auto`), in which case just use that value
36
+ const asInt = typeof value === 'number' ? value : Number(value); // Test if the input has a unit, was NaN, or was one of the named CSS values (like `auto`), in which case just use that value.
37
37
 
38
38
  if (typeof window !== 'undefined' && (_window$CSS = window.CSS) !== null && _window$CSS !== void 0 && (_window$CSS$supports = _window$CSS.supports) !== null && _window$CSS$supports !== void 0 && _window$CSS$supports.call(_window$CSS, 'margin', value.toString()) || Number.isNaN(asInt)) {
39
39
  return value.toString();
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/components/src/ui/utils/space.ts"],"names":["GRID_BASE","space","value","undefined","asInt","Number","window","CSS","supports","toString","isNaN"],"mappings":";;;;;;;AAAA;AACA;AACA;AAGA,MAAMA,SAAS,GAAG,KAAlB;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACO,SAASC,KAAT,CAAgBC,KAAhB,EAAyD;AAAA;;AAC/D,MAAK,OAAOA,KAAP,KAAiB,WAAtB,EAAoC;AACnC,WAAOC,SAAP;AACA,GAH8D,CAK/D;;;AACA,MAAK,CAAED,KAAP,EAAe;AACd,WAAO,GAAP;AACA;;AAED,QAAME,KAAK,GAAG,OAAOF,KAAP,KAAiB,QAAjB,GAA4BA,KAA5B,GAAoCG,MAAM,CAAEH,KAAF,CAAxD,CAV+D,CAY/D;;AACA,MACG,OAAOI,MAAP,KAAkB,WAAlB,mBACDA,MAAM,CAACC,GADN,gEACD,YAAYC,QADX,iDACD,uCAAwB,QAAxB,EAAkCN,KAAK,CAACO,QAAN,EAAlC,CADD,IAEAJ,MAAM,CAACK,KAAP,CAAcN,KAAd,CAHD,EAIE;AACD,WAAOF,KAAK,CAACO,QAAN,EAAP;AACA;;AAED,SAAQ,QAAQT,SAAW,MAAME,KAAO,GAAxC;AACA","sourcesContent":["/**\n * A real number or something parsable as a number\n */\nexport type SpaceInput = number | string;\n\nconst GRID_BASE = '4px';\n\n/**\n * A function that handles numbers, numeric strings, and unit values.\n *\n * When given a number or a numeric string, it will return the grid-based\n * value as a factor of GRID_BASE, defined above.\n *\n * When given a unit value or one of the named CSS values like `auto`,\n * it will simply return the value back.\n *\n * @param value A number, numeric string, or a unit value.\n */\nexport function space( value?: SpaceInput ): string | undefined {\n\tif ( typeof value === 'undefined' ) {\n\t\treturn undefined;\n\t}\n\n\t// handle empty strings, if it's the number 0 this still works\n\tif ( ! value ) {\n\t\treturn '0';\n\t}\n\n\tconst asInt = typeof value === 'number' ? value : Number( value );\n\n\t// test if the input has a unit, was NaN, or was one of the named CSS values (like `auto`), in which case just use that value\n\tif (\n\t\t( typeof window !== 'undefined' &&\n\t\t\twindow.CSS?.supports?.( 'margin', value.toString() ) ) ||\n\t\tNumber.isNaN( asInt )\n\t) {\n\t\treturn value.toString();\n\t}\n\n\treturn `calc(${ GRID_BASE } * ${ value })`;\n}\n"]}
1
+ {"version":3,"sources":["@wordpress/components/src/ui/utils/space.ts"],"names":["GRID_BASE","space","value","undefined","asInt","Number","window","CSS","supports","toString","isNaN"],"mappings":";;;;;;;AAAA;AACA;AACA;AAGA,MAAMA,SAAS,GAAG,KAAlB;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACO,SAASC,KAAT,CAAgBC,KAAhB,EAAyD;AAAA;;AAC/D,MAAK,OAAOA,KAAP,KAAiB,WAAtB,EAAoC;AACnC,WAAOC,SAAP;AACA,GAH8D,CAK/D;;;AACA,MAAK,CAAED,KAAP,EAAe;AACd,WAAO,GAAP;AACA;;AAED,QAAME,KAAK,GAAG,OAAOF,KAAP,KAAiB,QAAjB,GAA4BA,KAA5B,GAAoCG,MAAM,CAAEH,KAAF,CAAxD,CAV+D,CAY/D;;AACA,MACG,OAAOI,MAAP,KAAkB,WAAlB,mBACDA,MAAM,CAACC,GADN,gEACD,YAAYC,QADX,iDACD,uCAAwB,QAAxB,EAAkCN,KAAK,CAACO,QAAN,EAAlC,CADD,IAEAJ,MAAM,CAACK,KAAP,CAAcN,KAAd,CAHD,EAIE;AACD,WAAOF,KAAK,CAACO,QAAN,EAAP;AACA;;AAED,SAAQ,QAAQT,SAAW,MAAME,KAAO,GAAxC;AACA","sourcesContent":["/**\n * A real number or something parsable as a number\n */\nexport type SpaceInput = number | string;\n\nconst GRID_BASE = '4px';\n\n/**\n * A function that handles numbers, numeric strings, and unit values.\n *\n * When given a number or a numeric string, it will return the grid-based\n * value as a factor of GRID_BASE, defined above.\n *\n * When given a unit value or one of the named CSS values like `auto`,\n * it will simply return the value back.\n *\n * @param value A number, numeric string, or a unit value.\n */\nexport function space( value?: SpaceInput ): string | undefined {\n\tif ( typeof value === 'undefined' ) {\n\t\treturn undefined;\n\t}\n\n\t// Handle empty strings, if it's the number 0 this still works.\n\tif ( ! value ) {\n\t\treturn '0';\n\t}\n\n\tconst asInt = typeof value === 'number' ? value : Number( value );\n\n\t// Test if the input has a unit, was NaN, or was one of the named CSS values (like `auto`), in which case just use that value.\n\tif (\n\t\t( typeof window !== 'undefined' &&\n\t\t\twindow.CSS?.supports?.( 'margin', value.toString() ) ) ||\n\t\tNumber.isNaN( asInt )\n\t) {\n\t\treturn value.toString();\n\t}\n\n\treturn `calc(${ GRID_BASE } * ${ value })`;\n}\n"]}
@@ -6,10 +6,10 @@ Object.defineProperty(exports, "__esModule", {
6
6
  value: true
7
7
  });
8
8
  exports.default = void 0;
9
- Object.defineProperty(exports, "parseUnit", {
9
+ Object.defineProperty(exports, "parseQuantityAndUnitFromRawValue", {
10
10
  enumerable: true,
11
11
  get: function () {
12
- return _utils.parseUnit;
12
+ return _utils.parseQuantityAndUnitFromRawValue;
13
13
  }
14
14
  });
15
15
  Object.defineProperty(exports, "useCustomUnits", {
@@ -74,18 +74,25 @@ function UnitControl(_ref, forwardedRef) {
74
74
  value: valueProp,
75
75
  ...props
76
76
  } = _ref;
77
- const units = (0, _element.useMemo)(() => (0, _utils.getUnitsWithCurrentUnit)(valueProp, unitProp, unitsProp), [valueProp, unitProp, unitsProp]);
78
- const [value, initialUnit] = (0, _utils.getParsedValue)(valueProp, unitProp, units);
77
+ // The `value` prop, in theory, should not be `null`, but the following line
78
+ // ensures it fallback to `undefined` in case a consumer of `UnitControl`
79
+ // still passes `null` as a `value`.
80
+ const nonNullValueProp = valueProp !== null && valueProp !== void 0 ? valueProp : undefined;
81
+ const units = (0, _element.useMemo)(() => (0, _utils.getUnitsWithCurrentUnit)(nonNullValueProp, unitProp, unitsProp), [nonNullValueProp, unitProp, unitsProp]);
82
+ const [parsedQuantity, parsedUnit] = (0, _utils.getParsedQuantityAndUnit)(nonNullValueProp, unitProp, units);
79
83
  const [unit, setUnit] = (0, _hooks.useControlledState)(unitProp, {
80
- initial: initialUnit,
84
+ initial: parsedUnit,
81
85
  fallback: ''
82
- }); // Stores parsed value for hand-off in state reducer
86
+ });
87
+ (0, _element.useEffect)(() => {
88
+ setUnit(parsedUnit);
89
+ }, [parsedUnit]); // Stores parsed value for hand-off in state reducer.
83
90
 
84
- const refParsedValue = (0, _element.useRef)(null);
91
+ const refParsedQuantity = (0, _element.useRef)(undefined);
85
92
  const classes = (0, _classnames.default)('components-unit-control', className);
86
93
 
87
- const handleOnChange = (next, changeProps) => {
88
- if (next === '') {
94
+ const handleOnQuantityChange = (nextQuantityValue, changeProps) => {
95
+ if (nextQuantityValue === '' || typeof nextQuantityValue === 'undefined' || nextQuantityValue === null) {
89
96
  onChange('', changeProps);
90
97
  return;
91
98
  }
@@ -95,43 +102,43 @@ function UnitControl(_ref, forwardedRef) {
95
102
  */
96
103
 
97
104
 
98
- next = (0, _utils.getValidParsedUnit)(next, units, value, unit).join('');
99
- onChange(next, changeProps);
105
+ const onChangeValue = (0, _utils.getValidParsedQuantityAndUnit)(nextQuantityValue, units, parsedQuantity, unit).join('');
106
+ onChange(onChangeValue, changeProps);
100
107
  };
101
108
 
102
- const handleOnUnitChange = (next, changeProps) => {
109
+ const handleOnUnitChange = (nextUnitValue, changeProps) => {
103
110
  const {
104
111
  data
105
112
  } = changeProps;
106
- let nextValue = `${value}${next}`;
113
+ let nextValue = `${parsedQuantity !== null && parsedQuantity !== void 0 ? parsedQuantity : ''}${nextUnitValue}`;
107
114
 
108
115
  if (isResetValueOnUnitChange && (data === null || data === void 0 ? void 0 : data.default) !== undefined) {
109
- nextValue = `${data.default}${next}`;
116
+ nextValue = `${data.default}${nextUnitValue}`;
110
117
  }
111
118
 
112
119
  onChange(nextValue, changeProps);
113
- onUnitChange(next, changeProps);
114
- setUnit(next);
120
+ onUnitChange(nextUnitValue, changeProps);
121
+ setUnit(nextUnitValue);
115
122
  };
116
123
 
117
124
  const mayUpdateUnit = event => {
118
125
  if (!isNaN(Number(event.currentTarget.value))) {
119
- refParsedValue.current = null;
126
+ refParsedQuantity.current = undefined;
120
127
  return;
121
128
  }
122
129
 
123
- const [parsedValue, parsedUnit] = (0, _utils.getValidParsedUnit)(event.currentTarget.value, units, value, unit);
124
- refParsedValue.current = parsedValue.toString();
130
+ const [validParsedQuantity, validParsedUnit] = (0, _utils.getValidParsedQuantityAndUnit)(event.currentTarget.value, units, parsedQuantity, unit);
131
+ refParsedQuantity.current = validParsedQuantity;
125
132
 
126
- if (isPressEnterToChange && parsedUnit !== unit) {
127
- const data = Array.isArray(units) ? units.find(option => option.value === parsedUnit) : undefined;
133
+ if (isPressEnterToChange && validParsedUnit !== unit) {
134
+ const data = Array.isArray(units) ? units.find(option => option.value === validParsedUnit) : undefined;
128
135
  const changeProps = {
129
136
  event,
130
137
  data
131
138
  };
132
- onChange(`${parsedValue}${parsedUnit}`, changeProps);
133
- onUnitChange(parsedUnit, changeProps);
134
- setUnit(parsedUnit);
139
+ onChange(`${validParsedQuantity !== null && validParsedQuantity !== void 0 ? validParsedQuantity : ''}${validParsedUnit}`, changeProps);
140
+ onUnitChange(validParsedUnit, changeProps);
141
+ setUnit(validParsedUnit);
135
142
  }
136
143
  };
137
144
 
@@ -164,9 +171,11 @@ function UnitControl(_ref, forwardedRef) {
164
171
  * then use that result to update the state.
165
172
  */
166
173
  if (action.type === inputControlActionTypes.COMMIT) {
167
- if (refParsedValue.current !== null) {
168
- state.value = refParsedValue.current;
169
- refParsedValue.current = null;
174
+ if (refParsedQuantity.current !== undefined) {
175
+ var _refParsedQuantity$cu;
176
+
177
+ state.value = ((_refParsedQuantity$cu = refParsedQuantity.current) !== null && _refParsedQuantity$cu !== void 0 ? _refParsedQuantity$cu : '').toString();
178
+ refParsedQuantity.current = undefined;
170
179
  }
171
180
  }
172
181
 
@@ -210,11 +219,11 @@ function UnitControl(_ref, forwardedRef) {
210
219
  label: label,
211
220
  onBlur: handleOnBlur,
212
221
  onKeyDown: handleOnKeyDown,
213
- onChange: handleOnChange,
222
+ onChange: handleOnQuantityChange,
214
223
  ref: forwardedRef,
215
224
  size: size,
216
225
  suffix: inputSuffix,
217
- value: value,
226
+ value: parsedQuantity !== null && parsedQuantity !== void 0 ? parsedQuantity : '',
218
227
  step: step,
219
228
  __unstableStateReducer: (0, _reducer.composeStateReducers)(unitControlStateReducer, stateReducer)
220
229
  })));
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/components/src/unit-control/index.tsx"],"names":["UnitControl","forwardedRef","__unstableStateReducer","stateReducer","state","autoComplete","className","disabled","disableUnits","isPressEnterToChange","isResetValueOnUnitChange","isUnitSelectTabbable","label","onChange","noop","onUnitChange","size","style","unit","unitProp","units","unitsProp","CSS_UNITS","value","valueProp","props","initialUnit","setUnit","initial","fallback","refParsedValue","classes","handleOnChange","next","changeProps","join","handleOnUnitChange","data","nextValue","default","undefined","mayUpdateUnit","event","isNaN","Number","currentTarget","current","parsedValue","parsedUnit","toString","Array","isArray","find","option","handleOnBlur","handleOnKeyDown","keyCode","ENTER","unitControlStateReducer","action","type","inputControlActionTypes","COMMIT","inputSuffix","step","activeUnit","ForwardedUnitControl"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAeA;;;;AANA;;AACA;;AAMA;;AACA;;AAMA;;AACA;;AACA;;AACA;;AACA;;AAMA;;;;;;AAjCA;AACA;AACA;;AAUA;AACA;AACA;AAuBA,SAASA,WAAT,OAoBCC,YApBD,EAqBE;AAAA,MApBD;AACCC,IAAAA,sBAAsB,EAAEC,YAAY,GAAKC,KAAF,IAAaA,KADrD;AAECC,IAAAA,YAAY,GAAG,KAFhB;AAGCC,IAAAA,SAHD;AAICC,IAAAA,QAAQ,GAAG,KAJZ;AAKCC,IAAAA,YAAY,GAAG,KALhB;AAMCC,IAAAA,oBAAoB,GAAG,KANxB;AAOCC,IAAAA,wBAAwB,GAAG,KAP5B;AAQCC,IAAAA,oBAAoB,GAAG,IARxB;AASCC,IAAAA,KATD;AAUCC,IAAAA,QAAQ,GAAGC,YAVZ;AAWCC,IAAAA,YAAY,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KAAP,KAAiBL,IAA3C,CAAnB;AACA8C,IAAAA,IAAI,uBAAGC,UAAH,aAAGA,UAAH,uBAAGA,UAAU,CAAED,IAAf,+DAAuB,CAA3B;AACA;;AAED,SACC,4BAAC,uBAAD;AAAM,IAAA,SAAS,EAAC,iCAAhB;AAAkD,IAAA,KAAK,EAAG/C;AAA1D,KACC,4BAAC,6BAAD;AACC,kBAAaL,KADd;AAEC,IAAA,IAAI,EAAGH,oBAAoB,GAAG,MAAH,GAAY;AAFxC,KAGM,kBAAMgB,KAAN,EAAa,CAAE,UAAF,CAAb,CAHN;AAIC,IAAA,YAAY,EAAGpB,YAJhB;AAKC,IAAA,SAAS,EAAG0B,OALb;AAMC,IAAA,QAAQ,EAAGxB,QANZ;AAOC,IAAA,YAAY,EAAGC,YAPhB;AAQC,IAAA,oBAAoB,EAAGC,oBARxB;AASC,IAAA,KAAK,EAAGG,KATT;AAUC,IAAA,MAAM,EAAG0C,YAVV;AAWC,IAAA,SAAS,EAAGC,eAXb;AAYC,IAAA,QAAQ,EAAGvB,cAZZ;AAaC,IAAA,GAAG,EAAG/B,YAbP;AAcC,IAAA,IAAI,EAAGe,IAdR;AAeC,IAAA,MAAM,EAAG+C,WAfV;AAgBC,IAAA,KAAK,EAAGxC,KAhBT;AAiBC,IAAA,IAAI,EAAGyC,IAjBR;AAkBC,IAAA,sBAAsB,EAAG,mCACxBN,uBADwB,EAExBvD,YAFwB;AAlB1B,KADD,CADD;AA2BA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AACA,MAAM+D,oBAAoB,GAAG,yBAAYlE,WAAZ,CAA7B;eAGekE,oB","sourcesContent":["/**\n * External dependencies\n */\nimport type {\n\tFocusEventHandler,\n\tKeyboardEvent,\n\tForwardedRef,\n\tSyntheticEvent,\n} from 'react';\nimport { noop, omit } from 'lodash';\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport { forwardRef, useMemo, useRef } from '@wordpress/element';\nimport { __ } from '@wordpress/i18n';\nimport { ENTER } from '@wordpress/keycodes';\n\n/**\n * Internal dependencies\n */\nimport type { WordPressComponentProps } from '../ui/context';\nimport * as inputControlActionTypes from '../input-control/reducer/actions';\nimport { composeStateReducers } from '../input-control/reducer/reducer';\nimport { Root, ValueInput } from './styles/unit-control-styles';\nimport UnitSelectControl from './unit-select-control';\nimport {\n\tCSS_UNITS,\n\tgetParsedValue,\n\tgetUnitsWithCurrentUnit,\n\tgetValidParsedUnit,\n} from './utils';\nimport { useControlledState } from '../utils/hooks';\nimport type { UnitControlProps, UnitControlOnChangeCallback } from './types';\nimport type { StateReducer } from '../input-control/reducer/state';\n\nfunction UnitControl(\n\t{\n\t\t__unstableStateReducer: stateReducer = ( state ) => state,\n\t\tautoComplete = 'off',\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 = noop,\n\t\tonUnitChange = noop,\n\t\tsize = 'default',\n\t\tstyle,\n\t\tunit: unitProp,\n\t\tunits: unitsProp = CSS_UNITS,\n\t\tvalue: valueProp,\n\t\t...props\n\t}: WordPressComponentProps< UnitControlProps, 'input', false >,\n\tforwardedRef: ForwardedRef< any >\n) {\n\tconst units = useMemo(\n\t\t() => getUnitsWithCurrentUnit( valueProp, unitProp, unitsProp ),\n\t\t[ valueProp, unitProp, unitsProp ]\n\t);\n\tconst [ value, initialUnit ] = getParsedValue( valueProp, unitProp, units );\n\tconst [ unit, setUnit ] = useControlledState< string | undefined >(\n\t\tunitProp,\n\t\t{\n\t\t\tinitial: initialUnit,\n\t\t\tfallback: '',\n\t\t}\n\t);\n\n\t// Stores parsed value for hand-off in state reducer\n\tconst refParsedValue = useRef< string | null >( null );\n\n\tconst classes = classnames( 'components-unit-control', className );\n\n\tconst handleOnChange: UnitControlOnChangeCallback = (\n\t\tnext,\n\t\tchangeProps\n\t) => {\n\t\tif ( next === '' ) {\n\t\t\tonChange( '', 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\tnext = getValidParsedUnit( next, units, value, unit ).join( '' );\n\n\t\tonChange( next, changeProps );\n\t};\n\n\tconst handleOnUnitChange: UnitControlOnChangeCallback = (\n\t\tnext,\n\t\tchangeProps\n\t) => {\n\t\tconst { data } = changeProps;\n\n\t\tlet nextValue = `${ value }${ next }`;\n\n\t\tif ( isResetValueOnUnitChange && data?.default !== undefined ) {\n\t\t\tnextValue = `${ data.default }${ next }`;\n\t\t}\n\n\t\tonChange( nextValue, changeProps );\n\t\tonUnitChange( next, changeProps );\n\n\t\tsetUnit( next );\n\t};\n\n\tconst mayUpdateUnit = ( event: SyntheticEvent< HTMLInputElement > ) => {\n\t\tif ( ! isNaN( Number( event.currentTarget.value ) ) ) {\n\t\t\trefParsedValue.current = null;\n\t\t\treturn;\n\t\t}\n\t\tconst [ parsedValue, parsedUnit ] = getValidParsedUnit(\n\t\t\tevent.currentTarget.value,\n\t\t\tunits,\n\t\t\tvalue,\n\t\t\tunit\n\t\t);\n\n\t\trefParsedValue.current = parsedValue.toString();\n\n\t\tif ( isPressEnterToChange && parsedUnit !== unit ) {\n\t\t\tconst data = Array.isArray( units )\n\t\t\t\t? units.find( ( option ) => option.value === parsedUnit )\n\t\t\t\t: undefined;\n\t\t\tconst changeProps = { event, data };\n\n\t\t\tonChange( `${ parsedValue }${ parsedUnit }`, changeProps );\n\t\t\tonUnitChange( parsedUnit, changeProps );\n\n\t\t\tsetUnit( parsedUnit );\n\t\t}\n\t};\n\n\tconst handleOnBlur: FocusEventHandler< HTMLInputElement > = mayUpdateUnit;\n\n\tconst handleOnKeyDown = ( event: KeyboardEvent< HTMLInputElement > ) => {\n\t\tconst { keyCode } = event;\n\t\tif ( keyCode === 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\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 ( refParsedValue.current !== null ) {\n\t\t\t\tstate.value = refParsedValue.current;\n\t\t\t\trefParsedValue.current = null;\n\t\t\t}\n\t\t}\n\n\t\treturn state;\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/>\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{ ...omit( props, [ 'children' ] ) }\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={ handleOnChange }\n\t\t\t\tref={ forwardedRef }\n\t\t\t\tsize={ size }\n\t\t\t\tsuffix={ inputSuffix }\n\t\t\t\tvalue={ value }\n\t\t\t\tstep={ step }\n\t\t\t\t__unstableStateReducer={ composeStateReducers(\n\t\t\t\t\tunitControlStateReducer,\n\t\t\t\t\tstateReducer\n\t\t\t\t) }\n\t\t\t/>\n\t\t</Root>\n\t);\n}\n\n/**\n * `UnitControl` allows the user to set a value 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 */\nconst ForwardedUnitControl = forwardRef( UnitControl );\n\nexport { parseUnit, useCustomUnits } from './utils';\nexport default ForwardedUnitControl;\n"]}
1
+ {"version":3,"sources":["@wordpress/components/src/unit-control/index.tsx"],"names":["UnitControl","forwardedRef","__unstableStateReducer","stateReducer","state","autoComplete","className","disabled","disableUnits","isPressEnterToChange","isResetValueOnUnitChange","isUnitSelectTabbable","label","onChange","noop","onUnitChange","size","style","unit","unitProp","units","unitsProp","CSS_UNITS","value","valueProp","props","nonNullValueProp","undefined","parsedQuantity","parsedUnit","setUnit","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","keyCode","ENTER","unitControlStateReducer","action","type","inputControlActionTypes","COMMIT","toString","inputSuffix","step","activeUnit","ForwardedUnitControl"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAgBA;;;;AANA;;AACA;;AAMA;;AACA;;AAMA;;AACA;;AAC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Aa,CAAE,UAAF,CAAb,CAHN;AAIC,IAAA,YAAY,EAAGpB,YAJhB;AAKC,IAAA,SAAS,EAAG6B,OALb;AAMC,IAAA,QAAQ,EAAG3B,QANZ;AAOC,IAAA,YAAY,EAAGC,YAPhB;AAQC,IAAA,oBAAoB,EAAGC,oBARxB;AASC,IAAA,KAAK,EAAGG,KATT;AAUC,IAAA,MAAM,EAAG6C,YAVV;AAWC,IAAA,SAAS,EAAGC,eAXb;AAYC,IAAA,QAAQ,EAAGvB,sBAZZ;AAaC,IAAA,GAAG,EAAGlC,YAbP;AAcC,IAAA,IAAI,EAAGe,IAdR;AAeC,IAAA,MAAM,EAAGmD,WAfV;AAgBC,IAAA,KAAK,EAAGvC,cAAH,aAAGA,cAAH,cAAGA,cAAH,GAAqB,EAhB3B;AAiBC,IAAA,IAAI,EAAGwC,IAjBR;AAkBC,IAAA,sBAAsB,EAAG,mCACxBP,uBADwB,EAExB1D,YAFwB;AAlB1B,KADD,CADD;AA2BA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AACA,MAAMmE,oBAAoB,GAAG,yBAAYtE,WAAZ,CAA7B;eAGesE,oB","sourcesContent":["/**\n * External dependencies\n */\nimport type {\n\tFocusEventHandler,\n\tKeyboardEvent,\n\tForwardedRef,\n\tSyntheticEvent,\n\tChangeEvent,\n} from 'react';\nimport { noop, omit } from 'lodash';\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport { forwardRef, useMemo, useRef, useEffect } from '@wordpress/element';\nimport { __ } from '@wordpress/i18n';\nimport { ENTER } from '@wordpress/keycodes';\n\n/**\n * Internal dependencies\n */\nimport type { WordPressComponentProps } from '../ui/context';\nimport * as inputControlActionTypes from '../input-control/reducer/actions';\nimport { composeStateReducers } from '../input-control/reducer/reducer';\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 UnitControl(\n\t{\n\t\t__unstableStateReducer: stateReducer = ( state ) => state,\n\t\tautoComplete = 'off',\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 = noop,\n\t\tonUnitChange = noop,\n\t\tsize = 'default',\n\t\tstyle,\n\t\tunit: unitProp,\n\t\tunits: unitsProp = CSS_UNITS,\n\t\tvalue: valueProp,\n\t\t...props\n\t}: WordPressComponentProps< UnitControlProps, 'input', false >,\n\tforwardedRef: ForwardedRef< any >\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\tunitProp,\n\t\t{\n\t\t\tinitial: parsedUnit,\n\t\t\tfallback: '',\n\t\t}\n\t);\n\n\tuseEffect( () => {\n\t\tsetUnit( parsedUnit );\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: { event: ChangeEvent< HTMLInputElement > }\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\tonChange( '', 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\tonChange( 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\tonChange( 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 [\n\t\t\tvalidParsedQuantity,\n\t\t\tvalidParsedUnit,\n\t\t] = getValidParsedQuantityAndUnit(\n\t\t\tevent.currentTarget.value,\n\t\t\tunits,\n\t\t\tparsedQuantity,\n\t\t\tunit\n\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\tonChange(\n\t\t\t\t`${ validParsedQuantity ?? '' }${ validParsedUnit }`,\n\t\t\t\tchangeProps\n\t\t\t);\n\t\t\tonUnitChange( validParsedUnit, changeProps );\n\n\t\t\tsetUnit( validParsedUnit );\n\t\t}\n\t};\n\n\tconst handleOnBlur: FocusEventHandler< HTMLInputElement > = mayUpdateUnit;\n\n\tconst handleOnKeyDown = ( event: KeyboardEvent< HTMLInputElement > ) => {\n\t\tconst { keyCode } = event;\n\t\tif ( keyCode === 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\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\tstate.value = ( refParsedQuantity.current ?? '' ).toString();\n\t\t\t\trefParsedQuantity.current = undefined;\n\t\t\t}\n\t\t}\n\n\t\treturn state;\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/>\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{ ...omit( props, [ 'children' ] ) }\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={ composeStateReducers(\n\t\t\t\t\tunitControlStateReducer,\n\t\t\t\t\tstateReducer\n\t\t\t\t) }\n\t\t\t/>\n\t\t</Root>\n\t);\n}\n\n/**\n * `UnitControl` allows the user to set a value 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 */\nconst ForwardedUnitControl = forwardRef( UnitControl );\n\nexport { parseQuantityAndUnitFromRawValue, useCustomUnits } from './utils';\nexport default ForwardedUnitControl;\n"]}
@@ -105,6 +105,8 @@ function UnitControl(_ref) {
105
105
  };
106
106
 
107
107
  const renderUnitPicker = (0, _element.useCallback)(() => {
108
+ // Keeping for legacy reasons, although `false` should not be a valid
109
+ // value for the `units` prop anymore.
108
110
  if (units === false) {
109
111
  return null;
110
112
  }
@@ -147,7 +149,7 @@ function UnitControl(_ref) {
147
149
  shouldDisplayTextInput: true,
148
150
  decimalNum: decimalNum,
149
151
  openUnitPicker: onPickerPresent,
150
- unitLabel: (0, _utils.parseA11yLabelForUnit)(unit)
152
+ unitLabel: (0, _utils.getAccessibleLabelForUnit)(unit)
151
153
  }, props), renderUnitPicker()) : (0, _element.createElement)(_rangeCell.default, (0, _extends2.default)({
152
154
  label: label,
153
155
  onChange: onChange,
@@ -160,7 +162,7 @@ function UnitControl(_ref) {
160
162
  separatorType: separatorType,
161
163
  decimalNum: decimalNum,
162
164
  openUnitPicker: onPickerPresent,
163
- unitLabel: (0, _utils.parseA11yLabelForUnit)(unit)
165
+ unitLabel: (0, _utils.getAccessibleLabelForUnit)(unit)
164
166
  }, props), renderUnitPicker()));
165
167
  }
166
168