Skip to content

Commit f6099e9

Browse files
committed
fix: rebase dev
2 parents bdffc78 + 6d2dbeb commit f6099e9

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+4327
-5557
lines changed

.eslintrc.js

+1
Original file line numberDiff line numberDiff line change
@@ -35,5 +35,6 @@ module.exports = {
3535
'valid-jsdoc': 0,
3636
'no-unused-vars': 0,
3737
'no-invalid-this': 0,
38+
'react/display-name': 0,
3839
},
3940
};

.yarnrc

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
# Set default registry: yarn config set registry https://registry.yarnpkg.com
2-
registry=http://registry.npm.dtstack.com/
2+
registry "http://registry.npm.dtstack.com/"

build/web/favicon.png

317 Bytes
Loading

package.json

+10-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
"main": "dist/index.js",
66
"scripts": {
77
"test": "jest --coverage",
8-
"dev": "tsc --skipLibCheck && start-storybook -s ./public -p 6006",
8+
"dev": "start-storybook -s ./dist -p 6006",
99
"build-storybook": "build-storybook",
1010
"check-types": "tsc --skipLibCheck",
1111
"build": "tsc --project tsconfig.build.json",
@@ -27,11 +27,15 @@
2727
"@types/react": "^16.9.35",
2828
"@types/react-dom": "^16.9.9",
2929
"dt-utils": "^1.0.1",
30+
"immutability-helper": "^3.1.1",
3031
"loadsh": "^0.0.4",
3132
"monaco-editor": "^0.21.2",
3233
"rc-collapse": "^2.0.1",
3334
"rc-tree": "^3.10.0",
3435
"react": "^16.13.1",
36+
"react-dnd": "^9.3.4",
37+
"react-dnd-html5-backend": "^9.3.4",
38+
"rc-tabs": "11.7.0",
3539
"react-dom": "^16.13.1",
3640
"react-split-pane": "^0.1.92",
3741
"reflect-metadata": "^0.1.13",
@@ -78,5 +82,10 @@
7882
"commit-msg": "commitlint -E HUSKY_GIT_PARAMS",
7983
"pre-push": "prettier --ignore-unknown --write ."
8084
}
85+
},
86+
"config": {
87+
"commitizen": {
88+
"path": "cz-conventional-changelog"
89+
}
8190
}
8291
}

src/common/className.ts

