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,5 +1,4 @@
1
1
  /** @jsxRuntime classic */
2
-
3
2
  /** @jsx jsx */
4
3
  import { memo, useRef, forwardRef, useMemo, useImperativeHandle } from 'react';
5
4
  import PropTypes from 'prop-types';
@@ -25,7 +24,6 @@ const iconSizeMap = new Map([['medium', 24], ['large', 32], ['giant', 40]]);
25
24
  const dotSizeMap = new Map([['medium', 8], ['large', 10], ['giant', 12]]);
26
25
  const dotIndentMap = new Map([['medium', 4], ['large', 2]]);
27
26
  const typographySizeMap = new Map([['medium', paragraph3], ['large', paragraph2], ['giant', paragraph1]]);
28
-
29
27
  const calDotPos = (anchorOrigin, contentDirection, dotSize, hasContent, size) => {
30
28
  const halfDotSize = dotSize / 2;
31
29
  const {
@@ -43,7 +41,6 @@ const calDotPos = (anchorOrigin, contentDirection, dotSize, hasContent, size) =>
43
41
  ` : css`
44
42
  top: ${-halfDotSize}px;
45
43
  `;
46
-
47
44
  if (contentDirection === 'right') {
48
45
  if (horizontal === 'left') {
49
46
  return css`
@@ -70,7 +67,6 @@ const calDotPos = (anchorOrigin, contentDirection, dotSize, hasContent, size) =>
70
67
  }
71
68
  }
72
69
  };
73
-
74
70
  const Badge = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
75
71
  action = {},
76
72
  anchorOrigin,
@@ -94,25 +90,20 @@ const Badge = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
94
90
  const dotSize = content || content === 0 && showZero ? dotSizeMap.get(size) + 8 : dotSizeMap.get(size);
95
91
  const dotColor = colors[color] || colorMap.get(color) || color;
96
92
  const dotPos = calDotPos(anchorOrigin, !children && name ? 'right' : contentDirection, dotSize, content || content === 0, size);
97
-
98
93
  const _BadgeNumberCSS = BadgeNumberCSS(typographySize, children, name, dotSize, dotColor, invisible);
99
-
100
94
  const _BadgeRootCSS = BadgeRootCSS(children, name, dotPos, _BadgeNumberCSS);
101
-
102
95
  useImperativeHandle(reference, () => {
103
96
  const currentRef = ref.current || {};
104
97
  currentRef.element = ref.current;
105
- const _instance = { ...action
98
+ const _instance = {
99
+ ...action
106
100
  }; // methods
107
-
108
101
  _instance.__proto__ = {}; // hidden methods
109
-
110
102
  currentRef.instance = _instance;
111
103
  return currentRef;
112
104
  });
113
105
  return useMemo(() => {
114
106
  let node = children;
115
-
116
107
  if (!node && name) {
117
108
  node = jsx(Icon, {
118
109
  name: name,
@@ -122,7 +113,6 @@ const Badge = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
122
113
  ...iconProps
123
114
  });
124
115
  }
125
-
126
116
  return jsx("div", {
127
117
  css: _BadgeRootCSS,
128
118
  ref: ref,
@@ -137,7 +127,6 @@ const Badge = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
137
127
  }, max && content > max ? max + '+' : content === 0 && !showZero ? null : content));
138
128
  }, [anchorOrigin, contentDirection, content, name, size, children, max, showZero, invisible, color, style, className, iconProps]);
139
129
  }));
140
-
141
130
  const BadgeNumberCSS = (typographySize, children, name, dotSize, dotColor, invisible) => css`
142
131
  ${typographySize};
143
132
  ${flexRow};
@@ -156,7 +145,6 @@ const BadgeNumberCSS = (typographySize, children, name, dotSize, dotColor, invis
156
145
  transition: transform 225ms cubic-bezier(0.4, 0, 0.2, 1) 0ms;
157
146
  ${invisible && 'transform: scale(0) translate(50%, -50%);'};
158
147
  `;
