@daoyi/nmtl-ui 2.0.1-beta.9 → 2.0.1-beta.90

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 (104) hide show
  1. package/README.md +45 -45
  2. package/lib/components/Autocomplete-24e9686d.js +423 -0
  3. package/lib/components/Autocomplete.js +19 -1
  4. package/lib/components/Avatar.js +53 -1
  5. package/lib/components/BackTop.js +109 -1
  6. package/lib/components/BarChart.js +762 -1
  7. package/lib/components/Breadcrumbs.js +122 -1
  8. package/lib/components/Button-430d39e6.js +92 -0
  9. package/lib/components/Button.js +6 -1
  10. package/lib/components/Carousel.js +4713 -1
  11. package/lib/components/Checkbox.js +37 -1
  12. package/lib/components/CollapseContent.js +179 -1
  13. package/lib/components/ContactModal-523ae294.js +12030 -0
  14. package/lib/components/ContactModal.js +22 -3
  15. package/lib/components/Drawer-ec47e780.js +156 -0
  16. package/lib/components/Drawer.js +11 -1
  17. package/lib/components/Dropdown.js +134 -1
  18. package/lib/components/Empty-dc5fc2fc.js +45 -0
  19. package/lib/components/Empty.js +5 -1
  20. package/lib/components/ExportButton.js +112 -1
  21. package/lib/components/ExtraTools-0ffc772b.js +3598 -0
  22. package/lib/components/ExtraTools.js +10 -22
  23. package/lib/components/Filter.js +782 -12
  24. package/lib/components/Footer.js +271 -1
  25. package/lib/components/ForwardLink-15222b22.js +106 -0
  26. package/lib/components/ForwardLink.js +8 -0
  27. package/lib/components/Header.js +194 -1
  28. package/lib/components/Image.js +61 -1
  29. package/lib/components/Input.js +82 -1
  30. package/lib/components/InputMethod.js +33937 -10
  31. package/lib/components/KeywordSearch-91167d24.js +144 -0
  32. package/lib/components/KeywordSearch.js +21 -1
  33. package/lib/components/KeywordTicker.js +190 -1
  34. package/lib/components/Keywords.js +317 -1
  35. package/lib/components/Loading.js +28 -1
  36. package/lib/components/MUITheme.js +2624 -1
  37. package/lib/components/Modal-6b8c72d7.js +108 -0
  38. package/lib/components/Modal.js +9 -1
  39. package/lib/components/MoreButton-4d5d94da.js +110 -0
  40. package/lib/components/MoreButton.js +6 -1
  41. package/lib/components/Pagination.js +3637 -0
  42. package/lib/components/Radio.js +78 -1
  43. package/lib/components/SNA.js +1691 -22
  44. package/lib/components/Select-7da870e0.js +115 -0
  45. package/lib/components/Select.js +8 -1
  46. package/lib/components/Spin-9a07b106.js +75 -0
  47. package/lib/components/Spin.js +6 -1
  48. package/lib/components/Table.js +51 -1
  49. package/lib/components/Tooltip-6d53cb6e.js +70 -0
  50. package/lib/components/Tooltip.js +7 -1
  51. package/lib/components/_commonjsHelpers-70de2c37.js +28 -0
  52. package/lib/components/_rollupPluginBabelHelpers-ed61ffc0.js +160 -0
  53. package/lib/components/createSvgIcon-ff0e3b99.js +576 -0
  54. package/lib/components/dataExport-d55d6fa3.js +92 -0
  55. package/lib/components/debounce-127da66c.js +355 -0
  56. package/lib/components/defaultTheme-ed7746fe.js +1661 -0
  57. package/lib/components/globalConfig.js +191 -0
  58. package/lib/components/hoist-non-react-statics.cjs-3f408ad2.js +105 -0
  59. package/lib/components/index-a6f22b92.js +481 -0
  60. package/lib/components/index-f491ebce.js +61 -0
  61. package/lib/components/isObjectLike-e111475d.js +190 -0
  62. package/lib/components/style-inject.es-1f59c1d0.js +28 -1
  63. package/lib/components/toConsumableArray-dbe8af76.js +19 -0
  64. package/lib/components/transform-3a04288b.js +5475 -0
  65. package/lib/components/withTheme-2d778133.js +6 -0
  66. package/lib/configs/config.selector.js +151 -0
  67. package/lib/configs/index.d.ts +1 -0
  68. package/lib/configs/index.js +1 -0
  69. package/lib/index.d.ts +2 -0
  70. package/lib/index.js +2 -0
  71. package/lib/utils/_rollupPluginBabelHelpers-a6e0e6e3.js +139 -0
  72. package/lib/utils/arrayMerge.js +4953 -1
  73. package/lib/utils/chunkArray.js +15 -1
  74. package/lib/utils/convert2HtmlEntities.js +42 -1
  75. package/lib/utils/domToImage.js +802 -1
  76. package/lib/utils/downloadGephi.js +106 -1
  77. package/lib/utils/exportXlsx.js +219 -1
  78. package/lib/utils/historyAppendSearch.js +502 -1
  79. package/lib/utils/isDevelopMode.js +5 -1
  80. package/lib/utils/parseYMD.js +36 -1
  81. package/lib/utils/removeDuplicateItem.js +11 -1
  82. package/lib/utils/sendEmail.js +39 -1
  83. package/lib/utils/snaDefine-6a2bcd94.js +5 -0
  84. package/lib/utils/snaDefine.js +1 -1
  85. package/lib/utils/snaPreProcess.js +84 -1
  86. package/package.json +125 -127
  87. package/lib/components/Empty-54b79907.js +0 -1
  88. package/lib/components/KeywordSearch-5a393f12.js +0 -1
  89. package/lib/components/Select-f2441b83.js +0 -1
  90. package/lib/components/_rollupPluginBabelHelpers-1b8c042f.js +0 -1
  91. package/lib/components/_rollupPluginBabelHelpers-ec4e2a53.js +0 -1
  92. package/lib/components/createSvgIcon-62b64929.js +0 -1
  93. package/lib/components/createSvgIcon-e24792d4.js +0 -1
  94. package/lib/components/createTheme-7fffa109.js +0 -1
  95. package/lib/components/dataExport-9fccd4f0.js +0 -1
  96. package/lib/components/debounce-c993109b.js +0 -1
  97. package/lib/components/hoist-non-react-statics.cjs-d6a9befd.js +0 -1
  98. package/lib/components/index-11391ca3.js +0 -7
  99. package/lib/components/index-b2745105.js +0 -7
  100. package/lib/components/isObjectLike-2f1983fe.js +0 -1
  101. package/lib/components/style-inject.es-c875d022.js +0 -1
  102. package/lib/components/transform-95ae0119.js +0 -1
  103. package/lib/utils/_commonjsHelpers-e2cda605.js +0 -1
  104. package/lib/utils/_rollupPluginBabelHelpers-928a52ce.js +0 -1
