@wordpress/components 19.2.3 → 19.4.1-next.f435e9e01b.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 (1000) hide show
  1. package/CHANGELOG.md +74 -5
  2. package/CONTRIBUTING.md +1 -1
  3. package/LICENSE.md +1 -1
  4. package/README.md +8 -4
  5. package/build/angle-picker-control/index.js +2 -0
  6. package/build/angle-picker-control/index.js.map +1 -1
  7. package/build/base-control/index.js +2 -3
  8. package/build/base-control/index.js.map +1 -1
  9. package/build/base-control/styles/base-control-styles.js +23 -13
  10. package/build/base-control/styles/base-control-styles.js.map +1 -1
  11. package/build/base-field/hook.js +1 -1
  12. package/build/base-field/hook.js.map +1 -1
  13. package/build/box-control/styles/box-control-styles.js +9 -9
  14. package/build/box-control/styles/box-control-styles.js.map +1 -1
  15. package/build/button/deprecated.js +2 -1
  16. package/build/button/deprecated.js.map +1 -1
  17. package/build/button/index.js +2 -1
  18. package/build/button/index.js.map +1 -1
  19. package/build/button/index.native.js +13 -3
  20. package/build/button/index.native.js.map +1 -1
  21. package/build/card/card/component.js +1 -1
  22. package/build/card/card/component.js.map +1 -1
  23. package/build/card/card/hook.js +1 -1
  24. package/build/card/card/hook.js.map +1 -1
  25. package/build/card/card-body/hook.js +1 -1
  26. package/build/card/card-body/hook.js.map +1 -1
  27. package/build/card/card-divider/hook.js +1 -1
  28. package/build/card/card-divider/hook.js.map +1 -1
  29. package/build/card/card-footer/hook.js +1 -1
  30. package/build/card/card-footer/hook.js.map +1 -1
  31. package/build/card/card-header/hook.js +1 -1
  32. package/build/card/card-header/hook.js.map +1 -1
  33. package/build/card/card-media/hook.js +1 -1
  34. package/build/card/card-media/hook.js.map +1 -1
  35. package/build/checkbox-control/index.js +1 -1
  36. package/build/checkbox-control/index.js.map +1 -1
  37. package/build/circular-option-picker/index.js +2 -0
  38. package/build/circular-option-picker/index.js.map +1 -1
  39. package/build/clipboard-button/index.js +1 -2
  40. package/build/clipboard-button/index.js.map +1 -1
  41. package/build/color-indicator/index.js +2 -0
  42. package/build/color-indicator/index.js.map +1 -1
  43. package/build/color-palette/index.js +2 -0
  44. package/build/color-palette/index.js.map +1 -1
  45. package/build/color-palette/index.native.js +4 -2
  46. package/build/color-palette/index.native.js.map +1 -1
  47. package/build/color-picker/color-display.js +4 -2
  48. package/build/color-picker/color-display.js.map +1 -1
  49. package/build/color-picker/color-input.js.map +1 -1
  50. package/build/color-picker/component.js +2 -5
  51. package/build/color-picker/component.js.map +1 -1
  52. package/build/color-picker/hex-input.js +3 -1
  53. package/build/color-picker/hex-input.js.map +1 -1
  54. package/build/color-picker/input-with-slider.js +3 -1
  55. package/build/color-picker/input-with-slider.js.map +1 -1
  56. package/build/color-picker/use-deprecated-props.js +2 -0
  57. package/build/color-picker/use-deprecated-props.js.map +1 -1
  58. package/build/confirm-dialog/component.js +107 -0
  59. package/build/confirm-dialog/component.js.map +1 -0
  60. package/build/confirm-dialog/index.js +16 -0
  61. package/build/confirm-dialog/index.js.map +1 -0
  62. package/build/confirm-dialog/styles.js +30 -0
  63. package/build/confirm-dialog/styles.js.map +1 -0
  64. package/build/confirm-dialog/types.js +6 -0
  65. package/build/confirm-dialog/types.js.map +1 -0
  66. package/build/custom-gradient-picker/index.js +1 -0
  67. package/build/custom-gradient-picker/index.js.map +1 -1
  68. package/build/date-time/date.js +63 -86
  69. package/build/date-time/date.js.map +1 -1
  70. package/build/date-time/time.js +1 -1
  71. package/build/date-time/time.js.map +1 -1
  72. package/build/date-time/utils.js +32 -0
  73. package/build/date-time/utils.js.map +1 -0
  74. package/build/divider/component.js +8 -7
  75. package/build/divider/component.js.map +1 -1
  76. package/build/divider/styles.js +38 -13
  77. package/build/divider/styles.js.map +1 -1
  78. package/build/drop-zone/index.js +14 -6
  79. package/build/drop-zone/index.js.map +1 -1
  80. package/build/drop-zone/provider.js +1 -0
  81. package/build/drop-zone/provider.js.map +1 -1
  82. package/build/dropdown/index.js +3 -3
  83. package/build/dropdown/index.js.map +1 -1
  84. package/build/elevation/hook.js +5 -5
  85. package/build/elevation/hook.js.map +1 -1
  86. package/build/external-link/styles/external-link-styles.js +5 -5
  87. package/build/external-link/styles/external-link-styles.js.map +1 -1
  88. package/build/flex/flex/hook.js +4 -4
  89. package/build/flex/flex/hook.js.map +1 -1
  90. package/build/flyout/styles.js +2 -2
  91. package/build/flyout/styles.js.map +1 -1
  92. package/build/focusable-iframe/index.js +1 -0
  93. package/build/focusable-iframe/index.js.map +1 -1
  94. package/build/form-token-field/suggestions-list.js +75 -81
  95. package/build/form-token-field/suggestions-list.js.map +1 -1
  96. package/build/grid/hook.js +2 -2
  97. package/build/grid/hook.js.map +1 -1
  98. package/build/heading/component.js +0 -1
  99. package/build/heading/component.js.map +1 -1
  100. package/build/higher-order/with-focus-outside/index.js +2 -0
  101. package/build/higher-order/with-focus-outside/index.js.map +1 -1
  102. package/build/icon/index.js +0 -1
  103. package/build/icon/index.js.map +1 -1
  104. package/build/index.js +8 -0
  105. package/build/index.js.map +1 -1
  106. package/build/input-control/index.js.map +1 -1
  107. package/build/input-control/input-base.js +0 -1
  108. package/build/input-control/input-base.js.map +1 -1
  109. package/build/input-control/input-field.js.map +1 -1
  110. package/build/input-control/reducer/actions.js +0 -1
  111. package/build/input-control/reducer/actions.js.map +1 -1
  112. package/build/input-control/reducer/reducer.js.map +1 -1
  113. package/build/input-control/reducer/state.js +0 -1
  114. package/build/input-control/reducer/state.js.map +1 -1
  115. package/build/input-control/styles/input-control-styles.js +51 -37
  116. package/build/input-control/styles/input-control-styles.js.map +1 -1
  117. package/build/item-group/item/component.js +0 -1
  118. package/build/item-group/item/component.js.map +1 -1
  119. package/build/item-group/item/hook.js +1 -2
  120. package/build/item-group/item/hook.js.map +1 -1
  121. package/build/item-group/item-group/component.js +0 -1
  122. package/build/item-group/item-group/component.js.map +1 -1
  123. package/build/mobile/bottom-sheet/bottom-sheet-context.native.js +3 -1
  124. package/build/mobile/bottom-sheet/bottom-sheet-context.native.js.map +1 -1
  125. package/build/mobile/bottom-sheet/bottom-sheet-navigation/navigation-container.native.js +4 -12
  126. package/build/mobile/bottom-sheet/bottom-sheet-navigation/navigation-container.native.js.map +1 -1
  127. package/build/mobile/bottom-sheet/bottom-sheet-navigation/navigation-screen.native.js +23 -5
  128. package/build/mobile/bottom-sheet/bottom-sheet-navigation/navigation-screen.native.js.map +1 -1
  129. package/build/mobile/bottom-sheet/cell.native.js +3 -5
  130. package/build/mobile/bottom-sheet/cell.native.js.map +1 -1
  131. package/build/mobile/bottom-sheet/index.native.js +16 -16
  132. package/build/mobile/bottom-sheet/index.native.js.map +1 -1
  133. package/build/mobile/bottom-sheet/link-suggestion-item-cell.native.js +10 -3
  134. package/build/mobile/bottom-sheet/link-suggestion-item-cell.native.js.map +1 -1
  135. package/build/mobile/bottom-sheet/range-text-input.native.js +2 -3
  136. package/build/mobile/bottom-sheet/range-text-input.native.js.map +1 -1
  137. package/build/mobile/color-settings/index.native.js +6 -2
  138. package/build/mobile/color-settings/index.native.js.map +1 -1
  139. package/build/mobile/color-settings/palette.screen.native.js +12 -6
  140. package/build/mobile/color-settings/palette.screen.native.js.map +1 -1
  141. package/build/mobile/color-settings/utils.native.js +9 -3
  142. package/build/mobile/color-settings/utils.native.js.map +1 -1
  143. package/build/mobile/global-styles-context/utils.native.js +1 -1
  144. package/build/mobile/global-styles-context/utils.native.js.map +1 -1
  145. package/build/mobile/gridicons/index.native.js +3 -1
  146. package/build/mobile/gridicons/index.native.js.map +1 -1
  147. package/build/mobile/keyboard-avoiding-view/index.ios.js +6 -8
  148. package/build/mobile/keyboard-avoiding-view/index.ios.js.map +1 -1
  149. package/build/mobile/link-picker/index.native.js +47 -4
  150. package/build/mobile/link-picker/index.native.js.map +1 -1
  151. package/build/mobile/link-picker/link-picker-screen.native.js +18 -5
  152. package/build/mobile/link-picker/link-picker-screen.native.js.map +1 -1
  153. package/build/mobile/link-settings/index.native.js +13 -1
  154. package/build/mobile/link-settings/index.native.js.map +1 -1
  155. package/build/mobile/readable-content-view/index.native.js +2 -2
  156. package/build/mobile/readable-content-view/index.native.js.map +1 -1
  157. package/build/mobile/utils/use-is-floating-keyboard.native.js +2 -2
  158. package/build/mobile/utils/use-is-floating-keyboard.native.js.map +1 -1
  159. package/build/mobile/utils/use-unit-converter-to-mobile.native.js +2 -2
  160. package/build/mobile/utils/use-unit-converter-to-mobile.native.js.map +1 -1
  161. package/build/modal/aria-helper.js +2 -0
  162. package/build/modal/aria-helper.js.map +1 -1
  163. package/build/modal/index.js +18 -20
  164. package/build/modal/index.js.map +1 -1
  165. package/build/navigator/context.js +5 -1
  166. package/build/navigator/context.js.map +1 -1
  167. package/build/navigator/navigator-provider/component.js +42 -22
  168. package/build/navigator/navigator-provider/component.js.map +1 -1
  169. package/build/navigator/navigator-screen/component.js +57 -29
  170. package/build/navigator/navigator-screen/component.js.map +1 -1
  171. package/build/navigator/use-navigator.js +8 -8
  172. package/build/navigator/use-navigator.js.map +1 -1
  173. package/build/notice/index.native.js +2 -2
  174. package/build/notice/index.native.js.map +1 -1
  175. package/build/palette-edit/index.js +8 -3
  176. package/build/palette-edit/index.js.map +1 -1
  177. package/build/palette-edit/styles.js +11 -13
  178. package/build/palette-edit/styles.js.map +1 -1
  179. package/build/placeholder/index.js +4 -4
  180. package/build/placeholder/index.js.map +1 -1
  181. package/build/range-control/styles/range-control-styles.js +29 -29
  182. package/build/range-control/styles/range-control-styles.js.map +1 -1
  183. package/build/resizable-box/index.js.map +1 -1
  184. package/build/resizable-box/resize-tooltip/index.js.map +1 -1
  185. package/build/resizable-box/resize-tooltip/label.js +0 -1
  186. package/build/resizable-box/resize-tooltip/label.js.map +1 -1
  187. package/build/sandbox/index.native.js +5 -5
  188. package/build/sandbox/index.native.js.map +1 -1
  189. package/build/scrollable/hook.js +1 -1
  190. package/build/scrollable/hook.js.map +1 -1
  191. package/build/select-control/styles/select-control-styles.js +33 -9
  192. package/build/select-control/styles/select-control-styles.js.map +1 -1
  193. package/build/slot-fill/bubbles-virtually/fill.js +11 -2
  194. package/build/slot-fill/bubbles-virtually/fill.js.map +1 -1
  195. package/build/spacer/component.js +0 -1
  196. package/build/spacer/component.js.map +1 -1
  197. package/build/spinner/index.js +44 -5
  198. package/build/spinner/index.js.map +1 -1
  199. package/build/spinner/index.native.js +4 -2
  200. package/build/spinner/index.native.js.map +1 -1
  201. package/build/spinner/styles.js +56 -0
  202. package/build/spinner/styles.js.map +1 -0
  203. package/build/style-provider/index.js +2 -0
  204. package/build/style-provider/index.js.map +1 -1
  205. package/build/surface/hook.js +1 -1
  206. package/build/surface/hook.js.map +1 -1
  207. package/build/text/get-line-height.js +0 -1
  208. package/build/text/get-line-height.js.map +1 -1
  209. package/build/text/hook.js +5 -5
  210. package/build/text/hook.js.map +1 -1
  211. package/build/tip/index.js +4 -8
  212. package/build/tip/index.js.map +1 -1
  213. package/build/toggle-group-control/toggle-group-control/component.js +9 -14
  214. package/build/toggle-group-control/toggle-group-control/component.js.map +1 -1
  215. package/build/toggle-group-control/toggle-group-control/styles.js +3 -14
  216. package/build/toggle-group-control/toggle-group-control/styles.js.map +1 -1
  217. package/build/toggle-group-control/toggle-group-control-option/component.js +0 -1
  218. package/build/toggle-group-control/toggle-group-control-option/component.js.map +1 -1
  219. package/build/toggle-group-control/toggle-group-control-option/styles.js +8 -8
  220. package/build/toggle-group-control/toggle-group-control-option/styles.js.map +1 -1
  221. package/build/tools-panel/styles.js +12 -10
  222. package/build/tools-panel/styles.js.map +1 -1
  223. package/build/tools-panel/tools-panel/component.js +6 -9
  224. package/build/tools-panel/tools-panel/component.js.map +1 -1
  225. package/build/tools-panel/tools-panel/hook.js +51 -44
  226. package/build/tools-panel/tools-panel/hook.js.map +1 -1
  227. package/build/tools-panel/tools-panel-header/component.js +0 -1
  228. package/build/tools-panel/tools-panel-header/component.js.map +1 -1
  229. package/build/tools-panel/tools-panel-header/hook.js +3 -3
  230. package/build/tools-panel/tools-panel-header/hook.js.map +1 -1
  231. package/build/tools-panel/tools-panel-item/component.js +0 -1
  232. package/build/tools-panel/tools-panel-item/component.js.map +1 -1
  233. package/build/tools-panel/tools-panel-item/hook.js +9 -3
  234. package/build/tools-panel/tools-panel-item/hook.js.map +1 -1
  235. package/build/tree-grid/index.js +13 -6
  236. package/build/tree-grid/index.js.map +1 -1
  237. package/build/truncate/hook.js +2 -2
  238. package/build/truncate/hook.js.map +1 -1
  239. package/build/ui/shortcut/component.js +0 -1
  240. package/build/ui/shortcut/component.js.map +1 -1
  241. package/build/ui/utils/font-size.js +0 -1
  242. package/build/ui/utils/font-size.js.map +1 -1
  243. package/build/ui/utils/get-valid-children.js +0 -1
  244. package/build/ui/utils/get-valid-children.js.map +1 -1
  245. package/build/unit-control/index.js +0 -1
  246. package/build/unit-control/index.js.map +1 -1
  247. package/build/unit-control/styles/unit-control-styles.js +23 -41
  248. package/build/unit-control/styles/unit-control-styles.js.map +1 -1
  249. package/build/unit-control/unit-select-control.js.map +1 -1
  250. package/build/utils/colors-values.js +6 -3
  251. package/build/utils/colors-values.js.map +1 -1
  252. package/build/utils/config-values.js +1 -4
  253. package/build/utils/config-values.js.map +1 -1
  254. package/build/utils/hooks/use-combined-ref.js.map +1 -1
  255. package/build/utils/hooks/use-latest-ref.js +0 -1
  256. package/build/utils/hooks/use-latest-ref.js.map +1 -1
  257. package/build/z-stack/component.js +0 -1
  258. package/build/z-stack/component.js.map +1 -1
  259. package/build/z-stack/styles.js +10 -8
  260. package/build/z-stack/styles.js.map +1 -1
  261. package/build-module/angle-picker-control/index.js +2 -0
  262. package/build-module/angle-picker-control/index.js.map +1 -1
  263. package/build-module/base-control/index.js +3 -4
  264. package/build-module/base-control/index.js.map +1 -1
  265. package/build-module/base-control/styles/base-control-styles.js +20 -12
  266. package/build-module/base-control/styles/base-control-styles.js.map +1 -1
  267. package/build-module/base-field/hook.js +1 -1
  268. package/build-module/base-field/hook.js.map +1 -1
  269. package/build-module/box-control/styles/box-control-styles.js +9 -9
  270. package/build-module/box-control/styles/box-control-styles.js.map +1 -1
  271. package/build-module/button/deprecated.js +2 -1
  272. package/build-module/button/deprecated.js.map +1 -1
  273. package/build-module/button/index.js +2 -1
  274. package/build-module/button/index.js.map +1 -1
  275. package/build-module/button/index.native.js +13 -3
  276. package/build-module/button/index.native.js.map +1 -1
  277. package/build-module/card/card/component.js +1 -1
  278. package/build-module/card/card/component.js.map +1 -1
  279. package/build-module/card/card/hook.js +1 -1
  280. package/build-module/card/card/hook.js.map +1 -1
  281. package/build-module/card/card-body/hook.js +1 -1
  282. package/build-module/card/card-body/hook.js.map +1 -1
  283. package/build-module/card/card-divider/hook.js +1 -1
  284. package/build-module/card/card-divider/hook.js.map +1 -1
  285. package/build-module/card/card-footer/hook.js +1 -1
  286. package/build-module/card/card-footer/hook.js.map +1 -1
  287. package/build-module/card/card-header/hook.js +1 -1
  288. package/build-module/card/card-header/hook.js.map +1 -1
  289. package/build-module/card/card-media/hook.js +1 -1
  290. package/build-module/card/card-media/hook.js.map +1 -1
  291. package/build-module/checkbox-control/index.js +1 -1
  292. package/build-module/checkbox-control/index.js.map +1 -1
  293. package/build-module/circular-option-picker/index.js +1 -0
  294. package/build-module/circular-option-picker/index.js.map +1 -1
  295. package/build-module/clipboard-button/index.js +1 -2
  296. package/build-module/clipboard-button/index.js.map +1 -1
  297. package/build-module/color-indicator/index.js +1 -0
  298. package/build-module/color-indicator/index.js.map +1 -1
  299. package/build-module/color-palette/index.js +1 -0
  300. package/build-module/color-palette/index.js.map +1 -1
  301. package/build-module/color-palette/index.native.js +4 -2
  302. package/build-module/color-palette/index.native.js.map +1 -1
  303. package/build-module/color-picker/color-display.js +3 -2
  304. package/build-module/color-picker/color-display.js.map +1 -1
  305. package/build-module/color-picker/color-input.js.map +1 -1
  306. package/build-module/color-picker/component.js +2 -4
  307. package/build-module/color-picker/component.js.map +1 -1
  308. package/build-module/color-picker/hex-input.js +2 -1
  309. package/build-module/color-picker/hex-input.js.map +1 -1
  310. package/build-module/color-picker/input-with-slider.js +2 -1
  311. package/build-module/color-picker/input-with-slider.js.map +1 -1
  312. package/build-module/color-picker/use-deprecated-props.js +3 -2
  313. package/build-module/color-picker/use-deprecated-props.js.map +1 -1
  314. package/build-module/confirm-dialog/component.js +87 -0
  315. package/build-module/confirm-dialog/component.js.map +1 -0
  316. package/build-module/confirm-dialog/index.js +6 -0
  317. package/build-module/confirm-dialog/index.js.map +1 -0
  318. package/build-module/confirm-dialog/styles.js +25 -0
  319. package/build-module/confirm-dialog/styles.js.map +1 -0
  320. package/build-module/confirm-dialog/types.js +2 -0
  321. package/build-module/confirm-dialog/types.js.map +1 -0
  322. package/build-module/custom-gradient-picker/index.js +1 -0
  323. package/build-module/custom-gradient-picker/index.js.map +1 -1
  324. package/build-module/date-time/date.js +63 -87
  325. package/build-module/date-time/date.js.map +1 -1
  326. package/build-module/date-time/time.js +1 -1
  327. package/build-module/date-time/time.js.map +1 -1
  328. package/build-module/date-time/utils.js +20 -0
  329. package/build-module/date-time/utils.js.map +1 -0
  330. package/build-module/divider/component.js +9 -8
  331. package/build-module/divider/component.js.map +1 -1
  332. package/build-module/divider/styles.js +37 -13
  333. package/build-module/divider/styles.js.map +1 -1
  334. package/build-module/drop-zone/index.js +14 -6
  335. package/build-module/drop-zone/index.js.map +1 -1
  336. package/build-module/drop-zone/provider.js +1 -0
  337. package/build-module/drop-zone/provider.js.map +1 -1
  338. package/build-module/dropdown/index.js +3 -3
  339. package/build-module/dropdown/index.js.map +1 -1
  340. package/build-module/elevation/hook.js +5 -5
  341. package/build-module/elevation/hook.js.map +1 -1
  342. package/build-module/external-link/styles/external-link-styles.js +5 -5
  343. package/build-module/external-link/styles/external-link-styles.js.map +1 -1
  344. package/build-module/flex/flex/hook.js +4 -4
  345. package/build-module/flex/flex/hook.js.map +1 -1
  346. package/build-module/flyout/styles.js +2 -2
  347. package/build-module/flyout/styles.js.map +1 -1
  348. package/build-module/focusable-iframe/index.js +1 -0
  349. package/build-module/focusable-iframe/index.js.map +1 -1
  350. package/build-module/form-token-field/suggestions-list.js +73 -79
  351. package/build-module/form-token-field/suggestions-list.js.map +1 -1
  352. package/build-module/grid/hook.js +2 -2
  353. package/build-module/grid/hook.js.map +1 -1
  354. package/build-module/heading/component.js +0 -1
  355. package/build-module/heading/component.js.map +1 -1
  356. package/build-module/higher-order/with-focus-outside/index.js +1 -0
  357. package/build-module/higher-order/with-focus-outside/index.js.map +1 -1
  358. package/build-module/icon/index.js +0 -1
  359. package/build-module/icon/index.js.map +1 -1
  360. package/build-module/index.js +1 -0
  361. package/build-module/index.js.map +1 -1
  362. package/build-module/input-control/index.js +1 -1
  363. package/build-module/input-control/index.js.map +1 -1
  364. package/build-module/input-control/input-base.js +0 -1
  365. package/build-module/input-control/input-base.js.map +1 -1
  366. package/build-module/input-control/input-field.js +1 -1
  367. package/build-module/input-control/input-field.js.map +1 -1
  368. package/build-module/input-control/reducer/actions.js +0 -1
  369. package/build-module/input-control/reducer/actions.js.map +1 -1
  370. package/build-module/input-control/reducer/reducer.js +1 -1
  371. package/build-module/input-control/reducer/reducer.js.map +1 -1
  372. package/build-module/input-control/reducer/state.js +0 -1
  373. package/build-module/input-control/reducer/state.js.map +1 -1
  374. package/build-module/input-control/styles/input-control-styles.js +51 -37
  375. package/build-module/input-control/styles/input-control-styles.js.map +1 -1
  376. package/build-module/item-group/item/component.js +0 -1
  377. package/build-module/item-group/item/component.js.map +1 -1
  378. package/build-module/item-group/item/hook.js +1 -2
  379. package/build-module/item-group/item/hook.js.map +1 -1
  380. package/build-module/item-group/item-group/component.js +0 -1
  381. package/build-module/item-group/item-group/component.js.map +1 -1
  382. package/build-module/mobile/bottom-sheet/bottom-sheet-context.native.js +3 -1
  383. package/build-module/mobile/bottom-sheet/bottom-sheet-context.native.js.map +1 -1
  384. package/build-module/mobile/bottom-sheet/bottom-sheet-navigation/navigation-container.native.js +5 -13
  385. package/build-module/mobile/bottom-sheet/bottom-sheet-navigation/navigation-container.native.js.map +1 -1
  386. package/build-module/mobile/bottom-sheet/bottom-sheet-navigation/navigation-screen.native.js +23 -5
  387. package/build-module/mobile/bottom-sheet/bottom-sheet-navigation/navigation-screen.native.js.map +1 -1
  388. package/build-module/mobile/bottom-sheet/cell.native.js +3 -3
  389. package/build-module/mobile/bottom-sheet/cell.native.js.map +1 -1
  390. package/build-module/mobile/bottom-sheet/index.native.js +16 -13
  391. package/build-module/mobile/bottom-sheet/index.native.js.map +1 -1
  392. package/build-module/mobile/bottom-sheet/link-suggestion-item-cell.native.js +10 -4
  393. package/build-module/mobile/bottom-sheet/link-suggestion-item-cell.native.js.map +1 -1
  394. package/build-module/mobile/bottom-sheet/range-text-input.native.js +2 -2
  395. package/build-module/mobile/bottom-sheet/range-text-input.native.js.map +1 -1
  396. package/build-module/mobile/color-settings/index.native.js +6 -2
  397. package/build-module/mobile/color-settings/index.native.js.map +1 -1
  398. package/build-module/mobile/color-settings/palette.screen.native.js +12 -6
  399. package/build-module/mobile/color-settings/palette.screen.native.js.map +1 -1
  400. package/build-module/mobile/color-settings/utils.native.js +7 -3
  401. package/build-module/mobile/color-settings/utils.native.js.map +1 -1
  402. package/build-module/mobile/global-styles-context/utils.native.js +1 -1
  403. package/build-module/mobile/global-styles-context/utils.native.js.map +1 -1
  404. package/build-module/mobile/gridicons/index.native.js +1 -0
  405. package/build-module/mobile/gridicons/index.native.js.map +1 -1
  406. package/build-module/mobile/keyboard-avoiding-view/index.ios.js +6 -6
  407. package/build-module/mobile/keyboard-avoiding-view/index.ios.js.map +1 -1
  408. package/build-module/mobile/link-picker/index.native.js +50 -7
  409. package/build-module/mobile/link-picker/index.native.js.map +1 -1
  410. package/build-module/mobile/link-picker/link-picker-screen.native.js +13 -5
  411. package/build-module/mobile/link-picker/link-picker-screen.native.js.map +1 -1
  412. package/build-module/mobile/link-settings/index.native.js +12 -1
  413. package/build-module/mobile/link-settings/index.native.js.map +1 -1
  414. package/build-module/mobile/readable-content-view/index.native.js +2 -2
  415. package/build-module/mobile/readable-content-view/index.native.js.map +1 -1
  416. package/build-module/mobile/utils/use-is-floating-keyboard.native.js +2 -2
  417. package/build-module/mobile/utils/use-is-floating-keyboard.native.js.map +1 -1
  418. package/build-module/mobile/utils/use-unit-converter-to-mobile.native.js +2 -2
  419. package/build-module/mobile/utils/use-unit-converter-to-mobile.native.js.map +1 -1
  420. package/build-module/modal/aria-helper.js +2 -0
  421. package/build-module/modal/aria-helper.js.map +1 -1
  422. package/build-module/modal/index.js +16 -19
  423. package/build-module/modal/index.js.map +1 -1
  424. package/build-module/navigator/context.js +5 -1
  425. package/build-module/navigator/context.js.map +1 -1
  426. package/build-module/navigator/navigator-provider/component.js +43 -24
  427. package/build-module/navigator/navigator-provider/component.js.map +1 -1
  428. package/build-module/navigator/navigator-screen/component.js +57 -32
  429. package/build-module/navigator/navigator-screen/component.js.map +1 -1
  430. package/build-module/navigator/use-navigator.js +8 -8
  431. package/build-module/navigator/use-navigator.js.map +1 -1
  432. package/build-module/notice/index.native.js +2 -2
  433. package/build-module/notice/index.native.js.map +1 -1
  434. package/build-module/palette-edit/index.js +8 -3
  435. package/build-module/palette-edit/index.js.map +1 -1
  436. package/build-module/palette-edit/styles.js +11 -12
  437. package/build-module/palette-edit/styles.js.map +1 -1
  438. package/build-module/placeholder/index.js +4 -4
  439. package/build-module/placeholder/index.js.map +1 -1
  440. package/build-module/range-control/styles/range-control-styles.js +29 -29
  441. package/build-module/range-control/styles/range-control-styles.js.map +1 -1
  442. package/build-module/resizable-box/index.js.map +1 -1
  443. package/build-module/resizable-box/resize-tooltip/index.js +3 -3
  444. package/build-module/resizable-box/resize-tooltip/index.js.map +1 -1
  445. package/build-module/resizable-box/resize-tooltip/label.js +0 -1
  446. package/build-module/resizable-box/resize-tooltip/label.js.map +1 -1
  447. package/build-module/sandbox/index.native.js +5 -5
  448. package/build-module/sandbox/index.native.js.map +1 -1
  449. package/build-module/scrollable/hook.js +1 -1
  450. package/build-module/scrollable/hook.js.map +1 -1
  451. package/build-module/select-control/styles/select-control-styles.js +33 -9
  452. package/build-module/select-control/styles/select-control-styles.js.map +1 -1
  453. package/build-module/slot-fill/bubbles-virtually/fill.js +11 -2
  454. package/build-module/slot-fill/bubbles-virtually/fill.js.map +1 -1
  455. package/build-module/spacer/component.js +0 -1
  456. package/build-module/spacer/component.js.map +1 -1
  457. package/build-module/spinner/index.js +40 -5
  458. package/build-module/spinner/index.js.map +1 -1
  459. package/build-module/spinner/index.native.js +4 -2
  460. package/build-module/spinner/index.native.js.map +1 -1
  461. package/build-module/spinner/styles.js +49 -0
  462. package/build-module/spinner/styles.js.map +1 -0
  463. package/build-module/style-provider/index.js +1 -0
  464. package/build-module/style-provider/index.js.map +1 -1
  465. package/build-module/surface/hook.js +1 -1
  466. package/build-module/surface/hook.js.map +1 -1
  467. package/build-module/text/get-line-height.js +0 -1
  468. package/build-module/text/get-line-height.js.map +1 -1
  469. package/build-module/text/hook.js +5 -5
  470. package/build-module/text/hook.js.map +1 -1
  471. package/build-module/tip/index.js +4 -8
  472. package/build-module/tip/index.js.map +1 -1
  473. package/build-module/toggle-group-control/toggle-group-control/component.js +10 -13
  474. package/build-module/toggle-group-control/toggle-group-control/component.js.map +1 -1
  475. package/build-module/toggle-group-control/toggle-group-control/styles.js +3 -11
  476. package/build-module/toggle-group-control/toggle-group-control/styles.js.map +1 -1
  477. package/build-module/toggle-group-control/toggle-group-control-option/component.js +0 -1
  478. package/build-module/toggle-group-control/toggle-group-control-option/component.js.map +1 -1
  479. package/build-module/toggle-group-control/toggle-group-control-option/styles.js +8 -8
  480. package/build-module/toggle-group-control/toggle-group-control-option/styles.js.map +1 -1
  481. package/build-module/tools-panel/styles.js +12 -11
  482. package/build-module/tools-panel/styles.js.map +1 -1
  483. package/build-module/tools-panel/tools-panel/component.js +5 -9
  484. package/build-module/tools-panel/tools-panel/component.js.map +1 -1
  485. package/build-module/tools-panel/tools-panel/hook.js +52 -45
  486. package/build-module/tools-panel/tools-panel/hook.js.map +1 -1
  487. package/build-module/tools-panel/tools-panel-header/component.js +0 -1
  488. package/build-module/tools-panel/tools-panel-header/component.js.map +1 -1
  489. package/build-module/tools-panel/tools-panel-header/hook.js +3 -3
  490. package/build-module/tools-panel/tools-panel-header/hook.js.map +1 -1
  491. package/build-module/tools-panel/tools-panel-item/component.js +0 -1
  492. package/build-module/tools-panel/tools-panel-item/component.js.map +1 -1
  493. package/build-module/tools-panel/tools-panel-item/hook.js +9 -3
  494. package/build-module/tools-panel/tools-panel-item/hook.js.map +1 -1
  495. package/build-module/tree-grid/index.js +12 -6
  496. package/build-module/tree-grid/index.js.map +1 -1
  497. package/build-module/truncate/hook.js +2 -2
  498. package/build-module/truncate/hook.js.map +1 -1
  499. package/build-module/ui/shortcut/component.js +0 -1
  500. package/build-module/ui/shortcut/component.js.map +1 -1
  501. package/build-module/ui/utils/font-size.js +0 -1
  502. package/build-module/ui/utils/font-size.js.map +1 -1
  503. package/build-module/ui/utils/get-valid-children.js +0 -1
  504. package/build-module/ui/utils/get-valid-children.js.map +1 -1
  505. package/build-module/unit-control/index.js +0 -1
  506. package/build-module/unit-control/index.js.map +1 -1
  507. package/build-module/unit-control/styles/unit-control-styles.js +23 -41
  508. package/build-module/unit-control/styles/unit-control-styles.js.map +1 -1
  509. package/build-module/unit-control/unit-select-control.js +1 -2
  510. package/build-module/unit-control/unit-select-control.js.map +1 -1
  511. package/build-module/utils/colors-values.js +6 -3
  512. package/build-module/utils/colors-values.js.map +1 -1
  513. package/build-module/utils/config-values.js +1 -4
  514. package/build-module/utils/config-values.js.map +1 -1
  515. package/build-module/utils/hooks/use-combined-ref.js +0 -1
  516. package/build-module/utils/hooks/use-combined-ref.js.map +1 -1
  517. package/build-module/utils/hooks/use-latest-ref.js +0 -1
  518. package/build-module/utils/hooks/use-latest-ref.js.map +1 -1
  519. package/build-module/z-stack/component.js +0 -1
  520. package/build-module/z-stack/component.js.map +1 -1
  521. package/build-module/z-stack/styles.js +13 -8
  522. package/build-module/z-stack/styles.js.map +1 -1
  523. package/build-style/style-rtl.css +36 -15
  524. package/build-style/style.css +36 -15
  525. package/build-types/base-control/index.d.ts.map +1 -1
  526. package/build-types/base-control/styles/base-control-styles.d.ts +4 -0
  527. package/build-types/base-control/styles/base-control-styles.d.ts.map +1 -1
  528. package/build-types/base-field/hook.d.ts +16 -16
  529. package/build-types/button/index.d.ts.map +1 -1
  530. package/build-types/card/card/hook.d.ts +16 -16
  531. package/build-types/card/card-body/hook.d.ts +16 -16
  532. package/build-types/card/card-divider/hook.d.ts +18 -18
  533. package/build-types/card/card-footer/hook.d.ts +17 -17
  534. package/build-types/card/card-header/hook.d.ts +16 -16
  535. package/build-types/card/card-media/hook.d.ts +16 -16
  536. package/build-types/card/types.d.ts.map +1 -1
  537. package/build-types/color-picker/color-display.d.ts +1 -0
  538. package/build-types/color-picker/color-display.d.ts.map +1 -1
  539. package/build-types/color-picker/color-input.d.ts +1 -0
  540. package/build-types/color-picker/color-input.d.ts.map +1 -1
  541. package/build-types/color-picker/hex-input.d.ts +1 -0
  542. package/build-types/color-picker/hex-input.d.ts.map +1 -1
  543. package/build-types/color-picker/hsl-input.d.ts +1 -0
  544. package/build-types/color-picker/hsl-input.d.ts.map +1 -1
  545. package/build-types/color-picker/input-with-slider.d.ts +1 -0
  546. package/build-types/color-picker/input-with-slider.d.ts.map +1 -1
  547. package/build-types/color-picker/legacy-adapter.d.ts +1 -0
  548. package/build-types/color-picker/legacy-adapter.d.ts.map +1 -1
  549. package/build-types/color-picker/picker.d.ts +1 -0
  550. package/build-types/color-picker/picker.d.ts.map +1 -1
  551. package/build-types/color-picker/rgb-input.d.ts +1 -0
  552. package/build-types/color-picker/rgb-input.d.ts.map +1 -1
  553. package/build-types/color-picker/styles.d.ts +1 -1
  554. package/build-types/confirm-dialog/component.d.ts +4 -4
  555. package/build-types/divider/component.d.ts +8 -7
  556. package/build-types/divider/component.d.ts.map +1 -1
  557. package/build-types/divider/styles.d.ts +2 -2
  558. package/build-types/divider/styles.d.ts.map +1 -1
  559. package/build-types/divider/types.d.ts +5 -5
  560. package/build-types/divider/types.d.ts.map +1 -1
  561. package/build-types/dropdown/index.d.ts +1 -13
  562. package/build-types/dropdown/index.d.ts.map +1 -1
  563. package/build-types/elevation/hook.d.ts +15 -15
  564. package/build-types/elevation/hook.d.ts.map +1 -1
  565. package/build-types/elevation/types.d.ts.map +1 -1
  566. package/build-types/flex/flex/hook.d.ts +16 -16
  567. package/build-types/flex/flex/hook.d.ts.map +1 -1
  568. package/build-types/flex/flex-block/hook.d.ts +16 -16
  569. package/build-types/flex/flex-item/hook.d.ts +16 -16
  570. package/build-types/flex/types.d.ts.map +1 -1
  571. package/build-types/flyout/flyout/hook.d.ts +17 -17
  572. package/build-types/flyout/styles.d.ts +7 -9
  573. package/build-types/flyout/styles.d.ts.map +1 -1
  574. package/build-types/flyout/types.d.ts.map +1 -1
  575. package/build-types/grid/hook.d.ts +16 -16
  576. package/build-types/grid/hook.d.ts.map +1 -1
  577. package/build-types/grid/types.d.ts.map +1 -1
  578. package/build-types/h-stack/hook.d.ts +17 -17
  579. package/build-types/h-stack/hook.d.ts.map +1 -1
  580. package/build-types/h-stack/types.d.ts.map +1 -1
  581. package/build-types/heading/component.d.ts.map +1 -1
  582. package/build-types/heading/hook.d.ts +16 -16
  583. package/build-types/icon/index.d.ts.map +1 -1
  584. package/build-types/input-control/index.d.ts +1 -1
  585. package/build-types/input-control/index.d.ts.map +1 -1
  586. package/build-types/input-control/input-base.d.ts.map +1 -1
  587. package/build-types/input-control/input-field.d.ts +1 -1
  588. package/build-types/input-control/input-field.d.ts.map +1 -1
  589. package/build-types/input-control/reducer/actions.d.ts.map +1 -1
  590. package/build-types/input-control/reducer/reducer.d.ts.map +1 -1
  591. package/build-types/input-control/reducer/state.d.ts.map +1 -1
  592. package/build-types/input-control/styles/input-control-styles.d.ts +1 -2
  593. package/build-types/input-control/styles/input-control-styles.d.ts.map +1 -1
  594. package/build-types/input-control/types.d.ts +2 -1
  595. package/build-types/input-control/types.d.ts.map +1 -1
  596. package/build-types/item-group/item/component.d.ts.map +1 -1
  597. package/build-types/item-group/item/hook.d.ts +16 -16
  598. package/build-types/item-group/item/hook.d.ts.map +1 -1
  599. package/build-types/item-group/item-group/component.d.ts.map +1 -1
  600. package/build-types/item-group/item-group/hook.d.ts +16 -16
  601. package/build-types/navigator/context.d.ts.map +1 -1
  602. package/build-types/navigator/navigator-provider/component.d.ts +16 -17
  603. package/build-types/navigator/navigator-provider/component.d.ts.map +1 -1
  604. package/build-types/navigator/navigator-screen/component.d.ts +16 -16
  605. package/build-types/navigator/navigator-screen/component.d.ts.map +1 -1
  606. package/build-types/navigator/types.d.ts +10 -9
  607. package/build-types/navigator/types.d.ts.map +1 -1
  608. package/build-types/number-control/styles/number-control-styles.d.ts +1 -1
  609. package/build-types/resizable-box/index.d.ts +1 -1
  610. package/build-types/resizable-box/index.d.ts.map +1 -1
  611. package/build-types/resizable-box/resize-tooltip/index.d.ts +1 -1
  612. package/build-types/resizable-box/resize-tooltip/index.d.ts.map +1 -1
  613. package/build-types/resizable-box/resize-tooltip/label.d.ts.map +1 -1
  614. package/build-types/scrollable/hook.d.ts +16 -16
  615. package/build-types/select-control/styles/select-control-styles.d.ts.map +1 -1
  616. package/build-types/select-control/types.d.ts +1 -1
  617. package/build-types/select-control/types.d.ts.map +1 -1
  618. package/build-types/slot-fill/bubbles-virtually/fill.d.ts.map +1 -1
  619. package/build-types/spacer/component.d.ts.map +1 -1
  620. package/build-types/spacer/hook.d.ts +16 -16
  621. package/build-types/spacer/types.d.ts.map +1 -1
  622. package/build-types/spinner/index.d.ts +18 -1
  623. package/build-types/spinner/index.d.ts.map +1 -1
  624. package/build-types/surface/hook.d.ts +16 -16
  625. package/build-types/surface/hook.d.ts.map +1 -1
  626. package/build-types/text/get-line-height.d.ts.map +1 -1
  627. package/build-types/text/hook.d.ts +16 -16
  628. package/build-types/text/hook.d.ts.map +1 -1
  629. package/build-types/text/types.d.ts.map +1 -1
  630. package/build-types/tip/index.d.ts.map +1 -1
  631. package/build-types/toggle-group-control/toggle-group-control/component.d.ts.map +1 -1
  632. package/build-types/toggle-group-control/toggle-group-control/styles.d.ts +0 -5
  633. package/build-types/toggle-group-control/toggle-group-control/styles.d.ts.map +1 -1
  634. package/build-types/toggle-group-control/toggle-group-control-option/component.d.ts.map +1 -1
  635. package/build-types/toggle-group-control/toggle-group-control-option/styles.d.ts.map +1 -1
  636. package/build-types/toggle-group-control/types.d.ts +1 -7
  637. package/build-types/toggle-group-control/types.d.ts.map +1 -1
  638. package/build-types/tools-panel/styles.d.ts.map +1 -1
  639. package/build-types/tools-panel/tools-panel/component.d.ts.map +1 -1
  640. package/build-types/tools-panel/tools-panel/hook.d.ts +24 -20
  641. package/build-types/tools-panel/tools-panel/hook.d.ts.map +1 -1
  642. package/build-types/tools-panel/tools-panel-header/component.d.ts.map +1 -1
  643. package/build-types/tools-panel/tools-panel-header/hook.d.ts +16 -16
  644. package/build-types/tools-panel/tools-panel-item/component.d.ts.map +1 -1
  645. package/build-types/tools-panel/tools-panel-item/hook.d.ts +16 -16
  646. package/build-types/tools-panel/tools-panel-item/hook.d.ts.map +1 -1
  647. package/build-types/tools-panel/types.d.ts +14 -0
  648. package/build-types/tools-panel/types.d.ts.map +1 -1
  649. package/build-types/truncate/hook.d.ts +16 -16
  650. package/build-types/ui/context/wordpress-component.d.ts.map +1 -1
  651. package/build-types/ui/control-group/hook.d.ts +18 -18
  652. package/build-types/ui/control-group/types.d.ts.map +1 -1
  653. package/build-types/ui/control-label/hook.d.ts +16 -16
  654. package/build-types/ui/form-group/form-group.d.ts +4 -4
  655. package/build-types/ui/form-group/types.d.ts.map +1 -1
  656. package/build-types/ui/form-group/use-form-group.d.ts +55 -55
  657. package/build-types/ui/shortcut/component.d.ts.map +1 -1
  658. package/build-types/ui/tooltip/types.d.ts.map +1 -1
  659. package/build-types/ui/utils/font-size.d.ts.map +1 -1
  660. package/build-types/ui/utils/get-valid-children.d.ts.map +1 -1
  661. package/build-types/unit-control/index.d.ts +3 -2
  662. package/build-types/unit-control/index.d.ts.map +1 -1
  663. package/build-types/unit-control/styles/unit-control-styles.d.ts +1 -0
  664. package/build-types/unit-control/styles/unit-control-styles.d.ts.map +1 -1
  665. package/build-types/unit-control/types.d.ts +4 -3
  666. package/build-types/unit-control/types.d.ts.map +1 -1
  667. package/build-types/unit-control/unit-select-control.d.ts.map +1 -1
  668. package/build-types/utils/colors-values.d.ts +1 -0
  669. package/build-types/utils/colors-values.d.ts.map +1 -1
  670. package/build-types/utils/config-values.d.ts +1 -5
  671. package/build-types/utils/config-values.d.ts.map +1 -1
  672. package/build-types/utils/hooks/use-combined-ref.d.ts.map +1 -1
  673. package/build-types/utils/hooks/use-latest-ref.d.ts.map +1 -1
  674. package/build-types/v-stack/hook.d.ts +16 -16
  675. package/build-types/v-stack/types.d.ts.map +1 -1
  676. package/build-types/z-stack/component.d.ts +1 -1
  677. package/build-types/z-stack/component.d.ts.map +1 -1
  678. package/build-types/z-stack/styles.d.ts.map +1 -1
  679. package/package.json +23 -22
  680. package/src/alignment-matrix-control/stories/index.js +1 -1
  681. package/src/angle-picker-control/index.js +2 -0
  682. package/src/base-control/index.js +11 -2
  683. package/src/base-control/stories/index.js +1 -1
  684. package/src/base-control/styles/base-control-styles.js +10 -1
  685. package/src/base-field/hook.js +1 -1
  686. package/src/box-control/styles/box-control-styles.js +1 -1
  687. package/src/button/deprecated.js +1 -0
  688. package/src/button/index.js +1 -0
  689. package/src/button/index.native.js +15 -1
  690. package/src/button/stories/index.js +1 -1
  691. package/src/button/style.scss +14 -0
  692. package/src/card/card/README.md +3 -3
  693. package/src/card/card/component.js +1 -1
  694. package/src/card/card/hook.js +1 -1
  695. package/src/card/card-body/hook.js +1 -1
  696. package/src/card/card-divider/hook.js +1 -1
  697. package/src/card/card-footer/hook.js +1 -1
  698. package/src/card/card-header/hook.js +1 -1
  699. package/src/card/card-media/hook.js +1 -1
  700. package/src/card/stories/index.js +1 -1
  701. package/src/card/test/__snapshots__/index.js.snap +6 -6
  702. package/src/card/types.ts +0 -1
  703. package/src/checkbox-control/index.js +1 -1
  704. package/src/checkbox-control/stories/index.js +1 -1
  705. package/src/circular-option-picker/index.js +1 -0
  706. package/src/clipboard-button/index.js +1 -2
  707. package/src/color-indicator/README.md +28 -0
  708. package/src/color-indicator/index.js +2 -0
  709. package/src/color-indicator/stories/index.js +1 -1
  710. package/src/color-indicator/style.scss +5 -8
  711. package/src/color-palette/index.js +1 -0
  712. package/src/color-palette/index.native.js +2 -0
  713. package/src/color-palette/stories/index.js +1 -1
  714. package/src/color-palette/test/__snapshots__/index.js.snap +1 -1
  715. package/src/color-picker/README.md +1 -1
  716. package/src/color-picker/color-display.tsx +4 -3
  717. package/src/color-picker/color-input.tsx +1 -1
  718. package/src/color-picker/component.tsx +3 -4
  719. package/src/color-picker/hex-input.tsx +2 -1
  720. package/src/color-picker/input-with-slider.tsx +2 -1
  721. package/src/color-picker/stories/index.js +1 -1
  722. package/src/color-picker/use-deprecated-props.ts +2 -1
  723. package/src/combobox-control/README.md +2 -2
  724. package/src/combobox-control/stories/index.js +6 -2
  725. package/src/combobox-control/style.scss +2 -2
  726. package/src/confirm-dialog/README.md +128 -0
  727. package/src/confirm-dialog/component.tsx +117 -0
  728. package/src/confirm-dialog/index.tsx +6 -0
  729. package/src/confirm-dialog/stories/index.js +123 -0
  730. package/src/confirm-dialog/styles.ts +18 -0
  731. package/src/confirm-dialog/test/index.js +302 -0
  732. package/src/confirm-dialog/types.ts +25 -0
  733. package/src/custom-gradient-picker/index.js +1 -0
  734. package/src/custom-gradient-picker/style.scss +0 -5
  735. package/src/custom-select-control/stories/index.js +27 -0
  736. package/src/date-time/README.md +9 -2
  737. package/src/date-time/date.js +67 -84
  738. package/src/date-time/stories/index.js +1 -1
  739. package/src/date-time/stories/time.js +1 -1
  740. package/src/date-time/test/date.js +3 -29
  741. package/src/date-time/test/time.js +2 -2
  742. package/src/date-time/test/utils.js +32 -0
  743. package/src/date-time/time.js +2 -2
  744. package/src/date-time/utils.js +18 -0
  745. package/src/dimension-control/README.md +3 -1
  746. package/src/divider/README.md +33 -5
  747. package/src/divider/component.tsx +8 -8
  748. package/src/divider/stories/index.js +43 -17
  749. package/src/divider/styles.ts +53 -16
  750. package/src/divider/test/__snapshots__/index.js.snap +11 -11
  751. package/src/divider/test/index.js +4 -4
  752. package/src/divider/types.ts +5 -5
  753. package/src/drop-zone/index.js +14 -6
  754. package/src/drop-zone/provider.js +1 -0
  755. package/src/dropdown/index.js +14 -13
  756. package/src/dropdown-menu/stories/index.js +1 -1
  757. package/src/duotone-picker/README.md +1 -1
  758. package/src/elevation/hook.js +1 -0
  759. package/src/elevation/stories/index.js +1 -1
  760. package/src/elevation/types.ts +0 -1
  761. package/src/external-link/stories/index.js +1 -1
  762. package/src/external-link/styles/external-link-styles.js +3 -3
  763. package/src/flex/flex/hook.js +1 -0
  764. package/src/flex/types.ts +0 -1
  765. package/src/flyout/styles.ts +4 -2
  766. package/src/flyout/types.ts +0 -1
  767. package/src/focusable-iframe/index.js +1 -0
  768. package/src/font-size-picker/stories/index.js +1 -1
  769. package/src/form-token-field/stories/index.js +1 -1
  770. package/src/form-token-field/style.scss +1 -1
  771. package/src/form-token-field/suggestions-list.js +109 -120
  772. package/src/form-token-field/test/index.js +4 -2
  773. package/src/gradient-picker/README.md +94 -0
  774. package/src/gradient-picker/stories/index.js +1 -1
  775. package/src/grid/hook.js +1 -0
  776. package/src/grid/stories/index.js +1 -1
  777. package/src/grid/types.ts +0 -1
  778. package/src/guide/stories/index.js +1 -1
  779. package/src/h-stack/types.ts +0 -1
  780. package/src/heading/component.tsx +0 -1
  781. package/src/higher-order/with-focus-outside/index.js +2 -0
  782. package/src/icon/index.tsx +0 -1
  783. package/src/icon/stories/index.js +1 -1
  784. package/src/index.js +1 -0
  785. package/src/input-control/index.tsx +0 -1
  786. package/src/input-control/input-base.tsx +0 -1
  787. package/src/input-control/input-field.tsx +0 -1
  788. package/src/input-control/reducer/actions.ts +0 -1
  789. package/src/input-control/reducer/reducer.ts +0 -1
  790. package/src/input-control/reducer/state.ts +0 -1
  791. package/src/input-control/stories/index.js +2 -1
  792. package/src/input-control/styles/input-control-styles.tsx +23 -13
  793. package/src/input-control/types.ts +3 -2
  794. package/src/item-group/item/component.tsx +0 -1
  795. package/src/item-group/item/hook.ts +1 -2
  796. package/src/item-group/item-group/component.tsx +0 -1
  797. package/src/item-group/stories/index.js +84 -2
  798. package/src/menu-item/README.md +2 -2
  799. package/src/mobile/bottom-sheet/bottom-sheet-context.native.js +2 -0
  800. package/src/mobile/bottom-sheet/bottom-sheet-navigation/navigation-container.native.js +8 -14
  801. package/src/mobile/bottom-sheet/bottom-sheet-navigation/navigation-screen.native.js +33 -3
  802. package/src/mobile/bottom-sheet/bottom-sheet-navigation/test/navigation-container.native.js +162 -0
  803. package/src/mobile/bottom-sheet/cell.native.js +8 -6
  804. package/src/mobile/bottom-sheet/index.native.js +24 -14
  805. package/src/mobile/bottom-sheet/link-suggestion-item-cell.native.js +6 -2
  806. package/src/mobile/bottom-sheet/link-suggestion-styles.native.scss +3 -0
  807. package/src/mobile/bottom-sheet/range-text-input.native.js +5 -2
  808. package/src/mobile/bottom-sheet/styles.native.scss +4 -0
  809. package/src/mobile/bottom-sheet/test/index.native.js +24 -0
  810. package/src/mobile/color-settings/index.native.js +4 -0
  811. package/src/mobile/color-settings/palette.screen.native.js +13 -5
  812. package/src/mobile/color-settings/style.native.scss +1 -1
  813. package/src/mobile/color-settings/utils.native.js +8 -3
  814. package/src/mobile/global-styles-context/utils.native.js +1 -1
  815. package/src/mobile/gridicons/index.native.js +3 -3
  816. package/src/mobile/html-text-input/test/index.native.js +34 -35
  817. package/src/mobile/inserter-button/style.native.scss +1 -0
  818. package/src/mobile/keyboard-avoiding-view/index.ios.js +12 -9
  819. package/src/mobile/link-picker/index.native.js +41 -6
  820. package/src/mobile/link-picker/link-picker-screen.native.js +13 -5
  821. package/src/mobile/link-settings/index.native.js +13 -1
  822. package/src/mobile/link-settings/test/edit.native.js +368 -0
  823. package/src/mobile/link-settings/test/link-settings-navigation.native.js +97 -0
  824. package/src/mobile/readable-content-view/index.native.js +5 -2
  825. package/src/mobile/utils/use-is-floating-keyboard.native.js +2 -5
  826. package/src/mobile/utils/use-unit-converter-to-mobile.native.js +5 -2
  827. package/src/modal/README.md +10 -0
  828. package/src/modal/aria-helper.js +2 -0
  829. package/src/modal/index.js +71 -63
  830. package/src/modal/stories/index.js +6 -1
  831. package/src/modal/style.scss +9 -0
  832. package/src/modal/test/index.js +11 -0
  833. package/src/navigation/README.md +0 -9
  834. package/src/navigator/context.ts +5 -1
  835. package/src/navigator/navigator-provider/README.md +30 -20
  836. package/src/navigator/navigator-provider/component.tsx +69 -25
  837. package/src/navigator/navigator-screen/component.tsx +71 -34
  838. package/src/navigator/stories/index.js +26 -13
  839. package/src/navigator/test/index.js +167 -32
  840. package/src/navigator/types.ts +11 -11
  841. package/src/navigator/use-navigator.ts +4 -4
  842. package/src/notice/index.native.js +5 -2
  843. package/src/notice/stories/index.js +1 -1
  844. package/src/number-control/stories/index.js +1 -1
  845. package/src/palette-edit/index.js +9 -2
  846. package/src/palette-edit/styles.js +22 -3
  847. package/src/panel/stories/index.js +1 -1
  848. package/src/placeholder/index.js +8 -6
  849. package/src/placeholder/stories/index.js +1 -1
  850. package/src/placeholder/style.scss +12 -0
  851. package/src/placeholder/test/index.js +18 -1
  852. package/src/popover/stories/index.js +1 -1
  853. package/src/query-controls/README.md +138 -6
  854. package/src/radio-group/README.md +4 -1
  855. package/src/range-control/stories/index.js +1 -1
  856. package/src/range-control/styles/range-control-styles.js +1 -1
  857. package/src/resizable-box/index.tsx +0 -1
  858. package/src/resizable-box/resize-tooltip/index.tsx +1 -2
  859. package/src/resizable-box/resize-tooltip/label.tsx +0 -1
  860. package/src/resizable-box/stories/index.js +1 -1
  861. package/src/sandbox/index.native.js +8 -5
  862. package/src/scrollable/hook.js +1 -1
  863. package/src/scrollable/stories/index.js +7 -4
  864. package/src/search-control/stories/index.js +1 -1
  865. package/src/select-control/stories/index.js +2 -1
  866. package/src/select-control/styles/select-control-styles.ts +25 -2
  867. package/src/select-control/types.ts +1 -1
  868. package/src/slot-fill/bubbles-virtually/fill.js +12 -1
  869. package/src/slot-fill/stories/index.js +1 -1
  870. package/src/snackbar/stories/index.js +1 -1
  871. package/src/spacer/component.tsx +0 -1
  872. package/src/spacer/stories/index.js +1 -1
  873. package/src/spacer/types.ts +0 -1
  874. package/src/spinner/README.md +10 -10
  875. package/src/spinner/index.js +42 -3
  876. package/src/spinner/index.native.js +7 -2
  877. package/src/spinner/stories/index.js +36 -3
  878. package/src/spinner/styles.js +47 -0
  879. package/src/style-provider/index.js +2 -0
  880. package/src/surface/hook.js +1 -0
  881. package/src/surface/stories/index.js +1 -1
  882. package/src/tab-panel/stories/index.js +1 -1
  883. package/src/text/get-line-height.ts +0 -1
  884. package/src/text/hook.js +1 -0
  885. package/src/text/types.ts +0 -1
  886. package/src/text-control/stories/index.js +1 -1
  887. package/src/text-highlight/stories/index.js +1 -1
  888. package/src/textarea-control/stories/index.js +1 -1
  889. package/src/tip/index.js +2 -4
  890. package/src/tip/stories/index.js +1 -1
  891. package/src/toggle-control/stories/index.js +1 -1
  892. package/src/toggle-group-control/stories/index.js +1 -1
  893. package/src/toggle-group-control/test/__snapshots__/index.js.snap +25 -27
  894. package/src/toggle-group-control/toggle-group-control/component.tsx +8 -14
  895. package/src/toggle-group-control/toggle-group-control/styles.ts +0 -14
  896. package/src/toggle-group-control/toggle-group-control-option/component.tsx +0 -1
  897. package/src/toggle-group-control/toggle-group-control-option/styles.ts +1 -3
  898. package/src/toggle-group-control/types.ts +1 -9
  899. package/src/toolbar-button/stories/index.js +1 -1
  900. package/src/tools-panel/stories/index.js +75 -1
  901. package/src/tools-panel/stories/tools-panel-with-item-group-slot.js +244 -0
  902. package/src/tools-panel/styles.ts +40 -2
  903. package/src/tools-panel/test/__snapshots__/index.js.snap +219 -0
  904. package/src/tools-panel/test/index.js +81 -1
  905. package/src/tools-panel/tools-panel/README.md +9 -0
  906. package/src/tools-panel/tools-panel/component.tsx +2 -6
  907. package/src/tools-panel/tools-panel/hook.ts +164 -97
  908. package/src/tools-panel/tools-panel-header/component.tsx +0 -1
  909. package/src/tools-panel/tools-panel-header/hook.ts +3 -3
  910. package/src/tools-panel/tools-panel-item/component.tsx +0 -1
  911. package/src/tools-panel/tools-panel-item/hook.ts +25 -2
  912. package/src/tools-panel/types.ts +14 -1
  913. package/src/tooltip/stories/index.js +1 -1
  914. package/src/tooltip/test/index.native.js +3 -1
  915. package/src/tree-grid/index.js +19 -5
  916. package/src/tree-select/stories/index.js +1 -1
  917. package/src/truncate/hook.js +1 -1
  918. package/src/truncate/stories/index.js +1 -1
  919. package/src/ui/README.md +1 -1
  920. package/src/ui/context/wordpress-component.ts +0 -1
  921. package/src/ui/control-group/types.ts +0 -1
  922. package/src/ui/form-group/types.ts +0 -1
  923. package/src/ui/shortcut/component.tsx +0 -1
  924. package/src/ui/tooltip/types.ts +0 -1
  925. package/src/ui/utils/font-size.ts +0 -1
  926. package/src/ui/utils/get-valid-children.ts +0 -1
  927. package/src/unit-control/index.tsx +0 -1
  928. package/src/unit-control/stories/index.js +19 -1
  929. package/src/unit-control/styles/unit-control-styles.ts +33 -46
  930. package/src/unit-control/types.ts +7 -4
  931. package/src/unit-control/unit-select-control.tsx +0 -1
  932. package/src/utils/colors-values.js +4 -3
  933. package/src/utils/config-values.js +1 -5
  934. package/src/utils/hooks/stories/use-cx.js +121 -44
  935. package/src/utils/hooks/use-combined-ref.ts +0 -1
  936. package/src/utils/hooks/use-latest-ref.ts +0 -1
  937. package/src/v-stack/types.ts +0 -1
  938. package/src/z-stack/README.md +1 -1
  939. package/src/z-stack/component.tsx +1 -2
  940. package/src/z-stack/stories/index.js +1 -1
  941. package/src/z-stack/styles.ts +7 -2
  942. package/tsconfig.json +9 -2
  943. package/tsconfig.tsbuildinfo +1 -1
  944. package/build/spinner/styles/spinner-styles.js +0 -40
  945. package/build/spinner/styles/spinner-styles.js.map +0 -1
  946. package/build/toggle-group-control/toggle-group-control/toggle-group-control-backdrop.js +0 -90
  947. package/build/toggle-group-control/toggle-group-control/toggle-group-control-backdrop.js.map +0 -1
  948. package/build-module/spinner/styles/spinner-styles.js +0 -28
  949. package/build-module/spinner/styles/spinner-styles.js.map +0 -1
  950. package/build-module/toggle-group-control/toggle-group-control/toggle-group-control-backdrop.js +0 -86
  951. package/build-module/toggle-group-control/toggle-group-control/toggle-group-control-backdrop.js.map +0 -1
  952. package/build-types/spinner/styles/spinner-styles.d.ts +0 -5
  953. package/build-types/spinner/styles/spinner-styles.d.ts.map +0 -1
  954. package/build-types/toggle-group-control/component.d.ts +0 -4
  955. package/build-types/toggle-group-control/component.d.ts.map +0 -1
  956. package/build-types/toggle-group-control/styles.d.ts +0 -25
  957. package/build-types/toggle-group-control/styles.d.ts.map +0 -1
  958. package/build-types/toggle-group-control/toggle-group-control/toggle-group-control-backdrop.d.ts +0 -9
  959. package/build-types/toggle-group-control/toggle-group-control/toggle-group-control-backdrop.d.ts.map +0 -1
  960. package/build-types/toggle-group-control/toggle-group-control-backdrop.d.ts +0 -9
  961. package/build-types/toggle-group-control/toggle-group-control-backdrop.d.ts.map +0 -1
  962. package/build-types/toggle-group-control/toggle-group-control-button.d.ts +0 -6
  963. package/build-types/toggle-group-control/toggle-group-control-button.d.ts.map +0 -1
  964. package/build-types/toggle-group-control/toggle-group-control-context.d.ts +0 -9
  965. package/build-types/toggle-group-control/toggle-group-control-context.d.ts.map +0 -1
  966. package/build-types/toggle-group-control/toggle-group-control-option.d.ts +0 -4
  967. package/build-types/toggle-group-control/toggle-group-control-option.d.ts.map +0 -1
  968. package/build-types/ui/color-picker/color-display.d.ts +0 -13
  969. package/build-types/ui/color-picker/color-display.d.ts.map +0 -1
  970. package/build-types/ui/color-picker/color-input.d.ts +0 -13
  971. package/build-types/ui/color-picker/color-input.d.ts.map +0 -1
  972. package/build-types/ui/color-picker/component.d.ts +0 -12
  973. package/build-types/ui/color-picker/component.d.ts.map +0 -1
  974. package/build-types/ui/color-picker/hex-input.d.ts +0 -12
  975. package/build-types/ui/color-picker/hex-input.d.ts.map +0 -1
  976. package/build-types/ui/color-picker/hsl-input.d.ts +0 -12
  977. package/build-types/ui/color-picker/hsl-input.d.ts.map +0 -1
  978. package/build-types/ui/color-picker/index.d.ts +0 -2
  979. package/build-types/ui/color-picker/index.d.ts.map +0 -1
  980. package/build-types/ui/color-picker/input-with-slider.d.ts +0 -11
  981. package/build-types/ui/color-picker/input-with-slider.d.ts.map +0 -1
  982. package/build-types/ui/color-picker/legacy-adapter.d.ts +0 -5
  983. package/build-types/ui/color-picker/legacy-adapter.d.ts.map +0 -1
  984. package/build-types/ui/color-picker/picker.d.ts +0 -12
  985. package/build-types/ui/color-picker/picker.d.ts.map +0 -1
  986. package/build-types/ui/color-picker/rgb-input.d.ts +0 -12
  987. package/build-types/ui/color-picker/rgb-input.d.ts.map +0 -1
  988. package/build-types/ui/color-picker/styles.d.ts +0 -76
  989. package/build-types/ui/color-picker/styles.d.ts.map +0 -1
  990. package/build-types/ui/color-picker/types.d.ts +0 -2
  991. package/build-types/ui/color-picker/types.d.ts.map +0 -1
  992. package/build-types/ui/color-picker/use-deprecated-props.d.ts +0 -50
  993. package/build-types/ui/color-picker/use-deprecated-props.d.ts.map +0 -1
  994. package/build-types/ui/utils/create-component.d.ts +0 -21
  995. package/build-types/ui/utils/create-component.d.ts.map +0 -1
  996. package/build-types/utils/hooks/use-jump-step.d.ts +0 -25
  997. package/build-types/utils/hooks/use-jump-step.d.ts.map +0 -1
  998. package/src/spinner/styles/spinner-styles.js +0 -47
  999. package/src/toggle-group-control/toggle-group-control/toggle-group-control-backdrop.tsx +0 -86
  1000. package/src/ui/visually-hidden/README.md +0 -21
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/components/src/tools-panel/styles.ts"],"names":["css","StyledField","BaseControlField","Wrapper","BaseControlWrapper","COLORS","CONFIG","space","toolsPanelGrid","spacing","item","fullWidth","ToolsPanel","borderWidth","gray","ToolsPanelWithInnerWrapper","columns","ToolsPanelHiddenInnerWrapper","ToolsPanelHeader","ToolsPanelHeading","ToolsPanelItem","ToolsPanelItemPlaceholder","DropdownMenu"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,GAAT,QAAoB,gBAApB;AAEA;AACA;AACA;;AACA,SACCC,WAAW,IAAIC,gBADhB,EAECC,OAAO,IAAIC,kBAFZ,QAGO,4CAHP;AAIA,SAASC,MAAT,EAAiBC,MAAjB,QAA+B,UAA/B;AACA,SAASC,KAAT,QAAsB,mBAAtB;AAEA,MAAMC,cAAc,GAAG;AACtBC,EAAAA,OAAO,eAAET,GAAF,gBACSO,KAAK,CAAE,CAAF,CADd,eAEMA,KAAK,CAAE,CAAF,CAFX,ygIADe;AAKtBG,EAAAA,IAAI,EAAE;AACLC,IAAAA,SAAS;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AADJ;AALgB,CAAvB;AAYA,OAAO,MAAMC,UAAU,gBAAGZ,GAAH,CACnBQ,cAAc,CAACC,OADI,kBAGPH,MAAM,CAACO,WAHA,aAGuBR,MAAM,CAACS,IAAP,CAAa,GAAb,CAHvB,+BAKVP,KAAK,CAAE,CAAF,CALK,4gIAAhB;AAQP;AACA;AACA;AACA;AACA;;AAEA,OAAO,MAAMQ,0BAA0B,GAAKC,OAAF,IAAuB;AAChE,sBAAOhB,GAAP,mEAG6B,WAAWgB,OAAS,SAHjD,OAIKR,cAAc,CAACC,OAJpB,OAKKD,cAAc,CAACE,IAAf,CAAoBC,SALzB;AAQA,CATM;AAWP,OAAO,MAAMM,4BAA4B;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,CAAlC;AAMP,OAAO,MAAMC,gBAAgB,gBAAGlB,GAAH,CACzBQ,cAAc,CAACE,IAAf,CAAoBC,SADK,WAEpBJ,KAAK,CAAE,CAAF,CAFe,wCAYhBA,KAAK,CAAE,CAAC,CAAH,CAZW,qEAgBbA,KAAK,CAAE,CAAF,CAhBQ,mhIAAtB;AAoBP,OAAO,MAAMY,iBAAiB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,CAAvB;AAWP,OAAO,MAAMC,cAAc,gBAAGpB,GAAH,CACvBQ,cAAc,CAACE,IAAf,CAAoBC,SADG,2EAapBP,kBAboB,uBAgBtBF,gBAhBsB,kiIAApB;AAsBP,OAAO,MAAMmB,yBAAyB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,CAA/B;AAIP,OAAO,MAAMC,YAAY;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,CAAlB","sourcesContent":["/**\n * External dependencies\n */\nimport { css } from '@emotion/react';\n\n/**\n * Internal dependencies\n */\nimport {\n\tStyledField as BaseControlField,\n\tWrapper as BaseControlWrapper,\n} from '../base-control/styles/base-control-styles';\nimport { COLORS, CONFIG } from '../utils';\nimport { space } from '../ui/utils/space';\n\nconst toolsPanelGrid = {\n\tspacing: css`\n\t\tcolumn-gap: ${ space( 4 ) };\n\t\trow-gap: ${ space( 6 ) };\n\t`,\n\titem: {\n\t\tfullWidth: css`\n\t\t\tgrid-column: 1 / -1;\n\t\t`,\n\t},\n};\n\nexport const ToolsPanel = css`\n\t${ toolsPanelGrid.spacing };\n\n\tborder-top: ${ CONFIG.borderWidth } solid ${ COLORS.gray[ 200 ] };\n\tmargin-top: -1px;\n\tpadding: ${ space( 4 ) };\n`;\n\n/**\n * Items injected into a ToolsPanel via a virtual bubbling slot will require\n * an inner dom element to be injected. The following rule allows for the\n * CSS grid display to be re-established.\n */\n\nexport const ToolsPanelWithInnerWrapper = ( columns: number ) => {\n\treturn css`\n\t\t> div:not( :first-of-type ) {\n\t\t\tdisplay: grid;\n\t\t\tgrid-template-columns: ${ `repeat( ${ columns }, 1fr )` };\n\t\t\t${ toolsPanelGrid.spacing }\n\t\t\t${ toolsPanelGrid.item.fullWidth }\n\t\t}\n\t`;\n};\n\nexport const ToolsPanelHiddenInnerWrapper = css`\n\t> div:not( :first-of-type ) {\n\t\tdisplay: none;\n\t}\n`;\n\nexport const ToolsPanelHeader = css`\n\t${ toolsPanelGrid.item.fullWidth }\n\tgap: ${ space( 2 ) };\n\n\t/**\n\t * The targeting of dropdown menu component classes here is a temporary\n\t * measure only.\n\t *\n\t * The following styles should be replaced once the DropdownMenu has been\n\t * refactored and can be targeted via component interpolation.\n\t */\n\t.components-dropdown-menu {\n\t\tmargin: ${ space( -1 ) } 0;\n\t}\n\t&&&& .components-dropdown-menu__toggle {\n\t\tpadding: 0;\n\t\tmin-width: ${ space( 6 ) };\n\t}\n`;\n\nexport const ToolsPanelHeading = css`\n\tfont-size: inherit;\n\tfont-weight: 500;\n\tline-height: normal;\n\n\t/* Required to meet specificity requirements to ensure zero margin */\n\t&& {\n\t\tmargin: 0;\n\t}\n`;\n\nexport const ToolsPanelItem = css`\n\t${ toolsPanelGrid.item.fullWidth }\n\n\t/* Clear spacing in and around controls added as panel items. */\n\t/* Remove when they can be addressed via context system. */\n\t& > div,\n\t& > fieldset {\n\t\tpadding-bottom: 0;\n\t\tmargin-bottom: 0;\n\t\tmax-width: 100%;\n\t}\n\n\t/* Remove BaseControl components margins and leave spacing to grid layout */\n\t&& ${ BaseControlWrapper } {\n\t\tmargin-bottom: 0;\n\n\t\t${ BaseControlField } {\n\t\t\tmargin-bottom: 0;\n\t\t}\n\t}\n`;\n\nexport const ToolsPanelItemPlaceholder = css`\n\tdisplay: none;\n`;\n\nexport const DropdownMenu = css`\n\tmin-width: 200px;\n`;\n"]}
1
+ {"version":3,"sources":["@wordpress/components/src/tools-panel/styles.ts"],"names":["css","StyledField","BaseControlField","StyledHelp","BaseControlHelp","StyledLabel","BaseControlLabel","Wrapper","BaseControlWrapper","LabelWrapper","COLORS","CONFIG","space","toolsPanelGrid","spacing","item","fullWidth","ToolsPanel","borderWidth","gray","ToolsPanelWithInnerWrapper","columns","ToolsPanelHiddenInnerWrapper","ToolsPanelHeader","ToolsPanelHeading","ToolsPanelItem","ToolsP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,2+KAAtB;AAqBP,OAAO,MAAMY,iBAAiB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,CAAvB;AAWP,OAAO,MAAMC,cAAc,gBAAGzB,GAAH,CACvBa,cAAc,CAACE,IAAf,CAAoBC,SADG,2EAapBR,kBAboB,uBAqBtBN,gBArBsB,oCA0BvBE,eA1BuB,2BAqCpBK,YArCoB,0EAmDvBH,gBAnDuB,2/KAApB;AAwDP,OAAO,MAAMoB,yBAAyB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,CAA/B;AAIP,OAAO,MAAMC,YAAY;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,CAAlB","sourcesContent":["/**\n * External dependencies\n */\nimport { css } from '@emotion/react';\n\n/**\n * Internal dependencies\n */\nimport {\n\tStyledField as BaseControlField,\n\tStyledHelp as BaseControlHelp,\n\tStyledLabel as BaseControlLabel,\n\tWrapper as BaseControlWrapper,\n} from '../base-control/styles/base-control-styles';\nimport { LabelWrapper } from '../input-control/styles/input-control-styles';\nimport { COLORS, CONFIG } from '../utils';\nimport { space } from '../ui/utils/space';\n\nconst toolsPanelGrid = {\n\tspacing: css`\n\t\tcolumn-gap: ${ space( 4 ) };\n\t\trow-gap: ${ space( 6 ) };\n\t`,\n\titem: {\n\t\tfullWidth: css`\n\t\t\tgrid-column: 1 / -1;\n\t\t`,\n\t},\n};\n\nexport const ToolsPanel = css`\n\t${ toolsPanelGrid.spacing };\n\n\tborder-top: ${ CONFIG.borderWidth } solid ${ COLORS.gray[ 300 ] };\n\tmargin-top: -1px;\n\tpadding: ${ space( 4 ) };\n`;\n\n/**\n * Items injected into a ToolsPanel via a virtual bubbling slot will require\n * an inner dom element to be injected. The following rule allows for the\n * CSS grid display to be re-established.\n */\n\nexport const ToolsPanelWithInnerWrapper = ( columns: number ) => {\n\treturn css`\n\t\t> div:not( :first-of-type ) {\n\t\t\tdisplay: grid;\n\t\t\tgrid-template-columns: ${ `repeat( ${ columns }, 1fr )` };\n\t\t\t${ toolsPanelGrid.spacing }\n\t\t\t${ toolsPanelGrid.item.fullWidth }\n\t\t}\n\t`;\n};\n\nexport const ToolsPanelHiddenInnerWrapper = css`\n\t> div:not( :first-of-type ) {\n\t\tdisplay: none;\n\t}\n`;\n\nexport const ToolsPanelHeader = css`\n\t${ toolsPanelGrid.item.fullWidth }\n\tgap: ${ space( 2 ) };\n\n\t/**\n\t * The targeting of dropdown menu component classes here is a temporary\n\t * measure only.\n\t *\n\t * The following styles should be replaced once the DropdownMenu has been\n\t * refactored and can be targeted via component interpolation.\n\t */\n\t.components-dropdown-menu {\n\t\tmargin: ${ space( -1 ) } 0;\n\t\tline-height: 0;\n\t}\n\t&&&& .components-dropdown-menu__toggle {\n\t\tpadding: 0;\n\t\tmin-width: ${ space( 6 ) };\n\t}\n`;\n\nexport const ToolsPanelHeading = css`\n\tfont-size: inherit;\n\tfont-weight: 500;\n\tline-height: normal;\n\n\t/* Required to meet specificity requirements to ensure zero margin */\n\t&& {\n\t\tmargin: 0;\n\t}\n`;\n\nexport const ToolsPanelItem = css`\n\t${ toolsPanelGrid.item.fullWidth }\n\n\t/* Clear spacing in and around controls added as panel items. */\n\t/* Remove when they can be addressed via context system. */\n\t& > div,\n\t& > fieldset {\n\t\tpadding-bottom: 0;\n\t\tmargin-bottom: 0;\n\t\tmax-width: 100%;\n\t}\n\n\t/* Remove BaseControl components margins and leave spacing to grid layout */\n\t&& ${ BaseControlWrapper } {\n\t\tmargin-bottom: 0;\n\n\t\t/**\n\t\t * To maintain proper spacing within a base control, the field's bottom\n\t\t * margin should only be removed when there is no help text included and\n\t\t * it is therefore the last-child.\n\t\t */\n\t\t${ BaseControlField }:last-child {\n\t\t\tmargin-bottom: 0;\n\t\t}\n\t}\n\n\t${ BaseControlHelp } {\n\t\tmargin-bottom: 0;\n\t}\n\n\t/**\n\t * Standardize InputControl and BaseControl labels with other labels when\n\t * inside ToolsPanel.\n\t *\n\t * This is a temporary fix until the different control components have their\n\t * labels normalized.\n\t */\n\t&& ${ LabelWrapper } {\n\t\tlabel {\n\t\t\tline-height: 1.4em;\n\t\t}\n\t}\n\n\t/**\n\t * The targeting of .components-custom-select-control__label here is a\n\t * temporary measure only.\n\t *\n\t * It should be replaced once CustomSelectControl component has been\n\t * refactored and can be targeted via component interpolation.\n\t */\n\t.components-custom-select-control__label,\n\t${ BaseControlLabel } {\n\t\tline-height: 1.4em;\n\t}\n`;\n\nexport const ToolsPanelItemPlaceholder = css`\n\tdisplay: none;\n`;\n\nexport const DropdownMenu = css`\n\tmin-width: 200px;\n`;\n"]}
@@ -1,9 +1,9 @@
1
+ import _extends from "@babel/runtime/helpers/esm/extends";
1
2
  import { createElement } from "@wordpress/element";
2
3
 
3
4
  /**
4
5
  * External dependencies
5
6
  */
6
- // eslint-disable-next-line no-restricted-imports
7
7
 
8
8
  /**
9
9
  * Internal dependencies
@@ -21,16 +21,12 @@ const ToolsPanel = (props, forwardedRef) => {
21
21
  panelContext,
22
22
  resetAllItems,
23
23
  toggleItem,
24
- className
25
- } = useToolsPanel(props); // Props are not directly passed through to avoid exposing Grid props
26
- // until agreement has been reached on how ToolsPanel layout should be
27
- // handled.
28
-
29
- return createElement(Grid, {
24
+ ...toolsPanelProps
25
+ } = useToolsPanel(props);
26
+ return createElement(Grid, _extends({}, toolsPanelProps, {
30
27
  columns: 2,
31
- className: className,
32
28
  ref: forwardedRef
33
- }, createElement(ToolsPanelContext.Provider, {
29
+ }), createElement(ToolsPanelContext.Provider, {
34
30
  value: panelContext
35
31
  }, createElement(ToolsPanelHeader, {
36
32
  label: label,
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/components/src/tools-panel/tools-panel/component.tsx"],"names":["ToolsPanelHeader","ToolsPanelContext","useToolsPanel","Grid","contextConnect","ToolsPanel","props","forwardedRef","children","label","panelContext","resetAllItems","toggleItem","className","ConnectedToolsPanel"],"mappings":";;AAAA;AACA;AACA;AACA;;AAGA;AACA;AACA;AACA,OAAOA,gBAAP,MAA6B,uBAA7B;AACA,SAASC,iBAAT,QAAkC,YAAlC;AACA,SAASC,aAAT,QAA8B,QAA9B;AACA,SAASC,IAAT,QAAqB,YAArB;AACA,SAASC,cAAT,QAAwD,kBAAxD;;AAGA,MAAMC,UAAU,GAAG,CAClBC,KADkB,EAElBC,YAFkB,KAGd;AACJ,QAAM;AACLC,IAAAA,QADK;AAELC,IAAAA,KAFK;AAGLC,IAAAA,YAHK;AAILC,IAAAA,aAJK;AAKLC,IAAAA,UALK;AAMLC,IAAAA;AANK,MAOFX,aAAa,CAAEI,KAAF,CAPjB,CADI,CAUJ;AACA;AACA;;AACA,SACC,cAAC,IAAD;AAAM,IAAA,OAAO,EAAG,CAAhB;AAAoB,IAAA,SAAS,EAAGO,SAAhC;AAA4C,IAAA,GAAG,EAAGN;AAAlD,KACC,cAAC,iBAAD,CAAmB,QAAnB;AAA4B,IAAA,KAAK,EAAGG;AAApC,KACC,cAAC,gBAAD;AACC,IAAA,KAAK,EAAGD,KADT;AAEC,IAAA,QAAQ,EAAGE,aAFZ;AAGC,IAAA,UAAU,EAAGC;AAHd,IADD,EAMGJ,QANH,CADD,CADD;AAYA,CA5BD;;AA8BA,MAAMM,mBAAmB,GAAGV,cAAc,CAAEC,UAAF,EAAc,YAAd,CAA1C;AAEA,eAAeS,mBAAf","sourcesContent":["/**\n * External dependencies\n */\n// eslint-disable-next-line no-restricted-imports\nimport type { Ref } 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 { contextConnect, WordPressComponentProps } from '../../ui/context';\nimport type { ToolsPanelProps } from '../types';\n\nconst ToolsPanel = (\n\tprops: WordPressComponentProps< ToolsPanelProps, 'div' >,\n\tforwardedRef: Ref< any >\n) => {\n\tconst {\n\t\tchildren,\n\t\tlabel,\n\t\tpanelContext,\n\t\tresetAllItems,\n\t\ttoggleItem,\n\t\tclassName,\n\t} = useToolsPanel( props );\n\n\t// Props are not directly passed through to avoid exposing Grid props\n\t// until agreement has been reached on how ToolsPanel layout should be\n\t// handled.\n\treturn (\n\t\t<Grid columns={ 2 } className={ className } 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/>\n\t\t\t\t{ children }\n\t\t\t</ToolsPanelContext.Provider>\n\t\t</Grid>\n\t);\n};\n\nconst ConnectedToolsPanel = contextConnect( ToolsPanel, 'ToolsPanel' );\n\nexport default ConnectedToolsPanel;\n"]}
1
+ {"version":3,"sources":["@wordpress/components/src/tools-panel/tools-panel/component.tsx"],"names":["ToolsPanelHeader","ToolsPanelContext","useToolsPanel","Grid","contextConnect","ToolsPanel","props","forwardedRef","children","label","panelContext","resetAllItems","toggleItem","toolsPanelProps","ConnectedToolsPanel"],"mappings":";;;AAAA;AACA;AACA;;AAGA;AACA;AACA;AACA,OAAOA,gBAAP,MAA6B,uBAA7B;AACA,SAASC,iBAAT,QAAkC,YAAlC;AACA,SAASC,aAAT,QAA8B,QAA9B;AACA,SAASC,IAAT,QAAqB,YAArB;AACA,SAASC,cAAT,QAAwD,kBAAxD;;AAGA,MAAMC,UAAU,GAAG,CAClBC,KADkB,EAElBC,YAFkB,KAGd;AACJ,QAAM;AACLC,IAAAA,QADK;AAELC,IAAAA,KAFK;AAGLC,IAAAA,YAHK;AAILC,IAAAA,aAJK;AAKLC,IAAAA,UALK;AAML,OAAGC;AANE,MAOFX,aAAa,CAAEI,KAAF,CAPjB;AASA,SACC,cAAC,IAAD,eAAWO,eAAX;AAA6B,IAAA,OAAO,EAAG,CAAvC;AAA2C,IAAA,GAAG,EAAGN;AAAjD,MACC,cAAC,iBAAD,CAAmB,QAAnB;AAA4B,IAAA,KAAK,EAAGG;AAApC,KACC,cAAC,gBAAD;AACC,IAAA,KAAK,EAAGD,KADT;AAEC,IAAA,QAAQ,EAAGE,aAFZ;AAGC,IAAA,UAAU,EAAGC;AAHd,IADD,EAMGJ,QANH,CADD,CADD;AAYA,CAzBD;;AA2BA,MAAMM,mBAAmB,GAAGV,cAAc,CAAEC,UAAF,EAAc,YAAd,CAA1C;AAEA,eAAeS,mBAAf","sourcesContent":["/**\n * External dependencies\n */\nimport type { Ref } 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 { contextConnect, WordPressComponentProps } from '../../ui/context';\nimport type { ToolsPanelProps } from '../types';\n\nconst ToolsPanel = (\n\tprops: WordPressComponentProps< ToolsPanelProps, 'div' >,\n\tforwardedRef: Ref< any >\n) => {\n\tconst {\n\t\tchildren,\n\t\tlabel,\n\t\tpanelContext,\n\t\tresetAllItems,\n\t\ttoggleItem,\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/>\n\t\t\t\t{ children }\n\t\t\t</ToolsPanelContext.Provider>\n\t\t</Grid>\n\t);\n};\n\nconst ConnectedToolsPanel = contextConnect( ToolsPanel, 'ToolsPanel' );\n\nexport default ConnectedToolsPanel;\n"]}
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * WordPress dependencies
3
3
  */
4
- import { useEffect, useMemo, useRef, useState } from '@wordpress/element';
4
+ import { useCallback, useEffect, useMemo, useRef, useState } from '@wordpress/element';
5
5
  /**
6
6
  * Internal dependencies
7
7
  */
@@ -40,6 +40,8 @@ const generateMenuItems = _ref => {
40
40
  return menuItems;
41
41
  };
42
42
 
43
+ const isMenuItemTypeEmpty = obj => obj && Object.keys(obj).length === 0;
44
+
43
45
  export function useToolsPanel(props) {
44
46
  const {
45
47
  className,
@@ -47,6 +49,8 @@ export function useToolsPanel(props) {
47
49
  panelId,
48
50
  hasInnerWrapper,
49
51
  shouldRenderPlaceholderItems,
52
+ __experimentalFirstVisibleItemClass,
53
+ __experimentalLastVisibleItemClass,
50
54
  ...otherProps
51
55
  } = useContextSystem(props, 'ToolsPanel');
52
56
  const isResetting = useRef(false);
@@ -62,12 +66,11 @@ export function useToolsPanel(props) {
62
66
  }, [wasResetting]); // Allow panel items to register themselves.
63
67
 
64
68
  const [panelItems, setPanelItems] = useState([]);
65
-
66
- const registerPanelItem = item => {
69
+ const registerPanelItem = useCallback(item => {
67
70
  setPanelItems(items => {
68
- const newItems = [...items]; // If an item with this label is already registered, remove it first.
69
- // This can happen when an item is moved between the default and optional
70
- // groups.
71
+ const newItems = [...items]; // If an item with this label has already been registered, remove it
72
+ // first. This can happen when an item is moved between the default
73
+ // and optional groups.
71
74
 
72
75
  const existingIndex = newItems.findIndex(oldItem => oldItem.label === item.label);
73
76
 
@@ -77,11 +80,10 @@ export function useToolsPanel(props) {
77
80
 
78
81
  return [...newItems, item];
79
82
  });
80
- }; // Panels need to deregister on unmount to avoid orphans in menu state.
83
+ }, [setPanelItems]); // Panels need to deregister on unmount to avoid orphans in menu state.
81
84
  // This is an issue when panel items are being injected via SlotFills.
82
85
 
83
-
84
- const deregisterPanelItem = label => {
86
+ const deregisterPanelItem = useCallback(label => {
85
87
  // When switching selections between components injecting matching
86
88
  // controls, e.g. both panels have a "padding" control, the
87
89
  // deregistration of the first panel doesn't occur until after the
@@ -96,8 +98,7 @@ export function useToolsPanel(props) {
96
98
 
97
99
  return newItems;
98
100
  });
99
- }; // Manage and share display state of menu items representing child controls.
100
-
101
+ }, [setPanelItems]); // Manage and share display state of menu items representing child controls.
101
102
 
102
103
  const [menuItems, setMenuItems] = useState({
103
104
  default: {},
@@ -113,12 +114,12 @@ export function useToolsPanel(props) {
113
114
  });
114
115
  return items;
115
116
  });
116
- }, [panelItems]); // Force a menu item to be checked.
117
+ }, [generateMenuItems, panelItems, setMenuItems]); // Force a menu item to be checked.
117
118
  // This is intended for use with default panel items. They are displayed
