@midscene/recorder-ui 0.0.0
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/LICENSE +21 -0
- package/README.md +7 -0
- package/dist/Button.js +19 -0
- package/dist/RecordTimeline.css +41 -0
- package/dist/RecordTimeline.js +549 -0
- package/dist/button.css +35 -0
- package/dist/components/shiny-text.css +73 -0
- package/dist/components/shiny-text.js +13 -0
- package/dist/index.js +4 -0
- package/dist/recorder-iife-index.js +2 -0
- package/dist/recorder-iife.js +455 -0
- package/dist/recorder.js +323 -0
- package/dist/types/src/Button.d.ts +10 -0
- package/dist/types/src/RecordTimeline.d.ts +9 -0
- package/dist/types/src/components/shiny-text.d.ts +12 -0
- package/dist/types/src/index.d.ts +3 -0
- package/dist/types/src/recorder-iife-index.d.ts +6 -0
- package/dist/types/src/recorder.d.ts +41 -0
- package/package.json +43 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024-present Bytedance, Inc. and its affiliates.
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
# @midscene/recorder-ui
|
|
2
|
+
|
|
3
|
+
Internal recorder UI package for Midscene applications.
|
|
4
|
+
|
|
5
|
+
> Do not add `@midscene/recorder-ui` as a dependency in external projects. Its API is not intended for external consumption and may change without notice.
|
|
6
|
+
|
|
7
|
+
See <https://midscenejs.com>.
|
package/dist/Button.js
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import "./button.css";
|
|
3
|
+
const Button = ({ primary = false, size = 'medium', backgroundColor, label, ...props })=>{
|
|
4
|
+
const mode = primary ? 'demo-button--primary' : 'demo-button--secondary';
|
|
5
|
+
return /*#__PURE__*/ jsx("button", {
|
|
6
|
+
type: "button",
|
|
7
|
+
className: [
|
|
8
|
+
'demo-button',
|
|
9
|
+
`demo-button--${size}`,
|
|
10
|
+
mode
|
|
11
|
+
].join(' '),
|
|
12
|
+
style: {
|
|
13
|
+
backgroundColor
|
|
14
|
+
},
|
|
15
|
+
...props,
|
|
16
|
+
children: label
|
|
17
|
+
});
|
|
18
|
+
};
|
|
19
|
+
export { Button };
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
.record-timeline-screenshot-thumbnail {
|
|
2
|
+
transition: transform .2s ease-in-out, box-shadow .2s ease-in-out;
|
|
3
|
+
}
|
|
4
|
+
|
|
5
|
+
.record-timeline-screenshot-thumbnail:hover {
|
|
6
|
+
transform: scale(1.05);
|
|
7
|
+
box-shadow: 0 4px 12px #00000026;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
.record-timeline-screenshot-popover {
|
|
11
|
+
max-width: 600px;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
.record-timeline-screenshot-popover .ant-popover-inner {
|
|
15
|
+
padding: 8px;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
.record-timeline-screenshot-full {
|
|
19
|
+
border-radius: 4px;
|
|
20
|
+
box-shadow: 0 2px 8px #0000001a;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
.ant-image-preview-root, .ant-image-preview-mask, .ant-image-preview-wrap, .ant-image-preview-img-wrapper, .ant-image-preview-operations-wrapper, .ant-image-preview-close, .ant-image-preview-operations-operation {
|
|
24
|
+
-webkit-app-region: no-drag;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
.ant-image-preview-close, .ant-image-preview-operations-operation {
|
|
28
|
+
pointer-events: auto;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
.timeline-scrollable {
|
|
32
|
+
overscroll-behavior: contain;
|
|
33
|
+
max-height: 500px;
|
|
34
|
+
overflow-y: auto;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
.timeline-scrollable > div {
|
|
38
|
+
max-height: inherit;
|
|
39
|
+
overflow-y: auto;
|
|
40
|
+
}
|
|
41
|
+
|
|
@@ -0,0 +1,549 @@
|
|
|
1
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { AimOutlined, CompassOutlined, CopyOutlined, EditOutlined, KeyOutlined, VerticalAlignTopOutlined } from "@ant-design/icons";
|
|
3
|
+
import { getMidsceneRecorderEventDescription, getMidsceneRecorderSemantic } from "@midscene/shared/recorder";
|
|
4
|
+
import { App, Button, Card, Image, Space, Timeline, Tooltip, Typography } from "antd";
|
|
5
|
+
import { useEffect, useRef, useState } from "react";
|
|
6
|
+
import { ShinyText } from "./components/shiny-text.js";
|
|
7
|
+
import "./RecordTimeline.css";
|
|
8
|
+
const { Text } = Typography;
|
|
9
|
+
function TwoLineEventDescription({ children, tooltip }) {
|
|
10
|
+
const contentRef = useRef(null);
|
|
11
|
+
const [isTruncated, setIsTruncated] = useState(false);
|
|
12
|
+
useEffect(()=>{
|
|
13
|
+
const updateTruncation = ()=>{
|
|
14
|
+
const element = contentRef.current;
|
|
15
|
+
if (!element) return;
|
|
16
|
+
setIsTruncated(element.scrollHeight > element.clientHeight + 1);
|
|
17
|
+
};
|
|
18
|
+
updateTruncation();
|
|
19
|
+
if ('undefined' == typeof ResizeObserver || !contentRef.current) return;
|
|
20
|
+
const observer = new ResizeObserver(updateTruncation);
|
|
21
|
+
observer.observe(contentRef.current);
|
|
22
|
+
return ()=>observer.disconnect();
|
|
23
|
+
}, [
|
|
24
|
+
tooltip
|
|
25
|
+
]);
|
|
26
|
+
return /*#__PURE__*/ jsx(Tooltip, {
|
|
27
|
+
title: isTruncated ? tooltip : void 0,
|
|
28
|
+
children: /*#__PURE__*/ jsx("div", {
|
|
29
|
+
ref: contentRef,
|
|
30
|
+
className: "record-timeline-event-description",
|
|
31
|
+
children: children
|
|
32
|
+
})
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
const RecordTimeline = ({ events, onEventClick, variant = 'default' })=>{
|
|
36
|
+
const { message } = App.useApp();
|
|
37
|
+
const [expandedEvents, setExpandedEvents] = useState(new Set());
|
|
38
|
+
const timelineRootRef = useRef(null);
|
|
39
|
+
useEffect(()=>{
|
|
40
|
+
if (events.length > 0) {
|
|
41
|
+
const timeline = timelineRootRef.current?.querySelector('.ant-timeline');
|
|
42
|
+
if (timeline) {
|
|
43
|
+
const nextScrollTop = timeline.scrollHeight;
|
|
44
|
+
if ('function' == typeof timeline.scrollTo) timeline.scrollTo({
|
|
45
|
+
top: nextScrollTop,
|
|
46
|
+
behavior: 'smooth'
|
|
47
|
+
});
|
|
48
|
+
else timeline.scrollTop = nextScrollTop;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
}, [
|
|
52
|
+
events.length
|
|
53
|
+
]);
|
|
54
|
+
const toggleEventExpansion = (index)=>{
|
|
55
|
+
const newExpanded = new Set(expandedEvents);
|
|
56
|
+
if (newExpanded.has(index)) newExpanded.delete(index);
|
|
57
|
+
else newExpanded.add(index);
|
|
58
|
+
setExpandedEvents(newExpanded);
|
|
59
|
+
};
|
|
60
|
+
const truncateJsonStrings = (obj, maxLength = 30)=>{
|
|
61
|
+
if ('string' == typeof obj) return obj.length > maxLength ? `${obj.substring(0, maxLength)}...` : obj;
|
|
62
|
+
if (Array.isArray(obj)) return obj.map((item)=>truncateJsonStrings(item, maxLength));
|
|
63
|
+
if (obj && 'object' == typeof obj) {
|
|
64
|
+
const truncated = {};
|
|
65
|
+
for(const key in obj)if (Object.prototype.hasOwnProperty.call(obj, key)) truncated[key] = truncateJsonStrings(obj[key], maxLength);
|
|
66
|
+
return truncated;
|
|
67
|
+
}
|
|
68
|
+
return obj;
|
|
69
|
+
};
|
|
70
|
+
const copyToClipboard = (text)=>{
|
|
71
|
+
navigator.clipboard.writeText(text).then(()=>{
|
|
72
|
+
message.success('JSON copied to clipboard');
|
|
73
|
+
}).catch(()=>{
|
|
74
|
+
message.error('Copy failed');
|
|
75
|
+
});
|
|
76
|
+
};
|
|
77
|
+
const getEventIcon = (type)=>{
|
|
78
|
+
switch(type){
|
|
79
|
+
case 'click':
|
|
80
|
+
return /*#__PURE__*/ jsx(AimOutlined, {
|
|
81
|
+
style: {
|
|
82
|
+
color: '#1890ff'
|
|
83
|
+
}
|
|
84
|
+
});
|
|
85
|
+
case 'drag':
|
|
86
|
+
return /*#__PURE__*/ jsx(AimOutlined, {
|
|
87
|
+
style: {
|
|
88
|
+
color: '#13c2c2'
|
|
89
|
+
}
|
|
90
|
+
});
|
|
91
|
+
case 'input':
|
|
92
|
+
return /*#__PURE__*/ jsx(EditOutlined, {
|
|
93
|
+
style: {
|
|
94
|
+
color: '#52c41a'
|
|
95
|
+
}
|
|
96
|
+
});
|
|
97
|
+
case 'scroll':
|
|
98
|
+
return /*#__PURE__*/ jsx(VerticalAlignTopOutlined, {
|
|
99
|
+
style: {
|
|
100
|
+
color: '#faad14'
|
|
101
|
+
}
|
|
102
|
+
});
|
|
103
|
+
case 'navigation':
|
|
104
|
+
return /*#__PURE__*/ jsx(CompassOutlined, {
|
|
105
|
+
style: {
|
|
106
|
+
color: '#722ed1'
|
|
107
|
+
}
|
|
108
|
+
});
|
|
109
|
+
case 'setViewport':
|
|
110
|
+
return /*#__PURE__*/ jsx(CompassOutlined, {
|
|
111
|
+
style: {
|
|
112
|
+
color: '#eb2f96'
|
|
113
|
+
}
|
|
114
|
+
});
|
|
115
|
+
case 'keydown':
|
|
116
|
+
return /*#__PURE__*/ jsx(KeyOutlined, {
|
|
117
|
+
style: {
|
|
118
|
+
color: '#fa8c16'
|
|
119
|
+
}
|
|
120
|
+
});
|
|
121
|
+
default:
|
|
122
|
+
return /*#__PURE__*/ jsx(AimOutlined, {
|
|
123
|
+
style: {
|
|
124
|
+
color: '#d9d9d9'
|
|
125
|
+
}
|
|
126
|
+
});
|
|
127
|
+
}
|
|
128
|
+
};
|
|
129
|
+
const getEventColor = (type)=>{
|
|
130
|
+
switch(type){
|
|
131
|
+
case 'click':
|
|
132
|
+
return '#1890ff';
|
|
133
|
+
case 'drag':
|
|
134
|
+
return '#13c2c2';
|
|
135
|
+
case 'input':
|
|
136
|
+
return '#52c41a';
|
|
137
|
+
case 'scroll':
|
|
138
|
+
return '#faad14';
|
|
139
|
+
case 'navigation':
|
|
140
|
+
return '#722ed1';
|
|
141
|
+
case 'setViewport':
|
|
142
|
+
return '#eb2f96';
|
|
143
|
+
case 'keydown':
|
|
144
|
+
return '#fa8c16';
|
|
145
|
+
default:
|
|
146
|
+
return '#d9d9d9';
|
|
147
|
+
}
|
|
148
|
+
};
|
|
149
|
+
const isCoordinateValue = (value)=>Boolean(value && /^\s*\d+(?:\.\d+)?,\s*\d+(?:\.\d+)?\s*$/.test(value));
|
|
150
|
+
const getDisplayDescription = (event)=>getMidsceneRecorderEventDescription(event);
|
|
151
|
+
const getViewportDescription = (event)=>{
|
|
152
|
+
const width = event.pageInfo?.width;
|
|
153
|
+
const height = event.pageInfo?.height;
|
|
154
|
+
if ('number' != typeof width || 'number' != typeof height || !Number.isFinite(width) || !Number.isFinite(height) || width <= 0 || height <= 0) return;
|
|
155
|
+
return `${width}x${height} px`;
|
|
156
|
+
};
|
|
157
|
+
const getEventTitle = (event)=>{
|
|
158
|
+
switch(event.type){
|
|
159
|
+
case 'click':
|
|
160
|
+
if ('BUTTON' === event.targetTagName) return 'Click Button';
|
|
161
|
+
if (event.value && !isCoordinateValue(event.value)) return `Click Element "${event.value}"`;
|
|
162
|
+
return 'Click';
|
|
163
|
+
case 'drag':
|
|
164
|
+
return 'Drag';
|
|
165
|
+
case 'input':
|
|
166
|
+
return 'Input';
|
|
167
|
+
case 'scroll':
|
|
168
|
+
return 'Scroll';
|
|
169
|
+
case 'navigation':
|
|
170
|
+
return 'Navigate';
|
|
171
|
+
case 'setViewport':
|
|
172
|
+
return 'Viewport changed';
|
|
173
|
+
case 'keydown':
|
|
174
|
+
return 'Key down';
|
|
175
|
+
default:
|
|
176
|
+
return event.type;
|
|
177
|
+
}
|
|
178
|
+
};
|
|
179
|
+
const getEventDescription = (event)=>{
|
|
180
|
+
const eventTitle = getEventTitle(event);
|
|
181
|
+
switch(event.type){
|
|
182
|
+
case 'click':
|
|
183
|
+
case 'drag':
|
|
184
|
+
if (getMidsceneRecorderSemantic(event)?.status === 'pending') return /*#__PURE__*/ jsxs("span", {
|
|
185
|
+
style: {
|
|
186
|
+
display: 'flex',
|
|
187
|
+
alignItems: 'center',
|
|
188
|
+
gap: '4px'
|
|
189
|
+
},
|
|
190
|
+
children: [
|
|
191
|
+
/*#__PURE__*/ jsxs(Text, {
|
|
192
|
+
children: [
|
|
193
|
+
eventTitle,
|
|
194
|
+
" - "
|
|
195
|
+
]
|
|
196
|
+
}),
|
|
197
|
+
/*#__PURE__*/ jsx(ShinyText, {
|
|
198
|
+
text: "analyzing target...",
|
|
199
|
+
disabled: false,
|
|
200
|
+
speed: 3,
|
|
201
|
+
className: "step-title-shiny"
|
|
202
|
+
})
|
|
203
|
+
]
|
|
204
|
+
});
|
|
205
|
+
if (getMidsceneRecorderSemantic(event)?.status === 'ready') return /*#__PURE__*/ jsxs(Text, {
|
|
206
|
+
children: [
|
|
207
|
+
eventTitle,
|
|
208
|
+
" - ",
|
|
209
|
+
getDisplayDescription(event)
|
|
210
|
+
]
|
|
211
|
+
});
|
|
212
|
+
return /*#__PURE__*/ jsx(Text, {
|
|
213
|
+
children: eventTitle
|
|
214
|
+
});
|
|
215
|
+
case 'input':
|
|
216
|
+
if (getMidsceneRecorderSemantic(event)?.status === 'ready') return /*#__PURE__*/ jsxs(Text, {
|
|
217
|
+
children: [
|
|
218
|
+
eventTitle,
|
|
219
|
+
" - ",
|
|
220
|
+
getDisplayDescription(event)
|
|
221
|
+
]
|
|
222
|
+
});
|
|
223
|
+
return /*#__PURE__*/ jsxs("span", {
|
|
224
|
+
style: {
|
|
225
|
+
display: 'flex',
|
|
226
|
+
alignItems: 'center',
|
|
227
|
+
gap: '4px'
|
|
228
|
+
},
|
|
229
|
+
children: [
|
|
230
|
+
/*#__PURE__*/ jsxs(Text, {
|
|
231
|
+
children: [
|
|
232
|
+
eventTitle,
|
|
233
|
+
" - "
|
|
234
|
+
]
|
|
235
|
+
}),
|
|
236
|
+
/*#__PURE__*/ jsx(ShinyText, {
|
|
237
|
+
text: event.value ? `"${event.value}"` : '',
|
|
238
|
+
disabled: false,
|
|
239
|
+
speed: 3,
|
|
240
|
+
className: "step-title-shiny"
|
|
241
|
+
})
|
|
242
|
+
]
|
|
243
|
+
});
|
|
244
|
+
case 'scroll':
|
|
245
|
+
if (getDisplayDescription(event)) return /*#__PURE__*/ jsxs(Text, {
|
|
246
|
+
children: [
|
|
247
|
+
eventTitle,
|
|
248
|
+
" - ",
|
|
249
|
+
getDisplayDescription(event)
|
|
250
|
+
]
|
|
251
|
+
});
|
|
252
|
+
return /*#__PURE__*/ jsxs(Text, {
|
|
253
|
+
children: [
|
|
254
|
+
eventTitle,
|
|
255
|
+
" - ",
|
|
256
|
+
event.value?.split(' ')[0] || 'recorded scroll'
|
|
257
|
+
]
|
|
258
|
+
});
|
|
259
|
+
case 'navigation':
|
|
260
|
+
{
|
|
261
|
+
const navigationDescription = getDisplayDescription(event);
|
|
262
|
+
if (navigationDescription) return /*#__PURE__*/ jsxs(Text, {
|
|
263
|
+
children: [
|
|
264
|
+
eventTitle,
|
|
265
|
+
" - ",
|
|
266
|
+
navigationDescription
|
|
267
|
+
]
|
|
268
|
+
});
|
|
269
|
+
const truncatedUrl = event.url && event.url.length > 50 ? `${event.url.substring(0, 50)}...` : event.url;
|
|
270
|
+
return /*#__PURE__*/ jsxs(Text, {
|
|
271
|
+
children: [
|
|
272
|
+
eventTitle,
|
|
273
|
+
" - ",
|
|
274
|
+
truncatedUrl
|
|
275
|
+
]
|
|
276
|
+
});
|
|
277
|
+
}
|
|
278
|
+
case 'setViewport':
|
|
279
|
+
{
|
|
280
|
+
const viewportDescription = getViewportDescription(event);
|
|
281
|
+
return /*#__PURE__*/ jsxs(Text, {
|
|
282
|
+
children: [
|
|
283
|
+
eventTitle,
|
|
284
|
+
viewportDescription ? ` - ${viewportDescription}` : ''
|
|
285
|
+
]
|
|
286
|
+
});
|
|
287
|
+
}
|
|
288
|
+
case 'keydown':
|
|
289
|
+
return /*#__PURE__*/ jsxs(Text, {
|
|
290
|
+
children: [
|
|
291
|
+
eventTitle,
|
|
292
|
+
" - Key: ",
|
|
293
|
+
event.value || 'Unknown'
|
|
294
|
+
]
|
|
295
|
+
});
|
|
296
|
+
default:
|
|
297
|
+
return /*#__PURE__*/ jsx(Text, {
|
|
298
|
+
children: eventTitle
|
|
299
|
+
});
|
|
300
|
+
}
|
|
301
|
+
};
|
|
302
|
+
const getEventDescriptionText = (event)=>{
|
|
303
|
+
const eventTitle = getEventTitle(event);
|
|
304
|
+
const description = getDisplayDescription(event);
|
|
305
|
+
switch(event.type){
|
|
306
|
+
case 'click':
|
|
307
|
+
case 'drag':
|
|
308
|
+
return getMidsceneRecorderSemantic(event)?.status === 'pending' ? `${eventTitle} - analyzing target...` : description ? `${eventTitle} - ${description}` : eventTitle;
|
|
309
|
+
case 'input':
|
|
310
|
+
return getMidsceneRecorderSemantic(event)?.status === 'ready' ? `${eventTitle} - ${description}` : `${eventTitle} - ${event.value ? `"${event.value}"` : ''}`;
|
|
311
|
+
case 'scroll':
|
|
312
|
+
return description ? `${eventTitle} - ${description}` : `${eventTitle} - ${event.value?.split(' ')[0] || 'recorded scroll'}`;
|
|
313
|
+
case 'navigation':
|
|
314
|
+
return `${eventTitle} - ${description || event.url || ''}`;
|
|
315
|
+
case 'setViewport':
|
|
316
|
+
{
|
|
317
|
+
const viewportDescription = getViewportDescription(event);
|
|
318
|
+
return viewportDescription ? `${eventTitle} - ${viewportDescription}` : eventTitle;
|
|
319
|
+
}
|
|
320
|
+
case 'keydown':
|
|
321
|
+
return `${eventTitle} - Key: ${event.value || 'Unknown'}`;
|
|
322
|
+
default:
|
|
323
|
+
return eventTitle;
|
|
324
|
+
}
|
|
325
|
+
};
|
|
326
|
+
const timelineItems = events.map((event, index)=>{
|
|
327
|
+
const boxedImage = event.screenshotWithBox;
|
|
328
|
+
const afterImage = event.screenshotAfter;
|
|
329
|
+
const isExpanded = expandedEvents.has(index);
|
|
330
|
+
const eventDescription = getEventDescription(event);
|
|
331
|
+
const eventDescriptionText = getEventDescriptionText(event);
|
|
332
|
+
return {
|
|
333
|
+
dot: getEventIcon(event.type),
|
|
334
|
+
color: getEventColor(event.type),
|
|
335
|
+
children: /*#__PURE__*/ jsx("div", {
|
|
336
|
+
children: /*#__PURE__*/ jsxs(Card, {
|
|
337
|
+
className: "record-timeline-event-card",
|
|
338
|
+
size: "small",
|
|
339
|
+
bordered: false,
|
|
340
|
+
style: {
|
|
341
|
+
marginBottom: isExpanded ? 8 : 8,
|
|
342
|
+
cursor: 'pointer'
|
|
343
|
+
},
|
|
344
|
+
onClick: ()=>{
|
|
345
|
+
toggleEventExpansion(index);
|
|
346
|
+
onEventClick?.(event, index);
|
|
347
|
+
},
|
|
348
|
+
styles: {
|
|
349
|
+
body: {
|
|
350
|
+
padding: '8px 12px',
|
|
351
|
+
backgroundColor: '#F2F4F7',
|
|
352
|
+
borderRadius: '8px'
|
|
353
|
+
}
|
|
354
|
+
},
|
|
355
|
+
children: [
|
|
356
|
+
/*#__PURE__*/ jsxs(Space, {
|
|
357
|
+
className: 'chrome-extension' === variant ? 'record-timeline-event-row' : void 0,
|
|
358
|
+
style: {
|
|
359
|
+
width: '100%',
|
|
360
|
+
justifyContent: 'space-between',
|
|
361
|
+
alignItems: 'center',
|
|
362
|
+
color: 'rgba(0, 0, 0, 0.85)'
|
|
363
|
+
},
|
|
364
|
+
children: [
|
|
365
|
+
/*#__PURE__*/ jsx(Space, {
|
|
366
|
+
className: 'chrome-extension' === variant ? 'record-timeline-event-copy' : void 0,
|
|
367
|
+
style: {
|
|
368
|
+
flex: 1,
|
|
369
|
+
minWidth: 0
|
|
370
|
+
},
|
|
371
|
+
children: 'chrome-extension' === variant ? /*#__PURE__*/ jsx(TwoLineEventDescription, {
|
|
372
|
+
tooltip: eventDescriptionText,
|
|
373
|
+
children: eventDescription
|
|
374
|
+
}) : eventDescription
|
|
375
|
+
}),
|
|
376
|
+
/*#__PURE__*/ jsx(Space, {
|
|
377
|
+
className: 'chrome-extension' === variant ? 'record-timeline-event-media' : void 0,
|
|
378
|
+
children: (boxedImage || afterImage) && /*#__PURE__*/ jsxs("div", {
|
|
379
|
+
style: {
|
|
380
|
+
display: 'flex',
|
|
381
|
+
alignItems: 'center'
|
|
382
|
+
},
|
|
383
|
+
children: [
|
|
384
|
+
boxedImage && /*#__PURE__*/ jsx("div", {
|
|
385
|
+
className: "record-timeline-screenshot-thumbnail",
|
|
386
|
+
style: {
|
|
387
|
+
width: '24px',
|
|
388
|
+
height: '24px',
|
|
389
|
+
borderRadius: '4px',
|
|
390
|
+
overflow: 'hidden',
|
|
391
|
+
boxShadow: '1px 1px 1px 1px #00000014',
|
|
392
|
+
cursor: 'pointer',
|
|
393
|
+
transition: 'all 0.2s ease-in-out',
|
|
394
|
+
zIndex: 2
|
|
395
|
+
},
|
|
396
|
+
onMouseEnter: (e)=>{
|
|
397
|
+
const target = e.currentTarget;
|
|
398
|
+
target.style.transform = 'scale(1.2)';
|
|
399
|
+
target.style.boxShadow = `0 2px 8px ${getEventColor(event.type)}60`;
|
|
400
|
+
},
|
|
401
|
+
onMouseLeave: (e)=>{
|
|
402
|
+
const target = e.currentTarget;
|
|
403
|
+
target.style.transform = 'scale(1)';
|
|
404
|
+
target.style.boxShadow = '1px 1px 1px 1px #00000014';
|
|
405
|
+
},
|
|
406
|
+
onClick: (e)=>{
|
|
407
|
+
e.stopPropagation();
|
|
408
|
+
},
|
|
409
|
+
children: /*#__PURE__*/ jsx(Image, {
|
|
410
|
+
src: boxedImage,
|
|
411
|
+
width: "100%",
|
|
412
|
+
height: "100%",
|
|
413
|
+
style: {
|
|
414
|
+
objectFit: 'cover',
|
|
415
|
+
display: 'block'
|
|
416
|
+
},
|
|
417
|
+
preview: {
|
|
418
|
+
mask: false
|
|
419
|
+
}
|
|
420
|
+
})
|
|
421
|
+
}),
|
|
422
|
+
afterImage && /*#__PURE__*/ jsx("div", {
|
|
423
|
+
className: "record-timeline-screenshot-thumbnail",
|
|
424
|
+
style: {
|
|
425
|
+
width: '24px',
|
|
426
|
+
height: '24px',
|
|
427
|
+
borderRadius: '4px',
|
|
428
|
+
overflow: 'hidden',
|
|
429
|
+
boxShadow: '1px 1px 1px 1px #00000014',
|
|
430
|
+
cursor: 'pointer',
|
|
431
|
+
transition: 'all 0.2s ease-in-out',
|
|
432
|
+
marginLeft: boxedImage ? '-8px' : '0',
|
|
433
|
+
zIndex: 1
|
|
434
|
+
},
|
|
435
|
+
onMouseEnter: (e)=>{
|
|
436
|
+
const target = e.currentTarget;
|
|
437
|
+
target.style.transform = 'scale(1.2)';
|
|
438
|
+
target.style.boxShadow = '0 2px 8px #52c41a60';
|
|
439
|
+
},
|
|
440
|
+
onMouseLeave: (e)=>{
|
|
441
|
+
const target = e.currentTarget;
|
|
442
|
+
target.style.transform = 'scale(1)';
|
|
443
|
+
target.style.boxShadow = '1px 1px 1px 1px #00000014';
|
|
444
|
+
},
|
|
445
|
+
onClick: (e)=>{
|
|
446
|
+
e.stopPropagation();
|
|
447
|
+
},
|
|
448
|
+
children: /*#__PURE__*/ jsx(Image, {
|
|
449
|
+
src: afterImage,
|
|
450
|
+
width: "100%",
|
|
451
|
+
height: "100%",
|
|
452
|
+
style: {
|
|
453
|
+
objectFit: 'cover',
|
|
454
|
+
display: 'block'
|
|
455
|
+
},
|
|
456
|
+
preview: {
|
|
457
|
+
mask: false
|
|
458
|
+
}
|
|
459
|
+
})
|
|
460
|
+
})
|
|
461
|
+
]
|
|
462
|
+
})
|
|
463
|
+
})
|
|
464
|
+
]
|
|
465
|
+
}),
|
|
466
|
+
isExpanded && /*#__PURE__*/ jsx("div", {
|
|
467
|
+
style: {
|
|
468
|
+
marginTop: 8,
|
|
469
|
+
marginBottom: 8
|
|
470
|
+
},
|
|
471
|
+
children: /*#__PURE__*/ jsx(Card, {
|
|
472
|
+
size: "small",
|
|
473
|
+
style: {
|
|
474
|
+
backgroundColor: '#f5f5f5'
|
|
475
|
+
},
|
|
476
|
+
styles: {
|
|
477
|
+
body: {
|
|
478
|
+
padding: '0px'
|
|
479
|
+
}
|
|
480
|
+
},
|
|
481
|
+
children: /*#__PURE__*/ jsxs("div", {
|
|
482
|
+
style: {
|
|
483
|
+
position: 'relative'
|
|
484
|
+
},
|
|
485
|
+
children: [
|
|
486
|
+
/*#__PURE__*/ jsx("pre", {
|
|
487
|
+
style: {
|
|
488
|
+
fontSize: '12px',
|
|
489
|
+
margin: 0,
|
|
490
|
+
whiteSpace: 'pre-wrap',
|
|
491
|
+
backgroundColor: '#ffffff',
|
|
492
|
+
padding: '12px',
|
|
493
|
+
borderRadius: '8px',
|
|
494
|
+
maxHeight: '250px',
|
|
495
|
+
overflow: 'auto'
|
|
496
|
+
},
|
|
497
|
+
children: JSON.stringify(truncateJsonStrings(event), null, 2)
|
|
498
|
+
}),
|
|
499
|
+
/*#__PURE__*/ jsx(Button, {
|
|
500
|
+
type: "text",
|
|
501
|
+
size: "small",
|
|
502
|
+
icon: /*#__PURE__*/ jsx(CopyOutlined, {}),
|
|
503
|
+
onClick: (e)=>{
|
|
504
|
+
e.stopPropagation();
|
|
505
|
+
copyToClipboard(JSON.stringify(event, null, 2));
|
|
506
|
+
},
|
|
507
|
+
style: {
|
|
508
|
+
position: 'absolute',
|
|
509
|
+
top: '8px',
|
|
510
|
+
right: '8px',
|
|
511
|
+
background: 'rgba(255, 255, 255, 0.9)',
|
|
512
|
+
border: '1px solid #d9d9d9'
|
|
513
|
+
},
|
|
514
|
+
title: "Copy JSON"
|
|
515
|
+
})
|
|
516
|
+
]
|
|
517
|
+
})
|
|
518
|
+
})
|
|
519
|
+
})
|
|
520
|
+
]
|
|
521
|
+
})
|
|
522
|
+
})
|
|
523
|
+
};
|
|
524
|
+
});
|
|
525
|
+
return /*#__PURE__*/ jsx("div", {
|
|
526
|
+
ref: timelineRootRef,
|
|
527
|
+
className: `record-timeline-${variant}`,
|
|
528
|
+
style: {
|
|
529
|
+
minHeight: 0,
|
|
530
|
+
padding: '3px'
|
|
531
|
+
},
|
|
532
|
+
children: /*#__PURE__*/ jsx(Space, {
|
|
533
|
+
direction: "vertical",
|
|
534
|
+
size: "large",
|
|
535
|
+
style: {
|
|
536
|
+
width: '100%'
|
|
537
|
+
},
|
|
538
|
+
children: /*#__PURE__*/ jsx(Timeline, {
|
|
539
|
+
mode: "left",
|
|
540
|
+
className: "timeline-scrollable",
|
|
541
|
+
items: timelineItems,
|
|
542
|
+
style: {
|
|
543
|
+
paddingTop: 16
|
|
544
|
+
}
|
|
545
|
+
})
|
|
546
|
+
})
|
|
547
|
+
});
|
|
548
|
+
};
|
|
549
|
+
export { RecordTimeline };
|
package/dist/button.css
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
.demo-button {
|
|
2
|
+
cursor: pointer;
|
|
3
|
+
border: 0;
|
|
4
|
+
border-radius: 3em;
|
|
5
|
+
font-weight: 700;
|
|
6
|
+
line-height: 1;
|
|
7
|
+
display: inline-block;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
.demo-button--primary {
|
|
11
|
+
color: #fff;
|
|
12
|
+
background-color: #1ea7fd;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
.demo-button--secondary {
|
|
16
|
+
color: #333;
|
|
17
|
+
background-color: #0000;
|
|
18
|
+
box-shadow: inset 0 0 0 1px #00000026;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
.demo-button--small {
|
|
22
|
+
padding: 10px 16px;
|
|
23
|
+
font-size: 12px;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
.demo-button--medium {
|
|
27
|
+
padding: 11px 20px;
|
|
28
|
+
font-size: 14px;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
.demo-button--large {
|
|
32
|
+
padding: 12px 24px;
|
|
33
|
+
font-size: 16px;
|
|
34
|
+
}
|
|
35
|
+
|