@elice/material-exercise 1.221028.1 → 1.221109.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/cjs/components/shared/file-viewer/FileViewer.js +12 -6
- package/cjs/components/shared/file-viewer/FileViewerCsv.js +204 -11
- package/cjs/components/shared/xterm/locales/en.json.js +1 -1
- package/cjs/components/shared/xterm/locales/ko.json.js +1 -1
- package/es/components/shared/file-viewer/FileViewer.js +12 -6
- package/es/components/shared/file-viewer/FileViewerCsv.js +204 -11
- package/es/components/shared/xterm/locales/en.json.js +1 -1
- package/es/components/shared/xterm/locales/ko.json.js +1 -1
- package/package.json +4 -4
|
@@ -54,14 +54,20 @@ const FileViewer = ({
|
|
|
54
54
|
*/
|
|
55
55
|
|
|
56
56
|
const PreviewComponent = React__default["default"].useMemo(() => {
|
|
57
|
-
//
|
|
58
|
-
if (
|
|
59
|
-
return
|
|
60
|
-
} // Text file
|
|
57
|
+
// Binary file which shows as text
|
|
58
|
+
if (showInTextViewer) {
|
|
59
|
+
return AsyncFileViewerText;
|
|
60
|
+
} // Text file
|
|
61
61
|
|
|
62
62
|
|
|
63
|
-
if (
|
|
64
|
-
|
|
63
|
+
if (mimeType.startsWith('text/')) {
|
|
64
|
+
// csv
|
|
65
|
+
if (mimeType === 'text/csv') {
|
|
66
|
+
return AsyncFileViewerCsv;
|
|
67
|
+
} // other text file
|
|
68
|
+
else {
|
|
69
|
+
return AsyncFileViewerText;
|
|
70
|
+
}
|
|
65
71
|
} // Image file
|
|
66
72
|
|
|
67
73
|
|
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
var React = require('react');
|
|
4
|
-
var
|
|
4
|
+
var reactIntl = require('react-intl');
|
|
5
|
+
var blocks = require('@elice/blocks');
|
|
6
|
+
var designTokens = require('@elice/design-tokens');
|
|
7
|
+
var icons = require('@elice/icons');
|
|
5
8
|
var styled = require('styled-components');
|
|
6
9
|
var ExerciseFileShimmer = require('../exercise-shimmer/ExerciseFileShimmer.js');
|
|
7
10
|
require('../exercise-shimmer/ExerciseFileTabsShimmer.js');
|
|
@@ -14,33 +17,223 @@ function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'defau
|
|
|
14
17
|
var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
|
|
15
18
|
var styled__default = /*#__PURE__*/_interopDefaultLegacy(styled);
|
|
16
19
|
|
|
17
|
-
|
|
20
|
+
//
|
|
21
|
+
//
|
|
22
|
+
|
|
23
|
+
const ROW_PER_PAGE_LIST = [10, 25, 50]; //
|
|
24
|
+
//
|
|
25
|
+
//
|
|
26
|
+
|
|
27
|
+
const StyledViewer = styled__default["default"].div.withConfig({
|
|
18
28
|
componentId: "sc-pyv7uu-0"
|
|
19
|
-
})(["flex:1
|
|
29
|
+
})(["flex:1;display:flex;flex-direction:column;width:100%;height:100%;min-width:0;min-height:0;background-color:", ";"], designTokens.base.color.navy9);
|
|
30
|
+
const StyledViewerTableWrap = styled__default["default"].div.withConfig({
|
|
31
|
+
componentId: "sc-pyv7uu-1"
|
|
32
|
+
})(["flex:1;overflow:auto;"]);
|
|
33
|
+
const StyledViewerFooter = styled__default["default"].div.withConfig({
|
|
34
|
+
componentId: "sc-pyv7uu-2"
|
|
35
|
+
})(["flex:0 0 auto;display:flex;justify-content:space-between;align-items:center;padding:0.5rem;"]);
|
|
36
|
+
const StyledViewerFooterSelect = styled__default["default"].select.withConfig({
|
|
37
|
+
componentId: "sc-pyv7uu-3"
|
|
38
|
+
})(["width:3rem;border-radius:0.25rem;"]);
|
|
39
|
+
const StyledViewerTable = styled__default["default"].table.withConfig({
|
|
40
|
+
componentId: "sc-pyv7uu-4"
|
|
41
|
+
})(["border:1px solid ", ";border-collapse:collapse;color:", ";font-family:'Elice Digital Coding',monospace,fixed-width;th,td{border:1px solid ", ";padding:0.5rem;white-space:pre;&:nth-child(1){color:", ";}}tbody{tr:nth-child(odd){background:", ";}tr:hover{background:", ";}}"], designTokens.base.color.navy5, designTokens.base.color.white, designTokens.base.color.navy5, designTokens.base.color.gray5, designTokens.base.color.navy8, designTokens.base.color.navy6);
|
|
20
42
|
|
|
21
43
|
const FileViewerCsv = ({
|
|
22
44
|
fileurl
|
|
23
45
|
}) => {
|
|
24
|
-
const [
|
|
46
|
+
const [csvHeader, setCsvHeader] = React__default["default"].useState(null);
|
|
47
|
+
const [csvRecords, setCsvRecords] = React__default["default"].useState([]);
|
|
48
|
+
const [csvStatus, setCsvStatus] = React__default["default"].useState('idle');
|
|
49
|
+
const [page, setPage] = React__default["default"].useState(1);
|
|
50
|
+
const [perPage, setPerPage] = React__default["default"].useState(ROW_PER_PAGE_LIST[0]);
|
|
51
|
+
const maxPage = Math.ceil(csvRecords.length / perPage);
|
|
52
|
+
const [isUsingHeader, setUsingHeader] = React__default["default"].useState(true);
|
|
53
|
+
const tableWrapElRef = React__default["default"].useRef(null); //
|
|
54
|
+
// fetch csv file and parse it
|
|
55
|
+
//
|
|
56
|
+
|
|
25
57
|
React__default["default"].useEffect(() => {
|
|
26
58
|
if (!fileurl) {
|
|
59
|
+
setCsvRecords([]);
|
|
27
60
|
return;
|
|
28
61
|
}
|
|
29
62
|
|
|
30
|
-
|
|
63
|
+
const abortCtrl = new AbortController();
|
|
64
|
+
setCsvStatus('pending');
|
|
65
|
+
fetch(fileurl, {
|
|
66
|
+
signal: abortCtrl.signal
|
|
67
|
+
}).then(res => res.text()).then(data => data.split('\n').map(row => row.split(','))).then(setCsvRecords).then(() => setCsvStatus('resolved')).catch(err => {
|
|
68
|
+
if (err.name === 'AbortError') {
|
|
69
|
+
return;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
setCsvRecords([]);
|
|
73
|
+
setCsvStatus('rejected');
|
|
74
|
+
});
|
|
75
|
+
return () => {
|
|
76
|
+
abortCtrl.abort();
|
|
77
|
+
};
|
|
31
78
|
}, [fileurl]); //
|
|
79
|
+
// Set CSV header.
|
|
32
80
|
//
|
|
81
|
+
|
|
82
|
+
React__default["default"].useEffect(() => setCsvHeader(isUsingHeader ? csvRecords[0] : null), [csvRecords, isUsingHeader]); //
|
|
83
|
+
// Set CSV header.
|
|
33
84
|
//
|
|
34
85
|
|
|
35
|
-
|
|
86
|
+
React__default["default"].useEffect(() => {
|
|
87
|
+
var _a;
|
|
88
|
+
|
|
89
|
+
return (_a = tableWrapElRef.current) === null || _a === void 0 ? void 0 : _a.scrollTo(0, 0);
|
|
90
|
+
}, [page]);
|
|
91
|
+
/**
|
|
92
|
+
*
|
|
93
|
+
*/
|
|
94
|
+
|
|
95
|
+
const renderViewerTableThead = () => {
|
|
96
|
+
if (!csvHeader) {
|
|
97
|
+
return null;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
const colunms = ['', ...csvHeader];
|
|
101
|
+
return React__default["default"].createElement("thead", null, React__default["default"].createElement("tr", null, colunms.map((col, colIdx) => React__default["default"].createElement("th", {
|
|
102
|
+
key: colIdx
|
|
103
|
+
}, col))));
|
|
104
|
+
};
|
|
105
|
+
/**
|
|
106
|
+
*
|
|
107
|
+
*/
|
|
108
|
+
|
|
109
|
+
|
|
110
|
+
const renderViewerTableTbody = () => {
|
|
111
|
+
const start = (page - 1) * perPage;
|
|
112
|
+
const end = page * perPage;
|
|
113
|
+
const records = csvRecords.slice(isUsingHeader ? 1 : 0).slice(start, end);
|
|
114
|
+
return React__default["default"].createElement("tbody", null, records.map((row, rowIdx) => {
|
|
115
|
+
const curRecordNo = start + rowIdx + 1;
|
|
116
|
+
const curRow = [curRecordNo, ...row];
|
|
117
|
+
return React__default["default"].createElement("tr", {
|
|
118
|
+
key: curRecordNo
|
|
119
|
+
}, curRow.map((col, colIdx) => React__default["default"].createElement("td", {
|
|
120
|
+
key: colIdx,
|
|
121
|
+
style: {
|
|
122
|
+
// test whether the column is number, and align right
|
|
123
|
+
textAlign: // eslint-disable-next-line no-self-compare
|
|
124
|
+
+col === +col ? 'right' : 'left'
|
|
125
|
+
}
|
|
126
|
+
}, col)));
|
|
127
|
+
}));
|
|
128
|
+
};
|
|
129
|
+
/**
|
|
130
|
+
*
|
|
131
|
+
*/
|
|
132
|
+
|
|
133
|
+
|
|
134
|
+
const renderViewerTable = () => {
|
|
135
|
+
return React__default["default"].createElement(StyledViewerTableWrap, {
|
|
136
|
+
ref: tableWrapElRef
|
|
137
|
+
}, React__default["default"].createElement(StyledViewerTable, null, renderViewerTableThead(), renderViewerTableTbody()));
|
|
138
|
+
};
|
|
139
|
+
/**
|
|
140
|
+
*
|
|
141
|
+
*/
|
|
142
|
+
|
|
143
|
+
|
|
144
|
+
const renderViewerFooterPagination = () => {
|
|
145
|
+
return React__default["default"].createElement(blocks.Flex, {
|
|
146
|
+
align: "center"
|
|
147
|
+
}, React__default["default"].createElement(blocks.Text, {
|
|
148
|
+
role: "gray1",
|
|
149
|
+
size: "small"
|
|
150
|
+
}, csvRecords.length, " records"), React__default["default"].createElement(blocks.Hr, {
|
|
151
|
+
vertical: true,
|
|
152
|
+
color: designTokens.base.color.navy5
|
|
153
|
+
}), React__default["default"].createElement(blocks.Flex, {
|
|
154
|
+
align: "center"
|
|
155
|
+
}, React__default["default"].createElement(blocks.IconButton, {
|
|
156
|
+
icon: icons.eilArrowLeftwardsBasic,
|
|
157
|
+
role: "gray5",
|
|
158
|
+
size: "nano",
|
|
159
|
+
disabled: page <= 1,
|
|
160
|
+
onClick: () => setPage(prevPage => prevPage - 1)
|
|
161
|
+
}), React__default["default"].createElement(blocks.Hspace, {
|
|
162
|
+
width: 0.5
|
|
163
|
+
}), React__default["default"].createElement(blocks.Text, {
|
|
164
|
+
role: "gray1",
|
|
165
|
+
size: "small"
|
|
166
|
+
}, page, " / ", maxPage), React__default["default"].createElement(blocks.Hspace, {
|
|
167
|
+
width: 0.5
|
|
168
|
+
}), React__default["default"].createElement(blocks.IconButton, {
|
|
169
|
+
icon: icons.eilArrowRightwardsBasic,
|
|
170
|
+
role: "gray5",
|
|
171
|
+
size: "nano",
|
|
172
|
+
disabled: page >= maxPage,
|
|
173
|
+
onClick: () => setPage(prevPage => prevPage + 1)
|
|
174
|
+
})));
|
|
175
|
+
};
|
|
176
|
+
/**
|
|
177
|
+
*
|
|
178
|
+
*/
|
|
179
|
+
|
|
180
|
+
|
|
181
|
+
const renderViewerFooterSettings = () => {
|
|
182
|
+
return React__default["default"].createElement(blocks.Flex, {
|
|
183
|
+
align: "center"
|
|
184
|
+
}, React__default["default"].createElement(blocks.Flex, {
|
|
185
|
+
align: "center"
|
|
186
|
+
}, React__default["default"].createElement(blocks.Text, {
|
|
187
|
+
role: "gray1",
|
|
188
|
+
size: "small"
|
|
189
|
+
}, React__default["default"].createElement(reactIntl.FormattedMessage, {
|
|
190
|
+
id: "\uD5E4\uB354 \uC0AC\uC6A9"
|
|
191
|
+
})), React__default["default"].createElement(blocks.Hspace, {
|
|
192
|
+
width: 0.5
|
|
193
|
+
}), React__default["default"].createElement(blocks.AntSwitch, {
|
|
194
|
+
size: "small",
|
|
195
|
+
checked: isUsingHeader,
|
|
196
|
+
onChange: setUsingHeader
|
|
197
|
+
})), React__default["default"].createElement(blocks.Hr, {
|
|
198
|
+
vertical: true,
|
|
199
|
+
color: designTokens.base.color.navy5
|
|
200
|
+
}), React__default["default"].createElement(blocks.Flex, {
|
|
201
|
+
align: "center"
|
|
202
|
+
}, React__default["default"].createElement(blocks.Text, {
|
|
203
|
+
role: "gray1",
|
|
204
|
+
size: "small"
|
|
205
|
+
}, React__default["default"].createElement(reactIntl.FormattedMessage, {
|
|
206
|
+
id: "\uD398\uC774\uC9C0\uB2F9 \uD589:"
|
|
207
|
+
})), React__default["default"].createElement(blocks.Hspace, {
|
|
208
|
+
width: 0.5
|
|
209
|
+
}), React__default["default"].createElement(StyledViewerFooterSelect, {
|
|
210
|
+
value: perPage,
|
|
211
|
+
onChange: e => setPerPage(Number(e.target.value))
|
|
212
|
+
}, ROW_PER_PAGE_LIST.map(perPage => React__default["default"].createElement("option", {
|
|
213
|
+
value: perPage
|
|
214
|
+
}, perPage)))));
|
|
215
|
+
};
|
|
216
|
+
/**
|
|
217
|
+
*
|
|
218
|
+
*/
|
|
219
|
+
|
|
220
|
+
|
|
221
|
+
const renderViewerFooter = () => {
|
|
222
|
+
return React__default["default"].createElement(StyledViewerFooter, null, renderViewerFooterPagination(), renderViewerFooterSettings());
|
|
223
|
+
}; //
|
|
224
|
+
//
|
|
225
|
+
//
|
|
226
|
+
|
|
227
|
+
|
|
228
|
+
if (csvStatus === 'idle' || csvStatus === 'pending') {
|
|
36
229
|
return React__default["default"].createElement(ExerciseFileShimmer, null);
|
|
37
230
|
}
|
|
38
231
|
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
232
|
+
if (csvStatus === 'rejected') {
|
|
233
|
+
return React__default["default"].createElement("div", null, "error");
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
return React__default["default"].createElement(StyledViewer, null, renderViewerTable(), renderViewerFooter());
|
|
44
237
|
};
|
|
45
238
|
|
|
46
239
|
module.exports = FileViewerCsv;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var phrasesEn = {"xterm.systemMessage.runAfter":"\n/* Code running is complete! */
|
|
3
|
+
var phrasesEn = {"xterm.systemMessage.runAfter":"\n/* Code running is complete! */","xterm.systemMessage.runBefore":"/* Code has not run yet. */","xterm.systemMessage.running":"/* Code is running... */"};
|
|
4
4
|
|
|
5
5
|
module.exports = phrasesEn;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var phrasesKo = {"xterm.systemMessage.runAfter":"\n/* 코드 실행이 완료되었습니다! */
|
|
3
|
+
var phrasesKo = {"xterm.systemMessage.runAfter":"\n/* 코드 실행이 완료되었습니다! */","xterm.systemMessage.runBefore":"/* 코드가 아직 실행되지 않았습니다. */","xterm.systemMessage.running":"/* 코드가 실행되는 중입니다... */"};
|
|
4
4
|
|
|
5
5
|
module.exports = phrasesKo;
|
|
@@ -43,14 +43,20 @@ const FileViewer = ({
|
|
|
43
43
|
*/
|
|
44
44
|
|
|
45
45
|
const PreviewComponent = React.useMemo(() => {
|
|
46
|
-
//
|
|
47
|
-
if (
|
|
48
|
-
return
|
|
49
|
-
} // Text file
|
|
46
|
+
// Binary file which shows as text
|
|
47
|
+
if (showInTextViewer) {
|
|
48
|
+
return AsyncFileViewerText;
|
|
49
|
+
} // Text file
|
|
50
50
|
|
|
51
51
|
|
|
52
|
-
if (
|
|
53
|
-
|
|
52
|
+
if (mimeType.startsWith('text/')) {
|
|
53
|
+
// csv
|
|
54
|
+
if (mimeType === 'text/csv') {
|
|
55
|
+
return AsyncFileViewerCsv;
|
|
56
|
+
} // other text file
|
|
57
|
+
else {
|
|
58
|
+
return AsyncFileViewerText;
|
|
59
|
+
}
|
|
54
60
|
} // Image file
|
|
55
61
|
|
|
56
62
|
|
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import {
|
|
2
|
+
import { FormattedMessage } from 'react-intl';
|
|
3
|
+
import { Flex, Text, Hr, IconButton, Hspace, AntSwitch } from '@elice/blocks';
|
|
4
|
+
import { base } from '@elice/design-tokens';
|
|
5
|
+
import { eilArrowLeftwardsBasic, eilArrowRightwardsBasic } from '@elice/icons';
|
|
3
6
|
import styled from 'styled-components';
|
|
4
7
|
import ExerciseFileShimmer from '../exercise-shimmer/ExerciseFileShimmer.js';
|
|
5
8
|
import '../exercise-shimmer/ExerciseFileTabsShimmer.js';
|
|
@@ -7,33 +10,223 @@ import '../exercise-shimmer/ExerciseFileTabShimmer.js';
|
|
|
7
10
|
import '../exercise-shimmer/ExerciseFileTreeListShimmer.js';
|
|
8
11
|
import '../exercise-shimmer/ExerciseFileTreeListItemShimmer.js';
|
|
9
12
|
|
|
10
|
-
|
|
13
|
+
//
|
|
14
|
+
//
|
|
15
|
+
|
|
16
|
+
const ROW_PER_PAGE_LIST = [10, 25, 50]; //
|
|
17
|
+
//
|
|
18
|
+
//
|
|
19
|
+
|
|
20
|
+
const StyledViewer = styled.div.withConfig({
|
|
11
21
|
componentId: "sc-pyv7uu-0"
|
|
12
|
-
})(["flex:1
|
|
22
|
+
})(["flex:1;display:flex;flex-direction:column;width:100%;height:100%;min-width:0;min-height:0;background-color:", ";"], base.color.navy9);
|
|
23
|
+
const StyledViewerTableWrap = styled.div.withConfig({
|
|
24
|
+
componentId: "sc-pyv7uu-1"
|
|
25
|
+
})(["flex:1;overflow:auto;"]);
|
|
26
|
+
const StyledViewerFooter = styled.div.withConfig({
|
|
27
|
+
componentId: "sc-pyv7uu-2"
|
|
28
|
+
})(["flex:0 0 auto;display:flex;justify-content:space-between;align-items:center;padding:0.5rem;"]);
|
|
29
|
+
const StyledViewerFooterSelect = styled.select.withConfig({
|
|
30
|
+
componentId: "sc-pyv7uu-3"
|
|
31
|
+
})(["width:3rem;border-radius:0.25rem;"]);
|
|
32
|
+
const StyledViewerTable = styled.table.withConfig({
|
|
33
|
+
componentId: "sc-pyv7uu-4"
|
|
34
|
+
})(["border:1px solid ", ";border-collapse:collapse;color:", ";font-family:'Elice Digital Coding',monospace,fixed-width;th,td{border:1px solid ", ";padding:0.5rem;white-space:pre;&:nth-child(1){color:", ";}}tbody{tr:nth-child(odd){background:", ";}tr:hover{background:", ";}}"], base.color.navy5, base.color.white, base.color.navy5, base.color.gray5, base.color.navy8, base.color.navy6);
|
|
13
35
|
|
|
14
36
|
const FileViewerCsv = ({
|
|
15
37
|
fileurl
|
|
16
38
|
}) => {
|
|
17
|
-
const [
|
|
39
|
+
const [csvHeader, setCsvHeader] = React.useState(null);
|
|
40
|
+
const [csvRecords, setCsvRecords] = React.useState([]);
|
|
41
|
+
const [csvStatus, setCsvStatus] = React.useState('idle');
|
|
42
|
+
const [page, setPage] = React.useState(1);
|
|
43
|
+
const [perPage, setPerPage] = React.useState(ROW_PER_PAGE_LIST[0]);
|
|
44
|
+
const maxPage = Math.ceil(csvRecords.length / perPage);
|
|
45
|
+
const [isUsingHeader, setUsingHeader] = React.useState(true);
|
|
46
|
+
const tableWrapElRef = React.useRef(null); //
|
|
47
|
+
// fetch csv file and parse it
|
|
48
|
+
//
|
|
49
|
+
|
|
18
50
|
React.useEffect(() => {
|
|
19
51
|
if (!fileurl) {
|
|
52
|
+
setCsvRecords([]);
|
|
20
53
|
return;
|
|
21
54
|
}
|
|
22
55
|
|
|
23
|
-
|
|
56
|
+
const abortCtrl = new AbortController();
|
|
57
|
+
setCsvStatus('pending');
|
|
58
|
+
fetch(fileurl, {
|
|
59
|
+
signal: abortCtrl.signal
|
|
60
|
+
}).then(res => res.text()).then(data => data.split('\n').map(row => row.split(','))).then(setCsvRecords).then(() => setCsvStatus('resolved')).catch(err => {
|
|
61
|
+
if (err.name === 'AbortError') {
|
|
62
|
+
return;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
setCsvRecords([]);
|
|
66
|
+
setCsvStatus('rejected');
|
|
67
|
+
});
|
|
68
|
+
return () => {
|
|
69
|
+
abortCtrl.abort();
|
|
70
|
+
};
|
|
24
71
|
}, [fileurl]); //
|
|
72
|
+
// Set CSV header.
|
|
25
73
|
//
|
|
74
|
+
|
|
75
|
+
React.useEffect(() => setCsvHeader(isUsingHeader ? csvRecords[0] : null), [csvRecords, isUsingHeader]); //
|
|
76
|
+
// Set CSV header.
|
|
26
77
|
//
|
|
27
78
|
|
|
28
|
-
|
|
79
|
+
React.useEffect(() => {
|
|
80
|
+
var _a;
|
|
81
|
+
|
|
82
|
+
return (_a = tableWrapElRef.current) === null || _a === void 0 ? void 0 : _a.scrollTo(0, 0);
|
|
83
|
+
}, [page]);
|
|
84
|
+
/**
|
|
85
|
+
*
|
|
86
|
+
*/
|
|
87
|
+
|
|
88
|
+
const renderViewerTableThead = () => {
|
|
89
|
+
if (!csvHeader) {
|
|
90
|
+
return null;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
const colunms = ['', ...csvHeader];
|
|
94
|
+
return React.createElement("thead", null, React.createElement("tr", null, colunms.map((col, colIdx) => React.createElement("th", {
|
|
95
|
+
key: colIdx
|
|
96
|
+
}, col))));
|
|
97
|
+
};
|
|
98
|
+
/**
|
|
99
|
+
*
|
|
100
|
+
*/
|
|
101
|
+
|
|
102
|
+
|
|
103
|
+
const renderViewerTableTbody = () => {
|
|
104
|
+
const start = (page - 1) * perPage;
|
|
105
|
+
const end = page * perPage;
|
|
106
|
+
const records = csvRecords.slice(isUsingHeader ? 1 : 0).slice(start, end);
|
|
107
|
+
return React.createElement("tbody", null, records.map((row, rowIdx) => {
|
|
108
|
+
const curRecordNo = start + rowIdx + 1;
|
|
109
|
+
const curRow = [curRecordNo, ...row];
|
|
110
|
+
return React.createElement("tr", {
|
|
111
|
+
key: curRecordNo
|
|
112
|
+
}, curRow.map((col, colIdx) => React.createElement("td", {
|
|
113
|
+
key: colIdx,
|
|
114
|
+
style: {
|
|
115
|
+
// test whether the column is number, and align right
|
|
116
|
+
textAlign: // eslint-disable-next-line no-self-compare
|
|
117
|
+
+col === +col ? 'right' : 'left'
|
|
118
|
+
}
|
|
119
|
+
}, col)));
|
|
120
|
+
}));
|
|
121
|
+
};
|
|
122
|
+
/**
|
|
123
|
+
*
|
|
124
|
+
*/
|
|
125
|
+
|
|
126
|
+
|
|
127
|
+
const renderViewerTable = () => {
|
|
128
|
+
return React.createElement(StyledViewerTableWrap, {
|
|
129
|
+
ref: tableWrapElRef
|
|
130
|
+
}, React.createElement(StyledViewerTable, null, renderViewerTableThead(), renderViewerTableTbody()));
|
|
131
|
+
};
|
|
132
|
+
/**
|
|
133
|
+
*
|
|
134
|
+
*/
|
|
135
|
+
|
|
136
|
+
|
|
137
|
+
const renderViewerFooterPagination = () => {
|
|
138
|
+
return React.createElement(Flex, {
|
|
139
|
+
align: "center"
|
|
140
|
+
}, React.createElement(Text, {
|
|
141
|
+
role: "gray1",
|
|
142
|
+
size: "small"
|
|
143
|
+
}, csvRecords.length, " records"), React.createElement(Hr, {
|
|
144
|
+
vertical: true,
|
|
145
|
+
color: base.color.navy5
|
|
146
|
+
}), React.createElement(Flex, {
|
|
147
|
+
align: "center"
|
|
148
|
+
}, React.createElement(IconButton, {
|
|
149
|
+
icon: eilArrowLeftwardsBasic,
|
|
150
|
+
role: "gray5",
|
|
151
|
+
size: "nano",
|
|
152
|
+
disabled: page <= 1,
|
|
153
|
+
onClick: () => setPage(prevPage => prevPage - 1)
|
|
154
|
+
}), React.createElement(Hspace, {
|
|
155
|
+
width: 0.5
|
|
156
|
+
}), React.createElement(Text, {
|
|
157
|
+
role: "gray1",
|
|
158
|
+
size: "small"
|
|
159
|
+
}, page, " / ", maxPage), React.createElement(Hspace, {
|
|
160
|
+
width: 0.5
|
|
161
|
+
}), React.createElement(IconButton, {
|
|
162
|
+
icon: eilArrowRightwardsBasic,
|
|
163
|
+
role: "gray5",
|
|
164
|
+
size: "nano",
|
|
165
|
+
disabled: page >= maxPage,
|
|
166
|
+
onClick: () => setPage(prevPage => prevPage + 1)
|
|
167
|
+
})));
|
|
168
|
+
};
|
|
169
|
+
/**
|
|
170
|
+
*
|
|
171
|
+
*/
|
|
172
|
+
|
|
173
|
+
|
|
174
|
+
const renderViewerFooterSettings = () => {
|
|
175
|
+
return React.createElement(Flex, {
|
|
176
|
+
align: "center"
|
|
177
|
+
}, React.createElement(Flex, {
|
|
178
|
+
align: "center"
|
|
179
|
+
}, React.createElement(Text, {
|
|
180
|
+
role: "gray1",
|
|
181
|
+
size: "small"
|
|
182
|
+
}, React.createElement(FormattedMessage, {
|
|
183
|
+
id: "\uD5E4\uB354 \uC0AC\uC6A9"
|
|
184
|
+
})), React.createElement(Hspace, {
|
|
185
|
+
width: 0.5
|
|
186
|
+
}), React.createElement(AntSwitch, {
|
|
187
|
+
size: "small",
|
|
188
|
+
checked: isUsingHeader,
|
|
189
|
+
onChange: setUsingHeader
|
|
190
|
+
})), React.createElement(Hr, {
|
|
191
|
+
vertical: true,
|
|
192
|
+
color: base.color.navy5
|
|
193
|
+
}), React.createElement(Flex, {
|
|
194
|
+
align: "center"
|
|
195
|
+
}, React.createElement(Text, {
|
|
196
|
+
role: "gray1",
|
|
197
|
+
size: "small"
|
|
198
|
+
}, React.createElement(FormattedMessage, {
|
|
199
|
+
id: "\uD398\uC774\uC9C0\uB2F9 \uD589:"
|
|
200
|
+
})), React.createElement(Hspace, {
|
|
201
|
+
width: 0.5
|
|
202
|
+
}), React.createElement(StyledViewerFooterSelect, {
|
|
203
|
+
value: perPage,
|
|
204
|
+
onChange: e => setPerPage(Number(e.target.value))
|
|
205
|
+
}, ROW_PER_PAGE_LIST.map(perPage => React.createElement("option", {
|
|
206
|
+
value: perPage
|
|
207
|
+
}, perPage)))));
|
|
208
|
+
};
|
|
209
|
+
/**
|
|
210
|
+
*
|
|
211
|
+
*/
|
|
212
|
+
|
|
213
|
+
|
|
214
|
+
const renderViewerFooter = () => {
|
|
215
|
+
return React.createElement(StyledViewerFooter, null, renderViewerFooterPagination(), renderViewerFooterSettings());
|
|
216
|
+
}; //
|
|
217
|
+
//
|
|
218
|
+
//
|
|
219
|
+
|
|
220
|
+
|
|
221
|
+
if (csvStatus === 'idle' || csvStatus === 'pending') {
|
|
29
222
|
return React.createElement(ExerciseFileShimmer, null);
|
|
30
223
|
}
|
|
31
224
|
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
225
|
+
if (csvStatus === 'rejected') {
|
|
226
|
+
return React.createElement("div", null, "error");
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
return React.createElement(StyledViewer, null, renderViewerTable(), renderViewerFooter());
|
|
37
230
|
};
|
|
38
231
|
|
|
39
232
|
export { FileViewerCsv as default };
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
var phrasesEn = {"xterm.systemMessage.runAfter":"\n/* Code running is complete! */
|
|
1
|
+
var phrasesEn = {"xterm.systemMessage.runAfter":"\n/* Code running is complete! */","xterm.systemMessage.runBefore":"/* Code has not run yet. */","xterm.systemMessage.running":"/* Code is running... */"};
|
|
2
2
|
|
|
3
3
|
export { phrasesEn as default };
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
var phrasesKo = {"xterm.systemMessage.runAfter":"\n/* 코드 실행이 완료되었습니다! */
|
|
1
|
+
var phrasesKo = {"xterm.systemMessage.runAfter":"\n/* 코드 실행이 완료되었습니다! */","xterm.systemMessage.runBefore":"/* 코드가 아직 실행되지 않았습니다. */","xterm.systemMessage.running":"/* 코드가 실행되는 중입니다... */"};
|
|
2
2
|
|
|
3
3
|
export { phrasesKo as default };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@elice/material-exercise",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.221109.0",
|
|
4
4
|
"description": "User view and editing components of Elice material exercise",
|
|
5
5
|
"repository": "https://git.elicer.io/elice/frontend/library/elice-material",
|
|
6
6
|
"license": "UNLICENSED",
|
|
@@ -116,8 +116,8 @@
|
|
|
116
116
|
"@elice/design-tokens": "^1.220803.0",
|
|
117
117
|
"@elice/icons": "^1.220803.0",
|
|
118
118
|
"@elice/markdown": "^1.220803.0",
|
|
119
|
-
"@elice/material-shared-types": "1.
|
|
120
|
-
"@elice/material-shared-utils": "1.
|
|
119
|
+
"@elice/material-shared-types": "1.221109.0",
|
|
120
|
+
"@elice/material-shared-utils": "1.221109.0",
|
|
121
121
|
"@elice/types": "^1.221027.0",
|
|
122
122
|
"@elice/websocket": "^1.220803.0",
|
|
123
123
|
"@types/classnames": "^2.3.1",
|
|
@@ -139,5 +139,5 @@
|
|
|
139
139
|
"recoil": "^0.6.1",
|
|
140
140
|
"styled-components": "^5.2.0"
|
|
141
141
|
},
|
|
142
|
-
"gitHead": "
|
|
142
|
+
"gitHead": "bd17b325b12a0b7b2b1e663180666dc45bb90b27"
|
|
143
143
|
}
|