@wordpress/components 25.12.0 → 25.13.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.
- package/CHANGELOG.md +28 -0
- package/build/angle-picker-control/index.js +0 -1
- package/build/angle-picker-control/index.js.map +1 -1
- package/build/custom-select-control-v2/index.js +87 -0
- package/build/custom-select-control-v2/index.js.map +1 -0
- package/build/custom-select-control-v2/styles.js +85 -0
- package/build/custom-select-control-v2/styles.js.map +1 -0
- package/build/custom-select-control-v2/types.js +6 -0
- package/build/custom-select-control-v2/types.js.map +1 -0
- package/build/dropdown-menu-v2-ariakit/index.js +49 -20
- package/build/dropdown-menu-v2-ariakit/index.js.map +1 -1
- package/build/dropdown-menu-v2-ariakit/styles.js +82 -59
- package/build/dropdown-menu-v2-ariakit/styles.js.map +1 -1
- package/build/dropdown-menu-v2-ariakit/types.js.map +1 -1
- package/build/form-token-field/index.js +6 -2
- package/build/form-token-field/index.js.map +1 -1
- package/build/form-token-field/token-input.js.map +1 -1
- package/build/form-token-field/types.js.map +1 -1
- package/build/heading/hook.js +6 -3
- package/build/heading/hook.js.map +1 -1
- package/build/heading/types.js.map +1 -1
- package/build/mobile/utils/alignments.native.js +1 -1
- package/build/mobile/utils/alignments.native.js.map +1 -1
- package/build/private-apis.js +3 -2
- package/build/private-apis.js.map +1 -1
- package/build/slot-fill/types.js.map +1 -1
- package/build/tabs/index.js +6 -4
- package/build/tabs/index.js.map +1 -1
- package/build/tabs/tab.js +2 -2
- package/build/tabs/tab.js.map +1 -1
- package/build/tabs/tabpanel.js +1 -1
- package/build/tabs/tabpanel.js.map +1 -1
- package/build/text/types.js.map +1 -1
- package/build/tools-panel/tools-panel-item/hook.js +5 -1
- package/build/tools-panel/tools-panel-item/hook.js.map +1 -1
- package/build-module/angle-picker-control/index.js +0 -1
- package/build-module/angle-picker-control/index.js.map +1 -1
- package/build-module/custom-select-control-v2/index.js +74 -0
- package/build-module/custom-select-control-v2/index.js.map +1 -0
- package/build-module/custom-select-control-v2/styles.js +71 -0
- package/build-module/custom-select-control-v2/styles.js.map +1 -0
- package/build-module/custom-select-control-v2/types.js +2 -0
- package/build-module/custom-select-control-v2/types.js.map +1 -0
- package/build-module/dropdown-menu-v2-ariakit/index.js +46 -18
- package/build-module/dropdown-menu-v2-ariakit/index.js.map +1 -1
- package/build-module/dropdown-menu-v2-ariakit/styles.js +69 -40
- package/build-module/dropdown-menu-v2-ariakit/styles.js.map +1 -1
- package/build-module/dropdown-menu-v2-ariakit/types.js.map +1 -1
- package/build-module/form-token-field/index.js +6 -2
- package/build-module/form-token-field/index.js.map +1 -1
- package/build-module/form-token-field/token-input.js.map +1 -1
- package/build-module/form-token-field/types.js.map +1 -1
- package/build-module/heading/hook.js +6 -3
- package/build-module/heading/hook.js.map +1 -1
- package/build-module/heading/types.js.map +1 -1
- package/build-module/mobile/utils/alignments.native.js +1 -1
- package/build-module/mobile/utils/alignments.native.js.map +1 -1
- package/build-module/private-apis.js +4 -3
- package/build-module/private-apis.js.map +1 -1
- package/build-module/slot-fill/types.js.map +1 -1
- package/build-module/tabs/index.js +7 -5
- package/build-module/tabs/index.js.map +1 -1
- package/build-module/tabs/tab.js +4 -4
- package/build-module/tabs/tab.js.map +1 -1
- package/build-module/tabs/tabpanel.js +3 -3
- package/build-module/tabs/tabpanel.js.map +1 -1
- package/build-module/text/types.js.map +1 -1
- package/build-module/tools-panel/tools-panel-item/hook.js +6 -2
- package/build-module/tools-panel/tools-panel-item/hook.js.map +1 -1
- package/build-style/style-rtl.css +31 -5
- package/build-style/style.css +31 -5
- package/build-types/angle-picker-control/index.d.ts.map +1 -1
- package/build-types/box-control/stories/index.story.d.ts +1944 -0
- package/build-types/box-control/stories/index.story.d.ts.map +1 -0
- package/build-types/color-palette/styles.d.ts +4 -1
- package/build-types/color-palette/styles.d.ts.map +1 -1
- package/build-types/custom-select-control-v2/index.d.ts +6 -0
- package/build-types/custom-select-control-v2/index.d.ts.map +1 -0
- package/build-types/custom-select-control-v2/stories/index.story.d.ts +19 -0
- package/build-types/custom-select-control-v2/stories/index.story.d.ts.map +1 -0
- package/build-types/custom-select-control-v2/styles.d.ts +47 -0
- package/build-types/custom-select-control-v2/styles.d.ts.map +1 -0
- package/build-types/custom-select-control-v2/types.d.ts +57 -0
- package/build-types/custom-select-control-v2/types.d.ts.map +1 -0
- package/build-types/date-time/date/styles.d.ts +4 -1
- package/build-types/date-time/date/styles.d.ts.map +1 -1
- package/build-types/dropdown-menu-v2-ariakit/index.d.ts +11 -2
- package/build-types/dropdown-menu-v2-ariakit/index.d.ts.map +1 -1
- package/build-types/dropdown-menu-v2-ariakit/stories/index.story.d.ts.map +1 -1
- package/build-types/dropdown-menu-v2-ariakit/styles.d.ts +26 -18
- package/build-types/dropdown-menu-v2-ariakit/styles.d.ts.map +1 -1
- package/build-types/dropdown-menu-v2-ariakit/types.d.ts +0 -6
- package/build-types/dropdown-menu-v2-ariakit/types.d.ts.map +1 -1
- package/build-types/form-token-field/index.d.ts.map +1 -1
- package/build-types/form-token-field/token-input.d.ts.map +1 -1
- package/build-types/form-token-field/types.d.ts +1 -1
- package/build-types/form-token-field/types.d.ts.map +1 -1
- package/build-types/heading/component.d.ts +4 -1
- package/build-types/heading/component.d.ts.map +1 -1
- package/build-types/heading/hook.d.ts.map +1 -1
- package/build-types/heading/types.d.ts +20 -1
- package/build-types/heading/types.d.ts.map +1 -1
- package/build-types/navigation/styles/navigation-styles.d.ts +4 -1
- package/build-types/navigation/styles/navigation-styles.d.ts.map +1 -1
- package/build-types/palette-edit/styles.d.ts +4 -1
- package/build-types/palette-edit/styles.d.ts.map +1 -1
- package/build-types/private-apis.d.ts.map +1 -1
- package/build-types/slot-fill/bubbles-virtually/slot.d.ts +1 -1
- package/build-types/slot-fill/types.d.ts +16 -6
- package/build-types/slot-fill/types.d.ts.map +1 -1
- package/build-types/tabs/index.d.ts +1 -0
- package/build-types/tabs/index.d.ts.map +1 -1
- package/build-types/tabs/stories/index.story.d.ts.map +1 -1
- package/build-types/text/types.d.ts +15 -2
- package/build-types/text/types.d.ts.map +1 -1
- package/build-types/tools-panel/tools-panel-item/hook.d.ts.map +1 -1
- package/package.json +19 -19
- package/src/angle-picker-control/index.tsx +0 -1
- package/src/box-control/stories/index.story.tsx +82 -0
- package/src/button/style.scss +10 -2
- package/src/combobox-control/README.md +1 -3
- package/src/custom-select-control-v2/README.md +73 -0
- package/src/custom-select-control-v2/index.tsx +99 -0
- package/src/custom-select-control-v2/stories/index.story.tsx +149 -0
- package/src/custom-select-control-v2/styles.ts +76 -0
- package/src/custom-select-control-v2/types.ts +63 -0
- package/src/dropdown-menu-v2-ariakit/README.md +19 -5
- package/src/dropdown-menu-v2-ariakit/index.tsx +85 -36
- package/src/dropdown-menu-v2-ariakit/stories/index.story.tsx +204 -90
- package/src/dropdown-menu-v2-ariakit/styles.ts +153 -117
- package/src/dropdown-menu-v2-ariakit/test/index.tsx +5 -10
- package/src/dropdown-menu-v2-ariakit/types.ts +0 -7
- package/src/form-toggle/style.scss +37 -7
- package/src/form-token-field/index.tsx +11 -3
- package/src/form-token-field/token-input.tsx +1 -3
- package/src/form-token-field/types.ts +1 -0
- package/src/heading/README.md +6 -1
- package/src/heading/hook.ts +6 -3
- package/src/heading/types.ts +23 -1
- package/src/mobile/utils/alignments.native.js +1 -0
- package/src/navigable-container/README.md +1 -1
- package/src/private-apis.ts +4 -2
- package/src/slot-fill/README.md +1 -1
- package/src/slot-fill/types.ts +18 -6
- package/src/tabs/index.tsx +12 -2
- package/src/tabs/stories/index.story.tsx +8 -0
- package/src/tabs/tab.tsx +4 -4
- package/src/tabs/tabpanel.tsx +3 -3
- package/src/tabs/test/index.tsx +19 -0
- package/src/text/README.md +5 -1
- package/src/text/types.ts +15 -2
- package/src/toggle-control/README.md +2 -2
- package/src/tools-panel/tools-panel-item/hook.ts +11 -2
- package/tsconfig.tsbuildinfo +1 -1
- package/src/box-control/stories/index.story.js +0 -75
|
@@ -12,6 +12,7 @@ import styled from '@emotion/styled';
|
|
|
12
12
|
import { COLORS, font, rtl, CONFIG } from '../utils';
|
|
13
13
|
import { space } from '../utils/space';
|
|
14
14
|
import Icon from '../icon';
|
|
15
|
+
import { Truncate } from '../truncate';
|
|
15
16
|
import type { DropdownMenuContext } from './types';
|
|
16
17
|
|
|
17
18
|
const ANIMATION_PARAMS = {
|
|
@@ -20,13 +21,16 @@ const ANIMATION_PARAMS = {
|
|
|
20
21
|
EASING: 'cubic-bezier( 0.16, 1, 0.3, 1 )',
|
|
21
22
|
};
|
|
22
23
|
|
|
23
|
-
const CONTENT_WRAPPER_PADDING = space(
|
|
24
|
-
const
|
|
25
|
-
const
|
|
26
|
-
const ITEM_PADDING_INLINE_END = space( 2.5 );
|
|
24
|
+
const CONTENT_WRAPPER_PADDING = space( 1 );
|
|
25
|
+
const ITEM_PADDING_BLOCK = space( 2 );
|
|
26
|
+
const ITEM_PADDING_INLINE = space( 3 );
|
|
27
27
|
|
|
28
|
-
// TODO:
|
|
29
|
-
|
|
28
|
+
// TODO:
|
|
29
|
+
// - those values are different from saved variables?
|
|
30
|
+
// - should bring this into the config, and make themeable
|
|
31
|
+
// - border color and divider color are different?
|
|
32
|
+
const DEFAULT_BORDER_COLOR = COLORS.gray[ 300 ];
|
|
33
|
+
const DIVIDER_COLOR = COLORS.gray[ 200 ];
|
|
30
34
|
const TOOLBAR_VARIANT_BORDER_COLOR = COLORS.gray[ '900' ];
|
|
31
35
|
const DEFAULT_BOX_SHADOW = `0 0 0 ${ CONFIG.borderWidth } ${ DEFAULT_BORDER_COLOR }, ${ CONFIG.popoverShadow }`;
|
|
32
36
|
const TOOLBAR_VARIANT_BOX_SHADOW = `0 0 0 ${ CONFIG.borderWidth } ${ TOOLBAR_VARIANT_BORDER_COLOR }`;
|
|
@@ -71,12 +75,18 @@ export const DropdownMenu = styled( Ariakit.Menu )<
|
|
|
71
75
|
/* TODO: is there a way to read the sass variable? */
|
|
72
76
|
z-index: 1000000;
|
|
73
77
|
|
|
74
|
-
|
|
78
|
+
display: grid;
|
|
79
|
+
grid-template-columns: minmax( 0, max-content ) 1fr;
|
|
80
|
+
grid-template-rows: auto;
|
|
81
|
+
|
|
82
|
+
box-sizing: border-box;
|
|
83
|
+
min-width: 160px;
|
|
84
|
+
max-width: 320px;
|
|
75
85
|
max-height: var( --popover-available-height );
|
|
76
86
|
padding: ${ CONTENT_WRAPPER_PADDING };
|
|
77
87
|
|
|
78
88
|
background-color: ${ COLORS.ui.background };
|
|
79
|
-
border-radius:
|
|
89
|
+
border-radius: 4px;
|
|
80
90
|
${ ( props ) => css`
|
|
81
91
|
box-shadow: ${ props.variant === 'toolbar'
|
|
82
92
|
? TOOLBAR_VARIANT_BOX_SHADOW
|
|
@@ -110,102 +120,55 @@ export const DropdownMenu = styled( Ariakit.Menu )<
|
|
|
110
120
|
}
|
|
111
121
|
`;
|
|
112
122
|
|
|
113
|
-
const
|
|
114
|
-
|
|
115
|
-
width: ${ ITEM_PREFIX_WIDTH } !important;
|
|
116
|
-
/* !important is to override some inline styles set by Ariakit */
|
|
117
|
-
height: auto !important;
|
|
118
|
-
display: inline-flex;
|
|
119
|
-
align-items: center;
|
|
120
|
-
justify-content: center;
|
|
121
|
-
/* Prefixes don't get affected by the item's inline start padding */
|
|
122
|
-
margin-inline-start: calc( -1 * ${ ITEM_PADDING_INLINE_START } );
|
|
123
|
-
/*
|
|
124
|
-
Negative margin allows the suffix to be as tall as the whole item
|
|
125
|
-
(incl. padding) before increasing the items' height. This can be useful,
|
|
126
|
-
e.g., when using icons that are bigger than 20x20 px
|
|
127
|
-
*/
|
|
128
|
-
margin-top: ${ space( -2 ) };
|
|
129
|
-
margin-bottom: ${ space( -2 ) };
|
|
130
|
-
`;
|
|
131
|
-
|
|
132
|
-
const itemSuffix = css`
|
|
133
|
-
width: max-content;
|
|
134
|
-
display: inline-flex;
|
|
135
|
-
align-items: center;
|
|
136
|
-
justify-content: center;
|
|
137
|
-
/* Push prefix to the inline-end of the item */
|
|
138
|
-
margin-inline-start: auto;
|
|
139
|
-
/* Minimum space between the item's content and suffix */
|
|
140
|
-
padding-inline-start: ${ space( 6 ) };
|
|
141
|
-
/*
|
|
142
|
-
Negative margin allows the suffix to be as tall as the whole item
|
|
143
|
-
(incl. padding) before increasing the items' height. This can be useful,
|
|
144
|
-
e.g., when using icons that are bigger than 20x20 px
|
|
145
|
-
*/
|
|
146
|
-
margin-top: ${ space( -2 ) };
|
|
147
|
-
margin-bottom: ${ space( -2 ) };
|
|
148
|
-
|
|
149
|
-
/*
|
|
150
|
-
Override color in normal conditions, but inherit the item's color
|
|
151
|
-
for altered conditions.
|
|
152
|
-
|
|
153
|
-
TODO:
|
|
154
|
-
- For now, used opacity like for disabled item, which makes it work
|
|
155
|
-
regardless of the theme
|
|
156
|
-
- how do we translate this for themes? Should we have a new variable
|
|
157
|
-
for "secondary" text?
|
|
158
|
-
*/
|
|
159
|
-
opacity: 0.6;
|
|
123
|
+
const baseItem = css`
|
|
124
|
+
all: unset;
|
|
160
125
|
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
[aria-expanded='true'] > &,
|
|
165
|
-
/* when the parent item is disabled */
|
|
166
|
-
[aria-disabled='true'] > & {
|
|
167
|
-
opacity: 1;
|
|
168
|
-
}
|
|
169
|
-
`;
|
|
126
|
+
position: relative;
|
|
127
|
+
min-height: ${ space( 10 ) };
|
|
128
|
+
box-sizing: border-box;
|
|
170
129
|
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
`;
|
|
130
|
+
/* Occupy the width of all grid columns (ie. full width) */
|
|
131
|
+
grid-column: 1 / -1;
|
|
174
132
|
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
133
|
+
/*
|
|
134
|
+
* Define a grid layout which inherits the same columns configuration
|
|
135
|
+
* from the parent layout (ie. subgrid).
|
|
136
|
+
*/
|
|
137
|
+
display: grid;
|
|
138
|
+
grid-template-columns: subgrid;
|
|
139
|
+
align-items: center;
|
|
178
140
|
|
|
179
|
-
const baseItem = css`
|
|
180
|
-
all: unset;
|
|
181
141
|
font-size: ${ font( 'default.fontSize' ) };
|
|
182
142
|
font-family: inherit;
|
|
183
143
|
font-weight: normal;
|
|
184
144
|
line-height: 20px;
|
|
145
|
+
|
|
185
146
|
color: ${ COLORS.gray[ 900 ] };
|
|
186
147
|
border-radius: ${ CONFIG.radiusBlockUi };
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
padding: ${
|
|
190
|
-
|
|
191
|
-
|
|
148
|
+
|
|
149
|
+
padding-block: ${ ITEM_PADDING_BLOCK };
|
|
150
|
+
padding-inline: ${ ITEM_PADDING_INLINE };
|
|
151
|
+
|
|
152
|
+
/*
|
|
153
|
+
* Make sure that, when an item is scrolled into view (eg. while using the
|
|
154
|
+
* keyboard to move focus), the whole item comes into view
|
|
155
|
+
*/
|
|
156
|
+
scroll-margin: ${ CONTENT_WRAPPER_PADDING };
|
|
157
|
+
|
|
192
158
|
user-select: none;
|
|
193
159
|
outline: none;
|
|
194
160
|
|
|
195
161
|
&[aria-disabled='true'] {
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
- we need a disabled color in the Theme variables
|
|
199
|
-
- design specs use opacity instead of setting a new text color
|
|
200
|
-
*/
|
|
201
|
-
opacity: 0.5;
|
|
202
|
-
pointer-events: none;
|
|
162
|
+
color: ${ COLORS.ui.textDisabled };
|
|
163
|
+
cursor: not-allowed;
|
|
203
164
|
}
|
|
204
165
|
|
|
205
166
|
/* Hover */
|
|
206
|
-
&[data-active-item]
|
|
207
|
-
|
|
208
|
-
|
|
167
|
+
&[data-active-item]:not( [data-focus-visible] ):not(
|
|
168
|
+
[aria-disabled='true']
|
|
169
|
+
) {
|
|
170
|
+
background-color: ${ COLORS.theme.accent };
|
|
171
|
+
color: ${ COLORS.white };
|
|
209
172
|
}
|
|
210
173
|
|
|
211
174
|
/* Keyboard focus (focus-visible) */
|
|
@@ -224,74 +187,147 @@ const baseItem = css`
|
|
|
224
187
|
|
|
225
188
|
/* When the item is the trigger of an open submenu */
|
|
226
189
|
${ DropdownMenu }:not(:focus) &:not(:focus)[aria-expanded="true"] {
|
|
227
|
-
|
|
190
|
+
background-color: ${ COLORS.gray[ 100 ] };
|
|
191
|
+
color: ${ COLORS.gray[ 900 ] };
|
|
228
192
|
}
|
|
229
193
|
|
|
230
194
|
svg {
|
|
231
195
|
fill: currentColor;
|
|
232
196
|
}
|
|
233
|
-
|
|
234
|
-
&:not( :has( ${ ItemPrefixWrapper } ) ) {
|
|
235
|
-
padding-inline-start: ${ ITEM_PREFIX_WIDTH };
|
|
236
|
-
}
|
|
237
197
|
`;
|
|
238
198
|
|
|
239
199
|
export const DropdownMenuItem = styled( Ariakit.MenuItem )`
|
|
240
|
-
${ baseItem }
|
|
200
|
+
${ baseItem };
|
|
241
201
|
`;
|
|
242
202
|
|
|
243
203
|
export const DropdownMenuCheckboxItem = styled( Ariakit.MenuItemCheckbox )`
|
|
244
|
-
${ baseItem }
|
|
204
|
+
${ baseItem };
|
|
245
205
|
`;
|
|
246
206
|
|
|
247
207
|
export const DropdownMenuRadioItem = styled( Ariakit.MenuItemRadio )`
|
|
248
|
-
${ baseItem }
|
|
208
|
+
${ baseItem };
|
|
249
209
|
`;
|
|
250
210
|
|
|
251
|
-
export const
|
|
211
|
+
export const ItemPrefixWrapper = styled.span`
|
|
212
|
+
/* Always occupy the first column, even when auto-collapsing */
|
|
213
|
+
grid-column: 1;
|
|
214
|
+
|
|
215
|
+
&:not( :empty ) {
|
|
216
|
+
margin-inline-end: ${ space( 2 ) };
|
|
217
|
+
}
|
|
252
218
|
|
|
253
|
-
export const DropdownMenuGroupLabel = styled( Ariakit.MenuGroupLabel )`
|
|
254
|
-
box-sizing: border-box;
|
|
255
219
|
display: flex;
|
|
256
220
|
align-items: center;
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
/*
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
221
|
+
justify-content: center;
|
|
222
|
+
|
|
223
|
+
color: ${ COLORS.gray[ '700' ] };
|
|
224
|
+
|
|
225
|
+
/*
|
|
226
|
+
* When the parent menu item is active, except when it's a non-focused/hovered
|
|
227
|
+
* submenu trigger (in that case, color should not be inherited)
|
|
228
|
+
*/
|
|
229
|
+
[data-active-item]:not( [data-focus-visible] ) > &,
|
|
230
|
+
/* When the parent menu item is disabled */
|
|
231
|
+
[aria-disabled='true'] > & {
|
|
232
|
+
color: inherit;
|
|
233
|
+
}
|
|
234
|
+
`;
|
|
235
|
+
|
|
236
|
+
export const DropdownMenuItemContentWrapper = styled.div`
|
|
237
|
+
/*
|
|
238
|
+
* Always occupy the second column, since the first column
|
|
239
|
+
* is taken by the prefix wrapper (when displayed).
|
|
240
|
+
*/
|
|
241
|
+
grid-column: 2;
|
|
242
|
+
|
|
243
|
+
display: flex;
|
|
244
|
+
align-items: center;
|
|
245
|
+
justify-content: space-between;
|
|
246
|
+
gap: ${ space( 3 ) };
|
|
247
|
+
|
|
248
|
+
pointer-events: none;
|
|
249
|
+
`;
|
|
250
|
+
|
|
251
|
+
export const DropdownMenuItemChildrenWrapper = styled.div`
|
|
252
|
+
flex: 1;
|
|
253
|
+
|
|
254
|
+
display: inline-flex;
|
|
255
|
+
flex-direction: column;
|
|
256
|
+
gap: ${ space( 1 ) };
|
|
257
|
+
`;
|
|
258
|
+
|
|
259
|
+
export const ItemSuffixWrapper = styled.span`
|
|
260
|
+
flex: 0;
|
|
261
|
+
width: max-content;
|
|
262
|
+
|
|
263
|
+
display: flex;
|
|
264
|
+
align-items: center;
|
|
265
|
+
justify-content: center;
|
|
266
|
+
gap: ${ space( 3 ) };
|
|
267
|
+
|
|
268
|
+
color: ${ COLORS.gray[ '700' ] };
|
|
269
|
+
|
|
270
|
+
/*
|
|
271
|
+
* When the parent menu item is active, except when it's a non-focused/hovered
|
|
272
|
+
* submenu trigger (in that case, color should not be inherited)
|
|
273
|
+
*/
|
|
274
|
+
[data-active-item]:not( [data-focus-visible] ) *:not(${ DropdownMenu }) &,
|
|
275
|
+
/* When the parent menu item is disabled */
|
|
276
|
+
[aria-disabled='true'] *:not(${ DropdownMenu }) & {
|
|
277
|
+
color: inherit;
|
|
278
|
+
}
|
|
279
|
+
`;
|
|
280
|
+
|
|
281
|
+
export const DropdownMenuGroup = styled( Ariakit.MenuGroup )`
|
|
282
|
+
/* Ignore this element when calculating the layout. Useful for subgrid */
|
|
283
|
+
display: contents;
|
|
269
284
|
`;
|
|
270
285
|
|
|
271
286
|
export const DropdownMenuSeparator = styled( Ariakit.MenuSeparator )<
|
|
272
287
|
Pick< DropdownMenuContext, 'variant' >
|
|
273
288
|
>`
|
|
289
|
+
/* Occupy the width of all grid columns (ie. full width) */
|
|
290
|
+
grid-column: 1 / -1;
|
|
291
|
+
|
|
274
292
|
border: none;
|
|
275
293
|
height: ${ CONFIG.borderWidth };
|
|
276
|
-
/* TODO: doesn't match border color from variables */
|
|
277
294
|
background-color: ${ ( props ) =>
|
|
278
295
|
props.variant === 'toolbar'
|
|
279
296
|
? TOOLBAR_VARIANT_BORDER_COLOR
|
|
280
|
-
:
|
|
281
|
-
/*
|
|
282
|
-
margin: ${ space( 2 ) }
|
|
297
|
+
: DIVIDER_COLOR };
|
|
298
|
+
/* Align with menu items' content */
|
|
299
|
+
margin-block: ${ space( 2 ) };
|
|
300
|
+
margin-inline: ${ ITEM_PADDING_INLINE };
|
|
283
301
|
|
|
284
302
|
/* Only visible in Windows High Contrast mode */
|
|
285
303
|
outline: 2px solid transparent;
|
|
286
304
|
`;
|
|
287
305
|
|
|
288
306
|
export const SubmenuChevronIcon = styled( Icon )`
|
|
307
|
+
width: ${ space( 1.5 ) };
|
|
289
308
|
${ rtl(
|
|
290
309
|
{
|
|
291
|
-
transform: `scaleX(1)
|
|
310
|
+
transform: `scaleX(1)`,
|
|
292
311
|
},
|
|
293
312
|
{
|
|
294
|
-
transform: `scaleX(-1)
|
|
313
|
+
transform: `scaleX(-1)`,
|
|
295
314
|
}
|
|
296
|
-
) }
|
|
315
|
+
) };
|
|
316
|
+
`;
|
|
317
|
+
|
|
318
|
+
export const DropdownMenuItemLabel = styled( Truncate )`
|
|
319
|
+
font-size: ${ font( 'default.fontSize' ) };
|
|
320
|
+
line-height: 20px;
|
|
321
|
+
color: inherit;
|
|
322
|
+
`;
|
|
323
|
+
|
|
324
|
+
export const DropdownMenuItemHelpText = styled( Truncate )`
|
|
325
|
+
font-size: ${ font( 'helpText.fontSize' ) };
|
|
326
|
+
line-height: 16px;
|
|
327
|
+
color: ${ COLORS.gray[ '700' ] };
|
|
328
|
+
|
|
329
|
+
[data-active-item]:not( [data-focus-visible] ) *:not( ${ DropdownMenu } ) &,
|
|
330
|
+
[aria-disabled='true'] *:not( ${ DropdownMenu } ) & {
|
|
331
|
+
color: inherit;
|
|
332
|
+
}
|
|
297
333
|
`;
|
|
@@ -16,7 +16,6 @@ import {
|
|
|
16
16
|
DropdownMenu,
|
|
17
17
|
DropdownMenuCheckboxItem,
|
|
18
18
|
DropdownMenuItem,
|
|
19
|
-
DropdownMenuGroupLabel,
|
|
20
19
|
DropdownMenuRadioItem,
|
|
21
20
|
DropdownMenuSeparator,
|
|
22
21
|
DropdownMenuGroup,
|
|
@@ -134,8 +133,9 @@ describe( 'DropdownMenu', () => {
|
|
|
134
133
|
await press.ArrowDown();
|
|
135
134
|
|
|
136
135
|
// DropdownMenu open, focus is on the first focusable item
|
|
136
|
+
// (disabled items are still focusable and accessible)
|
|
137
137
|
expect(
|
|
138
|
-
screen.getByRole( 'menuitem', { name: '
|
|
138
|
+
screen.getByRole( 'menuitem', { name: 'First item' } )
|
|
139
139
|
).toHaveFocus();
|
|
140
140
|
} );
|
|
141
141
|
|
|
@@ -163,8 +163,9 @@ describe( 'DropdownMenu', () => {
|
|
|
163
163
|
await press.Space();
|
|
164
164
|
|
|
165
165
|
// DropdownMenu open, focus is on the first focusable item
|
|
166
|
+
// (disabled items are still focusable and accessible
|
|
166
167
|
expect(
|
|
167
|
-
screen.getByRole( 'menuitem', { name: '
|
|
168
|
+
screen.getByRole( 'menuitem', { name: 'First item' } )
|
|
168
169
|
).toHaveFocus();
|
|
169
170
|
} );
|
|
170
171
|
|
|
@@ -452,9 +453,6 @@ describe( 'DropdownMenu', () => {
|
|
|
452
453
|
return (
|
|
453
454
|
<DropdownMenu trigger={ <button>Open dropdown</button> }>
|
|
454
455
|
<DropdownMenuGroup>
|
|
455
|
-
<DropdownMenuGroupLabel>
|
|
456
|
-
Radio group label
|
|
457
|
-
</DropdownMenuGroupLabel>
|
|
458
456
|
<DropdownMenuRadioItem
|
|
459
457
|
name="radio-test"
|
|
460
458
|
value="radio-one"
|
|
@@ -532,9 +530,6 @@ describe( 'DropdownMenu', () => {
|
|
|
532
530
|
render(
|
|
533
531
|
<DropdownMenu trigger={ <button>Open dropdown</button> }>
|
|
534
532
|
<DropdownMenuGroup>
|
|
535
|
-
<DropdownMenuGroupLabel>
|
|
536
|
-
Radio group label
|
|
537
|
-
</DropdownMenuGroupLabel>
|
|
538
533
|
<DropdownMenuRadioItem
|
|
539
534
|
name="radio-test"
|
|
540
535
|
value="radio-one"
|
|
@@ -991,7 +986,7 @@ describe( 'DropdownMenu', () => {
|
|
|
991
986
|
// The contents of the suffix are rendered after the item's children
|
|
992
987
|
expect(
|
|
993
988
|
screen.getByRole( 'menuitemradio', {
|
|
994
|
-
name: 'Radio item
|
|
989
|
+
name: 'Radio item one Radio suffix',
|
|
995
990
|
} )
|
|
996
991
|
).toBeInTheDocument();
|
|
997
992
|
} );
|
|
@@ -88,13 +88,6 @@ export interface DropdownMenuGroupProps {
|
|
|
88
88
|
children: React.ReactNode;
|
|
89
89
|
}
|
|
90
90
|
|
|
91
|
-
export interface DropdownMenuGroupLabelProps {
|
|
92
|
-
/**
|
|
93
|
-
* The contents of the dropdown menu group label.
|
|
94
|
-
*/
|
|
95
|
-
children: React.ReactNode;
|
|
96
|
-
}
|
|
97
|
-
|
|
98
91
|
export interface DropdownMenuItemProps {
|
|
99
92
|
/**
|
|
100
93
|
* The contents of the menu item.
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
$toggle-width: 36px;
|
|
2
2
|
$toggle-height: 18px;
|
|
3
3
|
$toggle-border-width: 1px;
|
|
4
|
+
$thumb-size: $toggle-height - ($toggle-border-width * 6);
|
|
5
|
+
|
|
6
|
+
$transition-duration: 0.2s;
|
|
4
7
|
|
|
5
8
|
.components-form-toggle {
|
|
6
9
|
position: relative;
|
|
@@ -8,6 +11,7 @@ $toggle-border-width: 1px;
|
|
|
8
11
|
|
|
9
12
|
// Unchecked state.
|
|
10
13
|
.components-form-toggle__track {
|
|
14
|
+
position: relative;
|
|
11
15
|
content: "";
|
|
12
16
|
display: inline-block;
|
|
13
17
|
box-sizing: border-box;
|
|
@@ -17,8 +21,26 @@ $toggle-border-width: 1px;
|
|
|
17
21
|
width: $toggle-width;
|
|
18
22
|
height: $toggle-height;
|
|
19
23
|
border-radius: $toggle-height * 0.5;
|
|
20
|
-
transition:
|
|
24
|
+
transition:
|
|
25
|
+
$transition-duration background-color ease,
|
|
26
|
+
$transition-duration border-color ease;
|
|
21
27
|
@include reduce-motion("transition");
|
|
28
|
+
overflow: hidden;
|
|
29
|
+
|
|
30
|
+
// Windows High Contrast Mode
|
|
31
|
+
&::after {
|
|
32
|
+
content: "";
|
|
33
|
+
position: absolute;
|
|
34
|
+
inset: 0;
|
|
35
|
+
box-sizing: border-box;
|
|
36
|
+
// Expand the border to fake a solid in Windows High Contrast Mode.
|
|
37
|
+
border-top: #{ $toggle-height } solid transparent;
|
|
38
|
+
|
|
39
|
+
transition: $transition-duration opacity ease;
|
|
40
|
+
@include reduce-motion("transition");
|
|
41
|
+
|
|
42
|
+
opacity: 0;
|
|
43
|
+
}
|
|
22
44
|
}
|
|
23
45
|
|
|
24
46
|
.components-form-toggle__thumb {
|
|
@@ -27,20 +49,28 @@ $toggle-border-width: 1px;
|
|
|
27
49
|
box-sizing: border-box;
|
|
28
50
|
top: $toggle-border-width * 3;
|
|
29
51
|
left: $toggle-border-width * 3;
|
|
30
|
-
width: $
|
|
31
|
-
height: $
|
|
52
|
+
width: $thumb-size;
|
|
53
|
+
height: $thumb-size;
|
|
32
54
|
border-radius: 50%;
|
|
33
|
-
transition:
|
|
55
|
+
transition:
|
|
56
|
+
$transition-duration transform ease,
|
|
57
|
+
$transition-duration background-color ease-out;
|
|
34
58
|
@include reduce-motion("transition");
|
|
35
59
|
background-color: $gray-900;
|
|
36
|
-
|
|
60
|
+
|
|
61
|
+
// Transparent border acts as a fill in Windows High Contrast Mode.
|
|
62
|
+
border: $thumb-size / 2 solid transparent;
|
|
37
63
|
}
|
|
38
64
|
|
|
39
65
|
// Checked state.
|
|
40
66
|
&.is-checked .components-form-toggle__track {
|
|
41
67
|
background-color: $components-color-accent;
|
|
42
|
-
border: $
|
|
43
|
-
|
|
68
|
+
border-color: $components-color-accent;
|
|
69
|
+
|
|
70
|
+
// Windows High Contrast Mode
|
|
71
|
+
&::after {
|
|
72
|
+
opacity: 1;
|
|
73
|
+
}
|
|
44
74
|
}
|
|
45
75
|
|
|
46
76
|
.components-form-toggle__input:focus + .components-form-toggle__track {
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* External dependencies
|
|
3
3
|
*/
|
|
4
4
|
import classnames from 'classnames';
|
|
5
|
-
import type { KeyboardEvent, MouseEvent, TouchEvent } from 'react';
|
|
5
|
+
import type { KeyboardEvent, MouseEvent, TouchEvent, FocusEvent } from 'react';
|
|
6
6
|
|
|
7
7
|
/**
|
|
8
8
|
* WordPress dependencies
|
|
@@ -162,7 +162,7 @@ export function FormTokenField( props: FormTokenFieldProps ) {
|
|
|
162
162
|
}
|
|
163
163
|
}
|
|
164
164
|
|
|
165
|
-
function onBlur() {
|
|
165
|
+
function onBlur( event: FocusEvent ) {
|
|
166
166
|
if (
|
|
167
167
|
inputHasValidValue() &&
|
|
168
168
|
__experimentalValidateInput( incompleteTokenValue )
|
|
@@ -176,7 +176,15 @@ export function FormTokenField( props: FormTokenFieldProps ) {
|
|
|
176
176
|
setIncompleteTokenValue( '' );
|
|
177
177
|
setInputOffsetFromEnd( 0 );
|
|
178
178
|
setIsActive( false );
|
|
179
|
-
|
|
179
|
+
|
|
180
|
+
// If `__experimentalExpandOnFocus` is true, don't close the suggestions list when
|
|
181
|
+
// the user clicks on it (`tokensAndInput` will be the element that caused the blur).
|
|
182
|
+
const shouldKeepSuggestionsExpanded =
|
|
183
|
+
! __experimentalExpandOnFocus ||
|
|
184
|
+
( __experimentalExpandOnFocus &&
|
|
185
|
+
event.relatedTarget === tokensAndInput.current );
|
|
186
|
+
setIsExpanded( shouldKeepSuggestionsExpanded );
|
|
187
|
+
|
|
180
188
|
setSelectedSuggestionIndex( -1 );
|
|
181
189
|
setSelectedSuggestionScroll( false );
|
|
182
190
|
}
|
|
@@ -48,9 +48,7 @@ export function UnForwardedTokenInput(
|
|
|
48
48
|
onFocus?.( e );
|
|
49
49
|
};
|
|
50
50
|
|
|
51
|
-
const onBlurHandler:
|
|
52
|
-
e
|
|
53
|
-
) => {
|
|
51
|
+
const onBlurHandler: FocusEventHandler< HTMLInputElement > = ( e ) => {
|
|
54
52
|
setHasFocus( false );
|
|
55
53
|
onBlur?.( e );
|
|
56
54
|
};
|
package/src/heading/README.md
CHANGED
|
@@ -18,7 +18,12 @@ function Example() {
|
|
|
18
18
|
|
|
19
19
|
## Props
|
|
20
20
|
|
|
21
|
-
`Heading` uses `Text` underneath, so we have access to all of `Text`'s props except for
|
|
21
|
+
`Heading` uses `Text` underneath, so we have access to all of `Text`'s props except for:
|
|
22
|
+
|
|
23
|
+
- `size` which is replaced by `level`;
|
|
24
|
+
- `isBlock`'s default value, which is `true` for the `Heading` component.
|
|
25
|
+
|
|
26
|
+
For a complete list of those props, check out [`Text`](/packages/components/src/text/README.md#props).
|
|
22
27
|
|
|
23
28
|
##### `level`: `1 | 2 | 3 | 4 | 5 | 6 | '1' | '2' | '3' | '4' | '5' | '6'`
|
|
24
29
|
|
package/src/heading/hook.ts
CHANGED
|
@@ -14,6 +14,9 @@ export function useHeading(
|
|
|
14
14
|
const {
|
|
15
15
|
as: asProp,
|
|
16
16
|
level = 2,
|
|
17
|
+
color = COLORS.gray[ 900 ],
|
|
18
|
+
isBlock = true,
|
|
19
|
+
weight = CONFIG.fontWeightHeading as import('react').CSSProperties[ 'fontWeight' ],
|
|
17
20
|
...otherProps
|
|
18
21
|
} = useContextSystem( props, 'Heading' );
|
|
19
22
|
|
|
@@ -31,10 +34,10 @@ export function useHeading(
|
|
|
31
34
|
}
|
|
32
35
|
|
|
33
36
|
const textProps = useText( {
|
|
34
|
-
color
|
|
37
|
+
color,
|
|
38
|
+
isBlock,
|
|
39
|
+
weight,
|
|
35
40
|
size: getHeadingFontSize( level ),
|
|
36
|
-
isBlock: true,
|
|
37
|
-
weight: CONFIG.fontWeightHeading as import('react').CSSProperties[ 'fontWeight' ],
|
|
38
41
|
...otherProps,
|
|
39
42
|
} );
|
|
40
43
|
|
package/src/heading/types.ts
CHANGED
|
@@ -17,7 +17,10 @@ export type HeadingSize =
|
|
|
17
17
|
| '5'
|
|
18
18
|
| '6';
|
|
19
19
|
|
|
20
|
-
export type HeadingProps = Omit<
|
|
20
|
+
export type HeadingProps = Omit<
|
|
21
|
+
TextProps,
|
|
22
|
+
'size' | 'isBlock' | 'color' | 'weight'
|
|
23
|
+
> & {
|
|
21
24
|
/**
|
|
22
25
|
* Passing any of the heading levels to `level` will both render the correct
|
|
23
26
|
* typographic text size as well as the semantic element corresponding to
|
|
@@ -26,4 +29,23 @@ export type HeadingProps = Omit< TextProps, 'size' > & {
|
|
|
26
29
|
* @default 2
|
|
27
30
|
*/
|
|
28
31
|
level?: HeadingSize;
|
|
32
|
+
/**
|
|
33
|
+
* Sets `Heading` to have `display: block`. Note: text truncation only works
|
|
34
|
+
* when `isBlock` is `false`.
|
|
35
|
+
*
|
|
36
|
+
* @default true
|
|
37
|
+
*/
|
|
38
|
+
isBlock?: TextProps[ 'isBlock' ];
|
|
39
|
+
/**
|
|
40
|
+
* Adjusts the text color.
|
|
41
|
+
*
|
|
42
|
+
* @default '#1e1e1e'
|
|
43
|
+
*/
|
|
44
|
+
color?: TextProps[ 'color' ];
|
|
45
|
+
/**
|
|
46
|
+
* Adjusts font-weight of the text.
|
|
47
|
+
*
|
|
48
|
+
* @default '600'
|
|
49
|
+
*/
|
|
50
|
+
weight?: TextProps[ 'weight' ];
|
|
29
51
|
};
|