diginet-core-ui 1.3.49 → 1.3.51-beta.2
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/css.js +27 -30
- package/components/accordion/details.js +17 -15
- package/components/accordion/group.js +10 -10
- package/components/accordion/index.js +25 -21
- package/components/accordion/summary.js +28 -37
- package/components/alert/index.js +1 -1
- package/components/avatar/index.js +46 -32
- package/components/chip/index.js +1 -2
- package/components/form-control/checkbox/index.js +1 -1
- package/components/form-control/dropdown/index.js +84 -79
- package/components/form-control/input-base/index.js +33 -25
- package/components/modal/modal.js +4 -4
- package/components/popover/index.js +45 -17
- package/components/tree-view/css.js +1 -0
- package/components/typography/index.js +75 -68
- package/package.json +55 -35
- package/readme.md +8 -0
- package/styles/general.js +1 -1
- package/theme/make-styles.js +19 -2
- package/theme/theme-provider.js +2 -1
- package/utils/useDelayUnmount.js +19 -0
|
@@ -1,37 +1,37 @@
|
|
|
1
1
|
import { css } from '@emotion/core';
|
|
2
|
-
import
|
|
3
|
-
import {
|
|
4
|
-
import { alignCenter, backgroundTransparent, borderBox, borderRadius4px, breakWord, cursorPointer, displayInlineBlock, flexRow, flexRowReverse, inlineFlex, justifyBetween, justifyCenter, justifyEnd, pointerEventsNone, positionAbsolute, positionRelative, userSelectNone } from '../../styles/general';
|
|
2
|
+
import theme from '../../theme/settings';
|
|
3
|
+
import { alignCenter, alignStart, backgroundTransparent, borderBox, borderRadius4px, breakWord, cursorPointer, displayInlineBlock, flexRow, flexRowReverse, inlineFlex, justifyBetween, justifyCenter, justifyEnd, parseWidthHeight, pointerEventsNone, positionAbsolute, positionRelative, userSelectNone } from '../../styles/general';
|
|
5
4
|
const {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
5
|
+
colors: {
|
|
6
|
+
system: {
|
|
7
|
+
active,
|
|
8
|
+
disabled: systemDisabled
|
|
9
|
+
},
|
|
10
|
+
fill: {
|
|
11
|
+
disabled: fillDisabled,
|
|
12
|
+
headerbar,
|
|
13
|
+
focus,
|
|
14
|
+
hover,
|
|
15
|
+
pressed
|
|
16
|
+
}
|
|
12
17
|
},
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
}
|
|
20
|
-
} = colors;
|
|
21
|
-
export const SummaryRootCSS = css`
|
|
18
|
+
typography: {
|
|
19
|
+
heading3
|
|
20
|
+
},
|
|
21
|
+
spacing
|
|
22
|
+
} = theme;
|
|
23
|
+
export const SummaryRootCSS = background => css`
|
|
22
24
|
${flexRow};
|
|
23
25
|
${positionRelative};
|
|
24
26
|
${justifyBetween};
|
|
25
|
-
${
|
|
27
|
+
${alignStart};
|
|
26
28
|
${cursorPointer};
|
|
27
29
|
${borderBox};
|
|
28
30
|
${borderRadius4px};
|
|
29
31
|
width: 100%;
|
|
30
32
|
min-height: 56px;
|
|
31
|
-
padding:
|
|
32
|
-
|
|
33
|
-
background-color: ${headerbar};
|
|
34
|
-
}
|
|
33
|
+
padding: ${spacing(4)}px ${spacing(6)}px;
|
|
34
|
+
${background && `background-color: ${background === true ? headerbar : theme.colors[background] || background};`};
|
|
35
35
|
.Accordion-Expand-Icon,
|
|
36
36
|
.Accordion-Collapse-Icon {
|
|
37
37
|
${cursorPointer};
|
|
@@ -47,8 +47,7 @@ export const SummaryRootCSS = css`
|
|
|
47
47
|
${flexRow};
|
|
48
48
|
.Accordion-Icon.rotate-able {
|
|
49
49
|
${borderBox};
|
|
50
|
-
|
|
51
|
-
height: 24px;
|
|
50
|
+
${parseWidthHeight(24, 24)};
|
|
52
51
|
&:not(.TreeView) {
|
|
53
52
|
transform: rotateZ(0deg);
|
|
54
53
|
transform-origin: center;
|
|
@@ -62,7 +61,7 @@ export const SummaryRootCSS = css`
|
|
|
62
61
|
${flexRowReverse};
|
|
63
62
|
${justifyEnd};
|
|
64
63
|
.Accordion-Icon.rotate-able {
|
|
65
|
-
margin-right:
|
|
64
|
+
margin-right: ${spacing(2)}px;
|
|
66
65
|
&.TreeView {
|
|
67
66
|
transform: rotateZ(-90deg);
|
|
68
67
|
}
|
|
@@ -70,7 +69,7 @@ export const SummaryRootCSS = css`
|
|
|
70
69
|
}
|
|
71
70
|
&.end {
|
|
72
71
|
.Accordion-Icon.rotate-able {
|
|
73
|
-
margin-left:
|
|
72
|
+
margin-left: ${spacing(2)}px;
|
|
74
73
|
&.TreeView {
|
|
75
74
|
transform: rotateZ(90deg);
|
|
76
75
|
}
|
|
@@ -144,8 +143,7 @@ export const SummaryRootCSS = css`
|
|
|
144
143
|
${displayInlineBlock};
|
|
145
144
|
${positionRelative};
|
|
146
145
|
${cursorPointer};
|
|
147
|
-
|
|
148
|
-
height: 24px;
|
|
146
|
+
${parseWidthHeight(24, 24)};
|
|
149
147
|
transition: transform 200ms linear;
|
|
150
148
|
.Accordion-Expand-Icon {
|
|
151
149
|
transform: scale(1);
|
|
@@ -169,7 +167,6 @@ export const SummaryRootCSS = css`
|
|
|
169
167
|
max-width: 34px;
|
|
170
168
|
min-height: 24px;
|
|
171
169
|
max-height: 34px;
|
|
172
|
-
padding: 3px;
|
|
173
170
|
}
|
|
174
171
|
}
|
|
175
172
|
`;
|
|
@@ -5,16 +5,18 @@ import { memo, forwardRef, useRef, useMemo, useImperativeHandle } from 'react';
|
|
|
5
5
|
import PropTypes from 'prop-types';
|
|
6
6
|
import { jsx, css } from '@emotion/core';
|
|
7
7
|
import { borderBox, displayBlock, overflowHidden, pointerEventsNone, positionRelative, userSelectNone } from '../../styles/general';
|
|
8
|
-
import
|
|
9
|
-
import { color as colors } from '../../styles/colors';
|
|
8
|
+
import theme from '../../theme/settings';
|
|
10
9
|
const {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
10
|
+
colors: {
|
|
11
|
+
text: {
|
|
12
|
+
main
|
|
13
|
+
}
|
|
14
|
+
},
|
|
15
|
+
typography: {
|
|
16
|
+
paragraph1
|
|
17
|
+
},
|
|
18
|
+
spacing
|
|
19
|
+
} = theme;
|
|
18
20
|
const AccordionDetails = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
19
21
|
children,
|
|
20
22
|
className,
|
|
@@ -52,7 +54,7 @@ const DetailsRootCSS = css`
|
|
|
52
54
|
.DGN-UI-Accordion-Details-Content {
|
|
53
55
|
${borderBox};
|
|
54
56
|
${paragraph1};
|
|
55
|
-
padding: 0
|
|
57
|
+
padding: 0 ${spacing(6)}px ${spacing(4)}px ${spacing(6)}px;
|
|
56
58
|
color: ${main};
|
|
57
59
|
&.disabled {
|
|
58
60
|
${pointerEventsNone}
|
|
@@ -66,13 +68,13 @@ AccordionDetails.defaultProps = {
|
|
|
66
68
|
id: ''
|
|
67
69
|
};
|
|
68
70
|
AccordionDetails.propTypes = {
|
|
69
|
-
/** The
|
|
71
|
+
/** The content of the component. */
|
|
70
72
|
children: PropTypes.node,
|
|
71
73
|
|
|
72
|
-
/**
|
|
73
|
-
|
|
74
|
+
/** Style inline of component. */
|
|
75
|
+
style: PropTypes.object,
|
|
74
76
|
|
|
75
|
-
/**
|
|
76
|
-
|
|
77
|
+
/** Class for component. */
|
|
78
|
+
className: PropTypes.string
|
|
77
79
|
};
|
|
78
80
|
export default AccordionDetails;
|
|
@@ -41,10 +41,10 @@ const AccordionGroup = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
41
41
|
ref: ref,
|
|
42
42
|
style: style,
|
|
43
43
|
className: ['DGN-UI-Accordion-Group', className].join(' ').trim().replace(/\s+/g, ' ')
|
|
44
|
-
}, Children.map(children, child => /*#__PURE__*/cloneElement(child, {
|
|
44
|
+
}, Children.map(children, child => child && /*#__PURE__*/cloneElement(child, {
|
|
45
45
|
onExpand: e => onCollapseOther(e, child.props.onExpand)
|
|
46
46
|
})));
|
|
47
|
-
}, [className, children]);
|
|
47
|
+
}, [style, className, children]);
|
|
48
48
|
}));
|
|
49
49
|
const AccordionGroupRootCSS = css`
|
|
50
50
|
${borderRadius4px};
|
|
@@ -113,16 +113,16 @@ AccordionGroup.defaultProps = {
|
|
|
113
113
|
style: {}
|
|
114
114
|
};
|
|
115
115
|
AccordionGroup.propTypes = {
|
|
116
|
-
/**
|
|
117
|
-
|
|
116
|
+
/** The content of the component. */
|
|
117
|
+
children: PropTypes.node,
|
|
118
118
|
|
|
119
|
-
/**
|
|
120
|
-
|
|
119
|
+
/** Style inline of component. */
|
|
120
|
+
style: PropTypes.object,
|
|
121
121
|
|
|
122
|
-
/**
|
|
123
|
-
|
|
122
|
+
/** Class for component. */
|
|
123
|
+
className: PropTypes.string,
|
|
124
124
|
|
|
125
|
-
/**
|
|
126
|
-
|
|
125
|
+
/** If `true`, collapse other when expand */
|
|
126
|
+
collapseOther: PropTypes.bool
|
|
127
127
|
};
|
|
128
128
|
export default AccordionGroup;
|
|
@@ -7,13 +7,16 @@ import { jsx, css } from '@emotion/core';
|
|
|
7
7
|
import AccordionContext from './context';
|
|
8
8
|
import Divider from '../divider';
|
|
9
9
|
import { borderRadius4px, displayBlock, positionRelative } from '../../styles/general';
|
|
10
|
-
import
|
|
10
|
+
import theme from '../../theme/settings';
|
|
11
11
|
const {
|
|
12
|
-
|
|
13
|
-
|
|
12
|
+
colors: {
|
|
13
|
+
line: {
|
|
14
|
+
category
|
|
15
|
+
}
|
|
14
16
|
}
|
|
15
|
-
} =
|
|
17
|
+
} = theme;
|
|
16
18
|
const Accordion = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
19
|
+
id,
|
|
17
20
|
disabled,
|
|
18
21
|
expand,
|
|
19
22
|
expanded,
|
|
@@ -57,6 +60,7 @@ const Accordion = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
57
60
|
});
|
|
58
61
|
return useMemo(() => {
|
|
59
62
|
return jsx("div", {
|
|
63
|
+
id: id,
|
|
60
64
|
css: AccordionRootCSS,
|
|
61
65
|
ref: ref,
|
|
62
66
|
style: style,
|
|
@@ -78,7 +82,7 @@ const Accordion = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
78
82
|
display: 'none'
|
|
79
83
|
}
|
|
80
84
|
})));
|
|
81
|
-
}, [disabled, className, boxShadow, onClick, children, expanded, onExpand, onCollapse, expandState]);
|
|
85
|
+
}, [id, disabled, className, boxShadow, onClick, children, expanded, onExpand, onCollapse, expandState]);
|
|
82
86
|
}));
|
|
83
87
|
const AccordionRootCSS = css`
|
|
84
88
|
${displayBlock};
|
|
@@ -102,31 +106,31 @@ Accordion.defaultProps = {
|
|
|
102
106
|
style: {}
|
|
103
107
|
};
|
|
104
108
|
Accordion.propTypes = {
|
|
105
|
-
/**
|
|
109
|
+
/** The content of the component (insist <AccordionSummary />, <AccordionDetails />). */
|
|
110
|
+
children: PropTypes.node,
|
|
111
|
+
|
|
112
|
+
/** Style inline of component. */
|
|
113
|
+
style: PropTypes.object,
|
|
114
|
+
|
|
115
|
+
/** Class for component. */
|
|
116
|
+
className: PropTypes.string,
|
|
117
|
+
|
|
118
|
+
/** If `true`, the component is disabled. */
|
|
106
119
|
disabled: PropTypes.bool,
|
|
107
120
|
|
|
108
|
-
/** expand immediate after render
|
|
121
|
+
/** If `true`, expand immediate after render (shouldn't use this). */
|
|
109
122
|
expand: PropTypes.bool,
|
|
110
123
|
|
|
111
|
-
/**
|
|
124
|
+
/** Expand state of accordion (should use this). */
|
|
112
125
|
expanded: PropTypes.bool,
|
|
113
126
|
|
|
114
|
-
/**
|
|
115
|
-
className: PropTypes.string,
|
|
116
|
-
|
|
117
|
-
/** class on element */
|
|
127
|
+
/** The box-shadow of component. */
|
|
118
128
|
boxShadow: PropTypes.oneOfType([PropTypes.string, PropTypes.bool]),
|
|
119
129
|
|
|
120
|
-
/**
|
|
130
|
+
/** Callback fired when Accordion is expanded. */
|
|
121
131
|
onExpand: PropTypes.func,
|
|
122
132
|
|
|
123
|
-
/**
|
|
124
|
-
onCollapse: PropTypes.func
|
|
125
|
-
|
|
126
|
-
/** insist <AccordionSummary />, <AccordionDetails /> */
|
|
127
|
-
children: PropTypes.node,
|
|
128
|
-
|
|
129
|
-
/** style inline of component */
|
|
130
|
-
style: PropTypes.object
|
|
133
|
+
/** Callback fired when Accordion is collapsed. */
|
|
134
|
+
onCollapse: PropTypes.func
|
|
131
135
|
};
|
|
132
136
|
export default Accordion;
|
|
@@ -8,6 +8,7 @@ import { renderIcon } from '../../utils';
|
|
|
8
8
|
import { SummaryRootCSS } from './css';
|
|
9
9
|
import AccordionContext from './context';
|
|
10
10
|
const AccordionSummary = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
11
|
+
id,
|
|
11
12
|
expandIcon,
|
|
12
13
|
collapseIcon,
|
|
13
14
|
expandIconAt,
|
|
@@ -18,9 +19,6 @@ const AccordionSummary = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
18
19
|
expandIconProps,
|
|
19
20
|
style
|
|
20
21
|
}, reference) => {
|
|
21
|
-
const ref = useRef(null);
|
|
22
|
-
const expandIconRef = useRef(null);
|
|
23
|
-
const timer = useRef(null);
|
|
24
22
|
const {
|
|
25
23
|
expanded,
|
|
26
24
|
expandState,
|
|
@@ -30,8 +28,13 @@ const AccordionSummary = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
30
28
|
onCollapse,
|
|
31
29
|
setExpandState
|
|
32
30
|
} = useContext(AccordionContext);
|
|
31
|
+
const ref = useRef(null);
|
|
32
|
+
const expandIconRef = useRef(null);
|
|
33
|
+
const timer = useRef(null);
|
|
33
34
|
|
|
34
|
-
const
|
|
35
|
+
const _SummaryRootCSS = SummaryRootCSS(background);
|
|
36
|
+
|
|
37
|
+
const _onClick = e => {
|
|
35
38
|
if (!disabled) {
|
|
36
39
|
const target = e.target;
|
|
37
40
|
|
|
@@ -93,19 +96,6 @@ const AccordionSummary = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
93
96
|
}
|
|
94
97
|
};
|
|
95
98
|
|
|
96
|
-
useEffect(() => {
|
|
97
|
-
if (/^(#|rgb)/.test(background)) {
|
|
98
|
-
if (ref.current) {
|
|
99
|
-
ref.current.style.backgroundColor = background;
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
return () => {
|
|
103
|
-
if (ref.current) {
|
|
104
|
-
ref.current.style.backgroundColor = null;
|
|
105
|
-
}
|
|
106
|
-
};
|
|
107
|
-
}
|
|
108
|
-
}, [background]);
|
|
109
99
|
useEffect(() => {
|
|
110
100
|
if (expandState) {
|
|
111
101
|
showHideDetailHandler('show');
|
|
@@ -124,19 +114,20 @@ const AccordionSummary = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
124
114
|
});
|
|
125
115
|
return useMemo(() => {
|
|
126
116
|
return jsx("div", {
|
|
127
|
-
|
|
117
|
+
id: id,
|
|
118
|
+
css: _SummaryRootCSS,
|
|
128
119
|
ref: ref,
|
|
129
120
|
tabIndex: "-1",
|
|
130
|
-
onClick:
|
|
121
|
+
onClick: _onClick,
|
|
131
122
|
style: style,
|
|
132
|
-
className: ['DGN-UI-Accordion-Summary', disabled ? 'disabled' : '', expandIcon ? expandIconAt : '',
|
|
123
|
+
className: ['DGN-UI-Accordion-Summary', disabled ? 'disabled' : '', expandIcon ? expandIconAt : '', expandState ? 'expanding' : '', className].join(' ').trim().replace(/\s+/g, ' ')
|
|
133
124
|
}, jsx("div", {
|
|
134
125
|
className: 'DGN-UI-Accordion-Summary-Content'
|
|
135
126
|
}, children), !!expandIcon && jsx("div", {
|
|
136
127
|
className: 'Accordion-Icon-Root'
|
|
137
128
|
}, jsx("div", { ...expandIconProps,
|
|
138
129
|
ref: expandIconRef,
|
|
139
|
-
className: ['Accordion-Icon', collapseIcon ? '' : 'rotate-able', expandIconProps.className ? expandIconProps.className : ''].join(' ').trim()
|
|
130
|
+
className: ['Accordion-Icon', collapseIcon ? '' : 'rotate-able', expandIconProps.className ? expandIconProps.className : ''].join(' ').trim().replace(/\s+/g, ' ')
|
|
140
131
|
}, typeof expandIcon === 'string' ? renderIcon(expandIcon, 'effect', {
|
|
141
132
|
className: 'Accordion-Expand-Icon'
|
|
142
133
|
}) : jsx("span", {
|
|
@@ -146,7 +137,7 @@ const AccordionSummary = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
146
137
|
}) : jsx("span", {
|
|
147
138
|
className: 'Accordion-Collapse-Icon effect'
|
|
148
139
|
}, collapseIcon)))));
|
|
149
|
-
}, [expandIcon, expandIconAt, className, background, children, collapseIcon, expandIconProps, expandState]);
|
|
140
|
+
}, [id, expandIcon, expandIconAt, className, background, children, collapseIcon, expandIconProps, expandState]);
|
|
150
141
|
}));
|
|
151
142
|
AccordionSummary.defaultProps = {
|
|
152
143
|
expandIconAt: 'start',
|
|
@@ -156,28 +147,28 @@ AccordionSummary.defaultProps = {
|
|
|
156
147
|
style: {}
|
|
157
148
|
};
|
|
158
149
|
AccordionSummary.propTypes = {
|
|
159
|
-
/**
|
|
150
|
+
/** The content of the component. */
|
|
151
|
+
children: PropTypes.node,
|
|
152
|
+
|
|
153
|
+
/** Style inline of component. */
|
|
154
|
+
style: PropTypes.object,
|
|
155
|
+
|
|
156
|
+
/** Class for component. */
|
|
157
|
+
className: PropTypes.string,
|
|
158
|
+
|
|
159
|
+
/** Icon display for expand icon. */
|
|
160
160
|
expandIcon: PropTypes.any,
|
|
161
161
|
|
|
162
|
-
/**
|
|
162
|
+
/** Icon display for collapse icon. */
|
|
163
163
|
collapseIcon: PropTypes.any,
|
|
164
164
|
|
|
165
|
-
/**
|
|
165
|
+
/** Position to render icon. */
|
|
166
166
|
expandIconAt: PropTypes.oneOf(['start', 'end']),
|
|
167
167
|
|
|
168
|
-
/**
|
|
168
|
+
/** Background for label summary. */
|
|
169
169
|
background: PropTypes.oneOfType([PropTypes.string, PropTypes.bool]),
|
|
170
170
|
|
|
171
|
-
/**
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
/** The element to display in alert like text props (priority) */
|
|
175
|
-
children: PropTypes.node,
|
|
176
|
-
|
|
177
|
-
/** props of expand and collapse icons */
|
|
178
|
-
expandIconProps: PropTypes.any,
|
|
179
|
-
|
|
180
|
-
/** style inline of component */
|
|
181
|
-
style: PropTypes.object
|
|
171
|
+
/** Other props of icons. */
|
|
172
|
+
expandIconProps: PropTypes.any
|
|
182
173
|
};
|
|
183
174
|
export default AccordionSummary;
|
|
@@ -10,8 +10,8 @@ import ButtonIcon from '../button/icon';
|
|
|
10
10
|
import Icon from '../../icons';
|
|
11
11
|
import { hexToRGBA } from '../../styles/color-helper';
|
|
12
12
|
import { typography } from '../../styles/typography';
|
|
13
|
-
import { alignCenter, border, borderBox, borderRadius4px, breakWord, displayBlock, flexRow, justifyStart, positionRelative, userSelectNone } from '../../styles/general';
|
|
14
13
|
import { useTheme } from '../../theme';
|
|
14
|
+
import { alignCenter, border, borderBox, borderRadius4px, breakWord, displayBlock, flexRow, justifyStart, positionRelative, userSelectNone } from '../../styles/general';
|
|
15
15
|
const {
|
|
16
16
|
heading3,
|
|
17
17
|
heading4,
|
|
@@ -12,18 +12,22 @@ 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';
|
|
14
14
|
import isMobile from '../../utils/isMobile';
|
|
15
|
-
import
|
|
15
|
+
import theme from '../../theme/settings';
|
|
16
16
|
const {
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
17
|
+
colors: {
|
|
18
|
+
system: {
|
|
19
|
+
white
|
|
20
|
+
},
|
|
21
|
+
fill: {
|
|
22
|
+
tooltip: fillTooltip
|
|
23
|
+
},
|
|
24
|
+
text: {
|
|
25
|
+
tooltip: textTooltip
|
|
26
|
+
}
|
|
22
27
|
},
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
} = colors;
|
|
28
|
+
spacing,
|
|
29
|
+
zIndex: zIndexCORE
|
|
30
|
+
} = theme;
|
|
27
31
|
const existed = {},
|
|
28
32
|
urlAvatar = {},
|
|
29
33
|
popupHandler = {};
|
|
@@ -34,6 +38,18 @@ const blurKeyframe = keyframes`
|
|
|
34
38
|
75% { -webkit-filter: blur(1px);}
|
|
35
39
|
100% { -webkit-filter: blur(0px);}
|
|
36
40
|
`;
|
|
41
|
+
|
|
42
|
+
const checkFileType = (type, matchType) => {
|
|
43
|
+
if (typeof matchType === 'object' && matchType instanceof RegExp) {
|
|
44
|
+
return matchType.test(type);
|
|
45
|
+
} else if (typeof matchType === 'object' && Array.isArray(matchType)) {
|
|
46
|
+
const pattern = new RegExp('^image/(' + matchType.join('|') + ')', 'i');
|
|
47
|
+
return pattern.test(type);
|
|
48
|
+
} else {
|
|
49
|
+
return new RegExp(matchType).test(type);
|
|
50
|
+
}
|
|
51
|
+
};
|
|
52
|
+
|
|
37
53
|
const Avatar = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
38
54
|
src,
|
|
39
55
|
defaultSrc,
|
|
@@ -56,7 +72,9 @@ const Avatar = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
56
72
|
readOnly,
|
|
57
73
|
disabled,
|
|
58
74
|
lazyLoading,
|
|
59
|
-
id
|
|
75
|
+
id,
|
|
76
|
+
allowEdit,
|
|
77
|
+
onClick
|
|
60
78
|
}, reference) => {
|
|
61
79
|
if (!defaultSrc) defaultSrc = AvatarDefault;
|
|
62
80
|
const ref = useRef(null);
|
|
@@ -94,23 +112,12 @@ const Avatar = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
94
112
|
}
|
|
95
113
|
};
|
|
96
114
|
|
|
97
|
-
const checkFileType = type => {
|
|
98
|
-
if (typeof matchType === 'object' && matchType instanceof RegExp) {
|
|
99
|
-
return matchType.test(type);
|
|
100
|
-
} else if (typeof matchType === 'object' && Array.isArray(matchType)) {
|
|
101
|
-
const pattern = new RegExp('^image/(' + matchType.join('|') + ')', 'i');
|
|
102
|
-
return pattern.test(type);
|
|
103
|
-
} else {
|
|
104
|
-
return new RegExp(matchType).test(type);
|
|
105
|
-
}
|
|
106
|
-
};
|
|
107
|
-
|
|
108
115
|
const onChangeAvatar = input => {
|
|
109
116
|
const [file] = input.target.files;
|
|
110
117
|
if (!file) return;
|
|
111
118
|
const reader = new FileReader();
|
|
112
119
|
|
|
113
|
-
if (!checkFileType(file.type)) {
|
|
120
|
+
if (!checkFileType(file.type, matchType)) {
|
|
114
121
|
input.target.value = '';
|
|
115
122
|
popupHandler[unique].show(wrongTypeError);
|
|
116
123
|
return;
|
|
@@ -194,12 +201,15 @@ const Avatar = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
194
201
|
if (hoverAble) setViewMoreInfo(false);
|
|
195
202
|
};
|
|
196
203
|
|
|
197
|
-
const _onClick =
|
|
204
|
+
const _onClick = event => {
|
|
205
|
+
onClick && event.stopPropagation();
|
|
198
206
|
if (disabled) return;
|
|
199
207
|
|
|
200
208
|
if (readOnly) {
|
|
201
209
|
if (_isMobile) showMoreInfo();
|
|
202
|
-
} else
|
|
210
|
+
} else {
|
|
211
|
+
allowEdit ? triggerInput() : onClick === null || onClick === void 0 ? void 0 : onClick(event);
|
|
212
|
+
}
|
|
203
213
|
};
|
|
204
214
|
|
|
205
215
|
const _onMouseEnter = () => {
|
|
@@ -264,7 +274,7 @@ const Avatar = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
264
274
|
onMouseLeave: _onMouseLeave,
|
|
265
275
|
tabIndex: "-1",
|
|
266
276
|
onBlur: closeMoreInfo
|
|
267
|
-
}, renderImage())), !readOnly && !disabled && jsx("span", {
|
|
277
|
+
}, renderImage())), allowEdit && !readOnly && !disabled && jsx("span", {
|
|
268
278
|
css: _ActionIconCSS
|
|
269
279
|
}, jsx(ButtonIcon, {
|
|
270
280
|
viewType: 'ghost',
|
|
@@ -315,7 +325,7 @@ const Avatar = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
315
325
|
icon: 'danger',
|
|
316
326
|
fullScreen: true
|
|
317
327
|
}));
|
|
318
|
-
}, [width, height, readOnly, disabled, clearAble, maxSize, matchType, hoverAble, outlined, actionIconWidth, actionIconHeight, lazyLoading, defaultSrc, direction, data, maxSizeError, srcState, isInView, onLoaded, viewAvatar, viewMoreInfo]);
|
|
328
|
+
}, [width, height, readOnly, disabled, clearAble, maxSize, matchType, hoverAble, outlined, actionIconWidth, actionIconHeight, lazyLoading, defaultSrc, direction, data, maxSizeError, allowEdit, srcState, isInView, onLoaded, viewAvatar, viewMoreInfo]);
|
|
319
329
|
}));
|
|
320
330
|
|
|
321
331
|
const ActionIconCSS = actionIconWidth => css`
|
|
@@ -325,7 +335,7 @@ const ActionIconCSS = actionIconWidth => css`
|
|
|
325
335
|
min-width: ${actionIconWidth}px;
|
|
326
336
|
transition: opacity 0.5s;
|
|
327
337
|
opacity: 0;
|
|
328
|
-
z-index:
|
|
338
|
+
z-index: ${zIndexCORE(2)};
|
|
329
339
|
`;
|
|
330
340
|
|
|
331
341
|
const AvatarPreviewCSS = readOnly => css`
|
|
@@ -380,12 +390,13 @@ const AvatarRootCSS = (width, height, outlined) => css`
|
|
|
380
390
|
const MoreInfoCSS = css`
|
|
381
391
|
${displayBlock};
|
|
382
392
|
${positionRelative};
|
|
383
|
-
padding:
|
|
393
|
+
padding: ${spacing([2])};
|
|
384
394
|
`;
|
|
385
395
|
const blurAnimationCSS = css`
|
|
386
396
|
animation: ${blurKeyframe} 1s ease;
|
|
387
397
|
`;
|
|
388
398
|
Avatar.defaultProps = {
|
|
399
|
+
allowEdit: false,
|
|
389
400
|
disabled: false,
|
|
390
401
|
readOnly: false,
|
|
391
402
|
clearAble: true,
|
|
@@ -404,6 +415,9 @@ Avatar.defaultProps = {
|
|
|
404
415
|
lazyLoading: false
|
|
405
416
|
};
|
|
406
417
|
Avatar.propTypes = {
|
|
418
|
+
/** If `true`, allow to edit avatar. */
|
|
419
|
+
allowEdit: PropTypes.bool,
|
|
420
|
+
|
|
407
421
|
/** prevent all events, only view */
|
|
408
422
|
disabled: PropTypes.bool,
|
|
409
423
|
|
|
@@ -470,12 +484,12 @@ Avatar.propTypes = {
|
|
|
470
484
|
/** will run after change avatar */
|
|
471
485
|
onChange: PropTypes.func,
|
|
472
486
|
|
|
487
|
+
/** Callback fired when the component is clicked. */
|
|
488
|
+
onClick: PropTypes.func,
|
|
489
|
+
|
|
473
490
|
/** lazy loading */
|
|
474
491
|
lazyLoading: PropTypes.bool,
|
|
475
492
|
|
|
476
|
-
/** any props else */
|
|
477
|
-
props: PropTypes.any,
|
|
478
|
-
|
|
479
493
|
/**
|
|
480
494
|
* ref methods
|
|
481
495
|
*
|
package/components/chip/index.js
CHANGED
|
@@ -114,8 +114,7 @@ const Chip = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
114
114
|
className: size
|
|
115
115
|
}, jsx(Typography, {
|
|
116
116
|
type: size === 'small' ? 'p2' : 'p1',
|
|
117
|
-
color: 'inherit'
|
|
118
|
-
lineClamp: 1
|
|
117
|
+
color: 'inherit'
|
|
119
118
|
}, renderLabel()));
|
|
120
119
|
}, [label, size, startIcon, endIcon, clearAble]);
|
|
121
120
|
const endIconView = useMemo(() => {
|