diginet-core-ui 1.3.24 → 1.3.29

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 (153) hide show
  1. package/assets/fonts/SF-Pro-Display-Bold.otf +0 -0
  2. package/assets/fonts/SF-Pro-Display-Medium.otf +0 -0
  3. package/assets/fonts/SF-Pro-Display-Regular.otf +0 -0
  4. package/assets/images/icons/wifi.svg +3 -0
  5. package/assets/images/menu/dhr/MHRM09N0004.svg +14 -0
  6. package/assets/images/menu/dhr/MHRP09N0028.svg +6 -0
  7. package/assets/images/menu/dhr/MHRP09N0029.svg +14 -0
  8. package/assets/images/menu/dhr/MHRP09N0030.svg +4 -0
  9. package/assets/images/menu/dhr/MHRP09N0031.svg +5 -0
  10. package/assets/images/menu/dhr/MHRP29N0012.svg +7 -0
  11. package/assets/images/menu/dhr/MHRP29N0021.svg +8 -0
  12. package/assets/images/menu/dhr/MHRP29N0022.svg +9 -0
  13. package/assets/images/menu/dhr/MHRP29N0023.svg +22 -0
  14. package/assets/images/menu/dhr/MHRP39N0015.svg +5 -0
  15. package/assets/images/menu/dhr/TASK.svg +9 -0
  16. package/assets/images/menu/erp/D05.svg +8 -0
  17. package/assets/images/menu/erp/D06.svg +4 -0
  18. package/assets/images/menu/erp/D90R.svg +9 -0
  19. package/assets/images/menu/erp/DBC.svg +9 -0
  20. package/assets/images/menu/erp/{W05F0006.svg → W05F0006N0000.svg} +0 -0
  21. package/assets/images/menu/erp/{W05F0008.svg → W05F0008N0000.svg} +0 -0
  22. package/assets/images/menu/erp/{W05F4000.svg → W05F4000N0000.svg} +0 -0
  23. package/assets/images/menu/erp/{W06F0005.svg → W06F0005N0000.svg} +0 -0
  24. package/assets/images/menu/erp/{W06F0006.svg → W06F0006N0000.svg} +0 -0
  25. package/assets/images/menu/erp/{W06F0008.svg → W06F0008N0000.svg} +0 -0
  26. package/assets/images/menu/erp/W94F1000N0000.svg +9 -0
  27. package/assets/images/menu/erp/W94F1000N0001.svg +9 -0
  28. package/components/accordion/css.js +42 -33
  29. package/components/accordion/details.js +29 -17
  30. package/components/accordion/group.js +23 -23
  31. package/components/accordion/index.js +36 -27
  32. package/components/accordion/summary.js +10 -11
  33. package/components/alert/index.js +97 -91
  34. package/components/alert/notify.js +10 -8
  35. package/components/avatar/index.js +19 -17
  36. package/components/badge/index.js +122 -139
  37. package/components/button/icon.js +242 -334
  38. package/components/button/index.js +272 -427
  39. package/components/button/more.js +4 -5
  40. package/components/button/ripple-effect.js +4 -6
  41. package/components/card/body-card.js +4 -6
  42. package/components/card/card.js +4 -8
  43. package/components/card/index.js +4 -5
  44. package/components/chart/Pie/Sector.js +4 -5
  45. package/components/chart/Pie/Sectors.js +5 -5
  46. package/components/chart/Pie/index.js +8 -9
  47. package/components/chart/Pie-v2/Sector.js +4 -5
  48. package/components/chart/Pie-v2/Sectors.js +7 -8
  49. package/components/chart/Pie-v2/index.js +11 -16
  50. package/components/chart/bar/Bar.js +2 -3
  51. package/components/chart/bar/Labels.js +9 -11
  52. package/components/chart/bar/index.js +17 -9
  53. package/components/chart/bar-v2/Bar.js +2 -3
  54. package/components/chart/bar-v2/Labels.js +9 -11
  55. package/components/chart/bar-v2/index.js +17 -9
  56. package/components/chart/line/Labels.js +8 -10
  57. package/components/chart/line/Point.js +2 -3
  58. package/components/chart/line/index.js +17 -9
  59. package/components/chart/line-v2/Labels.js +8 -10
  60. package/components/chart/line-v2/Point.js +2 -3
  61. package/components/chart/line-v2/index.js +17 -9
  62. package/components/chip/attach.js +12 -16
  63. package/components/chip/index.js +8 -11
  64. package/components/collapse/index.js +4 -5
  65. package/components/divider/index.js +27 -14
  66. package/components/form-control/attachment/index.js +143 -87
  67. package/components/form-control/calendar/function.js +24 -23
  68. package/components/form-control/calendar/index.js +2 -4
  69. package/components/form-control/calendar/range.js +3 -4
  70. package/components/form-control/checkbox/index.js +85 -71
  71. package/components/form-control/control/index.js +4 -6
  72. package/components/form-control/date-picker/index-old.js +0 -2
  73. package/components/form-control/date-picker/index.js +39 -43
  74. package/components/form-control/date-range-picker/index.js +26 -28
  75. package/components/form-control/dropdown/index.js +173 -202
  76. package/components/form-control/dropdown-box/index.js +72 -49
  77. package/components/form-control/form-group/index.js +4 -5
  78. package/components/form-control/helper-text/index.js +4 -5
  79. package/components/form-control/input-base/index.js +28 -38
  80. package/components/form-control/label/index.js +23 -13
  81. package/components/form-control/money-input/index.js +6 -6
  82. package/components/form-control/number-input/index.js +12 -14
  83. package/components/form-control/phone-input/index.js +4 -5
  84. package/components/form-control/radio/index.js +7 -15
  85. package/components/form-control/text-input/index.js +14 -24
  86. package/components/form-control/time-picker/index.js +15 -26
  87. package/components/form-control/time-picker/swiper.js +2 -4
  88. package/components/form-control/toggle/index.js +22 -18
  89. package/components/form-view/helper-text.js +4 -5
  90. package/components/form-view/index.js +4 -5
  91. package/components/form-view/input.js +5 -7
  92. package/components/form-view/label.js +2 -6
  93. package/components/list/list-item-action.js +7 -8
  94. package/components/list/list-item-icon.js +4 -5
  95. package/components/list/list-item-text.js +4 -5
  96. package/components/list/list-item.js +4 -5
  97. package/components/list/list.js +4 -5
  98. package/components/list/sub-header.js +4 -5
  99. package/components/modal/body.js +4 -6
  100. package/components/modal/footer.js +4 -6
  101. package/components/modal/header.js +8 -14
  102. package/components/modal/index.js +4 -5
  103. package/components/modal/modal.js +6 -13
  104. package/components/others/extra/index.js +4 -8
  105. package/components/others/option-wrapper/index.js +57 -0
  106. package/components/others/scrollbar/index.js +4 -5
  107. package/components/paging/page-info.js +282 -231
  108. package/components/paging/page-selector.js +4 -7
  109. package/components/popover/index.js +6 -7
  110. package/components/popup/danger_popup.js +8 -18
  111. package/components/popup/index.js +26 -34
  112. package/components/popup/proposals_popup.js +9 -16
  113. package/components/popup/v2/danger-popup.js +4 -6
  114. package/components/popup/v2/index.js +116 -98
  115. package/components/popup/v2/info-popup.js +4 -6
  116. package/components/popup/v2/success-popup.js +4 -6
  117. package/components/popup/v2/warning-popup.js +4 -6
  118. package/components/popup/v2/yes-no-popup.js +4 -6
  119. package/components/progress/circular.js +17 -26
  120. package/components/progress/linear.js +11 -13
  121. package/components/rating/index.js +114 -233
  122. package/components/slider/slider-container.js +15 -10
  123. package/components/slider/slider-item.js +10 -12
  124. package/components/status/index.js +63 -57
  125. package/components/tab/tab-container.js +26 -24
  126. package/components/tab/tab-header.js +36 -27
  127. package/components/tab/tab-panel.js +32 -15
  128. package/components/tab/tab.js +79 -80
  129. package/components/tooltip/index.js +4 -4
  130. package/components/transfer/index.js +10 -11
  131. package/components/tree-view/css.js +2 -0
  132. package/components/tree-view/index.js +14 -13
  133. package/components/typography/index.js +6 -112
  134. package/css/styles.css +1 -1
  135. package/css/styles.css.map +1 -1
  136. package/global/index.js +2 -0
  137. package/icons/basic.js +1648 -959
  138. package/icons/effect.js +45 -103
  139. package/package.json +1 -1
  140. package/readme.md +66 -0
  141. package/styles/color-helper.js +7 -146
  142. package/styles/colors.js +6 -2
  143. package/styles/font.js +9 -0
  144. package/styles/general.js +100 -7
  145. package/styles/typography.js +25 -26
  146. package/theme/settings.js +9 -2
  147. package/theme/theme-provider.js +15 -7
  148. package/theme/with-styles.js +2 -4
  149. package/theme/with-theme.js +2 -4
  150. package/utils/isMobile.js +21 -0
  151. package/utils/renderHTML.js +4 -5
  152. package/utils/renderIcon.js +15 -11
  153. package/utils/updatePosition.js +2 -2
