@wordpress/components 23.9.0 → 24.0.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 (279) hide show
  1. package/CHANGELOG.md +36 -0
  2. package/CONTRIBUTING.md +65 -1
  3. package/README.md +1 -3
  4. package/build/autocomplete/autocompleter-ui.js +0 -2
  5. package/build/autocomplete/autocompleter-ui.js.map +1 -1
  6. package/build/autocomplete/index.js +2 -0
  7. package/build/autocomplete/index.js.map +1 -1
  8. package/build/button/index.js +2 -0
  9. package/build/button/index.js.map +1 -1
  10. package/build/card/card-media/component.js +2 -1
  11. package/build/card/card-media/component.js.map +1 -1
  12. package/build/combobox-control/index.js +7 -5
  13. package/build/combobox-control/index.js.map +1 -1
  14. package/build/combobox-control/styles.js +3 -3
  15. package/build/combobox-control/styles.js.map +1 -1
  16. package/build/dimension-control/index.js +1 -1
  17. package/build/dimension-control/index.js.map +1 -1
  18. package/build/draggable/index.js +2 -7
  19. package/build/draggable/index.js.map +1 -1
  20. package/build/form-token-field/index.js +5 -3
  21. package/build/form-token-field/index.js.map +1 -1
  22. package/build/form-token-field/styles.js +3 -3
  23. package/build/form-token-field/styles.js.map +1 -1
  24. package/build/mobile/global-styles-context/index.native.js +13 -1
  25. package/build/mobile/global-styles-context/index.native.js.map +1 -1
  26. package/build/mobile/link-picker/link-picker-results.native.js +3 -1
  27. package/build/mobile/link-picker/link-picker-results.native.js.map +1 -1
  28. package/build/modal/index.js +2 -1
  29. package/build/modal/index.js.map +1 -1
  30. package/build/navigable-container/container.js +39 -19
  31. package/build/navigable-container/container.js.map +1 -1
  32. package/build/navigable-container/index.js.map +1 -1
  33. package/build/navigable-container/menu.js +37 -5
  34. package/build/navigable-container/menu.js.map +1 -1
  35. package/build/navigable-container/tabbable.js +45 -4
  36. package/build/navigable-container/tabbable.js.map +1 -1
  37. package/build/navigable-container/types.js +6 -0
  38. package/build/navigable-container/types.js.map +1 -0
  39. package/build/palette-edit/index.js +34 -12
  40. package/build/palette-edit/index.js.map +1 -1
  41. package/build/sandbox/index.native.js +6 -2
  42. package/build/sandbox/index.native.js.map +1 -1
  43. package/build/slot-fill/bubbles-virtually/fill.js +2 -1
  44. package/build/slot-fill/bubbles-virtually/fill.js.map +1 -1
  45. package/build/slot-fill/bubbles-virtually/slot-fill-provider.js +45 -35
  46. package/build/slot-fill/bubbles-virtually/slot-fill-provider.js.map +1 -1
  47. package/build/slot-fill/bubbles-virtually/use-slot.js +11 -26
  48. package/build/slot-fill/bubbles-virtually/use-slot.js.map +1 -1
  49. package/build/slot-fill/fill.js +7 -31
  50. package/build/slot-fill/fill.js.map +1 -1
  51. package/build/slot-fill/index.js.map +1 -1
  52. package/build/slot-fill/provider.js +0 -6
  53. package/build/slot-fill/provider.js.map +1 -1
  54. package/build/slot-fill/slot.js +0 -5
  55. package/build/slot-fill/slot.js.map +1 -1
  56. package/build/tab-panel/index.js.map +1 -1
  57. package/build/theme/color-algorithms.js +1 -1
  58. package/build/theme/color-algorithms.js.map +1 -1
  59. package/build/toolbar/toolbar-button/index.js +1 -2
  60. package/build/toolbar/toolbar-button/index.js.map +1 -1
  61. package/build/toolbar/toolbar-item/index.js +4 -2
  62. package/build/toolbar/toolbar-item/index.js.map +1 -1
  63. package/build/utils/colors-values.js +3 -3
  64. package/build/utils/colors-values.js.map +1 -1
  65. package/build/utils/use-deprecated-props.js +35 -0
  66. package/build/utils/use-deprecated-props.js.map +1 -0
  67. package/build-module/autocomplete/autocompleter-ui.js +1 -3
  68. package/build-module/autocomplete/autocompleter-ui.js.map +1 -1
  69. package/build-module/autocomplete/index.js +3 -3
  70. package/build-module/autocomplete/index.js.map +1 -1
  71. package/build-module/button/index.js +2 -0
  72. package/build-module/button/index.js.map +1 -1
  73. package/build-module/card/card-media/component.js +2 -1
  74. package/build-module/card/card-media/component.js.map +1 -1
  75. package/build-module/combobox-control/index.js +6 -5
  76. package/build-module/combobox-control/index.js.map +1 -1
  77. package/build-module/combobox-control/styles.js +3 -3
  78. package/build-module/combobox-control/styles.js.map +1 -1
  79. package/build-module/dimension-control/index.js +1 -1
  80. package/build-module/dimension-control/index.js.map +1 -1
  81. package/build-module/draggable/index.js +2 -7
  82. package/build-module/draggable/index.js.map +1 -1
  83. package/build-module/form-token-field/index.js +4 -3
  84. package/build-module/form-token-field/index.js.map +1 -1
  85. package/build-module/form-token-field/styles.js +3 -3
  86. package/build-module/form-token-field/styles.js.map +1 -1
  87. package/build-module/mobile/global-styles-context/index.native.js +13 -1
  88. package/build-module/mobile/global-styles-context/index.native.js.map +1 -1
  89. package/build-module/mobile/link-picker/link-picker-results.native.js +3 -1
  90. package/build-module/mobile/link-picker/link-picker-results.native.js.map +1 -1
  91. package/build-module/modal/index.js +2 -1
  92. package/build-module/modal/index.js.map +1 -1
  93. package/build-module/navigable-container/container.js +43 -19
  94. package/build-module/navigable-container/container.js.map +1 -1
  95. package/build-module/navigable-container/index.js +0 -2
  96. package/build-module/navigable-container/index.js.map +1 -1
  97. package/build-module/navigable-container/menu.js +36 -4
  98. package/build-module/navigable-container/menu.js.map +1 -1
  99. package/build-module/navigable-container/tabbable.js +44 -3
  100. package/build-module/navigable-container/tabbable.js.map +1 -1
  101. package/build-module/navigable-container/types.js +2 -0
  102. package/build-module/navigable-container/types.js.map +1 -0
  103. package/build-module/palette-edit/index.js +34 -13
  104. package/build-module/palette-edit/index.js.map +1 -1
  105. package/build-module/sandbox/index.native.js +6 -2
  106. package/build-module/sandbox/index.native.js.map +1 -1
  107. package/build-module/slot-fill/bubbles-virtually/fill.js +2 -1
  108. package/build-module/slot-fill/bubbles-virtually/fill.js.map +1 -1
  109. package/build-module/slot-fill/bubbles-virtually/slot-fill-provider.js +46 -36
  110. package/build-module/slot-fill/bubbles-virtually/slot-fill-provider.js.map +1 -1
  111. package/build-module/slot-fill/bubbles-virtually/use-slot.js +12 -27
  112. package/build-module/slot-fill/bubbles-virtually/use-slot.js.map +1 -1
  113. package/build-module/slot-fill/fill.js +7 -31
  114. package/build-module/slot-fill/fill.js.map +1 -1
  115. package/build-module/slot-fill/index.js +1 -2
  116. package/build-module/slot-fill/index.js.map +1 -1
  117. package/build-module/slot-fill/provider.js +0 -6
  118. package/build-module/slot-fill/provider.js.map +1 -1
  119. package/build-module/slot-fill/slot.js +0 -5
  120. package/build-module/slot-fill/slot.js.map +1 -1
  121. package/build-module/tab-panel/index.js.map +1 -1
  122. package/build-module/theme/color-algorithms.js +1 -1
  123. package/build-module/theme/color-algorithms.js.map +1 -1
  124. package/build-module/toolbar/toolbar-button/index.js +1 -2
  125. package/build-module/toolbar/toolbar-button/index.js.map +1 -1
  126. package/build-module/toolbar/toolbar-item/index.js +5 -2
  127. package/build-module/toolbar/toolbar-item/index.js.map +1 -1
  128. package/build-module/utils/colors-values.js +3 -3
  129. package/build-module/utils/colors-values.js.map +1 -1
  130. package/build-module/utils/use-deprecated-props.js +25 -0
  131. package/build-module/utils/use-deprecated-props.js.map +1 -0
  132. package/build-style/style-rtl.css +58 -55
  133. package/build-style/style.css +58 -55
  134. package/build-types/autocomplete/autocompleter-ui.d.ts.map +1 -1
  135. package/build-types/autocomplete/index.d.ts.map +1 -1
  136. package/build-types/autocomplete/types.d.ts +2 -18
  137. package/build-types/autocomplete/types.d.ts.map +1 -1
  138. package/build-types/button/deprecated.d.ts +6 -0
  139. package/build-types/button/deprecated.d.ts.map +1 -1
  140. package/build-types/button/index.d.ts.map +1 -1
  141. package/build-types/button/types.d.ts +7 -0
  142. package/build-types/button/types.d.ts.map +1 -1
  143. package/build-types/card/card-media/component.d.ts +2 -1
  144. package/build-types/card/card-media/component.d.ts.map +1 -1
  145. package/build-types/card/stories/index.d.ts +21 -1
  146. package/build-types/card/stories/index.d.ts.map +1 -1
  147. package/build-types/combobox-control/index.d.ts +1 -1
  148. package/build-types/combobox-control/index.d.ts.map +1 -1
  149. package/build-types/combobox-control/stories/index.d.ts.map +1 -1
  150. package/build-types/combobox-control/styles.d.ts +1 -1
  151. package/build-types/combobox-control/types.d.ts +8 -1
  152. package/build-types/combobox-control/types.d.ts.map +1 -1
  153. package/build-types/dimension-control/index.d.ts +1 -1
  154. package/build-types/draggable/index.d.ts.map +1 -1
  155. package/build-types/form-token-field/index.d.ts.map +1 -1
  156. package/build-types/form-token-field/styles.d.ts +1 -1
  157. package/build-types/form-token-field/types.d.ts +8 -1
  158. package/build-types/form-token-field/types.d.ts.map +1 -1
  159. package/build-types/modal/index.d.ts.map +1 -1
  160. package/build-types/navigable-container/container.d.ts +20 -1
  161. package/build-types/navigable-container/container.d.ts.map +1 -1
  162. package/build-types/navigable-container/index.d.ts +5 -2
  163. package/build-types/navigable-container/index.d.ts.map +1 -1
  164. package/build-types/navigable-container/menu.d.ts +45 -11
  165. package/build-types/navigable-container/menu.d.ts.map +1 -1
  166. package/build-types/navigable-container/stories/navigable-menu.d.ts +12 -0
  167. package/build-types/navigable-container/stories/navigable-menu.d.ts.map +1 -0
  168. package/build-types/navigable-container/stories/tabbable-container.d.ts +12 -0
  169. package/build-types/navigable-container/stories/tabbable-container.d.ts.map +1 -0
  170. package/build-types/navigable-container/tabbable.d.ts +52 -9
  171. package/build-types/navigable-container/tabbable.d.ts.map +1 -1
  172. package/build-types/navigable-container/test/navigable-menu.d.ts +2 -0
  173. package/build-types/navigable-container/test/navigable-menu.d.ts.map +1 -0
  174. package/build-types/navigable-container/test/tababble-container.d.ts +2 -0
  175. package/build-types/navigable-container/test/tababble-container.d.ts.map +1 -0
  176. package/build-types/navigable-container/types.d.ts +61 -0
  177. package/build-types/navigable-container/types.d.ts.map +1 -0
  178. package/build-types/navigator/navigator-back-button/component.d.ts +1 -0
  179. package/build-types/navigator/navigator-back-button/component.d.ts.map +1 -1
  180. package/build-types/navigator/navigator-back-button/hook.d.ts +1 -0
  181. package/build-types/navigator/navigator-back-button/hook.d.ts.map +1 -1
  182. package/build-types/navigator/navigator-button/component.d.ts +1 -0
  183. package/build-types/navigator/navigator-button/component.d.ts.map +1 -1
  184. package/build-types/navigator/navigator-button/hook.d.ts +1 -0
  185. package/build-types/navigator/navigator-button/hook.d.ts.map +1 -1
  186. package/build-types/navigator/navigator-to-parent-button/component.d.ts +1 -0
  187. package/build-types/navigator/navigator-to-parent-button/component.d.ts.map +1 -1
  188. package/build-types/palette-edit/index.d.ts +1 -1
  189. package/build-types/palette-edit/index.d.ts.map +1 -1
  190. package/build-types/palette-edit/stories/index.d.ts.map +1 -1
  191. package/build-types/palette-edit/types.d.ts +8 -0
  192. package/build-types/palette-edit/types.d.ts.map +1 -1
  193. package/build-types/slot-fill/bubbles-virtually/fill.d.ts.map +1 -1
  194. package/build-types/slot-fill/bubbles-virtually/slot-fill-provider.d.ts.map +1 -1
  195. package/build-types/slot-fill/bubbles-virtually/use-slot.d.ts.map +1 -1
  196. package/build-types/slot-fill/fill.d.ts +4 -2
  197. package/build-types/slot-fill/fill.d.ts.map +1 -1
  198. package/build-types/slot-fill/index.d.ts +1 -2
  199. package/build-types/slot-fill/index.d.ts.map +1 -1
  200. package/build-types/slot-fill/provider.d.ts +0 -2
  201. package/build-types/slot-fill/provider.d.ts.map +1 -1
  202. package/build-types/slot-fill/slot.d.ts.map +1 -1
  203. package/build-types/toolbar/stories/index.d.ts.map +1 -1
  204. package/build-types/toolbar/toolbar-button/index.d.ts +6 -0
  205. package/build-types/toolbar/toolbar-button/index.d.ts.map +1 -1
  206. package/build-types/toolbar/toolbar-item/index.d.ts +6 -4
  207. package/build-types/toolbar/toolbar-item/index.d.ts.map +1 -1
  208. package/build-types/tree-grid/types.d.ts +7 -0
  209. package/build-types/tree-grid/types.d.ts.map +1 -1
  210. package/build-types/utils/use-deprecated-props.d.ts +9 -0
  211. package/build-types/utils/use-deprecated-props.d.ts.map +1 -0
  212. package/package.json +19 -19
  213. package/src/autocomplete/README.md +78 -52
  214. package/src/autocomplete/autocompleter-ui.tsx +0 -2
  215. package/src/autocomplete/index.tsx +1 -2
  216. package/src/autocomplete/types.ts +3 -19
  217. package/src/button/index.tsx +2 -0
  218. package/src/button/style.scss +13 -6
  219. package/src/button/types.ts +7 -0
  220. package/src/card/card-media/README.md +1 -1
  221. package/src/card/card-media/component.tsx +2 -1
  222. package/src/card/stories/index.tsx +47 -26
  223. package/src/checkbox-control/style.scss +1 -4
  224. package/src/combobox-control/index.tsx +24 -18
  225. package/src/combobox-control/stories/index.tsx +0 -1
  226. package/src/combobox-control/styles.ts +4 -4
  227. package/src/combobox-control/types.ts +8 -1
  228. package/src/custom-gradient-picker/style.scss +2 -2
  229. package/src/dimension-control/index.tsx +1 -1
  230. package/src/draggable/index.tsx +1 -9
  231. package/src/form-toggle/style.scss +1 -5
  232. package/src/form-token-field/index.tsx +7 -3
  233. package/src/form-token-field/styles.ts +4 -4
  234. package/src/form-token-field/types.ts +8 -1
  235. package/src/mobile/global-styles-context/index.native.js +12 -1
  236. package/src/mobile/link-picker/link-picker-results.native.js +3 -0
  237. package/src/modal/index.tsx +6 -1
  238. package/src/modal/style.scss +1 -1
  239. package/src/navigable-container/README.md +24 -13
  240. package/src/navigable-container/{container.js → container.tsx} +57 -27
  241. package/src/navigable-container/{index.js → index.tsx} +0 -1
  242. package/src/navigable-container/menu.tsx +100 -0
  243. package/src/navigable-container/stories/{navigable-menu.js → navigable-menu.tsx} +15 -10
  244. package/src/navigable-container/stories/{tabbable-container.js → tabbable-container.tsx} +15 -6
  245. package/src/navigable-container/tabbable.tsx +92 -0
  246. package/src/navigable-container/test/{navigable-menu.js → navigable-menu.tsx} +3 -1
  247. package/src/navigable-container/test/{tababble-container.js → tababble-container.tsx} +53 -24
  248. package/src/navigable-container/types.ts +76 -0
  249. package/src/palette-edit/index.tsx +45 -7
  250. package/src/palette-edit/stories/index.tsx +4 -0
  251. package/src/palette-edit/types.ts +11 -0
  252. package/src/sandbox/index.native.js +4 -0
  253. package/src/slot-fill/bubbles-virtually/fill.js +2 -1
  254. package/src/slot-fill/bubbles-virtually/slot-fill-provider.js +46 -60
  255. package/src/slot-fill/bubbles-virtually/use-slot.js +14 -41
  256. package/src/slot-fill/fill.js +4 -26
  257. package/src/slot-fill/index.js +1 -3
  258. package/src/slot-fill/provider.js +0 -6
  259. package/src/slot-fill/slot.js +0 -5
  260. package/src/style.scss +6 -0
  261. package/src/tab-panel/index.tsx +1 -1
  262. package/src/theme/color-algorithms.ts +1 -1
  263. package/src/theme/stories/index.tsx +1 -1
  264. package/src/theme/test/color-algorithms.ts +2 -2
  265. package/src/toggle-group-control/test/__snapshots__/index.tsx.snap +4 -4
  266. package/src/toolbar/stories/index.tsx +26 -24
  267. package/src/toolbar/toolbar-button/index.tsx +10 -13
  268. package/src/toolbar/toolbar-item/{index.js → index.tsx} +12 -3
  269. package/src/tree-grid/README.md +18 -0
  270. package/src/tree-grid/types.ts +7 -0
  271. package/src/utils/colors-values.js +3 -3
  272. package/src/utils/theme-variables.scss +4 -4
  273. package/src/utils/use-deprecated-props.ts +29 -0
  274. package/tsconfig.json +1 -0
  275. package/tsconfig.tsbuildinfo +1 -1
  276. package/src/CONTRIBUTING.md +0 -78
  277. package/src/README.md +0 -20
  278. package/src/navigable-container/menu.js +0 -62
  279. package/src/navigable-container/tabbable.js +0 -46
