@wordpress/components 23.1.0 → 23.2.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 (280) hide show
  1. package/CHANGELOG.md +19 -0
  2. package/LICENSE.md +1 -1
  3. package/build/color-picker/component.js +1 -0
  4. package/build/color-picker/component.js.map +1 -1
  5. package/build/color-picker/styles.js +8 -10
  6. package/build/color-picker/styles.js.map +1 -1
  7. package/build/combobox-control/index.js +5 -1
  8. package/build/combobox-control/index.js.map +1 -1
  9. package/build/focal-point-picker/utils.js +1 -1
  10. package/build/focal-point-picker/utils.js.map +1 -1
  11. package/build/index.js +7 -17
  12. package/build/index.js.map +1 -1
  13. package/build/index.native.js +8 -18
  14. package/build/index.native.js.map +1 -1
  15. package/build/item-group/item/component.js +27 -3
  16. package/build/item-group/item/component.js.map +1 -1
  17. package/build/item-group/item-group/component.js +26 -3
  18. package/build/item-group/item-group/component.js.map +1 -1
  19. package/build/item-group/styles.js +14 -14
  20. package/build/item-group/styles.js.map +1 -1
  21. package/build/panel/row.js +5 -3
  22. package/build/panel/row.js.map +1 -1
  23. package/build/query-controls/index.js +1 -0
  24. package/build/query-controls/index.js.map +1 -1
  25. package/build/resizable-box/index.js +5 -4
  26. package/build/resizable-box/index.js.map +1 -1
  27. package/build/responsive-wrapper/index.js +18 -1
  28. package/build/responsive-wrapper/index.js.map +1 -1
  29. package/build/responsive-wrapper/types.js +6 -0
  30. package/build/responsive-wrapper/types.js.map +1 -0
  31. package/build/sandbox/index.js +35 -24
  32. package/build/sandbox/index.js.map +1 -1
  33. package/build/sandbox/types.js +6 -0
  34. package/build/sandbox/types.js.map +1 -0
  35. package/build/tab-panel/index.js +10 -5
  36. package/build/tab-panel/index.js.map +1 -1
  37. package/build/toolbar/index.js +42 -60
  38. package/build/toolbar/index.js.map +1 -1
  39. package/build/toolbar/toolbar/index.js +74 -0
  40. package/build/toolbar/toolbar/index.js.map +1 -0
  41. package/build/toolbar/{toolbar-container.js → toolbar/toolbar-container.js} +0 -0
  42. package/build/toolbar/toolbar/toolbar-container.js.map +1 -0
  43. package/build/toolbar/{toolbar-container.native.js → toolbar/toolbar-container.native.js} +0 -0
  44. package/build/toolbar/toolbar/toolbar-container.native.js.map +1 -0
  45. package/build/{toolbar-button → toolbar/toolbar-button}/index.js +1 -1
  46. package/build/toolbar/toolbar-button/index.js.map +1 -0
  47. package/build/{toolbar-button → toolbar/toolbar-button}/toolbar-button-container.js +0 -0
  48. package/build/toolbar/toolbar-button/toolbar-button-container.js.map +1 -0
  49. package/build/{toolbar-button → toolbar/toolbar-button}/toolbar-button-container.native.js +0 -0
  50. package/build/toolbar/toolbar-button/toolbar-button-container.native.js.map +1 -0
  51. package/build/{toolbar-context → toolbar/toolbar-context}/index.js +0 -0
  52. package/build/toolbar/toolbar-context/index.js.map +1 -0
  53. package/build/{toolbar-dropdown-menu → toolbar/toolbar-dropdown-menu}/index.js +1 -1
  54. package/build/toolbar/toolbar-dropdown-menu/index.js.map +1 -0
  55. package/build/{toolbar-group → toolbar/toolbar-group}/index.js +0 -0
  56. package/build/toolbar/toolbar-group/index.js.map +1 -0
  57. package/build/{toolbar-group → toolbar/toolbar-group}/toolbar-group-collapsed.js +1 -1
  58. package/build/toolbar/toolbar-group/toolbar-group-collapsed.js.map +1 -0
  59. package/build/{toolbar-group → toolbar/toolbar-group}/toolbar-group-collapsed.native.js +1 -1
  60. package/build/toolbar/toolbar-group/toolbar-group-collapsed.native.js.map +1 -0
  61. package/build/{toolbar-group → toolbar/toolbar-group}/toolbar-group-container.js +0 -0
  62. package/build/toolbar/toolbar-group/toolbar-group-container.js.map +1 -0
  63. package/build/{toolbar-group → toolbar/toolbar-group}/toolbar-group-container.native.js +0 -0
  64. package/build/toolbar/toolbar-group/toolbar-group-container.native.js.map +1 -0
  65. package/build/{toolbar-item → toolbar/toolbar-item}/index.js +0 -0
  66. package/build/toolbar/toolbar-item/index.js.map +1 -0
  67. package/build/{toolbar-item → toolbar/toolbar-item}/index.native.js +0 -0
  68. package/build/toolbar/toolbar-item/index.native.js.map +1 -0
  69. package/build/tree-grid/index.js +3 -3
  70. package/build/tree-grid/index.js.map +1 -1
  71. package/build-module/color-picker/component.js +1 -0
  72. package/build-module/color-picker/component.js.map +1 -1
  73. package/build-module/color-picker/styles.js +8 -9
  74. package/build-module/color-picker/styles.js.map +1 -1
  75. package/build-module/combobox-control/index.js +5 -1
  76. package/build-module/combobox-control/index.js.map +1 -1
  77. package/build-module/focal-point-picker/utils.js +1 -1
  78. package/build-module/focal-point-picker/utils.js.map +1 -1
  79. package/build-module/index.js +1 -6
  80. package/build-module/index.js.map +1 -1
  81. package/build-module/index.native.js +1 -6
  82. package/build-module/index.native.js.map +1 -1
  83. package/build-module/item-group/item/component.js +26 -2
  84. package/build-module/item-group/item/component.js.map +1 -1
  85. package/build-module/item-group/item-group/component.js +25 -2
  86. package/build-module/item-group/item-group/component.js.map +1 -1
  87. package/build-module/item-group/styles.js +14 -14
  88. package/build-module/item-group/styles.js.map +1 -1
  89. package/build-module/panel/row.js +5 -3
  90. package/build-module/panel/row.js.map +1 -1
  91. package/build-module/query-controls/index.js +1 -0
  92. package/build-module/query-controls/index.js.map +1 -1
  93. package/build-module/resizable-box/index.js +3 -2
  94. package/build-module/resizable-box/index.js.map +1 -1
  95. package/build-module/responsive-wrapper/index.js +20 -1
  96. package/build-module/responsive-wrapper/index.js.map +1 -1
  97. package/build-module/responsive-wrapper/types.js +2 -0
  98. package/build-module/responsive-wrapper/types.js.map +1 -0
  99. package/build-module/sandbox/index.js +37 -23
  100. package/build-module/sandbox/index.js.map +1 -1
  101. package/build-module/sandbox/types.js +2 -0
  102. package/build-module/sandbox/types.js.map +1 -0
  103. package/build-module/tab-panel/index.js +10 -5
  104. package/build-module/tab-panel/index.js.map +1 -1
  105. package/build-module/toolbar/index.js +6 -58
  106. package/build-module/toolbar/index.js.map +1 -1
  107. package/build-module/toolbar/toolbar/index.js +59 -0
  108. package/build-module/toolbar/toolbar/index.js.map +1 -0
  109. package/build-module/toolbar/{toolbar-container.js → toolbar/toolbar-container.js} +0 -0
  110. package/{build → build-module/toolbar}/toolbar/toolbar-container.js.map +1 -1
  111. package/build-module/toolbar/{toolbar-container.native.js → toolbar/toolbar-container.native.js} +0 -0
  112. package/build-module/toolbar/toolbar/toolbar-container.native.js.map +1 -0
  113. package/build-module/{toolbar-button → toolbar/toolbar-button}/index.js +1 -1
  114. package/build-module/toolbar/toolbar-button/index.js.map +1 -0
  115. package/build-module/{toolbar-button → toolbar/toolbar-button}/toolbar-button-container.js +0 -0
  116. package/build-module/toolbar/toolbar-button/toolbar-button-container.js.map +1 -0
  117. package/build-module/{toolbar-button → toolbar/toolbar-button}/toolbar-button-container.native.js +0 -0
  118. package/build-module/toolbar/toolbar-button/toolbar-button-container.native.js.map +1 -0
  119. package/build-module/{toolbar-context → toolbar/toolbar-context}/index.js +0 -0
  120. package/build-module/toolbar/toolbar-context/index.js.map +1 -0
  121. package/build-module/{toolbar-dropdown-menu → toolbar/toolbar-dropdown-menu}/index.js +1 -1
  122. package/build-module/toolbar/toolbar-dropdown-menu/index.js.map +1 -0
  123. package/build-module/{toolbar-group → toolbar/toolbar-group}/index.js +0 -0
  124. package/build-module/toolbar/toolbar-group/index.js.map +1 -0
  125. package/build-module/{toolbar-group → toolbar/toolbar-group}/toolbar-group-collapsed.js +1 -1
  126. package/build-module/toolbar/toolbar-group/toolbar-group-collapsed.js.map +1 -0
  127. package/build-module/{toolbar-group → toolbar/toolbar-group}/toolbar-group-collapsed.native.js +1 -1
  128. package/build-module/toolbar/toolbar-group/toolbar-group-collapsed.native.js.map +1 -0
  129. package/build-module/{toolbar-group → toolbar/toolbar-group}/toolbar-group-container.js +0 -0
  130. package/build-module/toolbar/toolbar-group/toolbar-group-container.js.map +1 -0
  131. package/build-module/{toolbar-group → toolbar/toolbar-group}/toolbar-group-container.native.js +0 -0
  132. package/build-module/toolbar/toolbar-group/toolbar-group-container.native.js.map +1 -0
  133. package/build-module/{toolbar-item → toolbar/toolbar-item}/index.js +0 -0
  134. package/build-module/toolbar/toolbar-item/index.js.map +1 -0
  135. package/build-module/{toolbar-item → toolbar/toolbar-item}/index.native.js +0 -0
  136. package/build-module/toolbar/toolbar-item/index.native.js.map +1 -0
  137. package/build-module/tree-grid/index.js +3 -3
  138. package/build-module/tree-grid/index.js.map +1 -1
  139. package/build-style/style-rtl.css +1 -1
  140. package/build-style/style.css +1 -1
  141. package/build-types/color-picker/component.d.ts.map +1 -1
  142. package/build-types/color-picker/styles.d.ts.map +1 -1
  143. package/build-types/dashicon/types.d.ts +0 -4
  144. package/build-types/dashicon/types.d.ts.map +1 -1
  145. package/build-types/focal-point-picker/utils.d.ts.map +1 -1
  146. package/build-types/item-group/item/component.d.ts +24 -2
  147. package/build-types/item-group/item/component.d.ts.map +1 -1
  148. package/build-types/item-group/item-group/component.d.ts +23 -2
  149. package/build-types/item-group/item-group/component.d.ts.map +1 -1
  150. package/build-types/item-group/stories/index.d.ts +15 -0
  151. package/build-types/item-group/stories/index.d.ts.map +1 -0
  152. package/build-types/item-group/styles.d.ts.map +1 -1
  153. package/build-types/radio-context/index.d.ts +6 -0
  154. package/build-types/radio-context/index.d.ts.map +1 -0
  155. package/build-types/resizable-box/index.d.ts +6 -7
  156. package/build-types/resizable-box/index.d.ts.map +1 -1
  157. package/build-types/resizable-box/stories/index.d.ts +61 -0
  158. package/build-types/resizable-box/stories/index.d.ts.map +1 -0
  159. package/build-types/responsive-wrapper/index.d.ts +24 -0
  160. package/build-types/responsive-wrapper/index.d.ts.map +1 -0
  161. package/build-types/responsive-wrapper/stories/index.d.ts +12 -0
  162. package/build-types/responsive-wrapper/stories/index.d.ts.map +1 -0
  163. package/build-types/responsive-wrapper/types.d.ts +22 -0
  164. package/build-types/responsive-wrapper/types.d.ts.map +1 -0
  165. package/build-types/sandbox/index.d.ts +19 -0
  166. package/build-types/sandbox/index.d.ts.map +1 -0
  167. package/build-types/sandbox/stories/index.d.ts +12 -0
  168. package/build-types/sandbox/stories/index.d.ts.map +1 -0
  169. package/build-types/sandbox/test/index.d.ts +2 -0
  170. package/build-types/sandbox/test/index.d.ts.map +1 -0
  171. package/build-types/sandbox/types.d.ts +36 -0
  172. package/build-types/sandbox/types.d.ts.map +1 -0
  173. package/build-types/tab-panel/index.d.ts.map +1 -1
  174. package/build-types/tab-panel/stories/index.d.ts +1 -0
  175. package/build-types/tab-panel/stories/index.d.ts.map +1 -1
  176. package/build-types/tab-panel/types.d.ts +10 -4
  177. package/build-types/tab-panel/types.d.ts.map +1 -1
  178. package/package.json +17 -17
  179. package/src/color-picker/component.tsx +1 -0
  180. package/src/color-picker/stories/index.js +20 -60
  181. package/src/color-picker/styles.ts +0 -5
  182. package/src/combobox-control/index.js +9 -1
  183. package/src/dashicon/types.ts +0 -6
  184. package/src/focal-point-picker/stories/index.tsx +1 -1
  185. package/src/focal-point-picker/utils.ts +4 -1
  186. package/src/guide/stories/index.js +14 -41
  187. package/src/index.js +8 -6
  188. package/src/index.native.js +8 -6
  189. package/src/item-group/item/component.tsx +26 -2
  190. package/src/item-group/item-group/component.tsx +25 -2
  191. package/src/item-group/stories/index.tsx +103 -0
  192. package/src/item-group/styles.ts +1 -0
  193. package/src/item-group/test/__snapshots__/index.js.snap +11 -10
  194. package/src/notice/stories/index.js +30 -58
  195. package/src/panel/row.js +3 -3
  196. package/src/panel/stories/index.js +62 -80
  197. package/src/placeholder/style.scss +1 -1
  198. package/src/query-controls/index.js +1 -0
  199. package/src/resizable-box/README.md +2 -2
  200. package/src/resizable-box/index.tsx +7 -6
  201. package/src/resizable-box/stories/index.tsx +92 -0
  202. package/src/responsive-wrapper/README.md +29 -0
  203. package/src/responsive-wrapper/{index.js → index.tsx} +23 -2
  204. package/src/responsive-wrapper/stories/index.tsx +38 -0
  205. package/src/responsive-wrapper/types.ts +20 -0
  206. package/src/sandbox/README.md +45 -2
  207. package/src/sandbox/{index.js → index.tsx} +47 -24
  208. package/src/sandbox/stories/index.tsx +32 -0
  209. package/src/sandbox/test/{index.js → index.tsx} +9 -4
  210. package/src/sandbox/types.ts +34 -0
  211. package/src/slot-fill/stories/index.js +12 -17
  212. package/src/style.scss +3 -3
  213. package/src/tab-panel/README.md +1 -0
  214. package/src/tab-panel/index.tsx +19 -5
  215. package/src/tab-panel/stories/index.tsx +20 -0
  216. package/src/tab-panel/test/index.tsx +89 -0
  217. package/src/tab-panel/types.ts +10 -4
  218. package/src/toolbar/index.js +6 -52
  219. package/src/toolbar/stories/index.js +2 -9
  220. package/src/{toolbar-button/stories/index.js → toolbar/stories/toolbar-button.js} +1 -2
  221. package/src/{toolbar-group/stories/index.js → toolbar/stories/toolbar-group.js} +1 -1
  222. package/src/toolbar/test/index.js +1 -2
  223. package/src/{toolbar-group/test/index.js → toolbar/test/toolbar-group.js} +1 -1
  224. package/src/toolbar/{README.md → toolbar/README.md} +0 -0
  225. package/src/toolbar/toolbar/index.js +52 -0
  226. package/src/toolbar/{style.native.scss → toolbar/style.native.scss} +0 -0
  227. package/src/toolbar/{style.scss → toolbar/style.scss} +0 -0
  228. package/src/toolbar/{toolbar-container.js → toolbar/toolbar-container.js} +0 -0
  229. package/src/toolbar/{toolbar-container.native.js → toolbar/toolbar-container.native.js} +0 -0
  230. package/src/{toolbar-button → toolbar/toolbar-button}/README.md +0 -0
  231. package/src/{toolbar-button → toolbar/toolbar-button}/index.js +1 -1
  232. package/src/{toolbar-button → toolbar/toolbar-button}/style.scss +0 -0
  233. package/src/{toolbar-button → toolbar/toolbar-button}/toolbar-button-container.js +0 -0
  234. package/src/{toolbar-button → toolbar/toolbar-button}/toolbar-button-container.native.js +0 -0
  235. package/src/{toolbar-context → toolbar/toolbar-context}/index.js +0 -0
  236. package/src/{toolbar-dropdown-menu → toolbar/toolbar-dropdown-menu}/README.md +0 -0
  237. package/src/{toolbar-dropdown-menu → toolbar/toolbar-dropdown-menu}/index.js +1 -1
  238. package/src/{toolbar-group → toolbar/toolbar-group}/README.md +0 -0
  239. package/src/{toolbar-group → toolbar/toolbar-group}/index.js +0 -0
  240. package/src/{toolbar-group → toolbar/toolbar-group}/style.native.scss +0 -0
  241. package/src/{toolbar-group → toolbar/toolbar-group}/style.scss +0 -0
  242. package/src/{toolbar-group → toolbar/toolbar-group}/toolbar-group-collapsed.js +1 -1
  243. package/src/{toolbar-group → toolbar/toolbar-group}/toolbar-group-collapsed.native.js +1 -1
  244. package/src/{toolbar-group → toolbar/toolbar-group}/toolbar-group-container.js +0 -0
  245. package/src/{toolbar-group → toolbar/toolbar-group}/toolbar-group-container.native.js +0 -0
  246. package/src/{toolbar-item → toolbar/toolbar-item}/README.md +0 -0
  247. package/src/{toolbar-item → toolbar/toolbar-item}/index.js +0 -0
  248. package/src/{toolbar-item → toolbar/toolbar-item}/index.native.js +0 -0
  249. package/src/tree-grid/index.js +2 -4
  250. package/tsconfig.json +0 -7
  251. package/tsconfig.tsbuildinfo +1 -1
  252. package/build/toolbar/toolbar-container.native.js.map +0 -1
  253. package/build/toolbar-button/index.js.map +0 -1
  254. package/build/toolbar-button/toolbar-button-container.js.map +0 -1
  255. package/build/toolbar-button/toolbar-button-container.native.js.map +0 -1
  256. package/build/toolbar-context/index.js.map +0 -1
  257. package/build/toolbar-dropdown-menu/index.js.map +0 -1
  258. package/build/toolbar-group/index.js.map +0 -1
  259. package/build/toolbar-group/toolbar-group-collapsed.js.map +0 -1
  260. package/build/toolbar-group/toolbar-group-collapsed.native.js.map +0 -1
  261. package/build/toolbar-group/toolbar-group-container.js.map +0 -1
  262. package/build/toolbar-group/toolbar-group-container.native.js.map +0 -1
  263. package/build/toolbar-item/index.js.map +0 -1
  264. package/build/toolbar-item/index.native.js.map +0 -1
  265. package/build-module/toolbar/toolbar-container.js.map +0 -1
  266. package/build-module/toolbar/toolbar-container.native.js.map +0 -1
  267. package/build-module/toolbar-button/index.js.map +0 -1
  268. package/build-module/toolbar-button/toolbar-button-container.js.map +0 -1
  269. package/build-module/toolbar-button/toolbar-button-container.native.js.map +0 -1
  270. package/build-module/toolbar-context/index.js.map +0 -1
  271. package/build-module/toolbar-dropdown-menu/index.js.map +0 -1
  272. package/build-module/toolbar-group/index.js.map +0 -1
  273. package/build-module/toolbar-group/toolbar-group-collapsed.js.map +0 -1
  274. package/build-module/toolbar-group/toolbar-group-collapsed.native.js.map +0 -1
  275. package/build-module/toolbar-group/toolbar-group-container.js.map +0 -1
  276. package/build-module/toolbar-group/toolbar-group-container.native.js.map +0 -1
  277. package/build-module/toolbar-item/index.js.map +0 -1
  278. package/build-module/toolbar-item/index.native.js.map +0 -1
  279. package/src/item-group/stories/index.js +0 -270
  280. package/src/resizable-box/stories/index.js +0 -97
