@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
@@ -5,7 +5,7 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
5
5
  Object.defineProperty(exports, "__esModule", {
6
6
  value: true
7
7
  });
8
- exports.default = void 0;
8
+ exports.default = exports.Snackbar = void 0;
9
9
 
10
10
  var _element = require("@wordpress/element");
11
11
 
@@ -17,7 +17,7 @@ var _i18n = require("@wordpress/i18n");
17
17
 
18
18
  var _warning = _interopRequireDefault(require("@wordpress/warning"));
19
19
 
20
- var _ = require("../");
20
+ var _button = _interopRequireDefault(require("../button"));
21
21
 
22
22
  /**
23
23
  * External dependencies
@@ -30,17 +30,13 @@ var _ = require("../");
30
30
  /**
31
31
  * Internal dependencies
32
32
  */
33
- const noop = () => {};
34
-
35
33
  const NOTICE_TIMEOUT = 10000;
36
- /** @typedef {import('@wordpress/element').WPElement} WPElement */
37
-
38
34
  /**
39
35
  * Custom hook which announces the message with the given politeness, if a
40
36
  * valid message is provided.
41
37
  *
42
- * @param {string|WPElement} [message] Message to announce.
43
- * @param {'polite'|'assertive'} politeness Politeness to announce.
38
+ * @param message Message to announce.
39
+ * @param politeness Politeness to announce.
44
40
  */
45
41
 
46
42
  function useSpokenMessage(message, politeness) {
@@ -52,38 +48,39 @@ function useSpokenMessage(message, politeness) {
52
48
  }, [spokenMessage, politeness]);
53
49
  }
54
50
 
