@wordpress/components 25.14.0 → 25.15.1-next.79a6196f.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 (568) hide show
  1. package/CHANGELOG.md +51 -0
  2. package/CONTRIBUTING.md +57 -115
  3. package/LICENSE.md +1 -1
  4. package/build/base-control/index.js +17 -13
  5. package/build/base-control/index.js.map +1 -1
  6. package/build/border-box-control/border-box-control-linked-button/component.js +1 -1
  7. package/build/border-box-control/border-box-control-linked-button/component.js.map +1 -1
  8. package/build/border-control/border-control-style-picker/component.js +1 -1
  9. package/build/border-control/border-control-style-picker/component.js.map +1 -1
  10. package/build/box-control/index.js +1 -1
  11. package/build/box-control/index.js.map +1 -1
  12. package/build/box-control/linked-button.js +1 -1
  13. package/build/box-control/linked-button.js.map +1 -1
  14. package/build/button/index.js +1 -1
  15. package/build/button/index.js.map +1 -1
  16. package/build/color-palette/index.native.js +11 -7
  17. package/build/color-palette/index.native.js.map +1 -1
  18. package/build/color-picker/color-copy-button.js +1 -1
  19. package/build/color-picker/color-copy-button.js.map +1 -1
  20. package/build/context/wordpress-component.js.map +1 -1
  21. package/build/custom-select-control-v2/index.js +11 -10
  22. package/build/custom-select-control-v2/index.js.map +1 -1
  23. package/build/date-time/date/styles.js +8 -8
  24. package/build/date-time/date/styles.js.map +1 -1
  25. package/build/dropdown-menu-v2/index.js +205 -159
  26. package/build/dropdown-menu-v2/index.js.map +1 -1
  27. package/build/dropdown-menu-v2/styles.js +86 -77
  28. package/build/dropdown-menu-v2/styles.js.map +1 -1
  29. package/build/dropdown-menu-v2/types.js.map +1 -1
  30. package/build/duotone-picker/duotone-picker.js +4 -3
  31. package/build/duotone-picker/duotone-picker.js.map +1 -1
  32. package/build/font-size-picker/index.js +4 -2
  33. package/build/font-size-picker/index.js.map +1 -1
  34. package/build/font-size-picker/index.native.js +6 -3
  35. package/build/font-size-picker/index.native.js.map +1 -1
  36. package/build/form-token-field/index.js +10 -5
  37. package/build/form-token-field/index.js.map +1 -1
  38. package/build/form-token-field/token.js +1 -0
  39. package/build/form-token-field/token.js.map +1 -1
  40. package/build/gradient-picker/index.js +3 -2
  41. package/build/gradient-picker/index.js.map +1 -1
  42. package/build/index.native.js +20 -3
  43. package/build/index.native.js.map +1 -1
  44. package/build/input-control/styles/input-control-styles.js +32 -29
  45. package/build/input-control/styles/input-control-styles.js.map +1 -1
  46. package/build/input-control/types.js.map +1 -1
  47. package/build/lock-unlock.js +18 -0
  48. package/build/lock-unlock.js.map +1 -0
  49. package/build/mobile/bottom-sheet/index.native.js +8 -0
  50. package/build/mobile/bottom-sheet/index.native.js.map +1 -1
  51. package/build/mobile/color-settings/palette.screen.native.js +8 -4
  52. package/build/mobile/color-settings/palette.screen.native.js.map +1 -1
  53. package/build/mobile/global-styles-context/utils.native.js +26 -13
  54. package/build/mobile/global-styles-context/utils.native.js.map +1 -1
  55. package/build/mobile/image/constants.js +12 -0
  56. package/build/mobile/image/constants.js.map +1 -0
  57. package/build/mobile/image/index.native.js +26 -18
  58. package/build/mobile/image/index.native.js.map +1 -1
  59. package/build/mobile/keyboard-aware-flat-list/index.android.js +40 -8
  60. package/build/mobile/keyboard-aware-flat-list/index.android.js.map +1 -1
  61. package/build/mobile/keyboard-aware-flat-list/index.ios.js +44 -68
  62. package/build/mobile/keyboard-aware-flat-list/index.ios.js.map +1 -1
  63. package/build/mobile/keyboard-aware-flat-list/use-scroll-to-element.native.js +39 -0
  64. package/build/mobile/keyboard-aware-flat-list/use-scroll-to-element.native.js.map +1 -0
  65. package/build/mobile/keyboard-aware-flat-list/{use-scroll-to-text-input.native.js → use-scroll-to-section.native.js} +22 -29
  66. package/build/mobile/keyboard-aware-flat-list/use-scroll-to-section.native.js.map +1 -0
  67. package/build/mobile/keyboard-aware-flat-list/use-scroll.native.js +93 -0
  68. package/build/mobile/keyboard-aware-flat-list/use-scroll.native.js.map +1 -0
  69. package/build/mobile/utils/get-px-from-css-unit.native.js +302 -0
  70. package/build/mobile/utils/get-px-from-css-unit.native.js.map +1 -0
  71. package/build/modal/index.js +18 -13
  72. package/build/modal/index.js.map +1 -1
  73. package/build/navigation/menu/menu-title.js +1 -1
  74. package/build/navigation/menu/menu-title.js.map +1 -1
  75. package/build/navigator/navigator-provider/component.js +13 -15
  76. package/build/navigator/navigator-provider/component.js.map +1 -1
  77. package/build/navigator/navigator-screen/component.js +23 -63
  78. package/build/navigator/navigator-screen/component.js.map +1 -1
  79. package/build/navigator/styles.js +52 -0
  80. package/build/navigator/styles.js.map +1 -0
  81. package/build/number-control/index.js +4 -8
  82. package/build/number-control/index.js.map +1 -1
  83. package/build/number-control/types.js.map +1 -1
  84. package/build/palette-edit/index.js +15 -54
  85. package/build/palette-edit/index.js.map +1 -1
  86. package/build/private-apis.js +11 -26
  87. package/build/private-apis.js.map +1 -1
  88. package/build/private-apis.native.js +21 -0
  89. package/build/private-apis.native.js.map +1 -0
  90. package/build/radio-control/index.js +1 -0
  91. package/build/radio-control/index.js.map +1 -1
  92. package/build/range-control/index.js +1 -1
  93. package/build/range-control/index.js.map +1 -1
  94. package/build/select-control/styles/select-control-styles.js +15 -25
  95. package/build/select-control/styles/select-control-styles.js.map +1 -1
  96. package/build/slot-fill/index.js +3 -2
  97. package/build/slot-fill/index.js.map +1 -1
  98. package/build/slot-fill/types.js.map +1 -1
  99. package/build/snackbar/types.js.map +1 -1
  100. package/build/tabs/styles.js +3 -3
  101. package/build/tabs/styles.js.map +1 -1
  102. package/build/tabs/tabpanel.js +9 -7
  103. package/build/tabs/tabpanel.js.map +1 -1
  104. package/build/toggle-group-control/toggle-group-control/component.js +4 -4
  105. package/build/toggle-group-control/toggle-group-control/component.js.map +1 -1
  106. package/build/toggle-group-control/toggle-group-control/styles.js +29 -15
  107. package/build/toggle-group-control/toggle-group-control/styles.js.map +1 -1
  108. package/build/toggle-group-control/toggle-group-control-option-base/styles.js +9 -9
  109. package/build/toggle-group-control/toggle-group-control-option-base/styles.js.map +1 -1
  110. package/build/tools-panel/tools-panel/component.js +3 -1
  111. package/build/tools-panel/tools-panel/component.js.map +1 -1
  112. package/build/tools-panel/tools-panel-header/component.js +9 -8
  113. package/build/tools-panel/tools-panel-header/component.js.map +1 -1
  114. package/build/tools-panel/types.js.map +1 -1
  115. package/build/tooltip/index.js +34 -10
  116. package/build/tooltip/index.js.map +1 -1
  117. package/build/tooltip/types.js.map +1 -1
  118. package/build/truncate/hook.js +10 -4
  119. package/build/truncate/hook.js.map +1 -1
  120. package/build/truncate/types.js.map +1 -1
  121. package/build/unit-control/index.js +1 -1
  122. package/build/unit-control/index.js.map +1 -1
  123. package/build/utils/strings.js +34 -3
  124. package/build/utils/strings.js.map +1 -1
  125. package/build-module/base-control/index.js +16 -12
  126. package/build-module/base-control/index.js.map +1 -1
  127. package/build-module/border-box-control/border-box-control-linked-button/component.js +1 -1
  128. package/build-module/border-box-control/border-box-control-linked-button/component.js.map +1 -1
  129. package/build-module/border-control/border-control-style-picker/component.js +1 -1
  130. package/build-module/border-control/border-control-style-picker/component.js.map +1 -1
  131. package/build-module/box-control/index.js +1 -1
  132. package/build-module/box-control/index.js.map +1 -1
  133. package/build-module/box-control/linked-button.js +1 -1
  134. package/build-module/box-control/linked-button.js.map +1 -1
  135. package/build-module/button/index.js +1 -1
  136. package/build-module/button/index.js.map +1 -1
  137. package/build-module/color-palette/index.native.js +11 -7
  138. package/build-module/color-palette/index.native.js.map +1 -1
  139. package/build-module/color-picker/color-copy-button.js +1 -1
  140. package/build-module/color-picker/color-copy-button.js.map +1 -1
  141. package/build-module/context/wordpress-component.js.map +1 -1
  142. package/build-module/custom-select-control-v2/index.js +11 -10
  143. package/build-module/custom-select-control-v2/index.js.map +1 -1
  144. package/build-module/date-time/date/styles.js +8 -8
  145. package/build-module/date-time/date/styles.js.map +1 -1
  146. package/build-module/dropdown-menu-v2/index.js +201 -154
  147. package/build-module/dropdown-menu-v2/index.js.map +1 -1
  148. package/build-module/dropdown-menu-v2/styles.js +68 -61
  149. package/build-module/dropdown-menu-v2/styles.js.map +1 -1
  150. package/build-module/dropdown-menu-v2/types.js.map +1 -1
  151. package/build-module/duotone-picker/duotone-picker.js +4 -3
  152. package/build-module/duotone-picker/duotone-picker.js.map +1 -1
  153. package/build-module/font-size-picker/index.js +4 -2
  154. package/build-module/font-size-picker/index.js.map +1 -1
  155. package/build-module/font-size-picker/index.native.js +5 -2
  156. package/build-module/font-size-picker/index.native.js.map +1 -1
  157. package/build-module/form-token-field/index.js +10 -5
  158. package/build-module/form-token-field/index.js.map +1 -1
  159. package/build-module/form-token-field/token.js +1 -0
  160. package/build-module/form-token-field/token.js.map +1 -1
  161. package/build-module/gradient-picker/index.js +3 -2
  162. package/build-module/gradient-picker/index.js.map +1 -1
  163. package/build-module/index.native.js +6 -1
  164. package/build-module/index.native.js.map +1 -1
  165. package/build-module/input-control/styles/input-control-styles.js +31 -29
  166. package/build-module/input-control/styles/input-control-styles.js.map +1 -1
  167. package/build-module/input-control/types.js.map +1 -1
  168. package/build-module/lock-unlock.js +9 -0
  169. package/build-module/lock-unlock.js.map +1 -0
  170. package/build-module/mobile/bottom-sheet/index.native.js +9 -1
  171. package/build-module/mobile/bottom-sheet/index.native.js.map +1 -1
  172. package/build-module/mobile/color-settings/palette.screen.native.js +8 -4
  173. package/build-module/mobile/color-settings/palette.screen.native.js.map +1 -1
  174. package/build-module/mobile/global-styles-context/utils.native.js +25 -13
  175. package/build-module/mobile/global-styles-context/utils.native.js.map +1 -1
  176. package/build-module/mobile/image/constants.js +5 -0
  177. package/build-module/mobile/image/constants.js.map +1 -0
  178. package/build-module/mobile/image/index.native.js +25 -16
  179. package/build-module/mobile/image/index.native.js.map +1 -1
  180. package/build-module/mobile/keyboard-aware-flat-list/index.android.js +40 -6
  181. package/build-module/mobile/keyboard-aware-flat-list/index.android.js.map +1 -1
  182. package/build-module/mobile/keyboard-aware-flat-list/index.ios.js +46 -68
  183. package/build-module/mobile/keyboard-aware-flat-list/index.ios.js.map +1 -1
  184. package/build-module/mobile/keyboard-aware-flat-list/use-scroll-to-element.native.js +33 -0
  185. package/build-module/mobile/keyboard-aware-flat-list/use-scroll-to-element.native.js.map +1 -0
  186. package/build-module/mobile/keyboard-aware-flat-list/{use-scroll-to-text-input.native.js → use-scroll-to-section.native.js} +21 -27
  187. package/build-module/mobile/keyboard-aware-flat-list/use-scroll-to-section.native.js.map +1 -0
  188. package/build-module/mobile/keyboard-aware-flat-list/use-scroll.native.js +86 -0
  189. package/build-module/mobile/keyboard-aware-flat-list/use-scroll.native.js.map +1 -0
  190. package/build-module/mobile/utils/get-px-from-css-unit.native.js +294 -0
  191. package/build-module/mobile/utils/get-px-from-css-unit.native.js.map +1 -0
  192. package/build-module/modal/index.js +18 -13
  193. package/build-module/modal/index.js.map +1 -1
  194. package/build-module/navigation/menu/menu-title.js +1 -1
  195. package/build-module/navigation/menu/menu-title.js.map +1 -1
  196. package/build-module/navigator/navigator-provider/component.js +3 -16
  197. package/build-module/navigator/navigator-provider/component.js.map +1 -1
  198. package/build-module/navigator/navigator-screen/component.js +16 -70
  199. package/build-module/navigator/navigator-screen/component.js.map +1 -1
  200. package/build-module/navigator/styles.js +47 -0
  201. package/build-module/navigator/styles.js.map +1 -0
  202. package/build-module/number-control/index.js +4 -8
  203. package/build-module/number-control/index.js.map +1 -1
  204. package/build-module/number-control/types.js.map +1 -1
  205. package/build-module/palette-edit/index.js +15 -51
  206. package/build-module/palette-edit/index.js.map +1 -1
  207. package/build-module/private-apis.js +10 -23
  208. package/build-module/private-apis.js.map +1 -1
  209. package/build-module/private-apis.native.js +14 -0
  210. package/build-module/private-apis.native.js.map +1 -0
  211. package/build-module/radio-control/index.js +1 -0
  212. package/build-module/radio-control/index.js.map +1 -1
  213. package/build-module/range-control/index.js +1 -1
  214. package/build-module/range-control/index.js.map +1 -1
  215. package/build-module/select-control/styles/select-control-styles.js +15 -25
  216. package/build-module/select-control/styles/select-control-styles.js.map +1 -1
  217. package/build-module/slot-fill/index.js +3 -2
  218. package/build-module/slot-fill/index.js.map +1 -1
  219. package/build-module/slot-fill/types.js.map +1 -1
  220. package/build-module/snackbar/types.js.map +1 -1
  221. package/build-module/tabs/styles.js +3 -3
  222. package/build-module/tabs/styles.js.map +1 -1
  223. package/build-module/tabs/tabpanel.js +9 -7
  224. package/build-module/tabs/tabpanel.js.map +1 -1
  225. package/build-module/toggle-group-control/toggle-group-control/component.js +4 -4
  226. package/build-module/toggle-group-control/toggle-group-control/component.js.map +1 -1
  227. package/build-module/toggle-group-control/toggle-group-control/styles.js +29 -15
  228. package/build-module/toggle-group-control/toggle-group-control/styles.js.map +1 -1
  229. package/build-module/toggle-group-control/toggle-group-control-option-base/styles.js +9 -9
  230. package/build-module/toggle-group-control/toggle-group-control-option-base/styles.js.map +1 -1
  231. package/build-module/tools-panel/tools-panel/component.js +3 -1
  232. package/build-module/tools-panel/tools-panel/component.js.map +1 -1
  233. package/build-module/tools-panel/tools-panel-header/component.js +9 -8
  234. package/build-module/tools-panel/tools-panel-header/component.js.map +1 -1
  235. package/build-module/tools-panel/types.js.map +1 -1
  236. package/build-module/tooltip/index.js +34 -12
  237. package/build-module/tooltip/index.js.map +1 -1
  238. package/build-module/tooltip/types.js.map +1 -1
  239. package/build-module/truncate/hook.js +10 -4
  240. package/build-module/truncate/hook.js.map +1 -1
  241. package/build-module/truncate/types.js.map +1 -1
  242. package/build-module/unit-control/index.js +1 -1
  243. package/build-module/unit-control/index.js.map +1 -1
  244. package/build-module/utils/strings.js +32 -2
  245. package/build-module/utils/strings.js.map +1 -1
  246. package/build-style/style-rtl.css +29 -5
  247. package/build-style/style.css +29 -5
  248. package/build-types/base-control/index.d.ts +3 -27
  249. package/build-types/base-control/index.d.ts.map +1 -1
  250. package/build-types/base-control/stories/index.story.d.ts +4 -1
  251. package/build-types/base-control/stories/index.story.d.ts.map +1 -1
  252. package/build-types/border-box-control/border-box-control/hook.d.ts +4 -4
  253. package/build-types/border-box-control/border-box-control-linked-button/hook.d.ts +6 -6
  254. package/build-types/border-box-control/border-box-control-split-controls/hook.d.ts +4 -4
  255. package/build-types/border-box-control/border-box-control-visualizer/hook.d.ts +4 -4
  256. package/build-types/border-box-control/stories/index.story.d.ts +1 -1
  257. package/build-types/border-control/border-control/hook.d.ts +4 -4
  258. package/build-types/border-control/border-control-dropdown/hook.d.ts +4 -4
  259. package/build-types/border-control/border-control-style-picker/hook.d.ts +4 -4
  260. package/build-types/border-control/stories/index.story.d.ts +6 -6
  261. package/build-types/box-control/stories/index.story.d.ts +42 -42
  262. package/build-types/box-control/styles/box-control-styles.d.ts +1 -1
  263. package/build-types/button/deprecated.d.ts +3 -3
  264. package/build-types/card/card/hook.d.ts +4 -4
  265. package/build-types/card/card-body/hook.d.ts +4 -4
  266. package/build-types/card/card-divider/hook.d.ts +4 -4
  267. package/build-types/card/card-footer/hook.d.ts +4 -4
  268. package/build-types/card/card-header/hook.d.ts +4 -4
  269. package/build-types/card/card-media/hook.d.ts +4 -4
  270. package/build-types/color-palette/styles.d.ts +2 -2
  271. package/build-types/color-picker/component.d.ts +2 -2
  272. package/build-types/color-picker/stories/index.story.d.ts +1 -1
  273. package/build-types/color-picker/stories/index.story.d.ts.map +1 -1
  274. package/build-types/color-picker/styles.d.ts +3 -3
  275. package/build-types/composite/test/index.d.ts.map +1 -0
  276. package/build-types/context/wordpress-component.d.ts +3 -3
  277. package/build-types/context/wordpress-component.d.ts.map +1 -1
  278. package/build-types/custom-select-control-v2/index.d.ts +3 -2
  279. package/build-types/custom-select-control-v2/index.d.ts.map +1 -1
  280. package/build-types/custom-select-control-v2/stories/index.story.d.ts +4 -3
  281. package/build-types/custom-select-control-v2/stories/index.story.d.ts.map +1 -1
  282. package/build-types/date-time/date/styles.d.ts +3 -3
  283. package/build-types/date-time/date-time/styles.d.ts +1 -1
  284. package/build-types/date-time/time/styles.d.ts +4 -4
  285. package/build-types/dropdown/index.d.ts +1 -1
  286. package/build-types/dropdown/index.d.ts.map +1 -1
  287. package/build-types/dropdown/stories/index.story.d.ts +3 -3
  288. package/build-types/dropdown/stories/index.story.d.ts.map +1 -1
  289. package/build-types/dropdown-menu/index.d.ts +1 -1
  290. package/build-types/dropdown-menu/index.d.ts.map +1 -1
  291. package/build-types/dropdown-menu/stories/index.story.d.ts +2 -2
  292. package/build-types/dropdown-menu/stories/index.story.d.ts.map +1 -1
  293. package/build-types/dropdown-menu-v2/index.d.ts +18 -15
  294. package/build-types/dropdown-menu-v2/index.d.ts.map +1 -1
  295. package/build-types/dropdown-menu-v2/stories/index.story.d.ts +7 -2
  296. package/build-types/dropdown-menu-v2/stories/index.story.d.ts.map +1 -1
  297. package/build-types/dropdown-menu-v2/styles.d.ts +77 -23
  298. package/build-types/dropdown-menu-v2/styles.d.ts.map +1 -1
  299. package/build-types/dropdown-menu-v2/types.d.ts +89 -173
  300. package/build-types/dropdown-menu-v2/types.d.ts.map +1 -1
  301. package/build-types/duotone-picker/duotone-picker.d.ts.map +1 -1
  302. package/build-types/elevation/hook.d.ts +4 -4
  303. package/build-types/flex/flex/hook.d.ts +4 -4
  304. package/build-types/flex/flex-block/hook.d.ts +4 -4
  305. package/build-types/flex/flex-item/hook.d.ts +4 -4
  306. package/build-types/focal-point-picker/stories/index.story.d.ts +4 -4
  307. package/build-types/focal-point-picker/styles/focal-point-picker-style.d.ts +1 -1
  308. package/build-types/font-size-picker/index.d.ts.map +1 -1
  309. package/build-types/font-size-picker/styles.d.ts +1 -1
  310. package/build-types/form-token-field/index.d.ts.map +1 -1
  311. package/build-types/form-token-field/token.d.ts.map +1 -1
  312. package/build-types/grid/hook.d.ts +4 -4
  313. package/build-types/h-stack/hook.d.ts +4 -4
  314. package/build-types/heading/component.d.ts +1 -1
  315. package/build-types/heading/hook.d.ts +4 -4
  316. package/build-types/input-control/styles/input-control-styles.d.ts +11 -0
  317. package/build-types/input-control/styles/input-control-styles.d.ts.map +1 -1
  318. package/build-types/input-control/types.d.ts +1 -1
  319. package/build-types/input-control/types.d.ts.map +1 -1
  320. package/build-types/item-group/item/hook.d.ts +4 -4
  321. package/build-types/item-group/item-group/hook.d.ts +4 -4
  322. package/build-types/lock-unlock.d.ts +3 -0
  323. package/build-types/lock-unlock.d.ts.map +1 -0
  324. package/build-types/menu-item/index.d.ts +1 -1
  325. package/build-types/menu-item/stories/index.story.d.ts +4 -4
  326. package/build-types/mobile/image/constants.d.ts +5 -0
  327. package/build-types/mobile/image/constants.d.ts.map +1 -0
  328. package/build-types/modal/index.d.ts.map +1 -1
  329. package/build-types/navigation/styles/navigation-styles.d.ts +3 -3
  330. package/build-types/navigator/navigator-back-button/hook.d.ts +6 -6
  331. package/build-types/navigator/navigator-button/hook.d.ts +6 -6
  332. package/build-types/navigator/navigator-provider/component.d.ts.map +1 -1
  333. package/build-types/navigator/navigator-screen/component.d.ts +1 -7
  334. package/build-types/navigator/navigator-screen/component.d.ts.map +1 -1
  335. package/build-types/navigator/styles.d.ts +9 -0
  336. package/build-types/navigator/styles.d.ts.map +1 -0
  337. package/build-types/number-control/index.d.ts +1 -1
  338. package/build-types/number-control/index.d.ts.map +1 -1
  339. package/build-types/number-control/stories/index.story.d.ts +1 -1
  340. package/build-types/number-control/types.d.ts +1 -1
  341. package/build-types/palette-edit/index.d.ts +3 -8
  342. package/build-types/palette-edit/index.d.ts.map +1 -1
  343. package/build-types/palette-edit/styles.d.ts +3 -3
  344. package/build-types/popover/index.d.ts +1 -1
  345. package/build-types/popover/index.d.ts.map +1 -1
  346. package/build-types/popover/stories/e2e/index.story.d.ts +1 -1
  347. package/build-types/private-apis.d.ts +0 -1
  348. package/build-types/private-apis.d.ts.map +1 -1
  349. package/build-types/radio-control/index.d.ts.map +1 -1
  350. package/build-types/range-control/index.d.ts +1 -1
  351. package/build-types/range-control/styles/range-control-styles.d.ts +1 -1
  352. package/build-types/resizable-box/index.d.ts +1 -1
  353. package/build-types/resizable-box/resize-tooltip/index.d.ts +1 -1
  354. package/build-types/resizable-box/stories/index.story.d.ts +2 -2
  355. package/build-types/scrollable/hook.d.ts +4 -4
  356. package/build-types/search-control/index.d.ts +1 -1
  357. package/build-types/search-control/stories/index.story.d.ts +2 -2
  358. package/build-types/select-control/styles/select-control-styles.d.ts.map +1 -1
  359. package/build-types/slot-fill/index.d.ts +1 -1
  360. package/build-types/slot-fill/index.d.ts.map +1 -1
  361. package/build-types/slot-fill/types.d.ts +4 -0
  362. package/build-types/slot-fill/types.d.ts.map +1 -1
  363. package/build-types/snackbar/index.d.ts +2 -2
  364. package/build-types/snackbar/stories/index.story.d.ts +0 -3
  365. package/build-types/snackbar/stories/index.story.d.ts.map +1 -1
  366. package/build-types/snackbar/types.d.ts +1 -1
  367. package/build-types/snackbar/types.d.ts.map +1 -1
  368. package/build-types/spacer/hook.d.ts +4 -4
  369. package/build-types/surface/hook.d.ts +4 -4
  370. package/build-types/tabs/styles.d.ts.map +1 -1
  371. package/build-types/tabs/tabpanel.d.ts +1 -1
  372. package/build-types/tabs/tabpanel.d.ts.map +1 -1
  373. package/build-types/text/hook.d.ts +4 -4
  374. package/build-types/text-control/index.d.ts +1 -1
  375. package/build-types/textarea-control/index.d.ts +1 -1
  376. package/build-types/toggle-control/stories/index.story.d.ts +2 -2
  377. package/build-types/toggle-group-control/toggle-group-control/as-button-group.d.ts +1 -1
  378. package/build-types/toggle-group-control/toggle-group-control/as-radio-group.d.ts +1 -1
  379. package/build-types/toggle-group-control/toggle-group-control/component.d.ts.map +1 -1
  380. package/build-types/toggle-group-control/toggle-group-control/styles.d.ts +2 -2
  381. package/build-types/toggle-group-control/toggle-group-control/styles.d.ts.map +1 -1
  382. package/build-types/toggle-group-control/toggle-group-control-option/component.d.ts +1 -1
  383. package/build-types/toggle-group-control/toggle-group-control-option-base/component.d.ts +1 -1
  384. package/build-types/toggle-group-control/toggle-group-control-option-base/component.d.ts.map +1 -1
  385. package/build-types/toggle-group-control/toggle-group-control-option-base/styles.d.ts.map +1 -1
  386. package/build-types/toggle-group-control/toggle-group-control-option-icon/component.d.ts +1 -1
  387. package/build-types/toolbar/toolbar-button/index.d.ts +3 -3
  388. package/build-types/tools-panel/tools-panel/component.d.ts.map +1 -1
  389. package/build-types/tools-panel/tools-panel/hook.d.ts +5 -4
  390. package/build-types/tools-panel/tools-panel/hook.d.ts.map +1 -1
  391. package/build-types/tools-panel/tools-panel-header/component.d.ts.map +1 -1
  392. package/build-types/tools-panel/tools-panel-header/hook.d.ts +5 -4
  393. package/build-types/tools-panel/tools-panel-header/hook.d.ts.map +1 -1
  394. package/build-types/tools-panel/tools-panel-item/hook.d.ts +4 -4
  395. package/build-types/tools-panel/types.d.ts +9 -0
  396. package/build-types/tools-panel/types.d.ts.map +1 -1
  397. package/build-types/tooltip/index.d.ts +1 -1
  398. package/build-types/tooltip/index.d.ts.map +1 -1
  399. package/build-types/tooltip/stories/index.story.d.ts +10 -1
  400. package/build-types/tooltip/stories/index.story.d.ts.map +1 -1
  401. package/build-types/tooltip/types.d.ts +3 -0
  402. package/build-types/tooltip/types.d.ts.map +1 -1
  403. package/build-types/truncate/hook.d.ts +5 -5
  404. package/build-types/truncate/hook.d.ts.map +1 -1
  405. package/build-types/truncate/types.d.ts +4 -0
  406. package/build-types/truncate/types.d.ts.map +1 -1
  407. package/build-types/unit-control/index.d.ts +1 -1
  408. package/build-types/unit-control/styles/unit-control-styles.d.ts +1 -1
  409. package/build-types/utils/strings.d.ts +14 -2
  410. package/build-types/utils/strings.d.ts.map +1 -1
  411. package/build-types/v-stack/hook.d.ts +4 -4
  412. package/build-types/v-stack/stories/index.story.d.ts +1 -1
  413. package/package.json +20 -21
  414. package/src/alignment-matrix-control/test/index.tsx +10 -16
  415. package/src/base-control/index.tsx +21 -16
  416. package/src/border-box-control/border-box-control-linked-button/component.tsx +1 -1
  417. package/src/border-control/border-control-style-picker/component.tsx +1 -1
  418. package/src/box-control/index.tsx +1 -1
  419. package/src/box-control/linked-button.tsx +1 -1
  420. package/src/button/README.md +32 -6
  421. package/src/button/index.tsx +1 -1
  422. package/src/button-group/README.md +0 -6
  423. package/src/card/card/README.md +1 -1
  424. package/src/checkbox-control/README.md +1 -9
  425. package/src/color-palette/index.native.js +18 -7
  426. package/src/color-picker/color-copy-button.tsx +1 -1
  427. package/src/combobox-control/README.md +0 -6
  428. package/src/composite/test/index.tsx +576 -0
  429. package/src/context/wordpress-component.ts +11 -6
  430. package/src/custom-select-control/README.md +0 -6
  431. package/src/custom-select-control-v2/index.tsx +13 -12
  432. package/src/date-time/date/styles.ts +3 -3
  433. package/src/dropdown-menu/README.md +0 -5
  434. package/src/dropdown-menu-v2/README.md +75 -136
  435. package/src/dropdown-menu-v2/index.tsx +321 -231
  436. package/src/dropdown-menu-v2/stories/index.story.tsx +522 -126
  437. package/src/dropdown-menu-v2/styles.ts +226 -151
  438. package/src/dropdown-menu-v2/test/index.tsx +480 -188
  439. package/src/dropdown-menu-v2/types.ts +98 -184
  440. package/src/duotone-picker/duotone-picker.tsx +7 -3
  441. package/src/font-size-picker/index.native.js +8 -2
  442. package/src/font-size-picker/index.tsx +4 -2
  443. package/src/form-toggle/README.md +0 -6
  444. package/src/form-token-field/index.tsx +11 -7
  445. package/src/form-token-field/test/index.tsx +97 -0
  446. package/src/form-token-field/token.tsx +1 -0
  447. package/src/gradient-picker/index.tsx +2 -2
  448. package/src/index.native.js +6 -1
  449. package/src/input-control/styles/input-control-styles.tsx +10 -8
  450. package/src/input-control/types.ts +1 -1
  451. package/src/lock-unlock.js +10 -0
  452. package/src/menu-group/README.md +0 -8
  453. package/src/menu-items-choice/README.md +0 -7
  454. package/src/mobile/bottom-sheet/index.native.js +15 -1
  455. package/src/mobile/color-settings/palette.screen.native.js +7 -5
  456. package/src/mobile/global-styles-context/test/fixtures/theme.native.js +0 -20
  457. package/src/mobile/global-styles-context/utils.native.js +28 -19
  458. package/src/mobile/image/constants.js +1 -0
  459. package/src/mobile/image/index.native.js +55 -18
  460. package/src/mobile/image/style.native.scss +35 -9
  461. package/src/mobile/keyboard-aware-flat-list/index.android.js +50 -5
  462. package/src/mobile/keyboard-aware-flat-list/index.ios.js +65 -91
  463. package/src/mobile/keyboard-aware-flat-list/test/{use-scroll-to-text-input.native.js → use-scroll-to-section.native.js} +27 -25
  464. package/src/mobile/keyboard-aware-flat-list/test/use-scroll.native.js +71 -0
  465. package/src/mobile/keyboard-aware-flat-list/use-scroll-to-element.native.js +41 -0
  466. package/src/mobile/keyboard-aware-flat-list/{use-scroll-to-text-input.native.js → use-scroll-to-section.native.js} +22 -27
  467. package/src/mobile/keyboard-aware-flat-list/use-scroll.native.js +100 -0
  468. package/src/mobile/utils/get-px-from-css-unit.native.js +329 -0
  469. package/src/mobile/utils/test/get-px-from-css-unit.native.js +172 -0
  470. package/src/modal/README.md +0 -6
  471. package/src/modal/index.tsx +18 -16
  472. package/src/modal/test/index.tsx +90 -1
  473. package/src/navigation/menu/menu-title.tsx +1 -1
  474. package/src/navigator/navigator-provider/component.tsx +3 -4
  475. package/src/navigator/navigator-screen/component.tsx +15 -93
  476. package/src/navigator/styles.ts +71 -0
  477. package/src/navigator/test/index.tsx +0 -64
  478. package/src/notice/README.md +0 -6
  479. package/src/number-control/README.md +2 -2
  480. package/src/number-control/index.tsx +4 -8
  481. package/src/number-control/types.ts +1 -1
  482. package/src/palette-edit/index.tsx +15 -58
  483. package/src/palette-edit/test/index.tsx +1 -75
  484. package/src/panel/README.md +0 -6
  485. package/src/private-apis.native.js +13 -0
  486. package/src/private-apis.ts +12 -37
  487. package/src/radio-control/README.md +0 -6
  488. package/src/radio-control/index.tsx +4 -1
  489. package/src/radio-control/style.scss +29 -2
  490. package/src/radio-group/README.md +0 -6
  491. package/src/range-control/README.md +1 -9
  492. package/src/range-control/index.tsx +1 -1
  493. package/src/search-control/README.md +0 -6
  494. package/src/select-control/README.md +0 -6
  495. package/src/select-control/styles/select-control-styles.ts +10 -28
  496. package/src/slot-fill/index.tsx +5 -2
  497. package/src/slot-fill/types.ts +5 -0
  498. package/src/snackbar/README.md +0 -6
  499. package/src/snackbar/stories/index.story.tsx +7 -5
  500. package/src/snackbar/style.scss +4 -3
  501. package/src/snackbar/types.ts +2 -1
  502. package/src/spacer/README.md +0 -2
  503. package/src/tab-panel/README.md +0 -5
  504. package/src/tab-panel/test/index.tsx +39 -56
  505. package/src/tabs/styles.ts +7 -1
  506. package/src/tabs/tabpanel.tsx +7 -6
  507. package/src/tabs/test/index.tsx +56 -0
  508. package/src/text-control/README.md +0 -6
  509. package/src/textarea-control/README.md +0 -6
  510. package/src/toggle-group-control/test/__snapshots__/index.tsx.snap +12 -16
  511. package/src/toggle-group-control/test/index.tsx +58 -45
  512. package/src/toggle-group-control/toggle-group-control/component.tsx +5 -4
  513. package/src/toggle-group-control/toggle-group-control/styles.ts +13 -19
  514. package/src/toggle-group-control/toggle-group-control-option/README.md +1 -1
  515. package/src/toggle-group-control/toggle-group-control-option-base/README.md +1 -1
  516. package/src/toggle-group-control/toggle-group-control-option-base/styles.ts +3 -2
  517. package/src/toggle-group-control/toggle-group-control-option-icon/README.md +1 -1
  518. package/src/toolbar/toolbar/README.md +0 -6
  519. package/src/tools-panel/test/index.tsx +12 -20
  520. package/src/tools-panel/tools-panel/README.md +7 -0
  521. package/src/tools-panel/tools-panel/component.tsx +2 -0
  522. package/src/tools-panel/tools-panel-header/README.md +7 -0
  523. package/src/tools-panel/tools-panel-header/component.tsx +20 -13
  524. package/src/tools-panel/types.ts +9 -0
  525. package/src/tooltip/README.md +4 -0
  526. package/src/tooltip/index.tsx +48 -10
  527. package/src/tooltip/stories/index.story.tsx +18 -1
  528. package/src/tooltip/test/index.tsx +404 -254
  529. package/src/tooltip/types.ts +4 -0
  530. package/src/tree-grid/README.md +0 -4
  531. package/src/truncate/README.md +8 -0
  532. package/src/truncate/hook.ts +17 -10
  533. package/src/truncate/test/index.tsx +54 -27
  534. package/src/truncate/types.ts +4 -0
  535. package/src/unit-control/index.tsx +1 -1
  536. package/src/utils/strings.ts +30 -2
  537. package/src/utils/test/strings.js +96 -1
  538. package/tsconfig.tsbuildinfo +1 -1
  539. package/build/dropdown-menu-v2-ariakit/index.js +0 -256
  540. package/build/dropdown-menu-v2-ariakit/index.js.map +0 -1
  541. package/build/dropdown-menu-v2-ariakit/styles.js +0 -180
  542. package/build/dropdown-menu-v2-ariakit/styles.js.map +0 -1
  543. package/build/dropdown-menu-v2-ariakit/types.js +0 -6
  544. package/build/dropdown-menu-v2-ariakit/types.js.map +0 -1
  545. package/build/mobile/keyboard-aware-flat-list/use-scroll-to-text-input.native.js.map +0 -1
  546. package/build-module/dropdown-menu-v2-ariakit/index.js +0 -237
  547. package/build-module/dropdown-menu-v2-ariakit/index.js.map +0 -1
  548. package/build-module/dropdown-menu-v2-ariakit/styles.js +0 -165
  549. package/build-module/dropdown-menu-v2-ariakit/styles.js.map +0 -1
  550. package/build-module/dropdown-menu-v2-ariakit/types.js +0 -2
  551. package/build-module/dropdown-menu-v2-ariakit/types.js.map +0 -1
  552. package/build-module/mobile/keyboard-aware-flat-list/use-scroll-to-text-input.native.js.map +0 -1
  553. package/build-types/dropdown-menu-v2-ariakit/index.d.ts +0 -20
  554. package/build-types/dropdown-menu-v2-ariakit/index.d.ts.map +0 -1
  555. package/build-types/dropdown-menu-v2-ariakit/stories/index.story.d.ts +0 -16
  556. package/build-types/dropdown-menu-v2-ariakit/stories/index.story.d.ts.map +0 -1
  557. package/build-types/dropdown-menu-v2-ariakit/styles.d.ts +0 -96
  558. package/build-types/dropdown-menu-v2-ariakit/styles.d.ts.map +0 -1
  559. package/build-types/dropdown-menu-v2-ariakit/test/index.d.ts.map +0 -1
  560. package/build-types/dropdown-menu-v2-ariakit/types.d.ts +0 -168
  561. package/build-types/dropdown-menu-v2-ariakit/types.d.ts.map +0 -1
  562. package/src/dropdown-menu-v2-ariakit/README.md +0 -331
  563. package/src/dropdown-menu-v2-ariakit/index.tsx +0 -383
  564. package/src/dropdown-menu-v2-ariakit/stories/index.story.tsx +0 -617
  565. package/src/dropdown-menu-v2-ariakit/styles.ts +0 -345
  566. package/src/dropdown-menu-v2-ariakit/test/index.tsx +0 -1108
  567. package/src/dropdown-menu-v2-ariakit/types.ts +0 -179
  568. /package/build-types/{dropdown-menu-v2-ariakit → composite}/test/index.d.ts +0 -0
