@antscorp/antsomi-ui 1.3.5-beta.314 → 1.3.5-beta.316
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/es/components/molecules/EditorTab/EditorTab.d.ts +1 -6
- package/es/components/molecules/EditorTab/EditorTab.js +8 -15
- package/es/components/molecules/EditorTab/styled.js +10 -0
- package/es/components/organism/PreviewTemplateModal/components/Banner/styled.js +1 -1
- package/es/constants/theme.js +3 -3
- package/package.json +1 -1
|
@@ -3,14 +3,9 @@ interface EditorTabItem {
|
|
|
3
3
|
showIcon?: boolean;
|
|
4
4
|
showDropdown?: boolean;
|
|
5
5
|
closeable?: boolean;
|
|
6
|
-
formatSelectedText: string;
|
|
7
|
-
formattedQuery: string;
|
|
8
6
|
id: string;
|
|
9
7
|
name: string;
|
|
10
|
-
|
|
11
|
-
type: string;
|
|
12
|
-
selectedTextOut: string;
|
|
13
|
-
queryResult: any;
|
|
8
|
+
type: 'query' | 'table-detail';
|
|
14
9
|
cursorSql?: string;
|
|
15
10
|
cursorSqlOut?: string;
|
|
16
11
|
refreshAndFocusId?: string;
|
|
@@ -9,12 +9,6 @@ import { EditorTabStyled } from './styled';
|
|
|
9
9
|
// Utils
|
|
10
10
|
import { handleError } from '@antscorp/antsomi-ui/es/utils';
|
|
11
11
|
const PATH = 'src/components/EditorTab/index.jsx';
|
|
12
|
-
const constants = {
|
|
13
|
-
TAB_TYPE: {
|
|
14
|
-
QUERY: 'query',
|
|
15
|
-
TABLE_DETAIL: 'table-detail',
|
|
16
|
-
},
|
|
17
|
-
};
|
|
18
12
|
export const EditorTab = props => {
|
|
19
13
|
var _a;
|
|
20
14
|
const { listTab = [], activeId = '', showArrow, showDropdown, disabledScroll, onCloseTab, onActiveTab, handleAddTab, onConfigure, onSaveName, showComposeNewQuery, className, leftBlockClassName, tabItemClassName, } = props;
|
|
@@ -23,15 +17,13 @@ export const EditorTab = props => {
|
|
|
23
17
|
const [isEditable, setIsEditable] = useState();
|
|
24
18
|
// Ref
|
|
25
19
|
const leftBlockRef = useRef(null);
|
|
26
|
-
const activeTabIdx = useMemo(() =>
|
|
27
|
-
return arrTabs.findIndex(tab => tab.id === activeId);
|
|
28
|
-
}, [activeId]);
|
|
20
|
+
const activeTabIdx = useMemo(() => arrTabs.findIndex(tab => tab.id === activeId), [activeId, arrTabs]);
|
|
29
21
|
useEffect(() => {
|
|
30
22
|
if (listTab.length - arrTabs.length === 1) {
|
|
31
23
|
setActiveTabId(listTab[listTab.length - 1].id);
|
|
32
24
|
}
|
|
33
25
|
setArrTabs(listTab);
|
|
34
|
-
}, [listTab]);
|
|
26
|
+
}, [listTab, arrTabs.length]);
|
|
35
27
|
useEffect(() => {
|
|
36
28
|
onActiveTab(activeTabId);
|
|
37
29
|
setTimeout(() => {
|
|
@@ -42,12 +34,12 @@ export const EditorTab = props => {
|
|
|
42
34
|
}
|
|
43
35
|
}
|
|
44
36
|
}, 500);
|
|
45
|
-
}, [activeTabId]);
|
|
37
|
+
}, [activeTabId, disabledScroll, onActiveTab]);
|
|
46
38
|
useEffect(() => {
|
|
47
39
|
if (activeId && activeTabId !== activeId) {
|
|
48
40
|
setActiveTabId(activeId);
|
|
49
41
|
}
|
|
50
|
-
}, [activeId]);
|
|
42
|
+
}, [activeId, activeTabId]);
|
|
51
43
|
const handleAddNew = () => {
|
|
52
44
|
handleAddTab();
|
|
53
45
|
};
|
|
@@ -105,6 +97,8 @@ export const EditorTab = props => {
|
|
|
105
97
|
}
|
|
106
98
|
setActiveTabId(arrTabs[idx + 1].id);
|
|
107
99
|
break;
|
|
100
|
+
default:
|
|
101
|
+
break;
|
|
108
102
|
}
|
|
109
103
|
}
|
|
110
104
|
};
|
|
@@ -121,7 +115,7 @@ export const EditorTab = props => {
|
|
|
121
115
|
active: tab.id === activeTabId,
|
|
122
116
|
}) },
|
|
123
117
|
showIcon &&
|
|
124
|
-
(tab.type ===
|
|
118
|
+
(tab.type === 'query' ? (React.createElement(Icon, { type: "icon-ants-material-outline-manage-search", overlayStyle: { fontSize: 21 } })) : (React.createElement(Icon, { type: "icon-ants-table-vertical", overlayStyle: { fontSize: 21 } }))),
|
|
125
119
|
isEditable === tab.id ? (React.createElement(ContentEditable, { value: tab.name, onSave: newValue => {
|
|
126
120
|
setIsEditable(undefined);
|
|
127
121
|
onSaveName === null || onSaveName === void 0 ? void 0 : onSaveName(tab.id, newValue);
|
|
@@ -134,7 +128,6 @@ export const EditorTab = props => {
|
|
|
134
128
|
onClick: ({ key, domEvent }) => {
|
|
135
129
|
switch (key) {
|
|
136
130
|
case 'configure':
|
|
137
|
-
console.log('click configure', domEvent);
|
|
138
131
|
setIsEditable(tab.id);
|
|
139
132
|
onConfigure === null || onConfigure === void 0 ? void 0 : onConfigure(tab.id);
|
|
140
133
|
break;
|
|
@@ -145,7 +138,7 @@ export const EditorTab = props => {
|
|
|
145
138
|
break;
|
|
146
139
|
}
|
|
147
140
|
},
|
|
148
|
-
}, placement: "bottomRight", trigger: ['click'] },
|
|
141
|
+
}, placement: "bottomRight", trigger: ['click'], destroyPopupOnHide: true },
|
|
149
142
|
React.createElement(Button, { icon: React.createElement(Icon, { type: "icon-ants-angle-left", overlayStyle: { fontSize: 12 } }), style: { transform: 'rotate(-90deg)' }, size: "small" }))) : closeable ? (React.createElement(Button, { icon: React.createElement(Icon, { type: "icon-ants-remove-slim", onClick: e => handleCloseTab(e, tab, idx), overlayStyle: { fontSize: 12 } }), size: "small" })) : null));
|
|
150
143
|
})
|
|
151
144
|
: null),
|
|
@@ -54,8 +54,15 @@ export const EditorTabStyled = styled.div `
|
|
|
54
54
|
max-width: 200px;
|
|
55
55
|
background-color: ${(_b = THEME.token) === null || _b === void 0 ? void 0 : _b.bw2};
|
|
56
56
|
|
|
57
|
+
& button {
|
|
58
|
+
display: none !important;
|
|
59
|
+
}
|
|
60
|
+
|
|
57
61
|
&:hover {
|
|
58
62
|
background-color: ${(_c = THEME.token) === null || _c === void 0 ? void 0 : _c.blue};
|
|
63
|
+
& button {
|
|
64
|
+
display: flex !important;
|
|
65
|
+
}
|
|
59
66
|
}
|
|
60
67
|
|
|
61
68
|
white-space: nowrap;
|
|
@@ -87,6 +94,9 @@ export const EditorTabStyled = styled.div `
|
|
|
87
94
|
transform: scaleX(1);
|
|
88
95
|
}
|
|
89
96
|
background-color: #fff;
|
|
97
|
+
& button {
|
|
98
|
+
display: flex !important;
|
|
99
|
+
}
|
|
90
100
|
}
|
|
91
101
|
}
|
|
92
102
|
|
package/es/constants/theme.js
CHANGED
|
@@ -177,9 +177,9 @@ THEME.components = {
|
|
|
177
177
|
titleFontSizeSM: 14,
|
|
178
178
|
horizontalMargin: '0px',
|
|
179
179
|
colorBorderSecondary: '#E5E5E5',
|
|
180
|
-
lineHeight: 1.
|
|
181
|
-
lineHeightLG: 1.
|
|
182
|
-
lineHeightSM: 1.
|
|
180
|
+
lineHeight: 1.143,
|
|
181
|
+
lineHeightLG: 1.143,
|
|
182
|
+
lineHeightSM: 1.143,
|
|
183
183
|
itemHoverColor: (_w = THEME.token) === null || _w === void 0 ? void 0 : _w.colorPrimary,
|
|
184
184
|
},
|
|
185
185
|
Collapse: {
|