@daoyi/nmtl-ui 2.0.1-beta.116 → 2.0.1-beta.118
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/Avatar.js +8 -2
- package/lib/components/BarChart.js +4 -2
- package/lib/components/{ContactModal-7f35b424.js → ContactModal-c3d96d09.js} +1 -1
- package/lib/components/ContactModal.js +2 -2
- package/lib/components/{Drawer-43937e1c.js → Drawer-c04df870.js} +13 -6
- package/lib/components/Drawer.js +2 -2
- package/lib/components/ExportButton.js +1 -1
- package/lib/components/{ExtraTools-55f66039.js → ExtraTools-0f9ca8be.js} +31 -12
- package/lib/components/ExtraTools.js +2 -2
- package/lib/components/Footer.js +2 -2
- package/lib/components/Header.js +14 -6
- package/lib/components/SNA.js +17 -9
- package/lib/components/{Select-52ab5299.js → Select-141d7992.js} +8 -0
- package/lib/components/Select.js +1 -1
- package/lib/components/{dataExport-d55d6fa3.js → dataExport-a9e3fae1.js} +10 -11
- package/lib/components/globalConfig.js +3 -0
- package/lib/utils/exportXlsx.js +29 -13
- package/package.json +1 -1
package/lib/components/Avatar.js
CHANGED
|
@@ -11,19 +11,22 @@ var Avatar = function Avatar(_ref) {
|
|
|
11
11
|
var className = _ref.className,
|
|
12
12
|
shape = _ref.shape,
|
|
13
13
|
src = _ref.src,
|
|
14
|
+
alt = _ref.alt,
|
|
14
15
|
_onError = _ref.onError,
|
|
15
16
|
_ref$defaultImg = _ref.defaultImg,
|
|
16
17
|
defaultImg = _ref$defaultImg === void 0 ? '' : _ref$defaultImg;
|
|
17
18
|
return /*#__PURE__*/React__default.createElement(React__default.Fragment, null, /*#__PURE__*/React__default.createElement(Avatar$1, {
|
|
18
19
|
className: classNames('avatar', className),
|
|
19
20
|
variant: shape,
|
|
20
|
-
src: src
|
|
21
|
+
src: src,
|
|
22
|
+
alt: alt
|
|
21
23
|
}, defaultImg), typeof _onError === 'function' && /*#__PURE__*/React__default.createElement("img", {
|
|
22
24
|
src: src,
|
|
23
25
|
onError: function onError() {
|
|
24
26
|
return _onError();
|
|
25
27
|
},
|
|
26
|
-
alt: "
|
|
28
|
+
alt: "",
|
|
29
|
+
"aria-hidden": true,
|
|
27
30
|
style: {
|
|
28
31
|
display: 'none'
|
|
29
32
|
}
|
|
@@ -33,6 +36,7 @@ Avatar.defaultProps = {
|
|
|
33
36
|
className: undefined,
|
|
34
37
|
shape: 'circular',
|
|
35
38
|
src: undefined,
|
|
39
|
+
alt: undefined,
|
|
36
40
|
onError: undefined,
|
|
37
41
|
defaultImg: undefined
|
|
38
42
|
};
|
|
@@ -45,6 +49,8 @@ Avatar.propTypes = {
|
|
|
45
49
|
shape: PropTypes.oneOf(['circle', 'circular', 'rounded', 'square']),
|
|
46
50
|
/** 圖片來源 */
|
|
47
51
|
src: PropTypes.string,
|
|
52
|
+
/** 圖片文字替代(WCAG 1.1.1);裝飾或與相鄰文字重複時傳空字串 */
|
|
53
|
+
alt: PropTypes.string,
|
|
48
54
|
/** 圖片有錯誤則callback */
|
|
49
55
|
onError: PropTypes.func,
|
|
50
56
|
defaultImg: PropTypes.string
|
|
@@ -672,7 +672,8 @@ var BarChart = function BarChart(_ref) {
|
|
|
672
672
|
var x = band().range([0, width]).domain(data.map(function (d) {
|
|
673
673
|
return d.year;
|
|
674
674
|
})).padding(0.2);
|
|
675
|
-
svg.append('g').attr('id', 'xaxis').attr('transform', "translate(0,".concat(height, ")")).call(axisBottom(x)).style('color', fontColor).selectAll('text').attr('transform', 'translate(-10,0)rotate(-45)').style('text-anchor', 'end').style('color', fontColor)
|
|
675
|
+
svg.append('g').attr('id', 'xaxis').attr('transform', "translate(0,".concat(height, ")")).call(axisBottom(x)).style('color', fontColor).selectAll('text').attr('transform', 'translate(-10,0)rotate(-45)').style('text-anchor', 'end').style('color', fontColor)
|
|
676
|
+
/* WCAG 1.4.4 / Freego CS2140401C:D3 inline font-size 改相對單位(16→1rem) */.style('font-size', '1rem').style('cursor', 'pointer').on('click', function (d) {
|
|
676
677
|
setSelectedYear(d);
|
|
677
678
|
});
|
|
678
679
|
|
|
@@ -707,7 +708,8 @@ var BarChart = function BarChart(_ref) {
|
|
|
707
708
|
});
|
|
708
709
|
svg.append('g').call(axisLeft(y).tickValues(sequence(y.domain()[0], y.domain()[1] + 1, scaleTicks)).tickFormat(function (d) {
|
|
709
710
|
return Math.round(d);
|
|
710
|
-
})).attr('id', 'yaxis').style('color', fontColor)
|
|
711
|
+
})).attr('id', 'yaxis').style('color', fontColor)
|
|
712
|
+
/* WCAG 1.4.4 / Freego CS2140401C:D3 inline font-size 改相對單位(15→0.9375rem) */.style('font-size', '0.9375rem');
|
|
711
713
|
};
|
|
712
714
|
function shiftYaxis() {
|
|
713
715
|
var element = document.getElementById('barChart__block');
|
|
@@ -12,7 +12,7 @@ import 'react-is';
|
|
|
12
12
|
import '@material-ui/styles';
|
|
13
13
|
import { u as useTheme } from './useTheme-d16d02d9.js';
|
|
14
14
|
import './withTheme-2d778133.js';
|
|
15
|
-
import { S as Select } from './Select-
|
|
15
|
+
import { S as Select } from './Select-141d7992.js';
|
|
16
16
|
import { VolumeUp } from '@material-ui/icons';
|
|
17
17
|
import { getIntl } from './globalConfig';
|
|
18
18
|
import { s as styleInject } from './style-inject.es-1f59c1d0.js';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { C as default } from './ContactModal-
|
|
1
|
+
export { C as default } from './ContactModal-c3d96d09.js';
|
|
2
2
|
import './_rollupPluginBabelHelpers-a52356f6.js';
|
|
3
3
|
import 'react';
|
|
4
4
|
import 'prop-types';
|
|
@@ -18,7 +18,7 @@ import './defaultTheme-ed7746fe.js';
|
|
|
18
18
|
import '@material-ui/styles';
|
|
19
19
|
import './useTheme-d16d02d9.js';
|
|
20
20
|
import './withTheme-2d778133.js';
|
|
21
|
-
import './Select-
|
|
21
|
+
import './Select-141d7992.js';
|
|
22
22
|
import './Empty-c6a44967.js';
|
|
23
23
|
import './createSvgIcon-e3803ee1.js';
|
|
24
24
|
import 'react-dom';
|
|
@@ -3,7 +3,7 @@ import React__default, { useState } from 'react';
|
|
|
3
3
|
import PropTypes from 'prop-types';
|
|
4
4
|
import { List, ListItem, ListItemIcon, ListItemText, IconButton, Drawer as Drawer$1, Divider } from '@material-ui/core';
|
|
5
5
|
import { DehazeRounded } from '@material-ui/icons';
|
|
6
|
-
import { S as Select } from './Select-
|
|
6
|
+
import { S as Select } from './Select-141d7992.js';
|
|
7
7
|
import { useHistory, useRouteMatch } from 'react-router-dom';
|
|
8
8
|
import { getIntl } from './globalConfig';
|
|
9
9
|
import { s as styleInject } from './style-inject.es-1f59c1d0.js';
|
|
@@ -82,7 +82,8 @@ var Drawer = function Drawer(_ref) {
|
|
|
82
82
|
locale = _ref.locale,
|
|
83
83
|
supportLanguages = _ref.supportLanguages,
|
|
84
84
|
drawerList = _ref.drawerList,
|
|
85
|
-
onLanguageChange = _ref.onLanguageChange
|
|
85
|
+
onLanguageChange = _ref.onLanguageChange,
|
|
86
|
+
languageSelectLabel = _ref.languageSelectLabel;
|
|
86
87
|
var _useState = useState(false),
|
|
87
88
|
_useState2 = _slicedToArray(_useState, 2),
|
|
88
89
|
open = _useState2[0],
|
|
@@ -108,8 +109,8 @@ var Drawer = function Drawer(_ref) {
|
|
|
108
109
|
onClose: function onClose() {
|
|
109
110
|
return setOpen(false);
|
|
110
111
|
},
|
|
111
|
-
onKeyDown: function onKeyDown() {
|
|
112
|
-
|
|
112
|
+
onKeyDown: function onKeyDown(event) {
|
|
113
|
+
if (event.key === 'Escape') setOpen(false);
|
|
113
114
|
}
|
|
114
115
|
}, (logo || title) && /*#__PURE__*/React__default.createElement("div", {
|
|
115
116
|
className: "drawer__header"
|
|
@@ -125,6 +126,9 @@ var Drawer = function Drawer(_ref) {
|
|
|
125
126
|
setOpen: setOpen
|
|
126
127
|
}), /*#__PURE__*/React__default.createElement(Divider, null), Array.isArray(supportLanguages) && supportLanguages.length > 0 && /*#__PURE__*/React__default.createElement(Select, {
|
|
127
128
|
className: "drawer__lang",
|
|
129
|
+
ariaLabel: languageSelectLabel || getIntl().formatMessage({
|
|
130
|
+
id: 'aria.header.languageSelect'
|
|
131
|
+
}),
|
|
128
132
|
defaultValue: checkLanguageSupport({
|
|
129
133
|
language: locale,
|
|
130
134
|
supportLanguages: supportLanguages
|
|
@@ -149,7 +153,8 @@ Drawer.defaultProps = {
|
|
|
149
153
|
],
|
|
150
154
|
|
|
151
155
|
drawerList: undefined,
|
|
152
|
-
onLanguageChange: function onLanguageChange() {}
|
|
156
|
+
onLanguageChange: function onLanguageChange() {},
|
|
157
|
+
languageSelectLabel: undefined
|
|
153
158
|
};
|
|
154
159
|
Drawer.propTypes = {
|
|
155
160
|
title: PropTypes.string,
|
|
@@ -157,7 +162,9 @@ Drawer.propTypes = {
|
|
|
157
162
|
locale: PropTypes.string,
|
|
158
163
|
supportLanguages: PropTypes.arrayOf(PropTypes.any),
|
|
159
164
|
drawerList: PropTypes.arrayOf(PropTypes.any),
|
|
160
|
-
onLanguageChange: PropTypes.func
|
|
165
|
+
onLanguageChange: PropTypes.func,
|
|
166
|
+
/** 語言下拉的無障礙名稱(WCAG 3.3.2);未提供時使用套件內 aria.header.languageSelect */
|
|
167
|
+
languageSelectLabel: PropTypes.string
|
|
161
168
|
};
|
|
162
169
|
|
|
163
170
|
export { Drawer as D, checkLanguageSupport as c, defaultSupportLanguage as d };
|
package/lib/components/Drawer.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
export { D as default } from './Drawer-
|
|
1
|
+
export { D as default } from './Drawer-c04df870.js';
|
|
2
2
|
import './_rollupPluginBabelHelpers-a52356f6.js';
|
|
3
3
|
import 'react';
|
|
4
4
|
import 'prop-types';
|
|
5
5
|
import '@material-ui/core';
|
|
6
6
|
import '@material-ui/icons';
|
|
7
|
-
import './Select-
|
|
7
|
+
import './Select-141d7992.js';
|
|
8
8
|
import './index-b76a85f4.js';
|
|
9
9
|
import './defaultTheme-ed7746fe.js';
|
|
10
10
|
import 'react-is';
|
|
@@ -4,7 +4,7 @@ import PropTypes from 'prop-types';
|
|
|
4
4
|
import { c as classNames } from './index-b76a85f4.js';
|
|
5
5
|
import { ExitToApp } from '@material-ui/icons';
|
|
6
6
|
import { Dialog, DialogContent, DialogContentText, DialogActions, Button } from '@material-ui/core';
|
|
7
|
-
import { f as fileDownload, j as jsonTxt, a as jsonExcel } from './dataExport-
|
|
7
|
+
import { f as fileDownload, j as jsonTxt, a as jsonExcel } from './dataExport-a9e3fae1.js';
|
|
8
8
|
import { getIntl } from './globalConfig';
|
|
9
9
|
import { s as styleInject } from './style-inject.es-1f59c1d0.js';
|
|
10
10
|
|
|
@@ -6,7 +6,7 @@ import PropTypes from 'prop-types';
|
|
|
6
6
|
import { a as getDefaultExportFromCjs } from './_commonjsHelpers-70de2c37.js';
|
|
7
7
|
import { Menu, MenuItem, useMediaQuery, IconButton } from '@material-ui/core';
|
|
8
8
|
import { T as Tooltip } from './Tooltip-6ebfa9c1.js';
|
|
9
|
-
import { s as snaToExcel, f as fileDownload$1, a as jsonExcel } from './dataExport-
|
|
9
|
+
import { s as snaToExcel, f as fileDownload$1, a as jsonExcel } from './dataExport-a9e3fae1.js';
|
|
10
10
|
import { s as styleInject } from './style-inject.es-1f59c1d0.js';
|
|
11
11
|
|
|
12
12
|
var __assign$3 = (undefined && undefined.__assign) || function () {
|
|
@@ -2872,11 +2872,19 @@ const worksSlider = data => (data || []).map(_ref6 => {
|
|
|
2872
2872
|
};
|
|
2873
2873
|
});
|
|
2874
2874
|
|
|
2875
|
+
/* \u532F\u51FA\u6A94\u540D\u7684\u65E5\u671F\u5F8C\u7DB4\uFF08YYYY-MM-DD\uFF09\uFF0C
|
|
2876
|
+
\u8207 DownloadMenu \u4E0B\u8F09\u5716\u7247\u5171\u7528 */
|
|
2877
|
+
const exportDateSuffix = () => {
|
|
2878
|
+
const now = new Date();
|
|
2879
|
+
const pad = n => String(n).padStart(2, '0');
|
|
2880
|
+
return `${now.getFullYear()}-${pad(now.getMonth() + 1)}-${pad(now.getDate())}`;
|
|
2881
|
+
};
|
|
2875
2882
|
const exportXlsx = _ref => {
|
|
2876
2883
|
let {
|
|
2877
2884
|
data,
|
|
2878
2885
|
dataType,
|
|
2879
|
-
extType = 'xlsx'
|
|
2886
|
+
extType = 'xlsx',
|
|
2887
|
+
fileName = 'output'
|
|
2880
2888
|
} = _ref;
|
|
2881
2889
|
let metadata;
|
|
2882
2890
|
switch (dataType) {
|
|
@@ -2887,7 +2895,7 @@ const exportXlsx = _ref => {
|
|
|
2887
2895
|
metadata = data;
|
|
2888
2896
|
break;
|
|
2889
2897
|
}
|
|
2890
|
-
fileDownload$1(`\uFEFF${jsonExcel(metadata)}`,
|
|
2898
|
+
fileDownload$1(`\uFEFF${jsonExcel(metadata, extType === 'tsv' ? '\t' : ',')}`, `${fileName}_${exportDateSuffix()}.${extType}`);
|
|
2891
2899
|
};
|
|
2892
2900
|
|
|
2893
2901
|
// 供外部使用dataConvert
|
|
@@ -3192,14 +3200,16 @@ const DownloadMenu = _ref2 => {
|
|
|
3192
3200
|
data,
|
|
3193
3201
|
dataType,
|
|
3194
3202
|
domToImageId,
|
|
3195
|
-
DownloadExcel
|
|
3203
|
+
DownloadExcel,
|
|
3204
|
+
exportFileName
|
|
3196
3205
|
} = _ref2;
|
|
3197
3206
|
const [anchorEl, setAnchorEl] = useState(null);
|
|
3198
3207
|
const hideButton = type => (exclude || []).filter(key => key === type).length > 0;
|
|
3199
3208
|
const btns = [{
|
|
3200
3209
|
key: 'downloadImage',
|
|
3201
3210
|
onClick: () => domToImage({
|
|
3202
|
-
id: domToImageId
|
|
3211
|
+
id: domToImageId,
|
|
3212
|
+
fileName: `${exportFileName}_${exportDateSuffix()}`
|
|
3203
3213
|
}),
|
|
3204
3214
|
label: intl ? 'knowledge.writersAndWorksSNA.download.img' : '下載圖片'
|
|
3205
3215
|
}, {
|
|
@@ -3211,7 +3221,8 @@ const DownloadMenu = _ref2 => {
|
|
|
3211
3221
|
onClick: () => exportXlsx({
|
|
3212
3222
|
data,
|
|
3213
3223
|
dataType,
|
|
3214
|
-
extType: 'tsv'
|
|
3224
|
+
extType: 'tsv',
|
|
3225
|
+
fileName: exportFileName
|
|
3215
3226
|
}),
|
|
3216
3227
|
label: intl ? 'knowledge.writersAndWorksSNA.download.tsv' : '下載Tsv'
|
|
3217
3228
|
}, {
|
|
@@ -3279,7 +3290,8 @@ DownloadMenu.defaultProps = {
|
|
|
3279
3290
|
dataType: undefined,
|
|
3280
3291
|
iconColor: '#825c0d',
|
|
3281
3292
|
domToImageId: 'network-graph',
|
|
3282
|
-
DownloadExcel: undefined
|
|
3293
|
+
DownloadExcel: undefined,
|
|
3294
|
+
exportFileName: 'output'
|
|
3283
3295
|
};
|
|
3284
3296
|
|
|
3285
3297
|
/* Write props detail information and 'npm run updateStory' will help you generate stories's argTypes */
|
|
@@ -3299,7 +3311,9 @@ DownloadMenu.propTypes = {
|
|
|
3299
3311
|
/** 指定dom轉換畫布的DOM ID */
|
|
3300
3312
|
domToImageId: PropTypes.string,
|
|
3301
3313
|
/** Download元件, 由外部傳入的原因是需要環境設定 */
|
|
3302
|
-
DownloadExcel: PropTypes.oneOfType([PropTypes.node, PropTypes.func])
|
|
3314
|
+
DownloadExcel: PropTypes.oneOfType([PropTypes.node, PropTypes.func]),
|
|
3315
|
+
/** 匯出檔名前綴(下載圖片/Tsv 檔名=前綴_YYYY-MM-DD) */
|
|
3316
|
+
exportFileName: PropTypes.string
|
|
3303
3317
|
};
|
|
3304
3318
|
const FullscreenBtn = _ref4 => {
|
|
3305
3319
|
let {
|
|
@@ -3514,7 +3528,8 @@ var ExtraTools = function ExtraTools(_ref) {
|
|
|
3514
3528
|
FontSizeOptions = _ref.FontSizeOptions,
|
|
3515
3529
|
DownloadExcel = _ref.DownloadExcel,
|
|
3516
3530
|
fullscreenDomId = _ref.fullscreenDomId,
|
|
3517
|
-
renderSNA = _ref.renderSNA
|
|
3531
|
+
renderSNA = _ref.renderSNA,
|
|
3532
|
+
exportFileName = _ref.exportFileName;
|
|
3518
3533
|
var hideButton = function hideButton(keys) {
|
|
3519
3534
|
return (exclude || []).filter(function (key) {
|
|
3520
3535
|
return keys.some(function (item) {
|
|
@@ -3533,7 +3548,8 @@ var ExtraTools = function ExtraTools(_ref) {
|
|
|
3533
3548
|
FontSizeOptions: FontSizeOptions,
|
|
3534
3549
|
DownloadExcel: DownloadExcel,
|
|
3535
3550
|
fullscreenDomId: fullscreenDomId,
|
|
3536
|
-
renderSNA: renderSNA
|
|
3551
|
+
renderSNA: renderSNA,
|
|
3552
|
+
exportFileName: exportFileName
|
|
3537
3553
|
};
|
|
3538
3554
|
var isIOSMobile = /iPhone|iPad|iPod/i.test(navigator.userAgent);
|
|
3539
3555
|
var tools = [{
|
|
@@ -3585,7 +3601,8 @@ ExtraTools.defaultProps = {
|
|
|
3585
3601
|
},
|
|
3586
3602
|
DownloadExcel: undefined,
|
|
3587
3603
|
fullscreenDomId: undefined,
|
|
3588
|
-
renderSNA: undefined
|
|
3604
|
+
renderSNA: undefined,
|
|
3605
|
+
exportFileName: 'output'
|
|
3589
3606
|
};
|
|
3590
3607
|
|
|
3591
3608
|
/* Write props detail information and 'npm run updateStory' will help you generate stories's argTypes */
|
|
@@ -3613,7 +3630,9 @@ ExtraTools.propTypes = {
|
|
|
3613
3630
|
/** 全螢幕指定DOM */
|
|
3614
3631
|
fullscreenDomId: PropTypes.string,
|
|
3615
3632
|
/** 重設SNA */
|
|
3616
|
-
renderSNA: PropTypes.func
|
|
3633
|
+
renderSNA: PropTypes.func,
|
|
3634
|
+
/** 匯出檔名前綴(下載圖片/Tsv 檔名=前綴_YYYY-MM-DD) */
|
|
3635
|
+
exportFileName: PropTypes.string
|
|
3617
3636
|
};
|
|
3618
3637
|
|
|
3619
3638
|
export { ExtraTools as E };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { E as default } from './ExtraTools-
|
|
1
|
+
export { E as default } from './ExtraTools-0f9ca8be.js';
|
|
2
2
|
import './_rollupPluginBabelHelpers-a52356f6.js';
|
|
3
3
|
import 'react';
|
|
4
4
|
import './index-b76a85f4.js';
|
|
@@ -7,4 +7,4 @@ import './_commonjsHelpers-70de2c37.js';
|
|
|
7
7
|
import '@material-ui/core';
|
|
8
8
|
import './Tooltip-6ebfa9c1.js';
|
|
9
9
|
import './style-inject.es-1f59c1d0.js';
|
|
10
|
-
import './dataExport-
|
|
10
|
+
import './dataExport-a9e3fae1.js';
|
package/lib/components/Footer.js
CHANGED
|
@@ -3,7 +3,7 @@ import React__default, { useState, useEffect } from 'react';
|
|
|
3
3
|
import { c as classNames } from './index-b76a85f4.js';
|
|
4
4
|
import PropTypes from 'prop-types';
|
|
5
5
|
import axios from 'axios';
|
|
6
|
-
import { C as ContactModal } from './ContactModal-
|
|
6
|
+
import { C as ContactModal } from './ContactModal-c3d96d09.js';
|
|
7
7
|
import { S as Spin } from './Spin-8dc60bfe.js';
|
|
8
8
|
import { getIntl } from './globalConfig';
|
|
9
9
|
import { s as styleInject } from './style-inject.es-1f59c1d0.js';
|
|
@@ -18,7 +18,7 @@ import './defaultTheme-ed7746fe.js';
|
|
|
18
18
|
import '@material-ui/styles';
|
|
19
19
|
import './useTheme-d16d02d9.js';
|
|
20
20
|
import './withTheme-2d778133.js';
|
|
21
|
-
import './Select-
|
|
21
|
+
import './Select-141d7992.js';
|
|
22
22
|
import './Empty-c6a44967.js';
|
|
23
23
|
import './createSvgIcon-e3803ee1.js';
|
|
24
24
|
import 'react-dom';
|
package/lib/components/Header.js
CHANGED
|
@@ -7,8 +7,8 @@ import { useHistory, useRouteMatch, NavLink } from 'react-router-dom';
|
|
|
7
7
|
import { Typography, IconButton } from '@material-ui/core';
|
|
8
8
|
import { SearchOutlined } from '@material-ui/icons';
|
|
9
9
|
import { K as KeywordSearch } from './KeywordSearch-d12e1b4f.js';
|
|
10
|
-
import { S as Select } from './Select-
|
|
11
|
-
import { c as checkLanguageSupport, D as Drawer, d as defaultSupportLanguage } from './Drawer-
|
|
10
|
+
import { S as Select } from './Select-141d7992.js';
|
|
11
|
+
import { c as checkLanguageSupport, D as Drawer, d as defaultSupportLanguage } from './Drawer-c04df870.js';
|
|
12
12
|
import { getIntl } from './globalConfig';
|
|
13
13
|
import { s as styleInject } from './style-inject.es-1f59c1d0.js';
|
|
14
14
|
import './isObjectLike-e111475d.js';
|
|
@@ -45,7 +45,8 @@ var Header = function Header(props) {
|
|
|
45
45
|
var onSearch = props.onSearch;
|
|
46
46
|
props.setDarkMode;
|
|
47
47
|
var onLanguageChange = props.onLanguageChange,
|
|
48
|
-
onSearchIconClick = props.onSearchIconClick
|
|
48
|
+
onSearchIconClick = props.onSearchIconClick,
|
|
49
|
+
languageSelectLabel = props.languageSelectLabel;
|
|
49
50
|
var history = useHistory();
|
|
50
51
|
var search = history.location.search;
|
|
51
52
|
var _useRouteMatch = useRouteMatch(),
|
|
@@ -150,6 +151,9 @@ var Header = function Header(props) {
|
|
|
150
151
|
"aria-hidden": "true"
|
|
151
152
|
})), showDarkModeSwitch , Array.isArray(supportLanguages) && supportLanguages.length > 0 && /*#__PURE__*/React__default.createElement(Select, {
|
|
152
153
|
className: "header__language",
|
|
154
|
+
ariaLabel: languageSelectLabel || getIntl().formatMessage({
|
|
155
|
+
id: 'aria.header.languageSelect'
|
|
156
|
+
}),
|
|
153
157
|
defaultValue: checkLanguageSupport({
|
|
154
158
|
language: locale,
|
|
155
159
|
supportLanguages: supportLanguages
|
|
@@ -163,7 +167,8 @@ var Header = function Header(props) {
|
|
|
163
167
|
logo: logo,
|
|
164
168
|
drawerList: pages,
|
|
165
169
|
supportLanguages: supportLanguages,
|
|
166
|
-
onLanguageChange: onLanguageChange
|
|
170
|
+
onLanguageChange: onLanguageChange,
|
|
171
|
+
languageSelectLabel: languageSelectLabel
|
|
167
172
|
}));
|
|
168
173
|
};
|
|
169
174
|
Header.defaultProps = {
|
|
@@ -180,7 +185,8 @@ Header.defaultProps = {
|
|
|
180
185
|
onSearch: function onSearch() {},
|
|
181
186
|
setDarkMode: function setDarkMode() {},
|
|
182
187
|
onLanguageChange: function onLanguageChange() {},
|
|
183
|
-
onSearchIconClick: function onSearchIconClick() {}
|
|
188
|
+
onSearchIconClick: function onSearchIconClick() {},
|
|
189
|
+
languageSelectLabel: undefined
|
|
184
190
|
};
|
|
185
191
|
Header.propTypes = {
|
|
186
192
|
/** Css Name */
|
|
@@ -212,7 +218,9 @@ Header.propTypes = {
|
|
|
212
218
|
/** 語系變動時的callback */
|
|
213
219
|
onLanguageChange: PropTypes.func,
|
|
214
220
|
/** SearchIcon點擊時的callback */
|
|
215
|
-
onSearchIconClick: PropTypes.func
|
|
221
|
+
onSearchIconClick: PropTypes.func,
|
|
222
|
+
/** 語言下拉的無障礙名稱(WCAG 3.3.2);未提供時使用套件內 aria.header.languageSelect */
|
|
223
|
+
languageSelectLabel: PropTypes.string
|
|
216
224
|
};
|
|
217
225
|
|
|
218
226
|
export { Header as default };
|
package/lib/components/SNA.js
CHANGED
|
@@ -2,13 +2,13 @@ import React__default, { useMemo, useEffect } from 'react';
|
|
|
2
2
|
import PropTypes from 'prop-types';
|
|
3
3
|
import { c as classNames } from './index-b76a85f4.js';
|
|
4
4
|
import { e as event, d as d3Select, a as dispatch, c as customEvent, D as DragEvent, q as quadtree, m as map, t as timer, T as Transform, i as identity, b as interrupt, o as ordinal, f as category10 } from './transform-3a04288b.js';
|
|
5
|
-
import { E as ExtraTools } from './ExtraTools-
|
|
5
|
+
import { E as ExtraTools } from './ExtraTools-0f9ca8be.js';
|
|
6
6
|
import { s as styleInject } from './style-inject.es-1f59c1d0.js';
|
|
7
7
|
import './_rollupPluginBabelHelpers-a52356f6.js';
|
|
8
8
|
import './_commonjsHelpers-70de2c37.js';
|
|
9
9
|
import '@material-ui/core';
|
|
10
10
|
import './Tooltip-6ebfa9c1.js';
|
|
11
|
-
import './dataExport-
|
|
11
|
+
import './dataExport-a9e3fae1.js';
|
|
12
12
|
|
|
13
13
|
function sourceEvent() {
|
|
14
14
|
var current = event, source;
|
|
@@ -1408,7 +1408,8 @@ var SNA = function SNA(props) {
|
|
|
1408
1408
|
SNAData = props.SNAData,
|
|
1409
1409
|
handleClickNodeGoto = props.handleClickNodeGoto,
|
|
1410
1410
|
DownloadExcel = props.DownloadExcel,
|
|
1411
|
-
nodeAriaHint = props.nodeAriaHint
|
|
1411
|
+
nodeAriaHint = props.nodeAriaHint,
|
|
1412
|
+
exportFileName = props.exportFileName;
|
|
1412
1413
|
// styles
|
|
1413
1414
|
var width = props.width,
|
|
1414
1415
|
height = props.height,
|
|
@@ -1505,7 +1506,8 @@ var SNA = function SNA(props) {
|
|
|
1505
1506
|
return "M".concat(source.x, ", ").concat(source.y, " Q").concat(qx, " ").concat(qy, " ").concat(target.x, " ").concat(target.y);
|
|
1506
1507
|
};
|
|
1507
1508
|
var init = function init(networkData) {
|
|
1508
|
-
|
|
1509
|
+
/* WCAG 1.4.4 / Freego CS2140401C:SVG 文字字型尺寸改相對單位(10px→0.625rem) */
|
|
1510
|
+
var edgeLabelSize = '0.625rem';
|
|
1509
1511
|
var lineRaduis = 30;
|
|
1510
1512
|
var nodeStroke = 1.5;
|
|
1511
1513
|
var nodeRadius = 10 - nodeStroke;
|
|
@@ -1577,13 +1579,15 @@ var SNA = function SNA(props) {
|
|
|
1577
1579
|
});
|
|
1578
1580
|
var nodeLabel = g.append('g').selectAll('text').data(nodes).join('text').attr('fill', fontColor).attr('text-anchor', 'middle').attr('key', function (d) {
|
|
1579
1581
|
return d.type;
|
|
1580
|
-
}).style('color', '#fff')
|
|
1582
|
+
}).style('color', '#fff')
|
|
1583
|
+
/* WCAG 1.4.4 / Freego CS2140401C:SVG 文字字型尺寸改相對單位(14px→0.875rem) */.style('font-size', '0.875rem').text(function (d) {
|
|
1581
1584
|
return d.name;
|
|
1582
1585
|
});
|
|
1583
1586
|
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) {
|
|
1584
1587
|
return "edgepath".concat(i);
|
|
1585
1588
|
}).style('pointer-events', 'none');
|
|
1586
|
-
var edgelabels = g.selectAll('.edgelabel').data(links).enter().append('text').style('pointer-events', 'none').attr('class', 'edgelabel')
|
|
1589
|
+
var edgelabels = g.selectAll('.edgelabel').data(links).enter().append('text').style('pointer-events', 'none').attr('class', 'edgelabel')
|
|
1590
|
+
/* rem 需以 style 設定(SVG presentation attribute 對 rem 支援不一致) */.style('font-size', edgeLabelSize).attr('fill', '#aaa').attr('visibility', 'visible').attr('key', function (d) {
|
|
1587
1591
|
return d.type;
|
|
1588
1592
|
}).attr('id', function (d, i) {
|
|
1589
1593
|
return "edgelabel".concat(i);
|
|
@@ -1659,7 +1663,8 @@ var SNA = function SNA(props) {
|
|
|
1659
1663
|
exclude: exclude,
|
|
1660
1664
|
DownloadExcel: DownloadExcel,
|
|
1661
1665
|
fullscreenDomId: "sna-graph",
|
|
1662
|
-
renderSNA: renderSNA
|
|
1666
|
+
renderSNA: renderSNA,
|
|
1667
|
+
exportFileName: exportFileName
|
|
1663
1668
|
}), /*#__PURE__*/React__default.createElement("div", {
|
|
1664
1669
|
id: "sna-graph"
|
|
1665
1670
|
}));
|
|
@@ -1677,7 +1682,8 @@ SNA.defaultProps = {
|
|
|
1677
1682
|
iconColor: '#825c0d',
|
|
1678
1683
|
exclude: ['downloadXls', 'downloadTsv'],
|
|
1679
1684
|
handleClickNodeGoto: null,
|
|
1680
|
-
DownloadExcel: undefined
|
|
1685
|
+
DownloadExcel: undefined,
|
|
1686
|
+
exportFileName: 'output'
|
|
1681
1687
|
};
|
|
1682
1688
|
|
|
1683
1689
|
/* Write props detail information and 'npm run updateStory' will help you generate stories's argTypes */
|
|
@@ -1707,7 +1713,9 @@ SNA.propTypes = {
|
|
|
1707
1713
|
/** 按下點後要轉址的功能 */
|
|
1708
1714
|
handleClickNodeGoto: PropTypes.func,
|
|
1709
1715
|
/** Download元件, 由外部傳入的原因是需要環境設定 */
|
|
1710
|
-
DownloadExcel: PropTypes.oneOfType([PropTypes.node, PropTypes.func])
|
|
1716
|
+
DownloadExcel: PropTypes.oneOfType([PropTypes.node, PropTypes.func]),
|
|
1717
|
+
/** 匯出檔名前綴(下載圖片/Tsv 檔名=前綴_YYYY-MM-DD) */
|
|
1718
|
+
exportFileName: PropTypes.string
|
|
1711
1719
|
};
|
|
1712
1720
|
|
|
1713
1721
|
export { SNA as default };
|
|
@@ -63,6 +63,12 @@ var Select = function Select(props) {
|
|
|
63
63
|
renderValue: function renderValue(id) {
|
|
64
64
|
var finder = itemFind(id);
|
|
65
65
|
var content = _typeof(finder) === 'object' ? finder.label : finder;
|
|
66
|
+
/* WCAG 3.1.2 局部語言:選項可帶 lang(如語言選單的「English」),顯示值同步標註 */
|
|
67
|
+
if (_typeof(finder) === 'object' && finder.lang) {
|
|
68
|
+
content = /*#__PURE__*/React__default.createElement("span", {
|
|
69
|
+
lang: finder.lang
|
|
70
|
+
}, content);
|
|
71
|
+
}
|
|
66
72
|
if (!id && id !== 0 || id.length === 0) {
|
|
67
73
|
content = /*#__PURE__*/React__default.createElement("span", {
|
|
68
74
|
className: "select__placeholder",
|
|
@@ -85,9 +91,11 @@ var Select = function Select(props) {
|
|
|
85
91
|
}, Array.isArray(options) && options.length > 0 ? options.map(function (option) {
|
|
86
92
|
var key = _typeof(option) === 'object' ? option.value : option;
|
|
87
93
|
var text = _typeof(option) === 'object' ? option.label : option;
|
|
94
|
+
var optionLang = _typeof(option) === 'object' ? option.lang : undefined;
|
|
88
95
|
return /*#__PURE__*/React__default.createElement(MenuItem, {
|
|
89
96
|
key: key,
|
|
90
97
|
value: key,
|
|
98
|
+
lang: optionLang,
|
|
91
99
|
ListItemClasses: menuItemClass
|
|
92
100
|
}, text);
|
|
93
101
|
}) : /*#__PURE__*/React__default.createElement(Empty, null)));
|
package/lib/components/Select.js
CHANGED
|
@@ -34,24 +34,23 @@ var fileDownload = function(data, filename, mime, bom) {
|
|
|
34
34
|
}
|
|
35
35
|
};
|
|
36
36
|
|
|
37
|
-
|
|
37
|
+
// delimiter 預設逗號(CSV/EXCEL 沿用既有行為);.tsv 需傳 '\t'——
|
|
38
|
+
// tsv 以逗號分隔時,試算表軟體會整列擠進單一儲存格。
|
|
39
|
+
// 值內的 tab/換行以空白取代,避免斷欄斷行
|
|
40
|
+
const jsonExcel = function (json) {
|
|
41
|
+
let delimiter = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : ',';
|
|
42
|
+
const cleanCell = value => String(value == null ? '' : value).replace(/[\t\r\n]+/g, ' ');
|
|
38
43
|
let output = '';
|
|
39
44
|
if (Array.isArray(json) && json.length > 0) {
|
|
40
45
|
const keys = Object.keys(json[0]);
|
|
41
|
-
output += `${keys.
|
|
46
|
+
output += `${keys.map(cleanCell).join(delimiter)}\n`;
|
|
42
47
|
json.forEach(item => {
|
|
43
|
-
keys.
|
|
44
|
-
output += `${item[key]},`;
|
|
45
|
-
});
|
|
46
|
-
output += '\n';
|
|
48
|
+
output += `${keys.map(key => cleanCell(item[key])).join(delimiter)}\n`;
|
|
47
49
|
});
|
|
48
50
|
} else {
|
|
49
51
|
const keys = Object.keys(json);
|
|
50
|
-
output += `${keys.
|
|
51
|
-
keys.
|
|
52
|
-
output += `${json[key]},`;
|
|
53
|
-
});
|
|
54
|
-
output += '\n';
|
|
52
|
+
output += `${keys.map(cleanCell).join(delimiter)}\n`;
|
|
53
|
+
output += `${keys.map(key => cleanCell(json[key])).join(delimiter)}\n`;
|
|
55
54
|
}
|
|
56
55
|
return output;
|
|
57
56
|
};
|
|
@@ -61,6 +61,7 @@ var zhtw = {
|
|
|
61
61
|
"aria.header.logoHome": "回首頁",
|
|
62
62
|
"aria.header.logoHomeWithTitle": "{title},回首頁",
|
|
63
63
|
"aria.header.navigation": "主選單",
|
|
64
|
+
"aria.header.languageSelect": "選擇語言",
|
|
64
65
|
"aria.autocomplete.search": "執行搜尋",
|
|
65
66
|
"aria.modal.close": "關閉視窗",
|
|
66
67
|
"aria.newWindow": "(另開新視窗)",
|
|
@@ -142,6 +143,7 @@ var zhcn = {
|
|
|
142
143
|
"aria.header.logoHome": "回首页",
|
|
143
144
|
"aria.header.logoHomeWithTitle": "{title},回首页",
|
|
144
145
|
"aria.header.navigation": "主选单",
|
|
146
|
+
"aria.header.languageSelect": "选择语言",
|
|
145
147
|
"aria.autocomplete.search": "执行搜寻",
|
|
146
148
|
"aria.modal.close": "关闭视窗",
|
|
147
149
|
"aria.newWindow": "(另开新视窗)",
|
|
@@ -223,6 +225,7 @@ var enus = {
|
|
|
223
225
|
"aria.header.logoHome": "Back to home",
|
|
224
226
|
"aria.header.logoHomeWithTitle": "{title}, back to home",
|
|
225
227
|
"aria.header.navigation": "Main menu",
|
|
228
|
+
"aria.header.languageSelect": "Select language",
|
|
226
229
|
"aria.autocomplete.search": "Search",
|
|
227
230
|
"aria.modal.close": "Close dialog",
|
|
228
231
|
"aria.newWindow": " (opens in new window)",
|
package/lib/utils/exportXlsx.js
CHANGED
|
@@ -36,24 +36,29 @@ var fileDownload = function(data, filename, mime, bom) {
|
|
|
36
36
|
}
|
|
37
37
|
};
|
|
38
38
|
|
|
39
|
+
// delimiter 預設逗號(CSV/EXCEL 沿用既有行為);.tsv 需傳 '\t'——
|
|
40
|
+
// tsv 以逗號分隔時,試算表軟體會整列擠進單一儲存格。
|
|
41
|
+
// 值內的 tab/換行以空白取代,避免斷欄斷行
|
|
39
42
|
var jsonExcel = function jsonExcel(json) {
|
|
43
|
+
var delimiter = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : ',';
|
|
44
|
+
var cleanCell = function cleanCell(value) {
|
|
45
|
+
return String(value == null ? '' : value).replace(/[\t\r\n]+/g, ' ');
|
|
46
|
+
};
|
|
40
47
|
var output = '';
|
|
41
48
|
if (Array.isArray(json) && json.length > 0) {
|
|
42
49
|
var keys = Object.keys(json[0]);
|
|
43
|
-
output += "".concat(keys.
|
|
50
|
+
output += "".concat(keys.map(cleanCell).join(delimiter), "\n");
|
|
44
51
|
json.forEach(function (item) {
|
|
45
|
-
keys.
|
|
46
|
-
|
|
47
|
-
});
|
|
48
|
-
output += '\n';
|
|
52
|
+
output += "".concat(keys.map(function (key) {
|
|
53
|
+
return cleanCell(item[key]);
|
|
54
|
+
}).join(delimiter), "\n");
|
|
49
55
|
});
|
|
50
56
|
} else {
|
|
51
57
|
var _keys = Object.keys(json);
|
|
52
|
-
output += "".concat(_keys.
|
|
53
|
-
_keys.
|
|
54
|
-
|
|
55
|
-
});
|
|
56
|
-
output += '\n';
|
|
58
|
+
output += "".concat(_keys.map(cleanCell).join(delimiter), "\n");
|
|
59
|
+
output += "".concat(_keys.map(function (key) {
|
|
60
|
+
return cleanCell(json[key]);
|
|
61
|
+
}).join(delimiter), "\n");
|
|
57
62
|
}
|
|
58
63
|
return output;
|
|
59
64
|
};
|
|
@@ -192,11 +197,22 @@ var worksSlider = function worksSlider(data) {
|
|
|
192
197
|
});
|
|
193
198
|
};
|
|
194
199
|
|
|
200
|
+
/* \u532F\u51FA\u6A94\u540D\u7684\u65E5\u671F\u5F8C\u7DB4\uFF08YYYY-MM-DD\uFF09\uFF0C
|
|
201
|
+
\u8207 DownloadMenu \u4E0B\u8F09\u5716\u7247\u5171\u7528 */
|
|
202
|
+
var exportDateSuffix = function exportDateSuffix() {
|
|
203
|
+
var now = new Date();
|
|
204
|
+
var pad = function pad(n) {
|
|
205
|
+
return String(n).padStart(2, '0');
|
|
206
|
+
};
|
|
207
|
+
return "".concat(now.getFullYear(), "-").concat(pad(now.getMonth() + 1), "-").concat(pad(now.getDate()));
|
|
208
|
+
};
|
|
195
209
|
var exportXlsx = function exportXlsx(_ref) {
|
|
196
210
|
var data = _ref.data,
|
|
197
211
|
dataType = _ref.dataType,
|
|
198
212
|
_ref$extType = _ref.extType,
|
|
199
|
-
extType = _ref$extType === void 0 ? 'xlsx' : _ref$extType
|
|
213
|
+
extType = _ref$extType === void 0 ? 'xlsx' : _ref$extType,
|
|
214
|
+
_ref$fileName = _ref.fileName,
|
|
215
|
+
fileName = _ref$fileName === void 0 ? 'output' : _ref$fileName;
|
|
200
216
|
var metadata;
|
|
201
217
|
switch (dataType) {
|
|
202
218
|
case 'sna':
|
|
@@ -206,7 +222,7 @@ var exportXlsx = function exportXlsx(_ref) {
|
|
|
206
222
|
metadata = data;
|
|
207
223
|
break;
|
|
208
224
|
}
|
|
209
|
-
fileDownload("\uFEFF".concat(jsonExcel(metadata)), "
|
|
225
|
+
fileDownload("\uFEFF".concat(jsonExcel(metadata, extType === 'tsv' ? '\t' : ',')), "".concat(fileName, "_").concat(exportDateSuffix(), ".").concat(extType));
|
|
210
226
|
};
|
|
211
227
|
|
|
212
228
|
// 供外部使用dataConvert
|
|
@@ -216,4 +232,4 @@ exportXlsx.mapLgConvert = mapLgConvert;
|
|
|
216
232
|
exportXlsx.worksBarChart = worksBarChart;
|
|
217
233
|
exportXlsx.worksSlider = worksSlider;
|
|
218
234
|
|
|
219
|
-
export { exportXlsx as default };
|
|
235
|
+
export { exportXlsx as default, exportDateSuffix };
|
package/package.json
CHANGED