@storybook/addon-interactions 6.4.0-beta.32 → 6.4.0-rc.10
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/dist/cjs/Panel.js +83 -110
- package/dist/cjs/Panel.stories.js +23 -9
- package/dist/cjs/components/AccountForm/addon-interactions.stories.js +207 -155
- package/dist/cjs/components/Interaction/Interaction.js +16 -15
- package/dist/cjs/components/Interaction/Interaction.stories.js +9 -3
- package/dist/cjs/components/Subnav/Subnav.js +15 -20
- package/dist/cjs/components/Subnav/Subnav.stories.js +54 -16
- package/dist/cjs/mocks/index.js +4 -3
- package/dist/esm/Panel.js +84 -109
- package/dist/esm/Panel.stories.js +20 -9
- package/dist/esm/components/AccountForm/addon-interactions.stories.js +203 -154
- package/dist/esm/components/Interaction/Interaction.js +16 -15
- package/dist/esm/components/Interaction/Interaction.stories.js +6 -3
- package/dist/esm/components/Subnav/Subnav.js +15 -20
- package/dist/esm/components/Subnav/Subnav.stories.js +49 -13
- package/dist/esm/mocks/index.js +4 -3
- package/dist/modern/Panel.js +58 -80
- package/dist/modern/Panel.stories.js +19 -9
- package/dist/modern/components/AccountForm/addon-interactions.stories.js +19 -0
- package/dist/modern/components/Interaction/Interaction.js +14 -15
- package/dist/modern/components/Interaction/Interaction.stories.js +6 -3
- package/dist/modern/components/Subnav/Subnav.js +15 -20
- package/dist/modern/components/Subnav/Subnav.stories.js +49 -13
- package/dist/modern/mocks/index.js +4 -3
- package/dist/ts3.4/Panel.d.ts +29 -0
- package/dist/ts3.4/Tool.d.ts +2 -0
- package/dist/ts3.4/components/AccountForm/AccountForm.d.ts +15 -0
- package/dist/ts3.4/components/Interaction/Interaction.d.ts +9 -0
- package/dist/ts3.4/components/List.d.ts +14 -0
- package/dist/ts3.4/components/MatcherResult.d.ts +12 -0
- package/dist/ts3.4/components/MethodCall.d.ts +55 -0
- package/dist/ts3.4/components/StatusBadge/StatusBadge.d.ts +6 -0
- package/dist/ts3.4/components/StatusIcon/StatusIcon.d.ts +7 -0
- package/dist/ts3.4/components/Subnav/Subnav.d.ts +12 -0
- package/dist/ts3.4/constants.d.ts +3 -0
- package/dist/ts3.4/index.d.ts +2 -0
- package/dist/ts3.4/mocks/index.d.ts +2 -0
- package/dist/ts3.4/preset/argsEnhancers.d.ts +3 -0
- package/dist/ts3.4/preset/checkActionsLoaded.d.ts +1 -0
- package/dist/ts3.4/register.d.ts +1 -0
- package/dist/ts3.4/theme.d.ts +14 -0
- package/dist/ts3.9/Panel.d.ts +29 -0
- package/dist/ts3.9/Tool.d.ts +2 -0
- package/dist/ts3.9/components/AccountForm/AccountForm.d.ts +15 -0
- package/dist/ts3.9/components/Interaction/Interaction.d.ts +9 -0
- package/dist/ts3.9/components/List.d.ts +14 -0
- package/dist/ts3.9/components/MatcherResult.d.ts +12 -0
- package/dist/ts3.9/components/MethodCall.d.ts +55 -0
- package/dist/ts3.9/components/StatusBadge/StatusBadge.d.ts +6 -0
- package/dist/ts3.9/components/StatusIcon/StatusIcon.d.ts +7 -0
- package/dist/ts3.9/components/Subnav/Subnav.d.ts +12 -0
- package/dist/ts3.9/constants.d.ts +3 -0
- package/dist/ts3.9/index.d.ts +2 -0
- package/dist/ts3.9/mocks/index.d.ts +2 -0
- package/dist/ts3.9/preset/argsEnhancers.d.ts +3 -0
- package/dist/ts3.9/preset/checkActionsLoaded.d.ts +1 -0
- package/dist/ts3.9/register.d.ts +1 -0
- package/dist/ts3.9/theme.d.ts +14 -0
- package/package.json +11 -11
|
@@ -87,7 +87,7 @@ var RowContainer = (0, _theming.styled)('div', {
|
|
|
87
87
|
borderBottom: "1px solid ".concat(theme.appBorderColor),
|
|
88
88
|
fontFamily: _theming.typography.fonts.base,
|
|
89
89
|
fontSize: 13
|
|
90
|
-
}, call.
|
|
90
|
+
}, call.status === _instrumenter.CallStates.ERROR && {
|
|
91
91
|
backgroundColor: theme.base === 'dark' ? (0, _polished.transparentize)(0.93, theme.color.negative) : theme.background.warning
|
|
92
92
|
});
|
|
93
93
|
});
|
|
@@ -109,17 +109,17 @@ var RowLabel = (0, _theming.styled)('button', {
|
|
|
109
109
|
margin: 0,
|
|
110
110
|
padding: '8px 15px',
|
|
111
111
|
textAlign: 'start',
|
|
112
|
-
cursor: disabled || call.
|
|
113
|
-
'&:hover': {
|
|
112
|
+
cursor: disabled || call.status === _instrumenter.CallStates.ERROR ? 'default' : 'pointer',
|
|
113
|
+
'&:hover': disabled ? {} : {
|
|
114
114
|
background: theme.background.hoverable
|
|
115
115
|
},
|
|
116
116
|
'&:focus-visible': {
|
|
117
117
|
outline: 0,
|
|
118
|
-
boxShadow: "inset 3px 0 0 0 ".concat(call.
|
|
119
|
-
background: call.
|
|
118
|
+
boxShadow: "inset 3px 0 0 0 ".concat(call.status === _instrumenter.CallStates.ERROR ? theme.color.warning : theme.color.secondary),
|
|
119
|
+
background: call.status === _instrumenter.CallStates.ERROR ? 'transparent' : theme.background.hoverable
|
|
120
120
|
},
|
|
121
121
|
'& > div': {
|
|
122
|
-
opacity: call.
|
|
122
|
+
opacity: call.status === _instrumenter.CallStates.WAITING ? 0.5 : 1
|
|
123
123
|
}
|
|
124
124
|
};
|
|
125
125
|
});
|
|
@@ -132,9 +132,8 @@ var RowMessage = (0, _theming.styled)('pre')({
|
|
|
132
132
|
var Interaction = function Interaction(_ref3) {
|
|
133
133
|
var call = _ref3.call,
|
|
134
134
|
callsById = _ref3.callsById,
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
isDebuggingEnabled = _ref3.isDebuggingEnabled;
|
|
135
|
+
controls = _ref3.controls,
|
|
136
|
+
controlStates = _ref3.controlStates;
|
|
138
137
|
|
|
139
138
|
var _React$useState = React.useState(false),
|
|
140
139
|
_React$useState2 = _slicedToArray(_React$useState, 2),
|
|
@@ -145,16 +144,18 @@ var Interaction = function Interaction(_ref3) {
|
|
|
145
144
|
call: call
|
|
146
145
|
}, /*#__PURE__*/React.createElement(RowLabel, {
|
|
147
146
|
call: call,
|
|
148
|
-
onClick: onClick
|
|
149
|
-
|
|
147
|
+
onClick: function onClick() {
|
|
148
|
+
return controls.goto(call.id);
|
|
149
|
+
},
|
|
150
|
+
disabled: !controlStates.goto,
|
|
150
151
|
onMouseEnter: function onMouseEnter() {
|
|
151
|
-
return
|
|
152
|
+
return controlStates.goto && setIsHovered(true);
|
|
152
153
|
},
|
|
153
154
|
onMouseLeave: function onMouseLeave() {
|
|
154
|
-
return
|
|
155
|
+
return controlStates.goto && setIsHovered(false);
|
|
155
156
|
}
|
|
156
157
|
}, /*#__PURE__*/React.createElement(_StatusIcon.StatusIcon, {
|
|
157
|
-
status: isHovered ? _instrumenter.CallStates.ACTIVE : call.
|
|
158
|
+
status: isHovered ? _instrumenter.CallStates.ACTIVE : call.status
|
|
158
159
|
}), /*#__PURE__*/React.createElement(MethodCallWrapper, {
|
|
159
160
|
style: {
|
|
160
161
|
marginLeft: 6,
|
|
@@ -163,7 +164,7 @@ var Interaction = function Interaction(_ref3) {
|
|
|
163
164
|
}, /*#__PURE__*/React.createElement(_MethodCall.MethodCall, {
|
|
164
165
|
call: call,
|
|
165
166
|
callsById: callsById
|
|
166
|
-
}))), call.
|
|
167
|
+
}))), call.status === _instrumenter.CallStates.ERROR && call.exception && (call.exception.message.startsWith('expect(') ? /*#__PURE__*/React.createElement(_MatcherResult.MatcherResult, call.exception) : /*#__PURE__*/React.createElement(RowMessage, null, call.exception.message)));
|
|
167
168
|
};
|
|
168
169
|
|
|
169
170
|
exports.Interaction = Interaction;
|
|
@@ -31,6 +31,10 @@ var _mocks = require("../../mocks");
|
|
|
31
31
|
|
|
32
32
|
var _Interaction = require("./Interaction");
|
|
33
33
|
|
|
34
|
+
var _Subnav = _interopRequireDefault(require("../Subnav/Subnav.stories"));
|
|
35
|
+
|
|
36
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
37
|
+
|
|
34
38
|
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
|
|
35
39
|
|
|
36
40
|
function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
|
|
@@ -40,8 +44,8 @@ var _default = {
|
|
|
40
44
|
component: _Interaction.Interaction,
|
|
41
45
|
args: {
|
|
42
46
|
callsById: new Map(),
|
|
43
|
-
|
|
44
|
-
|
|
47
|
+
controls: _Subnav.default.args.controls,
|
|
48
|
+
controlStates: _Subnav.default.args.controlStates
|
|
45
49
|
}
|
|
46
50
|
};
|
|
47
51
|
exports.default = _default;
|
|
@@ -71,7 +75,9 @@ var Done = {
|
|
|
71
75
|
exports.Done = Done;
|
|
72
76
|
var Disabled = {
|
|
73
77
|
args: Object.assign({}, Done.args, {
|
|
74
|
-
|
|
78
|
+
controlStates: Object.assign({}, _Subnav.default.args.controlStates, {
|
|
79
|
+
goto: false
|
|
80
|
+
})
|
|
75
81
|
})
|
|
76
82
|
};
|
|
77
83
|
exports.Disabled = Disabled;
|
|
@@ -103,15 +103,10 @@ var withTooltipModifiers = [{
|
|
|
103
103
|
}];
|
|
104
104
|
|
|
105
105
|
var Subnav = function Subnav(_ref6) {
|
|
106
|
-
var
|
|
107
|
-
|
|
108
|
-
hasPrevious = _ref6.hasPrevious,
|
|
109
|
-
storyFileName = _ref6.storyFileName,
|
|
106
|
+
var controls = _ref6.controls,
|
|
107
|
+
controlStates = _ref6.controlStates,
|
|
110
108
|
status = _ref6.status,
|
|
111
|
-
|
|
112
|
-
onPrevious = _ref6.onPrevious,
|
|
113
|
-
onNext = _ref6.onNext,
|
|
114
|
-
onEnd = _ref6.onEnd,
|
|
109
|
+
storyFileName = _ref6.storyFileName,
|
|
115
110
|
onScrollToEnd = _ref6.onScrollToEnd;
|
|
116
111
|
var buttonText = status === _instrumenter.CallStates.ERROR ? 'Scroll to error' : 'Scroll to end';
|
|
117
112
|
return /*#__PURE__*/_react.default.createElement(_components.Bar, null, /*#__PURE__*/_react.default.createElement(StyledSubnav, null, /*#__PURE__*/_react.default.createElement(Group, null, /*#__PURE__*/_react.default.createElement(_StatusBadge.StatusBadge, {
|
|
@@ -122,49 +117,49 @@ var Subnav = function Subnav(_ref6) {
|
|
|
122
117
|
}, buttonText), /*#__PURE__*/_react.default.createElement(StyledSeparator, null), /*#__PURE__*/_react.default.createElement(_components.WithTooltip, {
|
|
123
118
|
modifiers: withTooltipModifiers,
|
|
124
119
|
hasChrome: false,
|
|
125
|
-
trigger:
|
|
120
|
+
trigger: controlStates.start ? 'hover' : 'none',
|
|
126
121
|
tooltip: /*#__PURE__*/_react.default.createElement(Note, {
|
|
127
122
|
note: "Go to start"
|
|
128
123
|
})
|
|
129
124
|
}, /*#__PURE__*/_react.default.createElement(RewindButton, {
|
|
130
|
-
onClick:
|
|
131
|
-
disabled:
|
|
125
|
+
onClick: controls.start,
|
|
126
|
+
disabled: !controlStates.start
|
|
132
127
|
}, /*#__PURE__*/_react.default.createElement(_components.Icons, {
|
|
133
128
|
icon: "rewind"
|
|
134
129
|
}))), /*#__PURE__*/_react.default.createElement(_components.WithTooltip, {
|
|
135
130
|
modifiers: withTooltipModifiers,
|
|
136
131
|
hasChrome: false,
|
|
137
|
-
trigger:
|
|
132
|
+
trigger: controlStates.back ? 'hover' : 'none',
|
|
138
133
|
tooltip: /*#__PURE__*/_react.default.createElement(Note, {
|
|
139
134
|
note: "Go back"
|
|
140
135
|
})
|
|
141
136
|
}, /*#__PURE__*/_react.default.createElement(StyledIconButton, {
|
|
142
|
-
onClick:
|
|
143
|
-
disabled:
|
|
137
|
+
onClick: controls.back,
|
|
138
|
+
disabled: !controlStates.back
|
|
144
139
|
}, /*#__PURE__*/_react.default.createElement(_components.Icons, {
|
|
145
140
|
icon: "playback"
|
|
146
141
|
}))), /*#__PURE__*/_react.default.createElement(_components.WithTooltip, {
|
|
147
142
|
modifiers: withTooltipModifiers,
|
|
148
143
|
hasChrome: false,
|
|
149
|
-
trigger:
|
|
144
|
+
trigger: controlStates.next ? 'hover' : 'none',
|
|
150
145
|
tooltip: /*#__PURE__*/_react.default.createElement(Note, {
|
|
151
146
|
note: "Go forward"
|
|
152
147
|
})
|
|
153
148
|
}, /*#__PURE__*/_react.default.createElement(StyledIconButton, {
|
|
154
|
-
onClick:
|
|
155
|
-
disabled:
|
|
149
|
+
onClick: controls.next,
|
|
150
|
+
disabled: !controlStates.next
|
|
156
151
|
}, /*#__PURE__*/_react.default.createElement(_components.Icons, {
|
|
157
152
|
icon: "playnext"
|
|
158
153
|
}))), /*#__PURE__*/_react.default.createElement(_components.WithTooltip, {
|
|
159
154
|
modifiers: withTooltipModifiers,
|
|
160
|
-
trigger:
|
|
155
|
+
trigger: controlStates.end ? 'hover' : 'none',
|
|
161
156
|
hasChrome: false,
|
|
162
157
|
tooltip: /*#__PURE__*/_react.default.createElement(Note, {
|
|
163
158
|
note: "Go to end"
|
|
164
159
|
})
|
|
165
160
|
}, /*#__PURE__*/_react.default.createElement(StyledIconButton, {
|
|
166
|
-
onClick:
|
|
167
|
-
disabled:
|
|
161
|
+
onClick: controls.end,
|
|
162
|
+
disabled: !controlStates.end
|
|
168
163
|
}, /*#__PURE__*/_react.default.createElement(_components.Icons, {
|
|
169
164
|
icon: "fastforward"
|
|
170
165
|
})))), storyFileName && /*#__PURE__*/_react.default.createElement(Group, null, /*#__PURE__*/_react.default.createElement(StyledLocation, null, storyFileName))));
|
|
@@ -3,7 +3,9 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.
|
|
6
|
+
exports.Locked = exports.Midway = exports.AtStart = exports.Runs = exports.Fail = exports.Pass = exports.default = void 0;
|
|
7
|
+
|
|
8
|
+
var _addonActions = require("@storybook/addon-actions");
|
|
7
9
|
|
|
8
10
|
var _instrumenter = require("@storybook/instrumenter");
|
|
9
11
|
|
|
@@ -13,11 +15,21 @@ var _default = {
|
|
|
13
15
|
title: 'Addons/Interactions/Subnav',
|
|
14
16
|
component: _Subnav.Subnav,
|
|
15
17
|
args: {
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
18
|
+
controls: {
|
|
19
|
+
start: (0, _addonActions.action)('start'),
|
|
20
|
+
back: (0, _addonActions.action)('back'),
|
|
21
|
+
goto: (0, _addonActions.action)('goto'),
|
|
22
|
+
next: (0, _addonActions.action)('next'),
|
|
23
|
+
end: (0, _addonActions.action)('end')
|
|
24
|
+
},
|
|
25
|
+
controlStates: {
|
|
26
|
+
debugger: true,
|
|
27
|
+
start: true,
|
|
28
|
+
back: true,
|
|
29
|
+
goto: true,
|
|
30
|
+
next: false,
|
|
31
|
+
end: false
|
|
32
|
+
},
|
|
21
33
|
storyFileName: 'Subnav.stories.tsx',
|
|
22
34
|
hasNext: true,
|
|
23
35
|
hasPrevious: true
|
|
@@ -42,19 +54,45 @@ var Runs = {
|
|
|
42
54
|
}
|
|
43
55
|
};
|
|
44
56
|
exports.Runs = Runs;
|
|
45
|
-
var
|
|
46
|
-
|
|
57
|
+
var AtStart = {
|
|
58
|
+
args: {
|
|
59
|
+
status: _instrumenter.CallStates.WAITING,
|
|
60
|
+
controlStates: {
|
|
61
|
+
debugger: true,
|
|
62
|
+
start: false,
|
|
63
|
+
back: false,
|
|
64
|
+
goto: true,
|
|
65
|
+
next: true,
|
|
66
|
+
end: true
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
};
|
|
70
|
+
exports.AtStart = AtStart;
|
|
71
|
+
var Midway = {
|
|
47
72
|
args: {
|
|
48
|
-
status: _instrumenter.CallStates.
|
|
49
|
-
|
|
73
|
+
status: _instrumenter.CallStates.WAITING,
|
|
74
|
+
controlStates: {
|
|
75
|
+
debugger: true,
|
|
76
|
+
start: true,
|
|
77
|
+
back: true,
|
|
78
|
+
goto: true,
|
|
79
|
+
next: true,
|
|
80
|
+
end: true
|
|
81
|
+
}
|
|
50
82
|
}
|
|
51
83
|
};
|
|
52
|
-
exports.
|
|
53
|
-
var
|
|
54
|
-
name: 'at the end',
|
|
84
|
+
exports.Midway = Midway;
|
|
85
|
+
var Locked = {
|
|
55
86
|
args: {
|
|
56
|
-
status: _instrumenter.CallStates.
|
|
57
|
-
|
|
87
|
+
status: _instrumenter.CallStates.ACTIVE,
|
|
88
|
+
controlStates: {
|
|
89
|
+
debugger: true,
|
|
90
|
+
start: false,
|
|
91
|
+
back: false,
|
|
92
|
+
goto: false,
|
|
93
|
+
next: false,
|
|
94
|
+
end: false
|
|
95
|
+
}
|
|
58
96
|
}
|
|
59
97
|
};
|
|
60
|
-
exports.
|
|
98
|
+
exports.Locked = Locked;
|
package/dist/cjs/mocks/index.js
CHANGED
|
@@ -9,9 +9,10 @@ require("core-js/modules/es.object.assign.js");
|
|
|
9
9
|
|
|
10
10
|
var _instrumenter = require("@storybook/instrumenter");
|
|
11
11
|
|
|
12
|
-
var getCall = function getCall(
|
|
12
|
+
var getCall = function getCall(status) {
|
|
13
13
|
var defaultData = {
|
|
14
14
|
id: 'addons-interactions-accountform--standard-email-filled [3] change',
|
|
15
|
+
cursor: 0,
|
|
15
16
|
path: ['fireEvent'],
|
|
16
17
|
method: 'change',
|
|
17
18
|
storyId: 'addons-interactions-accountform--standard-email-filled',
|
|
@@ -25,11 +26,11 @@ var getCall = function getCall(state) {
|
|
|
25
26
|
}],
|
|
26
27
|
interceptable: true,
|
|
27
28
|
retain: false,
|
|
28
|
-
|
|
29
|
+
status: status
|
|
29
30
|
};
|
|
30
31
|
var overrides = _instrumenter.CallStates.ERROR ? {
|
|
31
32
|
exception: {
|
|
32
|
-
|
|
33
|
+
name: 'Error',
|
|
33
34
|
stack: '',
|
|
34
35
|
message: "Things didn't work!"
|
|
35
36
|
}
|
package/dist/esm/Panel.js
CHANGED
|
@@ -25,8 +25,6 @@ import "core-js/modules/es.array.slice.js";
|
|
|
25
25
|
import "core-js/modules/es.string.split.js";
|
|
26
26
|
import "core-js/modules/es.regexp.exec.js";
|
|
27
27
|
import "core-js/modules/es.regexp.to-string.js";
|
|
28
|
-
import "core-js/modules/es.array.includes.js";
|
|
29
|
-
import "core-js/modules/es.string.includes.js";
|
|
30
28
|
import "core-js/modules/es.object.keys.js";
|
|
31
29
|
import "core-js/modules/es.symbol.js";
|
|
32
30
|
import "core-js/modules/es.symbol.description.js";
|
|
@@ -41,7 +39,7 @@ function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) r
|
|
|
41
39
|
import global from 'global';
|
|
42
40
|
import * as React from 'react';
|
|
43
41
|
import ReactDOM from 'react-dom';
|
|
44
|
-
import { useChannel, useParameter
|
|
42
|
+
import { useChannel, useParameter } from '@storybook/api';
|
|
45
43
|
import { STORY_RENDER_PHASE_CHANGED } from '@storybook/core-events';
|
|
46
44
|
import { AddonPanel, Link, Placeholder } from '@storybook/components';
|
|
47
45
|
import { EVENTS, CallStates } from '@storybook/instrumenter';
|
|
@@ -49,9 +47,14 @@ import { styled } from '@storybook/theming';
|
|
|
49
47
|
import { StatusIcon } from './components/StatusIcon/StatusIcon';
|
|
50
48
|
import { Subnav } from './components/Subnav/Subnav';
|
|
51
49
|
import { Interaction } from './components/Interaction/Interaction';
|
|
52
|
-
var
|
|
53
|
-
|
|
54
|
-
|
|
50
|
+
var INITIAL_CONTROL_STATES = {
|
|
51
|
+
debugger: false,
|
|
52
|
+
start: false,
|
|
53
|
+
back: false,
|
|
54
|
+
goto: false,
|
|
55
|
+
next: false,
|
|
56
|
+
end: false
|
|
57
|
+
};
|
|
55
58
|
var TabIcon = styled(StatusIcon)({
|
|
56
59
|
marginLeft: 5
|
|
57
60
|
});
|
|
@@ -63,46 +66,31 @@ var TabStatus = function TabStatus(_ref) {
|
|
|
63
66
|
};
|
|
64
67
|
|
|
65
68
|
export var AddonPanelPure = /*#__PURE__*/React.memo(function (_ref2) {
|
|
66
|
-
var
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
69
|
+
var calls = _ref2.calls,
|
|
70
|
+
controls = _ref2.controls,
|
|
71
|
+
controlStates = _ref2.controlStates,
|
|
72
|
+
interactions = _ref2.interactions,
|
|
70
73
|
fileName = _ref2.fileName,
|
|
71
74
|
hasException = _ref2.hasException,
|
|
72
75
|
isPlaying = _ref2.isPlaying,
|
|
73
|
-
onStart = _ref2.onStart,
|
|
74
|
-
onPrevious = _ref2.onPrevious,
|
|
75
|
-
onNext = _ref2.onNext,
|
|
76
|
-
onEnd = _ref2.onEnd,
|
|
77
76
|
onScrollToEnd = _ref2.onScrollToEnd,
|
|
78
|
-
calls = _ref2.calls,
|
|
79
|
-
onInteractionClick = _ref2.onInteractionClick,
|
|
80
77
|
endRef = _ref2.endRef,
|
|
81
|
-
|
|
82
|
-
panelProps = _objectWithoutProperties(_ref2, ["interactions", "isDisabled", "hasPrevious", "hasNext", "fileName", "hasException", "isPlaying", "onStart", "onPrevious", "onNext", "onEnd", "onScrollToEnd", "calls", "onInteractionClick", "endRef", "isDebuggingEnabled"]);
|
|
78
|
+
panelProps = _objectWithoutProperties(_ref2, ["calls", "controls", "controlStates", "interactions", "fileName", "hasException", "isPlaying", "onScrollToEnd", "endRef"]);
|
|
83
79
|
|
|
84
|
-
return /*#__PURE__*/React.createElement(AddonPanel, panelProps,
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
hasNext: hasNext,
|
|
88
|
-
storyFileName: fileName,
|
|
80
|
+
return /*#__PURE__*/React.createElement(AddonPanel, panelProps, controlStates.debugger && interactions.length > 0 && /*#__PURE__*/React.createElement(Subnav, {
|
|
81
|
+
controls: controls,
|
|
82
|
+
controlStates: controlStates,
|
|
89
83
|
status: // eslint-disable-next-line no-nested-ternary
|
|
90
84
|
isPlaying ? CallStates.ACTIVE : hasException ? CallStates.ERROR : CallStates.DONE,
|
|
91
|
-
|
|
92
|
-
onPrevious: onPrevious,
|
|
93
|
-
onNext: onNext,
|
|
94
|
-
onEnd: onEnd,
|
|
85
|
+
storyFileName: fileName,
|
|
95
86
|
onScrollToEnd: onScrollToEnd
|
|
96
87
|
}), interactions.map(function (call) {
|
|
97
88
|
return /*#__PURE__*/React.createElement(Interaction, {
|
|
98
89
|
key: call.id,
|
|
99
90
|
call: call,
|
|
100
91
|
callsById: calls,
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
onClick: function onClick() {
|
|
104
|
-
return onInteractionClick(call.id);
|
|
105
|
-
}
|
|
92
|
+
controls: controls,
|
|
93
|
+
controlStates: controlStates
|
|
106
94
|
});
|
|
107
95
|
}), /*#__PURE__*/React.createElement("div", {
|
|
108
96
|
ref: endRef
|
|
@@ -115,40 +103,46 @@ export var AddonPanelPure = /*#__PURE__*/React.memo(function (_ref2) {
|
|
|
115
103
|
export var Panel = function Panel(props) {
|
|
116
104
|
var _useChannel;
|
|
117
105
|
|
|
118
|
-
var _React$useState = React.useState(
|
|
106
|
+
var _React$useState = React.useState(),
|
|
119
107
|
_React$useState2 = _slicedToArray(_React$useState, 2),
|
|
120
|
-
|
|
121
|
-
|
|
108
|
+
storyId = _React$useState2[0],
|
|
109
|
+
setStoryId = _React$useState2[1];
|
|
122
110
|
|
|
123
|
-
var _React$useState3 = React.useState(
|
|
111
|
+
var _React$useState3 = React.useState(INITIAL_CONTROL_STATES),
|
|
124
112
|
_React$useState4 = _slicedToArray(_React$useState3, 2),
|
|
125
|
-
|
|
126
|
-
|
|
113
|
+
controlStates = _React$useState4[0],
|
|
114
|
+
setControlStates = _React$useState4[1];
|
|
127
115
|
|
|
128
|
-
var _React$useState5 = React.useState(),
|
|
116
|
+
var _React$useState5 = React.useState(false),
|
|
129
117
|
_React$useState6 = _slicedToArray(_React$useState5, 2),
|
|
130
|
-
|
|
131
|
-
|
|
118
|
+
isPlaying = _React$useState6[0],
|
|
119
|
+
setPlaying = _React$useState6[1];
|
|
120
|
+
|
|
121
|
+
var _React$useState7 = React.useState(),
|
|
122
|
+
_React$useState8 = _slicedToArray(_React$useState7, 2),
|
|
123
|
+
scrollTarget = _React$useState8[0],
|
|
124
|
+
setScrollTarget = _React$useState8[1]; // Calls are tracked in a ref so we don't needlessly rerender.
|
|
125
|
+
|
|
132
126
|
|
|
133
127
|
var calls = React.useRef(new Map());
|
|
134
128
|
|
|
135
129
|
var setCall = function setCall(_ref3) {
|
|
136
|
-
var
|
|
137
|
-
call = _objectWithoutProperties(_ref3, ["
|
|
130
|
+
var status = _ref3.status,
|
|
131
|
+
call = _objectWithoutProperties(_ref3, ["status"]);
|
|
138
132
|
|
|
139
133
|
return calls.current.set(call.id, call);
|
|
140
134
|
};
|
|
141
135
|
|
|
142
|
-
var _React$
|
|
143
|
-
_React$
|
|
144
|
-
log = _React$
|
|
145
|
-
setLog = _React$
|
|
136
|
+
var _React$useState9 = React.useState([]),
|
|
137
|
+
_React$useState10 = _slicedToArray(_React$useState9, 2),
|
|
138
|
+
log = _React$useState10[0],
|
|
139
|
+
setLog = _React$useState10[1];
|
|
146
140
|
|
|
147
141
|
var interactions = log.map(function (_ref4) {
|
|
148
142
|
var callId = _ref4.callId,
|
|
149
|
-
|
|
143
|
+
status = _ref4.status;
|
|
150
144
|
return Object.assign({}, calls.current.get(callId), {
|
|
151
|
-
|
|
145
|
+
status: status
|
|
152
146
|
});
|
|
153
147
|
});
|
|
154
148
|
var endRef = React.useRef();
|
|
@@ -166,15 +160,43 @@ export var Panel = function Panel(props) {
|
|
|
166
160
|
return observer.disconnect();
|
|
167
161
|
};
|
|
168
162
|
}, []);
|
|
169
|
-
var emit = useChannel((_useChannel = {}, _defineProperty(_useChannel, EVENTS.CALL, setCall), _defineProperty(_useChannel, EVENTS.SYNC,
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
163
|
+
var emit = useChannel((_useChannel = {}, _defineProperty(_useChannel, EVENTS.CALL, setCall), _defineProperty(_useChannel, EVENTS.SYNC, function (payload) {
|
|
164
|
+
setControlStates(payload.controlStates);
|
|
165
|
+
setLog(payload.logItems);
|
|
166
|
+
}), _defineProperty(_useChannel, STORY_RENDER_PHASE_CHANGED, function (event) {
|
|
167
|
+
setStoryId(event.storyId);
|
|
168
|
+
setPlaying(event.newPhase === 'playing');
|
|
169
|
+
}), _useChannel), []);
|
|
170
|
+
var controls = React.useMemo(function () {
|
|
171
|
+
return {
|
|
172
|
+
start: function start() {
|
|
173
|
+
return emit(EVENTS.START, {
|
|
174
|
+
storyId: storyId
|
|
175
|
+
});
|
|
176
|
+
},
|
|
177
|
+
back: function back() {
|
|
178
|
+
return emit(EVENTS.BACK, {
|
|
179
|
+
storyId: storyId
|
|
180
|
+
});
|
|
181
|
+
},
|
|
182
|
+
goto: function goto(callId) {
|
|
183
|
+
return emit(EVENTS.GOTO, {
|
|
184
|
+
storyId: storyId,
|
|
185
|
+
callId: callId
|
|
186
|
+
});
|
|
187
|
+
},
|
|
188
|
+
next: function next() {
|
|
189
|
+
return emit(EVENTS.NEXT, {
|
|
190
|
+
storyId: storyId
|
|
191
|
+
});
|
|
192
|
+
},
|
|
193
|
+
end: function end() {
|
|
194
|
+
return emit(EVENTS.END, {
|
|
195
|
+
storyId: storyId
|
|
196
|
+
});
|
|
197
|
+
}
|
|
198
|
+
};
|
|
199
|
+
}, [storyId]);
|
|
178
200
|
var storyFilePath = useParameter('fileName', '');
|
|
179
201
|
|
|
180
202
|
var _storyFilePath$toStri = storyFilePath.toString().split('/').slice(-1),
|
|
@@ -188,70 +210,23 @@ export var Panel = function Panel(props) {
|
|
|
188
210
|
});
|
|
189
211
|
};
|
|
190
212
|
|
|
191
|
-
var isDebuggingEnabled = FEATURES.interactionsDebugger === true;
|
|
192
213
|
var showStatus = log.length > 0 && !isPlaying;
|
|
193
|
-
var isDebugging = log.some(function (item) {
|
|
194
|
-
return pendingStates.includes(item.state);
|
|
195
|
-
});
|
|
196
|
-
var hasPrevious = log.some(function (item) {
|
|
197
|
-
return completedStates.includes(item.state);
|
|
198
|
-
});
|
|
199
|
-
var hasNext = log.some(function (item) {
|
|
200
|
-
return item.state === CallStates.WAITING;
|
|
201
|
-
});
|
|
202
|
-
var hasActive = log.some(function (item) {
|
|
203
|
-
return item.state === CallStates.ACTIVE;
|
|
204
|
-
});
|
|
205
214
|
var hasException = log.some(function (item) {
|
|
206
|
-
return item.
|
|
215
|
+
return item.status === CallStates.ERROR;
|
|
207
216
|
});
|
|
208
|
-
var isDisabled = isDebuggingEnabled ? hasActive || isLocked || isPlaying && !isDebugging : true;
|
|
209
|
-
var onStart = React.useCallback(function () {
|
|
210
|
-
return emit(EVENTS.START, {
|
|
211
|
-
storyId: storyId
|
|
212
|
-
});
|
|
213
|
-
}, [storyId]);
|
|
214
|
-
var onPrevious = React.useCallback(function () {
|
|
215
|
-
return emit(EVENTS.BACK, {
|
|
216
|
-
storyId: storyId
|
|
217
|
-
});
|
|
218
|
-
}, [storyId]);
|
|
219
|
-
var onNext = React.useCallback(function () {
|
|
220
|
-
return emit(EVENTS.NEXT, {
|
|
221
|
-
storyId: storyId
|
|
222
|
-
});
|
|
223
|
-
}, [storyId]);
|
|
224
|
-
var onEnd = React.useCallback(function () {
|
|
225
|
-
return emit(EVENTS.END, {
|
|
226
|
-
storyId: storyId
|
|
227
|
-
});
|
|
228
|
-
}, [storyId]);
|
|
229
|
-
var onInteractionClick = React.useCallback(function (callId) {
|
|
230
|
-
return emit(EVENTS.GOTO, {
|
|
231
|
-
storyId: storyId,
|
|
232
|
-
callId: callId
|
|
233
|
-
});
|
|
234
|
-
}, [storyId]);
|
|
235
217
|
return /*#__PURE__*/React.createElement(React.Fragment, {
|
|
236
218
|
key: "interactions"
|
|
237
219
|
}, /*#__PURE__*/React.createElement(TabStatus, null, showStatus && (hasException ? /*#__PURE__*/React.createElement(TabIcon, {
|
|
238
220
|
status: CallStates.ERROR
|
|
239
221
|
}) : " (".concat(interactions.length, ")"))), /*#__PURE__*/React.createElement(AddonPanelPure, _extends({
|
|
222
|
+
calls: calls.current,
|
|
223
|
+
controls: controls,
|
|
224
|
+
controlStates: controlStates,
|
|
240
225
|
interactions: interactions,
|
|
241
|
-
isDisabled: isDisabled,
|
|
242
|
-
hasPrevious: hasPrevious,
|
|
243
|
-
hasNext: hasNext,
|
|
244
226
|
fileName: fileName,
|
|
245
227
|
hasException: hasException,
|
|
246
228
|
isPlaying: isPlaying,
|
|
247
|
-
calls: calls.current,
|
|
248
229
|
endRef: endRef,
|
|
249
|
-
isDebuggingEnabled: isDebuggingEnabled,
|
|
250
|
-
onStart: onStart,
|
|
251
|
-
onPrevious: onPrevious,
|
|
252
|
-
onNext: onNext,
|
|
253
|
-
onEnd: onEnd,
|
|
254
|
-
onInteractionClick: onInteractionClick,
|
|
255
230
|
onScrollToEnd: scrollTarget && scrollToTarget
|
|
256
231
|
}, props)));
|
|
257
232
|
};
|
|
@@ -3,11 +3,14 @@ import "core-js/modules/es.object.to-string.js";
|
|
|
3
3
|
import "core-js/modules/es.string.iterator.js";
|
|
4
4
|
import "core-js/modules/es.array.iterator.js";
|
|
5
5
|
import "core-js/modules/web.dom-collections.iterator.js";
|
|
6
|
+
import "core-js/modules/es.object.assign.js";
|
|
6
7
|
import React from 'react';
|
|
8
|
+
import { action } from '@storybook/addon-actions';
|
|
7
9
|
import { CallStates } from '@storybook/instrumenter';
|
|
8
10
|
import { styled } from '@storybook/theming';
|
|
9
11
|
import { getCall } from './mocks';
|
|
10
12
|
import { AddonPanelPure } from './Panel';
|
|
13
|
+
import SubnavStories from './components/Subnav/Subnav.stories';
|
|
11
14
|
var StyledWrapper = styled.div(function (_ref) {
|
|
12
15
|
var theme = _ref.theme;
|
|
13
16
|
return {
|
|
@@ -35,16 +38,14 @@ export default {
|
|
|
35
38
|
},
|
|
36
39
|
args: {
|
|
37
40
|
calls: new Map(),
|
|
38
|
-
|
|
41
|
+
controls: SubnavStories.args.controls,
|
|
42
|
+
controlStates: SubnavStories.args.controlStates,
|
|
43
|
+
interactions: [getCall(CallStates.DONE)],
|
|
39
44
|
fileName: 'addon-interactions.stories.tsx',
|
|
40
45
|
hasException: false,
|
|
41
|
-
hasNext: false,
|
|
42
|
-
hasPrevious: true,
|
|
43
|
-
interactions: [getCall(CallStates.DONE)],
|
|
44
|
-
isDisabled: false,
|
|
45
46
|
isPlaying: false,
|
|
46
|
-
|
|
47
|
-
|
|
47
|
+
onScrollToEnd: action('onScrollToEnd'),
|
|
48
|
+
endRef: null,
|
|
48
49
|
// prop for the AddonPanel used as wrapper of Panel
|
|
49
50
|
active: true
|
|
50
51
|
}
|
|
@@ -57,7 +58,15 @@ export var Passing = {
|
|
|
57
58
|
export var Paused = {
|
|
58
59
|
args: {
|
|
59
60
|
isPlaying: true,
|
|
60
|
-
interactions: [getCall(CallStates.WAITING)]
|
|
61
|
+
interactions: [getCall(CallStates.WAITING)],
|
|
62
|
+
controlStates: {
|
|
63
|
+
debugger: true,
|
|
64
|
+
start: false,
|
|
65
|
+
back: false,
|
|
66
|
+
goto: true,
|
|
67
|
+
next: true,
|
|
68
|
+
end: true
|
|
69
|
+
}
|
|
61
70
|
}
|
|
62
71
|
};
|
|
63
72
|
export var Playing = {
|
|
@@ -74,7 +83,9 @@ export var Failed = {
|
|
|
74
83
|
};
|
|
75
84
|
export var WithDebuggingDisabled = {
|
|
76
85
|
args: {
|
|
77
|
-
|
|
86
|
+
controlStates: Object.assign({}, SubnavStories.args.controlStates, {
|
|
87
|
+
debugger: false
|
|
88
|
+
})
|
|
78
89
|
}
|
|
79
90
|
};
|
|
80
91
|
export var NoInteractions = {
|