@storybook/react 7.1.0-alpha.32 → 7.1.0-alpha.33

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@storybook/react",
3
- "version": "7.1.0-alpha.32",
3
+ "version": "7.1.0-alpha.33",
4
4
  "description": "Storybook React renderer",
5
5
  "keywords": [
6
6
  "storybook"
@@ -52,13 +52,13 @@
52
52
  "prep": "../../../scripts/prepare/bundle.ts"
53
53
  },
54
54
  "dependencies": {
55
- "@storybook/client-logger": "7.1.0-alpha.32",
56
- "@storybook/core-client": "7.1.0-alpha.32",
57
- "@storybook/docs-tools": "7.1.0-alpha.32",
55
+ "@storybook/client-logger": "7.1.0-alpha.33",
56
+ "@storybook/core-client": "7.1.0-alpha.33",
57
+ "@storybook/docs-tools": "7.1.0-alpha.33",
58
58
  "@storybook/global": "^5.0.0",
59
- "@storybook/preview-api": "7.1.0-alpha.32",
60
- "@storybook/react-dom-shim": "7.1.0-alpha.32",
61
- "@storybook/types": "7.1.0-alpha.32",
59
+ "@storybook/preview-api": "7.1.0-alpha.33",
60
+ "@storybook/react-dom-shim": "7.1.0-alpha.33",
61
+ "@storybook/types": "7.1.0-alpha.33",
62
62
  "@types/escodegen": "^0.0.6",
63
63
  "@types/estree": "^0.0.51",
64
64
  "@types/node": "^16.0.0",
@@ -1,10 +1,12 @@
1
1
  import React, { useState } from 'react';
2
2
  import mapValues from 'lodash/mapValues.js';
3
3
  import { PureArgsTable as ArgsTable } from '@storybook/blocks';
4
+ import type { StoryObj } from '@storybook/react';
4
5
  import type { Args, Parameters, StoryContext } from '@storybook/types';
5
6
  import { inferControls } from '@storybook/preview-api';
6
7
  import { ThemeProvider, themes, convert } from '@storybook/theming';
7
8
 
9
+ import { within } from '@storybook/testing-library';
8
10
  import { component as TsFunctionComponentComponent } from './docgen-components/ts-function-component/input';
9
11
  import { component as TsFunctionComponentInlineDefaultsComponent } from './docgen-components/ts-function-component-inline-defaults/input';
10
12
  import { component as TsReactFcGenericsComponent } from './docgen-components/8143-ts-react-fc-generics/input';
@@ -76,6 +78,27 @@ export const TsComponentProps = { parameters: { component: TsComponentPropsCompo
76
78
 
77
79
  export const TsJsdoc = { parameters: { component: TsJsdocComponent } };
78
80
 
79
- export const TsTypes = { parameters: { component: TsTypesComponent } };
81
+ const addChromaticIgnore = async (element: HTMLElement) => {
82
+ const row = element.parentElement?.parentElement;
83
+ if (row?.nodeName === 'TR') {
84
+ row.setAttribute('data-chromatic', 'ignore');
85
+ } else {
86
+ throw new Error('the DOM structure changed, please update this test');
87
+ }
88
+ };
89
+
90
+ export const TsTypes: StoryObj = {
91
+ parameters: { component: TsTypesComponent },
92
+ play: async ({ canvasElement }) => {
93
+ // This play function's sole purpose is to add a "chromatic ignore" region to flaky rows.
94
+ const canvas = within(canvasElement);
95
+ const funcCell = await canvas.findByText('funcWithArgsAndReturns');
96
+ addChromaticIgnore(funcCell);
97
+ const namedNumericCell = await canvas.findByText('namedNumericLiteralUnion');
98
+ addChromaticIgnore(namedNumericCell);
99
+ const inlinedNumericCell = await canvas.findByText('inlinedNumericLiteralUnion');
100
+ addChromaticIgnore(inlinedNumericCell);
101
+ },
102
+ };
80
103
 
81
104
  export const TsHtml = { parameters: { component: TsHtmlComponent } };