diginet-core-ui 1.4.14-beta.2 → 1.4.14-beta.3
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.
- package/components/accordion/details.js +36 -25
- package/components/accordion/group.js +33 -18
- package/components/accordion/index.js +42 -28
- package/components/accordion/summary.js +60 -52
- package/components/alert/index.js +84 -75
- package/components/alert/notify.js +53 -41
- package/components/avatar/index.js +97 -94
- package/components/badge/index.js +80 -78
- package/components/breadcrumb/index.js +62 -44
- package/components/button/icon.js +90 -70
- package/components/button/index.js +110 -88
- package/components/button/more.js +60 -39
- package/components/button/ripple-effect.js +1 -1
- package/components/card/body.js +38 -28
- package/components/card/extra.js +38 -28
- package/components/card/footer.js +38 -28
- package/components/card/header.js +39 -28
- package/components/card/index.js +79 -70
- package/components/chart/bar/Labels.js +14 -8
- package/components/chart/bar-v2/Labels.js +14 -8
- package/components/chart/line/Labels.js +14 -8
- package/components/chart/line/Path.js +3 -3
- package/components/chart/line/Point.js +12 -11
- package/components/chart/line-v2/Labels.js +14 -8
- package/components/check-text/index.js +21 -16
- package/components/check-text/interview-confirmation.js +21 -15
- package/components/check-text/interview-status.js +21 -15
- package/components/chip/attach.js +11 -7
- package/components/chip/index.js +83 -82
- package/components/collapse/index.js +1 -1
- package/components/dialogs/colors.js +13 -11
- package/components/divider/index.js +40 -22
- package/components/form-control/attachment/index.js +94 -57
- package/components/form-control/calendar/function.js +173 -169
- package/components/form-control/calendar/index.js +48 -36
- package/components/form-control/calendar/range.js +38 -22
- package/components/form-control/checkbox/index.js +87 -63
- package/components/form-control/control/index.js +9 -10
- package/components/form-control/date-picker/index.js +81 -64
- package/components/form-control/date-range-picker/index.js +98 -81
- package/components/form-control/dropdown/index.js +240 -215
- package/components/form-control/dropdown-box/index.js +56 -43
- package/components/form-control/form-group/index.js +7 -6
- package/components/form-control/helper-text/index.js +45 -41
- package/components/form-control/input-base/index.js +165 -133
- package/components/form-control/label/index.js +48 -41
- package/components/form-control/money-input/index.js +87 -79
- package/components/form-control/number-input/index.js +579 -521
- package/components/form-control/number-input/index2.js +107 -87
- package/components/form-control/password-input/index.js +71 -63
- package/components/form-control/radio/index.js +90 -74
- package/components/form-control/text-input/index.js +83 -74
- package/components/form-control/time-picker/index.js +79 -56
- package/components/form-control/time-picker/v2/index.js +90 -84
- package/components/form-control/toggle/index.js +144 -133
- package/components/form-view/helper-text.js +2 -2
- package/components/form-view/index.js +34 -31
- package/components/form-view/input.js +70 -69
- package/components/form-view/label.js +14 -9
- package/components/grid/Col.js +48 -39
- package/components/grid/Container.js +31 -38
- package/components/grid/Row.js +28 -32
- package/components/grid/index.js +66 -54
- package/components/image/index.js +37 -27
- package/components/list/list-item-action.js +36 -26
- package/components/list/list-item-icon.js +34 -29
- package/components/list/list-item-text.js +27 -22
- package/components/list/list-item.js +42 -36
- package/components/list/list.js +46 -38
- package/components/list/sub-header.js +33 -26
- package/components/modal/body.js +24 -14
- package/components/modal/footer.js +23 -13
- package/components/modal/header.js +39 -28
- package/components/modal/index.js +3 -3
- package/components/modal/modal.js +60 -49
- package/components/others/extra/index.js +31 -30
- package/components/others/import/index.js +2 -2
- package/components/others/scrollbar/index.js +32 -26
- package/components/paging/page-info.js +67 -68
- package/components/paging/page-selector.js +49 -49
- package/components/paper/index.js +32 -28
- package/components/popover/body.js +14 -8
- package/components/popover/footer.js +13 -8
- package/components/popover/header.js +17 -15
- package/components/popover/index.js +103 -92
- package/components/popup/danger_popup.js +17 -16
- package/components/popup/index.js +16 -17
- package/components/popup/v2/index.js +41 -54
- package/components/progress/circular.js +65 -80
- package/components/progress/linear.js +73 -58
- package/components/rating/index.js +49 -63
- package/components/slider/slider-container.js +49 -57
- package/components/slider/slider-item.js +30 -29
- package/components/status/index.js +23 -34
- package/components/tab/tab-header.js +20 -11
- package/components/tab/tab-panel.js +12 -7
- package/components/tab/tab.js +35 -22
- package/components/tooltip/index.js +24 -35
- package/components/transfer/index.js +105 -106
- package/components/tree-view/index.js +133 -115
- package/components/typography/index.js +72 -55
- package/global/index.js +2 -17
- package/icons/basic.js +975 -972
- package/icons/effect.js +21 -20
- package/package.json +3 -1
- package/styles/color-helper.js +105 -105
- package/styles/colors.js +168 -30
- package/styles/general.js +84 -16
- package/styles/sx/index.js +7 -4
- package/styles/utils.js +20 -19
- package/theme/createSpacing.js +10 -0
- package/theme/createTheme.js +26 -0
- package/theme/createZIndex.js +9 -0
- package/theme/index.js +13 -2
- package/theme/make-styles.js +2 -1
- package/theme/settings.js +699 -8
- package/theme/theme-provider.js +32 -15
- package/theme/theme.js +57 -56
- package/theme/use-classes.js +15 -0
- package/theme/utils/getThemeProps.js +12 -0
- package/theme/utils/resolveProps.js +17 -0
- package/theme/utils/useThemeProps.js +14 -0
- package/utils/handleBreakpoints.js +2 -2
- package/utils/hexToRGBA/index.js +7 -7
- package/utils/object/deepmerge.js +104 -0
- package/utils/object/object.js +7 -12
- package/utils/render-portal.js +4 -3
- package/theme/set-theme.js +0 -38
|
@@ -5,12 +5,13 @@ import { CircularProgress, Icon, Typography } from "./..";
|
|
|
5
5
|
import OptionWrapper from "../others/option-wrapper";
|
|
6
6
|
import PropTypes from 'prop-types';
|
|
7
7
|
import { forwardRef, memo, useEffect, useImperativeHandle, useMemo, useRef, useState } from 'react';
|
|
8
|
-
import { detectColor, fade, hexToRGBA, hslToRgb, isColor, isColorName,
|
|
8
|
+
import { detectColor, fade, hexToRGBA, hslToRgb, isColor, isColorName, rgbToHex, rgbaToHexA } from "../../styles/color-helper";
|
|
9
9
|
import * as allColors from "../../styles/colors";
|
|
10
|
-
import { alphaPseudo, bgColor, border, borderColor, borderNone, borderRadius4px, boxBorder, cursorNotAllowed, cursorPointer, displayFlex, displayInlineFlex, flexRow, itemsCenter, justifyCenter,
|
|
11
|
-
import {
|
|
12
|
-
import { classNames } from "../../utils";
|
|
10
|
+
import { alphaPseudo, bgColor, border, borderColor, borderNone, borderRadius4px, boxBorder, cursorNotAllowed, cursorPointer, displayFlex, displayInlineFlex, flexRow, itemsCenter, justifyCenter, outlineNone, overflowHidden, parseHeight, parseMinWidth, parseMinWidthHeight, parseWidthHeight, pointerEventsNone, positionRelative, textColor, userSelectNone, whiteSpaceNoWrap } from "../../styles/general";
|
|
11
|
+
import { useTheme } from "../../theme";
|
|
12
|
+
import { classNames, getProp } from "../../utils";
|
|
13
13
|
import Ripple from "./ripple-effect";
|
|
14
|
+
import useThemeProps from "../../theme/utils/useThemeProps";
|
|
14
15
|
const {
|
|
15
16
|
spacing
|
|
16
17
|
} = useTheme();
|
|
@@ -55,30 +56,41 @@ const typographySizeMap = new Map([['tiny', 'h5'], ['small', 'h5'], ['medium', '
|
|
|
55
56
|
const minHeightSizeMap = new Map([['tiny', '24px'], ['small', '32px'], ['medium', '40px'], ['large', '48px'], ['giant', '56px']]);
|
|
56
57
|
const minHeightSizeLinkMap = new Map([['tiny', '16px'], ['small', '20px'], ['medium', '24px'], ['large', '32px'], ['giant', '40px']]);
|
|
57
58
|
const alphaLoading = 0.2;
|
|
58
|
-
const Button = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
59
|
-
action = {},
|
|
60
|
-
children,
|
|
61
|
-
className,
|
|
62
|
-
color: colorProp,
|
|
63
|
-
disabled,
|
|
64
|
-
endIcon,
|
|
65
|
-
href,
|
|
66
|
-
id,
|
|
67
|
-
label,
|
|
68
|
-
labelProps,
|
|
69
|
-
loading,
|
|
70
|
-
onClick,
|
|
71
|
-
size,
|
|
72
|
-
startIcon,
|
|
73
|
-
stopPropagation,
|
|
74
|
-
text,
|
|
75
|
-
type,
|
|
76
|
-
urlParams,
|
|
77
|
-
viewType,
|
|
78
|
-
...props
|
|
79
|
-
}, reference) => {
|
|
59
|
+
const Button = /*#__PURE__*/memo( /*#__PURE__*/forwardRef((inProps, reference) => {
|
|
80
60
|
if (!reference) reference = useRef(null);
|
|
81
|
-
|
|
61
|
+
const theme = useTheme();
|
|
62
|
+
const {
|
|
63
|
+
colors
|
|
64
|
+
} = theme;
|
|
65
|
+
|
|
66
|
+
// props priority: `inProps` > `themeDefaultProps`
|
|
67
|
+
const props = useThemeProps({
|
|
68
|
+
props: inProps,
|
|
69
|
+
name: 'Button'
|
|
70
|
+
});
|
|
71
|
+
const {
|
|
72
|
+
action = {},
|
|
73
|
+
children,
|
|
74
|
+
className,
|
|
75
|
+
color: colorProp,
|
|
76
|
+
disabled,
|
|
77
|
+
endIcon,
|
|
78
|
+
href,
|
|
79
|
+
id,
|
|
80
|
+
label: labelProp,
|
|
81
|
+
labelProps,
|
|
82
|
+
loading,
|
|
83
|
+
onClick,
|
|
84
|
+
size,
|
|
85
|
+
startIcon,
|
|
86
|
+
stopPropagation,
|
|
87
|
+
text,
|
|
88
|
+
type,
|
|
89
|
+
urlParams,
|
|
90
|
+
viewType,
|
|
91
|
+
...other
|
|
92
|
+
} = props;
|
|
93
|
+
const label = labelProp || text || '';
|
|
82
94
|
const ref = useRef(null);
|
|
83
95
|
const rippleRef = useRef(null);
|
|
84
96
|
const [urlState, setUrlState] = useState(href);
|
|
@@ -89,13 +101,13 @@ const Button = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
89
101
|
const typographySize = typographySizeMap.get(size);
|
|
90
102
|
const iconMarginSize = iconMarginSizeMap.get(size);
|
|
91
103
|
const minHeightSize = isViewTypeLink ? minHeightSizeLinkMap.get(size) : minHeightSizeMap.get(size);
|
|
92
|
-
const color = colors
|
|
104
|
+
const color = getProp(colors, colorProp, colorProp);
|
|
93
105
|
const TagName = href ? 'a' : 'button';
|
|
94
|
-
const _ButtonRootCSS = ButtonRootCSS(color, isColorDefault, viewType, loading);
|
|
95
|
-
const _ButtonIconCSS = ButtonIconCSS(endIcon, label, startIcon, iconMarginSize, iconSize);
|
|
96
|
-
const _NonStartIconCSS = NonStartIconCSS(iconSize);
|
|
106
|
+
const _ButtonRootCSS = ButtonRootCSS(color, isColorDefault, viewType, loading, theme);
|
|
107
|
+
const _ButtonIconCSS = ButtonIconCSS(endIcon, label, startIcon, iconMarginSize, iconSize, theme);
|
|
108
|
+
const _NonStartIconCSS = NonStartIconCSS(iconSize, theme);
|
|
97
109
|
const _ButtonLabelCSS = ButtonLabelCSS(loading, iconMarginSize);
|
|
98
|
-
const _ButtonSizeCSS = ButtonSizeCSS(paddingSize, minHeightSize);
|
|
110
|
+
const _ButtonSizeCSS = ButtonSizeCSS(paddingSize, minHeightSize, theme);
|
|
99
111
|
const _onClick = e => {
|
|
100
112
|
if (href) e.preventDefault(); //Prevent open link when click
|
|
101
113
|
onClick && stopPropagation && e.stopPropagation();
|
|
@@ -195,7 +207,7 @@ const Button = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
195
207
|
type: type,
|
|
196
208
|
className: classNames('DGN-UI-Button', disabled && 'disabled', viewType, size, className),
|
|
197
209
|
href: urlState || null,
|
|
198
|
-
...
|
|
210
|
+
...other
|
|
199
211
|
}, start, jsx(Typography, {
|
|
200
212
|
css: _ButtonLabelCSS,
|
|
201
213
|
type: typographySize,
|
|
@@ -206,25 +218,29 @@ const Button = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
206
218
|
ref: rippleRef,
|
|
207
219
|
color: getRippleColor(colorProp, viewType, allColors)
|
|
208
220
|
}) : null);
|
|
209
|
-
}, [children, className, colorProp, disabled, endIcon, href, id,
|
|
221
|
+
}, [children, className, colorProp, disabled, endIcon, href, id, labelProp, labelProps, loading, onClick, size, startIcon, stopPropagation, type, urlParams, viewType, urlState, theme]);
|
|
210
222
|
}));
|
|
211
|
-
const NonStartIconCSS = iconSize
|
|
212
|
-
|
|
223
|
+
const NonStartIconCSS = (iconSize, {
|
|
224
|
+
spacing
|
|
225
|
+
}) => css`
|
|
226
|
+
margin: ${spacing([0])};
|
|
213
227
|
${parseHeight(iconSize)};
|
|
214
228
|
${parseMinWidth(0)};
|
|
215
229
|
`;
|
|
216
|
-
const ButtonIconCSS = (endIcon, label, startIcon, iconMarginSize, iconSize
|
|
230
|
+
const ButtonIconCSS = (endIcon, label, startIcon, iconMarginSize, iconSize, {
|
|
231
|
+
spacing
|
|
232
|
+
}) => css`
|
|
217
233
|
${displayFlex};
|
|
218
234
|
${flexRow};
|
|
219
235
|
${itemsCenter};
|
|
220
236
|
${justifyCenter};
|
|
221
237
|
${positionRelative};
|
|
222
238
|
${boxBorder};
|
|
223
|
-
${
|
|
239
|
+
margin-right: ${spacing(endIcon || label ? iconMarginSize : 0)};
|
|
224
240
|
&.DGN-UI-Button-End-Icon,
|
|
225
241
|
&.DGN-UI-Button-Custom-End-Icon {
|
|
226
|
-
|
|
227
|
-
${
|
|
242
|
+
margin-right: unset;
|
|
243
|
+
margin-left: ${spacing(startIcon || label ? iconMarginSize : 0)};
|
|
228
244
|
}
|
|
229
245
|
&.DGN-UI-Button-Start-Icon,
|
|
230
246
|
&.DGN-UI-Button-End-Icon {
|
|
@@ -234,13 +250,17 @@ const ButtonIconCSS = (endIcon, label, startIcon, iconMarginSize, iconSize) => c
|
|
|
234
250
|
const ButtonLabelCSS = (loading, iconMarginSize) => css`
|
|
235
251
|
${whiteSpaceNoWrap};
|
|
236
252
|
${textColor('inherit')};
|
|
237
|
-
${
|
|
253
|
+
margin-left: ${spacing(loading ? iconMarginSize : 0)};
|
|
238
254
|
`;
|
|
239
|
-
const ButtonSizeCSS = (paddingSize, minHeightSize
|
|
240
|
-
|
|
255
|
+
const ButtonSizeCSS = (paddingSize, minHeightSize, {
|
|
256
|
+
spacing
|
|
257
|
+
}) => css`
|
|
258
|
+
padding: ${spacing(paddingSize)};
|
|
241
259
|
${parseMinWidthHeight('max-content', minHeightSize)};
|
|
242
260
|
`;
|
|
243
|
-
const ButtonRootCSS = (color, isColorDefault, viewType, loading
|
|
261
|
+
const ButtonRootCSS = (color, isColorDefault, viewType, loading, {
|
|
262
|
+
colors
|
|
263
|
+
}) => css`
|
|
244
264
|
${displayInlineFlex};
|
|
245
265
|
${itemsCenter};
|
|
246
266
|
${justifyCenter};
|
|
@@ -266,29 +286,29 @@ const ButtonRootCSS = (color, isColorDefault, viewType, loading) => css`
|
|
|
266
286
|
}
|
|
267
287
|
`)}
|
|
268
288
|
${isColorDefault && css`
|
|
269
|
-
${border(1, 'system
|
|
270
|
-
${textColor('system
|
|
289
|
+
${border(1, getProp(colors, 'system.rest'))};
|
|
290
|
+
${textColor(getProp(colors, 'system.rest'))};
|
|
271
291
|
${loading && css`
|
|
272
|
-
${textColor('system
|
|
273
|
-
${borderColor('system
|
|
274
|
-
${bgColor(hexToRGBA('system
|
|
292
|
+
${textColor(getProp(colors, 'system.active'))};
|
|
293
|
+
${borderColor(getProp(colors, 'system.active'))};
|
|
294
|
+
${bgColor(hexToRGBA(getProp(colors, 'system.active'), alphaLoading))};
|
|
275
295
|
`}
|
|
276
296
|
${Object.keys(alphaPseudo).map(key => css`
|
|
277
297
|
&: ${key} {
|
|
278
|
-
${textColor('system
|
|
279
|
-
${borderColor('system
|
|
280
|
-
${bgColor(hexToRGBA('system
|
|
298
|
+
${textColor(getProp(colors, 'system.active'))};
|
|
299
|
+
${borderColor(getProp(colors, 'system.active'))};
|
|
300
|
+
${bgColor(hexToRGBA(getProp(colors, 'system.active'), alphaPseudo[key]))};
|
|
281
301
|
}
|
|
282
302
|
`)} // &:hover | &:focus | &:active
|
|
283
303
|
`}
|
|
284
304
|
&.disabled {
|
|
285
|
-
${borderColor('system
|
|
305
|
+
${borderColor(getProp(colors, 'system.disabled'))};
|
|
286
306
|
${bgColor('transparent')};
|
|
287
307
|
}
|
|
288
308
|
`}
|
|
289
309
|
${viewType === 'filled' && css`
|
|
290
310
|
${borderNone};
|
|
291
|
-
${textColor('system
|
|
311
|
+
${textColor(getProp(colors, 'system.standard'))};
|
|
292
312
|
${bgColor(color)};
|
|
293
313
|
font-weight: bold;
|
|
294
314
|
${loading && css`
|
|
@@ -302,16 +322,16 @@ const ButtonRootCSS = (color, isColorDefault, viewType, loading) => css`
|
|
|
302
322
|
filter: brightness(0.7);
|
|
303
323
|
}
|
|
304
324
|
${isColorDefault && css`
|
|
305
|
-
${bgColor('system
|
|
306
|
-
${loading && bgColor('system
|
|
325
|
+
${bgColor(getProp(colors, 'system.rest'))};
|
|
326
|
+
${loading && bgColor(getProp(colors, 'system.active'))};
|
|
307
327
|
&:hover,
|
|
308
328
|
&:focus,
|
|
309
329
|
&:active {
|
|
310
|
-
${bgColor('system
|
|
330
|
+
${bgColor(getProp(colors, 'system.active'))};
|
|
311
331
|
}
|
|
312
332
|
`}
|
|
313
333
|
&.disabled {
|
|
314
|
-
${bgColor('fill
|
|
334
|
+
${bgColor(getProp(colors, 'fill.disabled'))};
|
|
315
335
|
}
|
|
316
336
|
`}
|
|
317
337
|
${viewType === 'text' && css`
|
|
@@ -325,15 +345,15 @@ const ButtonRootCSS = (color, isColorDefault, viewType, loading) => css`
|
|
|
325
345
|
}
|
|
326
346
|
`)}
|
|
327
347
|
${isColorDefault && css`
|
|
328
|
-
${textColor('system
|
|
348
|
+
${textColor(getProp(colors, 'system.rest'))};
|
|
329
349
|
${loading && css`
|
|
330
|
-
${textColor('system
|
|
331
|
-
${bgColor(hexToRGBA('system
|
|
350
|
+
${textColor(getProp(colors, 'system.active'))};
|
|
351
|
+
${bgColor(hexToRGBA(getProp(colors, 'system.active'), alphaLoading))};
|
|
332
352
|
`}
|
|
333
353
|
${Object.keys(alphaPseudo).map(key => css`
|
|
334
354
|
&: ${key} {
|
|
335
|
-
${textColor('system
|
|
336
|
-
${bgColor(hexToRGBA('system
|
|
355
|
+
${textColor(getProp(colors, 'system.active'))};
|
|
356
|
+
${bgColor(hexToRGBA(getProp(colors, 'system.active'), alphaPseudo[key]))};
|
|
337
357
|
}
|
|
338
358
|
`)}
|
|
339
359
|
`}
|
|
@@ -343,7 +363,7 @@ const ButtonRootCSS = (color, isColorDefault, viewType, loading) => css`
|
|
|
343
363
|
`}
|
|
344
364
|
${viewType === 'link' && css`
|
|
345
365
|
${borderNone};
|
|
346
|
-
${textColor(isColorDefault ? 'semantic
|
|
366
|
+
${textColor(isColorDefault ? getProp(colors, 'semantic.info') : color)};
|
|
347
367
|
${bgColor('transparent')};
|
|
348
368
|
${loading && css`
|
|
349
369
|
filter: brightness(0.85);
|
|
@@ -358,20 +378,22 @@ const ButtonRootCSS = (color, isColorDefault, viewType, loading) => css`
|
|
|
358
378
|
`}
|
|
359
379
|
&.disabled {
|
|
360
380
|
${cursorNotAllowed};
|
|
361
|
-
${textColor('system
|
|
381
|
+
${textColor(getProp(colors, 'system.disabled'))};
|
|
362
382
|
filter: brightness(1);
|
|
363
383
|
}
|
|
364
384
|
`;
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
385
|
+
|
|
386
|
+
// Button.defaultProps = {
|
|
387
|
+
// className: '',
|
|
388
|
+
// color: 'default',
|
|
389
|
+
// disabled: false,
|
|
390
|
+
// label: '',
|
|
391
|
+
// loading: false,
|
|
392
|
+
// size: 'medium',
|
|
393
|
+
// stopPropagation: true,
|
|
394
|
+
// viewType: 'text',
|
|
395
|
+
// };
|
|
396
|
+
|
|
375
397
|
Button.propTypes = {
|
|
376
398
|
/** The content of the component. */
|
|
377
399
|
children: PropTypes.node,
|
|
@@ -401,19 +423,19 @@ Button.propTypes = {
|
|
|
401
423
|
urlParams: PropTypes.object,
|
|
402
424
|
/** The variant to use. */
|
|
403
425
|
viewType: PropTypes.oneOf(['text', 'outlined', 'filled', 'link'])
|
|
404
|
-
/**
|
|
405
|
-
* ref methods (ref.current.instance.*method*)
|
|
406
|
-
*
|
|
407
|
-
* * option(): Gets all UI component properties
|
|
408
|
-
* * Returns value - object
|
|
409
|
-
* * option(optionName): Gets the value of a single property
|
|
410
|
-
* * @param {optionName} - string
|
|
411
|
-
* * Returns value - any
|
|
412
|
-
* * option(optionName, optionValue): Updates the value of a single property
|
|
413
|
-
* * @param {optionName} - string
|
|
414
|
-
* * @param {optionValue} - any
|
|
415
|
-
* * option(options): Updates the values of several properties
|
|
416
|
-
* * @param {options} - object
|
|
426
|
+
/**
|
|
427
|
+
* ref methods (ref.current.instance.*method*)
|
|
428
|
+
*
|
|
429
|
+
* * option(): Gets all UI component properties
|
|
430
|
+
* * Returns value - object
|
|
431
|
+
* * option(optionName): Gets the value of a single property
|
|
432
|
+
* * @param {optionName} - string
|
|
433
|
+
* * Returns value - any
|
|
434
|
+
* * option(optionName, optionValue): Updates the value of a single property
|
|
435
|
+
* * @param {optionName} - string
|
|
436
|
+
* * @param {optionValue} - any
|
|
437
|
+
* * option(options): Updates the values of several properties
|
|
438
|
+
* * @param {options} - object
|
|
417
439
|
*/
|
|
418
440
|
};
|
|
419
441
|
|
|
@@ -5,27 +5,39 @@ import { ButtonIcon, Icon, Popover, Tooltip, Typography } from "./..";
|
|
|
5
5
|
import OptionWrapper from "../others/option-wrapper";
|
|
6
6
|
import PropTypes from 'prop-types';
|
|
7
7
|
import React, { forwardRef, isValidElement, memo, useImperativeHandle, useMemo, useRef, useState } from 'react';
|
|
8
|
-
import { bgColor, borderNone, cursorPointer, displayFlex, flexCol, flexRow,
|
|
9
|
-
import {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
buttonProps,
|
|
14
|
-
className,
|
|
15
|
-
disabled,
|
|
16
|
-
id,
|
|
17
|
-
labelProp,
|
|
18
|
-
options,
|
|
19
|
-
optionType,
|
|
20
|
-
popoverProp,
|
|
21
|
-
style
|
|
22
|
-
}, reference) => {
|
|
8
|
+
import { bgColor, borderNone, cursorPointer, displayFlex, flexCol, flexRow, itemsCenter, outlineNone, parseHeight } from "../../styles/general";
|
|
9
|
+
import { useTheme } from "../../theme";
|
|
10
|
+
import useThemeProps from "../../theme/utils/useThemeProps";
|
|
11
|
+
import { classNames, getProp } from "../../utils";
|
|
12
|
+
const ButtonMore = /*#__PURE__*/memo( /*#__PURE__*/forwardRef((inProps, reference) => {
|
|
23
13
|
if (!reference) reference = useRef(null);
|
|
14
|
+
const theme = useTheme();
|
|
15
|
+
|
|
16
|
+
// props priority: `inProps` > `themeDefaultProps`
|
|
17
|
+
const props = useThemeProps({
|
|
18
|
+
props: inProps,
|
|
19
|
+
name: 'ButtonMore'
|
|
20
|
+
});
|
|
21
|
+
const {
|
|
22
|
+
action = {},
|
|
23
|
+
anchor: anchorProp,
|
|
24
|
+
buttonProps,
|
|
25
|
+
className,
|
|
26
|
+
disabled,
|
|
27
|
+
id,
|
|
28
|
+
labelProp,
|
|
29
|
+
options,
|
|
30
|
+
optionType,
|
|
31
|
+
popoverProp,
|
|
32
|
+
style
|
|
33
|
+
} = props;
|
|
24
34
|
const isOptionFull = optionType === 'full';
|
|
35
|
+
let anchor = anchorProp;
|
|
25
36
|
const ref = useRef(null);
|
|
26
37
|
const [openState, setOpenState] = useState(false);
|
|
27
38
|
const [iconState, setIconState] = useState(false);
|
|
28
|
-
const
|
|
39
|
+
const _OptionFullCSS = OptionFullCSS(theme);
|
|
40
|
+
const _PopoverCSS = PopoverCSS(isOptionFull, theme);
|
|
29
41
|
const openPopover = () => {
|
|
30
42
|
setOpenState(true);
|
|
31
43
|
};
|
|
@@ -44,7 +56,7 @@ const ButtonMore = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
44
56
|
});
|
|
45
57
|
const renderOptions = () => {
|
|
46
58
|
return options.map((item, idx) => {
|
|
47
|
-
if (item !== null && item !== void 0 && item.hidden) return;else if ( /*#__PURE__*/isValidElement(item)) return item;else {
|
|
59
|
+
if (item !== null && item !== void 0 && item.hidden) return null;else if ( /*#__PURE__*/isValidElement(item)) return item;else {
|
|
48
60
|
const icon = item === null || item === void 0 ? void 0 : item.icon;
|
|
49
61
|
const label = item === null || item === void 0 ? void 0 : item.label;
|
|
50
62
|
const action = () => {
|
|
@@ -54,7 +66,7 @@ const ButtonMore = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
54
66
|
if (icon && !iconState) setIconState(true);
|
|
55
67
|
return isOptionFull ? jsx("button", {
|
|
56
68
|
key: idx,
|
|
57
|
-
css:
|
|
69
|
+
css: _OptionFullCSS,
|
|
58
70
|
className: 'DGN-UI-ButtonMore-Option',
|
|
59
71
|
onClick: action
|
|
60
72
|
}, icon ? jsx(Icon, {
|
|
@@ -62,9 +74,9 @@ const ButtonMore = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
62
74
|
name: icon,
|
|
63
75
|
width: 20,
|
|
64
76
|
height: 20,
|
|
65
|
-
color: 'system/
|
|
77
|
+
color: 'system/on-standard'
|
|
66
78
|
}) : null, jsx(Typography, {
|
|
67
|
-
css: !icon && iconState && ExtraPaddingCSS,
|
|
79
|
+
css: !icon && iconState && ExtraPaddingCSS(theme),
|
|
68
80
|
className: 'DGN-UI-ButtonMore-Label',
|
|
69
81
|
...labelProp
|
|
70
82
|
}, label)) : jsx(Tooltip, {
|
|
@@ -124,14 +136,19 @@ const ButtonMore = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
124
136
|
}),
|
|
125
137
|
...popoverProp
|
|
126
138
|
}, renderOptions());
|
|
127
|
-
}, [buttonProps, className, disabled, id, options, optionType, popoverProp, style, iconState, openState]);
|
|
139
|
+
}, [buttonProps, className, disabled, id, options, optionType, popoverProp, style, iconState, openState, theme]);
|
|
128
140
|
}));
|
|
129
|
-
const PopoverCSS = isOptionFull
|
|
141
|
+
const PopoverCSS = (isOptionFull, {
|
|
142
|
+
spacing
|
|
143
|
+
}) => css`
|
|
130
144
|
${displayFlex};
|
|
131
145
|
${isOptionFull ? flexCol : flexRow};
|
|
132
|
-
${
|
|
146
|
+
padding: ${spacing(isOptionFull ? [1, 0] : [0, 2])};
|
|
133
147
|
`;
|
|
134
|
-
const OptionFullCSS =
|
|
148
|
+
const OptionFullCSS = ({
|
|
149
|
+
colors,
|
|
150
|
+
spacing
|
|
151
|
+
}) => css`
|
|
135
152
|
${displayFlex};
|
|
136
153
|
${flexRow};
|
|
137
154
|
${itemsCenter};
|
|
@@ -139,29 +156,33 @@ const OptionFullCSS = css`
|
|
|
139
156
|
${outlineNone};
|
|
140
157
|
${borderNone}
|
|
141
158
|
${parseHeight(28)};
|
|
142
|
-
${
|
|
143
|
-
${
|
|
144
|
-
${bgColor('system/
|
|
159
|
+
padding: ${spacing([0, 4])};
|
|
160
|
+
gap: ${spacing([0, 1])};
|
|
161
|
+
${bgColor(getProp(colors, 'system/standard'))};
|
|
145
162
|
transition: all 0.5s ease;
|
|
146
163
|
&:hover,
|
|
147
164
|
&:focus {
|
|
148
|
-
${bgColor('fill/hover')};
|
|
165
|
+
${bgColor(getProp(colors, 'fill/hover'))};
|
|
149
166
|
}
|
|
150
167
|
&:active {
|
|
151
|
-
${bgColor('fill/pressed')};
|
|
168
|
+
${bgColor(getProp(colors, 'fill/pressed'))};
|
|
152
169
|
}
|
|
153
170
|
`;
|
|
154
|
-
const ExtraPaddingCSS =
|
|
155
|
-
|
|
171
|
+
const ExtraPaddingCSS = ({
|
|
172
|
+
spacing
|
|
173
|
+
}) => css`
|
|
174
|
+
padding-left: ${spacing([6])};
|
|
156
175
|
`;
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
}
|
|
176
|
+
|
|
177
|
+
// ButtonMore.defaultProps = {
|
|
178
|
+
// buttonProps: {},
|
|
179
|
+
// className: '',
|
|
180
|
+
// disabled: false,
|
|
181
|
+
// options: [],
|
|
182
|
+
// optionType: 'full',
|
|
183
|
+
// style: {},
|
|
184
|
+
// };
|
|
185
|
+
|
|
165
186
|
ButtonMore.propTypes = {
|
|
166
187
|
/** [Props](https://core.diginet.com.vn/ui/?path=/docs/components-buttonicon) applied to the main `ButtonIcon`. */
|
|
167
188
|
buttonProps: PropTypes.object,
|
|
@@ -15,7 +15,7 @@ const useDebouncedRippleCleanUp = (rippleCount, duration, cleanUpFunction) => {
|
|
|
15
15
|
};
|
|
16
16
|
const Ripple = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
17
17
|
duration = 850,
|
|
18
|
-
color = 'system
|
|
18
|
+
color = 'system/standard',
|
|
19
19
|
circular = false,
|
|
20
20
|
...props
|
|
21
21
|
}, ref) => {
|
package/components/card/body.js
CHANGED
|
@@ -1,18 +1,26 @@
|
|
|
1
1
|
/** @jsxRuntime classic */
|
|
2
2
|
/** @jsx jsx */
|
|
3
|
-
import { memo, useRef, useMemo, forwardRef, useImperativeHandle } from 'react';
|
|
4
|
-
import PropTypes from 'prop-types';
|
|
5
3
|
import { jsx } from '@emotion/core';
|
|
6
4
|
import OptionWrapper from "../others/option-wrapper";
|
|
5
|
+
import PropTypes from 'prop-types';
|
|
6
|
+
import { forwardRef, memo, useImperativeHandle, useMemo, useRef } from 'react';
|
|
7
|
+
import useThemeProps from "../../theme/utils/useThemeProps";
|
|
7
8
|
import { classNames, refType as ref } from "../../utils";
|
|
8
|
-
const CardBody = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
}
|
|
9
|
+
const CardBody = /*#__PURE__*/memo( /*#__PURE__*/forwardRef((inProps, reference) => {
|
|
10
|
+
if (!reference) reference = useRef(null);
|
|
11
|
+
|
|
12
|
+
// props priority: `inProps` > `themeDefaultProps`
|
|
13
|
+
const props = useThemeProps({
|
|
14
|
+
props: inProps,
|
|
15
|
+
name: 'CardBody'
|
|
16
|
+
});
|
|
17
|
+
const {
|
|
18
|
+
action = {},
|
|
19
|
+
children,
|
|
20
|
+
className,
|
|
21
|
+
id,
|
|
22
|
+
style
|
|
23
|
+
} = props;
|
|
16
24
|
const ref = useRef(null);
|
|
17
25
|
useImperativeHandle(reference, () => {
|
|
18
26
|
const currentRef = ref.current || {};
|
|
@@ -31,12 +39,14 @@ const CardBody = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
31
39
|
style: style,
|
|
32
40
|
className: classNames(`DGN-UI-Card-Body`, className)
|
|
33
41
|
}, children);
|
|
34
|
-
}, [children, className, id, style
|
|
42
|
+
}, [children, className, id, style]);
|
|
35
43
|
}));
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
}
|
|
44
|
+
|
|
45
|
+
// CardBody.defaultProps = {
|
|
46
|
+
// className: '',
|
|
47
|
+
// style: {},
|
|
48
|
+
// };
|
|
49
|
+
|
|
40
50
|
CardBody.propTypes = {
|
|
41
51
|
/** The content of the component. */
|
|
42
52
|
children: PropTypes.node,
|
|
@@ -46,19 +56,19 @@ CardBody.propTypes = {
|
|
|
46
56
|
style: PropTypes.object,
|
|
47
57
|
/** The title of the component's header. */
|
|
48
58
|
title: PropTypes.string,
|
|
49
|
-
/**
|
|
50
|
-
* ref methods (ref.current.instance.*method*)
|
|
51
|
-
*
|
|
52
|
-
* * option(): Gets all UI component properties
|
|
53
|
-
* * Returns value - object
|
|
54
|
-
* * option(optionName): Gets the value of a single property
|
|
55
|
-
* * @param {optionName} - string
|
|
56
|
-
* * Returns value - any
|
|
57
|
-
* * option(optionName, optionValue): Updates the value of a single property
|
|
58
|
-
* * @param {optionName} - string
|
|
59
|
-
* * @param {optionValue} - any
|
|
60
|
-
* * option(options): Updates the values of several properties
|
|
61
|
-
* * @param {options} - object
|
|
59
|
+
/**
|
|
60
|
+
* ref methods (ref.current.instance.*method*)
|
|
61
|
+
*
|
|
62
|
+
* * option(): Gets all UI component properties
|
|
63
|
+
* * Returns value - object
|
|
64
|
+
* * option(optionName): Gets the value of a single property
|
|
65
|
+
* * @param {optionName} - string
|
|
66
|
+
* * Returns value - any
|
|
67
|
+
* * option(optionName, optionValue): Updates the value of a single property
|
|
68
|
+
* * @param {optionName} - string
|
|
69
|
+
* * @param {optionValue} - any
|
|
70
|
+
* * option(options): Updates the values of several properties
|
|
71
|
+
* * @param {options} - object
|
|
62
72
|
*/
|
|
63
73
|
ref: ref
|
|
64
74
|
};
|
package/components/card/extra.js
CHANGED
|
@@ -1,18 +1,26 @@
|
|
|
1
1
|
/** @jsxRuntime classic */
|
|
2
2
|
/** @jsx jsx */
|
|
3
|
-
import { memo, useRef, useMemo, forwardRef, useImperativeHandle } from 'react';
|
|
4
|
-
import PropTypes from 'prop-types';
|
|
5
3
|
import { jsx } from '@emotion/core';
|
|
6
4
|
import OptionWrapper from "../others/option-wrapper";
|
|
5
|
+
import PropTypes from 'prop-types';
|
|
6
|
+
import { forwardRef, memo, useImperativeHandle, useMemo, useRef } from 'react';
|
|
7
|
+
import useThemeProps from "../../theme/utils/useThemeProps";
|
|
7
8
|
import { classNames, refType as ref } from "../../utils";
|
|
8
|
-
const CardExtra = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
}
|
|
9
|
+
const CardExtra = /*#__PURE__*/memo( /*#__PURE__*/forwardRef((inProps, reference) => {
|
|
10
|
+
if (!reference) reference = useRef(null);
|
|
11
|
+
|
|
12
|
+
// props priority: `inProps` > `themeDefaultProps`
|
|
13
|
+
const props = useThemeProps({
|
|
14
|
+
props: inProps,
|
|
15
|
+
name: 'CardExtra'
|
|
16
|
+
});
|
|
17
|
+
const {
|
|
18
|
+
action = {},
|
|
19
|
+
children,
|
|
20
|
+
className,
|
|
21
|
+
id,
|
|
22
|
+
style
|
|
23
|
+
} = props;
|
|
16
24
|
const ref = useRef(null);
|
|
17
25
|
useImperativeHandle(reference, () => {
|
|
18
26
|
const currentRef = ref.current || {};
|
|
@@ -31,12 +39,14 @@ const CardExtra = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
31
39
|
style: style,
|
|
32
40
|
className: classNames(`DGN-UI-Card-Extra`, className)
|
|
33
41
|
}, children);
|
|
34
|
-
}, [children, className, id, style
|
|
42
|
+
}, [children, className, id, style]);
|
|
35
43
|
}));
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
}
|
|
44
|
+
|
|
45
|
+
// CardExtra.defaultProps = {
|
|
46
|
+
// className: '',
|
|
47
|
+
// style: {},
|
|
48
|
+
// };
|
|
49
|
+
|
|
40
50
|
CardExtra.propTypes = {
|
|
41
51
|
/** The content of the component. */
|
|
42
52
|
children: PropTypes.node,
|
|
@@ -46,19 +56,19 @@ CardExtra.propTypes = {
|
|
|
46
56
|
style: PropTypes.object,
|
|
47
57
|
/** The title of the component's header. */
|
|
48
58
|
title: PropTypes.string,
|
|
49
|
-
/**
|
|
50
|
-
* ref methods (ref.current.instance.*method*)
|
|
51
|
-
*
|
|
52
|
-
* * option(): Gets all UI component properties
|
|
53
|
-
* * Returns value - object
|
|
54
|
-
* * option(optionName): Gets the value of a single property
|
|
55
|
-
* * @param {optionName} - string
|
|
56
|
-
* * Returns value - any
|
|
57
|
-
* * option(optionName, optionValue): Updates the value of a single property
|
|
58
|
-
* * @param {optionName} - string
|
|
59
|
-
* * @param {optionValue} - any
|
|
60
|
-
* * option(options): Updates the values of several properties
|
|
61
|
-
* * @param {options} - object
|
|
59
|
+
/**
|
|
60
|
+
* ref methods (ref.current.instance.*method*)
|
|
61
|
+
*
|
|
62
|
+
* * option(): Gets all UI component properties
|
|
63
|
+
* * Returns value - object
|
|
64
|
+
* * option(optionName): Gets the value of a single property
|
|
65
|
+
* * @param {optionName} - string
|
|
66
|
+
* * Returns value - any
|
|
67
|
+
* * option(optionName, optionValue): Updates the value of a single property
|
|
68
|
+
* * @param {optionName} - string
|
|
69
|
+
* * @param {optionValue} - any
|
|
70
|
+
* * option(options): Updates the values of several properties
|
|
71
|
+
* * @param {options} - object
|
|
62
72
|
*/
|
|
63
73
|
ref: ref
|
|
64
74
|
};
|