@wordpress/components 25.11.1-next.f8d8eceb.0 → 25.12.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 +30 -1
- package/build/disclosure/index.js +37 -7
- package/build/disclosure/index.js.map +1 -1
- package/build/disclosure/types.js +6 -0
- package/build/disclosure/types.js.map +1 -0
- package/build/divider/component.js +5 -3
- package/build/divider/component.js.map +1 -1
- package/build/divider/types.js.map +1 -1
- package/build/dropdown-menu-v2-ariakit/index.js +26 -16
- package/build/dropdown-menu-v2-ariakit/index.js.map +1 -1
- package/build/dropdown-menu-v2-ariakit/types.js.map +1 -1
- package/build/gradient-picker/index.js +1 -1
- package/build/gradient-picker/index.js.map +1 -1
- package/build/index.native.js +8 -1
- package/build/index.native.js.map +1 -1
- package/build/mobile/audio-player/index.native.js +8 -9
- package/build/mobile/audio-player/index.native.js.map +1 -1
- package/build/mobile/global-styles-context/utils.native.js +44 -3
- package/build/mobile/global-styles-context/utils.native.js.map +1 -1
- package/build/radio-group/context.js +22 -0
- package/build/radio-group/context.js.map +1 -0
- package/build/radio-group/index.js +27 -23
- package/build/radio-group/index.js.map +1 -1
- package/build/radio-group/radio.js +58 -0
- package/build/radio-group/radio.js.map +1 -0
- package/build/radio-group/types.js +6 -0
- package/build/radio-group/types.js.map +1 -0
- package/build/slot-fill/bubbles-virtually/slot-fill-provider.js +1 -1
- package/build/slot-fill/bubbles-virtually/slot-fill-provider.js.map +1 -1
- package/build/tabs/styles.js +14 -7
- package/build/tabs/styles.js.map +1 -1
- package/build/tabs/tab.js +3 -5
- package/build/tabs/tab.js.map +1 -1
- package/build/tabs/tablist.js +3 -5
- package/build/tabs/tablist.js.map +1 -1
- package/build/tabs/tabpanel.js +6 -9
- package/build/tabs/tabpanel.js.map +1 -1
- package/build/tabs/types.js.map +1 -1
- package/build/text-control/index.js +5 -1
- package/build/text-control/index.js.map +1 -1
- package/build/text-control/types.js.map +1 -1
- package/build/toggle-group-control/toggle-group-control/component.js +4 -2
- package/build/toggle-group-control/toggle-group-control/component.js.map +1 -1
- package/build/toggle-group-control/toggle-group-control/styles.js +13 -9
- package/build/toggle-group-control/toggle-group-control/styles.js.map +1 -1
- package/build/toggle-group-control/types.js.map +1 -1
- package/build-module/disclosure/index.js +33 -8
- package/build-module/disclosure/index.js.map +1 -1
- package/build-module/disclosure/types.js +2 -0
- package/build-module/disclosure/types.js.map +1 -0
- package/build-module/divider/component.js +3 -3
- package/build-module/divider/component.js.map +1 -1
- package/build-module/divider/types.js.map +1 -1
- package/build-module/dropdown-menu-v2-ariakit/index.js +27 -17
- package/build-module/dropdown-menu-v2-ariakit/index.js.map +1 -1
- package/build-module/dropdown-menu-v2-ariakit/types.js.map +1 -1
- package/build-module/gradient-picker/index.js +1 -1
- package/build-module/gradient-picker/index.js.map +1 -1
- package/build-module/index.native.js +1 -1
- package/build-module/index.native.js.map +1 -1
- package/build-module/mobile/audio-player/index.native.js +9 -10
- package/build-module/mobile/audio-player/index.native.js.map +1 -1
- package/build-module/mobile/global-styles-context/utils.native.js +43 -4
- package/build-module/mobile/global-styles-context/utils.native.js.map +1 -1
- package/build-module/radio-group/context.js +14 -0
- package/build-module/radio-group/context.js.map +1 -0
- package/build-module/radio-group/index.js +24 -23
- package/build-module/radio-group/index.js.map +1 -1
- package/build-module/radio-group/radio.js +46 -0
- package/build-module/radio-group/radio.js.map +1 -0
- package/build-module/radio-group/types.js +2 -0
- package/build-module/radio-group/types.js.map +1 -0
- package/build-module/slot-fill/bubbles-virtually/slot-fill-provider.js +1 -1
- package/build-module/slot-fill/bubbles-virtually/slot-fill-provider.js.map +1 -1
- package/build-module/tabs/styles.js +11 -5
- package/build-module/tabs/styles.js.map +1 -1
- package/build-module/tabs/tab.js +3 -5
- package/build-module/tabs/tab.js.map +1 -1
- package/build-module/tabs/tablist.js +3 -5
- package/build-module/tabs/tablist.js.map +1 -1
- package/build-module/tabs/tabpanel.js +6 -7
- package/build-module/tabs/tabpanel.js.map +1 -1
- package/build-module/tabs/types.js.map +1 -1
- package/build-module/text-control/index.js +6 -1
- package/build-module/text-control/index.js.map +1 -1
- package/build-module/text-control/types.js.map +1 -1
- package/build-module/toggle-group-control/toggle-group-control/component.js +4 -2
- package/build-module/toggle-group-control/toggle-group-control/component.js.map +1 -1
- package/build-module/toggle-group-control/toggle-group-control/styles.js +13 -9
- package/build-module/toggle-group-control/toggle-group-control/styles.js.map +1 -1
- package/build-module/toggle-group-control/types.js.map +1 -1
- package/build-style/style-rtl.css +21 -3
- package/build-style/style.css +21 -3
- package/build-types/card/card-divider/component.d.ts +1 -1
- package/build-types/card/card-divider/hook.d.ts +162 -162
- package/build-types/disclosure/index.d.ts +7 -1
- package/build-types/disclosure/index.d.ts.map +1 -1
- package/build-types/disclosure/types.d.ts +12 -0
- package/build-types/disclosure/types.d.ts.map +1 -0
- package/build-types/divider/component.d.ts +5 -1
- package/build-types/divider/component.d.ts.map +1 -1
- package/build-types/divider/stories/index.story.d.ts.map +1 -1
- package/build-types/divider/styles.d.ts +1 -1
- package/build-types/divider/types.d.ts +2 -2
- package/build-types/divider/types.d.ts.map +1 -1
- 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/types.d.ts +1 -1
- package/build-types/radio-group/context.d.ts +10 -0
- package/build-types/radio-group/context.d.ts.map +1 -0
- package/build-types/radio-group/index.d.ts +7 -9
- package/build-types/radio-group/index.d.ts.map +1 -1
- package/build-types/radio-group/radio.d.ts +8 -0
- package/build-types/radio-group/radio.d.ts.map +1 -0
- package/build-types/radio-group/stories/index.story.d.ts +14 -0
- package/build-types/radio-group/stories/index.story.d.ts.map +1 -0
- package/build-types/radio-group/types.d.ts +40 -0
- package/build-types/radio-group/types.d.ts.map +1 -0
- package/build-types/tabs/index.d.ts +3 -3
- package/build-types/tabs/stories/index.story.d.ts.map +1 -1
- package/build-types/tabs/styles.d.ts +10 -0
- package/build-types/tabs/styles.d.ts.map +1 -1
- package/build-types/tabs/tab.d.ts +1 -1
- package/build-types/tabs/tab.d.ts.map +1 -1
- package/build-types/tabs/tablist.d.ts +1 -1
- package/build-types/tabs/tablist.d.ts.map +1 -1
- package/build-types/tabs/tabpanel.d.ts +4 -1
- package/build-types/tabs/tabpanel.d.ts.map +1 -1
- package/build-types/tabs/types.d.ts +7 -31
- package/build-types/tabs/types.d.ts.map +1 -1
- package/build-types/text-control/index.d.ts +2 -1
- package/build-types/text-control/index.d.ts.map +1 -1
- package/build-types/text-control/types.d.ts +6 -0
- package/build-types/text-control/types.d.ts.map +1 -1
- package/build-types/toggle-group-control/toggle-group-control/component.d.ts +1 -0
- package/build-types/toggle-group-control/toggle-group-control/component.d.ts.map +1 -1
- package/build-types/toggle-group-control/toggle-group-control/styles.d.ts +2 -2
- package/build-types/toggle-group-control/toggle-group-control/styles.d.ts.map +1 -1
- package/build-types/toggle-group-control/types.d.ts +6 -0
- package/build-types/toggle-group-control/types.d.ts.map +1 -1
- package/package.json +19 -20
- package/src/disclosure/index.tsx +44 -0
- package/src/disclosure/types.tsx +10 -0
- package/src/divider/component.tsx +3 -3
- package/src/divider/stories/index.story.tsx +8 -0
- package/src/divider/types.ts +2 -2
- package/src/dropdown-menu/style.scss +4 -0
- package/src/dropdown-menu-v2-ariakit/README.md +0 -7
- package/src/dropdown-menu-v2-ariakit/index.tsx +31 -15
- package/src/dropdown-menu-v2-ariakit/stories/index.story.tsx +1 -4
- package/src/dropdown-menu-v2-ariakit/test/index.tsx +0 -26
- package/src/dropdown-menu-v2-ariakit/types.ts +1 -1
- package/src/gradient-picker/index.tsx +1 -1
- package/src/index.native.js +1 -0
- package/src/mobile/audio-player/index.native.js +9 -13
- package/src/mobile/global-styles-context/utils.native.js +52 -3
- package/src/radio-group/context.tsx +18 -0
- package/src/radio-group/index.tsx +65 -0
- package/src/radio-group/radio.tsx +55 -0
- package/src/radio-group/stories/index.story.tsx +90 -0
- package/src/radio-group/types.ts +39 -0
- package/src/slot-fill/bubbles-virtually/slot-fill-provider.tsx +1 -1
- package/src/tabs/README.md +3 -33
- package/src/tabs/stories/index.story.tsx +9 -1
- package/src/tabs/styles.ts +16 -0
- package/src/tabs/tab.tsx +6 -6
- package/src/tabs/tablist.tsx +21 -20
- package/src/tabs/tabpanel.tsx +24 -23
- package/src/tabs/test/index.tsx +71 -16
- package/src/tabs/types.ts +7 -32
- package/src/text-control/index.tsx +5 -1
- package/src/text-control/style.scss +5 -0
- package/src/text-control/types.ts +6 -0
- package/src/toggle-group-control/toggle-group-control/component.tsx +8 -2
- package/src/toggle-group-control/toggle-group-control/styles.ts +13 -4
- package/src/toggle-group-control/types.ts +6 -0
- package/src/toolbar/toolbar-button/style.scss +0 -5
- package/tsconfig.tsbuildinfo +1 -1
- package/build/radio-group/radio/index.js +0 -49
- package/build/radio-group/radio/index.js.map +0 -1
- package/build/radio-group/radio-context/index.js +0 -18
- package/build/radio-group/radio-context/index.js.map +0 -1
- package/build-module/radio-group/radio/index.js +0 -40
- package/build-module/radio-group/radio/index.js.map +0 -1
- package/build-module/radio-group/radio-context/index.js +0 -10
- package/build-module/radio-group/radio-context/index.js.map +0 -1
- package/build-types/radio-group/radio/index.d.ts +0 -7
- package/build-types/radio-group/radio/index.d.ts.map +0 -1
- package/build-types/radio-group/radio-context/index.d.ts +0 -6
- package/build-types/radio-group/radio-context/index.d.ts.map +0 -1
- package/src/disclosure/index.js +0 -11
- package/src/radio-group/index.js +0 -51
- package/src/radio-group/radio/index.js +0 -40
- package/src/radio-group/radio-context/index.js +0 -11
- package/src/radio-group/stories/index.story.js +0 -83
package/src/tabs/test/index.tsx
CHANGED
|
@@ -7,7 +7,6 @@ import userEvent from '@testing-library/user-event';
|
|
|
7
7
|
/**
|
|
8
8
|
* WordPress dependencies
|
|
9
9
|
*/
|
|
10
|
-
import { wordpress, category, media } from '@wordpress/icons';
|
|
11
10
|
import { useState } from '@wordpress/element';
|
|
12
11
|
|
|
13
12
|
/**
|
|
@@ -15,7 +14,6 @@ import { useState } from '@wordpress/element';
|
|
|
15
14
|
*/
|
|
16
15
|
import Tabs from '..';
|
|
17
16
|
import type { TabsProps } from '../types';
|
|
18
|
-
import type { IconType } from '../../icon';
|
|
19
17
|
|
|
20
18
|
type Tab = {
|
|
21
19
|
id: string;
|
|
@@ -23,9 +21,11 @@ type Tab = {
|
|
|
23
21
|
content: React.ReactNode;
|
|
24
22
|
tab: {
|
|
25
23
|
className?: string;
|
|
26
|
-
icon?: IconType;
|
|
27
24
|
disabled?: boolean;
|
|
28
25
|
};
|
|
26
|
+
tabpanel?: {
|
|
27
|
+
focusable?: boolean;
|
|
28
|
+
};
|
|
29
29
|
};
|
|
30
30
|
|
|
31
31
|
const TABS: Tab[] = [
|
|
@@ -33,19 +33,19 @@ const TABS: Tab[] = [
|
|
|
33
33
|
id: 'alpha',
|
|
34
34
|
title: 'Alpha',
|
|
35
35
|
content: 'Selected tab: Alpha',
|
|
36
|
-
tab: { className: 'alpha-class'
|
|
36
|
+
tab: { className: 'alpha-class' },
|
|
37
37
|
},
|
|
38
38
|
{
|
|
39
39
|
id: 'beta',
|
|
40
40
|
title: 'Beta',
|
|
41
41
|
content: 'Selected tab: Beta',
|
|
42
|
-
tab: { className: 'beta-class'
|
|
42
|
+
tab: { className: 'beta-class' },
|
|
43
43
|
},
|
|
44
44
|
{
|
|
45
45
|
id: 'gamma',
|
|
46
46
|
title: 'Gamma',
|
|
47
47
|
content: 'Selected tab: Gamma',
|
|
48
|
-
tab: { className: 'gamma-class'
|
|
48
|
+
tab: { className: 'gamma-class' },
|
|
49
49
|
},
|
|
50
50
|
];
|
|
51
51
|
|
|
@@ -55,17 +55,15 @@ const TABS_WITH_DELTA: Tab[] = [
|
|
|
55
55
|
id: 'delta',
|
|
56
56
|
title: 'Delta',
|
|
57
57
|
content: 'Selected tab: Delta',
|
|
58
|
-
tab: { className: 'delta-class'
|
|
58
|
+
tab: { className: 'delta-class' },
|
|
59
59
|
},
|
|
60
60
|
];
|
|
61
61
|
|
|
62
62
|
const UncontrolledTabs = ( {
|
|
63
63
|
tabs,
|
|
64
|
-
showTabIcons = false,
|
|
65
64
|
...props
|
|
66
65
|
}: Omit< TabsProps, 'children' > & {
|
|
67
66
|
tabs: Tab[];
|
|
68
|
-
showTabIcons?: boolean;
|
|
69
67
|
} ) => {
|
|
70
68
|
return (
|
|
71
69
|
<Tabs { ...props }>
|
|
@@ -76,14 +74,17 @@ const UncontrolledTabs = ( {
|
|
|
76
74
|
id={ tabObj.id }
|
|
77
75
|
className={ tabObj.tab.className }
|
|
78
76
|
disabled={ tabObj.tab.disabled }
|
|
79
|
-
icon={ showTabIcons ? tabObj.tab.icon : undefined }
|
|
80
77
|
>
|
|
81
|
-
{
|
|
78
|
+
{ tabObj.title }
|
|
82
79
|
</Tabs.Tab>
|
|
83
80
|
) ) }
|
|
84
81
|
</Tabs.TabList>
|
|
85
82
|
{ tabs.map( ( tabObj ) => (
|
|
86
|
-
<Tabs.TabPanel
|
|
83
|
+
<Tabs.TabPanel
|
|
84
|
+
key={ tabObj.id }
|
|
85
|
+
id={ tabObj.id }
|
|
86
|
+
focusable={ tabObj.tabpanel?.focusable }
|
|
87
|
+
>
|
|
87
88
|
{ tabObj.content }
|
|
88
89
|
</Tabs.TabPanel>
|
|
89
90
|
) ) }
|
|
@@ -93,11 +94,9 @@ const UncontrolledTabs = ( {
|
|
|
93
94
|
|
|
94
95
|
const ControlledTabs = ( {
|
|
95
96
|
tabs,
|
|
96
|
-
showTabIcons = false,
|
|
97
97
|
...props
|
|
98
98
|
}: Omit< TabsProps, 'children' > & {
|
|
99
99
|
tabs: Tab[];
|
|
100
|
-
showTabIcons?: boolean;
|
|
101
100
|
} ) => {
|
|
102
101
|
const [ selectedTabId, setSelectedTabId ] = useState<
|
|
103
102
|
string | undefined | null
|
|
@@ -119,9 +118,8 @@ const ControlledTabs = ( {
|
|
|
119
118
|
id={ tabObj.id }
|
|
120
119
|
className={ tabObj.tab.className }
|
|
121
120
|
disabled={ tabObj.tab.disabled }
|
|
122
|
-
icon={ showTabIcons ? tabObj.tab.icon : undefined }
|
|
123
121
|
>
|
|
124
|
-
{
|
|
122
|
+
{ tabObj.title }
|
|
125
123
|
</Tabs.Tab>
|
|
126
124
|
) ) }
|
|
127
125
|
</Tabs.TabList>
|
|
@@ -184,6 +182,63 @@ describe( 'Tabs', () => {
|
|
|
184
182
|
);
|
|
185
183
|
} );
|
|
186
184
|
} );
|
|
185
|
+
describe( 'Focus Behavior', () => {
|
|
186
|
+
it( 'should focus on the related TabPanel when pressing the Tab key', async () => {
|
|
187
|
+
const user = userEvent.setup();
|
|
188
|
+
|
|
189
|
+
render( <UncontrolledTabs tabs={ TABS } /> );
|
|
190
|
+
|
|
191
|
+
const selectedTabPanel = await screen.findByRole( 'tabpanel' );
|
|
192
|
+
|
|
193
|
+
// Tab should initially focus the first tab in the tablist, which
|
|
194
|
+
// is Alpha.
|
|
195
|
+
await user.keyboard( '[Tab]' );
|
|
196
|
+
expect(
|
|
197
|
+
await screen.findByRole( 'tab', { name: 'Alpha' } )
|
|
198
|
+
).toHaveFocus();
|
|
199
|
+
|
|
200
|
+
// By default the tabpanel should receive focus
|
|
201
|
+
await user.keyboard( '[Tab]' );
|
|
202
|
+
expect( selectedTabPanel ).toHaveFocus();
|
|
203
|
+
} );
|
|
204
|
+
it( 'should not focus on the related TabPanel when pressing the Tab key if `focusable: false` is set', async () => {
|
|
205
|
+
const user = userEvent.setup();
|
|
206
|
+
|
|
207
|
+
const TABS_WITH_ALPHA_FOCUSABLE_FALSE = TABS.map( ( tabObj ) =>
|
|
208
|
+
tabObj.id === 'alpha'
|
|
209
|
+
? {
|
|
210
|
+
...tabObj,
|
|
211
|
+
content: (
|
|
212
|
+
<>
|
|
213
|
+
Selected Tab: Alpha
|
|
214
|
+
<button>Alpha Button</button>
|
|
215
|
+
</>
|
|
216
|
+
),
|
|
217
|
+
tabpanel: { focusable: false },
|
|
218
|
+
}
|
|
219
|
+
: tabObj
|
|
220
|
+
);
|
|
221
|
+
|
|
222
|
+
render(
|
|
223
|
+
<UncontrolledTabs tabs={ TABS_WITH_ALPHA_FOCUSABLE_FALSE } />
|
|
224
|
+
);
|
|
225
|
+
|
|
226
|
+
const alphaButton = await screen.findByRole( 'button', {
|
|
227
|
+
name: /alpha button/i,
|
|
228
|
+
} );
|
|
229
|
+
|
|
230
|
+
// Tab should initially focus the first tab in the tablist, which
|
|
231
|
+
// is Alpha.
|
|
232
|
+
await user.keyboard( '[Tab]' );
|
|
233
|
+
expect(
|
|
234
|
+
await screen.findByRole( 'tab', { name: 'Alpha' } )
|
|
235
|
+
).toHaveFocus();
|
|
236
|
+
// Because the alpha tabpanel is set to `focusable: false`, pressing
|
|
237
|
+
// the Tab key should focus the button, not the tabpanel
|
|
238
|
+
await user.keyboard( '[Tab]' );
|
|
239
|
+
expect( alphaButton ).toHaveFocus();
|
|
240
|
+
} );
|
|
241
|
+
} );
|
|
187
242
|
|
|
188
243
|
describe( 'Tab Attributes', () => {
|
|
189
244
|
it( "should apply the tab's `className` to the tab button", async () => {
|
package/src/tabs/types.ts
CHANGED
|
@@ -4,11 +4,6 @@
|
|
|
4
4
|
// eslint-disable-next-line no-restricted-imports
|
|
5
5
|
import type * as Ariakit from '@ariakit/react';
|
|
6
6
|
|
|
7
|
-
/**
|
|
8
|
-
* Internal dependencies
|
|
9
|
-
*/
|
|
10
|
-
import type { IconType } from '../icon';
|
|
11
|
-
|
|
12
7
|
export type TabsContextProps =
|
|
13
8
|
| {
|
|
14
9
|
/**
|
|
@@ -78,14 +73,6 @@ export type TabListProps = {
|
|
|
78
73
|
* The children elements, which should be a series of `Tabs.TabPanel` components.
|
|
79
74
|
*/
|
|
80
75
|
children?: React.ReactNode;
|
|
81
|
-
/**
|
|
82
|
-
* The class name to apply to the tablist.
|
|
83
|
-
*/
|
|
84
|
-
className?: string;
|
|
85
|
-
/**
|
|
86
|
-
* Custom CSS styles for the rendered tablist.
|
|
87
|
-
*/
|
|
88
|
-
style?: React.CSSProperties;
|
|
89
76
|
};
|
|
90
77
|
|
|
91
78
|
export type TabProps = {
|
|
@@ -93,22 +80,10 @@ export type TabProps = {
|
|
|
93
80
|
* The id of the tab, which is prepended with the `Tabs` instanceId.
|
|
94
81
|
*/
|
|
95
82
|
id: string;
|
|
96
|
-
/**
|
|
97
|
-
* Custom CSS styles for the tab.
|
|
98
|
-
*/
|
|
99
|
-
style?: React.CSSProperties;
|
|
100
83
|
/**
|
|
101
84
|
* The children elements, generally the text to display on the tab.
|
|
102
85
|
*/
|
|
103
86
|
children?: React.ReactNode;
|
|
104
|
-
/**
|
|
105
|
-
* The class name to apply to the tab button.
|
|
106
|
-
*/
|
|
107
|
-
className?: string;
|
|
108
|
-
/**
|
|
109
|
-
* The icon used for the tab button.
|
|
110
|
-
*/
|
|
111
|
-
icon?: IconType;
|
|
112
87
|
/**
|
|
113
88
|
* Determines if the tab button should be disabled.
|
|
114
89
|
*
|
|
@@ -128,15 +103,15 @@ export type TabPanelProps = {
|
|
|
128
103
|
*/
|
|
129
104
|
children?: React.ReactNode;
|
|
130
105
|
/**
|
|
131
|
-
* A unique identifier for the
|
|
106
|
+
* A unique identifier for the tabpanel, which is used to generate a unique `id` for the underlying element.
|
|
132
107
|
*/
|
|
133
108
|
id: string;
|
|
134
109
|
/**
|
|
135
|
-
*
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
*
|
|
110
|
+
* Determines whether or not the tabpanel element should be focusable.
|
|
111
|
+
* If `false`, pressing the tab key will skip over the tabpanel, and instead
|
|
112
|
+
* focus on the first focusable element in the panel (if there is one).
|
|
113
|
+
*
|
|
114
|
+
* @default true
|
|
140
115
|
*/
|
|
141
|
-
|
|
116
|
+
focusable?: boolean;
|
|
142
117
|
};
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
* External dependencies
|
|
3
3
|
*/
|
|
4
4
|
import type { ChangeEvent, ForwardedRef } from 'react';
|
|
5
|
+
import classnames from 'classnames';
|
|
5
6
|
|
|
6
7
|
/**
|
|
7
8
|
* WordPress dependencies
|
|
@@ -22,6 +23,7 @@ function UnforwardedTextControl(
|
|
|
22
23
|
) {
|
|
23
24
|
const {
|
|
24
25
|
__nextHasNoMarginBottom,
|
|
26
|
+
__next40pxDefaultSize = false,
|
|
25
27
|
label,
|
|
26
28
|
hideLabelFromVision,
|
|
27
29
|
value,
|
|
@@ -46,7 +48,9 @@ function UnforwardedTextControl(
|
|
|
46
48
|
className={ className }
|
|
47
49
|
>
|
|
48
50
|
<input
|
|
49
|
-
className=
|
|
51
|
+
className={ classnames( 'components-text-control__input', {
|
|
52
|
+
'is-next-40px-default-size': __next40pxDefaultSize,
|
|
53
|
+
} ) }
|
|
50
54
|
type={ type }
|
|
51
55
|
id={ id }
|
|
52
56
|
value={ value }
|
|
@@ -25,4 +25,10 @@ export type TextControlProps = Pick<
|
|
|
25
25
|
* @default 'text'
|
|
26
26
|
*/
|
|
27
27
|
type?: 'email' | 'number' | 'password' | 'tel' | 'text' | 'search' | 'url';
|
|
28
|
+
/**
|
|
29
|
+
* Start opting into the larger default height that will become the default size in a future version.
|
|
30
|
+
*
|
|
31
|
+
* @default false
|
|
32
|
+
*/
|
|
33
|
+
__next40pxDefaultSize?: boolean;
|
|
28
34
|
};
|
|
@@ -31,6 +31,7 @@ function UnconnectedToggleGroupControl(
|
|
|
31
31
|
) {
|
|
32
32
|
const {
|
|
33
33
|
__nextHasNoMarginBottom = false,
|
|
34
|
+
__next40pxDefaultSize = false,
|
|
34
35
|
className,
|
|
35
36
|
isAdaptiveWidth = false,
|
|
36
37
|
isBlock = false,
|
|
@@ -52,11 +53,16 @@ function UnconnectedToggleGroupControl(
|
|
|
52
53
|
const classes = useMemo(
|
|
53
54
|
() =>
|
|
54
55
|
cx(
|
|
55
|
-
styles.toggleGroupControl( {
|
|
56
|
+
styles.toggleGroupControl( {
|
|
57
|
+
isBlock,
|
|
58
|
+
isDeselectable,
|
|
59
|
+
size,
|
|
60
|
+
__next40pxDefaultSize,
|
|
61
|
+
} ),
|
|
56
62
|
isBlock && styles.block,
|
|
57
63
|
className
|
|
58
64
|
),
|
|
59
|
-
[ className, cx, isBlock, isDeselectable, size ]
|
|
65
|
+
[ className, cx, isBlock, isDeselectable, size, __next40pxDefaultSize ]
|
|
60
66
|
);
|
|
61
67
|
|
|
62
68
|
const MainControl = isDeselectable
|
|
@@ -14,7 +14,11 @@ export const toggleGroupControl = ( {
|
|
|
14
14
|
isBlock,
|
|
15
15
|
isDeselectable,
|
|
16
16
|
size,
|
|
17
|
-
|
|
17
|
+
__next40pxDefaultSize,
|
|
18
|
+
}: Pick<
|
|
19
|
+
ToggleGroupControlProps,
|
|
20
|
+
'isBlock' | 'isDeselectable' | '__next40pxDefaultSize'
|
|
21
|
+
> & {
|
|
18
22
|
size: NonNullable< ToggleGroupControlProps[ 'size' ] >;
|
|
19
23
|
} ) => css`
|
|
20
24
|
background: ${ COLORS.ui.background };
|
|
@@ -25,7 +29,7 @@ export const toggleGroupControl = ( {
|
|
|
25
29
|
padding: 2px;
|
|
26
30
|
position: relative;
|
|
27
31
|
|
|
28
|
-
${ toggleGroupControlSize( size ) }
|
|
32
|
+
${ toggleGroupControlSize( size, __next40pxDefaultSize ) }
|
|
29
33
|
${ ! isDeselectable && enclosingBorders( isBlock ) }
|
|
30
34
|
`;
|
|
31
35
|
|
|
@@ -53,13 +57,18 @@ const enclosingBorders = ( isBlock: ToggleGroupControlProps[ 'isBlock' ] ) => {
|
|
|
53
57
|
};
|
|
54
58
|
|
|
55
59
|
export const toggleGroupControlSize = (
|
|
56
|
-
size: NonNullable< ToggleGroupControlProps[ 'size' ]
|
|
60
|
+
size: NonNullable< ToggleGroupControlProps[ 'size' ] >,
|
|
61
|
+
__next40pxDefaultSize: ToggleGroupControlProps[ '__next40pxDefaultSize' ]
|
|
57
62
|
) => {
|
|
58
63
|
const heights = {
|
|
59
|
-
default: '
|
|
64
|
+
default: '40px',
|
|
60
65
|
'__unstable-large': '40px',
|
|
61
66
|
};
|
|
62
67
|
|
|
68
|
+
if ( ! __next40pxDefaultSize ) {
|
|
69
|
+
heights.default = '36px';
|
|
70
|
+
}
|
|
71
|
+
|
|
63
72
|
return css`
|
|
64
73
|
min-height: ${ heights[ size ] };
|
|
65
74
|
`;
|
|
@@ -122,6 +122,12 @@ export type ToggleGroupControlProps = Pick<
|
|
|
122
122
|
* @default 'default'
|
|
123
123
|
*/
|
|
124
124
|
size?: 'default' | '__unstable-large';
|
|
125
|
+
/**
|
|
126
|
+
* Start opting into the larger default height that will become the default size in a future version.
|
|
127
|
+
*
|
|
128
|
+
* @default false
|
|
129
|
+
*/
|
|
130
|
+
__next40pxDefaultSize?: boolean;
|
|
125
131
|
};
|
|
126
132
|
|
|
127
133
|
export type ToggleGroupControlContextProps = {
|