Skip to content

Commit ca3591e

Browse files
committed
Merge remote-tracking branch 'upstream/main' into refactor/react-children-takeover
# Conflicts: # src/components/Card/Card.tsx # src/components/Card/CardContent.tsx # src/components/__tests__/ListAccordion.test.tsx # src/components/__tests__/ToggleButton.test.tsx
2 parents 4ed52e3 + 84fdd8e commit ca3591e

89 files changed

Lines changed: 21269 additions & 2296 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎docs/6.x/docs/guides/fonts.md‎

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,13 @@ Platform.select({
6767
}),
6868
```
6969
70+
Material Design 3 typescale uses two font families:
71+
72+
- **Brand**: Display, Headline and Title Large
73+
- **Plain**: Title Medium/Small, Label and Body
74+
75+
The default theme uses the platform default for both font families.
76+
7077
:::
7178
7279
- #### Display
@@ -291,14 +298,29 @@ Platform.select({
291298
"fontFamily": "Font",
292299
"fontSize": 16,
293300
"fontWeight": "400",
294-
"letterSpacing": 0.15,
301+
"letterSpacing": 0.5,
295302
"lineHeight": 24,
296303
}
297304
```
298305
299306
</div>
300307
</div>
301308
309+
- #### Emphasized
310+
311+
Each variant also has an `Emphasized` counterpart with a heavier font weight: `displayLargeEmphasized`,
312+
`bodyMediumEmphasized` etc.
313+
314+
```json
315+
"bodyMediumEmphasized": {
316+
"fontFamily": "Font",
317+
"fontSize": 14,
318+
"fontWeight": "500",
319+
"letterSpacing": 0.25,
320+
"lineHeight": 20,
321+
}
322+
```
323+
302324
:::info
303325
If any component uses Paper's `Text` component, without specified <b>variant</b>, then `default` variant is applied:
304326

‎docs/6.x/docs/guides/migration.md‎

Lines changed: 33 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -71,61 +71,41 @@ You can use the component's color prop where available, or override the correspo
7171

7272
### Test IDs
7373

74-
Hardcoded default test IDs have been removed for the components listed below. Many of these components also derive test IDs for their internal parts by appending a suffix to the `testID` prop (e.g. `${testID}-container`). Since `testID` is no longer defaulted to a hardcoded value, none of these derived test IDs are set either unless you pass a `testID` explicitly — so all queries by the IDs below will stop matching:
74+
Hardcoded default test IDs have been removed for the components listed below:
7575

7676
- `Appbar.Content`: `appbar-content`
77-
- `appbar-content-title-text`
7877
- `Appbar.Header`: `appbar-header`
79-
- `appbar-header-root-layer`
8078
- `BottomNavigation`: `bottom-navigation`
81-
- `bottom-navigation-bar`
8279
- `BottomNavigation.Bar`: `bottom-navigation-bar`
83-
- `bottom-navigation-bar-content`
84-
- `bottom-navigation-bar-content-wrapper`
8580
- `Button`: `button`
86-
- `button-container`
87-
- `button-icon-container`
88-
- `button-text`
8981
- `Card`: `card`
90-
- `card-container`
91-
- `card-outline`
9282
- `Chip`: `chip`
93-
- `chip-container`
9483
- `Drawer.CollapsedItem`: `drawer-collapsed-item`
95-
- `drawer-collapsed-item-outline`
96-
- `drawer-collapsed-item-container`
9784
- `FAB`: `floating-action-button`
98-
- `floating-action-button-container`
99-
- `floating-action-button-text`
10085
- `FAB.Extended`: `extended-floating-action-button`
101-
- `extended-floating-action-button-container`
102-
- `extended-floating-action-button-text`
10386
- `FAB.Menu`: `floating-action-button-menu`
10487
- `IconButton`: `icon-button`
105-
- `icon-button-container`
106-
- `icon-button-icon` (and `icon-button-icon-previous` / `icon-button-icon-current` when `animated`)
10788
- `Menu`: `menu`
108-
- `menu-view`
109-
- `menu-surface`
11089
- `Menu.Item`: `menu-item`
111-
- `menu-item-title`
11290
- `Modal`: `modal`
113-
- `modal-backdrop`
114-
- `modal-wrapper`
115-
- `modal-surface`
11691
- `ProgressBar`: `progress-bar`
117-
- `progress-bar-fill`
11892
- `Searchbar`: `search-bar`
119-
- `search-bar-container`
120-
- `search-bar-icon`
121-
- `search-bar-icon-wrapper`
122-
- `search-bar-clear-icon`
123-
- `search-bar-trailering-icon`
124-
- `search-bar-divider`
12593
- `Surface`: `surface`
126-
- `surface-outer-layer`
12794

