@wordpress/components 23.8.0 → 24.0.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 (389) hide show
  1. package/CHANGELOG.md +71 -0
  2. package/CONTRIBUTING.md +65 -1
  3. package/README.md +1 -3
  4. package/build/autocomplete/autocompleter-ui.js +0 -2
  5. package/build/autocomplete/autocompleter-ui.js.map +1 -1
  6. package/build/autocomplete/index.js +2 -0
  7. package/build/autocomplete/index.js.map +1 -1
  8. package/build/button/index.js +2 -0
  9. package/build/button/index.js.map +1 -1
  10. package/build/card/card-media/component.js +2 -1
  11. package/build/card/card-media/component.js.map +1 -1
  12. package/build/checkbox-control/index.js +2 -2
  13. package/build/checkbox-control/index.js.map +1 -1
  14. package/build/color-palette/index.native.js +12 -0
  15. package/build/color-palette/index.native.js.map +1 -1
  16. package/build/combobox-control/index.js +7 -5
  17. package/build/combobox-control/index.js.map +1 -1
  18. package/build/combobox-control/styles.js +3 -3
  19. package/build/combobox-control/styles.js.map +1 -1
  20. package/build/custom-gradient-picker/index.native.js +3 -1
  21. package/build/custom-gradient-picker/index.native.js.map +1 -1
  22. package/build/dimension-control/index.js +1 -1
  23. package/build/dimension-control/index.js.map +1 -1
  24. package/build/draggable/index.js +8 -8
  25. package/build/draggable/index.js.map +1 -1
  26. package/build/form-token-field/index.js +5 -3
  27. package/build/form-token-field/index.js.map +1 -1
  28. package/build/form-token-field/styles.js +3 -3
  29. package/build/form-token-field/styles.js.map +1 -1
  30. package/build/index.js.map +1 -1
  31. package/build/mobile/bottom-sheet/cell.native.js +6 -6
  32. package/build/mobile/bottom-sheet/cell.native.js.map +1 -1
  33. package/build/mobile/color-settings/palette.screen.native.js +0 -8
  34. package/build/mobile/color-settings/palette.screen.native.js.map +1 -1
  35. package/build/mobile/global-styles-context/index.native.js +13 -1
  36. package/build/mobile/global-styles-context/index.native.js.map +1 -1
  37. package/build/mobile/global-styles-context/utils.native.js +21 -4
  38. package/build/mobile/global-styles-context/utils.native.js.map +1 -1
  39. package/build/mobile/link-picker/link-picker-results.native.js +3 -1
  40. package/build/mobile/link-picker/link-picker-results.native.js.map +1 -1
  41. package/build/mobile/segmented-control/index.native.js +4 -2
  42. package/build/mobile/segmented-control/index.native.js.map +1 -1
  43. package/build/modal/index.js +2 -1
  44. package/build/modal/index.js.map +1 -1
  45. package/build/navigable-container/container.js +39 -19
  46. package/build/navigable-container/container.js.map +1 -1
  47. package/build/navigable-container/index.js.map +1 -1
  48. package/build/navigable-container/menu.js +37 -5
  49. package/build/navigable-container/menu.js.map +1 -1
  50. package/build/navigable-container/tabbable.js +45 -4
  51. package/build/navigable-container/tabbable.js.map +1 -1
  52. package/build/navigable-container/types.js +6 -0
  53. package/build/navigable-container/types.js.map +1 -0
  54. package/build/navigator/navigator-screen/component.js +1 -1
  55. package/build/navigator/navigator-screen/component.js.map +1 -1
  56. package/build/palette-edit/index.js +34 -12
  57. package/build/palette-edit/index.js.map +1 -1
  58. package/build/popover/index.js +1 -8
  59. package/build/popover/index.js.map +1 -1
  60. package/build/private-apis.js +4 -1
  61. package/build/private-apis.js.map +1 -1
  62. package/build/sandbox/index.native.js +10 -3
  63. package/build/sandbox/index.native.js.map +1 -1
  64. package/build/slot-fill/bubbles-virtually/fill.js +2 -1
  65. package/build/slot-fill/bubbles-virtually/fill.js.map +1 -1
  66. package/build/slot-fill/bubbles-virtually/slot-fill-provider.js +45 -35
  67. package/build/slot-fill/bubbles-virtually/slot-fill-provider.js.map +1 -1
  68. package/build/slot-fill/bubbles-virtually/use-slot.js +11 -26
  69. package/build/slot-fill/bubbles-virtually/use-slot.js.map +1 -1
  70. package/build/slot-fill/fill.js +7 -31
  71. package/build/slot-fill/fill.js.map +1 -1
  72. package/build/slot-fill/index.js +20 -7
  73. package/build/slot-fill/index.js.map +1 -1
  74. package/build/slot-fill/provider.js +0 -6
  75. package/build/slot-fill/provider.js.map +1 -1
  76. package/build/slot-fill/slot.js +0 -5
  77. package/build/slot-fill/slot.js.map +1 -1
  78. package/build/spinner/styles.js +4 -4
  79. package/build/spinner/styles.js.map +1 -1
  80. package/build/tab-panel/index.js.map +1 -1
  81. package/build/theme/color-algorithms.js +1 -1
  82. package/build/theme/color-algorithms.js.map +1 -1
  83. package/build/toolbar/toolbar-button/index.js +1 -2
  84. package/build/toolbar/toolbar-button/index.js.map +1 -1
  85. package/build/toolbar/toolbar-item/index.js +4 -2
  86. package/build/toolbar/toolbar-item/index.js.map +1 -1
  87. package/build/tree-grid/index.js +3 -3
  88. package/build/tree-grid/index.js.map +1 -1
  89. package/build/utils/colors-values.js +3 -3
  90. package/build/utils/colors-values.js.map +1 -1
  91. package/build/utils/use-deprecated-props.js +35 -0
  92. package/build/utils/use-deprecated-props.js.map +1 -0
  93. package/build/view/component.js +1 -2
  94. package/build/view/component.js.map +1 -1
  95. package/build-module/autocomplete/autocompleter-ui.js +1 -3
  96. package/build-module/autocomplete/autocompleter-ui.js.map +1 -1
  97. package/build-module/autocomplete/index.js +3 -3
  98. package/build-module/autocomplete/index.js.map +1 -1
  99. package/build-module/button/index.js +2 -0
  100. package/build-module/button/index.js.map +1 -1
  101. package/build-module/card/card-media/component.js +2 -1
  102. package/build-module/card/card-media/component.js.map +1 -1
  103. package/build-module/checkbox-control/index.js +2 -2
  104. package/build-module/checkbox-control/index.js.map +1 -1
  105. package/build-module/color-palette/index.native.js +13 -1
  106. package/build-module/color-palette/index.native.js.map +1 -1
  107. package/build-module/combobox-control/index.js +6 -5
  108. package/build-module/combobox-control/index.js.map +1 -1
  109. package/build-module/combobox-control/styles.js +3 -3
  110. package/build-module/combobox-control/styles.js.map +1 -1
  111. package/build-module/custom-gradient-picker/index.native.js +3 -1
  112. package/build-module/custom-gradient-picker/index.native.js.map +1 -1
  113. package/build-module/dimension-control/index.js +1 -1
  114. package/build-module/dimension-control/index.js.map +1 -1
  115. package/build-module/draggable/index.js +8 -8
  116. package/build-module/draggable/index.js.map +1 -1
  117. package/build-module/form-token-field/index.js +4 -3
  118. package/build-module/form-token-field/index.js.map +1 -1
  119. package/build-module/form-token-field/styles.js +3 -3
  120. package/build-module/form-token-field/styles.js.map +1 -1
  121. package/build-module/index.js.map +1 -1
  122. package/build-module/mobile/bottom-sheet/cell.native.js +6 -5
  123. package/build-module/mobile/bottom-sheet/cell.native.js.map +1 -1
  124. package/build-module/mobile/color-settings/palette.screen.native.js +0 -8
  125. package/build-module/mobile/color-settings/palette.screen.native.js.map +1 -1
  126. package/build-module/mobile/global-styles-context/index.native.js +13 -1
  127. package/build-module/mobile/global-styles-context/index.native.js.map +1 -1
  128. package/build-module/mobile/global-styles-context/utils.native.js +21 -3
  129. package/build-module/mobile/global-styles-context/utils.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/segmented-control/index.native.js +4 -2
  133. package/build-module/mobile/segmented-control/index.native.js.map +1 -1
  134. package/build-module/modal/index.js +2 -1
  135. package/build-module/modal/index.js.map +1 -1
  136. package/build-module/navigable-container/container.js +43 -19
  137. package/build-module/navigable-container/container.js.map +1 -1
  138. package/build-module/navigable-container/index.js +0 -2
  139. package/build-module/navigable-container/index.js.map +1 -1
  140. package/build-module/navigable-container/menu.js +36 -4
  141. package/build-module/navigable-container/menu.js.map +1 -1
  142. package/build-module/navigable-container/tabbable.js +44 -3
  143. package/build-module/navigable-container/tabbable.js.map +1 -1
  144. package/build-module/navigable-container/types.js +2 -0
  145. package/build-module/navigable-container/types.js.map +1 -0
  146. package/build-module/navigator/navigator-screen/component.js +1 -1
  147. package/build-module/navigator/navigator-screen/component.js.map +1 -1
  148. package/build-module/palette-edit/index.js +34 -13
  149. package/build-module/palette-edit/index.js.map +1 -1
  150. package/build-module/popover/index.js +1 -8
  151. package/build-module/popover/index.js.map +1 -1
  152. package/build-module/private-apis.js +3 -1
  153. package/build-module/private-apis.js.map +1 -1
  154. package/build-module/sandbox/index.native.js +10 -3
  155. package/build-module/sandbox/index.native.js.map +1 -1
  156. package/build-module/slot-fill/bubbles-virtually/fill.js +2 -1
  157. package/build-module/slot-fill/bubbles-virtually/fill.js.map +1 -1
  158. package/build-module/slot-fill/bubbles-virtually/slot-fill-provider.js +46 -36
  159. package/build-module/slot-fill/bubbles-virtually/slot-fill-provider.js.map +1 -1
  160. package/build-module/slot-fill/bubbles-virtually/use-slot.js +12 -27
  161. package/build-module/slot-fill/bubbles-virtually/use-slot.js.map +1 -1
  162. package/build-module/slot-fill/fill.js +7 -31
  163. package/build-module/slot-fill/fill.js.map +1 -1
  164. package/build-module/slot-fill/index.js +17 -8
  165. package/build-module/slot-fill/index.js.map +1 -1
  166. package/build-module/slot-fill/provider.js +0 -6
  167. package/build-module/slot-fill/provider.js.map +1 -1
  168. package/build-module/slot-fill/slot.js +0 -5
  169. package/build-module/slot-fill/slot.js.map +1 -1
  170. package/build-module/spinner/styles.js +4 -4
  171. package/build-module/spinner/styles.js.map +1 -1
  172. package/build-module/tab-panel/index.js.map +1 -1
  173. package/build-module/theme/color-algorithms.js +1 -1
  174. package/build-module/theme/color-algorithms.js.map +1 -1
  175. package/build-module/toolbar/toolbar-button/index.js +1 -2
  176. package/build-module/toolbar/toolbar-button/index.js.map +1 -1
  177. package/build-module/toolbar/toolbar-item/index.js +5 -2
  178. package/build-module/toolbar/toolbar-item/index.js.map +1 -1
  179. package/build-module/tree-grid/index.js +3 -3
  180. package/build-module/tree-grid/index.js.map +1 -1
  181. package/build-module/utils/colors-values.js +3 -3
  182. package/build-module/utils/colors-values.js.map +1 -1
  183. package/build-module/utils/use-deprecated-props.js +25 -0
  184. package/build-module/utils/use-deprecated-props.js.map +1 -0
  185. package/build-module/view/component.js +1 -2
  186. package/build-module/view/component.js.map +1 -1
  187. package/build-style/style-rtl.css +83 -70
  188. package/build-style/style.css +83 -70
  189. package/build-types/autocomplete/autocompleter-ui.d.ts.map +1 -1
  190. package/build-types/autocomplete/index.d.ts.map +1 -1
  191. package/build-types/autocomplete/types.d.ts +2 -18
  192. package/build-types/autocomplete/types.d.ts.map +1 -1
  193. package/build-types/box-control/styles/box-control-styles.d.ts +1 -1
  194. package/build-types/button/deprecated.d.ts +12 -6
  195. package/build-types/button/deprecated.d.ts.map +1 -1
  196. package/build-types/button/index.d.ts.map +1 -1
  197. package/build-types/button/types.d.ts +7 -0
  198. package/build-types/button/types.d.ts.map +1 -1
  199. package/build-types/card/card-media/component.d.ts +2 -1
  200. package/build-types/card/card-media/component.d.ts.map +1 -1
  201. package/build-types/card/stories/index.d.ts +21 -1
  202. package/build-types/card/stories/index.d.ts.map +1 -1
  203. package/build-types/checkbox-control/index.d.ts.map +1 -1
  204. package/build-types/color-palette/styles.d.ts +1 -1
  205. package/build-types/color-picker/styles.d.ts +3 -3
  206. package/build-types/combobox-control/index.d.ts +1 -1
  207. package/build-types/combobox-control/index.d.ts.map +1 -1
  208. package/build-types/combobox-control/stories/index.d.ts.map +1 -1
  209. package/build-types/combobox-control/styles.d.ts +1 -1
  210. package/build-types/combobox-control/types.d.ts +8 -1
  211. package/build-types/combobox-control/types.d.ts.map +1 -1
  212. package/build-types/date-time/date/styles.d.ts +1 -1
  213. package/build-types/date-time/time/styles.d.ts +4 -4
  214. package/build-types/dimension-control/index.d.ts +1 -1
  215. package/build-types/draggable/index.d.ts +1 -1
  216. package/build-types/draggable/index.d.ts.map +1 -1
  217. package/build-types/draggable/stories/index.d.ts +8 -0
  218. package/build-types/draggable/stories/index.d.ts.map +1 -1
  219. package/build-types/draggable/types.d.ts +7 -0
  220. package/build-types/draggable/types.d.ts.map +1 -1
  221. package/build-types/focal-point-picker/styles/focal-point-picker-style.d.ts +1 -1
  222. package/build-types/form-token-field/index.d.ts.map +1 -1
  223. package/build-types/form-token-field/styles.d.ts +1 -1
  224. package/build-types/form-token-field/types.d.ts +8 -1
  225. package/build-types/form-token-field/types.d.ts.map +1 -1
  226. package/build-types/index.d.ts +1 -0
  227. package/build-types/index.d.ts.map +1 -1
  228. package/build-types/modal/index.d.ts.map +1 -1
  229. package/build-types/navigable-container/container.d.ts +20 -1
  230. package/build-types/navigable-container/container.d.ts.map +1 -1
  231. package/build-types/navigable-container/index.d.ts +5 -2
  232. package/build-types/navigable-container/index.d.ts.map +1 -1
  233. package/build-types/navigable-container/menu.d.ts +45 -11
  234. package/build-types/navigable-container/menu.d.ts.map +1 -1
  235. package/build-types/navigable-container/stories/navigable-menu.d.ts +12 -0
  236. package/build-types/navigable-container/stories/navigable-menu.d.ts.map +1 -0
  237. package/build-types/navigable-container/stories/tabbable-container.d.ts +12 -0
  238. package/build-types/navigable-container/stories/tabbable-container.d.ts.map +1 -0
  239. package/build-types/navigable-container/tabbable.d.ts +52 -9
  240. package/build-types/navigable-container/tabbable.d.ts.map +1 -1
  241. package/build-types/navigable-container/test/navigable-menu.d.ts +2 -0
  242. package/build-types/navigable-container/test/navigable-menu.d.ts.map +1 -0
  243. package/build-types/navigable-container/test/tababble-container.d.ts +2 -0
  244. package/build-types/navigable-container/test/tababble-container.d.ts.map +1 -0
  245. package/build-types/navigable-container/types.d.ts +61 -0
  246. package/build-types/navigable-container/types.d.ts.map +1 -0
  247. package/build-types/navigation/styles/navigation-styles.d.ts +1 -1
  248. package/build-types/navigator/navigator-back-button/component.d.ts +2 -1
  249. package/build-types/navigator/navigator-back-button/component.d.ts.map +1 -1
  250. package/build-types/navigator/navigator-back-button/hook.d.ts +2 -1
  251. package/build-types/navigator/navigator-back-button/hook.d.ts.map +1 -1
  252. package/build-types/navigator/navigator-button/component.d.ts +2 -1
  253. package/build-types/navigator/navigator-button/component.d.ts.map +1 -1
  254. package/build-types/navigator/navigator-button/hook.d.ts +2 -1
  255. package/build-types/navigator/navigator-button/hook.d.ts.map +1 -1
  256. package/build-types/navigator/navigator-screen/component.d.ts +1 -1
  257. package/build-types/navigator/navigator-screen/component.d.ts.map +1 -1
  258. package/build-types/navigator/navigator-to-parent-button/component.d.ts +2 -1
  259. package/build-types/navigator/navigator-to-parent-button/component.d.ts.map +1 -1
  260. package/build-types/number-control/index.d.ts +1 -1
  261. package/build-types/number-control/stories/index.d.ts +1 -1
  262. package/build-types/palette-edit/index.d.ts +1 -1
  263. package/build-types/palette-edit/index.d.ts.map +1 -1
  264. package/build-types/palette-edit/stories/index.d.ts.map +1 -1
  265. package/build-types/palette-edit/styles.d.ts +16 -10
  266. package/build-types/palette-edit/styles.d.ts.map +1 -1
  267. package/build-types/palette-edit/types.d.ts +8 -0
  268. package/build-types/palette-edit/types.d.ts.map +1 -1
  269. package/build-types/popover/index.d.ts +1 -1
  270. package/build-types/popover/index.d.ts.map +1 -1
  271. package/build-types/popover/stories/e2e/index.d.ts +1 -1
  272. package/build-types/private-apis.d.ts.map +1 -1
  273. package/build-types/range-control/styles/range-control-styles.d.ts +1 -1
  274. package/build-types/slot-fill/bubbles-virtually/fill.d.ts.map +1 -1
  275. package/build-types/slot-fill/bubbles-virtually/slot-fill-provider.d.ts.map +1 -1
  276. package/build-types/slot-fill/bubbles-virtually/use-slot.d.ts.map +1 -1
  277. package/build-types/slot-fill/fill.d.ts +4 -2
  278. package/build-types/slot-fill/fill.d.ts.map +1 -1
  279. package/build-types/slot-fill/index.d.ts +14 -3
  280. package/build-types/slot-fill/index.d.ts.map +1 -1
  281. package/build-types/slot-fill/provider.d.ts +0 -2
  282. package/build-types/slot-fill/provider.d.ts.map +1 -1
  283. package/build-types/slot-fill/slot.d.ts.map +1 -1
  284. package/build-types/spinner/styles.d.ts.map +1 -1
  285. package/build-types/toolbar/stories/index.d.ts.map +1 -1
  286. package/build-types/toolbar/toolbar-button/index.d.ts +12 -6
  287. package/build-types/toolbar/toolbar-button/index.d.ts.map +1 -1
  288. package/build-types/toolbar/toolbar-item/index.d.ts +6 -4
  289. package/build-types/toolbar/toolbar-item/index.d.ts.map +1 -1
  290. package/build-types/tree-grid/index.d.ts.map +1 -1
  291. package/build-types/tree-grid/types.d.ts +7 -0
  292. package/build-types/tree-grid/types.d.ts.map +1 -1
  293. package/build-types/ui/context/wordpress-component.d.ts +1 -1
  294. package/build-types/ui/context/wordpress-component.d.ts.map +1 -1
  295. package/build-types/unit-control/index.d.ts +1 -1
  296. package/build-types/unit-control/styles/unit-control-styles.d.ts +1 -1
  297. package/build-types/utils/use-deprecated-props.d.ts +9 -0
  298. package/build-types/utils/use-deprecated-props.d.ts.map +1 -0
  299. package/build-types/view/component.d.ts +1 -1
  300. package/build-types/view/component.d.ts.map +1 -1
  301. package/package.json +21 -22
  302. package/src/autocomplete/README.md +82 -54
  303. package/src/autocomplete/autocompleter-ui.tsx +0 -2
  304. package/src/autocomplete/index.tsx +1 -2
  305. package/src/autocomplete/types.ts +3 -19
  306. package/src/button/index.tsx +2 -0
  307. package/src/button/style.scss +13 -6
  308. package/src/button/types.ts +7 -0
  309. package/src/card/card-media/README.md +1 -1
  310. package/src/card/card-media/component.tsx +2 -1
  311. package/src/card/stories/index.tsx +47 -26
  312. package/src/checkbox-control/index.tsx +6 -2
  313. package/src/checkbox-control/style.scss +1 -4
  314. package/src/color-palette/index.native.js +20 -1
  315. package/src/color-picker/test/index.tsx +99 -99
  316. package/src/combobox-control/index.tsx +24 -18
  317. package/src/combobox-control/stories/index.tsx +0 -1
  318. package/src/combobox-control/styles.ts +4 -4
  319. package/src/combobox-control/types.ts +8 -1
  320. package/src/custom-gradient-picker/index.native.js +1 -1
  321. package/src/custom-gradient-picker/style.scss +2 -2
  322. package/src/dimension-control/README.md +1 -1
  323. package/src/dimension-control/index.tsx +1 -1
  324. package/src/draggable/README.md +8 -1
  325. package/src/draggable/index.tsx +7 -10
  326. package/src/draggable/stories/index.tsx +69 -33
  327. package/src/draggable/types.ts +7 -0
  328. package/src/form-toggle/style.scss +1 -5
  329. package/src/form-token-field/index.tsx +7 -3
  330. package/src/form-token-field/styles.ts +4 -4
  331. package/src/form-token-field/types.ts +8 -1
  332. package/src/index.ts +1 -0
  333. package/src/mobile/bottom-sheet/cell.native.js +4 -5
  334. package/src/mobile/color-settings/palette.screen.native.js +0 -7
  335. package/src/mobile/global-styles-context/index.native.js +12 -1
  336. package/src/mobile/global-styles-context/utils.native.js +18 -3
  337. package/src/mobile/link-picker/link-picker-results.native.js +3 -0
  338. package/src/mobile/segmented-control/index.native.js +2 -2
  339. package/src/modal/index.tsx +6 -1
  340. package/src/modal/style.scss +21 -13
  341. package/src/navigable-container/README.md +24 -13
  342. package/src/navigable-container/{container.js → container.tsx} +57 -27
  343. package/src/navigable-container/{index.js → index.tsx} +0 -1
  344. package/src/navigable-container/menu.tsx +100 -0
  345. package/src/navigable-container/stories/{navigable-menu.js → navigable-menu.tsx} +15 -10
  346. package/src/navigable-container/stories/{tabbable-container.js → tabbable-container.tsx} +15 -6
  347. package/src/navigable-container/tabbable.tsx +92 -0
  348. package/src/navigable-container/test/{navigable-menu.js → navigable-menu.tsx} +3 -1
  349. package/src/navigable-container/test/{tababble-container.js → tababble-container.tsx} +53 -24
  350. package/src/navigable-container/types.ts +76 -0
  351. package/src/navigator/navigator-screen/component.tsx +1 -1
  352. package/src/palette-edit/index.tsx +45 -7
  353. package/src/palette-edit/stories/index.tsx +4 -0
  354. package/src/palette-edit/types.ts +11 -0
  355. package/src/popover/index.tsx +2 -15
  356. package/src/private-apis.ts +2 -0
  357. package/src/sandbox/index.native.js +12 -1
  358. package/src/slot-fill/bubbles-virtually/fill.js +2 -1
  359. package/src/slot-fill/bubbles-virtually/slot-fill-provider.js +46 -60
  360. package/src/slot-fill/bubbles-virtually/use-slot.js +14 -41
  361. package/src/slot-fill/fill.js +4 -26
  362. package/src/slot-fill/index.js +14 -8
  363. package/src/slot-fill/provider.js +0 -6
  364. package/src/slot-fill/slot.js +0 -5
  365. package/src/snackbar/style.scss +2 -1
  366. package/src/spinner/styles.ts +2 -0
  367. package/src/style.scss +6 -0
  368. package/src/tab-panel/index.tsx +1 -1
  369. package/src/theme/color-algorithms.ts +1 -1
  370. package/src/theme/stories/index.tsx +1 -1
  371. package/src/theme/test/color-algorithms.ts +2 -2
  372. package/src/toggle-group-control/test/__snapshots__/index.tsx.snap +4 -4
  373. package/src/toolbar/stories/index.tsx +26 -24
  374. package/src/toolbar/toolbar-button/index.tsx +10 -13
  375. package/src/toolbar/toolbar-item/{index.js → index.tsx} +12 -3
  376. package/src/tree-grid/README.md +18 -0
  377. package/src/tree-grid/index.tsx +7 -2
  378. package/src/tree-grid/types.ts +7 -0
  379. package/src/ui/context/wordpress-component.ts +1 -1
  380. package/src/utils/colors-values.js +3 -3
  381. package/src/utils/theme-variables.scss +4 -4
  382. package/src/utils/use-deprecated-props.ts +29 -0
  383. package/src/view/component.tsx +2 -2
  384. package/tsconfig.json +3 -2
  385. package/tsconfig.tsbuildinfo +1 -1
  386. package/src/CONTRIBUTING.md +0 -78
  387. package/src/README.md +0 -20
  388. package/src/navigable-container/menu.js +0 -62
  389. package/src/navigable-container/tabbable.js +0 -46
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/components/src/color-palette/index.native.js"],"names":["ANIMATION_DURATION","contentWidth","scrollPosition","customIndicatorWidth","ColorPalette","enableCustomColor","setColor","activeColor","isGradientColor","defaultSettings","currentSegment","onCustomPress","shouldEnableBottomSheetScroll","shouldShowCustomIndicatorOption","shouldShowCustomLabel","shouldShowCustomVerticalSeparator","customColorIndicatorStyles","customIndicatorWrapperStyles","label","customSwatchGradients","scrollViewRef","isIOS","Platform","OS","isGradientSegment","colorsUtils","segments","scale","Animated","Value","current","opacity","defaultColors","Set","colors","map","color","mergedColors","allColors","defaultGradientColors","gradients","gradient","customIndicatorColor","isCustomGradientColor","isSelectedCustom","shouldShowCustomIndicator","accessibilityHint","customText","scrollToEndWithDelay","scrollTo","x","y","isWithinColors","includes","isSelected","timingAnimation","property","toValue","timing","duration","easing","Easing","ease","useNativeDriver","performAnimation","setValue","parallel","start","scaleInterpolation","interpolate","inputRange","outputRange","deselectCustomGradient","width","Dimensions","get","isVisible","onColorPress","onContentSizeChange","delayedScroll","setTimeout","scrollToEnd","clearTimeout","onCustomIndicatorLayout","nativeEvent","layout","onScroll","contentOffset","verticalSeparatorStyle","styles","verticalSeparator","verticalSeparatorDark","customTextStyle","customTextAndroid","customTextDark","customIndicatorWrapperStyle","customIndicatorWrapper","headerText","contentContainer","scaleValue","selected","transform","colorIndicator","toUpperCase"],"mappings":";;;;;;;;;AAkBA;;AAfA;;AAcA;;AAEA;;AAKA;;AACA;;AACA;;AA1BA;AACA;AACA;;AAYA;AACA;AACA;;AAKA;AACA;AACA;AAKA,MAAMA,kBAAkB,GAAG,GAA3B;AAEA,IAAIC,YAAY,GAAG,CAAnB;AACA,IAAIC,cAAc,GAAG,CAArB;AACA,IAAIC,oBAAoB,GAAG,CAA3B;;AAEA,SAASC,YAAT,OAeI;AAAA;;AAAA,MAfmB;AACtBC,IAAAA,iBAAiB,GAAG,IADE;AAEtBC,IAAAA,QAFsB;AAGtBC,IAAAA,WAHsB;AAItBC,IAAAA,eAJsB;AAKtBC,IAAAA,eALsB;AAMtBC,IAAAA,cANsB;AAOtBC,IAAAA,aAPsB;AAQtBC,IAAAA,6BARsB;AAStBC,IAAAA,+BAA+B,GAAG,IATZ;AAUtBC,IAAAA,qBAAqB,GAAG,IAVF;AAWtBC,IAAAA,iCAAiC,GAAG,IAXd;AAYtBC,IAAAA,0BAZsB;AAatBC,IAAAA,4BAbsB;AActBC,IAAAA;AAdsB,GAenB;AACH,QAAMC,qBAAqB,GAAG,CAC7B,0EAD6B,EAE7B,sEAF6B,EAG7B,sEAH6B,CAA9B;AAMA,QAAMC,aAAa,GAAG,sBAAtB;AACA,QAAMC,KAAK,GAAGC,sBAASC,EAAT,KAAgB,KAA9B;AAEA,QAAMC,iBAAiB,GAAGd,cAAc,KAAKe,mBAAYC,QAAZ,CAAsB,CAAtB,CAA7C;AAEA,QAAMC,KAAK,GAAG,qBAAQ,IAAIC,sBAASC,KAAb,CAAoB,CAApB,CAAR,EAAkCC,OAAhD;AACA,QAAMC,OAAO,GAAG,qBAAQ,IAAIH,sBAASC,KAAb,CAAoB,CAApB,CAAR,EAAkCC,OAAlD;A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qCAAD;AACC,IAAA,OAAO,EAAG7E,aADX;AAEC,IAAA,iBAAiB,EAAG,QAFrB;AAGC,IAAA,kBAAkB,EAAG;AACpByF,MAAAA,QAAQ,EAAExD,gBAAgB;AADN,KAHtB;AAMC,IAAA,iBAAiB,EAAGE;AANrB,KAQC,4BAAC,iBAAD;AAAM,IAAA,KAAK,EAAGiD;AAAd,KACC,4BAAC,uBAAD;AACC,IAAA,gBAAgB,EAAG,CAAEvE,iBADtB;AAEC,IAAA,KAAK,EAAGkB,oBAFT;AAGC,IAAA,UAAU,EAAGE,gBAAgB,EAH9B;AAIC,IAAA,KAAK,EAAG,CACP6C,eAAOa,cADA,EAEPtF,0BAFO;AAJT,IADD,EAUGF,qBAAqB,IACtB,4BAAC,iBAAD;AAAM,IAAA,KAAK,EAAG8E;AAAd,KACGvE,KAAK,GACJ0B,UADI,GAEJA,UAAU,CAACwD,WAAX,EAHJ,CAXF,CARD,CAPD,CAvDF,CAPD,CADD;AAsGA;;eAEcnG,Y","sourcesContent":["/**\n * External dependencies\n */\nimport {\n\tScrollView,\n\tTouchableWithoutFeedback,\n\tView,\n\tAnimated,\n\tEasing,\n\tDimensions,\n\tPlatform,\n\tText,\n} from 'react-native';\n\n/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { useRef, useEffect } from '@wordpress/element';\nimport { usePreferredColorSchemeStyle } from '@wordpress/compose';\n\n/**\n * Internal dependencies\n */\nimport styles from './style.scss';\nimport ColorIndicator from '../color-indicator';\nimport { colorsUtils } from '../mobile/color-settings/utils';\n\nconst ANIMATION_DURATION = 200;\n\nlet contentWidth = 0;\nlet scrollPosition = 0;\nlet customIndicatorWidth = 0;\n\nfunction ColorPalette( {\n\tenableCustomColor = true,\n\tsetColor,\n\tactiveColor,\n\tisGradientColor,\n\tdefaultSettings,\n\tcurrentSegment,\n\tonCustomPress,\n\tshouldEnableBottomSheetScroll,\n\tshouldShowCustomIndicatorOption = true,\n\tshouldShowCustomLabel = true,\n\tshouldShowCustomVerticalSeparator = true,\n\tcustomColorIndicatorStyles,\n\tcustomIndicatorWrapperStyles,\n\tlabel,\n} ) {\n\tconst customSwatchGradients = [\n\t\t'linear-gradient(120deg, rgba(255,0,0,.8) 0%, rgba(255,255,255,1) 70.71%)',\n\t\t'linear-gradient(240deg, rgba(0,255,0,.8) 0%, rgba(0,255,0,0) 70.71%)',\n\t\t'linear-gradient(360deg, rgba(0,0,255,.8) 0%, rgba(0,0,255,0) 70.71%)',\n\t];\n\n\tconst scrollViewRef = useRef();\n\tconst isIOS = Platform.OS === 'ios';\n\n\tconst isGradientSegment = currentSegment === colorsUtils.segments[ 1 ];\n\n\tconst scale = useRef( new Animated.Value( 1 ) ).current;\n\tconst opacity = useRef( new Animated.Value( 1 ) ).current;\n\n\tconst defaultColors = [\n\t\t...new Set(\n\t\t\t( defaultSettings.colors ?? [] ).map( ( { color } ) => color )\n\t\t),\n\t];\n\tconst mergedColors = [\n\t\t...new Set(\n\t\t\t( defaultSettings.allColors ?? [] ).map( ( { color } ) => color )\n\t\t),\n\t];\n\tconst defaultGradientColors = [\n\t\t...new Set(\n\t\t\t( defaultSettings.gradients ?? [] ).map(\n\t\t\t\t( { gradient } ) => gradient\n\t\t\t)\n\t\t),\n\t];\n\tconst colors = isGradientSegment ? defaultGradientColors : defaultColors;\n\n\tconst customIndicatorColor = isGradientSegment\n\t\t? activeColor\n\t\t: customSwatchGradients;\n\tconst isCustomGradientColor = isGradientColor && isSelectedCustom();\n\tconst shouldShowCustomIndicator =\n\t\tenableCustomColor &&\n\t\tshouldShowCustomIndicatorOption &&\n\t\t( ! isGradientSegment || isCustomGradientColor );\n\n\tconst accessibilityHint = isGradientSegment\n\t\t? __( 'Navigates to customize the gradient' )\n\t\t: __( 'Navigates to custom color picker' );\n\tconst customText = __( 'Custom' );\n\n\tuseEffect( () => {\n\t\tif ( scrollViewRef.current ) {\n\t\t\tif ( isSelectedCustom() ) {\n\t\t\t\tscrollToEndWithDelay();\n\t\t\t} else {\n\t\t\t\tscrollViewRef.current.scrollTo( { x: 0, y: 0 } );\n\t\t\t}\n\t\t}\n\t\t// Temporarily disabling exhuastive-deps until the component can be refactored and updated safely.\n\t\t// Please see https://github.com/WordPress/gutenberg/pull/41253 for discussion and details.\n\t\t// eslint-disable-next-line react-hooks/exhaustive-deps\n\t}, [ currentSegment ] );\n\n\tfunction isSelectedCustom() {\n\t\tconst isWithinColors =\n\t\t\tactiveColor && mergedColors && mergedColors.includes( activeColor );\n\t\tif ( enableCustomColor && activeColor ) {\n\t\t\tif ( isGradientSegment ) {\n\t\t\t\treturn isGradientColor && ! isWithinColors;\n\t\t\t}\n\t\t\treturn ! isGradientColor && ! isWithinColors;\n\t\t}\n\t\treturn false;\n\t}\n\n\tfunction isSelected( color ) {\n\t\treturn ! isSelectedCustom() && activeColor === color;\n\t}\n\n\tfunction timingAnimation( property, toValue ) {\n\t\treturn Animated.timing( property, {\n\t\t\ttoValue,\n\t\t\tduration: ANIMATION_DURATION,\n\t\t\teasing: Easing.ease,\n\t\t\tuseNativeDriver: true,\n\t\t} );\n\t}\n\n\tfunction performAnimation( color ) {\n\t\tif ( ! isSelected( color ) ) {\n\t\t\topacity.setValue( 0 );\n\t\t}\n\n\t\tAnimated.parallel( [\n\t\t\ttimingAnimation( scale, 2 ),\n\t\t\ttimingAnimation( opacity, 1 ),\n\t\t] ).start( () => {\n\t\t\topacity.setValue( 1 );\n\t\t\tscale.setValue( 1 );\n\t\t} );\n\t}\n\n\tconst scaleInterpolation = scale.interpolate( {\n\t\tinputRange: [ 1, 1.5, 2 ],\n\t\toutputRange: [ 1, 0.7, 1 ],\n\t} );\n\n\tfunction deselectCustomGradient() {\n\t\tconst { width } = Dimensions.get( 'window' );\n\t\tconst isVisible =\n\t\t\tcontentWidth - scrollPosition - customIndicatorWidth < width;\n\n\t\tif ( isCustomGradientColor ) {\n\t\t\tif ( ! isIOS ) {\n\t\t\t\t// Scroll position on Android doesn't adjust automatically when removing the last item from the horizontal list.\n\t\t\t\t// https://github.com/facebook/react-native/issues/27504\n\t\t\t\t// Workaround: Force the scroll when deselecting custom gradient color and when custom indicator is visible on layout.\n\t\t\t\tif (\n\t\t\t\t\tisCustomGradientColor &&\n\t\t\t\t\tisVisible &&\n\t\t\t\t\tscrollViewRef.current\n\t\t\t\t) {\n\t\t\t\t\tscrollViewRef.current.scrollTo( {\n\t\t\t\t\t\tx: scrollPosition - customIndicatorWidth,\n\t\t\t\t\t} );\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\tfunction onColorPress( color ) {\n\t\tdeselectCustomGradient();\n\t\tperformAnimation( color );\n\t\tsetColor( color );\n\t}\n\n\tfunction onContentSizeChange( width ) {\n\t\tcontentWidth = width;\n\t\tif ( isSelectedCustom() && scrollViewRef.current ) {\n\t\t\tscrollToEndWithDelay();\n\t\t}\n\t}\n\n\tfunction scrollToEndWithDelay() {\n\t\tconst delayedScroll = setTimeout( () => {\n\t\t\tscrollViewRef.current.scrollToEnd();\n\t\t}, ANIMATION_DURATION );\n\t\treturn () => {\n\t\t\tclearTimeout( delayedScroll );\n\t\t};\n\t}\n\n\tfunction onCustomIndicatorLayout( { nativeEvent } ) {\n\t\tconst { width } = nativeEvent.layout;\n\t\tif ( width !== customIndicatorWidth ) {\n\t\t\tcustomIndicatorWidth = width;\n\t\t}\n\t}\n\n\tfunction onScroll( { nativeEvent } ) {\n\t\tscrollPosition = nativeEvent.contentOffset.x;\n\t}\n\n\tconst verticalSeparatorStyle = usePreferredColorSchemeStyle(\n\t\tstyles.verticalSeparator,\n\t\tstyles.verticalSeparatorDark\n\t);\n\n\tconst customTextStyle = usePreferredColorSchemeStyle(\n\t\t[ styles.customText, ! isIOS && styles.customTextAndroid ],\n\t\tstyles.customTextDark\n\t);\n\n\tconst customIndicatorWrapperStyle = [\n\t\tstyles.customIndicatorWrapper,\n\t\tcustomIndicatorWrapperStyles,\n\t];\n\n\treturn (\n\t\t<>\n\t\t\t{ label && (\n\t\t\t\t<Text accessibilityRole=\"header\" style={ styles.headerText }>\n\t\t\t\t\t{ label }\n\t\t\t\t</Text>\n\t\t\t) }\n\n\t\t\t<ScrollView\n\t\t\t\tcontentContainerStyle={ styles.contentContainer }\n\t\t\t\thorizontal\n\t\t\t\tshowsHorizontalScrollIndicator={ false }\n\t\t\t\tkeyboardShouldPersistTaps=\"always\"\n\t\t\t\tdisableScrollViewPanResponder\n\t\t\t\tscrollEventThrottle={ 16 }\n\t\t\t\tonScroll={ onScroll }\n\t\t\t\tonContentSizeChange={ onContentSizeChange }\n\t\t\t\tonScrollBeginDrag={ () =>\n\t\t\t\t\tshouldEnableBottomSheetScroll( false )\n\t\t\t\t}\n\t\t\t\tonScrollEndDrag={ () => shouldEnableBottomSheetScroll( true ) }\n\t\t\t\tref={ scrollViewRef }\n\t\t\t\ttestID={ `color-palette${ label ? '-' + label : '' }` }\n\t\t\t>\n\t\t\t\t{ colors.map( ( color ) => {\n\t\t\t\t\tconst scaleValue = isSelected( color )\n\t\t\t\t\t\t? scaleInterpolation\n\t\t\t\t\t\t: 1;\n\t\t\t\t\treturn (\n\t\t\t\t\t\t<View key={ `${ color }-${ isSelected( color ) }` }>\n\t\t\t\t\t\t\t<TouchableWithoutFeedback\n\t\t\t\t\t\t\t\tonPress={ () => onColorPress( color ) }\n\t\t\t\t\t\t\t\taccessibilityRole={ 'button' }\n\t\t\t\t\t\t\t\taccessibilityState={ {\n\t\t\t\t\t\t\t\t\tselected: isSelected( color ),\n\t\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\t\taccessibilityHint={ color }\n\t\t\t\t\t\t\t\ttestID={ color }\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t<Animated.View\n\t\t\t\t\t\t\t\t\tstyle={ {\n\t\t\t\t\t\t\t\t\t\ttransform: [\n\t\t\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\t\t\tscale: scaleValue,\n\t\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t\t],\n\t\t\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t<ColorIndicator\n\t\t\t\t\t\t\t\t\t\tcolor={ color }\n\t\t\t\t\t\t\t\t\t\tisSelected={ isSelected( color ) }\n\t\t\t\t\t\t\t\t\t\topacity={ opacity }\n\t\t\t\t\t\t\t\t\t\tstyle={ [\n\t\t\t\t\t\t\t\t\t\t\tstyles.colorIndicator,\n\t\t\t\t\t\t\t\t\t\t\tcustomColorIndicatorStyles,\n\t\t\t\t\t\t\t\t\t\t] }\n\t\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t</Animated.View>\n\t\t\t\t\t\t\t</TouchableWithoutFeedback>\n\t\t\t\t\t\t</View>\n\t\t\t\t\t);\n\t\t\t\t} ) }\n\t\t\t\t{ shouldShowCustomIndicator && (\n\t\t\t\t\t<View\n\t\t\t\t\t\tstyle={ customIndicatorWrapperStyle }\n\t\t\t\t\t\tonLayout={ onCustomIndicatorLayout }\n\t\t\t\t\t>\n\t\t\t\t\t\t{ shouldShowCustomVerticalSeparator && (\n\t\t\t\t\t\t\t<View style={ verticalSeparatorStyle } />\n\t\t\t\t\t\t) }\n\t\t\t\t\t\t<TouchableWithoutFeedback\n\t\t\t\t\t\t\tonPress={ onCustomPress }\n\t\t\t\t\t\t\taccessibilityRole={ 'button' }\n\t\t\t\t\t\t\taccessibilityState={ {\n\t\t\t\t\t\t\t\tselected: isSelectedCustom(),\n\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\taccessibilityHint={ accessibilityHint }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t<View style={ customIndicatorWrapperStyle }>\n\t\t\t\t\t\t\t\t<ColorIndicator\n\t\t\t\t\t\t\t\t\twithCustomPicker={ ! isGradientSegment }\n\t\t\t\t\t\t\t\t\tcolor={ customIndicatorColor }\n\t\t\t\t\t\t\t\t\tisSelected={ isSelectedCustom() }\n\t\t\t\t\t\t\t\t\tstyle={ [\n\t\t\t\t\t\t\t\t\t\tstyles.colorIndicator,\n\t\t\t\t\t\t\t\t\t\tcustomColorIndicatorStyles,\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{ shouldShowCustomLabel && (\n\t\t\t\t\t\t\t\t\t<Text style={ customTextStyle }>\n\t\t\t\t\t\t\t\t\t\t{ isIOS\n\t\t\t\t\t\t\t\t\t\t\t? customText\n\t\t\t\t\t\t\t\t\t\t\t: customText.toUpperCase() }\n\t\t\t\t\t\t\t\t\t</Text>\n\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t</View>\n\t\t\t\t\t\t</TouchableWithoutFeedback>\n\t\t\t\t\t</View>\n\t\t\t\t) }\n\t\t\t</ScrollView>\n\t\t</>\n\t);\n}\n\nexport default ColorPalette;\n"]}
1
+ {"version":3,"sources":["@wordpress/components/src/color-palette/index.native.js"],"names":["ANIMATION_DURATION","contentWidth","scrollPosition","customIndicatorWidth","ColorPalette","enableCustomColor","setColor","activeColor","isGradientColor","defaultSettings","currentSegment","onCustomPress","shouldEnableBottomSheetScroll","shouldShowCustomIndicatorOption","shouldShowCustomLabel","shouldShowCustomVerticalSeparator","customColorIndicatorStyles","customIndicatorWrapperStyles","label","customSwatchGradients","scrollViewRef","isIOS","Platform","OS","isGradientSegment","colorsUtils","segments","scale","Animated","Value","current","opacity","defaultColors","Set","colors","map","color","mergedColors","allColors","defaultGradientColors","gradients","gradient","customIndicatorColor","isCustomGradientColor","isSelectedCustom","shouldShowCustomIndicator","accessibilityHint","customText","scrollToEndWithDelay","scrollTo","x","y","isWithinColors","includes","isSelected","timingAnimation","property","toValue","timing","duration","easing","Easing","ease","useNativeDriver","performAnimation","setValue","parallel","start","scaleInterpolation","interpolate","inputRange","outputRange","deselectCustomGradient","width","Dimensions","get","isVisible","getColorGradientName","value","fallbackName","foundColorName","find","name","onColorPress","onContentSizeChange","delayedScroll","setTimeout","scrollToEnd","clearTimeout","onCustomIndicatorLayout","nativeEvent","layout","onScroll","contentOffset","verticalSeparatorStyle","styles","verticalSeparator","verticalSeparatorDark","customTextStyle","customTextAndroid","customTextDark","customIndicatorWrapperStyle","customIndicatorWrapper","headerText","contentContainer","scaleValue","colorName","selected","transform","colorIndicator","toUpperCase"],"mappings":";;;;;;;;;AAkBA;;AAfA;;AAcA;;AAEA;;AAKA;;AACA;;AACA;;AA1BA;AACA;AACA;;AAYA;AACA;AACA;;AAKA;AACA;AACA;AAKA,MAAMA,kBAAkB,GAAG,GAA3B;AAEA,IAAIC,YAAY,GAAG,CAAnB;AACA,IAAIC,cAAc,GAAG,CAArB;AACA,IAAIC,oBAAoB,GAAG,CAA3B;;AAEA,SAASC,YAAT,OAeI;AAAA;;AAAA,MAfmB;AACtBC,IAAAA,iBAAiB,GAAG,IADE;AAEtBC,IAAAA,QAFsB;AAGtBC,IAAAA,WAHsB;AAItBC,IAAAA,eAJsB;AAKtBC,IAAAA,eALsB;AAMtBC,IAAAA,cANsB;AAOtBC,IAAAA,aAPsB;AAQtBC,IAAAA,6BARsB;AAStBC,IAAAA,+BAA+B,GAAG,IATZ;AAUtBC,IAAAA,qBAAqB,GAAG,IAVF;AAWtBC,IAAAA,iCAAiC,GAAG,IAXd;AAYtBC,IAAAA,0BAZsB;AAatBC,IAAAA,4BAbsB;AActBC,IAAAA;AAdsB,GAenB;AACH,QAAMC,qBAAqB,GAAG,CAC7B,0EAD6B,EAE7B,sEAF6B,EAG7B,sEAH6B,CAA9B;AAMA,QAAMC,aAAa,GAAG,sBAAtB;AACA,QAAMC,KAAK,GAAGC,sBAASC,EAAT,KAAgB,KAA9B;AAEA,QAAMC,iBAAiB,GAAGd,cAAc,KAAKe,mBAAYC,QAAZ,CAAsB,CAAtB,CAA7C;AAEA,QAAMC,KAAK,GAAG,qBAAQ,IAAIC,sBAASC,KAAb,CAAoB,CAApB,CAAR,EAAkCC,OAAhD;AACA,QAAMC,OAAO,GAAG,qBAAQ,IAAIH,sBAASC,KAAb,C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;AAyGA;;eAEc1G,Y","sourcesContent":["/**\n * External dependencies\n */\nimport {\n\tScrollView,\n\tTouchableWithoutFeedback,\n\tView,\n\tAnimated,\n\tEasing,\n\tDimensions,\n\tPlatform,\n\tText,\n} from 'react-native';\n\n/**\n * WordPress dependencies\n */\nimport { __, sprintf } from '@wordpress/i18n';\nimport { useRef, useEffect } from '@wordpress/element';\nimport { usePreferredColorSchemeStyle } from '@wordpress/compose';\n\n/**\n * Internal dependencies\n */\nimport styles from './style.scss';\nimport ColorIndicator from '../color-indicator';\nimport { colorsUtils } from '../mobile/color-settings/utils';\n\nconst ANIMATION_DURATION = 200;\n\nlet contentWidth = 0;\nlet scrollPosition = 0;\nlet customIndicatorWidth = 0;\n\nfunction ColorPalette( {\n\tenableCustomColor = true,\n\tsetColor,\n\tactiveColor,\n\tisGradientColor,\n\tdefaultSettings,\n\tcurrentSegment,\n\tonCustomPress,\n\tshouldEnableBottomSheetScroll,\n\tshouldShowCustomIndicatorOption = true,\n\tshouldShowCustomLabel = true,\n\tshouldShowCustomVerticalSeparator = true,\n\tcustomColorIndicatorStyles,\n\tcustomIndicatorWrapperStyles,\n\tlabel,\n} ) {\n\tconst customSwatchGradients = [\n\t\t'linear-gradient(120deg, rgba(255,0,0,.8) 0%, rgba(255,255,255,1) 70.71%)',\n\t\t'linear-gradient(240deg, rgba(0,255,0,.8) 0%, rgba(0,255,0,0) 70.71%)',\n\t\t'linear-gradient(360deg, rgba(0,0,255,.8) 0%, rgba(0,0,255,0) 70.71%)',\n\t];\n\n\tconst scrollViewRef = useRef();\n\tconst isIOS = Platform.OS === 'ios';\n\n\tconst isGradientSegment = currentSegment === colorsUtils.segments[ 1 ];\n\n\tconst scale = useRef( new Animated.Value( 1 ) ).current;\n\tconst opacity = useRef( new Animated.Value( 1 ) ).current;\n\n\tconst defaultColors = [\n\t\t...new Set(\n\t\t\t( defaultSettings.colors ?? [] ).map( ( { color } ) => color )\n\t\t),\n\t];\n\tconst mergedColors = [\n\t\t...new Set(\n\t\t\t( defaultSettings.allColors ?? [] ).map( ( { color } ) => color )\n\t\t),\n\t];\n\tconst defaultGradientColors = [\n\t\t...new Set(\n\t\t\t( defaultSettings.gradients ?? [] ).map(\n\t\t\t\t( { gradient } ) => gradient\n\t\t\t)\n\t\t),\n\t];\n\tconst colors = isGradientSegment ? defaultGradientColors : defaultColors;\n\n\tconst customIndicatorColor = isGradientSegment\n\t\t? activeColor\n\t\t: customSwatchGradients;\n\tconst isCustomGradientColor = isGradientColor && isSelectedCustom();\n\tconst shouldShowCustomIndicator =\n\t\tenableCustomColor &&\n\t\tshouldShowCustomIndicatorOption &&\n\t\t( ! isGradientSegment || isCustomGradientColor );\n\n\tconst accessibilityHint = isGradientSegment\n\t\t? __( 'Navigates to customize the gradient' )\n\t\t: __( 'Navigates to custom color picker' );\n\tconst customText = __( 'Custom' );\n\n\tuseEffect( () => {\n\t\tif ( scrollViewRef.current ) {\n\t\t\tif ( isSelectedCustom() ) {\n\t\t\t\tscrollToEndWithDelay();\n\t\t\t} else {\n\t\t\t\tscrollViewRef.current.scrollTo( { x: 0, y: 0 } );\n\t\t\t}\n\t\t}\n\t\t// Temporarily disabling exhuastive-deps until the component can be refactored and updated safely.\n\t\t// Please see https://github.com/WordPress/gutenberg/pull/41253 for discussion and details.\n\t\t// eslint-disable-next-line react-hooks/exhaustive-deps\n\t}, [ currentSegment ] );\n\n\tfunction isSelectedCustom() {\n\t\tconst isWithinColors =\n\t\t\tactiveColor && mergedColors && mergedColors.includes( activeColor );\n\t\tif ( enableCustomColor && activeColor ) {\n\t\t\tif ( isGradientSegment ) {\n\t\t\t\treturn isGradientColor && ! isWithinColors;\n\t\t\t}\n\t\t\treturn ! isGradientColor && ! isWithinColors;\n\t\t}\n\t\treturn false;\n\t}\n\n\tfunction isSelected( color ) {\n\t\treturn ! isSelectedCustom() && activeColor === color;\n\t}\n\n\tfunction timingAnimation( property, toValue ) {\n\t\treturn Animated.timing( property, {\n\t\t\ttoValue,\n\t\t\tduration: ANIMATION_DURATION,\n\t\t\teasing: Easing.ease,\n\t\t\tuseNativeDriver: true,\n\t\t} );\n\t}\n\n\tfunction performAnimation( color ) {\n\t\tif ( ! isSelected( color ) ) {\n\t\t\topacity.setValue( 0 );\n\t\t}\n\n\t\tAnimated.parallel( [\n\t\t\ttimingAnimation( scale, 2 ),\n\t\t\ttimingAnimation( opacity, 1 ),\n\t\t] ).start( () => {\n\t\t\topacity.setValue( 1 );\n\t\t\tscale.setValue( 1 );\n\t\t} );\n\t}\n\n\tconst scaleInterpolation = scale.interpolate( {\n\t\tinputRange: [ 1, 1.5, 2 ],\n\t\toutputRange: [ 1, 0.7, 1 ],\n\t} );\n\n\tfunction deselectCustomGradient() {\n\t\tconst { width } = Dimensions.get( 'window' );\n\t\tconst isVisible =\n\t\t\tcontentWidth - scrollPosition - customIndicatorWidth < width;\n\n\t\tif ( isCustomGradientColor ) {\n\t\t\tif ( ! isIOS ) {\n\t\t\t\t// Scroll position on Android doesn't adjust automatically when removing the last item from the horizontal list.\n\t\t\t\t// https://github.com/facebook/react-native/issues/27504\n\t\t\t\t// Workaround: Force the scroll when deselecting custom gradient color and when custom indicator is visible on layout.\n\t\t\t\tif (\n\t\t\t\t\tisCustomGradientColor &&\n\t\t\t\t\tisVisible &&\n\t\t\t\t\tscrollViewRef.current\n\t\t\t\t) {\n\t\t\t\t\tscrollViewRef.current.scrollTo( {\n\t\t\t\t\t\tx: scrollPosition - customIndicatorWidth,\n\t\t\t\t\t} );\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\tfunction getColorGradientName( value ) {\n\t\tconst fallbackName = sprintf(\n\t\t\t/* translators: %s: the hex color value */\n\t\t\t__( 'Unlabeled color. %s' ),\n\t\t\tvalue\n\t\t);\n\t\tconst foundColorName = isGradientSegment\n\t\t\t? defaultSettings.gradients?.find(\n\t\t\t\t\t( gradient ) => gradient.gradient === value\n\t\t\t )\n\t\t\t: defaultSettings.allColors?.find(\n\t\t\t\t\t( color ) => color.color === value\n\t\t\t );\n\t\treturn foundColorName ? foundColorName?.name : fallbackName;\n\t}\n\n\tfunction onColorPress( color ) {\n\t\tdeselectCustomGradient();\n\t\tperformAnimation( color );\n\t\tsetColor( color );\n\t}\n\n\tfunction onContentSizeChange( width ) {\n\t\tcontentWidth = width;\n\t\tif ( isSelectedCustom() && scrollViewRef.current ) {\n\t\t\tscrollToEndWithDelay();\n\t\t}\n\t}\n\n\tfunction scrollToEndWithDelay() {\n\t\tconst delayedScroll = setTimeout( () => {\n\t\t\tscrollViewRef.current.scrollToEnd();\n\t\t}, ANIMATION_DURATION );\n\t\treturn () => {\n\t\t\tclearTimeout( delayedScroll );\n\t\t};\n\t}\n\n\tfunction onCustomIndicatorLayout( { nativeEvent } ) {\n\t\tconst { width } = nativeEvent.layout;\n\t\tif ( width !== customIndicatorWidth ) {\n\t\t\tcustomIndicatorWidth = width;\n\t\t}\n\t}\n\n\tfunction onScroll( { nativeEvent } ) {\n\t\tscrollPosition = nativeEvent.contentOffset.x;\n\t}\n\n\tconst verticalSeparatorStyle = usePreferredColorSchemeStyle(\n\t\tstyles.verticalSeparator,\n\t\tstyles.verticalSeparatorDark\n\t);\n\n\tconst customTextStyle = usePreferredColorSchemeStyle(\n\t\t[ styles.customText, ! isIOS && styles.customTextAndroid ],\n\t\tstyles.customTextDark\n\t);\n\n\tconst customIndicatorWrapperStyle = [\n\t\tstyles.customIndicatorWrapper,\n\t\tcustomIndicatorWrapperStyles,\n\t];\n\n\treturn (\n\t\t<>\n\t\t\t{ label && (\n\t\t\t\t<Text accessibilityRole=\"header\" style={ styles.headerText }>\n\t\t\t\t\t{ label }\n\t\t\t\t</Text>\n\t\t\t) }\n\n\t\t\t<ScrollView\n\t\t\t\tcontentContainerStyle={ styles.contentContainer }\n\t\t\t\thorizontal\n\t\t\t\tshowsHorizontalScrollIndicator={ false }\n\t\t\t\tkeyboardShouldPersistTaps=\"always\"\n\t\t\t\tdisableScrollViewPanResponder\n\t\t\t\tscrollEventThrottle={ 16 }\n\t\t\t\tonScroll={ onScroll }\n\t\t\t\tonContentSizeChange={ onContentSizeChange }\n\t\t\t\tonScrollBeginDrag={ () =>\n\t\t\t\t\tshouldEnableBottomSheetScroll( false )\n\t\t\t\t}\n\t\t\t\tonScrollEndDrag={ () => shouldEnableBottomSheetScroll( true ) }\n\t\t\t\tref={ scrollViewRef }\n\t\t\t\ttestID={ `color-palette${ label ? '-' + label : '' }` }\n\t\t\t>\n\t\t\t\t{ colors.map( ( color ) => {\n\t\t\t\t\tconst scaleValue = isSelected( color )\n\t\t\t\t\t\t? scaleInterpolation\n\t\t\t\t\t\t: 1;\n\t\t\t\t\tconst colorName = getColorGradientName( color );\n\n\t\t\t\t\treturn (\n\t\t\t\t\t\t<View key={ `${ color }-${ isSelected( color ) }` }>\n\t\t\t\t\t\t\t<TouchableWithoutFeedback\n\t\t\t\t\t\t\t\tonPress={ () => onColorPress( color ) }\n\t\t\t\t\t\t\t\taccessibilityRole={ 'button' }\n\t\t\t\t\t\t\t\taccessibilityState={ {\n\t\t\t\t\t\t\t\t\tselected: isSelected( color ),\n\t\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\t\taccessibilityHint={ color }\n\t\t\t\t\t\t\t\taccessibilityLabel={ colorName }\n\t\t\t\t\t\t\t\ttestID={ color }\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t<Animated.View\n\t\t\t\t\t\t\t\t\tstyle={ {\n\t\t\t\t\t\t\t\t\t\ttransform: [\n\t\t\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\t\t\tscale: scaleValue,\n\t\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t\t],\n\t\t\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t<ColorIndicator\n\t\t\t\t\t\t\t\t\t\tcolor={ color }\n\t\t\t\t\t\t\t\t\t\tisSelected={ isSelected( color ) }\n\t\t\t\t\t\t\t\t\t\topacity={ opacity }\n\t\t\t\t\t\t\t\t\t\tstyle={ [\n\t\t\t\t\t\t\t\t\t\t\tstyles.colorIndicator,\n\t\t\t\t\t\t\t\t\t\t\tcustomColorIndicatorStyles,\n\t\t\t\t\t\t\t\t\t\t] }\n\t\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t</Animated.View>\n\t\t\t\t\t\t\t</TouchableWithoutFeedback>\n\t\t\t\t\t\t</View>\n\t\t\t\t\t);\n\t\t\t\t} ) }\n\t\t\t\t{ shouldShowCustomIndicator && (\n\t\t\t\t\t<View\n\t\t\t\t\t\tstyle={ customIndicatorWrapperStyle }\n\t\t\t\t\t\tonLayout={ onCustomIndicatorLayout }\n\t\t\t\t\t>\n\t\t\t\t\t\t{ shouldShowCustomVerticalSeparator && (\n\t\t\t\t\t\t\t<View style={ verticalSeparatorStyle } />\n\t\t\t\t\t\t) }\n\t\t\t\t\t\t<TouchableWithoutFeedback\n\t\t\t\t\t\t\tonPress={ onCustomPress }\n\t\t\t\t\t\t\taccessibilityRole={ 'button' }\n\t\t\t\t\t\t\taccessibilityState={ {\n\t\t\t\t\t\t\t\tselected: isSelectedCustom(),\n\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\taccessibilityHint={ accessibilityHint }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t<View style={ customIndicatorWrapperStyle }>\n\t\t\t\t\t\t\t\t<ColorIndicator\n\t\t\t\t\t\t\t\t\twithCustomPicker={ ! isGradientSegment }\n\t\t\t\t\t\t\t\t\tcolor={ customIndicatorColor }\n\t\t\t\t\t\t\t\t\tisSelected={ isSelectedCustom() }\n\t\t\t\t\t\t\t\t\tstyle={ [\n\t\t\t\t\t\t\t\t\t\tstyles.colorIndicator,\n\t\t\t\t\t\t\t\t\t\tcustomColorIndicatorStyles,\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{ shouldShowCustomLabel && (\n\t\t\t\t\t\t\t\t\t<Text style={ customTextStyle }>\n\t\t\t\t\t\t\t\t\t\t{ isIOS\n\t\t\t\t\t\t\t\t\t\t\t? customText\n\t\t\t\t\t\t\t\t\t\t\t: customText.toUpperCase() }\n\t\t\t\t\t\t\t\t\t</Text>\n\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t</View>\n\t\t\t\t\t\t</TouchableWithoutFeedback>\n\t\t\t\t\t</View>\n\t\t\t\t) }\n\t\t\t</ScrollView>\n\t\t</>\n\t);\n}\n\nexport default ColorPalette;\n"]}
@@ -37,6 +37,8 @@ var _hooks = require("../utils/hooks");
37
37
 
38
38
  var _strings = require("../utils/strings");
39
39
 
40
+ var _useDeprecatedProps = require("../utils/use-deprecated-props");
41
+
40
42
  /**
41
43
  * External dependencies
42
44
  */
@@ -113,12 +115,12 @@ const getIndexOfMatchingSuggestion = (selectedSuggestion, matchingSuggestions) =
113
115
  */
114
116
 
115
117
 
116
- function ComboboxControl(_ref) {
118
+ function ComboboxControl(props) {
117
119
  var _currentOption$label;
118
120
 
119
- let {
121
+ const {
120
122
  __nextHasNoMarginBottom = false,
121
- __next36pxDefaultSize = false,
123
+ __next40pxDefaultSize = false,
122
124
  value: valueProp,
123
125
  label,
124
126
  options,
@@ -132,7 +134,7 @@ function ComboboxControl(_ref) {
132
134
  selected: (0, _i18n.__)('Item selected.')
133
135
  },
134
136
  __experimentalRenderItem
135
- } = _ref;
137
+ } = (0, _useDeprecatedProps.useDeprecated36pxDefaultSizeProp)(props, 'wp.components.ComboboxControl');
136
138
  const [value, setValue] = (0, _hooks.useControlledValue)({
137
139
  value: valueProp,
138
140
  onChange: onChangeProp
@@ -304,7 +306,7 @@ function ComboboxControl(_ref) {
304
306
  tabIndex: -1,
305
307
  onKeyDown: onKeyDown
306
308
  }, (0, _element.createElement)(_styles.InputWrapperFlex, {
307
- __next36pxDefaultSize: __next36pxDefaultSize
309
+ __next40pxDefaultSize: __next40pxDefaultSize
308
310
  }, (0, _element.createElement)(_flex.FlexBlock, null, (0, _element.createElement)(_tokenInput.default, {
309
311
  className: "components-combobox-control__input",
310
312
  instanceId: instanceId,
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/components/src/combobox-control/index.tsx"],"names":["noop","DetectOutside","Component","handleFocusOutside","event","props","onFocusOutside","render","children","getIndexOfMatchingSuggestion","selectedSuggestion","matchingSuggestions","indexOf","ComboboxControl","__nextHasNoMarginBottom","__next36pxDefaultSize","value","valueProp","label","options","onChange","onChangeProp","onFilterValueChange","hideLabelFromVision","help","allowReset","className","messages","selected","__experimentalRenderItem","setValue","currentOption","find","option","currentLabel","instanceId","setSelectedSuggestion","isExpanded","setIsExpanded","inputHasFocus","setInputHasFocus","inputValue","setInputValue","inputContainer","startsWithMatch","containsMatch","match","forEach","index","push","concat","onSuggestionSelected","newSelectedSuggestion","handleArrowNavigation","offset","nextIndex","length","onKeyDown","preventDefault","defaultPrevented","nativeEvent","isComposing","keyCode","code","onBlur","onFocus","onInputChange","text","handleOnReset","current","focus","hasMatchingSuggestions","hasSelectedMatchingSuggestions","message","closeSmall","suggestion"],"mappings":";;;;;;;;;AASA;;AANA;;AAKA;;AAQA;;AACA;;AACA;;AAKA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AA/BA;AACA;AACA;;AAGA;AACA;AACA;;AAaA;AACA;AACA;AAaA,MAAMA,IAAI,GAAG,MAAM,CAAE,CAArB;;AAEA,MAAMC,aAAa,GAAG,+BACrB,cAAcC,kBAAd,CAAwB;AACvB;AACAC,EAAAA,kBAAkB,CAAEC,KAAF,EAAU;AAC3B;AACA,SAAKC,KAAL,CAAWC,cAAX,CAA2BF,KAA3B;AACA;;AAEDG,EAAAA,MAAM,GAAG;AACR;AACA,WAAO,KAAKF,KAAL,CAAWG,QAAlB;AACA;;AAVsB,CADH,CAAtB;;AAeA,MAAMC,4BAA4B,GAAG,CACpCC,kBADoC,EAEpCC,mBAFoC,KAIpCD,kBAAkB,KAAK,IAAvB,GACG,CAAC,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IAAA,uBAAuB,EAAG5B,4BAA4B,CACrDC,kBADqD,EAErDC,mBAFqD,CARvD;AAYC,IAAA,QAAQ,EAAGuD;AAZZ,IADD,CAHD,EAmBGzC,UAAU,IACX,4BAAC,cAAD,QACC,4BAAC,eAAD;AACC,IAAA,SAAS,EAAC,oCADX;AAEC,IAAA,IAAI,EAAGiD,iBAFR;AAGC,IAAA,QAAQ,EAAG,CAAE1D,KAHd;AAIC,IAAA,OAAO,EAAGoD,aAJX;AAKC,IAAA,KAAK,EAAG,cAAI,OAAJ;AALT,IADD,CApBF,CALD,EAoCG/B,UAAU,IACX,4BAAC,wBAAD;AACC,IAAA,UAAU,EAAGF,UADd,CAEC;AACA;AACA;AAJD;AAKC,IAAA,KAAK,EAAG;AAAEjB,MAAAA,KAAK,EAAEuB,UAAT;AAAqBzB,MAAAA,KAAK,EAAE;AAA5B,KALT;AAMC,IAAA,gBAAgB,EAAK2D,UAAF,IAClBA,UAAU,CAACzD,KAPb;AASC,IAAA,WAAW,EAAGP,mBATf;AAUC,IAAA,aAAa,EAAGF,4BAA4B,CAC3CC,kBAD2C,EAE3CC,mBAF2C,CAV7C;AAcC,IAAA,OAAO,EAAGyB,qBAdX;AAeC,IAAA,QAAQ,EAAGe,oBAfZ;AAgBC,IAAA,cAAc,MAhBf;AAiBC,IAAA,wBAAwB,EACvBtB;AAlBF,IArCF,CAXD,CADD,CADD;AA4EA;AACA;;eAEchB,e","sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport { __, _n, sprintf } from '@wordpress/i18n';\nimport {\n\tComponent,\n\tuseState,\n\tuseMemo,\n\tuseRef,\n\tuseEffect,\n} from '@wordpress/element';\nimport { useInstanceId } from '@wordpress/compose';\nimport { speak } from '@wordpress/a11y';\nimport { closeSmall } from '@wordpress/icons';\n\n/**\n * Internal dependencies\n */\nimport { InputWrapperFlex } from './styles';\nimport TokenInput from '../form-token-field/token-input';\nimport SuggestionsList from '../form-token-field/suggestions-list';\nimport BaseControl from '../base-control';\nimport Button from '../button';\nimport { FlexBlock, FlexItem } from '../flex';\nimport withFocusOutside from '../higher-order/with-focus-outside';\nimport { useControlledValue } from '../utils/hooks';\nimport { normalizeTextString } from '../utils/strings';\nimport type { ComboboxControlOption, ComboboxControlProps } from './types';\nimport type { TokenInputProps } from '../form-token-field/types';\n\nconst noop = () => {};\n\nconst DetectOutside = withFocusOutside(\n\tclass extends Component {\n\t\t// @ts-expect-error - TODO: Should be resolved when `withFocusOutside` is refactored to TypeScript\n\t\thandleFocusOutside( event ) {\n\t\t\t// @ts-expect-error - TODO: Should be resolved when `withFocusOutside` is refactored to TypeScript\n\t\t\tthis.props.onFocusOutside( event );\n\t\t}\n\n\t\trender() {\n\t\t\t// @ts-expect-error - TODO: Should be resolved when `withFocusOutside` is refactored to TypeScript\n\t\t\treturn this.props.children;\n\t\t}\n\t}\n);\n\nconst getIndexOfMatchingSuggestion = (\n\tselectedSuggestion: ComboboxControlOption | null,\n\tmatchingSuggestions: ComboboxControlOption[]\n) =>\n\tselectedSuggestion === null\n\t\t? -1\n\t\t: matchingSuggestions.indexOf( selectedSuggestion );\n\n/**\n * `ComboboxControl` is an enhanced version of a [`SelectControl`](../select-control/README.md) with the addition of\n * being able to search for options using a search input.\n *\n * ```jsx\n * import { ComboboxControl } from '@wordpress/components';\n * import { useState } from '@wordpress/element';\n *\n * const options = [\n * \t{\n * \t\tvalue: 'small',\n * \t\tlabel: 'Small',\n * \t},\n * \t{\n * \t\tvalue: 'normal',\n * \t\tlabel: 'Normal',\n * \t},\n * \t{\n * \t\tvalue: 'large',\n * \t\tlabel: 'Large',\n * \t},\n * ];\n *\n * function MyComboboxControl() {\n * \tconst [ fontSize, setFontSize ] = useState();\n * \tconst [ filteredOptions, setFilteredOptions ] = useState( options );\n * \treturn (\n * \t\t<ComboboxControl\n * \t\t\tlabel=\"Font Size\"\n * \t\t\tvalue={ fontSize }\n * \t\t\tonChange={ setFontSize }\n * \t\t\toptions={ filteredOptions }\n * \t\t\tonFilterValueChange={ ( inputValue ) =>\n * \t\t\t\tsetFilteredOptions(\n * \t\t\t\t\toptions.filter( ( option ) =>\n * \t\t\t\t\t\toption.label\n * \t\t\t\t\t\t\t.toLowerCase()\n * \t\t\t\t\t\t\t.startsWith( inputValue.toLowerCase() )\n * \t\t\t\t\t)\n * \t\t\t\t)\n * \t\t\t}\n * \t\t/>\n * \t);\n * }\n * ```\n */\nfunction ComboboxControl( {\n\t__nextHasNoMarginBottom = false,\n\t__next36pxDefaultSize = false,\n\tvalue: valueProp,\n\tlabel,\n\toptions,\n\tonChange: onChangeProp,\n\tonFilterValueChange = noop,\n\thideLabelFromVision,\n\thelp,\n\tallowReset = true,\n\tclassName,\n\tmessages = {\n\t\tselected: __( 'Item selected.' ),\n\t},\n\t__experimentalRenderItem,\n}: ComboboxControlProps ) {\n\tconst [ value, setValue ] = useControlledValue( {\n\t\tvalue: valueProp,\n\t\tonChange: onChangeProp,\n\t} );\n\n\tconst currentOption = options.find( ( option ) => option.value === value );\n\tconst currentLabel = currentOption?.label ?? '';\n\t// Use a custom prefix when generating the `instanceId` to avoid having\n\t// duplicate input IDs when rendering this component and `FormTokenField`\n\t// in the same page (see https://github.com/WordPress/gutenberg/issues/42112).\n\tconst instanceId = useInstanceId( ComboboxControl, 'combobox-control' );\n\tconst [ selectedSuggestion, setSelectedSuggestion ] = useState(\n\t\tcurrentOption || null\n\t);\n\tconst [ isExpanded, setIsExpanded ] = useState( false );\n\tconst [ inputHasFocus, setInputHasFocus ] = useState( false );\n\tconst [ inputValue, setInputValue ] = useState( '' );\n\tconst inputContainer = useRef< HTMLInputElement >( null );\n\n\tconst matchingSuggestions = useMemo( () => {\n\t\tconst startsWithMatch: ComboboxControlOption[] = [];\n\t\tconst containsMatch: ComboboxControlOption[] = [];\n\t\tconst match = normalizeTextString( inputValue );\n\t\toptions.forEach( ( option ) => {\n\t\t\tconst index = normalizeTextString( option.label ).indexOf( match );\n\t\t\tif ( index === 0 ) {\n\t\t\t\tstartsWithMatch.push( option );\n\t\t\t} else if ( index > 0 ) {\n\t\t\t\tcontainsMatch.push( option );\n\t\t\t}\n\t\t} );\n\n\t\treturn startsWithMatch.concat( containsMatch );\n\t}, [ inputValue, options ] );\n\n\tconst onSuggestionSelected = (\n\t\tnewSelectedSuggestion: ComboboxControlOption\n\t) => {\n\t\tsetValue( newSelectedSuggestion.value );\n\t\tspeak( messages.selected, 'assertive' );\n\t\tsetSelectedSuggestion( newSelectedSuggestion );\n\t\tsetInputValue( '' );\n\t\tsetIsExpanded( false );\n\t};\n\n\tconst handleArrowNavigation = ( offset = 1 ) => {\n\t\tconst index = getIndexOfMatchingSuggestion(\n\t\t\tselectedSuggestion,\n\t\t\tmatchingSuggestions\n\t\t);\n\t\tlet nextIndex = index + offset;\n\t\tif ( nextIndex < 0 ) {\n\t\t\tnextIndex = matchingSuggestions.length - 1;\n\t\t} else if ( nextIndex >= matchingSuggestions.length ) {\n\t\t\tnextIndex = 0;\n\t\t}\n\t\tsetSelectedSuggestion( matchingSuggestions[ nextIndex ] );\n\t\tsetIsExpanded( true );\n\t};\n\n\tconst onKeyDown: React.KeyboardEventHandler< HTMLDivElement > = (\n\t\tevent\n\t) => {\n\t\tlet preventDefault = false;\n\n\t\tif (\n\t\t\tevent.defaultPrevented ||\n\t\t\t// Ignore keydowns from IMEs\n\t\t\tevent.nativeEvent.isComposing ||\n\t\t\t// Workaround for Mac Safari where the final Enter/Backspace of an IME composition\n\t\t\t// is `isComposing=false`, even though it's technically still part of the composition.\n\t\t\t// These can only be detected by keyCode.\n\t\t\tevent.keyCode === 229\n\t\t) {\n\t\t\treturn;\n\t\t}\n\n\t\tswitch ( event.code ) {\n\t\t\tcase 'Enter':\n\t\t\t\tif ( selectedSuggestion ) {\n\t\t\t\t\tonSuggestionSelected( selectedSuggestion );\n\t\t\t\t\tpreventDefault = true;\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\tcase 'ArrowUp':\n\t\t\t\thandleArrowNavigation( -1 );\n\t\t\t\tpreventDefault = true;\n\t\t\t\tbreak;\n\t\t\tcase 'ArrowDown':\n\t\t\t\thandleArrowNavigation( 1 );\n\t\t\t\tpreventDefault = true;\n\t\t\t\tbreak;\n\t\t\tcase 'Escape':\n\t\t\t\tsetIsExpanded( false );\n\t\t\t\tsetSelectedSuggestion( null );\n\t\t\t\tpreventDefault = true;\n\t\t\t\tbreak;\n\t\t\tdefault:\n\t\t\t\tbreak;\n\t\t}\n\n\t\tif ( preventDefault ) {\n\t\t\tevent.preventDefault();\n\t\t}\n\t};\n\n\tconst onBlur = () => {\n\t\tsetInputHasFocus( false );\n\t};\n\n\tconst onFocus = () => {\n\t\tsetInputHasFocus( true );\n\t\tsetIsExpanded( true );\n\t\tonFilterValueChange( '' );\n\t\tsetInputValue( '' );\n\t};\n\n\tconst onFocusOutside = () => {\n\t\tsetIsExpanded( false );\n\t};\n\n\tconst onInputChange: TokenInputProps[ 'onChange' ] = ( event ) => {\n\t\tconst text = event.value;\n\t\tsetInputValue( text );\n\t\tonFilterValueChange( text );\n\t\tif ( inputHasFocus ) {\n\t\t\tsetIsExpanded( true );\n\t\t}\n\t};\n\n\tconst handleOnReset = () => {\n\t\tsetValue( null );\n\t\tinputContainer.current?.focus();\n\t};\n\n\t// Update current selections when the filter input changes.\n\tuseEffect( () => {\n\t\tconst hasMatchingSuggestions = matchingSuggestions.length > 0;\n\t\tconst hasSelectedMatchingSuggestions =\n\t\t\tgetIndexOfMatchingSuggestion(\n\t\t\t\tselectedSuggestion,\n\t\t\t\tmatchingSuggestions\n\t\t\t) > 0;\n\n\t\tif ( hasMatchingSuggestions && ! hasSelectedMatchingSuggestions ) {\n\t\t\t// If the current selection isn't present in the list of suggestions, then automatically select the first item from the list of suggestions.\n\t\t\tsetSelectedSuggestion( matchingSuggestions[ 0 ] );\n\t\t}\n\t}, [ matchingSuggestions, selectedSuggestion ] );\n\n\t// Announcements.\n\tuseEffect( () => {\n\t\tconst hasMatchingSuggestions = matchingSuggestions.length > 0;\n\t\tif ( isExpanded ) {\n\t\t\tconst message = hasMatchingSuggestions\n\t\t\t\t? sprintf(\n\t\t\t\t\t\t/* translators: %d: number of results. */\n\t\t\t\t\t\t_n(\n\t\t\t\t\t\t\t'%d result found, use up and down arrow keys to navigate.',\n\t\t\t\t\t\t\t'%d results found, use up and down arrow keys to navigate.',\n\t\t\t\t\t\t\tmatchingSuggestions.length\n\t\t\t\t\t\t),\n\t\t\t\t\t\tmatchingSuggestions.length\n\t\t\t\t )\n\t\t\t\t: __( 'No results.' );\n\n\t\t\tspeak( message, 'polite' );\n\t\t}\n\t}, [ matchingSuggestions, isExpanded ] );\n\n\t// Disable reason: There is no appropriate role which describes the\n\t// input container intended accessible usability.\n\t// TODO: Refactor click detection to use blur to stop propagation.\n\t/* eslint-disable jsx-a11y/no-static-element-interactions */\n\treturn (\n\t\t<DetectOutside onFocusOutside={ onFocusOutside }>\n\t\t\t<BaseControl\n\t\t\t\t__nextHasNoMarginBottom={ __nextHasNoMarginBottom }\n\t\t\t\tclassName={ classnames(\n\t\t\t\t\tclassName,\n\t\t\t\t\t'components-combobox-control'\n\t\t\t\t) }\n\t\t\t\tlabel={ label }\n\t\t\t\tid={ `components-form-token-input-${ instanceId }` }\n\t\t\t\thideLabelFromVision={ hideLabelFromVision }\n\t\t\t\thelp={ help }\n\t\t\t>\n\t\t\t\t<div\n\t\t\t\t\tclassName=\"components-combobox-control__suggestions-container\"\n\t\t\t\t\ttabIndex={ -1 }\n\t\t\t\t\tonKeyDown={ onKeyDown }\n\t\t\t\t>\n\t\t\t\t\t<InputWrapperFlex\n\t\t\t\t\t\t__next36pxDefaultSize={ __next36pxDefaultSize }\n\t\t\t\t\t>\n\t\t\t\t\t\t<FlexBlock>\n\t\t\t\t\t\t\t<TokenInput\n\t\t\t\t\t\t\t\tclassName=\"components-combobox-control__input\"\n\t\t\t\t\t\t\t\tinstanceId={ instanceId }\n\t\t\t\t\t\t\t\tref={ inputContainer }\n\t\t\t\t\t\t\t\tvalue={ isExpanded ? inputValue : currentLabel }\n\t\t\t\t\t\t\t\tonFocus={ onFocus }\n\t\t\t\t\t\t\t\tonBlur={ onBlur }\n\t\t\t\t\t\t\t\tisExpanded={ isExpanded }\n\t\t\t\t\t\t\t\tselectedSuggestionIndex={ getIndexOfMatchingSuggestion(\n\t\t\t\t\t\t\t\t\tselectedSuggestion,\n\t\t\t\t\t\t\t\t\tmatchingSuggestions\n\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\tonChange={ onInputChange }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t</FlexBlock>\n\t\t\t\t\t\t{ allowReset && (\n\t\t\t\t\t\t\t<FlexItem>\n\t\t\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\t\t\tclassName=\"components-combobox-control__reset\"\n\t\t\t\t\t\t\t\t\ticon={ closeSmall }\n\t\t\t\t\t\t\t\t\tdisabled={ ! value }\n\t\t\t\t\t\t\t\t\tonClick={ handleOnReset }\n\t\t\t\t\t\t\t\t\tlabel={ __( 'Reset' ) }\n\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t</FlexItem>\n\t\t\t\t\t\t) }\n\t\t\t\t\t</InputWrapperFlex>\n\t\t\t\t\t{ isExpanded && (\n\t\t\t\t\t\t<SuggestionsList\n\t\t\t\t\t\t\tinstanceId={ instanceId }\n\t\t\t\t\t\t\t// The empty string for `value` here is not actually used, but is\n\t\t\t\t\t\t\t// just a quick way to satisfy the TypeScript requirements of SuggestionsList.\n\t\t\t\t\t\t\t// See: https://github.com/WordPress/gutenberg/pull/47581/files#r1091089330\n\t\t\t\t\t\t\tmatch={ { label: inputValue, value: '' } }\n\t\t\t\t\t\t\tdisplayTransform={ ( suggestion ) =>\n\t\t\t\t\t\t\t\tsuggestion.label\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tsuggestions={ matchingSuggestions }\n\t\t\t\t\t\t\tselectedIndex={ getIndexOfMatchingSuggestion(\n\t\t\t\t\t\t\t\tselectedSuggestion,\n\t\t\t\t\t\t\t\tmatchingSuggestions\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\tonHover={ setSelectedSuggestion }\n\t\t\t\t\t\t\tonSelect={ onSuggestionSelected }\n\t\t\t\t\t\t\tscrollIntoView\n\t\t\t\t\t\t\t__experimentalRenderItem={\n\t\t\t\t\t\t\t\t__experimentalRenderItem\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t/>\n\t\t\t\t\t) }\n\t\t\t\t</div>\n\t\t\t</BaseControl>\n\t\t</DetectOutside>\n\t);\n\t/* eslint-enable jsx-a11y/no-static-element-interactions */\n}\n\nexport default ComboboxControl;\n"]}
1
+ {"version":3,"sources":["@wordpress/components/src/combobox-control/index.tsx"],"names":["noop","DetectOutside","Component","handleFocusOutside","event","props","onFocusOutside","render","children","getIndexOfMatchingSuggestion","selectedSuggestion","matchingSuggestions","indexOf","ComboboxControl","__nextHasNoMarginBottom","__next40pxDefaultSize","value","valueProp","label","options","onChange","onChangeProp","onFilterValueChange","hideLabelFromVision","help","allowReset","className","messages","selected","__experimentalRenderItem","setValue","currentOption","find","option","currentLabel","instanceId","setSelectedSuggestion","isExpanded","setIsExpanded","inputHasFocus","setInputHasFocus","inputValue","setInputValue","inputContainer","startsWithMatch","containsMatch","match","forEach","index","push","concat","onSuggestionSelected","newSelectedSuggestion","handleArrowNavigation","offset","nextIndex","length","onKeyDown","preventDefault","defaultPrevented","nativeEvent","isComposing","keyCode","code","onBlur","onFocus","onInputChange","text","handleOnReset","current","focus","hasMatchingSuggestions","hasSelectedMatchingSuggestions","message","closeSmall","suggestion"],"mappings":";;;;;;;;;AASA;;AANA;;AAKA;;AAQA;;AACA;;AACA;;AAKA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AAGA;;AAlCA;AACA;AACA;;AAGA;AACA;AACA;;AAaA;AACA;AACA;AAcA,MAAMA,IAAI,GAAG,MAAM,CAAE,CAArB;;AAEA,MAAM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D,CADD;AA4EA;AACA;;eAEchB,e","sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport { __, _n, sprintf } from '@wordpress/i18n';\nimport {\n\tComponent,\n\tuseState,\n\tuseMemo,\n\tuseRef,\n\tuseEffect,\n} from '@wordpress/element';\nimport { useInstanceId } from '@wordpress/compose';\nimport { speak } from '@wordpress/a11y';\nimport { closeSmall } from '@wordpress/icons';\n\n/**\n * Internal dependencies\n */\nimport { InputWrapperFlex } from './styles';\nimport TokenInput from '../form-token-field/token-input';\nimport SuggestionsList from '../form-token-field/suggestions-list';\nimport BaseControl from '../base-control';\nimport Button from '../button';\nimport { FlexBlock, FlexItem } from '../flex';\nimport withFocusOutside from '../higher-order/with-focus-outside';\nimport { useControlledValue } from '../utils/hooks';\nimport { normalizeTextString } from '../utils/strings';\nimport type { ComboboxControlOption, ComboboxControlProps } from './types';\nimport type { TokenInputProps } from '../form-token-field/types';\nimport { useDeprecated36pxDefaultSizeProp } from '../utils/use-deprecated-props';\n\nconst noop = () => {};\n\nconst DetectOutside = withFocusOutside(\n\tclass extends Component {\n\t\t// @ts-expect-error - TODO: Should be resolved when `withFocusOutside` is refactored to TypeScript\n\t\thandleFocusOutside( event ) {\n\t\t\t// @ts-expect-error - TODO: Should be resolved when `withFocusOutside` is refactored to TypeScript\n\t\t\tthis.props.onFocusOutside( event );\n\t\t}\n\n\t\trender() {\n\t\t\t// @ts-expect-error - TODO: Should be resolved when `withFocusOutside` is refactored to TypeScript\n\t\t\treturn this.props.children;\n\t\t}\n\t}\n);\n\nconst getIndexOfMatchingSuggestion = (\n\tselectedSuggestion: ComboboxControlOption | null,\n\tmatchingSuggestions: ComboboxControlOption[]\n) =>\n\tselectedSuggestion === null\n\t\t? -1\n\t\t: matchingSuggestions.indexOf( selectedSuggestion );\n\n/**\n * `ComboboxControl` is an enhanced version of a [`SelectControl`](../select-control/README.md) with the addition of\n * being able to search for options using a search input.\n *\n * ```jsx\n * import { ComboboxControl } from '@wordpress/components';\n * import { useState } from '@wordpress/element';\n *\n * const options = [\n * \t{\n * \t\tvalue: 'small',\n * \t\tlabel: 'Small',\n * \t},\n * \t{\n * \t\tvalue: 'normal',\n * \t\tlabel: 'Normal',\n * \t},\n * \t{\n * \t\tvalue: 'large',\n * \t\tlabel: 'Large',\n * \t},\n * ];\n *\n * function MyComboboxControl() {\n * \tconst [ fontSize, setFontSize ] = useState();\n * \tconst [ filteredOptions, setFilteredOptions ] = useState( options );\n * \treturn (\n * \t\t<ComboboxControl\n * \t\t\tlabel=\"Font Size\"\n * \t\t\tvalue={ fontSize }\n * \t\t\tonChange={ setFontSize }\n * \t\t\toptions={ filteredOptions }\n * \t\t\tonFilterValueChange={ ( inputValue ) =>\n * \t\t\t\tsetFilteredOptions(\n * \t\t\t\t\toptions.filter( ( option ) =>\n * \t\t\t\t\t\toption.label\n * \t\t\t\t\t\t\t.toLowerCase()\n * \t\t\t\t\t\t\t.startsWith( inputValue.toLowerCase() )\n * \t\t\t\t\t)\n * \t\t\t\t)\n * \t\t\t}\n * \t\t/>\n * \t);\n * }\n * ```\n */\nfunction ComboboxControl( props: ComboboxControlProps ) {\n\tconst {\n\t\t__nextHasNoMarginBottom = false,\n\t\t__next40pxDefaultSize = false,\n\t\tvalue: valueProp,\n\t\tlabel,\n\t\toptions,\n\t\tonChange: onChangeProp,\n\t\tonFilterValueChange = noop,\n\t\thideLabelFromVision,\n\t\thelp,\n\t\tallowReset = true,\n\t\tclassName,\n\t\tmessages = {\n\t\t\tselected: __( 'Item selected.' ),\n\t\t},\n\t\t__experimentalRenderItem,\n\t} = useDeprecated36pxDefaultSizeProp< ComboboxControlProps >(\n\t\tprops,\n\t\t'wp.components.ComboboxControl'\n\t);\n\n\tconst [ value, setValue ] = useControlledValue( {\n\t\tvalue: valueProp,\n\t\tonChange: onChangeProp,\n\t} );\n\n\tconst currentOption = options.find( ( option ) => option.value === value );\n\tconst currentLabel = currentOption?.label ?? '';\n\t// Use a custom prefix when generating the `instanceId` to avoid having\n\t// duplicate input IDs when rendering this component and `FormTokenField`\n\t// in the same page (see https://github.com/WordPress/gutenberg/issues/42112).\n\tconst instanceId = useInstanceId( ComboboxControl, 'combobox-control' );\n\tconst [ selectedSuggestion, setSelectedSuggestion ] = useState(\n\t\tcurrentOption || null\n\t);\n\tconst [ isExpanded, setIsExpanded ] = useState( false );\n\tconst [ inputHasFocus, setInputHasFocus ] = useState( false );\n\tconst [ inputValue, setInputValue ] = useState( '' );\n\tconst inputContainer = useRef< HTMLInputElement >( null );\n\n\tconst matchingSuggestions = useMemo( () => {\n\t\tconst startsWithMatch: ComboboxControlOption[] = [];\n\t\tconst containsMatch: ComboboxControlOption[] = [];\n\t\tconst match = normalizeTextString( inputValue );\n\t\toptions.forEach( ( option ) => {\n\t\t\tconst index = normalizeTextString( option.label ).indexOf( match );\n\t\t\tif ( index === 0 ) {\n\t\t\t\tstartsWithMatch.push( option );\n\t\t\t} else if ( index > 0 ) {\n\t\t\t\tcontainsMatch.push( option );\n\t\t\t}\n\t\t} );\n\n\t\treturn startsWithMatch.concat( containsMatch );\n\t}, [ inputValue, options ] );\n\n\tconst onSuggestionSelected = (\n\t\tnewSelectedSuggestion: ComboboxControlOption\n\t) => {\n\t\tsetValue( newSelectedSuggestion.value );\n\t\tspeak( messages.selected, 'assertive' );\n\t\tsetSelectedSuggestion( newSelectedSuggestion );\n\t\tsetInputValue( '' );\n\t\tsetIsExpanded( false );\n\t};\n\n\tconst handleArrowNavigation = ( offset = 1 ) => {\n\t\tconst index = getIndexOfMatchingSuggestion(\n\t\t\tselectedSuggestion,\n\t\t\tmatchingSuggestions\n\t\t);\n\t\tlet nextIndex = index + offset;\n\t\tif ( nextIndex < 0 ) {\n\t\t\tnextIndex = matchingSuggestions.length - 1;\n\t\t} else if ( nextIndex >= matchingSuggestions.length ) {\n\t\t\tnextIndex = 0;\n\t\t}\n\t\tsetSelectedSuggestion( matchingSuggestions[ nextIndex ] );\n\t\tsetIsExpanded( true );\n\t};\n\n\tconst onKeyDown: React.KeyboardEventHandler< HTMLDivElement > = (\n\t\tevent\n\t) => {\n\t\tlet preventDefault = false;\n\n\t\tif (\n\t\t\tevent.defaultPrevented ||\n\t\t\t// Ignore keydowns from IMEs\n\t\t\tevent.nativeEvent.isComposing ||\n\t\t\t// Workaround for Mac Safari where the final Enter/Backspace of an IME composition\n\t\t\t// is `isComposing=false`, even though it's technically still part of the composition.\n\t\t\t// These can only be detected by keyCode.\n\t\t\tevent.keyCode === 229\n\t\t) {\n\t\t\treturn;\n\t\t}\n\n\t\tswitch ( event.code ) {\n\t\t\tcase 'Enter':\n\t\t\t\tif ( selectedSuggestion ) {\n\t\t\t\t\tonSuggestionSelected( selectedSuggestion );\n\t\t\t\t\tpreventDefault = true;\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\tcase 'ArrowUp':\n\t\t\t\thandleArrowNavigation( -1 );\n\t\t\t\tpreventDefault = true;\n\t\t\t\tbreak;\n\t\t\tcase 'ArrowDown':\n\t\t\t\thandleArrowNavigation( 1 );\n\t\t\t\tpreventDefault = true;\n\t\t\t\tbreak;\n\t\t\tcase 'Escape':\n\t\t\t\tsetIsExpanded( false );\n\t\t\t\tsetSelectedSuggestion( null );\n\t\t\t\tpreventDefault = true;\n\t\t\t\tbreak;\n\t\t\tdefault:\n\t\t\t\tbreak;\n\t\t}\n\n\t\tif ( preventDefault ) {\n\t\t\tevent.preventDefault();\n\t\t}\n\t};\n\n\tconst onBlur = () => {\n\t\tsetInputHasFocus( false );\n\t};\n\n\tconst onFocus = () => {\n\t\tsetInputHasFocus( true );\n\t\tsetIsExpanded( true );\n\t\tonFilterValueChange( '' );\n\t\tsetInputValue( '' );\n\t};\n\n\tconst onFocusOutside = () => {\n\t\tsetIsExpanded( false );\n\t};\n\n\tconst onInputChange: TokenInputProps[ 'onChange' ] = ( event ) => {\n\t\tconst text = event.value;\n\t\tsetInputValue( text );\n\t\tonFilterValueChange( text );\n\t\tif ( inputHasFocus ) {\n\t\t\tsetIsExpanded( true );\n\t\t}\n\t};\n\n\tconst handleOnReset = () => {\n\t\tsetValue( null );\n\t\tinputContainer.current?.focus();\n\t};\n\n\t// Update current selections when the filter input changes.\n\tuseEffect( () => {\n\t\tconst hasMatchingSuggestions = matchingSuggestions.length > 0;\n\t\tconst hasSelectedMatchingSuggestions =\n\t\t\tgetIndexOfMatchingSuggestion(\n\t\t\t\tselectedSuggestion,\n\t\t\t\tmatchingSuggestions\n\t\t\t) > 0;\n\n\t\tif ( hasMatchingSuggestions && ! hasSelectedMatchingSuggestions ) {\n\t\t\t// If the current selection isn't present in the list of suggestions, then automatically select the first item from the list of suggestions.\n\t\t\tsetSelectedSuggestion( matchingSuggestions[ 0 ] );\n\t\t}\n\t}, [ matchingSuggestions, selectedSuggestion ] );\n\n\t// Announcements.\n\tuseEffect( () => {\n\t\tconst hasMatchingSuggestions = matchingSuggestions.length > 0;\n\t\tif ( isExpanded ) {\n\t\t\tconst message = hasMatchingSuggestions\n\t\t\t\t? sprintf(\n\t\t\t\t\t\t/* translators: %d: number of results. */\n\t\t\t\t\t\t_n(\n\t\t\t\t\t\t\t'%d result found, use up and down arrow keys to navigate.',\n\t\t\t\t\t\t\t'%d results found, use up and down arrow keys to navigate.',\n\t\t\t\t\t\t\tmatchingSuggestions.length\n\t\t\t\t\t\t),\n\t\t\t\t\t\tmatchingSuggestions.length\n\t\t\t\t )\n\t\t\t\t: __( 'No results.' );\n\n\t\t\tspeak( message, 'polite' );\n\t\t}\n\t}, [ matchingSuggestions, isExpanded ] );\n\n\t// Disable reason: There is no appropriate role which describes the\n\t// input container intended accessible usability.\n\t// TODO: Refactor click detection to use blur to stop propagation.\n\t/* eslint-disable jsx-a11y/no-static-element-interactions */\n\treturn (\n\t\t<DetectOutside onFocusOutside={ onFocusOutside }>\n\t\t\t<BaseControl\n\t\t\t\t__nextHasNoMarginBottom={ __nextHasNoMarginBottom }\n\t\t\t\tclassName={ classnames(\n\t\t\t\t\tclassName,\n\t\t\t\t\t'components-combobox-control'\n\t\t\t\t) }\n\t\t\t\tlabel={ label }\n\t\t\t\tid={ `components-form-token-input-${ instanceId }` }\n\t\t\t\thideLabelFromVision={ hideLabelFromVision }\n\t\t\t\thelp={ help }\n\t\t\t>\n\t\t\t\t<div\n\t\t\t\t\tclassName=\"components-combobox-control__suggestions-container\"\n\t\t\t\t\ttabIndex={ -1 }\n\t\t\t\t\tonKeyDown={ onKeyDown }\n\t\t\t\t>\n\t\t\t\t\t<InputWrapperFlex\n\t\t\t\t\t\t__next40pxDefaultSize={ __next40pxDefaultSize }\n\t\t\t\t\t>\n\t\t\t\t\t\t<FlexBlock>\n\t\t\t\t\t\t\t<TokenInput\n\t\t\t\t\t\t\t\tclassName=\"components-combobox-control__input\"\n\t\t\t\t\t\t\t\tinstanceId={ instanceId }\n\t\t\t\t\t\t\t\tref={ inputContainer }\n\t\t\t\t\t\t\t\tvalue={ isExpanded ? inputValue : currentLabel }\n\t\t\t\t\t\t\t\tonFocus={ onFocus }\n\t\t\t\t\t\t\t\tonBlur={ onBlur }\n\t\t\t\t\t\t\t\tisExpanded={ isExpanded }\n\t\t\t\t\t\t\t\tselectedSuggestionIndex={ getIndexOfMatchingSuggestion(\n\t\t\t\t\t\t\t\t\tselectedSuggestion,\n\t\t\t\t\t\t\t\t\tmatchingSuggestions\n\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\tonChange={ onInputChange }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t</FlexBlock>\n\t\t\t\t\t\t{ allowReset && (\n\t\t\t\t\t\t\t<FlexItem>\n\t\t\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\t\t\tclassName=\"components-combobox-control__reset\"\n\t\t\t\t\t\t\t\t\ticon={ closeSmall }\n\t\t\t\t\t\t\t\t\tdisabled={ ! value }\n\t\t\t\t\t\t\t\t\tonClick={ handleOnReset }\n\t\t\t\t\t\t\t\t\tlabel={ __( 'Reset' ) }\n\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t</FlexItem>\n\t\t\t\t\t\t) }\n\t\t\t\t\t</InputWrapperFlex>\n\t\t\t\t\t{ isExpanded && (\n\t\t\t\t\t\t<SuggestionsList\n\t\t\t\t\t\t\tinstanceId={ instanceId }\n\t\t\t\t\t\t\t// The empty string for `value` here is not actually used, but is\n\t\t\t\t\t\t\t// just a quick way to satisfy the TypeScript requirements of SuggestionsList.\n\t\t\t\t\t\t\t// See: https://github.com/WordPress/gutenberg/pull/47581/files#r1091089330\n\t\t\t\t\t\t\tmatch={ { label: inputValue, value: '' } }\n\t\t\t\t\t\t\tdisplayTransform={ ( suggestion ) =>\n\t\t\t\t\t\t\t\tsuggestion.label\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tsuggestions={ matchingSuggestions }\n\t\t\t\t\t\t\tselectedIndex={ getIndexOfMatchingSuggestion(\n\t\t\t\t\t\t\t\tselectedSuggestion,\n\t\t\t\t\t\t\t\tmatchingSuggestions\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\tonHover={ setSelectedSuggestion }\n\t\t\t\t\t\t\tonSelect={ onSuggestionSelected }\n\t\t\t\t\t\t\tscrollIntoView\n\t\t\t\t\t\t\t__experimentalRenderItem={\n\t\t\t\t\t\t\t\t__experimentalRenderItem\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t/>\n\t\t\t\t\t) }\n\t\t\t\t</div>\n\t\t\t</BaseControl>\n\t\t</DetectOutside>\n\t);\n\t/* eslint-enable jsx-a11y/no-static-element-interactions */\n}\n\nexport default ComboboxControl;\n"]}
@@ -24,9 +24,9 @@ var _space = require("../ui/utils/space");
24
24
  */
25
25
  const deprecatedDefaultSize = _ref => {
26
26
  let {
27
- __next36pxDefaultSize
27
+ __next40pxDefaultSize
28
28
  } = _ref;
29
- return !__next36pxDefaultSize && /*#__PURE__*/(0, _react.css)("height:28px;padding-left:", (0, _space.space)(1), ";padding-right:", (0, _space.space)(1), ";" + (process.env.NODE_ENV === "production" ? "" : ";label:deprecatedDefaultSize;"), process.env.NODE_ENV === "production" ? "" : "/*# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIkB3b3JkcHJlc3MvY29tcG9uZW50cy9zcmMvY29tYm9ib3gtY29udHJvbC9zdHlsZXMudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBaUJJIiwiZmlsZSI6IkB3b3JkcHJlc3MvY29tcG9uZW50cy9zcmMvY29tYm9ib3gtY29udHJvbC9zdHlsZXMudHMiLCJzb3VyY2VzQ29udGVudCI6WyIvKipcbiAqIEV4dGVybmFsIGRlcGVuZGVuY2llc1xuICovXG5pbXBvcnQgc3R5bGVkIGZyb20gJ0BlbW90aW9uL3N0eWxlZCc7XG5pbXBvcnQgeyBjc3MgfSBmcm9tICdAZW1vdGlvbi9yZWFjdCc7XG5cbi8qKlxuICogSW50ZXJuYWwgZGVwZW5kZW5jaWVzXG4gKi9cbmltcG9ydCB7IEZsZXggfSBmcm9tICcuLi9mbGV4JztcbmltcG9ydCB7IHNwYWNlIH0gZnJvbSAnLi4vdWkvdXRpbHMvc3BhY2UnO1xuaW1wb3J0IHR5cGUgeyBDb21ib2JveENvbnRyb2xQcm9wcyB9IGZyb20gJy4vdHlwZXMnO1xuXG5jb25zdCBkZXByZWNhdGVkRGVmYXVsdFNpemUgPSAoIHtcblx0X19uZXh0MzZweERlZmF1bHRTaXplLFxufTogUGljazwgQ29tYm9ib3hDb250cm9sUHJvcHMsICdfX25leHQzNnB4RGVmYXVsdFNpemUnID4gKSA9PlxuXHQhIF9fbmV4dDM2cHhEZWZhdWx0U2l6ZSAmJlxuXHRjc3NgXG5cdFx0aGVpZ2h0OiAyOHB4OyAvLyAzMHB4IC0gMnB4IHZlcnRpY2FsIGJvcmRlcnMgb24gcGFyZW50IGNvbnRhaW5lclxuXHRcdHBhZGRpbmctbGVmdDogJHsgc3BhY2UoIDEgKSB9O1xuXHRcdHBhZGRpbmctcmlnaHQ6ICR7IHNwYWNlKCAxICkgfTtcblx0YDtcblxuZXhwb3J0IGNvbnN0IElucHV0V3JhcHBlckZsZXggPSBzdHlsZWQoIEZsZXggKWBcblx0aGVpZ2h0OiAzNHB4OyAvLyAzNnB4IC0gMnB4IHZlcnRpY2FsIGJvcmRlcnMgb24gcGFyZW50IGNvbnRhaW5lclxuXHRwYWRkaW5nLWxlZnQ6ICR7IHNwYWNlKCAyICkgfTtcblx0cGFkZGluZy1yaWdodDogJHsgc3BhY2UoIDIgKSB9O1xuXG5cdCR7IGRlcHJlY2F0ZWREZWZhdWx0U2l6ZSB9XG5gO1xuIl19 */");
29
+ return !__next40pxDefaultSize && /*#__PURE__*/(0, _react.css)("height:28px;padding-left:", (0, _space.space)(1), ";padding-right:", (0, _space.space)(1), ";" + (process.env.NODE_ENV === "production" ? "" : ";label:deprecatedDefaultSize;"), process.env.NODE_ENV === "production" ? "" : "/*# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIkB3b3JkcHJlc3MvY29tcG9uZW50cy9zcmMvY29tYm9ib3gtY29udHJvbC9zdHlsZXMudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBaUJJIiwiZmlsZSI6IkB3b3JkcHJlc3MvY29tcG9uZW50cy9zcmMvY29tYm9ib3gtY29udHJvbC9zdHlsZXMudHMiLCJzb3VyY2VzQ29udGVudCI6WyIvKipcbiAqIEV4dGVybmFsIGRlcGVuZGVuY2llc1xuICovXG5pbXBvcnQgc3R5bGVkIGZyb20gJ0BlbW90aW9uL3N0eWxlZCc7XG5pbXBvcnQgeyBjc3MgfSBmcm9tICdAZW1vdGlvbi9yZWFjdCc7XG5cbi8qKlxuICogSW50ZXJuYWwgZGVwZW5kZW5jaWVzXG4gKi9cbmltcG9ydCB7IEZsZXggfSBmcm9tICcuLi9mbGV4JztcbmltcG9ydCB7IHNwYWNlIH0gZnJvbSAnLi4vdWkvdXRpbHMvc3BhY2UnO1xuaW1wb3J0IHR5cGUgeyBDb21ib2JveENvbnRyb2xQcm9wcyB9IGZyb20gJy4vdHlwZXMnO1xuXG5jb25zdCBkZXByZWNhdGVkRGVmYXVsdFNpemUgPSAoIHtcblx0X19uZXh0NDBweERlZmF1bHRTaXplLFxufTogUGljazwgQ29tYm9ib3hDb250cm9sUHJvcHMsICdfX25leHQ0MHB4RGVmYXVsdFNpemUnID4gKSA9PlxuXHQhIF9fbmV4dDQwcHhEZWZhdWx0U2l6ZSAmJlxuXHRjc3NgXG5cdFx0aGVpZ2h0OiAyOHB4OyAvLyAzMHB4IC0gMnB4IHZlcnRpY2FsIGJvcmRlcnMgb24gcGFyZW50IGNvbnRhaW5lclxuXHRcdHBhZGRpbmctbGVmdDogJHsgc3BhY2UoIDEgKSB9O1xuXHRcdHBhZGRpbmctcmlnaHQ6ICR7IHNwYWNlKCAxICkgfTtcblx0YDtcblxuZXhwb3J0IGNvbnN0IElucHV0V3JhcHBlckZsZXggPSBzdHlsZWQoIEZsZXggKWBcblx0aGVpZ2h0OiAzOHB4OyAvLyA0MHB4IC0gMnB4IHZlcnRpY2FsIGJvcmRlcnMgb24gcGFyZW50IGNvbnRhaW5lclxuXHRwYWRkaW5nLWxlZnQ6ICR7IHNwYWNlKCAyICkgfTtcblx0cGFkZGluZy1yaWdodDogJHsgc3BhY2UoIDIgKSB9O1xuXG5cdCR7IGRlcHJlY2F0ZWREZWZhdWx0U2l6ZSB9XG5gO1xuIl19 */");
30
30
  };
31
31
 
32
32
  const InputWrapperFlex = ( /*#__PURE__*/0, _base.default)(_flex.Flex, process.env.NODE_ENV === "production" ? {
@@ -34,6 +34,6 @@ const InputWrapperFlex = ( /*#__PURE__*/0, _base.default)(_flex.Flex, process.en
34
34
  } : {
35
35
  target: "evuatpg0",
36
36
  label: "InputWrapperFlex"
37
- })("height:34px;padding-left:", (0, _space.space)(2), ";padding-right:", (0, _space.space)(2), ";", deprecatedDefaultSize, ";" + (process.env.NODE_ENV === "production" ? "" : "/*# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIkB3b3JkcHJlc3MvY29tcG9uZW50cy9zcmMvY29tYm9ib3gtY29udHJvbC9zdHlsZXMudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBdUI4QyIsImZpbGUiOiJAd29yZHByZXNzL2NvbXBvbmVudHMvc3JjL2NvbWJvYm94LWNvbnRyb2wvc3R5bGVzLnRzIiwic291cmNlc0NvbnRlbnQiOlsiLyoqXG4gKiBFeHRlcm5hbCBkZXBlbmRlbmNpZXNcbiAqL1xuaW1wb3J0IHN0eWxlZCBmcm9tICdAZW1vdGlvbi9zdHlsZWQnO1xuaW1wb3J0IHsgY3NzIH0gZnJvbSAnQGVtb3Rpb24vcmVhY3QnO1xuXG4vKipcbiAqIEludGVybmFsIGRlcGVuZGVuY2llc1xuICovXG5pbXBvcnQgeyBGbGV4IH0gZnJvbSAnLi4vZmxleCc7XG5pbXBvcnQgeyBzcGFjZSB9IGZyb20gJy4uL3VpL3V0aWxzL3NwYWNlJztcbmltcG9ydCB0eXBlIHsgQ29tYm9ib3hDb250cm9sUHJvcHMgfSBmcm9tICcuL3R5cGVzJztcblxuY29uc3QgZGVwcmVjYXRlZERlZmF1bHRTaXplID0gKCB7XG5cdF9fbmV4dDM2cHhEZWZhdWx0U2l6ZSxcbn06IFBpY2s8IENvbWJvYm94Q29udHJvbFByb3BzLCAnX19uZXh0MzZweERlZmF1bHRTaXplJyA+ICkgPT5cblx0ISBfX25leHQzNnB4RGVmYXVsdFNpemUgJiZcblx0Y3NzYFxuXHRcdGhlaWdodDogMjhweDsgLy8gMzBweCAtIDJweCB2ZXJ0aWNhbCBib3JkZXJzIG9uIHBhcmVudCBjb250YWluZXJcblx0XHRwYWRkaW5nLWxlZnQ6ICR7IHNwYWNlKCAxICkgfTtcblx0XHRwYWRkaW5nLXJpZ2h0OiAkeyBzcGFjZSggMSApIH07XG5cdGA7XG5cbmV4cG9ydCBjb25zdCBJbnB1dFdyYXBwZXJGbGV4ID0gc3R5bGVkKCBGbGV4IClgXG5cdGhlaWdodDogMzRweDsgLy8gMzZweCAtIDJweCB2ZXJ0aWNhbCBib3JkZXJzIG9uIHBhcmVudCBjb250YWluZXJcblx0cGFkZGluZy1sZWZ0OiAkeyBzcGFjZSggMiApIH07XG5cdHBhZGRpbmctcmlnaHQ6ICR7IHNwYWNlKCAyICkgfTtcblxuXHQkeyBkZXByZWNhdGVkRGVmYXVsdFNpemUgfVxuYDtcbiJdfQ== */"));
37
+ })("height:38px;padding-left:", (0, _space.space)(2), ";padding-right:", (0, _space.space)(2), ";", deprecatedDefaultSize, ";" + (process.env.NODE_ENV === "production" ? "" : "/*# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIkB3b3JkcHJlc3MvY29tcG9uZW50cy9zcmMvY29tYm9ib3gtY29udHJvbC9zdHlsZXMudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBdUI4QyIsImZpbGUiOiJAd29yZHByZXNzL2NvbXBvbmVudHMvc3JjL2NvbWJvYm94LWNvbnRyb2wvc3R5bGVzLnRzIiwic291cmNlc0NvbnRlbnQiOlsiLyoqXG4gKiBFeHRlcm5hbCBkZXBlbmRlbmNpZXNcbiAqL1xuaW1wb3J0IHN0eWxlZCBmcm9tICdAZW1vdGlvbi9zdHlsZWQnO1xuaW1wb3J0IHsgY3NzIH0gZnJvbSAnQGVtb3Rpb24vcmVhY3QnO1xuXG4vKipcbiAqIEludGVybmFsIGRlcGVuZGVuY2llc1xuICovXG5pbXBvcnQgeyBGbGV4IH0gZnJvbSAnLi4vZmxleCc7XG5pbXBvcnQgeyBzcGFjZSB9IGZyb20gJy4uL3VpL3V0aWxzL3NwYWNlJztcbmltcG9ydCB0eXBlIHsgQ29tYm9ib3hDb250cm9sUHJvcHMgfSBmcm9tICcuL3R5cGVzJztcblxuY29uc3QgZGVwcmVjYXRlZERlZmF1bHRTaXplID0gKCB7XG5cdF9fbmV4dDQwcHhEZWZhdWx0U2l6ZSxcbn06IFBpY2s8IENvbWJvYm94Q29udHJvbFByb3BzLCAnX19uZXh0NDBweERlZmF1bHRTaXplJyA+ICkgPT5cblx0ISBfX25leHQ0MHB4RGVmYXVsdFNpemUgJiZcblx0Y3NzYFxuXHRcdGhlaWdodDogMjhweDsgLy8gMzBweCAtIDJweCB2ZXJ0aWNhbCBib3JkZXJzIG9uIHBhcmVudCBjb250YWluZXJcblx0XHRwYWRkaW5nLWxlZnQ6ICR7IHNwYWNlKCAxICkgfTtcblx0XHRwYWRkaW5nLXJpZ2h0OiAkeyBzcGFjZSggMSApIH07XG5cdGA7XG5cbmV4cG9ydCBjb25zdCBJbnB1dFdyYXBwZXJGbGV4ID0gc3R5bGVkKCBGbGV4IClgXG5cdGhlaWdodDogMzhweDsgLy8gNDBweCAtIDJweCB2ZXJ0aWNhbCBib3JkZXJzIG9uIHBhcmVudCBjb250YWluZXJcblx0cGFkZGluZy1sZWZ0OiAkeyBzcGFjZSggMiApIH07XG5cdHBhZGRpbmctcmlnaHQ6ICR7IHNwYWNlKCAyICkgfTtcblxuXHQkeyBkZXByZWNhdGVkRGVmYXVsdFNpemUgfVxuYDtcbiJdfQ== */"));
38
38
  exports.InputWrapperFlex = InputWrapperFlex;
39
39
  //# sourceMappingURL=styles.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/components/src/combobox-control/styles.ts"],"names":["deprecatedDefaultSize","__next36pxDefaultSize","css","InputWrapperFlex","Flex"],"mappings":";;;;;;;;;;;AAIA;;AAKA;;AACA;;AAVA;AACA;AACA;;AAIA;AACA;AACA;AAKA,MAAMA,qBAAqB,GAAG;AAAA,MAAE;AAC/BC,IAAAA;AAD+B,GAAF;AAAA,SAG7B,CAAEA,qBAAF,qBACAC,UADA,+BAGkB,kBAAO,CAAP,CAHlB,qBAImB,kBAAO,CAAP,CAJnB,mhDAH6B;AAAA,CAA9B;;AAUO,MAAMC,gBAAgB,GAAG,iCAAQC,UAAR;AAAA;AAAA;AAAA;AAAA;AAAA,EAAH,8BAEX,kBAAO,CAAP,CAFW,qBAGV,kBAAO,CAAP,CAHU,OAKzBJ,qBALyB,y8CAAtB","sourcesContent":["/**\n * External dependencies\n */\nimport styled from '@emotion/styled';\nimport { css } from '@emotion/react';\n\n/**\n * Internal dependencies\n */\nimport { Flex } from '../flex';\nimport { space } from '../ui/utils/space';\nimport type { ComboboxControlProps } from './types';\n\nconst deprecatedDefaultSize = ( {\n\t__next36pxDefaultSize,\n}: Pick< ComboboxControlProps, '__next36pxDefaultSize' > ) =>\n\t! __next36pxDefaultSize &&\n\tcss`\n\t\theight: 28px; // 30px - 2px vertical borders on parent container\n\t\tpadding-left: ${ space( 1 ) };\n\t\tpadding-right: ${ space( 1 ) };\n\t`;\n\nexport const InputWrapperFlex = styled( Flex )`\n\theight: 34px; // 36px - 2px vertical borders on parent container\n\tpadding-left: ${ space( 2 ) };\n\tpadding-right: ${ space( 2 ) };\n\n\t${ deprecatedDefaultSize }\n`;\n"]}
1
+ {"version":3,"sources":["@wordpress/components/src/combobox-control/styles.ts"],"names":["deprecatedDefaultSize","__next40pxDefaultSize","css","InputWrapperFlex","Flex"],"mappings":";;;;;;;;;;;AAIA;;AAKA;;AACA;;AAVA;AACA;AACA;;AAIA;AACA;AACA;AAKA,MAAMA,qBAAqB,GAAG;AAAA,MAAE;AAC/BC,IAAAA;AAD+B,GAAF;AAAA,SAG7B,CAAEA,qBAAF,qBACAC,UADA,+BAGkB,kBAAO,CAAP,CAHlB,qBAImB,kBAAO,CAAP,CAJnB,mhDAH6B;AAAA,CAA9B;;AAUO,MAAMC,gBAAgB,GAAG,iCAAQC,UAAR;AAAA;AAAA;AAAA;AAAA;AAAA,EAAH,8BAEX,kBAAO,CAAP,CAFW,qBAGV,kBAAO,CAAP,CAHU,OAKzBJ,qBALyB,y8CAAtB","sourcesContent":["/**\n * External dependencies\n */\nimport styled from '@emotion/styled';\nimport { css } from '@emotion/react';\n\n/**\n * Internal dependencies\n */\nimport { Flex } from '../flex';\nimport { space } from '../ui/utils/space';\nimport type { ComboboxControlProps } from './types';\n\nconst deprecatedDefaultSize = ( {\n\t__next40pxDefaultSize,\n}: Pick< ComboboxControlProps, '__next40pxDefaultSize' > ) =>\n\t! __next40pxDefaultSize &&\n\tcss`\n\t\theight: 28px; // 30px - 2px vertical borders on parent container\n\t\tpadding-left: ${ space( 1 ) };\n\t\tpadding-right: ${ space( 1 ) };\n\t`;\n\nexport const InputWrapperFlex = styled( Flex )`\n\theight: 38px; // 40px - 2px vertical borders on parent container\n\tpadding-left: ${ space( 2 ) };\n\tpadding-right: ${ space( 2 ) };\n\n\t${ deprecatedDefaultSize }\n`;\n"]}
@@ -43,7 +43,9 @@ function CustomGradientPicker(_ref) {
43
43
  gradients,
44
44
  gradientOptions
45
45
  } = _utils.colorsUtils;
46
- const gradientAST = (0, _utils2.getGradientAstWithDefault)(currentColor);
46
+ const {
47
+ gradientAST
48
+ } = (0, _utils2.getGradientAstWithDefault)(currentColor);
47
49
  const gradientType = getGradientType(currentColor);
48
50
 
49
51
  function isLinearGradient(type) {
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/components/src/custom-gradient-picker/index.native.js"],"names":["CustomGradientPicker","setColor","currentValue","isGradientColor","gradientOrientation","setGradientOrientation","HORIZONTAL_GRADIENT_ORIENTATION","currentColor","setCurrentColor","getGradientType","gradients","gradientOptions","colorsUtils","gradientAST","gradientType","isLinearGradient","type","linear","getGradientColor","orientation","restGradientAST","onGradientTypeChange","gradientColor","setGradientAngle","value","getGradientAngle","DEFAULT_LINEAR_GRADIENT_ANGLE","styles","angleControl"],"mappings":";;;;;;;;;AAKA;;AAFA;;AACA;;AAMA;;AACA;;AACA;;AACA;;AAIA;;AAjBA;AACA;AACA;;AAKA;AACA;AACA;AAUA,SAASA,oBAAT,OAA6E;AAAA,MAA9C;AAAEC,IAAAA,QAAF;AAA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AA,IAAI,EAAE,SADM;AAEZQ,QAAAA;AAFY;AAF2B,KAAnB,CAAtB;;AAQA,QAAKrB,eAAe,IAAImB,aAAa,KAAKf,YAA1C,EAAyD;AACxDC,MAAAA,eAAe,CAAEc,aAAF,CAAf;AACArB,MAAAA,QAAQ,CAAEqB,aAAF,CAAR;AACA;AACD;;AAED,WAASG,gBAAT,GAA4B;AAAA;;AAC3B,oCAAOZ,WAAP,aAAOA,WAAP,iDAAOA,WAAW,CAAEM,WAApB,2DAAO,uBAA0BK,KAAjC,yEAA0CE,wCAA1C;AACA;;AACD,SACC,qDACC,4BAAC,qBAAD;AAAW,IAAA,KAAK,EAAG,cAAI,eAAJ;AAAnB,KACC,4BAAC,wBAAD;AACC,IAAA,QAAQ,EAAGZ,YADZ;AAEC,IAAA,OAAO,EAAGH,eAFX;AAGC,IAAA,QAAQ,EAAGU;AAHZ,IADD,CADD,EAQGN,gBAAgB,CAAED,YAAF,CAAhB,IACD,4BAAC,qBAAD;AAAW,IAAA,KAAK,EAAGa,eAAOC;AAA1B,KACC,4BAAC,wBAAD;AACC,IAAA,KAAK,EAAG,cAAI,OAAJ,CADT;AAEC,IAAA,YAAY,EAAG,CAFhB;AAGC,IAAA,YAAY,EAAG,GAHhB;AAIC,IAAA,KAAK,EAAGH,gBAAgB,EAJzB;AAKC,IAAA,QAAQ,EAAGF;AALZ,IADD,CATF,CADD;AAsBA;;eAEcvB,oB","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { PanelBody, RadioControl, RangeControl } from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\nimport { useState } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport { colorsUtils } from '../mobile/color-settings/utils';\nimport { getGradientAstWithDefault } from './utils';\nimport { serializeGradient } from './serializer';\nimport {\n\tDEFAULT_LINEAR_GRADIENT_ANGLE,\n\tHORIZONTAL_GRADIENT_ORIENTATION,\n} from './constants';\nimport styles from './style.scss';\n\nfunction CustomGradientPicker( { setColor, currentValue, isGradientColor } ) {\n\tconst [ gradientOrientation, setGradientOrientation ] = useState(\n\t\tHORIZONTAL_GRADIENT_ORIENTATION\n\t);\n\n\tconst [ currentColor, setCurrentColor ] = useState( currentValue );\n\n\tconst { getGradientType, gradients, gradientOptions } = colorsUtils;\n\tconst gradientAST = getGradientAstWithDefault( currentColor );\n\tconst gradientType = getGradientType( currentColor );\n\n\tfunction isLinearGradient( type ) {\n\t\treturn type === gradients.linear;\n\t}\n\n\tfunction getGradientColor( type ) {\n\t\tconst { orientation, ...restGradientAST } = gradientAST;\n\n\t\tif ( orientation ) {\n\t\t\tsetGradientOrientation( orientation );\n\t\t}\n\n\t\treturn serializeGradient(\n\t\t\tisLinearGradient( type )\n\t\t\t\t? {\n\t\t\t\t\t\t...gradientAST,\n\t\t\t\t\t\t...( gradientAST.orientation\n\t\t\t\t\t\t\t? {}\n\t\t\t\t\t\t\t: {\n\t\t\t\t\t\t\t\t\torientation: gradientOrientation,\n\t\t\t\t\t\t\t } ),\n\t\t\t\t\t\ttype,\n\t\t\t\t }\n\t\t\t\t: {\n\t\t\t\t\t\t...restGradientAST,\n\t\t\t\t\t\ttype,\n\t\t\t\t }\n\t\t);\n\t}\n\n\tfunction onGradientTypeChange( type ) {\n\t\tconst gradientColor = getGradientColor( type );\n\t\tsetCurrentColor( gradientColor );\n\t\tsetColor( gradientColor );\n\t}\n\n\tfunction setGradientAngle( value ) {\n\t\tconst gradientColor = serializeGradient( {\n\t\t\t...gradientAST,\n\t\t\torientation: {\n\t\t\t\ttype: 'angular',\n\t\t\t\tvalue,\n\t\t\t},\n\t\t} );\n\n\t\tif ( isGradientColor && gradientColor !== currentColor ) {\n\t\t\tsetCurrentColor( gradientColor );\n\t\t\tsetColor( gradientColor );\n\t\t}\n\t}\n\n\tfunction getGradientAngle() {\n\t\treturn gradientAST?.orientation?.value ?? DEFAULT_LINEAR_GRADIENT_ANGLE;\n\t}\n\treturn (\n\t\t<>\n\t\t\t<PanelBody title={ __( 'Gradient Type' ) }>\n\t\t\t\t<RadioControl\n\t\t\t\t\tselected={ gradientType }\n\t\t\t\t\toptions={ gradientOptions }\n\t\t\t\t\tonChange={ onGradientTypeChange }\n\t\t\t\t/>\n\t\t\t</PanelBody>\n\t\t\t{ isLinearGradient( gradientType ) && (\n\t\t\t\t<PanelBody style={ styles.angleControl }>\n\t\t\t\t\t<RangeControl\n\t\t\t\t\t\tlabel={ __( 'Angle' ) }\n\t\t\t\t\t\tminimumValue={ 0 }\n\t\t\t\t\t\tmaximumValue={ 360 }\n\t\t\t\t\t\tvalue={ getGradientAngle() }\n\t\t\t\t\t\tonChange={ setGradientAngle }\n\t\t\t\t\t/>\n\t\t\t\t</PanelBody>\n\t\t\t) }\n\t\t</>\n\t);\n}\n\nexport default CustomGradientPicker;\n"]}
1
+ {"version":3,"sources":["@wordpress/components/src/custom-gradient-picker/index.native.js"],"names":["CustomGradientPicker","setColor","currentValue","isGradientColor","gradientOrientation","setGradientOrientation","HORIZONTAL_GRADIENT_ORIENTATION","currentColor","setCurrentColor","getGradientType","gradients","gradientOptions","colorsUtils","gradientAST","gradientType","isLinearGradient","type","linear","getGradientColor","orientation","restGradientAST","onGradientTypeChange","gradientColor","setGradientAngle","value","getGradientAngle","DEFAULT_LINEAR_GRADIENT_ANGLE","styles","angleControl"],"mappings":";;;;;;;;;AAKA;;AAFA;;AACA;;AAMA;;AACA;;AACA;;AACA;;AAIA;;AAjBA;AACA;AACA;;AAKA;AACA;AACA;AAUA,SAASA,oBAAT,OAA6E;AAAA,MAA9C;AAAEC,IAAAA,QAAF;AAAYC,IAAAA,YAAZ;AAA0BC,IAAAA;AAA1B,GAA8C;AAC5E,QAAM,CAAEC,mBAAF,EAAuBC,sBAAvB,IAAkD,uBACvDC,0CADuD,CAAxD;AAIA,QAAM,CAAEC,YAAF,EAAgBC,eAAhB,IAAoC,uBAAUN,YAAV,CAA1C;AAEA,QAAM;AAAEO,IAAAA,eAAF;AAAmBC,IAAAA,SAAnB;AAA8BC,IAAAA;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3B,oCAAOZ,WAAP,aAAOA,WAAP,iDAAOA,WAAW,CAAEM,WAApB,2DAAO,uBAA0BK,KAAjC,yEAA0CE,wCAA1C;AACA;;AACD,SACC,qDACC,4BAAC,qBAAD;AAAW,IAAA,KAAK,EAAG,cAAI,eAAJ;AAAnB,KACC,4BAAC,wBAAD;AACC,IAAA,QAAQ,EAAGZ,YADZ;AAEC,IAAA,OAAO,EAAGH,eAFX;AAGC,IAAA,QAAQ,EAAGU;AAHZ,IADD,CADD,EAQGN,gBAAgB,CAAED,YAAF,CAAhB,IACD,4BAAC,qBAAD;AAAW,IAAA,KAAK,EAAGa,eAAOC;AAA1B,KACC,4BAAC,wBAAD;AACC,IAAA,KAAK,EAAG,cAAI,OAAJ,CADT;AAEC,IAAA,YAAY,EAAG,CAFhB;AAGC,IAAA,YAAY,EAAG,GAHhB;AAIC,IAAA,KAAK,EAAGH,gBAAgB,EAJzB;AAKC,IAAA,QAAQ,EAAGF;AALZ,IADD,CATF,CADD;AAsBA;;eAEcvB,oB","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { PanelBody, RadioControl, RangeControl } from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\nimport { useState } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport { colorsUtils } from '../mobile/color-settings/utils';\nimport { getGradientAstWithDefault } from './utils';\nimport { serializeGradient } from './serializer';\nimport {\n\tDEFAULT_LINEAR_GRADIENT_ANGLE,\n\tHORIZONTAL_GRADIENT_ORIENTATION,\n} from './constants';\nimport styles from './style.scss';\n\nfunction CustomGradientPicker( { setColor, currentValue, isGradientColor } ) {\n\tconst [ gradientOrientation, setGradientOrientation ] = useState(\n\t\tHORIZONTAL_GRADIENT_ORIENTATION\n\t);\n\n\tconst [ currentColor, setCurrentColor ] = useState( currentValue );\n\n\tconst { getGradientType, gradients, gradientOptions } = colorsUtils;\n\tconst { gradientAST } = getGradientAstWithDefault( currentColor );\n\tconst gradientType = getGradientType( currentColor );\n\n\tfunction isLinearGradient( type ) {\n\t\treturn type === gradients.linear;\n\t}\n\n\tfunction getGradientColor( type ) {\n\t\tconst { orientation, ...restGradientAST } = gradientAST;\n\n\t\tif ( orientation ) {\n\t\t\tsetGradientOrientation( orientation );\n\t\t}\n\n\t\treturn serializeGradient(\n\t\t\tisLinearGradient( type )\n\t\t\t\t? {\n\t\t\t\t\t\t...gradientAST,\n\t\t\t\t\t\t...( gradientAST.orientation\n\t\t\t\t\t\t\t? {}\n\t\t\t\t\t\t\t: {\n\t\t\t\t\t\t\t\t\torientation: gradientOrientation,\n\t\t\t\t\t\t\t } ),\n\t\t\t\t\t\ttype,\n\t\t\t\t }\n\t\t\t\t: {\n\t\t\t\t\t\t...restGradientAST,\n\t\t\t\t\t\ttype,\n\t\t\t\t }\n\t\t);\n\t}\n\n\tfunction onGradientTypeChange( type ) {\n\t\tconst gradientColor = getGradientColor( type );\n\t\tsetCurrentColor( gradientColor );\n\t\tsetColor( gradientColor );\n\t}\n\n\tfunction setGradientAngle( value ) {\n\t\tconst gradientColor = serializeGradient( {\n\t\t\t...gradientAST,\n\t\t\torientation: {\n\t\t\t\ttype: 'angular',\n\t\t\t\tvalue,\n\t\t\t},\n\t\t} );\n\n\t\tif ( isGradientColor && gradientColor !== currentColor ) {\n\t\t\tsetCurrentColor( gradientColor );\n\t\t\tsetColor( gradientColor );\n\t\t}\n\t}\n\n\tfunction getGradientAngle() {\n\t\treturn gradientAST?.orientation?.value ?? DEFAULT_LINEAR_GRADIENT_ANGLE;\n\t}\n\treturn (\n\t\t<>\n\t\t\t<PanelBody title={ __( 'Gradient Type' ) }>\n\t\t\t\t<RadioControl\n\t\t\t\t\tselected={ gradientType }\n\t\t\t\t\toptions={ gradientOptions }\n\t\t\t\t\tonChange={ onGradientTypeChange }\n\t\t\t\t/>\n\t\t\t</PanelBody>\n\t\t\t{ isLinearGradient( gradientType ) && (\n\t\t\t\t<PanelBody style={ styles.angleControl }>\n\t\t\t\t\t<RangeControl\n\t\t\t\t\t\tlabel={ __( 'Angle' ) }\n\t\t\t\t\t\tminimumValue={ 0 }\n\t\t\t\t\t\tmaximumValue={ 360 }\n\t\t\t\t\t\tvalue={ getGradientAngle() }\n\t\t\t\t\t\tonChange={ setGradientAngle }\n\t\t\t\t\t/>\n\t\t\t\t</PanelBody>\n\t\t\t) }\n\t\t</>\n\t);\n}\n\nexport default CustomGradientPicker;\n"]}
@@ -42,8 +42,8 @@ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj &&
42
42
  * This feature is still experimental. “Experimental” means this is an early implementation subject to drastic and breaking changes.
43
43
  *
44
44
  * ```jsx
45
- * import { useState } from 'react';
46
45
  * import { __experimentalDimensionControl as DimensionControl } from '@wordpress/components';
46
+ * import { useState } from '@wordpress/element';
47
47
  *
48
48
  * export default function MyCustomDimensionControl() {
49
49
  * const [ paddingSize, setPaddingSize ] = useState( '' );
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/components/src/dimension-control/index.tsx"],"names":["DimensionControl","props","label","value","sizes","sizesTable","icon","onChange","className","onChangeSpacingSize","val","theSize","slug","undefined","formatSizesAsOptions","theSizes","options","map","name","selectLabel"],"mappings":";;;;;;;;;;;;AAGA;;AAKA;;AAKA;;AACA;;AACA;;;;;;AAfA;AACA;AACA;;AAGA;AACA;AACA;;AAGA;AACA;AACA;;AAOA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASA,gBAAT,CAA2BC,KAA3B,EAA0D;AAChE,QAAM;AACLC,IAAAA,KADK;AAELC,IAAAA,KAFK;AAGLC,IAAAA,KAAK,GAAGC,cAHH;AAILC,IAAAA,IAJK;AAKLC,IAAAA,QALK;AAMLC,IAAAA,SAAS,GAAG;AANP,MAOFP,KAPJ;;AASA,QAAMQ,mBAAoE,GACvEC,GAAF,IAAW;AACV,UAAMC,OAAO,GAAG,2BAAgBP,KAAhB,EAAuBM,GAAvB,CAAhB;;AAEA,QAAK,CAAEC,OAAF,IAAaR,KAAK,KAAKQ,OAAO,CAACC,IAApC,EAA2C;AAC1CL,MAAAA,QAAQ,SAAR,IAAAA,QAAQ,WAAR,YAAAA,QAAQ,CAAIM,SAAJ,CAAR;AACA,KAFD,MAEO,IAAK,OAAON,QAAP,KAAoB,UAAzB,EAAsC;AAC5CA,MAAAA,QAAQ,CAAEI,OAAO,CAACC,IAAV,CAAR;AACA;AACD,GATF;;AAWA,QAAME,oBAAoB,GAAKC,QAAF,IAAwB;AACpD,UAAMC,OAAO,GAAGD,QAAQ,CAACE,GAAT,CAAc;AAAA,UAAE;AAAEC,QAAAA,IAAF;AAAQN,QAAAA;AAAR,OAAF;AAAA,aAAwB;AACrDV,QAAAA,KAAK,EAAEgB,IAD8C;AAErDf,QAAAA,KAAK,EAAES;AAF8C,OAAxB;AAAA,KAAd,CAAhB;AAKA,WAAO,CACN;AACCV,MAAAA,KAAK,EAAE,cAAI,SAAJ,CADR;AAECC,MAAAA,KAAK,EAAE;AAFR,KADM,EAKN,GAAGa,OALG,CAAP;AAOA,GAbD;;AAeA,QAAMG,WAAW,GAChB,qDACGb,IAAI,IAAI,4BAAC,aAAD;AAAM,IAAA,IAAI,EAAGA;AAAb,IADX,EAEGJ,KAFH,CADD;AAOA,SACC,4BAAC,sBAAD;AACC,IAAA,SAAS,EAAG,yBACXM,SADW,EAEX,gCAFW,CADb;AAKC,IAAA,KAAK,EAAGW,WALT;AAMC,IAAA,mBAAmB,EAAG,KANvB;AAOC,IAAA,KAAK,EAAGhB,KAPT;AAQC,IAAA,QAAQ,EAAGM,mBARZ;AASC,IAAA,OAAO,EAAGK,oBAAoB,CAAEV,KAAF;AAT/B,IADD;AAaA;;eAEcJ,gB","sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport Icon from '../icon';\nimport SelectControl from '../select-control';\nimport sizesTable, { findSizeBySlug } from './sizes';\nimport type { DimensionControlProps, Size } from './types';\nimport type { SelectControlSingleSelectionProps } from '../select-control/types';\n\n/**\n * `DimensionControl` is a component designed to provide a UI to control spacing and/or dimensions.\n *\n * This feature is still experimental. “Experimental” means this is an early implementation subject to drastic and breaking changes.\n *\n * ```jsx\n * import { useState } from 'react';\n * import { __experimentalDimensionControl as DimensionControl } from '@wordpress/components';\n *\n * export default function MyCustomDimensionControl() {\n * \tconst [ paddingSize, setPaddingSize ] = useState( '' );\n *\n * \treturn (\n * \t\t<DimensionControl\n * \t\t\tlabel={ 'Padding' }\n * \t\t\ticon={ 'desktop' }\n * \t\t\tonChange={ ( value ) => setPaddingSize( value ) }\n * \t\t\tvalue={ paddingSize }\n * \t\t/>\n * \t);\n * }\n * ```\n */\nexport function DimensionControl( props: DimensionControlProps ) {\n\tconst {\n\t\tlabel,\n\t\tvalue,\n\t\tsizes = sizesTable,\n\t\ticon,\n\t\tonChange,\n\t\tclassName = '',\n\t} = props;\n\n\tconst onChangeSpacingSize: SelectControlSingleSelectionProps[ 'onChange' ] =\n\t\t( val ) => {\n\t\t\tconst theSize = findSizeBySlug( sizes, val );\n\n\t\t\tif ( ! theSize || value === theSize.slug ) {\n\t\t\t\tonChange?.( undefined );\n\t\t\t} else if ( typeof onChange === 'function' ) {\n\t\t\t\tonChange( theSize.slug );\n\t\t\t}\n\t\t};\n\n\tconst formatSizesAsOptions = ( theSizes: Size[] ) => {\n\t\tconst options = theSizes.map( ( { name, slug } ) => ( {\n\t\t\tlabel: name,\n\t\t\tvalue: slug,\n\t\t} ) );\n\n\t\treturn [\n\t\t\t{\n\t\t\t\tlabel: __( 'Default' ),\n\t\t\t\tvalue: '',\n\t\t\t},\n\t\t\t...options,\n\t\t];\n\t};\n\n\tconst selectLabel = (\n\t\t<>\n\t\t\t{ icon && <Icon icon={ icon } /> }\n\t\t\t{ label }\n\t\t</>\n\t);\n\n\treturn (\n\t\t<SelectControl\n\t\t\tclassName={ classnames(\n\t\t\t\tclassName,\n\t\t\t\t'block-editor-dimension-control'\n\t\t\t) }\n\t\t\tlabel={ selectLabel }\n\t\t\thideLabelFromVision={ false }\n\t\t\tvalue={ value }\n\t\t\tonChange={ onChangeSpacingSize }\n\t\t\toptions={ formatSizesAsOptions( sizes ) }\n\t\t/>\n\t);\n}\n\nexport default DimensionControl;\n"]}
1
+ {"version":3,"sources":["@wordpress/components/src/dimension-control/index.tsx"],"names":["DimensionControl","props","label","value","sizes","sizesTable","icon","onChange","className","onChangeSpacingSize","val","theSize","slug","undefined","formatSizesAsOptions","theSizes","options","map","name","selectLabel"],"mappings":";;;;;;;;;;;;AAGA;;AAKA;;AAKA;;AACA;;AACA;;;;;;AAfA;AACA;AACA;;AAGA;AACA;AACA;;AAGA;AACA;AACA;;AAOA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASA,gBAAT,CAA2BC,KAA3B,EAA0D;AAChE,QAAM;AACLC,IAAAA,KADK;AAELC,IAAAA,KAFK;AAGLC,IAAAA,KAAK,GAAGC,cAHH;AAILC,IAAAA,IAJK;AAKLC,IAAAA,QALK;AAMLC,IAAAA,SAAS,GAAG;AANP,MAOFP,KAPJ;;AASA,QAAMQ,mBAAoE,GACvEC,GAAF,IAAW;AACV,UAAMC,OAAO,GAAG,2BAAgBP,KAAhB,EAAuBM,GAAvB,CAAhB;;AAEA,QAAK,CAAEC,OAAF,IAAaR,KAAK,KAAKQ,OAAO,CAACC,IAApC,EAA2C;AAC1CL,MAAAA,QAAQ,SAAR,IAAAA,QAAQ,WAAR,YAAAA,QAAQ,CAAIM,SAAJ,CAAR;AACA,KAFD,MAEO,IAAK,OAAON,QAAP,KAAoB,UAAzB,EAAsC;AAC5CA,MAAAA,QAAQ,CAAEI,OAAO,CAACC,IAAV,CAAR;AACA;AACD,GATF;;AAWA,QAAME,oBAAoB,GAAKC,QAAF,IAAwB;AACpD,UAAMC,OAAO,GAAGD,QAAQ,CAACE,GAAT,CAAc;AAAA,UAAE;AAAEC,QAAAA,IAAF;AAAQN,QAAAA;AAAR,OAAF;AAAA,aAAwB;AACrDV,QAAAA,KAAK,EAAEgB,IAD8C;AAErDf,QAAAA,KAAK,EAAES;AAF8C,OAAxB;AAAA,KAAd,CAAhB;AAKA,WAAO,CACN;AACCV,MAAAA,KAAK,EAAE,cAAI,SAAJ,CADR;AAECC,MAAAA,KAAK,EAAE;AAFR,KADM,EAKN,GAAGa,OALG,CAAP;AAOA,GAbD;;AAeA,QAAMG,WAAW,GAChB,qDACGb,IAAI,IAAI,4BAAC,aAAD;AAAM,IAAA,IAAI,EAAGA;AAAb,IADX,EAEGJ,KAFH,CADD;AAOA,SACC,4BAAC,sBAAD;AACC,IAAA,SAAS,EAAG,yBACXM,SADW,EAEX,gCAFW,CADb;AAKC,IAAA,KAAK,EAAGW,WALT;AAMC,IAAA,mBAAmB,EAAG,KANvB;AAOC,IAAA,KAAK,EAAGhB,KAPT;AAQC,IAAA,QAAQ,EAAGM,mBARZ;AASC,IAAA,OAAO,EAAGK,oBAAoB,CAAEV,KAAF;AAT/B,IADD;AAaA;;eAEcJ,gB","sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport Icon from '../icon';\nimport SelectControl from '../select-control';\nimport sizesTable, { findSizeBySlug } from './sizes';\nimport type { DimensionControlProps, Size } from './types';\nimport type { SelectControlSingleSelectionProps } from '../select-control/types';\n\n/**\n * `DimensionControl` is a component designed to provide a UI to control spacing and/or dimensions.\n *\n * This feature is still experimental. “Experimental” means this is an early implementation subject to drastic and breaking changes.\n *\n * ```jsx\n * import { __experimentalDimensionControl as DimensionControl } from '@wordpress/components';\n * import { useState } from '@wordpress/element';\n *\n * export default function MyCustomDimensionControl() {\n * \tconst [ paddingSize, setPaddingSize ] = useState( '' );\n *\n * \treturn (\n * \t\t<DimensionControl\n * \t\t\tlabel={ 'Padding' }\n * \t\t\ticon={ 'desktop' }\n * \t\t\tonChange={ ( value ) => setPaddingSize( value ) }\n * \t\t\tvalue={ paddingSize }\n * \t\t/>\n * \t);\n * }\n * ```\n */\nexport function DimensionControl( props: DimensionControlProps ) {\n\tconst {\n\t\tlabel,\n\t\tvalue,\n\t\tsizes = sizesTable,\n\t\ticon,\n\t\tonChange,\n\t\tclassName = '',\n\t} = props;\n\n\tconst onChangeSpacingSize: SelectControlSingleSelectionProps[ 'onChange' ] =\n\t\t( val ) => {\n\t\t\tconst theSize = findSizeBySlug( sizes, val );\n\n\t\t\tif ( ! theSize || value === theSize.slug ) {\n\t\t\t\tonChange?.( undefined );\n\t\t\t} else if ( typeof onChange === 'function' ) {\n\t\t\t\tonChange( theSize.slug );\n\t\t\t}\n\t\t};\n\n\tconst formatSizesAsOptions = ( theSizes: Size[] ) => {\n\t\tconst options = theSizes.map( ( { name, slug } ) => ( {\n\t\t\tlabel: name,\n\t\t\tvalue: slug,\n\t\t} ) );\n\n\t\treturn [\n\t\t\t{\n\t\t\t\tlabel: __( 'Default' ),\n\t\t\t\tvalue: '',\n\t\t\t},\n\t\t\t...options,\n\t\t];\n\t};\n\n\tconst selectLabel = (\n\t\t<>\n\t\t\t{ icon && <Icon icon={ icon } /> }\n\t\t\t{ label }\n\t\t</>\n\t);\n\n\treturn (\n\t\t<SelectControl\n\t\t\tclassName={ classnames(\n\t\t\t\tclassName,\n\t\t\t\t'block-editor-dimension-control'\n\t\t\t) }\n\t\t\tlabel={ selectLabel }\n\t\t\thideLabelFromVision={ false }\n\t\t\tvalue={ value }\n\t\t\tonChange={ onChangeSpacingSize }\n\t\t\toptions={ formatSizesAsOptions( sizes ) }\n\t\t/>\n\t);\n}\n\nexport default DimensionControl;\n"]}
@@ -67,6 +67,7 @@ function Draggable(_ref) {
67
67
  onDragStart,
68
68
  onDragOver,
69
69
  onDragEnd,
70
+ appendToOwnerDocument = false,
70
71
  cloneClassname,
71
72
  elementId,
72
73
  transferData,
@@ -162,7 +163,11 @@ function Draggable(_ref) {
162
163
  });
163
164
  cloneWrapper.appendChild(clone); // Inject the cloneWrapper into the DOM.
164
165
 
165
- elementWrapper === null || elementWrapper === void 0 ? void 0 : elementWrapper.appendChild(cloneWrapper);
166
+ if (appendToOwnerDocument) {
167
+ ownerDocument.body.appendChild(cloneWrapper);
168
+ } else {
169
+ elementWrapper === null || elementWrapper === void 0 ? void 0 : elementWrapper.appendChild(cloneWrapper);
170
+ }
166
171
  } // Mark the current cursor coordinates.
167
172
 
168
173
 
@@ -194,14 +199,10 @@ function Draggable(_ref) {
194
199
  const throttledDragOver = (0, _compose.throttle)(over, 16);
195
200
  ownerDocument.addEventListener('dragover', throttledDragOver); // Update cursor to 'grabbing', document wide.
196
201
 
197
- ownerDocument.body.classList.add(bodyClass); // Allow the Synthetic Event to be accessed from asynchronous code.
198
- // https://reactjs.org/docs/events.html#event-pooling
199
-
200
- event.persist();
201
- let timerId;
202
+ ownerDocument.body.classList.add(bodyClass);
202
203
 
203
204
  if (onDragStart) {
204
- timerId = setTimeout(() => onDragStart(event));
205
+ onDragStart(event);
205
206
  }
206
207
 
207
208
  cleanup.current = () => {
@@ -217,7 +218,6 @@ function Draggable(_ref) {
217
218
 
218
219
  ownerDocument.body.classList.remove(bodyClass);
219
220
  ownerDocument.removeEventListener('dragover', throttledDragOver);
220
- clearTimeout(timerId);
221
221
  };
222
222
  }
223
223
 
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/components/src/draggable/index.tsx"],"names":["dragImageClass","cloneWrapperClass","clonePadding","bodyClass","Draggable","children","onDragStart","onDragOver","onDragEnd","cloneClassname","elementId","transferData","__experimentalTransferDataType","transferDataType","__experimentalDragComponent","dragComponent","dragComponentRef","cleanup","end","event","preventDefault","current","start","ownerDocument","target","dataTransfer","setData","JSON","stringify","cloneWrapper","createElement","style","top","left","dragImage","setDragImage","classList","add","body","appendChild","x","y","clientX","clientY","transform","clonedDragComponent","innerHTML","element","getElementById","elementRect","getBoundingClientRect","elementWrapper","parentNode","elementTopOffset","elementLeftOffset","width","clone","cloneNode","id","Array","from","querySelectorAll","forEach","child","removeChild","cursorLeft","cursorTop","over","e","nextX","nextY","throttledDragOver","addEventListener","persist","timerId","setTimeout","remove","removeEventListener","clearTimeout","onDraggableStart","onDraggableEnd","display"],"mappings":";;;;;;;;AASA;;AADA;;AARA;AACA;AACA;;AAGA;AACA;AACA;AASA,MAAMA,cAAc,GAAG,4CAAvB;AACA,MAAMC,iBAAiB,GAAG,6BAA1B;AACA,MAAMC,YAAY,GAAG,CAArB;AACA,MAAMC,SAAS,GAAG,kCAAlB;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACO,SAASC,SAAT,OAUa;AAAA,MAVO;AAC1BC,IAAAA,QAD0B;AAE1BC,IAAAA,WAF0B;AAG1BC,IAAAA,UAH0B;AAI1BC,IAAAA,SAJ0B;AAK1BC,IAAAA,cAL0B;AAM1BC,IAAAA,SAN0B;AAO1BC,IAAAA,YAP0B;AAQ1BC,IAAAA,8BAA8B,EAAEC,gBAAgB,GAAG,MARzB;AAS1BC,IAAAA,2BAA2B,EAAEC;AATH,GAUP;AACnB,QAAMC,gBAAgB,GAAG,qBAA0B,IAA1B,CAAzB;AACA,QAAMC,OAAO,GAAG,qBAAQ,MAAM,CAAE,CAAhB,CAAhB;AAEA;AACD;AACA;AACA;AACA;;AACC,WAASC,GAAT,CAAcC,KAAd,EAAiC;AAChCA,IAAAA,KAAK,CAACC,cAAN;AACAH,IAAAA,OAAO,CAACI,OAAR;;AAEA,QAAKb,SAAL,EAAiB;AAChBA,MAAAA,SAAS,CAAEW,KA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A,aAAa,CAACe,IAAd,CAAmBF,SAAnB,CAA6BC,GAA7B,CAAkClC,SAAlC,EA7GkC,CA+GlC;AACA;;AACAgB,IAAAA,KAAK,CAACsD,OAAN;AAEA,QAAIC,OAAJ;;AAEA,QAAKpE,WAAL,EAAmB;AAClBoE,MAAAA,OAAO,GAAGC,UAAU,CAAE,MAAMrE,WAAW,CAAEa,KAAF,CAAnB,CAApB;AACA;;AAEDF,IAAAA,OAAO,CAACI,OAAR,GAAkB,MAAM;AACvB;AACA,UAAKQ,YAAY,IAAIA,YAAY,CAACuB,UAAlC,EAA+C;AAC9CvB,QAAAA,YAAY,CAACuB,UAAb,CAAwBY,WAAxB,CAAqCnC,YAArC;AACA;;AAED,UAAKK,SAAS,IAAIA,SAAS,CAACkB,UAA5B,EAAyC;AACxClB,QAAAA,SAAS,CAACkB,UAAV,CAAqBY,WAArB,CAAkC9B,SAAlC;AACA,OARsB,CAUvB;;;AACAX,MAAAA,aAAa,CAACe,IAAd,CAAmBF,SAAnB,CAA6BwC,MAA7B,CAAqCzE,SAArC;AAEAoB,MAAAA,aAAa,CAACsD,mBAAd,CAAmC,UAAnC,EAA+CN,iBAA/C;AAEAO,MAAAA,YAAY,CAAEJ,OAAF,CAAZ;AACA,KAhBD;AAiBA;;AAED,0BACC,MAAM,MAAM;AACXzD,IAAAA,OAAO,CAACI,OAAR;AACA,GAHF,EAIC,EAJD;AAOA,SACC,qDACGhB,QAAQ,CAAE;AACX0E,IAAAA,gBAAgB,EAAEzD,KADP;AAEX0D,IAAAA,cAAc,EAAE9D;AAFL,GAAF,CADX,EAKGH,aAAa,IACd;AACC,IAAA,SAAS,EAAC,0CADX;AAEC,IAAA,KAAK,EAAG;AAAEkE,MAAAA,OAAO,EAAE;AAAX,KAFT;AAGC,IAAA,GAAG,EAAGjE;AAHP,KAKGD,aALH,CANF,CADD;AAiBA;;eAEcX,S","sourcesContent":["/**\n * External dependencies\n */\nimport type { DragEvent } from 'react';\n\n/**\n * WordPress dependencies\n */\nimport { throttle } from '@wordpress/compose';\nimport { useEffect, useRef } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport type { DraggableProps } from './types';\n\nconst dragImageClass = 'components-draggable__invisible-drag-image';\nconst cloneWrapperClass = 'components-draggable__clone';\nconst clonePadding = 0;\nconst bodyClass = 'is-dragging-components-draggable';\n\n/**\n * `Draggable` is a Component that provides a way to set up a cross-browser\n * (including IE) customizable drag image and the transfer data for the drag\n * event. It decouples the drag handle and the element to drag: use it by\n * wrapping the component that will become the drag handle and providing the DOM\n * ID of the element to drag.\n *\n * Note that the drag handle needs to declare the `draggable=\"true\"` property\n * and bind the `Draggable`s `onDraggableStart` and `onDraggableEnd` event\n * handlers to its own `onDragStart` and `onDragEnd` respectively. `Draggable`\n * takes care of the logic to setup the drag image and the transfer data, but is\n * not concerned with creating an actual DOM element that is draggable.\n *\n * ```jsx\n * import { Draggable, Panel, PanelBody } from '@wordpress/components';\n * import { Icon, more } from '@wordpress/icons';\n *\n * const MyDraggable = () => (\n * <div id=\"draggable-panel\">\n * <Panel header=\"Draggable panel\">\n * <PanelBody>\n * <Draggable elementId=\"draggable-panel\" transferData={ {} }>\n * { ( { onDraggableStart, onDraggableEnd } ) => (\n * <div\n * className=\"example-drag-handle\"\n * draggable\n * onDragStart={ onDraggableStart }\n * onDragEnd={ onDraggableEnd }\n * >\n * <Icon icon={ more } />\n * </div>\n * ) }\n * </Draggable>\n * </PanelBody>\n * </Panel>\n * </div>\n * );\n * ```\n */\nexport function Draggable( {\n\tchildren,\n\tonDragStart,\n\tonDragOver,\n\tonDragEnd,\n\tcloneClassname,\n\telementId,\n\ttransferData,\n\t__experimentalTransferDataType: transferDataType = 'text',\n\t__experimentalDragComponent: dragComponent,\n}: DraggableProps ) {\n\tconst dragComponentRef = useRef< HTMLDivElement >( null );\n\tconst cleanup = useRef( () => {} );\n\n\t/**\n\t * Removes the element clone, resets cursor, and removes drag listener.\n\t *\n\t * @param event The non-custom DragEvent.\n\t */\n\tfunction end( event: DragEvent ) {\n\t\tevent.preventDefault();\n\t\tcleanup.current();\n\n\t\tif ( onDragEnd ) {\n\t\t\tonDragEnd( event );\n\t\t}\n\t}\n\n\t/**\n\t * This method does a couple of things:\n\t *\n\t * - Clones the current element and spawns clone over original element.\n\t * - Adds a fake temporary drag image to avoid browser defaults.\n\t * - Sets transfer data.\n\t * - Adds dragover listener.\n\t *\n\t * @param event The non-custom DragEvent.\n\t */\n\tfunction start( event: DragEvent ) {\n\t\tconst { ownerDocument } = event.target as HTMLElement;\n\n\t\tevent.dataTransfer.setData(\n\t\t\ttransferDataType,\n\t\t\tJSON.stringify( transferData )\n\t\t);\n\n\t\tconst cloneWrapper = ownerDocument.createElement( 'div' );\n\t\t// Reset position to 0,0. Natural stacking order will position this lower, even with a transform otherwise.\n\t\tcloneWrapper.style.top = '0';\n\t\tcloneWrapper.style.left = '0';\n\n\t\tconst dragImage = ownerDocument.createElement( 'div' );\n\n\t\t// Set a fake drag image to avoid browser defaults. Remove from DOM\n\t\t// right after. event.dataTransfer.setDragImage is not supported yet in\n\t\t// IE, we need to check for its existence first.\n\t\tif ( 'function' === typeof event.dataTransfer.setDragImage ) {\n\t\t\tdragImage.classList.add( dragImageClass );\n\t\t\townerDocument.body.appendChild( dragImage );\n\t\t\tevent.dataTransfer.setDragImage( dragImage, 0, 0 );\n\t\t}\n\n\t\tcloneWrapper.classList.add( cloneWrapperClass );\n\n\t\tif ( cloneClassname ) {\n\t\t\tcloneWrapper.classList.add( cloneClassname );\n\t\t}\n\n\t\tlet x = 0;\n\t\tlet y = 0;\n\t\t// If a dragComponent is defined, the following logic will clone the\n\t\t// HTML node and inject it into the cloneWrapper.\n\t\tif ( dragComponentRef.current ) {\n\t\t\t// Position dragComponent at the same position as the cursor.\n\t\t\tx = event.clientX;\n\t\t\ty = event.clientY;\n\t\t\tcloneWrapper.style.transform = `translate( ${ x }px, ${ y }px )`;\n\n\t\t\tconst clonedDragComponent = ownerDocument.createElement( 'div' );\n\t\t\tclonedDragComponent.innerHTML = dragComponentRef.current.innerHTML;\n\t\t\tcloneWrapper.appendChild( clonedDragComponent );\n\n\t\t\t// Inject the cloneWrapper into the DOM.\n\t\t\townerDocument.body.appendChild( cloneWrapper );\n\t\t} else {\n\t\t\tconst element = ownerDocument.getElementById(\n\t\t\t\telementId\n\t\t\t) as HTMLElement;\n\n\t\t\t// Prepare element clone and append to element wrapper.\n\t\t\tconst elementRect = element.getBoundingClientRect();\n\t\t\tconst elementWrapper = element.parentNode;\n\t\t\tconst elementTopOffset = elementRect.top;\n\t\t\tconst elementLeftOffset = elementRect.left;\n\n\t\t\tcloneWrapper.style.width = `${\n\t\t\t\telementRect.width + clonePadding * 2\n\t\t\t}px`;\n\n\t\t\tconst clone = element.cloneNode( true ) as HTMLElement;\n\t\t\tclone.id = `clone-${ elementId }`;\n\n\t\t\t// Position clone right over the original element (20px padding).\n\t\t\tx = elementLeftOffset - clonePadding;\n\t\t\ty = elementTopOffset - clonePadding;\n\t\t\tcloneWrapper.style.transform = `translate( ${ x }px, ${ y }px )`;\n\n\t\t\t// Hack: Remove iFrames as it's causing the embeds drag clone to freeze.\n\t\t\tArray.from< HTMLIFrameElement >(\n\t\t\t\tclone.querySelectorAll( 'iframe' )\n\t\t\t).forEach( ( child ) => child.parentNode?.removeChild( child ) );\n\n\t\t\tcloneWrapper.appendChild( clone );\n\n\t\t\t// Inject the cloneWrapper into the DOM.\n\t\t\telementWrapper?.appendChild( cloneWrapper );\n\t\t}\n\n\t\t// Mark the current cursor coordinates.\n\t\tlet cursorLeft = event.clientX;\n\t\tlet cursorTop = event.clientY;\n\n\t\tfunction over( e: DragEvent ) {\n\t\t\t// Skip doing any work if mouse has not moved.\n\t\t\tif ( cursorLeft === e.clientX && cursorTop === e.clientY ) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tconst nextX = x + e.clientX - cursorLeft;\n\t\t\tconst nextY = y + e.clientY - cursorTop;\n\t\t\tcloneWrapper.style.transform = `translate( ${ nextX }px, ${ nextY }px )`;\n\t\t\tcursorLeft = e.clientX;\n\t\t\tcursorTop = e.clientY;\n\t\t\tx = nextX;\n\t\t\ty = nextY;\n\t\t\tif ( onDragOver ) {\n\t\t\t\tonDragOver( e );\n\t\t\t}\n\t\t}\n\n\t\t// Aim for 60fps (16 ms per frame) for now. We can potentially use requestAnimationFrame (raf) instead,\n\t\t// note that browsers may throttle raf below 60fps in certain conditions.\n\t\t// @ts-ignore\n\t\tconst throttledDragOver = throttle( over, 16 );\n\n\t\townerDocument.addEventListener( 'dragover', throttledDragOver );\n\n\t\t// Update cursor to 'grabbing', document wide.\n\t\townerDocument.body.classList.add( bodyClass );\n\n\t\t// Allow the Synthetic Event to be accessed from asynchronous code.\n\t\t// https://reactjs.org/docs/events.html#event-pooling\n\t\tevent.persist();\n\n\t\tlet timerId: number | undefined;\n\n\t\tif ( onDragStart ) {\n\t\t\ttimerId = setTimeout( () => onDragStart( event ) );\n\t\t}\n\n\t\tcleanup.current = () => {\n\t\t\t// Remove drag clone.\n\t\t\tif ( cloneWrapper && cloneWrapper.parentNode ) {\n\t\t\t\tcloneWrapper.parentNode.removeChild( cloneWrapper );\n\t\t\t}\n\n\t\t\tif ( dragImage && dragImage.parentNode ) {\n\t\t\t\tdragImage.parentNode.removeChild( dragImage );\n\t\t\t}\n\n\t\t\t// Reset cursor.\n\t\t\townerDocument.body.classList.remove( bodyClass );\n\n\t\t\townerDocument.removeEventListener( 'dragover', throttledDragOver );\n\n\t\t\tclearTimeout( timerId );\n\t\t};\n\t}\n\n\tuseEffect(\n\t\t() => () => {\n\t\t\tcleanup.current();\n\t\t},\n\t\t[]\n\t);\n\n\treturn (\n\t\t<>\n\t\t\t{ children( {\n\t\t\t\tonDraggableStart: start,\n\t\t\t\tonDraggableEnd: end,\n\t\t\t} ) }\n\t\t\t{ dragComponent && (\n\t\t\t\t<div\n\t\t\t\t\tclassName=\"components-draggable-drag-component-root\"\n\t\t\t\t\tstyle={ { display: 'none' } }\n\t\t\t\t\tref={ dragComponentRef }\n\t\t\t\t>\n\t\t\t\t\t{ dragComponent }\n\t\t\t\t</div>\n\t\t\t) }\n\t\t</>\n\t);\n}\n\nexport default Draggable;\n"]}
1
+ {"version":3,"sources":["@wordpress/components/src/draggable/index.tsx"],"names":["dragImageClass","cloneWrapperClass","clonePadding","bodyClass","Draggable","children","onDragStart","onDragOver","onDragEnd","appendToOwnerDocument","cloneClassname","elementId","transferData","__experimentalTransferDataType","transferDataType","__experimentalDragComponent","dragComponent","dragComponentRef","cleanup","end","event","preventDefault","current","start","ownerDocument","target","dataTransfer","setData","JSON","stringify","cloneWrapper","createElement","style","top","left","dragImage","setDragImage","classList","add","body","appendChild","x","y","clientX","clientY","transform","clonedDragComponent","innerHTML","element","getElementById","elementRect","getBoundingClientRect","elementWrapper","parentNode","elementTopOffset","elementLeftOffset","width","clone","cloneNode","id","Array","from","querySelectorAll","forEach","child","removeChild","cursorLeft","cursorTop","over","e","nextX","nextY","throttledDragOver","addEventListener","remove","removeEventListener","onDraggableStart","onDraggableEnd","display"],"mappings":";;;;;;;;AASA;;AADA;;AARA;AACA;AACA;;AAGA;AACA;AACA;AASA,MAAMA,cAAc,GAAG,4CAAvB;AACA,MAAMC,iBAAiB,GAAG,6BAA1B;AACA,MAAMC,YAAY,GAAG,CAArB;AACA,MAAMC,SAAS,GAAG,kCAAlB;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACO,SAASC,SAAT,OAWa;AAAA,MAXO;AAC1BC,IAAAA,QAD0B;AAE1BC,IAAAA,WAF0B;AAG1BC,IAAAA,UAH0B;AAI1BC,IAAAA,SAJ0B;AAK1BC,IAAAA,qBAAqB,GAAG,KALE;AAM1BC,IAAAA,cAN0B;AAO1BC,IAAAA,SAP0B;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AOA,SACC,qDACGjB,QAAQ,CAAE;AACXuE,IAAAA,gBAAgB,EAAErD,KADP;AAEXsD,IAAAA,cAAc,EAAE1D;AAFL,GAAF,CADX,EAKGH,aAAa,IACd;AACC,IAAA,SAAS,EAAC,0CADX;AAEC,IAAA,KAAK,EAAG;AAAE8D,MAAAA,OAAO,EAAE;AAAX,KAFT;AAGC,IAAA,GAAG,EAAG7D;AAHP,KAKGD,aALH,CANF,CADD;AAiBA;;eAEcZ,S","sourcesContent":["/**\n * External dependencies\n */\nimport type { DragEvent } from 'react';\n\n/**\n * WordPress dependencies\n */\nimport { throttle } from '@wordpress/compose';\nimport { useEffect, useRef } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport type { DraggableProps } from './types';\n\nconst dragImageClass = 'components-draggable__invisible-drag-image';\nconst cloneWrapperClass = 'components-draggable__clone';\nconst clonePadding = 0;\nconst bodyClass = 'is-dragging-components-draggable';\n\n/**\n * `Draggable` is a Component that provides a way to set up a cross-browser\n * (including IE) customizable drag image and the transfer data for the drag\n * event. It decouples the drag handle and the element to drag: use it by\n * wrapping the component that will become the drag handle and providing the DOM\n * ID of the element to drag.\n *\n * Note that the drag handle needs to declare the `draggable=\"true\"` property\n * and bind the `Draggable`s `onDraggableStart` and `onDraggableEnd` event\n * handlers to its own `onDragStart` and `onDragEnd` respectively. `Draggable`\n * takes care of the logic to setup the drag image and the transfer data, but is\n * not concerned with creating an actual DOM element that is draggable.\n *\n * ```jsx\n * import { Draggable, Panel, PanelBody } from '@wordpress/components';\n * import { Icon, more } from '@wordpress/icons';\n *\n * const MyDraggable = () => (\n * <div id=\"draggable-panel\">\n * <Panel header=\"Draggable panel\">\n * <PanelBody>\n * <Draggable elementId=\"draggable-panel\" transferData={ {} }>\n * { ( { onDraggableStart, onDraggableEnd } ) => (\n * <div\n * className=\"example-drag-handle\"\n * draggable\n * onDragStart={ onDraggableStart }\n * onDragEnd={ onDraggableEnd }\n * >\n * <Icon icon={ more } />\n * </div>\n * ) }\n * </Draggable>\n * </PanelBody>\n * </Panel>\n * </div>\n * );\n * ```\n */\nexport function Draggable( {\n\tchildren,\n\tonDragStart,\n\tonDragOver,\n\tonDragEnd,\n\tappendToOwnerDocument = false,\n\tcloneClassname,\n\telementId,\n\ttransferData,\n\t__experimentalTransferDataType: transferDataType = 'text',\n\t__experimentalDragComponent: dragComponent,\n}: DraggableProps ) {\n\tconst dragComponentRef = useRef< HTMLDivElement >( null );\n\tconst cleanup = useRef( () => {} );\n\n\t/**\n\t * Removes the element clone, resets cursor, and removes drag listener.\n\t *\n\t * @param event The non-custom DragEvent.\n\t */\n\tfunction end( event: DragEvent ) {\n\t\tevent.preventDefault();\n\t\tcleanup.current();\n\n\t\tif ( onDragEnd ) {\n\t\t\tonDragEnd( event );\n\t\t}\n\t}\n\n\t/**\n\t * This method does a couple of things:\n\t *\n\t * - Clones the current element and spawns clone over original element.\n\t * - Adds a fake temporary drag image to avoid browser defaults.\n\t * - Sets transfer data.\n\t * - Adds dragover listener.\n\t *\n\t * @param event The non-custom DragEvent.\n\t */\n\tfunction start( event: DragEvent ) {\n\t\tconst { ownerDocument } = event.target as HTMLElement;\n\n\t\tevent.dataTransfer.setData(\n\t\t\ttransferDataType,\n\t\t\tJSON.stringify( transferData )\n\t\t);\n\n\t\tconst cloneWrapper = ownerDocument.createElement( 'div' );\n\t\t// Reset position to 0,0. Natural stacking order will position this lower, even with a transform otherwise.\n\t\tcloneWrapper.style.top = '0';\n\t\tcloneWrapper.style.left = '0';\n\n\t\tconst dragImage = ownerDocument.createElement( 'div' );\n\n\t\t// Set a fake drag image to avoid browser defaults. Remove from DOM\n\t\t// right after. event.dataTransfer.setDragImage is not supported yet in\n\t\t// IE, we need to check for its existence first.\n\t\tif ( 'function' === typeof event.dataTransfer.setDragImage ) {\n\t\t\tdragImage.classList.add( dragImageClass );\n\t\t\townerDocument.body.appendChild( dragImage );\n\t\t\tevent.dataTransfer.setDragImage( dragImage, 0, 0 );\n\t\t}\n\n\t\tcloneWrapper.classList.add( cloneWrapperClass );\n\n\t\tif ( cloneClassname ) {\n\t\t\tcloneWrapper.classList.add( cloneClassname );\n\t\t}\n\n\t\tlet x = 0;\n\t\tlet y = 0;\n\t\t// If a dragComponent is defined, the following logic will clone the\n\t\t// HTML node and inject it into the cloneWrapper.\n\t\tif ( dragComponentRef.current ) {\n\t\t\t// Position dragComponent at the same position as the cursor.\n\t\t\tx = event.clientX;\n\t\t\ty = event.clientY;\n\t\t\tcloneWrapper.style.transform = `translate( ${ x }px, ${ y }px )`;\n\n\t\t\tconst clonedDragComponent = ownerDocument.createElement( 'div' );\n\t\t\tclonedDragComponent.innerHTML = dragComponentRef.current.innerHTML;\n\t\t\tcloneWrapper.appendChild( clonedDragComponent );\n\n\t\t\t// Inject the cloneWrapper into the DOM.\n\t\t\townerDocument.body.appendChild( cloneWrapper );\n\t\t} else {\n\t\t\tconst element = ownerDocument.getElementById(\n\t\t\t\telementId\n\t\t\t) as HTMLElement;\n\n\t\t\t// Prepare element clone and append to element wrapper.\n\t\t\tconst elementRect = element.getBoundingClientRect();\n\t\t\tconst elementWrapper = element.parentNode;\n\t\t\tconst elementTopOffset = elementRect.top;\n\t\t\tconst elementLeftOffset = elementRect.left;\n\n\t\t\tcloneWrapper.style.width = `${\n\t\t\t\telementRect.width + clonePadding * 2\n\t\t\t}px`;\n\n\t\t\tconst clone = element.cloneNode( true ) as HTMLElement;\n\t\t\tclone.id = `clone-${ elementId }`;\n\n\t\t\t// Position clone right over the original element (20px padding).\n\t\t\tx = elementLeftOffset - clonePadding;\n\t\t\ty = elementTopOffset - clonePadding;\n\t\t\tcloneWrapper.style.transform = `translate( ${ x }px, ${ y }px )`;\n\n\t\t\t// Hack: Remove iFrames as it's causing the embeds drag clone to freeze.\n\t\t\tArray.from< HTMLIFrameElement >(\n\t\t\t\tclone.querySelectorAll( 'iframe' )\n\t\t\t).forEach( ( child ) => child.parentNode?.removeChild( child ) );\n\n\t\t\tcloneWrapper.appendChild( clone );\n\n\t\t\t// Inject the cloneWrapper into the DOM.\n\t\t\tif ( appendToOwnerDocument ) {\n\t\t\t\townerDocument.body.appendChild( cloneWrapper );\n\t\t\t} else {\n\t\t\t\telementWrapper?.appendChild( cloneWrapper );\n\t\t\t}\n\t\t}\n\n\t\t// Mark the current cursor coordinates.\n\t\tlet cursorLeft = event.clientX;\n\t\tlet cursorTop = event.clientY;\n\n\t\tfunction over( e: DragEvent ) {\n\t\t\t// Skip doing any work if mouse has not moved.\n\t\t\tif ( cursorLeft === e.clientX && cursorTop === e.clientY ) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tconst nextX = x + e.clientX - cursorLeft;\n\t\t\tconst nextY = y + e.clientY - cursorTop;\n\t\t\tcloneWrapper.style.transform = `translate( ${ nextX }px, ${ nextY }px )`;\n\t\t\tcursorLeft = e.clientX;\n\t\t\tcursorTop = e.clientY;\n\t\t\tx = nextX;\n\t\t\ty = nextY;\n\t\t\tif ( onDragOver ) {\n\t\t\t\tonDragOver( e );\n\t\t\t}\n\t\t}\n\n\t\t// Aim for 60fps (16 ms per frame) for now. We can potentially use requestAnimationFrame (raf) instead,\n\t\t// note that browsers may throttle raf below 60fps in certain conditions.\n\t\t// @ts-ignore\n\t\tconst throttledDragOver = throttle( over, 16 );\n\n\t\townerDocument.addEventListener( 'dragover', throttledDragOver );\n\n\t\t// Update cursor to 'grabbing', document wide.\n\t\townerDocument.body.classList.add( bodyClass );\n\n\t\tif ( onDragStart ) {\n\t\t\tonDragStart( event );\n\t\t}\n\n\t\tcleanup.current = () => {\n\t\t\t// Remove drag clone.\n\t\t\tif ( cloneWrapper && cloneWrapper.parentNode ) {\n\t\t\t\tcloneWrapper.parentNode.removeChild( cloneWrapper );\n\t\t\t}\n\n\t\t\tif ( dragImage && dragImage.parentNode ) {\n\t\t\t\tdragImage.parentNode.removeChild( dragImage );\n\t\t\t}\n\n\t\t\t// Reset cursor.\n\t\t\townerDocument.body.classList.remove( bodyClass );\n\n\t\t\townerDocument.removeEventListener( 'dragover', throttledDragOver );\n\t\t};\n\t}\n\n\tuseEffect(\n\t\t() => () => {\n\t\t\tcleanup.current();\n\t\t},\n\t\t[]\n\t);\n\n\treturn (\n\t\t<>\n\t\t\t{ children( {\n\t\t\t\tonDraggableStart: start,\n\t\t\t\tonDraggableEnd: end,\n\t\t\t} ) }\n\t\t\t{ dragComponent && (\n\t\t\t\t<div\n\t\t\t\t\tclassName=\"components-draggable-drag-component-root\"\n\t\t\t\t\tstyle={ { display: 'none' } }\n\t\t\t\t\tref={ dragComponentRef }\n\t\t\t\t>\n\t\t\t\t\t{ dragComponent }\n\t\t\t\t</div>\n\t\t\t) }\n\t\t</>\n\t);\n}\n\nexport default Draggable;\n"]}
@@ -36,6 +36,8 @@ var _baseControlStyles = require("../base-control/styles/base-control-styles");
36
36
 
37
37
  var _spacer = require("../spacer");
38
38
 
39
+ var _useDeprecatedProps = require("../utils/use-deprecated-props");
40
+
39
41
  /**
40
42
  * External dependencies
41
43
  */
@@ -89,10 +91,10 @@ function FormTokenField(props) {
89
91
  __experimentalExpandOnFocus = false,
90
92
  __experimentalValidateInput = () => true,
91
93
  __experimentalShowHowTo = true,
92
- __next36pxDefaultSize = false,
94
+ __next40pxDefaultSize = false,
93
95
  __experimentalAutoSelectFirstMatch = false,
94
96
  __nextHasNoMarginBottom = false
95
- } = props;
97
+ } = (0, _useDeprecatedProps.useDeprecated36pxDefaultSizeProp)(props, 'wp.components.FormTokenField');
96
98
  const instanceId = (0, _compose.useInstanceId)(FormTokenField); // We reset to these initial values again in the onBlur
97
99
 
98
100
  const [incompleteTokenValue, setIncompleteTokenValue] = (0, _element.useState)('');
@@ -644,7 +646,7 @@ function FormTokenField(props) {
644
646
  align: "center",
645
647
  gap: 1,
646
648
  wrap: true,
647
- __next36pxDefaultSize: __next36pxDefaultSize,
649
+ __next40pxDefaultSize: __next40pxDefaultSize,
648
650
  hasTokens: !!value.length
649
651
  }, renderTokensAndInput()), isExpanded && (0, _element.createElement)(_suggestionsList.default, {
650
652
  instanceId: instanceId,