159
-
160
148
  const BadgeRootCSS = (children, name, dotPos, _BadgeNumberCSS) => css`
161
149
  ${inlineFlex};
162
150
  ${alignCenter};
@@ -173,7 +161,6 @@ const BadgeRootCSS = (children, name, dotPos, _BadgeNumberCSS) => css`
173
161
  ${(children || name) && dotPos}
174
162
  }
175
163
  `;
176
-
177
164
  Badge.defaultProps = {
178
165
  color: 'default',
179
166
  size: 'medium',
@@ -194,51 +181,37 @@ Badge.propTypes = {
194
181
  horizontal: PropTypes.oneOf(['left', 'right']),
195
182
  vertical: PropTypes.oneOf(['top', 'bottom'])
196
183
  }),
197
-
198
184
  /** the quantity is shown on the badge */
199
185
  content: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
200
-
201
186
  /** the largest number is displayed on the badge */
202
187
  max: PropTypes.number,
203
-
204
188
  /** used to fill background for button */
205
189
  contentDirection: PropTypes.oneOf(['left', 'right']),
206
-
207
190
  /** background color of badge */
208
191
  color: PropTypes.oneOfType([PropTypes.oneOf(['default', 'primary', 'info', 'success', 'warning', 'danger']), PropTypes.string]),
209
-
210
192
  /** use name will replace children with ButtonIcon */
211
193
  name: PropTypes.string,
212
-
213
194
  /** other icon props when use prop name */
214
195
  iconProps: PropTypes.object,
215
-
216
- /** size of Badge
217
- *
218
- * * medium (dot 8px, typography p3)
219
- * * large (button 10px, typography p2)
220
- * * giant (button 12px, typography p1)
196
+ /** size of Badge
197
+ *
198
+ * * medium (dot 8px, typography p3)
199
+ * * large (button 10px, typography p2)
200
+ * * giant (button 12px, typography p1)
221
201
  * */
222
202
  size: PropTypes.oneOf(['medium', 'large', 'giant']),
223
-
224
203
  /** Controls whether the badge is hidden when content is zero */
225
204
  showZero: PropTypes.bool,
226
-
227
205
  /** If true, the badge is invisible */
228
206
  invisible: PropTypes.bool,
229
-
230
207
  /** className of component */
231
208
  className: PropTypes.string,
232
-
233
209
  /** style inline of component */
234
210
  style: PropTypes.object,
235
-
236
211
  /** the function get ref */
237
212
  refs: PropTypes.func,
238
-
239
213
  /** the content displayed under the number of the badge */
240
214
  children: PropTypes.node,
241
-
242
215
  /** any props else */
243
216
  props: PropTypes.any
244
217
  };
@@ -1,36 +1,37 @@
1
1
  /** @jsxRuntime classic */
2
-
3
2
  /** @jsx jsx */
4
3
  import { memo, useRef, useMemo, forwardRef, useImperativeHandle } from 'react';
5
4
  import PropTypes from 'prop-types';
6
5
  import { jsx, css } from '@emotion/core';
7
6
  import OptionWrapper from '../others/option-wrapper';
8
7
  import * as allColors from '../../styles/colors';
9
- import { color as colors } from '../../styles/colors';
10
8
  import { hexToRGBA } from '../../styles/color-helper';
11
- import { capitalize } from '../../utils';
9
+ import { capitalize, classNames, refType as ref } from '../../utils';
12
10
  import Icon from '../../icons';
13
11
  import Ripple from './ripple-effect';
14
12
  import { getClassNameFromColor, getRippleColor } from '.';
15
13
  import CircularProgress from '../progress/circular';
16
- import { alignCenter, backgroundTransparent, border, borderBox, borderNone, cursorPointer, flexRow, inlineFlex, justifyCenter, noBorder, outlineNone, pointerEventsNone, positionRelative, userSelectNone } from '../../styles/general';
14
+ import { alignCenter, backgroundTransparent, border, borderBox, borderNone, borderRadius4px, borderRadius50, cursorPointer, flexRow, inlineFlex, justifyCenter, noBorder, outlineNone, parseMinWidthHeight, parseWidthHeight, pointerEventsNone, positionRelative, userSelectNone } from '../../styles/general';
15
+ import { useColor as colors, useTheme } from '../../theme';
17
16
  const {
18
- system: {
19
- active,
20
- disabled: systemDisabled,
21
- rest,
22
- white
23
- },
24
- semantic: {
25
- success,
26
- warning,
27
- danger,
28
- info
29
- },
30
- fill: {
31
- disabled: fillDisabled
17
+ colors: {
18
+ system: {
19
+ active,
20
+ disabled: systemDisabled,
21
+ rest: systemRest,
22
+ white: systemWhite
23
+ },
24
+ semantic: {
25
+ success: semanticSuccess,
26
+ warning: semanticWarning,
27
+ danger: semanticDanger,
28
+ info: semanticInfo
29
+ },
30
+ fill: {
31
+ disabled: fillDisabled
32
+ }
32
33
  }
33
- } = colors;
34
+ } = useTheme();
34
35
  const sizeMap = new Map([['tiny', {
35
36
  buttonSize: '24px',
36
37
  iconSize: '16px'
@@ -47,20 +48,19 @@ const sizeMap = new Map([['tiny', {
47
48
  buttonSize: '56px',
48
49
  iconSize: '40px'
49
50
  }]]);
50
- const iconColorMap = new Map([['Close', danger], ['Cancel', danger], ['Approval', success], ['Delete', warning], ['Trash', warning], ['Edit', info], ['EditV2', info], ['View', info]]);
51
+ const iconColorMap = new Map([['Close', semanticDanger], ['Cancel', semanticDanger], ['Approval', semanticSuccess], ['Delete', semanticWarning], ['Trash', semanticWarning], ['Edit', semanticInfo], ['EditV2', semanticInfo], ['View', semanticInfo]]);
51
52
  const alphaArr = {
52
53
  hover: 0.1,
53
54
  focus: 0.2,
54
55
  active: 0.3
55
56
  };
56
- const alphaLoading = 0.2; // customIconSize calculated based on design size
57
+ const alphaLoading = 0.2;
58
+ // customIconSize calculated based on design size
57
59
  // Button size <= 24 => icon size = Button size - 8
58
60
  // Button size > 24 && <= 32 => icon size = Button size - 12
59
61
  // Button size > 32 => icon size = Button size - 16
60
-
61
62
  const customIconSize = width => width <= 24 ? width - 8 : width <= 32 ? width - 12 : width - 16;
62
-
63
- const renderIconLoading = iconSize => {
63
+ const IconLoadingView = iconSize => {
64
64
  return jsx(CircularProgress, {
65
65
  size: 'extraSmall',
66
66
  background: 'transparent',
@@ -69,85 +69,110 @@ const renderIconLoading = iconSize => {
69
69
  width: parseInt(iconSize)
70
70
  });
71
71
  };
72
-
73
72
  const ButtonIcon = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
74
73
  action = {},
75
- viewType,
76
- color,
77
- size,
78
- name,
79
- width,
80
- height,
81
- className,
74
+ children,
82
75
  circular,
83
- viewBox,
76
+ className,
77
+ color: colorProp,
78
+ colorHover,
84
79
  disabled,
85
- style,
86
- onClick,
87
- children,
80
+ height,
81
+ id,
88
82
  loading,
89
- colorHover,
90
- id
83
+ name,
84
+ onClick,
85
+ size,
86
+ style,
87
+ viewBox,
88
+ viewType,
89
+ width
91
90
  }, reference) => {
92
91
  var _sizeMap$get, _sizeMap$get2;
93
-
94
92
  const ref = useRef(null);
93
+ const rippleRef = useRef(null);
95
94
  const buttonSize = ((_sizeMap$get = sizeMap.get(size)) === null || _sizeMap$get === void 0 ? void 0 : _sizeMap$get.buttonSize) || '40px';
96
95
  const iconSize = width ? isNaN(width) ? '60%' : customIconSize(parseInt(width)) + 'px' : ((_sizeMap$get2 = sizeMap.get(size)) === null || _sizeMap$get2 === void 0 ? void 0 : _sizeMap$get2.iconSize) || '24px';
97
96
  const isViewTypeGhost = viewType === 'ghost';
98
-
99
- const _width = isNaN(width) ? width : width + 'px';
100
-
101
- const _height = isNaN(height) ? height : height + 'px';
102
-
103
- const _color = colors[color];
97
+ const color = colors[colorProp] || colorProp;
104
98
  colorHover = colors[colorHover] || colorHover;
105
-
106
- const _ButtonRootCSS = ButtonRootCSS(circular, size, width, _width, height, _height, buttonSize, iconSize, colorHover, color, _color, name);
107
-
99
+ const _ButtonRootCSS = ButtonRootCSS(circular, colorHover, color, name);
100
+ const _ButtonSizeCSS = ButtonSizeCSS(width, height, buttonSize, iconSize);
101
+ const _ButtonIconCSS = ButtonIconCSS(iconSize);
108
102
  useImperativeHandle(reference, () => {
109
103
  const currentRef = ref.current || {};
110
104
  currentRef.element = ref.current;
111
- const _instance = { ...action
105
+ const _instance = {
106
+ ...action
112
107
  }; // methods
113
-
114
108
  _instance.__proto__ = {}; // hidden methods
115
-
116
109
  currentRef.instance = _instance;
117
110
  return currentRef;
118
111
  });
119
-
120
112
  const _onClick = event => {
121
113
  event.persist();
122
114
  onClick && event.stopPropagation();
123
115
  if (disabled || loading) return;
116
+ if (!isViewTypeGhost) rippleRef.current.start(event);
124
117
  onClick && onClick(event);
125
118
  };
126
-
127
119
  return useMemo(() => {
128
- return jsx("div", {
129
- css: _ButtonRootCSS,
120
+ return jsx("button", {
121
+ css: [_ButtonRootCSS, _ButtonSizeCSS, disabled && ButtonDisabledCSS],
130
122
  ref: ref,
131
123
  id: id,
132
124
  style: style,
133
125
  onClick: _onClick,
134
- className: ['DGN-UI-ButtonIcon', viewType, getClassNameFromColor(color), size, loading && 'button-icon--loading', disabled && 'button-icon--disabled', className].join(' ').trim().replace(/\s+/g, ' ')
135
- }, loading && renderIconLoading(iconSize), !loading && jsx("span", {
136
- className: 'DGN-UI-ButtonIcon-Icon'
126
+ className: classNames('DGN-UI-ButtonIcon', viewType, getClassNameFromColor(colorProp), size, loading && 'button-icon--loading', className)
127
+ }, loading && IconLoadingView(iconSize), !loading && jsx("span", {
128
+ className: 'DGN-UI-ButtonIcon-Icon',
129
+ css: _ButtonIconCSS
137
130
  }, children || jsx(Icon, {
138
131
  name: name,
139
- width: isViewTypeGhost ? width ? _width : iconSize : iconSize,
140
- height: isViewTypeGhost ? height ? _height : iconSize : iconSize,
132
+ width: isViewTypeGhost ? width || iconSize : iconSize,
133
+ height: isViewTypeGhost ? height || iconSize : iconSize,
141
134
  color: 'currentColor',
142
135
  viewBox: viewBox
143
- })), !disabled && !loading && viewType !== 'ghost' && jsx(Ripple, {
144
- color: getRippleColor(color, viewType, allColors),
136
+ })), !disabled && !loading && !isViewTypeGhost && jsx(Ripple, {
137
+ ref: rippleRef,
138
+ color: getRippleColor(colorProp, viewType, allColors),
145
139
  circular: circular
146
140
  }));
147
- }, [id, style, className, size, viewType, color, colorHover, disabled, name, children, onClick, loading, circular, viewBox, width, height]);
141
+ }, [children, circular, className, colorProp, colorHover, disabled, height, id, loading, name, onClick, size, style, viewBox, viewType, width]);
148
142
  }));
149
-
150
- const ButtonRootCSS = (circular, size, width, _width, height, _height, buttonSize, iconSize, colorHover, color, _color, name) => css`
143
+ const ButtonIconCSS = iconSize => css`
144
+ ${flexRow};
145
+ ${positionRelative};
146
+ ${borderBox};
147
+ ${justifyCenter};
148
+ ${alignCenter};
149
+ ${parseWidthHeight(iconSize)};
150
+ ${parseMinWidthHeight(iconSize)};
151
+ `;
152
+ const ButtonDisabledCSS = `
153
+ cursor: not-allowed !important;
154
+ color: ${systemDisabled} !important;
155
+ &.outlined {
156
+ border-color: ${systemDisabled} !important;
157
+ background-color: transparent !important;
158
+ }
159
+ &.filled {
160
+ background-color: ${fillDisabled} !important;
161
+ filter: brightness(1) !important;
162
+ }
163
+ &.text {
164
+ background-color: transparent !important;
165
+ }
166
+ `;
167
+ const ButtonSizeCSS = (width, height, buttonSize, iconSize) => css`
168
+ ${parseWidthHeight(width || buttonSize, height || buttonSize)};
169
+ ${parseMinWidthHeight(width || buttonSize, height || buttonSize)};
170
+ &.ghost {
171
+ ${parseWidthHeight(width || iconSize, height || iconSize)};
172
+ ${parseMinWidthHeight(width || iconSize, height || iconSize)};
173
+ }
174
+ `;
175
+ const ButtonRootCSS = (circular, colorHover, color, name) => css`
151
176
  ${inlineFlex};
152
177
  ${positionRelative};
153
178
  ${justifyCenter};
@@ -156,51 +181,25 @@ const ButtonRootCSS = (circular, size, width, _width, height, _height, buttonSiz
156
181
  ${borderBox};
157
182
  ${cursorPointer};
158
183
  ${userSelectNone};
184
+ ${circular ? borderRadius50 : borderRadius4px};
159
185
  padding: 0;
160
- border-radius: ${circular ? '50%' : '4px'};
161
186
  transition: background-color 0.5s, filter 0.5s;
162
- .DGN-UI-ButtonIcon-Icon {
163
- ${flexRow};
164
- ${positionRelative};
165
- ${borderBox};
166
- ${justifyCenter};
167
- ${alignCenter};
168
- }
169
- &.button-icon--disabled {
170
- cursor: not-allowed !important;
171
- color: ${systemDisabled} !important;
172
- &.outlined {
173
- border-color: ${systemDisabled} !important;
174
- background-color: transparent !important;
175
- }
176
- &.filled {
177
- background-color: ${fillDisabled} !important;
178
- filter: brightness(1) !important;
179
- }
180
- &.text {
181
- background-color: transparent !important;
182
- }
183
- }
184
187
  &.button-icon--loading {
185
188
  ${pointerEventsNone};
186
189
  }
187
- &.${size} {
188
- width: ${width ? _width : buttonSize};
189
- min-width: ${width ? _width : buttonSize};
190
- height: ${height ? _height : buttonSize};
191
- min-height: ${height ? _height : buttonSize};
192
- .DGN-UI-ButtonIcon-Icon {
193
- height: ${iconSize};
194
- min-height: ${iconSize};
195
- width: ${iconSize};
196
- min-width: ${iconSize};
197
- }
198
- }
199
190
  &.outlined {
200
191
  ${backgroundTransparent};
192
+ ${border(1, color)}
193
+ color: ${color};
194
+ &.button-icon--loading {
195
+ background-color: ${hexToRGBA(color, alphaLoading)};
196
+ }
197
+ ${Object.keys(alphaArr).map(key => `&:${key} {
198
+ background-color: ${hexToRGBA(color, alphaArr[key])};
199
+ }`)}
201
200
  &.default {
202
- ${border(1, rest)};
203
- color: ${rest};
201
+ ${border(1, systemRest)};
202
+ color: ${systemRest};
204
203
  &.button-icon--loading,
205
204
  &:hover,
206
205
  &:focus,
@@ -215,30 +214,11 @@ const ButtonRootCSS = (circular, size, width, _width, height, _height, buttonSiz
215
214
  background-color: ${hexToRGBA(colorHover, alphaArr[key])};
216
215
  }`)}// &:hover | &:focus | &:active
