@daoyi/nmtl-ui 2.0.1-beta.9 → 2.0.1-beta.91
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/components/Autocomplete-887cda6a.js +432 -0
- package/lib/components/Autocomplete.js +19 -1
- package/lib/components/Avatar.js +53 -1
- package/lib/components/BackTop.js +109 -1
- package/lib/components/BarChart.js +762 -1
- package/lib/components/Breadcrumbs.js +122 -1
- package/lib/components/Button-8742afeb.js +92 -0
- package/lib/components/Button.js +6 -1
- package/lib/components/Carousel.js +4654 -1
- package/lib/components/Checkbox.js +37 -1
- package/lib/components/CollapseContent.js +179 -1
- package/lib/components/ContactModal-530d4d80.js +12030 -0
- package/lib/components/ContactModal.js +22 -3
- package/lib/components/Drawer-96442344.js +156 -0
- package/lib/components/Drawer.js +11 -1
- package/lib/components/Dropdown.js +134 -1
- package/lib/components/Empty-94a8d8ff.js +45 -0
- package/lib/components/Empty.js +5 -1
- package/lib/components/ExportButton.js +112 -1
- package/lib/components/ExtraTools-bfb076ca.js +3537 -0
- package/lib/components/ExtraTools.js +10 -22
- package/lib/components/Filter.js +782 -12
- package/lib/components/Footer.js +271 -1
- package/lib/components/ForwardLink-059be72d.js +106 -0
- package/lib/components/ForwardLink.js +8 -0
- package/lib/components/Header.js +194 -1
- package/lib/components/Image.js +61 -1
- package/lib/components/Input.js +82 -1
- package/lib/components/InputMethod.js +33949 -12
- package/lib/components/KeywordSearch-c3acab41.js +144 -0
- package/lib/components/KeywordSearch.js +21 -1
- package/lib/components/KeywordTicker.js +190 -1
- package/lib/components/Keywords.js +317 -1
- package/lib/components/Loading.js +28 -1
- package/lib/components/MUITheme.js +2624 -1
- package/lib/components/Modal-fc4320d3.js +108 -0
- package/lib/components/Modal.js +9 -1
- package/lib/components/MoreButton-d7c9f3b8.js +110 -0
- package/lib/components/MoreButton.js +6 -1
- package/lib/components/Pagination.js +3637 -0
- package/lib/components/Radio.js +78 -1
- package/lib/components/SNA.js +1691 -22
- package/lib/components/Select-fdb4d9b8.js +115 -0
- package/lib/components/Select.js +8 -1
- package/lib/components/Spin-fafe3787.js +75 -0
- package/lib/components/Spin.js +6 -1
- package/lib/components/Table.js +51 -1
- package/lib/components/Tooltip-e67a18bc.js +70 -0
- package/lib/components/Tooltip.js +7 -1
- package/lib/components/_commonjsHelpers-70de2c37.js +28 -0
- package/lib/components/_rollupPluginBabelHelpers-a52356f6.js +142 -0
- package/lib/components/createSvgIcon-0d38de2e.js +576 -0
- package/lib/components/dataExport-d55d6fa3.js +92 -0
- package/lib/components/debounce-127da66c.js +355 -0
- package/lib/components/defaultTheme-ed7746fe.js +1661 -0
- package/lib/components/globalConfig.js +176 -0
- package/lib/components/hoist-non-react-statics.cjs-3f408ad2.js +105 -0
- package/lib/components/index-0be0afec.js +481 -0
- package/lib/components/index-ef96775f.js +61 -0
- package/lib/components/isObjectLike-e111475d.js +190 -0
- package/lib/components/style-inject.es-1f59c1d0.js +28 -1
- package/lib/components/toConsumableArray-dbe8af76.js +19 -0
- package/lib/components/transform-3a04288b.js +5475 -0
- package/lib/components/withTheme-2d778133.js +6 -0
- package/lib/configs/config.selector.js +151 -0
- package/lib/configs/index.d.ts +1 -0
- package/lib/configs/index.js +1 -0
- package/lib/index.d.ts +2 -0
- package/lib/index.js +2 -0
- package/lib/utils/_rollupPluginBabelHelpers-8dd26e1a.js +121 -0
- package/lib/utils/arrayMerge.js +4953 -1
- package/lib/utils/chunkArray.js +15 -1
- package/lib/utils/convert2HtmlEntities.js +42 -1
- package/lib/utils/domToImage.js +802 -1
- package/lib/utils/downloadGephi.js +106 -1
- package/lib/utils/exportXlsx.js +219 -1
- package/lib/utils/historyAppendSearch.js +502 -1
- package/lib/utils/isDevelopMode.js +5 -1
- package/lib/utils/parseYMD.js +36 -1
- package/lib/utils/removeDuplicateItem.js +11 -1
- package/lib/utils/sendEmail.js +39 -1
- package/lib/utils/snaDefine-6a2bcd94.js +5 -0
- package/lib/utils/snaDefine.js +1 -1
- package/lib/utils/snaPreProcess.js +84 -1
- package/package.json +17 -19
- package/lib/components/Empty-54b79907.js +0 -1
- package/lib/components/KeywordSearch-5a393f12.js +0 -1
- package/lib/components/Select-f2441b83.js +0 -1
- package/lib/components/_rollupPluginBabelHelpers-1b8c042f.js +0 -1
- package/lib/components/_rollupPluginBabelHelpers-ec4e2a53.js +0 -1
- package/lib/components/createSvgIcon-62b64929.js +0 -1
- package/lib/components/createSvgIcon-e24792d4.js +0 -1
- package/lib/components/createTheme-7fffa109.js +0 -1
- package/lib/components/dataExport-9fccd4f0.js +0 -1
- package/lib/components/debounce-c993109b.js +0 -1
- package/lib/components/hoist-non-react-statics.cjs-d6a9befd.js +0 -1
- package/lib/components/index-11391ca3.js +0 -7
- package/lib/components/index-b2745105.js +0 -7
- package/lib/components/isObjectLike-2f1983fe.js +0 -1
- package/lib/components/style-inject.es-c875d022.js +0 -1
- package/lib/components/transform-95ae0119.js +0 -1
- package/lib/utils/_commonjsHelpers-e2cda605.js +0 -1
- package/lib/utils/_rollupPluginBabelHelpers-928a52ce.js +0 -1
|
@@ -0,0 +1,432 @@
|
|
|
1
|
+
import { _ as _extends$1, a as _slicedToArray, b as _objectSpread2 } from './_rollupPluginBabelHelpers-a52356f6.js';
|
|
2
|
+
import React__default, { useCallback, useState, useRef, useEffect } from 'react';
|
|
3
|
+
import PropTypes from 'prop-types';
|
|
4
|
+
import { c as classNames } from './index-ef96775f.js';
|
|
5
|
+
import { d as debounce_1 } from './debounce-127da66c.js';
|
|
6
|
+
import { Autocomplete as Autocomplete$1 } from '@material-ui/lab';
|
|
7
|
+
import { Chip, TextField, CircularProgress } from '@material-ui/core';
|
|
8
|
+
import { Close, SearchOutlined } from '@material-ui/icons';
|
|
9
|
+
import { r as requireCreateSvgIcon, i as interopRequireDefault, a as interopRequireWildcard } from './createSvgIcon-0d38de2e.js';
|
|
10
|
+
import { _ as _extends, m as merge, d as defaultTheme, c as compose, b as borders, a as display, f as flexbox, g as grid, p as positions, e as palette, h as boxShadow, s as sizing, i as spacing, t as typography } from './defaultTheme-ed7746fe.js';
|
|
11
|
+
import 'react-is';
|
|
12
|
+
import { _ as _toConsumableArray } from './toConsumableArray-dbe8af76.js';
|
|
13
|
+
import { styled as styled$1 } from '@material-ui/styles';
|
|
14
|
+
import { s as styleInject } from './style-inject.es-1f59c1d0.js';
|
|
15
|
+
import { E as Empty } from './Empty-94a8d8ff.js';
|
|
16
|
+
|
|
17
|
+
var ArrowDropDown = {};
|
|
18
|
+
|
|
19
|
+
function omit(input, fields) {
|
|
20
|
+
var output = {};
|
|
21
|
+
Object.keys(input).forEach(function (prop) {
|
|
22
|
+
if (fields.indexOf(prop) === -1) {
|
|
23
|
+
output[prop] = input[prop];
|
|
24
|
+
}
|
|
25
|
+
});
|
|
26
|
+
return output;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
function styleFunctionSx(styleFunction) {
|
|
30
|
+
var newStyleFunction = function newStyleFunction(props) {
|
|
31
|
+
var output = styleFunction(props);
|
|
32
|
+
|
|
33
|
+
if (props.css) {
|
|
34
|
+
return _extends({}, merge(output, styleFunction(_extends({
|
|
35
|
+
theme: props.theme
|
|
36
|
+
}, props.css))), omit(props.css, [styleFunction.filterProps]));
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
if (props.sx) {
|
|
40
|
+
return _extends({}, merge(output, styleFunction(_extends({
|
|
41
|
+
theme: props.theme
|
|
42
|
+
}, props.sx))), omit(props.sx, [styleFunction.filterProps]));
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
return output;
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
newStyleFunction.propTypes = {};
|
|
49
|
+
newStyleFunction.filterProps = ['css', 'sx'].concat(_toConsumableArray(styleFunction.filterProps));
|
|
50
|
+
return newStyleFunction;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
var _interopRequireDefault = interopRequireDefault.exports;
|
|
54
|
+
|
|
55
|
+
var _interopRequireWildcard = interopRequireWildcard.exports;
|
|
56
|
+
|
|
57
|
+
Object.defineProperty(ArrowDropDown, "__esModule", {
|
|
58
|
+
value: true
|
|
59
|
+
});
|
|
60
|
+
var default_1 = ArrowDropDown.default = void 0;
|
|
61
|
+
|
|
62
|
+
var React = _interopRequireWildcard(React__default);
|
|
63
|
+
|
|
64
|
+
var _createSvgIcon = _interopRequireDefault(requireCreateSvgIcon());
|
|
65
|
+
|
|
66
|
+
var _default = (0, _createSvgIcon.default)( /*#__PURE__*/React.createElement("path", {
|
|
67
|
+
d: "M7 10l5 5 5-5z"
|
|
68
|
+
}), 'ArrowDropDown');
|
|
69
|
+
|
|
70
|
+
default_1 = ArrowDropDown.default = _default;
|
|
71
|
+
|
|
72
|
+
var styled = function styled(Component) {
|
|
73
|
+
var componentCreator = styled$1(Component);
|
|
74
|
+
return function (style, options) {
|
|
75
|
+
return componentCreator(style, _extends({
|
|
76
|
+
defaultTheme: defaultTheme
|
|
77
|
+
}, options));
|
|
78
|
+
};
|
|
79
|
+
};
|
|
80
|
+
|
|
81
|
+
var styleFunction = styleFunctionSx(compose(borders, display, flexbox, grid, positions, palette, boxShadow, sizing, spacing, typography));
|
|
82
|
+
/**
|
|
83
|
+
* @ignore - do not document.
|
|
84
|
+
*/
|
|
85
|
+
|
|
86
|
+
var Box = styled('div')(styleFunction, {
|
|
87
|
+
name: 'MuiBox'
|
|
88
|
+
});
|
|
89
|
+
|
|
90
|
+
var useAutocomplete = (_ref => {
|
|
91
|
+
let {
|
|
92
|
+
options,
|
|
93
|
+
placeholder,
|
|
94
|
+
loading,
|
|
95
|
+
searchIcon,
|
|
96
|
+
labelInValue,
|
|
97
|
+
onEnter,
|
|
98
|
+
currentResult,
|
|
99
|
+
setCurrentDefaultValue,
|
|
100
|
+
arrowIcon
|
|
101
|
+
} = _ref;
|
|
102
|
+
const getValue = useCallback(data => typeof data === 'object' ? data.value : data, []);
|
|
103
|
+
const getLabel = useCallback(value => {
|
|
104
|
+
const finder = (Array.isArray(options) ? options : []).find(item => getValue(item) === getValue(value)
|
|
105
|
+
// typeof item === 'object' ? item.label === value : item === value
|
|
106
|
+
);
|
|
107
|
+
|
|
108
|
+
// console.log('options', options);
|
|
109
|
+
// console.log('value', value);
|
|
110
|
+
// console.log('finder', finder);
|
|
111
|
+
if (finder) {
|
|
112
|
+
return typeof finder === 'object' ? finder.label : finder;
|
|
113
|
+
}
|
|
114
|
+
return typeof value === 'object' ? value.label : value;
|
|
115
|
+
}, [options]);
|
|
116
|
+
|
|
117
|
+
// Filter duplicate data by each item.value
|
|
118
|
+
const getUniqueArray = useCallback(result => {
|
|
119
|
+
if (!Array.isArray(result)) return undefined;
|
|
120
|
+
return [...new Map(result.map(obj => [obj.value, obj])).values()];
|
|
121
|
+
}, []);
|
|
122
|
+
|
|
123
|
+
/* 若MUI的Autocomplete下方的options列表要勾選已選的項目 必須從options取出才可 */
|
|
124
|
+
const getValueFromOptions = useCallback(defaultValue => {
|
|
125
|
+
if (Array.isArray(options)) {
|
|
126
|
+
if (Array.isArray(defaultValue)) {
|
|
127
|
+
return defaultValue.map(
|
|
128
|
+
// item有可能為 object({ label, value }) 或 string(value)
|
|
129
|
+
item => options.find(_ref2 => {
|
|
130
|
+
let {
|
|
131
|
+
value
|
|
132
|
+
} = _ref2;
|
|
133
|
+
return item === value || item.value === value;
|
|
134
|
+
}) || item
|
|
135
|
+
// if (typeof item === 'object') return options.find(({ value }) => item.value === value) || item;
|
|
136
|
+
// return item;
|
|
137
|
+
);
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
const result = options.find(_ref3 => {
|
|
141
|
+
let {
|
|
142
|
+
value
|
|
143
|
+
} = _ref3;
|
|
144
|
+
return defaultValue === value;
|
|
145
|
+
});
|
|
146
|
+
return labelInValue ? defaultValue : result || {
|
|
147
|
+
label: defaultValue,
|
|
148
|
+
value: defaultValue
|
|
149
|
+
};
|
|
150
|
+
}
|
|
151
|
+
return defaultValue;
|
|
152
|
+
}, [options, labelInValue]);
|
|
153
|
+
const defaultTag = useCallback((tagValue, getTagProps) => tagValue.map((option, index) => /*#__PURE__*/React__default.createElement(Chip, _extends$1({
|
|
154
|
+
label: getLabel(option),
|
|
155
|
+
deleteIcon: /*#__PURE__*/React__default.createElement(Close, null)
|
|
156
|
+
}, getTagProps({
|
|
157
|
+
index
|
|
158
|
+
})))), [options]);
|
|
159
|
+
const defaultRenderInput = useCallback(params => /*#__PURE__*/React__default.createElement(TextField, _extends$1({}, params, {
|
|
160
|
+
variant: "outlined",
|
|
161
|
+
placeholder: placeholder,
|
|
162
|
+
InputProps: {
|
|
163
|
+
...params.InputProps,
|
|
164
|
+
endAdornment: /*#__PURE__*/React__default.createElement(React__default.Fragment, null, loading && /*#__PURE__*/React__default.createElement(CircularProgress, {
|
|
165
|
+
className: "autocomplete__icon",
|
|
166
|
+
color: "inherit",
|
|
167
|
+
size: 20
|
|
168
|
+
}), searchIcon && /*#__PURE__*/React__default.createElement(SearchOutlined, {
|
|
169
|
+
className: "autocomplete__icon",
|
|
170
|
+
onClick: event => {
|
|
171
|
+
const tmpObj = {
|
|
172
|
+
labels: currentResult || '',
|
|
173
|
+
value: currentResult || ''
|
|
174
|
+
};
|
|
175
|
+
setCurrentDefaultValue(tmpObj);
|
|
176
|
+
return onEnter(event, tmpObj);
|
|
177
|
+
}
|
|
178
|
+
}), !searchIcon && !loading && arrowIcon && /*#__PURE__*/React__default.createElement(Box, {
|
|
179
|
+
style: {
|
|
180
|
+
top: 'calc(50% - 14px)',
|
|
181
|
+
right: '12px',
|
|
182
|
+
position: 'absolute'
|
|
183
|
+
}
|
|
184
|
+
}, /*#__PURE__*/React__default.createElement(default_1, null)), params.InputProps.endAdornment)
|
|
185
|
+
}
|
|
186
|
+
})), [loading, searchIcon, arrowIcon]);
|
|
187
|
+
return {
|
|
188
|
+
getValue,
|
|
189
|
+
getValueFromOptions,
|
|
190
|
+
defaultTag,
|
|
191
|
+
defaultRenderInput,
|
|
192
|
+
getUniqueArray
|
|
193
|
+
};
|
|
194
|
+
});
|
|
195
|
+
|
|
196
|
+
var css_248z = ".autocomplete .MuiAutocomplete-inputRoot[class*=MuiOutlinedInput-root] {\n flex-wrap: wrap;\n padding: 0px 8px;\n}\n.autocomplete .MuiChip-deleteIcon {\n width: 16px;\n height: 16px;\n}\n.autocomplete__icon {\n font-size: 1.25rem;\n margin-right: 8px;\n cursor: pointer;\n}\n.autocomplete--showSearchIcon .MuiAutocomplete-inputRoot[class*=MuiOutlinedInput-root] {\n display: flex;\n flex-wrap: nowrap;\n padding: 4px 8px;\n}";
|
|
197
|
+
styleInject(css_248z);
|
|
198
|
+
|
|
199
|
+
var Autocomplete = function Autocomplete(props) {
|
|
200
|
+
var options = props.options,
|
|
201
|
+
defaultValue = props.defaultValue,
|
|
202
|
+
renderAfterDefaultValueChange = props.renderAfterDefaultValueChange,
|
|
203
|
+
filterable = props.filterable,
|
|
204
|
+
loading = props.loading,
|
|
205
|
+
labelInValue = props.labelInValue,
|
|
206
|
+
disabled = props.disabled;
|
|
207
|
+
var className = props.className,
|
|
208
|
+
multiple = props.multiple,
|
|
209
|
+
freeTyping = props.freeTyping,
|
|
210
|
+
placeholder = props.placeholder,
|
|
211
|
+
searchIcon = props.searchIcon,
|
|
212
|
+
_renderInput = props.renderInput,
|
|
213
|
+
_renderTags = props.renderTags;
|
|
214
|
+
var _onChange = props.onChange,
|
|
215
|
+
onSearch = props.onSearch,
|
|
216
|
+
onFocus = props.onFocus,
|
|
217
|
+
onBlur = props.onBlur,
|
|
218
|
+
onEnter = props.onEnter,
|
|
219
|
+
arrowIcon = props.arrowIcon;
|
|
220
|
+
var _useState = useState(true),
|
|
221
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
222
|
+
rerender = _useState2[0],
|
|
223
|
+
setRerender = _useState2[1];
|
|
224
|
+
var _useState3 = useState(),
|
|
225
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
|
226
|
+
keyword = _useState4[0],
|
|
227
|
+
setKeyword = _useState4[1];
|
|
228
|
+
var _useState5 = useState(),
|
|
229
|
+
_useState6 = _slicedToArray(_useState5, 2),
|
|
230
|
+
currentResult = _useState6[0],
|
|
231
|
+
setCurrentResult = _useState6[1];
|
|
232
|
+
var _useState7 = useState(),
|
|
233
|
+
_useState8 = _slicedToArray(_useState7, 2),
|
|
234
|
+
isFocusItem = _useState8[0],
|
|
235
|
+
setFocusItem = _useState8[1];
|
|
236
|
+
var _useState9 = useState(),
|
|
237
|
+
_useState10 = _slicedToArray(_useState9, 2),
|
|
238
|
+
currentDefaultValue = _useState10[0],
|
|
239
|
+
setCurrentDefaultValue = _useState10[1];
|
|
240
|
+
var _useAutocomplete = useAutocomplete(_objectSpread2({}, {
|
|
241
|
+
options: options,
|
|
242
|
+
placeholder: placeholder,
|
|
243
|
+
loading: loading,
|
|
244
|
+
searchIcon: searchIcon,
|
|
245
|
+
labelInValue: labelInValue,
|
|
246
|
+
currentResult: currentResult,
|
|
247
|
+
onEnter: onEnter,
|
|
248
|
+
setCurrentDefaultValue: setCurrentDefaultValue,
|
|
249
|
+
arrowIcon: arrowIcon
|
|
250
|
+
})),
|
|
251
|
+
getValue = _useAutocomplete.getValue,
|
|
252
|
+
getValueFromOptions = _useAutocomplete.getValueFromOptions,
|
|
253
|
+
defaultTag = _useAutocomplete.defaultTag,
|
|
254
|
+
defaultRenderInput = _useAutocomplete.defaultRenderInput,
|
|
255
|
+
getUniqueArray = _useAutocomplete.getUniqueArray;
|
|
256
|
+
var handleSearch = useRef(debounce_1(function (result) {
|
|
257
|
+
return onSearch(result);
|
|
258
|
+
}, 500)).current;
|
|
259
|
+
|
|
260
|
+
// 複選時 defaultValue 必須為Array
|
|
261
|
+
// const currentDefaultValue = typeof defaultValue === 'string' && multiple ? undefined : getValueFromOptions(defaultValue);
|
|
262
|
+
useEffect(function () {
|
|
263
|
+
setCurrentDefaultValue(typeof defaultValue === 'string' && multiple ? {
|
|
264
|
+
label: keyword,
|
|
265
|
+
value: keyword
|
|
266
|
+
} : getValueFromOptions(defaultValue));
|
|
267
|
+
}, [JSON.stringify(defaultValue)]);
|
|
268
|
+
useEffect(function () {
|
|
269
|
+
if (renderAfterDefaultValueChange) setRerender(false);
|
|
270
|
+
}, [currentDefaultValue]); // defaultValue改變時強制rerender
|
|
271
|
+
useEffect(function () {
|
|
272
|
+
if (!rerender) setRerender(true);
|
|
273
|
+
}, [rerender]);
|
|
274
|
+
/* 監聽result變化時才觸發onSearch */
|
|
275
|
+
useEffect(function () {
|
|
276
|
+
if (currentResult) {
|
|
277
|
+
setKeyword(currentResult);
|
|
278
|
+
handleSearch(currentResult);
|
|
279
|
+
}
|
|
280
|
+
}, [currentResult]);
|
|
281
|
+
|
|
282
|
+
/* 這邊邏輯很複雜 變動需再三確認case */
|
|
283
|
+
return /*#__PURE__*/React__default.createElement("div", {
|
|
284
|
+
className: classNames('autocomplete', {
|
|
285
|
+
'autocomplete--showSearchIcon': searchIcon
|
|
286
|
+
}, className)
|
|
287
|
+
}, rerender && /*#__PURE__*/React__default.createElement(Autocomplete$1, {
|
|
288
|
+
className: "autocomplete__component",
|
|
289
|
+
options: Array.isArray(options) && (freeTyping && keyword ? [{
|
|
290
|
+
label: keyword,
|
|
291
|
+
value: keyword
|
|
292
|
+
}].concat(options) : options) || []
|
|
293
|
+
// value="asd"
|
|
294
|
+
,
|
|
295
|
+
defaultValue: currentDefaultValue,
|
|
296
|
+
disabled: disabled,
|
|
297
|
+
multiple: multiple
|
|
298
|
+
// 篩選機制(依據filterable決定是否要render全部)
|
|
299
|
+
,
|
|
300
|
+
filterOptions: function filterOptions(optionList, input) {
|
|
301
|
+
var _input$inputValue = input.inputValue,
|
|
302
|
+
inputValue = _input$inputValue === void 0 ? '' : _input$inputValue;
|
|
303
|
+
return (Array.isArray(optionList) ? optionList : []).filter(function (item) {
|
|
304
|
+
var _ref = item || {},
|
|
305
|
+
_ref$label = _ref.label,
|
|
306
|
+
label = _ref$label === void 0 ? '' : _ref$label;
|
|
307
|
+
return filterable ? label.toLowerCase().indexOf(inputValue.toLowerCase()) > -1 : true;
|
|
308
|
+
});
|
|
309
|
+
},
|
|
310
|
+
onChange: function onChange(event, result) {
|
|
311
|
+
if (Array.isArray(result)) {
|
|
312
|
+
_onChange(result.map(function (item) {
|
|
313
|
+
return labelInValue ? item : getValue(item);
|
|
314
|
+
}));
|
|
315
|
+
} else if (result) {
|
|
316
|
+
_onChange(labelInValue ? result : getValue(result));
|
|
317
|
+
}
|
|
318
|
+
},
|
|
319
|
+
onInputChange: function onInputChange(event, result, reason) {
|
|
320
|
+
/* 此callback會經常被觸發 因此需要setState並搭配useEffect穩定觸發 */
|
|
321
|
+
if (result && typeof result === 'string' && reason === 'input') setCurrentResult(result);
|
|
322
|
+
},
|
|
323
|
+
onKeyDown: function onKeyDown(event) {
|
|
324
|
+
switch (event.key) {
|
|
325
|
+
case 'ArrowDown':
|
|
326
|
+
case 'ArrowUp':
|
|
327
|
+
setFocusItem(true);
|
|
328
|
+
break;
|
|
329
|
+
case 'Enter':
|
|
330
|
+
if (!isFocusItem) {
|
|
331
|
+
var enterFreeTyping = freeTyping && !multiple;
|
|
332
|
+
onEnter(event, enterFreeTyping ? {
|
|
333
|
+
label: keyword,
|
|
334
|
+
value: keyword
|
|
335
|
+
} : undefined);
|
|
336
|
+
if (enterFreeTyping) setCurrentDefaultValue({
|
|
337
|
+
label: keyword,
|
|
338
|
+
value: keyword
|
|
339
|
+
});
|
|
340
|
+
}
|
|
341
|
+
break;
|
|
342
|
+
default:
|
|
343
|
+
setFocusItem(false);
|
|
344
|
+
}
|
|
345
|
+
},
|
|
346
|
+
getOptionLabel: function getOptionLabel(option) {
|
|
347
|
+
return option && option.label || '';
|
|
348
|
+
},
|
|
349
|
+
getOptionDisabled: function getOptionDisabled(option) {
|
|
350
|
+
return option.disabled;
|
|
351
|
+
},
|
|
352
|
+
renderInput: function renderInput(params) {
|
|
353
|
+
return _renderInput && _renderInput(params) || defaultRenderInput(params);
|
|
354
|
+
},
|
|
355
|
+
renderTags: function renderTags(tagValue, getTagProps) {
|
|
356
|
+
var uniqueArray = getUniqueArray(tagValue) || tagValue;
|
|
357
|
+
return _renderTags && _renderTags(uniqueArray, getTagProps) || defaultTag(uniqueArray, getTagProps);
|
|
358
|
+
}
|
|
359
|
+
// popupIcon={<ExpandMore />}
|
|
360
|
+
,
|
|
361
|
+
popupIcon: null,
|
|
362
|
+
noOptionsText: /*#__PURE__*/React__default.createElement(Empty, null),
|
|
363
|
+
onFocus: onFocus,
|
|
364
|
+
onBlur: onBlur
|
|
365
|
+
}));
|
|
366
|
+
};
|
|
367
|
+
Autocomplete.defaultProps = {
|
|
368
|
+
className: undefined,
|
|
369
|
+
defaultValue: undefined,
|
|
370
|
+
renderAfterDefaultValueChange: false,
|
|
371
|
+
options: undefined,
|
|
372
|
+
freeTyping: false,
|
|
373
|
+
loading: false,
|
|
374
|
+
disabled: false,
|
|
375
|
+
labelInValue: true,
|
|
376
|
+
searchIcon: true,
|
|
377
|
+
multiple: false,
|
|
378
|
+
placeholder: 'Search...',
|
|
379
|
+
filterable: false,
|
|
380
|
+
renderInput: undefined,
|
|
381
|
+
renderTags: undefined,
|
|
382
|
+
onChange: function onChange() {},
|
|
383
|
+
onSearch: function onSearch() {},
|
|
384
|
+
onFocus: function onFocus() {},
|
|
385
|
+
onBlur: function onBlur() {},
|
|
386
|
+
onEnter: function onEnter() {},
|
|
387
|
+
arrowIcon: false
|
|
388
|
+
};
|
|
389
|
+
Autocomplete.propTypes = {
|
|
390
|
+
/** Css名稱 */
|
|
391
|
+
className: PropTypes.string,
|
|
392
|
+
/** 初始內容值 */
|
|
393
|
+
defaultValue: PropTypes.any,
|
|
394
|
+
/** 初始值變動後重新載入元件 */
|
|
395
|
+
renderAfterDefaultValueChange: PropTypes.bool,
|
|
396
|
+
/** 下拉選單內容 */
|
|
397
|
+
options: PropTypes.arrayOf(PropTypes.any),
|
|
398
|
+
/** 是否允許自由輸入 */
|
|
399
|
+
freeTyping: PropTypes.bool,
|
|
400
|
+
/** 是否載入中 */
|
|
401
|
+
loading: PropTypes.bool,
|
|
402
|
+
/** 是否禁止使用 */
|
|
403
|
+
disabled: PropTypes.bool,
|
|
404
|
+
/** onChange時 label value 一起回傳 */
|
|
405
|
+
labelInValue: PropTypes.bool,
|
|
406
|
+
/** 搜尋的圖案是否顯示 */
|
|
407
|
+
searchIcon: PropTypes.bool,
|
|
408
|
+
/** 是否複選 */
|
|
409
|
+
multiple: PropTypes.bool,
|
|
410
|
+
/** 提示字 */
|
|
411
|
+
placeholder: PropTypes.string,
|
|
412
|
+
/** 是否要啟動篩選功能(若關閉則option有什麼即顯示什麼) */
|
|
413
|
+
filterable: PropTypes.bool,
|
|
414
|
+
/** input客製化 */
|
|
415
|
+
renderInput: PropTypes.func,
|
|
416
|
+
/** 已選選項客製化 */
|
|
417
|
+
renderTags: PropTypes.func,
|
|
418
|
+
/** 變動時的callback */
|
|
419
|
+
onChange: PropTypes.func,
|
|
420
|
+
/** 搜尋時的callback */
|
|
421
|
+
onSearch: PropTypes.func,
|
|
422
|
+
/** Input被聚焦時的callback */
|
|
423
|
+
onFocus: PropTypes.func,
|
|
424
|
+
/** Input離開時的callback */
|
|
425
|
+
onBlur: PropTypes.func,
|
|
426
|
+
/** 鍵盤輸入Enter的callback */
|
|
427
|
+
onEnter: PropTypes.func,
|
|
428
|
+
/** 是否顯示arrow icon */
|
|
429
|
+
arrowIcon: PropTypes.bool
|
|
430
|
+
};
|
|
431
|
+
|
|
432
|
+
export { Autocomplete as A };
|
|
@@ -1 +1,19 @@
|
|
|
1
|
-
|
|
1
|
+
export { A as default } from './Autocomplete-887cda6a.js';
|
|
2
|
+
import './_rollupPluginBabelHelpers-a52356f6.js';
|
|
3
|
+
import 'react';
|
|
4
|
+
import 'prop-types';
|
|
5
|
+
import './index-ef96775f.js';
|
|
6
|
+
import './debounce-127da66c.js';
|
|
7
|
+
import './isObjectLike-e111475d.js';
|
|
8
|
+
import './_commonjsHelpers-70de2c37.js';
|
|
9
|
+
import '@material-ui/lab';
|
|
10
|
+
import '@material-ui/core';
|
|
11
|
+
import '@material-ui/icons';
|
|
12
|
+
import './createSvgIcon-0d38de2e.js';
|
|
13
|
+
import './defaultTheme-ed7746fe.js';
|
|
14
|
+
import 'react-is';
|
|
15
|
+
import '@material-ui/styles';
|
|
16
|
+
import 'react-dom';
|
|
17
|
+
import './toConsumableArray-dbe8af76.js';
|
|
18
|
+
import './style-inject.es-1f59c1d0.js';
|
|
19
|
+
import './Empty-94a8d8ff.js';
|
package/lib/components/Avatar.js
CHANGED
|
@@ -1 +1,53 @@
|
|
|
1
|
-
import
|
|
1
|
+
import React__default from 'react';
|
|
2
|
+
import { c as classNames } from './index-ef96775f.js';
|
|
3
|
+
import PropTypes from 'prop-types';
|
|
4
|
+
import { Avatar as Avatar$1 } from '@material-ui/core';
|
|
5
|
+
import { s as styleInject } from './style-inject.es-1f59c1d0.js';
|
|
6
|
+
|
|
7
|
+
var css_248z = "";
|
|
8
|
+
styleInject(css_248z);
|
|
9
|
+
|
|
10
|
+
var Avatar = function Avatar(_ref) {
|
|
11
|
+
var className = _ref.className,
|
|
12
|
+
shape = _ref.shape,
|
|
13
|
+
src = _ref.src,
|
|
14
|
+
_onError = _ref.onError,
|
|
15
|
+
_ref$defaultImg = _ref.defaultImg,
|
|
16
|
+
defaultImg = _ref$defaultImg === void 0 ? '' : _ref$defaultImg;
|
|
17
|
+
return /*#__PURE__*/React__default.createElement(React__default.Fragment, null, /*#__PURE__*/React__default.createElement(Avatar$1, {
|
|
18
|
+
className: classNames('avatar', className),
|
|
19
|
+
variant: shape,
|
|
20
|
+
src: src
|
|
21
|
+
}, defaultImg), typeof _onError === 'function' && /*#__PURE__*/React__default.createElement("img", {
|
|
22
|
+
src: src,
|
|
23
|
+
onError: function onError() {
|
|
24
|
+
return _onError();
|
|
25
|
+
},
|
|
26
|
+
alt: "test",
|
|
27
|
+
style: {
|
|
28
|
+
display: 'none'
|
|
29
|
+
}
|
|
30
|
+
}));
|
|
31
|
+
};
|
|
32
|
+
Avatar.defaultProps = {
|
|
33
|
+
className: undefined,
|
|
34
|
+
shape: 'circular',
|
|
35
|
+
src: undefined,
|
|
36
|
+
onError: undefined,
|
|
37
|
+
defaultImg: undefined
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
/* Write props detail information and 'npm run updateStory' will help you generate stories's argTypes */
|
|
41
|
+
Avatar.propTypes = {
|
|
42
|
+
/** Css Name */
|
|
43
|
+
className: PropTypes.string,
|
|
44
|
+
/** 形狀 */
|
|
45
|
+
shape: PropTypes.oneOf(['circle', 'circular', 'rounded', 'square']),
|
|
46
|
+
/** 圖片來源 */
|
|
47
|
+
src: PropTypes.string,
|
|
48
|
+
/** 圖片有錯誤則callback */
|
|
49
|
+
onError: PropTypes.func,
|
|
50
|
+
defaultImg: PropTypes.string
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
export { Avatar as default };
|
|
@@ -1 +1,109 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { a as _slicedToArray } from './_rollupPluginBabelHelpers-a52356f6.js';
|
|
2
|
+
import React__default, { useState, useRef, useEffect } from 'react';
|
|
3
|
+
import PropTypes from 'prop-types';
|
|
4
|
+
import { c as classNames } from './index-ef96775f.js';
|
|
5
|
+
import { d as debounce_1 } from './debounce-127da66c.js';
|
|
6
|
+
import { Fade, NoSsr, Box } from '@material-ui/core';
|
|
7
|
+
import { r as requireCreateSvgIcon, i as interopRequireDefault, a as interopRequireWildcard } from './createSvgIcon-0d38de2e.js';
|
|
8
|
+
import { s as styleInject } from './style-inject.es-1f59c1d0.js';
|
|
9
|
+
import './isObjectLike-e111475d.js';
|
|
10
|
+
import './_commonjsHelpers-70de2c37.js';
|
|
11
|
+
import './defaultTheme-ed7746fe.js';
|
|
12
|
+
import 'react-is';
|
|
13
|
+
import '@material-ui/styles';
|
|
14
|
+
import 'react-dom';
|
|
15
|
+
|
|
16
|
+
var ExpandLessSharp = {};
|
|
17
|
+
|
|
18
|
+
var _interopRequireDefault = interopRequireDefault.exports;
|
|
19
|
+
|
|
20
|
+
var _interopRequireWildcard = interopRequireWildcard.exports;
|
|
21
|
+
|
|
22
|
+
Object.defineProperty(ExpandLessSharp, "__esModule", {
|
|
23
|
+
value: true
|
|
24
|
+
});
|
|
25
|
+
var default_1 = ExpandLessSharp.default = void 0;
|
|
26
|
+
|
|
27
|
+
var React = _interopRequireWildcard(React__default);
|
|
28
|
+
|
|
29
|
+
var _createSvgIcon = _interopRequireDefault(requireCreateSvgIcon());
|
|
30
|
+
|
|
31
|
+
var _default = (0, _createSvgIcon.default)( /*#__PURE__*/React.createElement("path", {
|
|
32
|
+
d: "M12 8l-6 6 1.41 1.41L12 10.83l4.59 4.58L18 14l-6-6z"
|
|
33
|
+
}), 'ExpandLessSharp');
|
|
34
|
+
|
|
35
|
+
default_1 = ExpandLessSharp.default = _default;
|
|
36
|
+
|
|
37
|
+
var css_248z = ".backTop {\n right: 30px;\n bottom: 50px;\n position: fixed;\n z-index: 10;\n opacity: 0;\n cursor: pointer;\n}\n.backTop__default {\n display: flex;\n flex-direction: column;\n align-items: center;\n justify-content: center;\n width: 70px;\n height: 70px;\n border-radius: 45px;\n opacity: 0.8;\n transition: opacity 0.3s ease-in-out;\n}\n.backTop__default:hover {\n opacity: 1;\n}\n.backTop__default .MuiSvgIcon-root {\n margin-bottom: -3px;\n}\n.backTop:hover {\n opacity: 0.7;\n}\n\n@media only screen and (max-width: 484px) {\n .backTop {\n right: 15px;\n }\n}";
|
|
38
|
+
styleInject(css_248z);
|
|
39
|
+
|
|
40
|
+
var scrollToTop = function scrollToTop() {
|
|
41
|
+
if (window.scrollTo) {
|
|
42
|
+
window.scrollTo({
|
|
43
|
+
top: 0,
|
|
44
|
+
left: 0,
|
|
45
|
+
behavior: 'smooth'
|
|
46
|
+
});
|
|
47
|
+
} else {
|
|
48
|
+
window.scrollTop = 0;
|
|
49
|
+
}
|
|
50
|
+
};
|
|
51
|
+
var BackTop = function BackTop(props) {
|
|
52
|
+
var className = props.className,
|
|
53
|
+
visibilityHeight = props.visibilityHeight,
|
|
54
|
+
_onClick = props.onClick,
|
|
55
|
+
children = props.children;
|
|
56
|
+
var _useState = useState(false),
|
|
57
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
58
|
+
show = _useState2[0],
|
|
59
|
+
setShow = _useState2[1];
|
|
60
|
+
var scrollDebounce = useRef(debounce_1(function () {
|
|
61
|
+
var top = window.scrollY;
|
|
62
|
+
setShow(top >= visibilityHeight);
|
|
63
|
+
}, 100)).current;
|
|
64
|
+
useEffect(function () {
|
|
65
|
+
// const scrollEvent = () => scrollDebounce.current;
|
|
66
|
+
window.addEventListener('scroll', function () {
|
|
67
|
+
return scrollDebounce();
|
|
68
|
+
});
|
|
69
|
+
return function () {
|
|
70
|
+
window.removeEventListener('scroll', function () {
|
|
71
|
+
return scrollDebounce();
|
|
72
|
+
});
|
|
73
|
+
};
|
|
74
|
+
}, []);
|
|
75
|
+
return /*#__PURE__*/React__default.createElement(Fade, {
|
|
76
|
+
in: show,
|
|
77
|
+
timeout: 500,
|
|
78
|
+
unmountOnExit: true
|
|
79
|
+
}, /*#__PURE__*/React__default.createElement("div", {
|
|
80
|
+
className: classNames('backTop', className),
|
|
81
|
+
onClick: function onClick() {
|
|
82
|
+
scrollToTop();
|
|
83
|
+
_onClick();
|
|
84
|
+
}
|
|
85
|
+
}, children ? /*#__PURE__*/React__default.createElement("div", null, children) : /*#__PURE__*/React__default.createElement(NoSsr, null, /*#__PURE__*/React__default.createElement(Box, {
|
|
86
|
+
className: "backTop__default",
|
|
87
|
+
color: "text.primary",
|
|
88
|
+
bgcolor: "primary.main",
|
|
89
|
+
borderColor: "text.secondary"
|
|
90
|
+
}, /*#__PURE__*/React__default.createElement(default_1, null), "Top"))));
|
|
91
|
+
};
|
|
92
|
+
BackTop.defaultProps = {
|
|
93
|
+
className: undefined,
|
|
94
|
+
visibilityHeight: 300,
|
|
95
|
+
onClick: function onClick() {},
|
|
96
|
+
children: undefined
|
|
97
|
+
};
|
|
98
|
+
BackTop.propTypes = {
|
|
99
|
+
/** Css Name */
|
|
100
|
+
className: PropTypes.string,
|
|
101
|
+
/** 可視返回Icon的高度偵測 */
|
|
102
|
+
visibilityHeight: PropTypes.number,
|
|
103
|
+
/** 點擊後的Callback */
|
|
104
|
+
onClick: PropTypes.func,
|
|
105
|
+
/** custom */
|
|
106
|
+
children: PropTypes.node
|
|
107
|
+
};
|
|
108
|
+
|
|
109
|
+
export { BackTop as default };
|