@storybook/addon-interactions 6.4.0-beta.31 → 6.4.0-rc.1

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.
@@ -1,5 +1,5 @@
1
1
  import { expect } from '@storybook/jest';
2
- import { within, waitFor, fireEvent, userEvent } from '@storybook/testing-library';
2
+ import { within, waitFor, fireEvent, userEvent, waitForElementToBeRemoved } from '@storybook/testing-library';
3
3
  import React from 'react';
4
4
  import { AccountForm } from './AccountForm';
5
5
  export default {
@@ -46,6 +46,60 @@ WaitFor.play = async ({
46
46
  });
47
47
  };
48
48
 
49
+ export const WaitForElementToBeRemoved = () => {
50
+ const [isLoading, setIsLoading] = React.useState(true);
51
+ React.useEffect(() => {
52
+ setTimeout(() => setIsLoading(false), 1500);
53
+ }, []);
54
+ return isLoading ? /*#__PURE__*/React.createElement("div", null, "Loading...") : /*#__PURE__*/React.createElement("button", {
55
+ type: "button"
56
+ }, "Loaded!");
57
+ };
58
+
59
+ WaitForElementToBeRemoved.play = async ({
60
+ canvasElement
61
+ }) => {
62
+ const canvas = within(canvasElement);
63
+ await waitForElementToBeRemoved(await canvas.findByText('Loading...'), {
64
+ timeout: 2000
65
+ });
66
+ const button = await canvas.findByText('Loaded!');
67
+ await expect(button).not.toBeNull();
68
+ };
69
+
70
+ export const WithLoaders = (args, {
71
+ loaded: {
72
+ todo
73
+ }
74
+ }) => {
75
+ return /*#__PURE__*/React.createElement("button", {
76
+ type: "button",
77
+ onClick: args.onSubmit(todo.title)
78
+ }, "Todo: ", todo.title);
79
+ };
80
+ WithLoaders.loaders = [async () => {
81
+ // long fake timeout
82
+ await new Promise(resolve => setTimeout(resolve, 2000));
83
+ return {
84
+ todo: {
85
+ userId: 1,
86
+ id: 1,
87
+ title: 'delectus aut autem',
88
+ completed: false
89
+ }
90
+ };
91
+ }];
92
+
93
+ WithLoaders.play = async ({
94
+ args,
95
+ canvasElement
96
+ }) => {
97
+ const canvas = within(canvasElement);
98
+ const todoItem = await canvas.findByText('Todo: delectus aut autem');
99
+ await userEvent.click(todoItem);
100
+ await expect(args.onSubmit).toHaveBeenCalledWith('delectus aut autem');
101
+ };
102
+
49
103
  export const Standard = {
50
104
  args: {
51
105
  passwordVerification: false
@@ -1,5 +1,5 @@
1
1
  import React from 'react';
2
- import { Button, Icons, Separator, P, TooltipNote, WithTooltip, Bar } from '@storybook/components';
2
+ import { Button, IconButton, Icons, Separator, P, TooltipNote, WithTooltip, Bar } from '@storybook/components';
3
3
  import { CallStates } from '@storybook/instrumenter';
4
4
  import { styled } from '@storybook/theming';
5
5
  import { StatusBadge } from '../StatusBadge/StatusBadge';
@@ -34,16 +34,11 @@ const Note = styled(TooltipNote)(({
34
34
  }) => ({
35
35
  fontFamily: theme.typography.fonts.base
36
36
  }));
37
- export const StyledIconButton = styled(StyledButton)(({
37
+ export const StyledIconButton = styled(IconButton)(({
38
38
  theme
39
39
  }) => ({
40
40
  color: theme.color.mediumdark,
41
- margin: '0 3px',
42
- '&:not(:disabled)': {
43
- '&:hover,&:focus-visible': {
44
- background: theme.background.hoverable
45
- }
46
- }
41
+ margin: '0 3px'
47
42
  }));
48
43
  const StyledSeparator = styled(Separator)({
49
44
  marginTop: 0
@@ -109,7 +104,6 @@ export const Subnav = ({
109
104
  note: "Go to start"
110
105
  })
111
106
  }, /*#__PURE__*/React.createElement(RewindButton, {
112
- containsIcon: true,
113
107
  onClick: onStart,
114
108
  disabled: isDisabled || !hasPrevious
115
109
  }, /*#__PURE__*/React.createElement(Icons, {
@@ -122,7 +116,6 @@ export const Subnav = ({
122
116
  note: "Go back"
123
117
  })
124
118
  }, /*#__PURE__*/React.createElement(StyledIconButton, {
125
- containsIcon: true,
126
119
  onClick: onPrevious,
127
120
  disabled: isDisabled || !hasPrevious
128
121
  }, /*#__PURE__*/React.createElement(Icons, {
@@ -135,7 +128,6 @@ export const Subnav = ({
135
128
  note: "Go forward"
136
129
  })
137
130
  }, /*#__PURE__*/React.createElement(StyledIconButton, {
138
- containsIcon: true,
139
131
  onClick: onNext,
140
132
  disabled: isDisabled || !hasNext
141
133
  }, /*#__PURE__*/React.createElement(Icons, {
@@ -148,7 +140,6 @@ export const Subnav = ({
148
140
  note: "Go to end"
149
141
  })
150
142
  }, /*#__PURE__*/React.createElement(StyledIconButton, {
151
- containsIcon: true,
152
143
  onClick: onEnd,
153
144
  disabled: isDisabled || !hasNext
154
145
  }, /*#__PURE__*/React.createElement(Icons, {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@storybook/addon-interactions",
3
- "version": "6.4.0-beta.31",
3
+ "version": "6.4.0-rc.1",
4
4
  "description": "Automate, test and debug user interactions",
5
5
  "keywords": [
6
6
  "storybook-addons",
@@ -41,14 +41,14 @@
41
41
  "prepare": "node ../../scripts/prepare.js"
42
42
  },
43
43
  "dependencies": {
44
- "@storybook/addons": "6.4.0-beta.31",
45
- "@storybook/api": "6.4.0-beta.31",
46
- "@storybook/components": "6.4.0-beta.31",
47
- "@storybook/core-common": "6.4.0-beta.31",
48
- "@storybook/core-events": "6.4.0-beta.31",
44
+ "@storybook/addons": "6.4.0-rc.1",
45
+ "@storybook/api": "6.4.0-rc.1",
46
+ "@storybook/components": "6.4.0-rc.1",
47
+ "@storybook/core-common": "6.4.0-rc.1",
48
+ "@storybook/core-events": "6.4.0-rc.1",
49
49
  "@storybook/csf": "0.0.2--canary.87bc651.0",
50
- "@storybook/instrumenter": "6.4.0-beta.31",
51
- "@storybook/theming": "6.4.0-beta.31",
50
+ "@storybook/instrumenter": "6.4.0-rc.1",
51
+ "@storybook/theming": "6.4.0-rc.1",
52
52
  "global": "^4.4.0",
53
53
  "jest-mock": "^27.0.6",
54
54
  "polished": "^4.0.5",
@@ -74,7 +74,7 @@
74
74
  "publishConfig": {
75
75
  "access": "public"
76
76
  },
77
- "gitHead": "17ef07b50965ad82f3c6a5f7442211bb8f140267",
77
+ "gitHead": "0d79fcc7dd9f8d949c2644aefb54e77a3f932db4",
78
78
  "sbmodern": "dist/modern/index.js",
79
79
  "storybook": {
80
80
  "displayName": "Interactions",