@@ -1,19 +1,66 @@
1
- function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
2
-
3
1
  /** @jsxRuntime classic */
4
2
 
5
3
  /** @jsx jsx */
6
- import { memo, useRef, useEffect, useMemo, forwardRef } from 'react';
4
+ import { memo, useRef, useMemo, forwardRef, useImperativeHandle } from 'react';
7
5
  import PropTypes from 'prop-types';
8
6
  import { jsx, css } from '@emotion/core';
9
- import * as colors from '../../styles/colors';
10
- import { hexToRgb, isColor, isColorName, lighten } from '../../styles/color-helper';
7
+ import OptionWrapper from '../others/option-wrapper';
8
+ import * as allColors from '../../styles/colors';
9
+ import { color as colors } from '../../styles/colors';
10
+ import { hexToRGBA } from '../../styles/color-helper';
11
11
  import { capitalize } from '../../utils';
12
- import * as Icons from '../../icons';
12
+ import Icon from '../../icons';
13
13
  import Ripple from './ripple-effect';
14
- import theme from '../../theme/settings';
15
14
  import { getClassNameFromColor, getRippleColor } from '.';
16
- import CircularProgress from "../progress/circular";
15
+ import CircularProgress from '../progress/circular';
16
+ import { alignCenter, backgroundTransparent, border, borderBox, borderNone, cursorPointer, flexRow, inlineFlex, justifyCenter, noBorder, outlineNone, overflowHidden, pointerEventsNone, positionRelative, userSelectNone } from '../../styles/general';
17
+ 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
32
+ }
33
+ } = colors;
34
+ const colorMap = new Map([['primary', active], ['success', success], ['warning', warning], ['danger', danger], ['info', info]]);
35
+ const sizeMap = new Map([['tiny', {
36
+ buttonSize: '24px',
37
+ iconSize: '16px'
38
+ }], ['small', {
39
+ buttonSize: '32px',
40
+ iconSize: '20px'
41
+ }], ['medium', {
42
+ buttonSize: '40px',
43
+ iconSize: '24px'
44
+ }], ['large', {
45
+ buttonSize: '48px',
46
+ iconSize: '32px'
47
+ }], ['giant', {
48
+ buttonSize: '56px',
49
+ iconSize: '40px'
50
+ }]]);
51
+ const iconColorMap = new Map([['Close', danger], ['Cancel', danger], ['Approval', success], ['Delete', warning], ['Trash', warning], ['Edit', info], ['EditV2', info], ['View', info]]);
52
+ const alphaArr = {
53
+ hover: 0.1,
54
+ focus: 0.2,
55
+ active: 0.3
56
+ };
57
+ const alphaLoading = 0.2; // customIconSize calculated based on design size
58
+ // Button size <= 24 => icon size = Button size - 8
59
+ // Button size > 24 && <= 32 => icon size = Button size - 12
60
+ // Button size > 32 => icon size = Button size - 16
61
+
62
+ const customIconSize = width => width <= 24 ? width - 8 : width <= 32 ? width - 12 : width - 16;
63
+
17
64
  const ButtonIcon = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