118
119
  // separately to optional items and have different display states,
119
120
  // we need to update that when their value is customized.
120
121
 
121
- const flagItemCustomization = function (label) {
122
+ const flagItemCustomization = useCallback(function (label) {
122
123
  let group = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'default';
123
124
  setMenuItems(items => {
124
125
  const newState = { ...items,
@@ -128,33 +129,30 @@ export function useToolsPanel(props) {
128
129
  };
129
130
  return newState;
130
131
  });
131
- }; // Whether all optional menu items are hidden or not must be tracked
132
+ }, [setMenuItems]); // Whether all optional menu items are hidden or not must be tracked
132
133
  // in order to later determine if the panel display is empty and handle
133
134
  // conditional display of a plus icon to indicate the presence of further
134
135
  // menu items.
135
136
 
136
-
137
137
  const [areAllOptionalControlsHidden, setAreAllOptionalControlsHidden] = useState(false);
138
138
  useEffect(() => {
139
- if (menuItems.optional) {
140
- const optionalItems = Object.entries(menuItems.optional);
141
- const allControlsHidden = optionalItems.length > 0 && !optionalItems.some(_ref3 => {
139
+ if (isMenuItemTypeEmpty(menuItems === null || menuItems === void 0 ? void 0 : menuItems.default) && !isMenuItemTypeEmpty(menuItems === null || menuItems === void 0 ? void 0 : menuItems.optional)) {
140
+ const allControlsHidden = !Object.entries(menuItems.optional).some(_ref3 => {
142
141
  let [, isSelected] = _ref3;
143
142
  return isSelected;
144
143
  });
145
144
  setAreAllOptionalControlsHidden(allControlsHidden);
146
145
  }
147
- }, [menuItems.optional]);
146
+ }, [menuItems, setAreAllOptionalControlsHidden]);
148
147
  const cx = useCx();
149
148
  const classes = useMemo(() => {
150
- const hasDefaultMenuItems = (menuItems === null || menuItems === void 0 ? void 0 : menuItems.default) && !!Object.keys(menuItems === null || menuItems === void 0 ? void 0 : menuItems.default).length;
151
149
  const wrapperStyle = hasInnerWrapper && styles.ToolsPanelWithInnerWrapper(DEFAULT_COLUMNS);
152
- const emptyStyle = !hasDefaultMenuItems && areAllOptionalControlsHidden && styles.ToolsPanelHiddenInnerWrapper;
150
+ const emptyStyle = isMenuItemTypeEmpty(menuItems === null || menuItems === void 0 ? void 0 : menuItems.default) && areAllOptionalControlsHidden && styles.ToolsPanelHiddenInnerWrapper;
153
151
  return cx(styles.ToolsPanel, wrapperStyle, emptyStyle, className);
154
- }, [className, hasInnerWrapper, menuItems, areAllOptionalControlsHidden]); // Toggle the checked state of a menu item which is then used to determine
152
+ }, [areAllOptionalControlsHidden, className, cx, hasInnerWrapper, menuItems]); // Toggle the checked state of a menu item which is then used to determine
155
153
  // display of the item within the panel.
