@wordpress/components 23.1.0 → 23.3.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 (623) hide show
  1. package/CHANGELOG.md +53 -0
  2. package/CONTRIBUTING.md +1 -1
  3. package/LICENSE.md +1 -1
  4. package/build/alignment-matrix-control/utils.js +2 -2
  5. package/build/alignment-matrix-control/utils.js.map +1 -1
  6. package/build/autocomplete/autocompleter-ui.js +1 -3
  7. package/build/autocomplete/autocompleter-ui.js.map +1 -1
  8. package/build/border-box-control/border-box-control-linked-button/component.js.map +1 -1
  9. package/build/border-box-control/border-box-control-linked-button/hook.js.map +1 -1
  10. package/build/border-control/border-control-dropdown/component.js +8 -4
  11. package/build/border-control/border-control-dropdown/component.js.map +1 -1
  12. package/build/button/deprecated.js +8 -6
  13. package/build/button/deprecated.js.map +1 -1
  14. package/build/button/index.js +52 -23
  15. package/build/button/index.js.map +1 -1
  16. package/build/button/types.js +6 -0
  17. package/build/button/types.js.map +1 -0
  18. package/build/color-list-picker/index.js.map +1 -1
  19. package/build/color-list-picker/types.js +6 -0
  20. package/build/color-list-picker/types.js.map +1 -0
  21. package/build/color-palette/index.js +9 -61
  22. package/build/color-palette/index.js.map +1 -1
  23. package/build/color-palette/index.native.js +24 -9
  24. package/build/color-palette/index.native.js.map +1 -1
  25. package/build/color-palette/utils.js +103 -0
  26. package/build/color-palette/utils.js.map +1 -0
  27. package/build/color-picker/component.js +1 -0
  28. package/build/color-picker/component.js.map +1 -1
  29. package/build/color-picker/styles.js +8 -10
  30. package/build/color-picker/styles.js.map +1 -1
  31. package/build/combobox-control/index.js +5 -1
  32. package/build/combobox-control/index.js.map +1 -1
  33. package/build/custom-gradient-picker/gradient-bar/utils.js +1 -1
  34. package/build/custom-gradient-picker/gradient-bar/utils.js.map +1 -1
  35. package/build/date-time/date/index.js.map +1 -1
  36. package/build/dropdown/index.js +20 -8
  37. package/build/dropdown/index.js.map +1 -1
  38. package/build/focal-point-picker/utils.js +1 -1
  39. package/build/focal-point-picker/utils.js.map +1 -1
  40. package/build/form-token-field/token.js +1 -1
  41. package/build/form-token-field/token.js.map +1 -1
  42. package/build/gradient-picker/index.js +9 -1
  43. package/build/gradient-picker/index.js.map +1 -1
  44. package/build/h-stack/component.js +0 -1
  45. package/build/h-stack/component.js.map +1 -1
  46. package/build/index.js +7 -17
  47. package/build/index.js.map +1 -1
  48. package/build/index.native.js +8 -18
  49. package/build/index.native.js.map +1 -1
  50. package/build/input-control/input-field.js +4 -2
  51. package/build/input-control/input-field.js.map +1 -1
  52. package/build/item-group/item/component.js +27 -3
  53. package/build/item-group/item/component.js.map +1 -1
  54. package/build/item-group/item-group/component.js +26 -3
  55. package/build/item-group/item-group/component.js.map +1 -1
  56. package/build/item-group/styles.js +14 -14
  57. package/build/item-group/styles.js.map +1 -1
  58. package/build/keyboard-shortcuts/index.js +44 -16
  59. package/build/keyboard-shortcuts/index.js.map +1 -1
  60. package/build/keyboard-shortcuts/types.js +6 -0
  61. package/build/keyboard-shortcuts/types.js.map +1 -0
  62. package/build/modal/index.js +1 -1
  63. package/build/modal/index.js.map +1 -1
  64. package/build/notice/index.js +16 -18
  65. package/build/notice/index.js.map +1 -1
  66. package/build/notice/list.js +23 -8
  67. package/build/notice/list.js.map +1 -1
  68. package/build/notice/types.js +6 -0
  69. package/build/notice/types.js.map +1 -0
  70. package/build/number-control/index.js +1 -1
  71. package/build/number-control/index.js.map +1 -1
  72. package/build/panel/row.js +5 -3
  73. package/build/panel/row.js.map +1 -1
  74. package/build/query-controls/author-select.js +7 -3
  75. package/build/query-controls/author-select.js.map +1 -1
  76. package/build/query-controls/category-select.js +7 -3
  77. package/build/query-controls/category-select.js.map +1 -1
  78. package/build/query-controls/index.js +69 -20
  79. package/build/query-controls/index.js.map +1 -1
  80. package/build/query-controls/terms.js +4 -3
  81. package/build/query-controls/terms.js.map +1 -1
  82. package/build/query-controls/types.js +6 -0
  83. package/build/query-controls/types.js.map +1 -0
  84. package/build/resizable-box/index.js +5 -4
  85. package/build/resizable-box/index.js.map +1 -1
  86. package/build/responsive-wrapper/index.js +18 -1
  87. package/build/responsive-wrapper/index.js.map +1 -1
  88. package/build/responsive-wrapper/types.js +6 -0
  89. package/build/responsive-wrapper/types.js.map +1 -0
  90. package/build/sandbox/index.js +35 -24
  91. package/build/sandbox/index.js.map +1 -1
  92. package/build/sandbox/types.js +6 -0
  93. package/build/sandbox/types.js.map +1 -0
  94. package/build/slot-fill/bubbles-virtually/fill.js +1 -0
  95. package/build/slot-fill/bubbles-virtually/fill.js.map +1 -1
  96. package/build/slot-fill/slot.js +1 -0
  97. package/build/slot-fill/slot.js.map +1 -1
  98. package/build/slot-fill/use-slot.js +1 -11
  99. package/build/slot-fill/use-slot.js.map +1 -1
  100. package/build/snackbar/index.js.map +1 -1
  101. package/build/snackbar/list.js.map +1 -1
  102. package/build/tab-panel/index.js +40 -7
  103. package/build/tab-panel/index.js.map +1 -1
  104. package/build/toolbar/index.js +42 -60
  105. package/build/toolbar/index.js.map +1 -1
  106. package/build/toolbar/toolbar/index.js +74 -0
  107. package/build/toolbar/toolbar/index.js.map +1 -0
  108. package/build/toolbar/{toolbar-container.js → toolbar/toolbar-container.js} +0 -0
  109. package/build/toolbar/toolbar/toolbar-container.js.map +1 -0
  110. package/build/toolbar/{toolbar-container.native.js → toolbar/toolbar-container.native.js} +0 -0
  111. package/build/toolbar/toolbar/toolbar-container.native.js.map +1 -0
  112. package/build/{toolbar-button → toolbar/toolbar-button}/index.js +1 -1
  113. package/build/toolbar/toolbar-button/index.js.map +1 -0
  114. package/build/{toolbar-button → toolbar/toolbar-button}/toolbar-button-container.js +0 -0
  115. package/build/toolbar/toolbar-button/toolbar-button-container.js.map +1 -0
  116. package/build/{toolbar-button → toolbar/toolbar-button}/toolbar-button-container.native.js +0 -0
  117. package/build/toolbar/toolbar-button/toolbar-button-container.native.js.map +1 -0
  118. package/build/{toolbar-context → toolbar/toolbar-context}/index.js +0 -0
  119. package/build/toolbar/toolbar-context/index.js.map +1 -0
  120. package/build/{toolbar-dropdown-menu → toolbar/toolbar-dropdown-menu}/index.js +1 -1
  121. package/build/toolbar/toolbar-dropdown-menu/index.js.map +1 -0
  122. package/build/{toolbar-group → toolbar/toolbar-group}/index.js +0 -0
  123. package/build/toolbar/toolbar-group/index.js.map +1 -0
  124. package/build/{toolbar-group → toolbar/toolbar-group}/toolbar-group-collapsed.js +1 -1
  125. package/build/toolbar/toolbar-group/toolbar-group-collapsed.js.map +1 -0
  126. package/build/{toolbar-group → toolbar/toolbar-group}/toolbar-group-collapsed.native.js +1 -1
  127. package/build/toolbar/toolbar-group/toolbar-group-collapsed.native.js.map +1 -0
  128. package/build/{toolbar-group → toolbar/toolbar-group}/toolbar-group-container.js +0 -0
  129. package/build/toolbar/toolbar-group/toolbar-group-container.js.map +1 -0
  130. package/build/{toolbar-group → toolbar/toolbar-group}/toolbar-group-container.native.js +0 -0
  131. package/build/toolbar/toolbar-group/toolbar-group-container.native.js.map +1 -0
  132. package/build/{toolbar-item → toolbar/toolbar-item}/index.js +0 -0
  133. package/build/toolbar/toolbar-item/index.js.map +1 -0
  134. package/build/{toolbar-item → toolbar/toolbar-item}/index.native.js +0 -0
  135. package/build/toolbar/toolbar-item/index.native.js.map +1 -0
  136. package/build/tree-grid/index.js +4 -4
  137. package/build/tree-grid/index.js.map +1 -1
  138. package/build/tree-select/index.js +2 -6
  139. package/build/tree-select/index.js.map +1 -1
  140. package/build-module/alignment-matrix-control/utils.js +2 -2
  141. package/build-module/alignment-matrix-control/utils.js.map +1 -1
  142. package/build-module/autocomplete/autocompleter-ui.js +1 -2
  143. package/build-module/autocomplete/autocompleter-ui.js.map +1 -1
  144. package/build-module/border-box-control/border-box-control-linked-button/component.js.map +1 -1
  145. package/build-module/border-box-control/border-box-control-linked-button/hook.js.map +1 -1
  146. package/build-module/border-control/border-control-dropdown/component.js +7 -4
  147. package/build-module/border-control/border-control-dropdown/component.js.map +1 -1
  148. package/build-module/button/deprecated.js +8 -5
  149. package/build-module/button/deprecated.js.map +1 -1
  150. package/build-module/button/index.js +51 -22
  151. package/build-module/button/index.js.map +1 -1
  152. package/build-module/button/types.js +2 -0
  153. package/build-module/button/types.js.map +1 -0
  154. package/build-module/color-list-picker/index.js.map +1 -1
  155. package/build-module/color-list-picker/types.js +2 -0
  156. package/build-module/color-list-picker/types.js.map +1 -0
  157. package/build-module/color-palette/index.js +7 -54
  158. package/build-module/color-palette/index.js.map +1 -1
  159. package/build-module/color-palette/index.native.js +24 -8
  160. package/build-module/color-palette/index.native.js.map +1 -1
  161. package/build-module/color-palette/utils.js +79 -0
  162. package/build-module/color-palette/utils.js.map +1 -0
  163. package/build-module/color-picker/component.js +1 -0
  164. package/build-module/color-picker/component.js.map +1 -1
  165. package/build-module/color-picker/styles.js +8 -9
  166. package/build-module/color-picker/styles.js.map +1 -1
  167. package/build-module/combobox-control/index.js +5 -1
  168. package/build-module/combobox-control/index.js.map +1 -1
  169. package/build-module/custom-gradient-picker/gradient-bar/utils.js +1 -1
  170. package/build-module/custom-gradient-picker/gradient-bar/utils.js.map +1 -1
  171. package/build-module/date-time/date/index.js +1 -1
  172. package/build-module/date-time/date/index.js.map +1 -1
  173. package/build-module/dropdown/index.js +19 -8
  174. package/build-module/dropdown/index.js.map +1 -1
  175. package/build-module/focal-point-picker/utils.js +1 -1
  176. package/build-module/focal-point-picker/utils.js.map +1 -1
  177. package/build-module/form-token-field/token.js +1 -1
  178. package/build-module/form-token-field/token.js.map +1 -1
  179. package/build-module/gradient-picker/index.js +9 -2
  180. package/build-module/gradient-picker/index.js.map +1 -1
  181. package/build-module/h-stack/component.js +0 -1
  182. package/build-module/h-stack/component.js.map +1 -1
  183. package/build-module/index.js +1 -6
  184. package/build-module/index.js.map +1 -1
  185. package/build-module/index.native.js +1 -6
  186. package/build-module/index.native.js.map +1 -1
  187. package/build-module/input-control/input-field.js +4 -2
  188. package/build-module/input-control/input-field.js.map +1 -1
  189. package/build-module/item-group/item/component.js +26 -2
  190. package/build-module/item-group/item/component.js.map +1 -1
  191. package/build-module/item-group/item-group/component.js +25 -2
  192. package/build-module/item-group/item-group/component.js.map +1 -1
  193. package/build-module/item-group/styles.js +14 -14
  194. package/build-module/item-group/styles.js.map +1 -1
  195. package/build-module/keyboard-shortcuts/index.js +48 -16
  196. package/build-module/keyboard-shortcuts/index.js.map +1 -1
  197. package/build-module/keyboard-shortcuts/types.js +2 -0
  198. package/build-module/keyboard-shortcuts/types.js.map +1 -0
  199. package/build-module/modal/index.js +1 -1
  200. package/build-module/modal/index.js.map +1 -1
  201. package/build-module/notice/index.js +14 -15
  202. package/build-module/notice/index.js.map +1 -1
  203. package/build-module/notice/list.js +23 -8
  204. package/build-module/notice/list.js.map +1 -1
  205. package/build-module/notice/types.js +2 -0
  206. package/build-module/notice/types.js.map +1 -0
  207. package/build-module/number-control/index.js +1 -1
  208. package/build-module/number-control/index.js.map +1 -1
  209. package/build-module/panel/row.js +5 -3
  210. package/build-module/panel/row.js.map +1 -1
  211. package/build-module/query-controls/author-select.js +7 -3
  212. package/build-module/query-controls/author-select.js.map +1 -1
  213. package/build-module/query-controls/category-select.js +8 -4
  214. package/build-module/query-controls/category-select.js.map +1 -1
  215. package/build-module/query-controls/index.js +65 -20
  216. package/build-module/query-controls/index.js.map +1 -1
  217. package/build-module/query-controls/terms.js +8 -4
  218. package/build-module/query-controls/terms.js.map +1 -1
  219. package/build-module/query-controls/types.js +2 -0
  220. package/build-module/query-controls/types.js.map +1 -0
  221. package/build-module/resizable-box/index.js +3 -2
  222. package/build-module/resizable-box/index.js.map +1 -1
  223. package/build-module/responsive-wrapper/index.js +20 -1
  224. package/build-module/responsive-wrapper/index.js.map +1 -1
  225. package/build-module/responsive-wrapper/types.js +2 -0
  226. package/build-module/responsive-wrapper/types.js.map +1 -0
  227. package/build-module/sandbox/index.js +37 -23
  228. package/build-module/sandbox/index.js.map +1 -1
  229. package/build-module/sandbox/types.js +2 -0
  230. package/build-module/sandbox/types.js.map +1 -0
  231. package/build-module/slot-fill/bubbles-virtually/fill.js +1 -0
  232. package/build-module/slot-fill/bubbles-virtually/fill.js.map +1 -1
  233. package/build-module/slot-fill/slot.js +1 -0
  234. package/build-module/slot-fill/slot.js.map +1 -1
  235. package/build-module/slot-fill/use-slot.js +2 -12
  236. package/build-module/slot-fill/use-slot.js.map +1 -1
  237. package/build-module/snackbar/index.js.map +1 -1
  238. package/build-module/snackbar/list.js.map +1 -1
  239. package/build-module/tab-panel/index.js +40 -7
  240. package/build-module/tab-panel/index.js.map +1 -1
  241. package/build-module/toolbar/index.js +6 -58
  242. package/build-module/toolbar/index.js.map +1 -1
  243. package/build-module/toolbar/toolbar/index.js +59 -0
  244. package/build-module/toolbar/toolbar/index.js.map +1 -0
  245. package/build-module/toolbar/{toolbar-container.js → toolbar/toolbar-container.js} +0 -0
  246. package/{build → build-module/toolbar}/toolbar/toolbar-container.js.map +1 -1
  247. package/build-module/toolbar/{toolbar-container.native.js → toolbar/toolbar-container.native.js} +0 -0
  248. package/build-module/toolbar/toolbar/toolbar-container.native.js.map +1 -0
  249. package/build-module/{toolbar-button → toolbar/toolbar-button}/index.js +1 -1
  250. package/build-module/toolbar/toolbar-button/index.js.map +1 -0
  251. package/build-module/{toolbar-button → toolbar/toolbar-button}/toolbar-button-container.js +0 -0
  252. package/build-module/toolbar/toolbar-button/toolbar-button-container.js.map +1 -0
  253. package/build-module/{toolbar-button → toolbar/toolbar-button}/toolbar-button-container.native.js +0 -0
  254. package/build-module/toolbar/toolbar-button/toolbar-button-container.native.js.map +1 -0
  255. package/build-module/{toolbar-context → toolbar/toolbar-context}/index.js +0 -0
  256. package/build-module/toolbar/toolbar-context/index.js.map +1 -0
  257. package/build-module/{toolbar-dropdown-menu → toolbar/toolbar-dropdown-menu}/index.js +1 -1
  258. package/build-module/toolbar/toolbar-dropdown-menu/index.js.map +1 -0
  259. package/build-module/{toolbar-group → toolbar/toolbar-group}/index.js +0 -0
  260. package/build-module/toolbar/toolbar-group/index.js.map +1 -0
  261. package/build-module/{toolbar-group → toolbar/toolbar-group}/toolbar-group-collapsed.js +1 -1
  262. package/build-module/toolbar/toolbar-group/toolbar-group-collapsed.js.map +1 -0
  263. package/build-module/{toolbar-group → toolbar/toolbar-group}/toolbar-group-collapsed.native.js +1 -1
  264. package/build-module/toolbar/toolbar-group/toolbar-group-collapsed.native.js.map +1 -0
  265. package/build-module/{toolbar-group → toolbar/toolbar-group}/toolbar-group-container.js +0 -0
  266. package/build-module/toolbar/toolbar-group/toolbar-group-container.js.map +1 -0
  267. package/build-module/{toolbar-group → toolbar/toolbar-group}/toolbar-group-container.native.js +0 -0
  268. package/build-module/toolbar/toolbar-group/toolbar-group-container.native.js.map +1 -0
  269. package/build-module/{toolbar-item → toolbar/toolbar-item}/index.js +0 -0
  270. package/build-module/toolbar/toolbar-item/index.js.map +1 -0
  271. package/build-module/{toolbar-item → toolbar/toolbar-item}/index.native.js +0 -0
  272. package/build-module/toolbar/toolbar-item/index.native.js.map +1 -0
  273. package/build-module/tree-grid/index.js +4 -4
  274. package/build-module/tree-grid/index.js.map +1 -1
  275. package/build-module/tree-select/index.js +2 -6
  276. package/build-module/tree-select/index.js.map +1 -1
  277. package/build-style/style-rtl.css +6 -1
  278. package/build-style/style.css +6 -1
  279. package/build-types/border-box-control/border-box-control/hook.d.ts +1 -1
  280. package/build-types/border-box-control/border-box-control-linked-button/component.d.ts +1 -1
  281. package/build-types/border-box-control/border-box-control-linked-button/hook.d.ts +171 -160
  282. package/build-types/border-box-control/border-box-control-linked-button/hook.d.ts.map +1 -1
  283. package/build-types/border-box-control/border-box-control-split-controls/hook.d.ts +1 -1
  284. package/build-types/border-control/border-control/hook.d.ts +1 -1
  285. package/build-types/border-control/border-control-dropdown/component.d.ts.map +1 -1
  286. package/build-types/border-control/border-control-dropdown/hook.d.ts +1 -1
  287. package/build-types/button/deprecated.d.ts +143 -7
  288. package/build-types/button/deprecated.d.ts.map +1 -1
  289. package/build-types/button/index.d.ts +20 -3
  290. package/build-types/button/index.d.ts.map +1 -1
  291. package/build-types/button/stories/index.d.ts +20 -0
  292. package/build-types/button/stories/index.d.ts.map +1 -0
  293. package/build-types/button/test/index.d.ts +2 -0
  294. package/build-types/button/test/index.d.ts.map +1 -0
  295. package/build-types/button/types.d.ts +134 -0
  296. package/build-types/button/types.d.ts.map +1 -0
  297. package/build-types/color-list-picker/index.d.ts +5 -0
  298. package/build-types/color-list-picker/index.d.ts.map +1 -0
  299. package/build-types/color-list-picker/types.d.ts +42 -0
  300. package/build-types/color-list-picker/types.d.ts.map +1 -0
  301. package/build-types/color-palette/index.d.ts +2 -4
  302. package/build-types/color-palette/index.d.ts.map +1 -1
  303. package/build-types/color-palette/stories/index.d.ts +2 -2
  304. package/build-types/color-palette/styles.d.ts +1 -1
  305. package/build-types/color-palette/types.d.ts +1 -1
  306. package/build-types/color-palette/types.d.ts.map +1 -1
  307. package/build-types/color-palette/utils.d.ts +14 -0
  308. package/build-types/color-palette/utils.d.ts.map +1 -0
  309. package/build-types/color-picker/component.d.ts.map +1 -1
  310. package/build-types/color-picker/styles.d.ts +2 -2
  311. package/build-types/color-picker/styles.d.ts.map +1 -1
  312. package/build-types/dashicon/types.d.ts +0 -4
  313. package/build-types/dashicon/types.d.ts.map +1 -1
  314. package/build-types/date-time/date/index.d.ts.map +1 -1
  315. package/build-types/date-time/date/styles.d.ts +3 -3
  316. package/build-types/dropdown/index.d.ts +4 -4
  317. package/build-types/dropdown/index.d.ts.map +1 -1
  318. package/build-types/dropdown/stories/index.d.ts.map +1 -1
  319. package/build-types/dropdown/types.d.ts +9 -10
  320. package/build-types/dropdown/types.d.ts.map +1 -1
  321. package/build-types/focal-point-picker/utils.d.ts.map +1 -1
  322. package/build-types/font-size-picker/styles.d.ts +2 -2
  323. package/build-types/h-stack/component.d.ts +0 -1
  324. package/build-types/h-stack/component.d.ts.map +1 -1
  325. package/build-types/input-control/input-field.d.ts.map +1 -1
  326. package/build-types/item-group/item/component.d.ts +24 -2
  327. package/build-types/item-group/item/component.d.ts.map +1 -1
  328. package/build-types/item-group/item-group/component.d.ts +23 -2
  329. package/build-types/item-group/item-group/component.d.ts.map +1 -1
  330. package/build-types/item-group/stories/index.d.ts +15 -0
  331. package/build-types/item-group/stories/index.d.ts.map +1 -0
  332. package/build-types/item-group/styles.d.ts.map +1 -1
  333. package/build-types/keyboard-shortcuts/index.d.ts +38 -0
  334. package/build-types/keyboard-shortcuts/index.d.ts.map +1 -0
  335. package/build-types/keyboard-shortcuts/stories/index.d.ts +12 -0
  336. package/build-types/keyboard-shortcuts/stories/index.d.ts.map +1 -0
  337. package/build-types/keyboard-shortcuts/test/index.d.ts +2 -0
  338. package/build-types/keyboard-shortcuts/test/index.d.ts.map +1 -0
  339. package/build-types/keyboard-shortcuts/types.d.ts +48 -0
  340. package/build-types/keyboard-shortcuts/types.d.ts.map +1 -0
  341. package/build-types/modal/index.d.ts.map +1 -1
  342. package/build-types/navigator/navigator-back-button/component.d.ts +1 -1
  343. package/build-types/navigator/navigator-back-button/hook.d.ts +2 -2
  344. package/build-types/navigator/navigator-button/component.d.ts +1 -1
  345. package/build-types/navigator/navigator-button/hook.d.ts +2 -2
  346. package/build-types/notice/index.d.ts +16 -0
  347. package/build-types/notice/index.d.ts.map +1 -0
  348. package/build-types/notice/list.d.ts +32 -0
  349. package/build-types/notice/list.d.ts.map +1 -0
  350. package/build-types/notice/stories/index.d.ts +17 -0
  351. package/build-types/notice/stories/index.d.ts.map +1 -0
  352. package/build-types/notice/test/index.d.ts +2 -0
  353. package/build-types/notice/test/index.d.ts.map +1 -0
  354. package/build-types/notice/test/list.d.ts +2 -0
  355. package/build-types/notice/test/list.d.ts.map +1 -0
  356. package/build-types/notice/types.d.ts +128 -0
  357. package/build-types/notice/types.d.ts.map +1 -0
  358. package/build-types/number-control/styles/number-control-styles.d.ts +2 -2
  359. package/build-types/number-control/styles/number-control-styles.d.ts.map +1 -1
  360. package/build-types/placeholder/stories/index.d.ts.map +1 -1
  361. package/build-types/query-controls/author-select.d.ts +4 -0
  362. package/build-types/query-controls/author-select.d.ts.map +1 -0
  363. package/build-types/query-controls/category-select.d.ts +4 -0
  364. package/build-types/query-controls/category-select.d.ts.map +1 -0
  365. package/build-types/query-controls/index.d.ts +30 -0
  366. package/build-types/query-controls/index.d.ts.map +1 -0
  367. package/build-types/query-controls/stories/index.d.ts +13 -0
  368. package/build-types/query-controls/stories/index.d.ts.map +1 -0
  369. package/build-types/query-controls/terms.d.ts +13 -0
  370. package/build-types/query-controls/terms.d.ts.map +1 -0
  371. package/build-types/query-controls/test/terms.d.ts +2 -0
  372. package/build-types/query-controls/test/terms.d.ts.map +1 -0
  373. package/build-types/query-controls/types.d.ts +131 -0
  374. package/build-types/query-controls/types.d.ts.map +1 -0
  375. package/build-types/range-control/index.d.ts +1 -1
  376. package/build-types/resizable-box/index.d.ts +6 -7
  377. package/build-types/resizable-box/index.d.ts.map +1 -1
  378. package/build-types/resizable-box/stories/index.d.ts +61 -0
  379. package/build-types/resizable-box/stories/index.d.ts.map +1 -0
  380. package/build-types/responsive-wrapper/index.d.ts +24 -0
  381. package/build-types/responsive-wrapper/index.d.ts.map +1 -0
  382. package/build-types/responsive-wrapper/stories/index.d.ts +12 -0
  383. package/build-types/responsive-wrapper/stories/index.d.ts.map +1 -0
  384. package/build-types/responsive-wrapper/types.d.ts +22 -0
  385. package/build-types/responsive-wrapper/types.d.ts.map +1 -0
  386. package/build-types/sandbox/index.d.ts +19 -0
  387. package/build-types/sandbox/index.d.ts.map +1 -0
  388. package/build-types/sandbox/stories/index.d.ts +12 -0
  389. package/build-types/sandbox/stories/index.d.ts.map +1 -0
  390. package/build-types/sandbox/test/index.d.ts +2 -0
  391. package/build-types/sandbox/test/index.d.ts.map +1 -0
  392. package/build-types/sandbox/types.d.ts +36 -0
  393. package/build-types/sandbox/types.d.ts.map +1 -0
  394. package/build-types/slot-fill/bubbles-virtually/fill.d.ts.map +1 -1
  395. package/build-types/slot-fill/use-slot.d.ts.map +1 -1
  396. package/build-types/snackbar/index.d.ts +9 -2
  397. package/build-types/snackbar/index.d.ts.map +1 -1
  398. package/build-types/snackbar/list.d.ts.map +1 -1
  399. package/build-types/snackbar/types.d.ts +15 -88
  400. package/build-types/snackbar/types.d.ts.map +1 -1
  401. package/build-types/tab-panel/index.d.ts.map +1 -1
  402. package/build-types/tab-panel/stories/index.d.ts +1 -0
  403. package/build-types/tab-panel/stories/index.d.ts.map +1 -1
  404. package/build-types/tab-panel/types.d.ts +11 -5
  405. package/build-types/tab-panel/types.d.ts.map +1 -1
  406. package/build-types/toggle-group-control/stories/index.d.ts.map +1 -1
  407. package/build-types/tree-select/index.d.ts.map +1 -1
  408. package/build-types/ui/form-group/form-group.d.ts +2 -2
  409. package/package.json +18 -17
  410. package/src/alignment-matrix-control/utils.tsx +2 -2
  411. package/src/autocomplete/autocompleter-ui.js +1 -2
  412. package/src/autocomplete/test/index.js +1 -5
  413. package/src/border-box-control/border-box-control-linked-button/component.tsx +1 -1
  414. package/src/border-box-control/border-box-control-linked-button/hook.ts +1 -1
  415. package/src/border-control/border-control-dropdown/component.tsx +9 -8
  416. package/src/box-control/test/index.js +11 -35
  417. package/src/button/README.md +49 -55
  418. package/src/button/{deprecated.js → deprecated.tsx} +19 -4
  419. package/src/button/{index.js → index.tsx} +95 -34
  420. package/src/button/stories/index.tsx +106 -0
  421. package/src/button/style.scss +3 -2
  422. package/src/button/test/{index.js → index.tsx} +30 -7
  423. package/src/button/types.ts +138 -0
  424. package/src/checkbox-control/test/index.tsx +1 -5
  425. package/src/color-list-picker/{index.js → index.tsx} +3 -2
  426. package/src/color-list-picker/types.ts +46 -0
  427. package/src/color-palette/README.md +1 -1
  428. package/src/color-palette/index.native.js +11 -4
  429. package/src/color-palette/index.tsx +11 -67
  430. package/src/color-palette/test/index.tsx +4 -14
  431. package/src/color-palette/test/utils.ts +1 -1
  432. package/src/color-palette/types.ts +1 -1
  433. package/src/color-palette/utils.ts +98 -0
  434. package/src/color-picker/component.tsx +1 -0
  435. package/src/color-picker/stories/index.js +20 -60
  436. package/src/color-picker/styles.ts +0 -5
  437. package/src/color-picker/test/index.js +6 -15
  438. package/src/combobox-control/index.js +9 -1
  439. package/src/combobox-control/test/index.js +1 -6
  440. package/src/confirm-dialog/test/index.js +9 -29
  441. package/src/custom-gradient-picker/gradient-bar/utils.js +1 -1
  442. package/src/dashicon/types.ts +0 -6
  443. package/src/date-time/date/index.tsx +2 -1
  444. package/src/date-time/date/test/index.tsx +2 -8
  445. package/src/date-time/time/test/index.tsx +9 -29
  446. package/src/dimension-control/test/index.test.js +2 -8
  447. package/src/disabled/test/index.tsx +1 -5
  448. package/src/draggable/test/index.native.js +4 -4
  449. package/src/dropdown/README.md +1 -8
  450. package/src/dropdown/index.tsx +17 -6
  451. package/src/dropdown/stories/index.tsx +3 -3
  452. package/src/dropdown/test/index.tsx +2 -8
  453. package/src/dropdown/types.ts +9 -10
  454. package/src/dropdown-menu/README.md +1 -1
  455. package/src/dropdown-menu/stories/index.js +96 -27
  456. package/src/dropdown-menu/test/index.js +2 -8
  457. package/src/external-link/test/index.tsx +1 -6
  458. package/src/focal-point-picker/stories/index.tsx +1 -1
  459. package/src/focal-point-picker/test/index.js +3 -11
  460. package/src/focal-point-picker/utils.ts +4 -1
  461. package/src/font-size-picker/test/index.tsx +14 -44
  462. package/src/form-file-upload/test/index.tsx +2 -17
  463. package/src/form-toggle/test/index.tsx +1 -5
  464. package/src/form-token-field/test/index.tsx +80 -163
  465. package/src/form-token-field/token.tsx +1 -1
  466. package/src/gradient-picker/index.js +15 -4
  467. package/src/guide/stories/index.js +14 -41
  468. package/src/guide/test/index.js +5 -17
  469. package/src/h-stack/component.tsx +0 -1
  470. package/src/higher-order/with-filters/test/index.js +24 -24
  471. package/src/higher-order/with-focus-outside/test/index.js +11 -25
  472. package/src/higher-order/with-focus-return/test/index.js +1 -5
  473. package/src/index.js +8 -6
  474. package/src/index.native.js +8 -6
  475. package/src/input-control/input-field.tsx +3 -1
  476. package/src/input-control/test/index.js +1 -6
  477. package/src/isolated-event-container/test/index.js +2 -8
  478. package/src/item-group/item/component.tsx +26 -2
  479. package/src/item-group/item-group/component.tsx +25 -2
  480. package/src/item-group/stories/index.tsx +103 -0
  481. package/src/item-group/styles.ts +1 -0
  482. package/src/item-group/test/__snapshots__/index.js.snap +11 -10
  483. package/src/keyboard-shortcuts/README.md +1 -1
  484. package/src/keyboard-shortcuts/index.tsx +93 -0
  485. package/src/keyboard-shortcuts/stories/index.tsx +60 -0
  486. package/src/keyboard-shortcuts/test/{index.js → index.tsx} +16 -6
  487. package/src/keyboard-shortcuts/types.ts +51 -0
  488. package/src/modal/index.tsx +1 -2
  489. package/src/navigable-container/test/navigable-menu.js +5 -17
  490. package/src/navigable-container/test/tababble-container.js +3 -11
  491. package/src/navigation/test/index.js +3 -11
  492. package/src/navigator/test/index.tsx +6 -20
  493. package/src/notice/README.md +89 -42
  494. package/src/notice/{index.js → index.tsx} +28 -20
  495. package/src/notice/list.tsx +72 -0
  496. package/src/notice/stories/index.tsx +119 -0
  497. package/src/notice/test/__snapshots__/{index.js.snap → index.tsx.snap} +0 -0
  498. package/src/notice/test/{index.js → index.tsx} +7 -4
  499. package/src/notice/test/{list.js → list.tsx} +0 -0
  500. package/src/notice/types.ts +136 -0
  501. package/src/number-control/index.tsx +1 -1
  502. package/src/number-control/test/index.tsx +28 -86
  503. package/src/panel/row.js +3 -3
  504. package/src/panel/stories/index.js +62 -80
  505. package/src/panel/test/body.js +2 -8
  506. package/src/placeholder/stories/index.tsx +1 -0
  507. package/src/placeholder/style.scss +1 -1
  508. package/src/query-controls/README.md +56 -56
  509. package/src/query-controls/author-select.tsx +37 -0
  510. package/src/query-controls/category-select.tsx +46 -0
  511. package/src/query-controls/index.tsx +192 -0
  512. package/src/query-controls/stories/index.tsx +205 -0
  513. package/src/query-controls/terms.ts +57 -0
  514. package/src/query-controls/test/{terms.js → terms.ts} +36 -20
  515. package/src/query-controls/types.ts +150 -0
  516. package/src/resizable-box/README.md +2 -2
  517. package/src/resizable-box/index.tsx +7 -6
  518. package/src/resizable-box/stories/index.tsx +92 -0
  519. package/src/responsive-wrapper/README.md +29 -0
  520. package/src/responsive-wrapper/{index.js → index.tsx} +23 -2
  521. package/src/responsive-wrapper/stories/index.tsx +38 -0
  522. package/src/responsive-wrapper/types.ts +20 -0
  523. package/src/sandbox/README.md +45 -2
  524. package/src/sandbox/{index.js → index.tsx} +47 -24
  525. package/src/sandbox/stories/index.tsx +32 -0
  526. package/src/sandbox/test/{index.js → index.tsx} +9 -4
  527. package/src/sandbox/types.ts +34 -0
  528. package/src/select-control/test/select-control.tsx +1 -6
  529. package/src/slot-fill/bubbles-virtually/fill.js +1 -0
  530. package/src/slot-fill/slot.js +1 -1
  531. package/src/slot-fill/stories/index.js +12 -17
  532. package/src/slot-fill/use-slot.js +6 -16
  533. package/src/snackbar/index.tsx +6 -5
  534. package/src/snackbar/list.tsx +4 -2
  535. package/src/snackbar/types.ts +18 -92
  536. package/src/style.scss +3 -3
  537. package/src/tab-panel/README.md +1 -0
  538. package/src/tab-panel/index.tsx +42 -6
  539. package/src/tab-panel/stories/index.tsx +20 -0
  540. package/src/tab-panel/style.scss +8 -0
  541. package/src/tab-panel/test/index.tsx +124 -7
  542. package/src/tab-panel/types.ts +11 -5
  543. package/src/theme/test/index.tsx +4 -4
  544. package/src/toggle-group-control/stories/index.tsx +1 -0
  545. package/src/toggle-group-control/test/index.tsx +7 -23
  546. package/src/toolbar/index.js +6 -52
  547. package/src/toolbar/stories/index.js +71 -75
  548. package/src/toolbar/test/index.js +1 -2
  549. package/src/{toolbar-group/test/index.js → toolbar/test/toolbar-group.js} +1 -1
  550. package/src/toolbar/{README.md → toolbar/README.md} +0 -0
  551. package/src/toolbar/toolbar/index.js +52 -0
  552. package/src/toolbar/{style.native.scss → toolbar/style.native.scss} +0 -0
  553. package/src/toolbar/{style.scss → toolbar/style.scss} +0 -0
  554. package/src/toolbar/{toolbar-container.js → toolbar/toolbar-container.js} +0 -0
  555. package/src/toolbar/{toolbar-container.native.js → toolbar/toolbar-container.native.js} +0 -0
  556. package/src/{toolbar-button → toolbar/toolbar-button}/README.md +0 -0
  557. package/src/{toolbar-button → toolbar/toolbar-button}/index.js +1 -1
  558. package/src/{toolbar-button → toolbar/toolbar-button}/style.scss +0 -0
  559. package/src/{toolbar-button → toolbar/toolbar-button}/toolbar-button-container.js +0 -0
  560. package/src/{toolbar-button → toolbar/toolbar-button}/toolbar-button-container.native.js +0 -0
  561. package/src/{toolbar-context → toolbar/toolbar-context}/index.js +0 -0
  562. package/src/{toolbar-dropdown-menu → toolbar/toolbar-dropdown-menu}/README.md +0 -0
  563. package/src/{toolbar-dropdown-menu → toolbar/toolbar-dropdown-menu}/index.js +1 -1
  564. package/src/{toolbar-group → toolbar/toolbar-group}/README.md +0 -0
  565. package/src/{toolbar-group → toolbar/toolbar-group}/index.js +0 -0
  566. package/src/{toolbar-group → toolbar/toolbar-group}/style.native.scss +0 -0
  567. package/src/{toolbar-group → toolbar/toolbar-group}/style.scss +0 -0
  568. package/src/{toolbar-group → toolbar/toolbar-group}/toolbar-group-collapsed.js +1 -1
  569. package/src/{toolbar-group → toolbar/toolbar-group}/toolbar-group-collapsed.native.js +1 -1
  570. package/src/{toolbar-group → toolbar/toolbar-group}/toolbar-group-container.js +0 -0
  571. package/src/{toolbar-group → toolbar/toolbar-group}/toolbar-group-container.native.js +0 -0
  572. package/src/{toolbar-item → toolbar/toolbar-item}/README.md +0 -0
  573. package/src/{toolbar-item → toolbar/toolbar-item}/index.js +0 -0
  574. package/src/{toolbar-item → toolbar/toolbar-item}/index.native.js +0 -0
  575. package/src/tools-panel/stories/index.js +3 -0
  576. package/src/tools-panel/test/index.js +1 -1
  577. package/src/tree-grid/index.js +3 -5
  578. package/src/tree-select/index.tsx +3 -6
  579. package/src/ui/context/test/context-connect.tsx +2 -0
  580. package/src/ui/context/test/wordpress-component.tsx +2 -0
  581. package/src/unit-control/test/index.tsx +21 -74
  582. package/src/utils/hooks/test/use-latest-ref.js +15 -18
  583. package/tsconfig.json +1 -11
  584. package/tsconfig.tsbuildinfo +1 -1
  585. package/build/toolbar/toolbar-container.native.js.map +0 -1
  586. package/build/toolbar-button/index.js.map +0 -1
  587. package/build/toolbar-button/toolbar-button-container.js.map +0 -1
  588. package/build/toolbar-button/toolbar-button-container.native.js.map +0 -1
  589. package/build/toolbar-context/index.js.map +0 -1
  590. package/build/toolbar-dropdown-menu/index.js.map +0 -1
  591. package/build/toolbar-group/index.js.map +0 -1
  592. package/build/toolbar-group/toolbar-group-collapsed.js.map +0 -1
  593. package/build/toolbar-group/toolbar-group-collapsed.native.js.map +0 -1
  594. package/build/toolbar-group/toolbar-group-container.js.map +0 -1
  595. package/build/toolbar-group/toolbar-group-container.native.js.map +0 -1
  596. package/build/toolbar-item/index.js.map +0 -1
  597. package/build/toolbar-item/index.native.js.map +0 -1
  598. package/build-module/toolbar/toolbar-container.js.map +0 -1
  599. package/build-module/toolbar/toolbar-container.native.js.map +0 -1
  600. package/build-module/toolbar-button/index.js.map +0 -1
  601. package/build-module/toolbar-button/toolbar-button-container.js.map +0 -1
  602. package/build-module/toolbar-button/toolbar-button-container.native.js.map +0 -1
  603. package/build-module/toolbar-context/index.js.map +0 -1
  604. package/build-module/toolbar-dropdown-menu/index.js.map +0 -1
  605. package/build-module/toolbar-group/index.js.map +0 -1
  606. package/build-module/toolbar-group/toolbar-group-collapsed.js.map +0 -1
  607. package/build-module/toolbar-group/toolbar-group-collapsed.native.js.map +0 -1
  608. package/build-module/toolbar-group/toolbar-group-container.js.map +0 -1
  609. package/build-module/toolbar-group/toolbar-group-container.native.js.map +0 -1
  610. package/build-module/toolbar-item/index.js.map +0 -1
  611. package/build-module/toolbar-item/index.native.js.map +0 -1
  612. package/src/button/stories/index.js +0 -179
  613. package/src/item-group/stories/index.js +0 -270
  614. package/src/keyboard-shortcuts/index.js +0 -56
  615. package/src/notice/list.js +0 -48
  616. package/src/notice/stories/index.js +0 -74
  617. package/src/query-controls/author-select.js +0 -23
  618. package/src/query-controls/category-select.js +0 -31
  619. package/src/query-controls/index.js +0 -121
  620. package/src/query-controls/terms.js +0 -40
  621. package/src/resizable-box/stories/index.js +0 -97
  622. package/src/toolbar-button/stories/index.js +0 -33
  623. package/src/toolbar-group/stories/index.js +0 -33
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/components/src/notice/index.js"],"names":["noop","useSpokenMessage","message","politeness","spokenMessage","getDefaultPoliteness","status","Notice","className","children","onRemove","isDismissible","actions","__unstableHTML","onDismiss","classes","onDismissNotice","event","preventDefault","map","index","buttonCustomClasses","label","isPrimary","variant","noDefaultClasses","onClick","url","computedVariant","undefined","close"],"mappings":";;;;;;;;;AASA;;AANA;;AAKA;;AAEA;;AACA;;AAKA;;AAhBA;AACA;AACA;;AAGA;AACA;AACA;;AAMA;AACA;AACA;;AAGA;AAEA,MAAMA,IAAI,GAAG,MAAM,CAAE,CAArB;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;;AACA,SAASC,gBAAT,CAA2BC,OAA3B,EAAoCC,UAApC,EAAiD;AAChD,QAAMC,aAAa,GAClB,OAAOF,OAAP,KAAmB,QAAnB,GAA8BA,OAA9B,GAAwC,6BAAgBA,OAAhB,CADzC;AAGA,0BAAW,MAAM;AAChB,QAAKE,aAAL,EAAqB;AACpB,uBAAOA,aAAP,EAAsBD,UAAtB;AACA;AACD,GAJD,EAIG,CAAEC,aAAF,EAAiBD,UAAjB,CAJH;AAKA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AACA,SAASE,oBAAT,CAA+BC,MAA/B,EAAwC;AACvC,UAASA,MAAT;AACC,SAAK,SAAL;AACA,SAAK,SAAL;AACA,SAAK,MAAL;AACC,aAAO,QAAP;;AAED,SAAK,OAAL;AACA;AACC,aAAO,WAAP;AARF;AAUA;;AAED,SAASC,MAAT,OAcI;AAAA,MAda;AAChBC,IAAAA,SADgB;AAEhBF,IAAAA,MAAM,GAAG,MAFO;AAGhBG,IAAAA,QAH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AsB,MAAxC;AACA;;AACD,QACC,OAAOC,eAAP,KAA2B,WAA3B,IACAL,SAFD,EAGE;AACDK,MAAAA,eAAe,GAAG,SAAlB;AACA;;AAED,WACC,4BAAC,QAAD;AACC,MAAA,GAAG,EAAGR,KADP;AAEC,MAAA,IAAI,EAAGO,GAFR;AAGC,MAAA,OAAO,EAAGC,eAHX;AAIC,MAAA,OAAO,EAAGD,GAAG,GAAGE,SAAH,GAAeH,OAJ7B;AAKC,MAAA,SAAS,EAAG,yBACX,2BADW,EAEXL,mBAFW;AALb,OAUGC,KAVH,CADD;AAcA,GAtCA,CADH,CAFD,CADD,EA8CGX,aAAa,IACd,4BAAC,QAAD;AACC,IAAA,SAAS,EAAC,4BADX;AAEC,IAAA,IAAI,EAAGmB,YAFR;AAGC,IAAA,KAAK,EAAG,cAAI,qBAAJ,CAHT;AAIC,IAAA,OAAO,EAAGd,eAJX;AAKC,IAAA,WAAW,EAAG;AALf,IA/CF,CADD;AA0DA;;eAEcT,M","sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { RawHTML, useEffect, renderToString } from '@wordpress/element';\nimport { speak } from '@wordpress/a11y';\nimport { close } from '@wordpress/icons';\n\n/**\n * Internal dependencies\n */\nimport { Button } from '../';\n\n/** @typedef {import('@wordpress/element').WPElement} WPElement */\n\nconst noop = () => {};\n\n/**\n * Custom hook which announces the message with the given politeness, if a\n * valid message is provided.\n *\n * @param {string|WPElement} [message] Message to announce.\n * @param {'polite'|'assertive'} politeness Politeness to announce.\n */\nfunction useSpokenMessage( message, politeness ) {\n\tconst spokenMessage =\n\t\ttypeof message === 'string' ? message : renderToString( message );\n\n\tuseEffect( () => {\n\t\tif ( spokenMessage ) {\n\t\t\tspeak( spokenMessage, politeness );\n\t\t}\n\t}, [ spokenMessage, politeness ] );\n}\n\n/**\n * Given a notice status, returns an assumed default politeness for the status.\n * Defaults to 'assertive'.\n *\n * @param {string} [status] Notice status.\n *\n * @return {'polite'|'assertive'} Notice politeness.\n */\nfunction getDefaultPoliteness( status ) {\n\tswitch ( status ) {\n\t\tcase 'success':\n\t\tcase 'warning':\n\t\tcase 'info':\n\t\t\treturn 'polite';\n\n\t\tcase 'error':\n\t\tdefault:\n\t\t\treturn 'assertive';\n\t}\n}\n\nfunction Notice( {\n\tclassName,\n\tstatus = 'info',\n\tchildren,\n\tspokenMessage = children,\n\tonRemove = noop,\n\tisDismissible = true,\n\tactions = [],\n\tpoliteness = getDefaultPoliteness( status ),\n\t__unstableHTML,\n\t// onDismiss is a callback executed when the notice is dismissed.\n\t// It is distinct from onRemove, which _looks_ like a callback but is\n\t// actually the function to call to remove the notice from the UI.\n\tonDismiss = noop,\n} ) {\n\tuseSpokenMessage( spokenMessage, politeness );\n\n\tconst classes = classnames(\n\t\tclassName,\n\t\t'components-notice',\n\t\t'is-' + status,\n\t\t{\n\t\t\t'is-dismissible': isDismissible,\n\t\t}\n\t);\n\n\tif ( __unstableHTML ) {\n\t\tchildren = <RawHTML>{ children }</RawHTML>;\n\t}\n\n\tconst onDismissNotice = ( event ) => {\n\t\tevent?.preventDefault?.();\n\t\tonDismiss();\n\t\tonRemove();\n\t};\n\n\treturn (\n\t\t<div className={ classes }>\n\t\t\t<div className=\"components-notice__content\">\n\t\t\t\t{ children }\n\t\t\t\t<div className=\"components-notice__actions\">\n\t\t\t\t\t{ actions.map(\n\t\t\t\t\t\t(\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tclassName: buttonCustomClasses,\n\t\t\t\t\t\t\t\tlabel,\n\t\t\t\t\t\t\t\tisPrimary,\n\t\t\t\t\t\t\t\tvariant,\n\t\t\t\t\t\t\t\tnoDefaultClasses = false,\n\t\t\t\t\t\t\t\tonClick,\n\t\t\t\t\t\t\t\turl,\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\tindex\n\t\t\t\t\t\t) => {\n\t\t\t\t\t\t\tlet computedVariant = variant;\n\t\t\t\t\t\t\tif ( variant !== 'primary' && ! noDefaultClasses ) {\n\t\t\t\t\t\t\t\tcomputedVariant = ! url ? 'secondary' : 'link';\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tif (\n\t\t\t\t\t\t\t\ttypeof computedVariant === 'undefined' &&\n\t\t\t\t\t\t\t\tisPrimary\n\t\t\t\t\t\t\t) {\n\t\t\t\t\t\t\t\tcomputedVariant = 'primary';\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\treturn (\n\t\t\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\t\t\tkey={ index }\n\t\t\t\t\t\t\t\t\thref={ url }\n\t\t\t\t\t\t\t\t\tvariant={ computedVariant }\n\t\t\t\t\t\t\t\t\tonClick={ url ? undefined : onClick }\n\t\t\t\t\t\t\t\t\tclassName={ classnames(\n\t\t\t\t\t\t\t\t\t\t'components-notice__action',\n\t\t\t\t\t\t\t\t\t\tbuttonCustomClasses\n\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t{ label }\n\t\t\t\t\t\t\t\t</Button>\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t}\n\t\t\t\t\t) }\n\t\t\t\t</div>\n\t\t\t</div>\n\t\t\t{ isDismissible && (\n\t\t\t\t<Button\n\t\t\t\t\tclassName=\"components-notice__dismiss\"\n\t\t\t\t\ticon={ close }\n\t\t\t\t\tlabel={ __( 'Dismiss this notice' ) }\n\t\t\t\t\tonClick={ onDismissNotice }\n\t\t\t\t\tshowTooltip={ false }\n\t\t\t\t/>\n\t\t\t) }\n\t\t</div>\n\t);\n}\n\nexport default Notice;\n"]}
1
+ {"version":3,"sources":["@wordpress/components/src/notice/index.tsx"],"names":["noop","useSpokenMessage","message","politeness","spokenMessage","getDefaultPoliteness","status","Notice","className","children","onRemove","isDismissible","actions","__unstableHTML","onDismiss","classes","onDismissNotice","event","preventDefault","map","index","buttonCustomClasses","label","isPrimary","variant","noDefaultClasses","onClick","url","computedVariant","undefined","close"],"mappings":";;;;;;;;;AASA;;AANA;;AAKA;;AAEA;;AACA;;AAKA;;AAhBA;AACA;AACA;;AAGA;AACA;AACA;;AAMA;AACA;AACA;AAMA,MAAMA,IAAI,GAAG,MAAM,CAAE,CAArB;AAEA;AACA;AACA;AACA;;;AACA,SAASC,gBAAT,CACCC,OADD,EAECC,UAFD,EAGE;AACD,QAAMC,aAAa,GAClB,OAAOF,OAAP,KAAmB,QAAnB,GAA8BA,OAA9B,GAAwC,6BAAgBA,OAAhB,CADzC;AAGA,0BAAW,MAAM;AAChB,QAAKE,aAAL,EAAqB;AACpB,uBAAOA,aAAP,EAAsBD,UAAtB;AACA;AACD,GAJD,EAIG,CAAEC,aAAF,EAAiBD,UAAjB,CAJH;AAKA;;AAED,SAASE,oBAAT,CAA+BC,MAA/B,EAAiE;AAChE,UAASA,MAAT;AACC,SAAK,SAAL;AACA,SAAK,SAAL;AACA,SAAK,MAAL;AACC,aAAO,QAAP;;AAED,SAAK,OAAL;AACA;AACC,aAAO,WAAP;AARF;AAUA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AACA,SAASC,MAAT,OAciB;AAAA,MAdA;AAChBC,IAAAA,SADgB;AAEhBF,IAAAA,MAAM,GAAG,MAFO;AAGhBG,IAAAA,QAHgB;AAIhBL,IAAAA,aAAa,GAAGK,QAJA;AAKhBC,IAAAA,QAAQ,GAAGV,IALK;AAMhBW,IAAAA,aAAa,GAAG,IANA;AAOhBC,IAAAA,OAAO,GAAG,EAPM;AAQhBT,IAAAA,UAAU,GAAGE,oBAAoB,CAAEC,MAAF,CARjB;AAShBO,IAAAA,cATgB;AAUhB;AACA;AACA;AACAC,IAAAA,SAAS,GAAGd;AAbI,GAcA;AAChBC,EAAAA,gBAAgB,CAAEG,aAAF,EAAiBD,UAAjB,CAAhB;AAEA,QAAMY,OAAO,GAAG,yBACfP,SADe,EAEf,mBAFe,EAGf,QAAQF,MAHO,E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GA1CA,CADH,CAFD,CADD,EAkDGX,aAAa,IACd,4BAAC,eAAD;AACC,IAAA,SAAS,EAAC,4BADX;AAEC,IAAA,IAAI,EAAGmB,YAFR;AAGC,IAAA,KAAK,EAAG,cAAI,qBAAJ,CAHT;AAIC,IAAA,OAAO,EAAGd,eAJX;AAKC,IAAA,WAAW,EAAG;AALf,IAnDF,CADD;AA8DA;;eAEcT,M","sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { RawHTML, useEffect, renderToString } from '@wordpress/element';\nimport { speak } from '@wordpress/a11y';\nimport { close } from '@wordpress/icons';\n\n/**\n * Internal dependencies\n */\nimport Button from '../button';\nimport type { NoticeAction, NoticeProps } from './types';\nimport type { SyntheticEvent } from 'react';\nimport type { DeprecatedButtonProps } from '../button/types';\n\nconst noop = () => {};\n\n/**\n * Custom hook which announces the message with the given politeness, if a\n * valid message is provided.\n */\nfunction useSpokenMessage(\n\tmessage: NoticeProps[ 'spokenMessage' ],\n\tpoliteness: NoticeProps[ 'politeness' ]\n) {\n\tconst spokenMessage =\n\t\ttypeof message === 'string' ? message : renderToString( message );\n\n\tuseEffect( () => {\n\t\tif ( spokenMessage ) {\n\t\t\tspeak( spokenMessage, politeness );\n\t\t}\n\t}, [ spokenMessage, politeness ] );\n}\n\nfunction getDefaultPoliteness( status: NoticeProps[ 'status' ] ) {\n\tswitch ( status ) {\n\t\tcase 'success':\n\t\tcase 'warning':\n\t\tcase 'info':\n\t\t\treturn 'polite';\n\n\t\tcase 'error':\n\t\tdefault:\n\t\t\treturn 'assertive';\n\t}\n}\n\n/**\n * `Notice` is a component used to communicate feedback to the user.\n *\n *```jsx\n * import { Notice } from `@wordpress/components`;\n *\n * const MyNotice = () => (\n * <Notice status=\"error\">An unknown error occurred.</Notice>\n * );\n * ```\n */\nfunction Notice( {\n\tclassName,\n\tstatus = 'info',\n\tchildren,\n\tspokenMessage = children,\n\tonRemove = noop,\n\tisDismissible = true,\n\tactions = [],\n\tpoliteness = getDefaultPoliteness( status ),\n\t__unstableHTML,\n\t// onDismiss is a callback executed when the notice is dismissed.\n\t// It is distinct from onRemove, which _looks_ like a callback but is\n\t// actually the function to call to remove the notice from the UI.\n\tonDismiss = noop,\n}: NoticeProps ) {\n\tuseSpokenMessage( spokenMessage, politeness );\n\n\tconst classes = classnames(\n\t\tclassName,\n\t\t'components-notice',\n\t\t'is-' + status,\n\t\t{\n\t\t\t'is-dismissible': isDismissible,\n\t\t}\n\t);\n\n\tif ( __unstableHTML && typeof children === 'string' ) {\n\t\tchildren = <RawHTML>{ children }</RawHTML>;\n\t}\n\n\tconst onDismissNotice = ( event: SyntheticEvent ) => {\n\t\tevent?.preventDefault?.();\n\t\tonDismiss();\n\t\tonRemove();\n\t};\n\n\treturn (\n\t\t<div className={ classes }>\n\t\t\t<div className=\"components-notice__content\">\n\t\t\t\t{ children }\n\t\t\t\t<div className=\"components-notice__actions\">\n\t\t\t\t\t{ actions.map(\n\t\t\t\t\t\t(\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tclassName: buttonCustomClasses,\n\t\t\t\t\t\t\t\tlabel,\n\t\t\t\t\t\t\t\tisPrimary,\n\t\t\t\t\t\t\t\tvariant,\n\t\t\t\t\t\t\t\tnoDefaultClasses = false,\n\t\t\t\t\t\t\t\tonClick,\n\t\t\t\t\t\t\t\turl,\n\t\t\t\t\t\t\t}: NoticeAction &\n\t\t\t\t\t\t\t\t// `isPrimary` is a legacy prop included for\n\t\t\t\t\t\t\t\t// backcompat, but `variant` should be used\n\t\t\t\t\t\t\t\t// instead.\n\t\t\t\t\t\t\t\tPick< DeprecatedButtonProps, 'isPrimary' >,\n\t\t\t\t\t\t\tindex\n\t\t\t\t\t\t) => {\n\t\t\t\t\t\t\tlet computedVariant = variant;\n\t\t\t\t\t\t\tif ( variant !== 'primary' && ! noDefaultClasses ) {\n\t\t\t\t\t\t\t\tcomputedVariant = ! url ? 'secondary' : 'link';\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tif (\n\t\t\t\t\t\t\t\ttypeof computedVariant === 'undefined' &&\n\t\t\t\t\t\t\t\tisPrimary\n\t\t\t\t\t\t\t) {\n\t\t\t\t\t\t\t\tcomputedVariant = 'primary';\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\treturn (\n\t\t\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\t\t\tkey={ index }\n\t\t\t\t\t\t\t\t\thref={ url }\n\t\t\t\t\t\t\t\t\tvariant={ computedVariant }\n\t\t\t\t\t\t\t\t\tonClick={ url ? undefined : onClick }\n\t\t\t\t\t\t\t\t\tclassName={ classnames(\n\t\t\t\t\t\t\t\t\t\t'components-notice__action',\n\t\t\t\t\t\t\t\t\t\tbuttonCustomClasses\n\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t{ label }\n\t\t\t\t\t\t\t\t</Button>\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t}\n\t\t\t\t\t) }\n\t\t\t\t</div>\n\t\t\t</div>\n\t\t\t{ isDismissible && (\n\t\t\t\t<Button\n\t\t\t\t\tclassName=\"components-notice__dismiss\"\n\t\t\t\t\ticon={ close }\n\t\t\t\t\tlabel={ __( 'Dismiss this notice' ) }\n\t\t\t\t\tonClick={ onDismissNotice }\n\t\t\t\t\tshowTooltip={ false }\n\t\t\t\t/>\n\t\t\t) }\n\t\t</div>\n\t);\n}\n\nexport default Notice;\n"]}
@@ -13,7 +13,7 @@ var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends")
13
13
 
14
14
  var _classnames = _interopRequireDefault(require("classnames"));
15
15
 
16
- var _ = _interopRequireDefault(require("./"));
16
+ var _ = _interopRequireDefault(require("."));
17
17
 
18
18
  /**
19
19
  * External dependencies
@@ -24,15 +24,30 @@ var _ = _interopRequireDefault(require("./"));
24
24
  */
25
25
  const noop = () => {};
26
26
  /**
27
- * Renders a list of notices.
27
+ * `NoticeList` is a component used to render a collection of notices.
28
28
  *
29
- * @param {Object} $0 Props passed to the component.
30
- * @param {Array} $0.notices Array of notices to render.
31
- * @param {Function} $0.onRemove Function called when a notice should be removed / dismissed.
32
- * @param {Object} $0.className Name of the class used by the component.
33
- * @param {Object} $0.children Array of children to be rendered inside the notice list.
29
+ *```jsx
30
+ * import { Notice, NoticeList } from `@wordpress/components`;
34
31
  *
35
- * @return {Object} The rendered notices list.
32
+ * const MyNoticeList = () => {
33
+ * const [ notices, setNotices ] = useState( [
34
+ * {
35
+ * id: 'second-notice',
36
+ * content: 'second notice content',
37
+ * },
38
+ * {
39
+ * id: 'fist-notice',
40
+ * content: 'first notice content',
41
+ * },
42
+ * ] );
43
+ *
44
+ * const removeNotice = ( id ) => {
45
+ * setNotices( notices.filter( ( notice ) => notice.id !== id ) );
46
+ * };
47
+ *
48
+ * return <NoticeList notices={ notices } onRemove={ removeNotice } />;
49
+ *};
50
+ *```
36
51
  */
37
52
 
38
53
 
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/components/src/notice/list.js"],"names":["noop","NoticeList","notices","onRemove","className","children","removeNotice","id","reverse","map","notice","content","restNotice"],"mappings":";;;;;;;;;;;;;AAGA;;AAKA;;AARA;AACA;AACA;;AAGA;AACA;AACA;AAGA,MAAMA,IAAI,GAAG,MAAM,CAAE,CAArB;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AACA,SAASC,UAAT,OAAyE;AAAA,MAApD;AAAEC,IAAAA,OAAF;AAAWC,IAAAA,QAAQ,GAAGH,IAAtB;AAA4BI,IAAAA,SAA5B;AAAuCC,IAAAA;AAAvC,GAAoD;;AACxE,QAAMC,YAAY,GAAKC,EAAF,IAAU,MAAMJ,QAAQ,CAAEI,EAAF,CAA7C;;AAEAH,EAAAA,SAAS,GAAG,yBAAY,wBAAZ,EAAsCA,SAAtC,CAAZ;AAEA,SACC;AAAK,IAAA,SAAS,EAAGA;AAAjB,KACGC,QADH,EAEG,CAAE,GAAGH,OAAL,EAAeM,OAAf,GAAyBC,GAAzB,CAAgCC,MAAF,IAAc;AAC7C,UAAM;AAAEC,MAAAA,OAAF;AAAW,SAAGC;AAAd,QAA6BF,MAAnC;AACA,WACC,4BAAC,SAAD,6BACME,UADN;AAEC,MAAA,GAAG,EAAGF,MAAM,CAACH,EAFd;AAGC,MAAA,QAAQ,EAAGD,YAAY,CAAEI,MAAM,CAACH,EAAT;AAHxB,QAKGG,MAAM,CAACC,OALV,CADD;AASA,GAXC,CAFH,CADD;AAiBA;;eAEcV,U","sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * Internal dependencies\n */\nimport Notice from './';\n\nconst noop = () => {};\n\n/**\n * Renders a list of notices.\n *\n * @param {Object} $0 Props passed to the component.\n * @param {Array} $0.notices Array of notices to render.\n * @param {Function} $0.onRemove Function called when a notice should be removed / dismissed.\n * @param {Object} $0.className Name of the class used by the component.\n * @param {Object} $0.children Array of children to be rendered inside the notice list.\n *\n * @return {Object} The rendered notices list.\n */\nfunction NoticeList( { notices, onRemove = noop, className, children } ) {\n\tconst removeNotice = ( id ) => () => onRemove( id );\n\n\tclassName = classnames( 'components-notice-list', className );\n\n\treturn (\n\t\t<div className={ className }>\n\t\t\t{ children }\n\t\t\t{ [ ...notices ].reverse().map( ( notice ) => {\n\t\t\t\tconst { content, ...restNotice } = notice;\n\t\t\t\treturn (\n\t\t\t\t\t<Notice\n\t\t\t\t\t\t{ ...restNotice }\n\t\t\t\t\t\tkey={ notice.id }\n\t\t\t\t\t\tonRemove={ removeNotice( notice.id ) }\n\t\t\t\t\t>\n\t\t\t\t\t\t{ notice.content }\n\t\t\t\t\t</Notice>\n\t\t\t\t);\n\t\t\t} ) }\n\t\t</div>\n\t);\n}\n\nexport default NoticeList;\n"]}
1
+ {"version":3,"sources":["@wordpress/components/src/notice/list.tsx"],"names":["noop","NoticeList","notices","onRemove","className","children","removeNotice","id","reverse","map","notice","content","restNotice"],"mappings":";;;;;;;;;;;;;AAGA;;AAKA;;AARA;AACA;AACA;;AAGA;AACA;AACA;AAKA,MAAMA,IAAI,GAAG,MAAM,CAAE,CAArB;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AACA,SAASC,UAAT,OAK8D;AAAA,MALzC;AACpBC,IAAAA,OADoB;AAEpBC,IAAAA,QAAQ,GAAGH,IAFS;AAGpBI,IAAAA,SAHoB;AAIpBC,IAAAA;AAJoB,GAKyC;;AAC7D,QAAMC,YAAY,GACfC,EAAF,IAA0D,MACzDJ,QAAQ,CAAEI,EAAF,CAFV;;AAIAH,EAAAA,SAAS,GAAG,yBAAY,wBAAZ,EAAsCA,SAAtC,CAAZ;AAEA,SACC;AAAK,IAAA,SAAS,EAAGA;AAAjB,KACGC,QADH,EAEG,CAAE,GAAGH,OAAL,EAAeM,OAAf,GAAyBC,GAAzB,CAAgCC,MAAF,IAAc;AAC7C,UAAM;AAAEC,MAAAA,OAAF;AAAW,SAAGC;AAAd,QAA6BF,MAAnC;AACA,WACC,4BAAC,SAAD,6BACME,UADN;AAEC,MAAA,GAAG,EAAGF,MAAM,CAACH,EAFd;AAGC,MAAA,QAAQ,EAAGD,YAAY,CAAEI,MAAM,CAACH,EAAT;AAHxB,QAKGG,MAAM,CAACC,OALV,CADD;AASA,GAXC,CAFH,CADD;AAiBA;;eAEcV,U","sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * Internal dependencies\n */\nimport Notice from '.';\nimport type { WordPressComponentProps } from '../ui/context';\nimport type { NoticeListProps } from './types';\n\nconst noop = () => {};\n\n/**\n * `NoticeList` is a component used to render a collection of notices.\n *\n *```jsx\n * import { Notice, NoticeList } from `@wordpress/components`;\n *\n * const MyNoticeList = () => {\n *\tconst [ notices, setNotices ] = useState( [\n *\t\t{\n *\t\t\tid: 'second-notice',\n *\t\t\tcontent: 'second notice content',\n *\t\t},\n *\t\t{\n *\t\t\tid: 'fist-notice',\n *\t\t\tcontent: 'first notice content',\n *\t\t},\n *\t] );\n *\n *\tconst removeNotice = ( id ) => {\n *\t\tsetNotices( notices.filter( ( notice ) => notice.id !== id ) );\n *\t};\n *\n *\treturn <NoticeList notices={ notices } onRemove={ removeNotice } />;\n *};\n *```\n */\nfunction NoticeList( {\n\tnotices,\n\tonRemove = noop,\n\tclassName,\n\tchildren,\n}: WordPressComponentProps< NoticeListProps, 'div', false > ) {\n\tconst removeNotice =\n\t\t( id: NoticeListProps[ 'notices' ][ number ][ 'id' ] ) => () =>\n\t\t\tonRemove( id );\n\n\tclassName = classnames( 'components-notice-list', className );\n\n\treturn (\n\t\t<div className={ className }>\n\t\t\t{ children }\n\t\t\t{ [ ...notices ].reverse().map( ( notice ) => {\n\t\t\t\tconst { content, ...restNotice } = notice;\n\t\t\t\treturn (\n\t\t\t\t\t<Notice\n\t\t\t\t\t\t{ ...restNotice }\n\t\t\t\t\t\tkey={ notice.id }\n\t\t\t\t\t\tonRemove={ removeNotice( notice.id ) }\n\t\t\t\t\t>\n\t\t\t\t\t\t{ notice.content }\n\t\t\t\t\t</Notice>\n\t\t\t\t);\n\t\t\t} ) }\n\t\t</div>\n\t);\n}\n\nexport default NoticeList;\n"]}
@@ -0,0 +1,6 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"names":[],"mappings":"","sourcesContent":[]}
@@ -74,7 +74,7 @@ function UnforwardedNumberControl(_ref, forwardedRef) {
74
74
  } = _ref;
