diginet-core-ui 1.3.78 → 1.3.79

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 (209) hide show
  1. package/components/accordion/details.js +2 -6
  2. package/components/accordion/group.js +2 -9
  3. package/components/accordion/index.js +2 -15
  4. package/components/accordion/summary.js +4 -27
  5. package/components/alert/index.js +98 -137
  6. package/components/alert/notify.js +97 -166
  7. package/components/avatar/index.js +4 -63
  8. package/components/badge/index.js +7 -34
  9. package/components/button/icon.js +120 -186
  10. package/components/button/index.js +136 -205
  11. package/components/button/more.js +0 -12
  12. package/components/button/ripple-effect.js +46 -44
  13. package/components/card/body.js +2 -7
  14. package/components/card/extra.js +2 -7
  15. package/components/card/footer.js +2 -7
  16. package/components/card/header.js +2 -7
  17. package/components/card/index.js +2 -22
  18. package/components/chart/Pie/Circle.js +0 -1
  19. package/components/chart/Pie/Sector.js +0 -17
  20. package/components/chart/Pie/Sectors.js +0 -10
  21. package/components/chart/Pie/index.js +4 -36
  22. package/components/chart/Pie-v2/Circle.js +0 -1
  23. package/components/chart/Pie-v2/Sector.js +0 -13
  24. package/components/chart/Pie-v2/Sectors.js +0 -20
  25. package/components/chart/Pie-v2/index.js +11 -38
  26. package/components/chart/bar/Axis.js +0 -12
  27. package/components/chart/bar/Bar.js +13 -35
  28. package/components/chart/bar/Grid.js +0 -18
  29. package/components/chart/bar/Labels.js +0 -18
  30. package/components/chart/bar/Points.js +0 -17
  31. package/components/chart/bar/index.js +6 -26
  32. package/components/chart/bar-v2/Axis.js +0 -12
  33. package/components/chart/bar-v2/Bar.js +15 -36
  34. package/components/chart/bar-v2/Grid.js +0 -18
  35. package/components/chart/bar-v2/Labels.js +0 -18
  36. package/components/chart/bar-v2/Points.js +0 -17
  37. package/components/chart/bar-v2/index.js +6 -26
  38. package/components/chart/line/Axis.js +4 -16
  39. package/components/chart/line/Grid.js +2 -19
  40. package/components/chart/line/Labels.js +0 -18
  41. package/components/chart/line/Path.js +23 -33
  42. package/components/chart/line/Point.js +6 -40
  43. package/components/chart/line/Title.js +0 -3
  44. package/components/chart/line/index.js +12 -35
  45. package/components/chart/line-v2/Axis.js +0 -13
  46. package/components/chart/line-v2/Grid.js +0 -18
  47. package/components/chart/line-v2/Labels.js +0 -18
  48. package/components/chart/line-v2/Path.js +23 -33
  49. package/components/chart/line-v2/Point.js +6 -35
  50. package/components/chart/line-v2/Title.js +0 -3
  51. package/components/chart/line-v2/index.js +12 -30
  52. package/components/check-text/index.js +0 -8
  53. package/components/check-text/interview-confirmation.js +0 -7
  54. package/components/check-text/interview-status.js +0 -7
  55. package/components/chip/attach.js +4 -17
  56. package/components/chip/index.js +6 -33
  57. package/components/collapse/index.js +0 -13
  58. package/components/divider/index.js +0 -8
  59. package/components/form-control/attachment/index.js +24 -202
  60. package/components/form-control/calendar/function.js +40 -94
  61. package/components/form-control/calendar/index.js +5 -30
  62. package/components/form-control/calendar/range.js +11 -28
  63. package/components/form-control/checkbox/index.js +4 -37
  64. package/components/form-control/control/index.js +3 -13
  65. package/components/form-control/date-picker/index-old.js +18 -0
  66. package/components/form-control/date-picker/index.js +23 -99
  67. package/components/form-control/date-range-picker/index.js +86 -221
  68. package/components/form-control/dropdown/index.js +72 -289
  69. package/components/form-control/dropdown-box/index.js +6 -35
  70. package/components/form-control/form/index.js +0 -2
  71. package/components/form-control/form-group/index.js +1 -6
  72. package/components/form-control/helper-text/index.js +2 -9
  73. package/components/form-control/input-base/index.js +218 -399
  74. package/components/form-control/label/index.js +2 -12
  75. package/components/form-control/money-input/index.js +43 -132
  76. package/components/form-control/number-input/index.js +15 -113
  77. package/components/form-control/number-input/index2.js +78 -119
  78. package/components/form-control/phone-input/index.js +16 -78
  79. package/components/form-control/radio/index.js +4 -23
  80. package/components/form-control/text-input/index.js +33 -256
  81. package/components/form-control/time-picker/index.js +14 -71
  82. package/components/form-control/time-picker/swiper.js +21 -73
  83. package/components/form-control/toggle/index.js +4 -19
  84. package/components/form-view/helper-text.js +2 -2
  85. package/components/form-view/index.js +0 -14
  86. package/components/form-view/input.js +2 -13
  87. package/components/form-view/label.js +0 -2
  88. package/components/grid/Col.js +2 -15
  89. package/components/grid/Container.js +2 -21
  90. package/components/grid/Row.js +2 -21
  91. package/components/grid/index.js +2 -43
  92. package/components/image/index.js +2 -22
  93. package/components/index.js +62 -31
  94. package/components/list/list-item-action.js +0 -9
  95. package/components/list/list-item-icon.js +0 -9
  96. package/components/list/list-item-text.js +0 -5
  97. package/components/list/list-item.js +0 -11
  98. package/components/list/list.js +0 -13
  99. package/components/list/sub-header.js +0 -4
  100. package/components/modal/body.js +2 -6
  101. package/components/modal/footer.js +2 -11
  102. package/components/modal/header.js +2 -12
  103. package/components/modal/index.js +2 -10
  104. package/components/modal/modal.js +11 -52
  105. package/components/others/extra/index.js +3 -10
  106. package/components/others/import/index.js +0 -7
  107. package/components/others/option-wrapper/index.js +4 -7
  108. package/components/others/scrollbar/index.js +0 -3
  109. package/components/paging/page-info.js +39 -101
  110. package/components/paging/page-selector.js +7 -35
  111. package/components/paging/page-selector2.js +35 -74
  112. package/components/paper/index.js +0 -11
  113. package/components/popover/body.js +2 -6
  114. package/components/popover/footer.js +2 -11
  115. package/components/popover/header.js +2 -7
  116. package/components/popover/index.js +39 -123
  117. package/components/popup/danger_popup.js +0 -19
  118. package/components/popup/index.js +2 -48
  119. package/components/popup/proposals_popup.js +10 -49
  120. package/components/popup/v2/index.js +0 -31
  121. package/components/progress/circular.js +19 -81
  122. package/components/progress/linear.js +4 -20
  123. package/components/rating/index.js +0 -24
  124. package/components/slider/slider-container.js +3 -40
  125. package/components/slider/slider-item.js +10 -25
  126. package/components/status/index.js +2 -16
  127. package/components/tab/tab-container.js +2 -16
  128. package/components/tab/tab-header.js +4 -24
  129. package/components/tab/tab-panel.js +4 -16
  130. package/components/tab/tab.js +4 -28
  131. package/components/tooltip/index.js +12 -97
  132. package/components/tooltip/portal.js +0 -2
  133. package/components/transfer/index.js +22 -67
  134. package/components/tree-view/index.js +62 -202
  135. package/components/typography/index.js +3 -31
  136. package/global/index.js +0 -8
  137. package/icons/basic.js +0 -48
  138. package/icons/effect.js +17 -29
  139. package/icons/general/clock/clock.js +0 -2
  140. package/icons/general/color-handler/background.js +0 -2
  141. package/icons/general/color-handler/text.js +0 -2
  142. package/icons/general/emoji/emoji.js +0 -2
  143. package/icons/general/font-properties/bold.js +0 -2
  144. package/icons/general/font-properties/font-family.js +0 -2
  145. package/icons/general/font-properties/font-size.js +0 -2
  146. package/icons/general/font-properties/italic.js +0 -2
  147. package/icons/general/font-properties/underline.js +0 -2
  148. package/icons/general/hyperlink/hyperlink.js +0 -2
  149. package/icons/general/indent/decrease.js +0 -2
  150. package/icons/general/indent/increase.js +0 -2
  151. package/icons/general/list/bullets.js +0 -2
  152. package/icons/general/list/numbering.js +0 -2
  153. package/icons/general/picture/picture.js +0 -2
  154. package/icons/general/steps/redo.js +0 -2
  155. package/icons/general/steps/undo.js +0 -2
  156. package/icons/general/text-align/center.js +0 -2
  157. package/icons/general/text-align/justify.js +0 -2
  158. package/icons/general/text-align/left.js +0 -2
  159. package/icons/general/text-align/right.js +0 -2
  160. package/icons/menu/dhr.js +2 -1
  161. package/icons/menu/index.js +2 -2
  162. package/icons/menu/v2/index.js +0 -10
  163. package/package.json +1 -1
  164. package/readme.md +11 -1
  165. package/styles/animation.js +15 -58
  166. package/styles/color-helper.js +24 -54
  167. package/styles/colors.js +17 -9
  168. package/styles/general.js +6 -2
  169. package/styles/typography.js +4 -4
  170. package/styles/utils.js +2 -2
  171. package/theme/createBreakpoints.js +7 -18
  172. package/theme/make-styles.js +2 -5
  173. package/theme/set-theme.js +3 -6
  174. package/theme/settings.js +3 -2
  175. package/theme/theme-provider.js +0 -1
  176. package/utils/array/array.js +14 -23
  177. package/utils/classNames.js +0 -5
  178. package/utils/console.js +0 -6
  179. package/utils/date.js +13 -82
  180. package/utils/error/error.js +1 -9
  181. package/utils/error/errors.js +1 -48
  182. package/utils/getFileType.js +0 -9
  183. package/utils/handleBreakpoints.js +0 -5
  184. package/utils/intersectionObserver.js +0 -5
  185. package/utils/iterator.js +0 -9
  186. package/utils/map-parent.js +3 -10
  187. package/utils/object/extend.js +0 -10
  188. package/utils/object/object.js +12 -11
  189. package/utils/parseHTML.js +0 -1
  190. package/utils/promisify.js +0 -5
  191. package/utils/randomString.js +0 -7
  192. package/utils/remove-unicode.js +0 -1
  193. package/utils/render-portal.js +1 -9
  194. package/utils/renderHTML.js +4 -6
  195. package/utils/renderIcon.js +4 -14
  196. package/utils/sb-template.js +6 -5
  197. package/utils/string/capitalize.js +0 -1
  198. package/utils/string/capitalizeSentenceCase.js +0 -2
  199. package/utils/string/string.js +0 -13
  200. package/utils/type.js +0 -21
  201. package/utils/updatePosition.js +4 -5
  202. package/utils/useDelayUnmount.js +0 -4
  203. package/utils/useElementSize.js +9 -3
  204. package/utils/useEventListener.js +12 -6
  205. package/utils/useInput.js +0 -6
  206. package/utils/useMediaQuery.js +8 -10
  207. package/utils/useOnClickOutside.js +0 -2
  208. package/utils/usePortal.js +3 -10
  209. package/utils/validate.js +6 -20