@@ -27,6 +27,7 @@ const UnconnectedToolsPanel = (props, forwardedRef) => {
27
27
  resetAllItems,
28
28
  toggleItem,
29
29
  headingLevel,
30
+ dropdownMenuProps,
30
31
  ...toolsPanelProps
31
32
  } = (0, _hook.useToolsPanel)(props);
32
33
  return (0, _react.createElement)(_grid.Grid, {
@@ -39,7 +40,8 @@ const UnconnectedToolsPanel = (props, forwardedRef) => {
39
40
  label: label,
40
41
  resetAll: resetAllItems,
41
42
  toggleItem: toggleItem,
42
- headingLevel: headingLevel
43
+ headingLevel: headingLevel,
44
+ dropdownMenuProps: dropdownMenuProps
43
45
  }), children));
44
46
  };
45
47
 
@@ -1 +1 @@
1
- {"version":3,"names":["_toolsPanelHeader","_interopRequireDefault","require","_context","_hook","_grid","_context2","UnconnectedToolsPanel","props","forwardedRef","children","label","panelContext","resetAllItems","toggleItem","headingLevel","toolsPanelProps","useToolsPanel","_react","createElement","Grid","columns","ref","ToolsPanelContext","Provider","value","default","resetAll","ToolsPanel","contextConnect","exports","_default"],"sources":["@wordpress/components/src/tools-panel/tools-panel/component.tsx"],"sourcesContent":["/**\n * External dependencies\n */\nimport type { ForwardedRef } from 'react';\n\n/**\n * Internal dependencies\n */\nimport ToolsPanelHeader from '../tools-panel-header';\nimport { ToolsPanelContext } from '../context';\nimport { useToolsPanel } from './hook';\nimport { Grid } from '../../grid';\nimport type { WordPressComponentProps } from '../../context';\nimport { contextConnect } from '../../context';\nimport type { ToolsPanelProps } from '../types';\n\nconst UnconnectedToolsPanel = (\n\tprops: WordPressComponentProps< ToolsPanelProps, 'div' >,\n\tforwardedRef: ForwardedRef< any >\n) => {\n\tconst {\n\t\tchildren,\n\t\tlabel,\n\t\tpanelContext,\n\t\tresetAllItems,\n\t\ttoggleItem,\n\t\theadingLevel,\n\t\t...toolsPanelProps\n\t} = useToolsPanel( props );\n\n\treturn (\n\t\t<Grid { ...toolsPanelProps } columns={ 2 } ref={ forwardedRef }>\n\t\t\t<ToolsPanelContext.Provider value={ panelContext }>\n\t\t\t\t<ToolsPanelHeader\n\t\t\t\t\tlabel={ label }\n\t\t\t\t\tresetAll={ resetAllItems }\n\t\t\t\t\ttoggleItem={ toggleItem }\n\t\t\t\t\theadingLevel={ headingLevel }\n\t\t\t\t/>\n\t\t\t\t{ children }\n\t\t\t</ToolsPanelContext.Provider>\n\t\t</Grid>\n\t);\n};\n\n/**\n * The `ToolsPanel` is a container component that displays its children preceded\n * by a header. The header includes a dropdown menu which is automatically\n * generated from the panel's inner `ToolsPanelItems`.\n *\n * ```jsx\n * import { __ } from '@wordpress/i18n';\n * import {\n * __experimentalToolsPanel as ToolsPanel,\n * __experimentalToolsPanelItem as ToolsPanelItem,\n * __experimentalUnitControl as UnitControl\n * } from '@wordpress/components';\n *\n * function Example() {\n * const [ height, setHeight ] = useState();\n * const [ width, setWidth ] = useState();\n *\n * const resetAll = () => {\n * setHeight();\n * setWidth();\n * }\n *\n * return (\n * <ToolsPanel label={ __( 'Dimensions' ) } resetAll={ resetAll }>\n * <ToolsPanelItem\n * hasValue={ () => !! height }\n * label={ __( 'Height' ) }\n * onDeselect={ () => setHeight() }\n * >\n * <UnitControl\n * label={ __( 'Height' ) }\n * onChange={ setHeight }\n * value={ height }\n * />\n * </ToolsPanelItem>\n * <ToolsPanelItem\n * hasValue={ () => !! width }\n * label={ __( 'Width' ) }\n * onDeselect={ () => setWidth() }\n * >\n * <UnitControl\n * label={ __( 'Width' ) }\n * onChange={ setWidth }\n * value={ width }\n * />\n * </ToolsPanelItem>\n * </ToolsPanel>\n * );\n * }\n * ```\n */\nexport const ToolsPanel = contextConnect( UnconnectedToolsPanel, 'ToolsPanel' );\n\nexport default ToolsPanel;\n"],"mappings":";;;;;;;;AAQA,IAAAA,iBAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,QAAA,GAAAD,OAAA;AACA,IAAAE,KAAA,GAAAF,OAAA;AACA,IAAA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equireDefault","require","_context","_hook","_grid","_context2","UnconnectedToolsPanel","props","forwardedRef","children","label","panelContext","resetAllItems","toggleItem","headingLevel","dropdownMenuProps","toolsPanelProps","useToolsPanel","_react","createElement","Grid","columns","ref","ToolsPanelContext","Provider","value","default","resetAll","ToolsPanel","contextConnect","exports","_default"],"sources":["@wordpress/components/src/tools-panel/tools-panel/component.tsx"],"sourcesContent":["/**\n * External dependencies\n */\nimport type { ForwardedRef } from 'react';\n\n/**\n * Internal dependencies\n */\nimport ToolsPanelHeader from '../tools-panel-header';\nimport { ToolsPanelContext } from '../context';\nimport { useToolsPanel } from './hook';\nimport { Grid } from '../../grid';\nimport type { WordPressComponentProps } from '../../context';\nimport { contextConnect } from '../../context';\nimport type { ToolsPanelProps } from '../types';\n\nconst UnconnectedToolsPanel = (\n\tprops: WordPressComponentProps< ToolsPanelProps, 'div' >,\n\tforwardedRef: ForwardedRef< any >\n) => {\n\tconst {\n\t\tchildren,\n\t\tlabel,\n\t\tpanelContext,\n\t\tresetAllItems,\n\t\ttoggleItem,\n\t\theadingLevel,\n\t\tdropdownMenuProps,\n\t\t...toolsPanelProps\n\t} = useToolsPanel( props );\n\n\treturn (\n\t\t<Grid { ...toolsPanelProps } columns={ 2 } ref={ forwardedRef }>\n\t\t\t<ToolsPanelContext.Provider value={ panelContext }>\n\t\t\t\t<ToolsPanelHeader\n\t\t\t\t\tlabel={ label }\n\t\t\t\t\tresetAll={ resetAllItems }\n\t\t\t\t\ttoggleItem={ toggleItem }\n\t\t\t\t\theadingLevel={ headingLevel }\n\t\t\t\t\tdropdownMenuProps={ dropdownMenuProps }\n\t\t\t\t/>\n\t\t\t\t{ children }\n\t\t\t</ToolsPanelContext.Provider>\n\t\t</Grid>\n\t);\n};\n\n/**\n * The `ToolsPanel` is a container component that displays its children preceded\n * by a header. The header includes a dropdown menu which is automatically\n * generated from the panel's inner `ToolsPanelItems`.\n *\n * ```jsx\n * import { __ } from '@wordpress/i18n';\n * import {\n * __experimentalToolsPanel as ToolsPanel,\n * __experimentalToolsPanelItem as ToolsPanelItem,\n * __experimentalUnitControl as UnitControl\n * } from '@wordpress/components';\n *\n * function Example() {\n * const [ height, setHeight ] = useState();\n * const [ width, setWidth ] = useState();\n *\n * const resetAll = () => {\n * setHeight();\n * setWidth();\n * }\n *\n * return (\n * <ToolsPanel label={ __( 'Dimensions' ) } resetAll={ resetAll }>\n * <ToolsPanelItem\n * hasValue={ () => !! height }\n * label={ __( 'Height' ) }\n * onDeselect={ () => setHeight() }\n * >\n * <UnitControl\n * label={ __( 'Height' ) }\n * onChange={ setHeight }\n * value={ height }\n * />\n * </ToolsPanelItem>\n * <ToolsPanelItem\n * hasValue={ () => !! width }\n * label={ __( 'Width' ) }\n * onDeselect={ () => setWidth() }\n * >\n * <UnitControl\n * label={ __( 'Width' ) }\n * onChange={ setWidth }\n * value={ width }\n * />\n * </ToolsPanelItem>\n * </ToolsPanel>\n * );\n * }\n * ```\n */\nexport const ToolsPanel = contextConnect( UnconnectedToolsPanel, 'ToolsPanel' );\n\nexport default ToolsPanel;\n"],"mappings":";;;;;;;;AAQA,IAAAA,iBAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,QAAA,GAAAD,OAAA;AACA,IAAAE,KAAA,GAAAF,OAAA;AACA,IAAAG,KAAA,GAAAH,OAAA;AAEA,IAAAI,SAAA,GAAAJ,OAAA;AAbA;AACA;AACA;;AAGA;AACA;AACA;;AASA,MAAMK,qBAAqB,GAAGA,CAC7BC,KAAwD,EACxDC,YAAiC,KAC7B;EACJ,MAAM;IACLC,QAAQ;IACRC,KAAK;IACLC,YAAY;IACZC,aAAa;IACbC,UAAU;IACVC,YAAY;IACZC,iBAAiB;IACjB,GAAGC;EACJ,CAAC,GAAG,IAAAC,mBAAa,EAAEV,KAAM,CAAC;EAE1B,OACC,IAAAW,MAAA,CAAAC,aAAA,EAACf,KAAA,CAAAgB,IAAI;IAAA,GAAMJ,eAAe;IAAGK,OAAO,EAAG,CAAG;IAACC,GAAG,EAAGd;EAAc,GAC9D,IAAAU,MAAA,CAAAC,aAAA,EAACjB,QAAA,CAAAqB,iBAAiB,CAACC,QAAQ;IAACC,KAAK,EAAGd;EAAc,GACjD,IAAAO,MAAA,CAAAC,aAAA,EAACpB,iBAAA,CAAA2B,OAAgB;IAChBhB,KAAK,EAAGA,KAAO;IACfiB,QAAQ,EAAGf,aAAe;IAC1BC,UAAU,EAAGA,UAAY;IACzBC,YAAY,EAAGA,YAAc;IAC7BC,iBAAiB,EAAGA;EAAmB,CACvC,CAAC,EACAN,QACyB,CACvB,CAAC;AAET,CAAC;;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,MAAMmB,UAAU,GAAG,IAAAC,wBAAc,EAAEvB,qBAAqB,EAAE,YAAa,CAAC;AAACwB,OAAA,CAAAF,UAAA,GAAAA,UAAA;AAAA,IAAAG,QAAA,GAEjEH,UAAU;AAAAE,OAAA,CAAAJ,OAAA,GAAAK,QAAA"}
@@ -40,9 +40,7 @@ const DefaultControlsGroup = ({
40
40
  const resetSuffix = (0, _react.createElement)(_styles.ResetLabel, {
41
41
  "aria-hidden": true
42
42
  }, (0, _i18n.__)('Reset'));
43
- return (0, _react.createElement)(_menuGroup.default, {
44
- label: (0, _i18n.__)('Defaults')
45
- }, items.map(([label, hasValue]) => {
43
+ return (0, _react.createElement)(_react.Fragment, null, items.map(([label, hasValue]) => {
46
44
  if (hasValue) {
47
45
  return (0, _react.createElement)(_menuItem.default, {
48
46
  key: label,
@@ -62,6 +60,7 @@ const DefaultControlsGroup = ({
62
60
  }
63
61
  return (0, _react.createElement)(_menuItem.default, {
64
62
  key: label,
63
+ icon: _icons.check,
65
64
  className: itemClassName,
66
65
  role: "menuitemcheckbox",
67
66
  isSelected: true,
@@ -76,9 +75,7 @@ const OptionalControlsGroup = ({
76
75
  if (!items.length) {
77
76
  return null;
78
77
  }
79
- return (0, _react.createElement)(_menuGroup.default, {
80
- label: (0, _i18n.__)('Tools')
81
- }, items.map(([label, isSelected]) => {
78
+ return (0, _react.createElement)(_react.Fragment, null, items.map(([label, isSelected]) => {
82
79
  const itemLabel = isSelected ? (0, _i18n.sprintf)(
83
80
  // translators: %s: The name of the control being hidden and reset e.g. "Padding".
84
81
  (0, _i18n.__)('Hide and reset %s'), label) : (0, _i18n.sprintf)(
@@ -117,6 +114,7 @@ const ToolsPanelHeader = (props, forwardedRef) => {
117
114
  menuItems,
118
115
  resetAll,
119
116
  toggleItem,
117
+ dropdownMenuProps,
120
118
  ...headerProps
121
119
  } = (0, _hook.useToolsPanelHeader)(props);
122
120
  if (!labelText) {
@@ -137,6 +135,7 @@ const ToolsPanelHeader = (props, forwardedRef) => {
137
135
  level: headingLevel,
138
136
  className: headingClassName
139
137
  }, labelText), hasMenuItems && (0, _react.createElement)(_dropdownMenu.default, {
138
+ ...dropdownMenuProps,
140
139
  icon: dropDownMenuIcon,
141
140
  label: dropDownMenuLabelText,
142
141
  menuProps: {
@@ -146,14 +145,16 @@ const ToolsPanelHeader = (props, forwardedRef) => {
146
145
  isSmall: true,
147
146
  describedBy: dropdownMenuDescriptionText
148
147
  }
149
- }, () => (0, _react.createElement)(_react.Fragment, null, (0, _react.createElement)(DefaultControlsGroup, {
148
+ }, () => (0, _react.createElement)(_react.Fragment, null, (0, _react.createElement)(_menuGroup.default, {
149
+ label: labelText
150
+ }, (0, _react.createElement)(DefaultControlsGroup, {
150
151
  items: defaultItems,
151
152
  toggleItem: toggleItem,
152
153
  itemClassName: defaultControlsItemClassName
153
154
  }), (0, _react.createElement)(OptionalControlsGroup, {
154
155
  items: optionalItems,
155
156
  toggleItem: toggleItem
156
- }), (0, _react.createElement)(_menuGroup.default, null, (0, _react.createElement)(_menuItem.default, {
157
+ })), (0, _react.createElement)(_menuGroup.default, null, (0, _react.createElement)(_menuItem.default, {
157
158
  "aria-disabled": !canResetAll
158
159
  // @ts-expect-error - TODO: If this "tertiary" style is something we really want to allow on MenuItem,
159
160
  // we should rename it and explicitly allow it as an official API. All the other Button variants
@@ -1 +1 @@
1
- {"version":3,"names":["_a11y","require","_icons","_i18n","_dropdownMenu","_interopRequireDefault","_menuGroup","_menuItem","_hStack","_heading","_hook","_context","_styles","DefaultControlsGroup","itemClassName","items","toggleItem","length","resetSuffix","_react","createElement","ResetLabel","__","default","label","map","hasValue","key","className","role","sprintf","onClick","speak","suffix","isSelected","OptionalControlsGroup","itemLabel","icon","check","ToolsPanelHeader","props","forwardedRef","areAllOptionalControlsHidden","defaultControlsItemClassName","dropdownMenuClassName","hasMenuItems","headingClassName","headingLevel","labelText","menuItems","resetAll","headerProps","useToolsPanelHeader","defaultItems","Object","entries","optionalItems","optional","dropDownMenuIcon","plus","moreVertical","dropDownMenuLabelText","_x","dropdownMenuDescriptionText","undefined","canResetAll","some","HStack","ref","Heading","level","menuProps","toggleProps","isSmall","describedBy","Fragment","variant","ConnectedToolsPanelHeader","contextConnect","_default","exports"],"sources":["@wordpress/components/src/tools-panel/tools-panel-header/component.tsx"],"sourcesContent":["/**\n * External dependencies\n */\nimport type { ForwardedRef } from 'react';\n\n/**\n * WordPress dependencies\n */\nimport { speak } from '@wordpress/a11y';\nimport { check, moreVertical, plus } from '@wordpress/icons';\nimport { __, _x, sprintf } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport DropdownMenu from '../../dropdown-menu';\nimport MenuGroup from '../../menu-group';\nimport MenuItem from '../../menu-item';\nimport { HStack } from '../../h-stack';\nimport { Heading } from '../../heading';\nimport { useToolsPanelHeader } from './hook';\nimport type { WordPressComponentProps } from '../../context';\nimport { contextConnect } from '../../context';\nimport { ResetLabel } from '../styles';\nimport type {\n\tToolsPanelControlsGroupProps,\n\tToolsPanelHeaderProps,\n} from '../types';\n\nconst DefaultControlsGroup = ( {\n\titemClassName,\n\titems,\n\ttoggleItem,\n}: ToolsPanelControlsGroupProps ) => {\n\tif ( ! items.length ) {\n\t\treturn null;\n\t}\n\n\tconst resetSuffix = <ResetLabel aria-hidden>{ __( 'Reset' ) }</ResetLabel>;\n\n\treturn (\n\t\t<MenuGroup label={ __( 'Defaults' ) }>\n\t\t\t{ items.map( ( [ label, hasValue ] ) => {\n\t\t\t\tif ( hasValue ) {\n\t\t\t\t\treturn (\n\t\t\t\t\t\t<MenuItem\n\t\t\t\t\t\t\tkey={ label }\n\t\t\t\t\t\t\tclassName={ itemClassName }\n\t\t\t\t\t\t\trole=\"menuitem\"\n\t\t\t\t\t\t\tlabel={ sprintf(\n\t\t\t\t\t\t\t\t// translators: %s: The name of the control being reset e.g. \"Padding\".\n\t\t\t\t\t\t\t\t__( 'Reset %s' ),\n\t\t\t\t\t\t\t\tlabel\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\t\t\ttoggleItem( label );\n\t\t\t\t\t\t\t\tspeak(\n\t\t\t\t\t\t\t\t\tsprintf(\n\t\t\t\t\t\t\t\t\t\t// translators: %s: The name of the control being reset e.g. \"Padding\".\n\t\t\t\t\t\t\t\t\t\t__( '%s reset to default' ),\n\t\t\t\t\t\t\t\t\t\tlabel\n\t\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t\t'assertive'\n\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\tsuffix={ resetSuffix }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ label }\n\t\t\t\t\t\t</MenuItem>\n\t\t\t\t\t);\n\t\t\t\t}\n\n\t\t\t\treturn (\n\t\t\t\t\t<MenuItem\n\t\t\t\t\t\tkey={ label }\n\t\t\t\t\t\tclassName={ itemClassName }\n\t\t\t\t\t\trole=\"menuitemcheckbox\"\n\t\t\t\t\t\tisSelected\n\t\t\t\t\t\taria-disabled\n\t\t\t\t\t>\n\t\t\t\t\t\t{ label }\n\t\t\t\t\t</MenuItem>\n\t\t\t\t);\n\t\t\t} ) }\n\t\t</MenuGroup>\n\t);\n};\n\nconst OptionalControlsGroup = ( {\n\titems,\n\ttoggleItem,\n}: ToolsPanelControlsGroupProps ) => {\n\tif ( ! items.length ) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<MenuGroup label={ __( 'Tools' ) }>\n\t\t\t{ items.map( ( [ label, isSelected ] ) => {\n\t\t\t\tconst itemLabel = isSelected\n\t\t\t\t\t? sprintf(\n\t\t\t\t\t\t\t// translators: %s: The name of the control being hidden and reset e.g. \"Padding\".\n\t\t\t\t\t\t\t__( 'Hide and reset %s' ),\n\t\t\t\t\t\t\tlabel\n\t\t\t\t\t )\n\t\t\t\t\t: sprintf(\n\t\t\t\t\t\t\t// translators: %s: The name of the control to display e.g. \"Padding\".\n\t\t\t\t\t\t\t__( 'Show %s' ),\n\t\t\t\t\t\t\tlabel\n\t\t\t\t\t );\n\n\t\t\t\treturn (\n\t\t\t\t\t<MenuItem\n\t\t\t\t\t\tkey={ label }\n\t\t\t\t\t\ticon={ isSelected ? check : null }\n\t\t\t\t\t\tisSelected={ isSelected }\n\t\t\t\t\t\tlabel={ itemLabel }\n\t\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\t\tif ( isSelected ) {\n\t\t\t\t\t\t\t\tspeak(\n\t\t\t\t\t\t\t\t\tsprintf(\n\t\t\t\t\t\t\t\t\t\t// translators: %s: The name of the control being reset e.g. \"Padding\".\n\t\t\t\t\t\t\t\t\t\t__( '%s hidden and reset to default' ),\n\t\t\t\t\t\t\t\t\t\tlabel\n\t\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t\t'assertive'\n\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\tspeak(\n\t\t\t\t\t\t\t\t\tsprintf(\n\t\t\t\t\t\t\t\t\t\t// translators: %s: The name of the control being reset e.g. \"Padding\".\n\t\t\t\t\t\t\t\t\t\t__( '%s is now visible' ),\n\t\t\t\t\t\t\t\t\t\tlabel\n\t\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t\t'assertive'\n\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\ttoggleItem( label );\n\t\t\t\t\t\t} }\n\t\t\t\t\t\trole=\"menuitemcheckbox\"\n\t\t\t\t\t>\n\t\t\t\t\t\t{ label }\n\t\t\t\t\t</MenuItem>\n\t\t\t\t);\n\t\t\t} ) }\n\t\t</MenuGroup>\n\t);\n};\n\nconst ToolsPanelHeader = (\n\tprops: WordPressComponentProps< ToolsPanelHeaderProps, 'h2' >,\n\tforwardedRef: ForwardedRef< any >\n) => {\n\tconst {\n\t\tareAllOptionalControlsHidden,\n\t\tdefaultControlsItemClassName,\n\t\tdropdownMenuClassName,\n\t\thasMenuItems,\n\t\theadingClassName,\n\t\theadingLevel = 2,\n\t\tlabel: labelText,\n\t\tmenuItems,\n\t\tresetAll,\n\t\ttoggleItem,\n\t\t...headerProps\n\t} = useToolsPanelHeader( props );\n\n\tif ( ! labelText ) {\n\t\treturn null;\n\t}\n\n\tconst defaultItems = Object.entries( menuItems?.default || {} );\n\tconst optionalItems = Object.entries( menuItems?.optional || {} );\n\tconst dropDownMenuIcon = areAllOptionalControlsHidden ? plus : moreVertical;\n\tconst dropDownMenuLabelText = sprintf(\n\t\t// translators: %s: The name of the tool e.g. \"Color\" or \"Typography\".\n\t\t_x( '%s options', 'Button label to reveal tool panel options' ),\n\t\tlabelText\n\t);\n\tconst dropdownMenuDescriptionText = areAllOptionalControlsHidden\n\t\t? __( 'All options are currently hidden' )\n\t\t: undefined;\n\n\tconst canResetAll = [ ...defaultItems, ...optionalItems ].some(\n\t\t( [ , isSelected ] ) => isSelected\n\t);\n\n\treturn (\n\t\t<HStack { ...headerProps } ref={ forwardedRef }>\n\t\t\t<Heading level={ headingLevel } className={ headingClassName }>\n\t\t\t\t{ labelText }\n\t\t\t</Heading>\n\t\t\t{ hasMenuItems && (\n\t\t\t\t<DropdownMenu\n\t\t\t\t\ticon={ dropDownMenuIcon }\n\t\t\t\t\tlabel={ dropDownMenuLabelText }\n\t\t\t\t\tmenuProps={ { className: dropdownMenuClassName } }\n\t\t\t\t\ttoggleProps={ {\n\t\t\t\t\t\tisSmall: true,\n\t\t\t\t\t\tdescribedBy: dropdownMenuDescriptionText,\n\t\t\t\t\t} }\n\t\t\t\t>\n\t\t\t\t\t{ () => (\n\t\t\t\t\t\t<>\n\t\t\t\t\t\t\t<DefaultControlsGroup\n\t\t\t\t\t\t\t\titems={ defaultItems }\n\t\t\t\t\t\t\t\ttoggleItem={ toggleItem }\n\t\t\t\t\t\t\t\titemClassName={ defaultControlsItemClassName }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t<OptionalControlsGroup\n\t\t\t\t\t\t\t\titems={ optionalItems }\n\t\t\t\t\t\t\t\ttoggleItem={ toggleItem }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t<MenuGroup>\n\t\t\t\t\t\t\t\t<MenuItem\n\t\t\t\t\t\t\t\t\taria-disabled={ ! canResetAll }\n\t\t\t\t\t\t\t\t\t// @ts-expect-error - TODO: If this \"tertiary\" style is something we really want to allow on MenuItem,\n\t\t\t\t\t\t\t\t\t// we should rename it and explicitly allow it as an official API. All the other Button variants\n\t\t\t\t\t\t\t\t\t// don't make sense in a MenuItem context, and should be disallowed.\n\t\t\t\t\t\t\t\t\tvariant={ 'tertiary' }\n\t\t\t\t\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\t\t\t\t\tif ( canResetAll ) {\n\t\t\t\t\t\t\t\t\t\t\tresetAll();\n\t\t\t\t\t\t\t\t\t\t\tspeak(\n\t\t\t\t\t\t\t\t\t\t\t\t__( 'All options reset' ),\n\t\t\t\t\t\t\t\t\t\t\t\t'assertive'\n\t\t\t\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t{ __( 'Reset all' ) }\n\t\t\t\t\t\t\t\t</MenuItem>\n\t\t\t\t\t\t\t</MenuGroup>\n\t\t\t\t\t\t</>\n\t\t\t\t\t) }\n\t\t\t\t</DropdownMenu>\n\t\t\t) }\n\t\t</HStack>\n\t);\n};\n\nconst ConnectedToolsPanelHeader = contextConnect(\n\tToolsPanelHeader,\n\t'ToolsPanelHeader'\n);\n\nexport default ConnectedToolsPanelHeader;\n"],"mappings":";;;;;;;;AAQA,IAAAA,KAAA,GAAAC,OAAA;AACA,IAAAC,MAAA,GAAAD,OAAA;AACA,IAAAE,KAAA,GAAAF,OAAA;AAKA,IAAAG,aAAA,GAAAC,sBAAA,CAAAJ,OAAA;AACA,IAAAK,UAAA,GAAAD,sBAAA,CAAAJ,OAAA;AACA,IAAAM,SAAA,GAAAF,sBAAA,CAAAJ,OAAA;AACA,IAAAO,OAAA,GAAAP,OAAA;AACA,IAAAQ,QAAA,GAAAR,OAAA;AACA,IAAAS,KAAA,GAAAT,OAAA;AAEA,IAAAU,QAAA,GAAAV,OAAA;AACA,IAAAW,OAAA,GAAAX,OAAA;AAvBA;AACA;AACA;;AAGA;AACA;AACA;;AAKA;AACA;AACA;;AAeA,MAAMY,oBAAoB,GAAGA,CAAE;EAC9BC,aAAa;EACbC,KAAK;EACLC;AAC6B,CAAC,KAAM;EACpC,IAAK,CAAED,KAAK,CAACE,MAAM,EAAG;IACrB,OAAO,IAAI;EACZ;EAEA,MAAMC,WAAW,GAAG,IAAAC,MAAA,CAAAC,aAAA,EAACR,OAAA,CAAAS,UAAU;IAAC;EAAW,GAAG,IAAAC,QAAE,EAAE,OAAQ,CAAe,CAAC;EAE1E,OACC,IAAAH,MAAA,CAAAC,aAAA,EAACd,UAAA,CAAAiB,OAAS;IAACC,KAAK,EAAG,IAAAF,QAAE,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C,aAAA,EAACe,qBAAqB;IACrBpB,KAAK,EAAGyC,aAAe;IACvBxC,UAAU,EAAGA;EAAY,CACzB,CAAC,EACF,IAAAG,MAAA,CAAAC,aAAA,EAACd,UAAA,CAAAiB,OAAS,QACT,IAAAJ,MAAA,CAAAC,aAAA,EAACb,SAAA,CAAAgB,OAAQ;IACR,iBAAgB,CAAE0C;IAClB;IACA;IACA;IAAA;IACAW,OAAO,EAAG,UAAY;IACtB7C,OAAO,EAAGA,CAAA,KAAM;MACf,IAAKkC,WAAW,EAAG;QAClBf,QAAQ,CAAC,CAAC;QACV,IAAAlB,WAAK,EACJ,IAAAV,QAAE,EAAE,mBAAoB,CAAC,EACzB,WACD,CAAC;MACF;IACD;EAAG,GAED,IAAAA,QAAE,EAAE,WAAY,CACT,CACA,CACV,CAEU,CAER,CAAC;AAEX,CAAC;AAED,MAAMuD,yBAAyB,GAAG,IAAAC,uBAAc,EAC/CvC,gBAAgB,EAChB,kBACD,CAAC;AAAC,IAAAwC,QAAA,GAEaF,yBAAyB;AAAAG,OAAA,CAAAzD,OAAA,GAAAwD,QAAA"}
1
+ {"version":3,"names":["_a11y","require","_icons","_i18n","_dropdownMenu","_interopRequireDefault","_menuGroup","_menuItem","_hStack","_heading","_hook","_context","_styles","DefaultControlsGroup","itemClassName","items","toggleItem","length","resetSuffix","_react","createElement","ResetLabel","__","Fragment","map","label","hasValue","default","key","className","role","sprintf","onClick","speak","suffix","icon","check","isSelected","OptionalControlsGroup","itemLabel","ToolsPanelHeader","props","forwardedRef","areAllOptionalControlsHidden","defaultControlsItemClassName","dropdownMenuClassName","hasMenuItems","headingClassName","headingLevel","labelText","menuItems","resetAll","dropdownMenuProps","headerProps","useToolsPanelHeader","defaultItems","Object","entries","optionalItems","optional","dropDownMenuIcon","plus","moreVertical","dropDownMenuLabelText","_x","dropdownMenuDescriptionText","undefined","canResetAll","some","HStack","ref","Heading","level","menuProps","toggleProps","isSmall","describedBy","variant","ConnectedToolsPanelHeader","contextConnect","_default","exports"],"sources":["@wordpress/components/src/tools-panel/tools-panel-header/component.tsx"],"sourcesContent":["/**\n * External dependencies\n */\nimport type { ForwardedRef } from 'react';\n\n/**\n * WordPress dependencies\n */\nimport { speak } from '@wordpress/a11y';\nimport { check, moreVertical, plus } from '@wordpress/icons';\nimport { __, _x, sprintf } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport DropdownMenu from '../../dropdown-menu';\nimport MenuGroup from '../../menu-group';\nimport MenuItem from '../../menu-item';\nimport { HStack } from '../../h-stack';\nimport { Heading } from '../../heading';\nimport { useToolsPanelHeader } from './hook';\nimport type { WordPressComponentProps } from '../../context';\nimport { contextConnect } from '../../context';\nimport { ResetLabel } from '../styles';\nimport type {\n\tToolsPanelControlsGroupProps,\n\tToolsPanelHeaderProps,\n} from '../types';\n\nconst DefaultControlsGroup = ( {\n\titemClassName,\n\titems,\n\ttoggleItem,\n}: ToolsPanelControlsGroupProps ) => {\n\tif ( ! items.length ) {\n\t\treturn null;\n\t}\n\n\tconst resetSuffix = <ResetLabel aria-hidden>{ __( 'Reset' ) }</ResetLabel>;\n\n\treturn (\n\t\t<>\n\t\t\t{ items.map( ( [ label, hasValue ] ) => {\n\t\t\t\tif ( hasValue ) {\n\t\t\t\t\treturn (\n\t\t\t\t\t\t<MenuItem\n\t\t\t\t\t\t\tkey={ label }\n\t\t\t\t\t\t\tclassName={ itemClassName }\n\t\t\t\t\t\t\trole=\"menuitem\"\n\t\t\t\t\t\t\tlabel={ sprintf(\n\t\t\t\t\t\t\t\t// translators: %s: The name of the control being reset e.g. \"Padding\".\n\t\t\t\t\t\t\t\t__( 'Reset %s' ),\n\t\t\t\t\t\t\t\tlabel\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\t\t\ttoggleItem( label );\n\t\t\t\t\t\t\t\tspeak(\n\t\t\t\t\t\t\t\t\tsprintf(\n\t\t\t\t\t\t\t\t\t\t// translators: %s: The name of the control being reset e.g. \"Padding\".\n\t\t\t\t\t\t\t\t\t\t__( '%s reset to default' ),\n\t\t\t\t\t\t\t\t\t\tlabel\n\t\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t\t'assertive'\n\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\tsuffix={ resetSuffix }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ label }\n\t\t\t\t\t\t</MenuItem>\n\t\t\t\t\t);\n\t\t\t\t}\n\n\t\t\t\treturn (\n\t\t\t\t\t<MenuItem\n\t\t\t\t\t\tkey={ label }\n\t\t\t\t\t\ticon={ check }\n\t\t\t\t\t\tclassName={ itemClassName }\n\t\t\t\t\t\trole=\"menuitemcheckbox\"\n\t\t\t\t\t\tisSelected\n\t\t\t\t\t\taria-disabled\n\t\t\t\t\t>\n\t\t\t\t\t\t{ label }\n\t\t\t\t\t</MenuItem>\n\t\t\t\t);\n\t\t\t} ) }\n\t\t</>\n\t);\n};\n\nconst OptionalControlsGroup = ( {\n\titems,\n\ttoggleItem,\n}: ToolsPanelControlsGroupProps ) => {\n\tif ( ! items.length ) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<>\n\t\t\t{ items.map( ( [ label, isSelected ] ) => {\n\t\t\t\tconst itemLabel = isSelected\n\t\t\t\t\t? sprintf(\n\t\t\t\t\t\t\t// translators: %s: The name of the control being hidden and reset e.g. \"Padding\".\n\t\t\t\t\t\t\t__( 'Hide and reset %s' ),\n\t\t\t\t\t\t\tlabel\n\t\t\t\t\t )\n\t\t\t\t\t: sprintf(\n\t\t\t\t\t\t\t// translators: %s: The name of the control to display e.g. \"Padding\".\n\t\t\t\t\t\t\t__( 'Show %s' ),\n\t\t\t\t\t\t\tlabel\n\t\t\t\t\t );\n\n\t\t\t\treturn (\n\t\t\t\t\t<MenuItem\n\t\t\t\t\t\tkey={ label }\n\t\t\t\t\t\ticon={ isSelected ? check : null }\n\t\t\t\t\t\tisSelected={ isSelected }\n\t\t\t\t\t\tlabel={ itemLabel }\n\t\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\t\tif ( isSelected ) {\n\t\t\t\t\t\t\t\tspeak(\n\t\t\t\t\t\t\t\t\tsprintf(\n\t\t\t\t\t\t\t\t\t\t// translators: %s: The name of the control being reset e.g. \"Padding\".\n\t\t\t\t\t\t\t\t\t\t__( '%s hidden and reset to default' ),\n\t\t\t\t\t\t\t\t\t\tlabel\n\t\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t\t'assertive'\n\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\tspeak(\n\t\t\t\t\t\t\t\t\tsprintf(\n\t\t\t\t\t\t\t\t\t\t// translators: %s: The name of the control being reset e.g. \"Padding\".\n\t\t\t\t\t\t\t\t\t\t__( '%s is now visible' ),\n\t\t\t\t\t\t\t\t\t\tlabel\n\t\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t\t'assertive'\n\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\ttoggleItem( label );\n\t\t\t\t\t\t} }\n\t\t\t\t\t\trole=\"menuitemcheckbox\"\n\t\t\t\t\t>\n\t\t\t\t\t\t{ label }\n\t\t\t\t\t</MenuItem>\n\t\t\t\t);\n\t\t\t} ) }\n\t\t</>\n\t);\n};\n\nconst ToolsPanelHeader = (\n\tprops: WordPressComponentProps< ToolsPanelHeaderProps, 'h2' >,\n\tforwardedRef: ForwardedRef< any >\n) => {\n\tconst {\n\t\tareAllOptionalControlsHidden,\n\t\tdefaultControlsItemClassName,\n\t\tdropdownMenuClassName,\n\t\thasMenuItems,\n\t\theadingClassName,\n\t\theadingLevel = 2,\n\t\tlabel: labelText,\n\t\tmenuItems,\n\t\tresetAll,\n\t\ttoggleItem,\n\t\tdropdownMenuProps,\n\t\t...headerProps\n\t} = useToolsPanelHeader( props );\n\n\tif ( ! labelText ) {\n\t\treturn null;\n\t}\n\n\tconst defaultItems = Object.entries( menuItems?.default || {} );\n\tconst optionalItems = Object.entries( menuItems?.optional || {} );\n\tconst dropDownMenuIcon = areAllOptionalControlsHidden ? plus : moreVertical;\n\tconst dropDownMenuLabelText = sprintf(\n\t\t// translators: %s: The name of the tool e.g. \"Color\" or \"Typography\".\n\t\t_x( '%s options', 'Button label to reveal tool panel options' ),\n\t\tlabelText\n\t);\n\tconst dropdownMenuDescriptionText = areAllOptionalControlsHidden\n\t\t? __( 'All options are currently hidden' )\n\t\t: undefined;\n\n\tconst canResetAll = [ ...defaultItems, ...optionalItems ].some(\n\t\t( [ , isSelected ] ) => isSelected\n\t);\n\n\treturn (\n\t\t<HStack { ...headerProps } ref={ forwardedRef }>\n\t\t\t<Heading level={ headingLevel } className={ headingClassName }>\n\t\t\t\t{ labelText }\n\t\t\t</Heading>\n\t\t\t{ hasMenuItems && (\n\t\t\t\t<DropdownMenu\n\t\t\t\t\t{ ...dropdownMenuProps }\n\t\t\t\t\ticon={ dropDownMenuIcon }\n\t\t\t\t\tlabel={ dropDownMenuLabelText }\n\t\t\t\t\tmenuProps={ { className: dropdownMenuClassName } }\n\t\t\t\t\ttoggleProps={ {\n\t\t\t\t\t\tisSmall: true,\n\t\t\t\t\t\tdescribedBy: dropdownMenuDescriptionText,\n\t\t\t\t\t} }\n\t\t\t\t>\n\t\t\t\t\t{ () => (\n\t\t\t\t\t\t<>\n\t\t\t\t\t\t\t<MenuGroup label={ labelText }>\n\t\t\t\t\t\t\t\t<DefaultControlsGroup\n\t\t\t\t\t\t\t\t\titems={ defaultItems }\n\t\t\t\t\t\t\t\t\ttoggleItem={ toggleItem }\n\t\t\t\t\t\t\t\t\titemClassName={\n\t\t\t\t\t\t\t\t\t\tdefaultControlsItemClassName\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t<OptionalControlsGroup\n\t\t\t\t\t\t\t\t\titems={ optionalItems }\n\t\t\t\t\t\t\t\t\ttoggleItem={ toggleItem }\n\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t</MenuGroup>\n\t\t\t\t\t\t\t<MenuGroup>\n\t\t\t\t\t\t\t\t<MenuItem\n\t\t\t\t\t\t\t\t\taria-disabled={ ! canResetAll }\n\t\t\t\t\t\t\t\t\t// @ts-expect-error - TODO: If this \"tertiary\" style is something we really want to allow on MenuItem,\n\t\t\t\t\t\t\t\t\t// we should rename it and explicitly allow it as an official API. All the other Button variants\n\t\t\t\t\t\t\t\t\t// don't make sense in a MenuItem context, and should be disallowed.\n\t\t\t\t\t\t\t\t\tvariant={ 'tertiary' }\n\t\t\t\t\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\t\t\t\t\tif ( canResetAll ) {\n\t\t\t\t\t\t\t\t\t\t\tresetAll();\n\t\t\t\t\t\t\t\t\t\t\tspeak(\n\t\t\t\t\t\t\t\t\t\t\t\t__( 'All options reset' ),\n\t\t\t\t\t\t\t\t\t\t\t\t'assertive'\n\t\t\t\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t{ __( 'Reset all' ) }\n\t\t\t\t\t\t\t\t</MenuItem>\n\t\t\t\t\t\t\t</MenuGroup>\n\t\t\t\t\t\t</>\n\t\t\t\t\t) }\n\t\t\t\t</DropdownMenu>\n\t\t\t) }\n\t\t</HStack>\n\t);\n};\n\nconst ConnectedToolsPanelHeader = contextConnect(\n\tToolsPanelHeader,\n\t'ToolsPanelHeader'\n);\n\nexport default ConnectedToolsPanelHeader;\n"],"mappings":";;;;;;;;AAQA,IAAAA,KAAA,GAAAC,OAAA;AACA,IAAAC,MAAA,GAAAD,OAAA;AACA,IAAAE,KAAA,GAAAF,OAAA;AAKA,IAAAG,aAAA,GAAAC,sBAAA,CAAAJ,OAAA;AACA,IAAAK,UAAA,GAAAD,sBAAA,CAAAJ,OAAA;AACA,IAAAM,SA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IAAAC,uBAAc,EAC/CvC,gBAAgB,EAChB,kBACD,CAAC;AAAC,IAAAwC,QAAA,GAEaF,yBAAyB;AAAAG,OAAA,CAAAtD,OAAA,GAAAqD,QAAA"}
@@ -1 +1 @@
1
- {"version":3,"names":[],"sources":["@wordpress/components/src/tools-panel/types.ts"],"sourcesContent":["/**\n * External dependencies\n */\nimport type { ReactNode } from 'react';\n\n/**\n * Internal dependencies\n */\nimport type { HeadingSize } from '../heading/types';\n\nexport type ResetAllFilter = ( attributes?: any ) => any;\ntype ResetAll = ( filters?: ResetAllFilter[] ) => void;\n\nexport type ToolsPanelProps = {\n\t/**\n\t * The child elements.\n\t */\n\tchildren: ReactNode;\n\t/**\n\t * Flags that the items in this ToolsPanel will be contained within an inner\n\t * wrapper element allowing the panel to lay them out accordingly.\n\t *\n\t * @default false\n\t */\n\thasInnerWrapper?: boolean;\n\t/**\n\t * The heading level of the panel's header.\n\t *\n\t * @default 2\n\t */\n\theadingLevel?: HeadingSize;\n\t/**\n\t * Text to be displayed within the panel's header and as the `aria-label`\n\t * for the panel's dropdown menu.\n\t */\n\tlabel: string;\n\t/**\n\t * If a `panelId` is set, it is passed through the `ToolsPanelContext` and\n\t * used to restrict panel items. When a `panelId` is set, items can only\n\t * register themselves if the `panelId` is explicitly `null` or the item's\n\t * `panelId` matches exactly.\n\t */\n\tpanelId?: string | null;\n\t/**\n\t * A function to call when the `Reset all` menu option is selected. As an\n\t * argument, it receives an array containing the `resetAllFilter` callbacks\n\t * of all the valid registered `ToolsPanelItems`.\n\t */\n\tresetAll: ResetAll;\n\t/**\n\t * Advises the `ToolsPanel` that its child `ToolsPanelItem`s should render\n\t * placeholder content instead of null when they are toggled off and hidden.\n\t * Note that placeholder items won't apply the `className` that would be\n\t * normally applied to a visible `ToolsPanelItem` via the `className` prop.\n\t *\n\t * @default false\n\t */\n\tshouldRenderPlaceholderItems?: boolean;\n\t/**\n\t * Experimental prop allowing for a custom CSS class to be applied to the\n\t * first visible `ToolsPanelItem` within the `ToolsPanel`.\n\t */\n\t__experimentalFirstVisibleItemClass?: string;\n\t/**\n\t * Experimental prop allowing for a custom CSS class to be applied to the\n\t * last visible `ToolsPanelItem` within the `ToolsPanel`.\n\t */\n\t__experimentalLastVisibleItemClass?: string;\n};\n\nexport type ToolsPanelHeaderProps = {\n\t/**\n\t * The heading level of the panel's header.\n\t *\n\t * @default 2\n\t */\n\theadingLevel?: HeadingSize;\n\t/**\n\t * Text to be displayed within the panel header. It is also passed along as\n\t * the `label` for the panel header's `DropdownMenu`.\n\t */\n\tlabel: string;\n\t/**\n\t * The `resetAll` prop provides the callback to execute when the \"Reset all\"\n\t * menu item is selected. Its purpose is to facilitate resetting any control\n\t * values for items contained within this header's panel.\n\t */\n\tresetAll: ResetAll;\n\t/**\n\t * This is executed when an individual control's menu item is toggled. It\n\t * will update the panel's menu item state and call the panel item's\n\t * `onSelect` or `onDeselect` callbacks as appropriate.\n\t */\n\ttoggleItem: ( label: string ) => void;\n};\n\nexport type ToolsPanelItem = {\n\t/**\n\t * This is called when building the `ToolsPanel` menu to determine the\n\t * item's initial checked state.\n\t */\n\thasValue: () => boolean;\n\t/**\n\t * This prop identifies the current item as being displayed by default. This\n\t * means it will show regardless of whether it has a value set or is toggled\n\t * on in the panel's menu.\n\t *\n\t * @default false\n\t */\n\tisShownByDefault?: boolean;\n\t/**\n\t * The supplied label is dual purpose. It is used as:\n\t * 1. the human-readable label for the panel's dropdown menu\n\t * 2. a key to locate the corresponding item in the panel's menu context to\n\t * determine if the panel item should be displayed.\n\t * A panel item's `label` should be unique among all items within a single\n\t * panel.\n\t */\n\tlabel: string;\n\t/**\n\t * Panel items will ensure they are only registering with their intended panel\n\t * by comparing the `panelId` props set on both the item and the panel itself,\n\t * or if the `panelId` is explicitly `null`. This allows items to be injected\n\t * from a shared source.\n\t */\n\tpanelId?: string | null;\n};\n\nexport type ToolsPanelItemProps = ToolsPanelItem & {\n\t/**\n\t * The child elements.\n\t */\n\tchildren?: ReactNode;\n\t/**\n\t * Called when this item is deselected in the `ToolsPanel` menu. This is\n\t * normally used to reset the panel item control's value.\n\t */\n\tonDeselect?: () => void;\n\t/**\n\t * A callback to take action when this item is selected in the `ToolsPanel`\n\t * menu.\n\t */\n\tonSelect?: () => void;\n\n\t/**\n\t * A `ToolsPanel` will collect each item's `resetAllFilter` and pass an\n\t * array of these functions through to the panel's `resetAll` callback. They\n\t * can then be iterated over to perform additional tasks.\n\t *\n\t * @default noop\n\t */\n\tresetAllFilter?: ResetAllFilter;\n};\n\nexport type ToolsPanelMenuItemKey = 'default' | 'optional';\n\nexport type ToolsPanelMenuItems = {\n\t[ menuItemKey in ToolsPanelMenuItemKey ]: { [ key: string ]: boolean };\n};\n\nexport type ToolsPanelContext = {\n\tpanelId?: string | null;\n\tmenuItems: ToolsPanelMenuItems;\n\thasMenuItems: boolean;\n\tregisterPanelItem: ( item: ToolsPanelItem ) => void;\n\tderegisterPanelItem: ( label: string ) => void;\n\tregisterResetAllFilter: ( filter: ResetAllFilter ) => void;\n\tderegisterResetAllFilter: ( filter: ResetAllFilter ) => void;\n\tflagItemCustomization: (\n\t\tlabel: string,\n\t\tgroup?: ToolsPanelMenuItemKey\n\t) => void;\n\tisResetting: boolean;\n\tshouldRenderPlaceholderItems: boolean;\n\tareAllOptionalControlsHidden: boolean;\n\tfirstDisplayedItem?: string;\n\tlastDisplayedItem?: string;\n\t__experimentalFirstVisibleItemClass?: string;\n\t__experimentalLastVisibleItemClass?: string;\n};\n\nexport type ToolsPanelControlsGroupProps = {\n\titemClassName?: string;\n\titems: [ string, boolean ][];\n\ttoggleItem: ( label: string ) => void;\n};\n\nexport type ToolsPanelMenuItemsConfig = {\n\tpanelItems: ToolsPanelItem[];\n\tshouldReset: boolean;\n\tcurrentMenuItems?: ToolsPanelMenuItems;\n\tmenuItemOrder: string[];\n};\n"],"mappings":""}
1
+ {"version":3,"names":[],"sources":["@wordpress/components/src/tools-panel/types.ts"],"sourcesContent":["/**\n * External dependencies\n */\nimport type { ReactNode } from 'react';\n\n/**\n * Internal dependencies\n */\nimport type { HeadingSize } from '../heading/types';\nimport type { DropdownMenu } from '../dropdown-menu';\n\nexport type ResetAllFilter = ( attributes?: any ) => any;\ntype ResetAll = ( filters?: ResetAllFilter[] ) => void;\n\nexport type ToolsPanelProps = {\n\t/**\n\t * The child elements.\n\t */\n\tchildren: ReactNode;\n\t/**\n\t * The dropdown menu props to configure the panel's `DropdownMenu`.\n\t */\n\tdropdownMenuProps?: React.ComponentProps< typeof DropdownMenu >;\n\t/**\n\t * Flags that the items in this ToolsPanel will be contained within an inner\n\t * wrapper element allowing the panel to lay them out accordingly.\n\t *\n\t * @default false\n\t */\n\thasInnerWrapper?: boolean;\n\t/**\n\t * The heading level of the panel's header.\n\t *\n\t * @default 2\n\t */\n\theadingLevel?: HeadingSize;\n\t/**\n\t * Text to be displayed within the panel's header and as the `aria-label`\n\t * for the panel's dropdown menu.\n\t */\n\tlabel: string;\n\t/**\n\t * If a `panelId` is set, it is passed through the `ToolsPanelContext` and\n\t * used to restrict panel items. When a `panelId` is set, items can only\n\t * register themselves if the `panelId` is explicitly `null` or the item's\n\t * `panelId` matches exactly.\n\t */\n\tpanelId?: string | null;\n\t/**\n\t * A function to call when the `Reset all` menu option is selected. As an\n\t * argument, it receives an array containing the `resetAllFilter` callbacks\n\t * of all the valid registered `ToolsPanelItems`.\n\t */\n\tresetAll: ResetAll;\n\t/**\n\t * Advises the `ToolsPanel` that its child `ToolsPanelItem`s should render\n\t * placeholder content instead of null when they are toggled off and hidden.\n\t * Note that placeholder items won't apply the `className` that would be\n\t * normally applied to a visible `ToolsPanelItem` via the `className` prop.\n\t *\n\t * @default false\n\t */\n\tshouldRenderPlaceholderItems?: boolean;\n\t/**\n\t * Experimental prop allowing for a custom CSS class to be applied to the\n\t * first visible `ToolsPanelItem` within the `ToolsPanel`.\n\t */\n\t__experimentalFirstVisibleItemClass?: string;\n\t/**\n\t * Experimental prop allowing for a custom CSS class to be applied to the\n\t * last visible `ToolsPanelItem` within the `ToolsPanel`.\n\t */\n\t__experimentalLastVisibleItemClass?: string;\n};\n\nexport type ToolsPanelHeaderProps = {\n\t/**\n\t * The dropdown menu props to configure the panel's `DropdownMenu`.\n\t */\n\tdropdownMenuProps?: React.ComponentProps< typeof DropdownMenu >;\n\t/**\n\t * The heading level of the panel's header.\n\t *\n\t * @default 2\n\t */\n\theadingLevel?: HeadingSize;\n\t/**\n\t * Text to be displayed within the panel header. It is also passed along as\n\t * the `label` for the panel header's `DropdownMenu`.\n\t */\n\tlabel: string;\n\t/**\n\t * The `resetAll` prop provides the callback to execute when the \"Reset all\"\n\t * menu item is selected. Its purpose is to facilitate resetting any control\n\t * values for items contained within this header's panel.\n\t */\n\tresetAll: ResetAll;\n\t/**\n\t * This is executed when an individual control's menu item is toggled. It\n\t * will update the panel's menu item state and call the panel item's\n\t * `onSelect` or `onDeselect` callbacks as appropriate.\n\t */\n\ttoggleItem: ( label: string ) => void;\n};\n\nexport type ToolsPanelItem = {\n\t/**\n\t * This is called when building the `ToolsPanel` menu to determine the\n\t * item's initial checked state.\n\t */\n\thasValue: () => boolean;\n\t/**\n\t * This prop identifies the current item as being displayed by default. This\n\t * means it will show regardless of whether it has a value set or is toggled\n\t * on in the panel's menu.\n\t *\n\t * @default false\n\t */\n\tisShownByDefault?: boolean;\n\t/**\n\t * The supplied label is dual purpose. It is used as:\n\t * 1. the human-readable label for the panel's dropdown menu\n\t * 2. a key to locate the corresponding item in the panel's menu context to\n\t * determine if the panel item should be displayed.\n\t * A panel item's `label` should be unique among all items within a single\n\t * panel.\n\t */\n\tlabel: string;\n\t/**\n\t * Panel items will ensure they are only registering with their intended panel\n\t * by comparing the `panelId` props set on both the item and the panel itself,\n\t * or if the `panelId` is explicitly `null`. This allows items to be injected\n\t * from a shared source.\n\t */\n\tpanelId?: string | null;\n};\n\nexport type ToolsPanelItemProps = ToolsPanelItem & {\n\t/**\n\t * The child elements.\n\t */\n\tchildren?: ReactNode;\n\t/**\n\t * Called when this item is deselected in the `ToolsPanel` menu. This is\n\t * normally used to reset the panel item control's value.\n\t */\n\tonDeselect?: () => void;\n\t/**\n\t * A callback to take action when this item is selected in the `ToolsPanel`\n\t * menu.\n\t */\n\tonSelect?: () => void;\n\n\t/**\n\t * A `ToolsPanel` will collect each item's `resetAllFilter` and pass an\n\t * array of these functions through to the panel's `resetAll` callback. They\n\t * can then be iterated over to perform additional tasks.\n\t *\n\t * @default noop\n\t */\n\tresetAllFilter?: ResetAllFilter;\n};\n\nexport type ToolsPanelMenuItemKey = 'default' | 'optional';\n\nexport type ToolsPanelMenuItems = {\n\t[ menuItemKey in ToolsPanelMenuItemKey ]: { [ key: string ]: boolean };\n};\n\nexport type ToolsPanelContext = {\n\tpanelId?: string | null;\n\tmenuItems: ToolsPanelMenuItems;\n\thasMenuItems: boolean;\n\tregisterPanelItem: ( item: ToolsPanelItem ) => void;\n\tderegisterPanelItem: ( label: string ) => void;\n\tregisterResetAllFilter: ( filter: ResetAllFilter ) => void;\n\tderegisterResetAllFilter: ( filter: ResetAllFilter ) => void;\n\tflagItemCustomization: (\n\t\tlabel: string,\n\t\tgroup?: ToolsPanelMenuItemKey\n\t) => void;\n\tisResetting: boolean;\n\tshouldRenderPlaceholderItems: boolean;\n\tareAllOptionalControlsHidden: boolean;\n\tfirstDisplayedItem?: string;\n\tlastDisplayedItem?: string;\n\t__experimentalFirstVisibleItemClass?: string;\n\t__experimentalLastVisibleItemClass?: string;\n};\n\nexport type ToolsPanelControlsGroupProps = {\n\titemClassName?: string;\n\titems: [ string, boolean ][];\n\ttoggleItem: ( label: string ) => void;\n};\n\nexport type ToolsPanelMenuItemsConfig = {\n\tpanelItems: ToolsPanelItem[];\n\tshouldReset: boolean;\n\tcurrentMenuItems?: ToolsPanelMenuItems;\n\tmenuItemOrder: string[];\n};\n"],"mappings":""}
@@ -4,7 +4,7 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
4
4
  Object.defineProperty(exports, "__esModule", {
5
5
  value: true
6
6
  });
7
- exports.default = exports.TOOLTIP_DELAY = void 0;
7
+ exports.default = exports.Tooltip = exports.TOOLTIP_DELAY = void 0;
8
8
  var _react = require("react");
9
9
  var Ariakit = _interopRequireWildcard(require("@ariakit/react"));
10
10
  var _compose = require("@wordpress/compose");
@@ -12,6 +12,7 @@ var _element = require("@wordpress/element");
12
12
  var _deprecated = _interopRequireDefault(require("@wordpress/deprecated"));
13
13
  var _shortcut = _interopRequireDefault(require("../shortcut"));
14
14
  var _utils = require("../popover/utils");
15
+ var _context = require("../context");
15
16
  function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
16
17
  function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
17
18
  /**
@@ -28,7 +29,12 @@ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj &&
28
29
  */
29
30
  const TOOLTIP_DELAY = 700;
30
31
  exports.TOOLTIP_DELAY = TOOLTIP_DELAY;
31
- function Tooltip(props) {
32
+ const CONTEXT_VALUE = {
33
+ Tooltip: {
34
+ isNestedInTooltip: true
35
+ }
36
+ };
37
+ function UnconnectedTooltip(props, ref) {
32
38
  const {
33
39
  children,
34
40
  delay = TOOLTIP_DELAY,
@@ -36,8 +42,11 @@ function Tooltip(props) {
36
42
  placement,
37
43
  position,
38
44
  shortcut,
39
- text
40
- } = props;
45
+ text,
46
+ // From Internal Context system
47
+ isNestedInTooltip,
48
+ ...restProps
49
+ } = (0, _context.useContextSystem)(props, 'Tooltip');
41
50
  const baseId = (0, _compose.useInstanceId)(Tooltip, 'tooltip');
42
51
  const describedById = text || shortcut ? baseId : undefined;
43
52
  const isOnlyChild = _element.Children.count(children) === 1;
@@ -45,7 +54,7 @@ function Tooltip(props) {
45
54
  if (!isOnlyChild) {
46
55
  if ('development' === process.env.NODE_ENV) {
47
56
  // eslint-disable-next-line no-console
48
- console.error('Tooltip should be called with only a single child element.');
57
+ console.error('wp-components.Tooltip should be called with only a single child element.');
49
58
  }
50
59
  }
51
60
 
@@ -64,17 +73,30 @@ function Tooltip(props) {
64
73
  });
65
74
  }
66
75
  computedPlacement = computedPlacement || 'bottom';
67
- const tooltipStore = Ariakit.useTooltipStore({
76
+
77
+ // Removing the `Ariakit` namespace from the hook name allows ESLint to
78
+ // properly identify the hook, and apply the correct linting rules.
79
+ const useAriakitTooltipStore = Ariakit.useTooltipStore;
80
+ const tooltipStore = useAriakitTooltipStore({
68
81
  placement: computedPlacement,
69
- timeout: delay
82
+ showTimeout: delay
70
83
  });
71
- return (0, _react.createElement)(_react.Fragment, null, (0, _react.createElement)(Ariakit.TooltipAnchor, {
84
+ if (isNestedInTooltip) {
85
+ return isOnlyChild ? (0, _element.cloneElement)(children, {
86
+ ...restProps,
87
+ ref
88
+ }) : children;
89
+ }
90
+ return (0, _react.createElement)(_context.ContextSystemProvider, {
91
+ value: CONTEXT_VALUE
92
+ }, (0, _react.createElement)(Ariakit.TooltipAnchor, {
72
93
  onClick: hideOnClick ? tooltipStore.hide : undefined,
73
94
  store: tooltipStore,
74
- render: isOnlyChild ? children : undefined
95
+ render: isOnlyChild ? children : undefined,
96
+ ref: ref
75
97
  }, isOnlyChild ? undefined : children), isOnlyChild && (text || shortcut) && (0, _react.createElement)(Ariakit.Tooltip, {
98
+ ...restProps,
76
99
  unmountOnHide: true,
77
- className: "components-tooltip",
78
100
  gutter: 4,
79
101
  id: describedById,
80
102
  overflowPadding: 0.5,
@@ -84,6 +106,8 @@ function Tooltip(props) {
84
106
  shortcut: shortcut
85
107
  })));
86
108
  }
109
+ const Tooltip = (0, _context.contextConnect)(UnconnectedTooltip, 'Tooltip');
110
+ exports.Tooltip = Tooltip;
87
111
  var _default = Tooltip;
88
112
  exports.default = _default;
89
113
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["Ariakit","_interopRequireWildcard","require","_compose","_element","_deprecated","_interopRequireDefault","_shortcut","_utils","_getRequireWildcardCache","nodeInterop","WeakMap","cacheBabelInterop","cacheNodeInterop","obj","__esModule","default","cache","has","get","newObj","hasPropertyDescriptor","Object","defineProperty","getOwnPropertyDescriptor","key","prototype","hasOwnProperty","call","desc","set","TOOLTIP_DELAY","exports","Tooltip","props","children","delay","hideOnClick","placement","position","shortcut","text","baseId","useInstanceId","describedById","undefined","isOnlyChild","Children","count","process","env","NODE_ENV","console","error","computedPlacement","positionToPlacement","deprecated","since","alternative","tooltipStore","useTooltipStore","timeout","_react","createElement","Fragment","TooltipAnchor","onClick","hide","store","render","unmountOnHide","className","gutter","id","overflowPadding","_default"],"sources":["@wordpress/components/src/tooltip/index.tsx"],"sourcesContent":["/**\n * External dependencies\n */\n// eslint-disable-next-line no-restricted-imports\nimport * as Ariakit from '@ariakit/react';\n\n/**\n * WordPress dependencies\n */\nimport { useInstanceId } from '@wordpress/compose';\nimport { Children } from '@wordpress/element';\nimport deprecated from '@wordpress/deprecated';\n\n/**\n * Internal dependencies\n */\nimport type { TooltipProps } from './types';\nimport Shortcut from '../shortcut';\nimport { positionToPlacement } from '../popover/utils';\n\n/**\n * Time over anchor to wait before showing tooltip\n */\nexport const TOOLTIP_DELAY = 700;\n\nfunction Tooltip( props: TooltipProps ) {\n\tconst {\n\t\tchildren,\n\t\tdelay = TOOLTIP_DELAY,\n\t\thideOnClick = true,\n\t\tplacement,\n\t\tposition,\n\t\tshortcut,\n\t\ttext,\n\t} = props;\n\n\tconst baseId = useInstanceId( Tooltip, 'tooltip' );\n\tconst describedById = text || shortcut ? baseId : undefined;\n\n\tconst isOnlyChild = Children.count( children ) === 1;\n\t// console error if more than one child element is added\n\tif ( ! isOnlyChild ) {\n\t\tif ( 'development' === process.env.NODE_ENV ) {\n\t\t\t// eslint-disable-next-line no-console\n\t\t\tconsole.error(\n\t\t\t\t'Tooltip should be called with only a single child element.'\n\t\t\t);\n\t\t}\n\t}\n\n\t// Compute tooltip's placement:\n\t// - give priority to `placement` prop, if defined\n\t// - otherwise, compute it from the legacy `position` prop (if defined)\n\t// - finally, fallback to the default placement: 'bottom'\n\tlet computedPlacement;\n\tif ( placement !== undefined ) {\n\t\tcomputedPlacement = placement;\n\t} else if ( position !== undefined ) {\n\t\tcomputedPlacement = positionToPlacement( position );\n\t\tdeprecated( '`position` prop in wp.components.tooltip', {\n\t\t\tsince: '6.4',\n\t\t\talternative: '`placement` prop',\n\t\t} );\n\t}\n\tcomputedPlacement = computedPlacement || 'bottom';\n\n\tconst tooltipStore = Ariakit.useTooltipStore( {\n\t\tplacement: computedPlacement,\n\t\ttimeout: delay,\n\t} );\n\n\treturn (\n\t\t<>\n\t\t\t<Ariakit.TooltipAnchor\n\t\t\t\tonClick={ hideOnClick ? tooltipStore.hide : undefined }\n\t\t\t\tstore={ tooltipStore }\n\t\t\t\trender={ isOnlyChild ? children : undefined }\n\t\t\t>\n\t\t\t\t{ isOnlyChild ? undefined : children }\n\t\t\t</Ariakit.TooltipAnchor>\n\t\t\t{ isOnlyChild && ( text || shortcut ) && (\n\t\t\t\t<Ariakit.Tooltip\n\t\t\t\t\tunmountOnHide\n\t\t\t\t\tclassName=\"components-tooltip\"\n\t\t\t\t\tgutter={ 4 }\n\t\t\t\t\tid={ describedById }\n\t\t\t\t\tover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A,GAEc1C,OAAO;AAAAD,OAAA,CAAAhB,OAAA,GAAA2D,QAAA"}
1
+ {"version":3,"names":["Ariakit","_interopRequireWildcard","require","_compose","_element","_deprecated","_interopRequireDefault","_shortcut","_utils","_context","_getRequireWildcardCache","nodeInterop","WeakMap","cacheBabelInterop","cacheNodeInterop","obj","__esModule","default","cache","has","get","newObj","hasPropertyDescriptor","Object","defineProperty","getOwnPropertyDescriptor","key","prototype","hasOwnProperty","call","desc","set","TOOLTIP_DELAY","exports","CONTEXT_VALUE","Tooltip","isNestedInTooltip","UnconnectedTooltip","props","ref","children","delay","hideOnClick","placement","position","shortcut","text","restProps","useContextSystem","baseId","useInstanceId","describedById","undefined","isOnlyChild","Children","count","process","env","NODE_ENV","console","error","computedPlacement","positionToPlacement","deprecated","since","alternative","useAriakitTooltipStore","useTooltipStore","tooltipStore","showTimeout","cloneElement","_react","createElement","ContextSystemProvider","value","TooltipAnchor","onClick","hide","store","render","unmountOnHide","gutter","id","overflowPadding","className","contextConnect","_default"],"sources":["@wordpress/components/src/tooltip/index.tsx"],"sourcesContent":["/**\n * External dependencies\n */\n// eslint-disable-next-line no-restricted-imports\nimport * as Ariakit from '@ariakit/react';\n\n/**\n * WordPress dependencies\n */\nimport { useInstanceId } from '@wordpress/compose';\nimport { Children, cloneElement } from '@wordpress/element';\nimport deprecated from '@wordpress/deprecated';\n\n/**\n * Internal dependencies\n */\nimport type { TooltipProps, TooltipInternalContext } from './types';\nimport Shortcut from '../shortcut';\nimport { positionToPlacement } from '../popover/utils';\nimport {\n\tcontextConnect,\n\tuseContextSystem,\n\tContextSystemProvider,\n} from '../context';\nimport type { WordPressComponentProps } from '../context';\n\n/**\n * Time over anchor to wait before showing tooltip\n */\nexport const TOOLTIP_DELAY = 700;\n\nconst CONTEXT_VALUE = {\n\tTooltip: {\n\t\tisNestedInTooltip: true,\n\t},\n};\n\nfunction UnconnectedTooltip(\n\tprops: WordPressComponentProps< TooltipProps, 'div', false >,\n\tref: React.ForwardedRef< any >\n) {\n\tconst {\n\t\tchildren,\n\t\tdelay = TOOLTIP_DELAY,\n\t\thideOnClick = true,\n\t\tplacement,\n\t\tposition,\n\t\tshortcut,\n\t\ttext,\n\n\t\t// From Internal Context system\n\t\tisNestedInTooltip,\n\n\t\t...restProps\n\t} = useContextSystem< typeof props & TooltipInternalContext >(\n\t\tprops,\n\t\t'Tooltip'\n\t);\n\n\tconst baseId = useInstanceId( Tooltip, 'tooltip' );\n\tconst describedById = text || shortcut ? baseId : undefined;\n\n\tconst isOnlyChild = Children.count( children ) === 1;\n\t// console error if more than one child element is added\n\tif ( ! isOnlyChild ) {\n\t\tif ( 'development' === process.env.NODE_ENV ) {\n\t\t\t// eslint-disable-next-line no-console\n\t\t\tconsole.error(\n\t\t\t\t'wp-components.Tooltip should be called with only a single child element.'\n\t\t\t);\n\t\t}\n\t}\n\n\t// Compute tooltip's placement:\n\t// - give priority to `placement` prop, if defined\n\t// - otherwise, compute it from the legacy `position` prop (if defined)\n\t// - finally, fallback to the default placement: 'bottom'\n\tlet computedPlacement;\n\tif ( placement !== undefined ) {\n\t\tcomputedPlacement = placement;\n\t} else if ( position !== undefined ) {\n\t\tcomputedPlacement = positionToPlacement( position );\n\t\tdeprecated( '`position` prop in wp.components.tooltip', {\n\t\t\tsince: '6.4',\n\t\t\talternative: '`placement` prop',\n\t\t} );\n\t}\n\tcomputedPlacement = computedPlacement || 'bottom';\n\n\t// Removing the `Ariakit` namespace from the hook name allows ESLint to\n\t// properly identify the hook, and apply the correct linting rules.\n\tconst useAriakitTooltipStore = Ariakit.useTooltipStore;\n\tconst tooltipStore = useAriakitTooltipStore( {\n\t\tplacement: computedPlacement,\n\t\tshowTimeout: delay,\n\t} );\n\n\tif ( isNestedInTooltip ) {\n\t\treturn isOnlyChild\n\t\t\t? cloneElement( children, {\n\t\t\t\t\t...restProps,\n\t\t\t\t\tref,\n\t\t\t } )\n\t\t\t: children;\n\t}\n\n\treturn (\n\t\t<ContextSystemProvider value={ CONTEXT_VALUE }>\n\t\t\t<Ariakit.TooltipAnchor\n\t\t\t\tonClick={ hideOnClick ? tooltipStore.hide : undefined }\n\t\t\t\tstore={ tooltipStore }\n\t\t\t\trender={ isOnlyChild ? children : undefined }\n\t\t\t\tref={ ref }\n\t\t\t>\n\t\t\t\t{ isOnlyChild ? undefined : children }\n\t\t\t</Ariakit.TooltipAnchor>\n\t\t\t{ isOnlyChild && ( text || shortcut ) && (\n\t\t\t\t<Ariakit.Tooltip\n\t\t\t\t\t{ ...restProps }\n\t\t\t\t\tunmountOnHide\n\t\t\t\t\tgutter={ 4 }\n\t\t\t\t\tid={ describedById }\n\t\t\t\t\toverflowPadding={ 0.5 }\n\t\t\t\t\tstore={ tooltipStore }\n\t\t\t\t>\n\t\t\t\t\t{ text }\n\t\t\t\t\t{ shortcut && (\n\t\t\t\t\t\t<Shortcut\n\t\t\t\t\t\t\tclassName={\n\t\t\t\t\t\t\t\ttext ? 'components-tooltip__shortcut' : ''\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tshortcut={ shortcut }\n\t\t\t\t\t\t/>\n\t\t\t\t\t) }\n\t\t\t\t</Ariakit.Tooltip>\n\t\t\t) }\n\t\t</ContextSystemProvider>\n\t);\n}\n\nexport const Tooltip = contextConnect( UnconnectedTooltip, 'Tooltip' );\n\nexport default Tooltip;\n"],"mappings":";;;;;;;;AAIA,IAAAA,OAAA,GAAAC,uBAAA,CAAAC,OAAA;AAKA,IAAAC,QAAA,GAAAD,OAAA;AACA,IAAAE,QAAA,GAAAF,OAAA;AACA,IAAAG,WAAA,GAAAC,sBAAA,CAAAJ,OAAA;AAMA,IAAAK,SAAA,GAAAD,sBAAA,CAAAJ,OAAA;AACA,IAAAM,MAAA,GAAAN,OAAA;AACA,IAAAO,QAAA,GAAAP,OAAA;AAIoB,SAAAQ,yBAAAC,WAAA,eAAAC,OAAA,kCAAAC,iBAAA,OAAAD,OAAA,QAAAE,gBAAA,OAAAF,OAAA,YAAAF,wBAAA,YAAAA,C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EAAE9B,QAAQ,EAAE;MACxB,GAAGO,SAAS;MACZR;IACA,CAAE,CAAC,GACHC,QAAQ;EACZ;EAEA,OACC,IAAA+B,MAAA,CAAAC,aAAA,EAAC/D,QAAA,CAAAgE,qBAAqB;IAACC,KAAK,EAAGxC;EAAe,GAC7C,IAAAqC,MAAA,CAAAC,aAAA,EAACxE,OAAO,CAAC2E,aAAa;IACrBC,OAAO,EAAGlC,WAAW,GAAG0B,YAAY,CAACS,IAAI,GAAGzB,SAAW;IACvD0B,KAAK,EAAGV,YAAc;IACtBW,MAAM,EAAG1B,WAAW,GAAGb,QAAQ,GAAGY,SAAW;IAC7Cb,GAAG,EAAGA;EAAK,GAETc,WAAW,GAAGD,SAAS,GAAGZ,QACN,CAAC,EACtBa,WAAW,KAAMP,IAAI,IAAID,QAAQ,CAAE,IACpC,IAAA0B,MAAA,CAAAC,aAAA,EAACxE,OAAO,CAACmC,OAAO;IAAA,GACVY,SAAS;IACdiC,aAAa;IACbC,MAAM,EAAG,CAAG;IACZC,EAAE,EAAG/B,aAAe;IACpBgC,eAAe,EAAG,GAAK;IACvBL,KAAK,EAAGV;EAAc,GAEpBtB,IAAI,EACJD,QAAQ,IACT,IAAA0B,MAAA,CAAAC,aAAA,EAACjE,SAAA,CAAAU,OAAQ;IACRmE,SAAS,EACRtC,IAAI,GAAG,8BAA8B,GAAG,EACxC;IACDD,QAAQ,EAAGA;EAAU,CACrB,CAEc,CAEI,CAAC;AAE1B;AAEO,MAAMV,OAAO,GAAG,IAAAkD,uBAAc,EAAEhD,kBAAkB,EAAE,SAAU,CAAC;AAACJ,OAAA,CAAAE,OAAA,GAAAA,OAAA;AAAA,IAAAmD,QAAA,GAExDnD,OAAO;AAAAF,OAAA,CAAAhB,OAAA,GAAAqE,QAAA"}
@@ -1 +1 @@
1
- {"version":3,"names":[],"sources":["@wordpress/components/src/tooltip/types.ts"],"sourcesContent":["/**\n * External dependencies\n */\nimport type { Placement } from '@floating-ui/react-dom';\n\n/**\n * Internal dependencies\n */\nimport type { PopoverProps } from '../popover/types';\nimport type { ShortcutProps } from '../shortcut/types';\n\nexport type TooltipProps = {\n\t/**\n\t * The anchor for the tooltip.\n\t *\n\t * **Note**: Accepts only one child element.\n\t */\n\tchildren: React.ReactElement;\n\t/**\n\t * Option to hide the tooltip when the anchor is clicked.\n\t *\n\t * @default true\n\t */\n\thideOnClick?: boolean;\n\t/**\n\t * The amount of time in milliseconds to wait before showing the tooltip.\n\t *\n\t * @default 700\n\t */\n\tdelay?: number;\n\t/**\n\t * Where the tooltip should be positioned relative to its parent.\n\t *\n\t * @default bottom\n\t */\n\tplacement?: Placement;\n\t/**\n\t * _Note: this prop is deprecated. Please use the `placement` prop instead._\n\t *\n\t * Legacy way of specifying the tooltip's position relative to its parent.\n\t *\n\t * Specify y- and x-axis as a space-separated string. Supports `\"top\"`,\n\t * `\"bottom\"` y axis, and `\"left\"`, `\"center\"`, `\"right\"` x axis.\n\t *\n\t * @deprecated\n\t * @default bottom\n\t */\n\tposition?: PopoverProps[ 'position' ];\n\t/**\n\t * An option for adding accessible keyboard shortcuts.\n\t *\n\t * If shortcut is a string, it is expecting the display text. If shortcut is an\n\t * object, it will accept the properties of `display` (string) and `ariaLabel`\n\t * (string).\n\t */\n\tshortcut?: ShortcutProps[ 'shortcut' ];\n\t/**\n\t * The text shown in the tooltip when anchor element is focused or hovered.\n\t */\n\ttext?: string;\n};\n"],"mappings":""}
1
+ {"version":3,"names":[],"sources":["@wordpress/components/src/tooltip/types.ts"],"sourcesContent":["/**\n * External dependencies\n */\nimport type { Placement } from '@floating-ui/react-dom';\n\n/**\n * Internal dependencies\n */\nimport type { PopoverProps } from '../popover/types';\nimport type { ShortcutProps } from '../shortcut/types';\n\nexport type TooltipProps = {\n\t/**\n\t * The anchor for the tooltip.\n\t *\n\t * **Note**: Accepts only one child element.\n\t */\n\tchildren: React.ReactElement;\n\t/**\n\t * Option to hide the tooltip when the anchor is clicked.\n\t *\n\t * @default true\n\t */\n\thideOnClick?: boolean;\n\t/**\n\t * The amount of time in milliseconds to wait before showing the tooltip.\n\t *\n\t * @default 700\n\t */\n\tdelay?: number;\n\t/**\n\t * Where the tooltip should be positioned relative to its parent.\n\t *\n\t * @default bottom\n\t */\n\tplacement?: Placement;\n\t/**\n\t * _Note: this prop is deprecated. Please use the `placement` prop instead._\n\t *\n\t * Legacy way of specifying the tooltip's position relative to its parent.\n\t *\n\t * Specify y- and x-axis as a space-separated string. Supports `\"top\"`,\n\t * `\"bottom\"` y axis, and `\"left\"`, `\"center\"`, `\"right\"` x axis.\n\t *\n\t * @deprecated\n\t * @default bottom\n\t */\n\tposition?: PopoverProps[ 'position' ];\n\t/**\n\t * An option for adding accessible keyboard shortcuts.\n\t *\n\t * If shortcut is a string, it is expecting the display text. If shortcut is an\n\t * object, it will accept the properties of `display` (string) and `ariaLabel`\n\t * (string).\n\t */\n\tshortcut?: ShortcutProps[ 'shortcut' ];\n\t/**\n\t * The text shown in the tooltip when anchor element is focused or hovered.\n\t */\n\ttext?: string;\n};\n\nexport type TooltipInternalContext = {\n\tisNestedInTooltip?: boolean;\n};\n"],"mappings":""}
@@ -31,15 +31,21 @@ function useTruncate(props) {
31
31
  ...otherProps
32
32
  } = (0, _context.useContextSystem)(props, 'Truncate');
33
33
  const cx = (0, _useCx.useCx)();
34
- const truncatedContent = (0, _utils.truncateContent)(typeof children === 'string' ? children : '', {
34
+ let childrenAsText;
35
+ if (typeof children === 'string') {
36
+ childrenAsText = children;
37
+ } else if (typeof children === 'number') {
38
+ childrenAsText = children.toString();
39
+ }
40
+ const truncatedContent = childrenAsText ? (0, _utils.truncateContent)(childrenAsText, {
35
41
  ellipsis,
36
42
  ellipsizeMode,
37
43
  limit,
38
44
  numberOfLines
39
- });
40
- const shouldTruncate = ellipsizeMode === _utils.TRUNCATE_TYPE.auto;
45
+ }) : children;
46
+ const shouldTruncate = !!childrenAsText && ellipsizeMode === _utils.TRUNCATE_TYPE.auto;
41
47
  const classes = (0, _element.useMemo)(() => {
42
- const truncateLines = /*#__PURE__*/(0, _react.css)("-webkit-box-orient:vertical;-webkit-line-clamp:", numberOfLines, ";display:-webkit-box;overflow:hidden;" + (process.env.NODE_ENV === "production" ? "" : ";label:truncateLines;"), process.env.NODE_ENV === "production" ? "" : "/*# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIkB3b3JkcHJlc3MvY29tcG9uZW50cy9zcmMvdHJ1bmNhdGUvaG9vay50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFnRDJCIiwiZmlsZSI6IkB3b3JkcHJlc3MvY29tcG9uZW50cy9zcmMvdHJ1bmNhdGUvaG9vay50cyIsInNvdXJjZXNDb250ZW50IjpbIi8qKlxuICogRXh0ZXJuYWwgZGVwZW5kZW5jaWVzXG4gKi9cbmltcG9ydCB7IGNzcyB9IGZyb20gJ0BlbW90aW9uL3JlYWN0JztcblxuLyoqXG4gKiBXb3JkUHJlc3MgZGVwZW5kZW5jaWVzXG4gKi9cbmltcG9ydCB7IHVzZU1lbW8gfSBmcm9tICdAd29yZHByZXNzL2VsZW1lbnQnO1xuXG4vKipcbiAqIEludGVybmFsIGRlcGVuZGVuY2llc1xuICovXG5pbXBvcnQgdHlwZSB7IFdvcmRQcmVzc0NvbXBvbmVudFByb3BzIH0gZnJvbSAnLi4vY29udGV4dCc7XG5pbXBvcnQgeyB1c2VDb250ZXh0U3lzdGVtIH0gZnJvbSAnLi4vY29udGV4dCc7XG5pbXBvcnQgKiBhcyBzdHlsZXMgZnJvbSAnLi9zdHlsZXMnO1xuaW1wb3J0IHsgVFJVTkNBVEVfRUxMSVBTSVMsIFRSVU5DQVRFX1RZUEUsIHRydW5jYXRlQ29udGVudCB9IGZyb20gJy4vdXRpbHMnO1xuaW1wb3J0IHsgdXNlQ3ggfSBmcm9tICcuLi91dGlscy9ob29rcy91c2UtY3gnO1xuaW1wb3J0IHR5cGUgeyBUcnVuY2F0ZVByb3BzIH0gZ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via2l0LWJveDtcblx0XHRcdG92ZXJmbG93OiBoaWRkZW47XG5cdFx0YDtcblxuXHRcdHJldHVybiBjeChcblx0XHRcdHNob3VsZFRydW5jYXRlICYmICEgbnVtYmVyT2ZMaW5lcyAmJiBzdHlsZXMuVHJ1bmNhdGUsXG5cdFx0XHRzaG91bGRUcnVuY2F0ZSAmJiAhISBudW1iZXJPZkxpbmVzICYmIHRydW5jYXRlTGluZXMsXG5cdFx0XHRjbGFzc05hbWVcblx0XHQpO1xuXHR9LCBbIGNsYXNzTmFtZSwgY3gsIG51bWJlck9mTGluZXMsIHNob3VsZFRydW5jYXRlIF0gKTtcblxuXHRyZXR1cm4geyAuLi5vdGhlclByb3BzLCBjbGFzc05hbWU6IGNsYXNzZXMsIGNoaWxkcmVuOiB0cnVuY2F0ZWRDb250ZW50IH07XG59XG4iXX0= */");
48
+ const truncateLines = /*#__PURE__*/(0, _react.css)("-webkit-box-orient:vertical;-webkit-line-clamp:", numberOfLines, ";display:-webkit-box;overflow:hidden;" + (process.env.NODE_ENV === "production" ? "" : ";label:truncateLines;"), process.env.NODE_ENV === "production" ? "" : "/*# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIkB3b3JkcHJlc3MvY29tcG9uZW50cy9zcmMvdHJ1bmNhdGUvaG9vay50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUF1RDJCIiwiZmlsZSI6IkB3b3JkcHJlc3MvY29tcG9uZW50cy9zcmMvdHJ1bmNhdGUvaG9vay50cyIsInNvdXJjZXNDb250ZW50IjpbIi8qKlxuICogRXh0ZXJuYWwgZGVwZW5kZW5jaWVzXG4gKi9cbmltcG9ydCB7IGNzcyB9IGZyb20gJ0BlbW90aW9uL3JlYWN0JztcblxuLyoqXG4gKiBXb3JkUHJlc3MgZGVwZW5kZW5jaWVzXG4gKi9cbmltcG9ydCB7IHVzZU1lbW8gfSBmcm9tICdAd29yZHByZXNzL2VsZW1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51bWJlck9mTGluZXMsIHNob3VsZFRydW5jYXRlIF0gKTtcblxuXHRyZXR1cm4geyAuLi5vdGhlclByb3BzLCBjbGFzc05hbWU6IGNsYXNzZXMsIGNoaWxkcmVuOiB0cnVuY2F0ZWRDb250ZW50IH07XG59XG4iXX0= */");
43
49
  return cx(shouldTruncate && !numberOfLines && styles.Truncate, shouldTruncate && !!numberOfLines && truncateLines, className);
44
50
  }, [className, cx, numberOfLines, shouldTruncate]);
45
51
  return {
@@ -1 +1 @@
1
- {"version":3,"names":["_react","require","_element","_context","styles","_interopRequireWildcard","_utils","_useCx","_getRequireWildcardCache","nodeInterop","WeakMap","cacheBabelInterop","cacheNodeInterop","obj","__esModule","default","cache","has","get","newObj","hasPropertyDescriptor","Object","defineProperty","getOwnPropertyDescriptor","key","prototype","hasOwnProperty","call","desc","set","useTruncate","props","className","children","ellipsis","TRUNCATE_ELLIPSIS","ellipsizeMode","TRUNCATE_TYPE","auto","limit","numberOfLines","otherProps","useContextSystem","cx","useCx","truncatedContent","truncateContent","shouldTruncate","classes","useMemo","truncateLines","css","process","env","NODE_ENV","Truncate"],"sources":["@wordpress/components/src/truncate/hook.ts"],"sourcesContent":["/**\n * External dependencies\n */\nimport { css } from '@emotion/react';\n\n/**\n * WordPress dependencies\n */\nimport { useMemo } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport type { WordPressComponentProps } from '../context';\nimport { useContextSystem } from '../context';\nimport * as styles from './styles';\nimport { TRUNCATE_ELLIPSIS, TRUNCATE_TYPE, truncateContent } from './utils';\nimport { useCx } from '../utils/hooks/use-cx';\nimport type { TruncateProps } from './types';\n\nexport default function useTruncate(\n\tprops: WordPressComponentProps< TruncateProps, 'span' >\n) {\n\tconst {\n\t\tclassName,\n\t\tchildren,\n\t\tellipsis = TRUNCATE_ELLIPSIS,\n\t\tellipsizeMode = TRUNCATE_TYPE.auto,\n\t\tlimit = 0,\n\t\tnumberOfLines = 0,\n\t\t...otherProps\n\t} = useContextSystem( props, 'Truncate' );\n\n\tconst cx = useCx();\n\n\tconst truncatedContent = truncateContent(\n\t\ttypeof children === 'string' ? children : '',\n\t\t{\n\t\t\tellipsis,\n\t\t\tellipsizeMode,\n\t\t\tlimit,\n\t\t\tnumberOfLines,\n\t\t}\n\t);\n\n\tconst shouldTruncate = ellipsizeMode === TRUNCATE_TYPE.auto;\n\n\tconst classes = useMemo( () => {\n\t\tconst truncateLines = css`\n\t\t\t-webkit-box-orient: vertical;\n\t\t\t-webkit-line-clamp: ${ numberOfLines };\n\t\t\tdisplay: -webkit-box;\n\t\t\toverflow: hidden;\n\t\t`;\n\n\t\treturn cx(\n\t\t\tshouldTruncate && ! numberOfLines && styles.Truncate,\n\t\t\tshouldTruncate && !! numberOfLines && truncateLines,\n\t\t\tclassName\n\t\t);\n\t}, [ className, cx, numberOfLines, shouldTruncate ] );\n\n\treturn { ...otherProps, className: classes, children: truncatedContent };\n}\n"],"mappings":";;;;;;AAGA,IAAAA,MAAA,GAAAC,OAAA;AAKA,IAAAC,QAAA,GAAAD,OAAA;AAMA,IAAAE,QAAA,GAAAF,OAAA;AACA,IAAAG,MAAA,GAAAC,uBAAA,CAAAJ,OAAA;AACA,IAAAK,MAAA,GAAAL,OAAA;AACA,IAAAM,MAAA,GAAAN,OAAA;AAA8C,SAAAO,yBAAAC,WAAA,eAAAC,OAAA,kCAAAC,iBAAA,OAAAD,OAAA,QAAAE,gBAAA,OAAAF,OAAA,YAAAF,wBAAA,YAAAA,CAAAC,WAAA,WAAAA,WAAA,GAAAG,gBAAA,GAAAD,iBAAA,KAAAF,WAAA;AAAA,SAAAJ,wBAAAQ,GAAA,EAAAJ,WAAA,SAAAA,WAAA,IAAAI,GAAA,IAAAA,GAAA,CAAAC,UAAA,WAAAD,GAAA,QAAAA,GAAA,oBAAAA,GAAA,wBAAAA,GAAA,4BAAAE,OAAA,EAAAF,GAAA,UAAAG,KAAA,GAAAR,wBAAA,CAAAC,WAAA,OAAAO,KAAA,IAAAA,KAAA,CAA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C,IAAI;EAE3D,MAAMU,OAAO,GAAG,IAAAC,gBAAO,EAAE,MAAM;IAC9B,MAAMC,aAAa,oBAAGC,UAAG,qDAEDX,aAAa,6CAAAY,OAAA,CAAAC,GAAA,CAAAC,QAAA,mDAAAF,OAAA,CAAAC,GAAA,CAAAC,QAAA,+9EAGpC;IAED,OAAOX,EAAE,CACRI,cAAc,IAAI,CAAEP,aAAa,IAAIpC,MAAM,CAACmD,QAAQ,EACpDR,cAAc,IAAI,CAAC,CAAEP,aAAa,IAAIU,aAAa,EACnDlB,SACD,CAAC;EACF,CAAC,EAAE,CAAEA,SAAS,EAAEW,EAAE,EAAEH,aAAa,EAAEO,cAAc,CAAG,CAAC;EAErD,OAAO;IAAE,GAAGN,UAAU;IAAET,SAAS,EAAEgB,OAAO;IAAEf,QAAQ,EAAEY;EAAiB,CAAC;AACzE"}
1
+ {"version":3,"names":["_react","require","_element","_context","styles","_interopRequireWildcard","_utils","_useCx","_getRequireWildcardCache","nodeInterop","WeakMap","cacheBabelInterop","cacheNodeInterop","obj","__esModule","default","cache","has","get","newObj","hasPropertyDescriptor","Object","defineProperty","getOwnPropertyDescriptor","key","prototype","hasOwnProperty","call","desc","set","useTruncate","props","className","children","ellipsis","TRUNCATE_ELLIPSIS","ellipsizeMode","TRUNCATE_TYPE","auto","limit","numberOfLines","otherProps","useContextSystem","cx","useCx","childrenAsText","toString","truncatedContent","truncateContent","shouldTruncate","classes","useMemo","truncateLines","css","process","env","NODE_ENV","Truncate"],"sources":["@wordpress/components/src/truncate/hook.ts"],"sourcesContent":["/**\n * External dependencies\n */\nimport { css } from '@emotion/react';\n\n/**\n * WordPress dependencies\n */\nimport { useMemo } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport type { WordPressComponentProps } from '../context';\nimport { useContextSystem } from '../context';\nimport * as styles from './styles';\nimport { TRUNCATE_ELLIPSIS, TRUNCATE_TYPE, truncateContent } from './utils';\nimport { useCx } from '../utils/hooks/use-cx';\nimport type { TruncateProps } from './types';\n\nexport default function useTruncate(\n\tprops: WordPressComponentProps< TruncateProps, 'span' >\n) {\n\tconst {\n\t\tclassName,\n\t\tchildren,\n\t\tellipsis = TRUNCATE_ELLIPSIS,\n\t\tellipsizeMode = TRUNCATE_TYPE.auto,\n\t\tlimit = 0,\n\t\tnumberOfLines = 0,\n\t\t...otherProps\n\t} = useContextSystem( props, 'Truncate' );\n\n\tconst cx = useCx();\n\n\tlet childrenAsText;\n\tif ( typeof children === 'string' ) {\n\t\tchildrenAsText = children;\n\t} else if ( typeof children === 'number' ) {\n\t\tchildrenAsText = children.toString();\n\t}\n\n\tconst truncatedContent = childrenAsText\n\t\t? truncateContent( childrenAsText, {\n\t\t\t\tellipsis,\n\t\t\t\tellipsizeMode,\n\t\t\t\tlimit,\n\t\t\t\tnumberOfLines,\n\t\t } )\n\t\t: children;\n\n\tconst shouldTruncate =\n\t\t!! childrenAsText && ellipsizeMode === TRUNCATE_TYPE.auto;\n\n\tconst classes = useMemo( () => {\n\t\tconst truncateLines = css`\n\t\t\t-webkit-box-orient: vertical;\n\t\t\t-webkit-line-clamp: ${ numberOfLines };\n\t\t\tdisplay: -webkit-box;\n\t\t\toverflow: hidden;\n\t\t`;\n\n\t\treturn cx(\n\t\t\tshouldTruncate && ! numberOfLines && styles.Truncate,\n\t\t\tshouldTruncate && !! numberOfLines && truncateLines,\n\t\t\tclassName\n\t\t);\n\t}, [ className, cx, numberOfLines, shouldTruncate ] );\n\n\treturn { ...otherProps, className: classes, children: truncatedContent };\n}\n"],"mappings":";;;;;;AAGA,IAAAA,MAAA,GAAAC,OAAA;AAKA,IAAAC,QAAA,GAAAD,OAAA;AAMA,IAAAE,QAAA,GAAAF,OAAA;AACA,IAAAG,MAAA,GAAAC,uBAAA,CAAAJ,OAAA;AACA,IAAAK,MAAA,GAAAL,OAAA;AACA,IAAAM,MAAA,GAAAN,OAAA;AAA8C,SAAAO,yBAAAC,WAAA,eAAAC,OAAA,kCAAAC,iBAAA,OAAAD,OAA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IACTC,aAAa,GAAG,CAAC;IACjB,GAAGC;EACJ,CAAC,GAAG,IAAAC,yBAAgB,EAAEX,KAAK,EAAE,UAAW,CAAC;EAEzC,MAAMY,EAAE,GAAG,IAAAC,YAAK,EAAC,CAAC;EAElB,IAAIC,cAAc;EAClB,IAAK,OAAOZ,QAAQ,KAAK,QAAQ,EAAG;IACnCY,cAAc,GAAGZ,QAAQ;EAC1B,CAAC,MAAM,IAAK,OAAOA,QAAQ,KAAK,QAAQ,EAAG;IAC1CY,cAAc,GAAGZ,QAAQ,CAACa,QAAQ,CAAC,CAAC;EACrC;EAEA,MAAMC,gBAAgB,GAAGF,cAAc,GACpC,IAAAG,sBAAe,EAAEH,cAAc,EAAE;IACjCX,QAAQ;IACRE,aAAa;IACbG,KAAK;IACLC;EACA,CAAE,CAAC,GACHP,QAAQ;EAEX,MAAMgB,cAAc,GACnB,CAAC,CAAEJ,cAAc,IAAIT,aAAa,KAAKC,oBAAa,CAACC,IAAI;EAE1D,MAAMY,OAAO,GAAG,IAAAC,gBAAO,EAAE,MAAM;IAC9B,MAAMC,aAAa,oBAAGC,UAAG,qDAEDb,aAAa,6CAAAc,OAAA,CAAAC,GAAA,CAAAC,QAAA,mDAAAF,OAAA,CAAAC,GAAA,CAAAC,QAAA,2wFAGpC;IAED,OAAOb,EAAE,CACRM,cAAc,IAAI,CAAET,aAAa,IAAIpC,MAAM,CAACqD,QAAQ,EACpDR,cAAc,IAAI,CAAC,CAAET,aAAa,IAAIY,aAAa,EACnDpB,SACD,CAAC;EACF,CAAC,EAAE,CAAEA,SAAS,EAAEW,EAAE,EAAEH,aAAa,EAAES,cAAc,CAAG,CAAC;EAErD,OAAO;IAAE,GAAGR,UAAU;IAAET,SAAS,EAAEkB,OAAO;IAAEjB,QAAQ,EAAEc;EAAiB,CAAC;AACzE"}
@@ -1 +1 @@
1
- {"version":3,"names":[],"sources":["@wordpress/components/src/truncate/types.ts"],"sourcesContent":["/**\n * External dependencies\n */\nimport type { ReactNode } from 'react';\n\nexport type TruncateEllipsizeMode =\n\t| 'auto'\n\t| 'head'\n\t| 'tail'\n\t| 'middle'\n\t| 'none';\n\nexport type TruncateProps = {\n\t/**\n\t * The ellipsis string when truncating the text by the `limit` prop's value.\n\t *\n\t * @default '…'\n\t */\n\tellipsis?: string;\n\t/**\n\t * Determines where to truncate. For example, we can truncate text right in\n\t * the middle. To do this, we need to set `ellipsizeMode` to `middle` and a\n\t * text `limit`.\n\t *\n\t * * `auto`: Trims content at the end automatically without a `limit`.\n\t * * `head`: Trims content at the beginning. Requires a `limit`.\n\t * * `middle`: Trims content in the middle. Requires a `limit`.\n\t * * `tail`: Trims content at the end. Requires a `limit`.\n\t *\n\t * @default 'auto'\n\t */\n\tellipsizeMode?: TruncateEllipsizeMode;\n\t/**\n\t * Determines the max number of characters to be displayed before the rest\n\t * of the text gets truncated. Requires `ellipsizeMode` to assume values\n\t * different from `auto` and `none`.\n\t *\n\t * @default 0\n\t */\n\tlimit?: number;\n\t/**\n\t * Clamps the text content to the specified `numberOfLines`, adding an\n\t * ellipsis at the end. Note: this feature ignores the value of the\n\t * `ellipsis` prop and always displays the default `…` ellipsis.\n\t *\n\t * @default 0\n\t */\n\tnumberOfLines?: number;\n\t/**\n\t * The children elements.\n\t */\n\tchildren: ReactNode;\n};\n"],"mappings":""}
1
+ {"version":3,"names":[],"sources":["@wordpress/components/src/truncate/types.ts"],"sourcesContent":["/**\n * External dependencies\n */\nimport type { ReactNode } from 'react';\n\nexport type TruncateEllipsizeMode =\n\t| 'auto'\n\t| 'head'\n\t| 'tail'\n\t| 'middle'\n\t| 'none';\n\nexport type TruncateProps = {\n\t/**\n\t * The ellipsis string when truncating the text by the `limit` prop's value.\n\t *\n\t * @default '…'\n\t */\n\tellipsis?: string;\n\t/**\n\t * Determines where to truncate. For example, we can truncate text right in\n\t * the middle. To do this, we need to set `ellipsizeMode` to `middle` and a\n\t * text `limit`.\n\t *\n\t * * `auto`: Trims content at the end automatically without a `limit`.\n\t * * `head`: Trims content at the beginning. Requires a `limit`.\n\t * * `middle`: Trims content in the middle. Requires a `limit`.\n\t * * `tail`: Trims content at the end. Requires a `limit`.\n\t *\n\t * @default 'auto'\n\t */\n\tellipsizeMode?: TruncateEllipsizeMode;\n\t/**\n\t * Determines the max number of characters to be displayed before the rest\n\t * of the text gets truncated. Requires `ellipsizeMode` to assume values\n\t * different from `auto` and `none`.\n\t *\n\t * @default 0\n\t */\n\tlimit?: number;\n\t/**\n\t * Clamps the text content to the specified `numberOfLines`, adding an\n\t * ellipsis at the end. Note: this feature ignores the value of the\n\t * `ellipsis` prop and always displays the default `…` ellipsis.\n\t *\n\t * @default 0\n\t */\n\tnumberOfLines?: number;\n\t/**\n\t * The children elements.\n\t *\n\t * Note: text truncation will be attempted only if the `children` are either\n\t * of type `string` or `number`. In any other scenarios, the component will\n\t * not attempt to truncate the text, and will pass through the `children`.\n\t */\n\tchildren: ReactNode;\n};\n"],"mappings":""}
@@ -139,7 +139,7 @@ function UnforwardedUnitControl(unitControlProps, forwardedRef) {
139
139
  disabled: disabled,
140
140
  isUnitSelectTabbable: isUnitSelectTabbable,
141
141
  onChange: handleOnUnitChange,
142
- size: size === 'small' || size === 'default' && !props.__next40pxDefaultSize ? 'small' : 'default',
142
+ size: ['small', 'compact'].includes(size) || size === 'default' && !props.__next40pxDefaultSize ? 'small' : 'default',
143
143
  unit: unit,
144
144
  units: units,
145
145
  onFocus: onFocusProp,
@@ -1 +1 @@
1
- {"version":3,"names":["_classnames","_interopRequireDefault","require","_deprecated","_element","_i18n","_unitControlStyles","_unitSelectControl","_utils","_hooks","_strings","_useDeprecatedProps","UnforwardedUnitControl","unitControlProps","forwardedRef","__unstableStateReducer","autoComplete","children","className","disabled","disableUnits","isPressEnterToChange","isResetValueOnUnitChange","isUnitSelectTabbable","label","onChange","onChangeProp","onUnitChange","size","unit","unitProp","units","unitsProp","CSS_UNITS","value","valueProp","onFocus","onFocusProp","props","useDeprecated36pxDefaultSizeProp","deprecated","since","hint","version","nonNullValueProp","undefined","reFirstCharacterOfUnits","useMemo","list","getUnitsWithCurrentUnit","firstUnitValue","rest","firstCharacters","reduce","carry","first","escapeRegExp","substring","includes","RegExp","parsedQuantity","parsedUnit","getParsedQuantityAndUnit","setUnit","useControlledState","length","initial","fallback","useEffect","classes","classnames","handleOnQuantityChange","nextQuantityValue","changeProps","onChangeValue","getValidParsedQuantityAndUnit","join","handleOnUnitChange","nextUnitValue","data","nextValue","default","handleOnKeyDown","event","onKeyDown","metaKey","test","key","refInputSuffix","current","focus","useRef","inputSuffix","_react","createElement","ref","__","__next40pxDefaultSize","onBlur","step","_activeUnit$step","activeUnit","find","option","ValueInput","spinControls","suffix","type","UnitControl","forwardRef","exports","_default"],"sources":["@wordpress/components/src/unit-control/index.tsx"],"sourcesContent":["/**\n * External dependencies\n */\nimport type { KeyboardEvent, ForwardedRef, SyntheticEvent } from 'react';\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport deprecated from '@wordpress/deprecated';\nimport { forwardRef, useMemo, useRef, useEffect } from '@wordpress/element';\nimport { __ } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport type { WordPressComponentProps } from '../context';\nimport { 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 { escapeRegExp } from '../utils/strings';\nimport type { UnitControlProps, UnitControlOnChangeCallback } from './types';\nimport { useDeprecated36pxDefaultSizeProp } from '../utils/use-deprecated-props';\n\nfunction UnforwardedUnitControl(\n\tunitControlProps: WordPressComponentProps<\n\t\tUnitControlProps,\n\t\t'input',\n\t\tfalse\n\t>,\n\tforwardedRef: ForwardedRef< any >\n) {\n\tconst {\n\t\t__unstableStateReducer,\n\t\tautoComplete = 'off',\n\t\t// @ts-expect-error Ensure that children is omitted from restProps\n\t\tchildren,\n\t\tclassName,\n\t\tdisabled = false,\n\t\tdisableUnits = false,\n\t\tisPressEnterToChange = false,\n\t\tisResetValueOnUnitChange = false,\n\t\tisUnitSelectTabbable = true,\n\t\tlabel,\n\t\tonChange: onChangeProp,\n\t\tonUnitChange,\n\t\tsize = 'default',\n\t\tunit: unitProp,\n\t\tunits: unitsProp = CSS_UNITS,\n\t\tvalue: valueProp,\n\t\tonFocus: onFocusProp,\n\t\t...props\n\t} = useDeprecated36pxDefaultSizeProp(\n\t\tunitControlProps,\n\t\t'wp.components.UnitControl',\n\t\t'6.4'\n\t);\n\n\tif ( 'unit' in unitControlProps ) {\n\t\tdeprecated( 'UnitControl unit prop', {\n\t\t\tsince: '5.6',\n\t\t\thint: 'The unit should be provided within the `value` prop.',\n\t\t\tversion: '6.2',\n\t\t} );\n\t}\n\n\t// The `value` prop, in theory, should not be `null`, but the following line\n\t// ensures it fallback to `undefined` in case a consumer of `UnitControl`\n\t// still passes `null` as a `value`.\n\tconst nonNullValueProp = valueProp ?? undefined;\n\tconst [ units, reFirstCharacterOfUnits ] = useMemo( () => {\n\t\tconst list = getUnitsWithCurrentUnit(\n\t\t\tnonNullValueProp,\n\t\t\tunitProp,\n\t\t\tunitsProp\n\t\t);\n\t\tconst [ { value: firstUnitValue = '' } = {}, ...rest ] = list;\n\t\tconst firstCharacters = rest.reduce(\n\t\t\t( carry, { value } ) => {\n\t\t\t\tconst first = escapeRegExp( value?.substring( 0, 1 ) || '' );\n\t\t\t\treturn carry.includes( first )\n\t\t\t\t\t? carry\n\t\t\t\t\t: `${ carry }|${ first }`;\n\t\t\t},\n\t\t\tescapeRegExp( firstUnitValue.substring( 0, 1 ) )\n\t\t);\n\t\treturn [ list, new RegExp( `^(?:${ firstCharacters })$`, 'i' ) ];\n\t}, [ nonNullValueProp, unitProp, unitsProp ] );\n\tconst [ parsedQuantity, parsedUnit ] = getParsedQuantityAndUnit(\n\t\tnonNullValueProp,\n\t\tunitProp,\n\t\tunits\n\t);\n\n\tconst [ unit, setUnit ] = useControlledState< string | undefined >(\n\t\tunits.length === 1 ? units[ 0 ].value : unitProp,\n\t\t{\n\t\t\tinitial: parsedUnit,\n\t\t\tfallback: '',\n\t\t}\n\t);\n\n\tuseEffect( () => {\n\t\tif ( parsedUnit !== undefined ) {\n\t\t\tsetUnit( parsedUnit );\n\t\t}\n\t}, [ parsedUnit, setUnit ] );\n\n\tconst classes = classnames(\n\t\t'components-unit-control',\n\t\t// This class is added for legacy purposes to maintain it on the outer\n\t\t// wrapper. See: https://github.com/WordPress/gutenberg/pull/45139\n\t\t'components-unit-control-wrapper',\n\t\tclassName\n\t);\n\n\tconst handleOnQuantityChange = (\n\t\tnextQuantityValue: number | string | undefined,\n\t\tchangeProps: {\n\t\t\tevent: SyntheticEvent;\n\t\t}\n\t) => {\n\t\tif (\n\t\t\tnextQuantityValue === '' ||\n\t\t\ttypeof nextQuantityValue === 'undefined' ||\n\t\t\tnextQuantityValue === null\n\t\t) {\n\t\t\tonChangeProp?.( '', changeProps );\n\t\t\treturn;\n\t\t}\n\n\t\t/*\n\t\t * Customizing the onChange callback.\n\t\t * This allows as to broadcast a combined value+unit to onChange.\n\t\t */\n\t\tconst onChangeValue = getValidParsedQuantityAndUnit(\n\t\t\tnextQuantityValue,\n\t\t\tunits,\n\t\t\tparsedQuantity,\n\t\t\tunit\n\t\t).join( '' );\n\n\t\tonChangeProp?.( onChangeValue, changeProps );\n\t};\n\n\tconst handleOnUnitChange: UnitControlOnChangeCallback = (\n\t\tnextUnitValue,\n\t\tchangeProps\n\t) => {\n\t\tconst { data } = changeProps;\n\n\t\tlet nextValue = `${ parsedQuantity ?? '' }${ nextUnitValue }`;\n\n\t\tif ( isResetValueOnUnitChange && data?.default !== undefined ) {\n\t\t\tnextValue = `${ data.default }${ nextUnitValue }`;\n\t\t}\n\n\t\tonChangeProp?.( nextValue, changeProps );\n\t\tonUnitChange?.( nextUnitValue, changeProps );\n\n\t\tsetUnit( nextUnitValue );\n\t};\n\n\tlet handleOnKeyDown;\n\tif ( ! disableUnits && isUnitSelectTabbable && units.length ) {\n\t\thandleOnKeyDown = ( event: KeyboardEvent< HTMLInputElement > ) => {\n\t\t\tprops.onKeyDown?.( event );\n\t\t\t// Unless the meta key was pressed (to avoid interfering with\n\t\t\t// shortcuts, e.g. pastes), moves focus to the unit select if a key\n\t\t\t// matches the first character of a unit.\n\t\t\tif ( ! event.metaKey && reFirstCharacterOfUnits.test( event.key ) )\n\t\t\t\trefInputSuffix.current?.focus();\n\t\t};\n\t}\n\n\tconst refInputSuffix = useRef< HTMLSelectElement >( null );\n\tconst inputSuffix = ! disableUnits ? (\n\t\t<UnitSelectControl\n\t\t\tref={ refInputSuffix }\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={\n\t\t\t\tsize === 'small' ||\n\t\t\t\t( size === 'default' && ! props.__next40pxDefaultSize )\n\t\t\t\t\t? 'small'\n\t\t\t\t\t: 'default'\n\t\t\t}\n\t\t\tunit={ unit }\n\t\t\tunits={ units }\n\t\t\tonFocus={ onFocusProp }\n\t\t\tonBlur={ unitControlProps.onBlur }\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<ValueInput\n\t\t\t{ ...props }\n\t\t\tautoComplete={ autoComplete }\n\t\t\tclassName={ classes }\n\t\t\tdisabled={ disabled }\n\t\t\tspinControls=\"none\"\n\t\t\tisPressEnterToChange={ isPressEnterToChange }\n\t\t\tlabel={ label }\n\t\t\tonKeyDown={ handleOnKeyDown }\n\t\t\tonChange={ handleOnQuantityChange }\n\t\t\tref={ forwardedRef }\n\t\t\tsize={ size }\n\t\t\tsuffix={ inputSuffix }\n\t\t\ttype={ isPressEnterToChange ? 'text' : 'number' }\n\t\t\tvalue={ parsedQuantity ?? '' }\n\t\t\tstep={ step }\n\t\t\tonFocus={ onFocusProp }\n\t\t\t__unstableStateReducer={ __unstableStateReducer }\n\t\t/>\n\t);\n}\n\n/**\n * `UnitControl` allows the user to set a numeric quantity as well as a unit (e.g. `px`).\n *\n *\n * ```jsx\n * import { __experimentalUnitControl as UnitControl } from '@wordpress/components';\n * import { useState } from '@wordpress/element';\n *\n * const Example = () => {\n * const [ value, setValue ] = useState( '10px' );\n *\n * return <UnitControl onChange={ setValue } value={ value } />;\n * };\n * ```\n */\nexport const UnitControl = forwardRef( UnforwardedUnitControl );\n\nexport { parseQuantityAndUnitFromRawValue, useCustomUnits } from './utils';\nexport default UnitControl;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAIA,IAAAA,WAAA,GAAAC,sBAAA,CAAAC,OAAA;AAKA,IAAAC,WAAA,GAAAF,sBAAA,CAAAC,OAAA;AACA,IAAAE,QAAA,GAAAF,OAAA;AACA,IAAAG,KAAA,GAAAH,OAAA;AAMA,IAAAI,kBAAA,GAAAJ,OAAA;AACA,IAAAK,kBAAA,GAAAN,sBAAA,CAAAC,OAAA;AACA,IAAAM,MAAA,GAAAN,OAAA;AAMA,IAAAO,MAAA,GAAAP,OAAA;AACA,IAAAQ,QAAA,GAAAR,OAAA;AAEA,IAAAS,mBAAA,GAAAT,OAAA;AA5BA;AACA;AACA;;AAIA;AACA;AACA;;AAsBA,SAASU,sBAAsBA,CAC9BC,gBAIC,EACDC,YAAiC,EAChC;EACD,MAAM;IACLC,sBAAsB;IACtBC,YAAY,GAAG,KAAK;IACpB;IACAC,QAAQ;IACRC,SAAS;IACTC,QAAQ,GAAG,KAAK;IAChBC,YAAY,GAAG,KAAK;IACpBC,oBAAoB,GAAG,KAAK;IAC5BC,wBAAwB,GAAG,KAAK;IAChCC,oBAAoB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A;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,MAAM6F,WAAW,GAAG,IAAAC,mBAAU,EAAEjG,sBAAuB,CAAC;AAACkG,OAAA,CAAAF,WAAA,GAAAA,WAAA;AAAA,IAAAG,QAAA,GAGjDH,WAAW;AAAAE,OAAA,CAAA7B,OAAA,GAAA8B,QAAA"}
1
+ {"version":3,"names":["_classnames","_interopRequireDefault","require","_deprecated","_element","_i18n","_unitControlStyles","_unitSelectControl","_utils","_hooks","_strings","_useDeprecatedProps","UnforwardedUnitControl","unitControlProps","forwardedRef","__unstableStateReducer","autoComplete","children","className","disabled","disableUnits","isPressEnterToChange","isResetValueOnUnitChange","isUnitSelectTabbable","label","onChange","onChangeProp","onUnitChange","size","unit","unitProp","units","unitsProp","CSS_UNITS","value","valueProp","onFocus","onFocusProp","props","useDeprecated36pxDefaultSizeProp","deprecated","since","hint","version","nonNullValueProp","undefined","reFirstCharacterOfUnits","useMemo","list","getUnitsWithCurrentUnit","firstUnitValue","rest","firstCharacters","reduce","carry","first","escapeRegExp","substring","includes","RegExp","parsedQuantity","parsedUnit","getParsedQuantityAndUnit","setUnit","useControlledState","length","initial","fallback","useEffect","classes","classnames","handleOnQuantityChange","nextQuantityValue","changeProps","onChangeValue","getValidParsedQuantityAndUnit","join","handleOnUnitChange","nextUnitValue","data","nextValue","default","handleOnKeyDown","event","onKeyDown","metaKey","test","key","refInputSuffix","current","focus","useRef","inputSuffix","_react","createElement","ref","__","__next40pxDefaultSize","onBlur","step","_activeUnit$step","activeUnit","find","option","ValueInput","spinControls","suffix","type","UnitControl","forwardRef","exports","_default"],"sources":["@wordpress/components/src/unit-control/index.tsx"],"sourcesContent":["/**\n * External dependencies\n */\nimport type { KeyboardEvent, ForwardedRef, SyntheticEvent } from 'react';\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport deprecated from '@wordpress/deprecated';\nimport { forwardRef, useMemo, useRef, useEffect } from '@wordpress/element';\nimport { __ } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport type { WordPressComponentProps } from '../context';\nimport { 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 { escapeRegExp } from '../utils/strings';\nimport type { UnitControlProps, UnitControlOnChangeCallback } from './types';\nimport { useDeprecated36pxDefaultSizeProp } from '../utils/use-deprecated-props';\n\nfunction UnforwardedUnitControl(\n\tunitControlProps: WordPressComponentProps<\n\t\tUnitControlProps,\n\t\t'input',\n\t\tfalse\n\t>,\n\tforwardedRef: ForwardedRef< any >\n) {\n\tconst {\n\t\t__unstableStateReducer,\n\t\tautoComplete = 'off',\n\t\t// @ts-expect-error Ensure that children is omitted from restProps\n\t\tchildren,\n\t\tclassName,\n\t\tdisabled = false,\n\t\tdisableUnits = false,\n\t\tisPressEnterToChange = false,\n\t\tisResetValueOnUnitChange = false,\n\t\tisUnitSelectTabbable = true,\n\t\tlabel,\n\t\tonChange: onChangeProp,\n\t\tonUnitChange,\n\t\tsize = 'default',\n\t\tunit: unitProp,\n\t\tunits: unitsProp = CSS_UNITS,\n\t\tvalue: valueProp,\n\t\tonFocus: onFocusProp,\n\t\t...props\n\t} = useDeprecated36pxDefaultSizeProp(\n\t\tunitControlProps,\n\t\t'wp.components.UnitControl',\n\t\t'6.4'\n\t);\n\n\tif ( 'unit' in unitControlProps ) {\n\t\tdeprecated( 'UnitControl unit prop', {\n\t\t\tsince: '5.6',\n\t\t\thint: 'The unit should be provided within the `value` prop.',\n\t\t\tversion: '6.2',\n\t\t} );\n\t}\n\n\t// The `value` prop, in theory, should not be `null`, but the following line\n\t// ensures it fallback to `undefined` in case a consumer of `UnitControl`\n\t// still passes `null` as a `value`.\n\tconst nonNullValueProp = valueProp ?? undefined;\n\tconst [ units, reFirstCharacterOfUnits ] = useMemo( () => {\n\t\tconst list = getUnitsWithCurrentUnit(\n\t\t\tnonNullValueProp,\n\t\t\tunitProp,\n\t\t\tunitsProp\n\t\t);\n\t\tconst [ { value: firstUnitValue = '' } = {}, ...rest ] = list;\n\t\tconst firstCharacters = rest.reduce(\n\t\t\t( carry, { value } ) => {\n\t\t\t\tconst first = escapeRegExp( value?.substring( 0, 1 ) || '' );\n\t\t\t\treturn carry.includes( first )\n\t\t\t\t\t? carry\n\t\t\t\t\t: `${ carry }|${ first }`;\n\t\t\t},\n\t\t\tescapeRegExp( firstUnitValue.substring( 0, 1 ) )\n\t\t);\n\t\treturn [ list, new RegExp( `^(?:${ firstCharacters })$`, 'i' ) ];\n\t}, [ nonNullValueProp, unitProp, unitsProp ] );\n\tconst [ parsedQuantity, parsedUnit ] = getParsedQuantityAndUnit(\n\t\tnonNullValueProp,\n\t\tunitProp,\n\t\tunits\n\t);\n\n\tconst [ unit, setUnit ] = useControlledState< string | undefined >(\n\t\tunits.length === 1 ? units[ 0 ].value : unitProp,\n\t\t{\n\t\t\tinitial: parsedUnit,\n\t\t\tfallback: '',\n\t\t}\n\t);\n\n\tuseEffect( () => {\n\t\tif ( parsedUnit !== undefined ) {\n\t\t\tsetUnit( parsedUnit );\n\t\t}\n\t}, [ parsedUnit, setUnit ] );\n\n\tconst classes = classnames(\n\t\t'components-unit-control',\n\t\t// This class is added for legacy purposes to maintain it on the outer\n\t\t// wrapper. See: https://github.com/WordPress/gutenberg/pull/45139\n\t\t'components-unit-control-wrapper',\n\t\tclassName\n\t);\n\n\tconst handleOnQuantityChange = (\n\t\tnextQuantityValue: number | string | undefined,\n\t\tchangeProps: {\n\t\t\tevent: SyntheticEvent;\n\t\t}\n\t) => {\n\t\tif (\n\t\t\tnextQuantityValue === '' ||\n\t\t\ttypeof nextQuantityValue === 'undefined' ||\n\t\t\tnextQuantityValue === null\n\t\t) {\n\t\t\tonChangeProp?.( '', changeProps );\n\t\t\treturn;\n\t\t}\n\n\t\t/*\n\t\t * Customizing the onChange callback.\n\t\t * This allows as to broadcast a combined value+unit to onChange.\n\t\t */\n\t\tconst onChangeValue = getValidParsedQuantityAndUnit(\n\t\t\tnextQuantityValue,\n\t\t\tunits,\n\t\t\tparsedQuantity,\n\t\t\tunit\n\t\t).join( '' );\n\n\t\tonChangeProp?.( onChangeValue, changeProps );\n\t};\n\n\tconst handleOnUnitChange: UnitControlOnChangeCallback = (\n\t\tnextUnitValue,\n\t\tchangeProps\n\t) => {\n\t\tconst { data } = changeProps;\n\n\t\tlet nextValue = `${ parsedQuantity ?? '' }${ nextUnitValue }`;\n\n\t\tif ( isResetValueOnUnitChange && data?.default !== undefined ) {\n\t\t\tnextValue = `${ data.default }${ nextUnitValue }`;\n\t\t}\n\n\t\tonChangeProp?.( nextValue, changeProps );\n\t\tonUnitChange?.( nextUnitValue, changeProps );\n\n\t\tsetUnit( nextUnitValue );\n\t};\n\n\tlet handleOnKeyDown;\n\tif ( ! disableUnits && isUnitSelectTabbable && units.length ) {\n\t\thandleOnKeyDown = ( event: KeyboardEvent< HTMLInputElement > ) => {\n\t\t\tprops.onKeyDown?.( event );\n\t\t\t// Unless the meta key was pressed (to avoid interfering with\n\t\t\t// shortcuts, e.g. pastes), moves focus to the unit select if a key\n\t\t\t// matches the first character of a unit.\n\t\t\tif ( ! event.metaKey && reFirstCharacterOfUnits.test( event.key ) )\n\t\t\t\trefInputSuffix.current?.focus();\n\t\t};\n\t}\n\n\tconst refInputSuffix = useRef< HTMLSelectElement >( null );\n\tconst inputSuffix = ! disableUnits ? (\n\t\t<UnitSelectControl\n\t\t\tref={ refInputSuffix }\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={\n\t\t\t\t[ 'small', 'compact' ].includes( size ) ||\n\t\t\t\t( size === 'default' && ! props.__next40pxDefaultSize )\n\t\t\t\t\t? 'small'\n\t\t\t\t\t: 'default'\n\t\t\t}\n\t\t\tunit={ unit }\n\t\t\tunits={ units }\n\t\t\tonFocus={ onFocusProp }\n\t\t\tonBlur={ unitControlProps.onBlur }\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<ValueInput\n\t\t\t{ ...props }\n\t\t\tautoComplete={ autoComplete }\n\t\t\tclassName={ classes }\n\t\t\tdisabled={ disabled }\n\t\t\tspinControls=\"none\"\n\t\t\tisPressEnterToChange={ isPressEnterToChange }\n\t\t\tlabel={ label }\n\t\t\tonKeyDown={ handleOnKeyDown }\n\t\t\tonChange={ handleOnQuantityChange }\n\t\t\tref={ forwardedRef }\n\t\t\tsize={ size }\n\t\t\tsuffix={ inputSuffix }\n\t\t\ttype={ isPressEnterToChange ? 'text' : 'number' }\n\t\t\tvalue={ parsedQuantity ?? '' }\n\t\t\tstep={ step }\n\t\t\tonFocus={ onFocusProp }\n\t\t\t__unstableStateReducer={ __unstableStateReducer }\n\t\t/>\n\t);\n}\n\n/**\n * `UnitControl` allows the user to set a numeric quantity as well as a unit (e.g. `px`).\n *\n *\n * ```jsx\n * import { __experimentalUnitControl as UnitControl } from '@wordpress/components';\n * import { useState } from '@wordpress/element';\n *\n * const Example = () => {\n * const [ value, setValue ] = useState( '10px' );\n *\n * return <UnitControl onChange={ setValue } value={ value } />;\n * };\n * ```\n */\nexport const UnitControl = forwardRef( UnforwardedUnitControl );\n\nexport { parseQuantityAndUnitFromRawValue, useCustomUnits } from './utils';\nexport default UnitControl;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAIA,IAAAA,WAAA,GAAAC,sBAAA,CAAAC,OAAA;AAKA,IAAAC,WAAA,GAAAF,sBAAA,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AAP,MAAA,CAAAC,aAAA,EAACxF,kBAAA,CAAAkG,UAAU;IAAA,GACLlE,KAAK;IACVtB,YAAY,EAAGA,YAAc;IAC7BE,SAAS,EAAGmD,OAAS;IACrBlD,QAAQ,EAAGA,QAAU;IACrBsF,YAAY,EAAC,MAAM;IACnBpF,oBAAoB,EAAGA,oBAAsB;IAC7CG,KAAK,EAAGA,KAAO;IACf4D,SAAS,EAAGF,eAAiB;IAC7BzD,QAAQ,EAAG8C,sBAAwB;IACnCwB,GAAG,EAAGjF,YAAc;IACpBc,IAAI,EAAGA,IAAM;IACb8E,MAAM,EAAGd,WAAa;IACtBe,IAAI,EAAGtF,oBAAoB,GAAG,MAAM,GAAG,QAAU;IACjDa,KAAK,EAAG0B,cAAc,aAAdA,cAAc,cAAdA,cAAc,GAAI,EAAI;IAC9BuC,IAAI,EAAGA,IAAM;IACb/D,OAAO,EAAGC,WAAa;IACvBtB,sBAAsB,EAAGA;EAAwB,CACjD,CAAC;AAEJ;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,MAAM6F,WAAW,GAAG,IAAAC,mBAAU,EAAEjG,sBAAuB,CAAC;AAACkG,OAAA,CAAAF,WAAA,GAAAA,WAAA;AAAA,IAAAG,QAAA,GAGjDH,WAAW;AAAAE,OAAA,CAAA7B,OAAA,GAAA8B,QAAA"}
@@ -5,8 +5,10 @@ Object.defineProperty(exports, "__esModule", {
5
5
  value: true
6
6
  });
7
7
  exports.escapeRegExp = escapeRegExp;
8
+ exports.kebabCase = kebabCase;
8
9
  exports.normalizeTextString = void 0;
9
10
  var _removeAccents = _interopRequireDefault(require("remove-accents"));
11
+ var _changeCase = require("change-case");
10
12
  /**
11
13
  * External dependencies
12
14
  */
@@ -73,13 +75,42 @@ const normalizeTextString = value => {
73
75
  };
74
76
 
75
77
  /**
76
- * Escapes the RegExp special characters.
78
+ * Converts any string to kebab case.
79
+ * Backwards compatible with Lodash's `_.kebabCase()`.
80
+ * Backwards compatible with `_wp_to_kebab_case()`.
77
81
  *
78
- * @param {string} string Input string.
82
+ * @see https://lodash.com/docs/4.17.15#kebabCase
83
+ * @see https://developer.wordpress.org/reference/functions/_wp_to_kebab_case/
79
84
  *
80
- * @return {string} Regex-escaped string.
85
+ * @param str String to convert.
86
+ * @return Kebab-cased string
81
87
  */
82
88
  exports.normalizeTextString = normalizeTextString;
89
+ function kebabCase(str) {
90
+ var _str$toString;
91
+ let input = (_str$toString = str?.toString?.()) !== null && _str$toString !== void 0 ? _str$toString : '';
92
+
93
+ // See https://github.com/lodash/lodash/blob/b185fcee26b2133bd071f4aaca14b455c2ed1008/lodash.js#L4970
94
+ input = input.replace(/['\u2019]/, '');
95
+ return (0, _changeCase.paramCase)(input, {
96
+ splitRegexp: [/(?!(?:1ST|2ND|3RD|[4-9]TH)(?![a-z]))([a-z0-9])([A-Z])/g,
97
+ // fooBar => foo-bar, 3Bar => 3-bar
98
+ /(?!(?:1st|2nd|3rd|[4-9]th)(?![a-z]))([0-9])([a-z])/g,
99
+ // 3bar => 3-bar
100
+ /([A-Za-z])([0-9])/g,
101
+ // Foo3 => foo-3, foo3 => foo-3
102
+ /([A-Z])([A-Z][a-z])/g // FOOBar => foo-bar
103
+ ]
104
+ });
105
+ }
106
+
107
+ /**
108
+ * Escapes the RegExp special characters.
109
+ *
110
+ * @param string Input string.
111
+ *
112
+ * @return Regex-escaped string.
113
+ */
83
114
  function escapeRegExp(string) {
84
115
  return string.replace(/[\\^$.*+?()[\]{}|]/g, '\\$&');
85
116
  }