156
154
 
157
- const toggleItem = label => {
155
+ const toggleItem = useCallback(label => {
158
156
  const currentItem = panelItems.find(item => item.label === label);
159
157
 
160
158
  if (!currentItem) {
@@ -168,23 +166,19 @@ export function useToolsPanel(props) {
168
166
  }
169
167
  };
170
168
  setMenuItems(newMenuItems);
171
- };
169
+ }, [menuItems, panelItems, setMenuItems]); // Resets display of children and executes resetAll callback if available.
172
170
 
173
- const getResetAllFilters = () => {
174
- const filters = [];
175
- panelItems.forEach(item => {
176
- if (item.resetAllFilter) {
177
- filters.push(item.resetAllFilter);
178
- }
179
- });
180
- return filters;
181
- }; // Resets display of children and executes resetAll callback if available.
182
-
183
-
184
- const resetAllItems = () => {
171
+ const resetAllItems = useCallback(() => {
185
172
  if (typeof resetAll === 'function') {
186
- isResetting.current = true;
187
- resetAll(getResetAllFilters());
173
+ isResetting.current = true; // Collect available reset filters from panel items.
174
+
175
+ const filters = [];
176
+ panelItems.forEach(item => {
177
+ if (item.resetAllFilter) {
178
+ filters.push(item.resetAllFilter);
179
+ }
180
+ });
181
+ resetAll(filters);
188
182
  } // Turn off display of all non-default items.
189
183
 
190
184
 
@@ -193,19 +187,32 @@ export function useToolsPanel(props) {
193
187
  shouldReset: true
194
188
  });
195
189
  setMenuItems(resetMenuItems);
190
+ }, [generateMenuItems, isResetting.current, panelItems, resetAll, setMenuItems]); // Assist ItemGroup styling when there are potentially hidden placeholder
191
+ // items by identifying first & last items that are toggled on for display.
192
+
193
+ const getFirstVisibleItemLabel = items => {
194
+ const optionalItems = menuItems.optional || {};
195
+ const firstItem = items.find(item => item.isShownByDefault || !!optionalItems[item.label]);
196
+ return firstItem === null || firstItem === void 0 ? void 0 : firstItem.label;
196
197
  };