128-
You can specify a `testID` explicitly to restore both the component's own test ID and all of its derived test IDs above, using the same suffixes.
95+
You can specify a `testID` explicitly to restore each component's own test ID.
96+
97+
These components used to also derive test IDs for internal, implementation-only elements by appending a suffix to the `testID` prop (e.g. `${testID}-container`, `${testID}-icon`, `${testID}-outline`). They have been removed entirely.
98+
99+
If you were relying on internal test IDs, update your tests not to rely on internal implementation details and only interact with elements or assert content your users can reach, e.g.: query by role, label, text etc., or `testID` props accepted by the component.
100+
101+
Some components now accept explicit `testID` props for their interactable elements:
102+
103+
- `BottomNavigation`: `barTestID` for the internal `BottomNavigation.Bar`, replacing the previous `${testID}-bar` derivation.
104+
- `Chip`: `closeIconTestID` for the close icon button.
105+
- `Dialog` and `Modal`: `overlayTestID` for the overlay displayed behind the content.
106+
- `Menu`: `overlayTestID` for the overlay displayed behind the menu.
107+
- `Searchbar`: `searchTestID`, `clearTestID`, and `trailingTestID` for the search, clear, and trailing icon buttons.
108+
- `Snackbar`: `iconTestID` for the icon button.
129109

130110
## Components
131111

@@ -208,6 +188,24 @@ e.g.:
208188
- The default elevation changed from level `1` to level `3`.
209189
- The `style` prop no longer configures the background color or border radius. You can override `theme.colors.surfaceContainerHigh` and `theme.shapes.corner.extraLarge` using the `theme` prop instead.
210190

191+
#### `Dialog.Actions`
192+
193+
`Dialog.Actions` no longer forces `compact` and `uppercase` on its buttons. Set them on the buttons if you want the old look.
194+
195+
```tsx
196+
// Before (v5)
197+
<Dialog.Actions>
198+
<Button onPress={hide}>Done</Button>
199+
</Dialog.Actions>
200+
201+
// After (v6)
202+
<Dialog.Actions>
203+
<Button compact uppercase onPress={hide}>
204+
Done
205+
</Button>
206+
</Dialog.Actions>
207+
```
208+
211209
### TextInput
212210

