@daoyi/nmtl-ui 2.0.1-beta.47 → 2.0.1-beta.49

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.
Files changed (66) hide show
  1. package/lib/components/{Autocomplete-5439ff22.js → Autocomplete-aa4a8d6c.js} +4 -2
  2. package/lib/components/Autocomplete.js +7 -6
  3. package/lib/components/Avatar.js +2 -4
  4. package/lib/components/BackTop.js +28 -1
  5. package/lib/components/BarChart.js +634 -4
  6. package/lib/components/Breadcrumbs.js +2 -4
  7. package/lib/components/{Button-63c7e9f3.js → Button-2f8f0493.js} +2 -1
  8. package/lib/components/Button.js +3 -5
  9. package/lib/components/Carousel.js +4659 -7
  10. package/lib/components/CollapseContent.js +3 -5
  11. package/lib/components/ContactModal-a44e2a42.js +10759 -0
  12. package/lib/components/ContactModal.js +14 -9
  13. package/lib/components/{Drawer-af3ed21a.js → Drawer-dd8942f1.js} +2 -2
  14. package/lib/components/Drawer.js +5 -7
  15. package/lib/components/Dropdown.js +2 -3
  16. package/lib/components/{Empty-70f040a9.js → Empty-3637b766.js} +2 -1
  17. package/lib/components/Empty.js +3 -5
  18. package/lib/components/ExportButton.js +3 -5
  19. package/lib/components/ExtraTools-55dad795.js +3479 -0
  20. package/lib/components/ExtraTools.js +6 -7
  21. package/lib/components/Filter.js +691 -5
  22. package/lib/components/Footer.js +14 -9
  23. package/lib/components/ForwardLink-4759cf99.js +105 -0
  24. package/lib/components/ForwardLink.js +9 -106
  25. package/lib/components/Header.js +10 -9
  26. package/lib/components/Image.js +7 -4
  27. package/lib/components/Input.js +2 -4
  28. package/lib/components/InputMethod.js +10861 -4
  29. package/lib/components/{KeywordSearch-224f84c1.js → KeywordSearch-2d01266e.js} +3 -2
  30. package/lib/components/KeywordSearch.js +8 -7
  31. package/lib/components/KeywordTicker.js +24 -16
  32. package/lib/components/Keywords.js +30 -5
  33. package/lib/components/Loading.js +2 -4
  34. package/lib/components/MUITheme.js +2375 -3
  35. package/lib/components/{Modal-a7591b98.js → Modal-572e17ea.js} +4 -3
  36. package/lib/components/Modal.js +5 -7
  37. package/lib/components/{MoreButton-f15ca38e.js → MoreButton-80996b5f.js} +2 -1
  38. package/lib/components/MoreButton.js +3 -5
  39. package/lib/components/Radio.js +1 -4
  40. package/lib/components/SNA.js +1416 -5
  41. package/lib/components/{Select-98a8e973.js → Select-5533b506.js} +3 -2
  42. package/lib/components/Select.js +4 -6
  43. package/lib/components/{Spin-690a3597.js → Spin-ebf79c17.js} +2 -1
  44. package/lib/components/Spin.js +3 -5
  45. package/lib/components/{Tooltip-b7eb966d.js → Tooltip-907eaa2e.js} +2 -1
  46. package/lib/components/Tooltip.js +3 -5
  47. package/lib/components/_commonjsHelpers-70de2c37.js +28 -0
  48. package/lib/components/createSvgIcon-48da8b6e.js +576 -0
  49. package/lib/components/dataExport-d55d6fa3.js +92 -0
  50. package/lib/components/debounce-127da66c.js +355 -0
  51. package/lib/components/defaultTheme-19a14721.js +1485 -0
  52. package/lib/components/hoist-non-react-statics.cjs-3f408ad2.js +105 -0
  53. package/lib/components/index-7b60a97d.js +481 -0
  54. package/lib/components/index-f491ebce.js +61 -0
  55. package/lib/components/isObjectLike-e111475d.js +190 -0
  56. package/lib/components/style-inject.es-1f59c1d0.js +28 -0
  57. package/lib/components/transform-3a04288b.js +5475 -0
  58. package/lib/utils/domToImage.js +771 -1
  59. package/lib/utils/exportXlsx.js +36 -1
  60. package/lib/utils/historyAppendSearch.js +480 -1
  61. package/package.json +1 -1
  62. package/lib/components/ContactModal-a59bc808.js +0 -924
  63. package/lib/components/ExtraTools-f10a66a8.js +0 -818
  64. package/lib/components/dataExport-f418e6fe.js +0 -56
  65. package/lib/components/vendor-851c6356.js +0 -41940
  66. package/lib/utils/vendor-3ec75cc9.js +0 -1289