-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import { APP_PREFIX } from 'mo/common/const';
2-
32
/**
43
* This function help you prefix a css class name, default is molecule.
54
* Example: prefixClaName('test') will return 'molecule-test',

src/components/actionbar/index.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ export default function ActionBar<T = any>(props: IActionBar<T>) {
5454
const claNames = classNames(prefixClaName(rootClassName), className);
5555

5656
const items = data.map((item: IActionBarItem<T>) => (
57-
<ActionBarItem key={item.id} {...item} />
57+
<ActionBarItem key={item.id} onClick={onClick} {...item} />
5858
));
5959

6060
return (

src/components/actionbar/style.scss

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
@import 'mo/style/const';
1+
@import 'mo/style/common';
22
$actionBar: 'action-bar';
33

44
#{prefix($actionBar)} {

src/components/collapse/index.tsx

+8-12
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,17 @@
11
import * as React from 'react';
22
import RcCollapse from 'rc-collapse';
3-
4-
import './style.scss';
3+
import { CollapseProps } from 'rc-collapse/lib/interface';
54
import { prefixClaName, classNames } from 'mo/common/className';
5+
import './style.scss';
66

7-
interface ICollapseProps {
8-
className?: string;
9-
}
10-
11-
export const Collapse: React.FunctionComponent<ICollapseProps> = (
12-
props: ICollapseProps
7+
export const Collapse: React.FunctionComponent<CollapseProps> = (
8+
props: CollapseProps
139
) => {
10+
const { className, ...others } = props;
1411
return (
15-
<RcCollapse
16-
className={classNames(prefixClaName('collapse'), props.className)}
17-
{...props}
18-
/>
12+
<div className={classNames(prefixClaName('collapse'), className)}>
13+
<RcCollapse {...others} />
14+
</div>
1915
);
2016
};
2117

src/components/collapse/style.scss

+81-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,84 @@
1-
@import 'mo/style/const.scss';
1+
@import 'mo/style/common';
2+
$collapse: 'collapse';
23

3-
.#{prefix}-collapse {
4+
@mixin header_border {
5+
border: 1px solid rgba(97, 97, 97, 0.19);
6+
}
7+
8+
#{prefix($collapse)} {
49
font-size: 13px;
10+
11+
.rc-collapse {
12+
background-color: inherit;
13+
}
14+
15+
.rc-collapse-anim-active {
16+
transition: height 0.2s ease-out;
17+
}
18+
19+
.rc-collapse > .rc-collapse-item {
20+
border-top: 0;
21+
color: #bbb;
22+
}
23+
24+
.rc-collapse > .rc-collapse-item > .rc-collapse-header {
25+
align-items: center;
26+
background: #333;
27+
cursor: pointer;
28+
display: flex;
29+
font-weight: bold;
30+
height: 22px;
31+
outline: none;
32+
padding: 1px 5px;
33+
padding: 1px 5px;
34+
35+
&:focus {
36+
@include header_border;
37+
}
38+
39+
&:active {
40+
@include header_border;
41+
}
42+
}
43+
44+
.rc-collapse > .rc-collapse-item > .rc-collapse-header .rc-collapse-extra {
45+
margin: 0 0 0 auto;
46+
47+
.action-label.codicon {
48+
height: inherit;
49+
line-height: inherit;
50+
}
51+
}
52+
53+
.rc-collapse > .rc-collapse-item .rc-collapse-header-collapsable-only {
54+
cursor: default;
55+
}
56+
57+
.rc-collapse
58+
> .rc-collapse-item
59+
.rc-collapse-header-collapsable-only
60+
.rc-collapse-header-text {
61+
cursor: pointer;
62+
}
63+
64+
.rc-collapse > .rc-collapse-item-disabled > .rc-collapse-header {
65+
cursor: not-allowed;
66+
}
67+
68+
.rc-collapse-content {
69+
overflow: auto;
70+
}
71+
72+
.rc-collapse-content > .rc-collapse-content-box {
73+
font-size: 12px;
74+
margin-bottom: 8px;
75+
}
76+
77+
.rc-collapse-content-inactive {
78+
display: none;
79+
}
80+
81+
.rc-collapse-item:last-child > .rc-collapse-content {
82+
border-radius: 0 0 3px 3px;
83+
}
584
}

src/components/contextMenu/style.scss

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
@import 'mo/style/const';
1+
@import 'mo/style/common';
22
$name: 'context-menu';
33

44
// #{prefix($name)} {

src/components/contextview/style.scss

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
@import 'mo/style/const';
1+
@import 'mo/style/common';
22
$name: 'context-view';
33

44
#{prefix($name)} {

src/components/dropdown/style.scss

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
@import 'mo/style/const';
1+
@import 'mo/style/common';
22
$dropDown: 'drop-down';
33

44
#{prefix($dropDown)} {

src/components/menu/style.scss

+7-5
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
1-
@import 'mo/style/const';
1+
@import 'mo/style/common';
22
$menu: 'menu';
3+
$subMenu: 'sub-menu';
4+
$menuItem: 'menu-item';
35

46
#{prefix($menu)} {
57
display: flex;
@@ -12,7 +14,7 @@ $menu: 'menu';
1214
flex-direction: column;
1315
padding: 0.5em 0;
1416

15-
#{prefix('menu-item')} {
17+
#{prefix($menuItem)} {
1618
min-width: 120px;
1719
}
1820

@@ -27,7 +29,7 @@ $menu: 'menu';
2729
&.horizontal {
2830
flex-direction: row;
2931

30-
#{prefix('menu-item')} {
32+
#{prefix($menuItem)} {
3133
min-width: 120px;
3234
}
3335
}
@@ -80,11 +82,11 @@ $menu: 'menu';
8082
}
8183
}
8284

83-
#{prefix('menu-item')} {
85+
#{prefix($menuItem)} {
8486
font-size: 13px;
8587
}
8688

87-
#{prefix('sub-menu')} {
89+
#{prefix($subMenu)} {
8890
display: block;
8991
font-size: 13px;
9092
position: fixed;

src/components/tabs/Tab.tsx

+73
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
import * as React from 'react';
2+
import { useRef } from 'react';
3+
import { findDOMNode } from 'react-dom';
4+
import {
5+
DragSourceMonitor,
6+
DropTargetMonitor,
7+
useDrag,
8+
useDrop,
9+
} from 'react-dnd';
10+
11+
interface ITabProps {
12+
active?: string;
13+
content?: React.ReactNode;
14+
index?: number;
15+
id?: number | string;
16+
name?: any;
17+
moveTab: (dragIndex?: number, hoverIndex?: number | string) => void;
18+
}
19+
20+
const WrapTabNode: React.FC<ITabProps> = (props) => {
21+
const { id, index, moveTab, children } = props;
22+
const ref = useRef<HTMLDivElement>(null);
23+
24+
const [, drag] = useDrag({
25+
collect: (monitor: DragSourceMonitor) => ({
26+
isDragging: monitor.isDragging(),
27+
}),
28+
item: { type: 'DND_NODE', id, index },
29+
});
30+
31+
const [, drop] = useDrop({
32+
accept: 'DND_NODE',
33+
hover(
34+
item: { type: string; index: number },
35+
monitor: DropTargetMonitor
36+
) {
37+
debugger;
38+
if (!ref.current) return;
39+
let hoverIndex;
40+
const component = ref.current;
41+
const dragIndex = monitor.getItem().index;
42+
hoverIndex = index;
43+
// Don't replace items with themselves
44+
if (dragIndex === hoverIndex) {
45+
return;
46+
}
47+
const hoverBoundingRect = (findDOMNode(
48+
component
49+
) as Element)?.getBoundingClientRect();
50+
const hoverMiddleX =
51+
(hoverBoundingRect.right - hoverBoundingRect.left) / 2;
52+
const clientOffset = monitor.getClientOffset();
53+
const hoverClientX =
54+
(clientOffset as { x: number; y: number }).x -
55+
hoverBoundingRect.left;
56+
// 往下拖动
57+
if (dragIndex < hoverIndex && hoverClientX < hoverMiddleX) {
58+
return;
59+
}
60+
// 往上拖动
61+
if (dragIndex > hoverIndex && hoverClientX > hoverMiddleX) {
62+
return;
63+
}
64+
moveTab(dragIndex, hoverIndex);
65+
monitor.getItem().index = hoverIndex;
66+
},
67+
});
68+
drag(drop(ref));
69+
70+
return <div ref={ref}>{children}</div>;
71+
};
72+
73+
export default WrapTabNode;

0 commit comments

Comments
 (0)