@wordpress/components 19.11.0 → 19.12.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 (385) hide show
  1. package/CHANGELOG.md +36 -0
  2. package/README.md +1 -1
  3. package/build/alignment-matrix-control/index.js +5 -2
  4. package/build/alignment-matrix-control/index.js.map +1 -1
  5. package/build/autocomplete/autocompleter-ui.js +1 -1
  6. package/build/autocomplete/autocompleter-ui.js.map +1 -1
  7. package/build/autocomplete/autocompleter-ui.native.js +2 -2
  8. package/build/autocomplete/autocompleter-ui.native.js.map +1 -1
  9. package/build/autocomplete/index.js +12 -10
  10. package/build/autocomplete/index.js.map +1 -1
  11. package/build/border-box-control/border-box-control/hook.js +2 -2
  12. package/build/border-box-control/border-box-control/hook.js.map +1 -1
  13. package/build/border-box-control/border-box-control-split-controls/component.js +2 -0
  14. package/build/border-box-control/border-box-control-split-controls/component.js.map +1 -1
  15. package/build/border-box-control/border-box-control-split-controls/hook.js +13 -4
  16. package/build/border-box-control/border-box-control-split-controls/hook.js.map +1 -1
  17. package/build/border-box-control/border-box-control-visualizer/hook.js +6 -2
  18. package/build/border-box-control/border-box-control-visualizer/hook.js.map +1 -1
  19. package/build/border-box-control/styles.js +21 -11
  20. package/build/border-box-control/styles.js.map +1 -1
  21. package/build/border-control/border-control/hook.js +2 -2
  22. package/build/border-control/border-control/hook.js.map +1 -1
  23. package/build/color-palette/index.js +9 -2
  24. package/build/color-palette/index.js.map +1 -1
  25. package/build/color-palette/index.native.js +4 -1
  26. package/build/color-palette/index.native.js.map +1 -1
  27. package/build/color-picker/color-copy-button.js +87 -0
  28. package/build/color-picker/color-copy-button.js.map +1 -0
  29. package/build/color-picker/component.js +5 -15
  30. package/build/color-picker/component.js.map +1 -1
  31. package/build/color-picker/hex-input.js +18 -1
  32. package/build/color-picker/hex-input.js.map +1 -1
  33. package/build/color-picker/styles.js +11 -11
  34. package/build/color-picker/styles.js.map +1 -1
  35. package/build/custom-gradient-picker/utils.js +1 -1
  36. package/build/custom-gradient-picker/utils.js.map +1 -1
  37. package/build/date-time/{date.js → date/index.js} +51 -12
  38. package/build/date-time/date/index.js.map +1 -0
  39. package/build/date-time/date/styles.js +70 -0
  40. package/build/date-time/date/styles.js.map +1 -0
  41. package/build/date-time/{utils.js → date/utils.js} +0 -0
  42. package/build/date-time/date/utils.js.map +1 -0
  43. package/build/date-time/date-time/index.js +175 -0
  44. package/build/date-time/date-time/index.js.map +1 -0
  45. package/build/date-time/date-time/styles.js +32 -0
  46. package/build/date-time/date-time/styles.js.map +1 -0
  47. package/build/date-time/index.js +2 -109
  48. package/build/date-time/index.js.map +1 -1
  49. package/build/date-time/time/index.js +322 -0
  50. package/build/date-time/time/index.js.map +1 -0
  51. package/build/date-time/time/styles.js +139 -0
  52. package/build/date-time/time/styles.js.map +1 -0
  53. package/build/date-time/{timezone.js → time/timezone.js} +4 -2
  54. package/build/date-time/time/timezone.js.map +1 -0
  55. package/build/draggable/index.native.js +10 -5
  56. package/build/draggable/index.native.js.map +1 -1
  57. package/build/dropdown/index.js +4 -1
  58. package/build/dropdown/index.js.map +1 -1
  59. package/build/input-control/index.js +9 -4
  60. package/build/input-control/index.js.map +1 -1
  61. package/build/input-control/input-field.js +1 -26
  62. package/build/input-control/input-field.js.map +1 -1
  63. package/build/input-control/reducer/reducer.js +36 -24
  64. package/build/input-control/reducer/reducer.js.map +1 -1
  65. package/build/input-control/reducer/state.js +0 -1
  66. package/build/input-control/reducer/state.js.map +1 -1
  67. package/build/input-control/utils.js +45 -0
  68. package/build/input-control/utils.js.map +1 -1
  69. package/build/popover/index.js +40 -33
  70. package/build/popover/index.js.map +1 -1
  71. package/build/search-control/index.js +4 -6
  72. package/build/search-control/index.js.map +1 -1
  73. package/build/select-control/index.js +3 -1
  74. package/build/select-control/index.js.map +1 -1
  75. package/build/spacer/hook.js +11 -3
  76. package/build/spacer/hook.js.map +1 -1
  77. package/build/surface/component.js +7 -7
  78. package/build/surface/component.js.map +1 -1
  79. package/build/surface/hook.js +8 -11
  80. package/build/surface/hook.js.map +1 -1
  81. package/build/surface/index.js.map +1 -1
  82. package/build/surface/styles.js +8 -48
  83. package/build/surface/styles.js.map +1 -1
  84. package/build/textarea-control/index.js +40 -6
  85. package/build/textarea-control/index.js.map +1 -1
  86. package/build/textarea-control/styles/textarea-control-styles.js +3 -3
  87. package/build/textarea-control/styles/textarea-control-styles.js.map +1 -1
  88. package/build/textarea-control/types.js +6 -0
  89. package/build/textarea-control/types.js.map +1 -0
  90. package/build/utils/hooks/index.js +0 -8
  91. package/build/utils/hooks/index.js.map +1 -1
  92. package/build-module/alignment-matrix-control/index.js +5 -2
  93. package/build-module/alignment-matrix-control/index.js.map +1 -1
  94. package/build-module/autocomplete/autocompleter-ui.js +1 -1
  95. package/build-module/autocomplete/autocompleter-ui.js.map +1 -1
  96. package/build-module/autocomplete/autocompleter-ui.native.js +2 -2
  97. package/build-module/autocomplete/autocompleter-ui.native.js.map +1 -1
  98. package/build-module/autocomplete/index.js +13 -11
  99. package/build-module/autocomplete/index.js.map +1 -1
  100. package/build-module/border-box-control/border-box-control/hook.js +2 -2
  101. package/build-module/border-box-control/border-box-control/hook.js.map +1 -1
  102. package/build-module/border-box-control/border-box-control-split-controls/component.js +2 -0
  103. package/build-module/border-box-control/border-box-control-split-controls/component.js.map +1 -1
  104. package/build-module/border-box-control/border-box-control-split-controls/hook.js +11 -4
  105. package/build-module/border-box-control/border-box-control-split-controls/hook.js.map +1 -1
  106. package/build-module/border-box-control/border-box-control-visualizer/hook.js +4 -2
  107. package/build-module/border-box-control/border-box-control-visualizer/hook.js.map +1 -1
  108. package/build-module/border-box-control/styles.js +13 -8
  109. package/build-module/border-box-control/styles.js.map +1 -1
  110. package/build-module/border-control/border-control/hook.js +2 -2
  111. package/build-module/border-control/border-control/hook.js.map +1 -1
  112. package/build-module/color-palette/index.js +7 -5
  113. package/build-module/color-palette/index.js.map +1 -1
  114. package/build-module/color-palette/index.native.js +4 -1
  115. package/build-module/color-palette/index.native.js.map +1 -1
  116. package/build-module/color-picker/color-copy-button.js +73 -0
  117. package/build-module/color-picker/color-copy-button.js.map +1 -0
  118. package/build-module/color-picker/component.js +6 -15
  119. package/build-module/color-picker/component.js.map +1 -1
  120. package/build-module/color-picker/hex-input.js +18 -1
  121. package/build-module/color-picker/hex-input.js.map +1 -1
  122. package/build-module/color-picker/styles.js +9 -9
  123. package/build-module/color-picker/styles.js.map +1 -1
  124. package/build-module/custom-gradient-picker/utils.js +1 -1
  125. package/build-module/custom-gradient-picker/utils.js.map +1 -1
  126. package/build-module/date-time/{date.js → date/index.js} +46 -14
  127. package/build-module/date-time/date/index.js.map +1 -0
  128. package/build-module/date-time/date/styles.js +61 -0
  129. package/build-module/date-time/date/styles.js.map +1 -0
  130. package/build-module/date-time/{utils.js → date/utils.js} +0 -0
  131. package/build-module/date-time/date/utils.js.map +1 -0
  132. package/build-module/date-time/date-time/index.js +144 -0
  133. package/build-module/date-time/date-time/index.js.map +1 -0
  134. package/build-module/date-time/date-time/styles.js +22 -0
  135. package/build-module/date-time/date-time/styles.js.map +1 -0
  136. package/build-module/date-time/index.js +1 -105
  137. package/build-module/date-time/index.js.map +1 -1
  138. package/build-module/date-time/time/index.js +302 -0
  139. package/build-module/date-time/time/index.js.map +1 -0
  140. package/build-module/date-time/time/styles.js +118 -0
  141. package/build-module/date-time/time/styles.js.map +1 -0
  142. package/build-module/date-time/{timezone.js → time/timezone.js} +3 -2
  143. package/build-module/date-time/time/timezone.js.map +1 -0
  144. package/build-module/draggable/index.native.js +10 -5
  145. package/build-module/draggable/index.native.js.map +1 -1
  146. package/build-module/dropdown/index.js +4 -1
  147. package/build-module/dropdown/index.js.map +1 -1
  148. package/build-module/input-control/index.js +8 -4
  149. package/build-module/input-control/index.js.map +1 -1
  150. package/build-module/input-control/input-field.js +1 -25
  151. package/build-module/input-control/input-field.js.map +1 -1
  152. package/build-module/input-control/reducer/reducer.js +38 -26
  153. package/build-module/input-control/reducer/reducer.js.map +1 -1
  154. package/build-module/input-control/reducer/state.js +0 -1
  155. package/build-module/input-control/reducer/state.js.map +1 -1
  156. package/build-module/input-control/utils.js +48 -2
  157. package/build-module/input-control/utils.js.map +1 -1
  158. package/build-module/popover/index.js +40 -33
  159. package/build-module/popover/index.js.map +1 -1
  160. package/build-module/search-control/index.js +6 -7
  161. package/build-module/search-control/index.js.map +1 -1
  162. package/build-module/select-control/index.js +3 -1
  163. package/build-module/select-control/index.js.map +1 -1
  164. package/build-module/spacer/hook.js +10 -2
  165. package/build-module/spacer/hook.js.map +1 -1
  166. package/build-module/surface/component.js +7 -7
  167. package/build-module/surface/component.js.map +1 -1
  168. package/build-module/surface/hook.js +8 -11
  169. package/build-module/surface/hook.js.map +1 -1
  170. package/build-module/surface/index.js.map +1 -1
  171. package/build-module/surface/styles.js +8 -48
  172. package/build-module/surface/styles.js.map +1 -1
  173. package/build-module/textarea-control/index.js +36 -5
  174. package/build-module/textarea-control/index.js.map +1 -1
  175. package/build-module/textarea-control/styles/textarea-control-styles.js +3 -3
  176. package/build-module/textarea-control/styles/textarea-control-styles.js.map +1 -1
  177. package/build-module/textarea-control/types.js +2 -0
  178. package/build-module/textarea-control/types.js.map +1 -0
  179. package/build-module/utils/hooks/index.js +0 -1
  180. package/build-module/utils/hooks/index.js.map +1 -1
  181. package/build-style/style-rtl.css +13 -188
  182. package/build-style/style.css +13 -191
  183. package/build-types/border-box-control/border-box-control-split-controls/component.d.ts.map +1 -1
  184. package/build-types/border-box-control/border-box-control-split-controls/hook.d.ts +1 -0
  185. package/build-types/border-box-control/border-box-control-split-controls/hook.d.ts.map +1 -1
  186. package/build-types/border-box-control/border-box-control-visualizer/hook.d.ts.map +1 -1
  187. package/build-types/border-box-control/styles.d.ts +3 -2
  188. package/build-types/border-box-control/styles.d.ts.map +1 -1
  189. package/build-types/border-control/border-control/hook.d.ts.map +1 -1
  190. package/build-types/card/types.d.ts +1 -1
  191. package/build-types/card/types.d.ts.map +1 -1
  192. package/build-types/checkbox-control/test/index.d.ts +2 -0
  193. package/build-types/checkbox-control/test/index.d.ts.map +1 -0
  194. package/build-types/color-palette/index.d.ts +1 -0
  195. package/build-types/color-palette/index.d.ts.map +1 -1
  196. package/build-types/{date-time → color-palette}/test/utils.d.ts +0 -0
  197. package/build-types/color-palette/test/utils.d.ts.map +1 -0
  198. package/build-types/color-picker/color-copy-button.d.ts +4 -0
  199. package/build-types/color-picker/color-copy-button.d.ts.map +1 -0
  200. package/build-types/color-picker/component.d.ts.map +1 -1
  201. package/build-types/color-picker/hex-input.d.ts.map +1 -1
  202. package/build-types/color-picker/styles.d.ts +1 -1
  203. package/build-types/color-picker/styles.d.ts.map +1 -1
  204. package/build-types/color-picker/types.d.ts +8 -0
  205. package/build-types/color-picker/types.d.ts.map +1 -1
  206. package/build-types/date-time/{date.d.ts → date/index.d.ts} +3 -2
  207. package/build-types/date-time/date/index.d.ts.map +1 -0
  208. package/build-types/date-time/date/styles.d.ts +23 -0
  209. package/build-types/date-time/date/styles.d.ts.map +1 -0
  210. package/build-types/date-time/date/test/index.d.ts +2 -0
  211. package/build-types/date-time/date/test/index.d.ts.map +1 -0
  212. package/build-types/date-time/date/test/utils.d.ts +2 -0
  213. package/build-types/date-time/date/test/utils.d.ts.map +1 -0
  214. package/build-types/date-time/{utils.d.ts → date/utils.d.ts} +0 -0
  215. package/build-types/date-time/date/utils.d.ts.map +1 -0
  216. package/build-types/date-time/date-time/index.d.ts +33 -0
  217. package/build-types/date-time/date-time/index.d.ts.map +1 -0
  218. package/build-types/date-time/date-time/styles.d.ts +6 -0
  219. package/build-types/date-time/date-time/styles.d.ts.map +1 -0
  220. package/build-types/date-time/index.d.ts +2 -28
  221. package/build-types/date-time/index.d.ts.map +1 -1
  222. package/build-types/date-time/stories/{index.d.ts → date-time.d.ts} +2 -2
  223. package/build-types/date-time/stories/date-time.d.ts.map +1 -0
  224. package/build-types/date-time/{time.d.ts → time/index.d.ts} +2 -2
  225. package/build-types/date-time/time/index.d.ts.map +1 -0
  226. package/build-types/date-time/time/styles.d.ts +111 -0
  227. package/build-types/date-time/time/styles.d.ts.map +1 -0
  228. package/build-types/date-time/time/test/index.d.ts +2 -0
  229. package/build-types/date-time/time/test/index.d.ts.map +1 -0
  230. package/build-types/date-time/{timezone.d.ts → time/timezone.d.ts} +0 -0
  231. package/build-types/date-time/time/timezone.d.ts.map +1 -0
  232. package/build-types/date-time/types.d.ts +14 -15
  233. package/build-types/date-time/types.d.ts.map +1 -1
  234. package/build-types/dropdown/index.d.ts.map +1 -1
  235. package/build-types/input-control/index.d.ts.map +1 -1
  236. package/build-types/input-control/input-field.d.ts.map +1 -1
  237. package/build-types/input-control/reducer/reducer.d.ts +5 -3
  238. package/build-types/input-control/reducer/reducer.d.ts.map +1 -1
  239. package/build-types/input-control/reducer/state.d.ts +2 -2
  240. package/build-types/input-control/reducer/state.d.ts.map +1 -1
  241. package/build-types/input-control/utils.d.ts +17 -0
  242. package/build-types/input-control/utils.d.ts.map +1 -1
  243. package/build-types/popover/index.d.ts +1 -0
  244. package/build-types/popover/index.d.ts.map +1 -1
  245. package/build-types/select-control/index.d.ts.map +1 -1
  246. package/build-types/select-control/types.d.ts +1 -1
  247. package/build-types/select-control/types.d.ts.map +1 -1
  248. package/build-types/surface/component.d.ts +3 -2
  249. package/build-types/surface/component.d.ts.map +1 -1
  250. package/build-types/surface/hook.d.ts +4 -4
  251. package/build-types/surface/hook.d.ts.map +1 -1
  252. package/build-types/surface/index.d.ts +2 -2
  253. package/build-types/surface/index.d.ts.map +1 -1
  254. package/build-types/surface/stories/index.d.ts +12 -0
  255. package/build-types/surface/stories/index.d.ts.map +1 -0
  256. package/build-types/surface/styles.d.ts +10 -21
  257. package/build-types/surface/styles.d.ts.map +1 -1
  258. package/build-types/surface/test/index.d.ts +2 -0
  259. package/build-types/surface/test/index.d.ts.map +1 -0
  260. package/build-types/surface/types.d.ts +1 -1
  261. package/build-types/surface/types.d.ts.map +1 -1
  262. package/build-types/textarea-control/index.d.ts +29 -0
  263. package/build-types/textarea-control/index.d.ts.map +1 -0
  264. package/build-types/textarea-control/stories/index.d.ts +12 -0
  265. package/build-types/textarea-control/stories/index.d.ts.map +1 -0
  266. package/build-types/textarea-control/styles/textarea-control-styles.d.ts +6 -0
  267. package/build-types/textarea-control/styles/textarea-control-styles.d.ts.map +1 -0
  268. package/build-types/textarea-control/types.d.ts +26 -0
  269. package/build-types/textarea-control/types.d.ts.map +1 -0
  270. package/build-types/utils/hooks/index.d.ts +0 -1
  271. package/package.json +18 -18
  272. package/src/alignment-matrix-control/index.js +4 -2
  273. package/src/autocomplete/autocompleter-ui.js +1 -1
  274. package/src/autocomplete/autocompleter-ui.native.js +2 -2
  275. package/src/autocomplete/index.js +21 -9
  276. package/src/border-box-control/border-box-control/hook.ts +2 -2
  277. package/src/border-box-control/border-box-control-split-controls/component.tsx +2 -0
  278. package/src/border-box-control/border-box-control-split-controls/hook.ts +18 -4
  279. package/src/border-box-control/border-box-control-visualizer/hook.ts +5 -2
  280. package/src/border-box-control/styles.ts +6 -2
  281. package/src/border-control/border-control/hook.ts +8 -2
  282. package/src/box-control/test/index.js +120 -109
  283. package/src/card/types.ts +1 -1
  284. package/src/checkbox-control/test/__snapshots__/index.tsx.snap +42 -0
  285. package/src/checkbox-control/test/index.tsx +109 -0
  286. package/src/color-palette/index.js +11 -4
  287. package/src/color-palette/index.native.js +3 -0
  288. package/src/color-palette/stories/index.js +25 -1
  289. package/src/color-palette/test/utils.ts +24 -0
  290. package/src/color-picker/color-copy-button.tsx +76 -0
  291. package/src/color-picker/component.tsx +18 -38
  292. package/src/color-picker/hex-input.tsx +16 -0
  293. package/src/color-picker/styles.ts +5 -1
  294. package/src/color-picker/types.ts +9 -0
  295. package/src/custom-gradient-picker/utils.js +1 -1
  296. package/src/date-time/README.md +16 -0
  297. package/src/date-time/{datepicker.scss → date/datepicker.scss} +0 -0
  298. package/src/date-time/{date.tsx → date/index.tsx} +38 -15
  299. package/src/date-time/date/style.scss +75 -0
  300. package/src/date-time/date/styles.ts +55 -0
  301. package/src/date-time/{test/date.tsx → date/test/index.tsx} +1 -1
  302. package/src/date-time/{test → date/test}/utils.ts +0 -0
  303. package/src/date-time/{utils.ts → date/utils.ts} +0 -0
  304. package/src/date-time/date-time/index.tsx +217 -0
  305. package/src/date-time/date-time/styles.ts +8 -0
  306. package/src/date-time/index.ts +9 -0
  307. package/src/date-time/stories/{index.tsx → date-time.tsx} +1 -1
  308. package/src/date-time/style.scss +1 -262
  309. package/src/date-time/time/index.tsx +356 -0
  310. package/src/date-time/time/styles.ts +119 -0
  311. package/src/date-time/{test/time.tsx → time/test/index.tsx} +85 -38
  312. package/src/date-time/{timezone.tsx → time/timezone.tsx} +5 -2
  313. package/src/date-time/types.ts +16 -18
  314. package/src/draggable/index.native.js +14 -3
  315. package/src/draggable/test/index.native.js +130 -0
  316. package/src/dropdown/index.js +5 -1
  317. package/src/input-control/index.tsx +8 -2
  318. package/src/input-control/input-field.tsx +10 -30
  319. package/src/input-control/reducer/reducer.ts +40 -26
  320. package/src/input-control/reducer/state.ts +2 -3
  321. package/src/input-control/utils.ts +55 -1
  322. package/src/popover/index.js +42 -27
  323. package/src/query-controls/README.md +1 -1
  324. package/src/search-control/index.js +6 -7
  325. package/src/select-control/README.md +11 -0
  326. package/src/select-control/index.tsx +6 -1
  327. package/src/select-control/types.ts +1 -1
  328. package/src/slot-fill/README.md +1 -1
  329. package/src/spacer/hook.ts +13 -13
  330. package/src/surface/README.md +15 -15
  331. package/src/surface/{component.js → component.tsx} +13 -7
  332. package/src/surface/{hook.js → hook.ts} +13 -12
  333. package/src/surface/{index.js → index.ts} +0 -0
  334. package/src/surface/stories/index.tsx +40 -0
  335. package/src/surface/{styles.js → styles.ts} +15 -44
  336. package/src/surface/test/__snapshots__/{index.js.snap → index.tsx.snap} +0 -0
  337. package/src/surface/test/{index.js → index.tsx} +2 -1
  338. package/src/surface/types.ts +1 -1
  339. package/src/textarea-control/README.md +14 -20
  340. package/src/textarea-control/index.tsx +86 -0
  341. package/src/textarea-control/stories/index.tsx +58 -0
  342. package/src/textarea-control/styles/{textarea-control-styles.js → textarea-control-styles.ts} +0 -0
  343. package/src/textarea-control/types.ts +30 -0
  344. package/src/utils/hooks/index.js +0 -1
  345. package/tsconfig.json +1 -0
  346. package/tsconfig.tsbuildinfo +1 -1
  347. package/build/color-picker/color-display.js +0 -184
  348. package/build/color-picker/color-display.js.map +0 -1
  349. package/build/date-time/date.js.map +0 -1
  350. package/build/date-time/time.js +0 -289
  351. package/build/date-time/time.js.map +0 -1
  352. package/build/date-time/timezone.js.map +0 -1
  353. package/build/date-time/utils.js.map +0 -1
  354. package/build/utils/hooks/use-combined-ref.js +0 -32
  355. package/build/utils/hooks/use-combined-ref.js.map +0 -1
  356. package/build-module/color-picker/color-display.js +0 -170
  357. package/build-module/color-picker/color-display.js.map +0 -1
  358. package/build-module/date-time/date.js.map +0 -1
  359. package/build-module/date-time/time.js +0 -271
  360. package/build-module/date-time/time.js.map +0 -1
  361. package/build-module/date-time/timezone.js.map +0 -1
  362. package/build-module/date-time/utils.js.map +0 -1
  363. package/build-module/utils/hooks/use-combined-ref.js +0 -28
  364. package/build-module/utils/hooks/use-combined-ref.js.map +0 -1
  365. package/build-types/color-picker/color-display.d.ts +0 -14
  366. package/build-types/color-picker/color-display.d.ts.map +0 -1
  367. package/build-types/date-time/date.d.ts.map +0 -1
  368. package/build-types/date-time/stories/index.d.ts.map +0 -1
  369. package/build-types/date-time/test/date.d.ts +0 -2
  370. package/build-types/date-time/test/date.d.ts.map +0 -1
  371. package/build-types/date-time/test/time.d.ts +0 -2
  372. package/build-types/date-time/test/time.d.ts.map +0 -1
  373. package/build-types/date-time/test/utils.d.ts.map +0 -1
  374. package/build-types/date-time/time.d.ts.map +0 -1
  375. package/build-types/date-time/timezone.d.ts.map +0 -1
  376. package/build-types/date-time/utils.d.ts.map +0 -1
  377. package/build-types/utils/hooks/use-combined-ref.d.ts +0 -8
  378. package/build-types/utils/hooks/use-combined-ref.d.ts.map +0 -1
  379. package/src/color-picker/color-display.tsx +0 -169
  380. package/src/date-time/index.tsx +0 -196
  381. package/src/date-time/time.tsx +0 -321
  382. package/src/surface/stories/index.js +0 -46
  383. package/src/textarea-control/index.js +0 -45
  384. package/src/textarea-control/stories/index.js +0 -48
  385. package/src/utils/hooks/use-combined-ref.ts +0 -28
