@wordpress/components 22.1.0 → 23.1.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 (660) hide show
  1. package/CHANGELOG.md +67 -0
  2. package/CONTRIBUTING.md +0 -21
  3. package/build/alignment-matrix-control/cell.js.map +1 -1
  4. package/build/alignment-matrix-control/icon.js +4 -2
  5. package/build/alignment-matrix-control/icon.js.map +1 -1
  6. package/build/alignment-matrix-control/index.js +25 -1
  7. package/build/alignment-matrix-control/index.js.map +1 -1
  8. package/build/alignment-matrix-control/styles/alignment-matrix-control-icon-styles.js +13 -13
  9. package/build/alignment-matrix-control/styles/alignment-matrix-control-icon-styles.js.map +1 -1
  10. package/build/alignment-matrix-control/styles/alignment-matrix-control-styles.js +16 -16
  11. package/build/alignment-matrix-control/styles/alignment-matrix-control-styles.js.map +1 -1
  12. package/build/alignment-matrix-control/types.js +6 -0
  13. package/build/alignment-matrix-control/types.js.map +1 -0
  14. package/build/alignment-matrix-control/utils.js +9 -8
  15. package/build/alignment-matrix-control/utils.js.map +1 -1
  16. package/build/angle-picker-control/styles/angle-picker-control-styles.js +9 -9
  17. package/build/angle-picker-control/styles/angle-picker-control-styles.js.map +1 -1
  18. package/build/autocomplete/index.js +39 -12
  19. package/build/autocomplete/index.js.map +1 -1
  20. package/build/base-control/hooks.js +52 -0
  21. package/build/base-control/hooks.js.map +1 -0
  22. package/build/base-control/index.js +24 -7
  23. package/build/base-control/index.js.map +1 -1
  24. package/build/base-field/hook.js +0 -14
  25. package/build/base-field/hook.js.map +1 -1
  26. package/build/base-field/index.js.map +1 -1
  27. package/build/base-field/styles.js +5 -5
  28. package/build/base-field/styles.js.map +1 -1
  29. package/build/base-field/types.js +6 -0
  30. package/build/base-field/types.js.map +1 -0
  31. package/build/border-box-control/border-box-control/component.js +0 -3
  32. package/build/border-box-control/border-box-control/component.js.map +1 -1
  33. package/build/border-box-control/border-box-control/hook.js +0 -2
  34. package/build/border-box-control/border-box-control/hook.js.map +1 -1
  35. package/build/border-box-control/border-box-control-split-controls/component.js +0 -2
  36. package/build/border-box-control/border-box-control-split-controls/component.js.map +1 -1
  37. package/build/border-box-control/border-box-control-split-controls/hook.js +0 -2
  38. package/build/border-box-control/border-box-control-split-controls/hook.js.map +1 -1
  39. package/build/border-control/border-control/component.js +1 -2
  40. package/build/border-control/border-control/component.js.map +1 -1
  41. package/build/border-control/border-control/hook.js +0 -2
  42. package/build/border-control/border-control/hook.js.map +1 -1
  43. package/build/border-control/border-control-dropdown/component.js +6 -11
  44. package/build/border-control/border-control-dropdown/component.js.map +1 -1
  45. package/build/border-control/border-control-dropdown/hook.js +0 -2
  46. package/build/border-control/border-control-dropdown/hook.js.map +1 -1
  47. package/build/border-control/styles.js +16 -16
  48. package/build/border-control/styles.js.map +1 -1
  49. package/build/box-control/linked-button.js +3 -4
  50. package/build/box-control/linked-button.js.map +1 -1
  51. package/build/color-palette/index.js +7 -15
  52. package/build/color-palette/index.js.map +1 -1
  53. package/build/color-picker/input-with-slider.js +1 -0
  54. package/build/color-picker/input-with-slider.js.map +1 -1
  55. package/build/color-picker/styles.js +8 -8
  56. package/build/color-picker/styles.js.map +1 -1
  57. package/build/custom-select-control/index.js +14 -2
  58. package/build/custom-select-control/index.js.map +1 -1
  59. package/build/dashicon/index.js +1 -4
  60. package/build/dashicon/index.js.map +1 -1
  61. package/build/date-time/date-time/index.js +4 -4
  62. package/build/date-time/date-time/index.js.map +1 -1
  63. package/build/dimension-control/index.js.map +1 -1
  64. package/build/dropdown/index.js +45 -10
  65. package/build/dropdown/index.js.map +1 -1
  66. package/build/duotone-picker/duotone-picker.js +2 -2
  67. package/build/duotone-picker/duotone-picker.js.map +1 -1
  68. package/build/gradient-picker/index.js +4 -11
  69. package/build/gradient-picker/index.js.map +1 -1
  70. package/build/higher-order/navigate-regions/index.js +4 -3
  71. package/build/higher-order/navigate-regions/index.js.map +1 -1
  72. package/build/higher-order/with-fallback-styles/index.js +2 -2
  73. package/build/higher-order/with-fallback-styles/index.js.map +1 -1
  74. package/build/index.js +13 -9
  75. package/build/index.js.map +1 -1
  76. package/build/input-control/index.js +17 -5
  77. package/build/input-control/index.js.map +1 -1
  78. package/build/input-control/input-base.js +2 -0
  79. package/build/input-control/input-base.js.map +1 -1
  80. package/build/mobile/bottom-sheet/cell.native.js +1 -1
  81. package/build/mobile/bottom-sheet/cell.native.js.map +1 -1
  82. package/build/mobile/bottom-sheet/picker-cell.native.js +1 -9
  83. package/build/mobile/bottom-sheet/picker-cell.native.js.map +1 -1
  84. package/build/mobile/bottom-sheet/switch-cell.native.js +1 -3
  85. package/build/mobile/bottom-sheet/switch-cell.native.js.map +1 -1
  86. package/build/mobile/global-styles-context/index.native.js +8 -8
  87. package/build/mobile/global-styles-context/index.native.js.map +1 -1
  88. package/build/mobile/global-styles-context/utils.native.js +30 -12
  89. package/build/mobile/global-styles-context/utils.native.js.map +1 -1
  90. package/build/mobile/keyboard-aware-flat-list/index.ios.js +4 -2
  91. package/build/mobile/keyboard-aware-flat-list/index.ios.js.map +1 -1
  92. package/build/modal/index.js +8 -0
  93. package/build/modal/index.js.map +1 -1
  94. package/build/navigator/navigator-provider/component.js +12 -8
  95. package/build/navigator/navigator-provider/component.js.map +1 -1
  96. package/build/number-control/styles/number-control-styles.js +8 -8
  97. package/build/number-control/styles/number-control-styles.js.map +1 -1
  98. package/build/palette-edit/index.js +72 -33
  99. package/build/palette-edit/index.js.map +1 -1
  100. package/build/popover/index.js +10 -2
  101. package/build/popover/index.js.map +1 -1
  102. package/build/query-controls/index.js +1 -0
  103. package/build/query-controls/index.js.map +1 -1
  104. package/build/snackbar/index.js +35 -24
  105. package/build/snackbar/index.js.map +1 -1
  106. package/build/snackbar/list.js +14 -19
  107. package/build/snackbar/list.js.map +1 -1
  108. package/build/snackbar/types.js +6 -0
  109. package/build/snackbar/types.js.map +1 -0
  110. package/build/tab-panel/index.js +15 -9
  111. package/build/tab-panel/index.js.map +1 -1
  112. package/build/theme/color-algorithms.js +118 -0
  113. package/build/theme/color-algorithms.js.map +1 -0
  114. package/build/theme/index.js +21 -18
  115. package/build/theme/index.js.map +1 -1
  116. package/build/theme/styles.js +10 -7
  117. package/build/theme/styles.js.map +1 -1
  118. package/build/toggle-control/index.js +5 -2
  119. package/build/toggle-control/index.js.map +1 -1
  120. package/build/ui/context/context-system-provider.js +3 -1
  121. package/build/ui/context/context-system-provider.js.map +1 -1
  122. package/build/unit-control/index.js +5 -2
  123. package/build/unit-control/index.js.map +1 -1
  124. package/build/utils/colors-values.js +1 -1
  125. package/build/utils/colors-values.js.map +1 -1
  126. package/build/utils/config-values.js +0 -2
  127. package/build/utils/config-values.js.map +1 -1
  128. package/build/utils/hooks/use-controlled-value.js.map +1 -1
  129. package/build-module/alignment-matrix-control/cell.js.map +1 -1
  130. package/build-module/alignment-matrix-control/icon.js +4 -2
  131. package/build-module/alignment-matrix-control/icon.js.map +1 -1
  132. package/build-module/alignment-matrix-control/index.js +23 -1
  133. package/build-module/alignment-matrix-control/index.js.map +1 -1
  134. package/build-module/alignment-matrix-control/styles/alignment-matrix-control-icon-styles.js +13 -13
  135. package/build-module/alignment-matrix-control/styles/alignment-matrix-control-icon-styles.js.map +1 -1
  136. package/build-module/alignment-matrix-control/styles/alignment-matrix-control-styles.js +16 -16
  137. package/build-module/alignment-matrix-control/styles/alignment-matrix-control-styles.js.map +1 -1
  138. package/build-module/alignment-matrix-control/types.js +2 -0
  139. package/build-module/alignment-matrix-control/types.js.map +1 -0
  140. package/build-module/alignment-matrix-control/utils.js +13 -8
  141. package/build-module/alignment-matrix-control/utils.js.map +1 -1
  142. package/build-module/angle-picker-control/styles/angle-picker-control-styles.js +9 -9
  143. package/build-module/angle-picker-control/styles/angle-picker-control-styles.js.map +1 -1
  144. package/build-module/autocomplete/index.js +39 -11
  145. package/build-module/autocomplete/index.js.map +1 -1
  146. package/build-module/base-control/hooks.js +41 -0
  147. package/build-module/base-control/hooks.js.map +1 -0
  148. package/build-module/base-control/index.js +18 -8
  149. package/build-module/base-control/index.js.map +1 -1
  150. package/build-module/base-field/hook.js +0 -14
  151. package/build-module/base-field/hook.js.map +1 -1
  152. package/build-module/base-field/index.js.map +1 -1
  153. package/build-module/base-field/styles.js +5 -5
  154. package/build-module/base-field/styles.js.map +1 -1
  155. package/build-module/base-field/types.js +2 -0
  156. package/build-module/base-field/types.js.map +1 -0
  157. package/build-module/border-box-control/border-box-control/component.js +0 -3
  158. package/build-module/border-box-control/border-box-control/component.js.map +1 -1
  159. package/build-module/border-box-control/border-box-control/hook.js +0 -2
  160. package/build-module/border-box-control/border-box-control/hook.js.map +1 -1
  161. package/build-module/border-box-control/border-box-control-split-controls/component.js +0 -2
  162. package/build-module/border-box-control/border-box-control-split-controls/component.js.map +1 -1
  163. package/build-module/border-box-control/border-box-control-split-controls/hook.js +0 -2
  164. package/build-module/border-box-control/border-box-control-split-controls/hook.js.map +1 -1
  165. package/build-module/border-control/border-control/component.js +1 -2
  166. package/build-module/border-control/border-control/component.js.map +1 -1
  167. package/build-module/border-control/border-control/hook.js +0 -2
  168. package/build-module/border-control/border-control/hook.js.map +1 -1
  169. package/build-module/border-control/border-control-dropdown/component.js +6 -11
  170. package/build-module/border-control/border-control-dropdown/component.js.map +1 -1
  171. package/build-module/border-control/border-control-dropdown/hook.js +0 -2
  172. package/build-module/border-control/border-control-dropdown/hook.js.map +1 -1
  173. package/build-module/border-control/styles.js +17 -17
  174. package/build-module/border-control/styles.js.map +1 -1
  175. package/build-module/box-control/linked-button.js +3 -4
  176. package/build-module/box-control/linked-button.js.map +1 -1
  177. package/build-module/color-palette/index.js +7 -15
  178. package/build-module/color-palette/index.js.map +1 -1
  179. package/build-module/color-picker/input-with-slider.js +1 -0
  180. package/build-module/color-picker/input-with-slider.js.map +1 -1
  181. package/build-module/color-picker/styles.js +8 -8
  182. package/build-module/color-picker/styles.js.map +1 -1
  183. package/build-module/custom-select-control/index.js +14 -2
  184. package/build-module/custom-select-control/index.js.map +1 -1
  185. package/build-module/dashicon/index.js +1 -4
  186. package/build-module/dashicon/index.js.map +1 -1
  187. package/build-module/date-time/date-time/index.js +4 -4
  188. package/build-module/date-time/date-time/index.js.map +1 -1
  189. package/build-module/dimension-control/index.js +1 -2
  190. package/build-module/dimension-control/index.js.map +1 -1
  191. package/build-module/dropdown/index.js +44 -10
  192. package/build-module/dropdown/index.js.map +1 -1
  193. package/build-module/duotone-picker/duotone-picker.js +2 -2
  194. package/build-module/duotone-picker/duotone-picker.js.map +1 -1
  195. package/build-module/gradient-picker/index.js +4 -10
  196. package/build-module/gradient-picker/index.js.map +1 -1
  197. package/build-module/higher-order/navigate-regions/index.js +4 -3
  198. package/build-module/higher-order/navigate-regions/index.js.map +1 -1
  199. package/build-module/higher-order/with-fallback-styles/index.js +2 -2
  200. package/build-module/higher-order/with-fallback-styles/index.js.map +1 -1
  201. package/build-module/index.js +2 -3
  202. package/build-module/index.js.map +1 -1
  203. package/build-module/input-control/index.js +16 -5
  204. package/build-module/input-control/index.js.map +1 -1
  205. package/build-module/input-control/input-base.js +2 -0
  206. package/build-module/input-control/input-base.js.map +1 -1
  207. package/build-module/mobile/bottom-sheet/cell.native.js +1 -1
  208. package/build-module/mobile/bottom-sheet/cell.native.js.map +1 -1
  209. package/build-module/mobile/bottom-sheet/picker-cell.native.js +1 -8
  210. package/build-module/mobile/bottom-sheet/picker-cell.native.js.map +1 -1
  211. package/build-module/mobile/bottom-sheet/switch-cell.native.js +1 -2
  212. package/build-module/mobile/bottom-sheet/switch-cell.native.js.map +1 -1
  213. package/build-module/mobile/global-styles-context/index.native.js +8 -7
  214. package/build-module/mobile/global-styles-context/index.native.js.map +1 -1
  215. package/build-module/mobile/global-styles-context/utils.native.js +31 -13
  216. package/build-module/mobile/global-styles-context/utils.native.js.map +1 -1
  217. package/build-module/mobile/keyboard-aware-flat-list/index.ios.js +2 -2
  218. package/build-module/mobile/keyboard-aware-flat-list/index.ios.js.map +1 -1
  219. package/build-module/modal/index.js +8 -0
  220. package/build-module/modal/index.js.map +1 -1
  221. package/build-module/navigator/navigator-provider/component.js +12 -8
  222. package/build-module/navigator/navigator-provider/component.js.map +1 -1
  223. package/build-module/number-control/styles/number-control-styles.js +8 -10
  224. package/build-module/number-control/styles/number-control-styles.js.map +1 -1
  225. package/build-module/palette-edit/index.js +73 -34
  226. package/build-module/palette-edit/index.js.map +1 -1
  227. package/build-module/popover/index.js +10 -2
  228. package/build-module/popover/index.js.map +1 -1
  229. package/build-module/query-controls/index.js +1 -0
  230. package/build-module/query-controls/index.js.map +1 -1
  231. package/build-module/snackbar/index.js +33 -23
  232. package/build-module/snackbar/index.js.map +1 -1
  233. package/build-module/snackbar/list.js +14 -22
  234. package/build-module/snackbar/list.js.map +1 -1
  235. package/build-module/snackbar/types.js +2 -0
  236. package/build-module/snackbar/types.js.map +1 -0
  237. package/build-module/tab-panel/index.js +15 -8
  238. package/build-module/tab-panel/index.js.map +1 -1
  239. package/build-module/theme/color-algorithms.js +105 -0
  240. package/build-module/theme/color-algorithms.js.map +1 -0
  241. package/build-module/theme/index.js +21 -17
  242. package/build-module/theme/index.js.map +1 -1
  243. package/build-module/theme/styles.js +8 -6
  244. package/build-module/theme/styles.js.map +1 -1
  245. package/build-module/toggle-control/index.js +4 -2
  246. package/build-module/toggle-control/index.js.map +1 -1
  247. package/build-module/ui/context/context-system-provider.js +3 -2
  248. package/build-module/ui/context/context-system-provider.js.map +1 -1
  249. package/build-module/unit-control/index.js +5 -2
  250. package/build-module/unit-control/index.js.map +1 -1
  251. package/build-module/utils/colors-values.js +1 -1
  252. package/build-module/utils/colors-values.js.map +1 -1
  253. package/build-module/utils/config-values.js +0 -2
  254. package/build-module/utils/config-values.js.map +1 -1
  255. package/build-module/utils/hooks/use-controlled-value.js.map +1 -1
  256. package/build-style/style-rtl.css +108 -104
  257. package/build-style/style.css +108 -104
  258. package/build-types/alignment-matrix-control/cell.d.ts +5 -0
  259. package/build-types/alignment-matrix-control/cell.d.ts.map +1 -0
  260. package/build-types/alignment-matrix-control/icon.d.ts +6 -0
  261. package/build-types/alignment-matrix-control/icon.d.ts.map +1 -0
  262. package/build-types/alignment-matrix-control/index.d.ts +30 -0
  263. package/build-types/alignment-matrix-control/index.d.ts.map +1 -0
  264. package/build-types/alignment-matrix-control/stories/index.d.ts +14 -0
  265. package/build-types/alignment-matrix-control/stories/index.d.ts.map +1 -0
  266. package/build-types/alignment-matrix-control/styles/alignment-matrix-control-icon-styles.d.ts +19 -0
  267. package/build-types/alignment-matrix-control/styles/alignment-matrix-control-icon-styles.d.ts.map +1 -0
  268. package/build-types/alignment-matrix-control/styles/alignment-matrix-control-styles.d.ts +23 -0
  269. package/build-types/alignment-matrix-control/styles/alignment-matrix-control-styles.d.ts.map +1 -0
  270. package/build-types/alignment-matrix-control/test/index.d.ts +2 -0
  271. package/build-types/alignment-matrix-control/test/index.d.ts.map +1 -0
  272. package/build-types/alignment-matrix-control/types.d.ts +39 -0
  273. package/build-types/alignment-matrix-control/types.d.ts.map +1 -0
  274. package/build-types/alignment-matrix-control/utils.d.ts +33 -0
  275. package/build-types/alignment-matrix-control/utils.d.ts.map +1 -0
  276. package/build-types/base-control/hooks.d.ts +23 -0
  277. package/build-types/base-control/hooks.d.ts.map +1 -0
  278. package/build-types/base-control/index.d.ts +17 -7
  279. package/build-types/base-control/index.d.ts.map +1 -1
  280. package/build-types/base-control/stories/index.d.ts.map +1 -1
  281. package/build-types/base-control/test/index.d.ts +2 -0
  282. package/build-types/base-control/test/index.d.ts.map +1 -0
  283. package/build-types/base-control/types.d.ts +8 -2
  284. package/build-types/base-control/types.d.ts.map +1 -1
  285. package/build-types/base-field/hook.d.ts +7 -31
  286. package/build-types/base-field/hook.d.ts.map +1 -1
  287. package/build-types/base-field/index.d.ts +1 -1
  288. package/build-types/base-field/index.d.ts.map +1 -1
  289. package/build-types/base-field/styles.d.ts +5 -5
  290. package/build-types/base-field/styles.d.ts.map +1 -1
  291. package/build-types/base-field/test/index.d.ts +2 -0
  292. package/build-types/base-field/test/index.d.ts.map +1 -0
  293. package/build-types/base-field/types.d.ts +29 -0
  294. package/build-types/base-field/types.d.ts.map +1 -0
  295. package/build-types/border-box-control/border-box-control/component.d.ts +1 -1
  296. package/build-types/border-box-control/border-box-control/component.d.ts.map +1 -1
  297. package/build-types/border-box-control/border-box-control/hook.d.ts +2 -3
  298. package/build-types/border-box-control/border-box-control/hook.d.ts.map +1 -1
  299. package/build-types/border-box-control/border-box-control-linked-button/hook.d.ts +2 -2
  300. package/build-types/border-box-control/border-box-control-split-controls/component.d.ts +1 -1
  301. package/build-types/border-box-control/border-box-control-split-controls/component.d.ts.map +1 -1
  302. package/build-types/border-box-control/border-box-control-split-controls/hook.d.ts +2 -3
  303. package/build-types/border-box-control/border-box-control-split-controls/hook.d.ts.map +1 -1
  304. package/build-types/border-box-control/border-box-control-visualizer/hook.d.ts +2 -2
  305. package/build-types/border-box-control/stories/index.d.ts +1 -1
  306. package/build-types/border-control/border-control/component.d.ts +1 -1
  307. package/build-types/border-control/border-control/component.d.ts.map +1 -1
  308. package/build-types/border-control/border-control/hook.d.ts +2 -3
  309. package/build-types/border-control/border-control/hook.d.ts.map +1 -1
  310. package/build-types/border-control/border-control-dropdown/component.d.ts +1 -1
  311. package/build-types/border-control/border-control-dropdown/component.d.ts.map +1 -1
  312. package/build-types/border-control/border-control-dropdown/hook.d.ts +2 -3
  313. package/build-types/border-control/border-control-dropdown/hook.d.ts.map +1 -1
  314. package/build-types/border-control/border-control-style-picker/hook.d.ts +2 -2
  315. package/build-types/border-control/stories/index.d.ts +6 -6
  316. package/build-types/border-control/stories/index.d.ts.map +1 -1
  317. package/build-types/border-control/styles.d.ts.map +1 -1
  318. package/build-types/border-control/types.d.ts +1 -1
  319. package/build-types/border-control/types.d.ts.map +1 -1
  320. package/build-types/card/card/hook.d.ts +2 -2
  321. package/build-types/card/card-body/hook.d.ts +2 -2
  322. package/build-types/card/card-divider/hook.d.ts +2 -2
  323. package/build-types/card/card-footer/hook.d.ts +2 -2
  324. package/build-types/card/card-header/hook.d.ts +2 -2
  325. package/build-types/card/card-media/hook.d.ts +2 -2
  326. package/build-types/color-palette/index.d.ts +3 -4
  327. package/build-types/color-palette/index.d.ts.map +1 -1
  328. package/build-types/color-palette/stories/index.d.ts +6 -14
  329. package/build-types/color-palette/stories/index.d.ts.map +1 -1
  330. package/build-types/color-palette/styles.d.ts +1 -1
  331. package/build-types/color-palette/types.d.ts +4 -17
  332. package/build-types/color-palette/types.d.ts.map +1 -1
  333. package/build-types/color-picker/input-with-slider.d.ts.map +1 -1
  334. package/build-types/color-picker/styles.d.ts +5 -5
  335. package/build-types/color-picker/styles.d.ts.map +1 -1
  336. package/build-types/custom-select-control/index.d.ts.map +1 -1
  337. package/build-types/dashicon/index.d.ts +6 -20
  338. package/build-types/dashicon/index.d.ts.map +1 -1
  339. package/build-types/dashicon/types.d.ts +14 -0
  340. package/build-types/dashicon/types.d.ts.map +1 -1
  341. package/build-types/date-time/date/styles.d.ts +3 -3
  342. package/build-types/date-time/date-time/styles.d.ts +3 -3
  343. package/build-types/date-time/time/styles.d.ts +8 -8
  344. package/build-types/disabled/stories/index.d.ts.map +1 -1
  345. package/build-types/dropdown/index.d.ts +29 -1
  346. package/build-types/dropdown/index.d.ts.map +1 -1
  347. package/build-types/dropdown/stories/index.d.ts +23 -0
  348. package/build-types/dropdown/stories/index.d.ts.map +1 -0
  349. package/build-types/dropdown/test/index.d.ts +2 -0
  350. package/build-types/dropdown/test/index.d.ts.map +1 -0
  351. package/build-types/dropdown/types.d.ts +101 -0
  352. package/build-types/dropdown/types.d.ts.map +1 -1
  353. package/build-types/elevation/hook.d.ts +2 -2
  354. package/build-types/external-link/styles/external-link-styles.d.ts +1 -1
  355. package/build-types/flex/flex/hook.d.ts +2 -2
  356. package/build-types/flex/flex-block/hook.d.ts +2 -2
  357. package/build-types/flex/flex-item/hook.d.ts +2 -2
  358. package/build-types/focal-point-picker/styles/focal-point-picker-style.d.ts +2 -5
  359. package/build-types/focal-point-picker/styles/focal-point-picker-style.d.ts.map +1 -1
  360. package/build-types/grid/hook.d.ts +2 -2
  361. package/build-types/h-stack/component.d.ts +1 -1
  362. package/build-types/h-stack/hook.d.ts +2 -2
  363. package/build-types/heading/hook.d.ts +2 -2
  364. package/build-types/icon/stories/index.d.ts +22 -0
  365. package/build-types/icon/stories/index.d.ts.map +1 -0
  366. package/build-types/input-control/index.d.ts +1 -1
  367. package/build-types/input-control/index.d.ts.map +1 -1
  368. package/build-types/input-control/input-base.d.ts.map +1 -1
  369. package/build-types/input-control/stories/index.d.ts +1 -0
  370. package/build-types/input-control/stories/index.d.ts.map +1 -1
  371. package/build-types/input-control/types.d.ts +2 -1
  372. package/build-types/input-control/types.d.ts.map +1 -1
  373. package/build-types/item-group/item/hook.d.ts +2 -2
  374. package/build-types/item-group/item-group/hook.d.ts +2 -2
  375. package/build-types/modal/index.d.ts.map +1 -1
  376. package/build-types/modal/stories/index.d.ts.map +1 -1
  377. package/build-types/navigator/navigator-back-button/hook.d.ts +3 -3
  378. package/build-types/navigator/navigator-button/hook.d.ts +3 -3
  379. package/build-types/navigator/navigator-provider/component.d.ts.map +1 -1
  380. package/build-types/number-control/index.d.ts +2 -2
  381. package/build-types/number-control/index.d.ts.map +1 -1
  382. package/build-types/number-control/stories/index.d.ts +25 -0
  383. package/build-types/number-control/stories/index.d.ts.map +1 -0
  384. package/build-types/number-control/styles/number-control-styles.d.ts +6 -6
  385. package/build-types/number-control/styles/number-control-styles.d.ts.map +1 -1
  386. package/build-types/number-control/test/index.d.ts +2 -0
  387. package/build-types/number-control/test/index.d.ts.map +1 -0
  388. package/build-types/popover/index.d.ts +1 -1
  389. package/build-types/popover/index.d.ts.map +1 -1
  390. package/build-types/popover/stories/e2e/index.d.ts +1 -1
  391. package/build-types/range-control/index.d.ts +1 -1
  392. package/build-types/range-control/styles/range-control-styles.d.ts +2 -2
  393. package/build-types/resizable-box/resize-tooltip/index.d.ts +15 -19
  394. package/build-types/resizable-box/resize-tooltip/index.d.ts.map +1 -1
  395. package/build-types/resizable-box/resize-tooltip/label.d.ts +4 -3
  396. package/build-types/resizable-box/resize-tooltip/label.d.ts.map +1 -1
  397. package/build-types/scrollable/hook.d.ts +2 -2
  398. package/build-types/search-control/index.d.ts +1 -1
  399. package/build-types/search-control/stories/index.d.ts +2 -2
  400. package/build-types/snackbar/index.d.ts +19 -0
  401. package/build-types/snackbar/index.d.ts.map +1 -0
  402. package/build-types/snackbar/list.d.ts +18 -0
  403. package/build-types/snackbar/list.d.ts.map +1 -0
  404. package/build-types/snackbar/stories/index.d.ts +16 -0
  405. package/build-types/snackbar/stories/index.d.ts.map +1 -0
  406. package/build-types/snackbar/stories/list.d.ts +12 -0
  407. package/build-types/snackbar/stories/list.d.ts.map +1 -0
  408. package/build-types/snackbar/types.d.ts +111 -0
  409. package/build-types/snackbar/types.d.ts.map +1 -0
  410. package/build-types/spacer/hook.d.ts +2 -2
  411. package/build-types/spinner/index.d.ts +1 -1
  412. package/build-types/surface/hook.d.ts +2 -2
  413. package/build-types/tab-panel/index.d.ts +1 -1
  414. package/build-types/tab-panel/index.d.ts.map +1 -1
  415. package/build-types/tab-panel/types.d.ts +19 -1
  416. package/build-types/tab-panel/types.d.ts.map +1 -1
  417. package/build-types/text/hook.d.ts +2 -2
  418. package/build-types/text-control/index.d.ts +2 -2
  419. package/build-types/text-control/stories/index.d.ts.map +1 -1
  420. package/build-types/text-control/types.d.ts +1 -5
  421. package/build-types/text-control/types.d.ts.map +1 -1
  422. package/build-types/theme/color-algorithms.d.ts +20 -0
  423. package/build-types/theme/color-algorithms.d.ts.map +1 -0
  424. package/build-types/theme/index.d.ts +1 -1
  425. package/build-types/theme/index.d.ts.map +1 -1
  426. package/build-types/theme/stories/index.d.ts +4 -0
  427. package/build-types/theme/stories/index.d.ts.map +1 -1
  428. package/build-types/theme/styles.d.ts +3 -2
  429. package/build-types/theme/styles.d.ts.map +1 -1
  430. package/build-types/theme/test/color-algorithms.d.ts +2 -0
  431. package/build-types/theme/test/color-algorithms.d.ts.map +1 -0
  432. package/build-types/theme/types.d.ts +41 -3
  433. package/build-types/theme/types.d.ts.map +1 -1
  434. package/build-types/toggle-control/index.d.ts.map +1 -1
  435. package/build-types/toggle-group-control/toggle-group-control/as-button-group.d.ts +2 -2
  436. package/build-types/toggle-group-control/toggle-group-control/as-radio-group.d.ts +2 -2
  437. package/build-types/toggle-group-control/toggle-group-control-option/component.d.ts +1 -1
  438. package/build-types/toggle-group-control/toggle-group-control-option-icon/component.d.ts +1 -1
  439. package/build-types/tools-panel/tools-panel/hook.d.ts +2 -2
  440. package/build-types/tools-panel/tools-panel-header/hook.d.ts +2 -2
  441. package/build-types/tools-panel/tools-panel-item/hook.d.ts +2 -2
  442. package/build-types/truncate/hook.d.ts +2 -2
  443. package/build-types/ui/context/context-system-provider.d.ts.map +1 -1
  444. package/build-types/ui/control-group/hook.d.ts +2 -2
  445. package/build-types/ui/control-label/hook.d.ts +2 -2
  446. package/build-types/ui/form-group/form-group.d.ts +2 -2
  447. package/build-types/ui/form-group/use-form-group.d.ts +5 -5
  448. package/build-types/unit-control/index.d.ts +2 -1
  449. package/build-types/unit-control/index.d.ts.map +1 -1
  450. package/build-types/unit-control/styles/unit-control-styles.d.ts +2 -2
  451. package/build-types/unit-control/types.d.ts +4 -0
  452. package/build-types/unit-control/types.d.ts.map +1 -1
  453. package/build-types/utils/config-values.d.ts +0 -2
  454. package/build-types/utils/hooks/use-controlled-value.d.ts +2 -1
  455. package/build-types/utils/hooks/use-controlled-value.d.ts.map +1 -1
  456. package/build-types/v-stack/component.d.ts +2 -2
  457. package/build-types/v-stack/hook.d.ts +2 -2
  458. package/build-types/v-stack/stories/index.d.ts +2 -2
  459. package/package.json +21 -20
  460. package/src/alignment-matrix-control/README.md +7 -7
  461. package/src/alignment-matrix-control/{cell.js → cell.tsx} +7 -1
  462. package/src/alignment-matrix-control/{icon.js → icon.tsx} +6 -3
  463. package/src/alignment-matrix-control/{index.js → index.tsx} +31 -4
  464. package/src/alignment-matrix-control/stories/{index.js → index.tsx} +17 -9
  465. package/src/alignment-matrix-control/styles/{alignment-matrix-control-icon-styles.js → alignment-matrix-control-icon-styles.ts} +11 -3
  466. package/src/alignment-matrix-control/styles/{alignment-matrix-control-styles.js → alignment-matrix-control-styles.ts} +13 -3
  467. package/src/alignment-matrix-control/test/{index.js → index.tsx} +5 -5
  468. package/src/alignment-matrix-control/types.ts +54 -0
  469. package/src/alignment-matrix-control/{utils.js → utils.tsx} +24 -14
  470. package/src/angle-picker-control/styles/angle-picker-control-styles.js +4 -0
  471. package/src/autocomplete/index.js +44 -15
  472. package/src/autocomplete/test/index.js +2 -0
  473. package/src/base-control/README.md +21 -12
  474. package/src/base-control/hooks.ts +45 -0
  475. package/src/base-control/index.tsx +18 -7
  476. package/src/base-control/stories/index.tsx +8 -10
  477. package/src/base-control/test/index.tsx +53 -0
  478. package/src/base-control/types.ts +8 -2
  479. package/src/base-field/README.md +21 -22
  480. package/src/base-field/{hook.js → hook.ts} +5 -15
  481. package/src/base-field/{index.js → index.ts} +0 -0
  482. package/src/base-field/{styles.js → styles.ts} +2 -2
  483. package/src/base-field/test/__snapshots__/{index.js.snap → index.tsx.snap} +4 -4
  484. package/src/base-field/test/{index.js → index.tsx} +10 -5
  485. package/src/base-field/types.ts +29 -0
  486. package/src/border-box-control/border-box-control/README.md +1 -0
  487. package/src/border-box-control/border-box-control/component.tsx +0 -7
  488. package/src/border-box-control/border-box-control/hook.ts +0 -2
  489. package/src/border-box-control/border-box-control-split-controls/component.tsx +0 -2
  490. package/src/border-box-control/border-box-control-split-controls/hook.ts +0 -2
  491. package/src/border-box-control/test/index.js +5 -1
  492. package/src/border-control/border-control/component.tsx +1 -4
  493. package/src/border-control/border-control/hook.ts +0 -2
  494. package/src/border-control/border-control-dropdown/component.tsx +11 -17
  495. package/src/border-control/border-control-dropdown/hook.ts +0 -2
  496. package/src/border-control/stories/index.tsx +0 -1
  497. package/src/border-control/styles.ts +1 -10
  498. package/src/border-control/test/index.js +70 -67
  499. package/src/border-control/types.ts +1 -4
  500. package/src/box-control/linked-button.js +8 -11
  501. package/src/box-control/test/index.js +207 -134
  502. package/src/button/stories/index.js +30 -0
  503. package/src/button/style.scss +17 -14
  504. package/src/button/test/index.js +32 -15
  505. package/src/card/test/index.tsx +32 -20
  506. package/src/checkbox-control/test/index.tsx +2 -0
  507. package/src/circular-option-picker/style.scss +1 -0
  508. package/src/color-palette/index.tsx +16 -18
  509. package/src/color-palette/stories/index.tsx +1 -18
  510. package/src/color-palette/test/__snapshots__/index.tsx.snap +4 -4
  511. package/src/color-palette/test/index.tsx +86 -36
  512. package/src/color-palette/types.ts +4 -18
  513. package/src/color-picker/README.md +1 -0
  514. package/src/color-picker/input-with-slider.tsx +1 -0
  515. package/src/color-picker/styles.ts +0 -4
  516. package/src/color-picker/test/index.js +2 -0
  517. package/src/combobox-control/test/index.js +2 -0
  518. package/src/confirm-dialog/README.md +3 -2
  519. package/src/confirm-dialog/test/index.js +2 -0
  520. package/src/custom-select-control/README.md +14 -0
  521. package/src/custom-select-control/index.js +14 -2
  522. package/src/dashicon/{index.js → index.tsx} +10 -4
  523. package/src/dashicon/types.ts +17 -0
  524. package/src/date-time/date/test/index.tsx +2 -0
  525. package/src/date-time/date-time/index.tsx +2 -2
  526. package/src/date-time/time/test/index.tsx +2 -0
  527. package/src/dimension-control/index.js +2 -3
  528. package/src/dimension-control/test/__snapshots__/index.test.js.snap +4 -8
  529. package/src/dimension-control/test/index.test.js +2 -0
  530. package/src/disabled/stories/index.tsx +6 -2
  531. package/src/disabled/test/index.tsx +23 -11
  532. package/src/dropdown/README.md +41 -46
  533. package/src/dropdown/{index.js → index.tsx} +57 -13
  534. package/src/dropdown/stories/{index.js → index.tsx} +21 -8
  535. package/src/dropdown/test/index.tsx +88 -0
  536. package/src/dropdown/types.ts +107 -0
  537. package/src/dropdown-menu/README.md +2 -3
  538. package/src/dropdown-menu/test/index.js +20 -12
  539. package/src/duotone-picker/duotone-picker.js +2 -2
  540. package/src/external-link/test/index.tsx +2 -0
  541. package/src/focal-point-picker/test/index.js +2 -0
  542. package/src/focal-point-picker/test/media.js +26 -21
  543. package/src/font-size-picker/test/index.tsx +2 -0
  544. package/src/form-file-upload/test/index.tsx +2 -0
  545. package/src/form-toggle/test/index.tsx +2 -0
  546. package/src/form-token-field/style.scss +1 -1
  547. package/src/form-token-field/test/index.tsx +3 -0
  548. package/src/gradient-picker/index.js +6 -10
  549. package/src/gradient-picker/stories/index.js +0 -1
  550. package/src/grid/test/grid.tsx +31 -31
  551. package/src/guide/test/index.js +2 -0
  552. package/src/higher-order/navigate-regions/index.js +5 -2
  553. package/src/higher-order/navigate-regions/style.scss +13 -59
  554. package/src/higher-order/with-fallback-styles/index.js +4 -2
  555. package/src/higher-order/with-filters/test/index.js +32 -43
  556. package/src/higher-order/with-focus-outside/test/index.js +2 -0
  557. package/src/higher-order/with-focus-return/test/index.js +3 -4
  558. package/src/higher-order/with-notices/test/index.js +1 -0
  559. package/src/icon/stories/index.tsx +103 -0
  560. package/src/index.js +2 -3
  561. package/src/input-control/index.tsx +42 -28
  562. package/src/input-control/input-base.tsx +8 -1
  563. package/src/input-control/stories/index.tsx +6 -0
  564. package/src/input-control/test/index.js +21 -0
  565. package/src/input-control/types.ts +2 -0
  566. package/src/isolated-event-container/test/index.js +2 -0
  567. package/src/mobile/bottom-sheet/cell.native.js +1 -1
  568. package/src/mobile/bottom-sheet/picker-cell.native.js +1 -6
  569. package/src/mobile/bottom-sheet/switch-cell.native.js +2 -2
  570. package/src/mobile/global-styles-context/index.native.js +9 -11
  571. package/src/mobile/global-styles-context/utils.native.js +17 -16
  572. package/src/mobile/keyboard-aware-flat-list/index.ios.js +2 -2
  573. package/src/mobile/link-settings/test/edit.native.js +68 -124
  574. package/src/modal/index.tsx +11 -0
  575. package/src/modal/stories/index.tsx +3 -0
  576. package/src/modal/test/index.tsx +13 -0
  577. package/src/navigable-container/test/navigable-menu.js +2 -0
  578. package/src/navigable-container/test/tababble-container.js +2 -0
  579. package/src/navigation/stories/index.js +6 -6
  580. package/src/navigation/stories/{controlled-state.js → utils/controlled-state.js} +3 -3
  581. package/src/navigation/stories/{default.js → utils/default.js} +3 -3
  582. package/src/navigation/stories/{group.js → utils/group.js} +4 -4
  583. package/src/navigation/stories/{hide-if-empty.js → utils/hide-if-empty.js} +3 -3
  584. package/src/navigation/stories/{more-examples.js → utils/more-examples.js} +4 -4
  585. package/src/navigation/stories/{search.js → utils/search.js} +5 -5
  586. package/src/navigation/test/index.js +2 -0
  587. package/src/navigator/navigator-provider/component.tsx +13 -10
  588. package/src/navigator/test/index.tsx +2 -0
  589. package/src/notice/test/index.js +8 -3
  590. package/src/notice/test/list.js +8 -5
  591. package/src/number-control/stories/{index.js → index.tsx} +24 -7
  592. package/src/number-control/styles/{number-control-styles.js → number-control-styles.ts} +5 -3
  593. package/src/number-control/test/index.tsx +602 -0
  594. package/src/palette-edit/index.js +88 -39
  595. package/src/palette-edit/test/index.js +25 -1
  596. package/src/panel/test/__snapshots__/body.js.snap +9 -0
  597. package/src/panel/test/body.js +71 -62
  598. package/src/placeholder/test/index.tsx +3 -0
  599. package/src/popover/index.tsx +10 -2
  600. package/src/popover/style.scss +12 -11
  601. package/src/popover/test/index.tsx +25 -15
  602. package/src/query-controls/index.js +1 -0
  603. package/src/range-control/test/index.tsx +57 -60
  604. package/src/resizable-box/style.scss +1 -0
  605. package/src/sandbox/test/index.js +13 -11
  606. package/src/search-control/style.scss +4 -0
  607. package/src/select-control/test/select-control.tsx +2 -0
  608. package/src/snackbar/README.md +63 -8
  609. package/src/snackbar/{index.js → index.tsx} +46 -28
  610. package/src/snackbar/{list.js → list.tsx} +20 -21
  611. package/src/snackbar/stories/index.tsx +96 -0
  612. package/src/snackbar/stories/list.tsx +98 -0
  613. package/src/snackbar/types.ts +116 -0
  614. package/src/tab-panel/README.md +9 -0
  615. package/src/tab-panel/index.tsx +15 -5
  616. package/src/tab-panel/style.scss +46 -34
  617. package/src/tab-panel/test/index.tsx +113 -0
  618. package/src/tab-panel/types.ts +20 -1
  619. package/src/text/test/__snapshots__/index.tsx.snap +1 -0
  620. package/src/text/test/index.tsx +98 -46
  621. package/src/text-control/stories/index.tsx +0 -1
  622. package/src/text-control/types.ts +1 -6
  623. package/src/text-highlight/test/index.tsx +1 -0
  624. package/src/theme/README.md +32 -2
  625. package/src/theme/color-algorithms.ts +138 -0
  626. package/src/theme/index.tsx +23 -16
  627. package/src/theme/stories/index.tsx +67 -0
  628. package/src/theme/styles.ts +22 -17
  629. package/src/theme/test/color-algorithms.ts +100 -0
  630. package/src/theme/test/index.tsx +68 -35
  631. package/src/theme/types.ts +43 -3
  632. package/src/toggle-control/index.tsx +4 -2
  633. package/src/toggle-group-control/test/index.tsx +15 -2
  634. package/src/toolbar/style.scss +1 -1
  635. package/src/toolbar-group/test/index.js +10 -6
  636. package/src/tools-panel/stories/index.js +1 -1
  637. package/src/tools-panel/stories/{tools-panel-with-item-group-slot.js → utils/tools-panel-with-item-group-slot.js} +14 -11
  638. package/src/tools-panel/test/index.js +20 -14
  639. package/src/tooltip/README.md +7 -0
  640. package/src/tooltip/stories/index.js +68 -78
  641. package/src/tooltip/style.scss +2 -2
  642. package/src/tooltip/test/index.js +111 -18
  643. package/src/ui/context/context-system-provider.js +3 -2
  644. package/src/ui/context/test/context-system-provider.js +5 -4
  645. package/src/ui/control-label/test/index.js +3 -5
  646. package/src/unit-control/README.md +9 -1
  647. package/src/unit-control/index.tsx +3 -0
  648. package/src/unit-control/test/index.tsx +4 -0
  649. package/src/unit-control/types.ts +4 -0
  650. package/src/utils/colors-values.js +1 -1
  651. package/src/utils/config-values.js +0 -2
  652. package/src/utils/hooks/test/use-latest-ref.js +2 -0
  653. package/src/utils/hooks/use-controlled-value.ts +2 -2
  654. package/src/utils/theme-variables.scss +20 -0
  655. package/tsconfig.json +2 -4
  656. package/tsconfig.tsbuildinfo +1 -1
  657. package/src/dropdown/test/index.js +0 -98
  658. package/src/icon/stories/index.js +0 -128
  659. package/src/number-control/test/index.js +0 -478
  660. package/src/snackbar/stories/index.js +0 -89
