@storybook/react 7.0.19 → 7.0.21

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.0.19",
3
+ "version": "7.0.21",
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.0.19",
56
- "@storybook/core-client": "7.0.19",
57
- "@storybook/docs-tools": "7.0.19",
55
+ "@storybook/client-logger": "7.0.21",
56
+ "@storybook/core-client": "7.0.21",
57
+ "@storybook/docs-tools": "7.0.21",
58
58
  "@storybook/global": "^5.0.0",
59
- "@storybook/preview-api": "7.0.19",
60
- "@storybook/react-dom-shim": "7.0.19",
61
- "@storybook/types": "7.0.19",
59
+ "@storybook/preview-api": "7.0.21",
60
+ "@storybook/react-dom-shim": "7.0.21",
61
+ "@storybook/types": "7.0.21",
62
62
  "@types/escodegen": "^0.0.6",
63
63
  "@types/estree": "^0.0.51",
64
64
  "@types/node": "^16.0.0",
@@ -105,5 +105,5 @@
105
105
  ],
106
106
  "platform": "browser"
107
107
  },
108
- "gitHead": "245bae01c81d87eeadf74886167507fcea16369c"
109
- }
108
+ "gitHead": "9fb2573aa274f3f69d3358050e8df9c903e8245f"
109
+ }
@@ -0,0 +1,3 @@
1
+ ## Integration tests for @storybook/react.
2
+
3
+ As these tests are implemented as stories, we may consider moving them inside the `template/stories` folder.
@@ -0,0 +1,48 @@
1
+ // TODO: Replace, as soon as @types/react-dom 17.0.14 is used
2
+ // Source: https://github.com/DefinitelyTyped/DefinitelyTyped/blob/fb0f14b7a35cde26ffaa82e7536c062e593e9ae6/types/react-dom/client.d.ts
3
+ declare module 'react-dom/client' {
4
+ import React = require('react');
5
+
6
+ export interface HydrationOptions {
7
+ onHydrated?(suspenseInstance: Comment): void;
8
+ onDeleted?(suspenseInstance: Comment): void;
9
+ /**
10
+ * Prefix for `useId`.
11
+ */
12
+ identifierPrefix?: string;
13
+ onRecoverableError?: (error: unknown) => void;
14
+ }
15
+
16
+ export interface RootOptions {
17
+ /**
18
+ * Prefix for `useId`.
19
+ */
20
+ identifierPrefix?: string;
21
+ onRecoverableError?: (error: unknown) => void;
22
+ }
23
+
24
+ export interface Root {
25
+ render(children: React.ReactChild | Iterable<React.ReactNode>): void;
26
+ unmount(): void;
27
+ }
28
+
29
+ /**
30
+ * Replaces `ReactDOM.render` when the `.render` method is called and enables Concurrent Mode.
31
+ *
32
+ * @see https://reactjs.org/docs/concurrent-mode-reference.html#createroot
33
+ */
34
+ export function createRoot(
35
+ container: Element | Document | DocumentFragment | Comment,
36
+ options?: RootOptions
37
+ ): Root;
38
+
39
+ export function hydrateRoot(
40
+ container: Element | Document | DocumentFragment | Comment,
41
+ initialChildren: React.ReactChild | Iterable<React.ReactNode>,
42
+ options?: HydrationOptions
43
+ ): Root;
44
+ }
45
+
46
+ declare var STORYBOOK_ENV: 'react';
47
+ declare var FRAMEWORK_OPTIONS: any;
48
+ declare var LOGLEVEL: 'trace' | 'debug' | 'info' | 'warn' | 'error' | 'silent' | undefined;
@@ -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 } };