55
- function Snackbar(_ref, ref) {
51
+ function UnforwardedSnackbar(_ref, ref) {
56
52
  let {
57
53
  className,
58
54
  children,
59
55
  spokenMessage = children,
60
56
  politeness = 'polite',
61
57
  actions = [],
62
- onRemove = noop,
58
+ onRemove,
63
59
  icon = null,
64
60
  explicitDismiss = false,
65
61
  // onDismiss is a callback executed when the snackbar is dismissed.
66
62
  // It is distinct from onRemove, which _looks_ like a callback but is
67
63
  // actually the function to call to remove the snackbar from the UI.
68
- onDismiss = noop,
64
+ onDismiss,
69
65
  listRef
70
66
  } = _ref;
71
- onDismiss = onDismiss || noop;
72
67
 
73
68
  function dismissMe(event) {
69
+ var _listRef$current;
70
+
74
71
  if (event && event.preventDefault) {
75
72
  event.preventDefault();
76
73
  } // Prevent focus loss by moving it to the list element.
77
74
 
78
75
 
79
- listRef.current.focus();
80
- onDismiss();
81
- onRemove();
76
+ listRef === null || listRef === void 0 ? void 0 : (_listRef$current = listRef.current) === null || _listRef$current === void 0 ? void 0 : _listRef$current.focus();
77
+ onDismiss === null || onDismiss === void 0 ? void 0 : onDismiss();
78
+ onRemove === null || onRemove === void 0 ? void 0 : onRemove();
82
79
  }
83
80
 
84
81
  function onActionClick(event, onClick) {
85
82
  event.stopPropagation();
86
- onRemove();
83
+ onRemove === null || onRemove === void 0 ? void 0 : onRemove();
87
84
 
88
85
  if (onClick) {
89
86
  onClick(event);
@@ -95,8 +92,8 @@ function Snackbar(_ref, ref) {
95
92
  (0, _element.useEffect)(() => {
96
93
  const timeoutHandle = setTimeout(() => {
97
94
  if (!explicitDismiss) {
98
- onDismiss();
99
- onRemove();
95
+ onDismiss === null || onDismiss === void 0 ? void 0 : onDismiss();
96
+ onRemove === null || onRemove === void 0 ? void 0 : onRemove();
100
97
  }
101
98
  }, NOTICE_TIMEOUT);
102
99
  return () => clearTimeout(timeoutHandle);
@@ -118,10 +115,10 @@ function Snackbar(_ref, ref) {
118
115
  return (0, _element.createElement)("div", {
119
116
  ref: ref,
120
117
  className: classes,
121
- onClick: !explicitDismiss ? dismissMe : noop,
122
- tabIndex: "0",
118
+ onClick: !explicitDismiss ? dismissMe : undefined,
119
+ tabIndex: 0,
123
120
  role: !explicitDismiss ? 'button' : '',
124
- onKeyPress: !explicitDismiss ? dismissMe : noop,
121
+ onKeyPress: !explicitDismiss ? dismissMe : undefined,
125
122
  "aria-label": !explicitDismiss ? (0, _i18n.__)('Dismiss this notice') : ''
126
123
  }, (0, _element.createElement)("div", {
127
124
  className: snackbarContentClassnames
@@ -133,7 +130,7 @@ function Snackbar(_ref, ref) {
133
130
  onClick,
134
131
  url
135
132
  } = _ref2;
136
- return (0, _element.createElement)(_.Button, {
133
+ return (0, _element.createElement)(_button.default, {
137
134
  key: index,
138
135
  href: url,
139
136
  variant: "tertiary",
@@ -143,14 +140,28 @@ function Snackbar(_ref, ref) {
143
140
  }), explicitDismiss && (0, _element.createElement)("span", {
144
141
  role: "button",
145
142
  "aria-label": "Dismiss this notice",
146
- tabIndex: "0",
143
+ tabIndex: 0,
147
144
  className: "components-snackbar__dismiss-button",
148
145
  onClick: dismissMe,
149
146
  onKeyPress: dismissMe
150
147
  }, "\u2715")));
151
148
  }
149
+ /**
150
+ * A Snackbar displays a succinct message that is cleared out after a small delay.
151
+ *
152
+ * It can also offer the user options, like viewing a published post.
153
+ * But these options should also be available elsewhere in the UI.
154
+ *
155
+ * ```jsx
156
+ * const MySnackbarNotice = () => (
157
+ * <Snackbar>Post published successfully.</Snackbar>
158
+ * );
159
+ * ```
160
+ */
152
161
 
153
- var _default = (0, _element.forwardRef)(Snackbar);
154
162
 
163
+ const Snackbar = (0, _element.forwardRef)(UnforwardedSnackbar);
164
+ exports.Snackbar = Snackbar;
165
+ var _default = Snackbar;
155
166
  exports.default = _default;
156
167
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/components/src/snackbar/index.js"],"names":["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":";;;;;;;;;AASA;;AANA;;AAKA;;AAEA;;AACA;;AAKA;;AAhBA;AACA;AACA;;AAGA;AACA;AACA;;AAMA;AACA;AACA;AAGA,MAAMA,IAAI,GAAG,MAAM,CAAE,CAArB;;AACA,MAAMC,cAAc,GAAG,KAAvB;AAEA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,SAASC,gBAAT,CAA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T;AAAkBW,MAAAA;AAAlB,KAAoC;AACpD,WACC,4BAAC,QAAD;AACC,MAAA,GAAG,EAAGF,KADP;AAEC,MAAA,IAAI,EAAGE,GAFR;AAGC,MAAA,OAAO,EAAC,UAHT;AAIC,MAAA,OAAO,EAAKhB,KAAF,IACTI,aAAa,CAAEJ,KAAF,EAASK,OAAT,CALf;AAOC,MAAA,SAAS,EAAC;AAPX,OASGU,KATH,CADD;AAaA,GAdC,CALH,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;;eAEc,yBAAYV,QAAZ,C","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":["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":";;;;;;;;;AAUA;;AANA;;AAKA;;AAEA;;AACA;;AAKA;;AAjBA;AACA;AACA;;AAIA;AACA;AACA;;AAMA;AACA;AACA;AAKA,MAAMA,cAAc,GAAG,KAAvB;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,SAASC,gBAAT,CACCC,OADD,EAECC,UAFD,EAGE;AACD,QAAMC,aAAa,GAClB,OAAOF,OAAP,KAAmB,QAAnB,GAA8BA,OAA9B,GAAwC,6BAAgBA,OAAhB,CADzC;AAGA,0BAAW,MAAM;AAChB,QAAKE,aAAL,EAAqB;AACpB,uBAAOA,aAAP,EAAsBD,UAAtB;AACA;AACD,GAJD,EAIG,CAAEC,aAAF,EAAiBD,UAAjB,CAJH;AAKA;;AAED,SAASE,mBAAT,OAgBCC,GAhBD,EAiBE;AAAA,MAhBD;AACCC,IAAAA,SADD;AAECC,IAAAA,QAFD;AAGCJ,IAAAA,aAAa,GAAGI,QAHjB;AAICL,IAAAA,UAAU,GAAG,QAJd;AAKCM,IAAAA,OAAO,GAAG,EALX;AAMCC,IAAAA,QAND;AAOCC,IAAAA,IAAI,GAAG,IAPR;AAQCC,IAAAA,eAAe,GAAG,KARnB;AASC;AACA;AACA;AACAC,IAAAA,SAZD;AAaCC,IAAAA;AAbD,GAgBC;;AACD,WAASC,SAAT,CAAoBC,KAApB,EAAwD;AAAA;;AACvD,QAAKA,KAAK,IAAIA,KAAK,CAACC,cAApB,EAAqC;AACpCD,MAAAA,KAAK,CAACC,cAAN;AACA,KAHsD,CAKvD;;;AACAH,IAAAA,OAAO,SAAP,IAAAA,OAAO,WAAP,gCAAAA,OAAO,CAAEI,OAAT,sEAAkBC,KAAlB;AAEAN,IAAAA,SAAS,SAAT,IAAAA,SAAS,WAAT,YAAAA,SAAS;AACTH,IAAAA,QAAQ,SAAR,IAAAA,QAAQ,WAAR,YAAAA,QAAQ;A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AA,IAAI,EAAG,CAAEjB,eAAF,GAAoB,QAApB,GAA+B,EALvC;AAMC,IAAA,UAAU,EAAG,CAAEA,eAAF,GAAoBG,SAApB,GAAgCc,SAN9C;AAOC,kBAAa,CAAEjB,eAAF,GAAoB,cAAI,qBAAJ,CAApB,GAAkD;AAPhE,KASC;AAAK,IAAA,SAAS,EAAGgB;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,4BAAC,eAAD;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;;;AACO,MAAMmB,QAAQ,GAAG,yBAAY7B,mBAAZ,CAAjB;;eAEQ6B,Q","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"]}
@@ -5,6 +5,7 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
5
5
  Object.defineProperty(exports, "__esModule", {
6
6
  value: true
7
7
  });
8
+ exports.SnackbarList = SnackbarList;
8
9
  exports.default = void 0;
9
10
 
10
11
  var _element = require("@wordpress/element");
@@ -15,7 +16,7 @@ var _classnames = _interopRequireDefault(require("classnames"));
15
16
 
16
17
  var _compose = require("@wordpress/compose");
17
18
 
18
- var _ = _interopRequireDefault(require("./"));
19
+ var _ = _interopRequireDefault(require("."));
19
20
 
20
21
  var _animation = require("../animation");
21
22
 
@@ -30,8 +31,6 @@ var _animation = require("../animation");
30
31
  /**
31
32
  * Internal dependencies
32
33
  */
33
- const noop = () => {};
34
-
35
34
  const SNACKBAR_VARIANTS = {
36
35
  init: {
37
36
  height: 0,
@@ -54,21 +53,17 @@ const SNACKBAR_VARIANTS = {
54
53
  }
55
54
  }
56
55
  };
57
- const SNACKBAR_REDUCE_MOTION_VARIANTS = {
58
- init: false,
59
- open: false,
60
- exit: false
61
- };
62
56
  /**
63
57
  * Renders a list of notices.
64
58
  *
65
- * @param {Object} $0 Props passed to the component.
66
- * @param {Array} $0.notices Array of notices to render.
67
- * @param {Function} $0.onRemove Function called when a notice should be removed / dismissed.
68
- * @param {Object} $0.className Name of the class used by the component.
69
- * @param {Object} $0.children Array of children to be rendered inside the notice list.
70
- *
71
- * @return {Object} The rendered notices list.
59
+ * ```jsx
60
+ * const MySnackbarListNotice = () => (
61
+ * <SnackbarList
62
+ * notices={ notices }
63
+ * onRemove={ removeNotice }
64
+ * />
65
+ * );
66
+ * ```
72
67
  */
73
68
 
74
69
  function SnackbarList(_ref) {
@@ -76,13 +71,13 @@ function SnackbarList(_ref) {
76
71
  notices,
77
72
  className,
78
73
  children,
79
- onRemove = noop
74
+ onRemove
80
75
  } = _ref;
81
- const listRef = (0, _element.useRef)();
76
+ const listRef = (0, _element.useRef)(null);
82
77
  const isReducedMotion = (0, _compose.useReducedMotion)();
83
78
  className = (0, _classnames.default)('components-snackbar-list', className);
84
79
 
85
- const removeNotice = notice => () => onRemove(notice.id);
80
+ const removeNotice = notice => () => onRemove === null || onRemove === void 0 ? void 0 : onRemove(notice.id);
86
81
 
87
82
  return (0, _element.createElement)("div", {
88
83
  className: className,
@@ -100,7 +95,7 @@ function SnackbarList(_ref) {
100
95
  animate: 'open',
101
96
  exit: 'exit',
102
97
  key: notice.id,
103
- variants: isReducedMotion ? SNACKBAR_REDUCE_MOTION_VARIANTS : SNACKBAR_VARIANTS
98
+ variants: isReducedMotion ? undefined : SNACKBAR_VARIANTS
104
99
  }, (0, _element.createElement)("div", {
105
100
  className: "components-snackbar-list__notice-container"
106
101
  }, (0, _element.createElement)(_.default, (0, _extends2.default)({}, restNotice, {
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/components/src/snackbar/list.js"],"names":["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":";;;;;;;;;AASA;;;;AANA;;AAKA;;AAMA;;AACA;;AAfA;AACA;AACA;;AAGA;AACA;AACA;;AAIA;AACA;AACA;AAOA,MAAMA,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,GAAG,sBAAhB;AACA,QAAMC,eAAe,GAAG,gCAAxB;AACAJ,EAAAA,SAAS,GAAG,yBAAY,0BAAZ,EAAwCA,SAAxC,CAAZ;;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,4BAAC,oCAAD,QACGF,OAAO,CAACS,GAAR,CAAeF,MAAF,IAAc;AAC5B,UAAM;AAAEG,MAAAA,OAAF;AAAW,SAAGC;AAAd,QAA6BJ,MAAnC;AAEA,WACC,4BAAC,2BAAD,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,4BAAC,SAAD,6BACMuB,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;;eAEcX,Y","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":["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":";;;;;;;;;;AASA;;;;AANA;;AAKA;;AAMA;;AACA;;AAfA;AACA;AACA;;AAGA;AACA;AACA;;AAIA;AACA;AACA;AASA,MAAMA,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;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACO,SAASC,YAAT,OAKkD;AAAA,MAL3B;AAC7BC,IAAAA,OAD6B;AAE7BC,IAAAA,SAF6B;AAG7BC,IAAAA,QAH6B;AAI7BC,IAAAA;AAJ6B,GAK2B;AACxD,QAAMC,OAAO,GAAG,qBAAiC,IAAjC,CAAhB;AACA,QAAMC,eAAe,GAAG,gCAAxB;AACAJ,EAAAA,SAAS,GAAG,yBAAY,0BAAZ,EAAwCA,SAAxC,CAAZ;;AACA,QAAMK,YAAY,GAAKC,MAAF,IAAsB,MAAMJ,QAAN,aAAMA,QAAN,uBAAMA,QAAQ,CAAII,MAAM,CAACC,EAAX,CAAzD;;AACA,SACC;AAAK,IAAA,SAAS,EAAGP,SAAjB;AAA6B,IAAA,QAAQ,EAAG,CAAC,CAAzC;AAA6C,IAAA,GAAG,EAAGG;AAAnD,KACGF,QADH,EAEC,4BAAC,oCAAD,QACGF,OAAO,CAACS,GAAR,CAAeF,MAAF,IAAc;AAC5B,UAAM;AAAEG,MAAAA,OAAF;AAAW,SAAGC;AAAd,QAA6BJ,MAAnC;AAEA,WACC,4BAAC,2BAAD,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,GAAGO,SAAH,GAAevB;AAPhC,OAUC;AAAK,MAAA,SAAS,EAAC;AAAf,OACC,4BAAC,SAAD,6BACMsB,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;;eAEcX,Y","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,6 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"names":[],"mappings":"","sourcesContent":[]}
@@ -14,8 +14,6 @@ var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends")
14
14
 
15
15
  var _classnames = _interopRequireDefault(require("classnames"));
16
16
 
17
- var _lodash = require("lodash");
18
-
19
17
  var _compose = require("@wordpress/compose");
20
18
 
21
19
  var _navigableContainer = require("../navigable-container");
@@ -94,6 +92,7 @@ function TabPanel(_ref2) {
94
92
  className,
95
93
  children,
96
94
  tabs,
95
+ selectOnMove = true,
97
96
  initialTabName,
98
97
  orientation = 'horizontal',
99
98
  activeClass = 'is-active',
@@ -104,14 +103,18 @@ function TabPanel(_ref2) {
104
103
  const handleTabSelection = (0, _element.useCallback)(tabKey => {
105
104
  setSelected(tabKey);
106
105
  onSelect === null || onSelect === void 0 ? void 0 : onSelect(tabKey);
107
- }, [onSelect]);
106
+ }, [onSelect]); // Simulate a click on the newly focused tab, which causes the component
107
+ // to show the `tab-panel` associated with the clicked tab.
108
108
 
109
- const onNavigate = (_childIndex, child) => {
109
+ const activateTabAutomatically = (_childIndex, child) => {
110
110
  child.click();
111
111
  };
112
112
 
113
- const selectedTab = (0, _lodash.find)(tabs, {
114
- name: selected
113
+ const selectedTab = tabs.find(_ref3 => {
114
+ let {
115
+ name
116
+ } = _ref3;
117
+ return name === selected;
115
118
  });
116
119
  const selectedId = `${instanceId}-${(_selectedTab$name = selectedTab === null || selectedTab === void 0 ? void 0 : selectedTab.name) !== null && _selectedTab$name !== void 0 ? _selectedTab$name : 'none'}`;
117
120
  (0, _element.useEffect)(() => {
@@ -124,7 +127,7 @@ function TabPanel(_ref2) {
124
127
  }, (0, _element.createElement)(_navigableContainer.NavigableMenu, {
125
128
  role: "tablist",
126
129
  orientation: orientation,
127
- onNavigate: onNavigate,
130
+ onNavigate: selectOnMove ? activateTabAutomatically : undefined,
128
131
  className: "components-tab-panel__tabs"
129
132
  }, tabs.map(tab => (0, _element.createElement)(TabButton, {
130
133
  className: (0, _classnames.default)('components-tab-panel__tabs-item', tab.className, {
@@ -134,8 +137,11 @@ function TabPanel(_ref2) {
134
137
  "aria-controls": `${instanceId}-${tab.name}-view`,
135
138
  selected: tab.name === selected,
136
139
  key: tab.name,
137
- onClick: () => handleTabSelection(tab.name)
138
- }, tab.title))), selectedTab && (0, _element.createElement)("div", {
140
+ onClick: () => handleTabSelection(tab.name),
141
+ label: tab.icon && tab.title,
142
+ icon: tab.icon,
143
+ showTooltip: !!tab.icon
144
+ }, !tab.icon && tab.title))), selectedTab && (0, _element.createElement)("div", {
139
145
  key: selectedId,
140
146
  "aria-labelledby": selectedId,
141
147
  role: "tabpanel",
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/components/src/tab-panel/index.tsx"],"names":["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":";;;;;;;;;;AASA;;;;AANA;;AACA;;AAMA;;AAKA;;AACA;;AAhBA;AACA;AACA;;A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AXX;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;;eAEcf,Q","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":["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":";;;;;;;;;;AAQA;;;;AALA;;AAMA;;AAKA;;AACA;;AAfA;AACA;AACA;;AAGA;AACA;AACA;;AAIA;AACA;AACA;AAMA,MAAMA,SAAS,GAAG;AAAA,MAAE;AACnBC,IAAAA,KADmB;AAEnBC,IAAAA,OAFmB;AAGnBC,IAAAA,QAHmB;AAInBC,IAAAA,QAJmB;AAKnB,OAAGC;AALgB,GAAF;AAAA,SAOjB,4BAAC,eAAD;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;AAC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,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;;eAEchB,Q","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,118 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+
5
+ Object.defineProperty(exports, "__esModule", {
6
+ value: true
7
+ });
8
+ exports.checkContrasts = checkContrasts;
9
+ exports.generateShades = generateShades;
10
+ exports.generateThemeVariables = generateThemeVariables;
11
+
12
+ var _colord = require("colord");
13
+
14
+ var _a11y = _interopRequireDefault(require("colord/plugins/a11y"));
15
+
16
+ var _names = _interopRequireDefault(require("colord/plugins/names"));
17
+
18
+ var _warning = _interopRequireDefault(require("@wordpress/warning"));
19
+
20
+ var _utils = require("../utils");
21
+
22
+ /**
23
+ * External dependencies
24
+ */
25
+
26
+ /**
27
+ * WordPress dependencies
28
+ */
29
+ (0, _colord.extend)([_names.default, _a11y.default]);
30
+
31
+ function generateThemeVariables(inputs) {
32
+ validateInputs(inputs);
33
+ const generatedColors = { ...generateAccentDependentColors(inputs.accent),
34
+ ...generateBackgroundDependentColors(inputs.background)
35
+ };
36
+ warnContrastIssues(checkContrasts(inputs, generatedColors));
37
+ return {
38
+ colors: generatedColors
39
+ };
40
+ }
41
+
42
+ function validateInputs(inputs) {
43
+ for (const [key, value] of Object.entries(inputs)) {
44
+ if (typeof value !== 'undefined' && !(0, _colord.colord)(value).isValid()) {
45
+ typeof process !== "undefined" && process.env && process.env.NODE_ENV !== "production" ? (0, _warning.default)(`wp.components.Theme: "${value}" is not a valid color value for the '${key}' prop.`) : void 0;
46
+ }
47
+ }
48
+ }
49
+
50
+ function checkContrasts(inputs, outputs) {
51
+ const background = inputs.background || _utils.COLORS.white;
52
+ const accent = inputs.accent || '#007cba';
53
+ const foreground = outputs.foreground || _utils.COLORS.gray[900];
54
+ const gray = outputs.gray || _utils.COLORS.gray;
55
+ return {
56
+ accent: (0, _colord.colord)(background).isReadable(accent) ? undefined : `The background color ("${background}") does not have sufficient contrast against the accent color ("${accent}").`,
57
+ foreground: (0, _colord.colord)(background).isReadable(foreground) ? undefined : `The background color provided ("${background}") does not have sufficient contrast against the standard foreground colors.`,
58
+ grays: (0, _colord.colord)(background).contrast(gray[600]) >= 3 && (0, _colord.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.`
59
+ };
60
+ }
61
+
62
+ function warnContrastIssues(issues) {
63
+ for (const error of Object.values(issues)) {
64
+ if (error) {
65
+ typeof process !== "undefined" && process.env && process.env.NODE_ENV !== "production" ? (0, _warning.default)('wp.components.Theme: ' + error) : void 0;
66
+ }
67
+ }
68
+ }
69
+
70
+ function generateAccentDependentColors(accent) {
71
+ if (!accent) return {};
72
+ return {
73
+ accent,
74
+ accentDarker10: (0, _colord.colord)(accent).darken(0.1).toHex(),
75
+ accentDarker20: (0, _colord.colord)(accent).darken(0.2).toHex(),
76
+ accentInverted: getForegroundForColor(accent)
77
+ };
78
+ }
79
+
80
+ function generateBackgroundDependentColors(background) {
81
+ if (!background) return {};
82
+ const foreground = getForegroundForColor(background);
83
+ return {
84
+ background,
85
+ foreground,
86
+ foregroundInverted: getForegroundForColor(foreground),
87
+ gray: generateShades(background, foreground)
88
+ };
89
+ }
90
+
91
+ function getForegroundForColor(color) {
92
+ return (0, _colord.colord)(color).isDark() ? _utils.COLORS.white : _utils.COLORS.gray[900];
93
+ }
94
+
95
+ function generateShades(background, foreground) {
96
+ // How much darkness you need to add to #fff to get the COLORS.gray[n] color
97
+ const SHADES = {
98
+ 100: 0.06,
99
+ 200: 0.121,
100
+ 300: 0.132,
101
+ 400: 0.2,
102
+ 600: 0.42,
103
+ 700: 0.543,
104
+ 800: 0.821
105
+ }; // Darkness of COLORS.gray[ 900 ], relative to #fff
106
+
107
+ const limit = 0.884;
108
+ const direction = (0, _colord.colord)(background).isDark() ? 'lighten' : 'darken'; // Lightness delta between the background and foreground colors
109
+
110
+ const range = Math.abs((0, _colord.colord)(background).toHsl().l - (0, _colord.colord)(foreground).toHsl().l) / 100;
111
+ const result = {};
112
+ Object.entries(SHADES).forEach(_ref => {
113
+ let [key, value] = _ref;
114
+ result[parseInt(key)] = (0, _colord.colord)(background)[direction](value / limit * range).toHex();
115
+ });
116
+ return result;
117
+ }
118
+ //# sourceMappingURL=color-algorithms.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["@wordpress/components/src/theme/color-algorithms.ts"],"names":["namesPlugin","a11yPlugin","generateThemeVariables","inputs","validateInputs","generatedColors","generateAccentDependentColors","accent","generateBackgroundDependentColors","background","warnContrastIssues","checkContrasts","colors","key","value","Object","entries","isValid","outputs","COLORS","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":";;;;;;;;;;;AAGA;;AACA;;AACA;;AAKA;;AAMA;;AAhBA;AACA;AACA;;AAKA;AAC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AAhC,EAAgD;AAC/C,SAAO,oBAAQA,KAAR,EAAgBC,MAAhB,KAA2BpB,cAAOC,KAAlC,GAA0CD,cAAOG,IAAP,CAAa,GAAb,CAAjD;AACA;;AAEM,SAASe,cAAT,CAAyB5B,UAAzB,EAA6CY,UAA7C,EAAkE;AACxE;AACA,QAAMmB,MAAM,GAAG;AACd,SAAK,IADS;AAEd,SAAK,KAFS;AAGd,SAAK,KAHS;AAId,SAAK,GAJS;AAKd,SAAK,IALS;AAMd,SAAK,KANS;AAOd,SAAK;AAPS,GAAf,CAFwE,CAYxE;;AACA,QAAMC,KAAK,GAAG,KAAd;AAEA,QAAMC,SAAS,GAAG,oBAAQjC,UAAR,EAAqB8B,MAArB,KAAgC,SAAhC,GAA4C,QAA9D,CAfwE,CAiBxE;;AACA,QAAMI,KAAK,GACVC,IAAI,CAACC,GAAL,CACC,oBAAQpC,UAAR,EAAqBqC,KAArB,GAA6BC,CAA7B,GAAiC,oBAAQ1B,UAAR,EAAqByB,KAArB,GAA6BC,CAD/D,IAEI,GAHL;AAKA,QAAMC,MAAgC,GAAG,EAAzC;AAEAjC,EAAAA,MAAM,CAACC,OAAP,CAAgBwB,MAAhB,EAAyBS,OAAzB,CAAkC,QAAsB;AAAA,QAApB,CAAEpC,GAAF,EAAOC,KAAP,CAAoB;AACvDkC,IAAAA,MAAM,CAAEE,QAAQ,CAAErC,GAAF,CAAV,CAAN,GAA4B,oBAAQJ,UAAR,EACzBiC,SADyB,EACV5B,KAAK,GAAG2B,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"]}
@@ -9,18 +9,18 @@ exports.default = void 0;
9
9
 
10
10
  var _element = require("@wordpress/element");
11
11
 
12
- var _colord = require("colord");
12
+ var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
13
13
 
14
- var _a11y = _interopRequireDefault(require("colord/plugins/a11y"));
14
+ var _styles = require("./styles");
15
15
 
16
- var _names = _interopRequireDefault(require("colord/plugins/names"));
16
+ var _colorAlgorithms = require("./color-algorithms");
17
17
 
18
- var _styles = require("./styles");
18
+ var _utils = require("../utils");
19
19
 
20
20
  /**
21
- * External dependencies
21
+ * WordPress dependencies
22
22
  */
23
- (0, _colord.extend)([_names.default, _a11y.default]);
23
+
24
24
  /**
25
25
  * `Theme` allows defining theme variables for components in the `@wordpress/components` package.
26
26
  *
@@ -43,18 +43,21 @@ var _styles = require("./styles");
43
43
  * };
44
44
  * ```
45
45
  */
46
-
47
- function Theme(props) {
48
- const {
49
- accent
50
- } = props;
51
-
52
- if (accent && !(0, _colord.colord)(accent).isValid()) {
53
- // eslint-disable-next-line no-console
54
- console.warn(`wp.components.Theme: "${accent}" is not a valid color value for the 'accent' prop.`);
55
- }
56
-
57
- return (0, _element.createElement)(_styles.Wrapper, props);
46
+ function Theme(_ref) {
47
+ let {
48
+ accent,
49
+ background,
50
+ className,
51
+ ...props
52
+ } = _ref;
53
+ const cx = (0, _utils.useCx)();
54
+ const classes = (0, _element.useMemo)(() => cx(...(0, _styles.colorVariables)((0, _colorAlgorithms.generateThemeVariables)({
55
+ accent,
56
+ background
57
+ })), className), [accent, background, className, cx]);
58
+ return (0, _element.createElement)(_styles.Wrapper, (0, _extends2.default)({
59
+ className: classes
60
+ }, props));
58
61
  }
59
62
 
60
63
  var _default = Theme;
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/components/src/theme/index.tsx"],"names":["namesPlugin","a11yPlugin","Theme","props","accent","isValid","console","warn"],"mappings":";;;;;;;;;;;AAGA;;AACA;;AACA;;AAOA;;AAZA;AACA;AACA;AAYA,oBAAQ,CAAEA,cAAF,EAAeC,aAAf,CAAR;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,CAAgBC,KAAhB,EAA4E;AAC3E,QAAM;AAAEC,IAAAA;AAAF,MAAaD,KAAnB;;AACA,MAAKC,MAAM,IAAI,CAAE,oBAAQA,MAAR,EAAiBC,OAAjB,EAAjB,EAA8C;AAC7C;AACAC,IAAAA,OAAO,CAACC,IAAR,CACE,yBAAyBH,MAAQ,qDADnC;AAGA;;AAED,SAAO,4BAAC,eAAD,EAAcD,KAAd,CAAP;AACA;;eAEcD,K","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":["Theme","accent","background","className","props","cx","classes"],"mappings":";;;;;;;;;AAGA;;;;AAOA;;AACA;;AACA;;AAZA;AACA;AACA;;AAYA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAASA,KAAT,OAKwD;AAAA,MALxC;AACfC,IAAAA,MADe;AAEfC,IAAAA,UAFe;AAGfC,IAAAA,SAHe;AAIf,OAAGC;AAJY,GAKwC;AACvD,QAAMC,EAAE,GAAG,mBAAX;AACA,QAAMC,OAAO,GAAG,sBACf,MACCD,EAAE,CACD,GAAG,4BACF,6CAAwB;AAAEJ,IAAAA,MAAF;AAAUC,IAAAA;AAAV,GAAxB,CADE,CADF,EAIDC,SAJC,CAFY,EAQf,CAAEF,MAAF,EAAUC,UAAV,EAAsBC,SAAtB,EAAiCE,EAAjC,CARe,CAAhB;AAWA,SAAO,4BAAC,eAAD;AAAS,IAAA,SAAS,EAAGC;AAArB,KAAoCF,KAApC,EAAP;AACA;;eAEcJ,K","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"]}