@@ -1,818 +0,0 @@
1
- import { _ as _extends } from './_rollupPluginBabelHelpers-fde6d1c6.js';
2
- import * as React from 'react';
3
- import React__default, { useState } from 'react';
4
- import { q as domtoimage, f as fileDownload$1, s as styleInject, c as classNames, F as FacebookShareButton, t as FacebookIcon, u as screenfull, v as FontSize } from './vendor-851c6356.js';
5
- import PropTypes from 'prop-types';
6
- import { Menu, MenuItem } from '@material-ui/core';
7
- import { T as Tooltip } from './Tooltip-b7eb966d.js';
8
- import { s as snaToExcel, a as jsonExcel } from './dataExport-f418e6fe.js';
9
-
10
- const domToImage = _ref => {
11
- let {
12
- id,
13
- fileName = 'image',
14
- quality = 0.95
15
- } = _ref;
16
- const node = document.getElementById(id);
17
- // 防止barchart的Y軸擋住圖,就先將他移到最左邊,拍完照再移回來
18
- const yaxis = document.getElementById('yaxis');
19
- const barChartElement = document.getElementById('barChart__block');
20
- if (yaxis) {
21
- yaxis.setAttribute('transform', 'translate(0, 0 )');
22
- }
23
- domtoimage.toPng(node, {
24
- quality
25
- }).then(dataUrl => {
26
- const link = document.createElement('a');
27
- link.download = `${fileName}.png`;
28
- link.href = dataUrl;
29
- link.click();
30
- if (yaxis && barChartElement) {
31
- yaxis.setAttribute('transform', 'translate(0, 0 )');
32
- yaxis.setAttribute('transform', `translate(${barChartElement.scrollLeft}, 0)`);
33
- }
34
- }).catch(error => {
35
- console.error('oops, something went wrong!', error);
36
- });
37
- };
38
-
39
- const JSZip = require('jszip');
40
- const fileDownload = require('react-file-download');
41
- const DownloadGephiFileName = 'Gephi_generated_by_NMTL.zip';
42
- const generateNode = result => {
43
- let IdCount = 10000000;
44
- const nodeMap = {};
45
- let foundType = false;
46
- result.forEach(_ref => {
47
- let {
48
- source,
49
- target,
50
- sourceType,
51
- targetType
52
- } = _ref;
53
- if (target === '' || source === '') {
54
- return;
55
- }
56
- if (Object.keys(nodeMap).indexOf(source) < 0) {
57
- if (sourceType !== '') {
58
- foundType = true;
59
- nodeMap[source] = {
60
- ID: IdCount,
61
- WEIGHT: 1,
62
- NODE_TYPE: sourceType
63
- };
64
- } else {
65
- nodeMap[source] = {
66
- ID: IdCount,
67
- WEIGHT: 1
68
- };
69
- }
70
- IdCount += 1;
71
- } else {
72
- nodeMap[source].WEIGHT += 1;
73
- }
74
- if (Object.keys(nodeMap).indexOf(target) < 0) {
75
- if (targetType !== '') {
76
- foundType = true;
77
- nodeMap[target] = {
78
- ID: IdCount,
79
- WEIGHT: 1,
80
- NODE_TYPE: targetType
81
- };
82
- } else {
83
- nodeMap[target] = {
84
- ID: IdCount,
85
- WEIGHT: 1
86
- };
87
- }
88
- IdCount += 1;
89
- } else {
90
- nodeMap[target].WEIGHT += 1;
91
- }
92
- });
93
- let tsvStr = foundType ? 'ID\tLABEL\tWEIGHT\tNODE_TYPE\r\n' : 'ID\tLABEL\tWEIGHT\r\n';
94
- Object.keys(nodeMap).forEach(key => {
95
- const idval = nodeMap[key].ID;
96
- const wval = nodeMap[key].WEIGHT;
97
- const type = foundType ? nodeMap[key].NODE_TYPE : '';
98
- tsvStr += foundType ? `${idval}\t${key}\t${wval}\t${type}\r\n` : `${idval}\t${key}\t${wval}\r\n`;
99
- });
100
- return {
101
- nodeMap,
102
- nodesTsv: tsvStr
103
- };
104
- };
105
- const generateEdge = (result, nodeMap) => {
106
- let edgeStr = 'SOURCE\tTARGET\tWEIGHT\tTYPE\r\n';
107
- result.forEach(_ref2 => {
108
- let {
109
- source,
110
- target
111
- } = _ref2;
112
- if (target === '' || source === '') {
113
- return;
114
- }
115
- const sourceId = nodeMap[source].ID;
116
- const targetId = nodeMap[target].ID;
117
- edgeStr += `${sourceId}\t${targetId}\t1\tUndirected\r\n`;
118
- });
119
- return edgeStr;
120
- };
121
- const downloadGephi = snaData => {
122
- const {
123
- nodes,
124
- links
125
- } = snaData;
126
- const result = (links || []).map(_ref3 => {
127
- let {
128
- source,
129
- target
130
- } = _ref3;
131
- return {
132
- source: nodes[source].name,
133
- target: nodes[target].name,
134
- sourceType: nodes[source].type,
135
- targetType: nodes[target].type
136
- };
137
- });
138
- const {
139
- nodeMap,
140
- nodesTsv
141
- } = generateNode(result);
142
- const edgesTsv = generateEdge(result, nodeMap);
143
- const zip = new JSZip();
144
- zip.file('Node_Table.tsv', nodesTsv);
145
- zip.file('Edge_Table.tsv', edgesTsv);
146
- zip.generateAsync({
147
- type: 'blob'
148
- }).then(content => {
149
- fileDownload(content, DownloadGephiFileName);
150
- });
151
- };
152
-
153
- /* 轉檔工具, 提供API轉下載tsv/xlsx */
154
-
155
- /* 大事年表 */
156
- const chronologyConvert = data => {
157
- const getText = function () {
158
- let text = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
159
- const [before, after] = text.split('<span class="tooltip">');
160
- return {
161
- before,
162
- after
163
- };
164
- };
165
-
166
- /* 做資料過濾 */
167
- const newData = (data || []).map(_ref => {
168
- let {
169
- start_date: {
170
- day,
171
- month,
172
- year
173
- },
174
- display_date: displayDate,
175
- text: {
176
- headline,
177
- text
178
- }
179
- } = _ref;
180
- return {
181
- 日期: `${year || ''}/${month || ''}/${day || ''}`,
182
- 名稱: (displayDate || '').replace('<span>', '').replace('</span>', ''),
183
- 描述: (headline || '').replaceAll(/(<([^>]+)>)/gi, ''),
184
- 類型: getText(text).before,
185
- '註(資料集名稱)': getText(text).after.replaceAll('\n', '').replaceAll('\t', '').replace('註', '').replace('資料來源:', '').replaceAll(/(<([^>]+)>)/gi, '')
186
- };
187
- });
188
- return newData;
189
- };
190
-
191
- /* 文學數據 - 地圖 */
192
- const mapConvert = data => (data || []).map(_ref2 => {
193
- let {
194
- title,
195
- author,
196
- publisher,
197
- locations,
198
- posX,
199
- posY
200
- } = _ref2;
201
- return {
202
- '名稱(書名/文章名)': title || '',
203
- 作者: author || '',
204
- 出版者: publisher || '',
205
- '地點(作品描述區域)': locations || '',
206
- 經度: posX || '',
207
- 緯度: posY || ''
208
- };
209
- });
210
-
211
- /* 文學數據 - 地圖(文學聚落) */
212
- const mapLgConvert = data => (data || []).map(_ref3 => {
213
- let {
214
- title,
215
- locationOfFormation,
216
- workLocations,
217
- createPosX,
218
- createPosY,
219
- activePosX,
220
- activePosY
221
- } = _ref3;
222
- return {
223
- 組織名稱: title || '',
224
- 創立地點: locationOfFormation,
225
- 創立地點經度: createPosX || '',
226
- 創立地點緯度: createPosY || '',
227
- 活動地點: workLocations || '',
228
- 活動地點經度: activePosX || '',
229
- 活動地點緯度: activePosY || ''
230
- };
231
- });
232
-
233
- /* 文學數據 - 年度聲量 */
234
- const worksBarChart = data => (data || []).map(_ref4 => {
235
- let {
236
- date,
237
- year,
238
- title,
239
- keywords,
240
- authors,
241
- genreName
242
- } = _ref4;
243
- return {
244
- '出版年/發表年': date || year || '',
245
- '名稱(書名/文章名)': title || '',
246
- 作者: (authors || []).map(_ref5 => {
247
- let {
248
- author
249
- } = _ref5;
250
- return author;
251
- }).join(','),
252
- 關鍵字: (keywords || '').replaceAll('\n', ''),
253
- 文學分類: genreName || ''
254
- };
255
- });
256
-
257
- /* 文學數據 - 文學自由搭配 */
258
- const worksSlider = data => (data || []).map(_ref6 => {
259
- let {
260
- title,
261
- author,
262
- date
263
- } = _ref6;
264
- return {
265
- '名稱(書名/文章名)': title || '',
266
- 作者: author || '',
267
- '出版日期/發表日期': date || ''
268
- // 文學分類: genreName || '',
269
- // 作品描述地: workDesc || '',
270
- // 作家出生地: locations,
271
- // 獲獎獎項: awards || '',
272
- };
273
- });
274
-
275
- const exportXlsx = _ref => {
276
- let {
277
- data,
278
- dataType,
279
- extType = 'xlsx'
280
- } = _ref;
281
- let metadata;
282
- switch (dataType) {
283
- case 'sna':
284
- metadata = snaToExcel(data);
285
- break;
286
- default:
287
- metadata = data;
288
- break;
289
- }
290
- fileDownload$1(`\uFEFF${jsonExcel(metadata)}`, `output.${extType}`);
291
- };
292
-
293
- // 供外部使用dataConvert
294
- exportXlsx.chronologyConvert = chronologyConvert;
295
- exportXlsx.mapConvert = mapConvert;
296
- exportXlsx.mapLgConvert = mapLgConvert;
297
- exportXlsx.worksBarChart = worksBarChart;
298
- exportXlsx.worksSlider = worksSlider;
299
-
300
- /* eslint-disable max-len */
301
- const DownloadImg = _ref => {
302
- let {
303
- fill = '#825c0d'
304
- } = _ref;
305
- return /*#__PURE__*/React__default.createElement("svg", {
306
- xmlns: "http://www.w3.org/2000/svg",
307
- width: 32,
308
- height: 32,
309
- viewBox: "0 0 32 32"
310
- }, /*#__PURE__*/React__default.createElement("defs", null, /*#__PURE__*/React__default.createElement("clipPath", {
311
- id: "a"
312
- }, /*#__PURE__*/React__default.createElement("path", {
313
- "data-name": "Rectangle 125",
314
- style: {
315
- fill: '#fff'
316
- },
317
- d: "M0 0h32v32H0z"
318
- }))), /*#__PURE__*/React__default.createElement("g", {
319
- style: {
320
- clipPath: 'url(#a)'
321
- }
322
- }, /*#__PURE__*/React__default.createElement("path", {
323
- d: "M-960 600h-20v-10h4v2h-2v6h16v-6h-2v-2h4zm-5.06-12.608-1.348-1.454-2.592 2.427V580h-2v8.365l-2.544-2.427-1.362 1.454 4.948 4.671z",
324
- transform: "translate(986 -574)",
325
- style: {
326
- fill
327
- },
328
- "data-name": "Mask Group 42"
329
- })));
330
- };
331
-
332
- /* eslint-disable max-len */
333
- const SVGComponent$2 = _ref => {
334
- let {
335
- fill = '#825c0d'
336
- } = _ref;
337
- return /*#__PURE__*/React.createElement("svg", {
338
- xmlns: "http://www.w3.org/2000/svg",
339
- width: 32,
340
- height: 32,
341
- viewBox: "0 0 32 32"
342
- }, /*#__PURE__*/React.createElement("defs", null, /*#__PURE__*/React.createElement("clipPath", {
343
- id: "clip-path"
344
- }, /*#__PURE__*/React.createElement("path", {
345
- id: "Rectangle_128",
346
- "data-name": "Rectangle 128",
347
- style: {
348
- fill: '#fff'
349
- },
350
- d: "M0 0h32v32H0z"
351
- })), /*#__PURE__*/React.createElement("style", null, `\n .cls-3{fill:${fill}}\n `)), /*#__PURE__*/React.createElement("g", {
352
- id: "Mask_Group_47",
353
- "data-name": "Mask Group 47",
354
- style: {
355
- clipPath: 'url(#clip-path)'
356
- }
357
- }, /*#__PURE__*/React.createElement("g", {
358
- id: "Group_3633",
359
- "data-name": "Group 3633",
360
- transform: "translate(6 6)"
361
- }, /*#__PURE__*/React.createElement("path", {
362
- id: "Path_181",
363
- "data-name": "Path 181",
364
- className: "cls-3",
365
- d: "M514 371v-2h-2v2h-2v2h2v2h2v-2h2v-2z",
366
- transform: "translate(-495 -369)"
367
- }), /*#__PURE__*/React.createElement("g", {
368
- id: "Group_3632",
369
- "data-name": "Group 3632",
370
- transform: "translate(0 2)"
371
- }, /*#__PURE__*/React.createElement("path", {
372
- id: "Path_182",
373
- "data-name": "Path 182",
374
- className: "cls-3",
375
- d: "M502.276 371h3.447L512 389h-3.164l-1.595-5.129h-6.586L499.036 389H496zm-.926 10.649h5.17l-.746-2.419c-.643-1.953-1.209-3.956-1.776-5.983h-.128a126.193 126.193 0 0 1-1.748 5.983z",
376
- transform: "translate(-496 -371)"
377
- })))));
378
- };
379
-
380
- /* eslint-disable max-len */
381
- const SVGComponent$1 = _ref => {
382
- let {
383
- fill = '#825c0d'
384
- } = _ref;
385
- return /*#__PURE__*/React.createElement("svg", {
386
- xmlns: "http://www.w3.org/2000/svg",
387
- width: 32,
388
- height: 32,
389
- viewBox: "0 0 32 32"
390
- }, /*#__PURE__*/React.createElement("defs", null, /*#__PURE__*/React.createElement("clipPath", {
391
- id: "clip-path"
392
- }, /*#__PURE__*/React.createElement("path", {
393
- id: "Rectangle_129",
394
- "data-name": "Rectangle 129",
395
- style: {
396
- fill: '#fff'
397
- },
398
- d: "M0 0h32v32H0z"
399
- })), /*#__PURE__*/React.createElement("style", null, `\n .cls-3{fill:${fill}}\n `)), /*#__PURE__*/React.createElement("g", {
400
- id: "Mask_Group_48",
401
- "data-name": "Mask Group 48",
402
- style: {
403
- clipPath: 'url(#clip-path)'
404
- }
405
- }, /*#__PURE__*/React.createElement("g", {
406
- id: "Group_3635",
407
- "data-name": "Group 3635",
408
- transform: "translate(6 8)"
409
- }, /*#__PURE__*/React.createElement("path", {
410
- id: "Path_181",
411
- "data-name": "Path 181",
412
- className: "cls-3",
413
- d: "M510 371v2h6v-2z",
414
- transform: "translate(-495 -371)"
415
- }), /*#__PURE__*/React.createElement("g", {
416
- id: "Group_3632",
417
- "data-name": "Group 3632"
418
- }, /*#__PURE__*/React.createElement("path", {
419
- id: "Path_182",
420
- "data-name": "Path 182",
421
- className: "cls-3",
422
- d: "M502.276 371h3.447L512 389h-3.164l-1.595-5.129h-6.586L499.036 389H496zm-.926 10.649h5.17l-.746-2.419c-.643-1.953-1.209-3.956-1.776-5.983h-.128a126.193 126.193 0 0 1-1.748 5.983z",
423
- transform: "translate(-496 -371)"
424
- })))));
425
- };
426
-
427
- const SVGComponent = _ref => {
428
- let {
429
- fill = '#825c0d'
430
- } = _ref;
431
- return /*#__PURE__*/React.createElement("svg", {
432
- xmlns: "http://www.w3.org/2000/svg",
433
- width: 32,
434
- height: 32,
435
- viewBox: "0 0 32 32"
436
- }, /*#__PURE__*/React.createElement("defs", null, /*#__PURE__*/React.createElement("clipPath", {
437
- id: "clip-path"
438
- }, /*#__PURE__*/React.createElement("path", {
439
- id: "Rectangle_124",
440
- "data-name": "Rectangle 124",
441
- style: {
442
- fill: '#fff'
443
- },
444
- d: "M0 0h32v32H0z"
445
- })), /*#__PURE__*/React.createElement("style", null, `\n .cls-3{fill:${fill}}\n `)), /*#__PURE__*/React.createElement("g", {
446
- id: "Mask_Group_46",
447
- "data-name": "Mask Group 46",
448
- style: {
449
- clipPath: 'url(#clip-path)'
450
- }
451
- }, /*#__PURE__*/React.createElement("g", {
452
- id: "Group_3629",
453
- "data-name": "Group 3629",
454
- transform: "translate(6 6.001)"
455
- }, /*#__PURE__*/React.createElement("path", {
456
- id: "Path_176",
457
- "data-name": "Path 176",
458
- className: "cls-3",
459
- d: "M-721 1949.376h2.5v-3.755h3.755v-2.5H-721z",
460
- transform: "translate(721.003 -1943.118)"
461
- }), /*#__PURE__*/React.createElement("path", {
462
- id: "Path_177",
463
- "data-name": "Path 177",
464
- className: "cls-3",
465
- d: "M-721 1960.376h6.258v-2.5h-3.758v-3.755h-2.5z",
466
- transform: "translate(721.003 -1940.376)"
467
- }), /*#__PURE__*/React.createElement("path", {
468
- id: "Path_178",
469
- "data-name": "Path 178",
470
- className: "cls-3",
471
- d: "M-703.744 1943.118H-710v2.5h3.755v3.755h2.5z",
472
- transform: "translate(723.744 -1943.118)"
473
- }), /*#__PURE__*/React.createElement("path", {
474
- id: "Path_179",
475
- "data-name": "Path 179",
476
- className: "cls-3",
477
- d: "M-703.744 1960.376v-6.259h-2.5v3.755H-710v2.5z",
478
- transform: "translate(723.744 -1940.376)"
479
- }))));
480
- };
481
-
482
- var css_248z = ".extraTools {\n width: 100%;\n display: inline-flex;\n justify-content: flex-end;\n align-items: center;\n gap: 1rem;\n padding: 0px 20px;\n padding-top: 12px; }\n .extraTools__share button {\n display: flex;\n justify-content: center;\n align-items: center; }\n .extraTools__download {\n cursor: pointer; }\n .extraTools__download-icon {\n display: flex;\n justify-content: center;\n align-items: center; }\n .extraTools__fullscreenBtn {\n cursor: pointer;\n padding-top: 0; }\n .extraTools__fullscreenBtn-icon {\n display: flex;\n justify-content: center;\n align-items: center; }\n .extraTools__fontsize {\n display: flex;\n justify-content: center;\n align-items: center; }\n .extraTools .font-size-changer,\n .extraTools .font-size-changer-buttons,\n .extraTools .font-size-up,\n .extraTools .font-size-down,\n .extraTools .tooltip {\n display: flex;\n justify-content: center;\n align-items: center; }\n .extraTools .font-size-up {\n width: 32px !important;\n cursor: pointer;\n margin-right: 16px !important; }\n .extraTools .font-size-down {\n cursor: pointer;\n width: 32px !important; }\n .extraTools .fullscreenExit {\n text-align: right;\n cursor: pointer;\n border: 0; }\n .extraTools #download-menu .MuiMenuItem-root {\n color: #4e3a16;\n width: auto;\n overflow: hidden;\n font-size: 1rem;\n box-sizing: border-box;\n min-height: 48px;\n font-weight: 400;\n line-height: 1;\n padding-top: 1rem;\n white-space: initial;\n border-bottom: 0;\n letter-spacing: 0.00938em;\n padding-bottom: 1rem; }\n";
483
- styleInject(css_248z);
484
-
485
- /* eslint-disable prefer-destructuring */
486
- const ShareButton = _ref => {
487
- let {
488
- className
489
- } = _ref;
490
- return /*#__PURE__*/React__default.createElement("div", {
491
- className: classNames('extraTools__share', className)
492
- }, /*#__PURE__*/React__default.createElement(FacebookShareButton, {
493
- url: document.location.href
494
- }, /*#__PURE__*/React__default.createElement(FacebookIcon, {
495
- size: 32,
496
- round: true
497
- })));
498
- };
499
- ShareButton.defaultProps = {
500
- className: undefined
501
- };
502
-
503
- /* Write props detail information and 'npm run updateStory' will help you generate stories's argTypes */
504
- ShareButton.propTypes = {
505
- /** Css Name */
506
- className: PropTypes.string
507
- };
508
- const DownloadMenu = _ref2 => {
509
- let {
510
- className,
511
- intl,
512
- exclude,
513
- iconColor,
514
- data,
515
- dataType,
516
- domToImageId,
517
- DownloadExcel
518
- } = _ref2;
519
- const [anchorEl, setAnchorEl] = useState(null);
520
- const hideButton = type => (exclude || []).filter(key => key === type).length > 0;
521
- const btns = [{
522
- key: 'downloadImage',
523
- onClick: () => domToImage({
524
- id: domToImageId
525
- }),
526
- label: intl ? 'knowledge.writersAndWorksSNA.download.img' : '下載圖片'
527
- }, {
528
- key: 'downloadGephi',
529
- onClick: () => downloadGephi(data),
530
- label: intl ? 'knowledge.writersAndWorksSNA.download.gephi' : '下載Gephi'
531
- }, {
532
- key: 'downloadTsv',
533
- onClick: () => exportXlsx({
534
- data,
535
- dataType,
536
- extType: 'tsv'
537
- }),
538
- label: intl ? 'knowledge.writersAndWorksSNA.download.tsv' : '下載Tsv'
539
- }, {
540
- key: 'downloadXls',
541
- // download click trigger 交給 react-data-export
542
- label: intl ? 'knowledge.writersAndWorksSNA.download.xls' : '下載Excel'
543
- }];
544
- // eslint-disable-next-line no-confusing-arrow
545
- const isXlsxButton = (key, dom) => key === 'downloadXls' && DownloadExcel ? /*#__PURE__*/React__default.createElement(DownloadExcel, {
546
- key: key,
547
- element: dom,
548
- data: data
549
- }) : dom;
550
- return /*#__PURE__*/React__default.createElement("div", {
551
- className: classNames('extraTools__download', className)
552
- }, /*#__PURE__*/React__default.createElement(Tooltip, {
553
- title: intl ? intl.formatMessage({
554
- id: 'knowledge.writersAndWorksSNA.download'
555
- }) : '下載',
556
- placement: "bottom"
557
- }, /*#__PURE__*/React__default.createElement("div", {
558
- className: "extraTools__download-icon",
559
- onClick: e => setAnchorEl(e.currentTarget)
560
- }, /*#__PURE__*/React__default.createElement(DownloadImg, {
561
- fill: iconColor
562
- }))), /*#__PURE__*/React__default.createElement(Menu, {
563
- id: "download-menu",
564
- anchorEl: anchorEl,
565
- keepMounted: true,
566
- open: Boolean(anchorEl),
567
- onClose: () => setAnchorEl(null)
568
- }, btns.map(_ref3 => {
569
- let {
570
- key,
571
- onClick,
572
- label
573
- } = _ref3;
574
- return !hideButton(key) && isXlsxButton(key, /*#__PURE__*/React__default.createElement(MenuItem, {
575
- key: key,
576
- onClick: onClick
577
- }, intl ? intl.formatMessage({
578
- id: label
579
- }) : label));
580
- })));
581
- };
582
- DownloadMenu.defaultProps = {
583
- className: undefined,
584
- intl: undefined,
585
- exclude: undefined,
586
- data: null,
587
- dataType: undefined,
588
- iconColor: '#825c0d',
589
- domToImageId: 'network-graph',
590
- DownloadExcel: undefined
591
- };
592
-
593
- /* Write props detail information and 'npm run updateStory' will help you generate stories's argTypes */
594
- DownloadMenu.propTypes = {
595
- /** Css Name */
596
- className: PropTypes.string,
597
- /** 語言 */
598
- intl: PropTypes.objectOf(PropTypes.any),
599
- /** 不顯示的按鈕 [ 'downloadImage', 'downloadTsv', 'downloadXls'] */
600
- exclude: PropTypes.arrayOf(PropTypes.string),
601
- /** 資料 */
602
- data: PropTypes.oneOfType([PropTypes.array, PropTypes.object]),
603
- /** 如果有下載xlsx文件, 需要提供type輸出使用 */
604
- dataType: PropTypes.string,
605
- /** icon顏色 */
606
- iconColor: PropTypes.string,
607
- /** 指定dom轉換畫布的DOM ID */
608
- domToImageId: PropTypes.string,
609
- /** Download元件, 由外部傳入的原因是需要環境設定 */
610
- DownloadExcel: PropTypes.oneOfType([PropTypes.node, PropTypes.func])
611
- };
612
- const FullscreenBtn = _ref4 => {
613
- let {
614
- className,
615
- intl,
616
- iconColor,
617
- fullscreenDomId
618
- } = _ref4;
619
- return /*#__PURE__*/React__default.createElement("div", {
620
- className: classNames('extraTools__fullscreenBtn', className)
621
- }, /*#__PURE__*/React__default.createElement(Tooltip, {
622
- title: intl ? intl.formatMessage({
623
- id: 'knowledge.writersAndWorksSNA.fullscreen'
624
- }) : '全螢幕模式',
625
- placement: "bottom"
626
- }, /*#__PURE__*/React__default.createElement("div", {
627
- className: "extraTools__fullscreenBtn-icon",
628
- onClick: () => {
629
- if (screenfull.isEnabled && fullscreenDomId) screenfull.request(document.getElementById(fullscreenDomId));
630
- }
631
- }, /*#__PURE__*/React__default.createElement(SVGComponent, {
632
- fill: iconColor
633
- }))));
634
- };
635
- FullscreenBtn.defaultProps = {
636
- className: undefined,
637
- intl: undefined,
638
- iconColor: '#825c0d',
639
- fullscreenDomId: undefined
640
- };
641
-
642
- /* Write props detail information and 'npm run updateStory' will help you generate stories's argTypes */
643
- FullscreenBtn.propTypes = {
644
- /** Css Name */
645
- className: PropTypes.string,
646
- /** 語言 */
647
- intl: PropTypes.objectOf(PropTypes.any),
648
- /** icon顏色 */
649
- iconColor: PropTypes.string,
650
- /** 全螢幕指定DOM */
651
- fullscreenDomId: PropTypes.string
652
- };
653
- const FontSizeChanger = _ref5 => {
654
- let {
655
- className,
656
- intl,
657
- iconColor,
658
- FontSizeTargets,
659
- FontSizeOptions
660
- } = _ref5;
661
- return /*#__PURE__*/React__default.createElement("div", {
662
- className: classNames('extraTools__fontsize', className)
663
- }, /*#__PURE__*/React__default.createElement(FontSize, {
664
- targets: FontSizeTargets,
665
- options: FontSizeOptions,
666
- customButtons: {
667
- up: /*#__PURE__*/React__default.createElement(Tooltip, {
668
- title: intl ? intl.formatMessage({
669
- id: 'knowledge.writersAndWorksSNA.big'
670
- }) : '字級放大',
671
- placement: "bottom"
672
- }, /*#__PURE__*/React__default.createElement(SVGComponent$2, {
673
- fill: iconColor
674
- })),
675
- down: /*#__PURE__*/React__default.createElement(Tooltip, {
676
- title: intl ? intl.formatMessage({
677
- id: 'knowledge.writersAndWorksSNA.small'
678
- }) : '字級縮小',
679
- placement: "bottom"
680
- }, /*#__PURE__*/React__default.createElement(SVGComponent$1, {
681
- fill: iconColor
682
- })),
683
- style: {
684
- border: 'none'
685
- },
686
- buttonsMargin: 10
687
- }
688
- }));
689
- };
690
- FontSizeChanger.defaultProps = {
691
- className: undefined,
692
- intl: undefined,
693
- iconColor: '#825c0d',
694
- FontSizeTargets: ['#network-graph svg g text'],
695
- FontSizeOptions: {
696
- stepSize: 2,
697
- range: 1
698
- }
699
- };
700
-
701
- /* Write props detail information and 'npm run updateStory' will help you generate stories's argTypes */
702
- FontSizeChanger.propTypes = {
703
- /** Css Name */
704
- className: PropTypes.string,
705
- /** 語言 */
706
- intl: PropTypes.objectOf(PropTypes.any),
707
- /** icon顏色 */
708
- iconColor: PropTypes.string,
709
- /** 改變文字的目標DOM['css selector']) */
710
- FontSizeTargets: PropTypes.arrayOf(PropTypes.string),
711
- /** 改變文字的選項 */
712
- FontSizeOptions: PropTypes.objectOf(PropTypes.any)
713
- };
714
-
715
- var ExtraTools = function ExtraTools(_ref) {
716
- var className = _ref.className,
717
- intl = _ref.intl,
718
- exclude = _ref.exclude,
719
- data = _ref.data,
720
- dataType = _ref.dataType,
721
- iconColor = _ref.iconColor,
722
- domToImageId = _ref.domToImageId,
723
- FontSizeTargets = _ref.FontSizeTargets,
724
- FontSizeOptions = _ref.FontSizeOptions,
725
- DownloadExcel = _ref.DownloadExcel,
726
- fullscreenDomId = _ref.fullscreenDomId;
727
- var hideButton = function hideButton(keys) {
728
- return (exclude || []).filter(function (key) {
729
- return keys.some(function (item) {
730
- return item === key;
731
- });
732
- }).length === keys.length;
733
- };
734
- var BtnsProps = {
735
- intl: intl,
736
- exclude: exclude,
737
- data: data,
738
- dataType: dataType,
739
- iconColor: iconColor,
740
- domToImageId: domToImageId,
741
- FontSizeTargets: FontSizeTargets,
742
- FontSizeOptions: FontSizeOptions,
743
- DownloadExcel: DownloadExcel,
744
- fullscreenDomId: fullscreenDomId
745
- };
746
- var tools = [{
747
- keys: ['share'],
748
- Component: ShareButton
749
- }, {
750
- keys: ['downloadImage', 'downloadGephi', 'downloadTsv', 'downloadXls'],
751
- Component: DownloadMenu
752
- }, {
753
- keys: ['fullscreen'],
754
- Component: FullscreenBtn
755
- }, {
756
- keys: ['fontSizeChanger'],
757
- Component: FontSizeChanger
758
- }];
759
- return /*#__PURE__*/React__default.createElement("div", {
760
- className: classNames('extraTools', className)
761
- }, tools.map(function (_ref2) {
762
- var keys = _ref2.keys,
763
- Component = _ref2.Component;
764
- return !hideButton(keys) && /*#__PURE__*/React__default.createElement(Component, _extends({
765
- key: keys[0]
766
- }, BtnsProps));
767
- }));
768
- };
769
-
770
- /* 提供外部引用子元件, 子元件各自享獨立運作功能 */
771
- ExtraTools.ShareButton = ShareButton;
772
- ExtraTools.DownloadMenu = DownloadMenu;
773
- ExtraTools.FullscreenBtn = FullscreenBtn;
774
- ExtraTools.FontSizeChanger = FontSizeChanger;
775
- ExtraTools.defaultProps = {
776
- className: undefined,
777
- intl: undefined,
778
- exclude: ['downloadGephi'],
779
- data: null,
780
- dataType: undefined,
781
- iconColor: '#825c0d',
782
- domToImageId: 'network-graph',
783
- FontSizeTargets: ['#network-graph svg g text'],
784
- FontSizeOptions: {
785
- stepSize: 2,
786
- range: 1
787
- },
788
- DownloadExcel: undefined,
789
- fullscreenDomId: undefined
790
- };
791
-
792
- /* Write props detail information and 'npm run updateStory' will help you generate stories's argTypes */
793
- ExtraTools.propTypes = {
794
- /** Css Name */
795
- className: PropTypes.string,
796
- /** 語言 */
797
- intl: PropTypes.objectOf(PropTypes.any),
798
- /** 不顯示的按鈕 ['share', 'downloadImage', 'downloadTsv', 'downloadXls', 'fullscreen', 'fontSizeChanger'] */
799
- exclude: PropTypes.arrayOf(PropTypes.string),
800
- /** 資料 */
801
- data: PropTypes.oneOfType([PropTypes.array, PropTypes.object]),
802
- /** 如果有下載xlsx文件, 需要提供type輸出使用 */
803
- dataType: PropTypes.string,
804
- /** icon顏色 */
805
- iconColor: PropTypes.string,
806
- /** 指定dom轉換畫布的DOM ID */
807
- domToImageId: PropTypes.string,
808
- /** 改變文字的目標DOM['css selector']) */
809
- FontSizeTargets: PropTypes.arrayOf(PropTypes.string),
810
- /** 改變文字的選項 */
811
- FontSizeOptions: PropTypes.objectOf(PropTypes.any),
812
- /** Download元件, 由外部傳入的原因是需要環境設定 */
813
- DownloadExcel: PropTypes.oneOfType([PropTypes.node, PropTypes.func]),
814
- /** 全螢幕指定DOM */
815
- fullscreenDomId: PropTypes.string
816
- };
817
-
818
- export { ExtraTools as E };