@wordpress/components 21.1.0 → 21.2.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 (309) hide show
  1. package/CHANGELOG.md +31 -0
  2. package/build/border-box-control/utils.js +42 -2
  3. package/build/border-box-control/utils.js.map +1 -1
  4. package/build/combobox-control/index.js +0 -1
  5. package/build/combobox-control/index.js.map +1 -1
  6. package/build/custom-select-control/index.js +4 -2
  7. package/build/custom-select-control/index.js.map +1 -1
  8. package/build/draggable/index.js +3 -6
  9. package/build/draggable/index.js.map +1 -1
  10. package/build/font-size-picker/index.js +46 -55
  11. package/build/font-size-picker/index.js.map +1 -1
  12. package/build/font-size-picker/styles.js +73 -0
  13. package/build/font-size-picker/styles.js.map +1 -0
  14. package/build/font-size-picker/types.js +6 -0
  15. package/build/font-size-picker/types.js.map +1 -0
  16. package/build/font-size-picker/utils.js +17 -15
  17. package/build/font-size-picker/utils.js.map +1 -1
  18. package/build/form-token-field/token-input.js +20 -1
  19. package/build/form-token-field/token-input.js.map +1 -1
  20. package/build/index.js +12 -0
  21. package/build/index.js.map +1 -1
  22. package/build/menu-item/index.js +4 -3
  23. package/build/menu-item/index.js.map +1 -1
  24. package/build/mobile/bottom-sheet/bottom-sheet-navigation/navigation-container.native.js +10 -3
  25. package/build/mobile/bottom-sheet/bottom-sheet-navigation/navigation-container.native.js.map +1 -1
  26. package/build/mobile/bottom-sheet/bottom-sheet-navigation/navigation-screen.native.js +12 -3
  27. package/build/mobile/bottom-sheet/bottom-sheet-navigation/navigation-screen.native.js.map +1 -1
  28. package/build/mobile/bottom-sheet/sub-sheet/index.native.js +4 -1
  29. package/build/mobile/bottom-sheet/sub-sheet/index.native.js.map +1 -1
  30. package/build/mobile/color-settings/index.native.js +3 -1
  31. package/build/mobile/color-settings/index.native.js.map +1 -1
  32. package/build/mobile/color-settings/picker-screen.native.js +3 -1
  33. package/build/mobile/color-settings/picker-screen.native.js.map +1 -1
  34. package/build/mobile/image/index.native.js +3 -1
  35. package/build/mobile/image/index.native.js.map +1 -1
  36. package/build/mobile/keyboard-avoiding-view/index.ios.js +3 -1
  37. package/build/mobile/keyboard-avoiding-view/index.ios.js.map +1 -1
  38. package/build/mobile/link-picker/index.native.js +3 -1
  39. package/build/mobile/link-picker/index.native.js.map +1 -1
  40. package/build/mobile/link-picker/link-picker-results.native.js +3 -1
  41. package/build/mobile/link-picker/link-picker-results.native.js.map +1 -1
  42. package/build/mobile/link-picker/link-picker-screen.native.js +3 -1
  43. package/build/mobile/link-picker/link-picker-screen.native.js.map +1 -1
  44. package/build/mobile/link-settings/index.native.js +24 -6
  45. package/build/mobile/link-settings/index.native.js.map +1 -1
  46. package/build/mobile/link-settings/link-settings-screen.native.js +3 -1
  47. package/build/mobile/link-settings/link-settings-screen.native.js.map +1 -1
  48. package/build/mobile/segmented-control/index.native.js +6 -2
  49. package/build/mobile/segmented-control/index.native.js.map +1 -1
  50. package/build/mobile/utils/use-unit-converter-to-mobile.native.js +6 -2
  51. package/build/mobile/utils/use-unit-converter-to-mobile.native.js.map +1 -1
  52. package/build/navigator/navigator-screen/component.js +8 -1
  53. package/build/navigator/navigator-screen/component.js.map +1 -1
  54. package/build/notice/index.native.js +15 -19
  55. package/build/notice/index.native.js.map +1 -1
  56. package/build/notice/list.native.js +2 -3
  57. package/build/notice/list.native.js.map +1 -1
  58. package/build/palette-edit/index.js +1 -1
  59. package/build/palette-edit/index.js.map +1 -1
  60. package/build/popover/index.js +29 -32
  61. package/build/popover/index.js.map +1 -1
  62. package/build/popover/limit-shift.js +145 -0
  63. package/build/popover/limit-shift.js.map +1 -0
  64. package/build/popover/utils.js +55 -15
  65. package/build/popover/utils.js.map +1 -1
  66. package/build/resizable-box/resize-tooltip/utils.js +12 -14
  67. package/build/resizable-box/resize-tooltip/utils.js.map +1 -1
  68. package/build/sandbox/index.js +13 -8
  69. package/build/sandbox/index.js.map +1 -1
  70. package/build/sandbox/index.native.js +3 -1
  71. package/build/sandbox/index.native.js.map +1 -1
  72. package/build/search-control/index.native.js +6 -2
  73. package/build/search-control/index.native.js.map +1 -1
  74. package/build/slot-fill/bubbles-virtually/slot-fill-context.js +8 -2
  75. package/build/slot-fill/bubbles-virtually/slot-fill-context.js.map +1 -1
  76. package/build/slot-fill/bubbles-virtually/slot-fill-provider.js +31 -41
  77. package/build/slot-fill/bubbles-virtually/slot-fill-provider.js.map +1 -1
  78. package/build/slot-fill/bubbles-virtually/use-slot-fills.js +39 -0
  79. package/build/slot-fill/bubbles-virtually/use-slot-fills.js.map +1 -0
  80. package/build/slot-fill/bubbles-virtually/use-slot.js +13 -4
  81. package/build/slot-fill/bubbles-virtually/use-slot.js.map +1 -1
  82. package/build/slot-fill/index.js +8 -0
  83. package/build/slot-fill/index.js.map +1 -1
  84. package/build/toggle-group-control/toggle-group-control-option-base/styles.js +8 -8
  85. package/build/toggle-group-control/toggle-group-control-option-base/styles.js.map +1 -1
  86. package/build/tools-panel/styles.js +27 -12
  87. package/build/tools-panel/styles.js.map +1 -1
  88. package/build/tools-panel/tools-panel-header/component.js +19 -6
  89. package/build/tools-panel/tools-panel-header/component.js.map +1 -1
  90. package/build/tools-panel/tools-panel-header/hook.js +4 -0
  91. package/build/tools-panel/tools-panel-header/hook.js.map +1 -1
  92. package/build-module/border-box-control/utils.js +36 -1
  93. package/build-module/border-box-control/utils.js.map +1 -1
  94. package/build-module/combobox-control/index.js +0 -1
  95. package/build-module/combobox-control/index.js.map +1 -1
  96. package/build-module/custom-select-control/index.js +2 -1
  97. package/build-module/custom-select-control/index.js.map +1 -1
  98. package/build-module/draggable/index.js +2 -5
  99. package/build-module/draggable/index.js.map +1 -1
  100. package/build-module/font-size-picker/index.js +45 -53
  101. package/build-module/font-size-picker/index.js.map +1 -1
  102. package/build-module/font-size-picker/styles.js +62 -0
  103. package/build-module/font-size-picker/styles.js.map +1 -0
  104. package/build-module/font-size-picker/types.js +2 -0
  105. package/build-module/font-size-picker/types.js.map +1 -0
  106. package/build-module/font-size-picker/utils.js +21 -15
  107. package/build-module/font-size-picker/utils.js.map +1 -1
  108. package/build-module/form-token-field/token-input.js +21 -2
  109. package/build-module/form-token-field/token-input.js.map +1 -1
  110. package/build-module/index.js +2 -2
  111. package/build-module/index.js.map +1 -1
  112. package/build-module/menu-item/index.js +4 -3
  113. package/build-module/menu-item/index.js.map +1 -1
  114. package/build-module/mobile/bottom-sheet/bottom-sheet-navigation/navigation-container.native.js +10 -3
  115. package/build-module/mobile/bottom-sheet/bottom-sheet-navigation/navigation-container.native.js.map +1 -1
  116. package/build-module/mobile/bottom-sheet/bottom-sheet-navigation/navigation-screen.native.js +12 -3
  117. package/build-module/mobile/bottom-sheet/bottom-sheet-navigation/navigation-screen.native.js.map +1 -1
  118. package/build-module/mobile/bottom-sheet/sub-sheet/index.native.js +4 -1
  119. package/build-module/mobile/bottom-sheet/sub-sheet/index.native.js.map +1 -1
  120. package/build-module/mobile/color-settings/index.native.js +3 -1
  121. package/build-module/mobile/color-settings/index.native.js.map +1 -1
  122. package/build-module/mobile/color-settings/picker-screen.native.js +3 -1
  123. package/build-module/mobile/color-settings/picker-screen.native.js.map +1 -1
  124. package/build-module/mobile/image/index.native.js +3 -1
  125. package/build-module/mobile/image/index.native.js.map +1 -1
  126. package/build-module/mobile/keyboard-avoiding-view/index.ios.js +3 -1
  127. package/build-module/mobile/keyboard-avoiding-view/index.ios.js.map +1 -1
  128. package/build-module/mobile/link-picker/index.native.js +3 -1
  129. package/build-module/mobile/link-picker/index.native.js.map +1 -1
  130. package/build-module/mobile/link-picker/link-picker-results.native.js +3 -1
  131. package/build-module/mobile/link-picker/link-picker-results.native.js.map +1 -1
  132. package/build-module/mobile/link-picker/link-picker-screen.native.js +3 -1
  133. package/build-module/mobile/link-picker/link-picker-screen.native.js.map +1 -1
  134. package/build-module/mobile/link-settings/index.native.js +24 -6
  135. package/build-module/mobile/link-settings/index.native.js.map +1 -1
  136. package/build-module/mobile/link-settings/link-settings-screen.native.js +3 -1
  137. package/build-module/mobile/link-settings/link-settings-screen.native.js.map +1 -1
  138. package/build-module/mobile/segmented-control/index.native.js +6 -2
  139. package/build-module/mobile/segmented-control/index.native.js.map +1 -1
  140. package/build-module/mobile/utils/use-unit-converter-to-mobile.native.js +6 -2
  141. package/build-module/mobile/utils/use-unit-converter-to-mobile.native.js.map +1 -1
  142. package/build-module/navigator/navigator-screen/component.js +8 -1
  143. package/build-module/navigator/navigator-screen/component.js.map +1 -1
  144. package/build-module/notice/index.native.js +16 -21
  145. package/build-module/notice/index.native.js.map +1 -1
  146. package/build-module/notice/list.native.js +3 -3
  147. package/build-module/notice/list.native.js.map +1 -1
  148. package/build-module/palette-edit/index.js +1 -1
  149. package/build-module/palette-edit/index.js.map +1 -1
  150. package/build-module/popover/index.js +31 -35
  151. package/build-module/popover/index.js.map +1 -1
  152. package/build-module/popover/limit-shift.js +136 -0
  153. package/build-module/popover/limit-shift.js.map +1 -0
  154. package/build-module/popover/utils.js +55 -15
  155. package/build-module/popover/utils.js.map +1 -1
  156. package/build-module/resizable-box/resize-tooltip/utils.js +13 -15
  157. package/build-module/resizable-box/resize-tooltip/utils.js.map +1 -1
  158. package/build-module/sandbox/index.js +13 -8
  159. package/build-module/sandbox/index.js.map +1 -1
  160. package/build-module/sandbox/index.native.js +3 -1
  161. package/build-module/sandbox/index.native.js.map +1 -1
  162. package/build-module/search-control/index.native.js +6 -2
  163. package/build-module/search-control/index.native.js.map +1 -1
  164. package/build-module/slot-fill/bubbles-virtually/slot-fill-context.js +7 -2
  165. package/build-module/slot-fill/bubbles-virtually/slot-fill-context.js.map +1 -1
  166. package/build-module/slot-fill/bubbles-virtually/slot-fill-provider.js +30 -42
  167. package/build-module/slot-fill/bubbles-virtually/slot-fill-provider.js.map +1 -1
  168. package/build-module/slot-fill/bubbles-virtually/use-slot-fills.js +27 -0
  169. package/build-module/slot-fill/bubbles-virtually/use-slot-fills.js.map +1 -0
  170. package/build-module/slot-fill/bubbles-virtually/use-slot.js +13 -5
  171. package/build-module/slot-fill/bubbles-virtually/use-slot.js.map +1 -1
  172. package/build-module/slot-fill/index.js +1 -0
  173. package/build-module/slot-fill/index.js.map +1 -1
  174. package/build-module/toggle-group-control/toggle-group-control-option-base/styles.js +7 -7
  175. package/build-module/toggle-group-control/toggle-group-control-option-base/styles.js.map +1 -1
  176. package/build-module/tools-panel/styles.js +23 -12
  177. package/build-module/tools-panel/styles.js.map +1 -1
  178. package/build-module/tools-panel/tools-panel-header/component.js +19 -7
  179. package/build-module/tools-panel/tools-panel-header/component.js.map +1 -1
  180. package/build-module/tools-panel/tools-panel-header/hook.js +4 -0
  181. package/build-module/tools-panel/tools-panel-header/hook.js.map +1 -1
  182. package/build-style/style-rtl.css +14 -100
  183. package/build-style/style.css +14 -100
  184. package/build-types/border-box-control/utils.d.ts +1 -3
  185. package/build-types/border-box-control/utils.d.ts.map +1 -1
  186. package/build-types/custom-select-control/index.d.ts +13 -0
  187. package/build-types/custom-select-control/index.d.ts.map +1 -0
  188. package/build-types/custom-select-control/styles.d.ts +9 -0
  189. package/build-types/custom-select-control/styles.d.ts.map +1 -0
  190. package/build-types/draggable/index.d.ts.map +1 -1
  191. package/build-types/external-link/styles/external-link-styles.d.ts +1 -1
  192. package/build-types/focal-point-picker/styles/focal-point-style.d.ts +3 -3
  193. package/build-types/font-size-picker/index.d.ts +5 -0
  194. package/build-types/font-size-picker/index.d.ts.map +1 -0
  195. package/build-types/font-size-picker/stories/e2e/index.d.ts +16 -0
  196. package/build-types/font-size-picker/stories/e2e/index.d.ts.map +1 -0
  197. package/build-types/font-size-picker/stories/index.d.ts +31 -0
  198. package/build-types/font-size-picker/stories/index.d.ts.map +1 -0
  199. package/build-types/font-size-picker/styles.d.ts +27 -0
  200. package/build-types/font-size-picker/styles.d.ts.map +1 -0
  201. package/build-types/font-size-picker/test/index.d.ts +2 -0
  202. package/build-types/font-size-picker/test/index.d.ts.map +1 -0
  203. package/build-types/font-size-picker/test/utils.d.ts +2 -0
  204. package/build-types/font-size-picker/test/utils.d.ts.map +1 -0
  205. package/build-types/font-size-picker/types.d.ts +93 -0
  206. package/build-types/font-size-picker/types.d.ts.map +1 -0
  207. package/build-types/font-size-picker/utils.d.ts +41 -0
  208. package/build-types/font-size-picker/utils.d.ts.map +1 -0
  209. package/build-types/form-token-field/token-input.d.ts.map +1 -1
  210. package/build-types/menu-item/index.d.ts.map +1 -1
  211. package/build-types/navigator/navigator-screen/component.d.ts.map +1 -1
  212. package/build-types/popover/index.d.ts.map +1 -1
  213. package/build-types/popover/limit-shift.d.ts +87 -0
  214. package/build-types/popover/limit-shift.d.ts.map +1 -0
  215. package/build-types/popover/test/index.d.ts +2 -0
  216. package/build-types/popover/test/index.d.ts.map +1 -0
  217. package/build-types/popover/types.d.ts +1 -1
  218. package/build-types/popover/types.d.ts.map +1 -1
  219. package/build-types/popover/utils.d.ts.map +1 -1
  220. package/build-types/range-control/types.d.ts +0 -32
  221. package/build-types/range-control/types.d.ts.map +1 -1
  222. package/build-types/slot-fill/bubbles-virtually/slot-fill-context.d.ts +2 -2
  223. package/build-types/slot-fill/bubbles-virtually/slot-fill-context.d.ts.map +1 -1
  224. package/build-types/slot-fill/bubbles-virtually/slot-fill-provider.d.ts.map +1 -1
  225. package/build-types/slot-fill/bubbles-virtually/use-slot-fills.d.ts +2 -0
  226. package/build-types/slot-fill/bubbles-virtually/use-slot-fills.d.ts.map +1 -0
  227. package/build-types/slot-fill/bubbles-virtually/use-slot.d.ts.map +1 -1
  228. package/build-types/slot-fill/index.d.ts +1 -0
  229. package/build-types/slot-fill/index.d.ts.map +1 -1
  230. package/build-types/spinner/index.d.ts +1 -1
  231. package/build-types/toggle-group-control/toggle-group-control-option-base/styles.d.ts +1 -1
  232. package/build-types/toggle-group-control/toggle-group-control-option-base/styles.d.ts.map +1 -1
  233. package/build-types/tools-panel/styles.d.ts +6 -0
  234. package/build-types/tools-panel/styles.d.ts.map +1 -1
  235. package/build-types/tools-panel/tools-panel-header/component.d.ts.map +1 -1
  236. package/build-types/tools-panel/tools-panel-header/hook.d.ts +1 -0
  237. package/build-types/tools-panel/tools-panel-header/hook.d.ts.map +1 -1
  238. package/build-types/tools-panel/types.d.ts +1 -0
  239. package/build-types/tools-panel/types.d.ts.map +1 -1
  240. package/package.json +19 -18
  241. package/src/alignment-matrix-control/test/index.js +17 -62
  242. package/src/border-box-control/test/utils.js +48 -0
  243. package/src/border-box-control/utils.ts +44 -1
  244. package/src/combobox-control/index.js +0 -5
  245. package/src/custom-select-control/index.js +2 -1
  246. package/src/draggable/index.js +2 -5
  247. package/src/font-size-picker/{index.js → index.tsx} +113 -79
  248. package/src/font-size-picker/stories/e2e/{index.js → index.tsx} +13 -4
  249. package/src/font-size-picker/stories/{index.js → index.tsx} +42 -36
  250. package/src/font-size-picker/styles.ts +44 -0
  251. package/src/font-size-picker/test/{index.js → index.tsx} +1 -1
  252. package/src/font-size-picker/test/{utils.js → utils.ts} +6 -2
  253. package/src/font-size-picker/types.ts +98 -0
  254. package/src/font-size-picker/{utils.js → utils.ts} +51 -27
  255. package/src/form-token-field/test/index.tsx +22 -1
  256. package/src/form-token-field/token-input.tsx +25 -3
  257. package/src/index.js +2 -1
  258. package/src/menu-item/README.md +7 -0
  259. package/src/menu-item/index.js +11 -5
  260. package/src/menu-item/style.scss +1 -0
  261. package/src/menu-item/test/index.js +36 -0
  262. package/src/mobile/bottom-sheet/bottom-sheet-navigation/navigation-container.native.js +9 -0
  263. package/src/mobile/bottom-sheet/bottom-sheet-navigation/navigation-screen.native.js +11 -0
  264. package/src/mobile/bottom-sheet/sub-sheet/index.native.js +3 -0
  265. package/src/mobile/color-settings/index.native.js +3 -0
  266. package/src/mobile/color-settings/picker-screen.native.js +3 -0
  267. package/src/mobile/image/index.native.js +3 -0
  268. package/src/mobile/keyboard-avoiding-view/index.ios.js +3 -0
  269. package/src/mobile/link-picker/index.native.js +3 -0
  270. package/src/mobile/link-picker/link-picker-results.native.js +3 -0
  271. package/src/mobile/link-picker/link-picker-screen.native.js +3 -0
  272. package/src/mobile/link-settings/index.native.js +18 -0
  273. package/src/mobile/link-settings/link-settings-screen.native.js +3 -0
  274. package/src/mobile/segmented-control/index.native.js +6 -0
  275. package/src/mobile/utils/use-unit-converter-to-mobile.native.js +6 -0
  276. package/src/navigator/navigator-screen/component.tsx +8 -1
  277. package/src/navigator/test/index.js +119 -54
  278. package/src/notice/index.native.js +17 -20
  279. package/src/notice/list.native.js +7 -3
  280. package/src/palette-edit/index.js +1 -1
  281. package/src/placeholder/style.scss +3 -3
  282. package/src/popover/index.tsx +26 -42
  283. package/src/popover/limit-shift.ts +205 -0
  284. package/src/popover/test/index.tsx +230 -0
  285. package/src/popover/types.ts +1 -0
  286. package/src/popover/utils.ts +58 -16
  287. package/src/range-control/types.ts +0 -33
  288. package/src/resizable-box/resize-tooltip/utils.ts +13 -13
  289. package/src/sandbox/index.js +13 -7
  290. package/src/sandbox/index.native.js +3 -0
  291. package/src/search-control/index.native.js +6 -0
  292. package/src/slot-fill/bubbles-virtually/slot-fill-context.js +6 -2
  293. package/src/slot-fill/bubbles-virtually/slot-fill-provider.js +51 -58
  294. package/src/slot-fill/bubbles-virtually/use-slot-fills.js +24 -0
  295. package/src/slot-fill/bubbles-virtually/use-slot.js +11 -6
  296. package/src/slot-fill/index.js +1 -0
  297. package/src/style.scss +0 -1
  298. package/src/toggle-group-control/test/__snapshots__/index.tsx.snap +1 -0
  299. package/src/toggle-group-control/toggle-group-control-option-base/styles.ts +9 -7
  300. package/src/tools-panel/stories/index.js +27 -0
  301. package/src/tools-panel/styles.ts +28 -1
  302. package/src/tools-panel/tools-panel-header/component.tsx +12 -5
  303. package/src/tools-panel/tools-panel-header/hook.ts +5 -0
  304. package/src/tools-panel/types.ts +1 -0
  305. package/tsconfig.json +0 -2
  306. package/tsconfig.tsbuildinfo +1 -1
  307. package/src/font-size-picker/style.scss +0 -78
  308. package/src/popover/test/__snapshots__/index.js.snap +0 -34
  309. package/src/popover/test/index.js +0 -164