package/CHANGELOG.md CHANGED
@@ -2,6 +2,39 @@
2
2
 
3
3
  ## Unreleased
4
4
 
5
+ ## 19.12.0 (2022-06-01)
6
+
7
+ ### Bug Fix
8
+
9
+ - `Popover`, `Dropdown`, `CustomGradientPicker`: Fix dropdown positioning by always targeting the rendered toggle, and switch off width in the Popover size middleware to stop reducing the width of the popover. ([#41361](https://github.com/WordPress/gutenberg/pull/41361))
10
+ - Fix `InputControl` blocking undo/redo while focused. ([#40518](https://github.com/WordPress/gutenberg/pull/40518))
11
+ - `ColorPalette`: Correctly update color name label when CSS variables are involved ([#41461](https://github.com/WordPress/gutenberg/pull/41461)).
12
+
13
+ ### Enhancements
14
+
15
+ - `SelectControl`: Add `__nextHasNoMarginBottom` prop for opting into the new margin-free styles ([#41269](https://github.com/WordPress/gutenberg/pull/41269)).
16
+ - `ColorPicker`: Strip leading hash character from hex values pasted into input. ([#41223](https://github.com/WordPress/gutenberg/pull/41223))
17
+ - `ColorPicker`: Display detailed color inputs by default. ([#41222](https://github.com/WordPress/gutenberg/pull/41222))
18
+ - Updated design for the `DateTimePicker`, `DatePicker` and `TimePicker` components ([#41097](https://github.com/WordPress/gutenberg/pull/41097)).
19
+ - `DateTimePicker`: Add `__nextRemoveHelpButton` and `__nextRemoveResetButton` for opting into new behaviour where there is no Help and Reset button ([#41097](https://github.com/WordPress/gutenberg/pull/41097)).
20
+
21
+ ### Internal
22
+
23
+ - `AlignmentMatrixControl` updated to satisfy `react/exhuastive-deps` eslint rule ([#41167](https://github.com/WordPress/gutenberg/pull/41167))
24
+ - `BorderControl` updated to satisfy `react/exhuastive-deps` eslint rule ([#41259](https://github.com/WordPress/gutenberg/pull/41259))
25
+ - `CheckboxControl`: Add unit tests ([#41165](https://github.com/WordPress/gutenberg/pull/41165)).
26
+ - `BorderBoxControl`: fix some layout misalignments, especially for RTL users ([#41254](https://github.com/WordPress/gutenberg/pull/41254)).
27
+ - `TimePicker`: Update unit tests to use `@testing-library/user-event` ([#41270](https://github.com/WordPress/gutenberg/pull/41270)).
28
+ - `DateTimePicker`: Update `moment` to 2.26.0 and update `react-date` typings ([#41266](https://github.com/WordPress/gutenberg/pull/41266)).
29
+ - `TextareaControl`: Convert to TypeScript ([#41215](https://github.com/WordPress/gutenberg/pull/41215)).
30
+ - `BoxControl`: Update unit tests to use `@testing-library/user-event` ([#41422](https://github.com/WordPress/gutenberg/pull/41422)).
31
+ - `Surface`: Convert to TypeScript ([#41212](https://github.com/WordPress/gutenberg/pull/41212)).
32
+ - `Autocomplete` updated to satisfy `react/exhuastive-deps` eslint rule ([#41382](https://github.com/WordPress/gutenberg/pull/41382))
33
+
34
+ ### Experimental
35
+
36
+ - `Spacer`: Add RTL support. ([#41172](https://github.com/WordPress/gutenberg/pull/41172))
37
+
5
38
  ## 19.11.0 (2022-05-18)
6
39
 
7
40
  ### Enhancements
@@ -10,6 +43,8 @@
10
43
  - `BorderControl` & `BorderBoxControl`: Add `__next36pxDefaultSize` flag for larger default size ([#40920](https://github.com/WordPress/gutenberg/pull/40920)).
11
44
  - `BorderControl` improved focus and border radius styling for component. ([#40951](https://github.com/WordPress/gutenberg/pull/40951))
12
45
  - Improve focused `CircularOptionPicker` styling ([#40990](https://github.com/WordPress/gutenberg/pull/40990))
46
+ - `BorderControl`: Make border color consistent with other controls ([#40921](https://github.com/WordPress/gutenberg/pull/40921))
47
+ - `SelectControl`: Remove `lineHeight` setting to fix issue with font descenders being cut off ([#40985](https://github.com/WordPress/gutenberg/pull/40985))
13
48
 
14
49
  ### Internal
15
50
 
@@ -17,6 +52,7 @@
17
52
  - `DateTimePicker`: Convert unit tests to TypeScript ([#40957](https://github.com/WordPress/gutenberg/pull/40957)).
18
53
  - `CheckboxControl`: Convert to TypeScript ([#40915](https://github.com/WordPress/gutenberg/pull/40915)).
19
54
  - `ButtonGroup`: Convert to TypeScript ([#41007](https://github.com/WordPress/gutenberg/pull/41007)).
55
+ - `Popover`: refactor component to use the `floating-ui` library internally ([#40740](https://github.com/WordPress/gutenberg/pull/40740)).
20
56
 
21
57
  ## 19.10.0 (2022-05-04)
22
58
 
package/README.md CHANGED
@@ -71,7 +71,7 @@ const Example = () => {
71
71
 
72
72
  ## Docs & examples
73
73
 
74
- You can browse the components docs and examples at https://wordpress.github.io/gutenberg/
74
+ You can browse the components docs and examples at [https://wordpress.github.io/gutenberg/](https://wordpress.github.io/gutenberg/)
75
75
 
76
76
  ## Contributing to this package
77
77
 
@@ -69,11 +69,14 @@ function AlignmentMatrixControl(_ref) {
69
69
  onChange(nextValue);
70
70
  };
71
71
 
72
+ const {
73
+ setCurrentId
74
+ } = composite;
72
75
  (0, _element.useEffect)(() => {
73
76
  if (typeof value !== 'undefined') {
74
- composite.setCurrentId((0, _utils.getItemId)(baseId, value));
77
+ setCurrentId((0, _utils.getItemId)(baseId, value));
75
78
  }
76
- }, [value, composite.setCurrentId]);
79
+ }, [value, setCurrentId, baseId]);
77
80
  const classes = (0, _classnames.default)('component-alignment-matrix-control', className);
78
81
  return (0, _element.createElement)(_composite.Composite, (0, _extends2.default)({}, props, composite, {
79
82
  "aria-label": label,
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/components/src/alignment-matrix-control/index.js"],"names":["useBaseId","id","instanceId","AlignmentMatrixControl","className","label","defaultValue","value","onChange","noop","width","props","immutableDefaultValue","baseId","initialCurrentId","composite","currentId","rtl","handleOnChange","nextValue","setCurrentId","classes","Root","GRID","map","cells","index","Row","cell","cellId","isActive","Icon","AlignmentMatrixControlIcon"],"mappings":";;;;;;;;;AAWA;;;;AARA;;AACA;;AAKA;;AACA;;AAMA;;AACA;;AACA;;AACA;;AACA;;AApBA;AACA;A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,SAFN;AAGC,kBAAaV,KAHd;AAIC,IAAA,EAAE,EAAGiB,kCAJN;AAKC,IAAA,SAAS,EAAGD,OALb;AAMC,IAAA,IAAI,EAAC,MANN;AAOC,IAAA,KAAK,EAAGX;AAPT,MASGa,YAAKC,GAAL,CAAU,CAAEC,KAAF,EAASC,KAAT,KACX,4BAAC,yBAAD,6BACMX,SADN;AAEC,IAAA,EAAE,EAAGY,iCAFN;AAGC,IAAA,IAAI,EAAC,KAHN;AAIC,IAAA,GAAG,EAAGD;AAJP,MAMGD,KAAK,CAACD,GAAN,CAAaI,IAAF,IAAY;AACxB,UAAMC,MAAM,GAAG,sBAAWhB,MAAX,EAAmBe,IAAnB,CAAf;AACA,UAAME,QAAQ,GAAGf,SAAS,CAACC,SAAV,KAAwBa,MAAzC;AAEA,WACC,4BAAC,aAAD,6BACMd,SADN;AAEC,MAAA,EAAE,EAAGc,MAFN;AAGC,MAAA,QAAQ,EAAGC,QAHZ;AAIC,MAAA,GAAG,EAAGF,IAJP;AAKC,MAAA,KAAK,EAAGA,IALT;AAMC,MAAA,OAAO,EAAG,MAAMV,cAAc,CAAEU,IAAF,CAN/B;AAOC,MAAA,QAAQ,EAAGE,QAAQ,GAAG,CAAH,GAAO,CAAC;AAP5B,OADD;AAWA,GAfC,CANH,CADC,CATH,CADD;AAqCA;;AAED3B,sBAAsB,CAAC4B,IAAvB,GAA8BC,aAA9B","sourcesContent":["/**\n * External dependencies\n */\nimport { noop } from 'lodash';\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport { __, isRTL } from '@wordpress/i18n';\nimport { useInstanceId } from '@wordpress/compose';\nimport { useState, useEffect } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport Cell from './cell';\nimport { Composite, CompositeGroup, useCompositeState } from '../composite';\nimport { Root, Row } from './styles/alignment-matrix-control-styles';\nimport AlignmentMatrixControlIcon from './icon';\nimport { GRID, getItemId } from './utils';\n\nfunction useBaseId( id ) {\n\tconst instanceId = useInstanceId(\n\t\tAlignmentMatrixControl,\n\t\t'alignment-matrix-control'\n\t);\n\n\treturn id || instanceId;\n}\n\nexport default function AlignmentMatrixControl( {\n\tclassName,\n\tid,\n\tlabel = __( 'Alignment Matrix Control' ),\n\tdefaultValue = 'center center',\n\tvalue,\n\tonChange = noop,\n\twidth = 92,\n\t...props\n} ) {\n\tconst [ immutableDefaultValue ] = useState( value ?? defaultValue );\n\tconst baseId = useBaseId( id );\n\tconst initialCurrentId = getItemId( baseId, immutableDefaultValue );\n\n\tconst composite = useCompositeState( {\n\t\tbaseId,\n\t\tcurrentId: initialCurrentId,\n\t\trtl: isRTL(),\n\t} );\n\n\tconst handleOnChange = ( nextValue ) => {\n\t\tonChange( nextValue );\n\t};\n\n\tuseEffect( () => {\n\t\tif ( typeof value !== 'undefined' ) {\n\t\t\tcomposite.setCurrentId( getItemId( baseId, value ) );\n\t\t}\n\t}, [ value, composite.setCurrentId ] );\n\n\tconst classes = classnames(\n\t\t'component-alignment-matrix-control',\n\t\tclassName\n\t);\n\n\treturn (\n\t\t<Composite\n\t\t\t{ ...props }\n\t\t\t{ ...composite }\n\t\t\taria-label={ label }\n\t\t\tas={ Root }\n\t\t\tclassName={ classes }\n\t\t\trole=\"grid\"\n\t\t\twidth={ width }\n\t\t>\n\t\t\t{ GRID.map( ( cells, index ) => (\n\t\t\t\t<CompositeGroup\n\t\t\t\t\t{ ...composite }\n\t\t\t\t\tas={ Row }\n\t\t\t\t\trole=\"row\"\n\t\t\t\t\tkey={ index }\n\t\t\t\t>\n\t\t\t\t\t{ cells.map( ( cell ) => {\n\t\t\t\t\t\tconst cellId = getItemId( baseId, cell );\n\t\t\t\t\t\tconst isActive = composite.currentId === cellId;\n\n\t\t\t\t\t\treturn (\n\t\t\t\t\t\t\t<Cell\n\t\t\t\t\t\t\t\t{ ...composite }\n\t\t\t\t\t\t\t\tid={ cellId }\n\t\t\t\t\t\t\t\tisActive={ isActive }\n\t\t\t\t\t\t\t\tkey={ cell }\n\t\t\t\t\t\t\t\tvalue={ cell }\n\t\t\t\t\t\t\t\tonFocus={ () => handleOnChange( cell ) }\n\t\t\t\t\t\t\t\ttabIndex={ isActive ? 0 : -1 }\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</CompositeGroup>\n\t\t\t) ) }\n\t\t</Composite>\n\t);\n}\n\nAlignmentMatrixControl.Icon = AlignmentMatrixControlIcon;\n"]}
1
+ {"version":3,"sources":["@wordpress/components/src/alignment-matrix-control/index.js"],"names":["useBaseId","id","instanceId","AlignmentMatrixControl","className","label","defaultValue","value","onChange","noop","width","props","immutableDefaultValue","baseId","initialCurrentId","composite","currentId","rtl","handleOnChange","nextValue","setCurrentId","classes","Root","GRID","map","cells","index","Row","cell","cellId","isActive","Icon","AlignmentMatrixControlIcon"],"mappings":";;;;;;;;;AAWA;;;;AARA;;AACA;;AAKA;;AACA;;AAMA;;AACA;;AACA;;AACA;;AACA;;AApBA;AACA;AACA;;AAIA;AACA;AACA;;AAKA;AACA;AACA;AAOA,SAASA,SAAT,CAAoBC,EAApB,EAAyB;AACxB,QAAMC,UAAU,GAAG,4BAClBC,sBADkB,EAElB,0BAFkB,CAAnB;AAKA,SAAOF,EAAE,IAAIC,UAAb;AACA;;AAEc,SAASC,sBAAT,OASX;AAAA,MAT4C;AAC/CC,IAAAA,SAD+C;AAE/CH,IAAAA,EAF+C;AAG/CI,IAAAA,KAAK,GAAG,cAAI,0BAAJ,CAHuC;AAI/CC,IAAAA,YAAY,GAAG,eAJgC;AAK/CC,IAAAA,KAL+C;AAM/CC,IAAAA,QAAQ,GAAGC,YANoC;AAO/CC,IAAAA,KAAK,GAAG,EAPuC;AAQ/C,OAAGC;AAR4C,GAS5C;AACH,QAAM,CAAEC,qBAAF,IAA4B,uBAAUL,KAAV,aAAUA,KAAV,cAAUA,KAAV,GAAmBD,YAAnB,CAAlC;AACA,QAAMO,MAAM,GAAGb,SAAS,CAAEC,EAAF,CAAxB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AQ,EAAGC,QAHZ;AAIC,MAAA,GAAG,EAAGF,IAJP;AAKC,MAAA,KAAK,EAAGA,IALT;AAMC,MAAA,OAAO,EAAG,MAAMV,cAAc,CAAEU,IAAF,CAN/B;AAOC,MAAA,QAAQ,EAAGE,QAAQ,GAAG,CAAH,GAAO,CAAC;AAP5B,OADD;AAWA,GAfC,CANH,CADC,CATH,CADD;AAqCA;;AAED3B,sBAAsB,CAAC4B,IAAvB,GAA8BC,aAA9B","sourcesContent":["/**\n * External dependencies\n */\nimport { noop } from 'lodash';\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport { __, isRTL } from '@wordpress/i18n';\nimport { useInstanceId } from '@wordpress/compose';\nimport { useState, useEffect } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport Cell from './cell';\nimport { Composite, CompositeGroup, useCompositeState } from '../composite';\nimport { Root, Row } from './styles/alignment-matrix-control-styles';\nimport AlignmentMatrixControlIcon from './icon';\nimport { GRID, getItemId } from './utils';\n\nfunction useBaseId( id ) {\n\tconst instanceId = useInstanceId(\n\t\tAlignmentMatrixControl,\n\t\t'alignment-matrix-control'\n\t);\n\n\treturn id || instanceId;\n}\n\nexport default function AlignmentMatrixControl( {\n\tclassName,\n\tid,\n\tlabel = __( 'Alignment Matrix Control' ),\n\tdefaultValue = 'center center',\n\tvalue,\n\tonChange = noop,\n\twidth = 92,\n\t...props\n} ) {\n\tconst [ immutableDefaultValue ] = useState( value ?? defaultValue );\n\tconst baseId = useBaseId( id );\n\tconst initialCurrentId = getItemId( baseId, immutableDefaultValue );\n\n\tconst composite = useCompositeState( {\n\t\tbaseId,\n\t\tcurrentId: initialCurrentId,\n\t\trtl: isRTL(),\n\t} );\n\n\tconst handleOnChange = ( nextValue ) => {\n\t\tonChange( nextValue );\n\t};\n\n\tconst { setCurrentId } = composite;\n\n\tuseEffect( () => {\n\t\tif ( typeof value !== 'undefined' ) {\n\t\t\tsetCurrentId( getItemId( baseId, value ) );\n\t\t}\n\t}, [ value, setCurrentId, baseId ] );\n\n\tconst classes = classnames(\n\t\t'component-alignment-matrix-control',\n\t\tclassName\n\t);\n\n\treturn (\n\t\t<Composite\n\t\t\t{ ...props }\n\t\t\t{ ...composite }\n\t\t\taria-label={ label }\n\t\t\tas={ Root }\n\t\t\tclassName={ classes }\n\t\t\trole=\"grid\"\n\t\t\twidth={ width }\n\t\t>\n\t\t\t{ GRID.map( ( cells, index ) => (\n\t\t\t\t<CompositeGroup\n\t\t\t\t\t{ ...composite }\n\t\t\t\t\tas={ Row }\n\t\t\t\t\trole=\"row\"\n\t\t\t\t\tkey={ index }\n\t\t\t\t>\n\t\t\t\t\t{ cells.map( ( cell ) => {\n\t\t\t\t\t\tconst cellId = getItemId( baseId, cell );\n\t\t\t\t\t\tconst isActive = composite.currentId === cellId;\n\n\t\t\t\t\t\treturn (\n\t\t\t\t\t\t\t<Cell\n\t\t\t\t\t\t\t\t{ ...composite }\n\t\t\t\t\t\t\t\tid={ cellId }\n\t\t\t\t\t\t\t\tisActive={ isActive }\n\t\t\t\t\t\t\t\tkey={ cell }\n\t\t\t\t\t\t\t\tvalue={ cell }\n\t\t\t\t\t\t\t\tonFocus={ () => handleOnChange( cell ) }\n\t\t\t\t\t\t\t\ttabIndex={ isActive ? 0 : -1 }\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</CompositeGroup>\n\t\t\t) ) }\n\t\t</Composite>\n\t);\n}\n\nAlignmentMatrixControl.Icon = AlignmentMatrixControlIcon;\n"]}
@@ -55,7 +55,7 @@ function getAutoCompleterUI(autocompleter) {
55
55
  });
56
56
  (0, _element.useLayoutEffect)(() => {
57
57
  onChangeOptions(items);
58
- }, [items]);
58
+ }, [onChangeOptions, items]);
59
59
 
60
60
  if (!items.length > 0) {
61
61
  return null;
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/components/src/autocomplete/autocompleter-ui.js"],"names":["getAutoCompleterUI","autocompleter","useItems","AutocompleterUI","filterValue","instanceId","listBoxId","className","selectedIndex","onChangeOptions","onSelect","onReset","value","contentRef","items","anchorRef","ref","length","option","index","key","isDisabled","label"],"mappings":";;;;;;;;;AASA;;AANA;;AACA;;AAMA;;AAKA;;AACA;;AACA;;AAjBA;AACA;AACA;;AAIA;AACA;AACA;;AAIA;AACA;AACA;AAKO,SAASA,kBAAT,CAA6BC,aAA7B,EAA6C;AACnD,QAAMC,QAAQ,GAAGD,aAAa,CAACC,QAAd,GACdD,aAAa,CAACC,QADA,GAEd,iCAAoBD,aAApB,CAFH;;AAIA,WAASE,eAAT,OAWI;AAAA,QAXsB;AACzBC,MAAAA,WADyB;AAEzBC,MAAAA,UAFyB;AAGzBC,MAAAA,SAHyB;AAIzBC,MAAAA,SAJyB;AAKzBC,MAAAA,aALyB;AAMzBC,MAAAA,eANyB;AAOzBC,MAAAA,QAPyB;AAQzBC,MAAAA,OARyB;AASzBC,MAAAA,KATyB;AAUzBC,MAAAA;AAVyB,KAWtB;AACH,UAAM,CAAEC,KAAF,IAAYZ,QAAQ,CAAEE,WAAF,CAA1B;AACA,UAAMW,SAAS,GAAG,4BAAc;AAAEC,MAAAA,GAAG,EAAEH,UAAP;AAAmBD,MAAAA;AAAnB,KAAd,CAAlB;AAEA,kCAAiB,MAAM;AACtBH,MAAAA,eAAe,CAAEK,KAAF,CAAf;AACA,KAFD,EAEG,CAAEA,KAAF,CAFH;;AAIA,QAAK,CAAEA,KAAK,CAACG,MAAR,GAAiB,CAAtB,EAA0B;AACzB,aAAO,IAAP;AACA;;AAED,WACC,4BAAC,gBAAD;AACC,MAAA,YAAY,EAAG,KADhB;AAEC,MAAA,OAAO,EAAGN,OAFX;AAGC,MAAA,QAAQ,EAAC,WAHV;AAIC,MAAA,SAAS,EAAC,kCAJX;AAKC,MAAA,SAAS,EAAGI;AALb,OAOC;AACC,MAAA,EAAE,EAAGT,SADN;AAEC,MAAA,IAAI,EAAC,SAFN;AAGC,MAAA,SAAS,EAAC;AAHX,OAKG,iBAAKQ,KAAL,EAAY,CAAEI,MAAF,EAAUC,KAAV,KACb,4BAAC,eAAD;AACC,MAAA,GAAG,EAAGD,MAAM,CAACE,GADd;AAEC,MAAA,EAAE,EAAI,gCAAgCf,UAAY,IAAIa,MAAM,CAACE,GAAK,EAFnE;AAGC,MAAA,IAAI,EAAC,QAHN;AAIC,uBAAgBD,KAAK,KAAKX,aAJ3B;AAKC,MAAA,QAAQ,EAAGU,MAAM,CAACG,UALnB;AAMC,MAAA,SAAS,EAAG,yBACX,iCADW,EAEXd,SAFW,EAGX;AACC,uBAAeY,KAAK,KAAKX;AAD1B,OAHW,CANb;AAaC,MAAA,OAAO,EAAG,MAAME,QAAQ,CAAEQ,MAAF;AAbzB,OAeGA,MAAM,CAACI,KAfV,CADC,CALH,CAPD,CADD;AAmCA;;AAED,SAAOnB,eAAP;AACA","sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\nimport { map } from 'lodash';\n\n/**\n * WordPress dependencies\n */\nimport { useLayoutEffect } from '@wordpress/element';\nimport { useAnchorRef } from '@wordpress/rich-text';\n\n/**\n * Internal dependencies\n */\nimport getDefaultUseItems from './get-default-use-items';\nimport Button from '../button';\nimport Popover from '../popover';\n\nexport function getAutoCompleterUI( autocompleter ) {\n\tconst useItems = autocompleter.useItems\n\t\t? autocompleter.useItems\n\t\t: getDefaultUseItems( autocompleter );\n\n\tfunction AutocompleterUI( {\n\t\tfilterValue,\n\t\tinstanceId,\n\t\tlistBoxId,\n\t\tclassName,\n\t\tselectedIndex,\n\t\tonChangeOptions,\n\t\tonSelect,\n\t\tonReset,\n\t\tvalue,\n\t\tcontentRef,\n\t} ) {\n\t\tconst [ items ] = useItems( filterValue );\n\t\tconst anchorRef = useAnchorRef( { ref: contentRef, value } );\n\n\t\tuseLayoutEffect( () => {\n\t\t\tonChangeOptions( items );\n\t\t}, [ items ] );\n\n\t\tif ( ! items.length > 0 ) {\n\t\t\treturn null;\n\t\t}\n\n\t\treturn (\n\t\t\t<Popover\n\t\t\t\tfocusOnMount={ false }\n\t\t\t\tonClose={ onReset }\n\t\t\t\tposition=\"top right\"\n\t\t\t\tclassName=\"components-autocomplete__popover\"\n\t\t\t\tanchorRef={ anchorRef }\n\t\t\t>\n\t\t\t\t<div\n\t\t\t\t\tid={ listBoxId }\n\t\t\t\t\trole=\"listbox\"\n\t\t\t\t\tclassName=\"components-autocomplete__results\"\n\t\t\t\t>\n\t\t\t\t\t{ map( items, ( option, index ) => (\n\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\tkey={ option.key }\n\t\t\t\t\t\t\tid={ `components-autocomplete-item-${ instanceId }-${ option.key }` }\n\t\t\t\t\t\t\trole=\"option\"\n\t\t\t\t\t\t\taria-selected={ index === selectedIndex }\n\t\t\t\t\t\t\tdisabled={ option.isDisabled }\n\t\t\t\t\t\t\tclassName={ classnames(\n\t\t\t\t\t\t\t\t'components-autocomplete__result',\n\t\t\t\t\t\t\t\tclassName,\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t'is-selected': index === selectedIndex,\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\tonClick={ () => onSelect( option ) }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ option.label }\n\t\t\t\t\t\t</Button>\n\t\t\t\t\t) ) }\n\t\t\t\t</div>\n\t\t\t</Popover>\n\t\t);\n\t}\n\n\treturn AutocompleterUI;\n}\n"]}
1
+ {"version":3,"sources":["@wordpress/components/src/autocomplete/autocompleter-ui.js"],"names":["getAutoCompleterUI","autocompleter","useItems","AutocompleterUI","filterValue","instanceId","listBoxId","className","selectedIndex","onChangeOptions","onSelect","onReset","value","contentRef","items","anchorRef","ref","length","option","index","key","isDisabled","label"],"mappings":";;;;;;;;;AASA;;AANA;;AACA;;AAMA;;AAKA;;AACA;;AACA;;AAjBA;AACA;AACA;;AAIA;AACA;AACA;;AAIA;AACA;AACA;AAKO,SAASA,kBAAT,CAA6BC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AgBD,KAAK,KAAKX,aAJ3B;AAKC,MAAA,QAAQ,EAAGU,MAAM,CAACG,UALnB;AAMC,MAAA,SAAS,EAAG,yBACX,iCADW,EAEXd,SAFW,EAGX;AACC,uBAAeY,KAAK,KAAKX;AAD1B,OAHW,CANb;AAaC,MAAA,OAAO,EAAG,MAAME,QAAQ,CAAEQ,MAAF;AAbzB,OAeGA,MAAM,CAACI,KAfV,CADC,CALH,CAPD,CADD;AAmCA;;AAED,SAAOnB,eAAP;AACA","sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\nimport { map } from 'lodash';\n\n/**\n * WordPress dependencies\n */\nimport { useLayoutEffect } from '@wordpress/element';\nimport { useAnchorRef } from '@wordpress/rich-text';\n\n/**\n * Internal dependencies\n */\nimport getDefaultUseItems from './get-default-use-items';\nimport Button from '../button';\nimport Popover from '../popover';\n\nexport function getAutoCompleterUI( autocompleter ) {\n\tconst useItems = autocompleter.useItems\n\t\t? autocompleter.useItems\n\t\t: getDefaultUseItems( autocompleter );\n\n\tfunction AutocompleterUI( {\n\t\tfilterValue,\n\t\tinstanceId,\n\t\tlistBoxId,\n\t\tclassName,\n\t\tselectedIndex,\n\t\tonChangeOptions,\n\t\tonSelect,\n\t\tonReset,\n\t\tvalue,\n\t\tcontentRef,\n\t} ) {\n\t\tconst [ items ] = useItems( filterValue );\n\t\tconst anchorRef = useAnchorRef( { ref: contentRef, value } );\n\n\t\tuseLayoutEffect( () => {\n\t\t\tonChangeOptions( items );\n\t\t}, [ onChangeOptions, items ] );\n\n\t\tif ( ! items.length > 0 ) {\n\t\t\treturn null;\n\t\t}\n\n\t\treturn (\n\t\t\t<Popover\n\t\t\t\tfocusOnMount={ false }\n\t\t\t\tonClose={ onReset }\n\t\t\t\tposition=\"top right\"\n\t\t\t\tclassName=\"components-autocomplete__popover\"\n\t\t\t\tanchorRef={ anchorRef }\n\t\t\t>\n\t\t\t\t<div\n\t\t\t\t\tid={ listBoxId }\n\t\t\t\t\trole=\"listbox\"\n\t\t\t\t\tclassName=\"components-autocomplete__results\"\n\t\t\t\t>\n\t\t\t\t\t{ map( items, ( option, index ) => (\n\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\tkey={ option.key }\n\t\t\t\t\t\t\tid={ `components-autocomplete-item-${ instanceId }-${ option.key }` }\n\t\t\t\t\t\t\trole=\"option\"\n\t\t\t\t\t\t\taria-selected={ index === selectedIndex }\n\t\t\t\t\t\t\tdisabled={ option.isDisabled }\n\t\t\t\t\t\t\tclassName={ classnames(\n\t\t\t\t\t\t\t\t'components-autocomplete__result',\n\t\t\t\t\t\t\t\tclassName,\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t'is-selected': index === selectedIndex,\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\tonClick={ () => onSelect( option ) }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ option.label }\n\t\t\t\t\t\t</Button>\n\t\t\t\t\t) ) }\n\t\t\t\t</div>\n\t\t\t</Popover>\n\t\t);\n\t}\n\n\treturn AutocompleterUI;\n}\n"]}
@@ -78,7 +78,7 @@ function getAutoCompleterUI(autocompleter) {
78
78
  } else if (isVisible && text.length === 0) {
79
79
  startAnimation(false);
80
80
  }
81
- }, [items, isVisible, text]);
81
+ }, [onChangeOptions, items, isVisible, text, startAnimation]);
82
82
  const activeItemStyles = (0, _compose.usePreferredColorSchemeStyle)(_style.default['components-autocomplete__item-active'], _style.default['components-autocomplete__item-active-dark']);
83
83
  const iconStyles = (0, _compose.usePreferredColorSchemeStyle)(_style.default['components-autocomplete__icon'], _style.default['components-autocomplete__icon-active-dark']);
84
84
  const activeIconStyles = (0, _compose.usePreferredColorSchemeStyle)(_style.default['components-autocomplete__icon-active '], _style.default['components-autocomplete__icon-active-dark']);
@@ -99,7 +99,7 @@ function getAutoCompleterUI(autocompleter) {
99
99
  reset();
100
100
  }
101
101
  });
102
- }, [isVisible]);
102
+ }, [animationValue, isVisible, reset]);
103
103
  const contentStyles = {
104
104
  transform: [{
105
105
  translateY: animationValue.interpolate({
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/components/src/autocomplete/autocompleter-ui.native.js"],"names":["compose","stylesCompose","StyleSheet","getAutoCompleterUI","autocompleter","useItems","AutocompleterUI","filterValue","selectedIndex","onChangeOptions","onSelect","value","reset","items","filteredItems","filter","item","isDisabled","scrollViewRef","animationValue","Animated","Value","current","isVisible","setIsVisible","text","length","scrollTo","x","animated","startAnimation","activeItemStyles","styles","iconStyles","activeIconStyles","textStyles","activeTextStyles","show","timing","toValue","duration","useNativeDriver","start","finished","contentStyles","transform","translateY","interpolate","inputRange","outputRange","height","map","option","index","isActive","itemStyle","textStyle","iconStyle","iconSource","icon","src","title"],"mappings":";;;;;;;;;;AAeA;;AAZA;;AAmBA;;AACA;;AAIA;;AAKA;;AACA;;AACA;;AAlCA;AACA;AACA;;AAUA;AACA;AACA;;AAeA;AACA;AACA;AAKA,MAAM;AAAEA,EAAAA,OAAO,EAAEC;AAAX,IAA6BC,uBAAnC;;AAEO,SAASC,kBAAT,CAA6BC,aAA7B,EAA6C;AACnD,QAAMC,QAAQ,GAAGD,aAAa,CAACC,QAAd,GACdD,aAAa,CAACC,QADA,GAEd,iCAAoBD,aAApB,CAFH;;AAIA,WAASE,eAAT,OAOI;AAAA,QAPsB;AACzBC,MAAAA,WADyB;AAEzBC,MAAAA,aAFyB;AAGzBC,MAAAA,eAHyB;AAIzBC,MAAAA,QAJyB;AAKzBC,MAAAA,KALyB;AAMzBC,MAAAA;AANyB,KAOtB;AACH,UAAM,CAAEC,KAAF,IAAYR,QAAQ,CAAEE,WAAF,CAA1B;AACA,UAAMO,aAAa,GAAGD,KAAK,CAACE,MAAN,CAAgBC,IAAF,IAAY,CAAEA,IAAI,CAACC,UAAjC,CAAtB;AACA,UAAMC,aAAa,GAAG,sBAAtB;AACA,UAAMC,cAAc,GAAG,qBAAQ,IAAIC,sBAASC,KAAb,CAAoB,CAApB,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,4BAAC,iBAAD;AAAM,QAAA,KAAK,EAAGD;AAAd,SACGJ,MADH,aACGA,MADH,yCACGA,MAAM,CAAEzC,KADX,mDACG,eAAekD,KADlB,CAxBD,CADD;AA8BA,KAlDC,CAbH,CADD,CADD,CADD,CADD,CADD;AA2EA;;AAED,SAAOvD,eAAP;AACA;;eAEcH,kB","sourcesContent":["/**\n * External dependencies\n */\nimport {\n\tView,\n\tAnimated,\n\tStyleSheet,\n\tText,\n\tTouchableOpacity,\n\tScrollView,\n} from 'react-native';\n\n/**\n * WordPress dependencies\n */\nimport {\n\tuseLayoutEffect,\n\tuseEffect,\n\tuseRef,\n\tuseState,\n\tuseCallback,\n} from '@wordpress/element';\nimport { __, sprintf } from '@wordpress/i18n';\nimport {\n\tIcon,\n\t__unstableAutocompletionItemsFill as AutocompletionItemsFill,\n} from '@wordpress/components';\nimport { usePreferredColorSchemeStyle } from '@wordpress/compose';\n\n/**\n * Internal dependencies\n */\nimport BackgroundView from './background-view';\nimport getDefaultUseItems from './get-default-use-items';\nimport styles from './style.scss';\n\nconst { compose: stylesCompose } = StyleSheet;\n\nexport function getAutoCompleterUI( autocompleter ) {\n\tconst useItems = autocompleter.useItems\n\t\t? autocompleter.useItems\n\t\t: getDefaultUseItems( autocompleter );\n\n\tfunction AutocompleterUI( {\n\t\tfilterValue,\n\t\tselectedIndex,\n\t\tonChangeOptions,\n\t\tonSelect,\n\t\tvalue,\n\t\treset,\n\t} ) {\n\t\tconst [ items ] = useItems( filterValue );\n\t\tconst filteredItems = items.filter( ( item ) => ! item.isDisabled );\n\t\tconst scrollViewRef = useRef();\n\t\tconst animationValue = useRef( new Animated.Value( 0 ) ).current;\n\t\tconst [ isVisible, setIsVisible ] = useState( false );\n\t\tconst { text } = value;\n\n\t\tuseEffect( () => {\n\t\t\tif ( ! isVisible && text.length > 0 ) {\n\t\t\t\tsetIsVisible( true );\n\t\t\t}\n\t\t}, [ isVisible, text ] );\n\n\t\tuseLayoutEffect( () => {\n\t\t\tonChangeOptions( items );\n\t\t\tscrollViewRef.current?.scrollTo( { x: 0, animated: false } );\n\n\t\t\tif ( isVisible && text.length > 0 ) {\n\t\t\t\tstartAnimation( true );\n\t\t\t} else if ( isVisible && text.length === 0 ) {\n\t\t\t\tstartAnimation( false );\n\t\t\t}\n\t\t}, [ items, isVisible, text ] );\n\n\t\tconst activeItemStyles = usePreferredColorSchemeStyle(\n\t\t\tstyles[ 'components-autocomplete__item-active' ],\n\t\t\tstyles[ 'components-autocomplete__item-active-dark' ]\n\t\t);\n\n\t\tconst iconStyles = usePreferredColorSchemeStyle(\n\t\t\tstyles[ 'components-autocomplete__icon' ],\n\t\t\tstyles[ 'components-autocomplete__icon-active-dark' ]\n\t\t);\n\n\t\tconst activeIconStyles = usePreferredColorSchemeStyle(\n\t\t\tstyles[ 'components-autocomplete__icon-active ' ],\n\t\t\tstyles[ 'components-autocomplete__icon-active-dark' ]\n\t\t);\n\n\t\tconst textStyles = usePreferredColorSchemeStyle(\n\t\t\tstyles[ 'components-autocomplete__text' ],\n\t\t\tstyles[ 'components-autocomplete__text-dark' ]\n\t\t);\n\n\t\tconst activeTextStyles = usePreferredColorSchemeStyle(\n\t\t\tstyles[ 'components-autocomplete__text-active' ],\n\t\t\tstyles[ 'components-autocomplete__text-active-dark' ]\n\t\t);\n\n\t\tconst startAnimation = useCallback(\n\t\t\t( show ) => {\n\t\t\t\tAnimated.timing( animationValue, {\n\t\t\t\t\ttoValue: show ? 1 : 0,\n\t\t\t\t\tduration: show ? 200 : 100,\n\t\t\t\t\tuseNativeDriver: true,\n\t\t\t\t} ).start( ( { finished } ) => {\n\t\t\t\t\tif ( finished && ! show && isVisible ) {\n\t\t\t\t\t\tsetIsVisible( false );\n\t\t\t\t\t\treset();\n\t\t\t\t\t}\n\t\t\t\t} );\n\t\t\t},\n\t\t\t[ isVisible ]\n\t\t);\n\n\t\tconst contentStyles = {\n\t\t\ttransform: [\n\t\t\t\t{\n\t\t\t\t\ttranslateY: animationValue.interpolate( {\n\t\t\t\t\t\tinputRange: [ 0, 1 ],\n\t\t\t\t\t\toutputRange: [\n\t\t\t\t\t\t\tstyles[ 'components-autocomplete' ].height,\n\t\t\t\t\t\t\t0,\n\t\t\t\t\t\t],\n\t\t\t\t\t} ),\n\t\t\t\t},\n\t\t\t],\n\t\t};\n\n\t\tif ( ! filteredItems.length > 0 || ! isVisible ) {\n\t\t\treturn null;\n\t\t}\n\n\t\treturn (\n\t\t\t<AutocompletionItemsFill>\n\t\t\t\t<View style={ styles[ 'components-autocomplete' ] }>\n\t\t\t\t\t<Animated.View style={ contentStyles }>\n\t\t\t\t\t\t<BackgroundView>\n\t\t\t\t\t\t\t<ScrollView\n\t\t\t\t\t\t\t\tref={ scrollViewRef }\n\t\t\t\t\t\t\t\thorizontal\n\t\t\t\t\t\t\t\tcontentContainerStyle={\n\t\t\t\t\t\t\t\t\tstyles[ 'components-autocomplete__content' ]\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tshowsHorizontalScrollIndicator={ false }\n\t\t\t\t\t\t\t\tkeyboardShouldPersistTaps=\"always\"\n\t\t\t\t\t\t\t\taccessibilityLabel={\n\t\t\t\t\t\t\t\t\t// translators: Slash inserter autocomplete results\n\t\t\t\t\t\t\t\t\t__( 'Slash inserter results' )\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t{ filteredItems.map( ( option, index ) => {\n\t\t\t\t\t\t\t\t\tconst isActive = index === selectedIndex;\n\t\t\t\t\t\t\t\t\tconst itemStyle = stylesCompose(\n\t\t\t\t\t\t\t\t\t\tstyles[\n\t\t\t\t\t\t\t\t\t\t\t'components-autocomplete__item'\n\t\t\t\t\t\t\t\t\t\t],\n\t\t\t\t\t\t\t\t\t\tisActive && activeItemStyles\n\t\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\t\tconst textStyle = stylesCompose(\n\t\t\t\t\t\t\t\t\t\ttextStyles,\n\t\t\t\t\t\t\t\t\t\tisActive && activeTextStyles\n\t\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\t\tconst iconStyle = stylesCompose(\n\t\t\t\t\t\t\t\t\t\ticonStyles,\n\t\t\t\t\t\t\t\t\t\tisActive && activeIconStyles\n\t\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\t\tconst iconSource =\n\t\t\t\t\t\t\t\t\t\toption?.value?.icon?.src ||\n\t\t\t\t\t\t\t\t\t\toption?.value?.icon;\n\n\t\t\t\t\t\t\t\t\treturn (\n\t\t\t\t\t\t\t\t\t\t<TouchableOpacity\n\t\t\t\t\t\t\t\t\t\t\tactiveOpacity={ 0.5 }\n\t\t\t\t\t\t\t\t\t\t\tstyle={ itemStyle }\n\t\t\t\t\t\t\t\t\t\t\tkey={ index }\n\t\t\t\t\t\t\t\t\t\t\tonPress={ () => onSelect( option ) }\n\t\t\t\t\t\t\t\t\t\t\taccessibilityLabel={ sprintf(\n\t\t\t\t\t\t\t\t\t\t\t\t// translators: %s: Block name e.g. \"Image block\"\n\t\t\t\t\t\t\t\t\t\t\t\t__( '%s block' ),\n\t\t\t\t\t\t\t\t\t\t\t\toption?.value?.title\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\t\t<View\n\t\t\t\t\t\t\t\t\t\t\t\tstyle={\n\t\t\t\t\t\t\t\t\t\t\t\t\tstyles[\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t'components-autocomplete__icon'\n\t\t\t\t\t\t\t\t\t\t\t\t\t]\n\t\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t\t\t\t<Icon\n\t\t\t\t\t\t\t\t\t\t\t\t\ticon={ iconSource }\n\t\t\t\t\t\t\t\t\t\t\t\t\tsize={ 24 }\n\t\t\t\t\t\t\t\t\t\t\t\t\tstyle={ iconStyle }\n\t\t\t\t\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t\t\t\t</View>\n\t\t\t\t\t\t\t\t\t\t\t<Text style={ textStyle }>\n\t\t\t\t\t\t\t\t\t\t\t\t{ option?.value?.title }\n\t\t\t\t\t\t\t\t\t\t\t</Text>\n\t\t\t\t\t\t\t\t\t\t</TouchableOpacity>\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</ScrollView>\n\t\t\t\t\t\t</BackgroundView>\n\t\t\t\t\t</Animated.View>\n\t\t\t\t</View>\n\t\t\t</AutocompletionItemsFill>\n\t\t);\n\t}\n\n\treturn AutocompleterUI;\n}\n\nexport default getAutoCompleterUI;\n"]}
1
+ {"version":3,"sources":["@wordpress/components/src/autocomplete/autocompleter-ui.native.js"],"names":["compose","stylesCompose","StyleSheet","getAutoCompleterUI","autocompleter","useItems","AutocompleterUI","filterValue","selectedIndex","onChangeOptions","onSelect","value","reset","items","filteredItems","filter","item","isDisabled","scrollViewRef","animationValue","Animated","Value","current","isVisible","setIsVisible","text","length","scrollTo","x","animated","startAnimation","activeItemStyles","styles","iconStyles","activeIconStyles","textStyles","activeTextStyles","show","timing","toValue","duration","useNativeDriver","start","finished","contentStyles","transform","translateY","interpolate","inputRange","outputRange","height","map","option","index","isActive","itemStyle","textStyle","iconStyle","iconSource","icon","src","title"],"mappings":";;;;;;;;;;AAeA;;AAZA;;AAmBA;;AACA;;AAIA;;AAKA;;AACA;;AACA;;AAlCA;AACA;AACA;;AAUA;AACA;AACA;;AAeA;AACA;AACA;AAKA,MAAM;AAAEA,EAAAA,OAAO,EAAEC;AAAX,IAA6BC,uBAAnC;;AAEO,SAASC,kBAAT,CAA6BC,aAA7B,EAA6C;AACnD,QAAMC,QAAQ,GAAGD,aAAa,CAACC,QAAd,GACdD,aAAa,CAACC,QADA,GAEd,iCAAoBD,aAApB,CAFH;;AAIA,WAASE,eAAT,OAOI;AAAA,QAPsB;AACzBC,MAAAA,WADyB;AAEzBC,MAAAA,a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GAAG,EAAGF,KAHP;AAIC,QAAA,OAAO,EAAG,MAAM3C,QAAQ,CAAE0C,MAAF,CAJzB;AAKC,QAAA,kBAAkB,EAAG,oBACpB;AACA,sBAAI,UAAJ,CAFoB,EAGpBA,MAHoB,aAGpBA,MAHoB,yCAGpBA,MAAM,CAAEzC,KAHY,mDAGpB,eAAekD,KAHK;AALtB,SAWC,4BAAC,iBAAD;AACC,QAAA,KAAK,EACJ7B,eACC,+BADD;AAFF,SAOC,4BAAC,gBAAD;AACC,QAAA,IAAI,EAAG0B,UADR;AAEC,QAAA,IAAI,EAAG,EAFR;AAGC,QAAA,KAAK,EAAGD;AAHT,QAPD,CAXD,EAwBC,4BAAC,iBAAD;AAAM,QAAA,KAAK,EAAGD;AAAd,SACGJ,MADH,aACGA,MADH,yCACGA,MAAM,CAAEzC,KADX,mDACG,eAAekD,KADlB,CAxBD,CADD;AA8BA,KAlDC,CAbH,CADD,CADD,CADD,CADD,CADD;AA2EA;;AAED,SAAOvD,eAAP;AACA;;eAEcH,kB","sourcesContent":["/**\n * External dependencies\n */\nimport {\n\tView,\n\tAnimated,\n\tStyleSheet,\n\tText,\n\tTouchableOpacity,\n\tScrollView,\n} from 'react-native';\n\n/**\n * WordPress dependencies\n */\nimport {\n\tuseLayoutEffect,\n\tuseEffect,\n\tuseRef,\n\tuseState,\n\tuseCallback,\n} from '@wordpress/element';\nimport { __, sprintf } from '@wordpress/i18n';\nimport {\n\tIcon,\n\t__unstableAutocompletionItemsFill as AutocompletionItemsFill,\n} from '@wordpress/components';\nimport { usePreferredColorSchemeStyle } from '@wordpress/compose';\n\n/**\n * Internal dependencies\n */\nimport BackgroundView from './background-view';\nimport getDefaultUseItems from './get-default-use-items';\nimport styles from './style.scss';\n\nconst { compose: stylesCompose } = StyleSheet;\n\nexport function getAutoCompleterUI( autocompleter ) {\n\tconst useItems = autocompleter.useItems\n\t\t? autocompleter.useItems\n\t\t: getDefaultUseItems( autocompleter );\n\n\tfunction AutocompleterUI( {\n\t\tfilterValue,\n\t\tselectedIndex,\n\t\tonChangeOptions,\n\t\tonSelect,\n\t\tvalue,\n\t\treset,\n\t} ) {\n\t\tconst [ items ] = useItems( filterValue );\n\t\tconst filteredItems = items.filter( ( item ) => ! item.isDisabled );\n\t\tconst scrollViewRef = useRef();\n\t\tconst animationValue = useRef( new Animated.Value( 0 ) ).current;\n\t\tconst [ isVisible, setIsVisible ] = useState( false );\n\t\tconst { text } = value;\n\n\t\tuseEffect( () => {\n\t\t\tif ( ! isVisible && text.length > 0 ) {\n\t\t\t\tsetIsVisible( true );\n\t\t\t}\n\t\t}, [ isVisible, text ] );\n\n\t\tuseLayoutEffect( () => {\n\t\t\tonChangeOptions( items );\n\t\t\tscrollViewRef.current?.scrollTo( { x: 0, animated: false } );\n\n\t\t\tif ( isVisible && text.length > 0 ) {\n\t\t\t\tstartAnimation( true );\n\t\t\t} else if ( isVisible && text.length === 0 ) {\n\t\t\t\tstartAnimation( false );\n\t\t\t}\n\t\t}, [ onChangeOptions, items, isVisible, text, startAnimation ] );\n\n\t\tconst activeItemStyles = usePreferredColorSchemeStyle(\n\t\t\tstyles[ 'components-autocomplete__item-active' ],\n\t\t\tstyles[ 'components-autocomplete__item-active-dark' ]\n\t\t);\n\n\t\tconst iconStyles = usePreferredColorSchemeStyle(\n\t\t\tstyles[ 'components-autocomplete__icon' ],\n\t\t\tstyles[ 'components-autocomplete__icon-active-dark' ]\n\t\t);\n\n\t\tconst activeIconStyles = usePreferredColorSchemeStyle(\n\t\t\tstyles[ 'components-autocomplete__icon-active ' ],\n\t\t\tstyles[ 'components-autocomplete__icon-active-dark' ]\n\t\t);\n\n\t\tconst textStyles = usePreferredColorSchemeStyle(\n\t\t\tstyles[ 'components-autocomplete__text' ],\n\t\t\tstyles[ 'components-autocomplete__text-dark' ]\n\t\t);\n\n\t\tconst activeTextStyles = usePreferredColorSchemeStyle(\n\t\t\tstyles[ 'components-autocomplete__text-active' ],\n\t\t\tstyles[ 'components-autocomplete__text-active-dark' ]\n\t\t);\n\n\t\tconst startAnimation = useCallback(\n\t\t\t( show ) => {\n\t\t\t\tAnimated.timing( animationValue, {\n\t\t\t\t\ttoValue: show ? 1 : 0,\n\t\t\t\t\tduration: show ? 200 : 100,\n\t\t\t\t\tuseNativeDriver: true,\n\t\t\t\t} ).start( ( { finished } ) => {\n\t\t\t\t\tif ( finished && ! show && isVisible ) {\n\t\t\t\t\t\tsetIsVisible( false );\n\t\t\t\t\t\treset();\n\t\t\t\t\t}\n\t\t\t\t} );\n\t\t\t},\n\t\t\t[ animationValue, isVisible, reset ]\n\t\t);\n\n\t\tconst contentStyles = {\n\t\t\ttransform: [\n\t\t\t\t{\n\t\t\t\t\ttranslateY: animationValue.interpolate( {\n\t\t\t\t\t\tinputRange: [ 0, 1 ],\n\t\t\t\t\t\toutputRange: [\n\t\t\t\t\t\t\tstyles[ 'components-autocomplete' ].height,\n\t\t\t\t\t\t\t0,\n\t\t\t\t\t\t],\n\t\t\t\t\t} ),\n\t\t\t\t},\n\t\t\t],\n\t\t};\n\n\t\tif ( ! filteredItems.length > 0 || ! isVisible ) {\n\t\t\treturn null;\n\t\t}\n\n\t\treturn (\n\t\t\t<AutocompletionItemsFill>\n\t\t\t\t<View style={ styles[ 'components-autocomplete' ] }>\n\t\t\t\t\t<Animated.View style={ contentStyles }>\n\t\t\t\t\t\t<BackgroundView>\n\t\t\t\t\t\t\t<ScrollView\n\t\t\t\t\t\t\t\tref={ scrollViewRef }\n\t\t\t\t\t\t\t\thorizontal\n\t\t\t\t\t\t\t\tcontentContainerStyle={\n\t\t\t\t\t\t\t\t\tstyles[ 'components-autocomplete__content' ]\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tshowsHorizontalScrollIndicator={ false }\n\t\t\t\t\t\t\t\tkeyboardShouldPersistTaps=\"always\"\n\t\t\t\t\t\t\t\taccessibilityLabel={\n\t\t\t\t\t\t\t\t\t// translators: Slash inserter autocomplete results\n\t\t\t\t\t\t\t\t\t__( 'Slash inserter results' )\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t{ filteredItems.map( ( option, index ) => {\n\t\t\t\t\t\t\t\t\tconst isActive = index === selectedIndex;\n\t\t\t\t\t\t\t\t\tconst itemStyle = stylesCompose(\n\t\t\t\t\t\t\t\t\t\tstyles[\n\t\t\t\t\t\t\t\t\t\t\t'components-autocomplete__item'\n\t\t\t\t\t\t\t\t\t\t],\n\t\t\t\t\t\t\t\t\t\tisActive && activeItemStyles\n\t\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\t\tconst textStyle = stylesCompose(\n\t\t\t\t\t\t\t\t\t\ttextStyles,\n\t\t\t\t\t\t\t\t\t\tisActive && activeTextStyles\n\t\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\t\tconst iconStyle = stylesCompose(\n\t\t\t\t\t\t\t\t\t\ticonStyles,\n\t\t\t\t\t\t\t\t\t\tisActive && activeIconStyles\n\t\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\t\tconst iconSource =\n\t\t\t\t\t\t\t\t\t\toption?.value?.icon?.src ||\n\t\t\t\t\t\t\t\t\t\toption?.value?.icon;\n\n\t\t\t\t\t\t\t\t\treturn (\n\t\t\t\t\t\t\t\t\t\t<TouchableOpacity\n\t\t\t\t\t\t\t\t\t\t\tactiveOpacity={ 0.5 }\n\t\t\t\t\t\t\t\t\t\t\tstyle={ itemStyle }\n\t\t\t\t\t\t\t\t\t\t\tkey={ index }\n\t\t\t\t\t\t\t\t\t\t\tonPress={ () => onSelect( option ) }\n\t\t\t\t\t\t\t\t\t\t\taccessibilityLabel={ sprintf(\n\t\t\t\t\t\t\t\t\t\t\t\t// translators: %s: Block name e.g. \"Image block\"\n\t\t\t\t\t\t\t\t\t\t\t\t__( '%s block' ),\n\t\t\t\t\t\t\t\t\t\t\t\toption?.value?.title\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\t\t<View\n\t\t\t\t\t\t\t\t\t\t\t\tstyle={\n\t\t\t\t\t\t\t\t\t\t\t\t\tstyles[\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t'components-autocomplete__icon'\n\t\t\t\t\t\t\t\t\t\t\t\t\t]\n\t\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t\t\t\t<Icon\n\t\t\t\t\t\t\t\t\t\t\t\t\ticon={ iconSource }\n\t\t\t\t\t\t\t\t\t\t\t\t\tsize={ 24 }\n\t\t\t\t\t\t\t\t\t\t\t\t\tstyle={ iconStyle }\n\t\t\t\t\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t\t\t\t</View>\n\t\t\t\t\t\t\t\t\t\t\t<Text style={ textStyle }>\n\t\t\t\t\t\t\t\t\t\t\t\t{ option?.value?.title }\n\t\t\t\t\t\t\t\t\t\t\t</Text>\n\t\t\t\t\t\t\t\t\t\t</TouchableOpacity>\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</ScrollView>\n\t\t\t\t\t\t</BackgroundView>\n\t\t\t\t\t</Animated.View>\n\t\t\t\t</View>\n\t\t\t</AutocompletionItemsFill>\n\t\t);\n\t}\n\n\treturn AutocompleterUI;\n}\n\nexport default getAutoCompleterUI;\n"]}
@@ -124,7 +124,7 @@ function useAutocomplete(_ref) {
124
124
  const [filterValue, setFilterValue] = (0, _element.useState)('');
125
125
  const [autocompleter, setAutocompleter] = (0, _element.useState)(null);
126
126
  const [AutocompleterUI, setAutocompleterUI] = (0, _element.useState)(null);
127
- const [backspacing, setBackspacing] = (0, _element.useState)(false);
127
+ const backspacing = (0, _element.useRef)(false);
128
128
 
129
129
  function insertCompletion(replacement) {
130
130
  const end = record.start;
@@ -204,7 +204,7 @@ function useAutocomplete(_ref) {
204
204
  }
205
205
 
206
206
  function handleKeyDown(event) {
207
- setBackspacing(event.keyCode === _keycodes.BACKSPACE);
207
+ backspacing.current = event.keyCode === _keycodes.BACKSPACE;
208
208
 
209
209
  if (!autocompleter) {
210
210
  return;
@@ -249,14 +249,16 @@ function useAutocomplete(_ref) {
249
249
 
250
250
 
251
251
  event.preventDefault();
252
- }
253
-
254
- let textContent;
252
+ } // textContent is a primitive (string), memoizing is not strictly necessary
253
+ // but this is a preemptive performance improvement, since the autocompleter
254
+ // is a potential bottleneck for the editor type metric.
255
255
 
256
- if ((0, _richText.isCollapsed)(record)) {
257
- textContent = (0, _richText.getTextContent)((0, _richText.slice)(record, 0));
258
- }
259
256
 
257
+ const textContent = (0, _element.useMemo)(() => {
258
+ if ((0, _richText.isCollapsed)(record)) {
259
+ return (0, _richText.getTextContent)((0, _richText.slice)(record, 0));
260
+ }
261
+ }, [record]);
260
262
  (0, _element.useEffect)(() => {
261
263
  if (!textContent) {
262
264
  reset();
@@ -304,7 +306,7 @@ function useAutocomplete(_ref) {
304
306
  // Ex: "Some text @marcelo sekkkk" <--- "kkkk" caused a mismatch, but
305
307
  // if the user presses backspace here, it will show the completion popup again.
306
308
 
307
- const matchingWhileBackspacing = backspacing && textWithoutTrigger.split(/\s/).length <= 3;
309
+ const matchingWhileBackspacing = backspacing.current && textWithoutTrigger.split(/\s/).length <= 3;
308
310
 
309
311
  if (mismatch && !(matchingWhileBackspacing || hasOneTriggerWord)) {
310
312
  return false;
@@ -332,7 +334,7 @@ function useAutocomplete(_ref) {
332
334
  setAutocompleter(completer);
333
335
  setAutocompleterUI(() => completer !== autocompleter ? (0, _autocompleterUi.getAutoCompleterUI)(completer) : AutocompleterUI);
334
336
  setFilterValue(query);
335
- }, [textContent]);
337
+ }, [textContent, AutocompleterUI, autocompleter, completers, record, filteredOptions.length]);
336
338
  const {
337
339
  key: selectedKey = ''
338
340
  } = filteredOptions[selectedIndex] || {};
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/components/src/autocomplete/index.js"],"names":["useAutocomplete","record","onChange","onReplace","completers","contentRef","debouncedSpeak","speak","instanceId","selectedIndex","setSelectedIndex","filteredOptions","setFilteredOptions","filterValue","setFilterValue","autocompleter","setAutocompleter","AutocompleterUI","setAutocompleterUI","backspacing","setBackspacing","insertCompletion","replacement","end","start","triggerPrefix","length","toInsert","html","select","option","getOptionCompletion","isDisabled","completion","value","action","undefined","reset","announce","options","onChangeOptions","handleKeyDown","event","keyCode","BACKSPACE","defaultPrevented","UP","DOWN","ESCAPE","preventDefault","ENTER","LEFT","RIGHT","textContent","text","textAfterSelection","completer","allowContext","index","lastIndexOf","textWithoutTrigger","slice","tooDistantFromTrigger","mismatch","wordsFromTrigger","split","hasOneTriggerWord","matchingWhileBackspacing","test","safeTrigger","match","RegExp","query","key","selectedKey","className","isExpanded","listBoxId","activeId","hasSelection","onKeyDown","popover","useAutocompleteProps","ref","onKeyDownRef","current","element","_onKeyDown","addEventListener","removeEventListener","children","Autocomplete","isSelected","props"],"mappings":";;;;;;;;AAQA;;AALA;;AAWA;;AASA;;AACA;;AAMA;;AAOA;;AAKA;;AA1CA;AACA;AACA;;AAGA;AACA;AACA;;AAgCA;AACA;AACA;;AAGA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA,SAASA,eAAT,OAMI;AAAA,MANsB;AACzBC,IAAAA,MADyB;AAEzBC,IAAAA,QAFyB;AAGzBC,IAAAA,SAHyB;AAIzBC,IAAAA,UAJyB;AAKzBC,IAAAA;AALyB,GAMtB;AACH,QAAMC,cAAc,GAAG,0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A6B,SAA7B,EAAwCF,UAAxC;AACA,OAFD;AAGA,KARD,EAQG,EARH,CAFkB,CAAd,CADC;AAaNG,IAAAA,QAAQ,EAAET,OAbJ;AAcN,yBAAqBJ,SAAS,GAAG,MAAH,GAAYzC,SAdpC;AAeN,iBAAayC,SAfP;AAgBN,6BAAyBC;AAhBnB,GAAP;AAkBA;;AAEc,SAASa,YAAT,QAA8D;AAAA,MAAvC;AAAED,IAAAA,QAAF;AAAYE,IAAAA,UAAZ;AAAwB,OAAGrD;AAA3B,GAAuC;AAC5E,QAAM;AAAE0C,IAAAA,OAAF;AAAW,OAAGY;AAAd,MAAwB7F,eAAe,CAAEuC,OAAF,CAA7C;AACA,SACC,qDACGmD,QAAQ,CAAEG,KAAF,CADX,EAEGD,UAAU,IAAIX,OAFjB,CADD;AAMA","sourcesContent":["/**\n * External dependencies\n */\nimport { escapeRegExp, find, deburr } from 'lodash';\n\n/**\n * WordPress dependencies\n */\nimport {\n\trenderToString,\n\tuseEffect,\n\tuseState,\n\tuseRef,\n} from '@wordpress/element';\nimport {\n\tENTER,\n\tESCAPE,\n\tUP,\n\tDOWN,\n\tLEFT,\n\tRIGHT,\n\tBACKSPACE,\n} from '@wordpress/keycodes';\nimport { __, _n, sprintf } from '@wordpress/i18n';\nimport {\n\tuseInstanceId,\n\tuseDebounce,\n\tuseMergeRefs,\n\tuseRefEffect,\n} from '@wordpress/compose';\nimport {\n\tcreate,\n\tslice,\n\tinsert,\n\tisCollapsed,\n\tgetTextContent,\n} from '@wordpress/rich-text';\nimport { speak } from '@wordpress/a11y';\n\n/**\n * Internal dependencies\n */\nimport { getAutoCompleterUI } from './autocompleter-ui';\n\n/**\n * A raw completer option.\n *\n * @typedef {*} CompleterOption\n */\n\n/**\n * @callback FnGetOptions\n *\n * @return {(CompleterOption[]|Promise.<CompleterOption[]>)} The completer options or a promise for them.\n */\n\n/**\n * @callback FnGetOptionKeywords\n * @param {CompleterOption} option a completer option.\n *\n * @return {string[]} list of key words to search.\n */\n\n/**\n * @callback FnIsOptionDisabled\n * @param {CompleterOption} option a completer option.\n *\n * @return {string[]} whether or not the given option is disabled.\n */\n\n/**\n * @callback FnGetOptionLabel\n * @param {CompleterOption} option a completer option.\n *\n * @return {(string|Array.<(string|WPElement)>)} list of react components to render.\n */\n\n/**\n * @callback FnAllowContext\n * @param {string} before the string before the auto complete trigger and query.\n * @param {string} after the string after the autocomplete trigger and query.\n *\n * @return {boolean} true if the completer can handle.\n */\n\n/**\n * @typedef {Object} OptionCompletion\n * @property {'insert-at-caret'|'replace'} action the intended placement of the completion.\n * @property {OptionCompletionValue} value the completion value.\n */\n\n/**\n * A completion value.\n *\n * @typedef {(string|WPElement|Object)} OptionCompletionValue\n */\n\n/**\n * @callback FnGetOptionCompletion\n * @param {CompleterOption} value the value of the completer option.\n * @param {string} query the text value of the autocomplete query.\n *\n * @return {(OptionCompletion|OptionCompletionValue)} the completion for the given option. If an\n * \t\t\t\t\t\t\t\t\t\t\t\t\t OptionCompletionValue is returned, the\n * \t\t\t\t\t\t\t\t\t\t\t\t\t completion action defaults to `insert-at-caret`.\n */\n\n/**\n * @typedef {Object} WPCompleter\n * @property {string} name a way to identify a completer, useful for selective overriding.\n * @property {?string} className A class to apply to the popup menu.\n * @property {string} triggerPrefix the prefix that will display the menu.\n * @property {(CompleterOption[]|FnGetOptions)} options the completer options or a function to get them.\n * @property {?FnGetOptionKeywords} getOptionKeywords get the keywords for a given option.\n * @property {?FnIsOptionDisabled} isOptionDisabled get whether or not the given option is disabled.\n * @property {FnGetOptionLabel} getOptionLabel get the label for a given option.\n * @property {?FnAllowContext} allowContext filter the context under which the autocomplete activates.\n * @property {FnGetOptionCompletion} getOptionCompletion get the completion associated with a given option.\n */\n\nfunction useAutocomplete( {\n\trecord,\n\tonChange,\n\tonReplace,\n\tcompleters,\n\tcontentRef,\n} ) {\n\tconst debouncedSpeak = useDebounce( speak, 500 );\n\tconst instanceId = useInstanceId( useAutocomplete );\n\tconst [ selectedIndex, setSelectedIndex ] = useState( 0 );\n\tconst [ filteredOptions, setFilteredOptions ] = useState( [] );\n\tconst [ filterValue, setFilterValue ] = useState( '' );\n\tconst [ autocompleter, setAutocompleter ] = useState( null );\n\tconst [ AutocompleterUI, setAutocompleterUI ] = useState( null );\n\tconst [ backspacing, setBackspacing ] = useState( false );\n\n\tfunction insertCompletion( replacement ) {\n\t\tconst end = record.start;\n\t\tconst start =\n\t\t\tend - autocompleter.triggerPrefix.length - filterValue.length;\n\t\tconst toInsert = create( { html: renderToString( replacement ) } );\n\n\t\tonChange( insert( record, toInsert, start, end ) );\n\t}\n\n\tfunction select( option ) {\n\t\tconst { getOptionCompletion } = autocompleter || {};\n\n\t\tif ( option.isDisabled ) {\n\t\t\treturn;\n\t\t}\n\n\t\tif ( getOptionCompletion ) {\n\t\t\tconst completion = getOptionCompletion( option.value, filterValue );\n\n\t\t\tconst { action, value } =\n\t\t\t\tundefined === completion.action ||\n\t\t\t\tundefined === completion.value\n\t\t\t\t\t? { action: 'insert-at-caret', value: completion }\n\t\t\t\t\t: completion;\n\n\t\t\tif ( 'replace' === action ) {\n\t\t\t\tonReplace( [ value ] );\n\t\t\t\t// When replacing, the component will unmount, so don't reset\n\t\t\t\t// state (below) on an unmounted component.\n\t\t\t\treturn;\n\t\t\t} else if ( 'insert-at-caret' === action ) {\n\t\t\t\tinsertCompletion( value );\n\t\t\t}\n\t\t}\n\n\t\t// Reset autocomplete state after insertion rather than before\n\t\t// so insertion events don't cause the completion menu to redisplay.\n\t\treset();\n\t}\n\n\tfunction reset() {\n\t\tsetSelectedIndex( 0 );\n\t\tsetFilteredOptions( [] );\n\t\tsetFilterValue( '' );\n\t\tsetAutocompleter( null );\n\t\tsetAutocompleterUI( null );\n\t}\n\n\tfunction announce( options ) {\n\t\tif ( ! debouncedSpeak ) {\n\t\t\treturn;\n\t\t}\n\t\tif ( !! options.length ) {\n\t\t\tdebouncedSpeak(\n\t\t\t\tsprintf(\n\t\t\t\t\t/* translators: %d: number of results. */\n\t\t\t\t\t_n(\n\t\t\t\t\t\t'%d result found, use up and down arrow keys to navigate.',\n\t\t\t\t\t\t'%d results found, use up and down arrow keys to navigate.',\n\t\t\t\t\t\toptions.length\n\t\t\t\t\t),\n\t\t\t\t\toptions.length\n\t\t\t\t),\n\t\t\t\t'assertive'\n\t\t\t);\n\t\t} else {\n\t\t\tdebouncedSpeak( __( 'No results.' ), 'assertive' );\n\t\t}\n\t}\n\n\t/**\n\t * Load options for an autocompleter.\n\t *\n\t * @param {Array} options\n\t */\n\tfunction onChangeOptions( options ) {\n\t\tsetSelectedIndex(\n\t\t\toptions.length === filteredOptions.length ? selectedIndex : 0\n\t\t);\n\t\tsetFilteredOptions( options );\n\t\tannounce( options );\n\t}\n\n\tfunction handleKeyDown( event ) {\n\t\tsetBackspacing( event.keyCode === BACKSPACE );\n\n\t\tif ( ! autocompleter ) {\n\t\t\treturn;\n\t\t}\n\t\tif ( filteredOptions.length === 0 ) {\n\t\t\treturn;\n\t\t}\n\t\tif ( event.defaultPrevented ) {\n\t\t\treturn;\n\t\t}\n\t\tswitch ( event.keyCode ) {\n\t\t\tcase UP:\n\t\t\t\tsetSelectedIndex(\n\t\t\t\t\t( selectedIndex === 0\n\t\t\t\t\t\t? filteredOptions.length\n\t\t\t\t\t\t: selectedIndex ) - 1\n\t\t\t\t);\n\t\t\t\tbreak;\n\n\t\t\tcase DOWN:\n\t\t\t\tsetSelectedIndex(\n\t\t\t\t\t( selectedIndex + 1 ) % filteredOptions.length\n\t\t\t\t);\n\t\t\t\tbreak;\n\n\t\t\tcase ESCAPE:\n\t\t\t\tsetAutocompleter( null );\n\t\t\t\tsetAutocompleterUI( null );\n\t\t\t\tevent.preventDefault();\n\t\t\t\tbreak;\n\n\t\t\tcase ENTER:\n\t\t\t\tselect( filteredOptions[ selectedIndex ] );\n\t\t\t\tbreak;\n\n\t\t\tcase LEFT:\n\t\t\tcase RIGHT:\n\t\t\t\treset();\n\t\t\t\treturn;\n\n\t\t\tdefault:\n\t\t\t\treturn;\n\t\t}\n\n\t\t// Any handled keycode should prevent original behavior. This relies on\n\t\t// the early return in the default case.\n\t\tevent.preventDefault();\n\t}\n\n\tlet textContent;\n\n\tif ( isCollapsed( record ) ) {\n\t\ttextContent = getTextContent( slice( record, 0 ) );\n\t}\n\n\tuseEffect( () => {\n\t\tif ( ! textContent ) {\n\t\t\treset();\n\t\t\treturn;\n\t\t}\n\n\t\tconst text = deburr( textContent );\n\t\tconst textAfterSelection = getTextContent(\n\t\t\tslice( record, undefined, getTextContent( record ).length )\n\t\t);\n\t\tconst completer = find(\n\t\t\tcompleters,\n\t\t\t( { triggerPrefix, allowContext } ) => {\n\t\t\t\tconst index = text.lastIndexOf( triggerPrefix );\n\n\t\t\t\tif ( index === -1 ) {\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\n\t\t\t\tconst textWithoutTrigger = text.slice(\n\t\t\t\t\tindex + triggerPrefix.length\n\t\t\t\t);\n\n\t\t\t\tconst tooDistantFromTrigger = textWithoutTrigger.length > 50; // 50 chars seems to be a good limit.\n\t\t\t\t// This is a final barrier to prevent the effect from completing with\n\t\t\t\t// an extremely long string, which causes the editor to slow-down\n\t\t\t\t// significantly. This could happen, for example, if `matchingWhileBackspacing`\n\t\t\t\t// is true and one of the \"words\" end up being too long. If that's the case,\n\t\t\t\t// it will be caught by this guard.\n\t\t\t\tif ( tooDistantFromTrigger ) return false;\n\n\t\t\t\tconst mismatch = filteredOptions.length === 0;\n\t\t\t\tconst wordsFromTrigger = textWithoutTrigger.split( /\\s/ );\n\t\t\t\t// We need to allow the effect to run when not backspacing and if there\n\t\t\t\t// was a mismatch. i.e when typing a trigger + the match string or when\n\t\t\t\t// clicking in an existing trigger word on the page. We do that if we\n\t\t\t\t// detect that we have one word from trigger in the current textual context.\n\t\t\t\t//\n\t\t\t\t// Ex.: \"Some text @a\" <-- \"@a\" will be detected as the trigger word and\n\t\t\t\t// allow the effect to run. It will run until there's a mismatch.\n\t\t\t\tconst hasOneTriggerWord = wordsFromTrigger.length === 1;\n\t\t\t\t// This is used to allow the effect to run when backspacing and if\n\t\t\t\t// \"touching\" a word that \"belongs\" to a trigger. We consider a \"trigger\n\t\t\t\t// word\" any word up to the limit of 3 from the trigger character.\n\t\t\t\t// Anything beyond that is ignored if there's a mismatch. This allows\n\t\t\t\t// us to \"escape\" a mismatch when backspacing, but still imposing some\n\t\t\t\t// sane limits.\n\t\t\t\t//\n\t\t\t\t// Ex: \"Some text @marcelo sekkkk\" <--- \"kkkk\" caused a mismatch, but\n\t\t\t\t// if the user presses backspace here, it will show the completion popup again.\n\t\t\t\tconst matchingWhileBackspacing =\n\t\t\t\t\tbackspacing && textWithoutTrigger.split( /\\s/ ).length <= 3;\n\n\t\t\t\tif (\n\t\t\t\t\tmismatch &&\n\t\t\t\t\t! ( matchingWhileBackspacing || hasOneTriggerWord )\n\t\t\t\t) {\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\n\t\t\t\tif (\n\t\t\t\t\tallowContext &&\n\t\t\t\t\t! allowContext( text.slice( 0, index ), textAfterSelection )\n\t\t\t\t) {\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\n\t\t\t\tif (\n\t\t\t\t\t/^\\s/.test( textWithoutTrigger ) ||\n\t\t\t\t\t/\\s\\s+$/.test( textWithoutTrigger )\n\t\t\t\t) {\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\n\t\t\t\treturn /[\\u0000-\\uFFFF]*$/.test( textWithoutTrigger );\n\t\t\t}\n\t\t);\n\n\t\tif ( ! completer ) {\n\t\t\treset();\n\t\t\treturn;\n\t\t}\n\n\t\tconst safeTrigger = escapeRegExp( completer.triggerPrefix );\n\t\tconst match = text\n\t\t\t.slice( text.lastIndexOf( completer.triggerPrefix ) )\n\t\t\t.match( new RegExp( `${ safeTrigger }([\\u0000-\\uFFFF]*)$` ) );\n\t\tconst query = match && match[ 1 ];\n\n\t\tsetAutocompleter( completer );\n\t\tsetAutocompleterUI( () =>\n\t\t\tcompleter !== autocompleter\n\t\t\t\t? getAutoCompleterUI( completer )\n\t\t\t\t: AutocompleterUI\n\t\t);\n\t\tsetFilterValue( query );\n\t}, [ textContent ] );\n\n\tconst { key: selectedKey = '' } = filteredOptions[ selectedIndex ] || {};\n\tconst { className } = autocompleter || {};\n\tconst isExpanded = !! autocompleter && filteredOptions.length > 0;\n\tconst listBoxId = isExpanded\n\t\t? `components-autocomplete-listbox-${ instanceId }`\n\t\t: null;\n\tconst activeId = isExpanded\n\t\t? `components-autocomplete-item-${ instanceId }-${ selectedKey }`\n\t\t: null;\n\tconst hasSelection = record.start !== undefined;\n\n\treturn {\n\t\tlistBoxId,\n\t\tactiveId,\n\t\tonKeyDown: handleKeyDown,\n\t\tpopover: hasSelection && AutocompleterUI && (\n\t\t\t<AutocompleterUI\n\t\t\t\tclassName={ className }\n\t\t\t\tfilterValue={ filterValue }\n\t\t\t\tinstanceId={ instanceId }\n\t\t\t\tlistBoxId={ listBoxId }\n\t\t\t\tselectedIndex={ selectedIndex }\n\t\t\t\tonChangeOptions={ onChangeOptions }\n\t\t\t\tonSelect={ select }\n\t\t\t\tvalue={ record }\n\t\t\t\tcontentRef={ contentRef }\n\t\t\t\treset={ reset }\n\t\t\t/>\n\t\t),\n\t};\n}\n\nexport function useAutocompleteProps( options ) {\n\tconst ref = useRef();\n\tconst onKeyDownRef = useRef();\n\tconst { popover, listBoxId, activeId, onKeyDown } = useAutocomplete( {\n\t\t...options,\n\t\tcontentRef: ref,\n\t} );\n\tonKeyDownRef.current = onKeyDown;\n\treturn {\n\t\tref: useMergeRefs( [\n\t\t\tref,\n\t\t\tuseRefEffect( ( element ) => {\n\t\t\t\tfunction _onKeyDown( event ) {\n\t\t\t\t\tonKeyDownRef.current( event );\n\t\t\t\t}\n\t\t\t\telement.addEventListener( 'keydown', _onKeyDown );\n\t\t\t\treturn () => {\n\t\t\t\t\telement.removeEventListener( 'keydown', _onKeyDown );\n\t\t\t\t};\n\t\t\t}, [] ),\n\t\t] ),\n\t\tchildren: popover,\n\t\t'aria-autocomplete': listBoxId ? 'list' : undefined,\n\t\t'aria-owns': listBoxId,\n\t\t'aria-activedescendant': activeId,\n\t};\n}\n\nexport default function Autocomplete( { children, isSelected, ...options } ) {\n\tconst { popover, ...props } = useAutocomplete( options );\n\treturn (\n\t\t<>\n\t\t\t{ children( props ) }\n\t\t\t{ isSelected && popover }\n\t\t</>\n\t);\n}\n"]}
1
+ {"version":3,"sources":["@wordpress/components/src/autocomplete/index.js"],"names":["useAutocomplete","record","onChange","onReplace","completers","contentRef","debouncedSpeak","speak","instanceId","selectedIndex","setSelectedIndex","filteredOptions","setFilteredOptions","filterValue","setFilterValue","autocompleter","setAutocompleter","AutocompleterUI","setAutocompleterUI","backspacing","insertCompletion","replacement","end","start","triggerPrefix","length","toInsert","html","select","option","getOptionCompletion","isDisabled","completion","value","action","undefined","reset","announce","options","onChangeOptions","handleKeyDown","event","current","keyCode","BACKSPACE","defaultPrevented","UP","DOWN","ESCAPE","preventDefault","ENTER","LEFT","RIGHT","textContent","text","textAfterSelection","completer","allowContext","index","lastIndexOf","textWithoutTrigger","slice","tooDistantFromTrigger","mismatch","wordsFromTrigger","split","hasOneTriggerWord","matchingWhileBackspacing","test","safeTrigger","match","RegExp","query","key","selectedKey","className","isExpanded","listBoxId","activeId","hasSelection","onKeyDown","popover","useAutocompleteProps","ref","onKeyDownRef","element","_onKeyDown","addEventListener","removeEventListener","children","Autocomplete","isSelected","props"],"mappings":";;;;;;;;AAQA;;AALA;;AAYA;;AASA;;AACA;;AAMA;;AAOA;;AAKA;;AA3CA;AACA;AACA;;AAGA;AACA;AACA;;AAiCA;AACA;AACA;;AAGA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;A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AA;AAAhC,MAA8ChF,eAAe,CAAE,EACpE,GAAGsC,OADiE;AAEpEjC,IAAAA,UAAU,EAAE8E;AAFwD,GAAF,CAAnE;AAIAC,EAAAA,YAAY,CAAC1C,OAAb,GAAuBsC,SAAvB;AACA,SAAO;AACNG,IAAAA,GAAG,EAAE,2BAAc,CAClBA,GADkB,EAElB,2BAAgBE,OAAF,IAAe;AAC5B,eAASC,UAAT,CAAqB7C,KAArB,EAA6B;AAC5B2C,QAAAA,YAAY,CAAC1C,OAAb,CAAsBD,KAAtB;AACA;;AACD4C,MAAAA,OAAO,CAACE,gBAAR,CAA0B,SAA1B,EAAqCD,UAArC;AACA,aAAO,MAAM;AACZD,QAAAA,OAAO,CAACG,mBAAR,CAA6B,SAA7B,EAAwCF,UAAxC;AACA,OAFD;AAGA,KARD,EAQG,EARH,CAFkB,CAAd,CADC;AAaNG,IAAAA,QAAQ,EAAER,OAbJ;AAcN,yBAAqBJ,SAAS,GAAG,MAAH,GAAY1C,SAdpC;AAeN,iBAAa0C,SAfP;AAgBN,6BAAyBC;AAhBnB,GAAP;AAkBA;;AAEc,SAASY,YAAT,QAA8D;AAAA,MAAvC;AAAED,IAAAA,QAAF;AAAYE,IAAAA,UAAZ;AAAwB,OAAGrD;AAA3B,GAAuC;AAC5E,QAAM;AAAE2C,IAAAA,OAAF;AAAW,OAAGW;AAAd,MAAwB5F,eAAe,CAAEsC,OAAF,CAA7C;AACA,SACC,qDACGmD,QAAQ,CAAEG,KAAF,CADX,EAEGD,UAAU,IAAIV,OAFjB,CADD;AAMA","sourcesContent":["/**\n * External dependencies\n */\nimport { escapeRegExp, find, deburr } from 'lodash';\n\n/**\n * WordPress dependencies\n */\nimport {\n\trenderToString,\n\tuseEffect,\n\tuseState,\n\tuseRef,\n\tuseMemo,\n} from '@wordpress/element';\nimport {\n\tENTER,\n\tESCAPE,\n\tUP,\n\tDOWN,\n\tLEFT,\n\tRIGHT,\n\tBACKSPACE,\n} from '@wordpress/keycodes';\nimport { __, _n, sprintf } from '@wordpress/i18n';\nimport {\n\tuseInstanceId,\n\tuseDebounce,\n\tuseMergeRefs,\n\tuseRefEffect,\n} from '@wordpress/compose';\nimport {\n\tcreate,\n\tslice,\n\tinsert,\n\tisCollapsed,\n\tgetTextContent,\n} from '@wordpress/rich-text';\nimport { speak } from '@wordpress/a11y';\n\n/**\n * Internal dependencies\n */\nimport { getAutoCompleterUI } from './autocompleter-ui';\n\n/**\n * A raw completer option.\n *\n * @typedef {*} CompleterOption\n */\n\n/**\n * @callback FnGetOptions\n *\n * @return {(CompleterOption[]|Promise.<CompleterOption[]>)} The completer options or a promise for them.\n */\n\n/**\n * @callback FnGetOptionKeywords\n * @param {CompleterOption} option a completer option.\n *\n * @return {string[]} list of key words to search.\n */\n\n/**\n * @callback FnIsOptionDisabled\n * @param {CompleterOption} option a completer option.\n *\n * @return {string[]} whether or not the given option is disabled.\n */\n\n/**\n * @callback FnGetOptionLabel\n * @param {CompleterOption} option a completer option.\n *\n * @return {(string|Array.<(string|WPElement)>)} list of react components to render.\n */\n\n/**\n * @callback FnAllowContext\n * @param {string} before the string before the auto complete trigger and query.\n * @param {string} after the string after the autocomplete trigger and query.\n *\n * @return {boolean} true if the completer can handle.\n */\n\n/**\n * @typedef {Object} OptionCompletion\n * @property {'insert-at-caret'|'replace'} action the intended placement of the completion.\n * @property {OptionCompletionValue} value the completion value.\n */\n\n/**\n * A completion value.\n *\n * @typedef {(string|WPElement|Object)} OptionCompletionValue\n */\n\n/**\n * @callback FnGetOptionCompletion\n * @param {CompleterOption} value the value of the completer option.\n * @param {string} query the text value of the autocomplete query.\n *\n * @return {(OptionCompletion|OptionCompletionValue)} the completion for the given option. If an\n * \t\t\t\t\t\t\t\t\t\t\t\t\t OptionCompletionValue is returned, the\n * \t\t\t\t\t\t\t\t\t\t\t\t\t completion action defaults to `insert-at-caret`.\n */\n\n/**\n * @typedef {Object} WPCompleter\n * @property {string} name a way to identify a completer, useful for selective overriding.\n * @property {?string} className A class to apply to the popup menu.\n * @property {string} triggerPrefix the prefix that will display the menu.\n * @property {(CompleterOption[]|FnGetOptions)} options the completer options or a function to get them.\n * @property {?FnGetOptionKeywords} getOptionKeywords get the keywords for a given option.\n * @property {?FnIsOptionDisabled} isOptionDisabled get whether or not the given option is disabled.\n * @property {FnGetOptionLabel} getOptionLabel get the label for a given option.\n * @property {?FnAllowContext} allowContext filter the context under which the autocomplete activates.\n * @property {FnGetOptionCompletion} getOptionCompletion get the completion associated with a given option.\n */\n\nfunction useAutocomplete( {\n\trecord,\n\tonChange,\n\tonReplace,\n\tcompleters,\n\tcontentRef,\n} ) {\n\tconst debouncedSpeak = useDebounce( speak, 500 );\n\tconst instanceId = useInstanceId( useAutocomplete );\n\tconst [ selectedIndex, setSelectedIndex ] = useState( 0 );\n\tconst [ filteredOptions, setFilteredOptions ] = useState( [] );\n\tconst [ filterValue, setFilterValue ] = useState( '' );\n\tconst [ autocompleter, setAutocompleter ] = useState( null );\n\tconst [ AutocompleterUI, setAutocompleterUI ] = useState( null );\n\tconst backspacing = useRef( false );\n\n\tfunction insertCompletion( replacement ) {\n\t\tconst end = record.start;\n\t\tconst start =\n\t\t\tend - autocompleter.triggerPrefix.length - filterValue.length;\n\t\tconst toInsert = create( { html: renderToString( replacement ) } );\n\n\t\tonChange( insert( record, toInsert, start, end ) );\n\t}\n\n\tfunction select( option ) {\n\t\tconst { getOptionCompletion } = autocompleter || {};\n\n\t\tif ( option.isDisabled ) {\n\t\t\treturn;\n\t\t}\n\n\t\tif ( getOptionCompletion ) {\n\t\t\tconst completion = getOptionCompletion( option.value, filterValue );\n\n\t\t\tconst { action, value } =\n\t\t\t\tundefined === completion.action ||\n\t\t\t\tundefined === completion.value\n\t\t\t\t\t? { action: 'insert-at-caret', value: completion }\n\t\t\t\t\t: completion;\n\n\t\t\tif ( 'replace' === action ) {\n\t\t\t\tonReplace( [ value ] );\n\t\t\t\t// When replacing, the component will unmount, so don't reset\n\t\t\t\t// state (below) on an unmounted component.\n\t\t\t\treturn;\n\t\t\t} else if ( 'insert-at-caret' === action ) {\n\t\t\t\tinsertCompletion( value );\n\t\t\t}\n\t\t}\n\n\t\t// Reset autocomplete state after insertion rather than before\n\t\t// so insertion events don't cause the completion menu to redisplay.\n\t\treset();\n\t}\n\n\tfunction reset() {\n\t\tsetSelectedIndex( 0 );\n\t\tsetFilteredOptions( [] );\n\t\tsetFilterValue( '' );\n\t\tsetAutocompleter( null );\n\t\tsetAutocompleterUI( null );\n\t}\n\n\tfunction announce( options ) {\n\t\tif ( ! debouncedSpeak ) {\n\t\t\treturn;\n\t\t}\n\t\tif ( !! options.length ) {\n\t\t\tdebouncedSpeak(\n\t\t\t\tsprintf(\n\t\t\t\t\t/* translators: %d: number of results. */\n\t\t\t\t\t_n(\n\t\t\t\t\t\t'%d result found, use up and down arrow keys to navigate.',\n\t\t\t\t\t\t'%d results found, use up and down arrow keys to navigate.',\n\t\t\t\t\t\toptions.length\n\t\t\t\t\t),\n\t\t\t\t\toptions.length\n\t\t\t\t),\n\t\t\t\t'assertive'\n\t\t\t);\n\t\t} else {\n\t\t\tdebouncedSpeak( __( 'No results.' ), 'assertive' );\n\t\t}\n\t}\n\n\t/**\n\t * Load options for an autocompleter.\n\t *\n\t * @param {Array} options\n\t */\n\tfunction onChangeOptions( options ) {\n\t\tsetSelectedIndex(\n\t\t\toptions.length === filteredOptions.length ? selectedIndex : 0\n\t\t);\n\t\tsetFilteredOptions( options );\n\t\tannounce( options );\n\t}\n\n\tfunction handleKeyDown( event ) {\n\t\tbackspacing.current = event.keyCode === BACKSPACE;\n\n\t\tif ( ! autocompleter ) {\n\t\t\treturn;\n\t\t}\n\t\tif ( filteredOptions.length === 0 ) {\n\t\t\treturn;\n\t\t}\n\t\tif ( event.defaultPrevented ) {\n\t\t\treturn;\n\t\t}\n\t\tswitch ( event.keyCode ) {\n\t\t\tcase UP:\n\t\t\t\tsetSelectedIndex(\n\t\t\t\t\t( selectedIndex === 0\n\t\t\t\t\t\t? filteredOptions.length\n\t\t\t\t\t\t: selectedIndex ) - 1\n\t\t\t\t);\n\t\t\t\tbreak;\n\n\t\t\tcase DOWN:\n\t\t\t\tsetSelectedIndex(\n\t\t\t\t\t( selectedIndex + 1 ) % filteredOptions.length\n\t\t\t\t);\n\t\t\t\tbreak;\n\n\t\t\tcase ESCAPE:\n\t\t\t\tsetAutocompleter( null );\n\t\t\t\tsetAutocompleterUI( null );\n\t\t\t\tevent.preventDefault();\n\t\t\t\tbreak;\n\n\t\t\tcase ENTER:\n\t\t\t\tselect( filteredOptions[ selectedIndex ] );\n\t\t\t\tbreak;\n\n\t\t\tcase LEFT:\n\t\t\tcase RIGHT:\n\t\t\t\treset();\n\t\t\t\treturn;\n\n\t\t\tdefault:\n\t\t\t\treturn;\n\t\t}\n\n\t\t// Any handled keycode should prevent original behavior. This relies on\n\t\t// the early return in the default case.\n\t\tevent.preventDefault();\n\t}\n\n\t// textContent is a primitive (string), memoizing is not strictly necessary\n\t// but this is a preemptive performance improvement, since the autocompleter\n\t// is a potential bottleneck for the editor type metric.\n\tconst textContent = useMemo( () => {\n\t\tif ( isCollapsed( record ) ) {\n\t\t\treturn getTextContent( slice( record, 0 ) );\n\t\t}\n\t}, [ record ] );\n\n\tuseEffect( () => {\n\t\tif ( ! textContent ) {\n\t\t\treset();\n\t\t\treturn;\n\t\t}\n\n\t\tconst text = deburr( textContent );\n\t\tconst textAfterSelection = getTextContent(\n\t\t\tslice( record, undefined, getTextContent( record ).length )\n\t\t);\n\t\tconst completer = find(\n\t\t\tcompleters,\n\t\t\t( { triggerPrefix, allowContext } ) => {\n\t\t\t\tconst index = text.lastIndexOf( triggerPrefix );\n\n\t\t\t\tif ( index === -1 ) {\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\n\t\t\t\tconst textWithoutTrigger = text.slice(\n\t\t\t\t\tindex + triggerPrefix.length\n\t\t\t\t);\n\n\t\t\t\tconst tooDistantFromTrigger = textWithoutTrigger.length > 50; // 50 chars seems to be a good limit.\n\t\t\t\t// This is a final barrier to prevent the effect from completing with\n\t\t\t\t// an extremely long string, which causes the editor to slow-down\n\t\t\t\t// significantly. This could happen, for example, if `matchingWhileBackspacing`\n\t\t\t\t// is true and one of the \"words\" end up being too long. If that's the case,\n\t\t\t\t// it will be caught by this guard.\n\t\t\t\tif ( tooDistantFromTrigger ) return false;\n\n\t\t\t\tconst mismatch = filteredOptions.length === 0;\n\t\t\t\tconst wordsFromTrigger = textWithoutTrigger.split( /\\s/ );\n\t\t\t\t// We need to allow the effect to run when not backspacing and if there\n\t\t\t\t// was a mismatch. i.e when typing a trigger + the match string or when\n\t\t\t\t// clicking in an existing trigger word on the page. We do that if we\n\t\t\t\t// detect that we have one word from trigger in the current textual context.\n\t\t\t\t//\n\t\t\t\t// Ex.: \"Some text @a\" <-- \"@a\" will be detected as the trigger word and\n\t\t\t\t// allow the effect to run. It will run until there's a mismatch.\n\t\t\t\tconst hasOneTriggerWord = wordsFromTrigger.length === 1;\n\t\t\t\t// This is used to allow the effect to run when backspacing and if\n\t\t\t\t// \"touching\" a word that \"belongs\" to a trigger. We consider a \"trigger\n\t\t\t\t// word\" any word up to the limit of 3 from the trigger character.\n\t\t\t\t// Anything beyond that is ignored if there's a mismatch. This allows\n\t\t\t\t// us to \"escape\" a mismatch when backspacing, but still imposing some\n\t\t\t\t// sane limits.\n\t\t\t\t//\n\t\t\t\t// Ex: \"Some text @marcelo sekkkk\" <--- \"kkkk\" caused a mismatch, but\n\t\t\t\t// if the user presses backspace here, it will show the completion popup again.\n\t\t\t\tconst matchingWhileBackspacing =\n\t\t\t\t\tbackspacing.current &&\n\t\t\t\t\ttextWithoutTrigger.split( /\\s/ ).length <= 3;\n\n\t\t\t\tif (\n\t\t\t\t\tmismatch &&\n\t\t\t\t\t! ( matchingWhileBackspacing || hasOneTriggerWord )\n\t\t\t\t) {\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\n\t\t\t\tif (\n\t\t\t\t\tallowContext &&\n\t\t\t\t\t! allowContext( text.slice( 0, index ), textAfterSelection )\n\t\t\t\t) {\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\n\t\t\t\tif (\n\t\t\t\t\t/^\\s/.test( textWithoutTrigger ) ||\n\t\t\t\t\t/\\s\\s+$/.test( textWithoutTrigger )\n\t\t\t\t) {\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\n\t\t\t\treturn /[\\u0000-\\uFFFF]*$/.test( textWithoutTrigger );\n\t\t\t}\n\t\t);\n\n\t\tif ( ! completer ) {\n\t\t\treset();\n\t\t\treturn;\n\t\t}\n\n\t\tconst safeTrigger = escapeRegExp( completer.triggerPrefix );\n\t\tconst match = text\n\t\t\t.slice( text.lastIndexOf( completer.triggerPrefix ) )\n\t\t\t.match( new RegExp( `${ safeTrigger }([\\u0000-\\uFFFF]*)$` ) );\n\t\tconst query = match && match[ 1 ];\n\n\t\tsetAutocompleter( completer );\n\t\tsetAutocompleterUI( () =>\n\t\t\tcompleter !== autocompleter\n\t\t\t\t? getAutoCompleterUI( completer )\n\t\t\t\t: AutocompleterUI\n\t\t);\n\t\tsetFilterValue( query );\n\t}, [\n\t\ttextContent,\n\t\tAutocompleterUI,\n\t\tautocompleter,\n\t\tcompleters,\n\t\trecord,\n\t\tfilteredOptions.length,\n\t] );\n\n\tconst { key: selectedKey = '' } = filteredOptions[ selectedIndex ] || {};\n\tconst { className } = autocompleter || {};\n\tconst isExpanded = !! autocompleter && filteredOptions.length > 0;\n\tconst listBoxId = isExpanded\n\t\t? `components-autocomplete-listbox-${ instanceId }`\n\t\t: null;\n\tconst activeId = isExpanded\n\t\t? `components-autocomplete-item-${ instanceId }-${ selectedKey }`\n\t\t: null;\n\tconst hasSelection = record.start !== undefined;\n\n\treturn {\n\t\tlistBoxId,\n\t\tactiveId,\n\t\tonKeyDown: handleKeyDown,\n\t\tpopover: hasSelection && AutocompleterUI && (\n\t\t\t<AutocompleterUI\n\t\t\t\tclassName={ className }\n\t\t\t\tfilterValue={ filterValue }\n\t\t\t\tinstanceId={ instanceId }\n\t\t\t\tlistBoxId={ listBoxId }\n\t\t\t\tselectedIndex={ selectedIndex }\n\t\t\t\tonChangeOptions={ onChangeOptions }\n\t\t\t\tonSelect={ select }\n\t\t\t\tvalue={ record }\n\t\t\t\tcontentRef={ contentRef }\n\t\t\t\treset={ reset }\n\t\t\t/>\n\t\t),\n\t};\n}\n\nexport function useAutocompleteProps( options ) {\n\tconst ref = useRef();\n\tconst onKeyDownRef = useRef();\n\tconst { popover, listBoxId, activeId, onKeyDown } = useAutocomplete( {\n\t\t...options,\n\t\tcontentRef: ref,\n\t} );\n\tonKeyDownRef.current = onKeyDown;\n\treturn {\n\t\tref: useMergeRefs( [\n\t\t\tref,\n\t\t\tuseRefEffect( ( element ) => {\n\t\t\t\tfunction _onKeyDown( event ) {\n\t\t\t\t\tonKeyDownRef.current( event );\n\t\t\t\t}\n\t\t\t\telement.addEventListener( 'keydown', _onKeyDown );\n\t\t\t\treturn () => {\n\t\t\t\t\telement.removeEventListener( 'keydown', _onKeyDown );\n\t\t\t\t};\n\t\t\t}, [] ),\n\t\t] ),\n\t\tchildren: popover,\n\t\t'aria-autocomplete': listBoxId ? 'list' : undefined,\n\t\t'aria-owns': listBoxId,\n\t\t'aria-activedescendant': activeId,\n\t};\n}\n\nexport default function Autocomplete( { children, isSelected, ...options } ) {\n\tconst { popover, ...props } = useAutocomplete( options );\n\treturn (\n\t\t<>\n\t\t\t{ children( props ) }\n\t\t\t{ isSelected && popover }\n\t\t</>\n\t);\n}\n"]}
@@ -94,10 +94,10 @@ function useBorderBoxControl(props) {
94
94
  const cx = (0, _useCx.useCx)();
95
95
  const classes = (0, _element.useMemo)(() => {
96
96
  return cx(styles.BorderBoxControl, className);
97
- }, [className]);
97
+ }, [cx, className]);
98
98
  const linkedControlClassName = (0, _element.useMemo)(() => {
99
99
  return cx(styles.LinkedBorderControl);
100
- }, []);
100
+ }, [cx]);
101
101
  return { ...otherProps,
102
102
  className: classes,
103
103
  hasMixedBorders: mixedBorders,
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/components/src/border-box-control/border-box-control/hook.ts"],"names":["useBorderBoxControl","props","className","onChange","value","otherProps","mixedBorders","splitBorders","linkedValue","splitValue","isLinked","setIsLinked","toggleLinked","onLinkedChange","newBorder","undefined","changes","updatedBorders","top","right","bottom","left","filteredResult","onSplitChange","side","cx","classes","styles","BorderBoxControl","linkedControlClassName","LinkedBorderControl","hasMixedBorders"],"mappings":";;;;;;;AAGA;;AAKA;;AACA;;AASA;;AACA;;;;;;AAnBA;AACA;AACA;;AAGA;AACA;AACA;AAiBO,SAASA,mBAAT,CACNC,KADM,EAEL;AACD,QAAM;AAAEC,IAAAA,SAAF;AAAaC,IAAAA,QAAb;AAAuBC,IAAAA,KAAvB;AAA8B,OAAGC;AAAjC,MAAgD,+BACrDJ,KADqD,EAErD,kBAFqD,CAAtD;AAKA,QAAMK,YAAY,GAAG,4BAAiBF,KAAjB,CAArB;AACA,QAAMG,YAAY,GAAG,4BAAiBH,KAAjB,CAArB;AAEA,QAAMI,WAAW,GAAGD,YAAY,GAC7B,4BAAiBH,KAAjB,CAD6B,GAE3BA,KAFL;AAIA,QAAMK,UAAU,GAAGF,YAAY,GAC1BH,KAD0B,GAE5B,4BAAiBA,KAAjB,CAFH;AAIA,QAAM,CAAEM,QAAF,EAAYC,WAAZ,IAA4B,uBAAU,CAAEL,YAAZ,CAAlC;;AACA,QAAMM,YAAY,GAAG,MAAMD,WAAW,CAAE,CAAED,QAAJ,CAAtC;;AAEA,QAAMG,cAAc,GAAKC,SAAF,IAA0B;AAChD,QAAK,CAAEA,SAAP,EAAmB;AAClB,aAAOX,QAAQ,CAAEY,SAAF,CAAf;AACA,KAH+C,CAKhD;;;AACA,QAAK,CAAET,YAAF,IAAkB,6BAAkBQ,SAAlB,CAAvB,EAAuD;AACtD,aAAOX,QAAQ,CACd,0BAAeW,SAAf,IAA6BC,SAA7B,GAAyCD,SAD3B,CAAf;AAGA,KAV+C,CAYhD;AACA;AACA;AACA;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,CAACC,gBAAT,EAA2B1B,SAA3B,CAAT;AACA,GAFe,EAEb,CAAEA,SAAF,CAFa,CAAhB;AAIA,QAAM2B,sBAAsB,GAAG,sBAAS,MAAM;AAC7C,WAAOJ,EAAE,CAAEE,MAAM,CAACG,mBAAT,CAAT;AACA,GAF8B,EAE5B,EAF4B,CAA/B;AAIA,SAAO,EACN,GAAGzB,UADG;AAENH,IAAAA,SAAS,EAAEwB,OAFL;AAGNK,IAAAA,eAAe,EAAEzB,YAHX;AAINI,IAAAA,QAJM;AAKNmB,IAAAA,sBALM;AAMNhB,IAAAA,cANM;AAONU,IAAAA,aAPM;AAQNX,IAAAA,YARM;AASNJ,IAAAA,WATM;AAUNC,IAAAA;AAVM,GAAP;AAYA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useMemo, useState } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport * as styles from '../styles';\nimport {\n\tgetBorderDiff,\n\tgetCommonBorder,\n\tgetSplitBorders,\n\thasMixedBorders,\n\thasSplitBorders,\n\tisCompleteBorder,\n\tisEmptyBorder,\n} from '../utils';\nimport { useContextSystem, WordPressComponentProps } from '../../ui/context';\nimport { useCx } from '../../utils/hooks/use-cx';\n\nimport type { Border } from '../../border-control/types';\nimport type { Borders, BorderSide, BorderBoxControlProps } from '../types';\n\nexport function useBorderBoxControl(\n\tprops: WordPressComponentProps< BorderBoxControlProps, 'div' >\n) {\n\tconst { className, onChange, value, ...otherProps } = useContextSystem(\n\t\tprops,\n\t\t'BorderBoxControl'\n\t);\n\n\tconst mixedBorders = hasMixedBorders( value );\n\tconst splitBorders = hasSplitBorders( value );\n\n\tconst linkedValue = splitBorders\n\t\t? getCommonBorder( value as Borders | undefined )\n\t\t: ( value as Border );\n\n\tconst splitValue = splitBorders\n\t\t? ( value as Borders )\n\t\t: getSplitBorders( value as Border | undefined );\n\n\tconst [ isLinked, setIsLinked ] = useState( ! mixedBorders );\n\tconst toggleLinked = () => setIsLinked( ! isLinked );\n\n\tconst onLinkedChange = ( newBorder?: Border ) => {\n\t\tif ( ! newBorder ) {\n\t\t\treturn onChange( undefined );\n\t\t}\n\n\t\t// If we have all props defined on the new border apply it.\n\t\tif ( ! mixedBorders || isCompleteBorder( newBorder ) ) {\n\t\t\treturn onChange(\n\t\t\t\tisEmptyBorder( newBorder ) ? undefined : newBorder\n\t\t\t);\n\t\t}\n\n\t\t// If we had mixed borders we might have had some shared border props\n\t\t// that we need to maintain. For example; we could have mixed borders\n\t\t// with all the same color but different widths. Then from the linked\n\t\t// control we change the color. We should keep the separate widths.\n\t\tconst changes = getBorderDiff(\n\t\t\tlinkedValue as Border,\n\t\t\tnewBorder as Border\n\t\t);\n\t\tconst updatedBorders = {\n\t\t\ttop: { ...( value as Borders )?.top, ...changes },\n\t\t\tright: { ...( value as Borders )?.right, ...changes },\n\t\t\tbottom: { ...( value as Borders )?.bottom, ...changes },\n\t\t\tleft: { ...( value as Borders )?.left, ...changes },\n\t\t};\n\n\t\tif ( hasMixedBorders( updatedBorders ) ) {\n\t\t\treturn onChange( updatedBorders );\n\t\t}\n\n\t\tconst filteredResult = isEmptyBorder( updatedBorders.top )\n\t\t\t? undefined\n\t\t\t: updatedBorders.top;\n\n\t\tonChange( filteredResult );\n\t};\n\n\tconst onSplitChange = (\n\t\tnewBorder: Border | undefined,\n\t\tside: BorderSide\n\t) => {\n\t\tconst updatedBorders = { ...splitValue, [ side ]: newBorder };\n\n\t\tif ( hasMixedBorders( updatedBorders ) ) {\n\t\t\tonChange( updatedBorders );\n\t\t} else {\n\t\t\tonChange( newBorder );\n\t\t}\n\t};\n\n\tconst cx = useCx();\n\tconst classes = useMemo( () => {\n\t\treturn cx( styles.BorderBoxControl, className );\n\t}, [ className ] );\n\n\tconst linkedControlClassName = useMemo( () => {\n\t\treturn cx( styles.LinkedBorderControl );\n\t}, [] );\n\n\treturn {\n\t\t...otherProps,\n\t\tclassName: classes,\n\t\thasMixedBorders: mixedBorders,\n\t\tisLinked,\n\t\tlinkedControlClassName,\n\t\tonLinkedChange,\n\t\tonSplitChange,\n\t\ttoggleLinked,\n\t\tlinkedValue,\n\t\tsplitValue,\n\t};\n}\n"]}
1
+ {"version":3,"sources":["@wordpress/components/src/border-box-control/border-box-control/hook.ts"],"names":["useBorderBoxControl","props","className","onChange","value","otherProps","mixedBorders","splitBorders","linkedValue","splitValue","isLinked","setIsLinked","toggleLinked","onLinkedChange","newBorder","undefined","changes","updatedBorders","top","right","bottom","left","filteredResult","onSplitChange","side","cx","classes","styles","BorderBoxControl","linkedControlClassName","LinkedBorderControl","hasMixedBorders"],"mappings":";;;;;;;AAGA;;AAKA;;AACA;;AASA;;AACA;;;;;;AAnBA;AACA;AACA;;AAGA;AACA;AACA;AAiBO,SAASA,mBAAT,CACNC,KADM,EAEL;AACD,QAAM;AAAEC,IAAAA,SAAF;AAAaC,IAAAA,QAAb;AAAuBC,IAAAA,KAAvB;AAA8B,OAAGC;AAAjC,MAAgD,+BACrDJ,KADqD,EAErD,kBAFqD,CAAtD;AAKA,QAAMK,YAAY,GAAG,4BAAiBF,KAAjB,CAArB;AACA,QAAMG,YAAY,GAAG,4BAAiBH,KAAjB,CAArB;AAEA,QAAMI,WAAW,GAAGD,YAAY,GAC7B,4BAAiBH,KAAjB,CAD6B,GAE3BA,KAFL;AAIA,QAAMK,UAAU,GAAGF,YAAY,GAC1BH,KAD0B,GAE5B,4BAAiBA,KAAjB,CAFH;AAIA,QAAM,CAAEM,QAAF,EAAYC,WAAZ,IAA4B,uBAAU,CAAEL,YAAZ,CAAlC;;AACA,QAAMM,YAAY,GAAG,MAAMD,WAAW,CAAE,CAAED,QAAJ,CAAtC;;AAEA,QAAMG,cAAc,GAAKC,SAAF,IAA0B;AAChD,QAAK,CAAEA,SAAP,EAAmB;AAClB,aAAOX,QAAQ,CAAEY,SAAF,CAAf;AACA,KAH+C,CAKhD;;;AACA,QAAK,CAAET,YAAF,IAAkB,6BAAkBQ,SAAlB,CAAvB,EAAuD;AACtD,aAAOX,QAAQ,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W,EAAE,GAAG,mBAAX;AACA,QAAMC,OAAO,GAAG,sBAAS,MAAM;AAC9B,WAAOD,EAAE,CAAEE,MAAM,CAACC,gBAAT,EAA2B1B,SAA3B,CAAT;AACA,GAFe,EAEb,CAAEuB,EAAF,EAAMvB,SAAN,CAFa,CAAhB;AAIA,QAAM2B,sBAAsB,GAAG,sBAAS,MAAM;AAC7C,WAAOJ,EAAE,CAAEE,MAAM,CAACG,mBAAT,CAAT;AACA,GAF8B,EAE5B,CAAEL,EAAF,CAF4B,CAA/B;AAIA,SAAO,EACN,GAAGpB,UADG;AAENH,IAAAA,SAAS,EAAEwB,OAFL;AAGNK,IAAAA,eAAe,EAAEzB,YAHX;AAINI,IAAAA,QAJM;AAKNmB,IAAAA,sBALM;AAMNhB,IAAAA,cANM;AAONU,IAAAA,aAPM;AAQNX,IAAAA,YARM;AASNJ,IAAAA,WATM;AAUNC,IAAAA;AAVM,GAAP;AAYA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useMemo, useState } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport * as styles from '../styles';\nimport {\n\tgetBorderDiff,\n\tgetCommonBorder,\n\tgetSplitBorders,\n\thasMixedBorders,\n\thasSplitBorders,\n\tisCompleteBorder,\n\tisEmptyBorder,\n} from '../utils';\nimport { useContextSystem, WordPressComponentProps } from '../../ui/context';\nimport { useCx } from '../../utils/hooks/use-cx';\n\nimport type { Border } from '../../border-control/types';\nimport type { Borders, BorderSide, BorderBoxControlProps } from '../types';\n\nexport function useBorderBoxControl(\n\tprops: WordPressComponentProps< BorderBoxControlProps, 'div' >\n) {\n\tconst { className, onChange, value, ...otherProps } = useContextSystem(\n\t\tprops,\n\t\t'BorderBoxControl'\n\t);\n\n\tconst mixedBorders = hasMixedBorders( value );\n\tconst splitBorders = hasSplitBorders( value );\n\n\tconst linkedValue = splitBorders\n\t\t? getCommonBorder( value as Borders | undefined )\n\t\t: ( value as Border );\n\n\tconst splitValue = splitBorders\n\t\t? ( value as Borders )\n\t\t: getSplitBorders( value as Border | undefined );\n\n\tconst [ isLinked, setIsLinked ] = useState( ! mixedBorders );\n\tconst toggleLinked = () => setIsLinked( ! isLinked );\n\n\tconst onLinkedChange = ( newBorder?: Border ) => {\n\t\tif ( ! newBorder ) {\n\t\t\treturn onChange( undefined );\n\t\t}\n\n\t\t// If we have all props defined on the new border apply it.\n\t\tif ( ! mixedBorders || isCompleteBorder( newBorder ) ) {\n\t\t\treturn onChange(\n\t\t\t\tisEmptyBorder( newBorder ) ? undefined : newBorder\n\t\t\t);\n\t\t}\n\n\t\t// If we had mixed borders we might have had some shared border props\n\t\t// that we need to maintain. For example; we could have mixed borders\n\t\t// with all the same color but different widths. Then from the linked\n\t\t// control we change the color. We should keep the separate widths.\n\t\tconst changes = getBorderDiff(\n\t\t\tlinkedValue as Border,\n\t\t\tnewBorder as Border\n\t\t);\n\t\tconst updatedBorders = {\n\t\t\ttop: { ...( value as Borders )?.top, ...changes },\n\t\t\tright: { ...( value as Borders )?.right, ...changes },\n\t\t\tbottom: { ...( value as Borders )?.bottom, ...changes },\n\t\t\tleft: { ...( value as Borders )?.left, ...changes },\n\t\t};\n\n\t\tif ( hasMixedBorders( updatedBorders ) ) {\n\t\t\treturn onChange( updatedBorders );\n\t\t}\n\n\t\tconst filteredResult = isEmptyBorder( updatedBorders.top )\n\t\t\t? undefined\n\t\t\t: updatedBorders.top;\n\n\t\tonChange( filteredResult );\n\t};\n\n\tconst onSplitChange = (\n\t\tnewBorder: Border | undefined,\n\t\tside: BorderSide\n\t) => {\n\t\tconst updatedBorders = { ...splitValue, [ side ]: newBorder };\n\n\t\tif ( hasMixedBorders( updatedBorders ) ) {\n\t\t\tonChange( updatedBorders );\n\t\t} else {\n\t\t\tonChange( newBorder );\n\t\t}\n\t};\n\n\tconst cx = useCx();\n\tconst classes = useMemo( () => {\n\t\treturn cx( styles.BorderBoxControl, className );\n\t}, [ cx, className ] );\n\n\tconst linkedControlClassName = useMemo( () => {\n\t\treturn cx( styles.LinkedBorderControl );\n\t}, [ cx ] );\n\n\treturn {\n\t\t...otherProps,\n\t\tclassName: classes,\n\t\thasMixedBorders: mixedBorders,\n\t\tisLinked,\n\t\tlinkedControlClassName,\n\t\tonLinkedChange,\n\t\tonSplitChange,\n\t\ttoggleLinked,\n\t\tlinkedValue,\n\t\tsplitValue,\n\t};\n}\n"]}
@@ -42,6 +42,7 @@ const BorderBoxControlSplitControls = (props, forwardedRef) => {
42
42
  onChange,
43
43
  popoverPlacement,
44
44
  popoverOffset,
45
+ rightAlignedClassName,
45
46
  value,
46
47
  __experimentalHasMultipleOrigins,
47
48
  __experimentalIsRenderedInSidebar,
@@ -85,6 +86,7 @@ const BorderBoxControlSplitControls = (props, forwardedRef) => {
85
86
  __unstablePopoverProps: popoverProps,
86
87
  value: value === null || value === void 0 ? void 0 : value.left
87
88
  }, sharedBorderControlProps)), (0, _element.createElement)(_borderControl.BorderControl, (0, _extends2.default)({
89
+ className: rightAlignedClassName,
88
90
  hideLabelFromVision: true,
89
91
  label: (0, _i18n.__)('Right border'),
90
92
  onChange: newBorder => onChange(newBorder, 'right'),
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/components/src/border-box-control/border-box-control-split-controls/component.tsx"],"names":["BorderBoxControlSplitControls","props","forwardedRef","centeredClassName","colors","disableCustomColors","enableAlpha","enableStyle","onChange","popoverPlacement","popoverOffset","value","__experimentalHasMultipleOrigins","__experimentalIsRenderedInSidebar","__next36pxDefaultSize","otherProps","containerRef","mergedRef","popoverProps","placement","offset","anchorRef","undefined","sharedBorderControlProps","isCompact","newBorder","top","left","right","bottom","ConnectedBorderBoxControlSplitControls"],"mappings":";;;;;;;;;AAIA;;;;AADA;;AAEA;;AAKA;;AACA;;AACA;;AACA;;AACA;;AAdA;AACA;AACA;;AAKA;AACA;AACA;AASA,MAAMA,6BAA6B,GAAG,CACrCC,KADqC,EAErCC,YAFqC,KAGjC;AACJ,QAAM;AACLC,IAAAA,iBADK;AAELC,IAAAA,M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AH,uBAAGA,KAAK,CAAEe;AANhB,KAOMH,wBAPN,EALD,EAcC,4BAAC,4BAAD;AACC,IAAA,mBAAmB,EAAG,IADvB;AAEC,IAAA,KAAK,EAAG,cAAI,aAAJ,CAFT;AAGC,IAAA,QAAQ,EAAKE,SAAF,IAAiBjB,QAAQ,CAAEiB,SAAF,EAAa,MAAb,CAHrC;AAIC,IAAA,sBAAsB,EAAGP,YAJ1B;AAKC,IAAA,KAAK,EAAGP,KAAH,aAAGA,KAAH,uBAAGA,KAAK,CAAEgB;AALhB,KAMMJ,wBANN,EAdD,EAsBC,4BAAC,4BAAD;AACC,IAAA,mBAAmB,EAAG,IADvB;AAEC,IAAA,KAAK,EAAG,cAAI,cAAJ,CAFT;AAGC,IAAA,QAAQ,EAAKE,SAAF,IAAiBjB,QAAQ,CAAEiB,SAAF,EAAa,OAAb,CAHrC;AAIC,IAAA,sBAAsB,EAAGP,YAJ1B;AAKC,IAAA,KAAK,EAAGP,KAAH,aAAGA,KAAH,uBAAGA,KAAK,CAAEiB;AALhB,KAMML,wBANN,EAtBD,EA8BC,4BAAC,4BAAD;AACC,IAAA,SAAS,EAAGpB,iBADb;AAEC,IAAA,mBAAmB,EAAG,IAFvB;AAGC,IAAA,KAAK,EAAG,cAAI,eAAJ,CAHT;AAIC,IAAA,QAAQ,EAAKsB,SAAF,IAAiBjB,QAAQ,CAAEiB,SAAF,EAAa,QAAb,CAJrC;AAKC,IAAA,sBAAsB,EAAGP,YAL1B;AAMC,IAAA,KAAK,EAAGP,KAAH,aAAGA,KAAH,uBAAGA,KAAK,CAAEkB;AANhB,KAOMN,wBAPN,EA9BD,CADD;AA0CA,CAlFD;;AAoFA,MAAMO,sCAAsC,GAAG,6BAC9C9B,6BAD8C,EAE9C,+BAF8C,CAA/C;eAIe8B,sC","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { useRef } from '@wordpress/element';\nimport { useMergeRefs } from '@wordpress/compose';\n\n/**\n * Internal dependencies\n */\nimport BorderBoxControlVisualizer from '../border-box-control-visualizer';\nimport { BorderControl } from '../../border-control';\nimport { Grid } from '../../grid';\nimport { contextConnect, WordPressComponentProps } from '../../ui/context';\nimport { useBorderBoxControlSplitControls } from './hook';\n\nimport type { SplitControlsProps } from '../types';\n\nconst BorderBoxControlSplitControls = (\n\tprops: WordPressComponentProps< SplitControlsProps, 'div' >,\n\tforwardedRef: React.ForwardedRef< any >\n) => {\n\tconst {\n\t\tcenteredClassName,\n\t\tcolors,\n\t\tdisableCustomColors,\n\t\tenableAlpha,\n\t\tenableStyle,\n\t\tonChange,\n\t\tpopoverPlacement,\n\t\tpopoverOffset,\n\t\tvalue,\n\t\t__experimentalHasMultipleOrigins,\n\t\t__experimentalIsRenderedInSidebar,\n\t\t__next36pxDefaultSize,\n\t\t...otherProps\n\t} = useBorderBoxControlSplitControls( props );\n\tconst containerRef = useRef();\n\tconst mergedRef = useMergeRefs( [ containerRef, forwardedRef ] );\n\tconst popoverProps = popoverPlacement\n\t\t? {\n\t\t\t\tplacement: popoverPlacement,\n\t\t\t\toffset: popoverOffset,\n\t\t\t\tanchorRef: containerRef,\n\t\t }\n\t\t: undefined;\n\n\tconst sharedBorderControlProps = {\n\t\tcolors,\n\t\tdisableCustomColors,\n\t\tenableAlpha,\n\t\tenableStyle,\n\t\tisCompact: true,\n\t\t__experimentalHasMultipleOrigins,\n\t\t__experimentalIsRenderedInSidebar,\n\t\t__next36pxDefaultSize,\n\t};\n\n\treturn (\n\t\t<Grid { ...otherProps } ref={ mergedRef } gap={ 4 }>\n\t\t\t<BorderBoxControlVisualizer\n\t\t\t\tvalue={ value }\n\t\t\t\t__next36pxDefaultSize={ __next36pxDefaultSize }\n\t\t\t/>\n\t\t\t<BorderControl\n\t\t\t\tclassName={ centeredClassName }\n\t\t\t\thideLabelFromVision={ true }\n\t\t\t\tlabel={ __( 'Top border' ) }\n\t\t\t\tonChange={ ( newBorder ) => onChange( newBorder, 'top' ) }\n\t\t\t\t__unstablePopoverProps={ popoverProps }\n\t\t\t\tvalue={ value?.top }\n\t\t\t\t{ ...sharedBorderControlProps }\n\t\t\t/>\n\t\t\t<BorderControl\n\t\t\t\thideLabelFromVision={ true }\n\t\t\t\tlabel={ __( 'Left border' ) }\n\t\t\t\tonChange={ ( newBorder ) => onChange( newBorder, 'left' ) }\n\t\t\t\t__unstablePopoverProps={ popoverProps }\n\t\t\t\tvalue={ value?.left }\n\t\t\t\t{ ...sharedBorderControlProps }\n\t\t\t/>\n\t\t\t<BorderControl\n\t\t\t\thideLabelFromVision={ true }\n\t\t\t\tlabel={ __( 'Right border' ) }\n\t\t\t\tonChange={ ( newBorder ) => onChange( newBorder, 'right' ) }\n\t\t\t\t__unstablePopoverProps={ popoverProps }\n\t\t\t\tvalue={ value?.right }\n\t\t\t\t{ ...sharedBorderControlProps }\n\t\t\t/>\n\t\t\t<BorderControl\n\t\t\t\tclassName={ centeredClassName }\n\t\t\t\thideLabelFromVision={ true }\n\t\t\t\tlabel={ __( 'Bottom border' ) }\n\t\t\t\tonChange={ ( newBorder ) => onChange( newBorder, 'bottom' ) }\n\t\t\t\t__unstablePopoverProps={ popoverProps }\n\t\t\t\tvalue={ value?.bottom }\n\t\t\t\t{ ...sharedBorderControlProps }\n\t\t\t/>\n\t\t</Grid>\n\t);\n};\n\nconst ConnectedBorderBoxControlSplitControls = contextConnect(\n\tBorderBoxControlSplitControls,\n\t'BorderBoxControlSplitControls'\n);\nexport default ConnectedBorderBoxControlSplitControls;\n"]}
1
+ {"version":3,"sources":["@wordpress/components/src/border-box-control/border-box-control-split-controls/component.tsx"],"names":["BorderBoxControlSplitControls","props","forwardedRef","centeredClassName","colors","disableCustomColors","enableAlpha","enableStyle","onChange","popoverPlacement","popoverOffset","rightAlignedClassName","value","__experimentalHasMultipleOrigins","__experimentalIsRenderedInSidebar","__next36pxDefaultSize","otherProps","containerRef","mergedRef","popoverProps","placement","offset","anchorRef","undefined","sharedBorderControlProps","isCompact","newBorder","top","left","right","b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AGP,KAAH,aAAGA,KAAH,uBAAGA,KAAK,CAAEkB;AANhB,KAOMN,wBAPN,EA/BD,CADD;AA2CA,CApFD;;AAsFA,MAAMO,sCAAsC,GAAG,6BAC9C/B,6BAD8C,EAE9C,+BAF8C,CAA/C;eAIe+B,sC","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { useRef } from '@wordpress/element';\nimport { useMergeRefs } from '@wordpress/compose';\n\n/**\n * Internal dependencies\n */\nimport BorderBoxControlVisualizer from '../border-box-control-visualizer';\nimport { BorderControl } from '../../border-control';\nimport { Grid } from '../../grid';\nimport { contextConnect, WordPressComponentProps } from '../../ui/context';\nimport { useBorderBoxControlSplitControls } from './hook';\n\nimport type { SplitControlsProps } from '../types';\n\nconst BorderBoxControlSplitControls = (\n\tprops: WordPressComponentProps< SplitControlsProps, 'div' >,\n\tforwardedRef: React.ForwardedRef< any >\n) => {\n\tconst {\n\t\tcenteredClassName,\n\t\tcolors,\n\t\tdisableCustomColors,\n\t\tenableAlpha,\n\t\tenableStyle,\n\t\tonChange,\n\t\tpopoverPlacement,\n\t\tpopoverOffset,\n\t\trightAlignedClassName,\n\t\tvalue,\n\t\t__experimentalHasMultipleOrigins,\n\t\t__experimentalIsRenderedInSidebar,\n\t\t__next36pxDefaultSize,\n\t\t...otherProps\n\t} = useBorderBoxControlSplitControls( props );\n\tconst containerRef = useRef();\n\tconst mergedRef = useMergeRefs( [ containerRef, forwardedRef ] );\n\tconst popoverProps = popoverPlacement\n\t\t? {\n\t\t\t\tplacement: popoverPlacement,\n\t\t\t\toffset: popoverOffset,\n\t\t\t\tanchorRef: containerRef,\n\t\t }\n\t\t: undefined;\n\n\tconst sharedBorderControlProps = {\n\t\tcolors,\n\t\tdisableCustomColors,\n\t\tenableAlpha,\n\t\tenableStyle,\n\t\tisCompact: true,\n\t\t__experimentalHasMultipleOrigins,\n\t\t__experimentalIsRenderedInSidebar,\n\t\t__next36pxDefaultSize,\n\t};\n\n\treturn (\n\t\t<Grid { ...otherProps } ref={ mergedRef } gap={ 4 }>\n\t\t\t<BorderBoxControlVisualizer\n\t\t\t\tvalue={ value }\n\t\t\t\t__next36pxDefaultSize={ __next36pxDefaultSize }\n\t\t\t/>\n\t\t\t<BorderControl\n\t\t\t\tclassName={ centeredClassName }\n\t\t\t\thideLabelFromVision={ true }\n\t\t\t\tlabel={ __( 'Top border' ) }\n\t\t\t\tonChange={ ( newBorder ) => onChange( newBorder, 'top' ) }\n\t\t\t\t__unstablePopoverProps={ popoverProps }\n\t\t\t\tvalue={ value?.top }\n\t\t\t\t{ ...sharedBorderControlProps }\n\t\t\t/>\n\t\t\t<BorderControl\n\t\t\t\thideLabelFromVision={ true }\n\t\t\t\tlabel={ __( 'Left border' ) }\n\t\t\t\tonChange={ ( newBorder ) => onChange( newBorder, 'left' ) }\n\t\t\t\t__unstablePopoverProps={ popoverProps }\n\t\t\t\tvalue={ value?.left }\n\t\t\t\t{ ...sharedBorderControlProps }\n\t\t\t/>\n\t\t\t<BorderControl\n\t\t\t\tclassName={ rightAlignedClassName }\n\t\t\t\thideLabelFromVision={ true }\n\t\t\t\tlabel={ __( 'Right border' ) }\n\t\t\t\tonChange={ ( newBorder ) => onChange( newBorder, 'right' ) }\n\t\t\t\t__unstablePopoverProps={ popoverProps }\n\t\t\t\tvalue={ value?.right }\n\t\t\t\t{ ...sharedBorderControlProps }\n\t\t\t/>\n\t\t\t<BorderControl\n\t\t\t\tclassName={ centeredClassName }\n\t\t\t\thideLabelFromVision={ true }\n\t\t\t\tlabel={ __( 'Bottom border' ) }\n\t\t\t\tonChange={ ( newBorder ) => onChange( newBorder, 'bottom' ) }\n\t\t\t\t__unstablePopoverProps={ popoverProps }\n\t\t\t\tvalue={ value?.bottom }\n\t\t\t\t{ ...sharedBorderControlProps }\n\t\t\t/>\n\t\t</Grid>\n\t);\n};\n\nconst ConnectedBorderBoxControlSplitControls = contextConnect(\n\tBorderBoxControlSplitControls,\n\t'BorderBoxControlSplitControls'\n);\nexport default ConnectedBorderBoxControlSplitControls;\n"]}
@@ -31,15 +31,24 @@ function useBorderBoxControlSplitControls(props) {
31
31
  } = (0, _context.useContextSystem)(props, 'BorderBoxControlSplitControls'); // Generate class names.
32
32
 
33
33
  const cx = (0, _utils.useCx)();
34
+
35
+ const rtlWatchResult = _utils.rtl.watch();
36
+
34
37
  const classes = (0, _element.useMemo)(() => {
35
- return cx(styles.BorderBoxControlSplitControls, className);
36
- }, [className, _utils.rtl.watch()]);
38
+ return cx(styles.borderBoxControlSplitControls(), className); // rtlWatchResult is needed to refresh styles when the writing direction changes
39
+ // eslint-disable-next-line react-hooks/exhaustive-deps
40
+ }, [cx, className, rtlWatchResult]);
37
41
  const centeredClassName = (0, _element.useMemo)(() => {
38
42
  return cx(styles.CenteredBorderControl, className);
39
- }, []);
43
+ }, [cx, className]);
44
+ const rightAlignedClassName = (0, _element.useMemo)(() => {
45
+ return cx(styles.rightBorderControl(), className); // rtlWatchResult is needed to refresh styles when the writing direction changes
46
+ // eslint-disable-next-line react-hooks/exhaustive-deps
47
+ }, [cx, className, rtlWatchResult]);
40
48
  return { ...otherProps,
41
49
  centeredClassName,
42
- className: classes
50
+ className: classes,
51
+ rightAlignedClassName
43
52
  };
44
53
  }
45
54
  //# sourceMappingURL=hook.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/components/src/border-box-control/border-box-control-split-controls/hook.ts"],"names":["useBorderBoxControlSplitControls","props","className","otherProps","cx","classes","styles","BorderBoxControlSplitControls","rtl","watch","centeredClassName","CenteredBorderControl"],"mappings":";;;;;;;AAGA;;AAKA;;AACA;;AACA;;;;;;AAVA;AACA;AACA;;AAGA;AACA;AACA;AAOO,SAASA,gCAAT,CACNC,KADM,EAEL;AACD,QAAM;AAAEC,IAAAA,SAAF;AAAa,OAAGC;AAAhB,MAA+B,+BACpCF,KADoC,EAEpC,+BAFoC,CAArC,CADC,CAMD;;AACA,QAAMG,EAAE,GAAG,mBAAX;AACA,QAAMC,OAAO,GAAG,sBAAS,MAAM;AAC9B,WAAOD,EAAE,CAAEE,MAAM,CAACC,6BAAT,EAAwCL,SAAxC,CAAT;AACA,GAFe,EAEb,CAAEA,SAAF,EAAaM,WAAIC,KAAJ,EAAb,CAFa,CAAhB;AAIA,QAAMC,iBAAiB,GAAG,sBAAS,MAAM;AACxC,WAAON,EAAE,CAAEE,MAAM,CAACK,qBAAT,EAAgCT,SAAhC,CAAT;AACA,GAFyB,EAEvB,EAFuB,CAA1B;AAIA,SAAO,EAAE,GAAGC,UAAL;AAAiBO,IAAAA,iBAAjB;AAAoCR,IAAAA,SAAS,EAAEG;AAA/C,GAAP;AACA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useMemo } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport * as styles from '../styles';\nimport { useContextSystem, WordPressComponentProps } from '../../ui/context';\nimport { useCx, rtl } from '../../utils/';\n\nimport type { SplitControlsProps } from '../types';\n\nexport function useBorderBoxControlSplitControls(\n\tprops: WordPressComponentProps< SplitControlsProps, 'div' >\n) {\n\tconst { className, ...otherProps } = useContextSystem(\n\t\tprops,\n\t\t'BorderBoxControlSplitControls'\n\t);\n\n\t// Generate class names.\n\tconst cx = useCx();\n\tconst classes = useMemo( () => {\n\t\treturn cx( styles.BorderBoxControlSplitControls, className );\n\t}, [ className, rtl.watch() ] );\n\n\tconst centeredClassName = useMemo( () => {\n\t\treturn cx( styles.CenteredBorderControl, className );\n\t}, [] );\n\n\treturn { ...otherProps, centeredClassName, className: classes };\n}\n"]}
1
+ {"version":3,"sources":["@wordpress/components/src/border-box-control/border-box-control-split-controls/hook.ts"],"names":["useBorderBoxControlSplitControls","props","className","otherProps","cx","rtlWatchResult","rtl","watch","classes","styles","borderBoxControlSplitControls","centeredClassName","CenteredBorderControl","rightAlignedClassName","rightBorderControl"],"mappings":";;;;;;;AAGA;;AAKA;;AACA;;AACA;;;;;;AAVA;AACA;AACA;;AAGA;AACA;AACA;AAOO,SAASA,gCAAT,CACNC,KADM,EAEL;AACD,QAAM;AAAEC,IAAAA,SAAF;AAAa,OAAGC;AAAhB,MAA+B,+BACpCF,KADoC,EAEpC,+BAFoC,CAArC,CADC,CAMD;;AACA,QAAMG,EAAE,GAAG,mBAAX;;AACA,QAAMC,cAAc,GAAGC,WAAIC,KAAJ,EAAvB;;AACA,QAAMC,OAAO,GAAG,sBAAS,MAAM;AAC9B,WAAOJ,EAAE,CAAEK,MAAM,CAACC,6BAAP,EAAF,EAA0CR,SAA1C,CAAT,CAD8B,CAE9B;AACA;AACA,GAJe,EAIb,CAAEE,EAAF,EAAMF,SAAN,EAAiBG,cAAjB,CAJa,CAAhB;AAMA,QAAMM,iBAAiB,GAAG,sBAAS,MAAM;AACxC,WAAOP,EAAE,CAAEK,MAAM,CAACG,qBAAT,EAAgCV,SAAhC,CAAT;AACA,GAFyB,EAEvB,CAAEE,EAAF,EAAMF,SAAN,CAFuB,CAA1B;AAIA,QAAMW,qBAAqB,GAAG,sBAAS,MAAM;AAC5C,WAAOT,EAAE,CAAEK,MAAM,CAACK,kBAAP,EAAF,EAA+BZ,SAA/B,CAAT,CAD4C,CAE5C;AACA;AACA,GAJ6B,EAI3B,CAAEE,EAAF,EAAMF,SAAN,EAAiBG,cAAjB,CAJ2B,CAA9B;AAMA,SAAO,EACN,GAAGF,UADG;AAENQ,IAAAA,iBAFM;AAGNT,IAAAA,SAAS,EAAEM,OAHL;AAINK,IAAAA;AAJM,GAAP;AAMA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useMemo } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport * as styles from '../styles';\nimport { useContextSystem, WordPressComponentProps } from '../../ui/context';\nimport { useCx, rtl } from '../../utils/';\n\nimport type { SplitControlsProps } from '../types';\n\nexport function useBorderBoxControlSplitControls(\n\tprops: WordPressComponentProps< SplitControlsProps, 'div' >\n) {\n\tconst { className, ...otherProps } = useContextSystem(\n\t\tprops,\n\t\t'BorderBoxControlSplitControls'\n\t);\n\n\t// Generate class names.\n\tconst cx = useCx();\n\tconst rtlWatchResult = rtl.watch();\n\tconst classes = useMemo( () => {\n\t\treturn cx( styles.borderBoxControlSplitControls(), className );\n\t\t// rtlWatchResult is needed to refresh styles when the writing direction changes\n\t\t// eslint-disable-next-line react-hooks/exhaustive-deps\n\t}, [ cx, className, rtlWatchResult ] );\n\n\tconst centeredClassName = useMemo( () => {\n\t\treturn cx( styles.CenteredBorderControl, className );\n\t}, [ cx, className ] );\n\n\tconst rightAlignedClassName = useMemo( () => {\n\t\treturn cx( styles.rightBorderControl(), className );\n\t\t// rtlWatchResult is needed to refresh styles when the writing direction changes\n\t\t// eslint-disable-next-line react-hooks/exhaustive-deps\n\t}, [ cx, className, rtlWatchResult ] );\n\n\treturn {\n\t\t...otherProps,\n\t\tcenteredClassName,\n\t\tclassName: classes,\n\t\trightAlignedClassName,\n\t};\n}\n"]}
@@ -33,9 +33,13 @@ function useBorderBoxControlVisualizer(props) {
33
33
  } = (0, _context.useContextSystem)(props, 'BorderBoxControlVisualizer'); // Generate class names.
34
34
 
35
35
  const cx = (0, _utils.useCx)();
36
+
37
+ const rtlWatchResult = _utils.rtl.watch();
38
+
36
39
  const classes = (0, _element.useMemo)(() => {
37
- return cx(styles.BorderBoxControlVisualizer(value, __next36pxDefaultSize), className);
38
- }, [className, value, __next36pxDefaultSize, _utils.rtl.watch()]);
40
+ return cx(styles.borderBoxControlVisualizer(value, __next36pxDefaultSize), className); // rtlWatchResult is needed to refresh styles when the writing direction changes
41
+ // eslint-disable-next-line react-hooks/exhaustive-deps
42
+ }, [cx, className, value, __next36pxDefaultSize, rtlWatchResult]);
39
43
  return { ...otherProps,
40
44
  className: classes,
41
45
  value
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/components/src/border-box-control/border-box-control-visualizer/hook.ts"],"names":["useBorderBoxControlVisualizer","props","className","value","__next36pxDefaultSize","otherProps","cx","classes","styles","BorderBoxControlVisualizer","rtl","watch"],"mappings":";;;;;;;AAGA;;AAKA;;AACA;;AACA;;;;;;AAVA;AACA;AACA;;AAGA;AACA;AACA;AAOO,SAASA,6BAAT,CACNC,KADM,EAEL;AACD,QAAM;AACLC,IAAAA,SADK;AAELC,IAAAA,KAFK;AAGLC,IAAAA,qBAAqB,GAAG,KAHnB;AAIL,OAAGC;AAJE,MAKF,+BAAkBJ,KAAlB,EAAyB,4BAAzB,CALJ,CADC,CAQD;;AACA,QAAMK,EAAE,GAAG,mBAAX;AACA,QAAMC,OAAO,GAAG,sBAAS,MAAM;AAC9B,WAAOD,EAAE,CACRE,MAAM,CAACC,0BAAP,CAAmCN,KAAnC,EAA0CC,qBAA1C,CADQ,EAERF,SAFQ,CAAT;AAIA,GALe,EAKb,CAAEA,SAAF,EAAaC,KAAb,EAAoBC,qBAApB,EAA2CM,WAAIC,KAAJ,EAA3C,CALa,CAAhB;AAOA,SAAO,EAAE,GAAGN,UAAL;AAAiBH,IAAAA,SAAS,EAAEK,OAA5B;AAAqCJ,IAAAA;AAArC,GAAP;AACA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useMemo } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport * as styles from '../styles';\nimport { useContextSystem, WordPressComponentProps } from '../../ui/context';\nimport { useCx, rtl } from '../../utils';\n\nimport type { VisualizerProps } from '../types';\n\nexport function useBorderBoxControlVisualizer(\n\tprops: WordPressComponentProps< VisualizerProps, 'div' >\n) {\n\tconst {\n\t\tclassName,\n\t\tvalue,\n\t\t__next36pxDefaultSize = false,\n\t\t...otherProps\n\t} = useContextSystem( props, 'BorderBoxControlVisualizer' );\n\n\t// Generate class names.\n\tconst cx = useCx();\n\tconst classes = useMemo( () => {\n\t\treturn cx(\n\t\t\tstyles.BorderBoxControlVisualizer( value, __next36pxDefaultSize ),\n\t\t\tclassName\n\t\t);\n\t}, [ className, value, __next36pxDefaultSize, rtl.watch() ] );\n\n\treturn { ...otherProps, className: classes, value };\n}\n"]}
1
+ {"version":3,"sources":["@wordpress/components/src/border-box-control/border-box-control-visualizer/hook.ts"],"names":["useBorderBoxControlVisualizer","props","className","value","__next36pxDefaultSize","otherProps","cx","rtlWatchResult","rtl","watch","classes","styles","borderBoxControlVisualizer"],"mappings":";;;;;;;AAGA;;AAKA;;AACA;;AACA;;;;;;AAVA;AACA;AACA;;AAGA;AACA;AACA;AAOO,SAASA,6BAAT,CACNC,KADM,EAEL;AACD,QAAM;AACLC,IAAAA,SADK;AAELC,IAAAA,KAFK;AAGLC,IAAAA,qBAAqB,GAAG,KAHnB;AAIL,OAAGC;AAJE,MAKF,+BAAkBJ,KAAlB,EAAyB,4BAAzB,CALJ,CADC,CAQD;;AACA,QAAMK,EAAE,GAAG,mBAAX;;AACA,QAAMC,cAAc,GAAGC,WAAIC,KAAJ,EAAvB;;AACA,QAAMC,OAAO,GAAG,sBAAS,MAAM;AAC9B,WAAOJ,EAAE,CACRK,MAAM,CAACC,0BAAP,CAAmCT,KAAnC,EAA0CC,qBAA1C,CADQ,EAERF,SAFQ,CAAT,CAD8B,CAK9B;AACA;AACA,GAPe,EAOb,CAAEI,EAAF,EAAMJ,SAAN,EAAiBC,KAAjB,EAAwBC,qBAAxB,EAA+CG,cAA/C,CAPa,CAAhB;AASA,SAAO,EAAE,GAAGF,UAAL;AAAiBH,IAAAA,SAAS,EAAEQ,OAA5B;AAAqCP,IAAAA;AAArC,GAAP;AACA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useMemo } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport * as styles from '../styles';\nimport { useContextSystem, WordPressComponentProps } from '../../ui/context';\nimport { useCx, rtl } from '../../utils';\n\nimport type { VisualizerProps } from '../types';\n\nexport function useBorderBoxControlVisualizer(\n\tprops: WordPressComponentProps< VisualizerProps, 'div' >\n) {\n\tconst {\n\t\tclassName,\n\t\tvalue,\n\t\t__next36pxDefaultSize = false,\n\t\t...otherProps\n\t} = useContextSystem( props, 'BorderBoxControlVisualizer' );\n\n\t// Generate class names.\n\tconst cx = useCx();\n\tconst rtlWatchResult = rtl.watch();\n\tconst classes = useMemo( () => {\n\t\treturn cx(\n\t\t\tstyles.borderBoxControlVisualizer( value, __next36pxDefaultSize ),\n\t\t\tclassName\n\t\t);\n\t\t// rtlWatchResult is needed to refresh styles when the writing direction changes\n\t\t// eslint-disable-next-line react-hooks/exhaustive-deps\n\t}, [ cx, className, value, __next36pxDefaultSize, rtlWatchResult ] );\n\n\treturn { ...otherProps, className: classes, value };\n}\n"]}