@wordpress/components 27.1.0 → 27.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 (122) hide show
  1. package/CHANGELOG.md +29 -3
  2. package/build/button/index.js +2 -3
  3. package/build/button/index.js.map +1 -1
  4. package/build/button/types.js.map +1 -1
  5. package/build/date-time/date/styles.js +7 -7
  6. package/build/date-time/date/styles.js.map +1 -1
  7. package/build/form-token-field/index.js +1 -1
  8. package/build/form-token-field/index.js.map +1 -1
  9. package/build/input-control/index.js +1 -1
  10. package/build/input-control/index.js.map +1 -1
  11. package/build/palette-edit/index.js +18 -12
  12. package/build/palette-edit/index.js.map +1 -1
  13. package/build/text-control/types.js.map +1 -1
  14. package/build/toggle-group-control/toggle-group-control-option-base/component.js +4 -1
  15. package/build/toggle-group-control/toggle-group-control-option-base/component.js.map +1 -1
  16. package/build/tools-panel/tools-panel-header/component.js +1 -1
  17. package/build/tools-panel/tools-panel-header/component.js.map +1 -1
  18. package/build/utils/config-values.js +1 -1
  19. package/build/utils/config-values.js.map +1 -1
  20. package/build/utils/input/base.js +2 -2
  21. package/build/utils/input/base.js.map +1 -1
  22. package/build-module/button/index.js +2 -3
  23. package/build-module/button/index.js.map +1 -1
  24. package/build-module/button/types.js.map +1 -1
  25. package/build-module/date-time/date/styles.js +7 -7
  26. package/build-module/date-time/date/styles.js.map +1 -1
  27. package/build-module/form-token-field/index.js +1 -1
  28. package/build-module/form-token-field/index.js.map +1 -1
  29. package/build-module/input-control/index.js +1 -1
  30. package/build-module/input-control/index.js.map +1 -1
  31. package/build-module/palette-edit/index.js +17 -11
  32. package/build-module/palette-edit/index.js.map +1 -1
  33. package/build-module/text-control/types.js.map +1 -1
  34. package/build-module/toggle-group-control/toggle-group-control-option-base/component.js +4 -1
  35. package/build-module/toggle-group-control/toggle-group-control-option-base/component.js.map +1 -1
  36. package/build-module/tools-panel/tools-panel-header/component.js +1 -1
  37. package/build-module/tools-panel/tools-panel-header/component.js.map +1 -1
  38. package/build-module/utils/config-values.js +1 -1
  39. package/build-module/utils/config-values.js.map +1 -1
  40. package/build-module/utils/input/base.js +2 -2
  41. package/build-module/utils/input/base.js.map +1 -1
  42. package/build-style/style-rtl.css +25 -22
  43. package/build-style/style.css +25 -22
  44. package/build-types/box-control/styles/box-control-styles.d.ts +1 -1
  45. package/build-types/button/deprecated.d.ts +4 -10
  46. package/build-types/button/deprecated.d.ts.map +1 -1
  47. package/build-types/button/index.d.ts +3 -3
  48. package/build-types/button/index.d.ts.map +1 -1
  49. package/build-types/button/stories/e2e/index.story.d.ts +1 -1
  50. package/build-types/button/stories/e2e/index.story.d.ts.map +1 -1
  51. package/build-types/button/stories/index.story.d.ts +7 -7
  52. package/build-types/button/stories/index.story.d.ts.map +1 -1
  53. package/build-types/button/types.d.ts +37 -8
  54. package/build-types/button/types.d.ts.map +1 -1
  55. package/build-types/color-picker/styles.d.ts +1 -1
  56. package/build-types/date-time/date/styles.d.ts +1 -1
  57. package/build-types/dropdown/stories/index.story.d.ts +1 -0
  58. package/build-types/dropdown/stories/index.story.d.ts.map +1 -1
  59. package/build-types/font-size-picker/styles.d.ts +1 -1
  60. package/build-types/form-token-field/index.d.ts +1 -1
  61. package/build-types/input-control/index.d.ts +1 -1
  62. package/build-types/input-control/stories/index.story.d.ts.map +1 -1
  63. package/build-types/navigation/styles/navigation-styles.d.ts +1 -1
  64. package/build-types/navigator/navigator-back-button/component.d.ts +0 -1
  65. package/build-types/navigator/navigator-back-button/component.d.ts.map +1 -1
  66. package/build-types/navigator/navigator-back-button/hook.d.ts +1 -2
  67. package/build-types/navigator/navigator-back-button/hook.d.ts.map +1 -1
  68. package/build-types/navigator/navigator-button/component.d.ts +0 -1
  69. package/build-types/navigator/navigator-button/component.d.ts.map +1 -1
  70. package/build-types/navigator/navigator-button/hook.d.ts +1 -2
  71. package/build-types/navigator/navigator-button/hook.d.ts.map +1 -1
  72. package/build-types/navigator/navigator-to-parent-button/component.d.ts +0 -1
  73. package/build-types/navigator/navigator-to-parent-button/component.d.ts.map +1 -1
  74. package/build-types/number-control/styles/number-control-styles.d.ts +1 -1
  75. package/build-types/palette-edit/index.d.ts +6 -3
  76. package/build-types/palette-edit/index.d.ts.map +1 -1
  77. package/build-types/palette-edit/styles.d.ts +2 -2
  78. package/build-types/text-control/index.d.ts +1 -1
  79. package/build-types/text-control/types.d.ts +1 -1
  80. package/build-types/text-control/types.d.ts.map +1 -1
  81. package/build-types/toggle-group-control/toggle-group-control-option-base/component.d.ts.map +1 -1
  82. package/build-types/toolbar/toolbar-button/index.d.ts +4 -10
  83. package/build-types/toolbar/toolbar-button/index.d.ts.map +1 -1
  84. package/package.json +19 -19
  85. package/src/button/index.tsx +2 -3
  86. package/src/button/test/index.tsx +6 -6
  87. package/src/button/types.ts +37 -9
  88. package/src/confirm-dialog/README.md +7 -0
  89. package/src/date-time/date/styles.ts +2 -2
  90. package/src/dimension-control/test/__snapshots__/index.test.js.snap +4 -4
  91. package/src/dropdown/stories/index.story.tsx +19 -0
  92. package/src/dropdown/style.scss +26 -0
  93. package/src/dropdown-menu/style.scss +0 -25
  94. package/src/flex/flex/README.md +2 -2
  95. package/src/form-token-field/README.md +1 -1
  96. package/src/form-token-field/index.tsx +1 -1
  97. package/src/grid/README.md +11 -11
  98. package/src/h-stack/README.md +6 -6
  99. package/src/heading/README.md +1 -1
  100. package/src/heading/test/__snapshots__/index.tsx.snap +3 -3
  101. package/src/input-control/README.md +1 -1
  102. package/src/input-control/index.tsx +1 -1
  103. package/src/input-control/stories/index.story.tsx +1 -0
  104. package/src/item-group/test/__snapshots__/index.js.snap +11 -11
  105. package/src/mobile/bottom-sheet-select-control/README.md +1 -1
  106. package/src/palette-edit/index.tsx +21 -21
  107. package/src/palette-edit/test/index.tsx +21 -17
  108. package/src/placeholder/style.scss +5 -1
  109. package/src/progress-bar/README.md +1 -1
  110. package/src/radio-control/README.md +3 -3
  111. package/src/resizable-box/resize-tooltip/README.md +2 -2
  112. package/src/text/test/__snapshots__/index.tsx.snap +3 -3
  113. package/src/text-control/types.ts +12 -1
  114. package/src/toggle-group-control/test/__snapshots__/index.tsx.snap +14 -10
  115. package/src/toggle-group-control/toggle-group-control-option-base/component.tsx +12 -10
  116. package/src/tools-panel/tools-panel-header/component.tsx +1 -1
  117. package/src/truncate/README.md +5 -5
  118. package/src/utils/config-values.js +1 -1
  119. package/src/utils/input/base.js +1 -1
  120. package/src/v-stack/README.md +6 -6
  121. package/tsconfig.json +1 -0
  122. package/tsconfig.tsbuildinfo +1 -1