@@ -16,19 +16,14 @@ import warning from '@wordpress/warning';
16
16
  * Internal dependencies
17
17
  */
18
18
 
19
- import { Button } from '../';
20
-
21
- const noop = () => {};
22
-
19
+ import Button from '../button';
23
20
  const NOTICE_TIMEOUT = 10000;
24
- /** @typedef {import('@wordpress/element').WPElement} WPElement */
25
-
26
21
  /**
27
22
  * Custom hook which announces the message with the given politeness, if a
28
23
  * valid message is provided.
29
24
  *
30
- * @param {string|WPElement} [message] Message to announce.
31
- * @param {'polite'|'assertive'} politeness Politeness to announce.
25
+ * @param message Message to announce.
26
+ * @param politeness Politeness to announce.
32
27
  */
33
28
 
34
29
  function useSpokenMessage(message, politeness) {
@@ -40,38 +35,39 @@ function useSpokenMessage(message, politeness) {
40
35
  }, [spokenMessage, politeness]);
41
36
  }
42
37
 
43
- function Snackbar(_ref, ref) {
38
+ function UnforwardedSnackbar(_ref, ref) {
44
39
  let {
45
40
  className,
46
41
  children,
47
42
  spokenMessage = children,
48
43
  politeness = 'polite',
49
44
  actions = [],
50
- onRemove = noop,
45
+ onRemove,
51
46
  icon = null,
52
47
  explicitDismiss = false,
53
48
  // onDismiss is a callback executed when the snackbar is dismissed.
54
49
  // It is distinct from onRemove, which _looks_ like a callback but is
55
50
  // actually the function to call to remove the snackbar from the UI.
56
- onDismiss = noop,
51
+ onDismiss,
57
52
  listRef
58
53
  } = _ref;
59
- onDismiss = onDismiss || noop;
60
54
 
61
55
  function dismissMe(event) {
56
+ var _listRef$current;
57
+
62
58
  if (event && event.preventDefault) {
63
59
  event.preventDefault();
64
60
  } // Prevent focus loss by moving it to the list element.
65
61
 
66
62
 
67
- listRef.current.focus();
68
- onDismiss();
69
- onRemove();
63
+ listRef === null || listRef === void 0 ? void 0 : (_listRef$current = listRef.current) === null || _listRef$current === void 0 ? void 0 : _listRef$current.focus();
64
+ onDismiss === null || onDismiss === void 0 ? void 0 : onDismiss();
65
+ onRemove === null || onRemove === void 0 ? void 0 : onRemove();
70
66
  }
71
67
 
72
68
  function onActionClick(event, onClick) {
73
69
  event.stopPropagation();
74
- onRemove();
70
+ onRemove === null || onRemove === void 0 ? void 0 : onRemove();
75
71
 
76
72
  if (onClick) {
77
73
  onClick(event);
@@ -83,8 +79,8 @@ function Snackbar(_ref, ref) {
83
79
  useEffect(() => {
84
80
  const timeoutHandle = setTimeout(() => {
85
81
  if (!explicitDismiss) {
86
- onDismiss();
87
- onRemove();
82
+ onDismiss === null || onDismiss === void 0 ? void 0 : onDismiss();
83
+ onRemove === null || onRemove === void 0 ? void 0 : onRemove();
88
84
  }
89
85
  }, NOTICE_TIMEOUT);
90
86
  return () => clearTimeout(timeoutHandle);
@@ -106,10 +102,10 @@ function Snackbar(_ref, ref) {
106
102
  return createElement("div", {
107
103
  ref: ref,
108
104
  className: classes,
109
- onClick: !explicitDismiss ? dismissMe : noop,
110
- tabIndex: "0",
105
+ onClick: !explicitDismiss ? dismissMe : undefined,
106
+ tabIndex: 0,
111
107
  role: !explicitDismiss ? 'button' : '',
112
- onKeyPress: !explicitDismiss ? dismissMe : noop,
108
+ onKeyPress: !explicitDismiss ? dismissMe : undefined,
113
109
  "aria-label": !explicitDismiss ? __('Dismiss this notice') : ''
114
110
  }, createElement("div", {
115
111
  className: snackbarContentClassnames
@@ -131,12 +127,26 @@ function Snackbar(_ref, ref) {
131
127
  }), explicitDismiss && createElement("span", {
132
128
  role: "button",
133
129
  "aria-label": "Dismiss this notice",
134
- tabIndex: "0",
130
+ tabIndex: 0,
135
131
  className: "components-snackbar__dismiss-button",
136
132
  onClick: dismissMe,
137
133
  onKeyPress: dismissMe
138
134
  }, "\u2715")));
139
135
  }
136
+ /**
137
+ * A Snackbar displays a succinct message that is cleared out after a small delay.
138
+ *
139
+ * It can also offer the user options, like viewing a published post.
140
+ * But these options should also be available elsewhere in the UI.
141
+ *
142
+ * ```jsx
143
+ * const MySnackbarNotice = () => (
144
+ * <Snackbar>Post published successfully.</Snackbar>
145
+ * );
146
+ * ```
147
+ */
148
+
140
149
 
141
- export default forwardRef(Snackbar);
150
+ export const Snackbar = forwardRef(UnforwardedSnackbar);
151
+ export default Snackbar;
142
152
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/components/src/snackbar/index.js"],"names":["classnames","speak","useEffect","forwardRef","renderToString","__","warning","Button","noop","NOTICE_TIMEOUT","useSpokenMessage","message","politeness","spokenMessage","Snackbar","ref","className","children","actions","onRemove","icon","explicitDismiss","onDismiss","listRef","dismissMe","event","preventDefault","current","focus","onActionClick","onClick","stopPropagation","timeoutHandle","setTimeout","clearTimeout","classes","length","snackbarContentClassnames","map","index","label","url"],"mappings":";;AAAA;AACA;AACA;AACA,OAAOA,UAAP,MAAuB,YAAvB;AAEA;AACA;AACA;;AACA,SAASC,KAAT,QAAsB,iBAAtB;AACA,SAASC,SAAT,EAAoBC,UAApB,EAAgCC,cAAhC,QAAsD,oBAAtD;AACA,SAASC,EAAT,QAAmB,iBAAnB;AACA,OAAOC,OAAP,MAAoB,oBAApB;AAEA;AACA;AACA;;AACA,SAASC,MAAT,QAAuB,KAAvB;;AAEA,MAAMC,IAAI,GAAG,MAAM,CAAE,CAArB;;AACA,MAAMC,cAAc,GAAG,KAAvB;AAEA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,SAASC,gBAAT,CAA2BC,OAA3B,EAAoCC,UAApC,EAAiD;AAChD,QAAMC,aAAa,GAClB,OAAOF,OAAP,KAAmB,QAAnB,GAA8BA,OAA9B,GAAwCP,cAAc,CAAEO,OAAF,CADvD;AAGAT,EAAAA,SAAS,CAAE,MAAM;AAChB,QAAKW,aAAL,EAAqB;AACpBZ,MAAAA,KAAK,CAAEY,aAAF,EAAiBD,UAAjB,CAAL;AACA;AACD,GAJQ,EAIN,CAAEC,aAAF,EAAiBD,UAAjB,CAJM,CAAT;AAKA;;AAED,SAASE,QAAT,OAgBCC,GAhBD,EAiBE;AAAA,MAhBD;AACCC,IAAAA,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EAoBGnB,eAAe,IAChB;AACC,IAAA,IAAI,EAAC,QADN;AAEC,kBAAW,qBAFZ;AAGC,IAAA,QAAQ,EAAC,GAHV;AAIC,IAAA,SAAS,EAAC,qCAJX;AAKC,IAAA,OAAO,EAAGG,SALX;AAMC,IAAA,UAAU,EAAGA;AANd,cArBF,CATD,CADD;AA6CA;;AAED,eAAerB,UAAU,CAAEW,QAAF,CAAzB","sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport { speak } from '@wordpress/a11y';\nimport { useEffect, forwardRef, renderToString } from '@wordpress/element';\nimport { __ } from '@wordpress/i18n';\nimport warning from '@wordpress/warning';\n\n/**\n * Internal dependencies\n */\nimport { Button } from '../';\n\nconst noop = () => {};\nconst NOTICE_TIMEOUT = 10000;\n\n/** @typedef {import('@wordpress/element').WPElement} WPElement */\n\n/**\n * Custom hook which announces the message with the given politeness, if a\n * valid message is provided.\n *\n * @param {string|WPElement} [message] Message to announce.\n * @param {'polite'|'assertive'} politeness Politeness to announce.\n */\nfunction useSpokenMessage( message, politeness ) {\n\tconst spokenMessage =\n\t\ttypeof message === 'string' ? message : renderToString( message );\n\n\tuseEffect( () => {\n\t\tif ( spokenMessage ) {\n\t\t\tspeak( spokenMessage, politeness );\n\t\t}\n\t}, [ spokenMessage, politeness ] );\n}\n\nfunction Snackbar(\n\t{\n\t\tclassName,\n\t\tchildren,\n\t\tspokenMessage = children,\n\t\tpoliteness = 'polite',\n\t\tactions = [],\n\t\tonRemove = noop,\n\t\ticon = null,\n\t\texplicitDismiss = false,\n\t\t// onDismiss is a callback executed when the snackbar is dismissed.\n\t\t// It is distinct from onRemove, which _looks_ like a callback but is\n\t\t// actually the function to call to remove the snackbar from the UI.\n\t\tonDismiss = noop,\n\t\tlistRef,\n\t},\n\tref\n) {\n\tonDismiss = onDismiss || noop;\n\n\tfunction dismissMe( event ) {\n\t\tif ( event && event.preventDefault ) {\n\t\t\tevent.preventDefault();\n\t\t}\n\n\t\t// Prevent focus loss by moving it to the list element.\n\t\tlistRef.current.focus();\n\n\t\tonDismiss();\n\t\tonRemove();\n\t}\n\n\tfunction onActionClick( event, onClick ) {\n\t\tevent.stopPropagation();\n\n\t\tonRemove();\n\n\t\tif ( onClick ) {\n\t\t\tonClick( event );\n\t\t}\n\t}\n\n\tuseSpokenMessage( spokenMessage, politeness );\n\n\t// Only set up the timeout dismiss if we're not explicitly dismissing.\n\tuseEffect( () => {\n\t\tconst timeoutHandle = setTimeout( () => {\n\t\t\tif ( ! explicitDismiss ) {\n\t\t\t\tonDismiss();\n\t\t\t\tonRemove();\n\t\t\t}\n\t\t}, NOTICE_TIMEOUT );\n\n\t\treturn () => clearTimeout( timeoutHandle );\n\t}, [ onDismiss, onRemove, explicitDismiss ] );\n\n\tconst classes = classnames( className, 'components-snackbar', {\n\t\t'components-snackbar-explicit-dismiss': !! explicitDismiss,\n\t} );\n\tif ( actions && actions.length > 1 ) {\n\t\t// We need to inform developers that snackbar only accepts 1 action.\n\t\twarning(\n\t\t\t'Snackbar can only have 1 action, use Notice if your message require many messages'\n\t\t);\n\t\t// return first element only while keeping it inside an array\n\t\tactions = [ actions[ 0 ] ];\n\t}\n\n\tconst snackbarContentClassnames = classnames(\n\t\t'components-snackbar__content',\n\t\t{\n\t\t\t'components-snackbar__content-with-icon': !! icon,\n\t\t}\n\t);\n\n\treturn (\n\t\t<div\n\t\t\tref={ ref }\n\t\t\tclassName={ classes }\n\t\t\tonClick={ ! explicitDismiss ? dismissMe : noop }\n\t\t\ttabIndex=\"0\"\n\t\t\trole={ ! explicitDismiss ? 'button' : '' }\n\t\t\tonKeyPress={ ! explicitDismiss ? dismissMe : noop }\n\t\t\taria-label={ ! explicitDismiss ? __( 'Dismiss this notice' ) : '' }\n\t\t>\n\t\t\t<div className={ snackbarContentClassnames }>\n\t\t\t\t{ icon && (\n\t\t\t\t\t<div className=\"components-snackbar__icon\">{ icon }</div>\n\t\t\t\t) }\n\t\t\t\t{ children }\n\t\t\t\t{ actions.map( ( { label, onClick, url }, index ) => {\n\t\t\t\t\treturn (\n\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\tkey={ index }\n\t\t\t\t\t\t\thref={ url }\n\t\t\t\t\t\t\tvariant=\"tertiary\"\n\t\t\t\t\t\t\tonClick={ ( event ) =>\n\t\t\t\t\t\t\t\tonActionClick( event, onClick )\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tclassName=\"components-snackbar__action\"\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ label }\n\t\t\t\t\t\t</Button>\n\t\t\t\t\t);\n\t\t\t\t} ) }\n\t\t\t\t{ explicitDismiss && (\n\t\t\t\t\t<span\n\t\t\t\t\t\trole=\"button\"\n\t\t\t\t\t\taria-label=\"Dismiss this notice\"\n\t\t\t\t\t\ttabIndex=\"0\"\n\t\t\t\t\t\tclassName=\"components-snackbar__dismiss-button\"\n\t\t\t\t\t\tonClick={ dismissMe }\n\t\t\t\t\t\tonKeyPress={ dismissMe }\n\t\t\t\t\t>\n\t\t\t\t\t\t&#x2715;\n\t\t\t\t\t</span>\n\t\t\t\t) }\n\t\t\t</div>\n\t\t</div>\n\t);\n}\n\nexport default forwardRef( Snackbar );\n"]}
1
+ {"version":3,"sources":["@wordpress/components/src/snackbar/index.tsx"],"names":["classnames","speak","useEffect","forwardRef","renderToString","__","warning","Button","NOTICE_TIMEOUT","useSpokenMessage","message","politeness","spokenMessage","UnforwardedSnackbar","ref","className","children","actions","onRemove","icon","explicitDismiss","onDismiss","listRef","dismissMe","event","preventDefault","current","focus","onActionClick","onClick","stopPropagation","timeoutHandle","setTimeout","clearTimeout","classes","length","snackbarContentClassnames","undefined","map","index","label","url","Snackbar"],"mappings":";;AAAA;AACA;AACA;AAEA,OAAOA,UAAP,MAAuB,YAAvB;AAEA;AACA;AACA;;AACA,SAASC,KAAT,QAAsB,iBAAtB;AACA,SAASC,SAAT,EAAoBC,UAApB,EAAgCC,cAAhC,QAAsD,oBAAt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,IAAA,QAAQ,EAAG,CAJZ;AAKC,IAAA,IAAI,EAAG,CAAEjB,eAAF,GAAoB,QAApB,GAA+B,EALvC;AAMC,IAAA,UAAU,EAAG,CAAEA,eAAF,GAAoBG,SAApB,GAAgCc,SAN9C;AAOC,kBAAa,CAAEjB,eAAF,GAAoBf,EAAE,CAAE,qBAAF,CAAtB,GAAkD;AAPhE,KASC;AAAK,IAAA,SAAS,EAAG+B;AAAjB,KACGjB,IAAI,IACL;AAAK,IAAA,SAAS,EAAC;AAAf,KAA6CA,IAA7C,CAFF,EAIGH,QAJH,EAKGC,OAAO,CAACqB,GAAR,CAAa,QAA2BC,KAA3B,KAAsC;AAAA,QAApC;AAAEC,MAAAA,KAAF;AAASX,MAAAA,OAAT;AAAkBY,MAAAA;AAAlB,KAAoC;AACpD,WACC,cAAC,MAAD;AACC,MAAA,GAAG,EAAGF,KADP;AAEC,MAAA,IAAI,EAAGE,GAFR;AAGC,MAAA,OAAO,EAAC,UAHT;AAIC,MAAA,OAAO,EAAKjB,KAAF,IACTI,aAAa,CAAEJ,KAAF,EAASK,OAAT,CALf;AAOC,MAAA,SAAS,EAAC;AAPX,OASGW,KATH,CADD;AAaA,GAdC,CALH,EAoBGpB,eAAe,IAChB;AACC,IAAA,IAAI,EAAC,QADN;AAEC,kBAAW,qBAFZ;AAGC,IAAA,QAAQ,EAAG,CAHZ;AAIC,IAAA,SAAS,EAAC,qCAJX;AAKC,IAAA,OAAO,EAAGG,SALX;AAMC,IAAA,UAAU,EAAGA;AANd,cArBF,CATD,CADD;AA6CA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AACA,OAAO,MAAMmB,QAAQ,GAAGvC,UAAU,CAAEU,mBAAF,CAA3B;AAEP,eAAe6B,QAAf","sourcesContent":["/**\n * External dependencies\n */\nimport type { ForwardedRef, KeyboardEvent, MouseEvent } from 'react';\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport { speak } from '@wordpress/a11y';\nimport { useEffect, forwardRef, renderToString } from '@wordpress/element';\nimport { __ } from '@wordpress/i18n';\nimport warning from '@wordpress/warning';\n\n/**\n * Internal dependencies\n */\nimport Button from '../button';\nimport type { NoticeAction, SnackbarProps } from './types';\nimport type { WordPressComponentProps } from '../ui/context';\n\nconst NOTICE_TIMEOUT = 10000;\n\n/**\n * Custom hook which announces the message with the given politeness, if a\n * valid message is provided.\n *\n * @param message Message to announce.\n * @param politeness Politeness to announce.\n */\nfunction useSpokenMessage(\n\tmessage: SnackbarProps[ 'spokenMessage' ],\n\tpoliteness: NonNullable< SnackbarProps[ 'politeness' ] >\n) {\n\tconst spokenMessage =\n\t\ttypeof message === 'string' ? message : renderToString( message );\n\n\tuseEffect( () => {\n\t\tif ( spokenMessage ) {\n\t\t\tspeak( spokenMessage, politeness );\n\t\t}\n\t}, [ spokenMessage, politeness ] );\n}\n\nfunction UnforwardedSnackbar(\n\t{\n\t\tclassName,\n\t\tchildren,\n\t\tspokenMessage = children,\n\t\tpoliteness = 'polite',\n\t\tactions = [],\n\t\tonRemove,\n\t\ticon = null,\n\t\texplicitDismiss = false,\n\t\t// onDismiss is a callback executed when the snackbar is dismissed.\n\t\t// It is distinct from onRemove, which _looks_ like a callback but is\n\t\t// actually the function to call to remove the snackbar from the UI.\n\t\tonDismiss,\n\t\tlistRef,\n\t}: WordPressComponentProps< SnackbarProps, 'div' >,\n\tref: ForwardedRef< any >\n) {\n\tfunction dismissMe( event: KeyboardEvent | MouseEvent ) {\n\t\tif ( event && event.preventDefault ) {\n\t\t\tevent.preventDefault();\n\t\t}\n\n\t\t// Prevent focus loss by moving it to the list element.\n\t\tlistRef?.current?.focus();\n\n\t\tonDismiss?.();\n\t\tonRemove?.();\n\t}\n\n\tfunction onActionClick(\n\t\tevent: MouseEvent,\n\t\tonClick: NoticeAction[ 'onClick' ]\n\t) {\n\t\tevent.stopPropagation();\n\n\t\tonRemove?.();\n\n\t\tif ( onClick ) {\n\t\t\tonClick( event );\n\t\t}\n\t}\n\n\tuseSpokenMessage( spokenMessage, politeness );\n\n\t// Only set up the timeout dismiss if we're not explicitly dismissing.\n\tuseEffect( () => {\n\t\tconst timeoutHandle = setTimeout( () => {\n\t\t\tif ( ! explicitDismiss ) {\n\t\t\t\tonDismiss?.();\n\t\t\t\tonRemove?.();\n\t\t\t}\n\t\t}, NOTICE_TIMEOUT );\n\n\t\treturn () => clearTimeout( timeoutHandle );\n\t}, [ onDismiss, onRemove, explicitDismiss ] );\n\n\tconst classes = classnames( className, 'components-snackbar', {\n\t\t'components-snackbar-explicit-dismiss': !! explicitDismiss,\n\t} );\n\tif ( actions && actions.length > 1 ) {\n\t\t// We need to inform developers that snackbar only accepts 1 action.\n\t\twarning(\n\t\t\t'Snackbar can only have 1 action, use Notice if your message require many messages'\n\t\t);\n\t\t// return first element only while keeping it inside an array\n\t\tactions = [ actions[ 0 ] ];\n\t}\n\n\tconst snackbarContentClassnames = classnames(\n\t\t'components-snackbar__content',\n\t\t{\n\t\t\t'components-snackbar__content-with-icon': !! icon,\n\t\t}\n\t);\n\n\treturn (\n\t\t<div\n\t\t\tref={ ref }\n\t\t\tclassName={ classes }\n\t\t\tonClick={ ! explicitDismiss ? dismissMe : undefined }\n\t\t\ttabIndex={ 0 }\n\t\t\trole={ ! explicitDismiss ? 'button' : '' }\n\t\t\tonKeyPress={ ! explicitDismiss ? dismissMe : undefined }\n\t\t\taria-label={ ! explicitDismiss ? __( 'Dismiss this notice' ) : '' }\n\t\t>\n\t\t\t<div className={ snackbarContentClassnames }>\n\t\t\t\t{ icon && (\n\t\t\t\t\t<div className=\"components-snackbar__icon\">{ icon }</div>\n\t\t\t\t) }\n\t\t\t\t{ children }\n\t\t\t\t{ actions.map( ( { label, onClick, url }, index ) => {\n\t\t\t\t\treturn (\n\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\tkey={ index }\n\t\t\t\t\t\t\thref={ url }\n\t\t\t\t\t\t\tvariant=\"tertiary\"\n\t\t\t\t\t\t\tonClick={ ( event: MouseEvent ) =>\n\t\t\t\t\t\t\t\tonActionClick( event, onClick )\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tclassName=\"components-snackbar__action\"\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ label }\n\t\t\t\t\t\t</Button>\n\t\t\t\t\t);\n\t\t\t\t} ) }\n\t\t\t\t{ explicitDismiss && (\n\t\t\t\t\t<span\n\t\t\t\t\t\trole=\"button\"\n\t\t\t\t\t\taria-label=\"Dismiss this notice\"\n\t\t\t\t\t\ttabIndex={ 0 }\n\t\t\t\t\t\tclassName=\"components-snackbar__dismiss-button\"\n\t\t\t\t\t\tonClick={ dismissMe }\n\t\t\t\t\t\tonKeyPress={ dismissMe }\n\t\t\t\t\t>\n\t\t\t\t\t\t&#x2715;\n\t\t\t\t\t</span>\n\t\t\t\t) }\n\t\t\t</div>\n\t\t</div>\n\t);\n}\n\n/**\n * A Snackbar displays a succinct message that is cleared out after a small delay.\n *\n * It can also offer the user options, like viewing a published post.\n * But these options should also be available elsewhere in the UI.\n *\n * ```jsx\n * const MySnackbarNotice = () => (\n * <Snackbar>Post published successfully.</Snackbar>\n * );\n * ```\n */\nexport const Snackbar = forwardRef( UnforwardedSnackbar );\n\nexport default Snackbar;\n"]}
@@ -15,11 +15,8 @@ import { useRef } from '@wordpress/element';
15
15
  * Internal dependencies
16
16
  */
17
17
 
18
- import Snackbar from './';
18
+ import Snackbar from '.';
19
19
  import { __unstableMotion as motion, __unstableAnimatePresence as AnimatePresence } from '../animation';
20
-
21
- const noop = () => {};
22
-
23
20
  const SNACKBAR_VARIANTS = {
24
21
  init: {
25
22
  height: 0,
@@ -42,35 +39,31 @@ const SNACKBAR_VARIANTS = {
42
39
  }
43
40
  }
44
41
  };
45
- const SNACKBAR_REDUCE_MOTION_VARIANTS = {
46
- init: false,
47
- open: false,
48
- exit: false
49
- };
50
42
  /**
51
43
  * Renders a list of notices.
52
44
  *
53
- * @param {Object} $0 Props passed to the component.
54
- * @param {Array} $0.notices Array of notices to render.
55
- * @param {Function} $0.onRemove Function called when a notice should be removed / dismissed.
56
- * @param {Object} $0.className Name of the class used by the component.
57
- * @param {Object} $0.children Array of children to be rendered inside the notice list.
58
- *
59
- * @return {Object} The rendered notices list.
45
+ * ```jsx
46
+ * const MySnackbarListNotice = () => (
47
+ * <SnackbarList
48
+ * notices={ notices }
49
+ * onRemove={ removeNotice }
50
+ * />
51
+ * );
52
+ * ```
60
53
  */
61
54
 
62
- function SnackbarList(_ref) {
55
+ export function SnackbarList(_ref) {
63
56
  let {
64
57
  notices,
65
58
  className,
66
59
  children,
67
- onRemove = noop
60
+ onRemove
68
61
  } = _ref;
69
- const listRef = useRef();
62
+ const listRef = useRef(null);
70
63
  const isReducedMotion = useReducedMotion();
71
64
  className = classnames('components-snackbar-list', className);
72
65
 
73
- const removeNotice = notice => () => onRemove(notice.id);
66
+ const removeNotice = notice => () => onRemove === null || onRemove === void 0 ? void 0 : onRemove(notice.id);
74
67
 
75
68
  return createElement("div", {
76
69
  className: className,
@@ -88,7 +81,7 @@ function SnackbarList(_ref) {
88
81
  animate: 'open',
89
82
  exit: 'exit',
90
83
  key: notice.id,
91
- variants: isReducedMotion ? SNACKBAR_REDUCE_MOTION_VARIANTS : SNACKBAR_VARIANTS
84
+ variants: isReducedMotion ? undefined : SNACKBAR_VARIANTS
92
85
  }, createElement("div", {
93
86
  className: "components-snackbar-list__notice-container"
94
87
  }, createElement(Snackbar, _extends({}, restNotice, {
@@ -97,6 +90,5 @@ function SnackbarList(_ref) {
97
90
  }), notice.content)));
98
91
  })));
99
92
  }
100
-
101
93
  export default SnackbarList;
102
94
  //# sourceMappingURL=list.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/components/src/snackbar/list.js"],"names":["classnames","useReducedMotion","useRef","Snackbar","__unstableMotion","motion","__unstableAnimatePresence","AnimatePresence","noop","SNACKBAR_VARIANTS","init","height","opacity","open","transition","stiffness","velocity","exit","duration","SNACKBAR_REDUCE_MOTION_VARIANTS","SnackbarList","notices","className","children","onRemove","listRef","isReducedMotion","removeNotice","notice","id","map","content","restNotice"],"mappings":";;;AAAA;AACA;AACA;AACA,OAAOA,UAAP,MAAuB,YAAvB;AAEA;AACA;AACA;;AACA,SAASC,gBAAT,QAAiC,oBAAjC;AACA,SAASC,MAAT,QAAuB,oBAAvB;AAEA;AACA;AACA;;AACA,OAAOC,QAAP,MAAqB,IAArB;AACA,SACCC,gBAAgB,IAAIC,MADrB,EAECC,yBAAyB,IAAIC,eAF9B,QAGO,cAHP;;AAKA,MAAMC,IAAI,GAAG,MAAM,CAAE,CAArB;;AACA,MAAMC,iBAAiB,GAAG;AACzBC,EAAAA,IAAI,EAAE;AACLC,IAAAA,MAAM,EAAE,CADH;AAELC,IAAAA,OAAO,EAAE;AAFJ,GADmB;AAKzBC,EAAAA,IAAI,EAAE;AACLF,IAAAA,MAAM,EAAE,MADH;AAELC,IAAAA,OAAO,EAAE,CAFJ;AAGLE,IAAAA,UAAU,EAAE;AACXH,MAAAA,MAAM,EAAE;AAAEI,QAAAA,SAAS,EAAE,IAAb;AAAmBC,QAAAA,QAAQ,EAAE,CAAC;AAA9B;AADG;AAHP,GALmB;AAYzBC,EAAAA,IAAI,EAAE;AACLL,IAAAA,OAAO,EAAE,CADJ;AAELE,IAAAA,UAAU,EAAE;AACXI,MAAAA,QAAQ,EAAE;AADC;AAFP;AAZmB,CAA1B;AAoBA,MAAMC,+BAA+B,GAAG;AACvCT,EAAAA,IAAI,EAAE,KADiC;AAEvCG,EAAAA,IAAI,EAAE,KAFiC;AAGvCI,EAAAA,IAAI,EAAE;AAHiC,CAAxC;AAMA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,SAASG,YAAT,OAA2E;AAAA,MAApD;AAAEC,IAAAA,OAAF;AAAWC,IAAAA,SAAX;AAAsBC,IAAAA,QAAtB;AAAgCC,IAAAA,QAAQ,GAAGhB;AAA3C,GAAoD;AAC1E,QAAMiB,OAAO,GAAGvB,MAAM,EAAtB;AACA,QAAMwB,eAAe,GAAGzB,gBAAgB,EAAxC;AACAqB,EAAAA,SAAS,GAAGtB,UAAU,CAAE,0BAAF,EAA8BsB,SAA9B,CAAtB;;AACA,QAAMK,YAAY,GAAKC,MAAF,IAAc,MAAMJ,QAAQ,CAAEI,MAAM,CAACC,EAAT,CAAjD;;AACA,SACC;AAAK,IAAA,SAAS,EAAGP,SAAjB;AAA6B,IAAA,QAAQ,EAAG,CAAC,CAAzC;AAA6C,IAAA,GAAG,EAAGG;AAAnD,KACGF,QADH,EAEC,cAAC,eAAD,QACGF,OAAO,CAACS,GAAR,CAAeF,MAAF,IAAc;AAC5B,UAAM;AAAEG,MAAAA,OAAF;AAAW,SAAGC;AAAd,QAA6BJ,MAAnC;AAEA,WACC,cAAC,MAAD,CAAQ,GAAR;AACC,MAAA,MAAM,EAAG,CAAEF,eADZ,CAC8B;AAD9B;AAEC,MAAA,OAAO,EAAG,MAFX;AAGC,MAAA,OAAO,EAAG,MAHX;AAIC,MAAA,IAAI,EAAG,MAJR;AAKC,MAAA,GAAG,EAAGE,MAAM,CAACC,EALd;AAMC,MAAA,QAAQ,EACPH,eAAe,GACZP,+BADY,GAEZV;AATL,OAYC;AAAK,MAAA,SAAS,EAAC;AAAf,OACC,cAAC,QAAD,eACMuB,UADN;AAEC,MAAA,QAAQ,EAAGL,YAAY,CAAEC,MAAF,CAFxB;AAGC,MAAA,OAAO,EAAGH;AAHX,QAKGG,MAAM,CAACG,OALV,CADD,CAZD,CADD;AAwBA,GA3BC,CADH,CAFD,CADD;AAmCA;;AAED,eAAeX,YAAf","sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport { useReducedMotion } from '@wordpress/compose';\nimport { useRef } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport Snackbar from './';\nimport {\n\t__unstableMotion as motion,\n\t__unstableAnimatePresence as AnimatePresence,\n} from '../animation';\n\nconst noop = () => {};\nconst SNACKBAR_VARIANTS = {\n\tinit: {\n\t\theight: 0,\n\t\topacity: 0,\n\t},\n\topen: {\n\t\theight: 'auto',\n\t\topacity: 1,\n\t\ttransition: {\n\t\t\theight: { stiffness: 1000, velocity: -100 },\n\t\t},\n\t},\n\texit: {\n\t\topacity: 0,\n\t\ttransition: {\n\t\t\tduration: 0.5,\n\t\t},\n\t},\n};\n\nconst SNACKBAR_REDUCE_MOTION_VARIANTS = {\n\tinit: false,\n\topen: false,\n\texit: false,\n};\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 SnackbarList( { notices, className, children, onRemove = noop } ) {\n\tconst listRef = useRef();\n\tconst isReducedMotion = useReducedMotion();\n\tclassName = classnames( 'components-snackbar-list', className );\n\tconst removeNotice = ( notice ) => () => onRemove( notice.id );\n\treturn (\n\t\t<div className={ className } tabIndex={ -1 } ref={ listRef }>\n\t\t\t{ children }\n\t\t\t<AnimatePresence>\n\t\t\t\t{ notices.map( ( notice ) => {\n\t\t\t\t\tconst { content, ...restNotice } = notice;\n\n\t\t\t\t\treturn (\n\t\t\t\t\t\t<motion.div\n\t\t\t\t\t\t\tlayout={ ! isReducedMotion } // See https://www.framer.com/docs/animation/#layout-animations\n\t\t\t\t\t\t\tinitial={ 'init' }\n\t\t\t\t\t\t\tanimate={ 'open' }\n\t\t\t\t\t\t\texit={ 'exit' }\n\t\t\t\t\t\t\tkey={ notice.id }\n\t\t\t\t\t\t\tvariants={\n\t\t\t\t\t\t\t\tisReducedMotion\n\t\t\t\t\t\t\t\t\t? SNACKBAR_REDUCE_MOTION_VARIANTS\n\t\t\t\t\t\t\t\t\t: SNACKBAR_VARIANTS\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t<div className=\"components-snackbar-list__notice-container\">\n\t\t\t\t\t\t\t\t<Snackbar\n\t\t\t\t\t\t\t\t\t{ ...restNotice }\n\t\t\t\t\t\t\t\t\tonRemove={ removeNotice( notice ) }\n\t\t\t\t\t\t\t\t\tlistRef={ listRef }\n\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t{ notice.content }\n\t\t\t\t\t\t\t\t</Snackbar>\n\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t</motion.div>\n\t\t\t\t\t);\n\t\t\t\t} ) }\n\t\t\t</AnimatePresence>\n\t\t</div>\n\t);\n}\n\nexport default SnackbarList;\n"]}
1
+ {"version":3,"sources":["@wordpress/components/src/snackbar/list.tsx"],"names":["classnames","useReducedMotion","useRef","Snackbar","__unstableMotion","motion","__unstableAnimatePresence","AnimatePresence","SNACKBAR_VARIANTS","init","height","opacity","open","transition","stiffness","velocity","exit","duration","SnackbarList","notices","className","children","onRemove","listRef","isReducedMotion","removeNotice","notice","id","map","content","restNotice","undefined"],"mappings":";;;AAAA;AACA;AACA;AACA,OAAOA,UAAP,MAAuB,YAAvB;AAEA;AACA;AACA;;AACA,SAASC,gBAAT,QAAiC,oBAAjC;AACA,SAASC,MAAT,QAAuB,oBAAvB;AAEA;AACA;AACA;;AACA,OAAOC,QAAP,MAAqB,GAArB;AACA,SACCC,gBAAgB,IAAIC,MADrB,EAECC,yBAAyB,IAAIC,eAF9B,QAGO,cAHP;AAOA,MAAMC,iBAAiB,GAAG;AACzBC,EAAAA,IAAI,EAAE;AACLC,IAAAA,MAAM,EAAE,CADH;AAELC,IAAAA,OAAO,EAAE;AAFJ,GADmB;AAKzBC,EAAAA,IAAI,EAAE;AACLF,IAAAA,MAAM,EAAE,MADH;AAELC,IAAAA,OAAO,EAAE,CAFJ;AAGLE,IAAAA,UAAU,EAAE;AACXH,MAAAA,MAAM,EAAE;AAAEI,QAAAA,SAAS,EAAE,IAAb;AAAmBC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SAAS,EAAC;AAAf,OACC,cAAC,QAAD,eACMsB,UADN;AAEC,MAAA,QAAQ,EAAGL,YAAY,CAAEC,MAAF,CAFxB;AAGC,MAAA,OAAO,EAAGH;AAHX,QAKGG,MAAM,CAACG,OALV,CADD,CAVD,CADD;AAsBA,GAzBC,CADH,CAFD,CADD;AAiCA;AAED,eAAeX,YAAf","sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport { useReducedMotion } from '@wordpress/compose';\nimport { useRef } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport Snackbar from '.';\nimport {\n\t__unstableMotion as motion,\n\t__unstableAnimatePresence as AnimatePresence,\n} from '../animation';\nimport type { Notice, SnackbarListProps } from './types';\nimport type { WordPressComponentProps } from '../ui/context';\n\nconst SNACKBAR_VARIANTS = {\n\tinit: {\n\t\theight: 0,\n\t\topacity: 0,\n\t},\n\topen: {\n\t\theight: 'auto',\n\t\topacity: 1,\n\t\ttransition: {\n\t\t\theight: { stiffness: 1000, velocity: -100 },\n\t\t},\n\t},\n\texit: {\n\t\topacity: 0,\n\t\ttransition: {\n\t\t\tduration: 0.5,\n\t\t},\n\t},\n};\n\n/**\n * Renders a list of notices.\n *\n * ```jsx\n * const MySnackbarListNotice = () => (\n * <SnackbarList\n * notices={ notices }\n * onRemove={ removeNotice }\n * />\n * );\n * ```\n */\nexport function SnackbarList( {\n\tnotices,\n\tclassName,\n\tchildren,\n\tonRemove,\n}: WordPressComponentProps< SnackbarListProps, 'div' > ) {\n\tconst listRef = useRef< HTMLDivElement | null >( null );\n\tconst isReducedMotion = useReducedMotion();\n\tclassName = classnames( 'components-snackbar-list', className );\n\tconst removeNotice = ( notice: Notice ) => () => onRemove?.( notice.id );\n\treturn (\n\t\t<div className={ className } tabIndex={ -1 } ref={ listRef }>\n\t\t\t{ children }\n\t\t\t<AnimatePresence>\n\t\t\t\t{ notices.map( ( notice ) => {\n\t\t\t\t\tconst { content, ...restNotice } = notice;\n\n\t\t\t\t\treturn (\n\t\t\t\t\t\t<motion.div\n\t\t\t\t\t\t\tlayout={ ! isReducedMotion } // See https://www.framer.com/docs/animation/#layout-animations\n\t\t\t\t\t\t\tinitial={ 'init' }\n\t\t\t\t\t\t\tanimate={ 'open' }\n\t\t\t\t\t\t\texit={ 'exit' }\n\t\t\t\t\t\t\tkey={ notice.id }\n\t\t\t\t\t\t\tvariants={\n\t\t\t\t\t\t\t\tisReducedMotion ? undefined : SNACKBAR_VARIANTS\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t<div className=\"components-snackbar-list__notice-container\">\n\t\t\t\t\t\t\t\t<Snackbar\n\t\t\t\t\t\t\t\t\t{ ...restNotice }\n\t\t\t\t\t\t\t\t\tonRemove={ removeNotice( notice ) }\n\t\t\t\t\t\t\t\t\tlistRef={ listRef }\n\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t{ notice.content }\n\t\t\t\t\t\t\t\t</Snackbar>\n\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t</motion.div>\n\t\t\t\t\t);\n\t\t\t\t} ) }\n\t\t\t</AnimatePresence>\n\t\t</div>\n\t);\n}\n\nexport default SnackbarList;\n"]}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"names":[],"mappings":"","sourcesContent":[]}
@@ -5,7 +5,6 @@ import { createElement } from "@wordpress/element";
5
5
  * External dependencies
6
6
  */
7
7
  import classnames from 'classnames';
8
- import { find } from 'lodash';
9
8
  /**
10
9
  * WordPress dependencies
11
10
  */
@@ -80,6 +79,7 @@ export function TabPanel(_ref2) {
80
79
  className,
81
80
  children,
82
81
  tabs,
82
+ selectOnMove = true,
83
83
  initialTabName,
84
84
  orientation = 'horizontal',
85
85
  activeClass = 'is-active',
@@ -90,14 +90,18 @@ export function TabPanel(_ref2) {
90
90
  const handleTabSelection = useCallback(tabKey => {
91
91
  setSelected(tabKey);
92
92
  onSelect === null || onSelect === void 0 ? void 0 : onSelect(tabKey);
93
- }, [onSelect]);
93
+ }, [onSelect]); // Simulate a click on the newly focused tab, which causes the component
94
+ // to show the `tab-panel` associated with the clicked tab.
94
95
 
95
- const onNavigate = (_childIndex, child) => {
96
+ const activateTabAutomatically = (_childIndex, child) => {
96
97
  child.click();
97
98
  };
98
99
 
99
- const selectedTab = find(tabs, {
100
- name: selected
100
+ const selectedTab = tabs.find(_ref3 => {
101
+ let {
102
+ name
103
+ } = _ref3;
104
+ return name === selected;
101
105
  });
102
106
  const selectedId = `${instanceId}-${(_selectedTab$name = selectedTab === null || selectedTab === void 0 ? void 0 : selectedTab.name) !== null && _selectedTab$name !== void 0 ? _selectedTab$name : 'none'}`;
103
107
  useEffect(() => {
@@ -110,7 +114,7 @@ export function TabPanel(_ref2) {
110
114
  }, createElement(NavigableMenu, {
111
115
  role: "tablist",
112
116
  orientation: orientation,
113
- onNavigate: onNavigate,
117
+ onNavigate: selectOnMove ? activateTabAutomatically : undefined,
114
118
  className: "components-tab-panel__tabs"
115
119
  }, tabs.map(tab => createElement(TabButton, {
116
120
  className: classnames('components-tab-panel__tabs-item', tab.className, {
@@ -120,8 +124,11 @@ export function TabPanel(_ref2) {
120
124
  "aria-controls": `${instanceId}-${tab.name}-view`,
121
125
  selected: tab.name === selected,
122
126
  key: tab.name,
123
- onClick: () => handleTabSelection(tab.name)
124
- }, tab.title))), selectedTab && createElement("div", {
127
+ onClick: () => handleTabSelection(tab.name),
128
+ label: tab.icon && tab.title,
129
+ icon: tab.icon,
130
+ showTooltip: !!tab.icon
131
+ }, !tab.icon && tab.title))), selectedTab && createElement("div", {
125
132
  key: selectedId,
126
133
  "aria-labelledby": selectedId,
127
134
  role: "tabpanel",
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/components/src/tab-panel/index.tsx"],"names":["classnames","find","useState","useEffect","useCallback","useInstanceId","NavigableMenu","Button","TabButton","tabId","onClick","children","selected","rest","TabPanel","className","tabs","initialTabName","orientation","activeClass","onSelect","instanceId","setSelected","handleTabSelection","tabKey","onNavigate","_childIndex","child","click","selectedTab","name","selectedId","length","map","tab","title"],"mappings":";;;AAAA;AACA;AACA;AACA,OAAOA,UAAP,MAAuB,YAAvB;AACA,SAASC,IAAT,QAAqB,QAArB;AAEA;AACA;AACA;;AACA,SAASC,QAAT,EAAmBC,SAAnB,EAA8BC,WAA9B,QAAiD,oBAAjD;AACA,SAASC,aAAT,QAA8B,oBAA9B;AAEA;AACA;AACA;;AACA,SAASC,aAAT,QAA8B,wBAA9B;AACA,OAAOC,MAAP,MAAmB,WAAnB;;AAIA,MAAMC,SAAS,GAAG;AAAA,MAAE;AACnBC,IAAAA,KADmB;AAEnBC,IAAAA,OAFmB;AAGnBC,IAAAA,QAHmB;AAInBC,IAAAA,QAJmB;AAKnB,OAAGC;AALgB,GAAF;AAAA,SAOjB,cAAC,MAAD;AACC,IAAA,IAAI,EAAC,KADN;AAEC,IAAA,QAAQ,EAAGD,QAAQ,GAAG,IAAH,GAAU,CAAC,CAF/B;AAGC,qBAAgBA,QAHjB;AAIC,IAAA,EAAE,EAAGH,KAJN;AAKC,IAAA,OAAO,EAAGC;AALX,KAMMG,IANN,GAQGF,QARH,CAPiB;AAAA,CAAlB;AAmBA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AACA,OAAO,SAASG,QAAT,QAQqD;AAAA;;AAAA,MARlC;AACzBC,IAAAA,SADyB;AAEzBJ,IAAAA,QAFyB;AAGzBK,IAAAA,IAHyB;AAIzBC,IAAAA,cAJyB;AAKzBC,IAAAA,WAAW,GAAG,YALW;AAMzBC,IAAAA,WAAW,GAAG,WANW;AAOzBC,IAAAA;AAPyB,GAQkC;AAC3D,QAAMC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JX,KAMGT,IAAI,CAACiB,GAAL,CAAYC,GAAF,IACX,cAAC,SAAD;AACC,IAAA,SAAS,EAAGlC,UAAU,CACrB,iCADqB,EAErBkC,GAAG,CAACnB,SAFiB,EAGrB;AACC,OAAEI,WAAF,GAAiBe,GAAG,CAACJ,IAAJ,KAAalB;AAD/B,KAHqB,CADvB;AAQC,IAAA,KAAK,EAAI,GAAGS,UAAY,IAAIa,GAAG,CAACJ,IAAM,EARvC;AASC,qBAAiB,GAAGT,UAAY,IAAIa,GAAG,CAACJ,IAAM,OAT/C;AAUC,IAAA,QAAQ,EAAGI,GAAG,CAACJ,IAAJ,KAAalB,QAVzB;AAWC,IAAA,GAAG,EAAGsB,GAAG,CAACJ,IAXX;AAYC,IAAA,OAAO,EAAG,MAAMP,kBAAkB,CAAEW,GAAG,CAACJ,IAAN;AAZnC,KAcGI,GAAG,CAACC,KAdP,CADC,CANH,CADD,EA0BGN,WAAW,IACZ;AACC,IAAA,GAAG,EAAGE,UADP;AAEC,uBAAkBA,UAFnB;AAGC,IAAA,IAAI,EAAC,UAHN;AAIC,IAAA,EAAE,EAAI,GAAGA,UAAY,OAJtB;AAKC,IAAA,SAAS,EAAC;AALX,KAOGpB,QAAQ,CAAEkB,WAAF,CAPX,CA3BF,CADD;AAwCA;AAED,eAAef,QAAf","sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\nimport { find } from 'lodash';\n\n/**\n * WordPress dependencies\n */\nimport { useState, useEffect, useCallback } from '@wordpress/element';\nimport { useInstanceId } from '@wordpress/compose';\n\n/**\n * Internal dependencies\n */\nimport { NavigableMenu } from '../navigable-container';\nimport Button from '../button';\nimport type { TabButtonProps, TabPanelProps } from './types';\nimport type { WordPressComponentProps } from '../ui/context';\n\nconst TabButton = ( {\n\ttabId,\n\tonClick,\n\tchildren,\n\tselected,\n\t...rest\n}: TabButtonProps ) => (\n\t<Button\n\t\trole=\"tab\"\n\t\ttabIndex={ selected ? null : -1 }\n\t\taria-selected={ selected }\n\t\tid={ tabId }\n\t\tonClick={ onClick }\n\t\t{ ...rest }\n\t>\n\t\t{ children }\n\t</Button>\n);\n\n/**\n * TabPanel is an ARIA-compliant tabpanel.\n *\n * TabPanels organize content across different screens, data sets, and interactions.\n * It has two sections: a list of tabs, and the view to show when tabs are chosen.\n *\n * ```jsx\n * import { TabPanel } from '@wordpress/components';\n *\n * const onSelect = ( tabName ) => {\n * console.log( 'Selecting tab', tabName );\n * };\n *\n * const MyTabPanel = () => (\n * <TabPanel\n * className=\"my-tab-panel\"\n * activeClass=\"active-tab\"\n * onSelect={ onSelect }\n * tabs={ [\n * {\n * name: 'tab1',\n * title: 'Tab 1',\n * className: 'tab-one',\n * },\n * {\n * name: 'tab2',\n * title: 'Tab 2',\n * className: 'tab-two',\n * },\n * ] }\n * >\n * { ( tab ) => <p>{ tab.title }</p> }\n * </TabPanel>\n * );\n * ```\n */\nexport function TabPanel( {\n\tclassName,\n\tchildren,\n\ttabs,\n\tinitialTabName,\n\torientation = 'horizontal',\n\tactiveClass = 'is-active',\n\tonSelect,\n}: WordPressComponentProps< TabPanelProps, 'div', false > ) {\n\tconst instanceId = useInstanceId( TabPanel, 'tab-panel' );\n\tconst [ selected, setSelected ] = useState< string >();\n\n\tconst handleTabSelection = useCallback(\n\t\t( tabKey: string ) => {\n\t\t\tsetSelected( tabKey );\n\t\t\tonSelect?.( tabKey );\n\t\t},\n\t\t[ onSelect ]\n\t);\n\n\tconst onNavigate = ( _childIndex: number, child: HTMLButtonElement ) => {\n\t\tchild.click();\n\t};\n\tconst selectedTab = find( tabs, { name: selected } );\n\tconst selectedId = `${ instanceId }-${ selectedTab?.name ?? 'none' }`;\n\n\tuseEffect( () => {\n\t\tif ( ! selectedTab?.name && tabs.length > 0 ) {\n\t\t\thandleTabSelection( initialTabName || tabs[ 0 ].name );\n\t\t}\n\t}, [ tabs, selectedTab?.name, initialTabName, handleTabSelection ] );\n\n\treturn (\n\t\t<div className={ className }>\n\t\t\t<NavigableMenu\n\t\t\t\trole=\"tablist\"\n\t\t\t\torientation={ orientation }\n\t\t\t\tonNavigate={ onNavigate }\n\t\t\t\tclassName=\"components-tab-panel__tabs\"\n\t\t\t>\n\t\t\t\t{ tabs.map( ( tab ) => (\n\t\t\t\t\t<TabButton\n\t\t\t\t\t\tclassName={ classnames(\n\t\t\t\t\t\t\t'components-tab-panel__tabs-item',\n\t\t\t\t\t\t\ttab.className,\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t[ activeClass ]: tab.name === selected,\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t) }\n\t\t\t\t\t\ttabId={ `${ instanceId }-${ tab.name }` }\n\t\t\t\t\t\taria-controls={ `${ instanceId }-${ tab.name }-view` }\n\t\t\t\t\t\tselected={ tab.name === selected }\n\t\t\t\t\t\tkey={ tab.name }\n\t\t\t\t\t\tonClick={ () => handleTabSelection( tab.name ) }\n\t\t\t\t\t>\n\t\t\t\t\t\t{ tab.title }\n\t\t\t\t\t</TabButton>\n\t\t\t\t) ) }\n\t\t\t</NavigableMenu>\n\t\t\t{ selectedTab && (\n\t\t\t\t<div\n\t\t\t\t\tkey={ selectedId }\n\t\t\t\t\taria-labelledby={ selectedId }\n\t\t\t\t\trole=\"tabpanel\"\n\t\t\t\t\tid={ `${ selectedId }-view` }\n\t\t\t\t\tclassName=\"components-tab-panel__tab-content\"\n\t\t\t\t>\n\t\t\t\t\t{ children( selectedTab ) }\n\t\t\t\t</div>\n\t\t\t) }\n\t\t</div>\n\t);\n}\n\nexport default TabPanel;\n"]}
1
+ {"version":3,"sources":["@wordpress/components/src/tab-panel/index.tsx"],"names":["classnames","useState","useEffect","useCallback","useInstanceId","NavigableMenu","Button","TabButton","tabId","onClick","children","selected","rest","TabPanel","className","tabs","selectOnMove","initialTabName","orientation","activeClass","onSelect","instanceId","setSelected","handleTabSelection","tabKey","activateTabAutomatically","_childIndex","child","click","selectedTab","find","name","selectedId","length","undefined","map","tab","icon","title"],"mappings":";;;AAAA;AACA;AAC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AC,SAAD;AACC,IAAA,SAAS,EAAGpC,UAAU,CACrB,iCADqB,EAErBoC,GAAG,CAACtB,SAFiB,EAGrB;AACC,OAAEK,WAAF,GAAiBiB,GAAG,CAACL,IAAJ,KAAapB;AAD/B,KAHqB,CADvB;AAQC,IAAA,KAAK,EAAI,GAAGU,UAAY,IAAIe,GAAG,CAACL,IAAM,EARvC;AASC,qBAAiB,GAAGV,UAAY,IAAIe,GAAG,CAACL,IAAM,OAT/C;AAUC,IAAA,QAAQ,EAAGK,GAAG,CAACL,IAAJ,KAAapB,QAVzB;AAWC,IAAA,GAAG,EAAGyB,GAAG,CAACL,IAXX;AAYC,IAAA,OAAO,EAAG,MAAMR,kBAAkB,CAAEa,GAAG,CAACL,IAAN,CAZnC;AAaC,IAAA,KAAK,EAAGK,GAAG,CAACC,IAAJ,IAAYD,GAAG,CAACE,KAbzB;AAcC,IAAA,IAAI,EAAGF,GAAG,CAACC,IAdZ;AAeC,IAAA,WAAW,EAAG,CAAC,CAAED,GAAG,CAACC;AAftB,KAiBG,CAAED,GAAG,CAACC,IAAN,IAAcD,GAAG,CAACE,KAjBrB,CADC,CARH,CADD,EA+BGT,WAAW,IACZ;AACC,IAAA,GAAG,EAAGG,UADP;AAEC,uBAAkBA,UAFnB;AAGC,IAAA,IAAI,EAAC,UAHN;AAIC,IAAA,EAAE,EAAI,GAAGA,UAAY,OAJtB;AAKC,IAAA,SAAS,EAAC;AALX,KAOGtB,QAAQ,CAAEmB,WAAF,CAPX,CAhCF,CADD;AA6CA;AAED,eAAehB,QAAf","sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport { useState, useEffect, useCallback } from '@wordpress/element';\nimport { useInstanceId } from '@wordpress/compose';\n\n/**\n * Internal dependencies\n */\nimport { NavigableMenu } from '../navigable-container';\nimport Button from '../button';\nimport type { TabButtonProps, TabPanelProps } from './types';\nimport type { WordPressComponentProps } from '../ui/context';\n\nconst TabButton = ( {\n\ttabId,\n\tonClick,\n\tchildren,\n\tselected,\n\t...rest\n}: TabButtonProps ) => (\n\t<Button\n\t\trole=\"tab\"\n\t\ttabIndex={ selected ? null : -1 }\n\t\taria-selected={ selected }\n\t\tid={ tabId }\n\t\tonClick={ onClick }\n\t\t{ ...rest }\n\t>\n\t\t{ children }\n\t</Button>\n);\n\n/**\n * TabPanel is an ARIA-compliant tabpanel.\n *\n * TabPanels organize content across different screens, data sets, and interactions.\n * It has two sections: a list of tabs, and the view to show when tabs are chosen.\n *\n * ```jsx\n * import { TabPanel } from '@wordpress/components';\n *\n * const onSelect = ( tabName ) => {\n * console.log( 'Selecting tab', tabName );\n * };\n *\n * const MyTabPanel = () => (\n * <TabPanel\n * className=\"my-tab-panel\"\n * activeClass=\"active-tab\"\n * onSelect={ onSelect }\n * tabs={ [\n * {\n * name: 'tab1',\n * title: 'Tab 1',\n * className: 'tab-one',\n * },\n * {\n * name: 'tab2',\n * title: 'Tab 2',\n * className: 'tab-two',\n * },\n * ] }\n * >\n * { ( tab ) => <p>{ tab.title }</p> }\n * </TabPanel>\n * );\n * ```\n */\nexport function TabPanel( {\n\tclassName,\n\tchildren,\n\ttabs,\n\tselectOnMove = true,\n\tinitialTabName,\n\torientation = 'horizontal',\n\tactiveClass = 'is-active',\n\tonSelect,\n}: WordPressComponentProps< TabPanelProps, 'div', false > ) {\n\tconst instanceId = useInstanceId( TabPanel, 'tab-panel' );\n\tconst [ selected, setSelected ] = useState< string >();\n\n\tconst handleTabSelection = useCallback(\n\t\t( tabKey: string ) => {\n\t\t\tsetSelected( tabKey );\n\t\t\tonSelect?.( tabKey );\n\t\t},\n\t\t[ onSelect ]\n\t);\n\n\t// Simulate a click on the newly focused tab, which causes the component\n\t// to show the `tab-panel` associated with the clicked tab.\n\tconst activateTabAutomatically = (\n\t\t_childIndex: number,\n\t\tchild: HTMLButtonElement\n\t) => {\n\t\tchild.click();\n\t};\n\tconst selectedTab = tabs.find( ( { name } ) => name === selected );\n\tconst selectedId = `${ instanceId }-${ selectedTab?.name ?? 'none' }`;\n\n\tuseEffect( () => {\n\t\tif ( ! selectedTab?.name && tabs.length > 0 ) {\n\t\t\thandleTabSelection( initialTabName || tabs[ 0 ].name );\n\t\t}\n\t}, [ tabs, selectedTab?.name, initialTabName, handleTabSelection ] );\n\n\treturn (\n\t\t<div className={ className }>\n\t\t\t<NavigableMenu\n\t\t\t\trole=\"tablist\"\n\t\t\t\torientation={ orientation }\n\t\t\t\tonNavigate={\n\t\t\t\t\tselectOnMove ? activateTabAutomatically : undefined\n\t\t\t\t}\n\t\t\t\tclassName=\"components-tab-panel__tabs\"\n\t\t\t>\n\t\t\t\t{ tabs.map( ( tab ) => (\n\t\t\t\t\t<TabButton\n\t\t\t\t\t\tclassName={ classnames(\n\t\t\t\t\t\t\t'components-tab-panel__tabs-item',\n\t\t\t\t\t\t\ttab.className,\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t[ activeClass ]: tab.name === selected,\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t) }\n\t\t\t\t\t\ttabId={ `${ instanceId }-${ tab.name }` }\n\t\t\t\t\t\taria-controls={ `${ instanceId }-${ tab.name }-view` }\n\t\t\t\t\t\tselected={ tab.name === selected }\n\t\t\t\t\t\tkey={ tab.name }\n\t\t\t\t\t\tonClick={ () => handleTabSelection( tab.name ) }\n\t\t\t\t\t\tlabel={ tab.icon && tab.title }\n\t\t\t\t\t\ticon={ tab.icon }\n\t\t\t\t\t\tshowTooltip={ !! tab.icon }\n\t\t\t\t\t>\n\t\t\t\t\t\t{ ! tab.icon && tab.title }\n\t\t\t\t\t</TabButton>\n\t\t\t\t) ) }\n\t\t\t</NavigableMenu>\n\t\t\t{ selectedTab && (\n\t\t\t\t<div\n\t\t\t\t\tkey={ selectedId }\n\t\t\t\t\taria-labelledby={ selectedId }\n\t\t\t\t\trole=\"tabpanel\"\n\t\t\t\t\tid={ `${ selectedId }-view` }\n\t\t\t\t\tclassName=\"components-tab-panel__tab-content\"\n\t\t\t\t>\n\t\t\t\t\t{ children( selectedTab ) }\n\t\t\t\t</div>\n\t\t\t) }\n\t\t</div>\n\t);\n}\n\nexport default TabPanel;\n"]}
@@ -0,0 +1,105 @@
1
+ /**
2
+ * External dependencies
3
+ */
4
+ import { colord, extend } from 'colord';
5
+ import a11yPlugin from 'colord/plugins/a11y';
6
+ import namesPlugin from 'colord/plugins/names';
7
+ /**
8
+ * WordPress dependencies
9
+ */
10
+
11
+ import warning from '@wordpress/warning';
12
+ /**
13
+ * Internal dependencies
14
+ */
15
+
16
+ import { COLORS } from '../utils';
17
+ extend([namesPlugin, a11yPlugin]);
18
+ export function generateThemeVariables(inputs) {
19
+ validateInputs(inputs);
20
+ const generatedColors = { ...generateAccentDependentColors(inputs.accent),
21
+ ...generateBackgroundDependentColors(inputs.background)
22
+ };
23
+ warnContrastIssues(checkContrasts(inputs, generatedColors));
24
+ return {
25
+ colors: generatedColors
26
+ };
27
+ }
28
+
29
+ function validateInputs(inputs) {
30
+ for (const [key, value] of Object.entries(inputs)) {
31
+ if (typeof value !== 'undefined' && !colord(value).isValid()) {
32
+ typeof process !== "undefined" && process.env && process.env.NODE_ENV !== "production" ? warning(`wp.components.Theme: "${value}" is not a valid color value for the '${key}' prop.`) : void 0;
33
+ }
34
+ }
35
+ }
36
+
37
+ export function checkContrasts(inputs, outputs) {
38
+ const background = inputs.background || COLORS.white;
39
+ const accent = inputs.accent || '#007cba';
40
+ const foreground = outputs.foreground || COLORS.gray[900];
41
+ const gray = outputs.gray || COLORS.gray;
42
+ return {
43
+ accent: colord(background).isReadable(accent) ? undefined : `The background color ("${background}") does not have sufficient contrast against the accent color ("${accent}").`,
44
+ foreground: colord(background).isReadable(foreground) ? undefined : `The background color provided ("${background}") does not have sufficient contrast against the standard foreground colors.`,
45
+ grays: colord(background).contrast(gray[600]) >= 3 && colord(background).contrast(gray[700]) >= 4.5 ? undefined : `The background color provided ("${background}") cannot generate a set of grayscale foreground colors with sufficient contrast. Try adjusting the color to be lighter or darker.`
46
+ };
47
+ }
48
+
49
+ function warnContrastIssues(issues) {
50
+ for (const error of Object.values(issues)) {
51
+ if (error) {
52
+ typeof process !== "undefined" && process.env && process.env.NODE_ENV !== "production" ? warning('wp.components.Theme: ' + error) : void 0;
53
+ }
54
+ }
55
+ }
56
+
57
+ function generateAccentDependentColors(accent) {
58
+ if (!accent) return {};
59
+ return {
60
+ accent,
61
+ accentDarker10: colord(accent).darken(0.1).toHex(),
62
+ accentDarker20: colord(accent).darken(0.2).toHex(),
63
+ accentInverted: getForegroundForColor(accent)
64
+ };
65
+ }
66
+
67
+ function generateBackgroundDependentColors(background) {
68
+ if (!background) return {};
69
+ const foreground = getForegroundForColor(background);
70
+ return {
71
+ background,
72
+ foreground,
73
+ foregroundInverted: getForegroundForColor(foreground),
74
+ gray: generateShades(background, foreground)
75
+ };
76
+ }
77
+
78
+ function getForegroundForColor(color) {
79
+ return colord(color).isDark() ? COLORS.white : COLORS.gray[900];
80
+ }
81
+
82
+ export function generateShades(background, foreground) {
83
+ // How much darkness you need to add to #fff to get the COLORS.gray[n] color
84
+ const SHADES = {
85
+ 100: 0.06,
86
+ 200: 0.121,
87
+ 300: 0.132,
88
+ 400: 0.2,
89
+ 600: 0.42,
90
+ 700: 0.543,
91
+ 800: 0.821
92
+ }; // Darkness of COLORS.gray[ 900 ], relative to #fff
93
+
94
+ const limit = 0.884;
95
+ const direction = colord(background).isDark() ? 'lighten' : 'darken'; // Lightness delta between the background and foreground colors
96
+
97
+ const range = Math.abs(colord(background).toHsl().l - colord(foreground).toHsl().l) / 100;
98
+ const result = {};
99
+ Object.entries(SHADES).forEach(_ref => {
100
+ let [key, value] = _ref;
101
+ result[parseInt(key)] = colord(background)[direction](value / limit * range).toHex();
102
+ });
103
+ return result;
104
+ }
105
+ //# sourceMappingURL=color-algorithms.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["@wordpress/components/src/theme/color-algorithms.ts"],"names":["colord","extend","a11yPlugin","namesPlugin","warning","COLORS","generateThemeVariables","inputs","validateInputs","generatedColors","generateAccentDependentColors","accent","generateBackgroundDependentColors","background","warnContrastIssues","checkContrasts","colors","key","value","Object","entries","isValid","outputs","white","foreground","gray","isReadable","undefined","grays","contrast","issues","error","values","accentDarker10","darken","toHex","accentDarker20","accentInverted","getForegroundForColor","foregroundInverted","generateShades","color","isDark","SHADES","limit","direction","range","Math","abs","toHsl","l","result","forEach","parseInt"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,MAAT,EAAiBC,MAAjB,QAA+B,QAA/B;AACA,OAAOC,UAAP,MAAuB,qBAAvB;AACA,OAAOC,WAAP,MAAwB,sBAAxB;AAEA;AACA;AACA;;AACA,OAAOC,OAAP,MAAoB,oBAApB;AAEA;AACA;AACA;;AAEA,SAASC,MAAT,QAAuB,UAAvB;AAEAJ,MAAM,CAAE,CAAEE,WAAF,EAAeD,UAAf,CAAF,CAAN;AAEA,OAAO,SAASI,sBAAT,CACNC,MADM,EAEc;AACpBC,EAAAA,cAAc,CAAED,MAAF,CAAd;AAEA,QAAME,eAAe,GAAG,EACvB,GAAGC,6BAA6B,CAAEH,MAAM,CAACI,MAAT,CADT;AAEvB,OAAGC,iCAAiC,CAAEL,MAAM,CAACM,UAAT;AAFb,GAAxB;AAKAC,EAAAA,kBAAkB,CAAEC,cAAc,CAAER,MAAF,EAAUE,eAAV,CAAhB,CAAlB;AAEA,SAAO;AAAEO,IAAAA,MAAM,EAAEP;AAAV,GAAP;AACA;;AAED,SAASD,cAAT,CAAyBD,MAAzB,EAAoD;AACnD,OAAM,MAAM,CAAEU,GAAF,EAAOC,KAAP,CAAZ,IAA8BC,MAAM,CAACC,OAAP,CAAgBb,MAAhB,CAA9B,EAAyD;AACxD,QAAK,OAAOW,KAAP,KAAiB,WAAjB,IAAgC,CAAElB,MAAM,CAAEkB,KAAF,CAAN,CAAgBG,OAAhB,EAAvC,EAAmE;AAClE,+FAAAjB,OAAO,CACL,yBAAyBc,KAAO,yCAAyCD,GAAK,S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CAACC,GAAL,CACChD,MAAM,CAAEa,UAAF,CAAN,CAAqBoC,KAArB,GAA6BC,CAA7B,GAAiClD,MAAM,CAAEwB,UAAF,CAAN,CAAqByB,KAArB,GAA6BC,CAD/D,IAEI,GAHL;AAKA,QAAMC,MAAgC,GAAG,EAAzC;AAEAhC,EAAAA,MAAM,CAACC,OAAP,CAAgBuB,MAAhB,EAAyBS,OAAzB,CAAkC,QAAsB;AAAA,QAApB,CAAEnC,GAAF,EAAOC,KAAP,CAAoB;AACvDiC,IAAAA,MAAM,CAAEE,QAAQ,CAAEpC,GAAF,CAAV,CAAN,GAA4BjB,MAAM,CAAEa,UAAF,CAAN,CACzBgC,SADyB,EACV3B,KAAK,GAAG0B,KAAV,GAAoBE,KADR,EAE1BX,KAF0B,EAA5B;AAGA,GAJD;AAMA,SAAOgB,MAAP;AACA","sourcesContent":["/**\n * External dependencies\n */\nimport { colord, extend } from 'colord';\nimport a11yPlugin from 'colord/plugins/a11y';\nimport namesPlugin from 'colord/plugins/names';\n\n/**\n * WordPress dependencies\n */\nimport warning from '@wordpress/warning';\n\n/**\n * Internal dependencies\n */\nimport type { ThemeInputValues, ThemeOutputValues } from './types';\nimport { COLORS } from '../utils';\n\nextend( [ namesPlugin, a11yPlugin ] );\n\nexport function generateThemeVariables(\n\tinputs: ThemeInputValues\n): ThemeOutputValues {\n\tvalidateInputs( inputs );\n\n\tconst generatedColors = {\n\t\t...generateAccentDependentColors( inputs.accent ),\n\t\t...generateBackgroundDependentColors( inputs.background ),\n\t};\n\n\twarnContrastIssues( checkContrasts( inputs, generatedColors ) );\n\n\treturn { colors: generatedColors };\n}\n\nfunction validateInputs( inputs: ThemeInputValues ) {\n\tfor ( const [ key, value ] of Object.entries( inputs ) ) {\n\t\tif ( typeof value !== 'undefined' && ! colord( value ).isValid() ) {\n\t\t\twarning(\n\t\t\t\t`wp.components.Theme: \"${ value }\" is not a valid color value for the '${ key }' prop.`\n\t\t\t);\n\t\t}\n\t}\n}\n\nexport function checkContrasts(\n\tinputs: ThemeInputValues,\n\toutputs: ThemeOutputValues[ 'colors' ]\n) {\n\tconst background = inputs.background || COLORS.white;\n\tconst accent = inputs.accent || '#007cba';\n\tconst foreground = outputs.foreground || COLORS.gray[ 900 ];\n\tconst gray = outputs.gray || COLORS.gray;\n\n\treturn {\n\t\taccent: colord( background ).isReadable( accent )\n\t\t\t? undefined\n\t\t\t: `The background color (\"${ background }\") does not have sufficient contrast against the accent color (\"${ accent }\").`,\n\t\tforeground: colord( background ).isReadable( foreground )\n\t\t\t? undefined\n\t\t\t: `The background color provided (\"${ background }\") does not have sufficient contrast against the standard foreground colors.`,\n\t\tgrays:\n\t\t\tcolord( background ).contrast( gray[ 600 ] ) >= 3 &&\n\t\t\tcolord( background ).contrast( gray[ 700 ] ) >= 4.5\n\t\t\t\t? undefined\n\t\t\t\t: `The background color provided (\"${ background }\") cannot generate a set of grayscale foreground colors with sufficient contrast. Try adjusting the color to be lighter or darker.`,\n\t};\n}\n\nfunction warnContrastIssues( issues: ReturnType< typeof checkContrasts > ) {\n\tfor ( const error of Object.values( issues ) ) {\n\t\tif ( error ) {\n\t\t\twarning( 'wp.components.Theme: ' + error );\n\t\t}\n\t}\n}\n\nfunction generateAccentDependentColors( accent?: string ) {\n\tif ( ! accent ) return {};\n\n\treturn {\n\t\taccent,\n\t\taccentDarker10: colord( accent ).darken( 0.1 ).toHex(),\n\t\taccentDarker20: colord( accent ).darken( 0.2 ).toHex(),\n\t\taccentInverted: getForegroundForColor( accent ),\n\t};\n}\n\nfunction generateBackgroundDependentColors( background?: string ) {\n\tif ( ! background ) return {};\n\n\tconst foreground = getForegroundForColor( background );\n\n\treturn {\n\t\tbackground,\n\t\tforeground,\n\t\tforegroundInverted: getForegroundForColor( foreground ),\n\t\tgray: generateShades( background, foreground ),\n\t};\n}\n\nfunction getForegroundForColor( color: string ) {\n\treturn colord( color ).isDark() ? COLORS.white : COLORS.gray[ 900 ];\n}\n\nexport function generateShades( background: string, foreground: string ) {\n\t// How much darkness you need to add to #fff to get the COLORS.gray[n] color\n\tconst SHADES = {\n\t\t100: 0.06,\n\t\t200: 0.121,\n\t\t300: 0.132,\n\t\t400: 0.2,\n\t\t600: 0.42,\n\t\t700: 0.543,\n\t\t800: 0.821,\n\t};\n\n\t// Darkness of COLORS.gray[ 900 ], relative to #fff\n\tconst limit = 0.884;\n\n\tconst direction = colord( background ).isDark() ? 'lighten' : 'darken';\n\n\t// Lightness delta between the background and foreground colors\n\tconst range =\n\t\tMath.abs(\n\t\t\tcolord( background ).toHsl().l - colord( foreground ).toHsl().l\n\t\t) / 100;\n\n\tconst result: Record< number, string > = {};\n\n\tObject.entries( SHADES ).forEach( ( [ key, value ] ) => {\n\t\tresult[ parseInt( key ) ] = colord( background )\n\t\t\t[ direction ]( ( value / limit ) * range )\n\t\t\t.toHex();\n\t} );\n\n\treturn result as NonNullable< ThemeOutputValues[ 'colors' ][ 'gray' ] >;\n}\n"]}
@@ -1,17 +1,17 @@
1
+ import _extends from "@babel/runtime/helpers/esm/extends";
1
2
  import { createElement } from "@wordpress/element";
2
3
 
3
4
  /**
4
- * External dependencies
5
+ * WordPress dependencies
5
6
  */
6
- import { colord, extend } from 'colord';
7
- import a11yPlugin from 'colord/plugins/a11y';
8
- import namesPlugin from 'colord/plugins/names';
7
+ import { useMemo } from '@wordpress/element';
9
8
  /**
10
9
  * Internal dependencies
11
10
  */
12
11
 
13
- import { Wrapper } from './styles';
14
- extend([namesPlugin, a11yPlugin]);
12
+ import { colorVariables, Wrapper } from './styles';
13
+ import { generateThemeVariables } from './color-algorithms';
14
+ import { useCx } from '../utils';
15
15
  /**
16
16
  * `Theme` allows defining theme variables for components in the `@wordpress/components` package.
17
17
  *
@@ -35,17 +35,21 @@ extend([namesPlugin, a11yPlugin]);
35
35
  * ```
36
36
  */
37
37
 
38
- function Theme(props) {
39
- const {
40
- accent
41
- } = props;
42
-
43
- if (accent && !colord(accent).isValid()) {
44
- // eslint-disable-next-line no-console
45
- console.warn(`wp.components.Theme: "${accent}" is not a valid color value for the 'accent' prop.`);
46
- }
47
-
48
- return createElement(Wrapper, props);
38
+ function Theme(_ref) {
39
+ let {
40
+ accent,
41
+ background,
42
+ className,
43
+ ...props
44
+ } = _ref;
45
+ const cx = useCx();
46
+ const classes = useMemo(() => cx(...colorVariables(generateThemeVariables({
47
+ accent,
48
+ background
49
+ })), className), [accent, background, className, cx]);
50
+ return createElement(Wrapper, _extends({
51
+ className: classes
52
+ }, props));
49
53
  }
50
54
 
51
55
  export default Theme;
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/components/src/theme/index.tsx"],"names":["colord","extend","a11yPlugin","namesPlugin","Wrapper","Theme","props","accent","isValid","console","warn"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,MAAT,EAAiBC,MAAjB,QAA+B,QAA/B;AACA,OAAOC,UAAP,MAAuB,qBAAvB;AACA,OAAOC,WAAP,MAAwB,sBAAxB;AAEA;AACA;AACA;;AAGA,SAASC,OAAT,QAAwB,UAAxB;AAEAH,MAAM,CAAE,CAAEE,WAAF,EAAeD,UAAf,CAAF,CAAN;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,SAASG,KAAT,CAAgBC,KAAhB,EAA4E;AAC3E,QAAM;AAAEC,IAAAA;AAAF,MAAaD,KAAnB;;AACA,MAAKC,MAAM,IAAI,CAAEP,MAAM,CAAEO,MAAF,CAAN,CAAiBC,OAAjB,EAAjB,EAA8C;AAC7C;AACAC,IAAAA,OAAO,CAACC,IAAR,CACE,yBAAyBH,MAAQ,qDADnC;AAGA;;AAED,SAAO,cAAC,OAAD,EAAcD,KAAd,CAAP;AACA;;AAED,eAAeD,KAAf","sourcesContent":["/**\n * External dependencies\n */\nimport { colord, extend } from 'colord';\nimport a11yPlugin from 'colord/plugins/a11y';\nimport namesPlugin from 'colord/plugins/names';\n\n/**\n * Internal dependencies\n */\nimport type { ThemeProps } from './types';\nimport type { WordPressComponentProps } from '../ui/context';\nimport { Wrapper } from './styles';\n\nextend( [ namesPlugin, a11yPlugin ] );\n\n/**\n * `Theme` allows defining theme variables for components in the `@wordpress/components` package.\n *\n * Multiple `Theme` components can be nested in order to override specific theme variables.\n *\n *\n * @example\n * ```jsx\n * import { __experimentalTheme as Theme } from '@wordpress/components';\n *\n * const Example = () => {\n * return (\n * <Theme accent=\"red\">\n * <Button variant=\"primary\">I'm red</Button>\n * <Theme accent=\"blue\">\n * <Button variant=\"primary\">I'm blue</Button>\n * </Theme>\n * </Theme>\n * );\n * };\n * ```\n */\nfunction Theme( props: WordPressComponentProps< ThemeProps, 'div', true > ) {\n\tconst { accent } = props;\n\tif ( accent && ! colord( accent ).isValid() ) {\n\t\t// eslint-disable-next-line no-console\n\t\tconsole.warn(\n\t\t\t`wp.components.Theme: \"${ accent }\" is not a valid color value for the 'accent' prop.`\n\t\t);\n\t}\n\n\treturn <Wrapper { ...props } />;\n}\n\nexport default Theme;\n"]}
1
+ {"version":3,"sources":["@wordpress/components/src/theme/index.tsx"],"names":["useMemo","colorVariables","Wrapper","generateThemeVariables","useCx","Theme","accent","background","className","props","cx","classes"],"mappings":";;;AAAA;AACA;AACA;AACA,SAASA,OAAT,QAAwB,oBAAxB;AAEA;AACA;AACA;;AAGA,SAASC,cAAT,EAAyBC,OAAzB,QAAwC,UAAxC;AACA,SAASC,sBAAT,QAAuC,oBAAvC;AACA,SAASC,KAAT,QAAsB,UAAtB;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,SAASC,KAAT,OAKwD;AAAA,MALxC;AACfC,IAAAA,MADe;AAEfC,IAAAA,UAFe;AAGfC,IAAAA,SAHe;AAIf,OAAGC;AAJY,GAKwC;AACvD,QAAMC,EAAE,GAAGN,KAAK,EAAhB;AACA,QAAMO,OAAO,GAAGX,OAAO,CACtB,MACCU,EAAE,CACD,GAAGT,cAAc,CAChBE,sBAAsB,CAAE;AAAEG,IAAAA,MAAF;AAAUC,IAAAA;AAAV,GAAF,CADN,CADhB,EAIDC,SAJC,CAFmB,EAQtB,CAAEF,MAAF,EAAUC,UAAV,EAAsBC,SAAtB,EAAiCE,EAAjC,CARsB,CAAvB;AAWA,SAAO,cAAC,OAAD;AAAS,IAAA,SAAS,EAAGC;AAArB,KAAoCF,KAApC,EAAP;AACA;;AAED,eAAeJ,KAAf","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useMemo } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport type { ThemeProps } from './types';\nimport type { WordPressComponentProps } from '../ui/context';\nimport { colorVariables, Wrapper } from './styles';\nimport { generateThemeVariables } from './color-algorithms';\nimport { useCx } from '../utils';\n\n/**\n * `Theme` allows defining theme variables for components in the `@wordpress/components` package.\n *\n * Multiple `Theme` components can be nested in order to override specific theme variables.\n *\n *\n * @example\n * ```jsx\n * import { __experimentalTheme as Theme } from '@wordpress/components';\n *\n * const Example = () => {\n * return (\n * <Theme accent=\"red\">\n * <Button variant=\"primary\">I'm red</Button>\n * <Theme accent=\"blue\">\n * <Button variant=\"primary\">I'm blue</Button>\n * </Theme>\n * </Theme>\n * );\n * };\n * ```\n */\nfunction Theme( {\n\taccent,\n\tbackground,\n\tclassName,\n\t...props\n}: WordPressComponentProps< ThemeProps, 'div', true > ) {\n\tconst cx = useCx();\n\tconst classes = useMemo(\n\t\t() =>\n\t\t\tcx(\n\t\t\t\t...colorVariables(\n\t\t\t\t\tgenerateThemeVariables( { accent, background } )\n\t\t\t\t),\n\t\t\t\tclassName\n\t\t\t),\n\t\t[ accent, background, className, cx ]\n\t);\n\n\treturn <Wrapper className={ classes } { ...props } />;\n}\n\nexport default Theme;\n"]}