@wordpress/components 23.2.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 (377) hide show
  1. package/CHANGELOG.md +35 -1
  2. package/CONTRIBUTING.md +1 -1
  3. package/build/alignment-matrix-control/utils.js +2 -2
  4. package/build/alignment-matrix-control/utils.js.map +1 -1
  5. package/build/autocomplete/autocompleter-ui.js +1 -3
  6. package/build/autocomplete/autocompleter-ui.js.map +1 -1
  7. package/build/border-box-control/border-box-control-linked-button/component.js.map +1 -1
  8. package/build/border-box-control/border-box-control-linked-button/hook.js.map +1 -1
  9. package/build/border-control/border-control-dropdown/component.js +8 -4
  10. package/build/border-control/border-control-dropdown/component.js.map +1 -1
  11. package/build/button/deprecated.js +8 -6
  12. package/build/button/deprecated.js.map +1 -1
  13. package/build/button/index.js +52 -23
  14. package/build/button/index.js.map +1 -1
  15. package/build/button/types.js +6 -0
  16. package/build/button/types.js.map +1 -0
  17. package/build/color-list-picker/index.js.map +1 -1
  18. package/build/color-list-picker/types.js +6 -0
  19. package/build/color-list-picker/types.js.map +1 -0
  20. package/build/color-palette/index.js +9 -61
  21. package/build/color-palette/index.js.map +1 -1
  22. package/build/color-palette/index.native.js +24 -9
  23. package/build/color-palette/index.native.js.map +1 -1
  24. package/build/color-palette/utils.js +103 -0
  25. package/build/color-palette/utils.js.map +1 -0
  26. package/build/custom-gradient-picker/gradient-bar/utils.js +1 -1
  27. package/build/custom-gradient-picker/gradient-bar/utils.js.map +1 -1
  28. package/build/date-time/date/index.js.map +1 -1
  29. package/build/dropdown/index.js +20 -8
  30. package/build/dropdown/index.js.map +1 -1
  31. package/build/form-token-field/token.js +1 -1
  32. package/build/form-token-field/token.js.map +1 -1
  33. package/build/gradient-picker/index.js +9 -1
  34. package/build/gradient-picker/index.js.map +1 -1
  35. package/build/h-stack/component.js +0 -1
  36. package/build/h-stack/component.js.map +1 -1
  37. package/build/input-control/input-field.js +4 -2
  38. package/build/input-control/input-field.js.map +1 -1
  39. package/build/keyboard-shortcuts/index.js +44 -16
  40. package/build/keyboard-shortcuts/index.js.map +1 -1
  41. package/build/keyboard-shortcuts/types.js +6 -0
  42. package/build/keyboard-shortcuts/types.js.map +1 -0
  43. package/build/modal/index.js +1 -1
  44. package/build/modal/index.js.map +1 -1
  45. package/build/notice/index.js +16 -18
  46. package/build/notice/index.js.map +1 -1
  47. package/build/notice/list.js +23 -8
  48. package/build/notice/list.js.map +1 -1
  49. package/build/notice/types.js +6 -0
  50. package/build/notice/types.js.map +1 -0
  51. package/build/number-control/index.js +1 -1
  52. package/build/number-control/index.js.map +1 -1
  53. package/build/query-controls/author-select.js +7 -3
  54. package/build/query-controls/author-select.js.map +1 -1
  55. package/build/query-controls/category-select.js +7 -3
  56. package/build/query-controls/category-select.js.map +1 -1
  57. package/build/query-controls/index.js +68 -20
  58. package/build/query-controls/index.js.map +1 -1
  59. package/build/query-controls/terms.js +4 -3
  60. package/build/query-controls/terms.js.map +1 -1
  61. package/build/query-controls/types.js +6 -0
  62. package/build/query-controls/types.js.map +1 -0
  63. package/build/slot-fill/bubbles-virtually/fill.js +1 -0
  64. package/build/slot-fill/bubbles-virtually/fill.js.map +1 -1
  65. package/build/slot-fill/slot.js +1 -0
  66. package/build/slot-fill/slot.js.map +1 -1
  67. package/build/slot-fill/use-slot.js +1 -11
  68. package/build/slot-fill/use-slot.js.map +1 -1
  69. package/build/snackbar/index.js.map +1 -1
  70. package/build/snackbar/list.js.map +1 -1
  71. package/build/tab-panel/index.js +36 -8
  72. package/build/tab-panel/index.js.map +1 -1
  73. package/build/tree-grid/index.js +1 -1
  74. package/build/tree-grid/index.js.map +1 -1
  75. package/build/tree-select/index.js +2 -6
  76. package/build/tree-select/index.js.map +1 -1
  77. package/build-module/alignment-matrix-control/utils.js +2 -2
  78. package/build-module/alignment-matrix-control/utils.js.map +1 -1
  79. package/build-module/autocomplete/autocompleter-ui.js +1 -2
  80. package/build-module/autocomplete/autocompleter-ui.js.map +1 -1
  81. package/build-module/border-box-control/border-box-control-linked-button/component.js.map +1 -1
  82. package/build-module/border-box-control/border-box-control-linked-button/hook.js.map +1 -1
  83. package/build-module/border-control/border-control-dropdown/component.js +7 -4
  84. package/build-module/border-control/border-control-dropdown/component.js.map +1 -1
  85. package/build-module/button/deprecated.js +8 -5
  86. package/build-module/button/deprecated.js.map +1 -1
  87. package/build-module/button/index.js +51 -22
  88. package/build-module/button/index.js.map +1 -1
  89. package/build-module/button/types.js +2 -0
  90. package/build-module/button/types.js.map +1 -0
  91. package/build-module/color-list-picker/index.js.map +1 -1
  92. package/build-module/color-list-picker/types.js +2 -0
  93. package/build-module/color-list-picker/types.js.map +1 -0
  94. package/build-module/color-palette/index.js +7 -54
  95. package/build-module/color-palette/index.js.map +1 -1
  96. package/build-module/color-palette/index.native.js +24 -8
  97. package/build-module/color-palette/index.native.js.map +1 -1
  98. package/build-module/color-palette/utils.js +79 -0
  99. package/build-module/color-palette/utils.js.map +1 -0
  100. package/build-module/custom-gradient-picker/gradient-bar/utils.js +1 -1
  101. package/build-module/custom-gradient-picker/gradient-bar/utils.js.map +1 -1
  102. package/build-module/date-time/date/index.js +1 -1
  103. package/build-module/date-time/date/index.js.map +1 -1
  104. package/build-module/dropdown/index.js +19 -8
  105. package/build-module/dropdown/index.js.map +1 -1
  106. package/build-module/form-token-field/token.js +1 -1
  107. package/build-module/form-token-field/token.js.map +1 -1
  108. package/build-module/gradient-picker/index.js +9 -2
  109. package/build-module/gradient-picker/index.js.map +1 -1
  110. package/build-module/h-stack/component.js +0 -1
  111. package/build-module/h-stack/component.js.map +1 -1
  112. package/build-module/input-control/input-field.js +4 -2
  113. package/build-module/input-control/input-field.js.map +1 -1
  114. package/build-module/keyboard-shortcuts/index.js +48 -16
  115. package/build-module/keyboard-shortcuts/index.js.map +1 -1
  116. package/build-module/keyboard-shortcuts/types.js +2 -0
  117. package/build-module/keyboard-shortcuts/types.js.map +1 -0
  118. package/build-module/modal/index.js +1 -1
  119. package/build-module/modal/index.js.map +1 -1
  120. package/build-module/notice/index.js +14 -15
  121. package/build-module/notice/index.js.map +1 -1
  122. package/build-module/notice/list.js +23 -8
  123. package/build-module/notice/list.js.map +1 -1
  124. package/build-module/notice/types.js +2 -0
  125. package/build-module/notice/types.js.map +1 -0
  126. package/build-module/number-control/index.js +1 -1
  127. package/build-module/number-control/index.js.map +1 -1
  128. package/build-module/query-controls/author-select.js +7 -3
  129. package/build-module/query-controls/author-select.js.map +1 -1
  130. package/build-module/query-controls/category-select.js +8 -4
  131. package/build-module/query-controls/category-select.js.map +1 -1
  132. package/build-module/query-controls/index.js +64 -20
  133. package/build-module/query-controls/index.js.map +1 -1
  134. package/build-module/query-controls/terms.js +8 -4
  135. package/build-module/query-controls/terms.js.map +1 -1
  136. package/build-module/query-controls/types.js +2 -0
  137. package/build-module/query-controls/types.js.map +1 -0
  138. package/build-module/slot-fill/bubbles-virtually/fill.js +1 -0
  139. package/build-module/slot-fill/bubbles-virtually/fill.js.map +1 -1
  140. package/build-module/slot-fill/slot.js +1 -0
  141. package/build-module/slot-fill/slot.js.map +1 -1
  142. package/build-module/slot-fill/use-slot.js +2 -12
  143. package/build-module/slot-fill/use-slot.js.map +1 -1
  144. package/build-module/snackbar/index.js.map +1 -1
  145. package/build-module/snackbar/list.js.map +1 -1
  146. package/build-module/tab-panel/index.js +36 -8
  147. package/build-module/tab-panel/index.js.map +1 -1
  148. package/build-module/tree-grid/index.js +1 -1
  149. package/build-module/tree-grid/index.js.map +1 -1
  150. package/build-module/tree-select/index.js +2 -6
  151. package/build-module/tree-select/index.js.map +1 -1
  152. package/build-style/style-rtl.css +5 -0
  153. package/build-style/style.css +5 -0
  154. package/build-types/border-box-control/border-box-control/hook.d.ts +1 -1
  155. package/build-types/border-box-control/border-box-control-linked-button/component.d.ts +1 -1
  156. package/build-types/border-box-control/border-box-control-linked-button/hook.d.ts +171 -160
  157. package/build-types/border-box-control/border-box-control-linked-button/hook.d.ts.map +1 -1
  158. package/build-types/border-box-control/border-box-control-split-controls/hook.d.ts +1 -1
  159. package/build-types/border-control/border-control/hook.d.ts +1 -1
  160. package/build-types/border-control/border-control-dropdown/component.d.ts.map +1 -1
  161. package/build-types/border-control/border-control-dropdown/hook.d.ts +1 -1
  162. package/build-types/button/deprecated.d.ts +143 -7
  163. package/build-types/button/deprecated.d.ts.map +1 -1
  164. package/build-types/button/index.d.ts +20 -3
  165. package/build-types/button/index.d.ts.map +1 -1
  166. package/build-types/button/stories/index.d.ts +20 -0
  167. package/build-types/button/stories/index.d.ts.map +1 -0
  168. package/build-types/button/test/index.d.ts +2 -0
  169. package/build-types/button/test/index.d.ts.map +1 -0
  170. package/build-types/button/types.d.ts +134 -0
  171. package/build-types/button/types.d.ts.map +1 -0
  172. package/build-types/color-list-picker/index.d.ts +5 -0
  173. package/build-types/color-list-picker/index.d.ts.map +1 -0
  174. package/build-types/color-list-picker/types.d.ts +42 -0
  175. package/build-types/color-list-picker/types.d.ts.map +1 -0
  176. package/build-types/color-palette/index.d.ts +2 -4
  177. package/build-types/color-palette/index.d.ts.map +1 -1
  178. package/build-types/color-palette/stories/index.d.ts +2 -2
  179. package/build-types/color-palette/styles.d.ts +1 -1
  180. package/build-types/color-palette/types.d.ts +1 -1
  181. package/build-types/color-palette/types.d.ts.map +1 -1
  182. package/build-types/color-palette/utils.d.ts +14 -0
  183. package/build-types/color-palette/utils.d.ts.map +1 -0
  184. package/build-types/color-picker/styles.d.ts +2 -2
  185. package/build-types/date-time/date/index.d.ts.map +1 -1
  186. package/build-types/date-time/date/styles.d.ts +3 -3
  187. package/build-types/dropdown/index.d.ts +4 -4
  188. package/build-types/dropdown/index.d.ts.map +1 -1
  189. package/build-types/dropdown/stories/index.d.ts.map +1 -1
  190. package/build-types/dropdown/types.d.ts +9 -10
  191. package/build-types/dropdown/types.d.ts.map +1 -1
  192. package/build-types/font-size-picker/styles.d.ts +2 -2
  193. package/build-types/h-stack/component.d.ts +0 -1
  194. package/build-types/h-stack/component.d.ts.map +1 -1
  195. package/build-types/input-control/input-field.d.ts.map +1 -1
  196. package/build-types/keyboard-shortcuts/index.d.ts +38 -0
  197. package/build-types/keyboard-shortcuts/index.d.ts.map +1 -0
  198. package/build-types/keyboard-shortcuts/stories/index.d.ts +12 -0
  199. package/build-types/keyboard-shortcuts/stories/index.d.ts.map +1 -0
  200. package/build-types/keyboard-shortcuts/test/index.d.ts +2 -0
  201. package/build-types/keyboard-shortcuts/test/index.d.ts.map +1 -0
  202. package/build-types/keyboard-shortcuts/types.d.ts +48 -0
  203. package/build-types/keyboard-shortcuts/types.d.ts.map +1 -0
  204. package/build-types/modal/index.d.ts.map +1 -1
  205. package/build-types/navigator/navigator-back-button/component.d.ts +1 -1
  206. package/build-types/navigator/navigator-back-button/hook.d.ts +2 -2
  207. package/build-types/navigator/navigator-button/component.d.ts +1 -1
  208. package/build-types/navigator/navigator-button/hook.d.ts +2 -2
  209. package/build-types/notice/index.d.ts +16 -0
  210. package/build-types/notice/index.d.ts.map +1 -0
  211. package/build-types/notice/list.d.ts +32 -0
  212. package/build-types/notice/list.d.ts.map +1 -0
  213. package/build-types/notice/stories/index.d.ts +17 -0
  214. package/build-types/notice/stories/index.d.ts.map +1 -0
  215. package/build-types/notice/test/index.d.ts +2 -0
  216. package/build-types/notice/test/index.d.ts.map +1 -0
  217. package/build-types/notice/test/list.d.ts +2 -0
  218. package/build-types/notice/test/list.d.ts.map +1 -0
  219. package/build-types/notice/types.d.ts +128 -0
  220. package/build-types/notice/types.d.ts.map +1 -0
  221. package/build-types/number-control/styles/number-control-styles.d.ts +2 -2
  222. package/build-types/number-control/styles/number-control-styles.d.ts.map +1 -1
  223. package/build-types/placeholder/stories/index.d.ts.map +1 -1
  224. package/build-types/query-controls/author-select.d.ts +4 -0
  225. package/build-types/query-controls/author-select.d.ts.map +1 -0
  226. package/build-types/query-controls/category-select.d.ts +4 -0
  227. package/build-types/query-controls/category-select.d.ts.map +1 -0
  228. package/build-types/query-controls/index.d.ts +30 -0
  229. package/build-types/query-controls/index.d.ts.map +1 -0
  230. package/build-types/query-controls/stories/index.d.ts +13 -0
  231. package/build-types/query-controls/stories/index.d.ts.map +1 -0
  232. package/build-types/query-controls/terms.d.ts +13 -0
  233. package/build-types/query-controls/terms.d.ts.map +1 -0
  234. package/build-types/query-controls/test/terms.d.ts +2 -0
  235. package/build-types/query-controls/test/terms.d.ts.map +1 -0
  236. package/build-types/query-controls/types.d.ts +131 -0
  237. package/build-types/query-controls/types.d.ts.map +1 -0
  238. package/build-types/range-control/index.d.ts +1 -1
  239. package/build-types/slot-fill/bubbles-virtually/fill.d.ts.map +1 -1
  240. package/build-types/slot-fill/use-slot.d.ts.map +1 -1
  241. package/build-types/snackbar/index.d.ts +9 -2
  242. package/build-types/snackbar/index.d.ts.map +1 -1
  243. package/build-types/snackbar/list.d.ts.map +1 -1
  244. package/build-types/snackbar/types.d.ts +15 -88
  245. package/build-types/snackbar/types.d.ts.map +1 -1
  246. package/build-types/tab-panel/index.d.ts.map +1 -1
  247. package/build-types/tab-panel/types.d.ts +1 -1
  248. package/build-types/tab-panel/types.d.ts.map +1 -1
  249. package/build-types/toggle-group-control/stories/index.d.ts.map +1 -1
  250. package/build-types/tree-select/index.d.ts.map +1 -1
  251. package/build-types/ui/form-group/form-group.d.ts +2 -2
  252. package/package.json +18 -17
  253. package/src/alignment-matrix-control/utils.tsx +2 -2
  254. package/src/autocomplete/autocompleter-ui.js +1 -2
  255. package/src/autocomplete/test/index.js +1 -5
  256. package/src/border-box-control/border-box-control-linked-button/component.tsx +1 -1
  257. package/src/border-box-control/border-box-control-linked-button/hook.ts +1 -1
  258. package/src/border-control/border-control-dropdown/component.tsx +9 -8
  259. package/src/box-control/test/index.js +11 -35
  260. package/src/button/README.md +49 -55
  261. package/src/button/{deprecated.js → deprecated.tsx} +19 -4
  262. package/src/button/{index.js → index.tsx} +95 -34
  263. package/src/button/stories/index.tsx +106 -0
  264. package/src/button/style.scss +3 -2
  265. package/src/button/test/{index.js → index.tsx} +30 -7
  266. package/src/button/types.ts +138 -0
  267. package/src/checkbox-control/test/index.tsx +1 -5
  268. package/src/color-list-picker/{index.js → index.tsx} +3 -2
  269. package/src/color-list-picker/types.ts +46 -0
  270. package/src/color-palette/README.md +1 -1
  271. package/src/color-palette/index.native.js +11 -4
  272. package/src/color-palette/index.tsx +11 -67
  273. package/src/color-palette/test/index.tsx +4 -14
  274. package/src/color-palette/test/utils.ts +1 -1
  275. package/src/color-palette/types.ts +1 -1
  276. package/src/color-palette/utils.ts +98 -0
  277. package/src/color-picker/test/index.js +6 -15
  278. package/src/combobox-control/test/index.js +1 -6
  279. package/src/confirm-dialog/test/index.js +9 -29
  280. package/src/custom-gradient-picker/gradient-bar/utils.js +1 -1
  281. package/src/date-time/date/index.tsx +2 -1
  282. package/src/date-time/date/test/index.tsx +2 -8
  283. package/src/date-time/time/test/index.tsx +9 -29
  284. package/src/dimension-control/test/index.test.js +2 -8
  285. package/src/disabled/test/index.tsx +1 -5
  286. package/src/draggable/test/index.native.js +4 -4
  287. package/src/dropdown/README.md +1 -8
  288. package/src/dropdown/index.tsx +17 -6
  289. package/src/dropdown/stories/index.tsx +3 -3
  290. package/src/dropdown/test/index.tsx +2 -8
  291. package/src/dropdown/types.ts +9 -10
  292. package/src/dropdown-menu/README.md +1 -1
  293. package/src/dropdown-menu/stories/index.js +96 -27
  294. package/src/dropdown-menu/test/index.js +2 -8
  295. package/src/external-link/test/index.tsx +1 -6
  296. package/src/focal-point-picker/test/index.js +3 -11
  297. package/src/font-size-picker/test/index.tsx +14 -44
  298. package/src/form-file-upload/test/index.tsx +2 -17
  299. package/src/form-toggle/test/index.tsx +1 -5
  300. package/src/form-token-field/test/index.tsx +80 -163
  301. package/src/form-token-field/token.tsx +1 -1
  302. package/src/gradient-picker/index.js +15 -4
  303. package/src/guide/test/index.js +5 -17
  304. package/src/h-stack/component.tsx +0 -1
  305. package/src/higher-order/with-filters/test/index.js +24 -24
  306. package/src/higher-order/with-focus-outside/test/index.js +11 -25
  307. package/src/higher-order/with-focus-return/test/index.js +1 -5
  308. package/src/input-control/input-field.tsx +3 -1
  309. package/src/input-control/test/index.js +1 -6
  310. package/src/isolated-event-container/test/index.js +2 -8
  311. package/src/keyboard-shortcuts/README.md +1 -1
  312. package/src/keyboard-shortcuts/index.tsx +93 -0
  313. package/src/keyboard-shortcuts/stories/index.tsx +60 -0
  314. package/src/keyboard-shortcuts/test/{index.js → index.tsx} +16 -6
  315. package/src/keyboard-shortcuts/types.ts +51 -0
  316. package/src/modal/index.tsx +1 -2
  317. package/src/navigable-container/test/navigable-menu.js +5 -17
  318. package/src/navigable-container/test/tababble-container.js +3 -11
  319. package/src/navigation/test/index.js +3 -11
  320. package/src/navigator/test/index.tsx +6 -20
  321. package/src/notice/README.md +89 -42
  322. package/src/notice/{index.js → index.tsx} +28 -20
  323. package/src/notice/list.tsx +72 -0
  324. package/src/notice/stories/index.tsx +119 -0
  325. package/src/notice/test/__snapshots__/{index.js.snap → index.tsx.snap} +0 -0
  326. package/src/notice/test/{index.js → index.tsx} +7 -4
  327. package/src/notice/test/{list.js → list.tsx} +0 -0
  328. package/src/notice/types.ts +136 -0
  329. package/src/number-control/index.tsx +1 -1
  330. package/src/number-control/test/index.tsx +28 -86
  331. package/src/panel/test/body.js +2 -8
  332. package/src/placeholder/stories/index.tsx +1 -0
  333. package/src/query-controls/README.md +56 -56
  334. package/src/query-controls/author-select.tsx +37 -0
  335. package/src/query-controls/category-select.tsx +46 -0
  336. package/src/query-controls/index.tsx +192 -0
  337. package/src/query-controls/stories/index.tsx +205 -0
  338. package/src/query-controls/terms.ts +57 -0
  339. package/src/query-controls/test/{terms.js → terms.ts} +36 -20
  340. package/src/query-controls/types.ts +150 -0
  341. package/src/select-control/test/select-control.tsx +1 -6
  342. package/src/slot-fill/bubbles-virtually/fill.js +1 -0
  343. package/src/slot-fill/slot.js +1 -1
  344. package/src/slot-fill/use-slot.js +6 -16
  345. package/src/snackbar/index.tsx +6 -5
  346. package/src/snackbar/list.tsx +4 -2
  347. package/src/snackbar/types.ts +18 -92
  348. package/src/tab-panel/index.tsx +38 -16
  349. package/src/tab-panel/style.scss +8 -0
  350. package/src/tab-panel/test/index.tsx +35 -7
  351. package/src/tab-panel/types.ts +1 -1
  352. package/src/theme/test/index.tsx +4 -4
  353. package/src/toggle-group-control/stories/index.tsx +1 -0
  354. package/src/toggle-group-control/test/index.tsx +7 -23
  355. package/src/toolbar/stories/index.js +75 -72
  356. package/src/tools-panel/stories/index.js +3 -0
  357. package/src/tools-panel/test/index.js +1 -1
  358. package/src/tree-grid/index.js +1 -1
  359. package/src/tree-select/index.tsx +3 -6
  360. package/src/ui/context/test/context-connect.tsx +2 -0
  361. package/src/ui/context/test/wordpress-component.tsx +2 -0
  362. package/src/unit-control/test/index.tsx +21 -74
  363. package/src/utils/hooks/test/use-latest-ref.js +15 -18
  364. package/tsconfig.json +1 -4
  365. package/tsconfig.tsbuildinfo +1 -1
  366. package/build-types/radio-context/index.d.ts +0 -6
  367. package/build-types/radio-context/index.d.ts.map +0 -1
  368. package/src/button/stories/index.js +0 -179
  369. package/src/keyboard-shortcuts/index.js +0 -56
  370. package/src/notice/list.js +0 -48
  371. package/src/notice/stories/index.js +0 -46
  372. package/src/query-controls/author-select.js +0 -23
  373. package/src/query-controls/category-select.js +0 -31
  374. package/src/query-controls/index.js +0 -122
  375. package/src/query-controls/terms.js +0 -40
  376. package/src/toolbar/stories/toolbar-button.js +0 -32
  377. package/src/toolbar/stories/toolbar-group.js +0 -33
