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,43 @@
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';
7
+ import OptionWrapper from '../others/option-wrapper';
8
+ import * as allColors from '../../styles/colors';
9
+ import { color as colors } from '../../styles/colors';
10
10
  import { Typography } from '../';
11
- import { detectColor, fade, hexToRgb, hslToRgb, isColor, isColorName, lighten, rgbaToHexA, rgbToHex } from '../../styles/color-helper';
12
- import { capitalize } from '../../utils';
13
- import * as Icons from '../../icons';
11
+ import { detectColor, fade, hslToRgb, isColor, isColorName, rgbaToHexA, rgbToHex, hexToRGBA } from '../../styles/color-helper';
14
12
  import Ripple from './ripple-effect';
15
- import theme from '../../theme/settings';
16
- import CircularProgress from "../progress/circular";
13
+ import CircularProgress from '../progress/circular';
14
+ import Icon from '../../icons';
15
+ import { flexRow, alignCenter, justifyCenter, positionRelative, borderRadius4px, borderBox, noPadding, noBorder, cursorPointer, overflowHidden, pointerEventsNone, outlineNone, userSelectNone, backgroundTransparent, inlineFlex, noMargin } from '../../styles/general';
16
+ import { typography } from '../../styles/typography';
17
+ const {
18
+ heading1,
19
+ heading2,
20
+ heading4,
21
+ heading5,
22
+ uppercase
23
+ } = typography;
24
+ const {
25
+ system: {
26
+ active,
27
+ disabled: systemDisabled,
28
+ rest,
29
+ white
30
+ },
31
+ semantic: {
32
+ success,
33
+ warning,
34
+ danger,
35
+ info
36
+ },
37
+ fill: {
38
+ disabled: fillDisabled
39
+ }
40
+ } = colors;
17
41
  export const getRippleColor = (color, viewType, colors) => {
18
42
  if (!isColor(color) && !isColorName(color)) {
19
43
  let level = 3;
@@ -59,12 +83,21 @@ export const getRippleColor = (color, viewType, colors) => {
59
83
  }
60
84
  };
61
85
  export const getClassNameFromColor = color => {
62
- if (!isColor(color) && !isColorName(color)) {
63
- return color;
64
- }
65
-
66
- return 'custom-color';
86
+ return !isColor(color) && !isColorName(color) ? color : 'custom-color';
67
87
  };
88
+ const colorMap = new Map([['primary', active], ['success', success], ['warning', warning], ['danger', danger], ['info', info]]);
89
+ const iconSizeMap = new Map([['tiny', '16px'], ['small', '20px'], ['medium', '24px'], ['large', '32px'], ['giant', '40px']]);
90
+ const paddingSizeMap = new Map([['tiny', '4px 8px'], ['small', '6px 12px'], ['medium', '8px 16px'], ['large', '8px 20px'], ['giant', '8px 24px']]);
91
+ const outlinedPaddingSizeMap = new Map([['tiny', '3px 7px'], ['small', '5px 11px'], ['medium', '7px 15px'], ['large', '7px 19px'], ['giant', '7px 23px']]);
92
+ const iconMarginSizeMap = new Map([['tiny', '4px'], ['small', '4px'], ['medium', '4px'], ['large', '6px'], ['giant', '8px']]);
93
+ const typographySizeMap = new Map([['tiny', heading5], ['small', heading5], ['medium', heading4], ['large', heading2], ['giant', heading1]]);
94
+ const minHeightSizeMap = new Map([['tiny', '24px'], ['small', '32px'], ['medium', '40px'], ['large', '48px'], ['giant', '56px']]);
95
+ const alphaArr = {
96
+ hover: 0.1,
97
+ focus: 0.2,
98
+ active: 0.3
99
+ };
100
+ const alphaLoading = 0.2;
68
101
  const Button = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
69
102
  type,
70
103
  viewType,
@@ -81,470 +114,280 @@ const Button = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
81
114
  refs,
82
115
  loading,
83
116
  ...props
84
- }, ref) => {
85
- if (!ref) {
86
- ref = useRef(null);
87
- }
88
-
117
+ }, reference) => {
118
+ const ref = useRef(null);
119
+ label = label || text || '';
120
+ const iconSize = iconSizeMap.get(size);
121
+ const paddingSize = paddingSizeMap.get(size);
122
+ const outlinedPaddingSize = outlinedPaddingSizeMap.get(size);
123
+ const typographySize = typographySizeMap.get(size);
124
+ const iconMarginSize = iconMarginSizeMap.get(size);
125
+ const minHeightSize = minHeightSizeMap.get(size);
89
126
  const ButtonIcon = css`
90
- display: flex;
91
- position: relative;
92
- box-sizing: border-box;
93
- justify-content: center;
94
- align-items: center;
127
+ ${flexRow}
128
+ ${alignCenter}
129
+ ${justifyCenter}
130
+ ${positionRelative}
131
+ ${borderBox}
95
132
  `;
96
133
  const ButtonText = css`
134
+ white-space: nowrap;
97
135
  color: inherit;
98
- text-transform: inherit;
99
- margin: 0 ${loading ? '5px' : 0};
136
+ margin: 0 ${loading ? iconMarginSize : 0};
100
137
  `;
101
138
  const ButtonRoot = css`
102
- display: flex;
103
- position: relative;
104
- justify-content: center;
105
- align-items: center;
139
+ ${inlineFlex}
140
+ ${alignCenter}
141
+ ${justifyCenter}
142
+ ${positionRelative}
143
+ ${borderRadius4px}
144
+ ${borderBox}
145
+ ${uppercase}
146
+ ${cursorPointer}
147
+ ${overflowHidden}
148
+ ${outlineNone}
149
+ ${userSelectNone}
106
150
  height: max-content;
107
- outline: none;
108
- margin: 2px;
109
- box-sizing: border-box;
110
- border-radius: 4px;
111
151
  transition: all 0.5s;
112
- overflow: hidden;
113
- text-transform: ${theme.typography.button.textTransform};
114
- cursor: pointer;
115
- user-select: none;
116
- &.text {
117
- background-color: transparent;
118
- border : none !important;
119
- &.default {
120
- color : ${theme.colors.secondary};
121
- &:hover {
122
- background-color: ${lighten(theme.colors.secondary, 0.9)};
123
- }
124
- &:focus {
125
- background-color: ${lighten(theme.colors.secondary, 0.8)};
126
- }
127
- &:active {
128
- background-color: ${lighten(theme.colors.secondary, 0.7)};
129
- }
152
+ &.disabled {
153
+ cursor: not-allowed !important;
154
+ color: ${systemDisabled} !important;
155
+ &.outlined {
156
+ border-color: ${systemDisabled} !important;
157
+ background-color: transparent !important;
130
158
  }
131
- &.primary {
132
- color : ${theme.colors.primary};
133
- &:hover {
134
- background-color: ${lighten(theme.colors.primary, 0.9)};
135
- }
136
- &:focus {
137
- background-color: ${lighten(theme.colors.primary, 0.8)};
138
- }
139
- &:active {
140
- background-color: ${lighten(theme.colors.primary, 0.7)};
141
- }
159
+ &.filled {
160
+ background-color: ${fillDisabled} !important;
161
+ filter: brightness(1) !important;
142
162
  }
143
- &.success {
144
- color : ${theme.colors.success};
145
- &:hover {
146
- background-color: ${lighten(theme.colors.success, 0.9)};
147
- }
148
- &:focus {
149
- background-color: ${lighten(theme.colors.success, 0.8)};
150
- }
151
- &:active {
152
- background-color: ${lighten(theme.colors.success, 0.7)};
153
- }
163
+ &.text {
164
+ background-color: transparent !important;
154
165
  }
155
- &.warning {
156
- color : ${theme.colors.warning};
157
- &:hover {
158
- background-color: ${lighten(theme.colors.warning, 0.9)};
159
- }
160
- &:focus {
161
- background-color: ${lighten(theme.colors.warning, 0.8)};
162
- }
163
- &:active {
164
- background-color: ${lighten(theme.colors.warning, 0.7)};
165
- }
166
+ }
167
+ /* &:not(:disabled):focus {
168
+ box-shadow: ${viewType === 'outlined' ? '0 0 0 2px ' + hexToRGBA(active, 0.13) : 'none'};
169
+ } */
170
+ &.loading {
171
+ ${pointerEventsNone}
172
+ }
173
+ &.${size} {
174
+ padding: ${paddingSize};
175
+ min-height: ${minHeightSize};
176
+ min-width: max-content;
177
+ &.outlined {
178
+ padding: ${outlinedPaddingSize};
166
179
  }
167
- &.danger {
168
- color : ${theme.colors.danger};
169
- &:hover {
170
- background-color: ${lighten(theme.colors.danger, 0.9)};
171
- }
172
- &:focus {
173
- background-color: ${lighten(theme.colors.danger, 0.8)};
174
- }
175
- &:active {
176
- background-color: ${lighten(theme.colors.danger, 0.7)};
177
- }
180
+ .css-${ButtonText.name} {
181
+ ${typographySize};
178
182
  }
179
- &.info {
180
- color : ${theme.colors.info};
181
- &:hover {
182
- background-color: ${lighten(theme.colors.info, 0.9)};
183
- }
184
- &:focus {
185
- background-color: ${lighten(theme.colors.info, 0.8)};
183
+ .css-${ButtonIcon.name} {
184
+ margin-right: ${endIcon || label ? iconMarginSize : 0};
185
+ &.DGN-UI-Button-End-Icon,
186
+ &.DGN-UI-Button-Custom-End-Icon {
187
+ margin-right: unset;
188
+ margin-left: ${startIcon || label ? iconMarginSize : 0};
186
189
  }
187
- &:active {
188
- background-color: ${lighten(theme.colors.info, 0.7)};
190
+ &.DGN-UI-Button-Start-Icon,
191
+ &.DGN-UI-Button-End-Icon {
192
+ height: ${iconSize};
193
+ width: ${iconSize};
189
194
  }
190
195
  }
191
- ${isColor(color) && `&.custom-color {
192
- color : ${color};
193
- &:hover {
194
- background-color: ${lighten(color, 0.9)};
195
- }
196
- &:focus {
197
- background-color: ${lighten(color, 0.8)};
198
- }
199
- &:active {
200
- background-color: ${lighten(color, 0.7)};
201
- }
202
- }`}
203
- ${isColorName(color) && `&.custom-color {
204
- color : ${isColorName(color)};
205
- &:hover {
206
- background-color: ${lighten(isColorName(color), 0.9)};
207
- }
208
- &:focus {
209
- background-color: ${lighten(isColorName(color), 0.8)};
210
- }
211
- &:active {
212
- background-color: ${lighten(isColorName(color), 0.7)};
213
- }
214
- }`}
196
+ .no-icon {
197
+ ${noMargin}
198
+ height: ${iconSize};
199
+ min-width: 0;
200
+ }
215
201
  }
216
202
  &.outlined {
217
- font-weight: bold;
218
- background-color: ${theme.colors.white};
203
+ ${backgroundTransparent}
219
204
  &.default {
220
- border: 1px solid ${theme.colors.secondary};
221
- color : ${theme.colors.default};
222
- &:hover {
223
- background-color: ${lighten(theme.colors.default, 0.9)};
224
- }
225
- &:focus {
226
- background-color: ${lighten(theme.colors.default, 0.8)};
227
- }
205
+ border: 1px solid ${rest};
206
+ color: ${rest};
207
+ &.loading,
208
+ &:hover,
209
+ &:focus,
228
210
  &:active {
229
- background-color: ${lighten(theme.colors.default, 0.7)};
230
- }
231
- }
232
- &.primary {
233
- border: 1px solid ${theme.colors.primary};
234
- color : ${theme.colors.primary};
235
- &:hover {
236
- background-color: ${lighten(theme.colors.primary, 0.9)};
211
+ color: ${active};
212
+ border-color: ${active};
237
213
  }
238
- &:focus {
239
- background-color: ${lighten(theme.colors.primary, 0.8)};
240
- }
241
- &:active {
242
- background-color: ${lighten(theme.colors.primary, 0.7)};
243
- }
244
- }
245
- &.success {
246
- border: 1px solid ${theme.colors.success};
247
- color : ${theme.colors.success};
248
- &:hover {
249
- background-color: ${lighten(theme.colors.success, 0.9)};
250
- }
251
- &:focus {
252
- background-color: ${lighten(theme.colors.success, 0.8)};
253
- }
254
- &:active {
255
- background-color: ${lighten(theme.colors.success, 0.7)};
256
- }
257
- }
258
- &.warning {
259
- border: 1px solid ${theme.colors.warning};
260
- color : ${theme.colors.warning};
261
- &:hover {
262
- background-color: ${lighten(theme.colors.warning, 0.9)};
263
- }
264
- &:focus {
265
- background-color: ${lighten(theme.colors.warning, 0.8)};
266
- }
267
- &:active {
268
- background-color: ${lighten(theme.colors.warning, 0.7)};
214
+ &.loading {
215
+ background-color: ${hexToRGBA(active, alphaLoading)};
269
216
  }
217
+ ${Object.keys(alphaArr).map(key => `&:${key} {
218
+ background-color: ${hexToRGBA(active, alphaArr[key])};
219
+ }`)}// &:hover | &:focus | &:active
270
220
  }
271
- &.danger {
272
- border: 1px solid ${theme.colors.danger};
273
- color : ${theme.colors.danger};
274
- &:hover {
275
- background-color: ${lighten(theme.colors.danger, 0.9)};
276
- }
277
- &:focus {
278
- background-color: ${lighten(theme.colors.danger, 0.8)};
279
- }
280
- &:active {
281
- background-color: ${lighten(theme.colors.danger, 0.7)};
221
+ &.${color} {
222
+ border: 1px solid ${colorMap.get(color)};
223
+ color: ${colorMap.get(color)};
224
+ &.loading {
225
+ background-color: ${hexToRGBA(colorMap.get(color), alphaLoading)};
282
226
  }
227
+ ${Object.keys(alphaArr).map(key => `&:${key} {
228
+ background-color: ${hexToRGBA(colorMap.get(color), alphaArr[key])};
229
+ }`)}
283
230
  }
284
- &.info {
285
- border: 1px solid ${theme.colors.info};
286
- color : ${theme.colors.info};
287
- &:hover {
288
- background-color: ${lighten(theme.colors.info, 0.9)};
289
- }
290
- &:focus {
291
- background-color: ${lighten(theme.colors.info, 0.8)};
292
- }
293
- &:active {
294
- background-color: ${lighten(theme.colors.info, 0.7)};
295
- }
296
- }
297
- ${isColor(color) && `&.custom-color {
231
+ &.custom-color {
298
232
  border: 1px solid ${color};
299
- color : ${color};
300
- &:hover {
301
- background-color: ${lighten(color, 0.9)};
302
- }
303
- &:focus {
304
- background-color: ${lighten(color, 0.8)};
305
- }
306
- &:active {
307
- background-color: ${lighten(color, 0.7)};
233
+ color: ${color};
234
+ &.loading {
235
+ background-color: ${hexToRGBA(color, alphaLoading)};
308
236
  }
309
- }`}
310
- ${isColorName(color) && `&.custom-color {
311
- border: 1px solid ${isColorName(color)};
312
- color : ${isColorName(color)};
313
- &:hover {
314
- background-color: ${lighten(isColorName(color), 0.9)};
315
- }
316
- &:focus {
317
- background-color: ${lighten(isColorName(color), 0.8)};
318
- }
319
- &:active {
320
- background-color: ${lighten(isColorName(color), 0.7)};
321
- }
322
- }`}
237
+ ${Object.keys(alphaArr).map(key => `&:${key} {
238
+ background-color: ${hexToRGBA(color, alphaArr[key])};
239
+ }`)}
240
+ }
323
241
  }
324
242
  &.filled {
325
- border : none;
326
- color : ${theme.colors.white};
243
+ border: none;
244
+ color: ${white};
327
245
  font-weight: bold;
328
- &:hover, &:focus {
246
+ &.loading,
247
+ &:hover,
248
+ &:focus {
329
249
  filter: brightness(0.85);
330
250
  }
331
251
  &:active {
332
252
  filter: brightness(0.7);
333
253
  }
334
254
  &.default {
335
- background-color: ${theme.colors.secondary};
336
- }
337
- &.primary {
338
- background-color: ${theme.colors.primary};
339
- }
340
- &.success {
341
- background-color: ${theme.colors.success};
342
- }
343
- &.warning {
344
- background-color: ${theme.colors.warning};
345
- }
346
- &.danger {
347
- background-color: ${theme.colors.danger};
255
+ background-color: ${rest};
256
+ &.loading {
257
+ background-color: ${active};
258
+ }
259
+ &:hover,
260
+ &:focus,
261
+ &:active {
262
+ background-color: ${active};
263
+ }
348
264
  }
349
- &.info {
350
- background-color: ${theme.colors.info};
265
+ &.${color} {
266
+ background-color: ${colorMap.get(color)};
351
267
  }
352
- ${isColor(color) && `&.custom-color {
268
+ &.custom-color {
353
269
  background-color: ${color};
354
- }`}
355
- ${isColorName(color) && `&.custom-color {
356
- background-color: ${isColorName(color)};
357
- }`}
358
- }
359
- &.tiny {
360
- padding: 4px 8px;
361
- &.outlined {
362
- padding: 3px 7px;
363
- }
364
- .css-${ButtonText.name} {
365
- font-size: 10px;
366
- line-height: 16px;
367
- }
368
- .css-${ButtonIcon.name} {
369
- max-height: 16px;
370
- min-width: 16px;
371
- max-width: 16px;
372
- margin-right: 4px;
373
- &.end-icon {
374
- margin-right: unset;
375
- margin-left: 4px;
376
- }
377
270
  }
378
271
  }
379
- &.small {
380
- padding: 6px 12px;
381
- &.outlined {
382
- padding: 5px 11px;
383
- }
384
- .css-${ButtonText.name} {
385
- font-size: 12px;
386
- line-height: 20px;
387
- }
388
- .css-${ButtonIcon.name} {
389
- max-height: 20px;
390
- min-width: 20px;
391
- max-width: 20px;
392
- margin-right: 6px;
393
- &.end-icon {
394
- margin-right: unset;
395
- margin-left: 6px;
272
+ &.text {
273
+ ${backgroundTransparent}
274
+ ${noBorder}
275
+ &.default {
276
+ color: ${rest};
277
+ &:hover,
278
+ &:focus,
279
+ &:active {
280
+ color: ${active};
396
281
  }
397
- }
398
- }
399
- &.medium {
400
- padding: 8px 16px;
401
- &.outlined {
402
- padding: 7px 15px;
403
- }
404
- .css-${ButtonText.name} {
405
- font-size: 14px;
406
- line-height: 24px;
407
- }
408
- .css-${ButtonIcon.name} {
409
- max-height: 24px;
410
- min-width: 24px;
411
- max-width: 24px;
412
- margin-right: 8px;
413
- &.end-icon {
414
- margin-right: unset;
415
- margin-left: 8px;
282
+ &.loading {
283
+ color: ${active};
284
+ background-color: ${hexToRGBA(active, alphaLoading)};
416
285
  }
286
+ ${Object.keys(alphaArr).map(key => `&:${key} {
287
+ background-color: ${hexToRGBA(active, alphaArr[key])};
288
+ }`)}
417
289
  }
418
- }
419
- &.large {
420
- padding: 8px 20px;
421
- &.outlined {
422
- padding: 7px 19px;
423
- }
424
- .css-${ButtonText.name} {
425
- font-size: 16px;
426
- line-height: 32px;
427
- }
428
- .css-${ButtonIcon.name} {
429
- max-height: 32px;
430
- min-width: 32px;
431
- max-width: 32px;
432
- margin-right: 8px;
433
- &.end-icon {
434
- margin-right: unset;
435
- margin-left: 8px;
290
+ &.${color} {
291
+ color: ${colorMap.get(color)};
292
+ &.loading {
293
+ background-color: ${hexToRGBA(colorMap.get(color), alphaLoading)};
436
294
  }
295
+ ${Object.keys(alphaArr).map(key => `&:${key} {
296
+ background-color: ${hexToRGBA(colorMap.get(color), alphaArr[key])};
297
+ }`)}
437
298
  }
438
- }
439
- &.giant {
440
- padding: 8px 24px;
441
- &.outlined {
442
- padding: 7px 23px;
443
- }
444
- .css-${ButtonText.name} {
445
- font-size: 20px;
446
- line-height: 40px;
447
- }
448
- .css-${ButtonIcon.name} {
449
- max-height: 40px;
450
- min-width: 40px;
451
- max-width: 40px;
452
- margin-right: 8px;
453
- &.end-icon {
454
- margin-right: unset;
455
- margin-left: 8px;
299
+ &.custom-color {
300
+ color: ${color};
301
+ &.loading {
302
+ background-color: ${hexToRGBA(color, alphaLoading)};
456
303
  }
304
+ ${Object.keys(alphaArr).map(key => `&:${key} {
305
+ background-color: ${hexToRGBA(color, alphaArr[key])};
306
+ }`)}
457
307
  }
458
308
  }
459
- &:disabled {
460
- cursor: initial;
461
- color: ${theme.colors.disabled} !important;
462
- &.outlined, &.filled {
463
- background-color: ${theme.colors.bgDisabled} !important;
464
- filter: brightness(1);
309
+ &.link {
310
+ ${backgroundTransparent}
311
+ ${noBorder}
312
+ ${noPadding}
313
+ color: ${info};
314
+ &.loading,
315
+ &:hover,
316
+ &:focus {
317
+ filter: brightness(0.85);
465
318
  }
466
- &.text {
467
- background-color: transparent !important;
319
+ &:active {
320
+ filter: brightness(0.7);
468
321
  }
469
- &.outlined {
470
- border-color: ${theme.colors.disabled} !important;
322
+ &.${color} {
323
+ color: ${colorMap.get(color)};
471
324
  }
472
- pointer-events: none;
473
- &::after {
474
- content: '';
475
- position: absolute;
476
- cursor: no-drop;
477
- inset: 0;
478
- pointer-events: auto;
479
- z-index: 1;
325
+ &.custom-color {
326
+ color: ${color};
480
327
  }
481
328
  }
482
- &:not(:disabled):focus {
483
- box-shadow: ${viewType !== 'text' ? '0 0 0 2px ' + hexToRgb(colors.brand + '20') : 'none'};
484
- }
485
329
  `;
486
- useEffect(() => {
487
- if (refs) refs(ref);
488
- }, []);
489
- useEffect(() => {
490
- if (!children) {
491
- ref.current.querySelector('.button-text').innerHTML = label || text;
492
- return () => {
493
- if (ref.current) {
494
- ref.current.querySelector('.button-text').innerHTML = null;
495
- }
496
- };
497
- }
498
- }, [label, text]);
330
+ useImperativeHandle(reference, () => {
331
+ const currentRef = ref.current || {};
332
+ const _instance = {}; // methods
333
+
334
+ _instance.__proto__ = {}; // hidden methods
335
+
336
+ currentRef.instance = _instance;
337
+ return currentRef;
338
+ });
499
339
  const StartIcon = useMemo(() => {
500
340
  let node = startIcon;
501
341
 
502
342
  if (typeof node === 'string') {
503
- const IconComp = Icons[capitalize(node)];
504
-
505
- if (IconComp) {
506
- node = jsx(IconComp, {
507
- color: 'currentColor',
508
- width: '100%',
509
- height: '100%',
510
- viewBox: true
511
- });
512
- }
343
+ node = jsx(Icon, {
344
+ name: node,
345
+ width: iconSize,
346
+ height: iconSize,
347
+ color: 'currentColor',
348
+ viewBox: true
349
+ });
350
+ return jsx("span", {
351
+ css: ButtonIcon,
352
+ className: 'DGN-UI-Button-Start-Icon'
353
+ }, node);
513
354
  }
514
355
 
515
356
  return jsx("span", {
516
- css: ButtonIcon
357
+ css: ButtonIcon,
358
+ className: 'DGN-UI-Button-Custom-Start-Icon'
517
359
  }, node);
518
- }, [startIcon]);
360
+ }, [startIcon, size]);
519
361
  const EndIcon = useMemo(() => {
520
362
  let node = endIcon;
521
363
 
522
364
  if (typeof node === 'string') {
523
- const IconComp = Icons[capitalize(node)];
524
-
525
- if (IconComp) {
526
- node = jsx(IconComp, {
527
- color: 'currentColor',
528
- width: '100%',
529
- height: '100%',
530
- viewBox: true
531
- });
532
- }
365
+ node = jsx(Icon, {
366
+ name: node,
367
+ width: iconSize,
368
+ height: iconSize,
369
+ color: 'currentColor',
370
+ viewBox: true
371
+ });
372
+ return jsx("span", {
373
+ css: ButtonIcon,
374
+ className: 'DGN-UI-Button-End-Icon'
375
+ }, node);
533
376
  }
534
377
 
535
378
  return jsx("span", {
536
379
  css: ButtonIcon,
537
- className: 'end-icon'
380
+ className: 'DGN-UI-Button-Custom-End-Icon'
538
381
  }, node);
539
- }, [endIcon]);
382
+ }, [endIcon, size]);
540
383
 