197
198
 
198
- const panelContext = {
199
- panelId,
200
- menuItems,
201
- registerPanelItem,
199
+ const firstDisplayedItem = getFirstVisibleItemLabel(panelItems);
200
+ const lastDisplayedItem = getFirstVisibleItemLabel([...panelItems].reverse());
201
+ const panelContext = useMemo(() => ({
202
+ areAllOptionalControlsHidden,
202
203
  deregisterPanelItem,
204
+ firstDisplayedItem,
203
205
  flagItemCustomization,
204
- areAllOptionalControlsHidden,
205
206
  hasMenuItems: !!panelItems.length,
206
207
  isResetting: isResetting.current,
207
- shouldRenderPlaceholderItems
208
- };
208
+ lastDisplayedItem,
209
+ menuItems,
210
+ panelId,
211
+ registerPanelItem,
212
+ shouldRenderPlaceholderItems,
213
+ __experimentalFirstVisibleItemClass,
214
+ __experimentalLastVisibleItemClass
215
+ }), [areAllOptionalControlsHidden, deregisterPanelItem, firstDisplayedItem, flagItemCustomization, isResetting.current, lastDisplayedItem, menuItems, panelId, panelItems, registerPanelItem, shouldRenderPlaceholderItems, __experimentalFirstVisibleItemClass, __experimentalLastVisibleItemClass]);
209
216
  return { ...otherProps,
210
217
  panelContext,
211
218
  resetAllItems,
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/components/src/tools-panel/tools-panel/hook.ts"],"names":["useEffect","useMemo","useRef","useState","styles","useContextSystem","useCx","DEFAULT_COLUMNS","generateMenuItems","panelItems","shouldReset","currentMenuItems","menuItems","default","optional","forEach","hasValue","isShownByDefault","label","group","existingItemValue","value","undefined","useToolsPanel","props","className","resetAll","panelId","hasInnerWrapper","shouldRenderPlaceholderItems","otherProps","isResetting","wasResetting","current","setPanelItems","registerPanelItem","item","items","newItems","existingIndex","findIndex","oldItem","splice","deregisterPanelItem","index","setMenuItems","prevState","flagItemCustomization","newState","areAllOptionalControlsHidden","setAreAllOptionalControlsHidden","optionalItems","Object","entries","allControlsHidden","length","some","isSelected","cx","classes","hasDefaultMenuItems","keys","wrapperStyle","ToolsPanelWithInnerWrapper","emptyStyle","ToolsPanelHiddenInnerWrapper","ToolsPanel","toggleItem","currentItem","find","menuGroup","newMenuItems","getResetAllFilters","filters","resetAllFilter","push","resetAllItems","resetMenuItems","panelContext","hasMenuItems"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,SAAT,EAAoBC,OAApB,EAA6BC,MAA7B,EAAqCC,QAArC,QAAqD,oBAArD;AAEA;AACA;AACA;;AACA,OAAO,KAAKC,MAAZ,MAAwB,WAAxB;AACA,SAASC,gBAAT,QAA0D,kBAA1D;AACA,SAASC,KAAT,QAAsB,0BAAtB;AASA,MAAMC,eAAe,GAAG,CAAxB;;AAEA,MAAMC,iBAAiB,GAAG,QAIQ;AAAA,MAJN;AAC3BC,IAAAA,UAD2B;AAE3BC,IAAAA,WAF2B;AAG3BC,IAAAA;AAH2B,GAIM;AACjC,QAAMC,SAA8B,GAAG;AAAEC,IAAAA,OAAO,EAAE,EAAX;AAAeC,IAAAA,QAAQ,EAAE;AAAzB,GAAvC;AAEAL,EAAAA,UAAU,CAACM,OAAX,CAAoB,SAA6C;AAAA;;AAAA,QAA3C;AAAEC,MAAAA,QAAF;AAAYC,MAAAA,gBAAZ;AAA8BC,MAAAA;AAA9B,KAA2C;AAChE,UAAMC,KAAK,GAAGF,gBAAgB,GAAG,SAAH,GAAe,UAA7C,CADgE,CAGhE;AACA;AACA;;AACA,UAAMG,iBAAiB,GAAGT,gBAAH,aAAGA,gBAAH,gDAAGA,gBAAgB,CAAIQ,KAAJ,CAAnB,0DAAG,sBAA+BD,K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AAxC;AAIAmC,IAAAA,YAAY,CAAEgC,cAAF,CAAZ;AACA,GAZD;;AAcA,QAAMC,YAAY,GAAG;AACpBnD,IAAAA,OADoB;AAEpBf,IAAAA,SAFoB;AAGpBuB,IAAAA,iBAHoB;AAIpBQ,IAAAA,mBAJoB;AAKpBI,IAAAA,qBALoB;AAMpBE,IAAAA,4BANoB;AAOpB8B,IAAAA,YAAY,EAAE,CAAC,CAAEtE,UAAU,CAAC8C,MAPR;AAQpBxB,IAAAA,WAAW,EAAEA,WAAW,CAACE,OARL;AASpBJ,IAAAA;AAToB,GAArB;AAYA,SAAO,EACN,GAAGC,UADG;AAENgD,IAAAA,YAFM;AAGNF,IAAAA,aAHM;AAINT,IAAAA,UAJM;AAKN1C,IAAAA,SAAS,EAAEkC;AALL,GAAP;AAOA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useEffect, useMemo, useRef, useState } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport * as styles from '../styles';\nimport { useContextSystem, WordPressComponentProps } from '../../ui/context';\nimport { useCx } from '../../utils/hooks/use-cx';\nimport type {\n\tToolsPanelItem,\n\tToolsPanelMenuItemKey,\n\tToolsPanelMenuItems,\n\tToolsPanelMenuItemsConfig,\n\tToolsPanelProps,\n} from '../types';\n\nconst DEFAULT_COLUMNS = 2;\n\nconst generateMenuItems = ( {\n\tpanelItems,\n\tshouldReset,\n\tcurrentMenuItems,\n}: ToolsPanelMenuItemsConfig ) => {\n\tconst menuItems: ToolsPanelMenuItems = { default: {}, optional: {} };\n\n\tpanelItems.forEach( ( { hasValue, isShownByDefault, label } ) => {\n\t\tconst group = isShownByDefault ? 'default' : 'optional';\n\n\t\t// If a menu item for this label already exists, do not overwrite its value.\n\t\t// This can cause default controls that have been flagged as customized to\n\t\t// lose their value.\n\t\tconst existingItemValue = currentMenuItems?.[ group ]?.[ label ];\n\t\tconst value =\n\t\t\texistingItemValue !== undefined ? existingItemValue : hasValue();\n\n\t\tmenuItems[ group ][ label ] = shouldReset ? false : value;\n\t} );\n\n\treturn menuItems;\n};\n\nexport function useToolsPanel(\n\tprops: WordPressComponentProps< ToolsPanelProps, 'div' >\n) {\n\tconst {\n\t\tclassName,\n\t\tresetAll,\n\t\tpanelId,\n\t\thasInnerWrapper,\n\t\tshouldRenderPlaceholderItems,\n\t\t...otherProps\n\t} = useContextSystem( props, 'ToolsPanel' );\n\n\tconst isResetting = useRef( false );\n\tconst wasResetting = isResetting.current;\n\n\t// `isResetting` is cleared via this hook to effectively batch together\n\t// the resetAll task. Without this, the flag is cleared after the first\n\t// control updates and forces a rerender with subsequent controls then\n\t// believing they need to reset, unfortunately using stale data.\n\tuseEffect( () => {\n\t\tif ( wasResetting ) {\n\t\t\tisResetting.current = false;\n\t\t}\n\t}, [ wasResetting ] );\n\n\t// Allow panel items to register themselves.\n\tconst [ panelItems, setPanelItems ] = useState< ToolsPanelItem[] >( [] );\n\n\tconst registerPanelItem = ( item: ToolsPanelItem ) => {\n\t\tsetPanelItems( ( items ) => {\n\t\t\tconst newItems = [ ...items ];\n\t\t\t// If an item with this label is already registered, remove it first.\n\t\t\t// This can happen when an item is moved between the default and optional\n\t\t\t// groups.\n\t\t\tconst existingIndex = newItems.findIndex(\n\t\t\t\t( oldItem ) => oldItem.label === item.label\n\t\t\t);\n\t\t\tif ( existingIndex !== -1 ) {\n\t\t\t\tnewItems.splice( existingIndex, 1 );\n\t\t\t}\n\t\t\treturn [ ...newItems, item ];\n\t\t} );\n\t};\n\n\t// Panels need to deregister on unmount to avoid orphans in menu state.\n\t// This is an issue when panel items are being injected via SlotFills.\n\tconst deregisterPanelItem = ( label: string ) => {\n\t\t// When switching selections between components injecting matching\n\t\t// controls, e.g. both panels have a \"padding\" control, the\n\t\t// deregistration of the first panel doesn't occur until after the\n\t\t// registration of the next.\n\t\tsetPanelItems( ( items ) => {\n\t\t\tconst newItems = [ ...items ];\n\t\t\tconst index = newItems.findIndex(\n\t\t\t\t( item ) => item.label === label\n\t\t\t);\n\t\t\tif ( index !== -1 ) {\n\t\t\t\tnewItems.splice( index, 1 );\n\t\t\t}\n\t\t\treturn newItems;\n\t\t} );\n\t};\n\n\t// Manage and share display state of menu items representing child controls.\n\tconst [ menuItems, setMenuItems ] = useState< ToolsPanelMenuItems >( {\n\t\tdefault: {},\n\t\toptional: {},\n\t} );\n\n\t// Setup menuItems state as panel items register themselves.\n\tuseEffect( () => {\n\t\tsetMenuItems( ( prevState ) => {\n\t\t\tconst items = generateMenuItems( {\n\t\t\t\tpanelItems,\n\t\t\t\tshouldReset: false,\n\t\t\t\tcurrentMenuItems: prevState,\n\t\t\t} );\n\t\t\treturn items;\n\t\t} );\n\t}, [ panelItems ] );\n\n\t// Force a menu item to be checked.\n\t// This is intended for use with default panel items. They are displayed\n\t// separately to optional items and have different display states,\n\t// we need to update that when their value is customized.\n\tconst flagItemCustomization = (\n\t\tlabel: string,\n\t\tgroup: ToolsPanelMenuItemKey = 'default'\n\t) => {\n\t\tsetMenuItems( ( items ) => {\n\t\t\tconst newState = {\n\t\t\t\t...items,\n\t\t\t\t[ group ]: {\n\t\t\t\t\t...items[ group ],\n\t\t\t\t\t[ label ]: true,\n\t\t\t\t},\n\t\t\t};\n\t\t\treturn newState;\n\t\t} );\n\t};\n\n\t// Whether all optional menu items are hidden or not must be tracked\n\t// in order to later determine if the panel display is empty and handle\n\t// conditional display of a plus icon to indicate the presence of further\n\t// menu items.\n\tconst [\n\t\tareAllOptionalControlsHidden,\n\t\tsetAreAllOptionalControlsHidden,\n\t] = useState( false );\n\n\tuseEffect( () => {\n\t\tif ( menuItems.optional ) {\n\t\t\tconst optionalItems = Object.entries( menuItems.optional );\n\t\t\tconst allControlsHidden =\n\t\t\t\toptionalItems.length > 0 &&\n\t\t\t\t! optionalItems.some( ( [ , isSelected ] ) => isSelected );\n\t\t\tsetAreAllOptionalControlsHidden( allControlsHidden );\n\t\t}\n\t}, [ menuItems.optional ] );\n\n\tconst cx = useCx();\n\tconst classes = useMemo( () => {\n\t\tconst hasDefaultMenuItems =\n\t\t\tmenuItems?.default && !! Object.keys( menuItems?.default ).length;\n\t\tconst wrapperStyle =\n\t\t\thasInnerWrapper &&\n\t\t\tstyles.ToolsPanelWithInnerWrapper( DEFAULT_COLUMNS );\n\t\tconst emptyStyle =\n\t\t\t! hasDefaultMenuItems &&\n\t\t\tareAllOptionalControlsHidden &&\n\t\t\tstyles.ToolsPanelHiddenInnerWrapper;\n\n\t\treturn cx( styles.ToolsPanel, wrapperStyle, emptyStyle, className );\n\t}, [\n\t\tclassName,\n\t\thasInnerWrapper,\n\t\tmenuItems,\n\t\tareAllOptionalControlsHidden,\n\t] );\n\n\t// Toggle the checked state of a menu item which is then used to determine\n\t// display of the item within the panel.\n\tconst toggleItem = ( label: string ) => {\n\t\tconst currentItem = panelItems.find( ( item ) => item.label === label );\n\n\t\tif ( ! currentItem ) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst menuGroup = currentItem.isShownByDefault ? 'default' : 'optional';\n\n\t\tconst newMenuItems = {\n\t\t\t...menuItems,\n\t\t\t[ menuGroup ]: {\n\t\t\t\t...menuItems[ menuGroup ],\n\t\t\t\t[ label ]: ! menuItems[ menuGroup ][ label ],\n\t\t\t},\n\t\t};\n\n\t\tsetMenuItems( newMenuItems );\n\t};\n\n\tconst getResetAllFilters = () => {\n\t\tconst filters: Array< () => void > = [];\n\n\t\tpanelItems.forEach( ( item ) => {\n\t\t\tif ( item.resetAllFilter ) {\n\t\t\t\tfilters.push( item.resetAllFilter );\n\t\t\t}\n\t\t} );\n\t\treturn filters;\n\t};\n\n\t// Resets display of children and executes resetAll callback if available.\n\tconst resetAllItems = () => {\n\t\tif ( typeof resetAll === 'function' ) {\n\t\t\tisResetting.current = true;\n\t\t\tresetAll( getResetAllFilters() );\n\t\t}\n\n\t\t// Turn off display of all non-default items.\n\t\tconst resetMenuItems = generateMenuItems( {\n\t\t\tpanelItems,\n\t\t\tshouldReset: true,\n\t\t} );\n\t\tsetMenuItems( resetMenuItems );\n\t};\n\n\tconst panelContext = {\n\t\tpanelId,\n\t\tmenuItems,\n\t\tregisterPanelItem,\n\t\tderegisterPanelItem,\n\t\tflagItemCustomization,\n\t\tareAllOptionalControlsHidden,\n\t\thasMenuItems: !! panelItems.length,\n\t\tisResetting: isResetting.current,\n\t\tshouldRenderPlaceholderItems,\n\t};\n\n\treturn {\n\t\t...otherProps,\n\t\tpanelContext,\n\t\tresetAllItems,\n\t\ttoggleItem,\n\t\tclassName: classes,\n\t};\n}\n"]}
1
+ {"version":3,"sources":["@wordpress/components/src/tools-panel/tools-panel/hook.ts"],"names":["useCallback","useEffect","useMemo","useRef","useState","styles","useContextSystem","useCx","DEFAULT_COLUMNS","generateMenuItems","panelItems","shouldReset","currentMenuItems","menuItems","default","optional","forEach","hasValue","isShownByDefault","label","group","existingItemValue","value","undefined","isMenuItemTypeEmpty","obj","Object","keys","length","useToolsPanel","props","className","resetAll","panelId","hasInnerWrapper","shouldRenderPlaceholderItems","__experimentalFirstVisibleItemClass","__experimentalLastVisibleItemClass","otherProps","isResetting","wasResetting","current","setPanelItems","registerPanelItem","item","items","newItems","existingIndex","findIndex","oldItem","splice","deregisterPanelItem","index","setMenuItems","prevState","flagItemCustomization","newState","areAllOptionalControlsHidden","setAreAllOptionalControlsHidden","allControlsHidden","entries","some","isSelected","cx","classes","wrapperStyle","ToolsPanelWithInnerWrapper","emptyStyle","ToolsPanelHiddenInnerWrapper","ToolsPanel","toggleItem","currentItem","find","menuGroup","newMenuItems","resetAllItems","filters","resetAllFilter","push","resetMenuItems","getFirstVisibleItemLabel","optionalItems","firstItem","firstDisplayedItem","lastDisplayedItem","reverse","panelContext","hasMenuItems"],"mappings":"AAAA;AACA;AACA;AACA,SACCA,WADD,EAECC,SAFD,EAGCC,OAHD,EAICC,MAJD,EAKCC,QALD,QAMO,oBANP;AAQA;AACA;AACA;;AACA,OAAO,KAAKC,MAAZ,MAAwB,WAAxB;AACA,SAASC,gBAAT,QAA0D,kBAA1D;AACA,SAASC,KAAT,Q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K,CAAC2B,IAAN,CACf5B,IAAF,IAAYA,IAAI,CAAC1B,gBAAL,IAAyB,CAAC,CAAE+D,aAAa,CAAErC,IAAI,CAACzB,KAAP,CADpC,CAAlB;AAIA,WAAO+D,SAAP,aAAOA,SAAP,uBAAOA,SAAS,CAAE/D,KAAlB;AACA,GAPD;;AASA,QAAMgE,kBAAkB,GAAGH,wBAAwB,CAAEtE,UAAF,CAAnD;AACA,QAAM0E,iBAAiB,GAAGJ,wBAAwB,CACjD,CAAE,GAAGtE,UAAL,EAAkB2E,OAAlB,EADiD,CAAlD;AAIA,QAAMC,YAAY,GAAGpF,OAAO,CAC3B,OAAQ;AACPuD,IAAAA,4BADO;AAEPN,IAAAA,mBAFO;AAGPgC,IAAAA,kBAHO;AAIP5B,IAAAA,qBAJO;AAKPgC,IAAAA,YAAY,EAAE,CAAC,CAAE7E,UAAU,CAACkB,MALrB;AAMPW,IAAAA,WAAW,EAAEA,WAAW,CAACE,OANlB;AAOP2C,IAAAA,iBAPO;AAQPvE,IAAAA,SARO;AASPoB,IAAAA,OATO;AAUPU,IAAAA,iBAVO;AAWPR,IAAAA,4BAXO;AAYPC,IAAAA,mCAZO;AAaPC,IAAAA;AAbO,GAAR,CAD2B,EAgB3B,CACCoB,4BADD,EAECN,mBAFD,EAGCgC,kBAHD,EAIC5B,qBAJD,EAKChB,WAAW,CAACE,OALb,EAMC2C,iBAND,EAOCvE,SAPD,EAQCoB,OARD,EASCvB,UATD,EAUCiC,iBAVD,EAWCR,4BAXD,EAYCC,mCAZD,EAaCC,kCAbD,CAhB2B,CAA5B;AAiCA,SAAO,EACN,GAAGC,UADG;AAENgD,IAAAA,YAFM;AAGNX,IAAAA,aAHM;AAINL,IAAAA,UAJM;AAKNvC,IAAAA,SAAS,EAAEiC;AALL,GAAP;AAOA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport {\n\tuseCallback,\n\tuseEffect,\n\tuseMemo,\n\tuseRef,\n\tuseState,\n} from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport * as styles from '../styles';\nimport { useContextSystem, WordPressComponentProps } from '../../ui/context';\nimport { useCx } from '../../utils/hooks/use-cx';\nimport type {\n\tToolsPanelItem,\n\tToolsPanelMenuItemKey,\n\tToolsPanelMenuItems,\n\tToolsPanelMenuItemsConfig,\n\tToolsPanelProps,\n} from '../types';\n\nconst DEFAULT_COLUMNS = 2;\n\nconst generateMenuItems = ( {\n\tpanelItems,\n\tshouldReset,\n\tcurrentMenuItems,\n}: ToolsPanelMenuItemsConfig ) => {\n\tconst menuItems: ToolsPanelMenuItems = { default: {}, optional: {} };\n\n\tpanelItems.forEach( ( { hasValue, isShownByDefault, label } ) => {\n\t\tconst group = isShownByDefault ? 'default' : 'optional';\n\n\t\t// If a menu item for this label already exists, do not overwrite its value.\n\t\t// This can cause default controls that have been flagged as customized to\n\t\t// lose their value.\n\t\tconst existingItemValue = currentMenuItems?.[ group ]?.[ label ];\n\t\tconst value =\n\t\t\texistingItemValue !== undefined ? existingItemValue : hasValue();\n\n\t\tmenuItems[ group ][ label ] = shouldReset ? false : value;\n\t} );\n\n\treturn menuItems;\n};\n\nconst isMenuItemTypeEmpty = (\n\tobj?: ToolsPanelMenuItems[ ToolsPanelMenuItemKey ]\n) => obj && Object.keys( obj ).length === 0;\n\nexport function useToolsPanel(\n\tprops: WordPressComponentProps< ToolsPanelProps, 'div' >\n) {\n\tconst {\n\t\tclassName,\n\t\tresetAll,\n\t\tpanelId,\n\t\thasInnerWrapper,\n\t\tshouldRenderPlaceholderItems,\n\t\t__experimentalFirstVisibleItemClass,\n\t\t__experimentalLastVisibleItemClass,\n\t\t...otherProps\n\t} = useContextSystem( props, 'ToolsPanel' );\n\n\tconst isResetting = useRef( false );\n\tconst wasResetting = isResetting.current;\n\n\t// `isResetting` is cleared via this hook to effectively batch together\n\t// the resetAll task. Without this, the flag is cleared after the first\n\t// control updates and forces a rerender with subsequent controls then\n\t// believing they need to reset, unfortunately using stale data.\n\tuseEffect( () => {\n\t\tif ( wasResetting ) {\n\t\t\tisResetting.current = false;\n\t\t}\n\t}, [ wasResetting ] );\n\n\t// Allow panel items to register themselves.\n\tconst [ panelItems, setPanelItems ] = useState< ToolsPanelItem[] >( [] );\n\n\tconst registerPanelItem = useCallback(\n\t\t( item: ToolsPanelItem ) => {\n\t\t\tsetPanelItems( ( items ) => {\n\t\t\t\tconst newItems = [ ...items ];\n\t\t\t\t// If an item with this label has already been registered, remove it\n\t\t\t\t// first. This can happen when an item is moved between the default\n\t\t\t\t// and optional groups.\n\t\t\t\tconst existingIndex = newItems.findIndex(\n\t\t\t\t\t( oldItem ) => oldItem.label === item.label\n\t\t\t\t);\n\t\t\t\tif ( existingIndex !== -1 ) {\n\t\t\t\t\tnewItems.splice( existingIndex, 1 );\n\t\t\t\t}\n\t\t\t\treturn [ ...newItems, item ];\n\t\t\t} );\n\t\t},\n\t\t[ setPanelItems ]\n\t);\n\n\t// Panels need to deregister on unmount to avoid orphans in menu state.\n\t// This is an issue when panel items are being injected via SlotFills.\n\tconst deregisterPanelItem = useCallback(\n\t\t( label: string ) => {\n\t\t\t// When switching selections between components injecting matching\n\t\t\t// controls, e.g. both panels have a \"padding\" control, the\n\t\t\t// deregistration of the first panel doesn't occur until after the\n\t\t\t// registration of the next.\n\t\t\tsetPanelItems( ( items ) => {\n\t\t\t\tconst newItems = [ ...items ];\n\t\t\t\tconst index = newItems.findIndex(\n\t\t\t\t\t( item ) => item.label === label\n\t\t\t\t);\n\t\t\t\tif ( index !== -1 ) {\n\t\t\t\t\tnewItems.splice( index, 1 );\n\t\t\t\t}\n\t\t\t\treturn newItems;\n\t\t\t} );\n\t\t},\n\t\t[ setPanelItems ]\n\t);\n\n\t// Manage and share display state of menu items representing child controls.\n\tconst [ menuItems, setMenuItems ] = useState< ToolsPanelMenuItems >( {\n\t\tdefault: {},\n\t\toptional: {},\n\t} );\n\n\t// Setup menuItems state as panel items register themselves.\n\tuseEffect( () => {\n\t\tsetMenuItems( ( prevState ) => {\n\t\t\tconst items = generateMenuItems( {\n\t\t\t\tpanelItems,\n\t\t\t\tshouldReset: false,\n\t\t\t\tcurrentMenuItems: prevState,\n\t\t\t} );\n\t\t\treturn items;\n\t\t} );\n\t}, [ generateMenuItems, panelItems, setMenuItems ] );\n\n\t// Force a menu item to be checked.\n\t// This is intended for use with default panel items. They are displayed\n\t// separately to optional items and have different display states,\n\t// we need to update that when their value is customized.\n\tconst flagItemCustomization = useCallback(\n\t\t( label: string, group: ToolsPanelMenuItemKey = 'default' ) => {\n\t\t\tsetMenuItems( ( items ) => {\n\t\t\t\tconst newState = {\n\t\t\t\t\t...items,\n\t\t\t\t\t[ group ]: {\n\t\t\t\t\t\t...items[ group ],\n\t\t\t\t\t\t[ label ]: true,\n\t\t\t\t\t},\n\t\t\t\t};\n\t\t\t\treturn newState;\n\t\t\t} );\n\t\t},\n\t\t[ setMenuItems ]\n\t);\n\n\t// Whether all optional menu items are hidden or not must be tracked\n\t// in order to later determine if the panel display is empty and handle\n\t// conditional display of a plus icon to indicate the presence of further\n\t// menu items.\n\tconst [\n\t\tareAllOptionalControlsHidden,\n\t\tsetAreAllOptionalControlsHidden,\n\t] = useState( false );\n\n\tuseEffect( () => {\n\t\tif (\n\t\t\tisMenuItemTypeEmpty( menuItems?.default ) &&\n\t\t\t! isMenuItemTypeEmpty( menuItems?.optional )\n\t\t) {\n\t\t\tconst allControlsHidden = ! Object.entries(\n\t\t\t\tmenuItems.optional\n\t\t\t).some( ( [ , isSelected ] ) => isSelected );\n\t\t\tsetAreAllOptionalControlsHidden( allControlsHidden );\n\t\t}\n\t}, [ menuItems, setAreAllOptionalControlsHidden ] );\n\n\tconst cx = useCx();\n\tconst classes = useMemo( () => {\n\t\tconst wrapperStyle =\n\t\t\thasInnerWrapper &&\n\t\t\tstyles.ToolsPanelWithInnerWrapper( DEFAULT_COLUMNS );\n\t\tconst emptyStyle =\n\t\t\tisMenuItemTypeEmpty( menuItems?.default ) &&\n\t\t\tareAllOptionalControlsHidden &&\n\t\t\tstyles.ToolsPanelHiddenInnerWrapper;\n\n\t\treturn cx( styles.ToolsPanel, wrapperStyle, emptyStyle, className );\n\t}, [\n\t\tareAllOptionalControlsHidden,\n\t\tclassName,\n\t\tcx,\n\t\thasInnerWrapper,\n\t\tmenuItems,\n\t] );\n\n\t// Toggle the checked state of a menu item which is then used to determine\n\t// display of the item within the panel.\n\tconst toggleItem = useCallback(\n\t\t( label: string ) => {\n\t\t\tconst currentItem = panelItems.find(\n\t\t\t\t( item ) => item.label === label\n\t\t\t);\n\n\t\t\tif ( ! currentItem ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst menuGroup = currentItem.isShownByDefault\n\t\t\t\t? 'default'\n\t\t\t\t: 'optional';\n\n\t\t\tconst newMenuItems = {\n\t\t\t\t...menuItems,\n\t\t\t\t[ menuGroup ]: {\n\t\t\t\t\t...menuItems[ menuGroup ],\n\t\t\t\t\t[ label ]: ! menuItems[ menuGroup ][ label ],\n\t\t\t\t},\n\t\t\t};\n\n\t\t\tsetMenuItems( newMenuItems );\n\t\t},\n\t\t[ menuItems, panelItems, setMenuItems ]\n\t);\n\n\t// Resets display of children and executes resetAll callback if available.\n\tconst resetAllItems = useCallback( () => {\n\t\tif ( typeof resetAll === 'function' ) {\n\t\t\tisResetting.current = true;\n\n\t\t\t// Collect available reset filters from panel items.\n\t\t\tconst filters: Array< () => void > = [];\n\t\t\tpanelItems.forEach( ( item ) => {\n\t\t\t\tif ( item.resetAllFilter ) {\n\t\t\t\t\tfilters.push( item.resetAllFilter );\n\t\t\t\t}\n\t\t\t} );\n\n\t\t\tresetAll( filters );\n\t\t}\n\n\t\t// Turn off display of all non-default items.\n\t\tconst resetMenuItems = generateMenuItems( {\n\t\t\tpanelItems,\n\t\t\tshouldReset: true,\n\t\t} );\n\t\tsetMenuItems( resetMenuItems );\n\t}, [\n\t\tgenerateMenuItems,\n\t\tisResetting.current,\n\t\tpanelItems,\n\t\tresetAll,\n\t\tsetMenuItems,\n\t] );\n\n\t// Assist ItemGroup styling when there are potentially hidden placeholder\n\t// items by identifying first & last items that are toggled on for display.\n\tconst getFirstVisibleItemLabel = ( items: ToolsPanelItem[] ) => {\n\t\tconst optionalItems = menuItems.optional || {};\n\t\tconst firstItem = items.find(\n\t\t\t( item ) => item.isShownByDefault || !! optionalItems[ item.label ]\n\t\t);\n\n\t\treturn firstItem?.label;\n\t};\n\n\tconst firstDisplayedItem = getFirstVisibleItemLabel( panelItems );\n\tconst lastDisplayedItem = getFirstVisibleItemLabel(\n\t\t[ ...panelItems ].reverse()\n\t);\n\n\tconst panelContext = useMemo(\n\t\t() => ( {\n\t\t\tareAllOptionalControlsHidden,\n\t\t\tderegisterPanelItem,\n\t\t\tfirstDisplayedItem,\n\t\t\tflagItemCustomization,\n\t\t\thasMenuItems: !! panelItems.length,\n\t\t\tisResetting: isResetting.current,\n\t\t\tlastDisplayedItem,\n\t\t\tmenuItems,\n\t\t\tpanelId,\n\t\t\tregisterPanelItem,\n\t\t\tshouldRenderPlaceholderItems,\n\t\t\t__experimentalFirstVisibleItemClass,\n\t\t\t__experimentalLastVisibleItemClass,\n\t\t} ),\n\t\t[\n\t\t\tareAllOptionalControlsHidden,\n\t\t\tderegisterPanelItem,\n\t\t\tfirstDisplayedItem,\n\t\t\tflagItemCustomization,\n\t\t\tisResetting.current,\n\t\t\tlastDisplayedItem,\n\t\t\tmenuItems,\n\t\t\tpanelId,\n\t\t\tpanelItems,\n\t\t\tregisterPanelItem,\n\t\t\tshouldRenderPlaceholderItems,\n\t\t\t__experimentalFirstVisibleItemClass,\n\t\t\t__experimentalLastVisibleItemClass,\n\t\t]\n\t);\n\n\treturn {\n\t\t...otherProps,\n\t\tpanelContext,\n\t\tresetAllItems,\n\t\ttoggleItem,\n\t\tclassName: classes,\n\t};\n}\n"]}
@@ -4,7 +4,6 @@ import { createElement, Fragment } from "@wordpress/element";
4
4
  /**
5
5
  * External dependencies
6
6
  */