@@ -9,19 +9,34 @@ import classnames from 'classnames';
9
9
  * Internal dependencies
10
10
  */
11
11
 
12
- import Notice from './';
12
+ import Notice from '.';
13
13
 
14
14
  const noop = () => {};
15
15
  /**
16
- * Renders a list of notices.
16
+ * `NoticeList` is a component used to render a collection of notices.
17
17
  *
18
- * @param {Object} $0 Props passed to the component.
19
- * @param {Array} $0.notices Array of notices to render.
20
- * @param {Function} $0.onRemove Function called when a notice should be removed / dismissed.
21
- * @param {Object} $0.className Name of the class used by the component.
22
- * @param {Object} $0.children Array of children to be rendered inside the notice list.
18
+ *```jsx
19
+ * import { Notice, NoticeList } from `@wordpress/components`;
23
20
  *
24
- * @return {Object} The rendered notices list.
21
+ * const MyNoticeList = () => {
22
+ * const [ notices, setNotices ] = useState( [
23
+ * {
24
+ * id: 'second-notice',
25
+ * content: 'second notice content',
26
+ * },
27
+ * {
28
+ * id: 'fist-notice',
29
+ * content: 'first notice content',
30
+ * },
31
+ * ] );
32
+ *
33
+ * const removeNotice = ( id ) => {
34
+ * setNotices( notices.filter( ( notice ) => notice.id !== id ) );
35
+ * };
36
+ *
37
+ * return <NoticeList notices={ notices } onRemove={ removeNotice } />;
38
+ *};
39
+ *```
25
40
  */
