diginet-core-ui 1.3.33 → 1.3.34
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/avatar/default.svg +2 -2
- package/assets/images/menu/dhr/ALL.svg +6 -0
- package/assets/images/menu/dhr/D00.svg +12 -0
- package/assets/images/menu/dhr/D09.svg +8 -0
- package/assets/images/menu/dhr/D13.svg +10 -0
- package/assets/images/menu/dhr/D15.svg +10 -0
- package/assets/images/menu/dhr/D21.svg +10 -0
- package/assets/images/menu/dhr/D25.svg +11 -0
- package/assets/images/menu/dhr/D29.svg +11 -0
- package/assets/images/menu/dhr/D38.svg +6 -0
- package/assets/images/menu/dhr/D39.svg +10 -0
- package/assets/images/menu/dhr/D51.svg +12 -0
- package/assets/images/menu/dhr/D52.svg +16 -0
- package/assets/images/menu/dhr/D77.svg +16 -0
- package/assets/images/menu/dhr/D84.svg +12 -0
- package/assets/images/menu/dhr/D89.svg +8 -0
- package/components/avatar/index.js +153 -204
- package/components/badge/index.js +120 -80
- package/components/button/icon.js +193 -170
- package/components/button/index.js +16 -9
- package/components/button/ripple-effect.js +2 -0
- package/components/chip/index.js +139 -137
- package/components/form-control/dropdown/index.js +337 -316
- package/components/form-control/dropdown-box/index.js +3 -3
- package/components/form-control/toggle/index.js +5 -12
- package/components/typography/index.js +92 -47
- package/icons/basic.js +74 -0
- package/icons/effect.js +51 -23
- package/package.json +1 -1
- package/readme.md +21 -0
- package/styles/colors.js +2 -2
- package/styles/general.js +15 -2
package/components/chip/index.js
CHANGED
|
@@ -1,11 +1,36 @@
|
|
|
1
1
|
/** @jsxRuntime classic */
|
|
2
2
|
|
|
3
3
|
/** @jsx jsx */
|
|
4
|
-
import { memo, useRef, forwardRef, useEffect, useMemo } from 'react';
|
|
4
|
+
import { memo, useRef, forwardRef, useEffect, useMemo, useImperativeHandle } from 'react';
|
|
5
5
|
import PropTypes from 'prop-types';
|
|
6
6
|
import { jsx, css } from '@emotion/core';
|
|
7
7
|
import { ButtonIcon, Typography } from '../';
|
|
8
|
-
import
|
|
8
|
+
import Icon from '../../icons';
|
|
9
|
+
import { alignCenter, borderBox, flexRow, inlineFlex, justifyCenter, positionRelative, userSelectNone } from '../../styles/general';
|
|
10
|
+
import { color as colors } from '../../styles/colors';
|
|
11
|
+
import { darken } from '../../styles/color-helper';
|
|
12
|
+
const {
|
|
13
|
+
system: {
|
|
14
|
+
active,
|
|
15
|
+
rest,
|
|
16
|
+
white
|
|
17
|
+
},
|
|
18
|
+
semantic: {
|
|
19
|
+
danger
|
|
20
|
+
},
|
|
21
|
+
fill: {
|
|
22
|
+
disabled: fillDisabled,
|
|
23
|
+
hover: fillHover
|
|
24
|
+
},
|
|
25
|
+
line: {
|
|
26
|
+
normal,
|
|
27
|
+
disabled: lineDisabled
|
|
28
|
+
},
|
|
29
|
+
text: {
|
|
30
|
+
disabled: textDisabled
|
|
31
|
+
}
|
|
32
|
+
} = colors;
|
|
33
|
+
const iconSizeMap = new Map([['small', '12px'], ['medium', '16px']]);
|
|
9
34
|
const Chip = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
10
35
|
viewType,
|
|
11
36
|
color,
|
|
@@ -25,20 +50,17 @@ const Chip = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
25
50
|
readOnly,
|
|
26
51
|
children,
|
|
27
52
|
...props
|
|
28
|
-
},
|
|
29
|
-
|
|
30
|
-
ref = useRef(null);
|
|
31
|
-
}
|
|
32
|
-
|
|
53
|
+
}, reference) => {
|
|
54
|
+
const ref = useRef(null);
|
|
33
55
|
const IconRef = useRef(null);
|
|
34
56
|
const ChipIcon = css`
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
57
|
+
${flexRow}
|
|
58
|
+
${justifyCenter}
|
|
59
|
+
${alignCenter}
|
|
60
|
+
${positionRelative}
|
|
61
|
+
${borderBox}
|
|
39
62
|
padding: 0 2px;
|
|
40
63
|
color: inherit;
|
|
41
|
-
box-sizing: border-box;
|
|
42
64
|
img {
|
|
43
65
|
border-radius: 50%;
|
|
44
66
|
}
|
|
@@ -65,17 +87,14 @@ const Chip = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
65
87
|
height: 26px;
|
|
66
88
|
}
|
|
67
89
|
}
|
|
68
|
-
.clear-icon svg {
|
|
69
|
-
padding: 0 !important;
|
|
70
|
-
}
|
|
71
90
|
`;
|
|
72
91
|
const ChipLabel = css`
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
92
|
+
${flexRow}
|
|
93
|
+
${alignCenter}
|
|
94
|
+
${positionRelative}
|
|
95
|
+
${userSelectNone}
|
|
76
96
|
padding-right: ${endIcon || clearAble ? 2 : 10}px;
|
|
77
97
|
padding-left: ${startIcon ? 2 : 10}px;
|
|
78
|
-
user-select: none;
|
|
79
98
|
white-space: nowrap;
|
|
80
99
|
&.small {
|
|
81
100
|
max-height: 24px;
|
|
@@ -85,16 +104,16 @@ const Chip = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
85
104
|
}
|
|
86
105
|
`;
|
|
87
106
|
const ChipRoot = css`
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
107
|
+
${inlineFlex}
|
|
108
|
+
${alignCenter}
|
|
109
|
+
${positionRelative}
|
|
110
|
+
${borderBox}
|
|
91
111
|
width: max-content;
|
|
92
112
|
margin-right: 15px;
|
|
93
113
|
padding: 0 6px;
|
|
94
|
-
color: ${
|
|
95
|
-
background:
|
|
96
|
-
border: 1px solid ${
|
|
97
|
-
box-sizing: border-box;
|
|
114
|
+
color: ${rest};
|
|
115
|
+
background: ${white};
|
|
116
|
+
border: 1px solid ${normal};
|
|
98
117
|
border-radius: 20px;
|
|
99
118
|
cursor: ${onClick || onDbClick ? 'pointer' : 'unset'};
|
|
100
119
|
&.small {
|
|
@@ -106,74 +125,43 @@ const Chip = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
106
125
|
padding-bottom: 2px;
|
|
107
126
|
}
|
|
108
127
|
&:hover {
|
|
109
|
-
background: ${
|
|
110
|
-
border-color: ${
|
|
128
|
+
background: ${fillHover};
|
|
129
|
+
border-color: ${active};
|
|
111
130
|
}
|
|
112
|
-
&.disabled {
|
|
113
|
-
color: ${
|
|
114
|
-
background-color: ${
|
|
131
|
+
&.chip--disabled {
|
|
132
|
+
color: ${textDisabled} !important;
|
|
133
|
+
background-color: ${fillDisabled} !important;
|
|
134
|
+
border-color: ${lineDisabled} !important;
|
|
115
135
|
pointer-events: none !important;
|
|
116
136
|
.css-${ChipIcon.name} {
|
|
117
137
|
path {
|
|
118
|
-
fill: ${
|
|
138
|
+
fill: ${textDisabled} !important;
|
|
119
139
|
}
|
|
120
140
|
}
|
|
121
141
|
}
|
|
122
|
-
&.readOnly {
|
|
142
|
+
&.chip--readOnly {
|
|
123
143
|
cursor: unset !important;
|
|
124
144
|
.css-${ChipIcon.name} {
|
|
125
145
|
pointer-events: none !important;
|
|
126
146
|
}
|
|
127
147
|
}
|
|
128
148
|
&.outlined {
|
|
129
|
-
|
|
130
|
-
color: ${
|
|
131
|
-
border-color: ${
|
|
132
|
-
}
|
|
133
|
-
&.info {
|
|
134
|
-
color: ${theme.colors.info};
|
|
135
|
-
border-color: ${theme.colors.info5};
|
|
136
|
-
}
|
|
137
|
-
&.success {
|
|
138
|
-
color: ${theme.colors.success};
|
|
139
|
-
border-color: ${theme.colors.success};
|
|
140
|
-
}
|
|
141
|
-
&.warning {
|
|
142
|
-
color: ${theme.colors.warning};
|
|
143
|
-
border-color: ${theme.colors.warning};
|
|
144
|
-
}
|
|
145
|
-
&.danger {
|
|
146
|
-
color: ${theme.colors.danger};
|
|
147
|
-
border-color: ${theme.colors.danger};
|
|
149
|
+
&.${color} {
|
|
150
|
+
color: ${colors[color] || color};
|
|
151
|
+
border-color: ${colors[color] || color};
|
|
148
152
|
}
|
|
149
153
|
}
|
|
150
154
|
&.filled {
|
|
151
|
-
color:
|
|
155
|
+
color: ${white};
|
|
152
156
|
.clear-icon {
|
|
153
|
-
color:
|
|
157
|
+
color: ${white};
|
|
154
158
|
&:hover {
|
|
155
|
-
color: ${
|
|
159
|
+
color: ${danger};
|
|
156
160
|
}
|
|
157
161
|
}
|
|
158
|
-
|
|
159
|
-
background-color: ${
|
|
160
|
-
border-color:
|
|
161
|
-
}
|
|
162
|
-
&.info {
|
|
163
|
-
background-color: ${theme.colors.info5};
|
|
164
|
-
border-color: ${theme.colors.info5};
|
|
165
|
-
}
|
|
166
|
-
&.success {
|
|
167
|
-
background-color: ${theme.colors.success};
|
|
168
|
-
border-color: ${theme.colors.success6};
|
|
169
|
-
}
|
|
170
|
-
&.warning {
|
|
171
|
-
background-color: ${theme.colors.warning};
|
|
172
|
-
border-color: ${theme.colors.warning6};
|
|
173
|
-
}
|
|
174
|
-
&.danger {
|
|
175
|
-
background-color: ${theme.colors.danger};
|
|
176
|
-
border-color: ${theme.colors.danger6};
|
|
162
|
+
&.${color} {
|
|
163
|
+
background-color: ${colors[color] || color};
|
|
164
|
+
border-color: ${darken(colors[color] || color, 0.22)};
|
|
177
165
|
}
|
|
178
166
|
}
|
|
179
167
|
`;
|
|
@@ -185,9 +173,20 @@ const Chip = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
185
173
|
}, 0);
|
|
186
174
|
};
|
|
187
175
|
|
|
188
|
-
const
|
|
189
|
-
|
|
190
|
-
|
|
176
|
+
const _onClick = event => {
|
|
177
|
+
onClick && event.stopPropagation();
|
|
178
|
+
if (disabled || loading) return;
|
|
179
|
+
onClick && onClick(event);
|
|
180
|
+
};
|
|
181
|
+
|
|
182
|
+
const _onDbClick = event => {
|
|
183
|
+
(onDbClick || onDoubleClick) && event.stopPropagation();
|
|
184
|
+
if (disabled || loading) return;
|
|
185
|
+
|
|
186
|
+
if (onDbClick) {
|
|
187
|
+
onDbClick && onDbClick(event);
|
|
188
|
+
} else if (onDoubleClick) {
|
|
189
|
+
onDoubleClick && onDoubleClick(event);
|
|
191
190
|
}
|
|
192
191
|
};
|
|
193
192
|
|
|
@@ -202,74 +201,77 @@ const Chip = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
202
201
|
useEffect(() => {
|
|
203
202
|
if (refs) refs(ref);
|
|
204
203
|
}, []);
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
ref.current.classList.add(color);
|
|
209
|
-
}
|
|
204
|
+
useImperativeHandle(reference, () => {
|
|
205
|
+
const currentRef = ref.current || {};
|
|
206
|
+
const _instance = {}; // methods
|
|
210
207
|
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
if (
|
|
220
|
-
|
|
208
|
+
_instance.__proto__ = {}; // hidden methods
|
|
209
|
+
|
|
210
|
+
currentRef.instance = _instance;
|
|
211
|
+
return currentRef;
|
|
212
|
+
});
|
|
213
|
+
const startIconView = useMemo(() => {
|
|
214
|
+
let node = startIcon;
|
|
215
|
+
|
|
216
|
+
if (typeof node === 'string') {
|
|
217
|
+
node = jsx(Icon, {
|
|
218
|
+
name: node,
|
|
219
|
+
width: iconSizeMap.get(size),
|
|
220
|
+
height: iconSizeMap.get(size),
|
|
221
|
+
color: 'currentColor',
|
|
222
|
+
viewBox: false
|
|
223
|
+
});
|
|
221
224
|
}
|
|
222
225
|
|
|
223
|
-
return (
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
226
|
+
return jsx("div", {
|
|
227
|
+
css: ChipIcon,
|
|
228
|
+
className: size
|
|
229
|
+
}, node);
|
|
230
|
+
}, [startIcon, size]);
|
|
231
|
+
const labelView = useMemo(() => {
|
|
232
|
+
return jsx("div", {
|
|
233
|
+
css: ChipLabel,
|
|
234
|
+
className: size
|
|
235
|
+
}, jsx(Typography, {
|
|
236
|
+
type: size === 'small' ? 'p2' : 'p1',
|
|
237
|
+
color: 'inherit'
|
|
238
|
+
}, renderLabel()));
|
|
239
|
+
}, [label]);
|
|
240
|
+
const endIconView = useMemo(() => {
|
|
241
|
+
let node = endIcon;
|
|
242
|
+
|
|
243
|
+
if (typeof node === 'string') {
|
|
244
|
+
node = jsx(Icon, {
|
|
245
|
+
name: node,
|
|
246
|
+
width: iconSizeMap.get(size),
|
|
247
|
+
height: iconSizeMap.get(size),
|
|
248
|
+
color: 'currentColor',
|
|
249
|
+
viewBox: false
|
|
250
|
+
});
|
|
232
251
|
}
|
|
233
252
|
|
|
234
|
-
return (
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
}
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
color: 'inherit'
|
|
250
|
-
}, renderLabel())), [label]);
|
|
251
|
-
const endIconView = useMemo(() => clearAble ? jsx("div", {
|
|
252
|
-
css: ChipIcon,
|
|
253
|
-
className: 'end-icon ' + size,
|
|
254
|
-
ref: IconRef
|
|
255
|
-
}, jsx(ButtonIcon, {
|
|
256
|
-
viewType: 'ghost',
|
|
257
|
-
name: 'Close',
|
|
258
|
-
className: 'clear-icon',
|
|
259
|
-
color: viewType === 'outlined' && color ? 'inherit' : undefined,
|
|
260
|
-
onClick: onRemoveHandler
|
|
261
|
-
})) : endIcon && jsx("div", {
|
|
262
|
-
css: ChipIcon,
|
|
263
|
-
className: 'end-icon ' + size,
|
|
264
|
-
ref: IconRef
|
|
265
|
-
}, endIcon), [clearAble]);
|
|
253
|
+
return clearAble ? jsx("div", {
|
|
254
|
+
css: ChipIcon,
|
|
255
|
+
className: 'end-icon ' + size,
|
|
256
|
+
ref: IconRef
|
|
257
|
+
}, jsx(ButtonIcon, {
|
|
258
|
+
viewType: 'ghost',
|
|
259
|
+
name: 'Close',
|
|
260
|
+
color: viewType === 'outlined' && color ? 'inherit' : undefined,
|
|
261
|
+
onClick: onRemoveHandler
|
|
262
|
+
})) : endIcon && jsx("div", {
|
|
263
|
+
css: ChipIcon,
|
|
264
|
+
className: 'end-icon ' + size,
|
|
265
|
+
ref: IconRef
|
|
266
|
+
}, node);
|
|
267
|
+
}, [clearAble, endIcon, size]);
|
|
266
268
|
return jsx("div", {
|
|
267
269
|
css: ChipRoot,
|
|
268
270
|
ref: ref,
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
271
|
+
className: ['DGN-UI-Chip', size, className, color && color !== 'default' && color, color && color !== 'default' && viewType, disabled && 'chip--disabled', readOnly && 'chip--readOnly'].join(' ').trim().replace(/\s+/g, ' '),
|
|
272
|
+
onClick: _onClick,
|
|
273
|
+
onDoubleClick: _onDbClick,
|
|
274
|
+
...props
|
|
273
275
|
}, startIconView, labelView, endIconView, children);
|
|
274
276
|
}));
|
|
275
277
|
Chip.defaultProps = {
|