@@ -0,0 +1,103 @@
1
+ /**
2
+ * External dependencies
3
+ */
4
+ import type { ComponentMeta, ComponentStory } from '@storybook/react';
5
+
6
+ /**
7
+ * Internal dependencies
8
+ */
9
+ import { ItemGroup } from '../item-group/component';
10
+ import { Item } from '../item/component';
11
+
12
+ type ItemProps = React.ComponentPropsWithoutRef< typeof Item >;
13
+
14
+ const meta: ComponentMeta< typeof ItemGroup > = {
15
+ component: ItemGroup,
16
+ title: 'Components (Experimental)/ItemGroup',
17
+ subcomponents: { Item },
18
+ argTypes: {
19
+ as: { control: { type: null } },
20
+ children: { control: { type: null } },
21
+ },
22
+ parameters: {
23
+ controls: { expanded: true },
24
+ docs: { source: { state: 'open' } },
25
+ },
26
+ };
27
+ export default meta;
28
+
29
+ const mapPropsToItem = ( props: ItemProps, index: number ) => (
30
+ <Item { ...props } key={ index } />
31
+ );
32
+
33
+ const Template: ComponentStory< typeof ItemGroup > = ( props ) => (
34
+ <ItemGroup { ...props } />
35
+ );
36
+
37
+ export const Default: ComponentStory< typeof ItemGroup > = Template.bind( {} );
38
+ Default.args = {
39
+ children: (
40
+ [
41
+ {
42
+ children: 'First item',
43
+ // eslint-disable-next-line no-alert
44
+ onClick: () => alert( 'First item clicked' ),
45
+ },
46
+ {
47
+ children: 'Second item',
48
+ // eslint-disable-next-line no-alert
49
+ onClick: () => alert( 'Second item clicked' ),
50
+ },
51
+ {
52
+ children: 'Third item',
53
+ // eslint-disable-next-line no-alert
54
+ onClick: () => alert( 'Third item clicked' ),
55
+ },
56
+ ] as ItemProps[]
57
+ ).map( mapPropsToItem ),
58
+ };
59
+
60
+ export const NonClickableItems: ComponentStory< typeof ItemGroup > =
61
+ Template.bind( {} );
62
+ NonClickableItems.args = {
63
+ children: (
64
+ [
65
+ {
66
+ children:
67
+ "This <Item /> is not click-able because it doesn't have an `onClick` prop",
68
+ },
69
+ {
70
+ children:
71
+ "This <Item /> is also not click-able because it doesn't have an `onClick` prop",
72
+ },
73
+ ] as ItemProps[]
74
+ ).map( mapPropsToItem ),
75
+ };
76
+
77
+ export const CustomItemSize: ComponentStory< typeof ItemGroup > = Template.bind(
78
+ {}
79
+ );
80
+ CustomItemSize.args = {
81
+ children: (
82
+ [
83
+ {
84
+ children:
85
+ 'This <Item /> will inherit the size from <ItemGroup /> (try changing the size prop)',
86
+ },
87
+ {
88
+ children:
89
+ 'This <Item /> has a hardcoded size="large", regardless of <ItemGroup />\'s size',
90
+ size: 'large',
91
+ },
92
+ ] as ItemProps[]
93
+ ).map( mapPropsToItem ),
94
+ };
95
+
96
+ export const WithBorder: ComponentStory< typeof ItemGroup > = Template.bind(
97
+ {}
98
+ );
99
+ WithBorder.args = {
100
+ ...Default.args,
101
+ isBordered: true,
102
+ isSeparated: true,
103
+ };
@@ -33,6 +33,7 @@ export const itemWrapper = css`
33
33
  `;