541
384
  const iconLoading = () => {
542
385
  return jsx(CircularProgress, {
543
- size: "extraSmall",
544
- background: "transparent",
386
+ size: 'extraSmall',
387
+ background: 'transparent',
545
388
  color: 'currentColor',
546
389
  strokeWidth: 3,
547
- width: 24
390
+ width: parseInt(iconSize)
548
391
  });
549
392
  };
550
393
 
@@ -553,12 +396,14 @@ const Button = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
553
396
  onClick && onClick(event);
554
397
  };
555
398
 
556
- const ButtonView = useMemo(() => {
399
+ return useMemo(() => {
557
400
  // 1. Có StartIcon => thay StartIcon
558
401
  // 2. Có EndIcon => thay EndIcon
559
402
  // 3. Có StartIcon + EndIcon => thay StartIcon
560
403
  // 4. Không có Icon => hiện thêm icon loading ở đầu
561
- let start = startIcon ? StartIcon : null;
404
+ let start = startIcon ? StartIcon : jsx("span", {
405
+ className: 'no-icon'
406
+ });
562
407
  let end = endIcon ? EndIcon : null;
563
408
 
564
409
  if (loading) {
@@ -573,35 +418,26 @@ const Button = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
573
418
  if (!startIcon && !endIcon) start = iconLoading();
574
419
  }
575
420
 
576
- return jsx("button", _extends({
421
+ return jsx("button", {
577
422
  css: ButtonRoot,
578
423
  onClick: _onClick,
579
424
  ref: ref,
580
- disabled: disabled,
581
425
  type: type,
582
- className: ['DGN-UI-Button', viewType, getClassNameFromColor(color), size, className].join(' ').trim().replace(/\s+/g, ' ')
583
- }, props), start && start, jsx("span", {
584
- css: ButtonText
585
- }, jsx(Typography, {
426
+ className: ['DGN-UI-Button', viewType, getClassNameFromColor(color), size, loading && 'loading', disabled && 'disabled', className].join(' ').trim().replace(/\s+/g, ' '),
427
+ ...props
428
+ }, start, jsx(Typography, {
429
+ css: ButtonText,
586
430
  type: 'h4',
587
- className: 'button-text',
588
- color: 'inherit',
589
- style: {
590
- fontSize: 'inherit',
591
- lineHeight: 'inherit',
592
- textTransform: 'inherit'
593
- }
594
- }, children || label || text)), end && end, jsx(Ripple, {
595
- color: getRippleColor(color, viewType, colors)
431
+ className: 'button-text'
432
+ }, children || label), end && end, !disabled && !loading && viewType !== 'link' && jsx(Ripple, {
433
+ color: getRippleColor(color, viewType, allColors)
596
434
  }));
597
- }, [size, viewType, color, disabled, onClick, loading, startIcon, endIcon]);
598
- return ButtonView;
435
+ }, [size, viewType, color, disabled, onClick, loading, startIcon, endIcon, label]);
599
436
  }));
