diginet-core-ui 1.3.73 → 1.3.74
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/assets/images/menu/dhr/MHRP29N0026.svg +13 -0
- package/assets/images/menu/dhr/MHRP29N0027.svg +14 -0
- package/assets/images/menu/dhr/MHRP29N0028.svg +15 -0
- package/components/accordion/details.js +19 -10
- package/components/accordion/group.js +15 -6
- package/components/accordion/index.js +20 -11
- package/components/accordion/summary.js +18 -9
- package/components/avatar/index.js +1 -1
- package/components/badge/index.js +17 -9
- package/components/button/icon.js +33 -25
- package/components/button/index.js +25 -17
- package/components/card/body.js +12 -4
- package/components/card/extra.js +12 -4
- package/components/card/footer.js +12 -4
- package/components/card/header.js +12 -4
- package/components/card/index.js +12 -4
- package/components/chip/index.js +6 -6
- package/components/form-control/attachment/index.js +197 -192
- package/components/form-control/date-picker/index.js +4 -2
- package/components/form-control/date-range-picker/index.js +15 -8
- package/components/form-control/dropdown/index.js +34 -13
- package/components/form-control/input-base/index.js +505 -483
- package/components/form-control/label/index.js +27 -21
- package/components/form-control/text-input/index.js +4 -1
- package/components/grid/Col.js +8 -7
- package/components/grid/Container.js +16 -15
- package/components/grid/Row.js +16 -15
- package/components/grid/index.js +17 -36
- package/components/image/index.js +164 -0
- package/components/index.js +3 -1
- package/components/modal/body.js +12 -9
- package/components/modal/footer.js +22 -11
- package/components/modal/header.js +25 -13
- package/components/modal/index.js +32 -30
- package/components/modal/modal.js +29 -25
- package/components/others/option-wrapper/index.js +5 -18
- package/components/paging/page-info.js +45 -33
- package/components/paging/page-selector2.js +45 -33
- package/components/popover/body.js +14 -6
- package/components/popover/footer.js +15 -6
- package/components/popover/header.js +17 -7
- package/components/popover/index.js +242 -109
- package/components/status/index.js +12 -4
- package/components/tab/tab-container.js +29 -27
- package/components/tab/tab-header.js +33 -28
- package/components/tab/tab-panel.js +31 -27
- package/components/tab/tab.js +45 -35
- package/components/tree-view/index.js +108 -73
- package/components/typography/index.js +36 -25
- package/icons/basic.js +248 -0
- package/icons/effect.js +44 -36
- package/package.json +1 -1
- package/readme.md +40 -0
- package/styles/general.js +23 -0
- package/theme/index.js +1 -1
- package/theme/set-theme.js +2 -1
- package/utils/index.js +13 -10
- package/utils/useMediaQuery.js +4 -2
|
@@ -7,21 +7,22 @@ import { jsx, css } from '@emotion/core';
|
|
|
7
7
|
import OptionWrapper from '../../others/option-wrapper';
|
|
8
8
|
import { Typography } from '../../';
|
|
9
9
|
import { flexRow } from '../../../styles/general';
|
|
10
|
-
import
|
|
10
|
+
import { classNames } from '../../../utils';
|
|
11
|
+
import { arrTypeTypography as typesTypography } from '../../typography';
|
|
12
|
+
import { useTheme } from '../../../theme';
|
|
11
13
|
const {
|
|
12
14
|
colors: {
|
|
13
15
|
system: {
|
|
14
16
|
disabled: systemDisabled
|
|
15
17
|
},
|
|
16
|
-
semantic: {
|
|
17
|
-
danger
|
|
18
|
-
},
|
|
19
18
|
text: {
|
|
20
19
|
normal_label
|
|
21
20
|
}
|
|
22
|
-
}
|
|
23
|
-
|
|
21
|
+
},
|
|
22
|
+
spacing
|
|
23
|
+
} = useTheme();
|
|
24
24
|
const Label = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
25
|
+
action = {},
|
|
25
26
|
disabled,
|
|
26
27
|
readOnly,
|
|
27
28
|
required,
|
|
@@ -35,10 +36,17 @@ const Label = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
35
36
|
...props
|
|
36
37
|
}, reference) => {
|
|
37
38
|
const ref = useRef(null);
|
|
38
|
-
useImperativeHandle(reference, () =>
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
39
|
+
useImperativeHandle(reference, () => {
|
|
40
|
+
const currentRef = ref.current || {};
|
|
41
|
+
currentRef.element = ref.current;
|
|
42
|
+
const _instance = { ...action
|
|
43
|
+
}; // methods
|
|
44
|
+
|
|
45
|
+
_instance.__proto__ = {}; // hidden methods
|
|
46
|
+
|
|
47
|
+
currentRef.instance = _instance;
|
|
48
|
+
return currentRef;
|
|
49
|
+
});
|
|
42
50
|
return useMemo(() => jsx("div", {
|
|
43
51
|
css: LabelContainerCSS,
|
|
44
52
|
className: 'DGN-UI-Label-Container'
|
|
@@ -52,23 +60,22 @@ const Label = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
52
60
|
lineClamp: lineClamp,
|
|
53
61
|
hoverTooltip: hoverTooltip,
|
|
54
62
|
type: type,
|
|
55
|
-
className:
|
|
63
|
+
className: classNames('DGN-UI-Label', className, readOnly && 'read-only', disabled && 'disabled'),
|
|
56
64
|
...props
|
|
57
|
-
}, children), required && jsx(
|
|
58
|
-
|
|
59
|
-
|
|
65
|
+
}, children), required && jsx(Typography, {
|
|
66
|
+
type: type,
|
|
67
|
+
color: 'danger'
|
|
68
|
+
}, "*")), [children, className, color, disabled, hoverTooltip, id, lineClamp, readOnly, required, type, props]);
|
|
60
69
|
}));
|
|
61
70
|
const LabelContainerCSS = css`
|
|
62
71
|
${flexRow};
|
|
63
|
-
.
|
|
64
|
-
|
|
72
|
+
& + .DGN-UI-InputBase.outlined {
|
|
73
|
+
margin-top: ${spacing([0.5])};
|
|
65
74
|
}
|
|
66
75
|
`;
|
|
67
76
|
const LabelRootCSS = css`
|
|
68
77
|
min-height: 16px;
|
|
69
|
-
|
|
70
|
-
margin-top: 2px;
|
|
71
|
-
}
|
|
78
|
+
margin: 0;
|
|
72
79
|
word-break: break-all;
|
|
73
80
|
`;
|
|
74
81
|
Label.defaultProps = {
|
|
@@ -81,7 +88,6 @@ Label.defaultProps = {
|
|
|
81
88
|
className: '',
|
|
82
89
|
children: ''
|
|
83
90
|
};
|
|
84
|
-
const arrTypeTypography = ['t1', 't2', 't3', 't4', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'p1', 'p2', 'p3', 'title1', 'title2', 'title3', 'title4', 'heading1', 'heading2', 'heading3', 'heading4', 'heading5', 'heading6', 'paragraph1', 'paragraph2', 'paragraph3'];
|
|
85
91
|
Label.propTypes = {
|
|
86
92
|
/** The content of the component. */
|
|
87
93
|
children: PropTypes.node,
|
|
@@ -108,7 +114,7 @@ Label.propTypes = {
|
|
|
108
114
|
hoverTooltip: PropTypes.bool,
|
|
109
115
|
|
|
110
116
|
/** Consult [Typography's](https://core.diginet.com.vn/ui/?path=/docs/typography) documents. */
|
|
111
|
-
type: PropTypes.oneOf(
|
|
117
|
+
type: PropTypes.oneOf(typesTypography)
|
|
112
118
|
};
|
|
113
119
|
export { Label };
|
|
114
120
|
export default OptionWrapper(Label);
|
|
@@ -18,6 +18,7 @@ const TextInput = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
18
18
|
endIconProps,
|
|
19
19
|
error,
|
|
20
20
|
helperTextProps,
|
|
21
|
+
hoverTooltip,
|
|
21
22
|
icon,
|
|
22
23
|
iconStyle,
|
|
23
24
|
inputProps,
|
|
@@ -276,7 +277,8 @@ const TextInput = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
276
277
|
onKeyDown: onKeyDown,
|
|
277
278
|
onKeyUp: onKeyUp,
|
|
278
279
|
onPaste: onPaste,
|
|
279
|
-
value: valueProp
|
|
280
|
+
value: valueProp,
|
|
281
|
+
hoverTooltip: hoverTooltip
|
|
280
282
|
}), isError && jsx(HelperText, { ...helperTextProps,
|
|
281
283
|
disabled: disabled,
|
|
282
284
|
status: status
|
|
@@ -316,6 +318,7 @@ TextInput.defaultProps = {
|
|
|
316
318
|
className: '',
|
|
317
319
|
defaultValue: '',
|
|
318
320
|
disabled: false,
|
|
321
|
+
hoverTooltip: false,
|
|
319
322
|
error: '',
|
|
320
323
|
iconStyle: {},
|
|
321
324
|
label: '',
|
package/components/grid/Col.js
CHANGED
|
@@ -5,6 +5,7 @@ import PropTypes from 'prop-types';
|
|
|
5
5
|
import { jsx } from '@emotion/core';
|
|
6
6
|
import Grid from '.';
|
|
7
7
|
import { makeStyles } from '../../theme';
|
|
8
|
+
import { classNames } from '../../utils';
|
|
8
9
|
const useStyles = makeStyles({
|
|
9
10
|
customCol: {
|
|
10
11
|
'& .DGN-UI-Control': {
|
|
@@ -34,30 +35,27 @@ const Col = props => {
|
|
|
34
35
|
className
|
|
35
36
|
} = props;
|
|
36
37
|
return jsx(Grid, { ...props,
|
|
37
|
-
className:
|
|
38
|
+
className: classNames(`DGN-UI-Col ${classes.customCol}`, className),
|
|
38
39
|
item: true
|
|
39
40
|
});
|
|
40
41
|
};
|
|
41
42
|
|
|
42
43
|
Col.defaultProps = {
|
|
43
|
-
style: {},
|
|
44
44
|
className: '',
|
|
45
45
|
columns: 12,
|
|
46
46
|
lg: false,
|
|
47
47
|
md: false,
|
|
48
48
|
sm: false,
|
|
49
|
+
style: {},
|
|
50
|
+
wrap: 'wrap',
|
|
49
51
|
xl: false,
|
|
50
52
|
xs: true,
|
|
51
|
-
zeroMinWidth: false
|
|
52
|
-
wrap: 'wrap'
|
|
53
|
+
zeroMinWidth: false
|
|
53
54
|
};
|
|
54
55
|
Col.propTypes = {
|
|
55
56
|
/** The content of the component. */
|
|
56
57
|
children: PropTypes.node,
|
|
57
58
|
|
|
58
|
-
/** Style inline of component. */
|
|
59
|
-
style: PropTypes.object,
|
|
60
|
-
|
|
61
59
|
/** Class for component. */
|
|
62
60
|
className: PropTypes.string,
|
|
63
61
|
|
|
@@ -76,6 +74,9 @@ Col.propTypes = {
|
|
|
76
74
|
/** If a number, it sets the number of columns the grid item uses. It can't be greater than the total number of columns of the container (12 by default). If 'auto', the grid item's width matches its content. If false, the prop is ignored. If true, the grid item's width grows to use the space available in the grid container. The value is applied for the `sm` breakpoint and wider screens if not overridden. */
|
|
77
75
|
sm: PropTypes.oneOfType([PropTypes.oneOf(['auto']), PropTypes.number, PropTypes.bool]),
|
|
78
76
|
|
|
77
|
+
/** Style inline of component. */
|
|
78
|
+
style: PropTypes.object,
|
|
79
|
+
|
|
79
80
|
/** Defines the flex-wrap style property. It's applied for all screen sizes. */
|
|
80
81
|
wrap: PropTypes.oneOf(['nowrap', 'wrap-reverse', 'wrap']),
|
|
81
82
|
|
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
import PropTypes from 'prop-types';
|
|
5
5
|
import { jsx } from '@emotion/core';
|
|
6
6
|
import Grid from '.';
|
|
7
|
+
import { classNames } from '../../utils';
|
|
7
8
|
|
|
8
9
|
const checkChildren = children => {
|
|
9
10
|
if (!children) return false;
|
|
@@ -21,24 +22,14 @@ const Container = props => {
|
|
|
21
22
|
children
|
|
22
23
|
} = props;
|
|
23
24
|
return checkChildren(children) ? jsx(Grid, { ...props,
|
|
24
|
-
className:
|
|
25
|
+
className: classNames('DGN-UI-Container', className),
|
|
25
26
|
container: true
|
|
26
27
|
}) : null;
|
|
27
28
|
};
|
|
28
29
|
|
|
29
30
|
Container.defaultProps = {
|
|
30
|
-
style: {},
|
|
31
31
|
className: '',
|
|
32
32
|
columns: 12,
|
|
33
|
-
lg: false,
|
|
34
|
-
md: false,
|
|
35
|
-
sm: false,
|
|
36
|
-
xl: false,
|
|
37
|
-
xs: false,
|
|
38
|
-
zeroMinWidth: false,
|
|
39
|
-
spacing: 0,
|
|
40
|
-
direction: 'row',
|
|
41
|
-
wrap: 'wrap',
|
|
42
33
|
columnSpacing: {
|
|
43
34
|
xs: 4,
|
|
44
35
|
sm: 4,
|
|
@@ -46,6 +37,9 @@ Container.defaultProps = {
|
|
|
46
37
|
lg: 4,
|
|
47
38
|
xl: 6
|
|
48
39
|
},
|
|
40
|
+
direction: 'row',
|
|
41
|
+
lg: false,
|
|
42
|
+
md: false,
|
|
49
43
|
rowSpacing: {
|
|
50
44
|
xs: 4,
|
|
51
45
|
sm: 4,
|
|
@@ -53,21 +47,25 @@ Container.defaultProps = {
|
|
|
53
47
|
lg: 4,
|
|
54
48
|
xl: 4
|
|
55
49
|
},
|
|
50
|
+
sm: false,
|
|
51
|
+
spacing: 0,
|
|
52
|
+
style: {},
|
|
56
53
|
topSpacing: {
|
|
57
54
|
xs: 2,
|
|
58
55
|
sm: 2,
|
|
59
56
|
md: 2,
|
|
60
57
|
lg: 2,
|
|
61
58
|
xl: 2
|
|
62
|
-
}
|
|
59
|
+
},
|
|
60
|
+
wrap: 'wrap',
|
|
61
|
+
xl: false,
|
|
62
|
+
xs: false,
|
|
63
|
+
zeroMinWidth: false
|
|
63
64
|
};
|
|
64
65
|
Container.propTypes = {
|
|
65
66
|
/** The content of the component. */
|
|
66
67
|
children: PropTypes.node,
|
|
67
68
|
|
|
68
|
-
/** Style inline of component. */
|
|
69
|
-
style: PropTypes.object,
|
|
70
|
-
|
|
71
69
|
/** Class for component. */
|
|
72
70
|
className: PropTypes.string,
|
|
73
71
|
|
|
@@ -95,6 +93,9 @@ Container.propTypes = {
|
|
|
95
93
|
/** Defines the space between the type `Col` components */
|
|
96
94
|
spacing: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.number, PropTypes.string])), PropTypes.number, PropTypes.object, PropTypes.string]),
|
|
97
95
|
|
|
96
|
+
/** Style inline of component. */
|
|
97
|
+
style: PropTypes.object,
|
|
98
|
+
|
|
98
99
|
/** Defines the flex-wrap style property. It's applied for all screen sizes. */
|
|
99
100
|
wrap: PropTypes.oneOf(['nowrap', 'wrap-reverse', 'wrap']),
|
|
100
101
|
|
package/components/grid/Row.js
CHANGED
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
import PropTypes from 'prop-types';
|
|
5
5
|
import { jsx } from '@emotion/core';
|
|
6
6
|
import Grid from '.';
|
|
7
|
+
import { classNames } from '../../utils';
|
|
7
8
|
|
|
8
9
|
const checkChildren = children => {
|
|
9
10
|
if (!children) return false;
|
|
@@ -21,24 +22,14 @@ const Row = props => {
|
|
|
21
22
|
children
|
|
22
23
|
} = props;
|
|
23
24
|
return checkChildren(children) ? jsx(Grid, { ...props,
|
|
24
|
-
className:
|
|
25
|
+
className: classNames('DGN-UI-Row', className),
|
|
25
26
|
container: true
|
|
26
27
|
}) : null;
|
|
27
28
|
};
|
|
28
29
|
|
|
29
30
|
Row.defaultProps = {
|
|
30
|
-
style: {},
|
|
31
31
|
className: '',
|
|
32
32
|
columns: 12,
|
|
33
|
-
lg: false,
|
|
34
|
-
md: false,
|
|
35
|
-
sm: false,
|
|
36
|
-
xl: false,
|
|
37
|
-
xs: false,
|
|
38
|
-
zeroMinWidth: false,
|
|
39
|
-
spacing: 0,
|
|
40
|
-
direction: 'row',
|
|
41
|
-
wrap: 'wrap',
|
|
42
33
|
columnSpacing: {
|
|
43
34
|
xs: 4,
|
|
44
35
|
sm: 4,
|
|
@@ -46,21 +37,28 @@ Row.defaultProps = {
|
|
|
46
37
|
lg: 4,
|
|
47
38
|
xl: 6
|
|
48
39
|
},
|
|
40
|
+
direction: 'row',
|
|
41
|
+
lg: false,
|
|
42
|
+
md: false,
|
|
49
43
|
rowSpacing: {
|
|
50
44
|
xs: 4,
|
|
51
45
|
sm: 4,
|
|
52
46
|
md: 4,
|
|
53
47
|
lg: 4,
|
|
54
48
|
xl: 4
|
|
55
|
-
}
|
|
49
|
+
},
|
|
50
|
+
sm: false,
|
|
51
|
+
spacing: 0,
|
|
52
|
+
style: {},
|
|
53
|
+
wrap: 'wrap',
|
|
54
|
+
xl: false,
|
|
55
|
+
xs: false,
|
|
56
|
+
zeroMinWidth: false
|
|
56
57
|
};
|
|
57
58
|
Row.propTypes = {
|
|
58
59
|
/** The content of the component. */
|
|
59
60
|
children: PropTypes.node,
|
|
60
61
|
|
|
61
|
-
/** Style inline of component. */
|
|
62
|
-
style: PropTypes.object,
|
|
63
|
-
|
|
64
62
|
/** Class for component. */
|
|
65
63
|
className: PropTypes.string,
|
|
66
64
|
|
|
@@ -88,6 +86,9 @@ Row.propTypes = {
|
|
|
88
86
|
/** Defines the space between the type `Col` components */
|
|
89
87
|
spacing: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.number, PropTypes.string])), PropTypes.number, PropTypes.object, PropTypes.string]),
|
|
90
88
|
|
|
89
|
+
/** Style inline of component. */
|
|
90
|
+
style: PropTypes.object,
|
|
91
|
+
|
|
91
92
|
/** Defines the flex-wrap style property. It's applied for all screen sizes. */
|
|
92
93
|
wrap: PropTypes.oneOf(['nowrap', 'wrap-reverse', 'wrap']),
|
|
93
94
|
|
package/components/grid/index.js
CHANGED
|
@@ -8,19 +8,20 @@ import GridContext from './context';
|
|
|
8
8
|
import theme from '../../theme/settings';
|
|
9
9
|
import { breakpointKeys } from '../../theme/createBreakpoints';
|
|
10
10
|
import { borderBox } from '../../styles/general';
|
|
11
|
+
import { classNames, handleBreakpoints } from '../../utils';
|
|
11
12
|
const {
|
|
12
13
|
breakpoints: themeBreakpoints,
|
|
13
14
|
spacing: themeSpacing
|
|
14
15
|
} = theme;
|
|
15
16
|
const Grid = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
16
|
-
|
|
17
|
-
style,
|
|
18
|
-
className,
|
|
17
|
+
action = {},
|
|
19
18
|
children,
|
|
19
|
+
className,
|
|
20
20
|
columns: columnsProp,
|
|
21
21
|
columnSpacing: columnSpacingProp,
|
|
22
22
|
container,
|
|
23
23
|
direction,
|
|
24
|
+
id,
|
|
24
25
|
item,
|
|
25
26
|
leftSpacing: leftSpacingProp,
|
|
26
27
|
lg,
|
|
@@ -28,6 +29,7 @@ const Grid = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
28
29
|
rowSpacing: rowSpacingProp,
|
|
29
30
|
sm,
|
|
30
31
|
spacing,
|
|
32
|
+
style,
|
|
31
33
|
topSpacing: topSpacingProp,
|
|
32
34
|
wrap,
|
|
33
35
|
xl,
|
|
@@ -50,7 +52,9 @@ const Grid = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
50
52
|
|
|
51
53
|
useImperativeHandle(reference, () => {
|
|
52
54
|
const currentRef = ref.current || {};
|
|
53
|
-
|
|
55
|
+
currentRef.element = ref.current;
|
|
56
|
+
const _instance = { ...action
|
|
57
|
+
}; // methods
|
|
54
58
|
|
|
55
59
|
_instance.__proto__ = {}; // hidden methods
|
|
56
60
|
|
|
@@ -63,11 +67,11 @@ const Grid = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
63
67
|
ref: ref,
|
|
64
68
|
css: [_GridCSS, container && (rowSpacing || columnSpacing) && _GridSpacingCSS, _HandleGridCSS],
|
|
65
69
|
style: style,
|
|
66
|
-
className:
|
|
70
|
+
className: classNames(`DGN-UI-Grid${item ? '-item' : ''}`, className)
|
|
67
71
|
}, jsx(GridContext.Provider, {
|
|
68
72
|
value: columns
|
|
69
73
|
}, children));
|
|
70
|
-
}, [
|
|
74
|
+
}, [columns, columnSpacing, leftSpacing, rowSpacing, topSpacing, children, className, container, direction, id, item, lg, md, sm, spacing, style, wrap, xl, xs, zeroMinWidth]);
|
|
71
75
|
}));
|
|
72
76
|
|
|
73
77
|
const getOffset = val => {
|
|
@@ -75,30 +79,7 @@ const getOffset = val => {
|
|
|
75
79
|
return `${parse}${String(val).replace(String(parse), '') || 'px'}`;
|
|
76
80
|
};
|
|
77
81
|
|
|
78
|
-
const
|
|
79
|
-
let output = '';
|
|
80
|
-
|
|
81
|
-
if (Array.isArray(propValue)) {
|
|
82
|
-
propValue.map((item, index) => {
|
|
83
|
-
output = output.concat([themeBreakpoints.up(breakpointKeys[index])]).concat(`{${cssFromPropValue(propValue[index])}} `);
|
|
84
|
-
});
|
|
85
|
-
return output;
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
if (typeof propValue === 'object') {
|
|
89
|
-
Object.keys(propValue).map(item => {
|
|
90
|
-
if (breakpointKeys.includes(item)) {
|
|
91
|
-
output = output.concat([themeBreakpoints.up(item)]).concat(`{${cssFromPropValue(propValue[item])}} `);
|
|
92
|
-
}
|
|
93
|
-
});
|
|
94
|
-
return output;
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
output = cssFromPropValue(propValue);
|
|
98
|
-
return output;
|
|
99
|
-
};
|
|
100
|
-
|
|
101
|
-
const progessSizeArray = sizeArr => {
|
|
82
|
+
const processSizeArray = sizeArr => {
|
|
102
83
|
let lastValue = false;
|
|
103
84
|
sizeArr = sizeArr.map(item => {
|
|
104
85
|
if (item === false) return lastValue;else lastValue = item;
|
|
@@ -208,26 +189,26 @@ const GridSpacingCSS = (rowSpacing, columnSpacing, topSpacing, leftSpacing) => c
|
|
|
208
189
|
`;
|
|
209
190
|
|
|
210
191
|
const HandleGridCSS = (sizeArr, columns) => css`
|
|
211
|
-
${
|
|
192
|
+
${processSizeArray(sizeArr).map((item, idx) => {
|
|
212
193
|
return handleGrid(breakpointKeys[idx], item, columns);
|
|
213
194
|
})}
|
|
214
195
|
`;
|
|
215
196
|
|
|
216
197
|
Grid.defaultProps = {
|
|
217
|
-
style: {},
|
|
218
198
|
className: '',
|
|
219
199
|
columns: 12,
|
|
220
200
|
container: false,
|
|
201
|
+
direction: 'row',
|
|
221
202
|
item: false,
|
|
222
203
|
lg: false,
|
|
223
204
|
md: false,
|
|
224
205
|
sm: false,
|
|
206
|
+
spacing: 0,
|
|
207
|
+
style: {},
|
|
208
|
+
wrap: 'wrap',
|
|
225
209
|
xl: false,
|
|
226
210
|
xs: false,
|
|
227
|
-
zeroMinWidth: false
|
|
228
|
-
spacing: 0,
|
|
229
|
-
direction: 'row',
|
|
230
|
-
wrap: 'wrap'
|
|
211
|
+
zeroMinWidth: false
|
|
231
212
|
};
|
|
232
213
|
Grid.propTypes = {
|
|
233
214
|
/** The content of the component. */
|
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
/** @jsxRuntime classic */
|
|
2
|
+
|
|
3
|
+
/** @jsx jsx */
|
|
4
|
+
import { forwardRef, Fragment, memo, useEffect, useImperativeHandle, useMemo, useRef, useState } from 'react';
|
|
5
|
+
import PropTypes from 'prop-types';
|
|
6
|
+
import { jsx, css, keyframes } from '@emotion/core';
|
|
7
|
+
import OptionWrapper from '../others/option-wrapper';
|
|
8
|
+
import { useIntersection } from '../../utils/intersectionObserver';
|
|
9
|
+
import { classNames } from '../../utils';
|
|
10
|
+
import AvatarDefault from '../../assets/avatar/default.svg';
|
|
11
|
+
import { alignCenter, inlineFlex, overflowHidden, parseWidthHeight, positionRelative } from '../../styles/general';
|
|
12
|
+
const blurKeyframe = keyframes`
|
|
13
|
+
0% { -webkit-filter: blur(4px);}
|
|
14
|
+
25% { -webkit-filter: blur(3px);}
|
|
15
|
+
50% { -webkit-filter: blur(2px);}
|
|
16
|
+
75% { -webkit-filter: blur(1px);}
|
|
17
|
+
100% { -webkit-filter: blur(0px);}
|
|
18
|
+
`;
|
|
19
|
+
const Image = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
20
|
+
action = {},
|
|
21
|
+
alt,
|
|
22
|
+
circular,
|
|
23
|
+
className,
|
|
24
|
+
defaultSrc,
|
|
25
|
+
height,
|
|
26
|
+
id,
|
|
27
|
+
lazyLoading,
|
|
28
|
+
onError,
|
|
29
|
+
src,
|
|
30
|
+
style,
|
|
31
|
+
width
|
|
32
|
+
}, reference) => {
|
|
33
|
+
if (!defaultSrc) defaultSrc = AvatarDefault;
|
|
34
|
+
const ref = useRef(null);
|
|
35
|
+
const [srcState, setSrcState] = useState(src);
|
|
36
|
+
const [isInView, setIsInView] = useState(false);
|
|
37
|
+
const [onLoaded, setOnLoaded] = useState(false);
|
|
38
|
+
useIntersection(ref, () => {
|
|
39
|
+
setIsInView(true);
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
const _ImageCSS = ImageCSS(width, height, circular);
|
|
43
|
+
|
|
44
|
+
useEffect(() => {
|
|
45
|
+
if (src) {
|
|
46
|
+
if (isInView || !lazyLoading) {
|
|
47
|
+
const img = document.createElement('img');
|
|
48
|
+
img.src = src;
|
|
49
|
+
img.alt = '';
|
|
50
|
+
|
|
51
|
+
img.onerror = () => {
|
|
52
|
+
setSrcState(defaultSrc);
|
|
53
|
+
onError === null || onError === void 0 ? void 0 : onError();
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
img.onload = () => {
|
|
57
|
+
setSrcState(src);
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
}, [src]);
|
|
62
|
+
useImperativeHandle(reference, () => {
|
|
63
|
+
const currentRef = ref.current || {};
|
|
64
|
+
currentRef.element = ref.current;
|
|
65
|
+
const _instance = { ...action
|
|
66
|
+
}; // methods
|
|
67
|
+
|
|
68
|
+
_instance.__proto__ = {}; // hidden methods
|
|
69
|
+
|
|
70
|
+
currentRef.instance = _instance;
|
|
71
|
+
return currentRef;
|
|
72
|
+
});
|
|
73
|
+
|
|
74
|
+
const renderImage = () => {
|
|
75
|
+
const defaultImage = jsx("img", {
|
|
76
|
+
src: defaultSrc,
|
|
77
|
+
alt: '',
|
|
78
|
+
style: {
|
|
79
|
+
objectFit: 'cover'
|
|
80
|
+
},
|
|
81
|
+
width: width,
|
|
82
|
+
height: height
|
|
83
|
+
});
|
|
84
|
+
const image = jsx(Fragment, null, !onLoaded && defaultImage, jsx("img", {
|
|
85
|
+
css: blurAnimationCSS,
|
|
86
|
+
src: srcState,
|
|
87
|
+
alt: alt || srcState,
|
|
88
|
+
style: {
|
|
89
|
+
objectFit: 'cover'
|
|
90
|
+
},
|
|
91
|
+
onLoad: () => setOnLoaded(true),
|
|
92
|
+
width: width,
|
|
93
|
+
height: height
|
|
94
|
+
}));
|
|
95
|
+
|
|
96
|
+
if (lazyLoading) {
|
|
97
|
+
return isInView ? image : defaultImage;
|
|
98
|
+
} else return image;
|
|
99
|
+
};
|
|
100
|
+
|
|
101
|
+
return useMemo(() => {
|
|
102
|
+
return jsx("div", {
|
|
103
|
+
ref: ref,
|
|
104
|
+
css: _ImageCSS,
|
|
105
|
+
id: id,
|
|
106
|
+
className: classNames('DGN-UI-Image', className),
|
|
107
|
+
style: style
|
|
108
|
+
}, renderImage());
|
|
109
|
+
}, [alt, circular, className, defaultSrc, height, id, lazyLoading, src, style, width, isInView, onLoaded, srcState]);
|
|
110
|
+
}));
|
|
111
|
+
|
|
112
|
+
const ImageCSS = (width, height, circular) => css`
|
|
113
|
+
${inlineFlex};
|
|
114
|
+
${positionRelative};
|
|
115
|
+
${alignCenter};
|
|
116
|
+
${overflowHidden};
|
|
117
|
+
${parseWidthHeight(width, height)};
|
|
118
|
+
${circular && `border-radius: 50%`};
|
|
119
|
+
`;
|
|
120
|
+
|
|
121
|
+
const blurAnimationCSS = css`
|
|
122
|
+
animation: ${blurKeyframe} 1s ease;
|
|
123
|
+
`;
|
|
124
|
+
Image.defaultProps = {
|
|
125
|
+
circular: false,
|
|
126
|
+
className: '',
|
|
127
|
+
height: 200,
|
|
128
|
+
lazyLoading: false,
|
|
129
|
+
style: {},
|
|
130
|
+
width: 200
|
|
131
|
+
};
|
|
132
|
+
Image.propTypes = {
|
|
133
|
+
/** Image description. */
|
|
134
|
+
alt: PropTypes.string,
|
|
135
|
+
|
|
136
|
+
/** If `true`, image is circular.*/
|
|
137
|
+
circular: PropTypes.bool,
|
|
138
|
+
|
|
139
|
+
/** Class for component. */
|
|
140
|
+
className: PropTypes.string,
|
|
141
|
+
|
|
142
|
+
/** Default img when src error. */
|
|
143
|
+
defaultSrc: PropTypes.string,
|
|
144
|
+
|
|
145
|
+
/** Height of component. */
|
|
146
|
+
height: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
|
|
147
|
+
|
|
148
|
+
/** If `true`, lazy loading image.*/
|
|
149
|
+
lazyLoading: PropTypes.bool,
|
|
150
|
+
|
|
151
|
+
/** Callback fired when the src is error. */
|
|
152
|
+
onError: PropTypes.func,
|
|
153
|
+
|
|
154
|
+
/** Image path. */
|
|
155
|
+
src: PropTypes.string,
|
|
156
|
+
|
|
157
|
+
/** Style inline of component. */
|
|
158
|
+
style: PropTypes.object,
|
|
159
|
+
|
|
160
|
+
/** Width of component. */
|
|
161
|
+
width: PropTypes.oneOfType([PropTypes.number, PropTypes.string])
|
|
162
|
+
};
|
|
163
|
+
export { Image };
|
|
164
|
+
export default OptionWrapper(Image);
|
package/components/index.js
CHANGED
|
@@ -64,7 +64,9 @@ export { default as Row } from './grid/Row';
|
|
|
64
64
|
export { default as Col } from './grid/Col';
|
|
65
65
|
export { default as Container } from './grid/Container'; //Icon
|
|
66
66
|
|
|
67
|
-
export { default as Icon } from '../icons/index'; //
|
|
67
|
+
export { default as Icon } from '../icons/index'; //Image
|
|
68
|
+
|
|
69
|
+
export { default as Image } from './image'; // List
|
|
68
70
|
|
|
69
71
|
export { default as List } from './list/list';
|
|
70
72
|
export { default as ListItem } from './list/list-item';
|