@@ -1,198 +1,129 @@
1
- import React, { memo, useEffect, forwardRef, useImperativeHandle } from 'react';
2
- import ReactDOM from 'react-dom';
1
+ /** @jsxRuntime classic */
2
+ /** @jsx jsx */
3
+ import { memo, useEffect, forwardRef, useImperativeHandle, useRef, useState } from 'react';
4
+ import ReactDOM, { createPortal } from 'react-dom';
3
5
  import PropTypes from 'prop-types';
6
+ import { jsx, css } from '@emotion/core';
4
7
  import Alert from './';
5
- import { randomString } from '../../utils';
6
8
  import theme from '../../theme/settings';
9
+ import { classNames, refType as ref } from '../../utils';
10
+ import { backgroundTransparent, pointerEventsNone, positionFixed } from '../../styles/general';
7
11
  const {
8
12
  zIndex: zIndexCORE
9
13
  } = theme;
10
- const positions = {
11
- general: {
12
- position: 'fixed',
13
- zIndex: zIndexCORE(2),
14
- backgroundColor: 'transparent',
15
- pointerEvents: 'none'
16
- },
17
- vertical: {
18
- top: {
19
- top: '15px'
20
- },
21
- center: {
22
- top: '50%',
23
- transform: 'translateY(-50%)'
24
- },
25
- bottom: {
26
- display: 'flex',
27
- flexDirection: 'column-reverse',
28
- bottom: 0
29
- }
30
- },
31
- horizontal: {
32
- left: {
33
- left: '15px'
34
- },
35
- center: {
36
- left: '50%',
37
- transform: 'translateX(-50%)'
38
- },
39
- right: {
40
- right: '15px'
41
- }
42
- }
43
- };
44
- const str = randomString(6, {
45
- allowSymbol: false
46
- });
47
- const AlertNotify = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
48
- position,
14
+ const positionVerticalMap = new Map([['top', css`
15
+ top: 15px;
16
+ `], ['center', css`
17
+ top: 50%;
18
+ transform: translateY(-50%);
19
+ `], ['bottom', css`
20
+ display: flex;
21
+ flex-direction: column-reverse;
22
+ bottom: 0;
23
+ `]]);
24
+ const positionHorizontalMap = new Map([['left', css`
25
+ left: 15px;
26
+ `], ['center', css`
27
+ left: 50%;
28
+ transform: translateX(-50%);
29
+ `], ['right', css`
30
+ right: 15px;
31
+ `]]);
32
+ const Notify = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
33
+ action = {},
34
+ className,
49
35
  getAddNotify,