@@ -61,15 +61,6 @@ type BaseButtonProps = {
61
61
  * Renders a pressed button style.
62
62
  */
63
63
  isPressed?: boolean;
64
- // TODO: Deprecate officially (add console warning and move to DeprecatedButtonProps).
65
- /**
66
- * Decreases the size of the button.
67
- *
68
- * Deprecated in favor of the `size` prop. If both props are defined, the `size` prop will take precedence.
69
- *
70
- * @deprecated Use the `'small'` value on the `size` prop instead.
71
- */
72
- isSmall?: boolean;
73
64
  /**
74
65
  * Sets the `aria-label` of the component, if none is provided.
75
66
  * Sets the Tooltip content if `showTooltip` is provided.
@@ -149,11 +140,48 @@ type AnchorProps = {
149
140
  };
150
141
 
151
142
  export type DeprecatedButtonProps = {
143
+ /**
144
+ * Gives the button a default style.
145
+ *
146
+ * @deprecated Use the `'secondary'` value on the `variant` prop instead.
147
+ * @ignore
148
+ */
152
149
  isDefault?: boolean;
150
+ /**
151
+ * Gives the button a link style.
152
+ *
153
+ * @deprecated Use the `'link'` value on the `variant` prop instead.
154
+ * @ignore
155
+ */
153
156
  isLink?: boolean;
157
+ /**
158
+ * Gives the button a primary style.
159
+ *
160
+ * @deprecated Use the `'primary'` value on the `variant` prop instead.
161
+ * @ignore
162
+ */
154
163
  isPrimary?: boolean;
164
+ /**
165
+ * Gives the button a default style.
166
+ *
167
+ * @deprecated Use the `'secondary'` value on the `variant` prop instead.
168
+ * @ignore
169
+ */
155
170
  isSecondary?: boolean;
171
+ /**
172
+ * Gives the button a text-based style.
173
+ *
174
+ * @deprecated Use the `'tertiary'` value on the `variant` prop instead.
175
+ * @ignore
176
+ */
156
177
  isTertiary?: boolean;
178
+ /**
179
+ * Decreases the size of the button.
180
+ *
181
+ * @deprecated Use the `'small'` value on the `size` prop instead.
182
+ * @ignore
183
+ */
184
+ isSmall?: boolean;
157
185
  };
