@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.
Files changed (72) hide show
  1. package/lib/components/Autocomplete-5439ff22.js +333 -1
  2. package/lib/components/Autocomplete.js +12 -1
  3. package/lib/components/Avatar.js +51 -1
  4. package/lib/components/BackTop.js +82 -1
  5. package/lib/components/BarChart.js +132 -1
  6. package/lib/components/Breadcrumbs.js +124 -1
  7. package/lib/components/Button-63c7e9f3.js +91 -1
  8. package/lib/components/Button.js +8 -1
  9. package/lib/components/Carousel.js +61 -1
  10. package/lib/components/Checkbox.js +37 -1
  11. package/lib/components/CollapseContent.js +181 -1
  12. package/lib/components/ContactModal-a59bc808.js +924 -0
  13. package/lib/components/ContactModal.js +17 -1
  14. package/lib/components/Drawer-af3ed21a.js +157 -1
  15. package/lib/components/Drawer.js +13 -1
  16. package/lib/components/Dropdown.js +135 -1
  17. package/lib/components/Empty-70f040a9.js +44 -1
  18. package/lib/components/Empty.js +7 -1
  19. package/lib/components/ExportButton.js +114 -1
  20. package/lib/components/ExtraTools-f10a66a8.js +818 -1
  21. package/lib/components/ExtraTools.js +11 -1
  22. package/lib/components/Filter.js +90 -1
  23. package/lib/components/Footer.js +266 -1
  24. package/lib/components/ForwardLink.js +106 -1
  25. package/lib/components/Header.js +186 -1
  26. package/lib/components/Image.js +58 -1
  27. package/lib/components/Input.js +79 -1
  28. package/lib/components/InputMethod.js +23106 -1
  29. package/lib/components/KeywordSearch-224f84c1.js +138 -1
  30. package/lib/components/KeywordSearch.js +14 -1
  31. package/lib/components/KeywordTicker.js +182 -1
  32. package/lib/components/Keywords.js +292 -1
  33. package/lib/components/Loading.js +30 -1
  34. package/lib/components/MUITheme.js +255 -1
  35. package/lib/components/Modal-a7591b98.js +107 -1
  36. package/lib/components/Modal.js +11 -1
  37. package/lib/components/MoreButton-f15ca38e.js +109 -1
  38. package/lib/components/MoreButton.js +8 -1
  39. package/lib/components/Radio.js +81 -1
  40. package/lib/components/SNA.js +324 -1
  41. package/lib/components/Select-98a8e973.js +114 -1
  42. package/lib/components/Select.js +10 -1
  43. package/lib/components/Spin-690a3597.js +74 -1
  44. package/lib/components/Spin.js +8 -1
  45. package/lib/components/Table.js +51 -1
  46. package/lib/components/Tooltip-b7eb966d.js +69 -1
  47. package/lib/components/Tooltip.js +9 -1
  48. package/lib/components/_rollupPluginBabelHelpers-fde6d1c6.js +491 -1
  49. package/lib/components/dataExport-f418e6fe.js +56 -1
  50. package/lib/components/globalConfig.js +186 -1
  51. package/lib/components/vendor-851c6356.js +41893 -16
  52. package/lib/index.d.ts +1 -3
  53. package/lib/index.js +1 -3
  54. package/lib/utils/_rollupPluginBabelHelpers-a6e0e6e3.js +139 -1
  55. package/lib/utils/arrayMerge.js +100 -1
  56. package/lib/utils/chunkArray.js +15 -1
  57. package/lib/utils/convert2HtmlEntities.js +42 -1
  58. package/lib/utils/domToImage.js +32 -1
  59. package/lib/utils/downloadGephi.js +106 -1
  60. package/lib/utils/exportXlsx.js +184 -1
  61. package/lib/utils/historyAppendSearch.js +23 -1
  62. package/lib/utils/isDevelopMode.js +5 -1
  63. package/lib/utils/parseYMD.js +36 -1
  64. package/lib/utils/removeDuplicateItem.js +11 -1
  65. package/lib/utils/sendEmail.js +39 -1
  66. package/lib/utils/snaDefine-6a2bcd94.js +5 -1
  67. package/lib/utils/snaDefine.js +1 -1
  68. package/lib/utils/snaPreProcess.js +84 -1
  69. package/lib/utils/vendor-3ec75cc9.js +1289 -1
  70. package/package.json +1 -1
  71. package/lib/components/ContactModal-d7e2f8bb.js +0 -1
  72. package/lib/components/globalConfig-40069b54.js +0 -1
