@storybook/addon-interactions 6.4.0-rc.7 → 6.4.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.
- 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
package/dist/cjs/Panel.js
CHANGED
|
@@ -43,10 +43,6 @@ require("core-js/modules/es.regexp.exec.js");
|
|
|
43
43
|
|
|
44
44
|
require("core-js/modules/es.regexp.to-string.js");
|
|
45
45
|
|
|
46
|
-
require("core-js/modules/es.array.includes.js");
|
|
47
|
-
|
|
48
|
-
require("core-js/modules/es.string.includes.js");
|
|
49
|
-
|
|
50
46
|
require("core-js/modules/es.object.keys.js");
|
|
51
47
|
|
|
52
48
|
var _global = _interopRequireDefault(require("global"));
|
|
@@ -97,9 +93,14 @@ function _objectWithoutProperties(source, excluded) { if (source == null) return
|
|
|
97
93
|
|
|
98
94
|
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
|
|
99
95
|
|
|
100
|
-
var
|
|
101
|
-
|
|
102
|
-
|
|
96
|
+
var INITIAL_CONTROL_STATES = {
|
|
97
|
+
debugger: false,
|
|
98
|
+
start: false,
|
|
99
|
+
back: false,
|
|
100
|
+
goto: false,
|
|
101
|
+
next: false,
|
|
102
|
+
end: false
|
|
103
|
+
};
|
|
103
104
|
var TabIcon = (0, _theming.styled)(_StatusIcon.StatusIcon)({
|
|
104
105
|
marginLeft: 5
|
|
105
106
|
});
|
|
@@ -113,46 +114,31 @@ var TabStatus = function TabStatus(_ref) {
|
|
|
113
114
|
};
|
|
114
115
|
|
|
115
116
|
var AddonPanelPure = /*#__PURE__*/React.memo(function (_ref2) {
|
|
116
|
-
var
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
117
|
+
var calls = _ref2.calls,
|
|
118
|
+
controls = _ref2.controls,
|
|
119
|
+
controlStates = _ref2.controlStates,
|
|
120
|
+
interactions = _ref2.interactions,
|
|
120
121
|
fileName = _ref2.fileName,
|
|
121
122
|
hasException = _ref2.hasException,
|
|
122
123
|
isPlaying = _ref2.isPlaying,
|
|
123
|
-
onStart = _ref2.onStart,
|
|
124
|
-
onPrevious = _ref2.onPrevious,
|
|
125
|
-
onNext = _ref2.onNext,
|
|
126
|
-
onEnd = _ref2.onEnd,
|
|
127
124
|
onScrollToEnd = _ref2.onScrollToEnd,
|
|
128
|
-
calls = _ref2.calls,
|
|
129
|
-
onInteractionClick = _ref2.onInteractionClick,
|
|
130
125
|
endRef = _ref2.endRef,
|
|
131
|
-
|
|
132
|
-
panelProps = _objectWithoutProperties(_ref2, ["interactions", "isDisabled", "hasPrevious", "hasNext", "fileName", "hasException", "isPlaying", "onStart", "onPrevious", "onNext", "onEnd", "onScrollToEnd", "calls", "onInteractionClick", "endRef", "isDebuggingEnabled"]);
|
|
126
|
+
panelProps = _objectWithoutProperties(_ref2, ["calls", "controls", "controlStates", "interactions", "fileName", "hasException", "isPlaying", "onScrollToEnd", "endRef"]);
|
|
133
127
|
|
|
134
|
-
return /*#__PURE__*/React.createElement(_components.AddonPanel, panelProps,
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
hasNext: hasNext,
|
|
138
|
-
storyFileName: fileName,
|
|
128
|
+
return /*#__PURE__*/React.createElement(_components.AddonPanel, panelProps, controlStates.debugger && interactions.length > 0 && /*#__PURE__*/React.createElement(_Subnav.Subnav, {
|
|
129
|
+
controls: controls,
|
|
130
|
+
controlStates: controlStates,
|
|
139
131
|
status: // eslint-disable-next-line no-nested-ternary
|
|
140
132
|
isPlaying ? _instrumenter.CallStates.ACTIVE : hasException ? _instrumenter.CallStates.ERROR : _instrumenter.CallStates.DONE,
|
|
141
|
-
|
|
142
|
-
onPrevious: onPrevious,
|
|
143
|
-
onNext: onNext,
|
|
144
|
-
onEnd: onEnd,
|
|
133
|
+
storyFileName: fileName,
|
|
145
134
|
onScrollToEnd: onScrollToEnd
|
|
146
135
|
}), interactions.map(function (call) {
|
|
147
136
|
return /*#__PURE__*/React.createElement(_Interaction.Interaction, {
|
|
148
137
|
key: call.id,
|
|
149
138
|
call: call,
|
|
150
139
|
callsById: calls,
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
onClick: function onClick() {
|
|
154
|
-
return onInteractionClick(call.id);
|
|
155
|
-
}
|
|
140
|
+
controls: controls,
|
|
141
|
+
controlStates: controlStates
|
|
156
142
|
});
|
|
157
143
|
}), /*#__PURE__*/React.createElement("div", {
|
|
158
144
|
ref: endRef
|
|
@@ -167,40 +153,46 @@ exports.AddonPanelPure = AddonPanelPure;
|
|
|
167
153
|
var Panel = function Panel(props) {
|
|
168
154
|
var _useChannel;
|
|
169
155
|
|
|
170
|
-
var _React$useState = React.useState(
|
|
156
|
+
var _React$useState = React.useState(),
|
|
171
157
|
_React$useState2 = _slicedToArray(_React$useState, 2),
|
|
172
|
-
|
|
173
|
-
|
|
158
|
+
storyId = _React$useState2[0],
|
|
159
|
+
setStoryId = _React$useState2[1];
|
|
174
160
|
|
|
175
|
-
var _React$useState3 = React.useState(
|
|
161
|
+
var _React$useState3 = React.useState(INITIAL_CONTROL_STATES),
|
|
176
162
|
_React$useState4 = _slicedToArray(_React$useState3, 2),
|
|
177
|
-
|
|
178
|
-
|
|
163
|
+
controlStates = _React$useState4[0],
|
|
164
|
+
setControlStates = _React$useState4[1];
|
|
179
165
|
|
|
180
|
-
var _React$useState5 = React.useState(),
|
|
166
|
+
var _React$useState5 = React.useState(false),
|
|
181
167
|
_React$useState6 = _slicedToArray(_React$useState5, 2),
|
|
182
|
-
|
|
183
|
-
|
|
168
|
+
isPlaying = _React$useState6[0],
|
|
169
|
+
setPlaying = _React$useState6[1];
|
|
170
|
+
|
|
171
|
+
var _React$useState7 = React.useState(),
|
|
172
|
+
_React$useState8 = _slicedToArray(_React$useState7, 2),
|
|
173
|
+
scrollTarget = _React$useState8[0],
|
|
174
|
+
setScrollTarget = _React$useState8[1]; // Calls are tracked in a ref so we don't needlessly rerender.
|
|
175
|
+
|
|
184
176
|
|
|
185
177
|
var calls = React.useRef(new Map());
|
|
186
178
|
|
|
187
179
|
var setCall = function setCall(_ref3) {
|
|
188
|
-
var
|
|
189
|
-
call = _objectWithoutProperties(_ref3, ["
|
|
180
|
+
var status = _ref3.status,
|
|
181
|
+
call = _objectWithoutProperties(_ref3, ["status"]);
|
|
190
182
|
|
|
191
183
|
return calls.current.set(call.id, call);
|
|
192
184
|
};
|
|
193
185
|
|
|
194
|
-
var _React$
|
|
195
|
-
_React$
|
|
196
|
-
log = _React$
|
|
197
|
-
setLog = _React$
|
|
186
|
+
var _React$useState9 = React.useState([]),
|
|
187
|
+
_React$useState10 = _slicedToArray(_React$useState9, 2),
|
|
188
|
+
log = _React$useState10[0],
|
|
189
|
+
setLog = _React$useState10[1];
|
|
198
190
|
|
|
199
191
|
var interactions = log.map(function (_ref4) {
|
|
200
192
|
var callId = _ref4.callId,
|
|
201
|
-
|
|
193
|
+
status = _ref4.status;
|
|
202
194
|
return Object.assign({}, calls.current.get(callId), {
|
|
203
|
-
|
|
195
|
+
status: status
|
|
204
196
|
});
|
|
205
197
|
});
|
|
206
198
|
var endRef = React.useRef();
|
|
@@ -218,15 +210,43 @@ var Panel = function Panel(props) {
|
|
|
218
210
|
return observer.disconnect();
|
|
219
211
|
};
|
|
220
212
|
}, []);
|
|
221
|
-
var emit = (0, _api.useChannel)((_useChannel = {}, _defineProperty(_useChannel, _instrumenter.EVENTS.CALL, setCall), _defineProperty(_useChannel, _instrumenter.EVENTS.SYNC,
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
213
|
+
var emit = (0, _api.useChannel)((_useChannel = {}, _defineProperty(_useChannel, _instrumenter.EVENTS.CALL, setCall), _defineProperty(_useChannel, _instrumenter.EVENTS.SYNC, function (payload) {
|
|
214
|
+
setControlStates(payload.controlStates);
|
|
215
|
+
setLog(payload.logItems);
|
|
216
|
+
}), _defineProperty(_useChannel, _coreEvents.STORY_RENDER_PHASE_CHANGED, function (event) {
|
|
217
|
+
setStoryId(event.storyId);
|
|
218
|
+
setPlaying(event.newPhase === 'playing');
|
|
219
|
+
}), _useChannel), []);
|
|
220
|
+
var controls = React.useMemo(function () {
|
|
221
|
+
return {
|
|
222
|
+
start: function start() {
|
|
223
|
+
return emit(_instrumenter.EVENTS.START, {
|
|
224
|
+
storyId: storyId
|
|
225
|
+
});
|
|
226
|
+
},
|
|
227
|
+
back: function back() {
|
|
228
|
+
return emit(_instrumenter.EVENTS.BACK, {
|
|
229
|
+
storyId: storyId
|
|
230
|
+
});
|
|
231
|
+
},
|
|
232
|
+
goto: function goto(callId) {
|
|
233
|
+
return emit(_instrumenter.EVENTS.GOTO, {
|
|
234
|
+
storyId: storyId,
|
|
235
|
+
callId: callId
|
|
236
|
+
});
|
|
237
|
+
},
|
|
238
|
+
next: function next() {
|
|
239
|
+
return emit(_instrumenter.EVENTS.NEXT, {
|
|
240
|
+
storyId: storyId
|
|
241
|
+
});
|
|
242
|
+
},
|
|
243
|
+
end: function end() {
|
|
244
|
+
return emit(_instrumenter.EVENTS.END, {
|
|
245
|
+
storyId: storyId
|
|
246
|
+
});
|
|
247
|
+
}
|
|
248
|
+
};
|
|
249
|
+
}, [storyId]);
|
|
230
250
|
var storyFilePath = (0, _api.useParameter)('fileName', '');
|
|
231
251
|
|
|
232
252
|
var _storyFilePath$toStri = storyFilePath.toString().split('/').slice(-1),
|
|
@@ -240,70 +260,23 @@ var Panel = function Panel(props) {
|
|
|
240
260
|
});
|
|
241
261
|
};
|
|
242
262
|
|
|
243
|
-
var isDebuggingEnabled = FEATURES.interactionsDebugger === true;
|
|
244
263
|
var showStatus = log.length > 0 && !isPlaying;
|
|
245
|
-
var isDebugging = log.some(function (item) {
|
|
246
|
-
return pendingStates.includes(item.state);
|
|
247
|
-
});
|
|
248
|
-
var hasPrevious = log.some(function (item) {
|
|
249
|
-
return completedStates.includes(item.state);
|
|
250
|
-
});
|
|
251
|
-
var hasNext = log.some(function (item) {
|
|
252
|
-
return item.state === _instrumenter.CallStates.WAITING;
|
|
253
|
-
});
|
|
254
|
-
var hasActive = log.some(function (item) {
|
|
255
|
-
return item.state === _instrumenter.CallStates.ACTIVE;
|
|
256
|
-
});
|
|
257
264
|
var hasException = log.some(function (item) {
|
|
258
|
-
return item.
|
|
265
|
+
return item.status === _instrumenter.CallStates.ERROR;
|
|
259
266
|
});
|
|
260
|
-
var isDisabled = isDebuggingEnabled ? hasActive || isLocked || isPlaying && !isDebugging : true;
|
|
261
|
-
var onStart = React.useCallback(function () {
|
|
262
|
-
return emit(_instrumenter.EVENTS.START, {
|
|
263
|
-
storyId: storyId
|
|
264
|
-
});
|
|
265
|
-
}, [storyId]);
|
|
266
|
-
var onPrevious = React.useCallback(function () {
|
|
267
|
-
return emit(_instrumenter.EVENTS.BACK, {
|
|
268
|
-
storyId: storyId
|
|
269
|
-
});
|
|
270
|
-
}, [storyId]);
|
|
271
|
-
var onNext = React.useCallback(function () {
|
|
272
|
-
return emit(_instrumenter.EVENTS.NEXT, {
|
|
273
|
-
storyId: storyId
|
|
274
|
-
});
|
|
275
|
-
}, [storyId]);
|
|
276
|
-
var onEnd = React.useCallback(function () {
|
|
277
|
-
return emit(_instrumenter.EVENTS.END, {
|
|
278
|
-
storyId: storyId
|
|
279
|
-
});
|
|
280
|
-
}, [storyId]);
|
|
281
|
-
var onInteractionClick = React.useCallback(function (callId) {
|
|
282
|
-
return emit(_instrumenter.EVENTS.GOTO, {
|
|
283
|
-
storyId: storyId,
|
|
284
|
-
callId: callId
|
|
285
|
-
});
|
|
286
|
-
}, [storyId]);
|
|
287
267
|
return /*#__PURE__*/React.createElement(React.Fragment, {
|
|
288
268
|
key: "interactions"
|
|
289
269
|
}, /*#__PURE__*/React.createElement(TabStatus, null, showStatus && (hasException ? /*#__PURE__*/React.createElement(TabIcon, {
|
|
290
270
|
status: _instrumenter.CallStates.ERROR
|
|
291
271
|
}) : " (".concat(interactions.length, ")"))), /*#__PURE__*/React.createElement(AddonPanelPure, _extends({
|
|
272
|
+
calls: calls.current,
|
|
273
|
+
controls: controls,
|
|
274
|
+
controlStates: controlStates,
|
|
292
275
|
interactions: interactions,
|
|
293
|
-
isDisabled: isDisabled,
|
|
294
|
-
hasPrevious: hasPrevious,
|
|
295
|
-
hasNext: hasNext,
|
|
296
276
|
fileName: fileName,
|
|
297
277
|
hasException: hasException,
|
|
298
278
|
isPlaying: isPlaying,
|
|
299
|
-
calls: calls.current,
|
|
300
279
|
endRef: endRef,
|
|
301
|
-
isDebuggingEnabled: isDebuggingEnabled,
|
|
302
|
-
onStart: onStart,
|
|
303
|
-
onPrevious: onPrevious,
|
|
304
|
-
onNext: onNext,
|
|
305
|
-
onEnd: onEnd,
|
|
306
|
-
onInteractionClick: onInteractionClick,
|
|
307
280
|
onScrollToEnd: scrollTarget && scrollToTarget
|
|
308
281
|
}, props)));
|
|
309
282
|
};
|
|
@@ -15,8 +15,12 @@ require("core-js/modules/es.array.iterator.js");
|
|
|
15
15
|
|
|
16
16
|
require("core-js/modules/web.dom-collections.iterator.js");
|
|
17
17
|
|
|
18
|
+
require("core-js/modules/es.object.assign.js");
|
|
19
|
+
|
|
18
20
|
var _react = _interopRequireDefault(require("react"));
|
|
19
21
|
|
|
22
|
+
var _addonActions = require("@storybook/addon-actions");
|
|
23
|
+
|
|
20
24
|
var _instrumenter = require("@storybook/instrumenter");
|
|
21
25
|
|
|
22
26
|
var _theming = require("@storybook/theming");
|
|
@@ -25,6 +29,8 @@ var _mocks = require("./mocks");
|
|
|
25
29
|
|
|
26
30
|
var _Panel = require("./Panel");
|
|
27
31
|
|
|
32
|
+
var _Subnav = _interopRequireDefault(require("./components/Subnav/Subnav.stories"));
|
|
33
|
+
|
|
28
34
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
29
35
|
|
|
30
36
|
var StyledWrapper = _theming.styled.div(function (_ref) {
|
|
@@ -55,16 +61,14 @@ var _default = {
|
|
|
55
61
|
},
|
|
56
62
|
args: {
|
|
57
63
|
calls: new Map(),
|
|
58
|
-
|
|
64
|
+
controls: _Subnav.default.args.controls,
|
|
65
|
+
controlStates: _Subnav.default.args.controlStates,
|
|
66
|
+
interactions: [(0, _mocks.getCall)(_instrumenter.CallStates.DONE)],
|
|
59
67
|
fileName: 'addon-interactions.stories.tsx',
|
|
60
68
|
hasException: false,
|
|
61
|
-
hasNext: false,
|
|
62
|
-
hasPrevious: true,
|
|
63
|
-
interactions: [(0, _mocks.getCall)(_instrumenter.CallStates.DONE)],
|
|
64
|
-
isDisabled: false,
|
|
65
69
|
isPlaying: false,
|
|
66
|
-
|
|
67
|
-
|
|
70
|
+
onScrollToEnd: (0, _addonActions.action)('onScrollToEnd'),
|
|
71
|
+
endRef: null,
|
|
68
72
|
// prop for the AddonPanel used as wrapper of Panel
|
|
69
73
|
active: true
|
|
70
74
|
}
|
|
@@ -79,7 +83,15 @@ exports.Passing = Passing;
|
|
|
79
83
|
var Paused = {
|
|
80
84
|
args: {
|
|
81
85
|
isPlaying: true,
|
|
82
|
-
interactions: [(0, _mocks.getCall)(_instrumenter.CallStates.WAITING)]
|
|
86
|
+
interactions: [(0, _mocks.getCall)(_instrumenter.CallStates.WAITING)],
|
|
87
|
+
controlStates: {
|
|
88
|
+
debugger: true,
|
|
89
|
+
start: false,
|
|
90
|
+
back: false,
|
|
91
|
+
goto: true,
|
|
92
|
+
next: true,
|
|
93
|
+
end: true
|
|
94
|
+
}
|
|
83
95
|
}
|
|
84
96
|
};
|
|
85
97
|
exports.Paused = Paused;
|
|
@@ -99,7 +111,9 @@ var Failed = {
|
|
|
99
111
|
exports.Failed = Failed;
|
|
100
112
|
var WithDebuggingDisabled = {
|
|
101
113
|
args: {
|
|
102
|
-
|
|
114
|
+
controlStates: Object.assign({}, _Subnav.default.args.controlStates, {
|
|
115
|
+
debugger: false
|
|
116
|
+
})
|
|
103
117
|
}
|
|
104
118
|
};
|
|
105
119
|
exports.WithDebuggingDisabled = WithDebuggingDisabled;
|