@daoyi/nmtl-ui 2.0.1-beta.45 → 2.0.1-beta.47
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/lib/components/Autocomplete-5439ff22.js +333 -1
- package/lib/components/Autocomplete.js +12 -1
- package/lib/components/Avatar.js +51 -1
- package/lib/components/BackTop.js +82 -1
- package/lib/components/BarChart.js +132 -1
- package/lib/components/Breadcrumbs.js +124 -1
- package/lib/components/Button-63c7e9f3.js +91 -1
- package/lib/components/Button.js +8 -1
- package/lib/components/Carousel.js +61 -1
- package/lib/components/Checkbox.js +37 -1
- package/lib/components/CollapseContent.js +181 -1
- package/lib/components/ContactModal-a59bc808.js +924 -0
- package/lib/components/ContactModal.js +17 -1
- package/lib/components/Drawer-af3ed21a.js +157 -1
- package/lib/components/Drawer.js +13 -1
- package/lib/components/Dropdown.js +135 -1
- package/lib/components/Empty-70f040a9.js +44 -1
- package/lib/components/Empty.js +7 -1
- package/lib/components/ExportButton.js +114 -1
- package/lib/components/ExtraTools-f10a66a8.js +818 -1
- package/lib/components/ExtraTools.js +11 -1
- package/lib/components/Filter.js +90 -1
- package/lib/components/Footer.js +266 -1
- package/lib/components/ForwardLink.js +106 -1
- package/lib/components/Header.js +186 -1
- package/lib/components/Image.js +58 -1
- package/lib/components/Input.js +79 -1
- package/lib/components/InputMethod.js +23106 -1
- package/lib/components/KeywordSearch-224f84c1.js +138 -1
- package/lib/components/KeywordSearch.js +14 -1
- package/lib/components/KeywordTicker.js +182 -1
- package/lib/components/Keywords.js +292 -1
- package/lib/components/Loading.js +30 -1
- package/lib/components/MUITheme.js +255 -1
- package/lib/components/Modal-a7591b98.js +107 -1
- package/lib/components/Modal.js +11 -1
- package/lib/components/MoreButton-f15ca38e.js +109 -1
- package/lib/components/MoreButton.js +8 -1
- package/lib/components/Radio.js +81 -1
- package/lib/components/SNA.js +324 -1
- package/lib/components/Select-98a8e973.js +114 -1
- package/lib/components/Select.js +10 -1
- package/lib/components/Spin-690a3597.js +74 -1
- package/lib/components/Spin.js +8 -1
- package/lib/components/Table.js +51 -1
- package/lib/components/Tooltip-b7eb966d.js +69 -1
- package/lib/components/Tooltip.js +9 -1
- package/lib/components/_rollupPluginBabelHelpers-fde6d1c6.js +491 -1
- package/lib/components/dataExport-f418e6fe.js +56 -1
- package/lib/components/globalConfig.js +186 -1
- package/lib/components/vendor-851c6356.js +41893 -16
- package/lib/index.d.ts +1 -3
- package/lib/index.js +1 -3
- package/lib/utils/_rollupPluginBabelHelpers-a6e0e6e3.js +139 -1
- package/lib/utils/arrayMerge.js +100 -1
- package/lib/utils/chunkArray.js +15 -1
- package/lib/utils/convert2HtmlEntities.js +42 -1
- package/lib/utils/domToImage.js +32 -1
- package/lib/utils/downloadGephi.js +106 -1
- package/lib/utils/exportXlsx.js +184 -1
- package/lib/utils/historyAppendSearch.js +23 -1
- package/lib/utils/isDevelopMode.js +5 -1
- package/lib/utils/parseYMD.js +36 -1
- package/lib/utils/removeDuplicateItem.js +11 -1
- package/lib/utils/sendEmail.js +39 -1
- package/lib/utils/snaDefine-6a2bcd94.js +5 -1
- package/lib/utils/snaDefine.js +1 -1
- package/lib/utils/snaPreProcess.js +84 -1
- package/lib/utils/vendor-3ec75cc9.js +1289 -1
- package/package.json +1 -1
- package/lib/components/ContactModal-d7e2f8bb.js +0 -1
- package/lib/components/globalConfig-40069b54.js +0 -1
package/lib/components/SNA.js
CHANGED
|
@@ -1 +1,324 @@
|
|
|
1
|
-
import
|
|
1
|
+
import React__default, { useMemo, useEffect } from 'react';
|
|
2
|
+
import PropTypes from 'prop-types';
|
|
3
|
+
import { e as default_1, s as styleInject, c as classNames, o as ordinal, g as category10, h as simulation, l as link, m as manyBody, i as center, j as collide, x, y, r as radial, k as d3Select, z as zoom, n as drag, p as event } from './vendor-851c6356.js';
|
|
4
|
+
import { E as ExtraTools } from './ExtraTools-f10a66a8.js';
|
|
5
|
+
import { Tooltip, IconButton } from '@material-ui/core';
|
|
6
|
+
import 'react-is';
|
|
7
|
+
import '@material-ui/styles';
|
|
8
|
+
import 'react-dom';
|
|
9
|
+
import './_rollupPluginBabelHelpers-fde6d1c6.js';
|
|
10
|
+
import './Tooltip-b7eb966d.js';
|
|
11
|
+
import './dataExport-f418e6fe.js';
|
|
12
|
+
|
|
13
|
+
const ResetBtn = _ref => {
|
|
14
|
+
let {
|
|
15
|
+
renderSNA
|
|
16
|
+
} = _ref;
|
|
17
|
+
return /*#__PURE__*/React__default.createElement("div", {
|
|
18
|
+
id: "resetBtn"
|
|
19
|
+
}, /*#__PURE__*/React__default.createElement(Tooltip, {
|
|
20
|
+
title: "\u56DE\u5230\u539F\u4F86\u4F4D\u7F6E\u8207\u5927\u5C0F"
|
|
21
|
+
}, /*#__PURE__*/React__default.createElement(IconButton, {
|
|
22
|
+
onClick: () => renderSNA()
|
|
23
|
+
}, /*#__PURE__*/React__default.createElement(default_1, null))));
|
|
24
|
+
};
|
|
25
|
+
ResetBtn.propTypes = {
|
|
26
|
+
renderSNA: PropTypes.func.isRequired
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
var css_248z = ".SNA {\n overflow: hidden;\n object-fit: contain;\n position: relative;\n font-size: 0.75rem;\n width: 100%; }\n .SNA--smallSize .node {\n padding-top: 8px;\n font-size: 0.75rem;\n width: 3rem;\n height: 3rem;\n overflow: hidden;\n white-space: pre-wrap;\n text-overflow: ellipsis;\n display: -webkit-box;\n -webkit-line-clamp: 2;\n -webkit-box-orient: vertical; }\n .SNA .node {\n background-color: #4a4e69;\n border-radius: 50%;\n color: #fff;\n font-size: 20px;\n font-weight: 500;\n height: 54px;\n width: 54px;\n padding-top: 15px;\n position: absolute;\n text-align: center;\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n cursor: grab; }\n .SNA .links line {\n stroke: #c7bfb4;\n stroke-width: 2; }\n .SNA .mainNode {\n fill: #4e3a16; }\n .SNA .person {\n fill: #867b3a; }\n .SNA .publication {\n fill: #825c0d; }\n .SNA .article {\n fill: #afafaf; }\n .SNA .keyword {\n fill: #fcfae8; }\n .SNA .org {\n fill: #000000; }\n .SNA #resetBtn {\n float: right; }\n .SNA #network-graph svg {\n width: 100%;\n height: 100%; }\n\n@media only screen and (max-width: 484px) {\n .SNA {\n margin-left: 0px; }\n .SNA .node {\n background-color: #4a4e69;\n border-radius: 50%;\n color: #fff;\n font-size: 1px;\n font-weight: 500;\n height: 44px;\n width: 44px;\n padding-top: 12px;\n position: absolute;\n text-align: center;\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n cursor: grab; } }\n\n@media only screen and (max-width: 484px) {\n .SNA {\n margin-left: 0px; } }\n";
|
|
30
|
+
styleInject(css_248z);
|
|
31
|
+
|
|
32
|
+
/* eslint-disable indent */
|
|
33
|
+
var SNA = function SNA(props) {
|
|
34
|
+
// common
|
|
35
|
+
var className = props.className,
|
|
36
|
+
intl = props.intl,
|
|
37
|
+
exclude = props.exclude,
|
|
38
|
+
distance = props.distance,
|
|
39
|
+
SNAData = props.SNAData,
|
|
40
|
+
handleClickNodeGoto = props.handleClickNodeGoto,
|
|
41
|
+
DownloadExcel = props.DownloadExcel;
|
|
42
|
+
// styles
|
|
43
|
+
var width = props.width,
|
|
44
|
+
height = props.height,
|
|
45
|
+
fontColor = props.fontColor,
|
|
46
|
+
backgroundColor = props.backgroundColor,
|
|
47
|
+
iconColor = props.iconColor;
|
|
48
|
+
var g;
|
|
49
|
+
if (!SNAData || SNAData.nodes.length === 0) {
|
|
50
|
+
return /*#__PURE__*/React__default.createElement("div", {
|
|
51
|
+
className: "noData"
|
|
52
|
+
}, intl ? intl.formatMessage({
|
|
53
|
+
id: 'common.noData'
|
|
54
|
+
}) : '暫無資料');
|
|
55
|
+
}
|
|
56
|
+
var contentWidth = useMemo(function () {
|
|
57
|
+
return screen.width > 1050 ? width : screen.width - 80;
|
|
58
|
+
}, [screen.width]);
|
|
59
|
+
var contentHeight = useMemo(function () {
|
|
60
|
+
return screen.width > 1050 ? height : screen.height - 300;
|
|
61
|
+
}, [screen.width]);
|
|
62
|
+
var translateType = function translateType(type) {
|
|
63
|
+
switch (type) {
|
|
64
|
+
case 'mainNode':
|
|
65
|
+
// 主要搜尋中心
|
|
66
|
+
return intl ? intl.formatMessage({
|
|
67
|
+
id: 'SNA.search.center'
|
|
68
|
+
}) : '主要搜尋中心';
|
|
69
|
+
case 'organization':
|
|
70
|
+
// 組織
|
|
71
|
+
return intl ? intl.formatMessage({
|
|
72
|
+
id: 'SNA.organization'
|
|
73
|
+
}) : '組織';
|
|
74
|
+
case 'person':
|
|
75
|
+
// 作家
|
|
76
|
+
return intl ? intl.formatMessage({
|
|
77
|
+
id: 'SNA.author'
|
|
78
|
+
}) : '作家';
|
|
79
|
+
case 'publication':
|
|
80
|
+
// 著作
|
|
81
|
+
return intl ? intl.formatMessage({
|
|
82
|
+
id: 'SNA.publication'
|
|
83
|
+
}) : '作家';
|
|
84
|
+
case 'article':
|
|
85
|
+
// 單篇作品
|
|
86
|
+
return intl ? intl.formatMessage({
|
|
87
|
+
id: 'SNA.article'
|
|
88
|
+
}) : '單篇作品';
|
|
89
|
+
case 'keyword':
|
|
90
|
+
// 關鍵字
|
|
91
|
+
return intl ? intl.formatMessage({
|
|
92
|
+
id: 'SNA.keyword'
|
|
93
|
+
}) : '關鍵字';
|
|
94
|
+
case 'event':
|
|
95
|
+
// 事件
|
|
96
|
+
return intl ? intl.formatMessage({
|
|
97
|
+
id: 'SNA.event'
|
|
98
|
+
}) : '事件';
|
|
99
|
+
default:
|
|
100
|
+
return '';
|
|
101
|
+
}
|
|
102
|
+
};
|
|
103
|
+
var drag$1 = function drag$1(simulation) {
|
|
104
|
+
function dragstarted(d) {
|
|
105
|
+
if (!event.active) simulation.alphaTarget(0.3).restart();
|
|
106
|
+
d.fx = d.x;
|
|
107
|
+
d.fy = d.y;
|
|
108
|
+
}
|
|
109
|
+
function dragged(d) {
|
|
110
|
+
d.fx = event.x > contentWidth - 10 || event.x < 20 ? d.x : event.x;
|
|
111
|
+
d.fy = event.y > contentHeight - 10 || event.y < 20 ? d.y : event.y;
|
|
112
|
+
}
|
|
113
|
+
return drag().on('start', dragstarted).on('drag', dragged);
|
|
114
|
+
};
|
|
115
|
+
var calculateCurve = function calculateCurve(source, target, curveLen) {
|
|
116
|
+
var mx = (target.x + source.x) * 0.5;
|
|
117
|
+
var my = (target.y + source.y) * 0.5;
|
|
118
|
+
var tsx = target.x - source.x;
|
|
119
|
+
var tsy = target.y - source.y;
|
|
120
|
+
var L = Math.pow(Math.pow(tsx, 2) + Math.pow(tsy, 2), 0.5);
|
|
121
|
+
var qx = mx - tsy * curveLen / L;
|
|
122
|
+
var qy = my + tsx * curveLen / L;
|
|
123
|
+
return {
|
|
124
|
+
qx: qx,
|
|
125
|
+
qy: qy
|
|
126
|
+
};
|
|
127
|
+
};
|
|
128
|
+
var getLineCurve = function getLineCurve(source, target, curveLen) {
|
|
129
|
+
var _calculateCurve = calculateCurve(source, target, curveLen),
|
|
130
|
+
qx = _calculateCurve.qx,
|
|
131
|
+
qy = _calculateCurve.qy;
|
|
132
|
+
if (isNaN(qx)) {
|
|
133
|
+
return "M".concat(source.x, ", ").concat(source.y, " Q0 0 ").concat(target.x, " ").concat(target.y);
|
|
134
|
+
}
|
|
135
|
+
return "M".concat(source.x, ", ").concat(source.y, " Q").concat(qx, " ").concat(qy, " ").concat(target.x, " ").concat(target.y);
|
|
136
|
+
};
|
|
137
|
+
var init = function init(networkData) {
|
|
138
|
+
var edgeLabelSize = '10px';
|
|
139
|
+
var lineRaduis = 30;
|
|
140
|
+
var nodeStroke = 1.5;
|
|
141
|
+
var nodeRadius = 10 - nodeStroke;
|
|
142
|
+
var mainNodeRadius = 15 - nodeStroke;
|
|
143
|
+
var arrowPercent = 0.8;
|
|
144
|
+
var arrowViewBox = "-0 -".concat(nodeRadius, " ").concat(nodeRadius * 2, " ").concat(nodeRadius * 2);
|
|
145
|
+
var arrowPath = "M 0,-".concat(nodeRadius * arrowPercent, " L ").concat(nodeRadius * arrowPercent * 2, " ,0 L 0,").concat(nodeRadius * arrowPercent);
|
|
146
|
+
var color = ordinal(category10);
|
|
147
|
+
var links = networkData.links.map(function (d) {
|
|
148
|
+
return Object.create(d);
|
|
149
|
+
});
|
|
150
|
+
var nodes = networkData.nodes.map(function (d) {
|
|
151
|
+
return Object.create(d);
|
|
152
|
+
});
|
|
153
|
+
var simulation$1 = simulation(nodes).force('link', link(links).id(function (d) {
|
|
154
|
+
return d.index;
|
|
155
|
+
}).distance(50)).force('charge', manyBody().strength(-200).distanceMax(1000)).force('center', center(contentWidth / 2, contentHeight / 2)).force('collide', collide().radius(function () {
|
|
156
|
+
return nodeRadius + 5;
|
|
157
|
+
}).strength(1).iterations(10)).force('x', x(contentWidth / 2)).force('y', y(contentHeight / 2)).force('radial', radial(100, contentWidth / 1.5, contentHeight / 1.5));
|
|
158
|
+
var svg = d3Select('#sna-graph').append('svg').attr('viewBox', [0, 0, contentWidth, contentHeight]).style('background-color', backgroundColor);
|
|
159
|
+
svg.append('defs').append('marker').attr('id', 'arrowhead').attr('viewBox', arrowViewBox).attr('refX', nodeRadius * 2 + nodeRadius * arrowPercent).attr('refY', 0).attr('orient', 'auto').attr('markerWidth', nodeRadius * (1 + arrowPercent)).attr('markerHeight', nodeRadius * (1 + arrowPercent)).attr('xoverflow', 'visible').append('svg:path').attr('d', arrowPath).attr('fill', '#999').style('stroke', 'none');
|
|
160
|
+
// 增加一層g用來包住所有的物件,並對此g加入縮放功能
|
|
161
|
+
g = svg.append('g');
|
|
162
|
+
var zoomActions = function zoomActions() {
|
|
163
|
+
g.attr('transform', event.transform);
|
|
164
|
+
};
|
|
165
|
+
var zoomHandler = zoom().scaleExtent([0.5, 20]).extent([[0, 0], [contentWidth, contentHeight]]).on('zoom', zoomActions);
|
|
166
|
+
zoomHandler(svg);
|
|
167
|
+
var link$1 = g.append('g').attr('stroke', '#999').attr('stroke-opacity', 0.6).selectAll('line').data(links).join('path').attr('fill', 'none').attr('stroke-dasharray', function (d) {
|
|
168
|
+
return d.ontology === 'protege' ? '2,5,3' : '';
|
|
169
|
+
}).attr('key', function (d) {
|
|
170
|
+
return d.type;
|
|
171
|
+
});
|
|
172
|
+
var node = g.append('g').attr('stroke', '#fff').attr('stroke-width', nodeStroke).selectAll('circle').data(nodes).join('circle').attr('r', function (d) {
|
|
173
|
+
return d.type === 'mainNode' ? mainNodeRadius : nodeRadius;
|
|
174
|
+
}).attr('fill', function (d) {
|
|
175
|
+
return color(d.type);
|
|
176
|
+
}).attr('key', function (d) {
|
|
177
|
+
return d.type;
|
|
178
|
+
}).attr('class', function (d) {
|
|
179
|
+
return "node node-".concat(d.id, " ").concat(d.type && d.type === 'organization' ? 'org' : d.type === 'person' ? 'person' : d.type === 'publication' ? 'publication' : d.type === 'mainNode' ? 'mainNode' : d.type === 'article' ? 'article' : d.type === 'keyword' ? 'keyword' : d.type === 'event' ? 'event' : '');
|
|
180
|
+
}).on('click', function (d) {
|
|
181
|
+
return d.hasClick ? handleClickNodeGoto({
|
|
182
|
+
name: d.name,
|
|
183
|
+
id: d.id,
|
|
184
|
+
type: d.type
|
|
185
|
+
}) : null;
|
|
186
|
+
}).call(drag$1(simulation$1));
|
|
187
|
+
node.append('title').text(function (d) {
|
|
188
|
+
return "".concat(d.name, "-").concat(translateType(d.type));
|
|
189
|
+
});
|
|
190
|
+
var nodeLabel = g.append('g').selectAll('text').data(nodes).join('text').attr('fill', fontColor).attr('text-anchor', 'middle').attr('key', function (d) {
|
|
191
|
+
return d.type;
|
|
192
|
+
}).style('color', '#fff').style('font-size', '14px').text(function (d) {
|
|
193
|
+
return d.name;
|
|
194
|
+
});
|
|
195
|
+
var edgepaths = g.selectAll('.edgepath').data(links).enter().append('path').attr('class', 'edgepath').attr('fill-opacity', 0).attr('stroke-opacity', 0).attr('id', function (d, i) {
|
|
196
|
+
return "edgepath".concat(i);
|
|
197
|
+
}).style('pointer-events', 'none');
|
|
198
|
+
var edgelabels = g.selectAll('.edgelabel').data(links).enter().append('text').style('pointer-events', 'none').attr('class', 'edgelabel').attr('font-size', edgeLabelSize).attr('fill', '#aaa').attr('visibility', 'visible').attr('key', function (d) {
|
|
199
|
+
return d.type;
|
|
200
|
+
}).attr('id', function (d, i) {
|
|
201
|
+
return "edgelabel".concat(i);
|
|
202
|
+
});
|
|
203
|
+
edgelabels.append('textPath').attr('xlink:href', function (d, i) {
|
|
204
|
+
return "#edgepath".concat(i);
|
|
205
|
+
}).style('text-anchor', 'middle').style('pointer-events', 'none').attr('startOffset', '50%').text(function (d) {
|
|
206
|
+
return d.property;
|
|
207
|
+
});
|
|
208
|
+
simulation$1.on('tick', function () {
|
|
209
|
+
nodes.forEach(function (d) {
|
|
210
|
+
// x軸 超過寬度380,回彈到380座標軸區域位置。 ——作用爲:超出範圍的回彈到視圖寬度範圍內
|
|
211
|
+
if (d.x >= contentWidth - 20) {
|
|
212
|
+
d.x = contentWidth - 20;
|
|
213
|
+
}
|
|
214
|
+
// y軸 超過高度280,回彈到280座標軸區域位置。 ——作用爲:超出範圍的回彈到視圖高度範圍內
|
|
215
|
+
if (d.y >= contentHeight - 20) {
|
|
216
|
+
d.y = contentHeight - 20;
|
|
217
|
+
}
|
|
218
|
+
if (d.x <= 20) {
|
|
219
|
+
d.x = 20;
|
|
220
|
+
}
|
|
221
|
+
if (d.y <= 20) {
|
|
222
|
+
d.y = 20;
|
|
223
|
+
}
|
|
224
|
+
});
|
|
225
|
+
link$1.attr('d', function (d) {
|
|
226
|
+
return getLineCurve(d.source, d.target, lineRaduis);
|
|
227
|
+
});
|
|
228
|
+
node.attr('cx', function (d) {
|
|
229
|
+
return d.x;
|
|
230
|
+
}).attr('cy', function (d) {
|
|
231
|
+
return d.y;
|
|
232
|
+
});
|
|
233
|
+
nodeLabel.attr('x', function (d) {
|
|
234
|
+
return d.x;
|
|
235
|
+
}).attr('y', function (d) {
|
|
236
|
+
return d.y - nodeRadius;
|
|
237
|
+
});
|
|
238
|
+
edgepaths.attr('d', function (d) {
|
|
239
|
+
return getLineCurve(d.source, d.target, lineRaduis);
|
|
240
|
+
});
|
|
241
|
+
});
|
|
242
|
+
};
|
|
243
|
+
var renderSNA = function renderSNA() {
|
|
244
|
+
if (SNAData && SNAData.nodes && SNAData.nodes.length > 0) {
|
|
245
|
+
var div = document.getElementById('sna-graph');
|
|
246
|
+
if (div && div.childNodes[0]) {
|
|
247
|
+
div.removeChild(div.childNodes[0]);
|
|
248
|
+
}
|
|
249
|
+
init(SNAData);
|
|
250
|
+
}
|
|
251
|
+
};
|
|
252
|
+
|
|
253
|
+
// 資料異動或全螢幕切換,重新渲染網絡圖
|
|
254
|
+
useEffect(function () {
|
|
255
|
+
renderSNA();
|
|
256
|
+
}, [SNAData]);
|
|
257
|
+
return /*#__PURE__*/React__default.createElement("div", {
|
|
258
|
+
className: classNames('SNA', {
|
|
259
|
+
'SNA--smallSize': distance < 200
|
|
260
|
+
}, className),
|
|
261
|
+
style: {
|
|
262
|
+
contentWidth: contentWidth,
|
|
263
|
+
contentHeight: contentHeight,
|
|
264
|
+
backgroundColor: backgroundColor
|
|
265
|
+
}
|
|
266
|
+
}, /*#__PURE__*/React__default.createElement(ExtraTools, {
|
|
267
|
+
intl: intl,
|
|
268
|
+
data: SNAData,
|
|
269
|
+
iconColor: iconColor,
|
|
270
|
+
domToImageId: "sna-graph",
|
|
271
|
+
FontSizeTargets: ['#sna-graph svg g text'],
|
|
272
|
+
exclude: exclude,
|
|
273
|
+
DownloadExcel: DownloadExcel,
|
|
274
|
+
fullscreenDomId: "sna-graph"
|
|
275
|
+
}), /*#__PURE__*/React__default.createElement(ResetBtn, {
|
|
276
|
+
renderSNA: renderSNA
|
|
277
|
+
}), /*#__PURE__*/React__default.createElement("div", {
|
|
278
|
+
id: "sna-graph"
|
|
279
|
+
}));
|
|
280
|
+
};
|
|
281
|
+
SNA.defaultProps = {
|
|
282
|
+
className: undefined,
|
|
283
|
+
intl: undefined,
|
|
284
|
+
width: 1050,
|
|
285
|
+
height: 600,
|
|
286
|
+
distance: 400,
|
|
287
|
+
SNAData: null,
|
|
288
|
+
fontColor: '#000000',
|
|
289
|
+
backgroundColor: '#FFFFFF',
|
|
290
|
+
iconColor: '#825c0d',
|
|
291
|
+
exclude: ['downloadXls', 'downloadTsv'],
|
|
292
|
+
handleClickNodeGoto: null,
|
|
293
|
+
DownloadExcel: undefined
|
|
294
|
+
};
|
|
295
|
+
|
|
296
|
+
/* Write props detail information and 'npm run updateStory' will help you generate stories's argTypes */
|
|
297
|
+
SNA.propTypes = {
|
|
298
|
+
/** Css Name */
|
|
299
|
+
className: PropTypes.string,
|
|
300
|
+
/** 語言 */
|
|
301
|
+
intl: PropTypes.objectOf(PropTypes.any),
|
|
302
|
+
/** 寬度 */
|
|
303
|
+
width: PropTypes.number,
|
|
304
|
+
/** 高度 */
|
|
305
|
+
height: PropTypes.number,
|
|
306
|
+
/** 點跟點之間的距離 */
|
|
307
|
+
distance: PropTypes.number,
|
|
308
|
+
/** 資料 */
|
|
309
|
+
SNAData: PropTypes.objectOf(PropTypes.any),
|
|
310
|
+
/** 網絡圖文字顏色 */
|
|
311
|
+
fontColor: PropTypes.string,
|
|
312
|
+
/** 網絡圖背景顏色 */
|
|
313
|
+
backgroundColor: PropTypes.string,
|
|
314
|
+
/** icon顏色 */
|
|
315
|
+
iconColor: PropTypes.string,
|
|
316
|
+
/** 不顯示的按鈕 ['share', 'downloadImage', 'downloadTsv', 'downloadXls', 'fullscreen', 'fontSizeChanger'] */
|
|
317
|
+
exclude: PropTypes.arrayOf(PropTypes.string),
|
|
318
|
+
/** 按下點後要轉址的功能 */
|
|
319
|
+
handleClickNodeGoto: PropTypes.func,
|
|
320
|
+
/** Download元件, 由外部傳入的原因是需要環境設定 */
|
|
321
|
+
DownloadExcel: PropTypes.oneOfType([PropTypes.node, PropTypes.func])
|
|
322
|
+
};
|
|
323
|
+
|
|
324
|
+
export { SNA as default };
|
|
@@ -1 +1,114 @@
|
|
|
1
|
-
import{b as
|
|
1
|
+
import { b as _objectSpread2, d as _typeof } from './_rollupPluginBabelHelpers-fde6d1c6.js';
|
|
2
|
+
import React__default from 'react';
|
|
3
|
+
import PropTypes from 'prop-types';
|
|
4
|
+
import { s as styleInject, c as classNames } from './vendor-851c6356.js';
|
|
5
|
+
import { FormControl, Select as Select$1, CircularProgress, MenuItem } from '@material-ui/core';
|
|
6
|
+
import { E as Empty } from './Empty-70f040a9.js';
|
|
7
|
+
|
|
8
|
+
var css_248z = ".select__placeholder {\n color: #999; }\n\n.select--small {\n width: 100%; }\n .select--small .MuiSelect-root {\n padding: 0.5rem 1.5rem 0.25rem;\n color: white; }\n .select--small .MuiSelect-root .select__placeholder {\n color: white; }\n .select--small .MuiSelect-root:hover, .select--small .MuiSelect-root:focus {\n background: transparent; }\n .select--small .MuiSvgIcon-root {\n color: white; }\n .select--small .MuiOutlinedInput-root {\n border-radius: 45px; }\n";
|
|
9
|
+
styleInject(css_248z);
|
|
10
|
+
|
|
11
|
+
var Select = function Select(props) {
|
|
12
|
+
var style = props.style,
|
|
13
|
+
className = props.className,
|
|
14
|
+
labelInValue = props.labelInValue,
|
|
15
|
+
disabled = props.disabled,
|
|
16
|
+
loading = props.loading,
|
|
17
|
+
placeholder = props.placeholder,
|
|
18
|
+
variantSmall = props.variantSmall,
|
|
19
|
+
background = props.background,
|
|
20
|
+
menuItemClass = props.menuItemClass;
|
|
21
|
+
var options = props.options,
|
|
22
|
+
value = props.value,
|
|
23
|
+
defaultValue = props.defaultValue,
|
|
24
|
+
_onChange = props.onChange;
|
|
25
|
+
var itemFind = function itemFind(key) {
|
|
26
|
+
return (options || []).find(function (option) {
|
|
27
|
+
return _typeof(option) === 'object' ? key === option.value : key === option;
|
|
28
|
+
}) || key;
|
|
29
|
+
};
|
|
30
|
+
return /*#__PURE__*/React__default.createElement(FormControl, {
|
|
31
|
+
className: classNames('select', {
|
|
32
|
+
'select--small': variantSmall
|
|
33
|
+
}, className),
|
|
34
|
+
variant: "outlined"
|
|
35
|
+
}, /*#__PURE__*/React__default.createElement(Select$1, {
|
|
36
|
+
style: _objectSpread2(_objectSpread2({}, style || {}), {}, {
|
|
37
|
+
background: background
|
|
38
|
+
}),
|
|
39
|
+
displayEmpty: true,
|
|
40
|
+
disabled: disabled || loading,
|
|
41
|
+
renderValue: function renderValue(id) {
|
|
42
|
+
var finder = itemFind(id);
|
|
43
|
+
var content = _typeof(finder) === 'object' ? finder.label : finder;
|
|
44
|
+
if (!id && id !== 0 || id.length === 0) content = /*#__PURE__*/React__default.createElement("span", {
|
|
45
|
+
className: "select__placeholder"
|
|
46
|
+
}, placeholder);
|
|
47
|
+
return /*#__PURE__*/React__default.createElement(React__default.Fragment, null, content, loading && /*#__PURE__*/React__default.createElement(CircularProgress, {
|
|
48
|
+
size: 16,
|
|
49
|
+
style: {
|
|
50
|
+
marginLeft: 8,
|
|
51
|
+
marginRight: 4
|
|
52
|
+
}
|
|
53
|
+
}));
|
|
54
|
+
},
|
|
55
|
+
value: value,
|
|
56
|
+
defaultValue: defaultValue,
|
|
57
|
+
onChange: function onChange(event) {
|
|
58
|
+
return _onChange(labelInValue ? itemFind(event.target.value) : event.target.value);
|
|
59
|
+
}
|
|
60
|
+
}, Array.isArray(options) && options.length > 0 ? options.map(function (option) {
|
|
61
|
+
var key = _typeof(option) === 'object' ? option.value : option;
|
|
62
|
+
var text = _typeof(option) === 'object' ? option.label : option;
|
|
63
|
+
return /*#__PURE__*/React__default.createElement(MenuItem, {
|
|
64
|
+
key: key,
|
|
65
|
+
value: key,
|
|
66
|
+
ListItemClasses: menuItemClass
|
|
67
|
+
}, text);
|
|
68
|
+
}) : /*#__PURE__*/React__default.createElement(Empty, null)));
|
|
69
|
+
};
|
|
70
|
+
Select.defaultProps = {
|
|
71
|
+
style: undefined,
|
|
72
|
+
className: undefined,
|
|
73
|
+
value: undefined,
|
|
74
|
+
defaultValue: undefined,
|
|
75
|
+
options: undefined,
|
|
76
|
+
labelInValue: undefined,
|
|
77
|
+
disabled: undefined,
|
|
78
|
+
loading: undefined,
|
|
79
|
+
placeholder: 'Please select...',
|
|
80
|
+
variantSmall: undefined,
|
|
81
|
+
background: undefined,
|
|
82
|
+
menuItemClass: undefined,
|
|
83
|
+
onChange: function onChange() {}
|
|
84
|
+
};
|
|
85
|
+
Select.propTypes = {
|
|
86
|
+
/** 樣式 */
|
|
87
|
+
style: PropTypes.objectOf(PropTypes.any),
|
|
88
|
+
/** Css Name */
|
|
89
|
+
className: PropTypes.string,
|
|
90
|
+
/** 選擇的id */
|
|
91
|
+
value: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
|
|
92
|
+
/** 預設選擇的id */
|
|
93
|
+
defaultValue: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
|
|
94
|
+
/** 下拉選單清單 */
|
|
95
|
+
options: PropTypes.arrayOf(PropTypes.any),
|
|
96
|
+
/** onChange時 label value 一起回傳 */
|
|
97
|
+
labelInValue: PropTypes.bool,
|
|
98
|
+
/** 是否禁止使用 */
|
|
99
|
+
disabled: PropTypes.bool,
|
|
100
|
+
/** 是否載入中 */
|
|
101
|
+
loading: PropTypes.bool,
|
|
102
|
+
/** 下拉選單提示字 */
|
|
103
|
+
placeholder: PropTypes.string,
|
|
104
|
+
/** 是否使用小size */
|
|
105
|
+
variantSmall: PropTypes.bool,
|
|
106
|
+
/** 使用變體後的顏色 */
|
|
107
|
+
background: PropTypes.string,
|
|
108
|
+
/** override menuItem class */
|
|
109
|
+
menuItemClass: PropTypes.objectOf(PropTypes.any),
|
|
110
|
+
/** 點選後的返回 */
|
|
111
|
+
onChange: PropTypes.func
|
|
112
|
+
};
|
|
113
|
+
|
|
114
|
+
export { Select as S };
|
package/lib/components/Select.js
CHANGED
|
@@ -1 +1,10 @@
|
|
|
1
|
-
export{S as default}from
|
|
1
|
+
export { S as default } from './Select-98a8e973.js';
|
|
2
|
+
import './_rollupPluginBabelHelpers-fde6d1c6.js';
|
|
3
|
+
import 'react';
|
|
4
|
+
import 'prop-types';
|
|
5
|
+
import './vendor-851c6356.js';
|
|
6
|
+
import 'react-is';
|
|
7
|
+
import '@material-ui/styles';
|
|
8
|
+
import 'react-dom';
|
|
9
|
+
import '@material-ui/core';
|
|
10
|
+
import './Empty-70f040a9.js';
|
|
@@ -1 +1,74 @@
|
|
|
1
|
-
import
|
|
1
|
+
import React__default, { useMemo } from 'react';
|
|
2
|
+
import PropTypes from 'prop-types';
|
|
3
|
+
import { s as styleInject, c as classNames } from './vendor-851c6356.js';
|
|
4
|
+
import { Fade, CircularProgress } from '@material-ui/core';
|
|
5
|
+
|
|
6
|
+
var css_248z = ".customSpin {\n width: 100%;\n min-height: 100px;\n position: relative; }\n .customSpin__spin {\n width: 100%;\n height: 100%;\n position: absolute;\n z-index: 2;\n display: flex;\n justify-content: center;\n align-items: center; }\n";
|
|
7
|
+
styleInject(css_248z);
|
|
8
|
+
|
|
9
|
+
var stringSize = {
|
|
10
|
+
small: 16,
|
|
11
|
+
middle: 24,
|
|
12
|
+
large: 40
|
|
13
|
+
};
|
|
14
|
+
var Spin = function Spin(props) {
|
|
15
|
+
var className = props.className,
|
|
16
|
+
spinning = props.spinning,
|
|
17
|
+
children = props.children,
|
|
18
|
+
size = props.size,
|
|
19
|
+
style = props.style;
|
|
20
|
+
var maxValue = function maxValue(val) {
|
|
21
|
+
// 極大極小值限制 300/16
|
|
22
|
+
var min = val < 16 ? 16 : val;
|
|
23
|
+
var max = min > 300 ? 300 : min;
|
|
24
|
+
return max;
|
|
25
|
+
};
|
|
26
|
+
var matchSize = useMemo(function () {
|
|
27
|
+
if (typeof size === 'string') {
|
|
28
|
+
if (Number(size) && typeof Number(size) === 'number') {
|
|
29
|
+
return maxValue(Number(size));
|
|
30
|
+
}
|
|
31
|
+
return stringSize[size] || 40;
|
|
32
|
+
}
|
|
33
|
+
if (typeof size === 'number') {
|
|
34
|
+
return maxValue(size);
|
|
35
|
+
}
|
|
36
|
+
// default size is large
|
|
37
|
+
return 40;
|
|
38
|
+
}, [size]);
|
|
39
|
+
return /*#__PURE__*/React__default.createElement("div", {
|
|
40
|
+
className: classNames('customSpin', className),
|
|
41
|
+
style: style || {}
|
|
42
|
+
}, /*#__PURE__*/React__default.createElement(Fade, {
|
|
43
|
+
in: spinning,
|
|
44
|
+
style: {
|
|
45
|
+
transitionDelay: '300ms'
|
|
46
|
+
},
|
|
47
|
+
unmountOnExit: true
|
|
48
|
+
}, /*#__PURE__*/React__default.createElement("div", {
|
|
49
|
+
className: "customSpin__spin"
|
|
50
|
+
}, /*#__PURE__*/React__default.createElement(CircularProgress, {
|
|
51
|
+
size: matchSize
|
|
52
|
+
}))), children);
|
|
53
|
+
};
|
|
54
|
+
Spin.defaultProps = {
|
|
55
|
+
className: undefined,
|
|
56
|
+
spinning: false,
|
|
57
|
+
children: null,
|
|
58
|
+
size: undefined,
|
|
59
|
+
style: undefined
|
|
60
|
+
};
|
|
61
|
+
Spin.propTypes = {
|
|
62
|
+
/** Css Name */
|
|
63
|
+
className: PropTypes.string,
|
|
64
|
+
/** 是否載入中 */
|
|
65
|
+
spinning: PropTypes.bool,
|
|
66
|
+
/** 內容 */
|
|
67
|
+
children: PropTypes.node,
|
|
68
|
+
/** 自訂尺寸 */
|
|
69
|
+
size: PropTypes.oneOfType([PropTypes.oneOf(Object.keys(stringSize)), PropTypes.number]),
|
|
70
|
+
/** 自訂Style設置 */
|
|
71
|
+
style: PropTypes.objectOf(PropTypes.any)
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
export { Spin as S };
|
package/lib/components/Spin.js
CHANGED
|
@@ -1 +1,8 @@
|
|
|
1
|
-
export{S as default}from
|
|
1
|
+
export { S as default } from './Spin-690a3597.js';
|
|
2
|
+
import 'react';
|
|
3
|
+
import 'prop-types';
|
|
4
|
+
import './vendor-851c6356.js';
|
|
5
|
+
import 'react-is';
|
|
6
|
+
import '@material-ui/styles';
|
|
7
|
+
import 'react-dom';
|
|
8
|
+
import '@material-ui/core';
|
package/lib/components/Table.js
CHANGED
|
@@ -1 +1,51 @@
|
|
|
1
|
-
import{c as
|
|
1
|
+
import { c as _objectWithoutProperties } from './_rollupPluginBabelHelpers-fde6d1c6.js';
|
|
2
|
+
import React__default from 'react';
|
|
3
|
+
import PropTypes from 'prop-types';
|
|
4
|
+
import { TableContainer, Paper, Table as Table$1, TableHead, TableRow, TableCell, TableBody } from '@material-ui/core';
|
|
5
|
+
|
|
6
|
+
var _excluded = ["render"];
|
|
7
|
+
var Table = function Table(_ref) {
|
|
8
|
+
var className = _ref.className,
|
|
9
|
+
columns = _ref.columns,
|
|
10
|
+
data = _ref.data;
|
|
11
|
+
return /*#__PURE__*/React__default.createElement(TableContainer, {
|
|
12
|
+
className: className,
|
|
13
|
+
component: Paper
|
|
14
|
+
}, /*#__PURE__*/React__default.createElement(Table$1, {
|
|
15
|
+
className: "customTable"
|
|
16
|
+
}, /*#__PURE__*/React__default.createElement(TableHead, null, /*#__PURE__*/React__default.createElement(TableRow, null, Array.isArray(columns) && columns.map(function (_ref2) {
|
|
17
|
+
var field = _ref2.field,
|
|
18
|
+
headerName = _ref2.headerName;
|
|
19
|
+
return /*#__PURE__*/React__default.createElement(TableCell, {
|
|
20
|
+
key: field
|
|
21
|
+
}, headerName);
|
|
22
|
+
}))), /*#__PURE__*/React__default.createElement(TableBody, null, Array.isArray(data) && data.map(function (item, index) {
|
|
23
|
+
return /*#__PURE__*/React__default.createElement(TableRow, {
|
|
24
|
+
key: index.toString()
|
|
25
|
+
}, Array.isArray(columns) && columns.map(function (_ref3) {
|
|
26
|
+
var render = _ref3.render,
|
|
27
|
+
columnProps = _objectWithoutProperties(_ref3, _excluded);
|
|
28
|
+
var field = columnProps.field;
|
|
29
|
+
return /*#__PURE__*/React__default.createElement(TableCell, {
|
|
30
|
+
key: field,
|
|
31
|
+
component: "th",
|
|
32
|
+
scope: "row"
|
|
33
|
+
}, render && render(item) || item[field]);
|
|
34
|
+
}));
|
|
35
|
+
}))));
|
|
36
|
+
};
|
|
37
|
+
Table.defaultProps = {
|
|
38
|
+
className: undefined,
|
|
39
|
+
columns: [],
|
|
40
|
+
data: []
|
|
41
|
+
};
|
|
42
|
+
Table.propTypes = {
|
|
43
|
+
/** Css Name */
|
|
44
|
+
className: PropTypes.string,
|
|
45
|
+
/** 欄位列表 */
|
|
46
|
+
columns: PropTypes.arrayOf(PropTypes.any),
|
|
47
|
+
/** 表格內容 */
|
|
48
|
+
data: PropTypes.arrayOf(PropTypes.any)
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
export { Table as default };
|