213211
The Paper 6.x `TextInput` is a complete rewrite with a new API. Import the component the same way, but note that the props and behavior have changed significantly.
@@ -353,26 +351,6 @@ const theme = {
353351

354352
`Card.Content` now has 16dp of padding on every side. It used to drop its top or bottom padding when it sat next to a `Card.Cover` or `Card.Title`, so cards that mix those sections grow a little taller. Pass `style` if you want the tighter spacing back.
355353

356-
### Dialog
357-
358-
#### `Dialog.Actions`
359-
360-
`Dialog.Actions` no longer forces `compact` and `uppercase` on its buttons. Set them on the buttons if you want the old look.
361-
362-
```tsx
363-
// Before (v5)
364-
<Dialog.Actions>
365-
<Button onPress={hide}>Done</Button>
366-
</Dialog.Actions>
367-
368-
// After (v6)
369-
<Dialog.Actions>
370-
<Button compact uppercase onPress={hide}>
371-
Done
372-
</Button>
373-
</Dialog.Actions>
374-
```
375-
376354
### List
377355

378356
#### `List.Accordion`

‎package.json‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@
5050
"dependencies": {
5151
"@callstack/react-theme-provider": "^3.0.9",
5252
"color": "^3.1.2",
53+
"fast-deep-equal": "^3.1.3",
5354
"use-latest-callback": "^0.2.3"
5455
},
5556
"devDependencies": {

‎src/components/Appbar/AppbarContent.tsx‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,6 @@ const AppbarContent = ({
135135
numberOfLines={1}
136136
accessible
137137
role={onPress ? 'none' : 'heading'}
138-
testID={testID ? `${testID}-title-text` : undefined}
139138
maxFontSizeMultiplier={titleMaxFontSizeMultiplier}
140139
>
141140
{title}

‎src/components/BottomNavigation/BottomNavigation.tsx‎

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -252,6 +252,10 @@ export type Props<Route extends BaseRoute> = {
252252
* TestID used for testing purposes
253253
*/
254254
testID?: string;
255+
/**
256+
* testID for the underlying `BottomNavigation.Bar`.
257+
*/
258+
barTestID?: string;
255259
};
256260

257261
const FAR_FAR_AWAY = Platform.OS === 'web' ? 0 : 9999;
@@ -336,6 +340,7 @@ const BottomNavigation = <Route extends BaseRoute>({
336340
labelMaxFontSizeMultiplier = 1,
337341
compact: compactProp,
338342
testID,
343+
barTestID,
339344
theme: themeOverrides,
340345
getLazy = ({ route }: { route: Route }) => route.lazy,
341346
}: Props<Route>) => {
@@ -579,7 +584,7 @@ const BottomNavigation = <Route extends BaseRoute>({
579584
safeAreaInsets={safeAreaInsets}
580585
labelMaxFontSizeMultiplier={labelMaxFontSizeMultiplier}
581586
compact={compact}
582-
testID={testID ? `${testID}-bar` : undefined}
587+
testID={barTestID}
583588
theme={theme}
584589
/>
585590
</View>

‎src/components/BottomNavigation/BottomNavigationBar.tsx‎

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -493,10 +493,7 @@ const BottomNavigationBar = <Route extends BaseRoute>({
493493
]}
494494
onLayout={onLayout}
495495
>
496-
<Animated.View
497-
style={[styles.barContent, { backgroundColor }]}
498-
testID={testID ? `${testID}-content` : undefined}
499-
>
496+
<Animated.View style={[styles.barContent, { backgroundColor }]}>
500497
<View
501498
style={[
502499
styles.items,
@@ -509,7 +506,6 @@ const BottomNavigationBar = <Route extends BaseRoute>({
509506
},
510507
]}
511508
role={'tablist'}
512-
testID={testID ? `${testID}-content-wrapper` : undefined}
513509
>
514510
{routes.map((route, index) => {
515511
const focused = navigationState.index === index;

‎src/components/Button/Button.tsx‎

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -292,7 +292,6 @@ const Button = ({
292292
<Surface
293293
{...rest}
294294
ref={ref}
295-
testID={testID ? `${testID}-container` : undefined}
296295
backgroundColor={backgroundOpacity < 1 ? 'transparent' : backgroundColor}
297296
{...touchableStyle}
298297
style={[
@@ -342,10 +341,7 @@ const Button = ({
342341
>
343342
<View style={[styles.content, { opacity: textOpacity }, contentStyle]}>
344343
{icon && loading !== true ? (
345-
<View
346-
style={iconStyle}
347-
testID={testID ? `${testID}-icon-container` : undefined}
348-
>
344+
<View style={iconStyle}>
349345
<Icon
350346
source={icon}
351347
size={customLabelSize ?? iconSize}
@@ -372,7 +368,6 @@ const Button = ({
372368
variant="labelLarge"
373369
selectable={false}
374370
numberOfLines={1}
375-
testID={testID ? `${testID}-text` : undefined}
376371
style={[
377372
styles.label,
378373
isMode('text')

‎src/components/Card/Card.tsx‎

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -195,10 +195,7 @@ const Card = ({
195195
const borderRadius = theme.shapes.corner.medium;
196196

197197
const content = (
198-
<View
199-
style={[styles.innerContainer, { borderRadius }, contentStyle]}
200-
testID={testID}
201-
>
198+
<View style={[styles.innerContainer, { borderRadius }, contentStyle]}>
202199
{children}
203200
</View>
204201
);
@@ -211,13 +208,12 @@ const Card = ({
211208
style={[{ borderColor }, style]}
212209
theme={theme}
213210
elevation={elevation}
214-
testID={testID ? `${testID}-container` : undefined}
211+
testID={hasPassedTouchHandler ? undefined : testID}
215212
{...rest}
216213
>
217214
{isMode('outlined') && (
218215
<View
219216
pointerEvents="none"
220-
testID={testID ? `${testID}-outline` : undefined}
221217
style={[
222218
{
223219
borderColor,
@@ -238,6 +234,7 @@ const Card = ({
238234
onPress={onPress}
239235
onPressIn={handlePressIn}
240236
onPressOut={handlePressOut}
237+
testID={testID}
241238
>
242239
{content}
243240
</Pressable>

‎src/components/Card/CardTitle.tsx‎

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,10 @@ export type Props = ViewProps & {
9494
* @optional
9595
*/
9696
theme?: ThemeProp;
97+
/**
98+
* testID to be used on tests.
99+
*/
100+
testID?: string;
97101
};
98102

99103
const LEFT_SIZE = 40;
@@ -135,14 +139,15 @@ const CardTitle = ({
135139
rightStyle,
136140
style,
137141
theme: themeOverrides,
142+
testID,
138143
}: Props) => {
139144
useInternalTheme(themeOverrides);
140145

141146
const minHeight = subtitle || left || right ? 72 : 50;
142147
const marginBottom = subtitle ? 0 : 2;
143148

144149
return (
145-
<View style={[styles.container, { minHeight }, style]}>
150+
<View style={[styles.container, { minHeight }, style]} testID={testID}>
146151
{left ? (
147152
<View style={[styles.left, leftStyle]}>
148153
{left({

‎src/components/Checkbox/CheckboxItem.tsx‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,6 @@ const CheckboxItem = ({
174174
{isLeading && checkbox}
175175
<Text
176176
variant={labelVariant}
177-
testID={testID ? `${testID}-text` : undefined}
178177
maxFontSizeMultiplier={labelMaxFontSizeMultiplier}
179178
style={[styles.label, computedStyle, labelStyle]}
180179
>

0 commit comments

Comments
 (0)