34
34
 
35
35
  export const item = css`
36
+ box-sizing: border-box;
36
37
  width: 100%;
37
38
  display: block;
38
39
  margin: 0;
@@ -11,8 +11,8 @@ Snapshot Diff:
11
11
  role="listitem"
12
12
  >
13
13
  <div
14
- - class="components-item css-1uo9kmu-View-medium-item-spacedAround e19lxcc00"
15
- + class="components-item css-10mizr-View-large-item-spacedAround e19lxcc00"
14
+ - class="components-item css-ufjlmj-View-medium-item-spacedAround e19lxcc00"
15
+ + class="components-item css-17haj95-View-large-item-spacedAround e19lxcc00"
16
16
  data-wp-c16t="true"
17
17
  data-wp-component="Item"
18
18
  >
@@ -24,8 +24,8 @@ Snapshot Diff:
24
24
  role="listitem"
25
25
  >
26
26
  <div
27
- - class="components-item css-1uo9kmu-View-medium-item-spacedAround e19lxcc00"
28
- + class="components-item css-10mizr-View-large-item-spacedAround e19lxcc00"
27
+ - class="components-item css-ufjlmj-View-medium-item-spacedAround e19lxcc00"
28
+ + class="components-item css-17haj95-View-large-item-spacedAround e19lxcc00"
29
29
  data-wp-c16t="true"
30
30
  data-wp-component="Item"
31
31
  >
@@ -44,8 +44,8 @@ Snapshot Diff:
44
44
  role="listitem"
45
45
  >
46
46
  <div
47
- - class="components-item css-bsdqin-View-medium-item e19lxcc00"
48
- + class="components-item css-1ohjtsa-View-large-item e19lxcc00"
47
+ - class="components-item css-cl593w-View-medium-item e19lxcc00"
48
+ + class="components-item css-1yvqxd-View-large-item e19lxcc00"
49
49
  data-wp-c16t="true"
50
50
  data-wp-component="Item"
51
51
  >
@@ -75,6 +75,7 @@ exports[`ItemGroup ItemGroup component should render correctly 1`] = `
75
75
 
