@wordpress/components 23.2.0 → 23.3.1

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
@@ -1,6 +0,0 @@
1
- export default RadioContext;
2
- declare const RadioContext: import("react").Context<{
3
- state: null;
4
- setState: () => void;
5
- }>;
6
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/radio-context/index.js"],"names":[],"mappings":";AAKA;;;GAGI"}
@@ -1,179 +0,0 @@
1
- /**
2
- * WordPress dependencies
3
- */
4
- import {
5
- formatBold,
6
- formatItalic,
7
- link,
8
- more,
9
- wordpress,
10
- } from '@wordpress/icons';
11
-
12
- /**
13
- * Internal dependencies
14
- */
15
- import './style.css';
16
- import Button from '../';
17
-
18
- export default {
19
- title: 'Components/Button',
20
- component: Button,
21
- argTypes: {
22
- label: {
23
- control: { type: 'text' },
24
- description:
25
- 'Sets the `aria-label` of the component, if none is provided. Sets the Tooltip content if `showTooltip` is provided.',
26
- },
27
- children: {
28
- control: { type: 'text' },
29
- },
30
- href: {
31
- control: { type: 'text' },
32
- description: 'If provided, renders `a` instead of `button`.',
33
- },
34
- icon: {
35
- control: { type: 'select' },
36
- description:
37
- 'If provided, renders an `Icon` component inside the button.',
38
- options: [ 'wordpress', 'link', 'more' ],
39
- mapping: {
40
- wordpress,
41
- link,
42
- more,
43
- },
44
- },
45
- iconSize: {
46
- control: { type: 'number' },
47
- description: 'If provided with `icon`, sets the icon size.',
48
- },
49
- iconPosition: {
50
- control: { type: 'select' },
51
- description:
52
- 'If provided with `icon`, sets the position of icon relative to the `text`. Available options are `left|right`.',
53
- options: [ 'left', 'right' ],
54
- table: {
55
- defaultValue: { summary: `left` },
56
- },
57
- },
58
- isBusy: {
59
- control: 'boolean',
60
- description:
61
- 'Indicates activity while a action is being performed.',
62
- },
63
- isDestructive: {
64
- control: 'boolean',
65
- description:
66
- 'Renders a red text-based button style to indicate destructive behavior.',
67
- },
68
- isPressed: {
69
- control: 'boolean',
70
- description: 'Renders a pressed button style.',
71
- },
72
- isSmall: {
73
- control: 'boolean',
74
- description: 'Decreases the size of the button.',
75
- },
76
- disabled: {
77
- control: 'boolean',
78
- description:
79
- 'Whether the button is disabled. If `true`, this will force a `button` element to be rendered.',
80
- },
81
- shortcut: {
82
- control: { type: 'text' },
83
- description:
84
- 'If provided with `showTooltip`, appends the Shortcut label to the tooltip content. If an `Object` is provided, it should contain `display` and `ariaLabel` keys.',
85
- },
86
- showTooltip: {
87
- control: 'boolean',
88
- description:
89
- 'If provided, renders a `Tooltip` component for the button.',
90
- },
91
- tooltipPosition: {
92
- control: { type: 'text' },
93
- description:
94
- 'If provided with `showTooltip`, sets the position of the tooltip.',
95
- },
96
- text: {
97
- control: { type: 'text' },
98
- description:
99
- 'If provided, displays the given text inside the button. If the button contains `children` elements, the text is displayed before them.',
100
- },
101
- target: {
102
- control: { type: 'text' },
103
- description:
104
- 'If provided with `href`, sets the `target` attribute to the `a`.',
105
- },
106
- variant: {
107
- control: { type: 'select' },
108
- description: "Specifies the button's style.",
109
- options: [ 'primary', 'secondary', 'tertiary', 'link' ],
110
- },
111
- __experimentalIsFocusable: {
112
- control: 'boolean',
113
- description: 'Makes the button focusable even when disabled',
114
- },
115
- },
116
- parameters: {
117
- controls: { expanded: true },
118
- docs: { source: { state: 'open' } },
119
- },
120
- };
121
-
122
- function Template( { children, ...props } ) {
123
- return <Button { ...props }>{ children }</Button>;
124
- }
125
-
126
- export const Default = Template.bind( {} );
127
- Default.args = {
128
- children: 'Code is poetry',
129
- };
130
-
131
- export const Primary = Template.bind( {} );
132
- Primary.args = {
133
- ...Default.args,
134
- variant: 'primary',
135
- };
136
-
137
- export const Secondary = Template.bind( {} );
138
- Secondary.args = {
139
- ...Default.args,
140
- variant: 'secondary',
141
- };
142
-
143
- export const Tertiary = Template.bind( {} );
144
- Tertiary.args = {
145
- ...Default.args,
146
- variant: 'tertiary',
147
- };
148
-
149
- export const Link = Template.bind( {} );
150
- Link.args = {
151
- ...Default.args,
152
- variant: 'link',
153
- };
154
-
155
- export const IsDestructive = Template.bind( {} );
156
- IsDestructive.args = {
157
- ...Default.args,
158
- isDestructive: true,
159
- };
160
-
161
- export const Icon = Template.bind( {} );
162
- Icon.args = {
163
- label: 'Code is poetry',
164
- icon: 'wordpress',
165
- };
166
-
167
- export const groupedIcons = () => {
168
- const GroupContainer = ( { children } ) => (
169
- <div style={ { display: 'inline-flex' } }>{ children }</div>
170
- );
171
-
172
- return (
173
- <GroupContainer>
174
- <Button icon={ formatBold } label="Bold" />
175
- <Button icon={ formatItalic } label="Italic" />
176
- <Button icon={ link } label="Link" />
177
- </GroupContainer>
178
- );
179
- };
@@ -1,56 +0,0 @@
1
- /**
2
- * External dependencies
3
- */
4
- import { map } from 'lodash';
5
-
6
- /**
7
- * WordPress dependencies
8
- */
9
- import { useRef, Children } from '@wordpress/element';
10
- import { useKeyboardShortcut } from '@wordpress/compose';
11
-
12
- function KeyboardShortcut( {
13
- target,
14
- callback,
15
- shortcut,
16
- bindGlobal,
17
- eventName,
18
- } ) {
19
- useKeyboardShortcut( shortcut, callback, {
20
- bindGlobal,
21
- target,
22
- eventName,
23
- } );
24
-
25
- return null;
26
- }
27
-
28
- function KeyboardShortcuts( { children, shortcuts, bindGlobal, eventName } ) {
29
- const target = useRef();
30
-
31
- const element = map( shortcuts, ( callback, shortcut ) => (
32
- <KeyboardShortcut
33
- key={ shortcut }
34
- shortcut={ shortcut }
35
- callback={ callback }
36
- bindGlobal={ bindGlobal }
37
- eventName={ eventName }
38
- target={ target }
39
- />
40
- ) );
41
-
42
- // Render as non-visual if there are no children pressed. Keyboard
43
- // events will be bound to the document instead.
44
- if ( ! Children.count( children ) ) {
45
- return element;
46
- }
47
-
48
- return (
49
- <div ref={ target }>
50
- { element }
51
- { children }
52
- </div>
53
- );
54
- }
55
-
56
- export default KeyboardShortcuts;
@@ -1,48 +0,0 @@
1
- /**
2
- * External dependencies
3
- */
4
- import classnames from 'classnames';
5
-
6
- /**
7
- * Internal dependencies
8
- */
9
- import Notice from './';
10
-
11
- const noop = () => {};
12
-
13
- /**
14
- * Renders a list of notices.
15
- *
16
- * @param {Object} $0 Props passed to the component.
17
- * @param {Array} $0.notices Array of notices to render.
18
- * @param {Function} $0.onRemove Function called when a notice should be removed / dismissed.
19
- * @param {Object} $0.className Name of the class used by the component.
20
- * @param {Object} $0.children Array of children to be rendered inside the notice list.
21
- *
22
- * @return {Object} The rendered notices list.
23
- */
24
- function NoticeList( { notices, onRemove = noop, className, children } ) {
25
- const removeNotice = ( id ) => () => onRemove( id );
26
-
27
- className = classnames( 'components-notice-list', className );
28
-
29
- return (
30
- <div className={ className }>
31
- { children }
32
- { [ ...notices ].reverse().map( ( notice ) => {
33
- const { content, ...restNotice } = notice;
34
- return (
35
- <Notice
36
- { ...restNotice }
37
- key={ notice.id }
38
- onRemove={ removeNotice( notice.id ) }
39
- >
40
- { notice.content }
41
- </Notice>
42
- );
43
- } ) }
44
- </div>
45
- );
46
- }
47
-
48
- export default NoticeList;
@@ -1,46 +0,0 @@
1
- /**
2
- * Internal dependencies
3
- */
4
- import Notice from '../';
5
-
6
- // TODO: Add a story involving NoticeList to help people understand
7
- // the difference between onDismiss/onRemove.
8
-
9
- export default {
10
- title: 'Components/Notice',
11
- component: Notice,
12
- argTypes: {
13
- isDismissible: { control: 'boolean' },
14
- onDismiss: { control: { type: null } },
15
- onRemove: { control: { type: null } },
16
- politeness: {
17
- control: 'radio',
18
- options: [ 'assertive', 'polite' ],
19
- },
20
- spokenMessage: { control: 'text' },
21
- status: {
22
- control: 'radio',
23
- options: [ 'warning', 'success', 'error', 'info' ],
24
- },
25
- },
26
- parameters: {
27
- controls: { expanded: true },
28
- docs: { source: { state: 'open' } },
29
- },
30
- };
31
-
32
- const Template = ( props ) => {
33
- return <Notice { ...props } />;
34
- };
35
-
36
- export const Default = Template.bind( {} );
37
- Default.args = {
38
- children: 'This is a notice.',
39
- };
40
-
41
- export const WithCustomSpokenMessage = Template.bind( {} );
42
- WithCustomSpokenMessage.args = {
43
- ...Default.args,
44
- politeness: 'assertive',
45
- spokenMessage: 'This is a notice with a custom spoken message',
46
- };
@@ -1,23 +0,0 @@
1
- /**
2
- * Internal dependencies
3
- */
4
- import { buildTermsTree } from './terms';
5
- import TreeSelect from '../tree-select';
6
-
7
- export default function AuthorSelect( {
8
- label,
9
- noOptionLabel,
10
- authorList,
11
- selectedAuthorId,
12
- onChange,
13
- } ) {
14
- if ( ! authorList ) return null;
15
- const termsTree = buildTermsTree( authorList );
16
- return (
17
- <TreeSelect
18
- { ...{ label, noOptionLabel, onChange } }
19
- tree={ termsTree }
20
- selectedId={ selectedAuthorId }
21
- />
22
- );
23
- }
@@ -1,31 +0,0 @@
1
- /**
2
- * Internal dependencies
3
- */
4
- import { buildTermsTree } from './terms';
5
- import TreeSelect from '../tree-select';
6
- /**
7
- * WordPress dependencies
8
- */
9
- import { useMemo } from '@wordpress/element';
10
-
11
- export default function CategorySelect( {
12
- label,
13
- noOptionLabel,
14
- categoriesList,
15
- selectedCategoryId,
16
- onChange,
17
- ...props
18
- } ) {
19
- const termsTree = useMemo( () => {
20
- return buildTermsTree( categoriesList );
21
- }, [ categoriesList ] );
22
-
23
- return (
24
- <TreeSelect
25
- { ...{ label, noOptionLabel, onChange } }
26
- tree={ termsTree }
27
- selectedId={ selectedCategoryId }
28
- { ...props }
29
- />
30
- );
31
- }
@@ -1,122 +0,0 @@
1
- /**
2
- * WordPress dependencies
3
- */
4
- import { __ } from '@wordpress/i18n';
5
-
6
- /**
7
- * Internal dependencies
8
- */
9
- import CategorySelect from './category-select';
10
- import { RangeControl, SelectControl, FormTokenField } from '../';
11
- import AuthorSelect from './author-select';
12
-
13
- const DEFAULT_MIN_ITEMS = 1;
14
- const DEFAULT_MAX_ITEMS = 100;
15
- const MAX_CATEGORIES_SUGGESTIONS = 20;
16
-
17
- export default function QueryControls( {
18
- authorList,
19
- selectedAuthorId,
20
- categoriesList,
21
- selectedCategoryId,
22
- categorySuggestions,
23
- selectedCategories,
24
- numberOfItems,
25
- order,
26
- orderBy,
27
- maxItems = DEFAULT_MAX_ITEMS,
28
- minItems = DEFAULT_MIN_ITEMS,
29
- onCategoryChange,
30
- onAuthorChange,
31
- onNumberOfItemsChange,
32
- onOrderChange,
33
- onOrderByChange,
34
- } ) {
35
- return [
36
- onOrderChange && onOrderByChange && (
37
- <SelectControl
38
- __nextHasNoMarginBottom
39
- key="query-controls-order-select"
40
- label={ __( 'Order by' ) }
41
- value={ `${ orderBy }/${ order }` }
42
- options={ [
43
- {
44
- label: __( 'Newest to oldest' ),
45
- value: 'date/desc',
46
- },
47
- {
48
- label: __( 'Oldest to newest' ),
49
- value: 'date/asc',
50
- },
51
- {
52
- /* translators: label for ordering posts by title in ascending order */
53
- label: __( 'A → Z' ),
54
- value: 'title/asc',
55
- },
56
- {
57
- /* translators: label for ordering posts by title in descending order */
58
- label: __( 'Z → A' ),
59
- value: 'title/desc',
60
- },
61
- ] }
62
- onChange={ ( value ) => {
63
- const [ newOrderBy, newOrder ] = value.split( '/' );
64
- if ( newOrder !== order ) {
65
- onOrderChange( newOrder );
66
- }
67
- if ( newOrderBy !== orderBy ) {
68
- onOrderByChange( newOrderBy );
69
- }
70
- } }
71
- />
72
- ),
73
- categoriesList && onCategoryChange && (
74
- <CategorySelect
75
- key="query-controls-category-select"
76
- categoriesList={ categoriesList }
77
- label={ __( 'Category' ) }
78
- noOptionLabel={ __( 'All' ) }
79
- selectedCategoryId={ selectedCategoryId }
80
- onChange={ onCategoryChange }
81
- />
82
- ),
83
- categorySuggestions && onCategoryChange && (
84
- <FormTokenField
85
- key="query-controls-categories-select"
86
- label={ __( 'Categories' ) }
87
- value={
88
- selectedCategories &&
89
- selectedCategories.map( ( item ) => ( {
90
- id: item.id,
91
- value: item.name || item.value,
92
- } ) )
93
- }
94
- suggestions={ Object.keys( categorySuggestions ) }
95
- onChange={ onCategoryChange }
96
- maxSuggestions={ MAX_CATEGORIES_SUGGESTIONS }
97
- />
98
- ),
99
- onAuthorChange && (
100
- <AuthorSelect
101
- key="query-controls-author-select"
102
- authorList={ authorList }
103
- label={ __( 'Author' ) }
104
- noOptionLabel={ __( 'All' ) }
105
- selectedAuthorId={ selectedAuthorId }
106
- onChange={ onAuthorChange }
107
- />
108
- ),
109
- onNumberOfItemsChange && (
110
- <RangeControl
111
- __nextHasNoMarginBottom
112
- key="query-controls-range-control"
113
- label={ __( 'Number of items' ) }
114
- value={ numberOfItems }
115
- onChange={ onNumberOfItemsChange }
116
- min={ minItems }
117
- max={ maxItems }
118
- required
119
- />
120
- ),
121
- ];
122
- }
@@ -1,40 +0,0 @@
1
- /**
2
- * External dependencies
3
- */
4
- import { groupBy } from 'lodash';
5
-
6
- /**
7
- * Returns terms in a tree form.
8
- *
9
- * @param {Array} flatTerms Array of terms in flat format.
10
- *
11
- * @return {Array} Array of terms in tree format.
12
- */
13
- export function buildTermsTree( flatTerms ) {
14
- const flatTermsWithParentAndChildren = flatTerms.map( ( term ) => {
15
- return {
16
- children: [],
17
- parent: null,
18
- ...term,
19
- };
20
- } );
21
-
22
- const termsByParent = groupBy( flatTermsWithParentAndChildren, 'parent' );
23
- if ( termsByParent.null && termsByParent.null.length ) {
24
- return flatTermsWithParentAndChildren;
25
- }
26
- const fillWithChildren = ( terms ) => {
27
- return terms.map( ( term ) => {
28
- const children = termsByParent[ term.id ];
29
- return {
30
- ...term,
31
- children:
32
- children && children.length
33
- ? fillWithChildren( children )
34
- : [],
35
- };
36
- } );
37
- };
38
-
39
- return fillWithChildren( termsByParent[ '0' ] || [] );
40
- }
@@ -1,32 +0,0 @@
1
- /**
2
- * External dependencies
3
- */
4
- import { text } from '@storybook/addon-knobs';
5
-
6
- /**
7
- * WordPress dependencies
8
- */
9
- import { wordpress } from '@wordpress/icons';
10
-
11
- /**
12
- * Internal dependencies
13
- */
14
- import { Toolbar, ToolbarButton } from '..';
15
-
16
- export default {
17
- title: 'Components/ToolbarButton',
18
- component: ToolbarButton,
19
- parameters: {
20
- knobs: { disable: false },
21
- },
22
- };
23
-
24
- export const _default = () => {
25
- const label = text( 'Label', 'This is an example label.' );
26
-
27
- return (
28
- <Toolbar label="Example Toolbar">
29
- <ToolbarButton icon={ wordpress } label={ label } />
30
- </Toolbar>
31
- );
32
- };
@@ -1,33 +0,0 @@
1
- /**
2
- * WordPress dependencies
3
- */
4
- import { formatBold, formatItalic, link } from '@wordpress/icons';
5
-
6
- /**
7
- * Internal dependencies
8
- */
9
- import { ToolbarButton, ToolbarGroup } from '..';
10
-
11
- export default { title: 'Components/ToolbarGroup', component: ToolbarGroup };
12
-
13
- export const _default = () => {
14
- return (
15
- <ToolbarGroup>
16
- <ToolbarButton icon={ formatBold } title="Bold" isActive />
17
- <ToolbarButton icon={ formatItalic } title="Italic" />
18
- <ToolbarButton icon={ link } title="Link" />
19
- </ToolbarGroup>
20
- );
21
- };
22
-
23
- export const withControlsProp = () => {
24
- return (
25
- <ToolbarGroup
26
- controls={ [
27
- { icon: formatBold, title: 'Bold', isActive: true },
28
- { icon: formatItalic, title: 'Italic' },
29
- { icon: link, title: 'Link' },
30
- ] }
31
- />
32
- );
33
- };