50
- width,
51
- maxWidth,
52
- height,
53
- maxHeight,
36
+ id,
37
+ position,
38
+ style,
54
39
  ...props
55
40
  }, reference) => {
56
- // Return true if it's a new position
57
- const checkPosition = pos => {
58
- if (pos === position || pos.vertical === (position.vertical || 'bottom') && pos.horizontal === (position.horizontal || 'center')) {
59
- return false;
60
- }
61
-
62
- if (pos === 'center') {
63
- pos = {
64
- vertical: 'center',
65
- horizontal: 'center'
66
- };
67
- }
68
-
69
- if (pos.vertical && pos.horizontal && /^top|center|bottom$/.test(pos.vertical) && /^left|center|right$/.test(pos.horizontal)) {
70
- return true;
71
- }
72
-
73
- return false;
74
- };
75
-
76
- const renderNotifyAlertPosition = (pos, className) => {
77
- if (pos === 'center') {
78
- pos = {
79
- vertical: 'center',
80
- horizontal: 'center'
81
- };
82
- }
83
-
84
- const el = document.createElement('div');
85
- el.className = `Notify-Alert-${className || pos.vertical + '-' + pos.horizontal}`;
86
- Object.assign(el.style, positions.general, positions.vertical[pos.vertical || 'bottom'], positions.horizontal[pos.horizontal || 'center'], pos.vertical === pos.horizontal ? {
87
- transform: 'translate(-50%, -50%)'
88
- } : {}, {
89
- width,
90
- maxWidth,
91
- height,
92
- maxHeight
93
- });
94
- document.body.appendChild(el);
95
- };
96
-
97
- const onClose = (e, removePosition) => {
98
- var _e$parentNode;
99
-
100
- (_e$parentNode = e.parentNode) === null || _e$parentNode === void 0 ? void 0 : _e$parentNode.remove();
101
-
102
- if (removePosition) {
103
- const node = document.querySelector(`div[class^="Notify-Alert-${removePosition.vertical}-${removePosition.horizontal}"]`);
104
-
105
- if (node && node.childNodes && !node.childNodes.length) {
106
- node.remove();
107
- }
108
- }
109
- };
110
-
111
- const onAddAlert = (message, {
41
+ const ref = useRef(null);
42
+ const [positionState, setPositionState] = useState(position);
43
+ const PositionVerticalCSS = positionVerticalMap.get((positionState === null || positionState === void 0 ? void 0 : positionState.vertical) || 'bottom');
44
+ const PositionHorizontalCSS = positionHorizontalMap.get((positionState === null || positionState === void 0 ? void 0 : positionState.horizontal) || 'center');
45
+ const showNotify = (message, {
112
46
  position,
113
47
  ...options
114
48
  } = {}) => {
115
49
  options = typeof options === 'object' ? options : {};
116
- const el = document.createElement('div');
117
- el.className = `Notify-Alert-${str}-item`;
118
-
119
- if (position && checkPosition(position)) {
120
- if (!document.querySelector(`div[class^="Notify-Alert-${position.vertical}-${position.horizontal}"]`)) {
121
- renderNotifyAlertPosition(position);
122
- }
123
-
124
- ReactDOM.render( /*#__PURE__*/React.createElement(Alert, {
125
- onClose: e => onClose(e, position),
126
- secondary: message,
127
- ...props,
128
- ...options
129
- }), document.querySelector(`div[class^="Notify-Alert-${position.vertical}-${position.horizontal}"]`).appendChild(el));
130
- } else {
131
- ReactDOM.render( /*#__PURE__*/React.createElement(Alert, {
132
- onClose: onClose,
133
- secondary: message,
134
- ...props,
135
- ...options
136
- }), document.querySelector(`div[class^="Notify-Alert-"]`).appendChild(el));
50
+ if (position) {
51
+ setPositionState(position);
137
52
  }
53
+ const el = document.createElement('div');
54
+ el.className = 'DGN-UI-Notify-Alert-Item';
55
+ ReactDOM.render(jsx(Alert
56
+ // onClose={() => el.remove()}
57
+ , {
58
+ secondary: message,
59
+ ...props,
60
+ ...options
61
+ }), ref.current.appendChild(el));
138
62
  };
139
-
140
63
  useEffect(() => {
141
- if (getAddNotify && typeof getAddNotify === 'function') getAddNotify(onAddAlert);
64
+ if (getAddNotify && typeof getAddNotify === 'function') getAddNotify(showNotify);
142
65
  }, [props]);
143
66
  useEffect(() => {
144
- renderNotifyAlertPosition(position, str);
145
- return () => {
146
- document.querySelector(`div[class^="Notify-Alert-${str}"]`).remove();
147
- };
148
- }, [position, width, maxWidth, height, maxHeight]);
149
- useImperativeHandle(reference, () => ({
150
- add: onAddAlert
151
- }));
152
- return null;
67
+ setPositionState(position);
68
+ }, [position]);
69
+ useImperativeHandle(reference, () => {
70
+ const currentRef = ref.current || {};
71
+ currentRef.element = ref.current;
72
+ const _instance = {
73
+ show: showNotify,
74
+ ...action
75
+ }; // methods
76
+ _instance.__proto__ = {}; // hidden methods
77
+ currentRef.instance = _instance;
78
+ currentRef.add = showNotify;
79
+ return currentRef;
80
+ });
81
+ const NotifyContainerView = jsx("div", {
82
+ ref: ref,
83
+ css: [AlertCSS, PositionVerticalCSS, PositionHorizontalCSS],
84
+ id: id,
85
+ style: style,
86
+ className: classNames('DGN-UI-Notify-Alert', (position === null || position === void 0 ? void 0 : position.vertical) || 'center' + '-' + (position === null || position === void 0 ? void 0 : position.horizontal) || 'center', className)
87
+ });
88
+ return /*#__PURE__*/createPortal(NotifyContainerView, document.body);
153
89
  }));