158
186
 
159
187
  export type DeprecatedIconButtonProps = {
@@ -138,3 +138,10 @@ The optional custom text to display as the confirmation button's label
138
138
  - Default: "Cancel"
139
139
 
140
140
  The optional custom text to display as the cancellation button's label
141
+
142
+ ## Best practices
143
+
144
+ The ConfirmDialog component should:
145
+
146
+ - Be used only for short confirmation messages where a cancel and confirm actions are provided.
147
+ - Use a descriptive text for the _confirm_ button. Default is "OK".
@@ -84,8 +84,8 @@ export const DayButton = styled( Button, {
84
84
 
85
85
  &&& {
86
86
  border-radius: 100%;
87
- height: ${ space( 8 ) };
88
- width: ${ space( 8 ) };
87
+ height: ${ space( 7 ) };
88
+ width: ${ space( 7 ) };
89
89
 
90
90
  ${ ( props ) =>
91
91
  props.isSelected &&
@@ -59,7 +59,7 @@ exports[`DimensionControl rendering renders with custom sizes 1`] = `
59
59
 
60
60
  .emotion-11 {
61
61
  color: #1e1e1e;
62
- line-height: 1.2;
62
+ line-height: 1.4;
63
63
  margin: 0;
64
64
  font-size: calc((13 / 13) * 13px);
65
65
  font-weight: normal;
@@ -330,7 +330,7 @@ exports[`DimensionControl rendering renders with defaults 1`] = `
330
330
 
331
331
  .emotion-11 {
332
332
  color: #1e1e1e;
333
- line-height: 1.2;
333
+ line-height: 1.4;
334
334
  margin: 0;
335
335
  font-size: calc((13 / 13) * 13px);
336
336
  font-weight: normal;
@@ -611,7 +611,7 @@ exports[`DimensionControl rendering renders with icon and custom icon label 1`]
611
611
 
612
612
  .emotion-11 {
613
613
  color: #1e1e1e;
614
- line-height: 1.2;
614
+ line-height: 1.4;
615
615
  margin: 0;
616
616
  font-size: calc((13 / 13) * 13px);
617
617
  font-weight: normal;
@@ -904,7 +904,7 @@ exports[`DimensionControl rendering renders with icon and default icon label 1`]
904
904
 
905
905
  .emotion-11 {
906
906
  color: #1e1e1e;
907
- line-height: 1.2;
907
+ line-height: 1.4;
908
908
  margin: 0;
909
909
  font-size: calc((13 / 13) * 13px);
910
910
  font-weight: normal;
@@ -8,6 +8,8 @@ import type { Meta, StoryFn } from '@storybook/react';
8
8
  */
9
9
  import Dropdown from '..';
10
10
  import Button from '../../button';
11
+ import MenuGroup from '../../menu-group';
12
+ import MenuItem from '../../menu-item';
11
13
  import { DropdownContentWrapper } from '../dropdown-content-wrapper';
12
14
 
13
15
  const meta: Meta< typeof Dropdown > = {
@@ -83,3 +85,20 @@ WithNoPadding.args = {
83
85
  </DropdownContentWrapper>
84
86
  ),
85
87
  };
88
+
89
+ export const WithMenuItems = Template.bind( {} );
90
+ WithMenuItems.args = {
91
+ ...Default.args,
92
+ renderContent: () => (
93
+ <>
94
+ <MenuGroup label="Group 1">
95
+ <MenuItem>Item 1</MenuItem>
96
+ <MenuItem>Item 2</MenuItem>
97
+ </MenuGroup>
98
+ <MenuGroup label="Group 2">
99
+ <MenuItem>Item 1</MenuItem>
100
+ <MenuItem>Item 2</MenuItem>
101
+ </MenuGroup>
102
+ </>
103
+ ),
104
+ };
@@ -10,4 +10,30 @@
10
10
  [role="menuitem"] {
11
11
  white-space: nowrap;
12
12
  }
13
+
14
+ .components-menu-group {
15
+ padding: $grid-unit-10;
16
+ margin-top: 0;
17
+ margin-bottom: 0;
18
+ margin-left: -$grid-unit-10;
19
+ margin-right: -$grid-unit-10;
20
+
21
+ &:first-child {
22
+ margin-top: -$grid-unit-10;
23
+ }
24
+
25
+ &:last-child {
26
+ margin-bottom: -$grid-unit-10;
27
+ }
28
+ }
29
+
30
+ .components-menu-group + .components-menu-group {
31
+ margin-top: 0;
32
+ border-top: $border-width solid $gray-400;
33
+ padding: $grid-unit-10;
34
+
35
+ .is-alternate & {
36
+ border-color: $gray-900;
37
+ }
38
+ }
13
39
  }
@@ -60,29 +60,4 @@
60
60
  padding-right: $grid-unit-10;
61
61
  }
62
62
 
63
- .components-menu-group {
64
- padding: $grid-unit-10;
65
- margin-top: 0;
66
- margin-bottom: 0;
67
- margin-left: -$grid-unit-10;
68
- margin-right: -$grid-unit-10;
69
-
70
- &:first-child {
71
- margin-top: -$grid-unit-10;
72
- }
73
-
74
- &:last-child {
75
- margin-bottom: -$grid-unit-10;
76
- }
77
- }
78
-
79
- .components-menu-group + .components-menu-group {
80
- margin-top: 0;
81
- border-top: $border-width solid $gray-400;
82
- padding: $grid-unit-10;
83
-
84
- .is-alternate & {
85
- border-color: $gray-900;
86
- }
87
- }
88
63
  }
@@ -53,14 +53,14 @@ Spacing in between each child can be adjusted by using `gap`. The value of `gap`
53
53
  - Required: No
54
54
  - Default: `2`
55
55
 
56
- ##### `justify`: `CSSProperties['justifyContent']`
56
+ ### `justify`: `CSSProperties['justifyContent']`
57
57
 
58
58
  Horizontally aligns content if the `direction` is `row`, or vertically aligns content if the `direction` is `column`.
59
59
 
60
60
  - Required: No
61
61
  - Default: `space-between`
62
62
 
63
- ##### `wrap`: `boolean`
63
+ ### `wrap`: `boolean`
64
64
 
65
65
  Determines if children should wrap.
66
66
 
@@ -4,7 +4,7 @@ A `FormTokenField` is a field similar to the tags and categories fields in the i
4
4
 
5
5
  Up to one hundred suggestions that match what the user has typed so far will be shown from which the user can pick from (auto-complete). Tokens are separated by the "," character. Suggestions can be selected with the up or down arrows and added with the tab or enter key.
6
6
 
7
- The `value` property is handled in a manner similar to controlled form components. See [Forms](http://facebook.github.io/react/docs/forms.html) in the React Documentation for more information.
7
+ The `value` property is handled in a manner similar to controlled form components. See [Forms](https://react.dev/reference/react-dom/components#form-components) in the React Documentation for more information.
8
8
 
9
9
  ## Keyboard Accessibility
10
10
 
@@ -40,7 +40,7 @@ const identity = ( value: string ) => value;
40
40
  * Tokens are separated by the "," character. Suggestions can be selected with the up or down arrows and added with the tab or enter key.
41
41
  *
42
42
  * The `value` property is handled in a manner similar to controlled form components.
43
- * See [Forms](http://facebook.github.io/react/docs/forms.html) in the React Documentation for more information.
43
+ * See [Forms](https://react.dev/reference/react-dom/components#form-components) in the React Documentation for more information.
44
44
  */
45
45
  export function FormTokenField( props: FormTokenFieldProps ) {
46
46
  const {
@@ -27,69 +27,69 @@ function Example() {
27
27
 
28
28
  ## Props
29
29
 
30
- ##### `align`: `CSS['alignItems']`
30
+ ### `align`: `CSS['alignItems']`
31
31
 
32
32
  Adjusts the block alignment of children.
33
33
 
34
34
  - Required: No
35
35
 
36
- ##### `alignment`: `GridAlignment`
36
+ ### `alignment`: `GridAlignment`
37
37
 
38
38
  Adjusts the horizontal and vertical alignment of children.
39
39
 
40
40
  - Required: No
41
41
 
42
- ##### `columnGap`: `CSSProperties['gridColumnGap']`
42
+ ### `columnGap`: `CSSProperties['gridColumnGap']`
43
43
 
44
44
  Adjusts the `grid-column-gap`.
45
45
 
46
46
  - Required: No
47
47
 
48
- ##### `columns`: `number`
48
+ ### `columns`: `number`
49
49
 
50
50
  Adjusts the number of columns of the `Grid`.
51
51
 
52
52
  - Required: No
53
53
  - Default: `2`
54
54
 
55
- ##### `gap`: `number`
55
+ ### `gap`: `number`
56
56
 
57
57
  Gap between each child.
58
58
 
59
59
  - Required: No
60
60
  - Default: `3`
61
61
 
62
- ##### `isInline`: `boolean`
62
+ ### `isInline`: `boolean`
63
63
 
64
64
  Changes the CSS display from `grid` to `inline-grid`.
65
65
 
66
66
  - Required: No
67
67
 
68
- ##### `justify`: `CSS['justifyContent']`
68
+ ### `justify`: `CSS['justifyContent']`
69
69
 
70
70
  Adjusts the inline alignment of children.
71
71
 
72
72
  - Required: No
73
73
 
74
- ##### `rowGap`: `CSSProperties['gridRowGap']`
74
+ ### `rowGap`: `CSSProperties['gridRowGap']`
75
75
 
76
76
  Adjusts the `grid-row-gap`.
77
77
 
78
78
  - Required: No
79
79
 
80
- ##### `rows`: `number`
80
+ ### `rows`: `number`
81
81
 
82
82
  Adjusts the number of rows of the `Grid`.
83
83
 
84
84
  - Required: No
85
85
 
86
- ##### `templateColumns`: `CSS['gridTemplateColumns']`
86
+ ### `templateColumns`: `CSS['gridTemplateColumns']`
87
87
 
88
88
  Adjusts the CSS grid `template-columns`.
89
89
 
90
90
  - Required: No
91
91
 
92
- ##### `templateRows`: `CSS['gridTemplateRows']`
92
+ ### `templateRows`: `CSS['gridTemplateRows']`
93
93
 
94
94
  Adjusts the CSS grid `template-rows`.
95
95
 
@@ -29,7 +29,7 @@ function Example() {
29
29
 
30
30
  ## Props
31
31
 
32
- ##### alignment
32
+ ### alignment
33
33
 
34
34
  **Type**: `HStackAlignment` | `CSS[ 'alignItems' ]`
35
35
 
@@ -47,33 +47,33 @@ Determines how the child elements are aligned.
47
47
  - `edge`: Justifies content to be evenly spread out up to the main axis edges of the container.
48
48
  - `stretch`: Stretches content to the cross axis edges of the container.
49
49
 
50
- ##### direction
50
+ ### direction
51
51
 
52
52
  **Type**: `FlexDirection`
53
53
 
54
54
  The direction flow of the children content can be adjusted with `direction`. `column` will align children vertically and `row` will align children horizontally.
55
55
 
56
- ##### expanded
56
+ ### expanded
57
57
 
58
58
  **Type**: `boolean`
59
59
 
60
60
  Expands to the maximum available width (if horizontal) or height (if vertical).
61
61
 
62
- ##### justify
62
+ ### justify
63
63
 
64
64
  **Type**: `CSS['justifyContent']`
65
65
 
66
66
  Horizontally aligns content if the `direction` is `row`, or vertically aligns content if the `direction` is `column`.
67
67
  In the example below, `flex-start` will align the children content to the left.
68
68
 
69
- ##### spacing
69
+ ### spacing
70
70
 
71
71
  **Type**: `CSS['width']`
72
72
 
73
73
  The amount of space between each child element. Spacing in between each child can be adjusted by using `spacing`.
74
74
  The value of `spacing` works as a multiplier to the library's grid system (base of `4px`).
75
75
 
76
- ##### wrap
76
+ ### wrap
77
77
 
78
78
  **Type**: `boolean`
79
79
 
@@ -25,7 +25,7 @@ function Example() {
25
25
 
26
26
  For a complete list of those props, check out [`Text`](/packages/components/src/text/README.md#props).
27
27
 
28
- ##### `level`: `1 | 2 | 3 | 4 | 5 | 6 | '1' | '2' | '3' | '4' | '5' | '6'`
28
+ ### `level`: `1 | 2 | 3 | 4 | 5 | 6 | '1' | '2' | '3' | '4' | '5' | '6'`
29
29
 
30
30
  Passing any of the heading levels to `level` will both render the correct typographic text size as well as the semantic element corresponding to the level (`h1` for `1` for example).
31
31
 
@@ -3,7 +3,7 @@
3
3
  exports[`props should render correctly 1`] = `
4
4
  .emotion-0 {
5
5
  color: #1e1e1e;
6
- line-height: 1.2;
6
+ line-height: 1.4;
7
7
  margin: 0;
8
8
  color: #1e1e1e;
9
9
  font-size: calc(1.95 * 13px);
@@ -32,7 +32,7 @@ Snapshot Diff:
32
32
  - "font-size": "calc(1.25 * 13px)",
33
33
  + "font-size": "calc(1.95 * 13px)",
34
34
  "font-weight": "600",
35
- "line-height": "1.2",
35
+ "line-height": "1.4",
36
36
  "margin": "0",
37
37
  },
38
38
  ]
@@ -50,7 +50,7 @@ Snapshot Diff:
50
50
  - "font-size": "calc(1.25 * 13px)",
51
51
  + "font-size": "calc(1.95 * 13px)",
52
52
  "font-weight": "600",
53
- "line-height": "1.2",
53
+ "line-height": "1.4",
54
54
  "margin": "0",
55
55
  },
56
56
  ]
@@ -10,7 +10,7 @@ InputControl components let users enter and edit text. This is an experimental c
10
10
 
11
11
  ```js
12
12
  import { __experimentalInputControl as InputControl } from '@wordpress/components';
13
- import { useState } from '@wordpress/compose';
13
+ import { useState } from 'react';
14
14
 
15
15
  const Example = () => {
16
16
  const [ value, setValue ] = useState( '' );
@@ -126,7 +126,7 @@ export function UnforwardedInputControl(
126
126
  *
127
127
  * ```jsx
128
128
  * import { __experimentalInputControl as InputControl } from '@wordpress/components';
129
- * import { useState } from '@wordpress/compose';
129
+ * import { useState } from 'react';
130
130
  *
131
131
  * const Example = () => {
132
132
  * const [ value, setValue ] = useState( '' );
@@ -25,6 +25,7 @@ const meta: Meta< typeof InputControl > = {
25
25
  value: { control: { disable: true } },
26
26
  },
27
27
  parameters: {
28
+ actions: { argTypesRegex: '^on.*' },
28
29
  controls: { expanded: true },
29
30
  docs: { canvas: { sourceState: 'shown' } },
30
31
  },
@@ -11,8 +11,8 @@ Snapshot Diff:
11
11
  role="listitem"
12
12
  >
13
13
  <div
14
- - class="components-item css-ufjlmj-View-medium-item-spacedAround e19lxcc00"
15
- + class="components-item css-17haj95-View-large-item-spacedAround e19lxcc00"
14
+ - class="components-item css-1n28wmo-View-medium-item-spacedAround e19lxcc00"
15
+ + class="components-item css-gg7ygh-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-ufjlmj-View-medium-item-spacedAround e19lxcc00"
28
- + class="components-item css-17haj95-View-large-item-spacedAround e19lxcc00"
27
+ - class="components-item css-1n28wmo-View-medium-item-spacedAround e19lxcc00"
28
+ + class="components-item css-gg7ygh-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-cl593w-View-medium-item e19lxcc00"
48
- + class="components-item css-1yvqxd-View-large-item e19lxcc00"
47
+ - class="components-item css-1lf4kzd-View-medium-item e19lxcc00"
48
+ + class="components-item css-1vv4aem-View-large-item e19lxcc00"
49
49
  data-wp-c16t="true"
50
50
  data-wp-component="Item"
51
51
  >
@@ -74,7 +74,7 @@ exports[`ItemGroup ItemGroup component should render correctly 1`] = `
74
74
  }
75
75
 
76
76
  .emotion-3 {
77
- padding: calc((36px - calc(13px * 1.2) - 2px) / 2) 12px;
77
+ padding: calc((36px - calc(13px * 1.4) - 2px) / 2) 12px;
78
78
  box-sizing: border-box;
79
79
  width: 100%;
80
80
  display: block;
@@ -125,8 +125,8 @@ Snapshot Diff:
125
125
  role="listitem"
126
126
  >
127
127
  <div
128
- - class="components-item css-ufjlmj-View-medium-item-spacedAround e19lxcc00"
129
- + class="components-item css-cl593w-View-medium-item e19lxcc00"
128
+ - class="components-item css-1n28wmo-View-medium-item-spacedAround e19lxcc00"
129
+ + class="components-item css-1lf4kzd-View-medium-item e19lxcc00"
130
130
  data-wp-c16t="true"
131
131
  data-wp-component="Item"
132
132
  >
@@ -153,8 +153,8 @@ Snapshot Diff:
153
153
  role="listitem"
154
154
  >
155
155
  <div
156
- - class="components-item css-ufjlmj-View-medium-item-spacedAround e19lxcc00"
157
- + class="components-item css-cl593w-View-medium-item e19lxcc00"
156
+ - class="components-item css-1n28wmo-View-medium-item-spacedAround e19lxcc00"
157
+ + class="components-item css-1lf4kzd-View-medium-item e19lxcc00"
158
158
  data-wp-c16t="true"
159
159
  data-wp-component="Item"
160
160
  >
@@ -10,7 +10,7 @@ However, instead of opening up the selection in a modal, the selection opens up
10
10
  * WordPress dependencies
11
11
  */
12
12
  import { BottomSheetSelectControl } from '@wordpress/components';
13
- import { useState } from '@wordpress/compose';
13
+ import { useState } from 'react';
14
14
 
15
15
  const options = [
16
16
  {
@@ -74,7 +74,7 @@ function NameInput( { value, onChange, label }: NameInputProps ) {
74
74
  }
75
75
 
76
76
  /**
77
- * Returns a name for a palette item in the format "Color + id".
77
+ * Returns a name and slug for a palette item. The name takes the format "Color + id".
78
78
  * To ensure there are no duplicate ids, this function checks all slugs.
79
79
  * It expects slugs to be in the format: slugPrefix + color- + number.
80
80
  * It then sets the id component of the new name based on the incremented id of the highest existing slug id.
@@ -82,9 +82,9 @@ function NameInput( { value, onChange, label }: NameInputProps ) {
82
82
  * @param elements An array of color palette items.
83
83
  * @param slugPrefix The slug prefix used to match the element slug.
84
84
  *
85
- * @return A unique name for a palette item.
85
+ * @return A name and slug for the new palette item.
86
86
  */
87
- export function getNameForPosition(
87
+ export function getNameAndSlugForPosition(
88
88
  elements: PaletteElement[],
89
89
  slugPrefix: string
90
90
  ) {
@@ -102,11 +102,14 @@ export function getNameForPosition(
102
102
  return previousValue;
103
103
  }, 1 );
104
104
 
105
- return sprintf(
106
- /* translators: %s: is an id for a custom color */
107
- __( 'Color %s' ),
108
- position
109
- );
105
+ return {
106
+ name: sprintf(
107
+ /* translators: %s: is an id for a custom color */
108
+ __( 'Color %s' ),
109
+ position
110
+ ),
111
+ slug: `${ slugPrefix }color-${ position }`,
112
+ };
110
113
  }
111
114
 
112
115
  function ColorPickerPopover< T extends Color | Gradient >( {
@@ -434,20 +437,19 @@ export function PaletteEdit( {
434
437
  : __( 'Add color' )
435
438
  }
436
439
  onClick={ () => {
437
- const optionName = getNameForPosition(
438
- elements,
439
- slugPrefix
440
- );
440
+ const { name, slug } =
441
+ getNameAndSlugForPosition(
442
+ elements,
443
+ slugPrefix
444
+ );
441
445
 
442
446
  if ( !! gradients ) {
443
447
  onChange( [
444
448
  ...gradients,
445
449
  {
446
450
  gradient: DEFAULT_GRADIENT,
447
- name: optionName,
448
- slug:
449
- slugPrefix +
450
- kebabCase( optionName ),
451
+ name,
452
+ slug,
451
453
  },
452
454
  ] );
453
455
  } else {
@@ -455,10 +457,8 @@ export function PaletteEdit( {
455
457
  ...colors,
456
458
  {
457
459
  color: DEFAULT_COLOR,
458
- name: optionName,
459
- slug:
460
- slugPrefix +
461
- kebabCase( optionName ),
460
+ name,
461
+ slug,
462
462
  },
463
463
  ] );
464
464
  }
@@ -480,7 +480,7 @@ export function PaletteEdit( {
480
480
  : __( 'Color options' )
481
481
  }
482
482
  toggleProps={ {
483
- isSmall: true,
483
+ size: 'small',
484
484
  } }
485
485
  >
486
486
  { ( { onClose }: { onClose: () => void } ) => (