26
41
 
27
42
 
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/components/src/notice/list.js"],"names":["classnames","Notice","noop","NoticeList","notices","onRemove","className","children","removeNotice","id","reverse","map","notice","content","restNotice"],"mappings":";;;AAAA;AACA;AACA;AACA,OAAOA,UAAP,MAAuB,YAAvB;AAEA;AACA;AACA;;AACA,OAAOC,MAAP,MAAmB,IAAnB;;AAEA,MAAMC,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,GAAGN,UAAU,CAAE,wBAAF,EAA4BM,SAA5B,CAAtB;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,cAAC,MAAD,eACME,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;;AAED,eAAeV,UAAf","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":["classnames","Notice","noop","NoticeList","notices","onRemove","className","children","removeNotice","id","reverse","map","notice","content","restNotice"],"mappings":";;;AAAA;AACA;AACA;AACA,OAAOA,UAAP,MAAuB,YAAvB;AAEA;AACA;AACA;;AACA,OAAOC,MAAP,MAAmB,GAAnB;;AAIA,MAAMC,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,GAAGN,UAAU,CAAE,wBAAF,EAA4BM,SAA5B,CAAtB;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,cAAC,MAAD,eACME,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;;AAED,eAAeV,UAAf","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,2 @@
1
+ export {};
2
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"names":[],"mappings":"","sourcesContent":[]}
@@ -51,7 +51,7 @@ function UnforwardedNumberControl(_ref, forwardedRef) {
51
51
  } = _ref;
52
52
 