@@ -1,78 +0,0 @@
1
- # Contributing components
2
-
3
- You can contribute by adding, modifying, or deprecating components, as well as helping with design, development, and documentation.
4
-
5
- ## Does it belong in the component library?
6
-
7
- A component library should include components that are generic and flexible enough to work across a variety of products. It should include what’s shared across many products and omit what’s not.
8
-
9
- To determine if a component should be added, ask yourself:
10
-
11
- - Could this component be used by other products/plugins?
12
- - Does the new component overlap (in functionality or visual design) with any existing components?
13
- - How much effort will be required to make and maintain?
14
- - Is there a clear purpose for the component?
15
-
16
- Here’s a flowchart that can help determine if a new component is necessary:
17
-
18
- [![New component flowchart](https://wordpress.org/gutenberg/files/2019/07/New_component_flowchart.png)](https://coggle.it/diagram/WtUSrld3uAYZHsn-/t/new-ui-component/992b38cbe685d897b4aec6d0dd93cc4b47c06e0d4484eeb0d7d9a47fb2c48d94)
19
-
20
- ## First steps
21
-
22
- If you have a component you'd like added or changed, start by opening a GitHub issue. Include a detailed description in which you:
23
-
24
- - Explain the rationale
25
- - Detail the intended behavior
26
- - Clarify whether it’s a variation of an existing component, or a new asset
27
- - Include mockups of any fidelity (optional)
28
- - Include any inspirations from other products (optional)
29
-
30
- This issue will be used to discuss the proposed changes and track progress. Reviewers start by discussing the proposal to determine if it's appropriate for WordPress Components, or if there's overlap with an existing component.
31
-
32
- It’s encouraged to surface works-in-progress. If you’re not able to complete all of the parts yourself, someone in the community may be able to pick up where you left off.
33
-
34
- ## Next steps
35
-
36
- Once the team has discussed and approved the change, it's time to start implementing it.
37
-
38
- 1. **Provide a rationale**: Explain how your component will add value to the system and the greater product ecosystem. Be sure to include any user experience and interaction descriptions.
39
- 2. **Draft documentation**: New components need development, design, and accessibility guidelines. Additionally, if your change adds additional behavior or expands a component’s features, those changes will need to be fully documented as well. Read through existing component documentation for examples. Start with a rough draft, and reviewers will help polish documentation.
40
- 3. **Provide working code**: The component or enhancement must be built in React. See the [developer contribution guidelines](https://github.com/WordPress/gutenberg/blob/HEAD/docs/contributors/code/README.md).
41
- 4. **Create a design spec**: Create sizing and styling annotations for all aspects of the component. This spec should provide a developer with everything they need to create the design in code. [Figma automatically does this for you](https://help.figma.com/article/32-developer-handoff).
42
- 5. **Create a Figma component**: Any new components or changes to existing components will be mirrored in the [WordPress Components Figma library](https://www.figma.com/file/ZtN5xslEVYgzU7Dd5CxgGZwq/WordPress-Components?node-id=735%3A0), so we’ll need to update the Figma library and publish the changes. Please follow the [guidelines](https://www.figma.com/file/ZtN5xslEVYgzU7Dd5CxgGZwq/WordPress-Components?node-id=746%3A38) for contributing to the Figma libraries.
43
-
44
- Remember, it’s unlikely that all parts will be done by one person. Contribute where you can, and others will help.
45
-
46
- ## Component refinement
47
-
48
- Before a component is published it will need to be fine-tuned:
49
-
50
- 1. **Expand** the features of the component to a minimum. Agree on what features should be included.
51
- 2. **Reduce** scope and leave off features lacking consensus.
52
- 3. **Quality assurance**: each contribution must adhere to system standards.
53
-
54
- ### Quality assurance
55
-
56
- To ensure quality, each component should be tested. The testing process should be done during the development of the component and before the component is published.
57
-
58
- - **Accessibility**: Has the design and implementation accounted for accessibility? Please use the [WordPress accessibility guidelines](https://make.wordpress.org/accessibility/handbook/best-practices/). You must use the "Needs Accessibility Feedback" label and get a review from the accessibility team. It's best to request a review early (at the documentation stage) in order to ensure the component is designed inclusively from the outset.
59
- - **Visual quality**: Does the component apply visual style — color, typography, icons, space, borders, and more — using appropriate variables, and does it follow [visual guidelines](https://make.wordpress.org/design/handbook/design-guide/)? You must use the "Needs Design Feedback" label and get a review from the design team.
60
- - **Documentation**: Ensure that the component has proper documentation for development, design, and accessibility.
61
- - **Sufficient states & variations**: Does it cover all the necessary variations (primary, secondary, dense, etc.) and states (default, hover, active, disabled, loading, etc.), within the intended scope?
62
- - **Functionality**: Do all behaviors function as expected?
63
- - **Responsiveness**: Does it incorporate responsive behaviors as needed? Is the component designed from a mobile-first perspective? Do all touch interactions work as expected?
64
- - **Content resilience**: Is each dynamic word or image element resilient to too much, too little, and no content at all, respectively? How long can labels be, and what happens when you run out of space?
65
- - **Composability**: Does it fit well when placed next to or layered with other components to form a larger composition?
66
- - **Browser support**: Has the component visual quality and accuracy been checked across Safari, Chrome, Firefox, IE, etc? Please adhere to our [browser support requirements](https://github.com/WordPress/gutenberg/blob/HEAD/packages/browserslist-config/index.js).
67
-
68
- ## Deprecation
69
-
70
- A component or prop may need deprecation if it's renamed or removed.
71
-
72
- At no point does the deprecated component/prop become unavailable. Instead, the commitment to support it stops. The following steps are needed to deprecate a component:
73
-
74
- 1. Communicate intent via regular channels.
75
- 1. Describe reasoning for deprecation.
76
- 2. Decide on a timeline.
77
- 2. Ensure backwards compatibility to keep it available.
78
- 3. Clearly mark the component as deprecated in documentation and other channels.
package/src/README.md DELETED
@@ -1,20 +0,0 @@
1
- # Components
2
-
3
- This directory includes a library of generic React components to be used for creating common UI elements shared between screens and features of the WordPress dashboard.
4
-
5
- ## Usage
6
-
7
- Within Gutenberg, these components can be accessed by importing from the `components` root directory:
8
-
9
- ```jsx
10
- /**
11
- * WordPress dependencies
12
- */
13
- import { Button } from '@wordpress/components';
14
-
15
- const MyButton = () => {
16
- return <Button>Click Me!</Button>;
17
- };
18
- ```
19
-
20
- Many components also include styles which will need to be output in order to appear correctly. Within WordPress, you can [add the `wp-components` stylesheet as a dependency of your plugin's stylesheet](https://developer.wordpress.org/reference/functions/wp_enqueue_style/#parameters). In other projects, you can link to the `build-style/style.css` file directly.
@@ -1,62 +0,0 @@
1
- // @ts-nocheck
2
-
3
- /**
4
- * WordPress dependencies
5
- */
6
- import { forwardRef } from '@wordpress/element';
7
-
8
- /**
9
- * Internal dependencies
10
- */
11
- import NavigableContainer from './container';
12
-
13
- export function NavigableMenu(
14
- { role = 'menu', orientation = 'vertical', ...rest },
15
- ref
16
- ) {
17
- const eventToOffset = ( evt ) => {
18
- const { code } = evt;
19
-
20
- let next = [ 'ArrowDown' ];
21
- let previous = [ 'ArrowUp' ];
22
-
23
- if ( orientation === 'horizontal' ) {
24
- next = [ 'ArrowRight' ];
25
- previous = [ 'ArrowLeft' ];
26
- }
27
-
28
- if ( orientation === 'both' ) {
29
- next = [ 'ArrowRight', 'ArrowDown' ];
30
- previous = [ 'ArrowLeft', 'ArrowUp' ];
31
- }
32
-
33
- if ( next.includes( code ) ) {
34
- return 1;
35
- } else if ( previous.includes( code ) ) {
36
- return -1;
37
- } else if (
38
- [ 'ArrowDown', 'ArrowUp', 'ArrowLeft', 'ArrowRight' ].includes(
39
- code
40
- )
41
- ) {
42
- // Key press should be handled, e.g. have event propagation and
43
- // default behavior handled by NavigableContainer but not result
44
- // in an offset.
45
- return 0;
46
- }
47
- };
48
-
49
- return (
50
- <NavigableContainer
51
- ref={ ref }
52
- stopNavigationEvents
53
- onlyBrowserTabstops={ false }
54
- role={ role }
55
- aria-orientation={ role === 'presentation' ? null : orientation }
56
- eventToOffset={ eventToOffset }
57
- { ...rest }
58
- />
59
- );
60
- }
61
-
62
- export default forwardRef( NavigableMenu );
@@ -1,46 +0,0 @@
1
- // @ts-nocheck
2
- /**
3
- * WordPress dependencies
4
- */
5
- import { forwardRef } from '@wordpress/element';
6
-
7
- /**
8
- * Internal dependencies
9
- */
10
- import NavigableContainer from './container';
11
-
12
- export function TabbableContainer( { eventToOffset, ...props }, ref ) {
13
- const innerEventToOffset = ( evt ) => {
14
- const { code, shiftKey } = evt;
15
- if ( 'Tab' === code ) {
16
- return shiftKey ? -1 : 1;
17
- }
18
-
19
- // Allow custom handling of keys besides Tab.
20
- //
21
- // By default, TabbableContainer will move focus forward on Tab and
22
- // backward on Shift+Tab. The handler below will be used for all other
23
- // events. The semantics for `eventToOffset`'s return
24
- // values are the following:
25
- //
26
- // - +1: move focus forward
27
- // - -1: move focus backward
28
- // - 0: don't move focus, but acknowledge event and thus stop it
29
- // - undefined: do nothing, let the event propagate.
30
- if ( eventToOffset ) {
31
- return eventToOffset( evt );
32
- }
33
- };
34
-
35
- return (
36
- <NavigableContainer
37
- ref={ ref }
38
- stopNavigationEvents
39
- onlyBrowserTabstops
40
- eventToOffset={ innerEventToOffset }
41
- { ...props }
42
- />
43
- );
44
- }
45
-
46
- export default forwardRef( TabbableContainer );