@oceanbase/ui 0.2.19 → 0.2.21
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/ui.min.js +1 -1
- package/es/Action/Group.d.ts +1 -1
- package/es/Action/Group.js +50 -41
- package/es/Action/Item.d.ts +2 -2
- package/es/Action/Item.js +32 -26
- package/es/Action/index.d.ts +1 -2
- package/es/BackgroundTaskManager/RefreshMan.js +8 -3
- package/es/BackgroundTaskManager/index.js +8 -4
- package/es/BasicLayout/Header.js +193 -140
- package/es/BasicLayout/index.js +149 -108
- package/es/BatchOperationBar/index.js +46 -29
- package/es/Boundary/Components/Code.js +17 -10
- package/es/Boundary/Components/Exception.js +46 -31
- package/es/Boundary/Components/Function.js +17 -10
- package/es/ContentWithIcon/index.js +42 -26
- package/es/ContentWithIcon/index.less +0 -1
- package/es/Dialog/Anchor.d.ts +1 -1
- package/es/Dialog/Anchor.js +9 -6
- package/es/Dialog/EventProxy.d.ts +1 -1
- package/es/Dialog/EventProxy.js +3 -2
- package/es/Dialog/index.js +129 -108
- package/es/Dialog/index.less +3 -1
- package/es/DocDialog/index.d.ts +1 -1
- package/es/DocDialog/index.js +8 -3
- package/es/FullscreenBox/index.d.ts +1 -1
- package/es/FullscreenBox/index.js +22 -16
- package/es/GraphToolbar/index.js +79 -65
- package/es/Highlight/DiffView/DiffCells.d.ts +2 -2
- package/es/Highlight/DiffView/DiffCells.js +22 -15
- package/es/Highlight/DiffView/index.js +49 -40
- package/es/Highlight/HighlightCell.d.ts +1 -1
- package/es/Highlight/HighlightCell.js +19 -13
- package/es/Highlight/JsonView.d.ts +1 -2
- package/es/Highlight/JsonView.js +15 -13
- package/es/Highlight/index.d.ts +1 -1
- package/es/Highlight/index.js +66 -54
- package/es/IconFont/index.d.ts +1 -1
- package/es/IconFont/index.js +9 -3
- package/es/LocaleDropdown/index.js +38 -26
- package/es/Login/ActivateForm.js +63 -50
- package/es/Login/LoginForm.js +115 -99
- package/es/Login/RegisterForm.js +78 -67
- package/es/Login/index.js +122 -91
- package/es/Lottie/index.js +2 -1
- package/es/NavMenu/index.d.ts +2 -2
- package/es/NavMenu/index.js +34 -29
- package/es/PageContainer/ItemRender.d.ts +1 -2
- package/es/PageContainer/ItemRender.js +7 -3
- package/es/PageContainer/index.js +13 -10
- package/es/Password/Content.js +55 -47
- package/es/Password/index.js +62 -45
- package/es/Ranger/QuickPicker.d.ts +1 -2
- package/es/Ranger/QuickPicker.js +42 -31
- package/es/Ranger/Ranger.js +31 -27
- package/es/SideTip/Dragger.d.ts +1 -1
- package/es/SideTip/Dragger.js +5 -3
- package/es/SideTip/IconLoading.d.ts +1 -2
- package/es/SideTip/IconLoading.js +28 -20
- package/es/SideTip/index.js +43 -30
- package/es/SideTip/index.less +4 -1
- package/es/TagSelect/Group.d.ts +1 -1
- package/es/TagSelect/Group.js +16 -11
- package/es/TagSelect/Item.d.ts +1 -1
- package/es/TagSelect/Item.js +30 -23
- package/es/TagSelect/style/index.d.ts +1 -1
- package/es/TaskGraph/Graph.js +39 -31
- package/es/TaskGraph/index.js +68 -57
- package/es/TreeSearch/index.js +36 -32
- package/es/Welcome/index.js +113 -83
- package/es/Welcome/step.js +31 -23
- package/es/locale/LocaleWrapper.js +3 -3
- package/lib/Action/Group.d.ts +1 -1
- package/lib/Action/Item.d.ts +2 -2
- package/lib/Action/index.d.ts +1 -2
- package/lib/ContentWithIcon/index.less +0 -1
- package/lib/Dialog/Anchor.d.ts +1 -1
- package/lib/Dialog/EventProxy.d.ts +1 -1
- package/lib/Dialog/EventProxy.js +12 -2
- package/lib/Dialog/index.less +3 -1
- package/lib/DocDialog/index.d.ts +1 -1
- package/lib/FullscreenBox/index.d.ts +1 -1
- package/lib/FullscreenBox/index.js +76 -74
- package/lib/Highlight/DiffView/DiffCells.d.ts +2 -2
- package/lib/Highlight/DiffView/index.js +1 -1
- package/lib/Highlight/HighlightCell.d.ts +1 -1
- package/lib/Highlight/JsonView.d.ts +1 -2
- package/lib/Highlight/JsonView.js +3 -3
- package/lib/Highlight/index.d.ts +1 -1
- package/lib/IconFont/index.d.ts +1 -1
- package/lib/NavMenu/index.d.ts +2 -2
- package/lib/PageContainer/ItemRender.d.ts +1 -2
- package/lib/Ranger/QuickPicker.d.ts +1 -2
- package/lib/SideTip/Dragger.d.ts +1 -1
- package/lib/SideTip/IconLoading.d.ts +1 -2
- package/lib/SideTip/index.less +4 -1
- package/lib/TagSelect/Group.d.ts +1 -1
- package/lib/TagSelect/Group.js +4 -6
- package/lib/TagSelect/Item.d.ts +1 -1
- package/lib/TagSelect/style/index.d.ts +1 -1
- package/package.json +10 -9
package/es/GraphToolbar/index.js
CHANGED
|
@@ -17,6 +17,8 @@ import fitViewIcon from "../assets/graph_fit_view_icon.svg";
|
|
|
17
17
|
// @ts-ignore
|
|
18
18
|
import resetIcon from "../assets/graph_reset_icon.svg";
|
|
19
19
|
import "./index.less";
|
|
20
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
21
|
+
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
20
22
|
export function getCenterPointByGraph(graph) {
|
|
21
23
|
var group = graph === null || graph === void 0 ? void 0 : graph.get('group');
|
|
22
24
|
if (group) {
|
|
@@ -59,72 +61,84 @@ var GraphToolbar = function GraphToolbar(_ref) {
|
|
|
59
61
|
setZoom(graph === null || graph === void 0 ? void 0 : graph.getZoom());
|
|
60
62
|
}, 16));
|
|
61
63
|
}, [graph]);
|
|
62
|
-
return /*#__PURE__*/
|
|
64
|
+
return /*#__PURE__*/_jsxs(Space, {
|
|
63
65
|
size: 16,
|
|
64
|
-
className: "".concat(prefix, " ", "".concat(prefix, "-").concat(mode), " ").concat(className)
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
66
|
+
className: "".concat(prefix, " ", "".concat(prefix, "-").concat(mode), " ").concat(className),
|
|
67
|
+
children: [showFullscreen && /*#__PURE__*/_jsx(Tooltip, {
|
|
68
|
+
title: locale.fullscreen,
|
|
69
|
+
children: /*#__PURE__*/_jsx(FullscreenOutlined, {
|
|
70
|
+
className: "pointable",
|
|
71
|
+
onClick: function onClick() {
|
|
72
|
+
if (onFullscreen) {
|
|
73
|
+
onFullscreen();
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
})
|
|
77
|
+
}), /*#__PURE__*/_jsxs("span", {
|
|
78
|
+
className: "".concat(prefix, "-zoom-wrapper"),
|
|
79
|
+
children: [/*#__PURE__*/_jsx(Tooltip, {
|
|
80
|
+
title: locale.shrink,
|
|
81
|
+
children: /*#__PURE__*/_jsx(MinusOutlined, {
|
|
82
|
+
className: zoom >= 0.3 ? "".concat(prefix, "-pointable") : "".concat(prefix, "-disabled"),
|
|
83
|
+
onClick: function onClick() {
|
|
84
|
+
if (zoom >= 0.3) {
|
|
85
|
+
var newZoom = zoom - 0.1;
|
|
86
|
+
setZoom(newZoom);
|
|
87
|
+
graph === null || graph === void 0 ? void 0 : graph.zoomTo(newZoom, getCenterPointByGraph(graph));
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
})
|
|
91
|
+
}), toPercent(zoom), /*#__PURE__*/_jsx(Tooltip, {
|
|
92
|
+
title: locale.enlarge,
|
|
93
|
+
children: /*#__PURE__*/_jsx(PlusOutlined, {
|
|
94
|
+
className: zoom <= 0.9 ? "".concat(prefix, "-pointable") : "".concat(prefix, "-disabled"),
|
|
95
|
+
onClick: function onClick() {
|
|
96
|
+
if (zoom <= 0.9) {
|
|
97
|
+
var newZoom = zoom + 0.1;
|
|
98
|
+
setZoom(newZoom);
|
|
99
|
+
graph === null || graph === void 0 ? void 0 : graph.zoomTo(newZoom, getCenterPointByGraph(graph));
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
})
|
|
103
|
+
})]
|
|
104
|
+
}), /*#__PURE__*/_jsx(Tooltip, {
|
|
105
|
+
title: locale.reset,
|
|
106
|
+
children: /*#__PURE__*/_jsx("img", {
|
|
107
|
+
src: resetIcon,
|
|
108
|
+
alt: "",
|
|
109
|
+
className: "".concat(prefix, "-pointable"),
|
|
110
|
+
onClick: function onClick() {
|
|
111
|
+
setZoom(1);
|
|
112
|
+
graph === null || graph === void 0 ? void 0 : graph.zoomTo(1, getCenterPointByGraph(graph));
|
|
113
|
+
}
|
|
114
|
+
})
|
|
115
|
+
}), /*#__PURE__*/_jsx(Tooltip, {
|
|
116
|
+
title: locale.fitView,
|
|
117
|
+
children: /*#__PURE__*/_jsx("img", {
|
|
118
|
+
src: fitViewIcon,
|
|
119
|
+
alt: "",
|
|
120
|
+
className: "".concat(prefix, "-pointable"),
|
|
121
|
+
onClick: function onClick() {
|
|
122
|
+
graph === null || graph === void 0 ? void 0 : graph.fitView();
|
|
123
|
+
}
|
|
124
|
+
})
|
|
125
|
+
}), onReload && /*#__PURE__*/_jsx("span", {
|
|
126
|
+
children: /*#__PURE__*/_jsx(Divider, {
|
|
127
|
+
type: "vertical",
|
|
128
|
+
className: "".concat(prefix, "-divider")
|
|
129
|
+
})
|
|
130
|
+
}), onReload && /*#__PURE__*/_jsx(Tooltip, {
|
|
131
|
+
title: locale.refresh,
|
|
132
|
+
children: /*#__PURE__*/_jsx("span", {
|
|
133
|
+
children: /*#__PURE__*/_jsx(SyncOutlined, {
|
|
134
|
+
className: "".concat(prefix, "-pointable"),
|
|
135
|
+
onClick: function onClick() {
|
|
136
|
+
onReload();
|
|
137
|
+
}
|
|
138
|
+
})
|
|
139
|
+
})
|
|
140
|
+
})]
|
|
141
|
+
});
|
|
128
142
|
};
|
|
129
143
|
export default LocaleWrapper({
|
|
130
144
|
componentName: 'GraphToolbar',
|
|
@@ -12,6 +12,6 @@ export interface DiffCellsProps {
|
|
|
12
12
|
lock?: boolean;
|
|
13
13
|
rowOffset?: number;
|
|
14
14
|
onMouseDown?: React.MouseEventHandler;
|
|
15
|
-
hashId
|
|
15
|
+
hashId?: string;
|
|
16
16
|
}
|
|
17
|
-
export default function DiffCells({ diffPrefixCls, data, emptyText, width, lock, rowOffset, onMouseDown, hashId, }: DiffCellsProps):
|
|
17
|
+
export default function DiffCells({ diffPrefixCls, data, emptyText, width, lock, rowOffset, onMouseDown, hashId, }: DiffCellsProps): import("@emotion/react/types/jsx-namespace").EmotionJSX.Element;
|
|
@@ -4,6 +4,9 @@ function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _ty
|
|
|
4
4
|
function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
|
5
5
|
import classNames from 'classnames';
|
|
6
6
|
import * as React from 'react';
|
|
7
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
8
|
+
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
9
|
+
import { Fragment as _Fragment } from "react/jsx-runtime";
|
|
7
10
|
export default function DiffCells(_ref) {
|
|
8
11
|
var _mergedClassName, _data$value;
|
|
9
12
|
var diffPrefixCls = _ref.diffPrefixCls,
|
|
@@ -25,19 +28,23 @@ export default function DiffCells(_ref) {
|
|
|
25
28
|
if (rowIndex !== undefined) {
|
|
26
29
|
rowIndex += rowOffset;
|
|
27
30
|
}
|
|
28
|
-
return /*#__PURE__*/
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
31
|
+
return /*#__PURE__*/_jsxs(_Fragment, {
|
|
32
|
+
children: [/*#__PURE__*/_jsx("td", {
|
|
33
|
+
className: classNames("".concat(diffPrefixCls, "-index"), mergedClassName, hashId),
|
|
34
|
+
children: rowIndex
|
|
35
|
+
}), /*#__PURE__*/_jsxs("td", {
|
|
36
|
+
className: classNames("".concat(diffPrefixCls, "-mark"), mergedClassName, hashId),
|
|
37
|
+
children: [add && '+', remove && '-']
|
|
38
|
+
}), /*#__PURE__*/_jsx("td", {
|
|
39
|
+
onMouseDown: onMouseDown,
|
|
40
|
+
style: {
|
|
41
|
+
width: width,
|
|
42
|
+
userSelect: lock ? 'none' : undefined
|
|
43
|
+
},
|
|
44
|
+
className: classNames("".concat(diffPrefixCls, "-code"), mergedClassName, hashId),
|
|
45
|
+
dangerouslySetInnerHTML: {
|
|
46
|
+
__html: (_data$value = data === null || data === void 0 ? void 0 : data.value) !== null && _data$value !== void 0 ? _data$value : emptyText || ''
|
|
47
|
+
}
|
|
48
|
+
})]
|
|
49
|
+
});
|
|
43
50
|
}
|
|
@@ -20,11 +20,13 @@ import hljs from 'highlight.js/lib/core';
|
|
|
20
20
|
import warning from 'rc-util/lib/warning';
|
|
21
21
|
import React, { useEffect, useMemo } from 'react';
|
|
22
22
|
import { languageMap } from '..';
|
|
23
|
-
import { getPrefix } from "
|
|
23
|
+
import { getPrefix } from "../../_util";
|
|
24
24
|
import { useKeyDownCopyEvent } from "../useKeyDownCopyEvent";
|
|
25
25
|
import DiffCells from "./DiffCells";
|
|
26
26
|
// @ts-ignore
|
|
27
27
|
import "../index.less";
|
|
28
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
29
|
+
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
28
30
|
var MAX_MERGE_TIMES = 10000;
|
|
29
31
|
var EMPTY_TEXT = "<span class=\"hljs-comment\">// \u6CA1\u6709\u6570\u636E</span>";
|
|
30
32
|
function getHighlightRows(language, code) {
|
|
@@ -256,62 +258,69 @@ var DiffView = function DiffView(_ref2) {
|
|
|
256
258
|
// ============================ Render ============================
|
|
257
259
|
var viewRows;
|
|
258
260
|
if (!report) {
|
|
259
|
-
viewRows = /*#__PURE__*/
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
261
|
+
viewRows = /*#__PURE__*/_jsx("tr", {
|
|
262
|
+
children: /*#__PURE__*/_jsx(DiffCells, {
|
|
263
|
+
width: "100%",
|
|
264
|
+
diffPrefixCls: diffPrefixCls,
|
|
265
|
+
data: {
|
|
266
|
+
index: 1,
|
|
267
|
+
value: EMPTY_TEXT,
|
|
268
|
+
type: 'keep'
|
|
269
|
+
}
|
|
270
|
+
})
|
|
271
|
+
});
|
|
268
272
|
} else if (split) {
|
|
269
273
|
// Split view
|
|
270
274
|
viewRows = mergedData.rows.map(function (_ref4, index) {
|
|
271
275
|
var src = _ref4.source,
|
|
272
276
|
tgt = _ref4.target;
|
|
273
|
-
return /*#__PURE__*/
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
})
|
|
277
|
+
return /*#__PURE__*/_jsxs("tr", {
|
|
278
|
+
children: [/*#__PURE__*/_jsx(DiffCells, {
|
|
279
|
+
width: "50%",
|
|
280
|
+
diffPrefixCls: diffPrefixCls,
|
|
281
|
+
data: src,
|
|
282
|
+
emptyText: index === 0 && mergedData.sourceEmpty && EMPTY_TEXT,
|
|
283
|
+
onMouseDown: onSourceMouseDown,
|
|
284
|
+
lock: selectable !== 'source',
|
|
285
|
+
rowOffset: rowOffsetSrc
|
|
286
|
+
}), /*#__PURE__*/_jsx(DiffCells, {
|
|
287
|
+
width: "50%",
|
|
288
|
+
diffPrefixCls: diffPrefixCls,
|
|
289
|
+
data: tgt,
|
|
290
|
+
emptyText: index === 0 && mergedData.targetEmpty && EMPTY_TEXT,
|
|
291
|
+
onMouseDown: onTargetMouseDown,
|
|
292
|
+
lock: selectable !== 'target',
|
|
293
|
+
rowOffset: rowOffsetTgt
|
|
294
|
+
})]
|
|
295
|
+
}, index);
|
|
292
296
|
});
|
|
293
297
|
} else {
|
|
294
298
|
// Merge
|
|
295
299
|
viewRows = diffData.sourceRows.map(function (src, index) {
|
|
296
|
-
return /*#__PURE__*/
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
})
|
|
300
|
+
return /*#__PURE__*/_jsx("tr", {
|
|
301
|
+
children: /*#__PURE__*/_jsx(DiffCells, {
|
|
302
|
+
width: "100%",
|
|
303
|
+
diffPrefixCls: diffPrefixCls,
|
|
304
|
+
data: src !== null && src !== void 0 ? src : diffData.targetRows[index],
|
|
305
|
+
rowOffset: rowOffsetTgt
|
|
306
|
+
})
|
|
307
|
+
}, index);
|
|
304
308
|
});
|
|
305
309
|
}
|
|
306
310
|
var codeRef = React.useRef();
|
|
307
311
|
useKeyDownCopyEvent(codeRef);
|
|
308
|
-
return /*#__PURE__*/
|
|
312
|
+
return /*#__PURE__*/_jsx("div", {
|
|
309
313
|
style: _objectSpread({
|
|
310
314
|
height: height
|
|
311
315
|
}, style),
|
|
312
316
|
ref: codeRef,
|
|
313
317
|
tabIndex: -1,
|
|
314
|
-
className: classNames(prefixCls, diffPrefixCls, "".concat(prefixCls, "-").concat(theme === 'dark' ? 'dark' : 'light'), _defineProperty({}, "".concat(diffPrefixCls, "-split"), split), className)
|
|
315
|
-
|
|
318
|
+
className: classNames(prefixCls, diffPrefixCls, "".concat(prefixCls, "-").concat(theme === 'dark' ? 'dark' : 'light'), _defineProperty({}, "".concat(diffPrefixCls, "-split"), split), className),
|
|
319
|
+
children: /*#__PURE__*/_jsx("table", {
|
|
320
|
+
children: /*#__PURE__*/_jsx("tbody", {
|
|
321
|
+
children: viewRows
|
|
322
|
+
})
|
|
323
|
+
})
|
|
324
|
+
});
|
|
316
325
|
};
|
|
317
326
|
export default DiffView;
|
|
@@ -15,4 +15,4 @@ export interface HighlightCellProps {
|
|
|
15
15
|
lineNumber?: boolean;
|
|
16
16
|
hashId?: string;
|
|
17
17
|
}
|
|
18
|
-
export default function HighlightCell({ prefixCls, theme, data, emptyText, width, lock, lineNumber, onMouseDown, hashId, }: HighlightCellProps):
|
|
18
|
+
export default function HighlightCell({ prefixCls, theme, data, emptyText, width, lock, lineNumber, onMouseDown, hashId, }: HighlightCellProps): import("@emotion/react/types/jsx-namespace").EmotionJSX.Element;
|
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
import classNames from 'classnames';
|
|
2
2
|
import * as React from 'react';
|
|
3
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
4
|
+
import { Fragment as _Fragment } from "react/jsx-runtime";
|
|
5
|
+
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
6
|
export default function HighlightCell(_ref) {
|
|
4
7
|
var _data$value;
|
|
5
8
|
var prefixCls = _ref.prefixCls,
|
|
@@ -13,17 +16,20 @@ export default function HighlightCell(_ref) {
|
|
|
13
16
|
onMouseDown = _ref.onMouseDown,
|
|
14
17
|
hashId = _ref.hashId;
|
|
15
18
|
var rowIndex = data === null || data === void 0 ? void 0 : data.index;
|
|
16
|
-
return /*#__PURE__*/
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
19
|
+
return /*#__PURE__*/_jsxs(_Fragment, {
|
|
20
|
+
children: [lineNumber ? /*#__PURE__*/_jsx("td", {
|
|
21
|
+
className: classNames("".concat(prefixCls, "-").concat(theme, "-index"), "".concat(prefixCls, "-index"), hashId),
|
|
22
|
+
children: rowIndex
|
|
23
|
+
}) : null, /*#__PURE__*/_jsx("td", {
|
|
24
|
+
onMouseDown: onMouseDown,
|
|
25
|
+
style: {
|
|
26
|
+
width: width,
|
|
27
|
+
userSelect: lock ? 'none' : undefined
|
|
28
|
+
},
|
|
29
|
+
className: classNames("".concat(prefixCls, "-content"), hashId),
|
|
30
|
+
dangerouslySetInnerHTML: {
|
|
31
|
+
__html: (_data$value = data === null || data === void 0 ? void 0 : data.value) !== null && _data$value !== void 0 ? _data$value : emptyText || ''
|
|
32
|
+
}
|
|
33
|
+
})]
|
|
34
|
+
});
|
|
29
35
|
}
|
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
/// <reference types="react" />
|
|
2
1
|
import type { HighlightProps } from '.';
|
|
3
2
|
import './index.less';
|
|
4
3
|
export interface JsonViewProps extends HighlightProps {
|
|
5
4
|
json: object;
|
|
6
5
|
}
|
|
7
|
-
declare const _default: ({ json, theme, style, className, height, onCopyChange, copyable, }: JsonViewProps) => import("react").
|
|
6
|
+
declare const _default: ({ json, theme, style, className, height, onCopyChange, copyable, }: JsonViewProps) => import("@emotion/react/types/jsx-namespace").EmotionJSX.Element;
|
|
8
7
|
export default _default;
|
package/es/Highlight/JsonView.js
CHANGED
|
@@ -3,13 +3,14 @@ function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key i
|
|
|
3
3
|
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
|
|
4
4
|
function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
|
5
5
|
import classNames from 'classnames';
|
|
6
|
-
import { useRef } from 'react';
|
|
6
|
+
import React, { useRef } from 'react';
|
|
7
7
|
import ReactJson from 'react-json-view';
|
|
8
8
|
import { getPrefix } from "../_util";
|
|
9
9
|
import { THEME_DARK } from '.';
|
|
10
10
|
import { useKeyDownCopyEvent } from "./useKeyDownCopyEvent";
|
|
11
11
|
// @ts-ignore
|
|
12
12
|
import "./index.less";
|
|
13
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
13
14
|
export default (function (_ref) {
|
|
14
15
|
var json = _ref.json,
|
|
15
16
|
theme = _ref.theme,
|
|
@@ -24,21 +25,22 @@ export default (function (_ref) {
|
|
|
24
25
|
var isDarkTheme = theme === THEME_DARK;
|
|
25
26
|
var codeRef = useRef();
|
|
26
27
|
useKeyDownCopyEvent(codeRef);
|
|
27
|
-
return /*#__PURE__*/
|
|
28
|
+
return /*#__PURE__*/_jsx("div", {
|
|
28
29
|
style: style,
|
|
29
30
|
ref: codeRef
|
|
30
31
|
// 让div支持focus能力
|
|
31
32
|
,
|
|
32
33
|
tabIndex: -1,
|
|
33
|
-
className: classNames(prefixCls, "".concat(prefixCls, "-json-view"), _defineProperty({}, "".concat(prefixCls, "-light"), !isDarkTheme), className)
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
34
|
+
className: classNames(prefixCls, "".concat(prefixCls, "-json-view"), _defineProperty({}, "".concat(prefixCls, "-light"), !isDarkTheme), className),
|
|
35
|
+
children: /*#__PURE__*/_jsx(ReactJson, {
|
|
36
|
+
enableClipboard: copyable && onCopyChange,
|
|
37
|
+
src: json,
|
|
38
|
+
theme: isDarkTheme ? 'ocean' : undefined,
|
|
39
|
+
displayDataTypes: false,
|
|
40
|
+
style: {
|
|
41
|
+
height: height
|
|
42
|
+
},
|
|
43
|
+
name: false
|
|
44
|
+
})
|
|
45
|
+
});
|
|
44
46
|
});
|
package/es/Highlight/index.d.ts
CHANGED
|
@@ -29,7 +29,7 @@ export declare const THEME_DARK = "dark";
|
|
|
29
29
|
export declare const THEME_LIGHT = "light";
|
|
30
30
|
declare const ThemeTypes: ["dark", "light"];
|
|
31
31
|
export type ThemeType = (typeof ThemeTypes)[number];
|
|
32
|
-
declare const supportedLanguages: ("ruby" | "
|
|
32
|
+
declare const supportedLanguages: ("ruby" | "css" | "javascript" | "typescript" | "groovy" | "java" | "python" | "bash" | "json" | "cpp" | "http" | "markdown" | "nginx" | "sql" | "xml" | "dockerfile" | "go" | "yaml" | "solidity" | "tsx" | "jsx")[];
|
|
33
33
|
export type LanguageType = (typeof supportedLanguages)[number] | 'html';
|
|
34
34
|
export interface HighlightProps extends LocaleWrapperProps {
|
|
35
35
|
/**
|
package/es/Highlight/index.js
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
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); }
|
|
2
|
-
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); }
|
|
3
2
|
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
4
3
|
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
5
4
|
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
@@ -55,6 +54,9 @@ import { useKeyDownCopyEvent } from "./useKeyDownCopyEvent";
|
|
|
55
54
|
import "./index.less";
|
|
56
55
|
|
|
57
56
|
// 目前支持的语言列表
|
|
57
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
58
|
+
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
59
|
+
import { Fragment as _Fragment } from "react/jsx-runtime";
|
|
58
60
|
export var languageMap = {
|
|
59
61
|
javascript: javascript,
|
|
60
62
|
typescript: typescript,
|
|
@@ -148,15 +150,15 @@ var Highlight = function Highlight(props) {
|
|
|
148
150
|
};
|
|
149
151
|
});
|
|
150
152
|
setCodeBlock(rowList.map(function (src, index) {
|
|
151
|
-
return /*#__PURE__*/
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
})
|
|
153
|
+
return /*#__PURE__*/_jsx("tr", {
|
|
154
|
+
children: /*#__PURE__*/_jsx(HighlightCell, {
|
|
155
|
+
lineNumber: lineNumber,
|
|
156
|
+
width: "100%",
|
|
157
|
+
data: src,
|
|
158
|
+
theme: theme,
|
|
159
|
+
prefixCls: prefixCls
|
|
160
|
+
})
|
|
161
|
+
}, index);
|
|
160
162
|
}));
|
|
161
163
|
};
|
|
162
164
|
|
|
@@ -177,7 +179,7 @@ var Highlight = function Highlight(props) {
|
|
|
177
179
|
customProps.dangerouslySetInnerHTML = {
|
|
178
180
|
__html: children
|
|
179
181
|
};
|
|
180
|
-
return /*#__PURE__*/
|
|
182
|
+
return /*#__PURE__*/_jsx("div", _objectSpread({}, customProps));
|
|
181
183
|
}
|
|
182
184
|
var CopyButton = function CopyButton() {
|
|
183
185
|
var _useState = useState(),
|
|
@@ -193,58 +195,68 @@ var Highlight = function Highlight(props) {
|
|
|
193
195
|
_useState4 = _slicedToArray(_useState3, 2),
|
|
194
196
|
copied = _useState4[0],
|
|
195
197
|
setCopied = _useState4[1];
|
|
196
|
-
return /*#__PURE__*/
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
198
|
+
return /*#__PURE__*/_jsx(_Fragment, {
|
|
199
|
+
children: /*#__PURE__*/_jsx(CopyToClipboard, {
|
|
200
|
+
text: children && children.length ? children : '',
|
|
201
|
+
onCopy: function onCopy(value) {
|
|
202
|
+
onCopyChange(value);
|
|
203
|
+
setCopied(true);
|
|
204
|
+
message.success('Copied');
|
|
205
|
+
var tempCopyId = window.setTimeout(function () {
|
|
206
|
+
setCopied(false);
|
|
207
|
+
}, 2000);
|
|
208
|
+
setCopyId(tempCopyId);
|
|
209
|
+
},
|
|
210
|
+
children: /*#__PURE__*/_jsxs("button", {
|
|
211
|
+
disabled: copied,
|
|
212
|
+
className: classNames("".concat(prefixCls, "-copy")),
|
|
213
|
+
style: {
|
|
214
|
+
background: "".concat(theme === THEME_DARK ? "#2b303b" : token.colorBgLayout)
|
|
215
|
+
},
|
|
216
|
+
children: [/*#__PURE__*/_jsx(CopyOutlined, {
|
|
217
|
+
className: classNames("".concat(prefixCls, "-copy-icon"), {
|
|
218
|
+
scoll: copied
|
|
219
|
+
}),
|
|
220
|
+
style: {
|
|
221
|
+
color: "".concat(theme === THEME_DARK ? token.colorBgLayout : "#2b303b")
|
|
222
|
+
}
|
|
223
|
+
}), /*#__PURE__*/_jsx(CheckOutlined, {
|
|
224
|
+
className: classNames("".concat(prefixCls, "-copy-icon")),
|
|
225
|
+
style: {
|
|
226
|
+
color: 'rgb(63,177,99)'
|
|
227
|
+
}
|
|
228
|
+
})]
|
|
229
|
+
})
|
|
230
|
+
})
|
|
231
|
+
});
|
|
226
232
|
};
|
|
227
|
-
return /*#__PURE__*/
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
233
|
+
return /*#__PURE__*/_jsx(_Fragment, {
|
|
234
|
+
children: /*#__PURE__*/_jsxs("pre", _objectSpread(_objectSpread({}, customProps), {}, {
|
|
235
|
+
style: _objectSpread(_objectSpread({}, customStyle), {}, {
|
|
236
|
+
position: 'relative'
|
|
237
|
+
}),
|
|
238
|
+
className: classNames("".concat(prefixCls), className, themeClass),
|
|
239
|
+
children: [copyable && /*#__PURE__*/_jsx(CopyButton, {}), /*#__PURE__*/_jsx("table", {
|
|
240
|
+
style: {
|
|
241
|
+
height: height
|
|
242
|
+
},
|
|
243
|
+
className: classNames("".concat(theme === THEME_DARK ? "".concat(prefixCls, "-dark") : "".concat(prefixCls, "-light"))),
|
|
244
|
+
children: /*#__PURE__*/_jsx("tbody", {
|
|
245
|
+
children: codeBlock
|
|
246
|
+
})
|
|
247
|
+
})]
|
|
248
|
+
}))
|
|
249
|
+
});
|
|
238
250
|
};
|
|
239
251
|
var HighlightWrapper = function HighlightWrapper(props) {
|
|
240
252
|
var language = props.language,
|
|
241
253
|
children = props.children;
|
|
242
254
|
if (language === 'json' && children && _typeof(children) === 'object' && ! /*#__PURE__*/React.isValidElement(children)) {
|
|
243
|
-
return /*#__PURE__*/
|
|
255
|
+
return /*#__PURE__*/_jsx(JsonView, _objectSpread(_objectSpread({}, props), {}, {
|
|
244
256
|
json: children
|
|
245
257
|
}));
|
|
246
258
|
}
|
|
247
|
-
return /*#__PURE__*/
|
|
259
|
+
return /*#__PURE__*/_jsx(Highlight, _objectSpread({}, props));
|
|
248
260
|
};
|
|
249
261
|
HighlightWrapper.Diff = DiffView;
|
|
250
262
|
|