@daoyi/nmtl-ui 2.0.1-beta.52 → 2.0.1-beta.53

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 (81) hide show
  1. package/lib/components/Autocomplete-3dae80ca.js +335 -0
  2. package/lib/components/Autocomplete.js +13 -0
  3. package/lib/components/Avatar.js +49 -0
  4. package/lib/components/BackTop.js +109 -0
  5. package/lib/components/BarChart.js +762 -0
  6. package/lib/components/Breadcrumbs.js +122 -0
  7. package/lib/components/Button-433372aa.js +92 -0
  8. package/lib/components/Button.js +6 -0
  9. package/lib/components/Carousel.js +4654 -0
  10. package/lib/components/Checkbox.js +37 -0
  11. package/lib/components/CollapseContent.js +179 -0
  12. package/lib/components/ContactModal-66bcb5d3.js +10779 -0
  13. package/lib/components/ContactModal.js +22 -0
  14. package/lib/components/Drawer-df3535c2.js +157 -0
  15. package/lib/components/Drawer.js +11 -0
  16. package/lib/components/Dropdown.js +134 -0
  17. package/lib/components/Empty-7318f658.js +45 -0
  18. package/lib/components/Empty.js +5 -0
  19. package/lib/components/ExportButton.js +112 -0
  20. package/lib/components/ExtraTools-b0bb9399.js +3537 -0
  21. package/lib/components/ExtraTools.js +10 -0
  22. package/lib/components/Filter.js +776 -0
  23. package/lib/components/Footer.js +271 -0
  24. package/lib/components/ForwardLink-0571e627.js +105 -0
  25. package/lib/components/ForwardLink.js +9 -0
  26. package/lib/components/Header.js +187 -0
  27. package/lib/components/Image.js +61 -0
  28. package/lib/components/Input.js +77 -0
  29. package/lib/components/InputMethod.js +33963 -0
  30. package/lib/components/KeywordSearch-568a8a44.js +139 -0
  31. package/lib/components/KeywordSearch.js +15 -0
  32. package/lib/components/KeywordTicker.js +190 -0
  33. package/lib/components/Keywords.js +317 -0
  34. package/lib/components/Loading.js +28 -0
  35. package/lib/components/MUITheme.js +2627 -0
  36. package/lib/components/Modal-64c4ab0d.js +108 -0
  37. package/lib/components/Modal.js +9 -0
  38. package/lib/components/MoreButton-6654cc5b.js +110 -0
  39. package/lib/components/MoreButton.js +6 -0
  40. package/lib/components/Radio.js +78 -0
  41. package/lib/components/SNA.js +1691 -0
  42. package/lib/components/Select-113372b2.js +115 -0
  43. package/lib/components/Select.js +8 -0
  44. package/lib/components/Spin-8a5a600d.js +75 -0
  45. package/lib/components/Spin.js +6 -0
  46. package/lib/components/Table.js +51 -0
  47. package/lib/components/Tooltip-abe1205f.js +70 -0
  48. package/lib/components/Tooltip.js +7 -0
  49. package/lib/components/_commonjsHelpers-70de2c37.js +28 -0
  50. package/lib/components/_rollupPluginBabelHelpers-3d9c8289.js +478 -0
  51. package/lib/components/createSvgIcon-a79ae4b1.js +576 -0
  52. package/lib/components/dataExport-d55d6fa3.js +92 -0
  53. package/lib/components/debounce-127da66c.js +355 -0
  54. package/lib/components/defaultTheme-19a14721.js +1485 -0
  55. package/lib/components/globalConfig.js +172 -0
  56. package/lib/components/hoist-non-react-statics.cjs-3f408ad2.js +105 -0
  57. package/lib/components/index-66babe67.js +61 -0
  58. package/lib/components/index-fdcc884e.js +481 -0
  59. package/lib/components/isObjectLike-e111475d.js +190 -0
  60. package/lib/components/style-inject.es-1f59c1d0.js +28 -0
  61. package/lib/components/transform-3a04288b.js +5475 -0
  62. package/lib/index.d.ts +36 -0
  63. package/lib/index.js +36 -0
  64. package/lib/utils/_rollupPluginBabelHelpers-8dd26e1a.js +121 -0
  65. package/lib/utils/arrayMerge.js +100 -0
  66. package/lib/utils/chunkArray.js +15 -0
  67. package/lib/utils/convert2HtmlEntities.js +42 -0
  68. package/lib/utils/domToImage.js +802 -0
  69. package/lib/utils/downloadGephi.js +106 -0
  70. package/lib/utils/exportXlsx.js +219 -0
  71. package/lib/utils/historyAppendSearch.js +502 -0
  72. package/lib/utils/index.d.ts +13 -0
  73. package/lib/utils/index.js +13 -0
  74. package/lib/utils/isDevelopMode.js +5 -0
  75. package/lib/utils/parseYMD.js +36 -0
  76. package/lib/utils/removeDuplicateItem.js +11 -0
  77. package/lib/utils/sendEmail.js +39 -0
  78. package/lib/utils/snaDefine-6a2bcd94.js +5 -0
  79. package/lib/utils/snaDefine.js +1 -0
  80. package/lib/utils/snaPreProcess.js +84 -0
  81. package/package.json +1 -1
