diginet-core-ui 1.3.70 → 1.3.71
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/avatar/index.js +99 -84
- package/components/button/index.js +13 -8
- package/components/card/body.js +2 -1
- package/components/card/extra.js +2 -1
- package/components/card/footer.js +2 -1
- package/components/card/header.js +2 -1
- package/components/card/index.js +11 -8
- package/components/chip/index.js +158 -189
- package/components/form-control/checkbox/index.js +2 -2
- package/components/form-control/dropdown/index.js +199 -218
- package/components/form-control/radio/index.js +2 -2
- package/components/form-control/text-input/index.js +139 -212
- package/components/form-control/toggle/index.js +2 -2
- package/components/grid/index.js +2 -2
- package/components/others/import/index.js +78 -0
- package/components/tooltip/index.js +8 -2
- package/global/index.js +5 -5
- package/package.json +1 -1
- package/readme.md +10 -0
- package/utils/index.js +2 -0
- package/utils/{sb-teamplate.js → sb-template.js} +20 -12
|
@@ -7,7 +7,7 @@ import { jsx, css, keyframes } from '@emotion/core';
|
|
|
7
7
|
import OptionWrapper from '../others/option-wrapper';
|
|
8
8
|
import { useIntersection } from '../../utils/intersectionObserver';
|
|
9
9
|
import { ButtonIcon, ModalSample, Popover, Popup, Typography } from '../';
|
|
10
|
-
import { randomString } from '../../utils';
|
|
10
|
+
import { classNames, randomString } from '../../utils';
|
|
11
11
|
import { getGlobal } from '../../global';
|
|
12
12
|
import AvatarDefault from '../../assets/avatar/default.svg';
|
|
13
13
|
import { alignCenter, borderNone, displayBlock, displayNone, flexCol, inlineFlex, overflowHidden, parseWidthHeight, pointerEventsNone, positionAbsolute, positionRelative, userSelectNone } from '../../styles/general';
|
|
@@ -51,30 +51,32 @@ const checkFileType = (type, matchType) => {
|
|
|
51
51
|
};
|
|
52
52
|
|
|
53
53
|
const Avatar = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
54
|
-
|
|
54
|
+
action = {},
|
|
55
|
+
actionIconHeight,
|
|
56
|
+
actionIconWidth,
|
|
57
|
+
allowEdit,
|
|
58
|
+
className,
|
|
59
|
+
clearAble,
|
|
60
|
+
data,
|
|
55
61
|
defaultSrc,
|
|
56
|
-
|
|
57
|
-
|
|
62
|
+
direction,
|
|
63
|
+
disabled,
|
|
58
64
|
height,
|
|
59
|
-
|
|
65
|
+
hoverAble,
|
|
66
|
+
id,
|
|
67
|
+
lazyLoading,
|
|
60
68
|
matchType,
|
|
61
|
-
|
|
69
|
+
maxSize,
|
|
62
70
|
maxSizeError,
|
|
63
|
-
wrongTypeError,
|
|
64
|
-
actionIconWidth,
|
|
65
|
-
actionIconHeight,
|
|
66
|
-
direction,
|
|
67
|
-
data,
|
|
68
|
-
onRemove,
|
|
69
71
|
onChange,
|
|
70
|
-
|
|
71
|
-
|
|
72
|
+
onClick,
|
|
73
|
+
onRemove,
|
|
74
|
+
outlined,
|
|
72
75
|
readOnly,
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
onClick
|
|
76
|
+
src,
|
|
77
|
+
style,
|
|
78
|
+
width,
|
|
79
|
+
wrongTypeError
|
|
78
80
|
}, reference) => {
|
|
79
81
|
if (!defaultSrc) defaultSrc = AvatarDefault;
|
|
80
82
|
const ref = useRef(null);
|
|
@@ -241,26 +243,35 @@ const Avatar = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
241
243
|
}
|
|
242
244
|
}
|
|
243
245
|
}, [src]);
|
|
244
|
-
useImperativeHandle(reference, () =>
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
246
|
+
useImperativeHandle(reference, () => {
|
|
247
|
+
const currentRef = ref.current || {};
|
|
248
|
+
currentRef.element = ref.current;
|
|
249
|
+
const _instance = { ...action
|
|
250
|
+
}; // methods
|
|
251
|
+
|
|
252
|
+
_instance.__proto__ = {}; // hidden methods
|
|
253
|
+
|
|
254
|
+
currentRef.instance = _instance;
|
|
255
|
+
return currentRef;
|
|
256
|
+
});
|
|
248
257
|
return useMemo(() => {
|
|
249
258
|
return jsx(Fragment, null, jsx("div", {
|
|
250
259
|
css: _AvatarContainerCSS,
|
|
251
260
|
ref: ref,
|
|
252
261
|
id: unique,
|
|
253
|
-
className: disabled
|
|
262
|
+
className: classNames(disabled && 'disabled')
|
|
254
263
|
}, jsx("div", {
|
|
255
264
|
css: _AvatarRootCSS,
|
|
256
|
-
className:
|
|
265
|
+
className: classNames('DGN-UI-Avatar', className),
|
|
266
|
+
style: style,
|
|
257
267
|
id: id
|
|
258
268
|
}, jsx("input", {
|
|
259
269
|
ref: inputRef,
|
|
260
270
|
type: "file",
|
|
261
271
|
title: '',
|
|
262
272
|
accept: 'image/*',
|
|
263
|
-
onChange: onChangeAvatar
|
|
273
|
+
onChange: onChangeAvatar,
|
|
274
|
+
disabled: disabled
|
|
264
275
|
}), jsx("div", {
|
|
265
276
|
css: _AvatarPreviewCSS,
|
|
266
277
|
onClick: _onClick,
|
|
@@ -320,7 +331,7 @@ const Avatar = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
320
331
|
icon: 'danger',
|
|
321
332
|
fullScreen: true
|
|
322
333
|
}));
|
|
323
|
-
}, [
|
|
334
|
+
}, [actionIconHeight, actionIconWidth, allowEdit, clearAble, data, defaultSrc, direction, disabled, height, hoverAble, lazyLoading, matchType, maxSize, maxSizeError, outlined, readOnly, width, isInView, onLoaded, srcState, viewAvatar, viewMoreInfo]);
|
|
324
335
|
}));
|
|
325
336
|
|
|
326
337
|
const ActionIconCSS = actionIconWidth => css`
|
|
@@ -391,99 +402,103 @@ const blurAnimationCSS = css`
|
|
|
391
402
|
animation: ${blurKeyframe} 1s ease;
|
|
392
403
|
`;
|
|
393
404
|
Avatar.defaultProps = {
|
|
405
|
+
actionIconHeight: 24,
|
|
406
|
+
actionIconWidth: 24,
|
|
394
407
|
allowEdit: false,
|
|
395
|
-
|
|
396
|
-
readOnly: false,
|
|
408
|
+
className: '',
|
|
397
409
|
clearAble: true,
|
|
410
|
+
data: {},
|
|
411
|
+
direction: 'bottom',
|
|
412
|
+
disabled: false,
|
|
413
|
+
height: 48,
|
|
398
414
|
hoverAble: false,
|
|
415
|
+
lazyLoading: false,
|
|
416
|
+
matchType: /^image\/(gif|jpe?g|tiff?|png|webp|bmp|svg(\+xml)?)$/i,
|
|
417
|
+
maxSizeError: `File ${getGlobal(['errorDefault', 'maxSize'])}`,
|
|
399
418
|
outlined: false,
|
|
419
|
+
readOnly: false,
|
|
420
|
+
style: {},
|
|
400
421
|
width: 48,
|
|
401
|
-
|
|
402
|
-
actionIconWidth: 24,
|
|
403
|
-
actionIconHeight: 24,
|
|
404
|
-
className: '',
|
|
405
|
-
direction: 'bottom',
|
|
406
|
-
maxSizeError: `File ${getGlobal(['errorDefault', 'maxSize'])}`,
|
|
407
|
-
wrongTypeError: `File ${getGlobal(['errorDefault', 'fileType'])}`,
|
|
408
|
-
matchType: /^image\/(gif|jpe?g|tiff?|png|webp|bmp|svg(\+xml)?)$/i,
|
|
409
|
-
data: {},
|
|
410
|
-
lazyLoading: false
|
|
422
|
+
wrongTypeError: `File ${getGlobal(['errorDefault', 'fileType'])}`
|
|
411
423
|
};
|
|
412
424
|
Avatar.propTypes = {
|
|
425
|
+
/** The height of action icon. */
|
|
426
|
+
actionIconHeight: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
|
|
427
|
+
|
|
428
|
+
/** The width of action icon. */
|
|
429
|
+
actionIconWidth: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
|
|
430
|
+
|
|
413
431
|
/** If `true`, allow to edit avatar. */
|
|
414
432
|
allowEdit: PropTypes.bool,
|
|
415
433
|
|
|
416
|
-
/**
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
/** only view and allow show more info if hoverAble is true */
|
|
420
|
-
readOnly: PropTypes.bool,
|
|
434
|
+
/** Class for component. */
|
|
435
|
+
className: PropTypes.string,
|
|
421
436
|
|
|
422
|
-
/** display remove avatar icon
|
|
437
|
+
/** If `true`, display remove avatar icon. */
|
|
423
438
|
clearAble: PropTypes.bool,
|
|
424
439
|
|
|
425
|
-
/**
|
|
426
|
-
|
|
440
|
+
/**
|
|
441
|
+
* data to display when hoverAble is true<br />
|
|
442
|
+
* data is an object or function return a jsx element
|
|
443
|
+
*/
|
|
444
|
+
data: PropTypes.oneOfType([PropTypes.object, PropTypes.func]),
|
|
427
445
|
|
|
428
|
-
/**
|
|
429
|
-
|
|
446
|
+
/**
|
|
447
|
+
* it is used to display the default if there is no src<br />
|
|
448
|
+
* if undefined, will display icons available in the icons store
|
|
449
|
+
*/
|
|
450
|
+
defaultSrc: PropTypes.string,
|
|
430
451
|
|
|
431
|
-
/**
|
|
432
|
-
|
|
452
|
+
/** the direction to display more info */
|
|
453
|
+
direction: PropTypes.oneOf(['top', 'bottom', 'left', 'right']),
|
|
454
|
+
|
|
455
|
+
/** prevent all events, only view */
|
|
456
|
+
disabled: PropTypes.bool,
|
|
433
457
|
|
|
434
458
|
/** The height of avatar box (48 or '48px' or ...) */
|
|
435
459
|
height: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
|
|
436
460
|
|
|
437
|
-
/**
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
/** The height of action icon (18 or '18px') */
|
|
441
|
-
actionIconHeight: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
|
|
461
|
+
/** show more info in popover if true */
|
|
462
|
+
hoverAble: PropTypes.bool,
|
|
442
463
|
|
|
443
|
-
/**
|
|
444
|
-
|
|
464
|
+
/** lazy loading */
|
|
465
|
+
lazyLoading: PropTypes.bool,
|
|
445
466
|
|
|
446
467
|
/** type of image was allowed */
|
|
447
468
|
matchType: PropTypes.oneOfType([PropTypes.string, PropTypes.object, PropTypes.func, PropTypes.array]),
|
|
448
469
|
|
|
449
|
-
/**
|
|
450
|
-
|
|
470
|
+
/** maximum size for avatar file (unit: MB) */
|
|
471
|
+
maxSize: PropTypes.number,
|
|
451
472
|
|
|
452
473
|
/** the error to show on exceeded allowed size */
|
|
453
474
|
maxSizeError: PropTypes.string,
|
|
454
475
|
|
|
455
|
-
/**
|
|
456
|
-
|
|
476
|
+
/** will run after change avatar */
|
|
477
|
+
onChange: PropTypes.func,
|
|
457
478
|
|
|
458
|
-
/**
|
|
459
|
-
|
|
479
|
+
/** Callback fired when the component is clicked. */
|
|
480
|
+
onClick: PropTypes.func,
|
|
460
481
|
|
|
461
|
-
/**
|
|
462
|
-
|
|
463
|
-
* if undefined, will display icons available in the icons store
|
|
464
|
-
*/
|
|
465
|
-
defaultSrc: PropTypes.string,
|
|
482
|
+
/** will run after remove avatar */
|
|
483
|
+
onRemove: PropTypes.func,
|
|
466
484
|
|
|
467
|
-
/**
|
|
468
|
-
|
|
485
|
+
/** border of avatar (true or '1px solid #color') */
|
|
486
|
+
outlined: PropTypes.oneOfType([PropTypes.bool, PropTypes.string]),
|
|
469
487
|
|
|
470
|
-
/**
|
|
471
|
-
|
|
472
|
-
* data is an object or function return a jsx element
|
|
473
|
-
*/
|
|
474
|
-
data: PropTypes.oneOfType([PropTypes.object, PropTypes.func]),
|
|
488
|
+
/** only view and allow show more info if hoverAble is true */
|
|
489
|
+
readOnly: PropTypes.bool,
|
|
475
490
|
|
|
476
|
-
/**
|
|
477
|
-
|
|
491
|
+
/** source of file (http:// or https://) */
|
|
492
|
+
src: PropTypes.string,
|
|
478
493
|
|
|
479
|
-
/**
|
|
480
|
-
|
|
494
|
+
/** Style inline of component. */
|
|
495
|
+
style: PropTypes.object,
|
|
481
496
|
|
|
482
|
-
/**
|
|
483
|
-
|
|
497
|
+
/** The width of avatar box (48 or '48px' or ...) */
|
|
498
|
+
width: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
|
|
484
499
|
|
|
485
|
-
/**
|
|
486
|
-
|
|
500
|
+
/** the error to show on wrong type */
|
|
501
|
+
wrongTypeError: PropTypes.string,
|
|
487
502
|
|
|
488
503
|
/**
|
|
489
504
|
* ref methods
|
|
@@ -12,6 +12,7 @@ import Ripple from './ripple-effect';
|
|
|
12
12
|
import CircularProgress from '../progress/circular';
|
|
13
13
|
import Icon from '../../icons';
|
|
14
14
|
import { flexRow, alignCenter, justifyCenter, positionRelative, borderRadius4px, borderBox, noPadding, noBorder, cursorPointer, overflowHidden, pointerEventsNone, outlineNone, userSelectNone, backgroundTransparent, inlineFlex, noMargin } from '../../styles/general';
|
|
15
|
+
import { classNames } from '../../utils';
|
|
15
16
|
import theme from '../../theme/settings';
|
|
16
17
|
const {
|
|
17
18
|
colors: {
|
|
@@ -33,7 +34,8 @@ const {
|
|
|
33
34
|
},
|
|
34
35
|
typography: {
|
|
35
36
|
uppercase
|
|
36
|
-
}
|
|
37
|
+
},
|
|
38
|
+
spacing
|
|
37
39
|
} = theme;
|
|
38
40
|
export const getRippleColor = (color, viewType, colors) => {
|
|
39
41
|
if (!isColor(color) && !isColorName(color)) {
|
|
@@ -83,12 +85,13 @@ export const getClassNameFromColor = color => {
|
|
|
83
85
|
return !isColor(color) && !isColorName(color) ? color : 'custom-color';
|
|
84
86
|
};
|
|
85
87
|
const colorMap = new Map([['primary', active], ['success', success], ['warning', warning], ['danger', danger], ['info', info]]);
|
|
86
|
-
const iconSizeMap = new Map([['tiny',
|
|
87
|
-
const paddingSizeMap = new Map([['tiny',
|
|
88
|
-
const outlinedPaddingSizeMap = new Map([['tiny',
|
|
88
|
+
const iconSizeMap = new Map([['tiny', spacing([4])], ['small', spacing([5])], ['medium', spacing([6])], ['large', spacing([8])], ['giant', spacing([10])]]);
|
|
89
|
+
const paddingSizeMap = new Map([['tiny', spacing([1, 2])], ['small', spacing([1.5, 3])], ['medium', spacing([2, 4])], ['large', spacing([2, 5])], ['giant', spacing([2, 6])]]);
|
|
90
|
+
const outlinedPaddingSizeMap = new Map([['tiny', spacing([0.75, 1.75])], ['small', spacing([1.25, 2.75])], ['medium', spacing([1.75, 3.75])], ['large', spacing([1.75, 4.75])], ['giant', spacing([1.75, 5.75])]]);
|
|
89
91
|
const iconMarginSizeMap = new Map([['tiny', '4px'], ['small', '4px'], ['medium', '4px'], ['large', '6px'], ['giant', '8px']]);
|
|
90
92
|
const typographySizeMap = new Map([['tiny', 'heading5'], ['small', 'heading5'], ['medium', 'heading4'], ['large', 'heading2'], ['giant', 'heading1']]);
|
|
91
93
|
const minHeightSizeMap = new Map([['tiny', '24px'], ['small', '32px'], ['medium', '40px'], ['large', '48px'], ['giant', '56px']]);
|
|
94
|
+
const minHeightSizeLinkMap = new Map([['tiny', '16px'], ['small', '20px'], ['medium', '24px'], ['large', '32px'], ['giant', '40px']]);
|
|
92
95
|
const alphaArr = {
|
|
93
96
|
hover: 0.1,
|
|
94
97
|
focus: 0.2,
|
|
@@ -121,10 +124,11 @@ const Button = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
121
124
|
const typographySize = typographySizeMap.get(size);
|
|
122
125
|
const iconMarginSize = iconMarginSizeMap.get(size);
|
|
123
126
|
const minHeightSize = minHeightSizeMap.get(size);
|
|
127
|
+
const minHeightSizeLink = minHeightSizeLinkMap.get(size);
|
|
124
128
|
|
|
125
129
|
const _ButtonText = ButtonText(loading, iconMarginSize);
|
|
126
130
|
|
|
127
|
-
const _ButtonRoot = ButtonRoot(viewType, size, paddingSize, minHeightSize, outlinedPaddingSize, endIcon, label, iconMarginSize, startIcon, iconSize, color);
|
|
131
|
+
const _ButtonRoot = ButtonRoot(viewType, size, paddingSize, minHeightSize, minHeightSizeLink, outlinedPaddingSize, endIcon, label, iconMarginSize, startIcon, iconSize, color);
|
|
128
132
|
|
|
129
133
|
useImperativeHandle(reference, () => ({
|
|
130
134
|
element: ref.current,
|
|
@@ -219,7 +223,7 @@ const Button = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
219
223
|
onClick: _onClick,
|
|
220
224
|
id: id,
|
|
221
225
|
type: type,
|
|
222
|
-
className:
|
|
226
|
+
className: classNames('DGN-UI-Button', viewType, getClassNameFromColor(color), size, loading && 'button--loading', disabled && 'button--disabled', className),
|
|
223
227
|
...props
|
|
224
228
|
}, start, jsx(Typography, {
|
|
225
229
|
css: _ButtonText,
|
|
@@ -228,7 +232,7 @@ const Button = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
228
232
|
}, children || label), end && end, !disabled && !loading && viewType !== 'link' && jsx(Ripple, {
|
|
229
233
|
color: getRippleColor(color, viewType, allColors)
|
|
230
234
|
}));
|
|
231
|
-
}, [
|
|
235
|
+
}, [children, className, color, disabled, endIcon, id, label, loading, onClick, size, startIcon, type, viewType]);
|
|
232
236
|
}));
|
|
233
237
|
const ButtonIcon = css`
|
|
234
238
|
${flexRow};
|
|
@@ -244,7 +248,7 @@ const ButtonText = (loading, iconMarginSize) => css`
|
|
|
244
248
|
margin: 0 ${loading ? iconMarginSize : 0};
|
|
245
249
|
`;
|
|
246
250
|
|
|
247
|
-
const ButtonRoot = (viewType, size, paddingSize, minHeightSize, outlinedPaddingSize, endIcon, label, iconMarginSize, startIcon, iconSize, color) => css`
|
|
251
|
+
const ButtonRoot = (viewType, size, paddingSize, minHeightSize, minHeightSizeLink, outlinedPaddingSize, endIcon, label, iconMarginSize, startIcon, iconSize, color) => css`
|
|
248
252
|
${inlineFlex};
|
|
249
253
|
${alignCenter};
|
|
250
254
|
${justifyCenter};
|
|
@@ -413,6 +417,7 @@ const ButtonRoot = (viewType, size, paddingSize, minHeightSize, outlinedPaddingS
|
|
|
413
417
|
}
|
|
414
418
|
}
|
|
415
419
|
&.link {
|
|
420
|
+
min-height: ${minHeightSizeLink};
|
|
416
421
|
${backgroundTransparent};
|
|
417
422
|
${noBorder};
|
|
418
423
|
${noPadding};
|
package/components/card/body.js
CHANGED
|
@@ -5,6 +5,7 @@ import { memo, useRef, useMemo, forwardRef, useImperativeHandle } from 'react';
|
|
|
5
5
|
import PropTypes from 'prop-types';
|
|
6
6
|
import { jsx } from '@emotion/core';
|
|
7
7
|
import OptionWrapper from '../others/option-wrapper';
|
|
8
|
+
import { classNames } from '../../utils';
|
|
8
9
|
const CardBody = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
9
10
|
children,
|
|
10
11
|
className,
|
|
@@ -22,7 +23,7 @@ const CardBody = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
22
23
|
id: id,
|
|
23
24
|
ref: ref,
|
|
24
25
|
style: style,
|
|
25
|
-
className:
|
|
26
|
+
className: classNames(`DGN-UI-Card-Body`, className)
|
|
26
27
|
}, children);
|
|
27
28
|
}, [children, className, id, style, title]);
|
|
28
29
|
}));
|
package/components/card/extra.js
CHANGED
|
@@ -5,6 +5,7 @@ import { memo, useRef, useMemo, forwardRef, useImperativeHandle } from 'react';
|
|
|
5
5
|
import PropTypes from 'prop-types';
|
|
6
6
|
import { jsx } from '@emotion/core';
|
|
7
7
|
import OptionWrapper from '../others/option-wrapper';
|
|
8
|
+
import { classNames } from '../../utils';
|
|
8
9
|
const CardExtra = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
9
10
|
children,
|
|
10
11
|
className,
|
|
@@ -22,7 +23,7 @@ const CardExtra = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
22
23
|
id: id,
|
|
23
24
|
ref: ref,
|
|
24
25
|
style: style,
|
|
25
|
-
className:
|
|
26
|
+
className: classNames(`DGN-UI-Card-Extra`, className)
|
|
26
27
|
}, children);
|
|
27
28
|
}, [children, className, id, style, title]);
|
|
28
29
|
}));
|
|
@@ -5,6 +5,7 @@ import { memo, useRef, useMemo, forwardRef, useImperativeHandle } from 'react';
|
|
|
5
5
|
import PropTypes from 'prop-types';
|
|
6
6
|
import { jsx } from '@emotion/core';
|
|
7
7
|
import OptionWrapper from '../others/option-wrapper';
|
|
8
|
+
import { classNames } from '../../utils';
|
|
8
9
|
const CardFooter = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
9
10
|
children,
|
|
10
11
|
className,
|
|
@@ -22,7 +23,7 @@ const CardFooter = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
22
23
|
id: id,
|
|
23
24
|
ref: ref,
|
|
24
25
|
style: style,
|
|
25
|
-
className:
|
|
26
|
+
className: classNames(`DGN-UI-Card-Footer`, className)
|
|
26
27
|
}, children);
|
|
27
28
|
}, [children, className, id, style, title]);
|
|
28
29
|
}));
|
|
@@ -6,6 +6,7 @@ import PropTypes from 'prop-types';
|
|
|
6
6
|
import { jsx } from '@emotion/core';
|
|
7
7
|
import OptionWrapper from '../others/option-wrapper';
|
|
8
8
|
import Typography from '../typography';
|
|
9
|
+
import { classNames } from '../../utils';
|
|
9
10
|
const CardHeader = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
10
11
|
children,
|
|
11
12
|
className,
|
|
@@ -23,7 +24,7 @@ const CardHeader = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
23
24
|
id: id,
|
|
24
25
|
ref: ref,
|
|
25
26
|
style: style,
|
|
26
|
-
className:
|
|
27
|
+
className: classNames(`DGN-UI-Card-Header`, className)
|
|
27
28
|
}, children || jsx(Typography, {
|
|
28
29
|
type: 'h3'
|
|
29
30
|
}, title));
|
package/components/card/index.js
CHANGED
|
@@ -11,6 +11,7 @@ import CardHeader from './header';
|
|
|
11
11
|
import { CardFooter } from './footer';
|
|
12
12
|
import { CardBody } from './body';
|
|
13
13
|
import { getColor } from '../../styles/utils';
|
|
14
|
+
import { classNames } from '../../utils';
|
|
14
15
|
const {
|
|
15
16
|
colors: {
|
|
16
17
|
system: {
|
|
@@ -28,6 +29,7 @@ const Card = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
28
29
|
children,
|
|
29
30
|
className,
|
|
30
31
|
dividerColor,
|
|
32
|
+
direction,
|
|
31
33
|
footer,
|
|
32
34
|
footerDivider,
|
|
33
35
|
footerStyle,
|
|
@@ -42,23 +44,23 @@ const Card = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
42
44
|
}, reference) => {
|
|
43
45
|
const ref = useRef(null);
|
|
44
46
|
|
|
45
|
-
const _CardCSS = CardCSS(width, height, headerDivider, footerDivider, dividerColor);
|
|
47
|
+
const _CardCSS = CardCSS(width, height, headerDivider, footerDivider, dividerColor, direction);
|
|
46
48
|
|
|
47
49
|
useImperativeHandle(reference, () => ({
|
|
48
50
|
element: ref.current,
|
|
49
51
|
instance: {}
|
|
50
52
|
}));
|
|
51
53
|
const head = header || title ? jsx(CardHeader, {
|
|
52
|
-
className: (className === null || className === void 0 ? void 0 : className.header)
|
|
54
|
+
className: classNames(className === null || className === void 0 ? void 0 : className.header),
|
|
53
55
|
style: headerStyle,
|
|
54
56
|
title: title
|
|
55
57
|
}, header) : null;
|
|
56
58
|
const foot = footer ? jsx(CardFooter, {
|
|
57
|
-
className: (className === null || className === void 0 ? void 0 : className.footer)
|
|
59
|
+
className: classNames(className === null || className === void 0 ? void 0 : className.footer),
|
|
58
60
|
style: footerStyle
|
|
59
61
|
}, footer) : null;
|
|
60
62
|
const body = bodyProp || children && (head || foot) ? jsx(CardBody, {
|
|
61
|
-
className: (className === null || className === void 0 ? void 0 : className.body)
|
|
63
|
+
className: classNames(className === null || className === void 0 ? void 0 : className.body),
|
|
62
64
|
style: bodyStyle
|
|
63
65
|
}, bodyProp || children) : null;
|
|
64
66
|
return useMemo(() => {
|
|
@@ -67,13 +69,13 @@ const Card = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
67
69
|
ref: ref,
|
|
68
70
|
css: _CardCSS,
|
|
69
71
|
style: style,
|
|
70
|
-
className:
|
|
72
|
+
className: classNames(`DGN-UI-Card`, (className === null || className === void 0 ? void 0 : className.container) || className)
|
|
71
73
|
}, head, body || children, foot);
|
|
72
|
-
}, [bodyProp, bodyStyle, children, className, dividerColor, footer, footerDivider, footerStyle, header, headerDivider, headerStyle, height, id, style, title, width]);
|
|
74
|
+
}, [bodyProp, bodyStyle, children, className, dividerColor, direction, footer, footerDivider, footerStyle, header, headerDivider, headerStyle, height, id, style, title, width]);
|
|
73
75
|
}));
|
|
74
76
|
|
|
75
|
-
const CardCSS = (width, height, headerDivider, footerDivider, dividerColor) => css`
|
|
76
|
-
${flexCol};
|
|
77
|
+
const CardCSS = (width, height, headerDivider, footerDivider, dividerColor, direction) => css`
|
|
78
|
+
${direction === 'vertical' ? flexCol : flexRow};
|
|
77
79
|
${positionRelative};
|
|
78
80
|
${borderBox};
|
|
79
81
|
${borderRadius4px};
|
|
@@ -132,6 +134,7 @@ Card.defaultProps = {
|
|
|
132
134
|
bodyStyle: {},
|
|
133
135
|
className: '',
|
|
134
136
|
dividerColor: category,
|
|
137
|
+
direction: 'vertical',
|
|
135
138
|
footerDivider: false,
|
|
136
139
|
footerStyle: {},
|
|
137
140
|
headerDivider: true,
|