package/README.md CHANGED
@@ -1,45 +1,45 @@
1
- # react-storybook-jsx-starter
2
-
3
- This project based
4
-
5
- This project is bootstrapped with the following
6
- - [Create React App](https://github.com/facebook/create-react-app)
7
- - [Storybook/react v.6.3.5](https://storybook.js.org/)
8
- - [Rollup v.2.54.0](https://rollupjs.org/guide/en/)
9
- - [Airbnb esint config v.18.0.0](https://www.npmjs.com/package/eslint-config-airbnb)
10
-
11
- ## Getting Started
12
-
13
-
14
- ## Available Scripts
15
-
16
- In the project directory, you can run:
17
-
18
- ### `yarn start` and `yarn storybook`
19
-
20
- Runs storybook.<br>
21
- Open [http://localhost:6006](http://localhost:6006) to view it in the browser.
22
- The page will reload if you make component edits.
23
-
24
- ### `yarn create`
25
-
26
- Help you create component or util. It will automatic generate `folder`, `JSX`, `.store.jsx`.
27
-
28
- ### `yarn lint`
29
-
30
- Runs airbnb linting config.<br>
31
- Please refer to `.eslintrc` for more details in rules that are excluded/added from the initial Airbnb configuration, which can be found [here](https://www.npmjs.com/package/eslint-config-airbnb)
32
- Notice: If developer using visual code IDE, download `eslint` and `prettier` extensions to help you develop.
33
-
34
- ### `yarn build`
35
-
36
- Builds the component library using rollup.<br>
37
- This runs a set of defined configurations under `rollup.config.js` file.<br>
38
- Index.js & index.ts will automatic generated by `rollup.index.js` file.
39
-
40
-
41
- ### `yarn build-storybook`
42
-
43
- Builds static files for storybook site. This is so it can be deployed as the docs source for the component library.
44
-
45
-
1
+ # react-storybook-jsx-starter
2
+
3
+ This project based
4
+
5
+ This project is bootstrapped with the following
6
+ - [Create React App](https://github.com/facebook/create-react-app)
7
+ - [Storybook/react v.6.3.5](https://storybook.js.org/)
8
+ - [Rollup v.2.54.0](https://rollupjs.org/guide/en/)
9
+ - [Airbnb esint config v.18.0.0](https://www.npmjs.com/package/eslint-config-airbnb)
10
+
11
+ ## Getting Started
12
+
13
+
14
+ ## Available Scripts
15
+
16
+ In the project directory, you can run:
17
+
18
+ ### `yarn start` and `yarn storybook`
19
+
20
+ Runs storybook.<br>
21
+ Open [http://localhost:6006](http://localhost:6006) to view it in the browser.
22
+ The page will reload if you make component edits.
23
+
24
+ ### `yarn create`
25
+
26
+ Help you create component or util. It will automatic generate `folder`, `JSX`, `.store.jsx`.
27
+
28
+ ### `yarn lint`
29
+
30
+ Runs airbnb linting config.<br>
31
+ Please refer to `.eslintrc` for more details in rules that are excluded/added from the initial Airbnb configuration, which can be found [here](https://www.npmjs.com/package/eslint-config-airbnb)
32
+ Notice: If developer using visual code IDE, download `eslint` and `prettier` extensions to help you develop.
33
+
34
+ ### `yarn build`
35
+
36
+ Builds the component library using rollup.<br>
37
+ This runs a set of defined configurations under `rollup.config.js` file.<br>
38
+ Index.js & index.ts will automatic generated by `rollup.index.js` file.
39
+
40
+
41
+ ### `yarn build-storybook`
42
+
43
+ Builds static files for storybook site. This is so it can be deployed as the docs source for the component library.
44
+
45
+
@@ -0,0 +1,423 @@
1
+ import { _ as _extends$1, a as _slicedToArray, b as _objectSpread2 } from './_rollupPluginBabelHelpers-ed61ffc0.js';
2
+ import React__default, { useCallback, useState, useRef, useEffect } from 'react';
3
+ import PropTypes from 'prop-types';
4
+ import { c as classNames } from './index-f491ebce.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-ff0e3b99.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-dc5fc2fc.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
+ /* 若MUI的Autocomplete下方的options列表要勾選已選的項目 必須從options取出才可 */
118
+ const getValueFromOptions = useCallback(defaultValue => {
119
+ if (Array.isArray(options)) {
120
+ if (Array.isArray(defaultValue)) {
121
+ return defaultValue.map(
122
+ // item有可能為 object({ label, value }) 或 string(value)
123
+ item => options.find(_ref2 => {
124
+ let {
125
+ value
126
+ } = _ref2;
127
+ return item === value || item.value === value;
128
+ }) || item
129
+ // if (typeof item === 'object') return options.find(({ value }) => item.value === value) || item;
130
+ // return item;
131
+ );
132
+ }
133
+
134
+ const result = options.find(_ref3 => {
135
+ let {
136
+ value
137
+ } = _ref3;
138
+ return defaultValue === value;
139
+ });
140
+ return labelInValue ? defaultValue : result || {
141
+ label: defaultValue,
142
+ value: defaultValue
143
+ };
144
+ }
145
+ return defaultValue;
146
+ }, [options, labelInValue]);
147
+ const defaultTag = useCallback((tagValue, getTagProps) => tagValue.map((option, index) => /*#__PURE__*/React__default.createElement(Chip, _extends$1({
148
+ label: getLabel(option),
149
+ deleteIcon: /*#__PURE__*/React__default.createElement(Close, null)
150
+ }, getTagProps({
151
+ index
152
+ })))), [options]);
153
+ const defaultRenderInput = useCallback(params => /*#__PURE__*/React__default.createElement(TextField, _extends$1({}, params, {
154
+ variant: "outlined",
155
+ placeholder: placeholder,
156
+ InputProps: {
157
+ ...params.InputProps,
158
+ endAdornment: /*#__PURE__*/React__default.createElement(React__default.Fragment, null, loading && /*#__PURE__*/React__default.createElement(CircularProgress, {
159
+ className: "autocomplete__icon",
160
+ color: "inherit",
161
+ size: 20
162
+ }), searchIcon && /*#__PURE__*/React__default.createElement(SearchOutlined, {
163
+ className: "autocomplete__icon",
164
+ onClick: event => {
165
+ const tmpObj = {
166
+ labels: currentResult || '',
167
+ value: currentResult || ''
168
+ };
169
+ setCurrentDefaultValue(tmpObj);
170
+ return onEnter(event, tmpObj);
171
+ }
172
+ }), !searchIcon && !loading && arrowIcon && /*#__PURE__*/React__default.createElement(Box, {
173
+ style: {
174
+ top: 'calc(50% - 14px)',
175
+ right: '12px',
176
+ position: 'absolute'
177
+ }
178
+ }, /*#__PURE__*/React__default.createElement(default_1, null)), params.InputProps.endAdornment)
179
+ }
180
+ })), [loading, searchIcon, arrowIcon]);
181
+ return {
182
+ getValue,
183
+ getValueFromOptions,
184
+ defaultTag,
185
+ defaultRenderInput
186
+ };
187
+ });
188
+
189
+ 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}";
190
+ styleInject(css_248z);
191
+
192
+ var Autocomplete = function Autocomplete(props) {
193
+ var options = props.options,
194
+ defaultValue = props.defaultValue,
195
+ renderAfterDefaultValueChange = props.renderAfterDefaultValueChange,
196
+ filterable = props.filterable,
197
+ loading = props.loading,
198
+ labelInValue = props.labelInValue,
199
+ disabled = props.disabled;
200
+ var className = props.className,
201
+ multiple = props.multiple,
202
+ freeTyping = props.freeTyping,
203
+ placeholder = props.placeholder,
204
+ searchIcon = props.searchIcon,
205
+ _renderInput = props.renderInput,
206
+ _renderTags = props.renderTags;
207
+ var _onChange = props.onChange,
208
+ onSearch = props.onSearch,
209
+ onFocus = props.onFocus,
210
+ onBlur = props.onBlur,
211
+ onEnter = props.onEnter,
212
+ arrowIcon = props.arrowIcon;
213
+ var _useState = useState(true),
214
+ _useState2 = _slicedToArray(_useState, 2),
215
+ rerender = _useState2[0],
216
+ setRerender = _useState2[1];
217
+ var _useState3 = useState(),
218
+ _useState4 = _slicedToArray(_useState3, 2),
219
+ keyword = _useState4[0],
220
+ setKeyword = _useState4[1];
221
+ var _useState5 = useState(),
222
+ _useState6 = _slicedToArray(_useState5, 2),
223
+ currentResult = _useState6[0],
224
+ setCurrentResult = _useState6[1];
225
+ var _useState7 = useState(),
226
+ _useState8 = _slicedToArray(_useState7, 2),
227
+ isFocusItem = _useState8[0],
228
+ setFocusItem = _useState8[1];
229
+ var _useState9 = useState(),
230
+ _useState10 = _slicedToArray(_useState9, 2),
231
+ currentDefaultValue = _useState10[0],
232
+ setCurrentDefaultValue = _useState10[1];
233
+ var _useAutocomplete = useAutocomplete(_objectSpread2({}, {
234
+ options: options,
235
+ placeholder: placeholder,
236
+ loading: loading,
237
+ searchIcon: searchIcon,
238
+ labelInValue: labelInValue,
239
+ currentResult: currentResult,
240
+ onEnter: onEnter,
241
+ setCurrentDefaultValue: setCurrentDefaultValue,
242
+ arrowIcon: arrowIcon
243
+ })),
244
+ getValue = _useAutocomplete.getValue,
245
+ getValueFromOptions = _useAutocomplete.getValueFromOptions,
246
+ defaultTag = _useAutocomplete.defaultTag,
247
+ defaultRenderInput = _useAutocomplete.defaultRenderInput;
248
+ var handleSearch = useRef(debounce_1(function (result) {
249
+ return onSearch(result);
250
+ }, 500)).current;
251
+
252
+ // 複選時 defaultValue 必須為Array
253
+ // const currentDefaultValue = typeof defaultValue === 'string' && multiple ? undefined : getValueFromOptions(defaultValue);
254
+ useEffect(function () {
255
+ setCurrentDefaultValue(typeof defaultValue === 'string' && multiple ? {
256
+ label: keyword,
257
+ value: keyword
258
+ } : getValueFromOptions(defaultValue));
259
+ }, [JSON.stringify(defaultValue)]);
260
+ useEffect(function () {
261
+ if (renderAfterDefaultValueChange) setRerender(false);
262
+ }, [currentDefaultValue]); // defaultValue改變時強制rerender
263
+ useEffect(function () {
264
+ if (!rerender) setRerender(true);
265
+ }, [rerender]);
266
+ /* 監聽result變化時才觸發onSearch */
267
+ useEffect(function () {
268
+ if (currentResult) {
269
+ setKeyword(currentResult);
270
+ handleSearch(currentResult);
271
+ }
272
+ }, [currentResult]);
273
+
274
+ /* 這邊邏輯很複雜 變動需再三確認case */
275
+ return /*#__PURE__*/React__default.createElement("div", {
276
+ className: classNames('autocomplete', {
277
+ 'autocomplete--showSearchIcon': searchIcon
278
+ }, className)
279
+ }, rerender && /*#__PURE__*/React__default.createElement(Autocomplete$1, {
280
+ className: "autocomplete__component",
281
+ options: Array.isArray(options) && (freeTyping && keyword ? [{
282
+ label: keyword,
283
+ value: keyword
284
+ }].concat(options) : options) || []
285
+ // value="asd"
286
+ ,
287
+ defaultValue: currentDefaultValue,
288
+ disabled: disabled,
289
+ multiple: multiple
290
+ // 篩選機制(依據filterable決定是否要render全部)
291
+ ,
292
+ filterOptions: function filterOptions(optionList, input) {
293
+ var _input$inputValue = input.inputValue,
294
+ inputValue = _input$inputValue === void 0 ? '' : _input$inputValue;
295
+ return (Array.isArray(optionList) ? optionList : []).filter(function (item) {
296
+ var _ref = item || {},
297
+ _ref$label = _ref.label,
298
+ label = _ref$label === void 0 ? '' : _ref$label;
299
+ return filterable ? label.toLowerCase().indexOf(inputValue.toLowerCase()) > -1 : true;
300
+ });
301
+ },
302
+ onChange: function onChange(event, result) {
303
+ if (Array.isArray(result)) {
304
+ _onChange(result.map(function (item) {
305
+ return labelInValue ? item : getValue(item);
306
+ }));
307
+ } else if (result) {
308
+ _onChange(labelInValue ? result : getValue(result));
309
+ }
310
+ },
311
+ onInputChange: function onInputChange(event, result, reason) {
312
+ /* 此callback會經常被觸發 因此需要setState並搭配useEffect穩定觸發 */
313
+ if (result && typeof result === 'string' && reason === 'input') setCurrentResult(result);
314
+ },
315
+ onKeyDown: function onKeyDown(event) {
316
+ switch (event.key) {
317
+ case 'ArrowDown':
318
+ case 'ArrowUp':
319
+ setFocusItem(true);
320
+ break;
321
+ case 'Enter':
322
+ if (!isFocusItem) {
323
+ var enterFreeTyping = freeTyping && !multiple;
324
+ onEnter(event, enterFreeTyping ? {
325
+ label: keyword,
326
+ value: keyword
327
+ } : undefined);
328
+ if (enterFreeTyping) setCurrentDefaultValue({
329
+ label: keyword,
330
+ value: keyword
331
+ });
332
+ }
333
+ break;
334
+ default:
335
+ setFocusItem(false);
336
+ }
337
+ },
338
+ getOptionLabel: function getOptionLabel(option) {
339
+ return option && option.label || '';
340
+ },
341
+ getOptionDisabled: function getOptionDisabled(option) {
342
+ return option.disabled;
343
+ },
344
+ renderInput: function renderInput(params) {
345
+ return _renderInput && _renderInput(params) || defaultRenderInput(params);
346
+ },
347
+ renderTags: function renderTags(tagValue, getTagProps) {
348
+ return _renderTags && _renderTags(tagValue, getTagProps) || defaultTag(tagValue, getTagProps);
349
+ }
350
+ // popupIcon={<ExpandMore />}
351
+ ,
352
+ popupIcon: null,
353
+ noOptionsText: /*#__PURE__*/React__default.createElement(Empty, null),
354
+ onFocus: onFocus,
355
+ onBlur: onBlur
356
+ }));
357
+ };
358
+ Autocomplete.defaultProps = {
359
+ className: undefined,
360
+ defaultValue: undefined,
361
+ renderAfterDefaultValueChange: false,
362
+ options: undefined,
363
+ freeTyping: false,
364
+ loading: false,
365
+ disabled: false,
366
+ labelInValue: true,
367
+ searchIcon: true,
368
+ multiple: false,
369
+ placeholder: 'Search...',
370
+ filterable: false,
371
+ renderInput: undefined,
372
+ renderTags: undefined,
373
+ onChange: function onChange() {},
374
+ onSearch: function onSearch() {},
375
+ onFocus: function onFocus() {},
376
+ onBlur: function onBlur() {},
377
+ onEnter: function onEnter() {},
378
+ arrowIcon: false
379
+ };
380
+ Autocomplete.propTypes = {
381
+ /** Css名稱 */
382
+ className: PropTypes.string,
383
+ /** 初始內容值 */
384
+ defaultValue: PropTypes.any,
385
+ /** 初始值變動後重新載入元件 */
386
+ renderAfterDefaultValueChange: PropTypes.bool,
387
+ /** 下拉選單內容 */
388
+ options: PropTypes.arrayOf(PropTypes.any),
389
+ /** 是否允許自由輸入 */
390
+ freeTyping: PropTypes.bool,
391
+ /** 是否載入中 */
392
+ loading: PropTypes.bool,
393
+ /** 是否禁止使用 */
394
+ disabled: PropTypes.bool,
395
+ /** onChange時 label value 一起回傳 */
396
+ labelInValue: PropTypes.bool,
397
+ /** 搜尋的圖案是否顯示 */
398
+ searchIcon: PropTypes.bool,
399
+ /** 是否複選 */
400
+ multiple: PropTypes.bool,
401
+ /** 提示字 */
402
+ placeholder: PropTypes.string,
403
+ /** 是否要啟動篩選功能(若關閉則option有什麼即顯示什麼) */
404
+ filterable: PropTypes.bool,
405
+ /** input客製化 */
406
+ renderInput: PropTypes.func,
407
+ /** 已選選項客製化 */
408
+ renderTags: PropTypes.func,
409
+ /** 變動時的callback */
410
+ onChange: PropTypes.func,
411
+ /** 搜尋時的callback */
412
+ onSearch: PropTypes.func,
413
+ /** Input被聚焦時的callback */
414
+ onFocus: PropTypes.func,
415
+ /** Input離開時的callback */
416
+ onBlur: PropTypes.func,
417
+ /** 鍵盤輸入Enter的callback */
418
+ onEnter: PropTypes.func,
419
+ /** 是否顯示arrow icon */
420
+ arrowIcon: PropTypes.bool
421
+ };
422
+
423
+ export { Autocomplete as A };
@@ -1 +1,19 @@
1
- import{_ as e,a as n,b as o}from"./_rollupPluginBabelHelpers-ec4e2a53.js";import t,{useCallback as r,useState as a,useRef as l,useEffect as u}from"react";import i from"prop-types";import{c}from"./index-b2745105.js";import{d as p}from"./debounce-c993109b.js";import{Autocomplete as s}from"@material-ui/lab";import{Chip as f,TextField as d,CircularProgress as m}from"@material-ui/core";import{Close as b,SearchOutlined as g}from"@material-ui/icons";import h from"./Empty.js";import{s as y}from"./style-inject.es-1f59c1d0.js";y(".autocomplete .MuiAutocomplete-inputRoot[class*='MuiOutlinedInput-root'] {\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\n.autocomplete--showSearchIcon .MuiAutocomplete-inputRoot[class*='MuiOutlinedInput-root'] {\n display: flex;\n flex-wrap: nowrap;\n padding: 4px 8px; }\n");var I=function(i){var y=i.options,I=i.defaultValue,v=i.renderAfterDefaultValueChange,A=i.filterable,V=i.loading,x=i.labelInValue,E=i.disabled,w=i.className,C=i.multiple,O=i.freeTyping,T=i.placeholder,_=i.searchIcon,j=i.renderInput,N=i.renderTags,F=i.onChange,S=i.onSearch,D=i.onFocus,B=i.onBlur,M=i.onEnter,P=a(!0),R=n(P,2),k=R[0],L=R[1],z=a(),H=n(z,2),J=H[0],K=H[1],U=a(),q=n(U,2),G=q[0],Q=q[1],W=a(),X=n(W,2),Y=X[0],Z=X[1],$=a(),ee=n($,2),ne=ee[0],oe=ee[1],te=(n=>{let{options:o,placeholder:a,loading:l,searchIcon:u,labelInValue:i}=n;const c=r((e=>"object"==typeof e?e.value:e),[]),p=r((e=>{const n=(Array.isArray(o)?o:[]).find((n=>c(n)===c(e)));return n?"object"==typeof n?n.label:n:"object"==typeof e?e.label:e}),[o]),s=r((e=>{if(Array.isArray(o)){if(Array.isArray(e))return e.map((e=>o.find((n=>{let{value:o}=n;return e===o||e.value===o}))||e));const n=o.find((n=>{let{value:o}=n;return e===o}));return i?e:n||{label:e,value:e}}return e}),[o,i]),h=r(((n,o)=>n.map(((n,r)=>t.createElement(f,e({label:p(n),deleteIcon:t.createElement(b,null)},o({index:r})))))),[o]),y=r((n=>t.createElement(d,e({},n,{variant:"outlined",placeholder:a,InputProps:{...n.InputProps,endAdornment:t.createElement(t.Fragment,null,l&&t.createElement(m,{className:"autocomplete__icon",color:"inherit",size:20}),u&&t.createElement(g,{className:"autocomplete__icon"}),n.InputProps.endAdornment)}}))),[l,u]);return{getValue:c,getValueFromOptions:s,defaultTag:h,defaultRenderInput:y}})(o({},{options:y,placeholder:T,loading:V,searchIcon:_,labelInValue:x})),re=te.getValue,ae=te.getValueFromOptions,le=te.defaultTag,ue=te.defaultRenderInput,ie=l(p((function(e){return S(e)}),500)).current;return u((function(){oe("string"==typeof I&&C?{label:J,value:J}:ae(I))}),[JSON.stringify(I)]),u((function(){v&&L(!1)}),[ne]),u((function(){k||L(!0)}),[k]),u((function(){G&&(K(G),ie(G))}),[G]),t.createElement("div",{className:c("autocomplete",{"autocomplete--showSearchIcon":_},w)},k&&t.createElement(s,{className:"autocomplete__component",options:Array.isArray(y)&&(O&&J?[{label:J,value:J}].concat(y):y)||[],defaultValue:ne,disabled:E,multiple:C,filterOptions:function(e,n){var o=n.inputValue,t=void 0===o?"":o;return(Array.isArray(e)?e:[]).filter((function(e){var n=(e||{}).label;return!A||(void 0===n?"":n).toLowerCase().indexOf(t.toLowerCase())>-1}))},onChange:function(e,n){Array.isArray(n)?F(n.map((function(e){return x?e:re(e)}))):n&&F(x?n:re(n))},onInputChange:function(e,n,o){n&&"string"==typeof n&&"input"===o&&Q(n)},onKeyDown:function(e){switch(e.key){case"ArrowDown":case"ArrowUp":Z(!0);break;case"Enter":if(!Y){var n=O&&!C;M(e,n?{label:J,value:J}:void 0),n&&oe({label:J,value:J})}break;default:Z(!1)}},getOptionLabel:function(e){return e&&e.label||""},getOptionDisabled:function(e){return e.disabled},renderInput:function(e){return j&&j(e)||ue(e)},renderTags:function(e,n){return N&&N(e,n)||le(e,n)},popupIcon:null,noOptionsText:t.createElement(h,null),onFocus:D,onBlur:B}))};I.defaultProps={className:void 0,defaultValue:void 0,renderAfterDefaultValueChange:!1,options:void 0,freeTyping:!1,loading:!1,disabled:!1,labelInValue:!0,searchIcon:!0,multiple:!1,placeholder:"Search...",filterable:!1,renderInput:void 0,renderTags:void 0,onChange:function(){},onSearch:function(){},onFocus:function(){},onBlur:function(){},onEnter:function(){}},I.propTypes={className:i.string,defaultValue:i.any,renderAfterDefaultValueChange:i.bool,options:i.arrayOf(i.any),freeTyping:i.bool,loading:i.bool,disabled:i.bool,labelInValue:i.bool,searchIcon:i.bool,multiple:i.bool,placeholder:i.string,filterable:i.bool,renderInput:i.func,renderTags:i.func,onChange:i.func,onSearch:i.func,onFocus:i.func,onBlur:i.func,onEnter:i.func};export{I as default};
1
+ export { A as default } from './Autocomplete-24e9686d.js';
2
+ import './_rollupPluginBabelHelpers-ed61ffc0.js';
3
+ import 'react';
4
+ import 'prop-types';
5
+ import './index-f491ebce.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-ff0e3b99.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-dc5fc2fc.js';
@@ -1 +1,53 @@
1
- import r from"react";import{c as a}from"./index-b2745105.js";import e from"prop-types";import{Avatar as s}from"@material-ui/core";import{s as o}from"./style-inject.es-1f59c1d0.js";o("");var t=function(e){var o=e.className,t=e.shape,c=e.src,i=e.onError;return r.createElement(s,{className:a("avatar",o),variant:t,src:c},r.createElement("img",{src:c,onError:function(){return i()},alt:"test",style:{display:"none"}}))};t.defaultProps={className:void 0,shape:"circular",src:void 0,onError:void 0},t.propTypes={className:e.string,shape:e.oneOf(["circle","circular","rounded","square"]),src:e.string,onError:e.func};export{t as default};
1
+ import React__default from 'react';
2
+ import { c as classNames } from './index-f491ebce.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 };