@@ -0,0 +1,22 @@
1
+ export { C as default } from './ContactModal-66bcb5d3.js';
2
+ import './_rollupPluginBabelHelpers-3d9c8289.js';
3
+ import 'react';
4
+ import 'prop-types';
5
+ import './hoist-non-react-statics.cjs-3f408ad2.js';
6
+ import 'react-is';
7
+ import 'axios';
8
+ import './Modal-64c4ab0d.js';
9
+ import './index-66babe67.js';
10
+ import '@material-ui/core';
11
+ import '@material-ui/icons';
12
+ import './Button-433372aa.js';
13
+ import './style-inject.es-1f59c1d0.js';
14
+ import './Spin-8a5a600d.js';
15
+ import './_commonjsHelpers-70de2c37.js';
16
+ import './Select-113372b2.js';
17
+ import './Empty-7318f658.js';
18
+ import './createSvgIcon-a79ae4b1.js';
19
+ import './defaultTheme-19a14721.js';
20
+ import '@material-ui/styles';
21
+ import 'react-dom';
22
+ import './globalConfig';
@@ -0,0 +1,157 @@
1
+ import { a as _slicedToArray } from './_rollupPluginBabelHelpers-3d9c8289.js';
2
+ import React__default, { useState } from 'react';
3
+ import PropTypes from 'prop-types';
4
+ import { List, ListItem, ListItemIcon, ListItemText, IconButton, Drawer as Drawer$1, Divider } from '@material-ui/core';
5
+ import { DehazeRounded } from '@material-ui/icons';
6
+ import { S as Select } from './Select-113372b2.js';
7
+ import { useHistory, useRouteMatch } from 'react-router-dom';
8
+ import { s as styleInject } from './style-inject.es-1f59c1d0.js';
9
+
10
+ var defaultSupportLanguage = [
11
+ // { value: 'en', label: 'English' },
12
+ {
13
+ value: 'zh-tw',
14
+ label: '繁體中文'
15
+ }
16
+ // { value: 'zh-cn', label: '簡體中文' },
17
+ ];
18
+
19
+ /* [檢查-語系]本系統是否支援該語系 並回傳語系 */
20
+ var checkLanguageSupport = function checkLanguageSupport(_ref) {
21
+ var language = _ref.language,
22
+ supportLanguages = _ref.supportLanguages;
23
+ var isSupport = supportLanguages.some(function (_ref2) {
24
+ var value = _ref2.value;
25
+ return value === language;
26
+ });
27
+ return isSupport ? language : supportLanguages[0].value;
28
+ };
29
+
30
+ const DrawerList = _ref => {
31
+ let {
32
+ drawerList,
33
+ setOpen
34
+ } = _ref;
35
+ const history = useHistory();
36
+ const {
37
+ url
38
+ } = useRouteMatch();
39
+ return /*#__PURE__*/React__default.createElement(List, {
40
+ className: "drawer__list"
41
+ }, Array.isArray(drawerList) && drawerList.map((_ref2, index) => {
42
+ let {
43
+ name,
44
+ icon,
45
+ path
46
+ } = _ref2;
47
+ return /*#__PURE__*/React__default.createElement(ListItem, {
48
+ button: true,
49
+ key: index.toString(),
50
+ onClick: () => {
51
+ if (path.indexOf('http') > -1) {
52
+ window.location = path;
53
+ } else {
54
+ history.push({
55
+ pathname: `${url}${path}`
56
+ });
57
+ }
58
+ setOpen(false);
59
+ }
60
+ }, icon && /*#__PURE__*/React__default.createElement(ListItemIcon, {
61
+ style: {
62
+ marginRight: 24
63
+ }
64
+ }, icon), /*#__PURE__*/React__default.createElement(ListItemText, {
65
+ primary: name
66
+ }));
67
+ }));
68
+ };
69
+ DrawerList.defaultProps = {};
70
+ DrawerList.propTypes = {
71
+ drawerList: PropTypes.arrayOf(PropTypes.any).isRequired,
72
+ setOpen: PropTypes.func.isRequired
73
+ };
74
+
75
+ var css_248z = ".drawer__icon {\n display: none !important; }\n\n.drawer__header {\n display: flex;\n align-items: center;\n padding: 20px; }\n .drawer__header-title {\n font-size: 18px;\n font-weight: bold; }\n\n.drawer__list {\n padding: 10px !important; }\n .drawer__list .MuiSvgIcon-root {\n margin-left: 8px; }\n\n.drawer__lang {\n margin: 24px 36px !important; }\n\n@media screen and (max-width: 768px) {\n .drawer {\n display: flex;\n justify-content: flex-end; }\n .drawer__icon {\n display: flex !important; } }\n";
76
+ styleInject(css_248z);
77
+
78
+ var Drawer = function Drawer(_ref) {
79
+ var title = _ref.title,
80
+ logo = _ref.logo,
81
+ locale = _ref.locale,
82
+ supportLanguages = _ref.supportLanguages,
83
+ drawerList = _ref.drawerList,
84
+ onLanguageChange = _ref.onLanguageChange;
85
+ var _useState = useState(false),
86
+ _useState2 = _slicedToArray(_useState, 2),
87
+ open = _useState2[0],
88
+ setOpen = _useState2[1];
89
+ return /*#__PURE__*/React__default.createElement("div", {
90
+ className: "drawer"
91
+ }, /*#__PURE__*/React__default.createElement(IconButton, {
92
+ className: "drawer__icon",
93
+ onClick: function onClick() {
94
+ return setOpen(true);
95
+ }
96
+ }, /*#__PURE__*/React__default.createElement(DehazeRounded, {
97
+ fontSize: "large"
98
+ })), /*#__PURE__*/React__default.createElement(Drawer$1, {
99
+ anchor: "right",
100
+ open: open,
101
+ onClose: function onClose() {
102
+ return setOpen(false);
103
+ },
104
+ onKeyDown: function onKeyDown() {
105
+ return setOpen(false);
106
+ }
107
+ }, (logo || title) && /*#__PURE__*/React__default.createElement("div", {
108
+ className: "drawer__header"
109
+ }, /*#__PURE__*/React__default.createElement("div", {
110
+ className: "drawer__header-logo"
111
+ }, logo), /*#__PURE__*/React__default.createElement("div", {
112
+ className: "drawer__header-title"
113
+ }, title)), /*#__PURE__*/React__default.createElement(Divider, null), /*#__PURE__*/React__default.createElement(DrawerList, {
114
+ drawerList: (Array.isArray(drawerList) ? drawerList : []).filter(function (_ref2) {
115
+ var showInHeader = _ref2.showInHeader;
116
+ return showInHeader;
117
+ }),
118
+ setOpen: setOpen
119
+ }), /*#__PURE__*/React__default.createElement(Divider, null), Array.isArray(supportLanguages) && supportLanguages.length > 0 && /*#__PURE__*/React__default.createElement(Select, {
120
+ className: "drawer__lang",
121
+ defaultValue: checkLanguageSupport({
122
+ language: locale,
123
+ supportLanguages: supportLanguages
124
+ }),
125
+ onChange: function onChange(value) {
126
+ return onLanguageChange(value);
127
+ },
128
+ options: supportLanguages
129
+ })));
130
+ };
131
+ Drawer.defaultProps = {
132
+ title: undefined,
133
+ logo: undefined,
134
+ locale: undefined,
135
+ supportLanguages: [{
136
+ value: 'en',
137
+ label: 'English'
138
+ }, {
139
+ value: 'zh-tw',
140
+ label: '繁體中文'
141
+ }, {
142
+ value: 'zh-cn',
143
+ label: '簡體中文'
144
+ }],
145
+ drawerList: undefined,
146
+ onLanguageChange: function onLanguageChange() {}
147
+ };
148
+ Drawer.propTypes = {
149
+ title: PropTypes.string,
150
+ logo: PropTypes.node,
151
+ locale: PropTypes.string,
152
+ supportLanguages: PropTypes.arrayOf(PropTypes.any),
153
+ drawerList: PropTypes.arrayOf(PropTypes.any),
154
+ onLanguageChange: PropTypes.func
155
+ };
156
+
157
+ export { Drawer as D, checkLanguageSupport as c, defaultSupportLanguage as d };
@@ -0,0 +1,11 @@
1
+ export { D as default } from './Drawer-df3535c2.js';
2
+ import './_rollupPluginBabelHelpers-3d9c8289.js';
3
+ import 'react';
4
+ import 'prop-types';
5
+ import '@material-ui/core';
6
+ import '@material-ui/icons';
7
+ import './Select-113372b2.js';
8
+ import './index-66babe67.js';
9
+ import './Empty-7318f658.js';
10
+ import './style-inject.es-1f59c1d0.js';
11
+ import 'react-router-dom';
@@ -0,0 +1,134 @@
1
+ import { a as _slicedToArray } from './_rollupPluginBabelHelpers-3d9c8289.js';
2
+ import React__default, { useRef, useState } from 'react';
3
+ import { c as classNames } from './index-66babe67.js';
4
+ import PropTypes from 'prop-types';
5
+ import { Button, Menu, Divider, MenuItem, ListItemIcon, ListItemText } from '@material-ui/core';
6
+ import { makeStyles } from '@material-ui/styles';
7
+ import { s as styleInject } from './style-inject.es-1f59c1d0.js';
8
+
9
+ var css_248z = "";
10
+ styleInject(css_248z);
11
+
12
+ var buttonType = {
13
+ default: 'outlined',
14
+ primary: 'contained',
15
+ link: 'text'
16
+ };
17
+ var Dropdown = function Dropdown(props) {
18
+ var className = props.className,
19
+ type = props.type,
20
+ disabled = props.disabled; // Attributes
21
+
22
+ var children = props.children,
23
+ icon = props.icon; // Node/Elements
24
+
25
+ var options = props.options; // Data List
26
+
27
+ var onOpen = props.onOpen,
28
+ _onClose = props.onClose,
29
+ getPopupContainer = props.getPopupContainer; // Callback List
30
+
31
+ var buttonRef = useRef(null);
32
+ var _useState = useState(false),
33
+ _useState2 = _slicedToArray(_useState, 2),
34
+ open = _useState2[0],
35
+ setOpen = _useState2[1];
36
+ var useStyles = makeStyles(function () {
37
+ return {
38
+ root: {
39
+ opacity: 0.6,
40
+ pointerEvents: 'none',
41
+ cursor: 'pointer'
42
+ },
43
+ disabled: true
44
+ };
45
+ });
46
+ return /*#__PURE__*/React__default.createElement("div", {
47
+ className: classNames('dropdown', className)
48
+ }, /*#__PURE__*/React__default.createElement(Button, {
49
+ id: "basic-button",
50
+ ref: buttonRef,
51
+ "aria-controls": "basic-menu",
52
+ "aria-haspopup": "true",
53
+ "aria-expanded": open ? 'true' : undefined,
54
+ onClick: function onClick() {
55
+ if (options && Array.isArray(options) && options.length > 0) {
56
+ setOpen(true);
57
+ if (onOpen) onOpen();
58
+ }
59
+ },
60
+ variant: buttonType[type] || 'text',
61
+ startIcon: icon || null,
62
+ disabled: disabled || false
63
+ }, children || null), /*#__PURE__*/React__default.createElement(Menu, {
64
+ id: "basic-menu",
65
+ getContentAnchorEl: null,
66
+ container: getPopupContainer || buttonRef.current,
67
+ anchorOrigin: {
68
+ vertical: 'bottom',
69
+ horizontal: 'center'
70
+ },
71
+ transformOrigin: {
72
+ vertical: 'top',
73
+ horizontal: 'center'
74
+ },
75
+ anchorEl: buttonRef.current,
76
+ open: open,
77
+ onClose: function onClose() {
78
+ setOpen(false);
79
+ if (_onClose) _onClose();
80
+ },
81
+ MenuListProps: {
82
+ 'aria-labelledby': 'basic-button'
83
+ }
84
+ }, options && Array.isArray(options) && options.map(function (item, index) {
85
+ return /*#__PURE__*/React__default.createElement("div", {
86
+ key: index.toString()
87
+ }, item.divider && /*#__PURE__*/React__default.createElement(Divider, null), /*#__PURE__*/React__default.createElement(MenuItem, {
88
+ className: item.disabled ? useStyles().root : '',
89
+ onClick: function onClick() {
90
+ setOpen(false);
91
+ if (_onClose) _onClose();
92
+ if (item.onClick) item.onClick({
93
+ label: item.label,
94
+ value: item.value
95
+ });
96
+ }
97
+ }, item.icon && /*#__PURE__*/React__default.createElement(ListItemIcon, null, item.icon), item.label && /*#__PURE__*/React__default.createElement(ListItemText, null, item.label)));
98
+ })));
99
+ };
100
+ Dropdown.defaultProps = {
101
+ className: undefined,
102
+ children: undefined,
103
+ icon: undefined,
104
+ type: 'link',
105
+ disabled: undefined,
106
+ options: undefined,
107
+ getPopupContainer: undefined,
108
+ onOpen: undefined,
109
+ onClose: undefined
110
+ };
111
+
112
+ /* Write props detail information and 'npm run updateStory' will help you generate stories's argTypes */
113
+ Dropdown.propTypes = {
114
+ /** Css Name */
115
+ className: PropTypes.string,
116
+ /** 按鈕內容 */
117
+ children: PropTypes.node,
118
+ /** 按鈕左側Icon */
119
+ icon: PropTypes.node,
120
+ /** 按鈕類型 */
121
+ type: PropTypes.oneOf(Object.keys(buttonType)),
122
+ /** Menu按鈕是否禁用 */
123
+ disabled: PropTypes.bool,
124
+ /** Menu Data list */
125
+ options: PropTypes.arrayOf(PropTypes.any),
126
+ /** Menu content render by node */
127
+ getPopupContainer: PropTypes.func,
128
+ /** Menu 開啟 Callback */
129
+ onOpen: PropTypes.func,
130
+ /** Menu 關閉 Callback */
131
+ onClose: PropTypes.func
132
+ };
133
+
134
+ export { Dropdown as default };
@@ -0,0 +1,45 @@
1
+ import React__default from 'react';
2
+ import PropTypes from 'prop-types';
3
+ import { c as classNames } from './index-66babe67.js';
4
+ import { s as styleInject } from './style-inject.es-1f59c1d0.js';
5
+
6
+ var img = "data:image/svg+xml,%3csvg class='ant-empty-img-default' width='184' height='152' viewBox='0 0 184 152' xmlns='http://www.w3.org/2000/svg'%3e %3cg fill='none' fill-rule='evenodd'%3e %3cg transform='translate(24 31.67)'%3e %3cellipse fill='%23f5f5f5' fill-opacity='0.8' cx='67.797' cy='106.89' rx='67.797' ry='12.668'%3e%3c/ellipse%3e %3cpath fill='%23aeb8c2' d='M122.034 69.674L98.109 40.229c-1.148-1.386-2.826-2.225-4.593-2.225h-51.44c-1.766 0-3.444.839-4.592 2.225L13.56 69.674v15.383h108.475V69.674z'%3e%3c/path%3e %3cpath fill='url(%23linearGradient-1)' d='M101.537 86.214L80.63 61.102c-1.001-1.207-2.507-1.867-4.048-1.867H31.724c-1.54 0-3.047.66-4.048 1.867L6.769 86.214v13.792h94.768V86.214z' transform='translate(13.56)'%3e%3c/path%3e %3cpath fill='%23f5f5f7' d='M33.83 0h67.933a4 4 0 0 1 4 4v93.344a4 4 0 0 1-4 4H33.83a4 4 0 0 1-4-4V4a4 4 0 0 1 4-4z'%3e%3c/path%3e %3cpath fill='%23dce0e6' d='M42.678 9.953h50.237a2 2 0 0 1 2 2V36.91a2 2 0 0 1-2 2H42.678a2 2 0 0 1-2-2V11.953a2 2 0 0 1 2-2zM42.94 49.767h49.713a2.262 2.262 0 1 1 0 4.524H42.94a2.262 2.262 0 0 1 0-4.524zM42.94 61.53h49.713a2.262 2.262 0 1 1 0 4.525H42.94a2.262 2.262 0 0 1 0-4.525zM121.813 105.032c-.775 3.071-3.497 5.36-6.735 5.36H20.515c-3.238 0-5.96-2.29-6.734-5.36a7.309 7.309 0 0 1-.222-1.79V69.675h26.318c2.907 0 5.25 2.448 5.25 5.42v.04c0 2.971 2.37 5.37 5.277 5.37h34.785c2.907 0 5.277-2.421 5.277-5.393V75.1c0-2.972 2.343-5.426 5.25-5.426h26.318v33.569c0 .617-.077 1.216-.221 1.789z'%3e%3c/path%3e %3c/g%3e %3cpath fill='%23dce0e6' d='M149.121 33.292l-6.83 2.65a1 1 0 0 1-1.317-1.23l1.937-6.207c-2.589-2.944-4.109-6.534-4.109-10.408C138.802 8.102 148.92 0 161.402 0 173.881 0 184 8.102 184 18.097c0 9.995-10.118 18.097-22.599 18.097-4.528 0-8.744-1.066-12.28-2.902z'%3e%3c/path%3e %3cg fill='white' transform='translate(149.65 15.383)'%3e %3cellipse cx='20.654' cy='3.167' rx='2.849' ry='2.815'%3e%3c/ellipse%3e %3cpath d='M5.698 5.63H0L2.898.704zM9.259.704h4.985V5.63H9.259z'%3e%3c/path%3e %3c/g%3e %3c/g%3e%3c/svg%3e";
7
+
8
+ var css_248z = ".antd-empty {\n width: 100%;\n font-size: 1rem;\n line-height: 1.5715;\n text-align: center;\n overflow: hidden;\n height: 100%; }\n .antd-empty .ant-empty-image {\n height: 100px;\n margin-bottom: 8px; }\n .antd-empty .ant-empty-image img {\n height: calc(100% - 22px);\n margin: auto; }\n .antd-empty .antd-empty-description {\n color: rgba(0, 0, 0, 0.85); }\n";
9
+ styleInject(css_248z);
10
+
11
+ var Empty = function Empty(_ref) {
12
+ var className = _ref.className,
13
+ description = _ref.description,
14
+ emptySrc = _ref.emptySrc,
15
+ imageStyle = _ref.imageStyle;
16
+ return /*#__PURE__*/React__default.createElement("div", {
17
+ className: classNames('antd-empty', className)
18
+ }, /*#__PURE__*/React__default.createElement("div", {
19
+ className: "ant-empty-image"
20
+ }, /*#__PURE__*/React__default.createElement("img", {
21
+ src: emptySrc || img,
22
+ alt: description,
23
+ style: imageStyle
24
+ }), description && /*#__PURE__*/React__default.createElement("div", {
25
+ className: "ant-empty-description"
26
+ }, description)));
27
+ };
28
+ Empty.defaultProps = {
29
+ className: undefined,
30
+ emptySrc: undefined,
31
+ description: 'No Data',
32
+ imageStyle: {}
33
+ };
34
+ Empty.propTypes = {
35
+ /** Css名稱 */
36
+ className: PropTypes.string,
37
+ /** 空白時圖案的Src */
38
+ emptySrc: PropTypes.string,
39
+ /** 描述 */
40
+ description: PropTypes.node,
41
+ /** 圖案的style */
42
+ imageStyle: PropTypes.objectOf(PropTypes.any)
43
+ };
44
+
45
+ export { Empty as E };
@@ -0,0 +1,5 @@
1
+ export { E as default } from './Empty-7318f658.js';
2
+ import 'react';
3
+ import 'prop-types';
4
+ import './index-66babe67.js';
5
+ import './style-inject.es-1f59c1d0.js';
@@ -0,0 +1,112 @@
1
+ import { a as _slicedToArray } from './_rollupPluginBabelHelpers-3d9c8289.js';
2
+ import React__default, { useState } from 'react';
3
+ import PropTypes from 'prop-types';
4
+ import { c as classNames } from './index-66babe67.js';
5
+ import { ExitToApp } from '@material-ui/icons';
6
+ import { Dialog, DialogContent, DialogContentText, DialogActions, Button } from '@material-ui/core';
7
+ import { f as fileDownload, j as jsonTxt, a as jsonExcel } from './dataExport-d55d6fa3.js';
8
+ import { getIntl } from './globalConfig';
9
+ import { s as styleInject } from './style-inject.es-1f59c1d0.js';
10
+
11
+ var css_248z = ".exportButton {\n display: flex;\n align-items: center;\n font-size: 1.5rem;\n transition: color 0.3s ease-in-out;\n -webkit-user-select: none;\n user-select: none; }\n .exportButton--right {\n justify-content: flex-end; }\n .exportButton__text {\n display: flex;\n align-items: center;\n text-decoration: underline;\n cursor: pointer; }\n .exportButton__text__icon {\n font-size: 2rem;\n margin-right: 4px; }\n .exportButton__text:hover {\n font-weight: bold; }\n";
12
+ styleInject(css_248z);
13
+
14
+ var ExportButton = function ExportButton(_ref) {
15
+ var className = _ref.className,
16
+ color = _ref.color,
17
+ right = _ref.right,
18
+ forceTxt = _ref.forceTxt,
19
+ exportText = _ref.exportText,
20
+ exportTypeText = _ref.exportTypeText,
21
+ data = _ref.data;
22
+ var _getIntl = getIntl(),
23
+ formatMessage = _getIntl.formatMessage;
24
+ var _useState = useState(false),
25
+ _useState2 = _slicedToArray(_useState, 2),
26
+ open = _useState2[0],
27
+ setOpen = _useState2[1];
28
+ var buttons = [{
29
+ type: 'CSV',
30
+ click: function click() {
31
+ return fileDownload("\uFEFF".concat(jsonExcel(data)), 'output.csv');
32
+ }
33
+ }, {
34
+ type: 'EXCEL',
35
+ click: function click() {
36
+ return fileDownload("\uFEFF".concat(jsonExcel(data)), 'output.xls');
37
+ }
38
+ }, {
39
+ type: 'TXT',
40
+ click: function click() {
41
+ return fileDownload("\uFEFF".concat(jsonTxt(data)), 'output.txt');
42
+ }
43
+ }];
44
+ return /*#__PURE__*/React__default.createElement("div", {
45
+ style: {
46
+ color: color
47
+ },
48
+ className: classNames('exportButton', {
49
+ 'exportButton--right': right
50
+ }, className)
51
+ }, /*#__PURE__*/React__default.createElement("div", {
52
+ className: "exportButton__text",
53
+ onClick: function onClick() {
54
+ return forceTxt ? fileDownload("\uFEFF".concat(jsonTxt(data)), 'output.txt') : setOpen(true);
55
+ }
56
+ }, /*#__PURE__*/React__default.createElement(ExitToApp, {
57
+ className: "exportButton__text__icon"
58
+ }), exportText || formatMessage({
59
+ id: 'common.export'
60
+ })), /*#__PURE__*/React__default.createElement(Dialog, {
61
+ open: open,
62
+ keepMounted: true,
63
+ onClose: function onClose() {
64
+ return setOpen(false);
65
+ },
66
+ "aria-labelledby": "alert-dialog-slide-title",
67
+ "aria-describedby": "alert-dialog-slide-description"
68
+ }, /*#__PURE__*/React__default.createElement(DialogContent, null, /*#__PURE__*/React__default.createElement(DialogContentText, null, exportTypeText || formatMessage({
69
+ id: 'common.export.type'
70
+ }))), /*#__PURE__*/React__default.createElement(DialogActions, null, buttons.map(function (_ref2) {
71
+ var type = _ref2.type,
72
+ click = _ref2.click;
73
+ return /*#__PURE__*/React__default.createElement(Button, {
74
+ key: type,
75
+ variant: "text",
76
+ onClick: function onClick() {
77
+ click();
78
+ setOpen(false);
79
+ }
80
+ }, type);
81
+ }))));
82
+ };
83
+ ExportButton.defaultProps = {
84
+ className: undefined,
85
+ color: '#4e3a16',
86
+ right: undefined,
87
+ forceTxt: true,
88
+ // 聽說Excel怪怪的 先強制隱藏
89
+ exportText: undefined,
90
+ exportTypeText: 'Export Type',
91
+ data: undefined
92
+ };
93
+
94
+ /* Write props detail information and 'npm run updateStory' will help you generate stories's argTypes */
95
+ ExportButton.propTypes = {
96
+ /** Css Name */
97
+ className: PropTypes.string,
98
+ /** 主題顏色 */
99
+ color: PropTypes.string,
100
+ /** 靠右起來 */
101
+ right: PropTypes.bool,
102
+ /** 匯出是否強制txt */
103
+ forceTxt: PropTypes.bool,
104
+ /** 匯出的文字 */
105
+ exportText: PropTypes.string,
106
+ /** 匯出類型的文字 */
107
+ exportTypeText: PropTypes.string,
108
+ /** 要匯出的JSON資料 */
109
+ data: PropTypes.oneOfType([PropTypes.objectOf(PropTypes.any), PropTypes.arrayOf(PropTypes.any)])
110
+ };
111
+
112
+ export { ExportButton as default };