18
65
  type,
19
66
  viewType,
@@ -32,364 +79,214 @@ const ButtonIcon = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
32
79
  children,
33
80
  refs,
34
81
  loading,
82
+ colorHover,
35
83
  ...props
36
- }, ref) => {
37
- if (!ref) {
38
- ref = useRef(null);
39
- }
84
+ }, reference) => {
85
+ var _sizeMap$get, _sizeMap$get2;
40
86
 
87
+ const ref = useRef(null);
88
+ const buttonSize = ((_sizeMap$get = sizeMap.get(size)) === null || _sizeMap$get === void 0 ? void 0 : _sizeMap$get.buttonSize) || '40px';
89
+ 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';
90
+ colorHover = colorMap.get(colorHover) || colorHover;
41
91
  const ButtonRoot = css`
42
- display: inline-flex;
43
- position: relative;
44
- justify-content: center;
45
- align-items: center;
46
- outline: none;
47
- margin: 2px;
48
- box-sizing: border-box;
92
+ ${inlineFlex}
93
+ ${positionRelative}
94
+ ${justifyCenter}
95
+ ${alignCenter}
96
+ ${outlineNone}
97
+ ${borderBox}
98
+ ${overflowHidden}
99
+ ${cursorPointer}
100
+ ${userSelectNone}
101
+ padding: 0;
49
102
  border-radius: ${circular ? '50%' : '4px'};
50
103
  transition: background-color 0.5s, filter 0.5s;
51
- overflow: hidden;
52
- cursor: pointer;
53
- user-select: none;
54
- &.tiny {
55
- padding: 4px;
56
- &.outlined {
57
- padding: 3px;
58
- }
59
- .DGN-UI-ButtonIcon-Icon {
60
- height: 16px;
61
- width: 16px;
62
- }
104
+ .DGN-UI-ButtonIcon-Icon {
105
+ ${flexRow}
106
+ ${positionRelative}
107
+ ${borderBox}
108
+ ${justifyCenter}
109
+ ${alignCenter}
63
110
  }
64
- &.small {
65
- padding: 6px;
111
+ &.disabled {
112
+ cursor: not-allowed !important;
113
+ color: ${systemDisabled} !important;
66
114
  &.outlined {
67
- padding: 5px;
68
- }
69
- .DGN-UI-ButtonIcon-Icon {
70
- height: 20px;
71
- width: 20px;
115
+ border-color: ${systemDisabled} !important;
116
+ background-color: transparent !important;
72
117
  }
73
- }
74
- &.medium {
75
- padding: 8px;
76
- &.outlined {
77
- padding: 7px;
118
+ &.filled {
119
+ background-color: ${fillDisabled} !important;
120
+ filter: brightness(1) !important;
78
121
  }
79
- .DGN-UI-ButtonIcon-Icon {
80
- height: 24px;
81
- width: 24px;
122
+ &.text {
123
+ background-color: transparent !important;
82
124
  }
83
125
  }
84
- &.large {
85
- padding: 8px;
86
- &.outlined {
87
- padding: 7px;
88
- }
89
- .DGN-UI-ButtonIcon-Icon {
90
- height: 32px;
91
- width: 32px;
92
- }
126
+ &.loading {
127
+ ${pointerEventsNone}
93
128
  }
94
- &.giant {
95
- padding: 8px;
96
- &.outlined {
97
- padding: 7px;
98
- }
129
+ &.${size} {
130
+ width: ${width ? isNaN(width) ? width : width + 'px' : buttonSize};
131
+ height: ${height ? isNaN(height) ? height : height + 'px' : buttonSize};
99
132
  .DGN-UI-ButtonIcon-Icon {
100
- height: 40px;
101
- width: 40px;
133
+ height: ${iconSize};
134
+ width: ${iconSize};
102
135
  }
103
136
  }
104
137
  &.outlined {
105
- background-color: ${theme.colors.white};
106
- font-weight : bold;
138
+ ${backgroundTransparent}
107
139
  &.default {
108
- border: 1px solid ${theme.colors.secondary};
109
- color : ${theme.colors.default};
110
- &:hover {
111
- background-color: ${lighten(theme.colors.default, 0.9)};
112
- }
113
- &:focus {
114
- background-color: ${lighten(theme.colors.default, 0.8)};
115
- }
140
+ ${border(1, rest)}
141
+ color: ${rest};
142
+ &.loading,
143
+ &:hover,
144
+ &:focus,
116
145
  &:active {
117
- background-color: ${lighten(theme.colors.default, 0.7)};
118
- }
119
- }
120
- &.primary {
121
- border: 1px solid ${theme.colors.primary};
122
- color : ${theme.colors.primary};
123
- &:hover {
124
- background-color: ${lighten(theme.colors.primary, 0.9)};
125
- }
126
- &:focus {
127
- background-color: ${lighten(theme.colors.primary, 0.8)};
128
- }
129
- &:active {
130
- background-color: ${lighten(theme.colors.primary, 0.7)};
131
- }
132
- }
133
- &.success {
134
- border: 1px solid ${theme.colors.success};
135
- color : ${theme.colors.success};
136
- &:hover {
137
- background-color: ${lighten(theme.colors.success, 0.9)};
138
- }
139
- &:focus {
140
- background-color: ${lighten(theme.colors.success, 0.8)};
141
- }
142
- &:active {
143
- background-color: ${lighten(theme.colors.success, 0.7)};
144
- }
145
- }
146
- &.warning {
147
- border: 1px solid ${theme.colors.warning};
148
- color : ${theme.colors.warning};
149
- &:hover {
150
- background-color: ${lighten(theme.colors.warning, 0.9)};
146
+ color: ${colorHover};
147
+ border-color: ${colorHover};
151
148
  }
152
- &:focus {
153
- background-color: ${lighten(theme.colors.warning, 0.8)};
154
- }
155
- &:active {
156
- background-color: ${lighten(theme.colors.warning, 0.7)};
149
+ &.loading {
150
+ background-color: ${hexToRGBA(colorHover, alphaLoading)};
157
151
  }
152
+ ${Object.keys(alphaArr).map(key => `&:${key} {
153
+ background-color: ${hexToRGBA(colorHover, alphaArr[key])};
154
+ }`)}// &:hover | &:focus | &:active
158
155
  }
159
- &.danger {
160
- border: 1px solid ${theme.colors.danger};
161
- color : ${theme.colors.danger};
162
- &:hover {
163
- background-color: ${lighten(theme.colors.danger, 0.9)};
164
- }
165
- &:focus {
166
- background-color: ${lighten(theme.colors.danger, 0.8)};
167
- }
168
- &:active {
169
- background-color: ${lighten(theme.colors.danger, 0.7)};
156
+ &.${color} {
157
+ ${color !== 'default' && border(1, colorMap.get(color))}
158
+ color: ${colorMap.get(color)};
159
+ &.loading {
160
+ background-color: ${hexToRGBA(colorMap.get(color), alphaLoading)};
170
161
  }
162
+ ${Object.keys(alphaArr).map(key => `&:${key} {
163
+ background-color: ${hexToRGBA(colorMap.get(color), alphaArr[key])};
164
+ }`)}
171
165
  }
172
- &.info {
173
- border: 1px solid ${theme.colors.info};
174
- color : ${theme.colors.info};
175
- &:hover {
176
- background-color: ${lighten(theme.colors.info, 0.9)};
177
- }
178
- &:focus {
179
- background-color: ${lighten(theme.colors.info, 0.8)};
180
- }
181
- &:active {
182
- background-color: ${lighten(theme.colors.info, 0.7)};
166
+ &.custom-color {
167
+ ${border(1, color)}
168
+ color: ${color};
169
+ &.loading {
170
+ background-color: ${hexToRGBA(color, alphaLoading)};
183
171
  }
172
+ ${Object.keys(alphaArr).map(key => `&:${key} {
173
+ background-color: ${hexToRGBA(color, alphaArr[key])};
174
+ }`)}
184
175
  }
185
- ${isColor(color) && `&.custom-color {
186
- border: 1px solid ${color};
187
- color : ${color};
188
- &:hover {
189
- background-color: ${lighten(color, 0.9)};
190
- }
191
- &:focus {
192
- background-color: ${lighten(color, 0.8)};
193
- }
194
- &:active {
195
- background-color: ${lighten(color, 0.7)};
196
- }
197
- }`}
198
- ${isColorName(color) && `&.custom-color {
199
- border: 1px solid ${isColorName(color)};
200
- color : ${isColorName(color)};
201
- &:hover {
202
- background-color: ${lighten(isColorName(color), 0.9)};
203
- }
204
- &:focus {
205
- background-color: ${lighten(isColorName(color), 0.8)};
206
- }
207
- &:active {
208
- background-color: ${lighten(isColorName(color), 0.7)};
209
- }
210
- }`}
211
176
  }
212
177
  &.filled {
213
- border : none;
214
- color : ${theme.colors.white};
178
+ ${borderNone}
179
+ color: ${white};
215
180
  font-weight: bold;
216
- &:hover, &:focus {
181
+ &.loading,
182
+ &:hover,
183
+ &:focus {
217
184
  filter: brightness(0.85);
218
185
  }
219
186
  &:active {
220
187
  filter: brightness(0.7);
221
188
  }
222
189
  &.default {
223
- background-color: ${theme.colors.secondary};
224
- }
225
- &.primary {
226
- background-color: ${theme.colors.primary};
227
- }
228
- &.success {
229
- background-color: ${theme.colors.success};
230
- }
231
- &.warning {
232
- background-color: ${theme.colors.warning};
233
- }
234
- &.danger {
235
- background-color: ${theme.colors.danger};
190
+ background-color: ${rest};
191
+ &.loading,
192
+ &:hover,
193
+ &:focus,
194
+ &:active {
195
+ background-color: ${colorHover};
196
+ }
236
197
  }
237
- &.info {
238
- background-color: ${theme.colors.info};
198
+ &.${color} {
199
+ background-color: ${colorMap.get(color)};
239
200
  }
240
- ${isColor(color) && `&.custom-color {
201
+ &.custom-color {
241
202
  background-color: ${color};
242
- }`}
243
- ${isColorName(color) && `&.custom-color {
244
- background-color: ${isColorName(color)};
245
- }`}
203
+ }
246
204
  }
247
205
  &.text {
248
- background-color: transparent;
249
- border : none !important;
206
+ ${noBorder}
207
+ ${backgroundTransparent}
250
208
  &.default {
251
- color : ${theme.colors.secondary};
252
- &:hover {
253
- background-color: ${lighten(theme.colors.secondary, 0.9)};
254
- }
255
- &:focus {
256
- background-color: ${lighten(theme.colors.secondary, 0.8)};
257
- }
209
+ color: ${rest};
210
+ &:hover,
211
+ &:focus,
258
212
  &:active {
259
- background-color: ${lighten(theme.colors.secondary, 0.7)};
260
- }
261
- }
262
- &.primary {
263
- color : ${theme.colors.primary};
264
- &:hover {
265
- background-color: ${lighten(theme.colors.primary, 0.9)};
266
- }
267
- &:focus {
268
- background-color: ${lighten(theme.colors.primary, 0.8)};
213
+ color: ${colorHover};
269
214
  }
270
- &:active {
271
- background-color: ${lighten(theme.colors.primary, 0.7)};
215
+ &.loading {
216
+ color: ${active};
217
+ background-color: ${hexToRGBA(colorHover, alphaLoading)};
272
218
  }
219
+ ${Object.keys(alphaArr).map(key => `&:${key} {
220
+ background-color: ${hexToRGBA(colorHover, alphaArr[key])};
221
+ }`)}
273
222
  }
274
- &.success {
275
- color : ${theme.colors.success};
276
- &:hover {
277
- background-color: ${lighten(theme.colors.success, 0.9)};
278
- }
279
- &:focus {
280
- background-color: ${lighten(theme.colors.success, 0.8)};
281
- }
282
- &:active {
283
- background-color: ${lighten(theme.colors.success, 0.7)};
223
+ &.${color} {
224
+ color: ${colorMap.get(color)};
225
+ &.loading {
226
+ background-color: ${hexToRGBA(colorMap.get(color), alphaLoading)};
284
227
  }
228
+ ${Object.keys(alphaArr).map(key => `&:${key} {
229
+ background-color: ${hexToRGBA(colorMap.get(color), alphaArr[key])};
230
+ }`)}
285
231
  }
286
- &.warning {
287
- color : ${theme.colors.warning};
288
- &:hover {
289
- background-color: ${lighten(theme.colors.warning, 0.9)};
290
- }
291
- &:focus {
292
- background-color: ${lighten(theme.colors.warning, 0.8)};
293
- }
294
- &:active {
295
- background-color: ${lighten(theme.colors.warning, 0.7)};
232
+ &.custom-color {
233
+ color: ${color};
234
+ &.loading {
235
+ background-color: ${hexToRGBA(color, alphaLoading)};
296
236
  }
237
+ ${Object.keys(alphaArr).map(key => `&:${key} {
238
+ background-color: ${hexToRGBA(color, alphaArr[key])};
239
+ }`)}
297
240
  }
298
- &.danger {
299
- color : ${theme.colors.danger};
300
- &:hover {
301
- background-color: ${lighten(theme.colors.danger, 0.9)};
302
- }
303
- &:focus {
304
- background-color: ${lighten(theme.colors.danger, 0.8)};
305
- }
306
- &:active {
307
- background-color: ${lighten(theme.colors.danger, 0.7)};
308
- }
241
+ }
242
+ &.ghost {
243
+ ${backgroundTransparent}
244
+ ${noBorder}
245
+ color: ${rest};
246
+ &.${size} {
247
+ height: ${iconSize};
248
+ width: ${iconSize};
309
249
  }
310
- &.info {
311
- color : ${theme.colors.info};
312
- &:hover {
313
- background-color: ${lighten(theme.colors.info, 0.9)};
314
- }
315
- &:focus {
316
- background-color: ${lighten(theme.colors.info, 0.8)};
317
- }
250
+ &.default {
251
+ &:hover,
252
+ &:focus,
318
253
  &:active {
319
- background-color: ${lighten(theme.colors.info, 0.7)};
254
+ color: ${iconColorMap.get(capitalize(name)) || colorHover};
320
255
  }
321
256
  }
322
- ${isColor(color) && `&.custom-color {
323
- color : ${color};
324
- &:hover {
325
- background-color: ${lighten(color, 0.9)};
326
- }
327
- &:focus {
328
- background-color: ${lighten(color, 0.8)};
329
- }
257
+ &.${color} {
258
+ &:hover,
259
+ &:focus,
330
260
  &:active {
331
- background-color: ${lighten(color, 0.7)};
332
- }
333
- }`}
334
- ${isColorName(color) && `&.custom-color {
335
- color : ${isColorName(color)};
336
- &:hover {
337
- background-color: ${lighten(isColorName(color), 0.9)};
338
- }
339
- &:focus {
340
- background-color: ${lighten(isColorName(color), 0.8)};
261
+ color: ${colorMap.get(color)};
341
262
  }
263
+ }
264
+ &.custom-color {
265
+ &:hover,
266
+ &:focus,
342
267
  &:active {
343
- background-color: ${lighten(isColorName(color), 0.7)};
268
+ color: ${color};
344
269
  }
345
- }`}
346
- }
347
- &:disabled {
348
- pointer-events: none;
349
- color: ${colors.dark4} !important;
350
- &.filled, &.outlined {
351
- background-color: ${theme.colors.bgDisabled} !important;
352
- filter: brightness(1);
353
- }
354
- &.outlined {
355
- border-color: ${theme.colors.disabled};
356
- }
357
- &.text {
358
- background-color: transparent !important;
359
- }
360
- .DGN-UI-ButtonIcon-Icon {
361
- pointer-events: auto;
362
- cursor: no-drop;
363
270
  }
364
271
  }
365
- &:not(:disabled):focus {
366
- box-shadow: ${viewType !== 'text' ? '0 0 0 2px ' + hexToRgb(colors.brand + '20') : 'none'};
367
- }
368
- .DGN-UI-ButtonIcon-Icon {
369
- display: flex;
370
- position: relative;
371
- box-sizing: border-box;
372
- justify-content: center;
373
- align-items: center;
374
- }
375
272
  `;
376
- const NotFoundIcon = css`
377
- display: block;
378
- width: 70%;
379
- height: 70%;
380
- border: 1px dashed ${theme.colors.border};
381
- `;
382
- useEffect(() => {
383
- if (refs) refs(ref);
384
- }, []);
273
+ useImperativeHandle(reference, () => {
274
+ const currentRef = ref.current || {};
275
+ const _instance = {}; // methods
276
+
277
+ _instance.__proto__ = {}; // hidden methods
278
+
279
+ currentRef.instance = _instance;
280
+ return currentRef;
281
+ });
385
282
 
386
283
  const iconLoading = () => {
387
284
  return jsx(CircularProgress, {
388
- size: "extraSmall",
389
- background: "transparent",
285
+ size: 'extraSmall',
286
+ background: 'transparent',
390
287
  color: 'currentColor',
391
288
  strokeWidth: 3,
392
- width: 24
289
+ width: parseInt(iconSize)
393
290
  });
394
291
  };
395
292
 
@@ -398,63 +295,66 @@ const ButtonIcon = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
398
295
  onClick && onClick(event);
399
296
  };
400
297
 
401
- const ButtonView = useMemo(() => {
298
+ return useMemo(() => {
402
299
  let node = children;
403
300
 
404
301
  if (!node) {
405
- const IconComp = Icons[capitalize(name)];
406
-
407
- if (IconComp) {
408
- node = jsx(IconComp, {
409
- width: width,
410
- height: height,
411
- color: 'currentColor',
412
- viewBox: viewBox
413
- });
414
- } else {
415
- node = jsx("span", {
416
- css: NotFoundIcon
417
- });
418
- }
302
+ node = jsx(Icon, {
303
+ name: name,
304
+ width: iconSize,
305
+ height: iconSize,
306
+ color: 'currentColor',
307
+ viewBox: true
308
+ });
419
309
  }
420
310
 
421
- return jsx("button", _extends({
311
+ return jsx("button", {
422
312
  css: ButtonRoot,
423
313
  style: style,
424
314
  ref: ref,
425
315
  type: type,
426
316
  onClick: _onClick,
427
- disabled: disabled,
428
- className: ['DGN-UI-ButtonIcon', viewType, getClassNameFromColor(color), size, className].join(' ').trim().replace(/\s+/g, ' ')
429
- }, props), loading && iconLoading(), !loading && jsx("span", {
317
+ className: ['DGN-UI-ButtonIcon', viewType, getClassNameFromColor(color), size, loading && 'loading', disabled && 'disabled', className].join(' ').trim().replace(/\s+/g, ' '),
318
+ ...props
319
+ }, loading && iconLoading(), !loading && jsx("span", {
430
320
  className: 'DGN-UI-ButtonIcon-Icon'
431
- }, " ", node, " "), !disabled && jsx(Ripple, {
432
- color: getRippleColor(color, viewType, colors)
321
+ }, " ", node, " "), !disabled && !loading && viewType !== 'ghost' && jsx(Ripple, {
322
+ color: getRippleColor(color, viewType, allColors)
433
323
  }));
434
- }, [size, viewType, color, disabled, name, children, onClick, loading, circular, viewBox]);
435
- return ButtonView;
324
+ }, [size, viewType, color, colorHover, disabled, name, children, onClick, loading, circular, viewBox, width, height]);
436
325
  }));
437
326
  ButtonIcon.defaultProps = {
438
327
  viewType: 'outlined',
439
328
  color: 'default',
329
+ colorHover: active,
440
330
  size: 'medium',
441
331
  className: '',
442
- width: '100%',
443
- height: '100%',
444
332
  circular: false,
445
- disabled: false
333
+ disabled: false,
334
+ viewBox: true
446
335
  };
447
336
  ButtonIcon.propTypes = {
448
337
  /** The type attribute specifies the type of tag button */
449
338
  type: PropTypes.oneOf(['button', 'submit', 'reset']),
450
339
 
451
340
  /** used to fill background for button */
452
- viewType: PropTypes.oneOf(['text', 'outlined', 'filled']),
341
+ viewType: PropTypes.oneOf(['text', 'outlined', 'filled', 'ghost']),
453
342
 
454
343
  /** color for button */
455
344
  color: PropTypes.string,
456
345
 
457
- /** size button */
346
+ /** custom hover color for button with color 'default' */
347
+ colorHover: PropTypes.string,
348
+
349
+ /**
350
+ * size of button
351
+ *
352
+ * * tiny (button 24px, icon 16px)
353
+ * * small (button 32px, icon 20px)
354
+ * * medium (button 40px, icon 24px)
355
+ * * large (button 48px, icon 32px)
356
+ * * giant (button 56px, icon 40px)
357
+ * */
458
358
  size: PropTypes.oneOf(['tiny', 'small', 'medium', 'large', 'giant']),
459
359
 
460
360
  /** name of icon in icons store */
@@ -463,10 +363,10 @@ ButtonIcon.propTypes = {
463
363
  /** the class for button */
464
364
  className: PropTypes.string,
465
365
 
466
- /** the width of icon */
366
+ /** the width of button */
467
367
  width: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
468
368
 
469
- /** the height of icon */
369
+ /** the height of button */
470
370
  height: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
471
371
 
472
372
  /** has view box if true */
@@ -488,6 +388,14 @@ ButtonIcon.propTypes = {
488
388
  props: PropTypes.any,
489
389
 
490
390
  /** status loading of button */
491
- loading: PropTypes.bool
391
+ loading: PropTypes.bool,
392
+
393
+ /**
394
+ * ref methods
395
+ *
396
+ * * onClick
397
+ */
398
+ reference: PropTypes.func
492
399
  };
493
- export default ButtonIcon;
400
+ export { ButtonIcon };
401
+ export default OptionWrapper(ButtonIcon);