Skip to content

Commit 6da6852

Browse files
authored
Merge branch 'next' into candrepa1/fix-ariaControls-accesibility
2 parents 5e40699 + 5e6b94c commit 6da6852

File tree

30 files changed

+222
-41
lines changed

30 files changed

+222
-41
lines changed

code/addons/a11y/src/a11yRunner.ts

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ export const run = async (input: A11yParameters = DEFAULT_PARAMETERS, storyId: s
5656

5757
const context: ContextSpec = {
5858
include: document?.body,
59-
exclude: ['.sb-wrapper', '#storybook-docs'], // Internal Storybook elements that are always in the document
59+
exclude: ['.sb-wrapper', '#storybook-docs', '#storybook-highlights-root'], // Internal Storybook elements that are always in the document
6060
};
6161

6262
if (input.context) {
@@ -93,6 +93,11 @@ export const run = async (input: A11yParameters = DEFAULT_PARAMETERS, storyId: s
9393
axe.configure(configWithDefault);
9494

9595
return new Promise<AxeResults>((resolve, reject) => {
96+
const highlightsRoot = document?.getElementById('storybook-highlights-root');
97+
if (highlightsRoot) {
98+
highlightsRoot.style.display = 'none';
99+
}
100+
96101
const task = async () => {
97102
try {
98103
const result = await axe.run(context, options);
@@ -108,6 +113,10 @@ export const run = async (input: A11yParameters = DEFAULT_PARAMETERS, storyId: s
108113
if (!isRunning) {
109114
runNext();
110115
}
116+
117+
if (highlightsRoot) {
118+
highlightsRoot.style.display = '';
119+
}
111120
});
112121
};
113122

code/core/src/common/satellite-addons.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,11 @@ export default [
77
'@storybook/addon-coverage',
88
'@storybook/addon-webpack5-compiler-babel',
99
'@storybook/addon-webpack5-compiler-swc',
10+
// Storybook for React Native related packages
11+
// TODO: For Storybook 10, we should check about possible automigrations
12+
'@storybook/addon-ondevice-actions',
13+
'@storybook/addon-ondevice-backgrounds',
14+
'@storybook/addon-ondevice-controls',
15+
'@storybook/addon-ondevice-notes',
16+
'@storybook/react-native',
1017
];

code/core/src/highlight/useHighlights.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
/// <reference path="./typings.d.ts" />
2+
13
/* eslint-env browser */
24
import type { Channel } from 'storybook/internal/channels';
35
import { STORY_RENDER_PHASE_CHANGED } from 'storybook/internal/core-events';

code/core/src/manager-api/lib/addons.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,8 @@ import { global } from '@storybook/global';
2121
import type { API } from '../root';
2222
import { mockChannel } from './storybook-channel-mock';
2323

24-
export { Addon_Type as Addon, Addon_TypesEnum as types };
24+
export type { Addon_Type as Addon };
25+
export { Addon_TypesEnum as types };
2526

2627
export function isSupportedType(type: Addon_Types): boolean {
2728
return !!Object.values(Addon_TypesEnum).find((typeVal) => typeVal === type);

code/core/src/measure/box-model/labels.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import type { ElementMeasurements, FloatingAlignment } from '../util-types';
2+
13
type LabelType = 'margin' | 'padding' | 'border' | 'content';
24
type LabelPosition = 'top' | 'right' | 'bottom' | 'left' | 'center';
35
type Direction = 'top' | 'right' | 'bottom' | 'left';

code/core/src/measure/box-model/visualizer.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
11
/** Based on https://gist.github.com/awestbro/e668c12662ad354f02a413205b65fce7 */
22
import { global } from '@storybook/global';
33

4+
import type {
5+
Dimensions,
6+
ElementMeasurements,
7+
Extremities,
8+
FloatingAlignment,
9+
} from '../util-types';
410
import { draw } from './canvas';
511
import type { Label, LabelStack } from './labels';
612
import { labelStacks } from './labels';
Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,25 @@
1-
interface Margin {
1+
export interface Margin {
22
top: number;
33
bottom: number;
44
left: number;
55
right: number;
66
}
77

8-
interface Padding {
8+
export interface Padding {
99
top: number;
1010
bottom: number;
1111
left: number;
1212
right: number;
1313
}
1414

15-
interface Border {
15+
export interface Border {
1616
top: number;
1717
bottom: number;
1818
left: number;
1919
right: number;
2020
}
2121

22-
interface Dimensions {
22+
export interface Dimensions {
2323
margin: Margin;
2424
padding: Padding;
2525
border: Border;
@@ -31,19 +31,19 @@ interface Dimensions {
3131
right: number;
3232
}
3333

34-
interface Extremities {
34+
export interface Extremities {
3535
top: number;
3636
bottom: number;
3737
left: number;
3838
right: number;
3939
}
4040

41-
interface FloatingAlignment {
41+
export interface FloatingAlignment {
4242
x: 'left' | 'right';
4343
y: 'top' | 'bottom';
4444
}
4545

46-
interface ElementMeasurements extends Dimensions {
46+
export interface ElementMeasurements extends Dimensions {
4747
extremities: Extremities;
4848
floatingAlignment: FloatingAlignment;
4949
}

code/core/src/telemetry/package-json.ts

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,13 @@ export const getActualPackageVersion = async (packageName: string) => {
2121
};
2222

2323
export const getActualPackageJson = async (packageName: string) => {
24-
const resolvedPackageJson = require.resolve(join(packageName, 'package.json'), {
25-
paths: [process.cwd()],
26-
});
27-
const packageJson = JSON.parse(await readFile(resolvedPackageJson, { encoding: 'utf8' }));
28-
return packageJson;
24+
try {
25+
const resolvedPackageJson = require.resolve(join(packageName, 'package.json'), {
26+
paths: [process.cwd()],
27+
});
28+
const packageJson = JSON.parse(await readFile(resolvedPackageJson, { encoding: 'utf8' }));
29+
return packageJson;
30+
} catch (err) {
31+
return null;
32+
}
2933
};

code/core/src/test/expect.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import {
1414
JestAsymmetricMatchers,
1515
JestChaiExpect,
1616
JestExtend,
17+
customMatchers,
1718
getState,
1819
setState,
1920
} from '@vitest/expect';
@@ -78,6 +79,8 @@ export function createExpect() {
7879
return assert;
7980
};
8081

82+
expect.extend(customMatchers);
83+
8184
// @ts-ignore tsup borks here for some reason
8285
expect.unreachable = (message?: string): never => {
8386
chai.assert.fail(`expected${message ? ` "${message}" ` : ' '}not to be reached`);

code/frameworks/nextjs/src/babel/loader.ts

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,15 @@ import type { Options } from 'storybook/internal/types';
33

44
import { getVirtualModules } from '@storybook/builder-webpack5';
55

6-
export const configureBabelLoader = async (baseConfig: any, options: Options) => {
6+
import type { NextConfig } from 'next';
7+
8+
import { getNodeModulesExcludeRegex } from '../utils';
9+
10+
export const configureBabelLoader = async (
11+
baseConfig: any,
12+
options: Options,
13+
nextConfig: NextConfig
14+
) => {
715
const { virtualModules } = await getVirtualModules(options);
816

917
const babelOptions = await options.presets.apply('babel', {}, options);
@@ -23,7 +31,10 @@ export const configureBabelLoader = async (baseConfig: any, options: Options) =>
2331
},
2432
],
2533
include: [getProjectRoot()],
26-
exclude: [/node_modules/, ...Object.keys(virtualModules)],
34+
exclude: [
35+
getNodeModulesExcludeRegex(nextConfig.transpilePackages ?? []),
36+
...Object.keys(virtualModules),
37+
],
2738
},
2839
];
2940
};

0 commit comments

Comments
 (0)