@@ -1 +1,818 @@
1
- import{_ as e}from"./_rollupPluginBabelHelpers-fde6d1c6.js";import*as t from"react";import a,{useState as n}from"react";import{q as l,f as o,s as r,c as s,F as i,t as c,u as d,v as m}from"./vendor-851c6356.js";import p from"prop-types";import{Menu as f,MenuItem as u}from"@material-ui/core";import{T as g}from"./Tooltip-b7eb966d.js";import{s as h,a as E}from"./dataExport-f418e6fe.js";const y=require("jszip"),w=require("react-file-download"),T=e=>{const{nodes:t,links:a}=e,n=(a||[]).map((e=>{let{source:a,target:n}=e;return{source:t[a].name,target:t[n].name,sourceType:t[a].type,targetType:t[n].type}})),{nodeMap:l,nodesTsv:o}=(e=>{let t=1e7;const a={};let n=!1;e.forEach((e=>{let{source:l,target:o,sourceType:r,targetType:s}=e;""!==o&&""!==l&&(Object.keys(a).indexOf(l)<0?(""!==r?(n=!0,a[l]={ID:t,WEIGHT:1,NODE_TYPE:r}):a[l]={ID:t,WEIGHT:1},t+=1):a[l].WEIGHT+=1,Object.keys(a).indexOf(o)<0?(""!==s?(n=!0,a[o]={ID:t,WEIGHT:1,NODE_TYPE:s}):a[o]={ID:t,WEIGHT:1},t+=1):a[o].WEIGHT+=1)}));let l=n?"ID\tLABEL\tWEIGHT\tNODE_TYPE\r\n":"ID\tLABEL\tWEIGHT\r\n";return Object.keys(a).forEach((e=>{const t=a[e].ID,o=a[e].WEIGHT,r=n?a[e].NODE_TYPE:"";l+=n?`${t}\t${e}\t${o}\t${r}\r\n`:`${t}\t${e}\t${o}\r\n`})),{nodeMap:a,nodesTsv:l}})(n),r=((e,t)=>{let a="SOURCE\tTARGET\tWEIGHT\tTYPE\r\n";return e.forEach((e=>{let{source:n,target:l}=e;if(""===l||""===n)return;const o=t[n].ID,r=t[l].ID;a+=`${o}\t${r}\t1\tUndirected\r\n`})),a})(n,l),s=new y;s.file("Node_Table.tsv",o),s.file("Edge_Table.tsv",r),s.generateAsync({type:"blob"}).then((e=>{w(e,"Gephi_generated_by_NMTL.zip")}))},v=e=>{let t,{data:a,dataType:n,extType:l="xlsx"}=e;if("sna"===n)t=h(a);else t=a;o(`\ufeff${E(t)}`,`output.${l}`)};v.chronologyConvert=e=>{const t=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"";const[t,a]=e.split('<span class="tooltip">');return{before:t,after:a}};return(e||[]).map((e=>{let{start_date:{day:a,month:n,year:l},display_date:o,text:{headline:r,text:s}}=e;return{"日期":`${l||""}/${n||""}/${a||""}`,"名稱":(o||"").replace("<span>","").replace("</span>",""),"描述":(r||"").replaceAll(/(<([^>]+)>)/gi,""),"類型":t(s).before,"註(資料集名稱)":t(s).after.replaceAll("\n","").replaceAll("\t","").replace("註","").replace("資料來源:","").replaceAll(/(<([^>]+)>)/gi,"")}}))},v.mapConvert=e=>(e||[]).map((e=>{let{title:t,author:a,publisher:n,locations:l,posX:o,posY:r}=e;return{"名稱(書名/文章名)":t||"","作者":a||"","出版者":n||"","地點(作品描述區域)":l||"","經度":o||"","緯度":r||""}})),v.mapLgConvert=e=>(e||[]).map((e=>{let{title:t,locationOfFormation:a,workLocations:n,createPosX:l,createPosY:o,activePosX:r,activePosY:s}=e;return{"組織名稱":t||"","創立地點":a,"創立地點經度":l||"","創立地點緯度":o||"","活動地點":n||"","活動地點經度":r||"","活動地點緯度":s||""}})),v.worksBarChart=e=>(e||[]).map((e=>{let{date:t,year:a,title:n,keywords:l,authors:o,genreName:r}=e;return{"出版年/發表年":t||a||"","名稱(書名/文章名)":n||"","作者":(o||[]).map((e=>{let{author:t}=e;return t})).join(","),"關鍵字":(l||"").replaceAll("\n",""),"文學分類":r||""}})),v.worksSlider=e=>(e||[]).map((e=>{let{title:t,author:a,date:n}=e;return{"名稱(書名/文章名)":t||"","作者":a||"","出版日期/發表日期":n||""}}));const x=e=>{let{fill:t="#825c0d"}=e;return a.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:32,height:32,viewBox:"0 0 32 32"},a.createElement("defs",null,a.createElement("clipPath",{id:"a"},a.createElement("path",{"data-name":"Rectangle 125",style:{fill:"#fff"},d:"M0 0h32v32H0z"}))),a.createElement("g",{style:{clipPath:"url(#a)"}},a.createElement("path",{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",transform:"translate(986 -574)",style:{fill:t},"data-name":"Mask Group 42"})))},_=e=>{let{fill:a="#825c0d"}=e;return t.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:32,height:32,viewBox:"0 0 32 32"},t.createElement("defs",null,t.createElement("clipPath",{id:"clip-path"},t.createElement("path",{id:"Rectangle_128","data-name":"Rectangle 128",style:{fill:"#fff"},d:"M0 0h32v32H0z"})),t.createElement("style",null,`\n .cls-3{fill:${a}}\n `)),t.createElement("g",{id:"Mask_Group_47","data-name":"Mask Group 47",style:{clipPath:"url(#clip-path)"}},t.createElement("g",{id:"Group_3633","data-name":"Group 3633",transform:"translate(6 6)"},t.createElement("path",{id:"Path_181","data-name":"Path 181",className:"cls-3",d:"M514 371v-2h-2v2h-2v2h2v2h2v-2h2v-2z",transform:"translate(-495 -369)"}),t.createElement("g",{id:"Group_3632","data-name":"Group 3632",transform:"translate(0 2)"},t.createElement("path",{id:"Path_182","data-name":"Path 182",className:"cls-3",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",transform:"translate(-496 -371)"})))))},k=e=>{let{fill:a="#825c0d"}=e;return t.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:32,height:32,viewBox:"0 0 32 32"},t.createElement("defs",null,t.createElement("clipPath",{id:"clip-path"},t.createElement("path",{id:"Rectangle_129","data-name":"Rectangle 129",style:{fill:"#fff"},d:"M0 0h32v32H0z"})),t.createElement("style",null,`\n .cls-3{fill:${a}}\n `)),t.createElement("g",{id:"Mask_Group_48","data-name":"Mask Group 48",style:{clipPath:"url(#clip-path)"}},t.createElement("g",{id:"Group_3635","data-name":"Group 3635",transform:"translate(6 8)"},t.createElement("path",{id:"Path_181","data-name":"Path 181",className:"cls-3",d:"M510 371v2h6v-2z",transform:"translate(-495 -371)"}),t.createElement("g",{id:"Group_3632","data-name":"Group 3632"},t.createElement("path",{id:"Path_182","data-name":"Path 182",className:"cls-3",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",transform:"translate(-496 -371)"})))))},b=e=>{let{fill:a="#825c0d"}=e;return t.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:32,height:32,viewBox:"0 0 32 32"},t.createElement("defs",null,t.createElement("clipPath",{id:"clip-path"},t.createElement("path",{id:"Rectangle_124","data-name":"Rectangle 124",style:{fill:"#fff"},d:"M0 0h32v32H0z"})),t.createElement("style",null,`\n .cls-3{fill:${a}}\n `)),t.createElement("g",{id:"Mask_Group_46","data-name":"Mask Group 46",style:{clipPath:"url(#clip-path)"}},t.createElement("g",{id:"Group_3629","data-name":"Group 3629",transform:"translate(6 6.001)"},t.createElement("path",{id:"Path_176","data-name":"Path 176",className:"cls-3",d:"M-721 1949.376h2.5v-3.755h3.755v-2.5H-721z",transform:"translate(721.003 -1943.118)"}),t.createElement("path",{id:"Path_177","data-name":"Path 177",className:"cls-3",d:"M-721 1960.376h6.258v-2.5h-3.758v-3.755h-2.5z",transform:"translate(721.003 -1940.376)"}),t.createElement("path",{id:"Path_178","data-name":"Path 178",className:"cls-3",d:"M-703.744 1943.118H-710v2.5h3.755v3.755h2.5z",transform:"translate(723.744 -1943.118)"}),t.createElement("path",{id:"Path_179","data-name":"Path 179",className:"cls-3",d:"M-703.744 1960.376v-6.259h-2.5v3.755H-710v2.5z",transform:"translate(723.744 -1940.376)"}))))};r(".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");const z=e=>{let{className:t}=e;return a.createElement("div",{className:s("extraTools__share",t)},a.createElement(i,{url:document.location.href},a.createElement(c,{size:32,round:!0})))};z.defaultProps={className:void 0},z.propTypes={className:p.string};const I=e=>{let{className:t,intl:o,exclude:r,iconColor:i,data:c,dataType:d,domToImageId:m,DownloadExcel:p}=e;const[h,E]=n(null),y=[{key:"downloadImage",onClick:()=>(e=>{let{id:t,fileName:a="image",quality:n=.95}=e;const o=document.getElementById(t),r=document.getElementById("yaxis"),s=document.getElementById("barChart__block");r&&r.setAttribute("transform","translate(0, 0 )"),l.toPng(o,{quality:n}).then((e=>{const t=document.createElement("a");t.download=`${a}.png`,t.href=e,t.click(),r&&s&&(r.setAttribute("transform","translate(0, 0 )"),r.setAttribute("transform",`translate(${s.scrollLeft}, 0)`))})).catch((e=>{console.error("oops, something went wrong!",e)}))})({id:m}),label:o?"knowledge.writersAndWorksSNA.download.img":"下載圖片"},{key:"downloadGephi",onClick:()=>T(c),label:o?"knowledge.writersAndWorksSNA.download.gephi":"下載Gephi"},{key:"downloadTsv",onClick:()=>v({data:c,dataType:d,extType:"tsv"}),label:o?"knowledge.writersAndWorksSNA.download.tsv":"下載Tsv"},{key:"downloadXls",label:o?"knowledge.writersAndWorksSNA.download.xls":"下載Excel"}];return a.createElement("div",{className:s("extraTools__download",t)},a.createElement(g,{title:o?o.formatMessage({id:"knowledge.writersAndWorksSNA.download"}):"下載",placement:"bottom"},a.createElement("div",{className:"extraTools__download-icon",onClick:e=>E(e.currentTarget)},a.createElement(x,{fill:i}))),a.createElement(f,{id:"download-menu",anchorEl:h,keepMounted:!0,open:Boolean(h),onClose:()=>E(null)},y.map((e=>{let{key:t,onClick:n,label:l}=e;return s=t,!((r||[]).filter((e=>e===s)).length>0)&&((e,t)=>"downloadXls"===e&&p?a.createElement(p,{key:e,element:t,data:c}):t)(t,a.createElement(u,{key:t,onClick:n},o?o.formatMessage({id:l}):l));var s}))))};I.defaultProps={className:void 0,intl:void 0,exclude:void 0,data:null,dataType:void 0,iconColor:"#825c0d",domToImageId:"network-graph",DownloadExcel:void 0},I.propTypes={className:p.string,intl:p.objectOf(p.any),exclude:p.arrayOf(p.string),data:p.oneOfType([p.array,p.object]),dataType:p.string,iconColor:p.string,domToImageId:p.string,DownloadExcel:p.oneOfType([p.node,p.func])};const N=e=>{let{className:t,intl:n,iconColor:l,fullscreenDomId:o}=e;return a.createElement("div",{className:s("extraTools__fullscreenBtn",t)},a.createElement(g,{title:n?n.formatMessage({id:"knowledge.writersAndWorksSNA.fullscreen"}):"全螢幕模式",placement:"bottom"},a.createElement("div",{className:"extraTools__fullscreenBtn-icon",onClick:()=>{d.isEnabled&&o&&d.request(document.getElementById(o))}},a.createElement(b,{fill:l}))))};N.defaultProps={className:void 0,intl:void 0,iconColor:"#825c0d",fullscreenDomId:void 0},N.propTypes={className:p.string,intl:p.objectOf(p.any),iconColor:p.string,fullscreenDomId:p.string};const P=e=>{let{className:t,intl:n,iconColor:l,FontSizeTargets:o,FontSizeOptions:r}=e;return a.createElement("div",{className:s("extraTools__fontsize",t)},a.createElement(m,{targets:o,options:r,customButtons:{up:a.createElement(g,{title:n?n.formatMessage({id:"knowledge.writersAndWorksSNA.big"}):"字級放大",placement:"bottom"},a.createElement(_,{fill:l})),down:a.createElement(g,{title:n?n.formatMessage({id:"knowledge.writersAndWorksSNA.small"}):"字級縮小",placement:"bottom"},a.createElement(k,{fill:l})),style:{border:"none"},buttonsMargin:10}}))};P.defaultProps={className:void 0,intl:void 0,iconColor:"#825c0d",FontSizeTargets:["#network-graph svg g text"],FontSizeOptions:{stepSize:2,range:1}},P.propTypes={className:p.string,intl:p.objectOf(p.any),iconColor:p.string,FontSizeTargets:p.arrayOf(p.string),FontSizeOptions:p.objectOf(p.any)};var C=function(t){var n=t.className,l=t.intl,o=t.exclude,r=t.data,i=t.dataType,c=t.iconColor,d=t.domToImageId,m=t.FontSizeTargets,p=t.FontSizeOptions,f=t.DownloadExcel,u=t.fullscreenDomId,g={intl:l,exclude:o,data:r,dataType:i,iconColor:c,domToImageId:d,FontSizeTargets:m,FontSizeOptions:p,DownloadExcel:f,fullscreenDomId:u},h=[{keys:["share"],Component:z},{keys:["downloadImage","downloadGephi","downloadTsv","downloadXls"],Component:I},{keys:["fullscreen"],Component:N},{keys:["fontSizeChanger"],Component:P}];return a.createElement("div",{className:s("extraTools",n)},h.map((function(t){var n=t.keys,l=t.Component;return!function(e){return(o||[]).filter((function(t){return e.some((function(e){return e===t}))})).length===e.length}(n)&&a.createElement(l,e({key:n[0]},g))})))};C.ShareButton=z,C.DownloadMenu=I,C.FullscreenBtn=N,C.FontSizeChanger=P,C.defaultProps={className:void 0,intl:void 0,exclude:["downloadGephi"],data:null,dataType:void 0,iconColor:"#825c0d",domToImageId:"network-graph",FontSizeTargets:["#network-graph svg g text"],FontSizeOptions:{stepSize:2,range:1},DownloadExcel:void 0,fullscreenDomId:void 0},C.propTypes={className:p.string,intl:p.objectOf(p.any),exclude:p.arrayOf(p.string),data:p.oneOfType([p.array,p.object]),dataType:p.string,iconColor:p.string,domToImageId:p.string,FontSizeTargets:p.arrayOf(p.string),FontSizeOptions:p.objectOf(p.any),DownloadExcel:p.oneOfType([p.node,p.func]),fullscreenDomId:p.string};export{C as E};
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 };