154
- AlertNotify.defaultProps = {
90
+ const AlertCSS = css`
91
+ ${positionFixed};
92
+ ${pointerEventsNone};
93
+ ${backgroundTransparent};
94
+ z-index: ${zIndexCORE(2)};
95
+ `;
96
+ Notify.defaultProps = {
97
+ className: '',
155
98
  position: {
156
99
  vertical: 'bottom',
157
100
  horizontal: 'center'
158
- }
101
+ },
102
+ style: {}
159
103
  };
160
- AlertNotify.propTypes = {
104
+ Notify.propTypes = {
105
+ /** Class for component. */
106
+ className: PropTypes.string,
161
107
  /**
162
108
  * used to set position of Alert (is a string or an object)
163
109
  * string is center (obligatory) as {vertical: 'center', horizontal: 'center'}
164
110
  */
165
111
  position: PropTypes.oneOfType([PropTypes.oneOf(['center']), PropTypes.shape({
166
- vertical: PropTypes.oneOf(['top', 'center', 'bottom']).isRequired,
167
- horizontal: PropTypes.oneOf(['left', 'center', 'right']).isRequired
112
+ horizontal: PropTypes.oneOf(['center', 'left', 'right']),
113
+ vertical: PropTypes.oneOf(['bottom', 'center', 'top'])
168
114
  })]),
169
-
115
+ /** Style inline of component. */
116
+ style: PropTypes.object,
117
+ /** Any [props](https://core.diginet.com.vn/ui/?path=/docs/alert--basic) of Alert */
118
+ props: PropTypes.any,
170
119
  /**
171
- * get the function used to add a new alert<br />
172
- * 2 parameters:<br />
173
- * + message: message for notify<br />
174
- * + options: is an object insist {<br />
175
- * position: position other than the default (if necessary)<br />
176
- * duration: new duration,<br />
177
- * color: new color,<br />
178
- * progressing: new progressing value,<br />
179
- * autoDisappear: new autoDisappear value,<br />
180
- * size: new autoDisappear,<br />
181
- * and any props else in Alert component <br />
182
- * }
120
+ * ref methods (ref.current.instance.*method*)
121
+ *
122
+ * * show(message, option): Show notify
123
+ * * @param {message} - number
124
+ * * @param {options} - object
125
+ * * {[Props](https://core.diginet.com.vn/ui/?path=/docs/alert--basic) applied to the `Alert`.}
183
126
  */
184
- getAddNotify: PropTypes.func.isRequired,
185
-
186
- /** the width of the alert box */
187
- width: PropTypes.string,
188
-
189
- /** the maximum width of the alert box */
190
- maxWidth: PropTypes.string,
191
-
192
- /** the height of the alert box */
193
- height: PropTypes.string,
194
-
195
- /** the maximum height of the alert box */
196
- maxHeight: PropTypes.string
127
+ reference: ref
197
128
  };
198
- export default AlertNotify;
129
+ export default Notify;
@@ -1,5 +1,4 @@
1
1
  /** @jsxRuntime classic */
2
-
3
2
  /** @jsx jsx */
4
3
  import { Fragment, memo, useRef, forwardRef, useState, useEffect, useMemo, useImperativeHandle, isValidElement } from 'react';
5
4
  import PropTypes from 'prop-types';
@@ -29,8 +28,8 @@ const {
29
28
  zIndex: zIndexCORE
30
29
  } = theme;
31
30
  const existed = {},
32
- urlAvatar = {},
33
- popupHandler = {};
31
+ urlAvatar = {},
32
+ popupHandler = {};
34
33
  const blurKeyframe = keyframes`
35
34
  0% { -webkit-filter: blur(4px);}
36
35
  25% { -webkit-filter: blur(3px);}
@@ -38,7 +37,6 @@ const blurKeyframe = keyframes`
38
37
  75% { -webkit-filter: blur(1px);}
39
38
  100% { -webkit-filter: blur(0px);}
40
39
  `;
41
-
42
40
  const checkFileType = (type, matchType) => {
43
41
  if (typeof matchType === 'object' && matchType instanceof RegExp) {
44
42
  return matchType.test(type);
@@ -49,7 +47,6 @@ const checkFileType = (type, matchType) => {
49
47
  return new RegExp(matchType).test(type);
50
48
  }
51
49
  };
52
-
53
50
  const Avatar = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
54
51
  action = {},
55
52
  actionIconHeight,
@@ -94,17 +91,11 @@ const Avatar = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
94
91
  useIntersection(ref, () => {
95
92
  setIsInView(true);
96
93
  });
97
-
98
94
  const _ActionIconCSS = ActionIconCSS(actionIconWidth);
99
-
100
95
  const _AvatarPreviewCSS = AvatarPreviewCSS(readOnly);
101
-
102
96
  const _AvatarContainerCSS = AvatarContainerCSS(_AvatarPreviewCSS.name, _ActionIconCSS.name);
103
-
104
97
  const _AvatarRootCSS = AvatarRootCSS(width, height, outlined);
105
-
106
98
  const _isMobile = isMobile.any();
107
-
108
99
  const triggerInput = e => {
109
100
  if (e || !existed[unique]) {
110
101
  inputRef.current.click();
@@ -113,45 +104,37 @@ const Avatar = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
113
104
  setViewAvatar(true);
114
105
  }
115
106
  };
116
-
117
107
  const onChangeAvatar = input => {
118
108
  const [file] = input.target.files;
119
109
  if (!file) return;
120
110
  const reader = new FileReader();
121
-
122
111
  if (!checkFileType(file.type, matchType)) {
123
112
  input.target.value = '';
124
113
  popupHandler[unique].show(wrongTypeError);
125
114
  return;
126
115
  }
127
-
128
116
  if (+maxSize && file.size > maxSize * 1024 ** 2) {
129
117
  input.target.value = '';
130
118
  popupHandler[unique].show(maxSizeError);
131
119
  return;
132
120
  }
133
-
134
121
  reader.onload = e => {
135
122
  urlAvatar[unique] = e.target.result;
136
123
  setSrcState(urlAvatar[unique]);
137
124
  existed[unique] = true;
138
125
  };
139
-
140
126
  reader.readAsDataURL(file);
141
127
  !!onChange && onChange(input);
142
128
  };
143
-
144
129
  const onRemoveAvatar = () => {
145
130
  setSrcState(null);
146
131
  existed[unique] = false;
147
132
  inputRef.current.value = '';
148
133
  !!onRemove && onRemove();
149
134
  };
150
-
151
135
  const renderData = () => {
152
136
  if ( /*#__PURE__*/isValidElement(data)) return data;
153
137
  const info = Object.keys(data || {});
154
-
155
138
  if (info !== null && info !== void 0 && info.length) {
156
139
  return info.map((key, index) => {
157
140
  return jsx(Typography, {
@@ -161,13 +144,11 @@ const Avatar = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
161
144
  }, key + ': ' + data[key]);
162
145
  });
163
146
  }
164
-
165
147
  return jsx(Typography, {
166
148
  color: textTooltip,
167
149
  type: 'p1'
168
150
  }, getGlobal('noDataText'));
169
151
  };
170
-
171
152
  const renderImage = () => {
172
153
  const _image = jsx(Fragment, null, !onLoaded && jsx("img", {
173
154
  src: defaultSrc,
@@ -184,7 +165,6 @@ const Avatar = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
184
165
  },
185
166
  onLoad: () => setOnLoaded(true)
186
167
  }));
187
-
188
168
  if (lazyLoading) {
189
169
  return isInView ? _image : jsx("img", {
190
170
  src: defaultSrc,
@@ -195,34 +175,27 @@ const Avatar = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
195
175
  });
196
176
  } else return _image;
197
177
  };
198
-
199
178
  const showMoreInfo = () => {
200
179
  if (hoverAble) setViewMoreInfo(true);
201
180
  };
202
-
203
181
  const closeMoreInfo = () => {
204
182
  if (hoverAble) setViewMoreInfo(false);
205
183
  };
206
-
207
184
  const _onClick = event => {
208
185
  onClick && event.stopPropagation();
209
186
  if (disabled) return;
210
-
211
187
  if (readOnly) {
212
188
  if (_isMobile) showMoreInfo();
213
189
  } else {
214
190
  allowEdit ? triggerInput() : onClick === null || onClick === void 0 ? void 0 : onClick(event);
215
191
  }
216
192
  };
217
-
218
193
  const _onMouseEnter = () => {
219
194
  if (!_isMobile) showMoreInfo();
220
195
  };
221
-
222
196
  const _onMouseLeave = () => {
223
197
  if (!_isMobile) closeMoreInfo();
224
198
  };
225
-
226
199
  useEffect(() => {
227
200
  if (src) {
228
201
  if (isInView || !lazyLoading) {
@@ -231,12 +204,10 @@ const Avatar = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
231
204
  urlAvatar[unique] = src;
232
205
  img.src = src;
233
206
  img.alt = '';
234
-
235
207
  img.onerror = () => {
236
208
  setSrcState(defaultSrc);
237
209
  existed[unique] = false;
238
210
  };
239
-
240
211
  img.onload = () => {
241
212
  setSrcState(src);
242
213
  existed[unique] = true;
@@ -247,11 +218,10 @@ const Avatar = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
247
218
  useImperativeHandle(reference, () => {
248
219
  const currentRef = ref.current || {};
249
220
  currentRef.element = ref.current;
250
- const _instance = { ...action
221
+ const _instance = {
222
+ ...action
251
223
  }; // methods
252
-
253
224
  _instance.__proto__ = {}; // hidden methods
254
-
255
225
  currentRef.instance = _instance;
256
226
  return currentRef;
257
227
  });
@@ -334,7 +304,6 @@ const Avatar = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
334
304
  }));
335
305
  }, [actionIconHeight, actionIconWidth, allowEdit, clearAble, data, defaultSrc, direction, disabled, height, hoverAble, lazyLoading, matchType, maxSize, maxSizeError, outlined, readOnly, width, isInView, onLoaded, srcState, viewAvatar, viewMoreInfo]);
336
306
  }));
337
-
338
307
  const ActionIconCSS = actionIconWidth => css`
339
308
  ${flexCol};
340
309
  ${positionAbsolute};
@@ -344,7 +313,6 @@ const ActionIconCSS = actionIconWidth => css`
344
313
  opacity: 0;
345
314
  z-index: ${zIndexCORE(2)};
346
315
  `;
347
-
348
316
  const AvatarPreviewCSS = readOnly => css`
349
317
  ${displayBlock};
350
318
  ${positionRelative};
@@ -354,7 +322,6 @@ const AvatarPreviewCSS = readOnly => css`
354
322
  border-radius: 50%;
355
323
  cursor: ${readOnly ? 'initial' : 'pointer'};
356
324
  `;
357
-
358
325
  const AvatarContainerCSS = (AvatarPreviewCSSName, ActionIconCSSName) => css`
359
326
  ${inlineFlex};
360
327
  ${positionRelative};
@@ -374,7 +341,6 @@ const AvatarContainerCSS = (AvatarPreviewCSSName, ActionIconCSSName) => css`
374
341
  }
375
342
  }
376
343
  `;
377
-
378
344
  const AvatarRootCSS = (width, height, outlined) => css`
379
345
  ${displayBlock};
380
346
  ${positionRelative};
@@ -393,7 +359,6 @@ const AvatarRootCSS = (width, height, outlined) => css`
393
359
  height: 100%;
394
360
  }