75
75
 
76
76
  if (hideHTMLArrows) {
77
- (0, _deprecated.default)('hideHTMLArrows', {
77
+ (0, _deprecated.default)('wp.components.NumberControl hideHTMLArrows prop ', {
78
78
  alternative: 'spinControls="none"',
79
79
  since: '6.2',
80
80
  version: '6.3'
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/components/src/number-control/index.tsx"],"names":["noop","UnforwardedNumberControl","forwardedRef","__unstableStateReducer","stateReducerProp","className","dragDirection","hideHTMLArrows","spinControls","isDragEnabled","isShiftStepEnabled","label","max","Infinity","min","required","shiftStep","step","type","typeProp","value","valueProp","size","suffix","onChange","props","alternative","since","version","inputRef","mergedRef","isStepAny","baseStep","baseValue","constrainValue","stepOverride","Math","autoComplete","undefined","classes","spinValue","direction","event","preventDefault","shift","shiftKey","delta","nextValue","numberControlStateReducer","state","action","nextState","payload","currentValue","inputControlActionTypes","PRESS_UP","PRESS_DOWN","DRAG","x","y","enableShift","modifier","directionModifier","ceil","abs","sign","distance","PRESS_ENTER","COMMIT","applyEmptyValue","buildSpinButtonClickHandler","String","target","current","baseState","plusIcon","resetIcon","NumberControl"],"mappings":";;;;;;;;;AASA;;;;AANA;;AAOA;;AACA;;AACA;;AACA;;AAKA;;AACA;;AACA;;AACA;;AAGA;;AACA;;;;;;AAzBA;AACA;AACA;;AAIA;AACA;AACA;;AAOA;AACA;AACA;AAUA,MAAMA,IAAI,GAAG,MAAM,CAAE,CAArB;;AAEA,SAASC,wBAAT,OAsBCC,YAtBD,EAuBE;AAAA,MAtBD;AACCC,IAAAA,sBAAsB,EAAEC,gBADzB;AAECC,IAAAA,SAFD;AAGCC,IAAAA,aAAa,GAAG,GAHjB;AAICC,IAAAA,cAAc,GAAG,KAJlB;AAKCC,IAAAA,YAAY,GAAG,QALhB;AAMCC,IAAAA,aAAa,GAAG,IANjB;AAOCC,IAAAA,kBAAkB,GAAG,IAPtB;AAQCC,IAAAA,KARD;AASCC,IAAAA,GAAG,GAAGC,QATP;AAUCC,IAAAA,GAAG,GAAG,CAACD,QAVR;AAWCE,IAAAA,QAAQ,GAAG,KAXZ;AAYCC,IAAAA,SAAS,GAAG,EAZb;AAaCC,IAAAA,IAAI,GAAG,CAbR;AAcCC,IAAAA,IAAI,EAAEC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KAAF,EAASC,MAAT,KAAqB;AAAA;;AAC7C,YAAMwB,SAAS,GAAG1B,yBAAyB,CAAEC,KAAF,EAASC,MAAT,CAA3C;AACA,kCAAO9C,gBAAP,aAAOA,gBAAP,uBAAOA,gBAAgB,CAAIsE,SAAJ,EAAexB,MAAf,CAAvB,iEAAkDwB,SAAlD;AACA,KApBF;AAqBC,IAAA,IAAI,EAAGpD,IArBR;AAsBC,IAAA,MAAM,EACLd,YAAY,KAAK,QAAjB,GACC,qDACGe,MADH,EAEC,4BAAC,cAAD;AAAQ,MAAA,YAAY,EAAG,CAAvB;AAA2B,MAAA,WAAW,EAAG;AAAzC,OACC,4BAAC,cAAD;AAAQ,MAAA,OAAO,EAAG;AAAlB,OACC,4BAAC,+BAAD;AACC,MAAA,IAAI,EAAGoD,WADR;AAEC,MAAA,OAAO,MAFR;AAGC,qBAAY,MAHb;AAIC,oBAAa,cAAI,WAAJ,CAJd;AAKC,MAAA,QAAQ,EAAG,CAAC,CALb;AAMC,MAAA,OAAO,EAAGL,2BAA2B,CACpC,IADoC,CANtC;AASC,MAAA,IAAI,EAAGhD;AATR,MADD,EAYC,4BAAC,+BAAD;AACC,MAAA,IAAI,EAAGsD,YADR;AAEC,MAAA,OAAO,MAFR;AAGC,qBAAY,MAHb;AAIC,oBAAa,cAAI,WAAJ,CAJd;AAKC,MAAA,QAAQ,EAAG,CAAC,CALb;AAMC,MAAA,OAAO,EAAGN,2BAA2B,CACpC,MADoC,CANtC;AASC,MAAA,IAAI,EAAGhD;AATR,MAZD,CADD,CAFD,CADD,GA+BCC,MAtDH;AAyDC,IAAA,QAAQ,EAAGC;AAzDZ,KADD;AA6DA;;AAEM,MAAMqD,aAAa,GAAG,yBAAY5E,wBAAZ,CAAtB;;eAEQ4E,a","sourcesContent":["/**\n * External dependencies\n */\nimport classNames from 'classnames';\nimport type { ForwardedRef, KeyboardEvent, MouseEvent } from 'react';\n\n/**\n * WordPress dependencies\n */\nimport { useRef, forwardRef } from '@wordpress/element';\nimport { isRTL, __ } from '@wordpress/i18n';\nimport { plus as plusIcon, reset as resetIcon } from '@wordpress/icons';\nimport { useMergeRefs } from '@wordpress/compose';\nimport deprecated from '@wordpress/deprecated';\n\n/**\n * Internal dependencies\n */\nimport { Input, SpinButton } from './styles/number-control-styles';\nimport * as inputControlActionTypes from '../input-control/reducer/actions';\nimport { add, subtract, roundClamp } from '../utils/math';\nimport { ensureNumber, isValueEmpty } from '../utils/values';\nimport type { WordPressComponentProps } from '../ui/context/wordpress-component';\nimport type { NumberControlProps } from './types';\nimport { HStack } from '../h-stack';\nimport { Spacer } from '../spacer';\n\nconst noop = () => {};\n\nfunction UnforwardedNumberControl(\n\t{\n\t\t__unstableStateReducer: stateReducerProp,\n\t\tclassName,\n\t\tdragDirection = 'n',\n\t\thideHTMLArrows = false,\n\t\tspinControls = 'native',\n\t\tisDragEnabled = true,\n\t\tisShiftStepEnabled = true,\n\t\tlabel,\n\t\tmax = Infinity,\n\t\tmin = -Infinity,\n\t\trequired = false,\n\t\tshiftStep = 10,\n\t\tstep = 1,\n\t\ttype: typeProp = 'number',\n\t\tvalue: valueProp,\n\t\tsize = 'default',\n\t\tsuffix,\n\t\tonChange = noop,\n\t\t...props\n\t}: WordPressComponentProps< NumberControlProps, 'input', false >,\n\tforwardedRef: ForwardedRef< any >\n) {\n\tif ( hideHTMLArrows ) {\n\t\tdeprecated( 'hideHTMLArrows', {\n\t\t\talternative: 'spinControls=\"none\"',\n\t\t\tsince: '6.2',\n\t\t\tversion: '6.3',\n\t\t} );\n\t\tspinControls = 'none';\n\t}\n\n\tconst inputRef = useRef< HTMLInputElement >();\n\tconst mergedRef = useMergeRefs( [ inputRef, forwardedRef ] );\n\n\tconst isStepAny = step === 'any';\n\tconst baseStep = isStepAny ? 1 : ensureNumber( step );\n\tconst baseValue = roundClamp( 0, min, max, baseStep );\n\tconst constrainValue = (\n\t\tvalue: number | string,\n\t\tstepOverride?: number\n\t) => {\n\t\t// When step is \"any\" clamp the value, otherwise round and clamp it.\n\t\treturn isStepAny\n\t\t\t? Math.min( max, Math.max( min, ensureNumber( value ) ) )\n\t\t\t: roundClamp( value, min, max, stepOverride ?? baseStep );\n\t};\n\n\tconst autoComplete = typeProp === 'number' ? 'off' : undefined;\n\tconst classes = classNames( 'components-number-control', className );\n\n\tconst spinValue = (\n\t\tvalue: string | number | undefined,\n\t\tdirection: 'up' | 'down',\n\t\tevent: KeyboardEvent | MouseEvent | undefined\n\t) => {\n\t\tevent?.preventDefault();\n\t\tconst shift = event?.shiftKey && isShiftStepEnabled;\n\t\tconst delta = shift ? ensureNumber( shiftStep ) * baseStep : baseStep;\n\t\tlet nextValue = isValueEmpty( value ) ? baseValue : value;\n\t\tif ( direction === 'up' ) {\n\t\t\tnextValue = add( nextValue, delta );\n\t\t} else if ( direction === 'down' ) {\n\t\t\tnextValue = subtract( nextValue, delta );\n\t\t}\n\t\treturn constrainValue( nextValue, shift ? delta : undefined );\n\t};\n\n\t/**\n\t * \"Middleware\" function that intercepts updates from InputControl.\n\t * This allows us to tap into actions to transform the (next) state for\n\t * InputControl.\n\t *\n\t * @return The updated state to apply to InputControl\n\t */\n\tconst numberControlStateReducer: NumberControlProps[ '__unstableStateReducer' ] =\n\t\t( state, action ) => {\n\t\t\tconst nextState = { ...state };\n\n\t\t\tconst { type, payload } = action;\n\t\t\tconst event = payload.event;\n\t\t\tconst currentValue = nextState.value;\n\n\t\t\t/**\n\t\t\t * Handles custom UP and DOWN Keyboard events\n\t\t\t */\n\t\t\tif (\n\t\t\t\ttype === inputControlActionTypes.PRESS_UP ||\n\t\t\t\ttype === inputControlActionTypes.PRESS_DOWN\n\t\t\t) {\n\t\t\t\t// @ts-expect-error TODO: Resolve discrepancy between `value` types in InputControl based components\n\t\t\t\tnextState.value = spinValue(\n\t\t\t\t\tcurrentValue,\n\t\t\t\t\ttype === inputControlActionTypes.PRESS_UP ? 'up' : 'down',\n\t\t\t\t\tevent as KeyboardEvent | undefined\n\t\t\t\t);\n\t\t\t}\n\n\t\t\t/**\n\t\t\t * Handles drag to update events\n\t\t\t */\n\t\t\tif ( type === inputControlActionTypes.DRAG && isDragEnabled ) {\n\t\t\t\t// @ts-expect-error TODO: See if reducer actions can be typed better\n\t\t\t\tconst [ x, y ] = payload.delta;\n\t\t\t\t// @ts-expect-error TODO: See if reducer actions can be typed better\n\t\t\t\tconst enableShift = payload.shiftKey && isShiftStepEnabled;\n\t\t\t\tconst modifier = enableShift\n\t\t\t\t\t? ensureNumber( shiftStep ) * baseStep\n\t\t\t\t\t: baseStep;\n\n\t\t\t\tlet directionModifier;\n\t\t\t\tlet delta;\n\n\t\t\t\tswitch ( dragDirection ) {\n\t\t\t\t\tcase 'n':\n\t\t\t\t\t\tdelta = y;\n\t\t\t\t\t\tdirectionModifier = -1;\n\t\t\t\t\t\tbreak;\n\n\t\t\t\t\tcase 'e':\n\t\t\t\t\t\tdelta = x;\n\t\t\t\t\t\tdirectionModifier = isRTL() ? -1 : 1;\n\t\t\t\t\t\tbreak;\n\n\t\t\t\t\tcase 's':\n\t\t\t\t\t\tdelta = y;\n\t\t\t\t\t\tdirectionModifier = 1;\n\t\t\t\t\t\tbreak;\n\n\t\t\t\t\tcase 'w':\n\t\t\t\t\t\tdelta = x;\n\t\t\t\t\t\tdirectionModifier = isRTL() ? 1 : -1;\n\t\t\t\t\t\tbreak;\n\t\t\t\t}\n\n\t\t\t\tif ( delta !== 0 ) {\n\t\t\t\t\tdelta = Math.ceil( Math.abs( delta ) ) * Math.sign( delta );\n\t\t\t\t\tconst distance = delta * modifier * directionModifier;\n\n\t\t\t\t\t// @ts-expect-error TODO: Resolve discrepancy between `value` types in InputControl based components\n\t\t\t\t\tnextState.value = constrainValue(\n\t\t\t\t\t\t// @ts-expect-error TODO: Investigate if it's ok for currentValue to be undefined\n\t\t\t\t\t\tadd( currentValue, distance ),\n\t\t\t\t\t\tenableShift ? modifier : undefined\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t/**\n\t\t\t * Handles commit (ENTER key press or blur)\n\t\t\t */\n\t\t\tif (\n\t\t\t\ttype === inputControlActionTypes.PRESS_ENTER ||\n\t\t\t\ttype === inputControlActionTypes.COMMIT\n\t\t\t) {\n\t\t\t\tconst applyEmptyValue =\n\t\t\t\t\trequired === false && currentValue === '';\n\n\t\t\t\t// @ts-expect-error TODO: Resolve discrepancy between `value` types in InputControl based components\n\t\t\t\tnextState.value = applyEmptyValue\n\t\t\t\t\t? currentValue\n\t\t\t\t\t: // @ts-expect-error TODO: Investigate if it's ok for currentValue to be undefined\n\t\t\t\t\t constrainValue( currentValue );\n\t\t\t}\n\n\t\t\treturn nextState;\n\t\t};\n\n\tconst buildSpinButtonClickHandler =\n\t\t( direction: 'up' | 'down' ) =>\n\t\t( event: MouseEvent< HTMLButtonElement > ) =>\n\t\t\tonChange( String( spinValue( valueProp, direction, event ) ), {\n\t\t\t\t// Set event.target to the <input> so that consumers can use\n\t\t\t\t// e.g. event.target.validity.\n\t\t\t\tevent: {\n\t\t\t\t\t...event,\n\t\t\t\t\ttarget: inputRef.current!,\n\t\t\t\t},\n\t\t\t} );\n\n\treturn (\n\t\t<Input\n\t\t\tautoComplete={ autoComplete }\n\t\t\tinputMode=\"numeric\"\n\t\t\t{ ...props }\n\t\t\tclassName={ classes }\n\t\t\tdragDirection={ dragDirection }\n\t\t\thideHTMLArrows={ spinControls !== 'native' }\n\t\t\tisDragEnabled={ isDragEnabled }\n\t\t\tlabel={ label }\n\t\t\tmax={ max }\n\t\t\tmin={ min }\n\t\t\tref={ mergedRef }\n\t\t\trequired={ required }\n\t\t\tstep={ step }\n\t\t\ttype={ typeProp }\n\t\t\t// @ts-expect-error TODO: Resolve discrepancy between `value` types in InputControl based components\n\t\t\tvalue={ valueProp }\n\t\t\t__unstableStateReducer={ ( state, action ) => {\n\t\t\t\tconst baseState = numberControlStateReducer( state, action );\n\t\t\t\treturn stateReducerProp?.( baseState, action ) ?? baseState;\n\t\t\t} }\n\t\t\tsize={ size }\n\t\t\tsuffix={\n\t\t\t\tspinControls === 'custom' ? (\n\t\t\t\t\t<>\n\t\t\t\t\t\t{ suffix }\n\t\t\t\t\t\t<Spacer marginBottom={ 0 } marginRight={ 2 }>\n\t\t\t\t\t\t\t<HStack spacing={ 1 }>\n\t\t\t\t\t\t\t\t<SpinButton\n\t\t\t\t\t\t\t\t\ticon={ plusIcon }\n\t\t\t\t\t\t\t\t\tisSmall\n\t\t\t\t\t\t\t\t\taria-hidden=\"true\"\n\t\t\t\t\t\t\t\t\taria-label={ __( 'Increment' ) }\n\t\t\t\t\t\t\t\t\ttabIndex={ -1 }\n\t\t\t\t\t\t\t\t\tonClick={ buildSpinButtonClickHandler(\n\t\t\t\t\t\t\t\t\t\t'up'\n\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t\tsize={ size }\n\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t<SpinButton\n\t\t\t\t\t\t\t\t\ticon={ resetIcon }\n\t\t\t\t\t\t\t\t\tisSmall\n\t\t\t\t\t\t\t\t\taria-hidden=\"true\"\n\t\t\t\t\t\t\t\t\taria-label={ __( 'Decrement' ) }\n\t\t\t\t\t\t\t\t\ttabIndex={ -1 }\n\t\t\t\t\t\t\t\t\tonClick={ buildSpinButtonClickHandler(\n\t\t\t\t\t\t\t\t\t\t'down'\n\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t\tsize={ size }\n\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t</HStack>\n\t\t\t\t\t\t</Spacer>\n\t\t\t\t\t</>\n\t\t\t\t) : (\n\t\t\t\t\tsuffix\n\t\t\t\t)\n\t\t\t}\n\t\t\tonChange={ onChange }\n\t\t/>\n\t);\n}\n\nexport const NumberControl = forwardRef( UnforwardedNumberControl );\n\nexport default NumberControl;\n"]}
1
+ {"version":3,"sources":["@wordpress/components/src/number-control/index.tsx"],"names":["noop","UnforwardedNumberControl","forwardedRef","__unstableStateReducer","stateReducerProp","className","dragDirection","hideHTMLArrows","spinControls","isDragEnabled","isShiftStepEnabled","label","max","Infinity","min","required","shiftStep","step","type","typeProp","value","valueProp","size","suffix","onChange","props","alternative","since","version","inputRef","mergedRef","isStepAny","baseStep","baseValue","constrainValue","stepOverride","Math","autoComplete","undefined","classes","spinValue","direction","event","preventDefault","shift","shiftKey","delta","nextValue","numberControlStateReducer","state","action","nextState","payload","currentValue","inputControlActionTypes","PRESS_UP","PRESS_DOWN","DRAG","x","y","enableShift","modifier","directionModifier","ceil","abs","sign","distance","PRESS_ENTER","COMMIT","applyEmptyValue","buildSpinButtonClickHandler","String","target","current","baseState","plusIcon","resetIcon","NumberControl"],"mappings":";;;;;;;;;AASA;;;;AANA;;AAOA;;AACA;;AACA;;AACA;;AAKA;;AACA;;AACA;;AACA;;AAGA;;AACA;;;;;;AAzBA;AACA;AACA;;AAIA;AACA;AACA;;AAOA;AACA;AACA;AAUA,MAAMA,IAAI,GAAG,MAAM,CAAE,CAArB;;AAEA,SAASC,wBAAT,OAsBCC,YAtBD,EAuBE;AAAA,MAtBD;AACCC,IAAAA,sBAAsB,EAAEC,gBADzB;AAECC,IAAAA,SAFD;AAGCC,IAAAA,aAAa,GAAG,GAHjB;AAICC,IAAAA,cAAc,GAAG,KAJlB;AAKCC,IAAAA,YAAY,GAAG,QALhB;AAMCC,IAAAA,aAAa,GAAG,IANjB;AAOCC,IAAAA,kBAAkB,GAAG,IAPtB;AAQCC,IAAAA,KARD;AASCC,IAAAA,GAAG,GAAGC,QATP;AAUCC,IAAAA,GAAG,GAAG,CAACD,QAVR;AAWCE,IAAAA,QAAQ,GAAG,KAXZ;AAYCC,IAAAA,SAAS,GAAG,EAZb;AAaCC,IAAAA,IAAI,GAAG,CAbR;AAcCC,IAAAA,IAAI,EAAEC,QAAQ,GAAG,QAdlB;AAeCC,IAAAA,KAAK,EAAEC,SAfR;AAgBCC,IAAAA,IAAI,GAAG,SAhBR;AAiBCC,IAAAA,MAjBD;AAkBCC,IAAAA,QAAQ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AAP,uBAAOA,gBAAgB,CAAIsE,SAAJ,EAAexB,MAAf,CAAvB,iEAAkDwB,SAAlD;AACA,KApBF;AAqBC,IAAA,IAAI,EAAGpD,IArBR;AAsBC,IAAA,MAAM,EACLd,YAAY,KAAK,QAAjB,GACC,qDACGe,MADH,EAEC,4BAAC,cAAD;AAAQ,MAAA,YAAY,EAAG,CAAvB;AAA2B,MAAA,WAAW,EAAG;AAAzC,OACC,4BAAC,cAAD;AAAQ,MAAA,OAAO,EAAG;AAAlB,OACC,4BAAC,+BAAD;AACC,MAAA,IAAI,EAAGoD,WADR;AAEC,MAAA,OAAO,MAFR;AAGC,qBAAY,MAHb;AAIC,oBAAa,cAAI,WAAJ,CAJd;AAKC,MAAA,QAAQ,EAAG,CAAC,CALb;AAMC,MAAA,OAAO,EAAGL,2BAA2B,CACpC,IADoC,CANtC;AASC,MAAA,IAAI,EAAGhD;AATR,MADD,EAYC,4BAAC,+BAAD;AACC,MAAA,IAAI,EAAGsD,YADR;AAEC,MAAA,OAAO,MAFR;AAGC,qBAAY,MAHb;AAIC,oBAAa,cAAI,WAAJ,CAJd;AAKC,MAAA,QAAQ,EAAG,CAAC,CALb;AAMC,MAAA,OAAO,EAAGN,2BAA2B,CACpC,MADoC,CANtC;AASC,MAAA,IAAI,EAAGhD;AATR,MAZD,CADD,CAFD,CADD,GA+BCC,MAtDH;AAyDC,IAAA,QAAQ,EAAGC;AAzDZ,KADD;AA6DA;;AAEM,MAAMqD,aAAa,GAAG,yBAAY5E,wBAAZ,CAAtB;;eAEQ4E,a","sourcesContent":["/**\n * External dependencies\n */\nimport classNames from 'classnames';\nimport type { ForwardedRef, KeyboardEvent, MouseEvent } from 'react';\n\n/**\n * WordPress dependencies\n */\nimport { useRef, forwardRef } from '@wordpress/element';\nimport { isRTL, __ } from '@wordpress/i18n';\nimport { plus as plusIcon, reset as resetIcon } from '@wordpress/icons';\nimport { useMergeRefs } from '@wordpress/compose';\nimport deprecated from '@wordpress/deprecated';\n\n/**\n * Internal dependencies\n */\nimport { Input, SpinButton } from './styles/number-control-styles';\nimport * as inputControlActionTypes from '../input-control/reducer/actions';\nimport { add, subtract, roundClamp } from '../utils/math';\nimport { ensureNumber, isValueEmpty } from '../utils/values';\nimport type { WordPressComponentProps } from '../ui/context/wordpress-component';\nimport type { NumberControlProps } from './types';\nimport { HStack } from '../h-stack';\nimport { Spacer } from '../spacer';\n\nconst noop = () => {};\n\nfunction UnforwardedNumberControl(\n\t{\n\t\t__unstableStateReducer: stateReducerProp,\n\t\tclassName,\n\t\tdragDirection = 'n',\n\t\thideHTMLArrows = false,\n\t\tspinControls = 'native',\n\t\tisDragEnabled = true,\n\t\tisShiftStepEnabled = true,\n\t\tlabel,\n\t\tmax = Infinity,\n\t\tmin = -Infinity,\n\t\trequired = false,\n\t\tshiftStep = 10,\n\t\tstep = 1,\n\t\ttype: typeProp = 'number',\n\t\tvalue: valueProp,\n\t\tsize = 'default',\n\t\tsuffix,\n\t\tonChange = noop,\n\t\t...props\n\t}: WordPressComponentProps< NumberControlProps, 'input', false >,\n\tforwardedRef: ForwardedRef< any >\n) {\n\tif ( hideHTMLArrows ) {\n\t\tdeprecated( 'wp.components.NumberControl hideHTMLArrows prop ', {\n\t\t\talternative: 'spinControls=\"none\"',\n\t\t\tsince: '6.2',\n\t\t\tversion: '6.3',\n\t\t} );\n\t\tspinControls = 'none';\n\t}\n\n\tconst inputRef = useRef< HTMLInputElement >();\n\tconst mergedRef = useMergeRefs( [ inputRef, forwardedRef ] );\n\n\tconst isStepAny = step === 'any';\n\tconst baseStep = isStepAny ? 1 : ensureNumber( step );\n\tconst baseValue = roundClamp( 0, min, max, baseStep );\n\tconst constrainValue = (\n\t\tvalue: number | string,\n\t\tstepOverride?: number\n\t) => {\n\t\t// When step is \"any\" clamp the value, otherwise round and clamp it.\n\t\treturn isStepAny\n\t\t\t? Math.min( max, Math.max( min, ensureNumber( value ) ) )\n\t\t\t: roundClamp( value, min, max, stepOverride ?? baseStep );\n\t};\n\n\tconst autoComplete = typeProp === 'number' ? 'off' : undefined;\n\tconst classes = classNames( 'components-number-control', className );\n\n\tconst spinValue = (\n\t\tvalue: string | number | undefined,\n\t\tdirection: 'up' | 'down',\n\t\tevent: KeyboardEvent | MouseEvent | undefined\n\t) => {\n\t\tevent?.preventDefault();\n\t\tconst shift = event?.shiftKey && isShiftStepEnabled;\n\t\tconst delta = shift ? ensureNumber( shiftStep ) * baseStep : baseStep;\n\t\tlet nextValue = isValueEmpty( value ) ? baseValue : value;\n\t\tif ( direction === 'up' ) {\n\t\t\tnextValue = add( nextValue, delta );\n\t\t} else if ( direction === 'down' ) {\n\t\t\tnextValue = subtract( nextValue, delta );\n\t\t}\n\t\treturn constrainValue( nextValue, shift ? delta : undefined );\n\t};\n\n\t/**\n\t * \"Middleware\" function that intercepts updates from InputControl.\n\t * This allows us to tap into actions to transform the (next) state for\n\t * InputControl.\n\t *\n\t * @return The updated state to apply to InputControl\n\t */\n\tconst numberControlStateReducer: NumberControlProps[ '__unstableStateReducer' ] =\n\t\t( state, action ) => {\n\t\t\tconst nextState = { ...state };\n\n\t\t\tconst { type, payload } = action;\n\t\t\tconst event = payload.event;\n\t\t\tconst currentValue = nextState.value;\n\n\t\t\t/**\n\t\t\t * Handles custom UP and DOWN Keyboard events\n\t\t\t */\n\t\t\tif (\n\t\t\t\ttype === inputControlActionTypes.PRESS_UP ||\n\t\t\t\ttype === inputControlActionTypes.PRESS_DOWN\n\t\t\t) {\n\t\t\t\t// @ts-expect-error TODO: Resolve discrepancy between `value` types in InputControl based components\n\t\t\t\tnextState.value = spinValue(\n\t\t\t\t\tcurrentValue,\n\t\t\t\t\ttype === inputControlActionTypes.PRESS_UP ? 'up' : 'down',\n\t\t\t\t\tevent as KeyboardEvent | undefined\n\t\t\t\t);\n\t\t\t}\n\n\t\t\t/**\n\t\t\t * Handles drag to update events\n\t\t\t */\n\t\t\tif ( type === inputControlActionTypes.DRAG && isDragEnabled ) {\n\t\t\t\t// @ts-expect-error TODO: See if reducer actions can be typed better\n\t\t\t\tconst [ x, y ] = payload.delta;\n\t\t\t\t// @ts-expect-error TODO: See if reducer actions can be typed better\n\t\t\t\tconst enableShift = payload.shiftKey && isShiftStepEnabled;\n\t\t\t\tconst modifier = enableShift\n\t\t\t\t\t? ensureNumber( shiftStep ) * baseStep\n\t\t\t\t\t: baseStep;\n\n\t\t\t\tlet directionModifier;\n\t\t\t\tlet delta;\n\n\t\t\t\tswitch ( dragDirection ) {\n\t\t\t\t\tcase 'n':\n\t\t\t\t\t\tdelta = y;\n\t\t\t\t\t\tdirectionModifier = -1;\n\t\t\t\t\t\tbreak;\n\n\t\t\t\t\tcase 'e':\n\t\t\t\t\t\tdelta = x;\n\t\t\t\t\t\tdirectionModifier = isRTL() ? -1 : 1;\n\t\t\t\t\t\tbreak;\n\n\t\t\t\t\tcase 's':\n\t\t\t\t\t\tdelta = y;\n\t\t\t\t\t\tdirectionModifier = 1;\n\t\t\t\t\t\tbreak;\n\n\t\t\t\t\tcase 'w':\n\t\t\t\t\t\tdelta = x;\n\t\t\t\t\t\tdirectionModifier = isRTL() ? 1 : -1;\n\t\t\t\t\t\tbreak;\n\t\t\t\t}\n\n\t\t\t\tif ( delta !== 0 ) {\n\t\t\t\t\tdelta = Math.ceil( Math.abs( delta ) ) * Math.sign( delta );\n\t\t\t\t\tconst distance = delta * modifier * directionModifier;\n\n\t\t\t\t\t// @ts-expect-error TODO: Resolve discrepancy between `value` types in InputControl based components\n\t\t\t\t\tnextState.value = constrainValue(\n\t\t\t\t\t\t// @ts-expect-error TODO: Investigate if it's ok for currentValue to be undefined\n\t\t\t\t\t\tadd( currentValue, distance ),\n\t\t\t\t\t\tenableShift ? modifier : undefined\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t/**\n\t\t\t * Handles commit (ENTER key press or blur)\n\t\t\t */\n\t\t\tif (\n\t\t\t\ttype === inputControlActionTypes.PRESS_ENTER ||\n\t\t\t\ttype === inputControlActionTypes.COMMIT\n\t\t\t) {\n\t\t\t\tconst applyEmptyValue =\n\t\t\t\t\trequired === false && currentValue === '';\n\n\t\t\t\t// @ts-expect-error TODO: Resolve discrepancy between `value` types in InputControl based components\n\t\t\t\tnextState.value = applyEmptyValue\n\t\t\t\t\t? currentValue\n\t\t\t\t\t: // @ts-expect-error TODO: Investigate if it's ok for currentValue to be undefined\n\t\t\t\t\t constrainValue( currentValue );\n\t\t\t}\n\n\t\t\treturn nextState;\n\t\t};\n\n\tconst buildSpinButtonClickHandler =\n\t\t( direction: 'up' | 'down' ) =>\n\t\t( event: MouseEvent< HTMLButtonElement > ) =>\n\t\t\tonChange( String( spinValue( valueProp, direction, event ) ), {\n\t\t\t\t// Set event.target to the <input> so that consumers can use\n\t\t\t\t// e.g. event.target.validity.\n\t\t\t\tevent: {\n\t\t\t\t\t...event,\n\t\t\t\t\ttarget: inputRef.current!,\n\t\t\t\t},\n\t\t\t} );\n\n\treturn (\n\t\t<Input\n\t\t\tautoComplete={ autoComplete }\n\t\t\tinputMode=\"numeric\"\n\t\t\t{ ...props }\n\t\t\tclassName={ classes }\n\t\t\tdragDirection={ dragDirection }\n\t\t\thideHTMLArrows={ spinControls !== 'native' }\n\t\t\tisDragEnabled={ isDragEnabled }\n\t\t\tlabel={ label }\n\t\t\tmax={ max }\n\t\t\tmin={ min }\n\t\t\tref={ mergedRef }\n\t\t\trequired={ required }\n\t\t\tstep={ step }\n\t\t\ttype={ typeProp }\n\t\t\t// @ts-expect-error TODO: Resolve discrepancy between `value` types in InputControl based components\n\t\t\tvalue={ valueProp }\n\t\t\t__unstableStateReducer={ ( state, action ) => {\n\t\t\t\tconst baseState = numberControlStateReducer( state, action );\n\t\t\t\treturn stateReducerProp?.( baseState, action ) ?? baseState;\n\t\t\t} }\n\t\t\tsize={ size }\n\t\t\tsuffix={\n\t\t\t\tspinControls === 'custom' ? (\n\t\t\t\t\t<>\n\t\t\t\t\t\t{ suffix }\n\t\t\t\t\t\t<Spacer marginBottom={ 0 } marginRight={ 2 }>\n\t\t\t\t\t\t\t<HStack spacing={ 1 }>\n\t\t\t\t\t\t\t\t<SpinButton\n\t\t\t\t\t\t\t\t\ticon={ plusIcon }\n\t\t\t\t\t\t\t\t\tisSmall\n\t\t\t\t\t\t\t\t\taria-hidden=\"true\"\n\t\t\t\t\t\t\t\t\taria-label={ __( 'Increment' ) }\n\t\t\t\t\t\t\t\t\ttabIndex={ -1 }\n\t\t\t\t\t\t\t\t\tonClick={ buildSpinButtonClickHandler(\n\t\t\t\t\t\t\t\t\t\t'up'\n\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t\tsize={ size }\n\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t<SpinButton\n\t\t\t\t\t\t\t\t\ticon={ resetIcon }\n\t\t\t\t\t\t\t\t\tisSmall\n\t\t\t\t\t\t\t\t\taria-hidden=\"true\"\n\t\t\t\t\t\t\t\t\taria-label={ __( 'Decrement' ) }\n\t\t\t\t\t\t\t\t\ttabIndex={ -1 }\n\t\t\t\t\t\t\t\t\tonClick={ buildSpinButtonClickHandler(\n\t\t\t\t\t\t\t\t\t\t'down'\n\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t\tsize={ size }\n\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t</HStack>\n\t\t\t\t\t\t</Spacer>\n\t\t\t\t\t</>\n\t\t\t\t) : (\n\t\t\t\t\tsuffix\n\t\t\t\t)\n\t\t\t}\n\t\t\tonChange={ onChange }\n\t\t/>\n\t);\n}\n\nexport const NumberControl = forwardRef( UnforwardedNumberControl );\n\nexport default NumberControl;\n"]}
@@ -18,7 +18,7 @@ var _classnames = _interopRequireDefault(require("classnames"));
18
18
  /**
19
19
  * WordPress dependencies
20
20
  */
21
- const PanelRow = (0, _element.forwardRef)((_ref, ref) => {
21
+ const PanelRow = (_ref, ref) => {
22
22
  let {
23
23
  className,
24
24
  children
@@ -27,7 +27,9 @@ const PanelRow = (0, _element.forwardRef)((_ref, ref) => {
27
27
  className: (0, _classnames.default)('components-panel__row', className),
28
28
  ref: ref
29
29
  }, children);
30
- });
31
- var _default = PanelRow;
30
+ };
31
+
32
+ var _default = (0, _element.forwardRef)(PanelRow);
33
+
32
34
  exports.default = _default;
33
35
  //# sourceMappingURL=row.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/components/src/panel/row.js"],"names":["PanelRow","ref","className","children"],"mappings":";;;;;;;;;AAQA;;AALA;;AAHA;AACA;AACA;;AAGA;AACA;AACA;AAGA,MAAMA,QAAQ,GAAG,yBAAY,OAA2BC,GAA3B;AAAA,MAAE;AAAEC,IAAAA,SAAF;AAAaC,IAAAA;AAAb,GAAF;AAAA,SAC5B;AACC,IAAA,SAAS,EAAG,yBAAY,uBAAZ,EAAqCD,SAArC,CADb;AAEC,IAAA,GAAG,EAAGD;AAFP,KAIGE,QAJH,CAD4B;AAAA,CAAZ,CAAjB;eASeH,Q","sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport { forwardRef } from '@wordpress/element';\n\nconst PanelRow = forwardRef( ( { className, children }, ref ) => (\n\t<div\n\t\tclassName={ classnames( 'components-panel__row', className ) }\n\t\tref={ ref }\n\t>\n\t\t{ children }\n\t</div>\n) );\n\nexport default PanelRow;\n"]}
1
+ {"version":3,"sources":["@wordpress/components/src/panel/row.js"],"names":["PanelRow","ref","className","children"],"mappings":";;;;;;;;;AAQA;;AALA;;AAHA;AACA;AACA;;AAGA;AACA;AACA;AAGA,MAAMA,QAAQ,GAAG,OAA2BC,GAA3B;AAAA,MAAE;AAAEC,IAAAA,SAAF;AAAaC,IAAAA;AAAb,GAAF;AAAA,SAChB;AACC,IAAA,SAAS,EAAG,yBAAY,uBAAZ,EAAqCD,SAArC,CADb;AAEC,IAAA,GAAG,EAAGD;AAFP,KAIGE,QAJH,CADgB;AAAA,CAAjB;;eASe,yBAAYH,QAAZ,C","sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport { forwardRef } from '@wordpress/element';\n\nconst PanelRow = ( { className, children }, ref ) => (\n\t<div\n\t\tclassName={ classnames( 'components-panel__row', className ) }\n\t\tref={ ref }\n\t>\n\t\t{ children }\n\t</div>\n);\n\nexport default forwardRef( PanelRow );\n"]}
@@ -22,16 +22,20 @@ function AuthorSelect(_ref) {
22
22
  noOptionLabel,
23
23
  authorList,
24
24
  selectedAuthorId,
25
- onChange
25
+ onChange: onChangeProp
26
26
  } = _ref;
27
27
  if (!authorList) return null;
28
28
  const termsTree = (0, _terms.buildTermsTree)(authorList);
29
29
  return (0, _element.createElement)(_treeSelect.default, {
30
30
  label,
31
31
  noOptionLabel,
32
- onChange,
32
+ // Since the `multiple` attribute is not passed to `TreeSelect`, it is
33
+ // safe to assume that the argument of `onChange` cannot be `string[]`.
34
+ // The correct solution would be to type `SelectControl` better, so that
35
+ // the type of `value` and `onChange` vary depending on `multiple`.
36
+ onChange: onChangeProp,
33
37
  tree: termsTree,
34
- selectedId: selectedAuthorId
38
+ selectedId: selectedAuthorId !== undefined ? String(selectedAuthorId) : undefined
35
39
  });
36
40
  }
37
41
  //# sourceMappingURL=author-select.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/components/src/query-controls/author-select.js"],"names":["AuthorSelect","label","noOptionLabel","authorList","selectedAuthorId","onChange","termsTree"],"mappings":";;;;;;;;;;;AAGA;;AACA;;AAJA;AACA;AACA;AAIe,SAASA,YAAT,OAMX;AAAA,MANkC;AACrCC,IAAAA,KADqC;AAErCC,IAAAA,aAFqC;AAGrCC,IAAAA,UAHqC;AAIrCC,IAAAA,gBAJqC;AAKrCC,IAAAA;AALqC,GAMlC;AACH,MAAK,CAAEF,UAAP,EAAoB,OAAO,IAAP;AACpB,QAAMG,SAAS,GAAG,2BAAgBH,UAAhB,CAAlB;AACA,SACC,4BAAC,mBAAD;AACQF,IAAAA,KADR;AACeC,IAAAA,aADf;AAC8BG,IAAAA,QAD9B;AAEC,IAAA,IAAI,EAAGC,SAFR;AAGC,IAAA,UAAU,EAAGF;AAHd,IADD;AAOA","sourcesContent":["/**\n * Internal dependencies\n */\nimport { buildTermsTree } from './terms';\nimport TreeSelect from '../tree-select';\n\nexport default function AuthorSelect( {\n\tlabel,\n\tnoOptionLabel,\n\tauthorList,\n\tselectedAuthorId,\n\tonChange,\n} ) {\n\tif ( ! authorList ) return null;\n\tconst termsTree = buildTermsTree( authorList );\n\treturn (\n\t\t<TreeSelect\n\t\t\t{ ...{ label, noOptionLabel, onChange } }\n\t\t\ttree={ termsTree }\n\t\t\tselectedId={ selectedAuthorId }\n\t\t/>\n\t);\n}\n"]}
1
+ {"version":3,"sources":["@wordpress/components/src/query-controls/author-select.tsx"],"names":["AuthorSelect","label","noOptionLabel","authorList","selectedAuthorId","onChange","onChangeProp","termsTree","undefined","String"],"mappings":";;;;;;;;;;;AAGA;;AACA;;AAJA;AACA;AACA;AAMe,SAASA,YAAT,OAMQ;AAAA,MANe;AACrCC,IAAAA,KADqC;AAErCC,IAAAA,aAFqC;AAGrCC,IAAAA,UAHqC;AAIrCC,IAAAA,gBAJqC;AAKrCC,IAAAA,QAAQ,EAAEC;AAL2B,GAMf;AACtB,MAAK,CAAEH,UAAP,EAAoB,OAAO,IAAP;AACpB,QAAMI,SAAS,GAAG,2BAAgBJ,UAAhB,CAAlB;AACA,SACC,4BAAC,mBAAD;AAEEF,IAAAA,KAFF;AAGEC,IAAAA,aAHF;AAIE;AACA;AACA;AACA;AACAG,IAAAA,QAAQ,EAAEC,YARZ;AAUC,IAAA,IAAI,EAAGC,SAVR;AAWC,IAAA,UAAU,EACTH,gBAAgB,KAAKI,SAArB,GACGC,MAAM,CAAEL,gBAAF,CADT,GAEGI;AAdL,IADD;AAmBA","sourcesContent":["/**\n * Internal dependencies\n */\nimport { buildTermsTree } from './terms';\nimport TreeSelect from '../tree-select';\nimport type { TreeSelectProps } from '../tree-select/types';\nimport type { AuthorSelectProps } from './types';\n\nexport default function AuthorSelect( {\n\tlabel,\n\tnoOptionLabel,\n\tauthorList,\n\tselectedAuthorId,\n\tonChange: onChangeProp,\n}: AuthorSelectProps ) {\n\tif ( ! authorList ) return null;\n\tconst termsTree = buildTermsTree( authorList );\n\treturn (\n\t\t<TreeSelect\n\t\t\t{ ...{\n\t\t\t\tlabel,\n\t\t\t\tnoOptionLabel,\n\t\t\t\t// Since the `multiple` attribute is not passed to `TreeSelect`, it is\n\t\t\t\t// safe to assume that the argument of `onChange` cannot be `string[]`.\n\t\t\t\t// The correct solution would be to type `SelectControl` better, so that\n\t\t\t\t// the type of `value` and `onChange` vary depending on `multiple`.\n\t\t\t\tonChange: onChangeProp as TreeSelectProps[ 'onChange' ],\n\t\t\t} }\n\t\t\ttree={ termsTree }\n\t\t\tselectedId={\n\t\t\t\tselectedAuthorId !== undefined\n\t\t\t\t\t? String( selectedAuthorId )\n\t\t\t\t\t: undefined\n\t\t\t}\n\t\t/>\n\t);\n}\n"]}
@@ -28,7 +28,7 @@ function CategorySelect(_ref) {
28
28
  noOptionLabel,
29
29
  categoriesList,
30
30
  selectedCategoryId,
31
- onChange,
31
+ onChange: onChangeProp,
32
32
  ...props
33
33
  } = _ref;
34
34
  const termsTree = (0, _element.useMemo)(() => {
@@ -37,9 +37,13 @@ function CategorySelect(_ref) {
37
37
  return (0, _element.createElement)(_treeSelect.default, (0, _extends2.default)({
38
38
  label,
39
39
  noOptionLabel,
40
- onChange,
40
+ // Since the `multiple` attribute is not passed to `TreeSelect`, it is
41
+ // safe to assume that the argument of `onChange` cannot be `string[]`.
42
+ // The correct solution would be to type `SelectControl` better, so that
43
+ // the type of `value` and `onChange` vary depending on `multiple`.
44
+ onChange: onChangeProp,
41
45
  tree: termsTree,
42
- selectedId: selectedCategoryId
46
+ selectedId: selectedCategoryId !== undefined ? String(selectedCategoryId) : undefined
43
47
  }, props));
44
48
  }
45
49
  //# sourceMappingURL=category-select.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/components/src/query-controls/category-select.js"],"names":["CategorySelect","label","noOptionLabel","categoriesList","selectedCategoryId","onChange","props","termsTree"],"mappings":";;;;;;;;;AAQA;;;;AALA;;AACA;;AAJA;AACA;AACA;;AAGA;AACA;AACA;AAGe,SAASA,cAAT,OAOX;AAAA,MAPoC;AACvCC,IAAAA,KADuC;AAEvCC,IAAAA,aAFuC;AAGvCC,IAAAA,cAHuC;AAIvCC,IAAAA,kBAJuC;AAKvCC,IAAAA,QALuC;AAMvC,OAAGC;AANoC,GAOpC;AACH,QAAMC,SAAS,GAAG,sBAAS,MAAM;AAChC,WAAO,2BAAgBJ,cAAhB,CAAP;AACA,GAFiB,EAEf,CAAEA,cAAF,CAFe,CAAlB;AAIA,SACC,4BAAC,mBAAD;AACQF,IAAAA,KADR;AACeC,IAAAA,aADf;AAC8BG,IAAAA,QAD9B;AAEC,IAAA,IAAI,EAAGE,SAFR;AAGC,IAAA,UAAU,EAAGH;AAHd,KAIME,KAJN,EADD;AAQA","sourcesContent":["/**\n * Internal dependencies\n */\nimport { buildTermsTree } from './terms';\nimport TreeSelect from '../tree-select';\n/**\n * WordPress dependencies\n */\nimport { useMemo } from '@wordpress/element';\n\nexport default function CategorySelect( {\n\tlabel,\n\tnoOptionLabel,\n\tcategoriesList,\n\tselectedCategoryId,\n\tonChange,\n\t...props\n} ) {\n\tconst termsTree = useMemo( () => {\n\t\treturn buildTermsTree( categoriesList );\n\t}, [ categoriesList ] );\n\n\treturn (\n\t\t<TreeSelect\n\t\t\t{ ...{ label, noOptionLabel, onChange } }\n\t\t\ttree={ termsTree }\n\t\t\tselectedId={ selectedCategoryId }\n\t\t\t{ ...props }\n\t\t/>\n\t);\n}\n"]}
1
+ {"version":3,"sources":["@wordpress/components/src/query-controls/category-select.tsx"],"names":["CategorySelect","label","noOptionLabel","categoriesList","selectedCategoryId","onChange","onChangeProp","props","termsTree","undefined","String"],"mappings":";;;;;;;;;AAUA;;;;AAPA;;AACA;;AAJA;AACA;AACA;;AAKA;AACA;AACA;AAIe,SAASA,cAAT,OAOU;AAAA,MAPe;AACvCC,IAAAA,KADuC;AAEvCC,IAAAA,aAFuC;AAGvCC,IAAAA,cAHuC;AAIvCC,IAAAA,kBAJuC;AAKvCC,IAAAA,QAAQ,EAAEC,YAL6B;AAMvC,OAAGC;AANoC,GAOf;AACxB,QAAMC,SAAS,GAAG,sBAAS,MAAM;AAChC,WAAO,2BAAgBL,cAAhB,CAAP;AACA,GAFiB,EAEf,CAAEA,cAAF,CAFe,CAAlB;AAIA,SACC,4BAAC,mBAAD;AAEEF,IAAAA,KAFF;AAGEC,IAAAA,aAHF;AAIE;AACA;AACA;AACA;AACAG,IAAAA,QAAQ,EAAEC,YARZ;AAUC,IAAA,IAAI,EAAGE,SAVR;AAWC,IAAA,UAAU,EACTJ,kBAAkB,KAAKK,SAAvB,GACGC,MAAM,CAAEN,kBAAF,CADT,GAEGK;AAdL,KAgBMF,KAhBN,EADD;AAoBA","sourcesContent":["/**\n * Internal dependencies\n */\nimport { buildTermsTree } from './terms';\nimport TreeSelect from '../tree-select';\nimport type { TreeSelectProps } from '../tree-select/types';\n\n/**\n * WordPress dependencies\n */\nimport { useMemo } from '@wordpress/element';\nimport type { CategorySelectProps } from './types';\n\nexport default function CategorySelect( {\n\tlabel,\n\tnoOptionLabel,\n\tcategoriesList,\n\tselectedCategoryId,\n\tonChange: onChangeProp,\n\t...props\n}: CategorySelectProps ) {\n\tconst termsTree = useMemo( () => {\n\t\treturn buildTermsTree( categoriesList );\n\t}, [ categoriesList ] );\n\n\treturn (\n\t\t<TreeSelect\n\t\t\t{ ...{\n\t\t\t\tlabel,\n\t\t\t\tnoOptionLabel,\n\t\t\t\t// Since the `multiple` attribute is not passed to `TreeSelect`, it is\n\t\t\t\t// safe to assume that the argument of `onChange` cannot be `string[]`.\n\t\t\t\t// The correct solution would be to type `SelectControl` better, so that\n\t\t\t\t// the type of `value` and `onChange` vary depending on `multiple`.\n\t\t\t\tonChange: onChangeProp as TreeSelectProps[ 'onChange' ],\n\t\t\t} }\n\t\t\ttree={ termsTree }\n\t\t\tselectedId={\n\t\t\t\tselectedCategoryId !== undefined\n\t\t\t\t\t? String( selectedCategoryId )\n\t\t\t\t\t: undefined\n\t\t\t}\n\t\t\t{ ...props }\n\t\t/>\n\t);\n}\n"]}
@@ -5,17 +5,22 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
5
5
  Object.defineProperty(exports, "__esModule", {
6
6
  value: true
7
7
  });
8
- exports.default = QueryControls;
8
+ exports.QueryControls = QueryControls;
9
+ exports.default = void 0;
9
10
 
10
11
  var _element = require("@wordpress/element");
11
12
 
12
13
  var _i18n = require("@wordpress/i18n");
13
14
 
15
+ var _authorSelect = _interopRequireDefault(require("./author-select"));
16
+
14
17
  var _categorySelect = _interopRequireDefault(require("./category-select"));
15
18
 
16
- var _ = require("../");
19
+ var _formTokenField = _interopRequireDefault(require("../form-token-field"));
17
20
 
18
- var _authorSelect = _interopRequireDefault(require("./author-select"));
21
+ var _rangeControl = _interopRequireDefault(require("../range-control"));
22
+
23
+ var _selectControl = _interopRequireDefault(require("../select-control"));
19
24
 
20
25
  /**
21
26
  * WordPress dependencies
@@ -28,26 +33,59 @@ const DEFAULT_MIN_ITEMS = 1;
28
33
  const DEFAULT_MAX_ITEMS = 100;
29
34
  const MAX_CATEGORIES_SUGGESTIONS = 20;
30
35
 
36
+ function isSingleCategorySelection(props) {
37
+ return 'categoriesList' in props;
38
+ }
39
+
40
+ function isMultipleCategorySelection(props) {
41
+ return 'categorySuggestions' in props;
42
+ }
43
+ /**
44
+ * Controls to query for posts.
45
+ *
46
+ * ```jsx
47
+ * const MyQueryControls = () => (
48
+ * <QueryControls
49
+ * { ...{ maxItems, minItems, numberOfItems, order, orderBy } }
50
+ * onOrderByChange={ ( newOrderBy ) => {
51
+ * updateQuery( { orderBy: newOrderBy } )
52
+ * }
53
+ * onOrderChange={ ( newOrder ) => {
54
+ * updateQuery( { order: newOrder } )
55
+ * }
56
+ * categoriesList={ categories }
57
+ * selectedCategoryId={ category }
58
+ * onCategoryChange={ ( newCategory ) => {
59
+ * updateQuery( { category: newCategory } )
60
+ * }
61
+ * onNumberOfItemsChange={ ( newNumberOfItems ) => {
62
+ * updateQuery( { numberOfItems: newNumberOfItems } )
63
+ * } }
64
+ * />
65
+ * );
66
+ * ```
67
+ */
68
+
69
+
31
70
  function QueryControls(_ref) {
32
71
  let {
33
72
  authorList,
34
73
  selectedAuthorId,
35
- categoriesList,
36
- selectedCategoryId,
37
- categorySuggestions,
38
- selectedCategories,
39
74
  numberOfItems,
40
75
  order,
41
76
  orderBy,
42
77
  maxItems = DEFAULT_MAX_ITEMS,
43
78
  minItems = DEFAULT_MIN_ITEMS,
44
- onCategoryChange,
45
79
  onAuthorChange,
46
80
  onNumberOfItemsChange,
47
81
  onOrderChange,
48
- onOrderByChange
82
+ onOrderByChange,
83
+ // Props for single OR multiple category selection are not destructured here,
84
+ // but instead are destructured inline where necessary.
85
+ ...props
49
86
  } = _ref;
50
- return [onOrderChange && onOrderByChange && (0, _element.createElement)(_.SelectControl, {
87
+ return (0, _element.createElement)(_element.Fragment, null, [onOrderChange && onOrderByChange && (0, _element.createElement)(_selectControl.default, {
88
+ __nextHasNoMarginBottom: true,
51
89
  key: "query-controls-order-select",
52
90
  label: (0, _i18n.__)('Order by'),
53
91
  value: `${orderBy}/${order}`,
@@ -67,6 +105,10 @@ function QueryControls(_ref) {
67
105
  value: 'title/desc'
68
106
  }],
69
107
  onChange: value => {
108
+ if (typeof value !== 'string') {
109
+ return;
110
+ }
111
+
70
112
  const [newOrderBy, newOrder] = value.split('/');
71
113
 
72
114
  if (newOrder !== order) {
@@ -77,22 +119,26 @@ function QueryControls(_ref) {
77
119
  onOrderByChange(newOrderBy);
78
120
  }
79
121
  }
80
- }), categoriesList && onCategoryChange && (0, _element.createElement)(_categorySelect.default, {
122
+ }), isSingleCategorySelection(props) && props.categoriesList && props.onCategoryChange && (0, _element.createElement)(_categorySelect.default, {
81
123
  key: "query-controls-category-select",
82
- categoriesList: categoriesList,
124
+ categoriesList: props.categoriesList,
83
125
  label: (0, _i18n.__)('Category'),
84
126
  noOptionLabel: (0, _i18n.__)('All'),
85
- selectedCategoryId: selectedCategoryId,
86
- onChange: onCategoryChange
87
- }), categorySuggestions && onCategoryChange && (0, _element.createElement)(_.FormTokenField, {
127
+ selectedCategoryId: props.selectedCategoryId,
128
+ onChange: props.onCategoryChange
129
+ }), isMultipleCategorySelection(props) && props.categorySuggestions && props.onCategoryChange && (0, _element.createElement)(_formTokenField.default, {
88
130
  key: "query-controls-categories-select",
89
131
  label: (0, _i18n.__)('Categories'),
90
- value: selectedCategories && selectedCategories.map(item => ({
132
+ value: props.selectedCategories && props.selectedCategories.map(item => ({
91
133
  id: item.id,
134
+ // Keeping the fallback to `item.value` for legacy reasons,
135
+ // even if items of `selectedCategories` should not have a
136
+ // `value` property.
137
+ // @ts-expect-error
92
138
  value: item.name || item.value
93
139
  })),
94
- suggestions: Object.keys(categorySuggestions),
95
- onChange: onCategoryChange,
140
+ suggestions: Object.keys(props.categorySuggestions),
141
+ onChange: props.onCategoryChange,
96
142
  maxSuggestions: MAX_CATEGORIES_SUGGESTIONS
97
143
  }), onAuthorChange && (0, _element.createElement)(_authorSelect.default, {
98
144
  key: "query-controls-author-select",
@@ -101,7 +147,7 @@ function QueryControls(_ref) {
101
147
  noOptionLabel: (0, _i18n.__)('All'),
102
148
  selectedAuthorId: selectedAuthorId,
103
149
  onChange: onAuthorChange
104
- }), onNumberOfItemsChange && (0, _element.createElement)(_.RangeControl, {
150
+ }), onNumberOfItemsChange && (0, _element.createElement)(_rangeControl.default, {
105
151
  __nextHasNoMarginBottom: true,
106
152
  key: "query-controls-range-control",
107
153
  label: (0, _i18n.__)('Number of items'),
@@ -110,6 +156,9 @@ function QueryControls(_ref) {
110
156
  min: minItems,
111
157
  max: maxItems,
112
158
  required: true
113
- })];
159
+ })]);
114
160
  }
161
+
162
+ var _default = QueryControls;
163
+ exports.default = _default;
115
164
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/components/src/query-controls/index.js"],"names":["DEFAULT_MIN_ITEMS","DEFAULT_MAX_ITEMS","MAX_CATEGORIES_SUGGESTIONS","QueryControls","authorList","selectedAuthorId","categoriesList","selectedCategoryId","categorySuggestions","selectedCategories","numberOfItems","order","orderBy","maxItems","minItems","onCategoryChange","onAuthorChange","onNumberOfItemsChange","onOrderChange","onOrderByChange","label","value","newOrderBy","newOrder","split","map","item","id","name","Object","keys"],"mappings":";;;;;;;;;;;AAGA;;AAKA;;AACA;;AACA;;AAVA;AACA;AACA;;AAGA;AACA;AACA;AAKA,MAAMA,iBAAiB,GAAG,CAA1B;AACA,MAAMC,iBAAiB,GAAG,GAA1B;AACA,MAAMC,0BAA0B,GAAG,EAAnC;;AAEe,SAASC,aAAT,OAiBX;AAAA,MAjBmC;AACtCC,IAAAA,UADsC;AAEtCC,IAAAA,gBAFsC;AAGtCC,IAAAA,cAHsC;AAItCC,IAAAA,kBAJsC;AAKtCC,IAAAA,mBALsC;AAMtCC,IAAAA,kBANsC;AAOtCC,IAAAA,aAPsC;AAQtCC,IAAAA,KARsC;AAStCC,IAAAA,OATsC;AAUtCC,IAAAA,QAAQ,GAAGZ,iBAV2B;AAWtCa,IAAAA,QAAQ,GAAGd,iBAX2B;AAYtCe,IAAAA,gBAZsC;AAatCC,IAAAA,cAbsC;AActCC,IAAAA,qBAdsC;AAetCC,IAAAA,aAfsC;AAgBtCC,IAAAA;AAhBsC,GAiBnC;AACH,SAAO,CACND,aAAa,IAAIC,eAAjB,IACC,4BAAC,eAAD;AACC,IAAA,GAAG,EAAC,6BADL;AAEC,IAAA,KAAK,EAAG,cAAI,UAAJ,CAFT;AAGC,IAAA,KAAK,EAAI,GAAGP,OAAS,IAAID,KAAO,EAHjC;AAIC,IAAA,OAAO,EAAG,CACT;AACCS,MAAAA,KAAK,EAAE,cAAI,kBAAJ,CADR;A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,CAAxB,CALF;AAUC,IAAA,WAAW,EAAGQ,MAAM,CAACC,IAAP,CAAatB,mBAAb,CAVf;AAWC,IAAA,QAAQ,EAAGO,gBAXZ;AAYC,IAAA,cAAc,EAAGb;AAZlB,IAhDK,EA+DNc,cAAc,IACb,4BAAC,qBAAD;AACC,IAAA,GAAG,EAAC,8BADL;AAEC,IAAA,UAAU,EAAGZ,UAFd;AAGC,IAAA,KAAK,EAAG,cAAI,QAAJ,CAHT;AAIC,IAAA,aAAa,EAAG,cAAI,KAAJ,CAJjB;AAKC,IAAA,gBAAgB,EAAGC,gBALpB;AAMC,IAAA,QAAQ,EAAGW;AANZ,IAhEK,EAyENC,qBAAqB,IACpB,4BAAC,cAAD;AACC,IAAA,uBAAuB,MADxB;AAEC,IAAA,GAAG,EAAC,8BAFL;AAGC,IAAA,KAAK,EAAG,cAAI,iBAAJ,CAHT;AAIC,IAAA,KAAK,EAAGP,aAJT;AAKC,IAAA,QAAQ,EAAGO,qBALZ;AAMC,IAAA,GAAG,EAAGH,QANP;AAOC,IAAA,GAAG,EAAGD,QAPP;AAQC,IAAA,QAAQ;AART,IA1EK,CAAP;AAsFA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport CategorySelect from './category-select';\nimport { RangeControl, SelectControl, FormTokenField } from '../';\nimport AuthorSelect from './author-select';\n\nconst DEFAULT_MIN_ITEMS = 1;\nconst DEFAULT_MAX_ITEMS = 100;\nconst MAX_CATEGORIES_SUGGESTIONS = 20;\n\nexport default function QueryControls( {\n\tauthorList,\n\tselectedAuthorId,\n\tcategoriesList,\n\tselectedCategoryId,\n\tcategorySuggestions,\n\tselectedCategories,\n\tnumberOfItems,\n\torder,\n\torderBy,\n\tmaxItems = DEFAULT_MAX_ITEMS,\n\tminItems = DEFAULT_MIN_ITEMS,\n\tonCategoryChange,\n\tonAuthorChange,\n\tonNumberOfItemsChange,\n\tonOrderChange,\n\tonOrderByChange,\n} ) {\n\treturn [\n\t\tonOrderChange && onOrderByChange && (\n\t\t\t<SelectControl\n\t\t\t\tkey=\"query-controls-order-select\"\n\t\t\t\tlabel={ __( 'Order by' ) }\n\t\t\t\tvalue={ `${ orderBy }/${ order }` }\n\t\t\t\toptions={ [\n\t\t\t\t\t{\n\t\t\t\t\t\tlabel: __( 'Newest to oldest' ),\n\t\t\t\t\t\tvalue: 'date/desc',\n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\tlabel: __( 'Oldest to newest' ),\n\t\t\t\t\t\tvalue: 'date/asc',\n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\t/* translators: label for ordering posts by title in ascending order */\n\t\t\t\t\t\tlabel: __( 'A → Z' ),\n\t\t\t\t\t\tvalue: 'title/asc',\n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\t/* translators: label for ordering posts by title in descending order */\n\t\t\t\t\t\tlabel: __( 'Z → A' ),\n\t\t\t\t\t\tvalue: 'title/desc',\n\t\t\t\t\t},\n\t\t\t\t] }\n\t\t\t\tonChange={ ( value ) => {\n\t\t\t\t\tconst [ newOrderBy, newOrder ] = value.split( '/' );\n\t\t\t\t\tif ( newOrder !== order ) {\n\t\t\t\t\t\tonOrderChange( newOrder );\n\t\t\t\t\t}\n\t\t\t\t\tif ( newOrderBy !== orderBy ) {\n\t\t\t\t\t\tonOrderByChange( newOrderBy );\n\t\t\t\t\t}\n\t\t\t\t} }\n\t\t\t/>\n\t\t),\n\t\tcategoriesList && onCategoryChange && (\n\t\t\t<CategorySelect\n\t\t\t\tkey=\"query-controls-category-select\"\n\t\t\t\tcategoriesList={ categoriesList }\n\t\t\t\tlabel={ __( 'Category' ) }\n\t\t\t\tnoOptionLabel={ __( 'All' ) }\n\t\t\t\tselectedCategoryId={ selectedCategoryId }\n\t\t\t\tonChange={ onCategoryChange }\n\t\t\t/>\n\t\t),\n\t\tcategorySuggestions && onCategoryChange && (\n\t\t\t<FormTokenField\n\t\t\t\tkey=\"query-controls-categories-select\"\n\t\t\t\tlabel={ __( 'Categories' ) }\n\t\t\t\tvalue={\n\t\t\t\t\tselectedCategories &&\n\t\t\t\t\tselectedCategories.map( ( item ) => ( {\n\t\t\t\t\t\tid: item.id,\n\t\t\t\t\t\tvalue: item.name || item.value,\n\t\t\t\t\t} ) )\n\t\t\t\t}\n\t\t\t\tsuggestions={ Object.keys( categorySuggestions ) }\n\t\t\t\tonChange={ onCategoryChange }\n\t\t\t\tmaxSuggestions={ MAX_CATEGORIES_SUGGESTIONS }\n\t\t\t/>\n\t\t),\n\t\tonAuthorChange && (\n\t\t\t<AuthorSelect\n\t\t\t\tkey=\"query-controls-author-select\"\n\t\t\t\tauthorList={ authorList }\n\t\t\t\tlabel={ __( 'Author' ) }\n\t\t\t\tnoOptionLabel={ __( 'All' ) }\n\t\t\t\tselectedAuthorId={ selectedAuthorId }\n\t\t\t\tonChange={ onAuthorChange }\n\t\t\t/>\n\t\t),\n\t\tonNumberOfItemsChange && (\n\t\t\t<RangeControl\n\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\tkey=\"query-controls-range-control\"\n\t\t\t\tlabel={ __( 'Number of items' ) }\n\t\t\t\tvalue={ numberOfItems }\n\t\t\t\tonChange={ onNumberOfItemsChange }\n\t\t\t\tmin={ minItems }\n\t\t\t\tmax={ maxItems }\n\t\t\t\trequired\n\t\t\t/>\n\t\t),\n\t];\n}\n"]}
1
+ {"version":3,"sources":["@wordpress/components/src/query-controls/index.tsx"],"names":["DEFAULT_MIN_ITEMS","DEFAULT_MAX_ITEMS","MAX_CATEGORIES_SUGGESTIONS","isSingleCategorySelection","props","isMultipleCategorySelection","QueryControls","authorList","selectedAuthorId","numberOfItems","order","orderBy","maxItems","minItems","onAuthorChange","onNumberOfItemsChange","onOrderChange","onOrderByChange","label","value","newOrderBy","newOrder","split","categoriesList","onCategoryChange","selectedCategoryId","categorySuggestions","selectedCategories","map","item","id","name","Object","keys"],"mappings":";;;;;;;;;;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,EAAE,EAAED,IAAI,CAACC,EADkC;AAE3C;AACA;AACA;AACA;AACAX,MAAAA,KAAK,EAAEU,IAAI,CAACE,IAAL,IAAaF,IAAI,CAACV;AANkB,KAAd,CAA9B,CALF;AAcC,IAAA,WAAW,EAAGa,MAAM,CAACC,IAAP,CACb7B,KAAK,CAACsB,mBADO,CAdf;AAiBC,IAAA,QAAQ,EAAGtB,KAAK,CAACoB,gBAjBlB;AAkBC,IAAA,cAAc,EAAGtB;AAlBlB,IAjED,EAsFDY,cAAc,IACb,4BAAC,qBAAD;AACC,IAAA,GAAG,EAAC,8BADL;AAEC,IAAA,UAAU,EAAGP,UAFd;AAGC,IAAA,KAAK,EAAG,cAAI,QAAJ,CAHT;AAIC,IAAA,aAAa,EAAG,cAAI,KAAJ,CAJjB;AAKC,IAAA,gBAAgB,EAAGC,gBALpB;AAMC,IAAA,QAAQ,EAAGM;AANZ,IAvFA,EAgGDC,qBAAqB,IACpB,4BAAC,qBAAD;AACC,IAAA,uBAAuB,MADxB;AAEC,IAAA,GAAG,EAAC,8BAFL;AAGC,IAAA,KAAK,EAAG,cAAI,iBAAJ,CAHT;AAIC,IAAA,KAAK,EAAGN,aAJT;AAKC,IAAA,QAAQ,EAAGM,qBALZ;AAMC,IAAA,GAAG,EAAGF,QANP;AAOC,IAAA,GAAG,EAAGD,QAPP;AAQC,IAAA,QAAQ;AART,IAjGA,CADH,CADD;AAiHA;;eAEcN,a","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport AuthorSelect from './author-select';\nimport CategorySelect from './category-select';\nimport FormTokenField from '../form-token-field';\nimport RangeControl from '../range-control';\nimport SelectControl from '../select-control';\nimport type {\n\tQueryControlsProps,\n\tQueryControlsWithMultipleCategorySelectionProps,\n\tQueryControlsWithSingleCategorySelectionProps,\n} from './types';\n\nconst DEFAULT_MIN_ITEMS = 1;\nconst DEFAULT_MAX_ITEMS = 100;\nconst MAX_CATEGORIES_SUGGESTIONS = 20;\n\nfunction isSingleCategorySelection(\n\tprops: QueryControlsProps\n): props is QueryControlsWithSingleCategorySelectionProps {\n\treturn 'categoriesList' in props;\n}\n\nfunction isMultipleCategorySelection(\n\tprops: QueryControlsProps\n): props is QueryControlsWithMultipleCategorySelectionProps {\n\treturn 'categorySuggestions' in props;\n}\n\n/**\n * Controls to query for posts.\n *\n * ```jsx\n * const MyQueryControls = () => (\n * <QueryControls\n * { ...{ maxItems, minItems, numberOfItems, order, orderBy } }\n * onOrderByChange={ ( newOrderBy ) => {\n * updateQuery( { orderBy: newOrderBy } )\n * }\n * onOrderChange={ ( newOrder ) => {\n * updateQuery( { order: newOrder } )\n * }\n * categoriesList={ categories }\n * selectedCategoryId={ category }\n * onCategoryChange={ ( newCategory ) => {\n * updateQuery( { category: newCategory } )\n * }\n * onNumberOfItemsChange={ ( newNumberOfItems ) => {\n * updateQuery( { numberOfItems: newNumberOfItems } )\n * } }\n * />\n * );\n * ```\n */\nexport function QueryControls( {\n\tauthorList,\n\tselectedAuthorId,\n\tnumberOfItems,\n\torder,\n\torderBy,\n\tmaxItems = DEFAULT_MAX_ITEMS,\n\tminItems = DEFAULT_MIN_ITEMS,\n\tonAuthorChange,\n\tonNumberOfItemsChange,\n\tonOrderChange,\n\tonOrderByChange,\n\t// Props for single OR multiple category selection are not destructured here,\n\t// but instead are destructured inline where necessary.\n\t...props\n}: QueryControlsProps ) {\n\treturn (\n\t\t<>\n\t\t\t{ [\n\t\t\t\tonOrderChange && onOrderByChange && (\n\t\t\t\t\t<SelectControl\n\t\t\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\t\t\tkey=\"query-controls-order-select\"\n\t\t\t\t\t\tlabel={ __( 'Order by' ) }\n\t\t\t\t\t\tvalue={ `${ orderBy }/${ order }` }\n\t\t\t\t\t\toptions={ [\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tlabel: __( 'Newest to oldest' ),\n\t\t\t\t\t\t\t\tvalue: 'date/desc',\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tlabel: __( 'Oldest to newest' ),\n\t\t\t\t\t\t\t\tvalue: 'date/asc',\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t/* translators: label for ordering posts by title in ascending order */\n\t\t\t\t\t\t\t\tlabel: __( 'A → Z' ),\n\t\t\t\t\t\t\t\tvalue: 'title/asc',\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t/* translators: label for ordering posts by title in descending order */\n\t\t\t\t\t\t\t\tlabel: __( 'Z → A' ),\n\t\t\t\t\t\t\t\tvalue: 'title/desc',\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t] }\n\t\t\t\t\t\tonChange={ ( value ) => {\n\t\t\t\t\t\t\tif ( typeof value !== 'string' ) {\n\t\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\tconst [ newOrderBy, newOrder ] = value.split( '/' );\n\t\t\t\t\t\t\tif ( newOrder !== order ) {\n\t\t\t\t\t\t\t\tonOrderChange(\n\t\t\t\t\t\t\t\t\tnewOrder as NonNullable<\n\t\t\t\t\t\t\t\t\t\tQueryControlsProps[ 'order' ]\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}\n\t\t\t\t\t\t\tif ( newOrderBy !== orderBy ) {\n\t\t\t\t\t\t\t\tonOrderByChange(\n\t\t\t\t\t\t\t\t\tnewOrderBy as NonNullable<\n\t\t\t\t\t\t\t\t\t\tQueryControlsProps[ 'orderBy' ]\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}\n\t\t\t\t\t\t} }\n\t\t\t\t\t/>\n\t\t\t\t),\n\t\t\t\tisSingleCategorySelection( props ) &&\n\t\t\t\t\tprops.categoriesList &&\n\t\t\t\t\tprops.onCategoryChange && (\n\t\t\t\t\t\t<CategorySelect\n\t\t\t\t\t\t\tkey=\"query-controls-category-select\"\n\t\t\t\t\t\t\tcategoriesList={ props.categoriesList }\n\t\t\t\t\t\t\tlabel={ __( 'Category' ) }\n\t\t\t\t\t\t\tnoOptionLabel={ __( 'All' ) }\n\t\t\t\t\t\t\tselectedCategoryId={ props.selectedCategoryId }\n\t\t\t\t\t\t\tonChange={ props.onCategoryChange }\n\t\t\t\t\t\t/>\n\t\t\t\t\t),\n\t\t\t\tisMultipleCategorySelection( props ) &&\n\t\t\t\t\tprops.categorySuggestions &&\n\t\t\t\t\tprops.onCategoryChange && (\n\t\t\t\t\t\t<FormTokenField\n\t\t\t\t\t\t\tkey=\"query-controls-categories-select\"\n\t\t\t\t\t\t\tlabel={ __( 'Categories' ) }\n\t\t\t\t\t\t\tvalue={\n\t\t\t\t\t\t\t\tprops.selectedCategories &&\n\t\t\t\t\t\t\t\tprops.selectedCategories.map( ( item ) => ( {\n\t\t\t\t\t\t\t\t\tid: item.id,\n\t\t\t\t\t\t\t\t\t// Keeping the fallback to `item.value` for legacy reasons,\n\t\t\t\t\t\t\t\t\t// even if items of `selectedCategories` should not have a\n\t\t\t\t\t\t\t\t\t// `value` property.\n\t\t\t\t\t\t\t\t\t// @ts-expect-error\n\t\t\t\t\t\t\t\t\tvalue: item.name || item.value,\n\t\t\t\t\t\t\t\t} ) )\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tsuggestions={ Object.keys(\n\t\t\t\t\t\t\t\tprops.categorySuggestions\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\tonChange={ props.onCategoryChange }\n\t\t\t\t\t\t\tmaxSuggestions={ MAX_CATEGORIES_SUGGESTIONS }\n\t\t\t\t\t\t/>\n\t\t\t\t\t),\n\t\t\t\tonAuthorChange && (\n\t\t\t\t\t<AuthorSelect\n\t\t\t\t\t\tkey=\"query-controls-author-select\"\n\t\t\t\t\t\tauthorList={ authorList }\n\t\t\t\t\t\tlabel={ __( 'Author' ) }\n\t\t\t\t\t\tnoOptionLabel={ __( 'All' ) }\n\t\t\t\t\t\tselectedAuthorId={ selectedAuthorId }\n\t\t\t\t\t\tonChange={ onAuthorChange }\n\t\t\t\t\t/>\n\t\t\t\t),\n\t\t\t\tonNumberOfItemsChange && (\n\t\t\t\t\t<RangeControl\n\t\t\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\t\t\tkey=\"query-controls-range-control\"\n\t\t\t\t\t\tlabel={ __( 'Number of items' ) }\n\t\t\t\t\t\tvalue={ numberOfItems }\n\t\t\t\t\t\tonChange={ onNumberOfItemsChange }\n\t\t\t\t\t\tmin={ minItems }\n\t\t\t\t\t\tmax={ maxItems }\n\t\t\t\t\t\trequired\n\t\t\t\t\t/>\n\t\t\t\t),\n\t\t\t] }\n\t\t</>\n\t);\n}\n\nexport default QueryControls;\n"]}
@@ -14,16 +14,17 @@ var _lodash = require("lodash");
14
14
  /**
15
15
  * Returns terms in a tree form.
16
16
  *
17
- * @param {Array} flatTerms Array of terms in flat format.
17
+ * @param flatTerms Array of terms in flat format.
18
18
  *
19
- * @return {Array} Array of terms in tree format.
19
+ * @return Terms in tree format.
20
20
  */
21
21
  function buildTermsTree(flatTerms) {
22
22
  const flatTermsWithParentAndChildren = flatTerms.map(term => {
23
23
  return {
24
24
  children: [],
25
25
  parent: null,
26
- ...term
26
+ ...term,
27
+ id: String(term.id)
27
28
  };
28
29
  });
29
30
  const termsByParent = (0, _lodash.groupBy)(flatTermsWithParentAndChildren, 'parent');
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/components/src/query-controls/terms.js"],"names":["buildTermsTree","flatTerms","flatTermsWithParentAndChildren","map","term","children","parent","termsByParent","null","length","fillWithChildren","terms","id"],"mappings":";;;;;;;AAGA;;AAHA;AACA;AACA;;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASA,cAAT,CAAyBC,SAAzB,EAAqC;AAC3C,QAAMC,8BAA8B,GAAGD,SAAS,CAACE,GAAV,CAAiBC,IAAF,IAAY;AACjE,WAAO;AACNC,MAAAA,QAAQ,EAAE,EADJ;AAENC,MAAAA,MAAM,EAAE,IAFF;AAGN,SAAGF;AAHG,KAAP;AAKA,GANsC,CAAvC;AAQA,QAAMG,aAAa,GAAG,qBAASL,8BAAT,EAAyC,QAAzC,CAAtB;;AACA,MAAKK,aAAa,CAACC,IAAd,IAAsBD,aAAa,CAACC,IAAd,CAAmBC,MAA9C,EAAuD;AACtD,WAAOP,8BAAP;AACA;;AACD,QAAMQ,gBAAgB,GAAKC,KAAF,IAAa;AACrC,WAAOA,KAAK,CAACR,GAAN,CAAaC,IAAF,IAAY;AAC7B,YAAMC,QAAQ,GAAGE,aAAa,CAAEH,IAAI,CAACQ,EAAP,CAA9B;AACA,aAAO,EACN,GAAGR,IADG;AAENC,QAAAA,QAAQ,EACPA,QAAQ,IAAIA,QAAQ,CAACI,MAArB,GACGC,gBAAgB,CAAEL,QAAF,CADnB,GAEG;AALE,OAAP;AAOA,KATM,CAAP;AAUA,GAXD;;AAaA,SAAOK,gBAAgB,CAAEH,aAAa,CAAE,GAAF,CAAb,IAAwB,EAA1B,CAAvB;AACA","sourcesContent":["/**\n * External dependencies\n */\nimport { groupBy } from 'lodash';\n\n/**\n * Returns terms in a tree form.\n *\n * @param {Array} flatTerms Array of terms in flat format.\n *\n * @return {Array} Array of terms in tree format.\n */\nexport function buildTermsTree( flatTerms ) {\n\tconst flatTermsWithParentAndChildren = flatTerms.map( ( term ) => {\n\t\treturn {\n\t\t\tchildren: [],\n\t\t\tparent: null,\n\t\t\t...term,\n\t\t};\n\t} );\n\n\tconst termsByParent = groupBy( flatTermsWithParentAndChildren, 'parent' );\n\tif ( termsByParent.null && termsByParent.null.length ) {\n\t\treturn flatTermsWithParentAndChildren;\n\t}\n\tconst fillWithChildren = ( terms ) => {\n\t\treturn terms.map( ( term ) => {\n\t\t\tconst children = termsByParent[ term.id ];\n\t\t\treturn {\n\t\t\t\t...term,\n\t\t\t\tchildren:\n\t\t\t\t\tchildren && children.length\n\t\t\t\t\t\t? fillWithChildren( children )\n\t\t\t\t\t\t: [],\n\t\t\t};\n\t\t} );\n\t};\n\n\treturn fillWithChildren( termsByParent[ '0' ] || [] );\n}\n"]}
1
+ {"version":3,"sources":["@wordpress/components/src/query-controls/terms.ts"],"names":["buildTermsTree","flatTerms","flatTermsWithParentAndChildren","map","term","children","parent","id","String","termsByParent","null","length","fillWithChildren","terms"],"mappings":";;;;;;;AAGA;;AAHA;AACA;AACA;;AAaA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASA,cAAT,CAAyBC,SAAzB,EAAuE;AAC7E,QAAMC,8BAA2D,GAChED,SAAS,CAACE,GAAV,CAAiBC,IAAF,IAAY;AAC1B,WAAO;AACNC,MAAAA,QAAQ,EAAE,EADJ;AAENC,MAAAA,MAAM,EAAE,IAFF;AAGN,SAAGF,IAHG;AAING,MAAAA,EAAE,EAAEC,MAAM,CAAEJ,IAAI,CAACG,EAAP;AAJJ,KAAP;AAMA,GAPD,CADD;AAUA,QAAME,aAA4B,GAAG,qBACpCP,8BADoC,EAEpC,QAFoC,CAArC;;AAIA,MAAKO,aAAa,CAACC,IAAd,IAAsBD,aAAa,CAACC,IAAd,CAAmBC,MAA9C,EAAuD;AACtD,WAAOT,8BAAP;AACA;;AACD,QAAMU,gBAAgB,GACrBC,KADwB,IAES;AACjC,WAAOA,KAAK,CAACV,GAAN,CAAaC,IAAF,IAAY;AAC7B,YAAMC,QAAQ,GAAGI,aAAa,CAAEL,IAAI,CAACG,EAAP,CAA9B;AACA,aAAO,EACN,GAAGH,IADG;AAENC,QAAAA,QAAQ,EACPA,QAAQ,IAAIA,QAAQ,CAACM,MAArB,GACGC,gBAAgB,CAAEP,QAAF,CADnB,GAEG;AALE,OAAP;AAOA,KATM,CAAP;AAUA,GAbD;;AAeA,SAAOO,gBAAgB,CAAEH,aAAa,CAAE,GAAF,CAAb,IAAwB,EAA1B,CAAvB;AACA","sourcesContent":["/**\n * External dependencies\n */\nimport { groupBy } from 'lodash';\n\n/**\n * Internal dependencies\n */\nimport type {\n\tAuthor,\n\tCategory,\n\tTermWithParentAndChildren,\n\tTermsByParent,\n} from './types';\n\n/**\n * Returns terms in a tree form.\n *\n * @param flatTerms Array of terms in flat format.\n *\n * @return Terms in tree format.\n */\nexport function buildTermsTree( flatTerms: readonly ( Author | Category )[] ) {\n\tconst flatTermsWithParentAndChildren: TermWithParentAndChildren[] =\n\t\tflatTerms.map( ( term ) => {\n\t\t\treturn {\n\t\t\t\tchildren: [],\n\t\t\t\tparent: null,\n\t\t\t\t...term,\n\t\t\t\tid: String( term.id ),\n\t\t\t};\n\t\t} );\n\n\tconst termsByParent: TermsByParent = groupBy(\n\t\tflatTermsWithParentAndChildren,\n\t\t'parent'\n\t);\n\tif ( termsByParent.null && termsByParent.null.length ) {\n\t\treturn flatTermsWithParentAndChildren;\n\t}\n\tconst fillWithChildren = (\n\t\tterms: TermWithParentAndChildren[]\n\t): TermWithParentAndChildren[] => {\n\t\treturn terms.map( ( term ) => {\n\t\t\tconst children = termsByParent[ term.id ];\n\t\t\treturn {\n\t\t\t\t...term,\n\t\t\t\tchildren:\n\t\t\t\t\tchildren && children.length\n\t\t\t\t\t\t? fillWithChildren( children )\n\t\t\t\t\t\t: [],\n\t\t\t};\n\t\t} );\n\t};\n\n\treturn fillWithChildren( termsByParent[ '0' ] || [] );\n}\n"]}
@@ -0,0 +1,6 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"names":[],"mappings":"","sourcesContent":[]}
@@ -5,7 +5,7 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
5
5
  Object.defineProperty(exports, "__esModule", {
6
6
  value: true
7
7
  });
8
- exports.default = void 0;
8
+ exports.default = exports.ResizableBox = void 0;
9
9
 
10
10
  var _element = require("@wordpress/element");
11
11
 
@@ -61,7 +61,7 @@ const HANDLE_STYLES = {
61
61
  bottomLeft: HANDLE_STYLES_OVERRIDES
62
62
  };
63
63
 
64
- function ResizableBox(_ref, ref) {
64
+ function UnforwardedResizableBox(_ref, ref) {
65
65
  let {
66
66
  className,
67
67
  children,
@@ -78,7 +78,8 @@ function ResizableBox(_ref, ref) {
78
78
  }, props), children, showTooltip && (0, _element.createElement)(_resizeTooltip.default, tooltipProps));
79
79
  }
80
80
 
81
- var _default = (0, _element.forwardRef)(ResizableBox);
82
-
81
+ const ResizableBox = (0, _element.forwardRef)(UnforwardedResizableBox);
82
+ exports.ResizableBox = ResizableBox;
83
+ var _default = ResizableBox;
83
84
  exports.default = _default;
84
85
  //# sourceMappingURL=index.js.map