600
437
  Button.defaultProps = {
601
438
  viewType: 'text',
602
439
  color: 'default',
603
440
  size: 'medium',
604
- text: '',
605
441
  label: '',
606
442
  className: '',
607
443
  disabled: false,
@@ -612,7 +448,7 @@ Button.propTypes = {
612
448
  type: PropTypes.oneOf(['button', 'submit', 'reset']),
613
449
 
614
450
  /** used to fill background for button */
615
- viewType: PropTypes.oneOf(['text', 'outlined', 'filled']),
451
+ viewType: PropTypes.oneOf(['text', 'outlined', 'filled', 'link']),
616
452
 
617
453
  /** color for button */
618
454
  color: PropTypes.string,
@@ -620,9 +456,6 @@ Button.propTypes = {
620
456
  /** size button */
621
457
  size: PropTypes.oneOf(['tiny', 'small', 'medium', 'large', 'giant']),
622
458
 
623
- /** text to display in button */
624
- text: PropTypes.string,
625
-
626
459
  /** the content to display in button (like text prop) */
627
460
  label: PropTypes.string,
628
461
 
@@ -648,6 +481,18 @@ Button.propTypes = {
648
481
  props: PropTypes.any,
649
482
 
650
483
  /** status loading of button */
651
- loading: PropTypes.bool
484
+ loading: PropTypes.bool,
485
+
486
+ /**
487
+ * ref methods
488
+ *
489
+ * * onClick(): Call onClick function
490
+ * * option(): Gets all UI component properties
491
+ * * option(optionName): Gets the value of a single property.
492
+ * * option(optionName, optionValue): Updates the value of a single property
493
+ * * option(options): Updates the values of several properties
494
+ */
495
+ ref: PropTypes.any
652
496
  };
653
- export default Button;
497
+ export { Button };
498
+ export default OptionWrapper(Button);