@wordpress/components 25.3.0 → 25.4.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 +15 -0
- package/build/button/index.native.js +9 -6
- package/build/button/index.native.js.map +1 -1
- package/build/form-token-field/styles.js +4 -2
- package/build/form-token-field/styles.js.map +1 -1
- package/build/item-group/item/hook.js +1 -1
- package/build/item-group/item/hook.js.map +1 -1
- package/build/item-group/styles.js +13 -10
- package/build/item-group/styles.js.map +1 -1
- package/build/mobile/image/index.native.js +4 -3
- package/build/mobile/image/index.native.js.map +1 -1
- package/build/navigator/navigator-provider/component.js +18 -10
- package/build/navigator/navigator-provider/component.js.map +1 -1
- package/build/query-controls/index.js +1 -0
- package/build/query-controls/index.js.map +1 -1
- package/build/query-controls/index.native.js +1 -0
- package/build/query-controls/index.native.js.map +1 -1
- package/build/text-control/index.js +2 -2
- package/build/text-control/index.js.map +1 -1
- package/build/toolbar/toolbar-group/toolbar-group-container.native.js +10 -7
- package/build/toolbar/toolbar-group/toolbar-group-container.native.js.map +1 -1
- package/build-module/button/index.native.js +8 -6
- package/build-module/button/index.native.js.map +1 -1
- package/build-module/form-token-field/styles.js +3 -2
- package/build-module/form-token-field/styles.js.map +1 -1
- package/build-module/item-group/item/hook.js +1 -1
- package/build-module/item-group/item/hook.js.map +1 -1
- package/build-module/item-group/styles.js +13 -11
- package/build-module/item-group/styles.js.map +1 -1
- package/build-module/mobile/image/index.native.js +4 -3
- package/build-module/mobile/image/index.native.js.map +1 -1
- package/build-module/navigator/navigator-provider/component.js +18 -10
- package/build-module/navigator/navigator-provider/component.js.map +1 -1
- package/build-module/query-controls/index.js +1 -0
- package/build-module/query-controls/index.js.map +1 -1
- package/build-module/query-controls/index.native.js +1 -0
- package/build-module/query-controls/index.native.js.map +1 -1
- package/build-module/text-control/index.js +2 -2
- package/build-module/text-control/index.js.map +1 -1
- package/build-module/toolbar/toolbar-group/toolbar-group-container.native.js +11 -7
- package/build-module/toolbar/toolbar-group/toolbar-group-container.native.js.map +1 -1
- package/build-style/style-rtl.css +3 -0
- package/build-style/style.css +3 -0
- package/build-types/form-token-field/styles.d.ts.map +1 -1
- package/build-types/item-group/item/hook.d.ts.map +1 -1
- package/build-types/item-group/stories/index.d.ts.map +1 -1
- package/build-types/item-group/styles.d.ts +1 -1
- package/build-types/item-group/styles.d.ts.map +1 -1
- package/build-types/navigator/navigator-provider/component.d.ts.map +1 -1
- package/build-types/navigator/types.d.ts +3 -1
- package/build-types/navigator/types.d.ts.map +1 -1
- package/build-types/query-controls/index.d.ts.map +1 -1
- package/build-types/text-control/test/text-control.d.ts +2 -0
- package/build-types/text-control/test/text-control.d.ts.map +1 -0
- package/package.json +21 -21
- package/src/button/index.native.js +9 -3
- package/src/button/style.native.scss +9 -0
- package/src/form-token-field/styles.ts +2 -0
- package/src/item-group/item/hook.ts +2 -1
- package/src/item-group/stories/index.tsx +8 -3
- package/src/item-group/styles.ts +39 -28
- package/src/mobile/image/index.native.js +8 -6
- package/src/mobile/image/style.native.scss +5 -1
- package/src/navigator/navigator-provider/component.tsx +30 -23
- package/src/navigator/types.ts +4 -1
- package/src/placeholder/style.scss +5 -0
- package/src/query-controls/index.native.js +1 -0
- package/src/query-controls/index.tsx +1 -0
- package/src/text-control/index.tsx +2 -2
- package/src/text-control/test/text-control.tsx +61 -0
- package/src/toolbar/toolbar-group/style.native.scss +2 -3
- package/src/toolbar/toolbar-group/toolbar-group-container.native.js +12 -17
- package/src/tooltip/README.md +1 -1
- package/tsconfig.tsbuildinfo +1 -1
|
@@ -148,6 +148,7 @@ function UnconnectedNavigatorProvider(
|
|
|
148
148
|
focusTargetSelector,
|
|
149
149
|
isBack = false,
|
|
150
150
|
skipFocus = false,
|
|
151
|
+
replace = false,
|
|
151
152
|
...restOptions
|
|
152
153
|
} = options;
|
|
153
154
|
|
|
@@ -172,34 +173,38 @@ function UnconnectedNavigatorProvider(
|
|
|
172
173
|
skipFocus,
|
|
173
174
|
};
|
|
174
175
|
|
|
175
|
-
if ( prevLocationHistory.length
|
|
176
|
-
return [ newLocation ];
|
|
176
|
+
if ( prevLocationHistory.length === 0 ) {
|
|
177
|
+
return replace ? [] : [ newLocation ];
|
|
177
178
|
}
|
|
178
179
|
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
180
|
+
const newLocationHistory = prevLocationHistory.slice(
|
|
181
|
+
prevLocationHistory.length > MAX_HISTORY_LENGTH - 1 ? 1 : 0,
|
|
182
|
+
-1
|
|
183
|
+
);
|
|
184
|
+
|
|
185
|
+
if ( ! replace ) {
|
|
186
|
+
newLocationHistory.push(
|
|
187
|
+
// Assign `focusTargetSelector` to the previous location in history
|
|
188
|
+
// (the one we just navigated from).
|
|
189
|
+
{
|
|
190
|
+
...prevLocationHistory[
|
|
191
|
+
prevLocationHistory.length - 1
|
|
192
|
+
],
|
|
193
|
+
focusTargetSelector,
|
|
194
|
+
}
|
|
195
|
+
);
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
newLocationHistory.push( newLocation );
|
|
199
|
+
|
|
200
|
+
return newLocationHistory;
|
|
196
201
|
} );
|
|
197
202
|
},
|
|
198
203
|
[ goBack ]
|
|
199
204
|
);
|
|
200
205
|
|
|
201
|
-
const goToParent: NavigatorContextType[ 'goToParent' ] =
|
|
202
|
-
|
|
206
|
+
const goToParent: NavigatorContextType[ 'goToParent' ] = useCallback(
|
|
207
|
+
( options = {} ) => {
|
|
203
208
|
const currentPath =
|
|
204
209
|
currentLocationHistory.current[
|
|
205
210
|
currentLocationHistory.current.length - 1
|
|
@@ -214,8 +219,10 @@ function UnconnectedNavigatorProvider(
|
|
|
214
219
|
if ( parentPath === undefined ) {
|
|
215
220
|
return;
|
|
216
221
|
}
|
|
217
|
-
goTo( parentPath, { isBack: true } );
|
|
218
|
-
},
|
|
222
|
+
goTo( parentPath, { ...options, isBack: true } );
|
|
223
|
+
},
|
|
224
|
+
[ goTo ]
|
|
225
|
+
);
|
|
219
226
|
|
|
220
227
|
const navigatorContextValue: NavigatorContextType = useMemo(
|
|
221
228
|
() => ( {
|
package/src/navigator/types.ts
CHANGED
|
@@ -14,8 +14,11 @@ export type NavigateOptions = {
|
|
|
14
14
|
focusTargetSelector?: string;
|
|
15
15
|
isBack?: boolean;
|
|
16
16
|
skipFocus?: boolean;
|
|
17
|
+
replace?: boolean;
|
|
17
18
|
};
|
|
18
19
|
|
|
20
|
+
export type NavigateToParentOptions = Omit< NavigateOptions, 'isBack' >;
|
|
21
|
+
|
|
19
22
|
export type NavigatorLocation = NavigateOptions & {
|
|
20
23
|
isInitial?: boolean;
|
|
21
24
|
path?: string;
|
|
@@ -28,7 +31,7 @@ export type Navigator = {
|
|
|
28
31
|
params: MatchParams;
|
|
29
32
|
goTo: ( path: string, options?: NavigateOptions ) => void;
|
|
30
33
|
goBack: () => void;
|
|
31
|
-
goToParent: () => void;
|
|
34
|
+
goToParent: ( options?: NavigateToParentOptions ) => void;
|
|
32
35
|
};
|
|
33
36
|
|
|
34
37
|
export type NavigatorContext = Navigator & {
|
|
@@ -26,13 +26,13 @@ function UnforwardedTextControl(
|
|
|
26
26
|
hideLabelFromVision,
|
|
27
27
|
value,
|
|
28
28
|
help,
|
|
29
|
+
id: idProp,
|
|
29
30
|
className,
|
|
30
31
|
onChange,
|
|
31
32
|
type = 'text',
|
|
32
33
|
...additionalProps
|
|
33
34
|
} = props;
|
|
34
|
-
const
|
|
35
|
-
const id = `inspector-text-control-${ instanceId }`;
|
|
35
|
+
const id = useInstanceId( TextControl, 'inspector-text-control', idProp );
|
|
36
36
|
const onChangeValue = ( event: ChangeEvent< HTMLInputElement > ) =>
|
|
37
37
|
onChange( event.target.value );
|
|
38
38
|
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* External dependencies
|
|
3
|
+
*/
|
|
4
|
+
import { render, screen } from '@testing-library/react';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Internal dependencies
|
|
8
|
+
*/
|
|
9
|
+
import TextControl from '..';
|
|
10
|
+
|
|
11
|
+
const noop = () => {};
|
|
12
|
+
|
|
13
|
+
describe( 'TextControl', () => {
|
|
14
|
+
describe( 'When no ID prop is provided', () => {
|
|
15
|
+
it( 'should generate an ID', () => {
|
|
16
|
+
render( <TextControl onChange={ noop } value="" /> );
|
|
17
|
+
|
|
18
|
+
expect( screen.getByRole( 'textbox' ) ).toHaveAttribute(
|
|
19
|
+
'id',
|
|
20
|
+
expect.stringMatching( /^inspector-text-control-/ )
|
|
21
|
+
);
|
|
22
|
+
} );
|
|
23
|
+
|
|
24
|
+
it( 'should be labelled correctly', () => {
|
|
25
|
+
const labelValue = 'Test Label';
|
|
26
|
+
render(
|
|
27
|
+
<TextControl label={ labelValue } onChange={ noop } value="" />
|
|
28
|
+
);
|
|
29
|
+
|
|
30
|
+
expect(
|
|
31
|
+
screen.getByRole( 'textbox', { name: labelValue } )
|
|
32
|
+
).toBeVisible();
|
|
33
|
+
} );
|
|
34
|
+
} );
|
|
35
|
+
|
|
36
|
+
describe( 'When an ID prop is provided', () => {
|
|
37
|
+
const id = 'test-id';
|
|
38
|
+
|
|
39
|
+
it( 'should use the passed ID prop if provided', () => {
|
|
40
|
+
render( <TextControl id={ id } onChange={ noop } value="" /> );
|
|
41
|
+
|
|
42
|
+
expect( screen.getByRole( 'textbox' ) ).toHaveAttribute( 'id', id );
|
|
43
|
+
} );
|
|
44
|
+
|
|
45
|
+
it( 'should be labelled correctly', () => {
|
|
46
|
+
const labelValue = 'Test Label';
|
|
47
|
+
render(
|
|
48
|
+
<TextControl
|
|
49
|
+
label={ labelValue }
|
|
50
|
+
id={ id }
|
|
51
|
+
onChange={ noop }
|
|
52
|
+
value=""
|
|
53
|
+
/>
|
|
54
|
+
);
|
|
55
|
+
|
|
56
|
+
expect(
|
|
57
|
+
screen.getByRole( 'textbox', { name: labelValue } )
|
|
58
|
+
).toBeVisible();
|
|
59
|
+
} );
|
|
60
|
+
} );
|
|
61
|
+
} );
|
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
.container {
|
|
2
2
|
flex-direction: row;
|
|
3
|
-
border-
|
|
4
|
-
border-color: #e9eff3;
|
|
3
|
+
border-color: $light-quaternary;
|
|
5
4
|
padding-left: 5px;
|
|
6
5
|
padding-right: 5px;
|
|
7
6
|
}
|
|
8
7
|
|
|
9
8
|
.containerDark {
|
|
10
|
-
border-color:
|
|
9
|
+
border-color: $dark-quaternary;
|
|
11
10
|
}
|
|
@@ -1,31 +1,26 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* External dependencies
|
|
3
3
|
*/
|
|
4
|
-
import { View } from 'react-native';
|
|
4
|
+
import { StyleSheet, View } from 'react-native';
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
* WordPress dependencies
|
|
8
8
|
*/
|
|
9
|
-
import {
|
|
9
|
+
import { usePreferredColorSchemeStyle } from '@wordpress/compose';
|
|
10
10
|
|
|
11
11
|
/**
|
|
12
12
|
* Internal dependencies
|
|
13
13
|
*/
|
|
14
14
|
import styles from './style.scss';
|
|
15
15
|
|
|
16
|
-
const ToolbarGroupContainer = ( {
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
style={ [
|
|
23
|
-
getStylesFromColorScheme( styles.container, styles.containerDark ),
|
|
24
|
-
passedStyle,
|
|
25
|
-
] }
|
|
26
|
-
>
|
|
27
|
-
{ children }
|
|
28
|
-
</View>
|
|
29
|
-
);
|
|
16
|
+
const ToolbarGroupContainer = ( { passedStyle, children } ) => {
|
|
17
|
+
const groupStyles = [
|
|
18
|
+
usePreferredColorSchemeStyle( styles.container, styles.containerDark ),
|
|
19
|
+
{ borderLeftWidth: StyleSheet.hairlineWidth },
|
|
20
|
+
passedStyle,
|
|
21
|
+
];
|
|
30
22
|
|
|
31
|
-
|
|
23
|
+
return <View style={ groupStyles }>{ children }</View>;
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
export default ToolbarGroupContainer;
|