7
- // eslint-disable-next-line no-restricted-imports
8
7
 
9
8
  /**
10
9
  * WordPress dependencies
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/components/src/tools-panel/tools-panel-header/component.tsx"],"names":["check","reset","moreVertical","plus","__","_x","sprintf","DropdownMenu","MenuGroup","MenuItem","HStack","Heading","useToolsPanelHeader","contextConnect","noop","DefaultControlsGroup","items","onClose","toggleItem","length","map","label","hasValue","icon","itemLabel","undefined","OptionalControlsGroup","isSelected","ToolsPanelHeader","props","forwardedRef","areAllOptionalControlsHidden","dropdownMenuClassName","hasMenuItems","headingClassName","labelText","menuItems","resetAll","headerProps","defaultItems","Object","entries","default","optionalItems","optional","dropDownMenuIcon","dropDownMenuLabelText","className","isSmall","ConnectedToolsPanelHeader"],"mappings":";;;AAAA;AACA;AACA;AACA;;AAGA;AACA;AACA;AACA,SAASA,KAAT,EAAgBC,KAAhB,EAAuBC,YAAvB,EAAqCC,IAArC,QAAiD,kBAAjD;AACA,SAASC,EAAT,EAAaC,EAAb,EAAiBC,OAAjB,QAAgC,iBAAhC;AAEA;AACA;AACA;;AACA,OAAOC,YAAP,MAAyB,qBAAzB;AACA,OAAOC,SAAP,MAAsB,kBAAtB;AACA,OAAOC,QAAP,MAAqB,iBAArB;AACA,SAASC,MAAT,QAAuB,eAAvB;AACA,SAASC,OAAT,QAAwB,eAAxB;AACA,SAASC,mBAAT,QAAoC,QAApC;AACA,SAASC,cAAT,QAAwD,kBAAxD;;AAMA,MAAMC,IAAI,GAAG,MAAM,CAAE,CAArB;;AAEA,MAAMC,oBAAoB,GAAG,QAIQ;AAAA,MAJN;AAC9BC,IAAAA,KAD8B;AAE9BC,IAAAA,OAF8B;AAG9BC,IAAAA;AAH8B,GAIM;;AACpC,MAAK,CAAEF,KAAK,CAACG,MAAb,EAAsB;AACrB,WAAO,IAAP;AACA;;AAED,SACC,cAAC,SAAD,QACGH,KAAK,CAACI,GAAN,CAAW,SAA2B;AAAA,QAAzB,CAAEC,KAAF,EAASC,QAAT,CAAyB;AACvC,UAAMC,IAAI,GAAGD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AS,EAAG;AAAEC,MAAAA,SAAS,EAAEf;AAAb,KAHb;AAIC,IAAA,WAAW,EAAG;AAAEgB,MAAAA,OAAO,EAAE;AAAX;AAJf,KAMG;AAAA,QAAE;AAAE/B,MAAAA,OAAO,GAAGH;AAAZ,KAAF;AAAA,WACD,8BACC,cAAC,oBAAD;AACC,MAAA,KAAK,EAAGyB,YADT;AAEC,MAAA,OAAO,EAAGtB,OAFX;AAGC,MAAA,UAAU,EAAGC;AAHd,MADD,EAMC,cAAC,qBAAD;AACC,MAAA,KAAK,EAAGyB,aADT;AAEC,MAAA,OAAO,EAAG1B,OAFX;AAGC,MAAA,UAAU,EAAGC;AAHd,MAND,EAWC,cAAC,SAAD,QACC,cAAC,QAAD;AACC,MAAA,OAAO,EAAG,UADX;AAEC,MAAA,OAAO,EAAG,MAAM;AACfmB,QAAAA,QAAQ;AACRpB,QAAAA,OAAO;AACP;AALF,OAOGb,EAAE,CAAE,WAAF,CAPL,CADD,CAXD,CADC;AAAA,GANH,CALF,CADD;AAyCA,CAvED;;AAyEA,MAAM6C,yBAAyB,GAAGpC,cAAc,CAC/Ce,gBAD+C,EAE/C,kBAF+C,CAAhD;AAKA,eAAeqB,yBAAf","sourcesContent":["/**\n * External dependencies\n */\n// eslint-disable-next-line no-restricted-imports\nimport type { Ref } from 'react';\n\n/**\n * WordPress dependencies\n */\nimport { check, reset, 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 { contextConnect, WordPressComponentProps } from '../../ui/context';\nimport type {\n\tToolsPanelControlsGroupProps,\n\tToolsPanelHeaderProps,\n} from '../types';\n\nconst noop = () => {};\n\nconst DefaultControlsGroup = ( {\n\titems,\n\tonClose,\n\ttoggleItem,\n}: ToolsPanelControlsGroupProps ) => {\n\tif ( ! items.length ) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<MenuGroup>\n\t\t\t{ items.map( ( [ label, hasValue ] ) => {\n\t\t\t\tconst icon = hasValue ? reset : check;\n\t\t\t\tconst itemLabel = hasValue\n\t\t\t\t\t? sprintf(\n\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__( 'Reset %s' ),\n\t\t\t\t\t\t\tlabel\n\t\t\t\t\t )\n\t\t\t\t\t: undefined;\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={ icon }\n\t\t\t\t\t\tisSelected={ true }\n\t\t\t\t\t\tdisabled={ ! hasValue }\n\t\t\t\t\t\tlabel={ itemLabel }\n\t\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\t\ttoggleItem( label );\n\t\t\t\t\t\t\tonClose();\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 OptionalControlsGroup = ( {\n\titems,\n\tonClose,\n\ttoggleItem,\n}: ToolsPanelControlsGroupProps ) => {\n\tif ( ! items.length ) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<MenuGroup>\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 }\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\ttoggleItem( label );\n\t\t\t\t\t\t\tonClose();\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: Ref< any >\n) => {\n\tconst {\n\t\tareAllOptionalControlsHidden,\n\t\tdropdownMenuClassName,\n\t\thasMenuItems,\n\t\theadingClassName,\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 = areAllOptionalControlsHidden\n\t\t? _x(\n\t\t\t\t'View and add options',\n\t\t\t\t'Button label to reveal tool panel options'\n\t\t )\n\t\t: _x( 'View options', 'Button label to reveal tool panel options' );\n\n\treturn (\n\t\t<HStack { ...headerProps } ref={ forwardedRef }>\n\t\t\t<Heading level={ 2 } 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={ { isSmall: true } }\n\t\t\t\t>\n\t\t\t\t\t{ ( { onClose = noop } ) => (\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\tonClose={ onClose }\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<OptionalControlsGroup\n\t\t\t\t\t\t\t\titems={ optionalItems }\n\t\t\t\t\t\t\t\tonClose={ onClose }\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\tvariant={ 'tertiary' }\n\t\t\t\t\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\t\t\t\t\tresetAll();\n\t\t\t\t\t\t\t\t\t\tonClose();\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"]}
1
+ {"version":3,"sources":["@wordpress/components/src/tools-panel/tools-panel-header/component.tsx"],"names":["check","reset","moreVertical","plus","__","_x","sprintf","DropdownMenu","MenuGroup","MenuItem","HStack","Heading","useToolsPanelHeader","contextConnect","noop","DefaultControlsGroup","items","onClose","toggleItem","length","map","label","hasValue","icon","itemLabel","undefined","OptionalControlsGroup","isSelected","ToolsPanelHeader","props","forwardedRef","areAllOptionalControlsHidden","dropdownMenuClassName","hasMenuItems","headingClassName","labelText","menuItems","resetAll","headerProps","defaultItems","Object","entries","default","optionalItems","optional","dropDownMenuIcon","dropDownMenuLabelText","className","isSmall","ConnectedToolsPanelHeader"],"mappings":";;;AAAA;AACA;AACA;;AAGA;AACA;AACA;AACA,SAASA,KAAT,EAAgBC,KAAhB,EAAuBC,YAAvB,EAAqCC,IAArC,QAAiD,kBAAjD;AACA,SAASC,EAAT,EAAaC,EAAb,EAAiBC,OAAjB,QAAgC,iBAAhC;AAEA;AACA;AACA;;AACA,OAAOC,YAAP,MAAyB,qBAAzB;AACA,OAAOC,SAAP,MAAsB,kBAAtB;AACA,OAAOC,QAAP,MAAqB,iBAArB;AACA,SAASC,MAAT,QAAuB,eAAvB;AACA,SAASC,OAAT,QAAwB,eAAxB;AACA,SAASC,mBAAT,QAAoC,QAApC;AACA,SAASC,cAAT,QAAwD,kBAAxD;;AAMA,MAAMC,IAAI,GAAG,MAAM,CAAE,CAArB;;AAEA,MAAMC,oBAAoB,GAAG,QAIQ;AAAA,MAJN;AAC9BC,IAAAA,KAD8B;AAE9BC,IAAAA,OAF8B;AAG9BC,IAAAA;AAH8B,GAIM;;AACpC,MAAK,CAAEF,KAAK,CAACG,MAAb,EAAsB;AACrB,WAAO,IAAP;AACA;;AAED,SACC,cAAC,SAAD,QACGH,KAAK,CAACI,GAAN,CAAW,SAA2B;AAAA,QAAzB,CAAEC,KAAF,EAASC,QAAT,CAAyB;AACvC,UAAMC,IAAI,GAAGD,QAAQ,GAAGrB,KAAH,GAAWD,KAAhC;AACA,UAAMwB,SAAS,GAAGF,QAAQ,GACvBhB,OAAO,EACP;AACAF,IAAAA,EAAE,CAAE,UAAF,CAFK,EAGPiB,KAHO,CADgB,GAMvBI,SANH;AAQA,WACC,cAAC,QAAD;AACC,MAAA,GAAG,EAAGJ,KADP;AAEC,MAAA,IAAI,EAAGE,IA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AA,OAAO,EAAGtB,OAFX;AAGC,MAAA,UAAU,EAAGC;AAHd,MADD,EAMC,cAAC,qBAAD;AACC,MAAA,KAAK,EAAGyB,aADT;AAEC,MAAA,OAAO,EAAG1B,OAFX;AAGC,MAAA,UAAU,EAAGC;AAHd,MAND,EAWC,cAAC,SAAD,QACC,cAAC,QAAD;AACC,MAAA,OAAO,EAAG,UADX;AAEC,MAAA,OAAO,EAAG,MAAM;AACfmB,QAAAA,QAAQ;AACRpB,QAAAA,OAAO;AACP;AALF,OAOGb,EAAE,CAAE,WAAF,CAPL,CADD,CAXD,CADC;AAAA,GANH,CALF,CADD;AAyCA,CAvED;;AAyEA,MAAM6C,yBAAyB,GAAGpC,cAAc,CAC/Ce,gBAD+C,EAE/C,kBAF+C,CAAhD;AAKA,eAAeqB,yBAAf","sourcesContent":["/**\n * External dependencies\n */\nimport type { Ref } from 'react';\n\n/**\n * WordPress dependencies\n */\nimport { check, reset, 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 { contextConnect, WordPressComponentProps } from '../../ui/context';\nimport type {\n\tToolsPanelControlsGroupProps,\n\tToolsPanelHeaderProps,\n} from '../types';\n\nconst noop = () => {};\n\nconst DefaultControlsGroup = ( {\n\titems,\n\tonClose,\n\ttoggleItem,\n}: ToolsPanelControlsGroupProps ) => {\n\tif ( ! items.length ) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<MenuGroup>\n\t\t\t{ items.map( ( [ label, hasValue ] ) => {\n\t\t\t\tconst icon = hasValue ? reset : check;\n\t\t\t\tconst itemLabel = hasValue\n\t\t\t\t\t? sprintf(\n\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__( 'Reset %s' ),\n\t\t\t\t\t\t\tlabel\n\t\t\t\t\t )\n\t\t\t\t\t: undefined;\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={ icon }\n\t\t\t\t\t\tisSelected={ true }\n\t\t\t\t\t\tdisabled={ ! hasValue }\n\t\t\t\t\t\tlabel={ itemLabel }\n\t\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\t\ttoggleItem( label );\n\t\t\t\t\t\t\tonClose();\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 OptionalControlsGroup = ( {\n\titems,\n\tonClose,\n\ttoggleItem,\n}: ToolsPanelControlsGroupProps ) => {\n\tif ( ! items.length ) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<MenuGroup>\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 }\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\ttoggleItem( label );\n\t\t\t\t\t\t\tonClose();\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: Ref< any >\n) => {\n\tconst {\n\t\tareAllOptionalControlsHidden,\n\t\tdropdownMenuClassName,\n\t\thasMenuItems,\n\t\theadingClassName,\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 = areAllOptionalControlsHidden\n\t\t? _x(\n\t\t\t\t'View and add options',\n\t\t\t\t'Button label to reveal tool panel options'\n\t\t )\n\t\t: _x( 'View options', 'Button label to reveal tool panel options' );\n\n\treturn (\n\t\t<HStack { ...headerProps } ref={ forwardedRef }>\n\t\t\t<Heading level={ 2 } 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={ { isSmall: true } }\n\t\t\t\t>\n\t\t\t\t\t{ ( { onClose = noop } ) => (\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\tonClose={ onClose }\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<OptionalControlsGroup\n\t\t\t\t\t\t\t\titems={ optionalItems }\n\t\t\t\t\t\t\t\tonClose={ onClose }\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\tvariant={ 'tertiary' }\n\t\t\t\t\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\t\t\t\t\tresetAll();\n\t\t\t\t\t\t\t\t\t\tonClose();\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"]}
@@ -18,13 +18,13 @@ export function useToolsPanelHeader(props) {
18
18
  const cx = useCx();
19
19
  const classes = useMemo(() => {
20
20
  return cx(styles.ToolsPanelHeader, className);
21
- }, [className]);
21
+ }, [className, cx]);
22
22
  const dropdownMenuClassName = useMemo(() => {
23
23
  return cx(styles.DropdownMenu);
24
- }, []);
24
+ }, [cx]);
25
25
  const headingClassName = useMemo(() => {
26
26
  return cx(styles.ToolsPanelHeading);
27
- }, []);
27
+ }, [cx]);
28
28
  const {
29
29
  menuItems,
30
30
  hasMenuItems,
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/components/src/tools-panel/tools-panel-header/hook.ts"],"names":["useMemo","styles","useToolsPanelContext","useContextSystem","useCx","useToolsPanelHeader","props","className","otherProps","cx","classes","ToolsPanelHeader","dropdownMenuClassName","DropdownMenu","headingClassName","ToolsPanelHeading","menuItems","hasMenuItems","areAllOptionalControlsHidden"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,OAAT,QAAwB,oBAAxB;AAEA;AACA;AACA;;AACA,OAAO,KAAKC,MAAZ,MAAwB,WAAxB;AACA,SAASC,oBAAT,QAAqC,YAArC;AACA,SAASC,gBAAT,QAA0D,kBAA1D;AACA,SAASC,KAAT,QAAsB,0BAAtB;AAGA,OAAO,SAASC,mBAAT,CACNC,KADM,EAEL;AACD,QAAM;AAAEC,IAAAA,SAAF;AAAa,OAAGC;AAAhB,MAA+BL,gBAAgB,CACpDG,KADoD,EAEpD,kBAFoD,CAArD;AAKA,QAAMG,EAAE,GAAGL,KAAK,EAAhB;AACA,QAAMM,OAAO,GAAGV,OAAO,CAAE,MAAM;AAC9B,WAAOS,EAAE,CAAER,MAAM,CAACU,gBAAT,EAA2BJ,SAA3B,CAAT;AACA,GAFsB,EAEpB,CAAEA,SAAF,CAFoB,CAAvB;AAIA,QAAMK,qBAAqB,GAAGZ,OAAO,CAAE,MAAM;AAC5C,WAAOS,EAAE,CAAER,MAAM,CAACY,YAAT,CAAT;AACA,GAFoC,EAElC,EAFkC,CAArC;AAIA,QAAMC,gBAAgB,GAAGd,OAAO,CAAE,MAAM;AACvC,WAAOS,EAAE,CAAER,MAAM,CAACc,iBAAT,CAAT;AACA,GAF+B,EAE7B,EAF6B,CAAhC;AAIA,QAAM;AACLC,IAAAA,SADK;AAELC,IAAAA,YAFK;AAGLC,IAAAA;AAHK,MAIFhB,oBAAoB,EAJxB;AAMA,SAAO,EACN,GAAGM,UADG;AAENU,IAAAA,4BAFM;AAGNN,IAAAA,qBAHM;AAINK,IAAAA,YAJM;AAKNH,IAAAA,gBALM;AAMNE,IAAAA,SANM;AAONT,IAAAA,SAAS,EAAEG;AAPL,GAAP;AASA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useMemo } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport * as styles from '../styles';\nimport { useToolsPanelContext } from '../context';\nimport { useContextSystem, WordPressComponentProps } from '../../ui/context';\nimport { useCx } from '../../utils/hooks/use-cx';\nimport type { ToolsPanelHeaderProps } from '../types';\n\nexport function useToolsPanelHeader(\n\tprops: WordPressComponentProps< ToolsPanelHeaderProps, 'h2' >\n) {\n\tconst { className, ...otherProps } = useContextSystem(\n\t\tprops,\n\t\t'ToolsPanelHeader'\n\t);\n\n\tconst cx = useCx();\n\tconst classes = useMemo( () => {\n\t\treturn cx( styles.ToolsPanelHeader, className );\n\t}, [ className ] );\n\n\tconst dropdownMenuClassName = useMemo( () => {\n\t\treturn cx( styles.DropdownMenu );\n\t}, [] );\n\n\tconst headingClassName = useMemo( () => {\n\t\treturn cx( styles.ToolsPanelHeading );\n\t}, [] );\n\n\tconst {\n\t\tmenuItems,\n\t\thasMenuItems,\n\t\tareAllOptionalControlsHidden,\n\t} = useToolsPanelContext();\n\n\treturn {\n\t\t...otherProps,\n\t\tareAllOptionalControlsHidden,\n\t\tdropdownMenuClassName,\n\t\thasMenuItems,\n\t\theadingClassName,\n\t\tmenuItems,\n\t\tclassName: classes,\n\t};\n}\n"]}
1
+ {"version":3,"sources":["@wordpress/components/src/tools-panel/tools-panel-header/hook.ts"],"names":["useMemo","styles","useToolsPanelContext","useContextSystem","useCx","useToolsPanelHeader","props","className","otherProps","cx","classes","ToolsPanelHeader","dropdownMenuClassName","DropdownMenu","headingClassName","ToolsPanelHeading","menuItems","hasMenuItems","areAllOptionalControlsHidden"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,OAAT,QAAwB,oBAAxB;AAEA;AACA;AACA;;AACA,OAAO,KAAKC,MAAZ,MAAwB,WAAxB;AACA,SAASC,oBAAT,QAAqC,YAArC;AACA,SAASC,gBAAT,QAA0D,kBAA1D;AACA,SAASC,KAAT,QAAsB,0BAAtB;AAGA,OAAO,SAASC,mBAAT,CACNC,KADM,EAEL;AACD,QAAM;AAAEC,IAAAA,SAAF;AAAa,OAAGC;AAAhB,MAA+BL,gBAAgB,CACpDG,KADoD,EAEpD,kBAFoD,CAArD;AAKA,QAAMG,EAAE,GAAGL,KAAK,EAAhB;AACA,QAAMM,OAAO,GAAGV,OAAO,CAAE,MAAM;AAC9B,WAAOS,EAAE,CAAER,MAAM,CAACU,gBAAT,EAA2BJ,SAA3B,CAAT;AACA,GAFsB,EAEpB,CAAEA,SAAF,EAAaE,EAAb,CAFoB,CAAvB;AAIA,QAAMG,qBAAqB,GAAGZ,OAAO,CAAE,MAAM;AAC5C,WAAOS,EAAE,CAAER,MAAM,CAACY,YAAT,CAAT;AACA,GAFoC,EAElC,CAAEJ,EAAF,CAFkC,CAArC;AAIA,QAAMK,gBAAgB,GAAGd,OAAO,CAAE,MAAM;AACvC,WAAOS,EAAE,CAAER,MAAM,CAACc,iBAAT,CAAT;AACA,GAF+B,EAE7B,CAAEN,EAAF,CAF6B,CAAhC;AAIA,QAAM;AACLO,IAAAA,SADK;AAELC,IAAAA,YAFK;AAGLC,IAAAA;AAHK,MAIFhB,oBAAoB,EAJxB;AAMA,SAAO,EACN,GAAGM,UADG;AAENU,IAAAA,4BAFM;AAGNN,IAAAA,qBAHM;AAINK,IAAAA,YAJM;AAKNH,IAAAA,gBALM;AAMNE,IAAAA,SANM;AAONT,IAAAA,SAAS,EAAEG;AAPL,GAAP;AASA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useMemo } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport * as styles from '../styles';\nimport { useToolsPanelContext } from '../context';\nimport { useContextSystem, WordPressComponentProps } from '../../ui/context';\nimport { useCx } from '../../utils/hooks/use-cx';\nimport type { ToolsPanelHeaderProps } from '../types';\n\nexport function useToolsPanelHeader(\n\tprops: WordPressComponentProps< ToolsPanelHeaderProps, 'h2' >\n) {\n\tconst { className, ...otherProps } = useContextSystem(\n\t\tprops,\n\t\t'ToolsPanelHeader'\n\t);\n\n\tconst cx = useCx();\n\tconst classes = useMemo( () => {\n\t\treturn cx( styles.ToolsPanelHeader, className );\n\t}, [ className, cx ] );\n\n\tconst dropdownMenuClassName = useMemo( () => {\n\t\treturn cx( styles.DropdownMenu );\n\t}, [ cx ] );\n\n\tconst headingClassName = useMemo( () => {\n\t\treturn cx( styles.ToolsPanelHeading );\n\t}, [ cx ] );\n\n\tconst {\n\t\tmenuItems,\n\t\thasMenuItems,\n\t\tareAllOptionalControlsHidden,\n\t} = useToolsPanelContext();\n\n\treturn {\n\t\t...otherProps,\n\t\tareAllOptionalControlsHidden,\n\t\tdropdownMenuClassName,\n\t\thasMenuItems,\n\t\theadingClassName,\n\t\tmenuItems,\n\t\tclassName: classes,\n\t};\n}\n"]}
@@ -4,7 +4,6 @@ import { createElement } from "@wordpress/element";
4
4
  /**
5
5
  * External dependencies
6
6
  */
7
- // eslint-disable-next-line no-restricted-imports
8
7
 
9
8
  /**
10
9
  * Internal dependencies
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/components/src/tools-panel/tools-panel-item/component.tsx"],"names":["useToolsPanelItem","View","contextConnect","ToolsPanelItem","props","forwardedRef","children","isShown","shouldRenderPlaceholder","toolsPanelItemProps","ConnectedToolsPanelItem"],"mappings":";;;AAAA;AACA;AACA;AACA;;AAGA;AACA;AACA;AACA,SAASA,iBAAT,QAAkC,QAAlC;AACA,SAASC,IAAT,QAAqB,YAArB;AACA,SAASC,cAAT,QAAwD,kBAAxD;;AAGA;AACA;AACA,MAAMC,cAAc,GAAG,CACtBC,KADsB,EAEtBC,YAFsB,KAGlB;AACJ,QAAM;AACLC,IAAAA,QADK;AAELC,IAAAA,OAFK;AAGLC,IAAAA,uBAHK;AAIL,OAAGC;AAJE,MAKFT,iBAAiB,CAAEI,KAAF,CALrB;;AAOA,MAAK,CAAEG,OAAP,EAAiB;AAChB,WAAOC,uBAAuB,GAC7B,cAAC,IAAD,eAAWC,mBAAX;AAAiC,MAAA,GAAG,EAAGJ;AAAvC,OAD6B,GAE1B,IAFJ;AAGA;;AAED,SACC,cAAC,IAAD,eAAWI,mBAAX;AAAiC,IAAA,GAAG,EAAGJ;AAAvC,MACGC,QADH,CADD;AAKA,CAtBD;;AAwBA,MAAMI,uBAAuB,GAAGR,cAAc,CAC7CC,cAD6C,EAE7C,gBAF6C,CAA9C;AAKA,eAAeO,uBAAf","sourcesContent":["/**\n * External dependencies\n */\n// eslint-disable-next-line no-restricted-imports\nimport type { Ref } from 'react';\n\n/**\n * Internal dependencies\n */\nimport { useToolsPanelItem } from './hook';\nimport { View } from '../../view';\nimport { contextConnect, WordPressComponentProps } from '../../ui/context';\nimport type { ToolsPanelItemProps } from '../types';\n\n// This wraps controls to be conditionally displayed within a tools panel. It\n// prevents props being applied to HTML elements that would make them invalid.\nconst ToolsPanelItem = (\n\tprops: WordPressComponentProps< ToolsPanelItemProps, 'div' >,\n\tforwardedRef: Ref< any >\n) => {\n\tconst {\n\t\tchildren,\n\t\tisShown,\n\t\tshouldRenderPlaceholder,\n\t\t...toolsPanelItemProps\n\t} = useToolsPanelItem( props );\n\n\tif ( ! isShown ) {\n\t\treturn shouldRenderPlaceholder ? (\n\t\t\t<View { ...toolsPanelItemProps } ref={ forwardedRef } />\n\t\t) : null;\n\t}\n\n\treturn (\n\t\t<View { ...toolsPanelItemProps } ref={ forwardedRef }>\n\t\t\t{ children }\n\t\t</View>\n\t);\n};\n\nconst ConnectedToolsPanelItem = contextConnect(\n\tToolsPanelItem,\n\t'ToolsPanelItem'\n);\n\nexport default ConnectedToolsPanelItem;\n"]}
1
+ {"version":3,"sources":["@wordpress/components/src/tools-panel/tools-panel-item/component.tsx"],"names":["useToolsPanelItem","View","contextConnect","ToolsPanelItem","props","forwardedRef","children","isShown","shouldRenderPlaceholder","toolsPanelItemProps","ConnectedToolsPanelItem"],"mappings":";;;AAAA;AACA;AACA;;AAGA;AACA;AACA;AACA,SAASA,iBAAT,QAAkC,QAAlC;AACA,SAASC,IAAT,QAAqB,YAArB;AACA,SAASC,cAAT,QAAwD,kBAAxD;;AAGA;AACA;AACA,MAAMC,cAAc,GAAG,CACtBC,KADsB,EAEtBC,YAFsB,KAGlB;AACJ,QAAM;AACLC,IAAAA,QADK;AAELC,IAAAA,OAFK;AAGLC,IAAAA,uBAHK;AAIL,OAAGC;AAJE,MAKFT,iBAAiB,CAAEI,KAAF,CALrB;;AAOA,MAAK,CAAEG,OAAP,EAAiB;AAChB,WAAOC,uBAAuB,GAC7B,cAAC,IAAD,eAAWC,mBAAX;AAAiC,MAAA,GAAG,EAAGJ;AAAvC,OAD6B,GAE1B,IAFJ;AAGA;;AAED,SACC,cAAC,IAAD,eAAWI,mBAAX;AAAiC,IAAA,GAAG,EAAGJ;AAAvC,MACGC,QADH,CADD;AAKA,CAtBD;;AAwBA,MAAMI,uBAAuB,GAAGR,cAAc,CAC7CC,cAD6C,EAE7C,gBAF6C,CAA9C;AAKA,eAAeO,uBAAf","sourcesContent":["/**\n * External dependencies\n */\nimport type { Ref } from 'react';\n\n/**\n * Internal dependencies\n */\nimport { useToolsPanelItem } from './hook';\nimport { View } from '../../view';\nimport { contextConnect, WordPressComponentProps } from '../../ui/context';\nimport type { ToolsPanelItemProps } from '../types';\n\n// This wraps controls to be conditionally displayed within a tools panel. It\n// prevents props being applied to HTML elements that would make them invalid.\nconst ToolsPanelItem = (\n\tprops: WordPressComponentProps< ToolsPanelItemProps, 'div' >,\n\tforwardedRef: Ref< any >\n) => {\n\tconst {\n\t\tchildren,\n\t\tisShown,\n\t\tshouldRenderPlaceholder,\n\t\t...toolsPanelItemProps\n\t} = useToolsPanelItem( props );\n\n\tif ( ! isShown ) {\n\t\treturn shouldRenderPlaceholder ? (\n\t\t\t<View { ...toolsPanelItemProps } ref={ forwardedRef } />\n\t\t) : null;\n\t}\n\n\treturn (\n\t\t<View { ...toolsPanelItemProps } ref={ forwardedRef }>\n\t\t\t{ children }\n\t\t</View>\n\t);\n};\n\nconst ConnectedToolsPanelItem = contextConnect(\n\tToolsPanelItem,\n\t'ToolsPanelItem'\n);\n\nexport default ConnectedToolsPanelItem;\n"]}
@@ -32,7 +32,11 @@ export function useToolsPanelItem(props) {
32
32
  deregisterPanelItem,
33
33
  flagItemCustomization,
34
34
  isResetting,
35
- shouldRenderPlaceholderItems: shouldRenderPlaceholder
35
+ shouldRenderPlaceholderItems: shouldRenderPlaceholder,
36
+ firstDisplayedItem,
37
+ lastDisplayedItem,
38
+ __experimentalFirstVisibleItemClass,
39
+ __experimentalLastVisibleItemClass
36
40
  } = useToolsPanelContext();
37
41
  const hasValueCallback = useCallback(hasValue, [panelId]);
38
42
  const resetAllFilterCallback = useCallback(resetAllFilter, [panelId]);
@@ -93,8 +97,10 @@ export function useToolsPanelItem(props) {
93
97
  const cx = useCx();
94
98
  const classes = useMemo(() => {
95
99
  const placeholderStyle = shouldRenderPlaceholder && !isShown && styles.ToolsPanelItemPlaceholder;
96
- return cx(styles.ToolsPanelItem, placeholderStyle, className);
97
- }, [isShown, shouldRenderPlaceholder, className]);
100
+ const firstItemStyle = firstDisplayedItem === label && __experimentalFirstVisibleItemClass;
101
+ const lastItemStyle = lastDisplayedItem === label && __experimentalLastVisibleItemClass;
102
+ return cx(styles.ToolsPanelItem, placeholderStyle, className, firstItemStyle, lastItemStyle);
103
+ }, [isShown, shouldRenderPlaceholder, className, cx, firstDisplayedItem, lastDisplayedItem, __experimentalFirstVisibleItemClass, __experimentalLastVisibleItemClass]);
98
104
  return { ...otherProps,
99
105
  isShown,
100
106
  shouldRenderPlaceholder,
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/components/src/tools-panel/tools-panel-item/hook.ts"],"names":["usePrevious","useCallback","useEffect","useMemo","styles","useToolsPanelContext","useContextSystem","useCx","useToolsPanelItem","props","className","hasValue","isShownByDefault","label","panelId","resetAllFilter","onDeselect","onSelect","otherProps","currentPanelId","menuItems","registerPanelItem","deregisterPanelItem","flagItemCustomization","isResetting","shouldRenderPlaceholderItems","shouldRenderPlaceholder","hasValueCallback","resetAllFilterCallback","previousPanelId","hasMatchingPanel","isValueSet","wasValueSet","menuGroup","isMenuItemChecked","wasMenuItemChecked","isShown","undefined","cx","classes","placeholderStyle","ToolsPanelItemPlaceholder","ToolsPanelItem"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,WAAT,QAA4B,oBAA5B;AACA,SAASC,WAAT,EAAsBC,SAAtB,EAAiCC,OAAjC,QAAgD,oBAAhD;AAEA;AACA;AACA;;AACA,OAAO,KAAKC,MAAZ,MAAwB,WAAxB;AACA,SAASC,oBAAT,QAAqC,YAArC;AACA,SAASC,gBAAT,QAA0D,kBAA1D;AACA,SAASC,KAAT,QAAsB,0BAAtB;AAGA,OAAO,SAASC,iBAAT,CACNC,KADM,EAEL;AAAA;;AACD,QAAM;AACLC,IAAAA,SADK;AAELC,IAAAA,QAFK;AAGLC,IAAAA,gBAHK;AAILC,IAAAA,KAJK;AAKLC,IAAAA,OALK;AAMLC,IAAAA,cANK;AAOLC,IAAAA,UAPK;AAQLC,IAAAA,QARK;AASL,OAAGC;AATE,MAUFZ,gBAAgB,CAAEG,KAAF,EAAS,gBAAT,CAVpB;AAYA,QAAM;AACLK,IAAAA,OAAO,EAAEK,cADJ;AAELC,IAAAA,SAFK;AAGLC,IAAAA,iBAHK;AAILC,IAAAA,mBAJK;AAKLC,IAAAA,qBALK;AAMLC,IAAAA,WANK;AAOLC,IAAAA,4BAA4B,EAAEC;AAPzB,MAQFrB,oBAAoB,EARxB;AAUA,QAAMsB,gBAAgB,GAAG1B,WAAW,CAAEU,QAAF,EAAY,CAAEG,OAAF,CAAZ,CAApC;AACA,QAAMc,sBAAsB,GAAG3B,WAAW,CAAEc,cAAF,EAAkB,CAAED,OAAF,CAAlB,CAA1C;AACA,QAAMe,eAAe,GAAG7B,WAAW,CAAEmB,cAAF,CAAnC;AAEA,QAAMW,gBAAgB,GACrBX,cAAc,KAAKL,OAAnB,IAA8BK,cAAc,KAAK,IADlD,CA3BC,CA8BD;AACA;;AACAjB,EAAAA,SAAS,CAAE,MAAM;A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IAAI,CAAEM,gBAAtB,EAAyC;AACxC;AACA;;AAED,QAAKI,iBAAiB,IAAI,CAAEH,UAAvB,IAAqC,CAAEI,kBAA5C,EAAiE;AAChElB,MAAAA,QAAQ,SAAR,IAAAA,QAAQ,WAAR,YAAAA,QAAQ;AACR;;AAED,QAAK,CAAEiB,iBAAF,IAAuBC,kBAA5B,EAAiD;AAChDnB,MAAAA,UAAU,SAAV,IAAAA,UAAU,WAAV,YAAAA,UAAU;AACV;AACD,GAZQ,EAYN,CACFc,gBADE,EAEFI,iBAFE,EAGFV,WAHE,EAIFO,UAJE,EAKFI,kBALE,CAZM,CAAT,CAjFC,CAqGD;AACA;AACA;;AACA,QAAMC,OAAO,GAAGxB,gBAAgB,GAC7B,CAAAQ,SAAS,SAAT,IAAAA,SAAS,WAAT,qCAAAA,SAAS,CAAIa,SAAJ,CAAT,gFAA4BpB,KAA5B,OAAwCwB,SADX,GAE7BH,iBAFH;AAIA,QAAMI,EAAE,GAAG/B,KAAK,EAAhB;AACA,QAAMgC,OAAO,GAAGpC,OAAO,CAAE,MAAM;AAC9B,UAAMqC,gBAAgB,GACrBd,uBAAuB,IACvB,CAAEU,OADF,IAEAhC,MAAM,CAACqC,yBAHR;AAIA,WAAOH,EAAE,CAAElC,MAAM,CAACsC,cAAT,EAAyBF,gBAAzB,EAA2C9B,SAA3C,CAAT;AACA,GANsB,EAMpB,CAAE0B,OAAF,EAAWV,uBAAX,EAAoChB,SAApC,CANoB,CAAvB;AAQA,SAAO,EACN,GAAGQ,UADG;AAENkB,IAAAA,OAFM;AAGNV,IAAAA,uBAHM;AAINhB,IAAAA,SAAS,EAAE6B;AAJL,GAAP;AAMA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { usePrevious } from '@wordpress/compose';\nimport { useCallback, useEffect, useMemo } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport * as styles from '../styles';\nimport { useToolsPanelContext } from '../context';\nimport { useContextSystem, WordPressComponentProps } from '../../ui/context';\nimport { useCx } from '../../utils/hooks/use-cx';\nimport type { ToolsPanelItemProps } from '../types';\n\nexport function useToolsPanelItem(\n\tprops: WordPressComponentProps< ToolsPanelItemProps, 'div' >\n) {\n\tconst {\n\t\tclassName,\n\t\thasValue,\n\t\tisShownByDefault,\n\t\tlabel,\n\t\tpanelId,\n\t\tresetAllFilter,\n\t\tonDeselect,\n\t\tonSelect,\n\t\t...otherProps\n\t} = useContextSystem( props, 'ToolsPanelItem' );\n\n\tconst {\n\t\tpanelId: currentPanelId,\n\t\tmenuItems,\n\t\tregisterPanelItem,\n\t\tderegisterPanelItem,\n\t\tflagItemCustomization,\n\t\tisResetting,\n\t\tshouldRenderPlaceholderItems: shouldRenderPlaceholder,\n\t} = useToolsPanelContext();\n\n\tconst hasValueCallback = useCallback( hasValue, [ panelId ] );\n\tconst resetAllFilterCallback = useCallback( resetAllFilter, [ panelId ] );\n\tconst previousPanelId = usePrevious( currentPanelId );\n\n\tconst hasMatchingPanel =\n\t\tcurrentPanelId === panelId || currentPanelId === null;\n\n\t// Registering the panel item allows the panel to include it in its\n\t// automatically generated menu and determine its initial checked status.\n\tuseEffect( () => {\n\t\tif ( hasMatchingPanel && previousPanelId !== null ) {\n\t\t\tregisterPanelItem( {\n\t\t\t\thasValue: hasValueCallback,\n\t\t\t\tisShownByDefault,\n\t\t\t\tlabel,\n\t\t\t\tresetAllFilter: resetAllFilterCallback,\n\t\t\t\tpanelId,\n\t\t\t} );\n\t\t}\n\n\t\treturn () => {\n\t\t\tif (\n\t\t\t\t( previousPanelId === null && !! currentPanelId ) ||\n\t\t\t\tcurrentPanelId === panelId\n\t\t\t) {\n\t\t\t\tderegisterPanelItem( label );\n\t\t\t}\n\t\t};\n\t}, [\n\t\tcurrentPanelId,\n\t\thasMatchingPanel,\n\t\tisShownByDefault,\n\t\tlabel,\n\t\thasValueCallback,\n\t\tpanelId,\n\t\tpreviousPanelId,\n\t\tresetAllFilterCallback,\n\t] );\n\n\tconst isValueSet = hasValue();\n\tconst wasValueSet = usePrevious( isValueSet );\n\n\t// If this item represents a default control it will need to notify the\n\t// panel when a custom value has been set.\n\tuseEffect( () => {\n\t\tif ( isShownByDefault && isValueSet && ! wasValueSet ) {\n\t\t\tflagItemCustomization( label );\n\t\t}\n\t}, [ isValueSet, wasValueSet, isShownByDefault, label ] );\n\n\t// Note: `label` is used as a key when building menu item state in\n\t// `ToolsPanel`.\n\tconst menuGroup = isShownByDefault ? 'default' : 'optional';\n\tconst isMenuItemChecked = menuItems?.[ menuGroup ]?.[ label ];\n\tconst wasMenuItemChecked = usePrevious( isMenuItemChecked );\n\n\t// Determine if the panel item's corresponding menu is being toggled and\n\t// trigger appropriate callback if it is.\n\tuseEffect( () => {\n\t\tif ( isResetting || ! hasMatchingPanel ) {\n\t\t\treturn;\n\t\t}\n\n\t\tif ( isMenuItemChecked && ! isValueSet && ! wasMenuItemChecked ) {\n\t\t\tonSelect?.();\n\t\t}\n\n\t\tif ( ! isMenuItemChecked && wasMenuItemChecked ) {\n\t\t\tonDeselect?.();\n\t\t}\n\t}, [\n\t\thasMatchingPanel,\n\t\tisMenuItemChecked,\n\t\tisResetting,\n\t\tisValueSet,\n\t\twasMenuItemChecked,\n\t] );\n\n\t// The item is shown if it is a default control regardless of whether it\n\t// has a value. Optional items are shown when they are checked or have\n\t// a value.\n\tconst isShown = isShownByDefault\n\t\t? menuItems?.[ menuGroup ]?.[ label ] !== undefined\n\t\t: isMenuItemChecked;\n\n\tconst cx = useCx();\n\tconst classes = useMemo( () => {\n\t\tconst placeholderStyle =\n\t\t\tshouldRenderPlaceholder &&\n\t\t\t! isShown &&\n\t\t\tstyles.ToolsPanelItemPlaceholder;\n\t\treturn cx( styles.ToolsPanelItem, placeholderStyle, className );\n\t}, [ isShown, shouldRenderPlaceholder, className ] );\n\n\treturn {\n\t\t...otherProps,\n\t\tisShown,\n\t\tshouldRenderPlaceholder,\n\t\tclassName: classes,\n\t};\n}\n"]}
1
+ {"version":3,"sources":["@wordpress/components/src/tools-panel/tools-panel-item/hook.ts"],"names":["usePrevious","useCallback","useEffect","useMemo","styles","useToolsPanelContext","useContextSystem","useCx","useToolsPanelItem","props","className","hasValue","isShownByDefault","label","panelId","resetAllFilter","onDeselect","onSelect","otherProps","currentPanelId","menuItems","registerPanelItem","deregisterPanelItem","flagItemCustomization","isResetting","shouldRenderPlaceholderItems","shouldRenderPlaceholder","firstDisplayedItem","lastDisplayedItem","__experimentalFirstVisibleItemClass","__experimentalLastVisibleItemClass","hasValueCallback","resetAllFilterCallback","previousPanelId","hasMatchingPanel","isValueSet","wasValueSet","menuGroup","isMenuItemChecked","wasMenuItemChecked","isShown","undefined","cx","classes","placeholderStyle","ToolsPanelItemPlaceholder","firstItemStyle","lastItemStyle","ToolsPanelItem"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,WAAT,QAA4B,oBAA5B;AACA,SAASC,WAAT,EAAsBC,SAAtB,EAAiCC,OAAjC,QAAgD,oBAAhD;AAEA;AACA;AACA;;AACA,OAAO,KAAKC,MAAZ,MAAwB,WAAxB;AACA,SAASC,oBAAT,QAAqC,YAArC;AACA,SAASC,gBAAT,QAA0D,kBAA1D;AACA,SAASC,KAAT,QAAsB,0BAAtB;AAGA,OAAO,SAASC,iBAAT,CACNC,KADM,EAEL;AAAA;;AACD,QAAM;AACLC,IAAAA,SADK;AAELC,IAAAA,QAFK;AAGLC,IAAAA,gBAHK;AAILC,IAAAA,KAJK;AAKLC,IAAAA,OALK;AAMLC,IAAAA,cANK;AAOLC,IAAAA,UAPK;AAQLC,IAAAA,QARK;AASL,OAAGC;AATE,MAUFZ,gBAAgB,CAAEG,KAAF,EAAS,gBAAT,CAVpB;AAYA,QAAM;AACLK,IAAAA,OAAO,EAAEK,cADJ;AAELC,IAAAA,SAFK;AAGLC,IAAAA,iBAHK;AAILC,IAAAA,mBAJK;AAKLC,IAAAA,qBALK;AAMLC,IAAAA,WANK;AAOLC,IAAAA,4BAA4B,EAAEC,uBAPzB;AAQLC,IAAAA,kBARK;AASLC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AAkB,KAAKd,KAAvB,IAAgCgB,mCADjC;AAEA,UAAMkB,aAAa,GAClBnB,iBAAiB,KAAKf,KAAtB,IAA+BiB,kCADhC;AAEA,WAAOY,EAAE,CACRtC,MAAM,CAAC4C,cADC,EAERJ,gBAFQ,EAGRlC,SAHQ,EAIRoC,cAJQ,EAKRC,aALQ,CAAT;AAOA,GAhBsB,EAgBpB,CACFP,OADE,EAEFd,uBAFE,EAGFhB,SAHE,EAIFgC,EAJE,EAKFf,kBALE,EAMFC,iBANE,EAOFC,mCAPE,EAQFC,kCARE,CAhBoB,CAAvB;AA2BA,SAAO,EACN,GAAGZ,UADG;AAENsB,IAAAA,OAFM;AAGNd,IAAAA,uBAHM;AAINhB,IAAAA,SAAS,EAAEiC;AAJL,GAAP;AAMA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { usePrevious } from '@wordpress/compose';\nimport { useCallback, useEffect, useMemo } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport * as styles from '../styles';\nimport { useToolsPanelContext } from '../context';\nimport { useContextSystem, WordPressComponentProps } from '../../ui/context';\nimport { useCx } from '../../utils/hooks/use-cx';\nimport type { ToolsPanelItemProps } from '../types';\n\nexport function useToolsPanelItem(\n\tprops: WordPressComponentProps< ToolsPanelItemProps, 'div' >\n) {\n\tconst {\n\t\tclassName,\n\t\thasValue,\n\t\tisShownByDefault,\n\t\tlabel,\n\t\tpanelId,\n\t\tresetAllFilter,\n\t\tonDeselect,\n\t\tonSelect,\n\t\t...otherProps\n\t} = useContextSystem( props, 'ToolsPanelItem' );\n\n\tconst {\n\t\tpanelId: currentPanelId,\n\t\tmenuItems,\n\t\tregisterPanelItem,\n\t\tderegisterPanelItem,\n\t\tflagItemCustomization,\n\t\tisResetting,\n\t\tshouldRenderPlaceholderItems: shouldRenderPlaceholder,\n\t\tfirstDisplayedItem,\n\t\tlastDisplayedItem,\n\t\t__experimentalFirstVisibleItemClass,\n\t\t__experimentalLastVisibleItemClass,\n\t} = useToolsPanelContext();\n\n\tconst hasValueCallback = useCallback( hasValue, [ panelId ] );\n\tconst resetAllFilterCallback = useCallback( resetAllFilter, [ panelId ] );\n\tconst previousPanelId = usePrevious( currentPanelId );\n\n\tconst hasMatchingPanel =\n\t\tcurrentPanelId === panelId || currentPanelId === null;\n\n\t// Registering the panel item allows the panel to include it in its\n\t// automatically generated menu and determine its initial checked status.\n\tuseEffect( () => {\n\t\tif ( hasMatchingPanel && previousPanelId !== null ) {\n\t\t\tregisterPanelItem( {\n\t\t\t\thasValue: hasValueCallback,\n\t\t\t\tisShownByDefault,\n\t\t\t\tlabel,\n\t\t\t\tresetAllFilter: resetAllFilterCallback,\n\t\t\t\tpanelId,\n\t\t\t} );\n\t\t}\n\n\t\treturn () => {\n\t\t\tif (\n\t\t\t\t( previousPanelId === null && !! currentPanelId ) ||\n\t\t\t\tcurrentPanelId === panelId\n\t\t\t) {\n\t\t\t\tderegisterPanelItem( label );\n\t\t\t}\n\t\t};\n\t}, [\n\t\tcurrentPanelId,\n\t\thasMatchingPanel,\n\t\tisShownByDefault,\n\t\tlabel,\n\t\thasValueCallback,\n\t\tpanelId,\n\t\tpreviousPanelId,\n\t\tresetAllFilterCallback,\n\t] );\n\n\tconst isValueSet = hasValue();\n\tconst wasValueSet = usePrevious( isValueSet );\n\n\t// If this item represents a default control it will need to notify the\n\t// panel when a custom value has been set.\n\tuseEffect( () => {\n\t\tif ( isShownByDefault && isValueSet && ! wasValueSet ) {\n\t\t\tflagItemCustomization( label );\n\t\t}\n\t}, [ isValueSet, wasValueSet, isShownByDefault, label ] );\n\n\t// Note: `label` is used as a key when building menu item state in\n\t// `ToolsPanel`.\n\tconst menuGroup = isShownByDefault ? 'default' : 'optional';\n\tconst isMenuItemChecked = menuItems?.[ menuGroup ]?.[ label ];\n\tconst wasMenuItemChecked = usePrevious( isMenuItemChecked );\n\n\t// Determine if the panel item's corresponding menu is being toggled and\n\t// trigger appropriate callback if it is.\n\tuseEffect( () => {\n\t\tif ( isResetting || ! hasMatchingPanel ) {\n\t\t\treturn;\n\t\t}\n\n\t\tif ( isMenuItemChecked && ! isValueSet && ! wasMenuItemChecked ) {\n\t\t\tonSelect?.();\n\t\t}\n\n\t\tif ( ! isMenuItemChecked && wasMenuItemChecked ) {\n\t\t\tonDeselect?.();\n\t\t}\n\t}, [\n\t\thasMatchingPanel,\n\t\tisMenuItemChecked,\n\t\tisResetting,\n\t\tisValueSet,\n\t\twasMenuItemChecked,\n\t] );\n\n\t// The item is shown if it is a default control regardless of whether it\n\t// has a value. Optional items are shown when they are checked or have\n\t// a value.\n\tconst isShown = isShownByDefault\n\t\t? menuItems?.[ menuGroup ]?.[ label ] !== undefined\n\t\t: isMenuItemChecked;\n\n\tconst cx = useCx();\n\tconst classes = useMemo( () => {\n\t\tconst placeholderStyle =\n\t\t\tshouldRenderPlaceholder &&\n\t\t\t! isShown &&\n\t\t\tstyles.ToolsPanelItemPlaceholder;\n\t\tconst firstItemStyle =\n\t\t\tfirstDisplayedItem === label && __experimentalFirstVisibleItemClass;\n\t\tconst lastItemStyle =\n\t\t\tlastDisplayedItem === label && __experimentalLastVisibleItemClass;\n\t\treturn cx(\n\t\t\tstyles.ToolsPanelItem,\n\t\t\tplaceholderStyle,\n\t\t\tclassName,\n\t\t\tfirstItemStyle,\n\t\t\tlastItemStyle\n\t\t);\n\t}, [\n\t\tisShown,\n\t\tshouldRenderPlaceholder,\n\t\tclassName,\n\t\tcx,\n\t\tfirstDisplayedItem,\n\t\tlastDisplayedItem,\n\t\t__experimentalFirstVisibleItemClass,\n\t\t__experimentalLastVisibleItemClass,\n\t] );\n\n\treturn {\n\t\t...otherProps,\n\t\tisShown,\n\t\tshouldRenderPlaceholder,\n\t\tclassName: classes,\n\t};\n}\n"]}
@@ -89,6 +89,8 @@ function TreeGrid(_ref, ref) {
89
89
  const activeRow = activeElement.closest('[role="row"]');
90
90
  const focusablesInRow = getRowFocusables(activeRow);
91
91
  const currentColumnIndex = focusablesInRow.indexOf(activeElement);
92
+ const canExpandCollapse = 0 === currentColumnIndex;
93
+ const cannotFocusNextColumn = canExpandCollapse && activeRow.getAttribute('aria-expanded') === 'false' && keyCode === RIGHT;
92
94
 
93
95
  if (includes([LEFT, RIGHT], keyCode)) {
94
96
  // Calculate to the next element.
@@ -98,12 +100,12 @@ function TreeGrid(_ref, ref) {
98
100
  nextIndex = Math.max(0, currentColumnIndex - 1);
99
101
  } else {
100
102
  nextIndex = Math.min(currentColumnIndex + 1, focusablesInRow.length - 1);
101
- } // Focus is either at the left or right edge of the grid.
103
+ } // Focus is at the left most column.
102
104
 
103
105
 
104
- if (nextIndex === currentColumnIndex) {
106
+ if (canExpandCollapse) {
105
107
  if (keyCode === LEFT) {
106
- var _activeRow$ariaLevel, _getRowFocusables, _getRowFocusables$;
108
+ var _activeRow$getAttribu, _getRowFocusables, _getRowFocusables$;
107
109
 
108
110
  // Left:
109
111
  // If a row is focused, and it is expanded, collapses the current row.
@@ -114,13 +116,13 @@ function TreeGrid(_ref, ref) {
114
116
  } // If a row is focused, and it is collapsed, moves to the parent row (if there is one).
115
117
 
116
118
 
117
- const level = Math.max(parseInt((_activeRow$ariaLevel = activeRow === null || activeRow === void 0 ? void 0 : activeRow.ariaLevel) !== null && _activeRow$ariaLevel !== void 0 ? _activeRow$ariaLevel : 1, 10) - 1, 1);
119
+ const level = Math.max(parseInt((_activeRow$getAttribu = activeRow === null || activeRow === void 0 ? void 0 : activeRow.getAttribute('aria-level')) !== null && _activeRow$getAttribu !== void 0 ? _activeRow$getAttribu : 1, 10) - 1, 1);
118
120
  const rows = Array.from(treeGridElement.querySelectorAll('[role="row"]'));
119
121
  let parentRow = activeRow;
120
122
  const currentRowIndex = rows.indexOf(activeRow);
121
123
 
122
124
  for (let i = currentRowIndex; i >= 0; i--) {
123
- if (parseInt(rows[i].ariaLevel, 10) === level) {
125
+ if (parseInt(rows[i].getAttribute('aria-level'), 10) === level) {
124
126
  parentRow = rows[i];
125
127
  break;
126
128
  }
@@ -153,9 +155,13 @@ function TreeGrid(_ref, ref) {
153
155
 
154
156
  event.preventDefault();
155
157
  return;
156
- } // Focus the next element.
158
+ } // Focus the next element. If at most left column and row is collapsed, moving right is not allowed as this will expand. However, if row is collapsed, moving left is allowed.
157
159
 
158
160
 
161
+ if (cannotFocusNextColumn) {
162
+ return;
163
+ }
164
+
159
165
  focusablesInRow[nextIndex].focus(); // Prevent key use for anything else. This ensures Voiceover
160
166
  // doesn't try to handle key navigation.
161
167