217
216
  }
218
- &.${color} {
219
- ${color !== 'default' && border(1, _color)}
220
- color: ${_color};
221
- &.button-icon--loading {
222
- background-color: ${hexToRGBA(_color, alphaLoading)};
223
- }
224
- ${Object.keys(alphaArr).map(key => `&:${key} {
225
- background-color: ${hexToRGBA(_color, alphaArr[key])};
226
- }`)}
227
- }
228
- &.custom-color {
229
- ${border(1, color)}
230
- color: ${color};
231
- &.button-icon--loading {
232
- background-color: ${hexToRGBA(color, alphaLoading)};
233
- }
234
- ${Object.keys(alphaArr).map(key => `&:${key} {
235
- background-color: ${hexToRGBA(color, alphaArr[key])};
236
- }`)}
237
- }
238
217
  }
239
218
  &.filled {
240
219
  ${borderNone};
241
- color: ${color === white ? rest : white};
220
+ background-color: ${color};
221
+ color: ${color === systemWhite ? systemRest : systemWhite};
242
222
  font-weight: bold;
243
223
  &.button-icon--loading,
244
224
  &:hover,
@@ -249,7 +229,7 @@ const ButtonRootCSS = (circular, size, width, _width, height, _height, buttonSiz
249
229
  filter: brightness(0.7);
250
230
  }
251
231
  &.default {
252
- background-color: ${rest};
232
+ background-color: ${systemRest};
253
233
  &.button-icon--loading,
254
234
  &:hover,
255
235
  &:focus,
@@ -257,18 +237,19 @@ const ButtonRootCSS = (circular, size, width, _width, height, _height, buttonSiz
257
237
  background-color: ${colorHover};
258
238
  }
259
239
  }
260
- &.${color} {
261
- background-color: ${_color};
262
- }
263
- &.custom-color {
264
- background-color: ${color};
265
- }
266
240
  }