53
53
  if (hideHTMLArrows) {
54
- deprecated('hideHTMLArrows', {
54
+ deprecated('wp.components.NumberControl hideHTMLArrows prop ', {
55
55
  alternative: 'spinControls="none"',
56
56
  since: '6.2',
57
57
  version: '6.3'
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/components/src/number-control/index.tsx"],"names":["classNames","useRef","forwardRef","isRTL","__","plus","plusIcon","reset","resetIcon","useMergeRefs","deprecated","Input","SpinButton","inputControlActionTypes","add","subtract","roundClamp","ensureNumber","isValueEmpty","HStack","Spacer","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","PRESS_UP","PRESS_DOWN","DRAG","x","y","enableShift","modifier","directionModifier","ceil","abs","sign","distance","PRESS_ENTER","COMMIT","applyEmptyValue","buildSpinButtonClickHandler","String","target","current","baseState","NumberControl"],"mappings":";;;AAAA;AACA;AACA;AACA,OAAOA,UAAP,MAAuB,YAAvB;;AAGA;AACA;AACA;AACA,SAASC,MAAT,EAAiBC,UAAjB,QAAmC,oBAAnC;AACA,SAASC,KAAT,EAAgBC,EAAhB,QAA0B,iBAA1B;AACA,SAASC,IAAI,IAAIC,QAAjB,EAA2BC,KAAK,IAAIC,SAApC,QAAqD,kBAArD;AACA,SAASC,YAAT,QAA6B,oBAA7B;AACA,OAAOC,UAAP,MAAuB,uBAAvB;AAEA;AACA;AACA;;AACA,SAASC,KAAT,EAAgBC,UAAhB,QAAkC,gCAAlC;AACA,OAAO,KAAKC,uBAAZ,MAAyC,kCAAzC;AACA,SAASC,GAAT,EAAcC,QAAd,EAAwBC,UAAxB,QAA0C,eAA1C;AACA,SAASC,YAAT,EAAuBC,YAAvB,QAA2C,iBAA3C;AAGA,SAASC,MAAT,QAAuB,YAAvB;AACA,SAASC,MAAT,QAAuB,WAAvB;;AAEA,MAAMC,IAAI,GAAG,MAAM,CAAE,CAArB;;AAEA,SAASC,wBAAT,OAsBCC,YAtBD,EAuBE;AAAA,MAtBD;AACCC,IAA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BAA2B,CACpC,IADoC,CANtC;AASC,MAAA,IAAI,EAAG/C;AATR,MADD,EAYC,cAAC,UAAD;AACC,MAAA,IAAI,EAAGnC,SADR;AAEC,MAAA,OAAO,MAFR;AAGC,qBAAY,MAHb;AAIC,oBAAaJ,EAAE,CAAE,WAAF,CAJhB;AAKC,MAAA,QAAQ,EAAG,CAAC,CALb;AAMC,MAAA,OAAO,EAAGsF,2BAA2B,CACpC,MADoC,CANtC;AASC,MAAA,IAAI,EAAG/C;AATR,MAZD,CADD,CAFD,CADD,GA+BCC,MAtDH;AAyDC,IAAA,QAAQ,EAAGC;AAzDZ,KADD;AA6DA;;AAED,OAAO,MAAMkD,aAAa,GAAG7F,UAAU,CAAEoB,wBAAF,CAAhC;AAEP,eAAeyE,aAAf","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":["classNames","useRef","forwardRef","isRTL","__","plus","plusIcon","reset","resetIcon","useMergeRefs","deprecated","Input","SpinButton","inputControlActionTypes","add","subtract","roundClamp","ensureNumber","isValueEmpty","HStack","Spacer","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","PRESS_UP","PRESS_DOWN","DRAG","x","y","enableShift","modifier","directionModifier","ceil","abs","sign","distance","PRESS_ENTER","COMMIT","applyEmptyValue","buildSpinButtonClickHandler","String","target","current","baseState","NumberControl"],"mappings":";;;AAAA;AACA;AACA;AACA,OAAOA,UAAP,MAAuB,YAAvB;;AAGA;AACA;AACA;AACA,SAASC,MAAT,EAAiBC,UA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MuB,SAAS,GAAGzB,yBAAyB,CAAEC,KAAF,EAASC,MAAT,CAA3C;AACA,kCAAO9C,gBAAP,aAAOA,gBAAP,uBAAOA,gBAAgB,CAAIqE,SAAJ,EAAevB,MAAf,CAAvB,iEAAkDuB,SAAlD;AACA,KApBF;AAqBC,IAAA,IAAI,EAAGnD,IArBR;AAsBC,IAAA,MAAM,EACLd,YAAY,KAAK,QAAjB,GACC,8BACGe,MADH,EAEC,cAAC,MAAD;AAAQ,MAAA,YAAY,EAAG,CAAvB;AAA2B,MAAA,WAAW,EAAG;AAAzC,OACC,cAAC,MAAD;AAAQ,MAAA,OAAO,EAAG;AAAlB,OACC,cAAC,UAAD;AACC,MAAA,IAAI,EAAGtC,QADR;AAEC,MAAA,OAAO,MAFR;AAGC,qBAAY,MAHb;AAIC,oBAAaF,EAAE,CAAE,WAAF,CAJhB;AAKC,MAAA,QAAQ,EAAG,CAAC,CALb;AAMC,MAAA,OAAO,EAAGsF,2BAA2B,CACpC,IADoC,CANtC;AASC,MAAA,IAAI,EAAG/C;AATR,MADD,EAYC,cAAC,UAAD;AACC,MAAA,IAAI,EAAGnC,SADR;AAEC,MAAA,OAAO,MAFR;AAGC,qBAAY,MAHb;AAIC,oBAAaJ,EAAE,CAAE,WAAF,CAJhB;AAKC,MAAA,QAAQ,EAAG,CAAC,CALb;AAMC,MAAA,OAAO,EAAGsF,2BAA2B,CACpC,MADoC,CANtC;AASC,MAAA,IAAI,EAAG/C;AATR,MAZD,CADD,CAFD,CADD,GA+BCC,MAtDH;AAyDC,IAAA,QAAQ,EAAGC;AAzDZ,KADD;AA6DA;;AAED,OAAO,MAAMkD,aAAa,GAAG7F,UAAU,CAAEoB,wBAAF,CAAhC;AAEP,eAAeyE,aAAf","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"]}
@@ -11,16 +11,20 @@ export default function AuthorSelect(_ref) {
11
11
  noOptionLabel,
12
12
  authorList,
13
13
  selectedAuthorId,
14
- onChange
14
+ onChange: onChangeProp
15
15
  } = _ref;
16
16
  if (!authorList) return null;
17
17
  const termsTree = buildTermsTree(authorList);
18
18
  return createElement(TreeSelect, {
19
19
  label,
20
20
  noOptionLabel,
21
- onChange,
21
+ // Since the `multiple` attribute is not passed to `TreeSelect`, it is
22
+ // safe to assume that the argument of `onChange` cannot be `string[]`.
23
+ // The correct solution would be to type `SelectControl` better, so that
24
+ // the type of `value` and `onChange` vary depending on `multiple`.
25
+ onChange: onChangeProp,
22
26
  tree: termsTree,
23
- selectedId: selectedAuthorId
27
+ selectedId: selectedAuthorId !== undefined ? String(selectedAuthorId) : undefined
24
28
  });
25
29
  }
26
30
  //# sourceMappingURL=author-select.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/components/src/query-controls/author-select.js"],"names":["buildTermsTree","TreeSelect","AuthorSelect","label","noOptionLabel","authorList","selectedAuthorId","onChange","termsTree"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,cAAT,QAA+B,SAA/B;AACA,OAAOC,UAAP,MAAuB,gBAAvB;AAEA,eAAe,SAASC,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,GAAGR,cAAc,CAAEK,UAAF,CAAhC;AACA,SACC,cAAC,UAAD;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":["buildTermsTree","TreeSelect","AuthorSelect","label","noOptionLabel","authorList","selectedAuthorId","onChange","onChangeProp","termsTree","undefined","String"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,cAAT,QAA+B,SAA/B;AACA,OAAOC,UAAP,MAAuB,gBAAvB;AAIA,eAAe,SAASC,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,GAAGT,cAAc,CAAEK,UAAF,CAAhC;AACA,SACC,cAAC,UAAD;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"]}
@@ -6,10 +6,10 @@ import { createElement } from "@wordpress/element";
6
6
  */
7
7
  import { buildTermsTree } from './terms';
8
8
  import TreeSelect from '../tree-select';
9
+
9
10
  /**
10
11
  * WordPress dependencies
11
12
  */
12
-
13
13
  import { useMemo } from '@wordpress/element';
14
14
  export default function CategorySelect(_ref) {
15
15
  let {
@@ -17,7 +17,7 @@ export default function CategorySelect(_ref) {
17
17
  noOptionLabel,
18
18
  categoriesList,
19
19
  selectedCategoryId,
20
- onChange,
20
+ onChange: onChangeProp,
21
21
  ...props
22
22
  } = _ref;
23
23
  const termsTree = useMemo(() => {
@@ -26,9 +26,13 @@ export default function CategorySelect(_ref) {
26
26
  return createElement(TreeSelect, _extends({
27
27
  label,
28
28
  noOptionLabel,
29
- onChange,
29
+ // Since the `multiple` attribute is not passed to `TreeSelect`, it is
30
+ // safe to assume that the argument of `onChange` cannot be `string[]`.
31
+ // The correct solution would be to type `SelectControl` better, so that
32
+ // the type of `value` and `onChange` vary depending on `multiple`.
33
+ onChange: onChangeProp,
30
34
  tree: termsTree,
31
- selectedId: selectedCategoryId
35
+ selectedId: selectedCategoryId !== undefined ? String(selectedCategoryId) : undefined
32
36
  }, props));
33
37
  }
34
38
  //# sourceMappingURL=category-select.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/components/src/query-controls/category-select.js"],"names":["buildTermsTree","TreeSelect","useMemo","CategorySelect","label","noOptionLabel","categoriesList","selectedCategoryId","onChange","props","termsTree"],"mappings":";;;AAAA;AACA;AACA;AACA,SAASA,cAAT,QAA+B,SAA/B;AACA,OAAOC,UAAP,MAAuB,gBAAvB;AACA;AACA;AACA;;AACA,SAASC,OAAT,QAAwB,oBAAxB;AAEA,eAAe,SAASC,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,GAAGR,OAAO,CAAE,MAAM;AAChC,WAAOF,cAAc,CAAEM,cAAF,CAArB;AACA,GAFwB,EAEtB,CAAEA,cAAF,CAFsB,CAAzB;AAIA,SACC,cAAC,UAAD;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":["buildTermsTree","TreeSelect","useMemo","CategorySelect","label","noOptionLabel","categoriesList","selectedCategoryId","onChange","onChangeProp","props","termsTree","undefined","String"],"mappings":";;;AAAA;AACA;AACA;AACA,SAASA,cAAT,QAA+B,SAA/B;AACA,OAAOC,UAAP,MAAuB,gBAAvB;;AAGA;AACA;AACA;AACA,SAASC,OAAT,QAAwB,oBAAxB;AAGA,eAAe,SAASC,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,GAAGT,OAAO,CAAE,MAAM;AAChC,WAAOF,cAAc,CAAEM,cAAF,CAArB;AACA,GAFwB,EAEtB,CAAEA,cAAF,CAFsB,CAAzB;AAIA,SACC,cAAC,UAAD;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"]}
@@ -1,4 +1,4 @@
1
- import { createElement } from "@wordpress/element";
1
+ import { createElement, Fragment } from "@wordpress/element";
2
2
 
3
3
  /**
4
4
  * WordPress dependencies
@@ -8,32 +8,67 @@ import { __ } from '@wordpress/i18n';
8
8
  * Internal dependencies
9
9
  */
10
10
 
11
- import CategorySelect from './category-select';
12
- import { RangeControl, SelectControl, FormTokenField } from '../';
13
11
  import AuthorSelect from './author-select';
12
+ import CategorySelect from './category-select';
13
+ import FormTokenField from '../form-token-field';
14
+ import RangeControl from '../range-control';
15
+ import SelectControl from '../select-control';
14
16
  const DEFAULT_MIN_ITEMS = 1;
15
17
  const DEFAULT_MAX_ITEMS = 100;
16
18
  const MAX_CATEGORIES_SUGGESTIONS = 20;
17
- export default function QueryControls(_ref) {
19
+
20
+ function isSingleCategorySelection(props) {
21
+ return 'categoriesList' in props;
22
+ }
23
+
24
+ function isMultipleCategorySelection(props) {
25
+ return 'categorySuggestions' in props;
26
+ }
27
+ /**
28
+ * Controls to query for posts.
29
+ *
30
+ * ```jsx
31
+ * const MyQueryControls = () => (
32
+ * <QueryControls
33
+ * { ...{ maxItems, minItems, numberOfItems, order, orderBy } }
34
+ * onOrderByChange={ ( newOrderBy ) => {
35
+ * updateQuery( { orderBy: newOrderBy } )
36
+ * }
37
+ * onOrderChange={ ( newOrder ) => {
38
+ * updateQuery( { order: newOrder } )
39
+ * }
40
+ * categoriesList={ categories }
41
+ * selectedCategoryId={ category }
42
+ * onCategoryChange={ ( newCategory ) => {
43
+ * updateQuery( { category: newCategory } )
44
+ * }
45
+ * onNumberOfItemsChange={ ( newNumberOfItems ) => {
46
+ * updateQuery( { numberOfItems: newNumberOfItems } )
47
+ * } }
48
+ * />
49
+ * );
50
+ * ```
51
+ */
52
+
53
+
54
+ export function QueryControls(_ref) {
18
55
  let {
19
56
  authorList,
20
57
  selectedAuthorId,
21
- categoriesList,
22
- selectedCategoryId,
23
- categorySuggestions,
24
- selectedCategories,
25
58
  numberOfItems,
26
59
  order,
27
60
  orderBy,
28
61
  maxItems = DEFAULT_MAX_ITEMS,
29
62
  minItems = DEFAULT_MIN_ITEMS,
30
- onCategoryChange,
31
63
  onAuthorChange,
32
64
  onNumberOfItemsChange,
33
65
  onOrderChange,
34
- onOrderByChange
66
+ onOrderByChange,
67
+ // Props for single OR multiple category selection are not destructured here,
68
+ // but instead are destructured inline where necessary.
69
+ ...props
35
70
  } = _ref;
36
- return [onOrderChange && onOrderByChange && createElement(SelectControl, {
71
+ return createElement(Fragment, null, [onOrderChange && onOrderByChange && createElement(SelectControl, {
37
72
  __nextHasNoMarginBottom: true,
38
73
  key: "query-controls-order-select",
39
74
  label: __('Order by'),
@@ -54,6 +89,10 @@ export default function QueryControls(_ref) {
54
89
  value: 'title/desc'
55
90
  }],
56
91
  onChange: value => {
92
+ if (typeof value !== 'string') {
93
+ return;
94
+ }
95
+
57
96
  const [newOrderBy, newOrder] = value.split('/');
58
97
 
59
98
  if (newOrder !== order) {
@@ -64,22 +103,26 @@ export default function QueryControls(_ref) {
64
103
  onOrderByChange(newOrderBy);
65
104
  }
66
105
  }
67
- }), categoriesList && onCategoryChange && createElement(CategorySelect, {
106
+ }), isSingleCategorySelection(props) && props.categoriesList && props.onCategoryChange && createElement(CategorySelect, {
68
107
  key: "query-controls-category-select",
69
- categoriesList: categoriesList,
108
+ categoriesList: props.categoriesList,
70
109
  label: __('Category'),
71
110
  noOptionLabel: __('All'),
72
- selectedCategoryId: selectedCategoryId,
73
- onChange: onCategoryChange
74
- }), categorySuggestions && onCategoryChange && createElement(FormTokenField, {
111
+ selectedCategoryId: props.selectedCategoryId,
112
+ onChange: props.onCategoryChange
113
+ }), isMultipleCategorySelection(props) && props.categorySuggestions && props.onCategoryChange && createElement(FormTokenField, {
75
114
  key: "query-controls-categories-select",
76
115
  label: __('Categories'),
77
- value: selectedCategories && selectedCategories.map(item => ({
116
+ value: props.selectedCategories && props.selectedCategories.map(item => ({
78
117
  id: item.id,
118
+ // Keeping the fallback to `item.value` for legacy reasons,
119
+ // even if items of `selectedCategories` should not have a
120
+ // `value` property.
121
+ // @ts-expect-error
79
122
  value: item.name || item.value
80
123
  })),
81
- suggestions: Object.keys(categorySuggestions),
82
- onChange: onCategoryChange,
124
+ suggestions: Object.keys(props.categorySuggestions),
125
+ onChange: props.onCategoryChange,
83
126
  maxSuggestions: MAX_CATEGORIES_SUGGESTIONS
84
127
  }), onAuthorChange && createElement(AuthorSelect, {
85
128
  key: "query-controls-author-select",
@@ -97,6 +140,7 @@ export default function QueryControls(_ref) {
97
140
  min: minItems,
98
141
  max: maxItems,
99
142
  required: true
100
- })];
143
+ })]);
101
144
  }
145
+ export default QueryControls;
102
146
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/components/src/query-controls/index.js"],"names":["__","CategorySelect","RangeControl","SelectControl","FormTokenField","AuthorSelect","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":";;AAAA;AACA;AACA;AACA,SAASA,EAAT,QAAmB,iBAA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AAA,GAAG,EAAC,8BADL;AAEC,IAAA,UAAU,EAAGZ,UAFd;AAGC,IAAA,KAAK,EAAGV,EAAE,CAAE,QAAF,CAHX;AAIC,IAAA,aAAa,EAAGA,EAAE,CAAE,KAAF,CAJnB;AAKC,IAAA,gBAAgB,EAAGW,gBALpB;AAMC,IAAA,QAAQ,EAAGW;AANZ,IAjEK,EA0ENC,qBAAqB,IACpB,cAAC,YAAD;AACC,IAAA,uBAAuB,MADxB;AAEC,IAAA,GAAG,EAAC,8BAFL;AAGC,IAAA,KAAK,EAAGvB,EAAE,CAAE,iBAAF,CAHX;AAIC,IAAA,KAAK,EAAGgB,aAJT;AAKC,IAAA,QAAQ,EAAGO,qBALZ;AAMC,IAAA,GAAG,EAAGH,QANP;AAOC,IAAA,GAAG,EAAGD,QAPP;AAQC,IAAA,QAAQ;AART,IA3EK,CAAP;AAuFA","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\t__nextHasNoMarginBottom\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":["__","AuthorSelect","CategorySelect","FormTokenField","RangeControl","SelectControl","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":";;AAAA;AACA;AACA;AACA,SAASA,EAAT,QAAmB,iBAAnB;AAEA;AACA;AACA;;AACA,OAAOC,YAAP,MAAyB,iBAAzB;AACA,OAAOC,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ACJU,KAAK,CAACuB,kBAAN,IACAvB,KAAK,CAACuB,kBAAN,CAAyBC,GAAzB,CAAgCC,IAAF,KAAc;AAC3CC,MAAAA,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,cAAC,YAAD;AACC,IAAA,GAAG,EAAC,8BADL;AAEC,IAAA,UAAU,EAAGP,UAFd;AAGC,IAAA,KAAK,EAAGb,EAAE,CAAE,QAAF,CAHX;AAIC,IAAA,aAAa,EAAGA,EAAE,CAAE,KAAF,CAJnB;AAKC,IAAA,gBAAgB,EAAGc,gBALpB;AAMC,IAAA,QAAQ,EAAGM;AANZ,IAvFA,EAgGDC,qBAAqB,IACpB,cAAC,YAAD;AACC,IAAA,uBAAuB,MADxB;AAEC,IAAA,GAAG,EAAC,8BAFL;AAGC,IAAA,KAAK,EAAGrB,EAAE,CAAE,iBAAF,CAHX;AAIC,IAAA,KAAK,EAAGe,aAJT;AAKC,IAAA,QAAQ,EAAGM,qBALZ;AAMC,IAAA,GAAG,EAAGF,QANP;AAOC,IAAA,GAAG,EAAGD,QAPP;AAQC,IAAA,QAAQ;AART,IAjGA,CADH,CADD;AAiHA;AAED,eAAeN,aAAf","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"]}
@@ -2,20 +2,24 @@
2
2
  * External dependencies
3
3
  */
4
4
  import { groupBy } from 'lodash';
5
+ /**
6
+ * Internal dependencies
7
+ */
8
+
5
9
  /**
6
10
  * Returns terms in a tree form.
7
11
  *
8
- * @param {Array} flatTerms Array of terms in flat format.
12
+ * @param flatTerms Array of terms in flat format.
9
13
  *
10
- * @return {Array} Array of terms in tree format.
14
+ * @return Terms in tree format.
11
15
  */
12
-
13
16
  export function buildTermsTree(flatTerms) {
14
17
  const flatTermsWithParentAndChildren = flatTerms.map(term => {
15
18
  return {
16
19
  children: [],
17
20
  parent: null,
18
- ...term
21
+ ...term,
22
+ id: String(term.id)
19
23
  };
20
24
  });
21
25
  const termsByParent = groupBy(flatTermsWithParentAndChildren, 'parent');
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/components/src/query-controls/terms.js"],"names":["groupBy","buildTermsTree","flatTerms","flatTermsWithParentAndChildren","map","term","children","parent","termsByParent","null","length","fillWithChildren","terms","id"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,OAAT,QAAwB,QAAxB;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,SAASC,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,GAAGR,OAAO,CAAEG,8BAAF,EAAkC,QAAlC,CAA7B;;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":["groupBy","buildTermsTree","flatTerms","flatTermsWithParentAndChildren","map","term","children","parent","id","String","termsByParent","null","length","fillWithChildren","terms"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,OAAT,QAAwB,QAAxB;AAEA;AACA;AACA;;AAQA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,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,GAAGV,OAAO,CAC3CG,8BAD2C,EAE3C,QAF2C,CAA5C;;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,2 @@
1
+ export {};
2
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"names":[],"mappings":"","sourcesContent":[]}
@@ -16,6 +16,7 @@ function useForceUpdate() {
16
16
  const [, setState] = useState({});
17
17
  const mounted = useRef(true);
18
18
  useEffect(() => {
19
+ mounted.current = true;
19
20
  return () => {
20
21
  mounted.current = false;
21
22
  };
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/components/src/slot-fill/bubbles-virtually/fill.js"],"names":["useRef","useState","useEffect","createPortal","useSlot","StyleProvider","useForceUpdate","setState","mounted","current","Fill","name","children","registerFill","unregisterFill","slot","ref","rerender","fillProps","wrappedChildren","ownerDocument"],"mappings":";AAAA;;AACA;AACA;AACA;AACA,SAASA,MAAT,EAAiBC,QAAjB,EAA2BC,SAA3B,EAAsCC,YAAtC,QAA0D,oBAA1D;AAEA;AACA;AACA;;AACA,OAAOC,OAAP,MAAoB,YAApB;AACA,OAAOC,aAAP,MAA0B,sBAA1B;;AAEA,SAASC,cAAT,GAA0B;AACzB,QAAM,GAAIC,QAAJ,IAAiBN,QAAQ,CAAE,EAAF,CAA/B;AACA,QAAMO,OAAO,GAAGR,MAAM,CAAE,IAAF,CAAtB;AAEAE,EAAAA,SAAS,CAAE,MAAM;AAChB,WAAO,MAAM;AACZM,MAAAA,OAAO,CAACC,OAAR,GAAkB,KAAlB;AACA,KAFD;AAGA,GAJQ,EAIN,EAJM,CAAT;AAMA,SAAO,MAAM;AACZ,QAAKD,OAAO,CAACC,OAAb,EAAuB;AACtBF,MAAAA,QAAQ,CAAE,EAAF,CAAR;AACA;AACD,GAJD;AAKA;;AAED,eAAe,SAASG,IAAT,OAAoC;AAAA,MAArB;AAAEC,IAAAA,IAAF;AAAQC,IAAAA;AAAR,GAAqB;AAClD,QAAM;AAAEC,IAAAA,YAAF;AAAgBC,IAAAA,cAAhB;AAAgC,OAAGC;AAAnC,MAA4CX,OAAO,CAAEO,IAAF,CAAzD;AACA,QAAMK,GAAG,GAAGhB,MAAM,CAAE;AAAEiB,IAAAA,QAAQ,EAAEX,cAAc;AAA1B,GAAF,CAAlB;AAEAJ,EAAAA,SAAS,CAAE,MAAM;AAChB;AACA;AACA;AACAW,IAAAA,YAAY,CAAEG,GAAF,CAAZ;AACA,WAAO,MAAM;AACZF,MAAAA,cAAc,CAAEE,GAAF,CAAd;AACA,KAFD;AAGA,GARQ,EAQN,CAAEH,YAAF,EAAgBC,cAAhB,CARM,CAAT;;AAUA,MAAK,CAAEC,IAAI,CAACC,GAAP,IAAc,CAAED,IAAI,CAACC,GAAL,CAASP,OAA9B,EAAwC;AACvC,WAAO,IAAP;AACA;;AAED,MAAK,OAAOG,QAAP,KAAoB,UAAzB,EAAsC;AACrCA,IAAAA,QAAQ,GAAGA,QAAQ,CAAEG,IAAI,CAACG,SAAP,CAAnB;AACA,GApBiD,CAsBlD;AACA;AACA;AACA;;;AACA,QAAMC,eAAe,GACpB,cAAC,aAAD;AAAe,IAAA,QAAQ,EAAGJ,IAAI,CAACC,GAAL,CAASP,OAAT,CAAiBW;AAA3C,KACGR,QADH,CADD;AAMA,SAAOT,YAAY,CAAEgB,eAAF,EAAmBJ,IAAI,CAACC,GAAL,CAASP,OAA5B,CAAnB;AACA","sourcesContent":["// @ts-nocheck\n/**\n * WordPress dependencies\n */\nimport { useRef, useState, useEffect, createPortal } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport useSlot from './use-slot';\nimport StyleProvider from '../../style-provider';\n\nfunction useForceUpdate() {\n\tconst [ , setState ] = useState( {} );\n\tconst mounted = useRef( true );\n\n\tuseEffect( () => {\n\t\treturn () => {\n\t\t\tmounted.current = false;\n\t\t};\n\t}, [] );\n\n\treturn () => {\n\t\tif ( mounted.current ) {\n\t\t\tsetState( {} );\n\t\t}\n\t};\n}\n\nexport default function Fill( { name, children } ) {\n\tconst { registerFill, unregisterFill, ...slot } = useSlot( name );\n\tconst ref = useRef( { rerender: useForceUpdate() } );\n\n\tuseEffect( () => {\n\t\t// We register fills so we can keep track of their existence.\n\t\t// Some Slot implementations need to know if there're already fills\n\t\t// registered so they can choose to render themselves or not.\n\t\tregisterFill( ref );\n\t\treturn () => {\n\t\t\tunregisterFill( ref );\n\t\t};\n\t}, [ registerFill, unregisterFill ] );\n\n\tif ( ! slot.ref || ! slot.ref.current ) {\n\t\treturn null;\n\t}\n\n\tif ( typeof children === 'function' ) {\n\t\tchildren = children( slot.fillProps );\n\t}\n\n\t// When using a `Fill`, the `children` will be rendered in the document of the\n\t// `Slot`. This means that we need to wrap the `children` in a `StyleProvider`\n\t// to make sure we're referencing the right document/iframe (instead of the\n\t// context of the `Fill`'s parent).\n\tconst wrappedChildren = (\n\t\t<StyleProvider document={ slot.ref.current.ownerDocument }>\n\t\t\t{ children }\n\t\t</StyleProvider>\n\t);\n\n\treturn createPortal( wrappedChildren, slot.ref.current );\n}\n"]}
1
+ {"version":3,"sources":["@wordpress/components/src/slot-fill/bubbles-virtually/fill.js"],"names":["useRef","useState","useEffect","createPortal","useSlot","StyleProvider","useForceUpdate","setState","mounted","current","Fill","name","children","registerFill","unregisterFill","slot","ref","rerender","fillProps","wrappedChildren","ownerDocument"],"mappings":";AAAA;;AACA;AACA;AACA;AACA,SAASA,MAAT,EAAiBC,QAAjB,EAA2BC,SAA3B,EAAsCC,YAAtC,QAA0D,oBAA1D;AAEA;AACA;AACA;;AACA,OAAOC,OAAP,MAAoB,YAApB;AACA,OAAOC,aAAP,MAA0B,sBAA1B;;AAEA,SAASC,cAAT,GAA0B;AACzB,QAAM,GAAIC,QAAJ,IAAiBN,QAAQ,CAAE,EAAF,CAA/B;AACA,QAAMO,OAAO,GAAGR,MAAM,CAAE,IAAF,CAAtB;AAEAE,EAAAA,SAAS,CAAE,MAAM;AAChBM,IAAAA,OAAO,CAACC,OAAR,GAAkB,IAAlB;AACA,WAAO,MAAM;AACZD,MAAAA,OAAO,CAACC,OAAR,GAAkB,KAAlB;AACA,KAFD;AAGA,GALQ,EAKN,EALM,CAAT;AAOA,SAAO,MAAM;AACZ,QAAKD,OAAO,CAACC,OAAb,EAAuB;AACtBF,MAAAA,QAAQ,CAAE,EAAF,CAAR;AACA;AACD,GAJD;AAKA;;AAED,eAAe,SAASG,IAAT,OAAoC;AAAA,MAArB;AAAEC,IAAAA,IAAF;AAAQC,IAAAA;AAAR,GAAqB;AAClD,QAAM;AAAEC,IAAAA,YAAF;AAAgBC,IAAAA,cAAhB;AAAgC,OAAGC;AAAnC,MAA4CX,OAAO,CAAEO,IAAF,CAAzD;AACA,QAAMK,GAAG,GAAGhB,MAAM,CAAE;AAAEiB,IAAAA,QAAQ,EAAEX,cAAc;AAA1B,GAAF,CAAlB;AAEAJ,EAAAA,SAAS,CAAE,MAAM;AAChB;AACA;AACA;AACAW,IAAAA,YAAY,CAAEG,GAAF,CAAZ;AACA,WAAO,MAAM;AACZF,MAAAA,cAAc,CAAEE,GAAF,CAAd;AACA,KAFD;AAGA,GARQ,EAQN,CAAEH,YAAF,EAAgBC,cAAhB,CARM,CAAT;;AAUA,MAAK,CAAEC,IAAI,CAACC,GAAP,IAAc,CAAED,IAAI,CAACC,GAAL,CAASP,OAA9B,EAAwC;AACvC,WAAO,IAAP;AACA;;AAED,MAAK,OAAOG,QAAP,KAAoB,UAAzB,EAAsC;AACrCA,IAAAA,QAAQ,GAAGA,QAAQ,CAAEG,IAAI,CAACG,SAAP,CAAnB;AACA,GApBiD,CAsBlD;AACA;AACA;AACA;;;AACA,QAAMC,eAAe,GACpB,cAAC,aAAD;AAAe,IAAA,QAAQ,EAAGJ,IAAI,CAACC,GAAL,CAASP,OAAT,CAAiBW;AAA3C,KACGR,QADH,CADD;AAMA,SAAOT,YAAY,CAAEgB,eAAF,EAAmBJ,IAAI,CAACC,GAAL,CAASP,OAA5B,CAAnB;AACA","sourcesContent":["// @ts-nocheck\n/**\n * WordPress dependencies\n */\nimport { useRef, useState, useEffect, createPortal } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport useSlot from './use-slot';\nimport StyleProvider from '../../style-provider';\n\nfunction useForceUpdate() {\n\tconst [ , setState ] = useState( {} );\n\tconst mounted = useRef( true );\n\n\tuseEffect( () => {\n\t\tmounted.current = true;\n\t\treturn () => {\n\t\t\tmounted.current = false;\n\t\t};\n\t}, [] );\n\n\treturn () => {\n\t\tif ( mounted.current ) {\n\t\t\tsetState( {} );\n\t\t}\n\t};\n}\n\nexport default function Fill( { name, children } ) {\n\tconst { registerFill, unregisterFill, ...slot } = useSlot( name );\n\tconst ref = useRef( { rerender: useForceUpdate() } );\n\n\tuseEffect( () => {\n\t\t// We register fills so we can keep track of their existence.\n\t\t// Some Slot implementations need to know if there're already fills\n\t\t// registered so they can choose to render themselves or not.\n\t\tregisterFill( ref );\n\t\treturn () => {\n\t\t\tunregisterFill( ref );\n\t\t};\n\t}, [ registerFill, unregisterFill ] );\n\n\tif ( ! slot.ref || ! slot.ref.current ) {\n\t\treturn null;\n\t}\n\n\tif ( typeof children === 'function' ) {\n\t\tchildren = children( slot.fillProps );\n\t}\n\n\t// When using a `Fill`, the `children` will be rendered in the document of the\n\t// `Slot`. This means that we need to wrap the `children` in a `StyleProvider`\n\t// to make sure we're referencing the right document/iframe (instead of the\n\t// context of the `Fill`'s parent).\n\tconst wrappedChildren = (\n\t\t<StyleProvider document={ slot.ref.current.ownerDocument }>\n\t\t\t{ children }\n\t\t</StyleProvider>\n\t);\n\n\treturn createPortal( wrappedChildren, slot.ref.current );\n}\n"]}
@@ -33,6 +33,7 @@ class SlotComponent extends Component {
33
33
  const {
34
34
  registerSlot
35
35
  } = this.props;
36
+ this.isUnmounted = false;
36
37
  registerSlot(this.props.name, this);
37
38
  }
38
39
 
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/components/src/slot-fill/slot.js"],"names":["Children","Component","cloneElement","isEmptyElement","SlotFillContext","isFunction","maybeFunc","SlotComponent","constructor","arguments","isUnmounted","bindNode","bind","componentDidMount","registerSlot","props","name","componentWillUnmount","unregisterSlot","componentDidUpdate","prevProps","node","forceUpdate","render","children","fillProps","getFills","fills","map","fill","fillChildren","child","childIndex","childKey","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AAA;AAAhC,GAAF;AAAA,SACD,cAAC,aAAD,eACMX,KADN;AAEC,IAAA,YAAY,EAAGD,YAFhB;AAGC,IAAA,cAAc,EAAGI,cAHlB;AAIC,IAAA,QAAQ,EAAGQ;AAJZ,KADC;AAAA,CADH,CADD;;AAaA,eAAeW,IAAf","sourcesContent":["// @ts-nocheck\n/**\n * WordPress dependencies\n */\nimport {\n\tChildren,\n\tComponent,\n\tcloneElement,\n\tisEmptyElement,\n} from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport SlotFillContext from './context';\n\n/**\n * Whether the argument is a function.\n *\n * @param {*} maybeFunc The argument to check.\n * @return {boolean} True if the argument is a function, false otherwise.\n */\nfunction isFunction( maybeFunc ) {\n\treturn typeof maybeFunc === 'function';\n}\n\nclass SlotComponent extends Component {\n\tconstructor() {\n\t\tsuper( ...arguments );\n\n\t\tthis.isUnmounted = false;\n\t\tthis.bindNode = this.bindNode.bind( this );\n\t}\n\n\tcomponentDidMount() {\n\t\tconst { registerSlot } = this.props;\n\n\t\tregisterSlot( this.props.name, this );\n\t}\n\n\tcomponentWillUnmount() {\n\t\tconst { unregisterSlot } = this.props;\n\t\tthis.isUnmounted = true;\n\t\tunregisterSlot( this.props.name, this );\n\t}\n\n\tcomponentDidUpdate( prevProps ) {\n\t\tconst { name, unregisterSlot, registerSlot } = this.props;\n\n\t\tif ( prevProps.name !== name ) {\n\t\t\tunregisterSlot( prevProps.name );\n\t\t\tregisterSlot( name, this );\n\t\t}\n\t}\n\n\tbindNode( node ) {\n\t\tthis.node = node;\n\t}\n\n\tforceUpdate() {\n\t\tif ( this.isUnmounted ) {\n\t\t\treturn;\n\t\t}\n\t\tsuper.forceUpdate();\n\t}\n\n\trender() {\n\t\tconst { children, name, fillProps = {}, getFills } = this.props;\n\n\t\tconst fills = ( getFills( name, this ) ?? [] )\n\t\t\t.map( ( fill ) => {\n\t\t\t\tconst fillChildren = isFunction( fill.children )\n\t\t\t\t\t? fill.children( fillProps )\n\t\t\t\t\t: fill.children;\n\n\t\t\t\treturn Children.map( fillChildren, ( child, childIndex ) => {\n\t\t\t\t\tif ( ! child || typeof child === 'string' ) {\n\t\t\t\t\t\treturn child;\n\t\t\t\t\t}\n\n\t\t\t\t\tconst childKey = child.key || childIndex;\n\t\t\t\t\treturn cloneElement( child, { key: childKey } );\n\t\t\t\t} );\n\t\t\t} )\n\t\t\t.filter(\n\t\t\t\t// In some cases fills are rendered only when some conditions apply.\n\t\t\t\t// This ensures that we only use non-empty fills when rendering, i.e.,\n\t\t\t\t// it allows us to render wrappers only when the fills are actually present.\n\t\t\t\t( element ) => ! isEmptyElement( element )\n\t\t\t);\n\n\t\treturn <>{ isFunction( children ) ? children( fills ) : fills }</>;\n\t}\n}\n\nconst Slot = ( props ) => (\n\t<SlotFillContext.Consumer>\n\t\t{ ( { registerSlot, unregisterSlot, getFills } ) => (\n\t\t\t<SlotComponent\n\t\t\t\t{ ...props }\n\t\t\t\tregisterSlot={ registerSlot }\n\t\t\t\tunregisterSlot={ unregisterSlot }\n\t\t\t\tgetFills={ getFills }\n\t\t\t/>\n\t\t) }\n\t</SlotFillContext.Consumer>\n);\n\nexport default Slot;\n"]}
1
+ {"version":3,"sources":["@wordpress/components/src/slot-fill/slot.js"],"names":["Children","Component","cloneElement","isEmptyElement","SlotFillContext","isFunction","maybeFunc","SlotComponent","constructor","arguments","isUnmounted","bindNode","bind","componentDidMount","registerSlot","props","name","componentWillUnmount","unregisterSlot","componentDidUpdate","prevProps","node","forceUpdate","render","children","fillProps","getFills","fills","map","fill","fillChildren","child","childIndex","childKey","key","filter","element","Slot"],"mappings":";;AAAA;;AACA;AACA;AACA;AACA,SACCA,QADD,EAECC,SAFD,EAGCC,YAHD,EAICC,cAJD,QAKO,oBALP;AAOA;AACA;AACA;;AACA,OAAOC,eAAP,MAA4B,WAA5B;AAEA;AACA;AACA;AACA;AACA;AACA;;AACA,SAASC,UAAT,CAAqBC,SAArB,EAAiC;AAChC,SAAO,OAAOA,SAAP,K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Press dependencies\n */\nimport {\n\tChildren,\n\tComponent,\n\tcloneElement,\n\tisEmptyElement,\n} from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport SlotFillContext from './context';\n\n/**\n * Whether the argument is a function.\n *\n * @param {*} maybeFunc The argument to check.\n * @return {boolean} True if the argument is a function, false otherwise.\n */\nfunction isFunction( maybeFunc ) {\n\treturn typeof maybeFunc === 'function';\n}\n\nclass SlotComponent extends Component {\n\tconstructor() {\n\t\tsuper( ...arguments );\n\n\t\tthis.isUnmounted = false;\n\t\tthis.bindNode = this.bindNode.bind( this );\n\t}\n\n\tcomponentDidMount() {\n\t\tconst { registerSlot } = this.props;\n\t\tthis.isUnmounted = false;\n\t\tregisterSlot( this.props.name, this );\n\t}\n\n\tcomponentWillUnmount() {\n\t\tconst { unregisterSlot } = this.props;\n\t\tthis.isUnmounted = true;\n\t\tunregisterSlot( this.props.name, this );\n\t}\n\n\tcomponentDidUpdate( prevProps ) {\n\t\tconst { name, unregisterSlot, registerSlot } = this.props;\n\n\t\tif ( prevProps.name !== name ) {\n\t\t\tunregisterSlot( prevProps.name );\n\t\t\tregisterSlot( name, this );\n\t\t}\n\t}\n\n\tbindNode( node ) {\n\t\tthis.node = node;\n\t}\n\n\tforceUpdate() {\n\t\tif ( this.isUnmounted ) {\n\t\t\treturn;\n\t\t}\n\t\tsuper.forceUpdate();\n\t}\n\n\trender() {\n\t\tconst { children, name, fillProps = {}, getFills } = this.props;\n\n\t\tconst fills = ( getFills( name, this ) ?? [] )\n\t\t\t.map( ( fill ) => {\n\t\t\t\tconst fillChildren = isFunction( fill.children )\n\t\t\t\t\t? fill.children( fillProps )\n\t\t\t\t\t: fill.children;\n\n\t\t\t\treturn Children.map( fillChildren, ( child, childIndex ) => {\n\t\t\t\t\tif ( ! child || typeof child === 'string' ) {\n\t\t\t\t\t\treturn child;\n\t\t\t\t\t}\n\n\t\t\t\t\tconst childKey = child.key || childIndex;\n\t\t\t\t\treturn cloneElement( child, { key: childKey } );\n\t\t\t\t} );\n\t\t\t} )\n\t\t\t.filter(\n\t\t\t\t// In some cases fills are rendered only when some conditions apply.\n\t\t\t\t// This ensures that we only use non-empty fills when rendering, i.e.,\n\t\t\t\t// it allows us to render wrappers only when the fills are actually present.\n\t\t\t\t( element ) => ! isEmptyElement( element )\n\t\t\t);\n\n\t\treturn <>{ isFunction( children ) ? children( fills ) : fills }</>;\n\t}\n}\n\nconst Slot = ( props ) => (\n\t<SlotFillContext.Consumer>\n\t\t{ ( { registerSlot, unregisterSlot, getFills } ) => (\n\t\t\t<SlotComponent\n\t\t\t\t{ ...props }\n\t\t\t\tregisterSlot={ registerSlot }\n\t\t\t\tunregisterSlot={ unregisterSlot }\n\t\t\t\tgetFills={ getFills }\n\t\t\t/>\n\t\t) }\n\t</SlotFillContext.Consumer>\n);\n\nexport default Slot;\n"]}
@@ -3,7 +3,7 @@
3
3
  /**
4
4
  * WordPress dependencies
5
5
  */
6
- import { useContext, useState, useEffect } from '@wordpress/element';
6
+ import { useContext, useSyncExternalStore } from '@wordpress/element';
7
7
  /**
8
8
  * Internal dependencies
9
9
  */
@@ -21,17 +21,7 @@ const useSlot = name => {
21
21
  getSlot,
22
22
  subscribe
23
23
  } = useContext(SlotFillContext);
24
- const [slot, setSlot] = useState(getSlot(name));
25
- useEffect(() => {
26
- setSlot(getSlot(name));
27
- const unsubscribe = subscribe(() => {
28
- setSlot(getSlot(name));
29
- });
30
- return unsubscribe; // Ignore reason: Modifying this dep array could introduce unexpected changes in behavior,
31
- // so we'll leave it as=is until the hook can be properly refactored for exhaustive-deps.
32
- // eslint-disable-next-line react-hooks/exhaustive-deps
33
- }, [name]);
34
- return slot;
24
+ return useSyncExternalStore(subscribe, () => getSlot(name), () => getSlot(name));
35
25
  };
36
26
 
37
27
  export default useSlot;
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/components/src/slot-fill/use-slot.js"],"names":["useContext","useState","useEffect","SlotFillContext","useSlot","name","getSlot","subscribe","slot","setSlot","unsubscribe"],"mappings":"AAAA;;AACA;AACA;AACA;AACA,SAASA,UAAT,EAAqBC,QAArB,EAA+BC,SAA/B,QAAgD,oBAAhD;AAEA;AACA;AACA;;AACA,OAAOC,eAAP,MAA4B,WAA5B;AAEA;AACA;AACA;AACA;AACA;AACA;;AACA,MAAMC,OAAO,GAAKC,IAAF,IAAY;AAC3B,QAAM;AAAEC,IAAAA,OAAF;AAAWC,IAAAA;AAAX,MAAyBP,UAAU,CAAEG,eAAF,CAAzC;AACA,QAAM,CAAEK,IAAF,EAAQC,OAAR,IAAoBR,QAAQ,CAAEK,OAAO,CAAED,IAAF,CAAT,CAAlC;AAEAH,EAAAA,SAAS,CAAE,MAAM;AAChBO,IAAAA,OAAO,CAAEH,OAAO,CAAED,IAAF,CAAT,CAAP;AACA,UAAMK,WAAW,GAAGH,SAAS,CAAE,MAAM;AACpCE,MAAAA,OAAO,CAAEH,OAAO,CAAED,IAAF,CAAT,CAAP;AACA,KAF4B,CAA7B;AAIA,WAAOK,WAAP,CANgB,CAOhB;AACA;AACA;AACA,GAVQ,EAUN,CAAEL,IAAF,CAVM,CAAT;AAYA,SAAOG,IAAP;AACA,CAjBD;;AAmBA,eAAeJ,OAAf","sourcesContent":["// @ts-nocheck\n/**\n * WordPress dependencies\n */\nimport { useContext, useState, useEffect } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport SlotFillContext from './context';\n\n/**\n * React hook returning the active slot given a name.\n *\n * @param {string} name Slot name.\n * @return {Object} Slot object.\n */\nconst useSlot = ( name ) => {\n\tconst { getSlot, subscribe } = useContext( SlotFillContext );\n\tconst [ slot, setSlot ] = useState( getSlot( name ) );\n\n\tuseEffect( () => {\n\t\tsetSlot( getSlot( name ) );\n\t\tconst unsubscribe = subscribe( () => {\n\t\t\tsetSlot( getSlot( name ) );\n\t\t} );\n\n\t\treturn unsubscribe;\n\t\t// Ignore reason: Modifying this dep array could introduce unexpected changes in behavior,\n\t\t// so we'll leave it as=is until the hook can be properly refactored for exhaustive-deps.\n\t\t// eslint-disable-next-line react-hooks/exhaustive-deps\n\t}, [ name ] );\n\n\treturn slot;\n};\n\nexport default useSlot;\n"]}
1
+ {"version":3,"sources":["@wordpress/components/src/slot-fill/use-slot.js"],"names":["useContext","useSyncExternalStore","SlotFillContext","useSlot","name","getSlot","subscribe"],"mappings":"AAAA;;AACA;AACA;AACA;AACA,SAASA,UAAT,EAAqBC,oBAArB,QAAiD,oBAAjD;AAEA;AACA;AACA;;AACA,OAAOC,eAAP,MAA4B,WAA5B;AAEA;AACA;AACA;AACA;AACA;AACA;;AACA,MAAMC,OAAO,GAAKC,IAAF,IAAY;AAC3B,QAAM;AAAEC,IAAAA,OAAF;AAAWC,IAAAA;AAAX,MAAyBN,UAAU,CAAEE,eAAF,CAAzC;AACA,SAAOD,oBAAoB,CAC1BK,SAD0B,EAE1B,MAAMD,OAAO,CAAED,IAAF,CAFa,EAG1B,MAAMC,OAAO,CAAED,IAAF,CAHa,CAA3B;AAKA,CAPD;;AASA,eAAeD,OAAf","sourcesContent":["// @ts-nocheck\n/**\n * WordPress dependencies\n */\nimport { useContext, useSyncExternalStore } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport SlotFillContext from './context';\n\n/**\n * React hook returning the active slot given a name.\n *\n * @param {string} name Slot name.\n * @return {Object} Slot object.\n */\nconst useSlot = ( name ) => {\n\tconst { getSlot, subscribe } = useContext( SlotFillContext );\n\treturn useSyncExternalStore(\n\t\tsubscribe,\n\t\t() => getSlot( name ),\n\t\t() => getSlot( name )\n\t);\n};\n\nexport default useSlot;\n"]}