76
76
  .emotion-3 {
77
77
  padding: calc((36px - calc(13px * 1.2) - 2px) / 2) 12px;
78
+ box-sizing: border-box;
78
79
  width: 100%;
79
80
  display: block;
80
81
  margin: 0;
@@ -124,8 +125,8 @@ Snapshot Diff:
124
125
  role="listitem"
125
126
  >
126
127
  <div
127
- - class="components-item css-1uo9kmu-View-medium-item-spacedAround e19lxcc00"
128
- + class="components-item css-bsdqin-View-medium-item e19lxcc00"
128
+ - class="components-item css-ufjlmj-View-medium-item-spacedAround e19lxcc00"
129
+ + class="components-item css-cl593w-View-medium-item e19lxcc00"
129
130
  data-wp-c16t="true"
130
131
  data-wp-component="Item"
131
132
  >
@@ -152,8 +153,8 @@ Snapshot Diff:
152
153
  role="listitem"
153
154
  >
154
155
  <div
155
- - class="components-item css-1uo9kmu-View-medium-item-spacedAround e19lxcc00"
156
- + class="components-item css-bsdqin-View-medium-item e19lxcc00"
156
+ - class="components-item css-ufjlmj-View-medium-item-spacedAround e19lxcc00"
157
+ + class="components-item css-cl593w-View-medium-item e19lxcc00"
157
158
  data-wp-c16t="true"
158
159
  data-wp-component="Item"
159
160
  >
@@ -1,74 +1,46 @@
1
- /**
2
- * External dependencies
3
- */
4
- import { boolean, select, text } from '@storybook/addon-knobs';
5
-
6
1
  /**
7
2
  * Internal dependencies
8
3
  */
9
4
  import Notice from '../';
10
5
 
6
+ // TODO: Add a story involving NoticeList to help people understand
7
+ // the difference between onDismiss/onRemove.
8
+
11
9
  export default {
12
10
  title: 'Components/Notice',
13
11
  component: Notice,
12
+ argTypes: {
13
+ isDismissible: { control: 'boolean' },
14
+ onDismiss: { control: { type: null } },
15
+ onRemove: { control: { type: null } },
16
+ politeness: {
17
+ control: 'radio',
18
+ options: [ 'assertive', 'polite' ],
19
+ },
20
+ spokenMessage: { control: 'text' },
21
+ status: {
22
+ control: 'radio',
23
+ options: [ 'warning', 'success', 'error', 'info' ],
24
+ },
25
+ },
14
26
  parameters: {
15
- knobs: { disable: false },
27
+ controls: { expanded: true },
28
+ docs: { source: { state: 'open' } },
16
29
  },
17
30
  };
18
31
 
19
- export const _default = () => {
20
- const status = select(
21
- 'Status',
22
- {
23
- Warning: 'warning',
24
- Success: 'success',
25
- Error: 'error',
26
- Info: 'info',
27
- },
28
- 'info'
29
- );
30
- const isDismissible = boolean( 'Is Dismissible', true );
31
-
32
- return (
33
- <Notice status={ status } isDismissible={ isDismissible }>
34
- <p>This is a notice.</p>
35
- </Notice>
36
- );
32
+ const Template = ( props ) => {
33
+ return <Notice { ...props } />;
37
34
  };
38
35
 
39
- export const withCustomSpokenMessage = () => {
40
- const status = select(
41
- 'Status',
42
- {
43
- Warning: 'warning',
44
- Success: 'success',
45
- Error: 'error',
46
- Info: 'info',
47
- },
48
- 'info'
49
- );
50
- const isDismissible = boolean( 'Is Dismissible', true );
51
- const politeness = select(
52
- 'Politeness',
53
- {
54
- Assertive: 'assertive',
55
- Polite: 'polite',
56
- },
57
- 'assertive'
58
- );
59
- const spokenMessage = text(
60
- 'Spoken Message',
61
- 'This is a notice with a custom spoken message'
62
- );
36
+ export const Default = Template.bind( {} );
37
+ Default.args = {
38
+ children: 'This is a notice.',
39
+ };
63
40
 
64
- return (
65
- <Notice
66
- status={ status }
67
- isDismissible={ isDismissible }
68
- politeness={ politeness }
69
- spokenMessage={ spokenMessage }
70
- >
71
- <p>This is a notice.</p>
72
- </Notice>
73
- );
41
+ export const WithCustomSpokenMessage = Template.bind( {} );
42
+ WithCustomSpokenMessage.args = {
43
+ ...Default.args,
44
+ politeness: 'assertive',
45
+ spokenMessage: 'This is a notice with a custom spoken message',
74
46
  };
package/src/panel/row.js CHANGED
@@ -8,13 +8,13 @@ import classnames from 'classnames';
8
8
  */
9
9
  import { forwardRef } from '@wordpress/element';
10
10
 
11
- const PanelRow = forwardRef( ( { className, children }, ref ) => (
11
+ const PanelRow = ( { className, children }, ref ) => (
12
12
  <div
13
13
  className={ classnames( 'components-panel__row', className ) }
14
14
  ref={ ref }
15
15
  >
16
16
  { children }
17
17
  </div>
18
- ) );
18
+ );
19
19
 
20
- export default PanelRow;
20
+ export default forwardRef( PanelRow );
@@ -1,8 +1,3 @@
1
- /**
2
- * External dependencies
3
- */
4
- import { boolean, text } from '@storybook/addon-knobs';
5
-
6
1
  /**
7
2
  * Internal dependencies
8
3
  */
@@ -18,88 +13,75 @@ import { wordpress } from '@wordpress/icons';
18
13
  export default {
19
14
  title: 'Components/Panel',
20
15
  component: Panel,
16
+ subcomponents: { PanelRow, PanelBody },
17
+ argTypes: {
18
+ children: { control: { type: null } },
19
+ },
21
20
  parameters: {
22
- knobs: { disable: false },
21
+ controls: { expanded: true },
22
+ docs: { source: { state: 'open' } },
23
23
  },
24
24
  };
25
25
 
26
- export const _default = () => {
27
- const bodyTitle = text( 'Body Title', 'My Block Settings' );
28
- const opened = boolean( 'Opened', true );
29
- const rowText = text( 'Row Text', 'My Panel Inputs and Labels' );
30
- return (
31
- <Panel header="My Panel">
32
- <PanelBody title={ bodyTitle } opened={ opened }>
33
- <PanelRow>{ rowText }</PanelRow>
26
+ const Template = ( props ) => <Panel { ...props } />;
27
+
28
+ export const Default = Template.bind( {} );
29
+ Default.args = {
30
+ header: 'My panel',
31
+ children: (
32
+ <>
33
+ <PanelBody title="First section">
34
+ <PanelRow>
35
+ <div
36
+ style={ {
37
+ background: '#ddd',
38
+ height: 100,
39
+ width: '100%',
40
+ } }
41
+ />
42
+ </PanelRow>
43
+ </PanelBody>
44
+ <PanelBody title="Second section" initialOpen={ false }>
45
+ <PanelRow>
46
+ <div
47
+ style={ {
48
+ background: '#ddd',
49
+ height: 100,
50
+ width: '100%',
51
+ } }
52
+ />
53
+ </PanelRow>
34
54
  </PanelBody>
35
- </Panel>
36
- );
55
+ </>
56
+ ),
37
57
  };
38
58
 
39
- export const multipleBodies = () => {
40
- return (
41
- <ScrollableContainer>
42
- <Panel header="My Panel">
43
- <PanelBody title="First Settings">
44
- <PanelRow>
45
- <Placeholder height={ 250 } />
46
- </PanelRow>
47
- </PanelBody>
48
- <PanelBody title="Second Settings" initialOpen={ false }>
49
- <PanelRow>
50
- <Placeholder height={ 400 } />
51
- </PanelRow>
52
- </PanelBody>
53
- <PanelBody title="Third Settings" initialOpen={ false }>
54
- <PanelRow>
55
- <Placeholder height={ 600 } />
56
- </PanelRow>
57
- </PanelBody>
58
- <PanelBody title="Fourth Settings" initialOpen={ false }>
59
- <PanelRow>
60
- <Placeholder />
61
- </PanelRow>
62
- </PanelBody>
63
- <PanelBody
64
- title="Disabled Settings"
65
- initialOpen={ false }
66
- buttonProps={ { disabled: true } }
67
- />
68
- </Panel>
69
- </ScrollableContainer>
70
- );
59
+ export const DisabledSection = Template.bind( {} );
60
+ DisabledSection.args = {
61
+ ...Default.args,
62
+ children: (
63
+ <PanelBody
64
+ title="Disabled section"
65
+ initialOpen={ false }
66
+ buttonProps={ { disabled: true } }
67
+ />
68
+ ),
71
69
  };
72
70
 
73
- export const withIcon = () => {
74
- const bodyTitle = text( 'Body Title', 'My Block Settings' );
75
- const rowText = text( 'Row Text', 'My Panel Inputs and Labels' );
76
- const icon = boolean( 'Icon', true ) ? wordpress : undefined;
77
- const opened = boolean( 'Opened', true );
78
- return (
79
- <Panel header="My Panel">
80
- <PanelBody title={ bodyTitle } opened={ opened } icon={ icon }>
81
- <PanelRow>{ rowText }</PanelRow>
82
- </PanelBody>
83
- </Panel>
84
- );
71
+ export const WithIcon = Template.bind( {} );
72
+ WithIcon.args = {
73
+ ...Default.args,
74
+ children: (
75
+ <PanelBody title="Section title" icon={ wordpress }>
76
+ <PanelRow>
77
+ <div
78
+ style={ {
79
+ background: '#ddd',
80
+ height: 100,
81
+ width: '100%',
82
+ } }
83
+ />
84
+ </PanelRow>
85
+ </PanelBody>
86
+ ),
85
87
  };
86
-
87
- function ScrollableContainer( { children } ) {
88
- return (
89
- <div
90
- style={ {
91
- width: 300,
92
- height: '100vh',
93
- overflowY: 'auto',
94
- margin: 'auto',
95
- boxShadow: '0 0 0 1px #ddd inset',
96
- } }
97
- >
98
- { children }
99
- </div>
100
- );
101
- }
102
-
103
- function Placeholder( { height = 200 } ) {
104
- return <div style={ { background: '#ddd', height, width: '100%' } } />;
105
- }
@@ -45,7 +45,7 @@
45
45
  > svg,
46
46
  .dashicon,
47
47
  .block-editor-block-icon {
48
- margin-right: 1ch;
48
+ margin-right: $grid-unit-15;
49
49
  fill: currentColor;
50
50
  // Optimizate for high contrast modes.
51
51
  // See also https://blogs.windows.com/msedgedev/2020/09/17/styling-for-windows-high-contrast-with-new-standards-for-forced-colors/.
@@ -35,6 +35,7 @@ export default function QueryControls( {
35
35
  return [
36
36
  onOrderChange && onOrderByChange && (
37
37
  <SelectControl
38
+ __nextHasNoMarginBottom
38
39
  key="query-controls-order-select"
39
40
  label={ __( 'Order by' ) }
40
41
  value={ `${ orderBy }/${ order }` }
@@ -38,8 +38,8 @@ const Edit = ( props ) => {
38
38
  } }
39
39
  onResizeStop={ ( event, direction, elt, delta ) => {
40
40
  setAttributes( {
41
- height: parseInt( height + delta.height, 10 ),
42
- width: parseInt( width + delta.width, 10 ),
41
+ height: height + delta.height,
42
+ width: width + delta.width,
43
43
  } );
44
44
  toggleSelection( true );
45
45
  } }
@@ -88,14 +88,13 @@ const HANDLE_STYLES = {
88
88
  };
89
89
 
90
90
  type ResizableBoxProps = ResizableProps & {
91
- className: string;
92
91
  children: ReactNode;
93
- showHandle: boolean;
94
- __experimentalShowTooltip: boolean;
95
- __experimentalTooltipProps: Parameters< typeof ResizeTooltip >[ 0 ];
92
+ showHandle?: boolean;
93
+ __experimentalShowTooltip?: boolean;
94
+ __experimentalTooltipProps?: Parameters< typeof ResizeTooltip >[ 0 ];
96
95
  };
97
96
 
98
- function ResizableBox(
97
+ function UnforwardedResizableBox(
99
98
  {
100
99
  className,
101
100
  children,
@@ -124,4 +123,6 @@ function ResizableBox(
124
123
  );
125
124
  }
126
125
 
127
- export default forwardRef( ResizableBox );
126
+ export const ResizableBox = forwardRef( UnforwardedResizableBox );
127
+
128
+ export default ResizableBox;
@@ -0,0 +1,92 @@
1
+ /**
2
+ * External dependencies
3
+ */
4
+ import type { ComponentMeta, ComponentStory } from '@storybook/react';
5
+
6
+ /**
7
+ * Internal dependencies
8
+ */
9
+ import ResizableBox from '..';
10
+
11
+ /**
12
+ * WordPress dependencies
13
+ */
14
+ import { useState } from '@wordpress/element';
15
+
16
+ const meta: ComponentMeta< typeof ResizableBox > = {
17
+ title: 'Components/ResizableBox',
18
+ component: ResizableBox,
19
+ argTypes: {
20
+ children: { control: { type: null } },
21
+ enable: { control: 'object' },
22
+ onResizeStop: { action: 'onResizeStop' },
23
+ },
24
+ parameters: {
25
+ controls: { expanded: true },
26
+ docs: { source: { state: 'open' } },
27
+ },
28
+ };
29
+ export default meta;
30
+
31
+ const Template: ComponentStory< typeof ResizableBox > = ( {
32
+ onResizeStop,
33
+ ...props
34
+ } ) => {
35
+ const [ { height, width }, setAttributes ] = useState( {
36
+ height: 200,
37
+ width: 400,
38
+ } );
39
+
40
+ return (
41
+ <ResizableBox
42
+ { ...props }
43
+ size={ {
44
+ height,
45
+ width,
46
+ } }
47
+ onResizeStop={ ( event, direction, elt, delta ) => {
48
+ onResizeStop?.( event, direction, elt, delta );
49
+ setAttributes( {
50
+ height: height + delta.height,
51
+ width: width + delta.width,
52
+ } );
53
+ } }
54
+ />
55
+ );
56
+ };
57
+
58
+ export const Default = Template.bind( {} );
59
+ Default.args = {
60
+ children: (
61
+ <div
62
+ style={ {
63
+ background: '#eee',
64
+ display: 'flex',
65
+ height: '100%',
66
+ width: '100%',
67
+ alignItems: 'center',
68
+ justifyContent: 'center',
69
+ } }
70
+ >
71
+ Resize
72
+ </div>
73
+ ),
74
+ };
75
+
76
+ /**
77
+ * The `enable` prop can be used to disable resizing in specific directions.
78
+ */
79
+ export const DisabledDirections = Template.bind( {} );
80
+ DisabledDirections.args = {
81
+ ...Default.args,
82
+ enable: {
83
+ top: false,
84
+ right: true,
85
+ bottom: true,
86
+ left: false,
87
+ topRight: false,
88
+ bottomRight: true,
89
+ bottomLeft: false,
90
+ topLeft: false,
91
+ },
92
+ };
@@ -1,5 +1,7 @@
1
1
  # ResponsiveWrapper
2
2
 
3
+ A wrapper component that maintains its aspect ratio when resized.
4
+
3
5
  ## Usage
4
6
 
5
7
  ```jsx
@@ -14,3 +16,30 @@ const MyResponsiveWrapper = () => (
14
16
  </ResponsiveWrapper>
15
17
  );
16
18
  ```
19
+
20
+ ## Props
21
+
22
+ ### `children`: `React.ReactElement`
23
+
24
+ The element to wrap.
25
+
26
+ - Required: Yes
27
+
28
+ ### `isInline`: `boolean`
29
+
30
+ If true, the wrapper will be `span` instead of `div`.
31
+
32
+ - Required: No
33
+ - Default: `false`
34
+
35
+ ### `naturalHeight`: `number`
36
+
37
+ The intrinsic height of the element to wrap. Will be used to determine the aspect ratio.
38
+
39
+ - Required: Yes
40
+
41
+ ### `naturalWidth`: `number`
42
+
43
+ The intrinsic width of the element to wrap. Will be used to determine the aspect ratio.
44
+
45
+ - Required: Yes
@@ -9,12 +9,33 @@ import classnames from 'classnames';
9
9
  import { cloneElement, Children } from '@wordpress/element';
10
10
  import { useResizeObserver } from '@wordpress/compose';
11
11
 
12
+ /**
13
+ * Internal dependencies
14
+ */
15
+ import type { ResponsiveWrapperProps } from './types';
16
+
17
+ /**
18
+ * A wrapper component that maintains its aspect ratio when resized.
19
+ *
20
+ * ```jsx
21
+ * import { ResponsiveWrapper } from '@wordpress/components';
22
+ *
23
+ * const MyResponsiveWrapper = () => (
24
+ * <ResponsiveWrapper naturalWidth={ 2000 } naturalHeight={ 680 }>
25
+ * <img
26
+ * src="https://s.w.org/style/images/about/WordPress-logotype-standard.png"
27
+ * alt="WordPress"
28
+ * />
29
+ * </ResponsiveWrapper>
30
+ * );
31
+ * ```
32
+ */
12
33
  function ResponsiveWrapper( {
13
34
  naturalWidth,
14
35
  naturalHeight,
15
36
  children,
16
37
  isInline = false,
17
- } ) {
38
+ }: ResponsiveWrapperProps ) {
18
39
  const [ containerResizeListener, { width: containerWidth } ] =
19
40
  useResizeObserver();
20
41
  if ( Children.count( children ) !== 1 ) {
@@ -22,7 +43,7 @@ function ResponsiveWrapper( {
22
43
  }
23
44
  const imageStyle = {
24
45
  paddingBottom:
25
- naturalWidth < containerWidth
46
+ naturalWidth < ( containerWidth ?? 0 )
26
47
  ? naturalHeight
27
48
  : ( naturalHeight / naturalWidth ) * 100 + '%',
28
49
  };