@storybook/addon-interactions 7.0.0-alpha.1 → 7.0.0-alpha.12
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/README.md +9 -6
- package/dist/cjs/Panel.js +139 -232
- package/dist/cjs/components/AccountForm/AccountForm.js +198 -298
- package/dist/cjs/components/AccountForm/addon-interactions.stories.js +181 -647
- package/dist/cjs/components/Interaction.js +202 -0
- package/dist/cjs/components/Interaction.stories.js +85 -0
- package/dist/cjs/components/InteractionsPanel.js +130 -0
- package/dist/cjs/components/InteractionsPanel.stories.js +158 -0
- package/dist/cjs/components/List.js +28 -79
- package/dist/cjs/components/MatcherResult.js +54 -112
- package/dist/cjs/components/MatcherResult.stories.js +49 -29
- package/dist/cjs/components/MethodCall.js +190 -261
- package/dist/cjs/components/MethodCall.stories.js +232 -257
- package/dist/cjs/components/StatusBadge.js +55 -0
- package/dist/cjs/components/{StatusBadge/StatusBadge.stories.js → StatusBadge.stories.js} +4 -4
- package/dist/cjs/components/StatusIcon.js +65 -0
- package/dist/cjs/components/{StatusIcon/StatusIcon.stories.js → StatusIcon.stories.js} +3 -3
- package/dist/cjs/components/{Subnav/Subnav.js → Subnav.js} +83 -87
- package/dist/cjs/components/{Subnav/Subnav.stories.js → Subnav.stories.js} +8 -7
- package/dist/cjs/components/TabStatus.js +27 -0
- package/dist/cjs/constants.js +2 -2
- package/dist/cjs/manager.js +4 -5
- package/dist/cjs/mocks/index.js +144 -23
- package/dist/cjs/preset/checkActionsLoaded.js +2 -6
- package/dist/cjs/preset/preview.js +45 -66
- package/dist/cjs/theme.js +3 -3
- package/dist/esm/Panel.js +84 -72
- package/dist/esm/components/AccountForm/addon-interactions.stories.js +19 -1
- package/dist/esm/components/Interaction.js +173 -0
- package/dist/esm/components/{Interaction/Interaction.stories.js → Interaction.stories.js} +14 -7
- package/dist/esm/components/InteractionsPanel.js +103 -0
- package/dist/esm/components/InteractionsPanel.stories.js +130 -0
- package/dist/esm/components/List.js +9 -9
- package/dist/esm/components/MatcherResult.js +1 -1
- package/dist/esm/components/MethodCall.js +61 -61
- package/dist/esm/components/MethodCall.stories.js +106 -20
- package/dist/esm/components/{StatusBadge/StatusBadge.js → StatusBadge.js} +0 -0
- package/dist/esm/components/{StatusBadge/StatusBadge.stories.js → StatusBadge.stories.js} +0 -0
- package/dist/esm/components/{StatusIcon/StatusIcon.js → StatusIcon.js} +1 -1
- package/dist/esm/components/{StatusIcon/StatusIcon.stories.js → StatusIcon.stories.js} +0 -0
- package/dist/esm/components/{Subnav/Subnav.js → Subnav.js} +6 -2
- package/dist/esm/components/{Subnav/Subnav.stories.js → Subnav.stories.js} +2 -1
- package/dist/esm/components/TabStatus.js +12 -0
- package/dist/esm/mocks/index.js +140 -20
- package/dist/esm/preset/preview.js +29 -11
- package/dist/types/Panel.d.ts +14 -28
- package/dist/types/components/Interaction.d.ts +14 -0
- package/dist/types/components/InteractionsPanel.d.ts +33 -0
- package/dist/types/components/MethodCall.d.ts +17 -16
- package/dist/types/components/{StatusBadge/StatusBadge.d.ts → StatusBadge.d.ts} +0 -0
- package/dist/types/components/{StatusIcon/StatusIcon.d.ts → StatusIcon.d.ts} +0 -0
- package/dist/types/components/{Subnav/Subnav.d.ts → Subnav.d.ts} +1 -1
- package/dist/types/components/TabStatus.d.ts +5 -0
- package/dist/types/mocks/index.d.ts +22 -1
- package/dist/types/preset/preview.d.ts +1 -2
- package/package.json +14 -12
- package/dist/cjs/Panel.stories.js +0 -125
- package/dist/cjs/components/Interaction/Interaction.js +0 -174
- package/dist/cjs/components/Interaction/Interaction.stories.js +0 -144
- package/dist/cjs/components/StatusBadge/StatusBadge.js +0 -51
- package/dist/cjs/components/StatusIcon/StatusIcon.js +0 -53
- package/dist/esm/Panel.stories.js +0 -86
- package/dist/esm/components/Interaction/Interaction.js +0 -88
- package/dist/types/components/Interaction/Interaction.d.ts +0 -9
package/README.md
CHANGED
|
@@ -41,22 +41,25 @@ Interactions relies on "instrumented" versions of Jest and Testing Library, that
|
|
|
41
41
|
`@storybook/testing-library` instead of their original package. You can then use these libraries in your `play` function.
|
|
42
42
|
|
|
43
43
|
```js
|
|
44
|
+
import { Button } from './Button';
|
|
44
45
|
import { expect } from '@storybook/jest';
|
|
45
46
|
import { within, userEvent } from '@storybook/testing-library';
|
|
46
47
|
|
|
47
48
|
export default {
|
|
48
49
|
title: 'Button',
|
|
50
|
+
component: Button,
|
|
49
51
|
argTypes: {
|
|
50
52
|
onClick: { action: true },
|
|
51
53
|
},
|
|
52
54
|
};
|
|
53
55
|
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
56
|
+
const Template = (args) => <Button {...args} />;
|
|
57
|
+
|
|
58
|
+
export const Demo = Template.bind({});
|
|
59
|
+
Demo.play = async ({ args, canvasElement }) => {
|
|
60
|
+
const canvas = within(canvasElement);
|
|
61
|
+
await userEvent.click(canvas.getByRole('button'));
|
|
62
|
+
await expect(args.onClick).toHaveBeenCalled();
|
|
60
63
|
};
|
|
61
64
|
```
|
|
62
65
|
|
package/dist/cjs/Panel.js
CHANGED
|
@@ -1,102 +1,37 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
|
|
4
|
-
|
|
5
|
-
require("core-js/modules/es.object.keys.js");
|
|
6
|
-
|
|
7
|
-
require("core-js/modules/es.symbol.js");
|
|
8
|
-
|
|
9
|
-
require("core-js/modules/es.symbol.description.js");
|
|
10
|
-
|
|
11
|
-
require("core-js/modules/es.symbol.iterator.js");
|
|
12
|
-
|
|
13
|
-
require("core-js/modules/es.function.name.js");
|
|
14
|
-
|
|
15
|
-
require("core-js/modules/es.array.from.js");
|
|
16
|
-
|
|
17
|
-
require("core-js/modules/es.weak-map.js");
|
|
18
|
-
|
|
19
|
-
require("core-js/modules/es.object.get-own-property-descriptor.js");
|
|
20
|
-
|
|
21
3
|
Object.defineProperty(exports, "__esModule", {
|
|
22
4
|
value: true
|
|
23
5
|
});
|
|
24
|
-
exports.
|
|
25
|
-
|
|
26
|
-
require("core-js/modules/es.array.map.js");
|
|
27
|
-
|
|
28
|
-
require("core-js/modules/es.array.iterator.js");
|
|
29
|
-
|
|
30
|
-
require("core-js/modules/es.map.js");
|
|
31
|
-
|
|
32
|
-
require("core-js/modules/es.object.to-string.js");
|
|
33
|
-
|
|
34
|
-
require("core-js/modules/es.string.iterator.js");
|
|
35
|
-
|
|
36
|
-
require("core-js/modules/web.dom-collections.iterator.js");
|
|
37
|
-
|
|
38
|
-
require("core-js/modules/es.object.assign.js");
|
|
39
|
-
|
|
40
|
-
require("core-js/modules/es.array.slice.js");
|
|
41
|
-
|
|
42
|
-
require("core-js/modules/es.regexp.exec.js");
|
|
43
|
-
|
|
44
|
-
require("core-js/modules/es.string.split.js");
|
|
45
|
-
|
|
46
|
-
require("core-js/modules/es.regexp.to-string.js");
|
|
6
|
+
exports.getInteractions = exports.Panel = void 0;
|
|
47
7
|
|
|
48
8
|
var _global = _interopRequireDefault(require("global"));
|
|
49
9
|
|
|
50
10
|
var React = _interopRequireWildcard(require("react"));
|
|
51
11
|
|
|
52
|
-
var _reactDom = _interopRequireDefault(require("react-dom"));
|
|
53
|
-
|
|
54
12
|
var _api = require("@storybook/api");
|
|
55
13
|
|
|
56
14
|
var _coreEvents = require("@storybook/core-events");
|
|
57
15
|
|
|
58
|
-
var _components = require("@storybook/components");
|
|
59
|
-
|
|
60
16
|
var _instrumenter = require("@storybook/instrumenter");
|
|
61
17
|
|
|
62
|
-
var
|
|
63
|
-
|
|
64
|
-
var _StatusIcon = require("./components/StatusIcon/StatusIcon");
|
|
65
|
-
|
|
66
|
-
var _Subnav = require("./components/Subnav/Subnav");
|
|
18
|
+
var _InteractionsPanel = require("./components/InteractionsPanel");
|
|
67
19
|
|
|
68
|
-
var
|
|
20
|
+
var _TabStatus = require("./components/TabStatus");
|
|
69
21
|
|
|
70
|
-
|
|
71
|
-
_excluded2 = ["status"];
|
|
22
|
+
const _excluded = ["status"];
|
|
72
23
|
|
|
73
|
-
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function
|
|
24
|
+
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
74
25
|
|
|
75
|
-
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null ||
|
|
26
|
+
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
76
27
|
|
|
77
28
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
78
29
|
|
|
79
30
|
function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
80
31
|
|
|
81
|
-
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
82
|
-
|
|
83
|
-
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
84
|
-
|
|
85
|
-
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
86
|
-
|
|
87
|
-
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
88
|
-
|
|
89
|
-
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
|
|
90
|
-
|
|
91
|
-
function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"]; if (_i == null) return; var _arr = []; var _n = true; var _d = false; var _s, _e; try { for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
|
|
92
|
-
|
|
93
|
-
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
94
|
-
|
|
95
|
-
function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
|
|
96
|
-
|
|
97
32
|
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; }
|
|
98
33
|
|
|
99
|
-
|
|
34
|
+
const INITIAL_CONTROL_STATES = {
|
|
100
35
|
debugger: false,
|
|
101
36
|
start: false,
|
|
102
37
|
back: false,
|
|
@@ -104,203 +39,175 @@ var INITIAL_CONTROL_STATES = {
|
|
|
104
39
|
next: false,
|
|
105
40
|
end: false
|
|
106
41
|
};
|
|
107
|
-
var TabIcon = (0, _theming.styled)(_StatusIcon.StatusIcon)({
|
|
108
|
-
marginLeft: 5
|
|
109
|
-
});
|
|
110
|
-
|
|
111
|
-
var TabStatus = function TabStatus(_ref) {
|
|
112
|
-
var children = _ref.children;
|
|
113
|
-
|
|
114
|
-
var container = _global.default.document.getElementById('tabbutton-interactions');
|
|
115
|
-
|
|
116
|
-
return container && /*#__PURE__*/_reactDom.default.createPortal(children, container);
|
|
117
|
-
};
|
|
118
42
|
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
status
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
43
|
+
const getInteractions = ({
|
|
44
|
+
log,
|
|
45
|
+
calls,
|
|
46
|
+
collapsed,
|
|
47
|
+
setCollapsed
|
|
48
|
+
}) => {
|
|
49
|
+
const callsById = new Map();
|
|
50
|
+
const childCallMap = new Map();
|
|
51
|
+
return log.filter(({
|
|
52
|
+
callId,
|
|
53
|
+
parentId
|
|
54
|
+
}) => {
|
|
55
|
+
if (!parentId) return true;
|
|
56
|
+
childCallMap.set(parentId, (childCallMap.get(parentId) || []).concat(callId));
|
|
57
|
+
return !collapsed.has(parentId);
|
|
58
|
+
}).map(({
|
|
59
|
+
callId,
|
|
60
|
+
status
|
|
61
|
+
}) => Object.assign({}, calls.get(callId), {
|
|
62
|
+
status
|
|
63
|
+
})).map(call => {
|
|
64
|
+
var _callsById$get;
|
|
65
|
+
|
|
66
|
+
const status = call.status === _instrumenter.CallStates.ERROR && ((_callsById$get = callsById.get(call.parentId)) === null || _callsById$get === void 0 ? void 0 : _callsById$get.status) === _instrumenter.CallStates.ACTIVE ? _instrumenter.CallStates.ACTIVE : call.status;
|
|
67
|
+
callsById.set(call.id, Object.assign({}, call, {
|
|
68
|
+
status
|
|
69
|
+
}));
|
|
70
|
+
return Object.assign({}, call, {
|
|
71
|
+
status,
|
|
72
|
+
childCallIds: childCallMap.get(call.id),
|
|
73
|
+
isCollapsed: collapsed.has(call.id),
|
|
74
|
+
toggleCollapsed: () => setCollapsed(ids => {
|
|
75
|
+
if (ids.has(call.id)) ids.delete(call.id);else ids.add(call.id);
|
|
76
|
+
return new Set(ids);
|
|
77
|
+
})
|
|
149
78
|
});
|
|
150
|
-
})
|
|
151
|
-
|
|
152
|
-
}), !isPlaying && interactions.length === 0 && /*#__PURE__*/React.createElement(_components.Placeholder, null, "No interactions found", /*#__PURE__*/React.createElement(_components.Link, {
|
|
153
|
-
href: "https://github.com/storybookjs/storybook/blob/next/addons/interactions/README.md",
|
|
154
|
-
target: "_blank",
|
|
155
|
-
withArrow: true
|
|
156
|
-
}, "Learn how to add interactions to your story")));
|
|
157
|
-
});
|
|
158
|
-
exports.AddonPanelPure = AddonPanelPure;
|
|
159
|
-
|
|
160
|
-
var Panel = function Panel(props) {
|
|
161
|
-
var _useChannel;
|
|
162
|
-
|
|
163
|
-
var _React$useState = React.useState(),
|
|
164
|
-
_React$useState2 = _slicedToArray(_React$useState, 2),
|
|
165
|
-
storyId = _React$useState2[0],
|
|
166
|
-
setStoryId = _React$useState2[1];
|
|
167
|
-
|
|
168
|
-
var _React$useState3 = React.useState(INITIAL_CONTROL_STATES),
|
|
169
|
-
_React$useState4 = _slicedToArray(_React$useState3, 2),
|
|
170
|
-
controlStates = _React$useState4[0],
|
|
171
|
-
setControlStates = _React$useState4[1];
|
|
172
|
-
|
|
173
|
-
var _React$useState5 = React.useState(false),
|
|
174
|
-
_React$useState6 = _slicedToArray(_React$useState5, 2),
|
|
175
|
-
isPlaying = _React$useState6[0],
|
|
176
|
-
setPlaying = _React$useState6[1];
|
|
177
|
-
|
|
178
|
-
var _React$useState7 = React.useState(false),
|
|
179
|
-
_React$useState8 = _slicedToArray(_React$useState7, 2),
|
|
180
|
-
isRerunAnimating = _React$useState8[0],
|
|
181
|
-
setIsRerunAnimating = _React$useState8[1];
|
|
79
|
+
});
|
|
80
|
+
};
|
|
182
81
|
|
|
183
|
-
|
|
184
|
-
_React$useState10 = _slicedToArray(_React$useState9, 2),
|
|
185
|
-
scrollTarget = _React$useState10[0],
|
|
186
|
-
setScrollTarget = _React$useState10[1]; // Calls are tracked in a ref so we don't needlessly rerender.
|
|
82
|
+
exports.getInteractions = getInteractions;
|
|
187
83
|
|
|
84
|
+
const Panel = props => {
|
|
85
|
+
const [storyId, setStoryId] = React.useState();
|
|
86
|
+
const [controlStates, setControlStates] = React.useState(INITIAL_CONTROL_STATES);
|
|
87
|
+
const [pausedAt, setPausedAt] = React.useState();
|
|
88
|
+
const [isErrored, setErrored] = React.useState(false);
|
|
89
|
+
const [isPlaying, setPlaying] = React.useState(false);
|
|
90
|
+
const [isRerunAnimating, setIsRerunAnimating] = React.useState(false);
|
|
91
|
+
const [scrollTarget, setScrollTarget] = React.useState();
|
|
92
|
+
const [collapsed, setCollapsed] = React.useState(new Set());
|
|
93
|
+
const [caughtException, setCaughtException] = React.useState();
|
|
94
|
+
const [interactions, setInteractions] = React.useState([]);
|
|
95
|
+
const [interactionsCount, setInteractionsCount] = React.useState(); // Calls are tracked in a ref so we don't needlessly rerender.
|
|
188
96
|
|
|
189
|
-
|
|
97
|
+
const calls = React.useRef(new Map());
|
|
190
98
|
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
call = _objectWithoutProperties(_ref3, _excluded2);
|
|
99
|
+
const setCall = _ref => {
|
|
100
|
+
let call = _objectWithoutPropertiesLoose(_ref, _excluded);
|
|
194
101
|
|
|
195
102
|
return calls.current.set(call.id, call);
|
|
196
103
|
};
|
|
197
104
|
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
setLog = _React$useState12[1];
|
|
202
|
-
|
|
203
|
-
var interactions = log.map(function (_ref4) {
|
|
204
|
-
var callId = _ref4.callId,
|
|
205
|
-
status = _ref4.status;
|
|
206
|
-
return Object.assign({}, calls.current.get(callId), {
|
|
207
|
-
status: status
|
|
208
|
-
});
|
|
209
|
-
});
|
|
210
|
-
var endRef = React.useRef();
|
|
211
|
-
React.useEffect(function () {
|
|
212
|
-
var observer;
|
|
105
|
+
const endRef = React.useRef();
|
|
106
|
+
React.useEffect(() => {
|
|
107
|
+
let observer;
|
|
213
108
|
|
|
214
109
|
if (_global.default.window.IntersectionObserver) {
|
|
215
|
-
observer = new _global.default.window.IntersectionObserver(
|
|
216
|
-
var _ref6 = _slicedToArray(_ref5, 1),
|
|
217
|
-
end = _ref6[0];
|
|
218
|
-
|
|
219
|
-
return setScrollTarget(end.isIntersecting ? undefined : end.target);
|
|
220
|
-
}, {
|
|
110
|
+
observer = new _global.default.window.IntersectionObserver(([end]) => setScrollTarget(end.isIntersecting ? undefined : end.target), {
|
|
221
111
|
root: _global.default.window.document.querySelector('#panel-tab-content')
|
|
222
112
|
});
|
|
223
113
|
if (endRef.current) observer.observe(endRef.current);
|
|
224
114
|
}
|
|
225
115
|
|
|
226
|
-
return
|
|
116
|
+
return () => {
|
|
227
117
|
var _observer;
|
|
228
118
|
|
|
229
119
|
return (_observer = observer) === null || _observer === void 0 ? void 0 : _observer.disconnect();
|
|
230
120
|
};
|
|
231
121
|
}, []);
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
return emit(_instrumenter.EVENTS.GOTO, {
|
|
253
|
-
storyId: storyId,
|
|
254
|
-
callId: callId
|
|
255
|
-
});
|
|
256
|
-
},
|
|
257
|
-
next: function next() {
|
|
258
|
-
return emit(_instrumenter.EVENTS.NEXT, {
|
|
259
|
-
storyId: storyId
|
|
260
|
-
});
|
|
261
|
-
},
|
|
262
|
-
end: function end() {
|
|
263
|
-
return emit(_instrumenter.EVENTS.END, {
|
|
264
|
-
storyId: storyId
|
|
265
|
-
});
|
|
266
|
-
},
|
|
267
|
-
rerun: function rerun() {
|
|
268
|
-
setIsRerunAnimating(true);
|
|
269
|
-
emit(_coreEvents.FORCE_REMOUNT, {
|
|
270
|
-
storyId: storyId
|
|
271
|
-
});
|
|
122
|
+
const emit = (0, _api.useChannel)({
|
|
123
|
+
[_instrumenter.EVENTS.CALL]: setCall,
|
|
124
|
+
[_instrumenter.EVENTS.SYNC]: payload => {
|
|
125
|
+
setControlStates(payload.controlStates);
|
|
126
|
+
setPausedAt(payload.pausedAt);
|
|
127
|
+
setInteractions(getInteractions({
|
|
128
|
+
log: payload.logItems,
|
|
129
|
+
calls: calls.current,
|
|
130
|
+
collapsed,
|
|
131
|
+
setCollapsed
|
|
132
|
+
}));
|
|
133
|
+
},
|
|
134
|
+
[_coreEvents.STORY_RENDER_PHASE_CHANGED]: event => {
|
|
135
|
+
setStoryId(event.storyId);
|
|
136
|
+
setPlaying(event.newPhase === 'playing');
|
|
137
|
+
setPausedAt(undefined);
|
|
138
|
+
|
|
139
|
+
if (event.newPhase === 'rendering') {
|
|
140
|
+
setErrored(false);
|
|
141
|
+
setCaughtException(undefined);
|
|
272
142
|
}
|
|
273
|
-
}
|
|
274
|
-
|
|
275
|
-
|
|
143
|
+
},
|
|
144
|
+
[_coreEvents.STORY_THREW_EXCEPTION]: () => {
|
|
145
|
+
setErrored(true);
|
|
146
|
+
},
|
|
147
|
+
[_coreEvents.PLAY_FUNCTION_THREW_EXCEPTION]: e => {
|
|
148
|
+
console.log('PLAY_FUNCTION_THREW_EXCEPTION');
|
|
149
|
+
if ((e === null || e === void 0 ? void 0 : e.message) !== _coreEvents.IGNORED_EXCEPTION.message) setCaughtException(e);else setCaughtException(undefined);
|
|
150
|
+
}
|
|
151
|
+
}, [collapsed]);
|
|
152
|
+
React.useEffect(() => {
|
|
153
|
+
if (isPlaying || isRerunAnimating) return;
|
|
154
|
+
setInteractionsCount(interactions.length);
|
|
155
|
+
}, [interactions, isPlaying, isRerunAnimating]);
|
|
156
|
+
const controls = React.useMemo(() => ({
|
|
157
|
+
start: () => emit(_instrumenter.EVENTS.START, {
|
|
158
|
+
storyId
|
|
159
|
+
}),
|
|
160
|
+
back: () => emit(_instrumenter.EVENTS.BACK, {
|
|
161
|
+
storyId
|
|
162
|
+
}),
|
|
163
|
+
goto: callId => emit(_instrumenter.EVENTS.GOTO, {
|
|
164
|
+
storyId,
|
|
165
|
+
callId
|
|
166
|
+
}),
|
|
167
|
+
next: () => emit(_instrumenter.EVENTS.NEXT, {
|
|
168
|
+
storyId
|
|
169
|
+
}),
|
|
170
|
+
end: () => emit(_instrumenter.EVENTS.END, {
|
|
171
|
+
storyId
|
|
172
|
+
}),
|
|
173
|
+
rerun: () => {
|
|
174
|
+
setIsRerunAnimating(true);
|
|
175
|
+
emit(_coreEvents.FORCE_REMOUNT, {
|
|
176
|
+
storyId
|
|
177
|
+
});
|
|
178
|
+
}
|
|
179
|
+
}), [storyId]);
|
|
180
|
+
const storyFilePath = (0, _api.useParameter)('fileName', '');
|
|
181
|
+
const [fileName] = storyFilePath.toString().split('/').slice(-1);
|
|
276
182
|
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
183
|
+
const scrollToTarget = () => scrollTarget === null || scrollTarget === void 0 ? void 0 : scrollTarget.scrollIntoView({
|
|
184
|
+
behavior: 'smooth',
|
|
185
|
+
block: 'end'
|
|
186
|
+
});
|
|
280
187
|
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
188
|
+
const showStatus = interactionsCount > 0 || !!caughtException || isRerunAnimating;
|
|
189
|
+
const hasException = !!caughtException || interactions.some(v => v.status === _instrumenter.CallStates.ERROR);
|
|
190
|
+
|
|
191
|
+
if (isErrored) {
|
|
192
|
+
return /*#__PURE__*/React.createElement(React.Fragment, {
|
|
193
|
+
key: "interactions"
|
|
285
194
|
});
|
|
286
|
-
}
|
|
195
|
+
}
|
|
287
196
|
|
|
288
|
-
var showStatus = log.length > 0 && !isPlaying;
|
|
289
|
-
var hasException = log.some(function (item) {
|
|
290
|
-
return item.status === _instrumenter.CallStates.ERROR;
|
|
291
|
-
});
|
|
292
197
|
return /*#__PURE__*/React.createElement(React.Fragment, {
|
|
293
198
|
key: "interactions"
|
|
294
|
-
}, /*#__PURE__*/React.createElement(TabStatus, null, showStatus && (hasException ? /*#__PURE__*/React.createElement(TabIcon, {
|
|
199
|
+
}, /*#__PURE__*/React.createElement(_TabStatus.TabStatus, null, showStatus && (hasException ? /*#__PURE__*/React.createElement(_TabStatus.TabIcon, {
|
|
295
200
|
status: _instrumenter.CallStates.ERROR
|
|
296
|
-
}) :
|
|
201
|
+
}) : ` (${interactionsCount})`)), /*#__PURE__*/React.createElement(_InteractionsPanel.InteractionsPanel, _extends({
|
|
297
202
|
calls: calls.current,
|
|
298
203
|
controls: controls,
|
|
299
204
|
controlStates: controlStates,
|
|
300
205
|
interactions: interactions,
|
|
301
206
|
fileName: fileName,
|
|
302
207
|
hasException: hasException,
|
|
208
|
+
caughtException: caughtException,
|
|
303
209
|
isPlaying: isPlaying,
|
|
210
|
+
pausedAt: pausedAt,
|
|
304
211
|
endRef: endRef,
|
|
305
212
|
onScrollToEnd: scrollTarget && scrollToTarget,
|
|
306
213
|
isRerunAnimating: isRerunAnimating,
|