@@ -115,6 +115,9 @@ function SearchControl( {
115
115
  mergeFutureStyles( activeDarkStyles, [ isActive, isDark ] );
116
116
 
117
117
  setCurrentStyles( futureStyles );
118
+ // Disable reason: deferring this refactor to the native team.
119
+ // see https://github.com/WordPress/gutenberg/pull/41166
120
+ // eslint-disable-next-line react-hooks/exhaustive-deps
118
121
  }, [ isActive, isDark ] );
119
122
 
120
123
  useEffect( () => {
@@ -130,6 +133,9 @@ function SearchControl( {
130
133
  clearTimeout( onCancelTimer.current );
131
134
  keyboardHideSubscription.remove();
132
135
  };
136
+ // Disable reason: deferring this refactor to the native team.
137
+ // see https://github.com/WordPress/gutenberg/pull/41166
138
+ // eslint-disable-next-line react-hooks/exhaustive-deps
133
139
  }, [] );
134
140
 
135
141
  const {
@@ -1,4 +1,8 @@
1
1
  // @ts-nocheck
2
+ /**
3
+ * External dependencies
4
+ */
5
+ import { proxyMap } from 'valtio/utils';
2
6
  /**
3
7
  * WordPress dependencies
4
8
  */
@@ -6,8 +10,8 @@ import { createContext } from '@wordpress/element';
6
10
  import warning from '@wordpress/warning';
7
11
 
8
12
  const SlotFillContext = createContext( {
9
- slots: {},
10
- fills: {},
13
+ slots: proxyMap(),
14
+ fills: proxyMap(),
11
15
  registerSlot: () => {
12
16
  warning(
13
17
  'Components must be wrapped within `SlotFillProvider`. ' +
@@ -1,8 +1,14 @@
1
1
  // @ts-nocheck
2
+ /**
3
+ * External dependencies
4
+ */
5
+ import { ref as valRef } from 'valtio';
6
+ import { proxyMap } from 'valtio/utils';
7
+
2
8
  /**
3
9
  * WordPress dependencies
4
10
  */
5
- import { useMemo, useCallback, useState } from '@wordpress/element';
11
+ import { useMemo, useCallback, useRef } from '@wordpress/element';
6
12
  import isShallowEqual from '@wordpress/is-shallow-equal';
7
13
 
8
14
  /**
@@ -11,79 +17,68 @@ import isShallowEqual from '@wordpress/is-shallow-equal';
11
17
  import SlotFillContext from './slot-fill-context';
12
18
 
13
19
  function useSlotRegistry() {
14
- const [ slots, setSlots ] = useState( {} );
15
- const [ fills, setFills ] = useState( {} );
20
+ const slots = useRef( proxyMap() );
21
+ const fills = useRef( proxyMap() );
16
22
 
17
23
  const registerSlot = useCallback( ( name, ref, fillProps ) => {
18
- setSlots( ( prevSlots ) => {
19
- const slot = prevSlots[ name ] || {};
20
- return {
21
- ...prevSlots,
22
- [ name ]: {
23
- ...slot,
24
- ref: ref || slot.ref,
25
- fillProps: fillProps || slot.fillProps || {},
26
- },
27
- };
28
- } );
24
+ const slot = slots.current.get( name ) || {};
25
+ slots.current.set(
26
+ name,
27
+ valRef( {
28
+ ...slot,
29
+ ref: ref || slot.ref,
30
+ fillProps: fillProps || slot.fillProps || {},
31
+ } )
32
+ );
29
33
  }, [] );
30
34
 
31
35
  const unregisterSlot = useCallback( ( name, ref ) => {
32
- setSlots( ( prevSlots ) => {
33
- const { [ name ]: slot, ...nextSlots } = prevSlots;
34
- // Make sure we're not unregistering a slot registered by another element
35
- // See https://github.com/WordPress/gutenberg/pull/19242#issuecomment-590295412
36
- if ( slot?.ref === ref ) {
37
- return nextSlots;
38
- }
39
- return prevSlots;
40
- } );
36
+ // Make sure we're not unregistering a slot registered by another element
37
+ // See https://github.com/WordPress/gutenberg/pull/19242#issuecomment-590295412
38
+ if ( slots.current.get( name )?.ref === ref ) {
39
+ slots.current.delete( name );
40
+ }
41
41
  }, [] );
42
42
 
43
- const updateSlot = useCallback(
44
- ( name, fillProps ) => {
45
- const slot = slots[ name ];
46
- if ( ! slot ) {
47
- return;
48
- }
49
- if ( ! isShallowEqual( slot.fillProps, fillProps ) ) {
50
- slot.fillProps = fillProps;
51
- const slotFills = fills[ name ];
52
- if ( slotFills ) {
53
- // Force update fills.
54
- slotFills.map( ( fill ) => fill.current.rerender() );
55
- }
43
+ const updateSlot = useCallback( ( name, fillProps ) => {
44
+ const slot = slots.current.get( name );
45
+ if ( ! slot ) {
46
+ return;
47
+ }
48
+
49
+ if ( ! isShallowEqual( slot.fillProps, fillProps ) ) {
50
+ slot.fillProps = fillProps;
51
+ const slotFills = fills.current.get( name );
52
+ if ( slotFills ) {
53
+ // Force update fills.
54
+ slotFills.map( ( fill ) => fill.current.rerender() );
56
55
  }
57
- },
58
- [ slots, fills ]
59
- );
56
+ }
57
+ }, [] );
60
58
 
61
59
  const registerFill = useCallback( ( name, ref ) => {
62
- setFills( ( prevFills ) => ( {
63
- ...prevFills,
64
- [ name ]: [ ...( prevFills[ name ] || [] ), ref ],
65
- } ) );
60
+ fills.current.set(
61
+ name,
62
+ valRef( [ ...( fills.current.get( name ) || [] ), ref ] )
63
+ );
66
64
  }, [] );
67
65
 
68
66
  const unregisterFill = useCallback( ( name, ref ) => {
69
- setFills( ( prevFills ) => {
70
- if ( prevFills[ name ] ) {
71
- return {
72
- ...prevFills,
73
- [ name ]: prevFills[ name ].filter(
74
- ( fillRef ) => fillRef !== ref
75
- ),
76
- };
77
- }
78
- return prevFills;
79
- } );
67
+ if ( fills.current.get( name ) ) {
68
+ fills.current.set(
69
+ name,
70
+ fills.current
71
+ .get( name )
72
+ .filter( ( fillRef ) => fillRef !== ref )
73
+ );
74
+ }
80
75
  }, [] );
81
76
 
82
77
  // Memoizing the return value so it can be directly passed to Provider value
83
78
  const registry = useMemo(
84
79
  () => ( {
85
- slots,
86
- fills,
80
+ slots: slots.current,
81
+ fills: fills.current,
87
82
  registerSlot,
88
83
  updateSlot,
89
84
  unregisterSlot,
@@ -91,8 +86,6 @@ function useSlotRegistry() {
91
86
  unregisterFill,
92
87
  } ),
93
88
  [
94
- slots,
95
- fills,
96
89
  registerSlot,
97
90
  updateSlot,
98
91
  unregisterSlot,
@@ -0,0 +1,24 @@
1
+ // @ts-nocheck
2
+ /**
3
+ * External dependencies
4
+ */
5
+ import { useSnapshot } from 'valtio';
6
+
7
+ /**
8
+ * WordPress dependencies
9
+ */
10
+ import { useContext } from '@wordpress/element';
11
+
12
+ /**
13
+ * Internal dependencies
14
+ */
15
+ import SlotFillContext from './slot-fill-context';
16
+
17
+ export default function useSlotFills( name ) {
18
+ const registry = useContext( SlotFillContext );
19
+ const fills = useSnapshot( registry.fills, { sync: true } );
20
+ // The important bit here is that this call ensures that the hook
21
+ // only causes a re-render if the "fills" of a given slot name
22
+ // change change, not any fills.
23
+ return fills.get( name );
24
+ }
@@ -1,8 +1,13 @@
1
1
  // @ts-nocheck
2
+ /**
3
+ * External dependencies
4
+ */
5
+ import { useSnapshot } from 'valtio';
6
+
2
7
  /**
3
8
  * WordPress dependencies
4
9
  */
5
- import { useCallback, useContext, useMemo } from '@wordpress/element';
10
+ import { useCallback, useContext } from '@wordpress/element';
6
11
 
7
12
  /**
8
13
  * Internal dependencies
@@ -11,10 +16,11 @@ import SlotFillContext from './slot-fill-context';
11
16
 
12
17
  export default function useSlot( name ) {
13
18
  const registry = useContext( SlotFillContext );
14
-
15
- const slot = registry.slots[ name ] || {};
16
- const slotFills = registry.fills[ name ];
17
- const fills = useMemo( () => slotFills || [], [ slotFills ] );
19
+ const slots = useSnapshot( registry.slots, { sync: true } );
20
+ // The important bit here is that this call ensures
21
+ // the hook only causes a re-render if the slot
22
+ // with the given name change, not any other slot.
23
+ const slot = slots.get( name );
18
24
 
19
25
  const updateSlot = useCallback(
20
26
  ( fillProps ) => {
@@ -48,7 +54,6 @@ export default function useSlot( name ) {
48
54
  ...slot,
49
55
  updateSlot,
50
56
  unregisterSlot,
51
- fills,
52
57
  registerFill,
53
58
  unregisterFill,
54
59
  };
@@ -14,6 +14,7 @@ import BubblesVirtuallySlot from './bubbles-virtually/slot';
14
14
  import BubblesVirtuallySlotFillProvider from './bubbles-virtually/slot-fill-provider';
15
15
  import SlotFillProvider from './provider';
16
16
  import useSlot from './bubbles-virtually/use-slot';
17
+ export { default as useSlotFills } from './bubbles-virtually/use-slot-fills';
17
18
 
18
19
  export function Fill( props ) {
19
20
  // We're adding both Fills here so they can register themselves before
package/src/style.scss CHANGED
@@ -17,7 +17,6 @@
17
17
  @import "./dropdown/style.scss";
18
18
  @import "./dropdown-menu/style.scss";
19
19
  @import "./duotone-picker/style.scss";
20
- @import "./font-size-picker/style.scss";
21
20
  @import "./form-toggle/style.scss";
22
21
  @import "./form-token-field/style.scss";
23
22
  @import "./guide/style.scss";
@@ -159,6 +159,7 @@ exports[`ToggleGroupControl should render correctly with icons 1`] = `
159
159
  }
160
160
 
161
161
  .emotion-15 {
162
+ color: #1e1e1e;
162
163
  width: 30px;
163
164
  padding-left: 0;
164
165
  padding-right: 0;
@@ -55,13 +55,6 @@ export const buttonView = css`
55
55
  }
56
56
  `;
57
57
 
58
- export const buttonActive = css`
59
- color: ${ COLORS.white };
60
- &:active {
61
- background: transparent;
62
- }
63
- `;
64
-
65
58
  export const ButtonContentView = styled.div`
66
59
  font-size: ${ CONFIG.fontSize };
67
60
  line-height: 1;
@@ -82,8 +75,17 @@ export const isIcon = ( {
82
75
  };
83
76
 
84
77
  return css`
78
+ color: ${ COLORS.gray[ 900 ] };
85
79
  width: ${ iconButtonSizes[ size ] };
86
80
  padding-left: 0;
87
81
  padding-right: 0;
88
82
  `;
89
83
  };
84
+
85
+ export const buttonActive = css`
86
+ color: ${ COLORS.white };
87
+
88
+ &:active {
89
+ background: transparent;
90
+ }
91
+ `;
@@ -29,11 +29,13 @@ export const _default = () => {
29
29
  const [ height, setHeight ] = useState();
30
30
  const [ minHeight, setMinHeight ] = useState();
31
31
  const [ width, setWidth ] = useState();
32
+ const [ scale, setScale ] = useState();
32
33
 
33
34
  const resetAll = () => {
34
35
  setHeight( undefined );
35
36
  setWidth( undefined );
36
37
  setMinHeight( undefined );
38
+ setScale( undefined );
37
39
  };
38
40
 
39
41
  return (
@@ -79,6 +81,31 @@ export const _default = () => {
79
81
  onChange={ ( next ) => setMinHeight( next ) }
80
82
  />
81
83
  </ToolsPanelItem>
84
+ <ToolsPanelItem
85
+ hasValue={ () => !! scale }
86
+ label="Scale"
87
+ onDeselect={ () => setScale( undefined ) }
88
+ >
89
+ <ToggleGroupControl
90
+ label="Scale"
91
+ value={ scale }
92
+ onChange={ ( next ) => setScale( next ) }
93
+ isBlock
94
+ >
95
+ <ToggleGroupControlOption
96
+ value="cover"
97
+ label="Cover"
98
+ />
99
+ <ToggleGroupControlOption
100
+ value="contain"
101
+ label="Contain"
102
+ />
103
+ <ToggleGroupControlOption
104
+ value="fill"
105
+ label="Fill"
106
+ />
107
+ </ToggleGroupControl>
108
+ </ToolsPanelItem>
82
109
  </ToolsPanel>
83
110
  </Panel>
84
111
  </PanelWrapperView>
@@ -1,6 +1,7 @@
1
1
  /**
2
2
  * External dependencies
3
3
  */
4
+ import styled from '@emotion/styled';
4
5
  import { css } from '@emotion/react';
5
6
 
6
7
  /**
@@ -12,7 +13,7 @@ import {
12
13
  Wrapper as BaseControlWrapper,
13
14
  } from '../base-control/styles/base-control-styles';
14
15
  import { LabelWrapper } from '../input-control/styles/input-control-styles';
15
- import { COLORS, CONFIG } from '../utils';
16
+ import { COLORS, CONFIG, rtl } from '../utils';
16
17
  import { space } from '../ui/utils/space';
17
18
 
18
19
  const toolsPanelGrid = {
@@ -145,3 +146,29 @@ export const ToolsPanelItemPlaceholder = css`
145
146
  export const DropdownMenu = css`
146
147
  min-width: 200px;
147
148
  `;
149
+
150
+ export const ResetLabel = styled.span`
151
+ color: var( --wp-admin-theme-color-darker-10 );
152
+ font-size: 11px;
153
+ font-weight: 500;
154
+ line-height: 1.4;
155
+ ${ rtl( { marginLeft: space( 3 ) } ) }
156
+ text-transform: uppercase;
157
+ `;
158
+
159
+ export const DefaultControlsItem = css`
160
+ color: ${ COLORS.gray[ 900 ] };
161
+
162
+ &&[aria-disabled='true'] {
163
+ color: ${ COLORS.gray[ 700 ] };
164
+ opacity: 1;
165
+
166
+ &:hover {
167
+ color: ${ COLORS.gray[ 700 ] };
168
+ }
169
+
170
+ ${ ResetLabel } {
171
+ opacity: 0.3;
172
+ }
173
+ }
174
+ `;
@@ -7,7 +7,7 @@ import type { ForwardedRef } from 'react';
7
7
  * WordPress dependencies
8
8
  */
9
9
  import { speak } from '@wordpress/a11y';
10
- import { check, reset, moreVertical, plus } from '@wordpress/icons';
10
+ import { check, moreVertical, plus } from '@wordpress/icons';
11
11
  import { __, _x, sprintf } from '@wordpress/i18n';
12
12
 
13
13
  /**
@@ -20,12 +20,14 @@ import { HStack } from '../../h-stack';
20
20
  import { Heading } from '../../heading';
21
21
  import { useToolsPanelHeader } from './hook';
22
22
  import { contextConnect, WordPressComponentProps } from '../../ui/context';
23
+ import { ResetLabel } from '../styles';
23
24
  import type {
24
25
  ToolsPanelControlsGroupProps,
25
26
  ToolsPanelHeaderProps,
26
27
  } from '../types';
27
28
 
28
29
  const DefaultControlsGroup = ( {
30
+ itemClassName,
29
31
  items,
30
32
  toggleItem,
31
33
  }: ToolsPanelControlsGroupProps ) => {
@@ -33,15 +35,17 @@ const DefaultControlsGroup = ( {
33
35
  return null;
34
36
  }
35
37
 
38
+ const resetSuffix = <ResetLabel aria-hidden>{ __( 'Reset' ) }</ResetLabel>;
39
+
36
40
  return (
37
- <MenuGroup>
41
+ <MenuGroup label={ __( 'Defaults' ) }>
38
42
  { items.map( ( [ label, hasValue ] ) => {
39
43
  if ( hasValue ) {
40
44
  return (
41
45
  <MenuItem
42
46
  key={ label }
47
+ className={ itemClassName }
43
48
  role="menuitem"
44
- icon={ reset }
45
49
  label={ sprintf(
46
50
  // translators: %s: The name of the control being reset e.g. "Padding".
47
51
  __( 'Reset %s' ),
@@ -58,6 +62,7 @@ const DefaultControlsGroup = ( {
58
62
  'assertive'
59
63
  );
60
64
  } }
65
+ suffix={ resetSuffix }
61
66
  >
62
67
  { label }
63
68
  </MenuItem>
@@ -67,8 +72,8 @@ const DefaultControlsGroup = ( {
67
72
  return (
68
73
  <MenuItem
69
74
  key={ label }
75
+ className={ itemClassName }
70
76
  role="menuitemcheckbox"
71
- icon={ check }
72
77
  isSelected
73
78
  aria-disabled
74
79
  >
@@ -89,7 +94,7 @@ const OptionalControlsGroup = ( {
89
94
  }
90
95
 
91
96
  return (
92
- <MenuGroup>
97
+ <MenuGroup label={ __( 'Tools' ) }>
93
98
  { items.map( ( [ label, isSelected ] ) => {
94
99
  const itemLabel = isSelected
95
100
  ? sprintf(
@@ -147,6 +152,7 @@ const ToolsPanelHeader = (
147
152
  ) => {
148
153
  const {
149
154
  areAllOptionalControlsHidden,
155
+ defaultControlsItemClassName,
150
156
  dropdownMenuClassName,
151
157
  hasMenuItems,
152
158
  headingClassName,
@@ -197,6 +203,7 @@ const ToolsPanelHeader = (
197
203
  <DefaultControlsGroup
198
204
  items={ defaultItems }
199
205
  toggleItem={ toggleItem }
206
+ itemClassName={ defaultControlsItemClassName }
200
207
  />
201
208
  <OptionalControlsGroup
202
209
  items={ optionalItems }
@@ -33,12 +33,17 @@ export function useToolsPanelHeader(
33
33
  return cx( styles.ToolsPanelHeading );
34
34
  }, [ cx ] );
35
35
 
36
+ const defaultControlsItemClassName = useMemo( () => {
37
+ return cx( styles.DefaultControlsItem );
38
+ }, [ cx ] );
39
+
36
40
  const { menuItems, hasMenuItems, areAllOptionalControlsHidden } =
37
41
  useToolsPanelContext();
38
42
 
39
43
  return {
40
44
  ...otherProps,
41
45
  areAllOptionalControlsHidden,
46
+ defaultControlsItemClassName,
42
47
  dropdownMenuClassName,
43
48
  hasMenuItems,
44
49
  headingClassName,
@@ -147,6 +147,7 @@ export type ToolsPanelContext = {
147
147
  };
148
148
 
149
149
  export type ToolsPanelControlsGroupProps = {
150
+ itemClassName?: string;
150
151
  items: [ string, boolean ][];
151
152
  toggleItem: ( label: string ) => void;
152
153
  };
package/tsconfig.json CHANGED
@@ -47,10 +47,8 @@
47
47
  "src/color-list-picker",
48
48
  "src/combobox-control",
49
49
  "src/custom-gradient-picker",
50
- "src/custom-select-control",
51
50
  "src/dimension-control",
52
51
  "src/duotone-picker",
53
- "src/font-size-picker",
54
52
  "src/gradient-picker",
55
53
  "src/guide",
56
54
  "src/higher-order/navigate-regions",