395
361
  `;
396
-
397
362
  const MoreInfoCSS = css`
398
363
  ${displayBlock};
399
364
  ${positionRelative};
@@ -425,82 +390,58 @@ Avatar.defaultProps = {
425
390
  Avatar.propTypes = {
426
391
  /** The height of action icon. */
427
392
  actionIconHeight: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
428
-
429
393
  /** The width of action icon. */
430
394
  actionIconWidth: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
431
-
432
395
  /** If `true`, allow to edit avatar. */
433
396
  allowEdit: PropTypes.bool,
434
-
435
397
  /** Class for component. */
436
398
  className: PropTypes.string,
437
-
438
399
  /** If `true`, display remove avatar icon. */
439
400
  clearAble: PropTypes.bool,
440
-
441
401
  /**
442
402
  * data to display when hoverAble is true<br />
443
403
  * data is an object or function return a jsx element
444
404
  */
445
405
  data: PropTypes.oneOfType([PropTypes.object, PropTypes.func, PropTypes.node]),
446
-
447
406
  /**
448
407
  * it is used to display the default if there is no src<br />
449
408
  * if undefined, will display icons available in the icons store
450
409
  */
451
410
  defaultSrc: PropTypes.string,
452
-
453
411
  /** the direction to display more info */
454
412
  direction: PropTypes.oneOf(['top', 'bottom', 'left', 'right']),
455
-
456
413
  /** prevent all events, only view */
457
414
  disabled: PropTypes.bool,
458
-
459
415
  /** The height of avatar box (48 or '48px' or ...) */
460
416
  height: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
461
-
462
417
  /** show more info in popover if true */
463
418
  hoverAble: PropTypes.bool,
464
-
465
419
  /** lazy loading */
466
420
  lazyLoading: PropTypes.bool,
467
-
468
421
  /** type of image was allowed */
469
422
  matchType: PropTypes.oneOfType([PropTypes.string, PropTypes.object, PropTypes.func, PropTypes.array]),
470
-
471
423
  /** maximum size for avatar file (unit: MB) */
472
424
  maxSize: PropTypes.number,
473
-
474
425
  /** the error to show on exceeded allowed size */
475
426
  maxSizeError: PropTypes.string,
476
-
477
427
  /** will run after change avatar */
478
428
  onChange: PropTypes.func,
479
-
480
429
  /** Callback fired when the component is clicked. */
481
430
  onClick: PropTypes.func,
482
-
483
431
  /** will run after remove avatar */
484
432
  onRemove: PropTypes.func,
485
-
486
433
  /** border of avatar (true or '1px solid #color') */
487
434
  outlined: PropTypes.oneOfType([PropTypes.bool, PropTypes.string]),
488
-
489
435
  /** only view and allow show more info if hoverAble is true */
490
436
  readOnly: PropTypes.bool,
491
-
492
437
  /** source of file (http:// or https://) */
493
438
  src: PropTypes.string,
494
-
495
439
  /** Style inline of component. */
496
440
  style: PropTypes.object,
497
-
498
441
  /** The width of avatar box (48 or '48px' or ...) */
499
442
  width: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
500
-
501
443
  /** the error to show on wrong type */
502
444
  wrongTypeError: PropTypes.string,
503
-
504
445
  /**
505
446
  * ref methods
506
447
  *