267
241
  &.text {
268
242
  ${noBorder};
269
243
  ${backgroundTransparent};
244
+ color: ${color};
245
+ &.button-icon--loading {
246
+ background-color: ${hexToRGBA(color, alphaLoading)};
247
+ }
248
+ ${Object.keys(alphaArr).map(key => `&:${key} {
249
+ background-color: ${hexToRGBA(color, alphaArr[key])};
250
+ }`)}
270
251
  &.default {
271
- color: ${rest};
252
+ color: ${systemRest};
272
253
  &:hover,
273
254
  &:focus,
274
255
  &:active {
@@ -282,35 +263,11 @@ const ButtonRootCSS = (circular, size, width, _width, height, _height, buttonSiz
282
263
  background-color: ${hexToRGBA(colorHover, alphaArr[key])};
283
264
  }`)}
284
265
  }
285
- &.${color} {
286
- color: ${_color};
287
- &.button-icon--loading {
288
- background-color: ${hexToRGBA(_color, alphaLoading)};
289
- }
290
- ${Object.keys(alphaArr).map(key => `&:${key} {
291
- background-color: ${hexToRGBA(_color, alphaArr[key])};
292
- }`)}
293
- }
294
- &.custom-color {
295
- color: ${color};
296
- &.button-icon--loading {
297
- background-color: ${hexToRGBA(color, alphaLoading)};
298
- }
299
- ${Object.keys(alphaArr).map(key => `&:${key} {
300
- background-color: ${hexToRGBA(color, alphaArr[key])};
301
- }`)}
302
- }
303
266
  }
304
267
  &.ghost {
305
268
  ${backgroundTransparent};
306
269
  ${noBorder};
307
- color: ${rest};
308
- &.${size} {
309
- height: ${height ? _height : iconSize};
310
- min-height: ${height ? _height : iconSize};
311
- width: ${width ? _width : iconSize};
312
- min-width: ${width ? _width : iconSize};
313
- }
270
+ color: ${color};
314
271
  &.loading,
315
272
  &:hover,
316
273
  &:focus {
@@ -320,62 +277,46 @@ const ButtonRootCSS = (circular, size, width, _width, height, _height, buttonSiz
320
277
  filter: brightness(0.7);
321
278
  }
322
279
  &.default {
280
+ color: ${systemRest};
323
281
  &:hover,
324
282
  &:focus,
325
283
  &:active {
326
284
  color: ${iconColorMap.get(capitalize(name)) || colorHover};
327
285
  }
328
286
  }
329
- &.${color} {
330
- color: ${_color};
331
- }
332
- &.custom-color {
333
- color: ${color};
334
- }
335
287
  }
336
288
  `;
337
-
338
289
  ButtonIcon.defaultProps = {
339
- viewType: 'outlined',
290
+ circular: false,
291
+ className: '',
340
292
  color: 'default',
341
293
  colorHover: active,
342
- size: 'medium',
343
- className: '',
344
- circular: false,
345
294
  disabled: false,
346
- viewBox: true
295
+ size: 'medium',
296
+ viewBox: true,
297
+ viewType: 'outlined'
347
298
  };
348
299
  ButtonIcon.propTypes = {
349
300
  /** The content of the component. */
350
301
  children: PropTypes.node,
351
-
352
302
  /** If `true`, component is circular. */
353
303
  circular: PropTypes.bool,
354
-
355
304
  /** Class for component. */
356
305
  className: PropTypes.string,
357
-
358
306
  /** The color of the component. */
359
307
  color: PropTypes.string,
360
-
361
308
  /** Custom hover color for button with color 'default'. */
362
309
  colorHover: PropTypes.string,
363
-
364
310
  /** If `true`, the component is disabled. */
365
311
  disabled: PropTypes.bool,
366
-
367
312
  /** Height oof the component. */
368
313
  height: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
369
-
370
314
  /** If `true`, the loading indicator is shown. */
371
315
  loading: PropTypes.bool,
372
-
373
316
  /** Callback fired when the component is clicked. */
374
317
  onClick: PropTypes.func,
375
-
376
318
  /** Name of [icon](https://core.diginet.com.vn/ui/?path=/story/icon-basic). */
377
319
  name: PropTypes.string,
378
-
379
320
  /**
380
321
  * The size of the component.
381
322
  *
@@ -386,19 +327,14 @@ ButtonIcon.propTypes = {
386
327
  * * giant (button 56px, icon 40px)
387
328
  * */
388
329
  size: PropTypes.oneOf(['tiny', 'small', 'medium', 'large', 'giant']),
389
-
390
330
  /** Style inline of component. */
391
331
  style: PropTypes.object,
392
-
393
332
  /** If `true`, icon has view box. */
394
333
  viewBox: PropTypes.bool,
395
-
396
334
  /** The variant to use. */
397
335
  viewType: PropTypes.oneOf(['text', 'outlined', 'filled', 'ghost']),
398
-
399
336
  /** Width of the component. */
400
337
  width: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
401
-
402
338
  /**
403
339
  * ref methods (ref.current.instance.*method*)
404
340
  *
@@ -413,9 +349,7 @@ ButtonIcon.propTypes = {
413
349
  * * option(options): Updates the values of several properties
414
350
  * * @param {options} - object
415
351
  */
416
- reference: PropTypes.oneOfType([PropTypes.func, PropTypes.shape({
417
- current: PropTypes.instanceOf(Element)
418
- })])
352
+ reference: ref
419
353
  };
420
354
  export { ButtonIcon };
421
355
  export default OptionWrapper(ButtonIcon);