diginet-core-ui 1.3.45 → 1.3.46
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/MHRM09N1025.svg +12 -0
- package/components/avatar/index.js +138 -187
- package/components/form-control/dropdown/index.js +54 -49
- package/components/form-control/radio/index.js +126 -113
- package/components/typography/index.js +18 -74
- package/package.json +1 -1
- package/readme.md +10 -0
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
<svg width="39" height="39" viewBox="0 0 39 39" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
2
|
+
<path d="M30.7901 28.13C30.7901 27.5 30.2701 26.99 29.6401 26.99H19.2301C18.5901 26.99 18.0801 27.5 18.0801 28.13C18.0801 28.76 18.6001 29.27 19.2301 29.27H29.6401C30.2701 29.27 30.7901 28.76 30.7901 28.13Z" fill="#FF8C00"/>
|
|
3
|
+
<path d="M29.6401 22.41H19.2301C18.5901 22.41 18.0801 22.92 18.0801 23.55C18.0801 24.18 18.6001 24.69 19.2301 24.69H29.6401C30.2801 24.69 30.7901 24.18 30.7901 23.55C30.7901 22.92 30.2701 22.41 29.6401 22.41Z" fill="#FF8C00"/>
|
|
4
|
+
<path d="M19.2301 31.56C18.5901 31.56 18.0801 32.07 18.0801 32.7C18.0801 33.33 18.6001 33.84 19.2301 33.84H25.0201C25.6601 33.84 26.1701 33.33 26.1701 32.7C26.1701 32.07 25.6501 31.56 25.0201 31.56H19.2301Z" fill="#FF8C00"/>
|
|
5
|
+
<path d="M10.0601 25.8101H11.2001V23.5701H10.2401V22.8501C10.8601 22.7501 11.1701 22.6401 11.5201 22.4301H12.3901V25.8201H13.3301V26.7601H10.0601V25.8101Z" fill="#FF8C00"/>
|
|
6
|
+
<path d="M14.8801 25.9401C14.8801 25.4501 15.2401 25.0501 15.7801 25.0501C16.3201 25.0501 16.6801 25.4501 16.6801 25.9401C16.6801 26.4301 16.3201 26.8301 15.7801 26.8301C15.2401 26.8301 14.8801 26.4301 14.8801 25.9401Z" fill="#FF8C00"/>
|
|
7
|
+
<path d="M9.92011 33.17C11.0901 32.23 11.9401 31.5 11.9401 30.91C11.9401 30.52 11.6901 30.34 11.3001 30.34C10.9801 30.34 10.7201 30.55 10.4901 30.75L9.86011 30.12C10.3401 29.64 10.7801 29.42 11.4701 29.42C12.4101 29.42 13.0601 29.98 13.0601 30.84C13.0601 31.54 12.3301 32.3 11.6101 32.9C11.8501 32.87 12.1801 32.85 12.4001 32.85H13.2801V33.83H9.92011V33.17Z" fill="#FF8C00"/>
|
|
8
|
+
<path d="M14.8801 33.03C14.8801 32.54 15.2401 32.14 15.7801 32.14C16.3201 32.14 16.6801 32.54 16.6801 33.03C16.6801 33.52 16.3201 33.92 15.7801 33.92C15.2401 33.92 14.8801 33.53 14.8801 33.03Z" fill="#FF8C00"/>
|
|
9
|
+
<path d="M34.74 9.52L25.35 0.26C25.17 0.1 24.93 0 24.7 0H8.26C6.47 0 5 1.45 5 3.22V35.78C5 37.55 6.47 39 8.26 39H31.73C33.53 39 34.99 37.55 34.99 35.78V10.16C35 9.93 34.9 9.69 34.74 9.52ZM25.61 3.09L26.05 3.52L31.42 8.82L31.86 9.26H27.03C26.25 9.26 25.6 8.63 25.6 7.85V3.09H25.61ZM33.16 35.78C33.16 36.56 32.52 37.19 31.73 37.19H8.26C7.48 37.19 6.83 36.56 6.83 35.78V3.22C6.83 2.44 7.47 1.81 8.26 1.81H23.77V7.85C23.77 9.62 25.24 11.07 27.03 11.07H31.22L32.9 11.06H33.16V35.78Z" fill="#2680EB"/>
|
|
10
|
+
<path d="M13.6299 9.34994C13.1999 8.87994 13.2199 8.14994 13.6899 7.71994L15.6799 5.85994C15.7899 5.75994 15.9199 5.67994 16.0599 5.61994C16.4999 5.44994 16.9899 5.56994 17.3099 5.90994L17.6599 6.28994C17.8699 6.50994 17.9099 6.82994 17.7999 7.08994L14.7799 9.91994C14.4999 10.0199 14.1899 9.93994 13.9899 9.72994L13.6299 9.34994ZM20.5499 10.0499C20.5399 10.0399 20.5499 10.0399 20.5499 10.0499L17.5299 12.8599C17.5299 12.8599 17.5299 12.8599 17.5399 12.8699C17.4299 13.1299 17.4699 13.4499 17.6799 13.6699L18.0299 14.0499C18.3499 14.3899 18.8399 14.5099 19.2799 14.3399C19.4199 14.2899 19.5499 14.2099 19.6599 14.0999L21.6499 12.2399C22.1099 11.8099 22.1399 11.0799 21.6999 10.6199L21.3499 10.2399C21.1299 10.0199 20.8299 9.94994 20.5499 10.0499ZM16.3199 12.6799C16.3799 12.6599 16.4299 12.6199 16.4799 12.5799L16.5799 12.4899C16.7199 12.5999 16.8999 12.6299 17.0699 12.5699C17.0999 12.5599 17.1199 12.5499 17.1499 12.5299L20.2399 9.64994C20.2999 9.56994 20.3399 9.46994 20.3399 9.36994C20.3399 9.23994 20.2999 9.10994 20.2099 9.01994L18.8099 7.51994C18.6399 7.33994 18.3699 7.31994 18.1799 7.44994L15.1299 10.2899C15.0599 10.3699 15.0099 10.4799 15.0099 10.5899C15.0099 10.6999 15.0399 10.7999 15.0999 10.8899L14.9999 10.9799C14.8999 11.0699 14.8499 11.1899 14.8399 11.3199C14.8399 11.4099 14.8599 11.4899 14.8999 11.5699L13.4399 12.9399C13.3899 12.9199 13.3399 12.9099 13.2899 12.9099C13.1599 12.9099 13.0299 12.9499 12.9399 13.0399L9.15988 16.5699C8.95988 16.7499 8.94988 17.0699 9.13988 17.2599L9.81988 17.9999C9.90988 18.0899 10.0299 18.1499 10.1599 18.1599C10.2299 18.1599 10.2899 18.1499 10.3499 18.1299C10.4099 18.1099 10.4599 18.0699 10.5099 18.0299L14.2899 14.4999C14.4299 14.3699 14.4799 14.1799 14.4299 13.9999L15.8899 12.6299C15.9599 12.6799 16.0499 12.6999 16.1399 12.7099C16.1899 12.7099 16.2599 12.6999 16.3199 12.6799Z" fill="#FF4444"/>
|
|
11
|
+
<path d="M21.4599 16.6599H15.0699C14.7699 16.6599 14.5299 16.8999 14.5299 17.1999V18.0199C14.5299 18.3199 14.7699 18.5599 15.0699 18.5599H21.4599C21.7599 18.5599 21.9999 18.3199 21.9999 18.0199V17.1999C21.9999 16.8999 21.7599 16.6599 21.4599 16.6599Z" fill="#FF4444"/>
|
|
12
|
+
</svg>
|
|
@@ -27,59 +27,6 @@ const {
|
|
|
27
27
|
const existed = {},
|
|
28
28
|
urlAvatar = {},
|
|
29
29
|
popupHandler = {};
|
|
30
|
-
|
|
31
|
-
const getDirection = direction => {
|
|
32
|
-
switch (direction) {
|
|
33
|
-
case 'top':
|
|
34
|
-
return {
|
|
35
|
-
anchorOrigin: {
|
|
36
|
-
vertical: 'top',
|
|
37
|
-
horizontal: 'center'
|
|
38
|
-
},
|
|
39
|
-
transformOrigin: {
|
|
40
|
-
vertical: 'bottom',
|
|
41
|
-
horizontal: 'center'
|
|
42
|
-
}
|
|
43
|
-
};
|
|
44
|
-
|
|
45
|
-
case 'left':
|
|
46
|
-
return {
|
|
47
|
-
anchorOrigin: {
|
|
48
|
-
vertical: 'center',
|
|
49
|
-
horizontal: 'left'
|
|
50
|
-
},
|
|
51
|
-
transformOrigin: {
|
|
52
|
-
vertical: 'center',
|
|
53
|
-
horizontal: 'right'
|
|
54
|
-
}
|
|
55
|
-
};
|
|
56
|
-
|
|
57
|
-
case 'right':
|
|
58
|
-
return {
|
|
59
|
-
anchorOrigin: {
|
|
60
|
-
vertical: 'center',
|
|
61
|
-
horizontal: 'right'
|
|
62
|
-
},
|
|
63
|
-
transformOrigin: {
|
|
64
|
-
vertical: 'center',
|
|
65
|
-
horizontal: 'left'
|
|
66
|
-
}
|
|
67
|
-
};
|
|
68
|
-
|
|
69
|
-
default:
|
|
70
|
-
return {
|
|
71
|
-
anchorOrigin: {
|
|
72
|
-
vertical: 'bottom',
|
|
73
|
-
horizontal: 'center'
|
|
74
|
-
},
|
|
75
|
-
transformOrigin: {
|
|
76
|
-
vertical: 'top',
|
|
77
|
-
horizontal: 'center'
|
|
78
|
-
}
|
|
79
|
-
};
|
|
80
|
-
}
|
|
81
|
-
};
|
|
82
|
-
|
|
83
30
|
const blurKeyframe = keyframes`
|
|
84
31
|
0% { -webkit-filter: blur(4px);}
|
|
85
32
|
25% { -webkit-filter: blur(3px);}
|
|
@@ -109,7 +56,7 @@ const Avatar = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
109
56
|
readOnly,
|
|
110
57
|
disabled,
|
|
111
58
|
lazyLoading,
|
|
112
|
-
|
|
59
|
+
id
|
|
113
60
|
}, reference) => {
|
|
114
61
|
if (!defaultSrc) defaultSrc = AvatarDefault;
|
|
115
62
|
const ref = useRef(null);
|
|
@@ -128,6 +75,14 @@ const Avatar = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
128
75
|
setIsInView(true);
|
|
129
76
|
});
|
|
130
77
|
|
|
78
|
+
const _ActionIconCSS = ActionIconCSS(actionIconWidth);
|
|
79
|
+
|
|
80
|
+
const _AvatarPreviewCSS = AvatarPreviewCSS(readOnly);
|
|
81
|
+
|
|
82
|
+
const _AvatarContainerCSS = AvatarContainerCSS(_AvatarPreviewCSS.name, _ActionIconCSS.name);
|
|
83
|
+
|
|
84
|
+
const _AvatarRootCSS = AvatarRootCSS(width, height, outlined);
|
|
85
|
+
|
|
131
86
|
const _isMobile = isMobile.any();
|
|
132
87
|
|
|
133
88
|
const triggerInput = e => {
|
|
@@ -204,36 +159,31 @@ const Avatar = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
204
159
|
};
|
|
205
160
|
|
|
206
161
|
const renderImage = () => {
|
|
162
|
+
const _image = jsx(Fragment, null, !onLoaded && jsx("img", {
|
|
163
|
+
src: defaultSrc,
|
|
164
|
+
alt: '',
|
|
165
|
+
style: {
|
|
166
|
+
objectFit: 'cover'
|
|
167
|
+
}
|
|
168
|
+
}), jsx("img", {
|
|
169
|
+
css: blurAnimationCSS,
|
|
170
|
+
src: srcState,
|
|
171
|
+
alt: srcState,
|
|
172
|
+
style: {
|
|
173
|
+
objectFit: 'cover'
|
|
174
|
+
},
|
|
175
|
+
onLoad: () => setOnLoaded(true)
|
|
176
|
+
}));
|
|
177
|
+
|
|
207
178
|
if (lazyLoading) {
|
|
208
|
-
return isInView ?
|
|
209
|
-
src:
|
|
210
|
-
alt: '',
|
|
211
|
-
style: {
|
|
212
|
-
objectFit: 'cover'
|
|
213
|
-
}
|
|
214
|
-
}), jsx("img", {
|
|
215
|
-
css: blurAnimation,
|
|
216
|
-
src: srcState || defaultSrc,
|
|
217
|
-
alt: srcState || defaultSrc,
|
|
218
|
-
style: {
|
|
219
|
-
objectFit: 'cover'
|
|
220
|
-
},
|
|
221
|
-
onLoad: () => setOnLoaded(true)
|
|
222
|
-
})) : jsx("img", {
|
|
223
|
-
src: AvatarDefault,
|
|
179
|
+
return isInView ? _image : jsx("img", {
|
|
180
|
+
src: defaultSrc,
|
|
224
181
|
alt: '',
|
|
225
182
|
style: {
|
|
226
183
|
objectFit: 'cover'
|
|
227
184
|
}
|
|
228
185
|
});
|
|
229
|
-
} else return
|
|
230
|
-
css: blurAnimation,
|
|
231
|
-
src: srcState || defaultSrc,
|
|
232
|
-
alt: srcState || defaultSrc,
|
|
233
|
-
style: {
|
|
234
|
-
objectFit: 'cover'
|
|
235
|
-
}
|
|
236
|
-
});
|
|
186
|
+
} else return _image;
|
|
237
187
|
};
|
|
238
188
|
|
|
239
189
|
const showMoreInfo = () => {
|
|
@@ -268,16 +218,19 @@ const Avatar = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
268
218
|
urlAvatar[unique] = src;
|
|
269
219
|
img.src = src;
|
|
270
220
|
img.alt = '';
|
|
271
|
-
setSrcState(src);
|
|
272
|
-
existed[unique] = true;
|
|
273
221
|
|
|
274
222
|
img.onerror = () => {
|
|
275
223
|
setSrcState(null);
|
|
276
224
|
existed[unique] = false;
|
|
277
225
|
};
|
|
226
|
+
|
|
227
|
+
img.onload = () => {
|
|
228
|
+
setSrcState(src);
|
|
229
|
+
existed[unique] = true;
|
|
230
|
+
};
|
|
278
231
|
}
|
|
279
232
|
}
|
|
280
|
-
}, [src
|
|
233
|
+
}, [src]);
|
|
281
234
|
useImperativeHandle(reference, () => {
|
|
282
235
|
const currentRef = ref.current || {};
|
|
283
236
|
const _instance = {}; // methods
|
|
@@ -287,89 +240,87 @@ const Avatar = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
287
240
|
currentRef.instance = _instance;
|
|
288
241
|
return currentRef;
|
|
289
242
|
});
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
}), [maxSizeError]);
|
|
367
|
-
return jsx(Fragment, null, AvatarView, ModalView, hoverAble && MoreInfoView, !disabled && !readOnly && PopupView);
|
|
243
|
+
return useMemo(() => {
|
|
244
|
+
return jsx(Fragment, null, jsx("div", {
|
|
245
|
+
css: _AvatarContainerCSS,
|
|
246
|
+
ref: ref,
|
|
247
|
+
id: unique,
|
|
248
|
+
className: disabled ? 'disabled' : ''
|
|
249
|
+
}, jsx("div", {
|
|
250
|
+
css: _AvatarRootCSS,
|
|
251
|
+
className: ['DGN-UI-Avatar', className].join(' ').trim().replace(/\s+/g, ' '),
|
|
252
|
+
id: id
|
|
253
|
+
}, jsx("input", {
|
|
254
|
+
ref: inputRef,
|
|
255
|
+
type: "file",
|
|
256
|
+
title: '',
|
|
257
|
+
accept: 'image/*',
|
|
258
|
+
onChange: onChangeAvatar
|
|
259
|
+
}), jsx("div", {
|
|
260
|
+
css: _AvatarPreviewCSS,
|
|
261
|
+
onClick: _onClick,
|
|
262
|
+
ref: avatarRef,
|
|
263
|
+
onMouseEnter: _onMouseEnter,
|
|
264
|
+
onMouseLeave: _onMouseLeave,
|
|
265
|
+
tabIndex: "-1",
|
|
266
|
+
onBlur: closeMoreInfo
|
|
267
|
+
}, renderImage())), !readOnly && !disabled && jsx("span", {
|
|
268
|
+
css: _ActionIconCSS
|
|
269
|
+
}, jsx(ButtonIcon, {
|
|
270
|
+
viewType: 'ghost',
|
|
271
|
+
name: 'Edit',
|
|
272
|
+
width: actionIconWidth,
|
|
273
|
+
height: actionIconHeight,
|
|
274
|
+
className: 'icon-edit',
|
|
275
|
+
onClick: triggerInput
|
|
276
|
+
}), clearAble && srcState && jsx(ButtonIcon, {
|
|
277
|
+
viewType: 'ghost',
|
|
278
|
+
name: 'Delete',
|
|
279
|
+
width: actionIconWidth,
|
|
280
|
+
height: actionIconHeight,
|
|
281
|
+
className: 'icon-delete',
|
|
282
|
+
onClick: onRemoveAvatar,
|
|
283
|
+
style: {
|
|
284
|
+
marginTop: '8px'
|
|
285
|
+
}
|
|
286
|
+
}))), jsx(ModalSample, {
|
|
287
|
+
open: viewAvatar,
|
|
288
|
+
onClose: () => setViewAvatar(false),
|
|
289
|
+
width: 'max-content'
|
|
290
|
+
}, jsx("img", {
|
|
291
|
+
src: urlAvatar[unique],
|
|
292
|
+
alt: "",
|
|
293
|
+
style: {
|
|
294
|
+
objectFit: 'cover',
|
|
295
|
+
maxHeight: '100%',
|
|
296
|
+
maxWidth: '100%',
|
|
297
|
+
margin: 'auto',
|
|
298
|
+
display: 'block'
|
|
299
|
+
}
|
|
300
|
+
})), hoverAble && jsx(Popover, {
|
|
301
|
+
arrow: true,
|
|
302
|
+
open: viewMoreInfo,
|
|
303
|
+
pressESCToClose: false,
|
|
304
|
+
bgColor: fillTooltip,
|
|
305
|
+
anchor: avatarRef,
|
|
306
|
+
fullScreen: false,
|
|
307
|
+
width: 'max-content',
|
|
308
|
+
direction: direction
|
|
309
|
+
}, jsx("div", {
|
|
310
|
+
css: MoreInfoCSS
|
|
311
|
+
}, typeof data === 'function' ? data() : renderData())), !disabled && !readOnly && jsx(Popup, {
|
|
312
|
+
getPopup: func => popupHandler[unique] = func,
|
|
313
|
+
type: 'info',
|
|
314
|
+
title: maxSizeError,
|
|
315
|
+
icon: 'danger',
|
|
316
|
+
fullScreen: true
|
|
317
|
+
}));
|
|
318
|
+
}, [width, height, readOnly, disabled, clearAble, maxSize, matchType, hoverAble, outlined, actionIconWidth, actionIconHeight, lazyLoading, defaultSrc, direction, data, maxSizeError, srcState, isInView, onLoaded, viewAvatar, viewMoreInfo]);
|
|
368
319
|
}));
|
|
369
320
|
|
|
370
|
-
const
|
|
371
|
-
${flexCol}
|
|
372
|
-
${positionAbsolute}
|
|
321
|
+
const ActionIconCSS = actionIconWidth => css`
|
|
322
|
+
${flexCol};
|
|
323
|
+
${positionAbsolute};
|
|
373
324
|
right: ${-actionIconWidth}px;
|
|
374
325
|
min-width: ${actionIconWidth}px;
|
|
375
326
|
transition: opacity 0.5s;
|
|
@@ -377,48 +328,48 @@ const ActionIcon = actionIconWidth => css`
|
|
|
377
328
|
z-index: 9002;
|
|
378
329
|
`;
|
|
379
330
|
|
|
380
|
-
const
|
|
381
|
-
${displayBlock}
|
|
382
|
-
${positionRelative}
|
|
383
|
-
${overflowHidden}
|
|
331
|
+
const AvatarPreviewCSS = readOnly => css`
|
|
332
|
+
${displayBlock};
|
|
333
|
+
${positionRelative};
|
|
334
|
+
${overflowHidden};
|
|
384
335
|
width: 100%;
|
|
385
336
|
height: 100%;
|
|
386
337
|
border-radius: 50%;
|
|
387
338
|
cursor: ${readOnly ? 'initial' : 'pointer'};
|
|
388
339
|
`;
|
|
389
340
|
|
|
390
|
-
const
|
|
391
|
-
${inlineFlex}
|
|
392
|
-
${positionRelative}
|
|
393
|
-
${alignCenter}
|
|
341
|
+
const AvatarContainerCSS = (AvatarPreviewCSSName, ActionIconCSSName) => css`
|
|
342
|
+
${inlineFlex};
|
|
343
|
+
${positionRelative};
|
|
344
|
+
${alignCenter};
|
|
394
345
|
&.disabled {
|
|
395
|
-
.css-${
|
|
346
|
+
.css-${AvatarPreviewCSSName} {
|
|
396
347
|
${pointerEventsNone}
|
|
397
348
|
cursor: inherit;
|
|
398
349
|
}
|
|
399
|
-
.css-${
|
|
350
|
+
.css-${ActionIconCSSName} {
|
|
400
351
|
display: none !important;
|
|
401
352
|
}
|
|
402
353
|
}
|
|
403
354
|
&:hover {
|
|
404
|
-
.css-${
|
|
355
|
+
.css-${ActionIconCSSName} {
|
|
405
356
|
opacity: 1;
|
|
406
357
|
}
|
|
407
358
|
}
|
|
408
359
|
`;
|
|
409
360
|
|
|
410
|
-
const
|
|
411
|
-
${displayBlock}
|
|
412
|
-
${positionRelative}
|
|
413
|
-
${overflowHidden}
|
|
414
|
-
${userSelectNone}
|
|
415
|
-
${borderNone}
|
|
416
|
-
${parseWidthHeight(width, height)}
|
|
361
|
+
const AvatarRootCSS = (width, height, outlined) => css`
|
|
362
|
+
${displayBlock};
|
|
363
|
+
${positionRelative};
|
|
364
|
+
${overflowHidden};
|
|
365
|
+
${userSelectNone};
|
|
366
|
+
${borderNone};
|
|
367
|
+
${parseWidthHeight(width, height)};
|
|
417
368
|
border: ${typeof outlined === 'boolean' && outlined ? `1px solid ${white}` : outlined};
|
|
418
369
|
border-radius: 50%;
|
|
419
370
|
box-sizing: content-box;
|
|
420
371
|
input {
|
|
421
|
-
${displayNone}
|
|
372
|
+
${displayNone};
|
|
422
373
|
}
|
|
423
374
|
img {
|
|
424
375
|
width: 100%;
|
|
@@ -426,12 +377,12 @@ const AvatarRoot = (width, height, outlined) => css`
|
|
|
426
377
|
}
|
|
427
378
|
`;
|
|
428
379
|
|
|
429
|
-
const
|
|
430
|
-
${displayBlock}
|
|
431
|
-
${positionRelative}
|
|
380
|
+
const MoreInfoCSS = css`
|
|
381
|
+
${displayBlock};
|
|
382
|
+
${positionRelative};
|
|
432
383
|
padding: 8px;
|
|
433
384
|
`;
|
|
434
|
-
const
|
|
385
|
+
const blurAnimationCSS = css`
|
|
435
386
|
animation: ${blurKeyframe} 1s ease;
|
|
436
387
|
`;
|
|
437
388
|
Avatar.defaultProps = {
|
|
@@ -445,7 +396,7 @@ Avatar.defaultProps = {
|
|
|
445
396
|
actionIconWidth: 24,
|
|
446
397
|
actionIconHeight: 24,
|
|
447
398
|
className: '',
|
|
448
|
-
direction: '
|
|
399
|
+
direction: 'bottom',
|
|
449
400
|
maxSizeError: `File ${getGlobal(['errorDefault', 'maxSize'])}`,
|
|
450
401
|
wrongTypeError: `File ${getGlobal(['errorDefault', 'fileType'])}`,
|
|
451
402
|
matchType: /^image\/(gif|jpe?g|tiff?|png|webp|bmp|svg(\+xml)?)$/i,
|
|
@@ -505,7 +456,7 @@ Avatar.propTypes = {
|
|
|
505
456
|
defaultSrc: PropTypes.string,
|
|
506
457
|
|
|
507
458
|
/** the direction to display more info */
|
|
508
|
-
direction: PropTypes.oneOf(['top', '
|
|
459
|
+
direction: PropTypes.oneOf(['top', 'bottom', 'left', 'right']),
|
|
509
460
|
|
|
510
461
|
/**
|
|
511
462
|
* data to display when hoverAble is true<br />
|
|
@@ -105,6 +105,7 @@ const Dropdown = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
105
105
|
children,
|
|
106
106
|
dropdownItemStyle
|
|
107
107
|
}, reference) => {
|
|
108
|
+
if (multiple && selectBox === undefined) selectBox = true;
|
|
108
109
|
const dropdownRef = useRef(null);
|
|
109
110
|
const timerRef = useRef(null);
|
|
110
111
|
const formRef = useRef(null);
|
|
@@ -169,14 +170,6 @@ const Dropdown = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
169
170
|
}
|
|
170
171
|
|
|
171
172
|
setOpenState(true);
|
|
172
|
-
setTimeout(() => {
|
|
173
|
-
showDropdown();
|
|
174
|
-
setTimeout(() => {
|
|
175
|
-
if (children && boxRef.current && boxRef.current.querySelector('input')) {
|
|
176
|
-
boxRef.current.querySelector('input').focus();
|
|
177
|
-
}
|
|
178
|
-
}, 10);
|
|
179
|
-
}, timing[unique + 'Box'] ? 200 : 0);
|
|
180
173
|
}
|
|
181
174
|
} else if (multiple || itemMode === 'treeview') {
|
|
182
175
|
if (searchRef.current) {
|
|
@@ -607,7 +600,7 @@ const Dropdown = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
607
600
|
}
|
|
608
601
|
|
|
609
602
|
const dropdownItem = document.createElement('div');
|
|
610
|
-
dropdownItem.className = `css-${_DropdownItemCSS.name}`;
|
|
603
|
+
dropdownItem.className = `DGN-UI-Dropdown-Item css-${_DropdownItemCSS.name}`;
|
|
611
604
|
dropdownItem.tabIndex = -1;
|
|
612
605
|
dropdownItem.addEventListener('click', () => onChangeValue(displayText, value, icon, data, i));
|
|
613
606
|
dropdownItem.addEventListener('keypress', e => {
|
|
@@ -952,6 +945,11 @@ const Dropdown = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
952
945
|
|
|
953
946
|
e && e.target && e.target.blur();
|
|
954
947
|
updatePositionDropdown();
|
|
948
|
+
onInput === null || onInput === void 0 ? void 0 : onInput({ ...(inputRef === null || inputRef === void 0 ? void 0 : inputRef.current),
|
|
949
|
+
target: {
|
|
950
|
+
value: inputRef === null || inputRef === void 0 ? void 0 : inputRef.current.value
|
|
951
|
+
}
|
|
952
|
+
});
|
|
955
953
|
!!onChange && onChange({
|
|
956
954
|
value: currentValue[unique]
|
|
957
955
|
});
|
|
@@ -1035,7 +1033,7 @@ const Dropdown = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
1035
1033
|
}
|
|
1036
1034
|
|
|
1037
1035
|
if (!isSearch[unique]) {
|
|
1038
|
-
inputRef.current.value =
|
|
1036
|
+
inputRef.current.value = source;
|
|
1039
1037
|
}
|
|
1040
1038
|
}
|
|
1041
1039
|
};
|
|
@@ -1130,13 +1128,18 @@ const Dropdown = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
1130
1128
|
|
|
1131
1129
|
currentRef.showDropdown = () => showDropdown();
|
|
1132
1130
|
|
|
1133
|
-
currentRef.onClear = onClear
|
|
1131
|
+
currentRef.onClear = onClear;
|
|
1132
|
+
currentRef.setPreviousValue = setPreviousValue;
|
|
1133
|
+
|
|
1134
|
+
currentRef.setValue = value => {
|
|
1134
1135
|
if (allValue[unique][allValue[unique].length - 1] !== value) {
|
|
1135
1136
|
allValue[unique].push(value);
|
|
1136
1137
|
}
|
|
1137
1138
|
|
|
1138
1139
|
setValueIntoInput(value);
|
|
1139
|
-
}
|
|
1140
|
+
};
|
|
1141
|
+
|
|
1142
|
+
currentRef.DOM = dropdownRef.current;
|
|
1140
1143
|
return currentRef;
|
|
1141
1144
|
});
|
|
1142
1145
|
useEffect(() => {
|
|
@@ -1298,7 +1301,6 @@ const Dropdown = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
1298
1301
|
!!onLoadMore && dataSource.length < total && boxRef.current.addEventListener('scroll', onLoadMoreHandler);
|
|
1299
1302
|
} else {
|
|
1300
1303
|
isSearch[unique] = false;
|
|
1301
|
-
renderDropdown();
|
|
1302
1304
|
}
|
|
1303
1305
|
} else {
|
|
1304
1306
|
if (!multiple && !disabled && !readOnly) {
|
|
@@ -1406,6 +1408,9 @@ const Dropdown = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
1406
1408
|
...errorStyle
|
|
1407
1409
|
}
|
|
1408
1410
|
}, error), [error, disabled, errorStyle]);
|
|
1411
|
+
const dropdownComp = useMemo(() => {
|
|
1412
|
+
return openState ? /*#__PURE__*/createPortal(showDropdown(), document.body) : null;
|
|
1413
|
+
}, [openState, dataSource]);
|
|
1409
1414
|
/* End component */
|
|
1410
1415
|
|
|
1411
1416
|
return jsx(Fragment, null, jsx("div", {
|
|
@@ -1413,7 +1418,7 @@ const Dropdown = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
1413
1418
|
css: DropdownRootCSS(viewType, multiple, placeholder, itemMultipleSize, renderSelectedItem, loading, showClear),
|
|
1414
1419
|
className: ['DGN-UI-Dropdown', className, error && 'error', loading && 'dgn-dropdown-loading', disabled ? 'disabled' : readOnly && 'readOnly'].join(' ').trim().replace(/\s+/g, ' '),
|
|
1415
1420
|
style: style
|
|
1416
|
-
}, labelComp, inputComp, errorComp),
|
|
1421
|
+
}, labelComp, inputComp, errorComp), dropdownComp);
|
|
1417
1422
|
}));
|
|
1418
1423
|
/* Start styled */
|
|
1419
1424
|
|
|
@@ -1756,7 +1761,7 @@ Dropdown.defaultProps = {
|
|
|
1756
1761
|
required: false,
|
|
1757
1762
|
multiple: false,
|
|
1758
1763
|
allowSearch: false,
|
|
1759
|
-
|
|
1764
|
+
closeAfterSelect: true,
|
|
1760
1765
|
inputProps: {},
|
|
1761
1766
|
formStyle: {},
|
|
1762
1767
|
dataSource: [],
|
|
@@ -1796,14 +1801,14 @@ Dropdown.propTypes = {
|
|
|
1796
1801
|
/** display this icon if not found the icon follow iconExpr */
|
|
1797
1802
|
iconDefault: PropTypes.string,
|
|
1798
1803
|
|
|
1799
|
-
/** field name used for icon display<br/>
|
|
1800
|
-
* Example:<br/>
|
|
1801
|
-
* string: 'icon'<br/>
|
|
1802
|
-
* object: {<br/>
|
|
1803
|
-
* key: 'icon',<br/>
|
|
1804
|
-
* prefix: 'https://imglink.com',<br/>
|
|
1805
|
-
* suffix: '.jpg'<br/>
|
|
1806
|
-
* }
|
|
1804
|
+
/** field name used for icon display<br/>
|
|
1805
|
+
* Example:<br/>
|
|
1806
|
+
* string: 'icon'<br/>
|
|
1807
|
+
* object: {<br/>
|
|
1808
|
+
* key: 'icon',<br/>
|
|
1809
|
+
* prefix: 'https://imglink.com',<br/>
|
|
1810
|
+
* suffix: '.jpg'<br/>
|
|
1811
|
+
* }
|
|
1807
1812
|
*/
|
|
1808
1813
|
iconExpr: PropTypes.oneOfType([PropTypes.string, PropTypes.shape({
|
|
1809
1814
|
key: PropTypes.string,
|
|
@@ -1821,9 +1826,9 @@ Dropdown.propTypes = {
|
|
|
1821
1826
|
/** field name used for text display in input */
|
|
1822
1827
|
keyExpr: PropTypes.oneOfType([PropTypes.string, PropTypes.number, PropTypes.array]),
|
|
1823
1828
|
|
|
1824
|
-
/** field name used for text display<br/>
|
|
1825
|
-
* Example: 'name', '{id} - {name}', '{age} age(s)'<br/>
|
|
1826
|
-
* Note: don't use 'id - name', return undefined
|
|
1829
|
+
/** field name used for text display<br/>
|
|
1830
|
+
* Example: 'name', '{id} - {name}', '{age} age(s)'<br/>
|
|
1831
|
+
* Note: don't use 'id - name', return undefined
|
|
1827
1832
|
*/
|
|
1828
1833
|
displayExpr: PropTypes.oneOfType([PropTypes.string, PropTypes.number, PropTypes.array]),
|
|
1829
1834
|
|
|
@@ -1833,9 +1838,9 @@ Dropdown.propTypes = {
|
|
|
1833
1838
|
/** the field name used for the returned result */
|
|
1834
1839
|
valueExpr: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
|
|
1835
1840
|
|
|
1836
|
-
/**
|
|
1837
|
-
* duration wait enter search content on search<br/>
|
|
1838
|
-
* Example: 700 -> 700ms, '700ms' -> 700ms, '0.7s' -> 700ms, '1m' -> 60000ms
|
|
1841
|
+
/**
|
|
1842
|
+
* duration wait enter search content on search<br/>
|
|
1843
|
+
* Example: 700 -> 700ms, '700ms' -> 700ms, '0.7s' -> 700ms, '1m' -> 60000ms
|
|
1839
1844
|
*/
|
|
1840
1845
|
searchDelayTime: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
|
|
1841
1846
|
|
|
@@ -1902,19 +1907,19 @@ Dropdown.propTypes = {
|
|
|
1902
1907
|
/** The array of elements that appear in the dropdown */
|
|
1903
1908
|
dataSource: PropTypes.array,
|
|
1904
1909
|
|
|
1905
|
-
/** function displays items by custom<br/>
|
|
1906
|
-
* renderItem={(data, index) => data.name + ' - ' + data.role}<br/>
|
|
1907
|
-
* --> such as: displayExpr={'name - role'}
|
|
1910
|
+
/** function displays items by custom<br/>
|
|
1911
|
+
* renderItem={(data, index) => data.name + ' - ' + data.role}<br/>
|
|
1912
|
+
* --> such as: displayExpr={'name - role'}
|
|
1908
1913
|
*/
|
|
1909
1914
|
renderItem: PropTypes.func,
|
|
1910
1915
|
|
|
1911
|
-
/** function displays selected items by custom, example:<br/>
|
|
1912
|
-
* renderItem={(data, index) => index + ' - ' + data.name}<br/>
|
|
1916
|
+
/** function displays selected items by custom, example:<br/>
|
|
1917
|
+
* renderItem={(data, index) => index + ' - ' + data.name}<br/>
|
|
1913
1918
|
*/
|
|
1914
1919
|
renderSelectedItem: PropTypes.func,
|
|
1915
1920
|
|
|
1916
|
-
/** the function will run when entering input<br/>
|
|
1917
|
-
* if undefined: the filter function will run (default)
|
|
1921
|
+
/** the function will run when entering input<br/>
|
|
1922
|
+
* if undefined: the filter function will run (default)
|
|
1918
1923
|
*/
|
|
1919
1924
|
onInput: PropTypes.func,
|
|
1920
1925
|
|
|
@@ -1933,19 +1938,19 @@ Dropdown.propTypes = {
|
|
|
1933
1938
|
/** the contents in Dropdown box (Exp: TreeView) */
|
|
1934
1939
|
children: PropTypes.node,
|
|
1935
1940
|
|
|
1936
|
-
/**
|
|
1937
|
-
* ref methods
|
|
1938
|
-
*
|
|
1939
|
-
* how to get component element? ref.current
|
|
1940
|
-
*
|
|
1941
|
-
* how to call method? ref.current.instance.{method}
|
|
1942
|
-
*
|
|
1943
|
-
* * showDropdown(): Show dropdown
|
|
1944
|
-
* * closeDropdown(): Close dropdown
|
|
1945
|
-
* * onClear(): Clear selected value
|
|
1946
|
-
* * setPreviousValue(): Set value to previous value
|
|
1947
|
-
* * setValue(value): Set value of dropdown
|
|
1948
|
-
* * @param {value} - string || number || array
|
|
1941
|
+
/**
|
|
1942
|
+
* ref methods
|
|
1943
|
+
*
|
|
1944
|
+
* how to get component element? ref.current
|
|
1945
|
+
*
|
|
1946
|
+
* how to call method? ref.current.instance.{method}
|
|
1947
|
+
*
|
|
1948
|
+
* * showDropdown(): Show dropdown
|
|
1949
|
+
* * closeDropdown(): Close dropdown
|
|
1950
|
+
* * onClear(): Clear selected value
|
|
1951
|
+
* * setPreviousValue(): Set value to previous value
|
|
1952
|
+
* * setValue(value): Set value of dropdown
|
|
1953
|
+
* * @param {value} - string || number || array
|
|
1949
1954
|
*/
|
|
1950
1955
|
reference: PropTypes.oneOfType([PropTypes.func, PropTypes.shape({
|
|
1951
1956
|
current: PropTypes.instanceOf(Element)
|
|
@@ -3,11 +3,11 @@
|
|
|
3
3
|
/** @jsx jsx */
|
|
4
4
|
import { css, jsx } from '@emotion/core';
|
|
5
5
|
import PropTypes from 'prop-types';
|
|
6
|
-
import { forwardRef, memo, useState, useRef } from 'react';
|
|
6
|
+
import { forwardRef, memo, useState, useRef, useEffect, useMemo } from 'react';
|
|
7
7
|
import theme from '../../../theme/settings';
|
|
8
8
|
import { randomString } from '../../../utils';
|
|
9
9
|
import Typography from './../../typography';
|
|
10
|
-
import { cursorPointer, borderBox, positionAbsolute, positionRelative, displayNone, displayBlock,
|
|
10
|
+
import { cursorPointer, borderBox, positionAbsolute, positionRelative, displayNone, displayBlock, cursorNoDrop } from '../../../styles/general';
|
|
11
11
|
const {
|
|
12
12
|
spacing,
|
|
13
13
|
colors: {
|
|
@@ -24,6 +24,7 @@ const {
|
|
|
24
24
|
const Radio = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
25
25
|
id,
|
|
26
26
|
disabled,
|
|
27
|
+
readOnly,
|
|
27
28
|
name,
|
|
28
29
|
defaultChecked,
|
|
29
30
|
checked,
|
|
@@ -34,8 +35,7 @@ const Radio = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
34
35
|
onChange,
|
|
35
36
|
inputRef,
|
|
36
37
|
inputProps,
|
|
37
|
-
|
|
38
|
-
hoverTooltip,
|
|
38
|
+
labelProps,
|
|
39
39
|
...props
|
|
40
40
|
}, ref) => {
|
|
41
41
|
if (!inputRef) {
|
|
@@ -46,127 +46,140 @@ const Radio = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
46
46
|
allowNumber: false,
|
|
47
47
|
allowSymbol: false
|
|
48
48
|
}));
|
|
49
|
-
const
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
}
|
|
55
|
-
`;
|
|
56
|
-
const formCheckInput = css`
|
|
57
|
-
${positionAbsolute};
|
|
58
|
-
${borderBox};
|
|
59
|
-
${displayNone};
|
|
60
|
-
&:hover ~ label::before {
|
|
61
|
-
box-shadow: 0 0 0 2px ${clFillHover};
|
|
62
|
-
background: ${clFillHover};
|
|
63
|
-
}
|
|
64
|
-
&:checked ~ label:after {
|
|
65
|
-
${borderBox};
|
|
66
|
-
${positionAbsolute};
|
|
67
|
-
width: ${width / 2}px;
|
|
68
|
-
height: ${width / 2}px;
|
|
69
|
-
left: ${width / 4}px;
|
|
70
|
-
background: ${clSystemActive};
|
|
71
|
-
border-radius: 50%;
|
|
72
|
-
top: 50%;
|
|
73
|
-
transform: translateY(-50%);
|
|
74
|
-
content: '';
|
|
75
|
-
transition: 0.28s ease;
|
|
76
|
-
}
|
|
77
|
-
&:checked ~ label:before {
|
|
78
|
-
border-color: ${clSystemActive};
|
|
79
|
-
}
|
|
80
|
-
&:disabled + label {
|
|
81
|
-
${pointerEventsNone};
|
|
82
|
-
${cursorNotAllowed};
|
|
83
|
-
color: ${clDisabled};
|
|
84
|
-
&::after {
|
|
85
|
-
background: ${clDisabled};
|
|
86
|
-
}
|
|
87
|
-
&::before {
|
|
88
|
-
border-color: ${clDisabled};
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
`;
|
|
92
|
-
const formCheckLabel = css`
|
|
93
|
-
${displayBlock};
|
|
94
|
-
${positionRelative};
|
|
95
|
-
${cursorPointer};
|
|
96
|
-
padding-left: ${width + spacing(1.5)}px;
|
|
97
|
-
min-height: ${width}px;
|
|
98
|
-
margin: 2px;
|
|
99
|
-
&:before {
|
|
100
|
-
${positionAbsolute};
|
|
101
|
-
${borderBox};
|
|
102
|
-
width: ${width}px;
|
|
103
|
-
height: ${width}px;
|
|
104
|
-
border-radius: 50%;
|
|
105
|
-
top: 50%;
|
|
106
|
-
transform: translateY(-50%);
|
|
107
|
-
left: 0;
|
|
108
|
-
content: '';
|
|
109
|
-
border: 2px solid ${clSystemRest};
|
|
110
|
-
transition: 0.28s ease;
|
|
111
|
-
}
|
|
112
|
-
`;
|
|
49
|
+
const [checkedState, setCheckedState] = useState(Boolean(checked !== undefined ? checked : defaultChecked));
|
|
50
|
+
|
|
51
|
+
const _formCheckInputCSS = formCheckInputCSS(width);
|
|
52
|
+
|
|
53
|
+
const _formCheckLabelCSS = formCheckLabelCSS(width);
|
|
113
54
|
|
|
114
55
|
const handleChange = e => {
|
|
115
|
-
|
|
56
|
+
if (disabled || readOnly) return;
|
|
57
|
+
if (checked === undefined) setCheckedState(true);
|
|
58
|
+
e = {
|
|
59
|
+
value: value,
|
|
60
|
+
target: { ...inputRef.current,
|
|
61
|
+
checked: true
|
|
62
|
+
}
|
|
116
63
|
};
|
|
117
|
-
|
|
118
|
-
onChange && onChange(el);
|
|
64
|
+
if (onChange) onChange(e);
|
|
119
65
|
};
|
|
120
66
|
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
67
|
+
useEffect(() => {
|
|
68
|
+
if (checked !== undefined) setCheckedState(Boolean(checked));
|
|
69
|
+
}, [checked]);
|
|
70
|
+
return useMemo(() => {
|
|
71
|
+
return jsx("div", {
|
|
72
|
+
id: 'DGN-Core-Radio-' + (id || unique),
|
|
73
|
+
css: formCheckCSS,
|
|
74
|
+
className: ['DGN-UI-Radio', className].join(' ').trim().replace(/\s+/g, ' '),
|
|
75
|
+
ref: ref,
|
|
76
|
+
...props
|
|
77
|
+
}, jsx("input", { ...inputProps,
|
|
78
|
+
disabled: disabled,
|
|
79
|
+
ref: inputRef,
|
|
80
|
+
name: name,
|
|
81
|
+
hidden: true,
|
|
82
|
+
checked: checkedState,
|
|
83
|
+
type: "radio",
|
|
84
|
+
css: _formCheckInputCSS,
|
|
85
|
+
id: id || unique,
|
|
86
|
+
onChange: handleChange
|
|
87
|
+
}), jsx("label", {
|
|
88
|
+
css: _formCheckLabelCSS,
|
|
89
|
+
className: `${disabled ? 'disabled' : ''} ${readOnly ? 'read-only' : ''}`,
|
|
90
|
+
htmlFor: id || unique,
|
|
91
|
+
onClick: handleChange
|
|
92
|
+
}, jsx(Typography, {
|
|
93
|
+
color: disabled ? clDisabled : '',
|
|
94
|
+
type: 'p1',
|
|
95
|
+
...labelProps
|
|
96
|
+
}, label !== null && label !== void 0 ? label : value)));
|
|
97
|
+
}, [disabled, onChange, readOnly, checkedState]);
|
|
147
98
|
}));
|
|
99
|
+
const formCheckCSS = css`
|
|
100
|
+
${displayBlock};
|
|
101
|
+
padding: ${spacing(0.5)}px;
|
|
102
|
+
`;
|
|
103
|
+
|
|
104
|
+
const formCheckInputCSS = width => css`
|
|
105
|
+
${positionAbsolute};
|
|
106
|
+
${borderBox};
|
|
107
|
+
${displayNone};
|
|
108
|
+
&:checked ~ label:after {
|
|
109
|
+
${borderBox};
|
|
110
|
+
${positionAbsolute};
|
|
111
|
+
width: ${width / 2}px;
|
|
112
|
+
height: ${width / 2}px;
|
|
113
|
+
left: ${width / 4}px;
|
|
114
|
+
background: ${clSystemActive};
|
|
115
|
+
border-radius: 50%;
|
|
116
|
+
top: 50%;
|
|
117
|
+
transform: translateY(-50%);
|
|
118
|
+
content: '';
|
|
119
|
+
transition: 0.28s ease;
|
|
120
|
+
}
|
|
121
|
+
&:checked ~ label:before {
|
|
122
|
+
border-color: ${clSystemActive};
|
|
123
|
+
}
|
|
124
|
+
`;
|
|
125
|
+
|
|
126
|
+
const formCheckLabelCSS = width => css`
|
|
127
|
+
${displayBlock};
|
|
128
|
+
${positionRelative};
|
|
129
|
+
${cursorPointer};
|
|
130
|
+
margin-bottom: 0 !important;
|
|
131
|
+
padding-left: ${width + spacing(1.5)}px;
|
|
132
|
+
min-height: ${width}px;
|
|
133
|
+
&:hover:not(.disabled):not(.read-only)::before {
|
|
134
|
+
box-shadow: 0 0 0 2px ${clFillHover};
|
|
135
|
+
background: ${clFillHover};
|
|
136
|
+
}
|
|
137
|
+
&.disabled,
|
|
138
|
+
&.read-only {
|
|
139
|
+
${cursorNoDrop};
|
|
140
|
+
}
|
|
141
|
+
&.disabled {
|
|
142
|
+
color: ${clDisabled};
|
|
143
|
+
&:after {
|
|
144
|
+
background: ${clDisabled} !important;
|
|
145
|
+
}
|
|
146
|
+
&:before {
|
|
147
|
+
border-color: ${clDisabled} !important;
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
&:before {
|
|
151
|
+
${positionAbsolute};
|
|
152
|
+
${borderBox};
|
|
153
|
+
width: ${width}px;
|
|
154
|
+
height: ${width}px;
|
|
155
|
+
border-radius: 50%;
|
|
156
|
+
top: 50%;
|
|
157
|
+
transform: translateY(-50%);
|
|
158
|
+
left: 0;
|
|
159
|
+
content: '';
|
|
160
|
+
border: 2px solid ${clSystemRest};
|
|
161
|
+
transition: 0.28s ease;
|
|
162
|
+
}
|
|
163
|
+
`;
|
|
164
|
+
|
|
148
165
|
Radio.defaultProps = {
|
|
149
166
|
disabled: false,
|
|
167
|
+
readOnly: false,
|
|
150
168
|
defaultChecked: false,
|
|
151
169
|
label: '',
|
|
152
170
|
value: '',
|
|
153
171
|
className: '',
|
|
154
|
-
width: 20
|
|
172
|
+
width: 20,
|
|
173
|
+
labelProps: {}
|
|
155
174
|
};
|
|
156
175
|
Radio.propTypes = {
|
|
157
|
-
/**
|
|
158
|
-
* If `true`, the component is disabled.
|
|
159
|
-
*/
|
|
176
|
+
/** If `true`, the component is disabled. */
|
|
160
177
|
disabled: PropTypes.bool,
|
|
161
178
|
|
|
162
|
-
/**
|
|
163
|
-
* If `true`, the component is checked.
|
|
164
|
-
*/
|
|
179
|
+
/** If `true`, the component is checked. */
|
|
165
180
|
checked: PropTypes.bool,
|
|
166
181
|
|
|
167
|
-
/**
|
|
168
|
-
* If `true`, the component is defaultChecked.
|
|
169
|
-
*/
|
|
182
|
+
/** If `true`, the component is defaultChecked. */
|
|
170
183
|
defaultChecked: PropTypes.bool,
|
|
171
184
|
|
|
172
185
|
/** Id is randomized randomly to avoid duplication. */
|
|
@@ -176,7 +189,7 @@ Radio.propTypes = {
|
|
|
176
189
|
name: PropTypes.string,
|
|
177
190
|
|
|
178
191
|
/** The value of the component. The DOM API casts this to a string. */
|
|
179
|
-
value: PropTypes.string,
|
|
192
|
+
value: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
|
|
180
193
|
|
|
181
194
|
/** The name of the Radio is displayed on the interface */
|
|
182
195
|
label: PropTypes.string,
|
|
@@ -184,7 +197,7 @@ Radio.propTypes = {
|
|
|
184
197
|
/** The class for Radio component */
|
|
185
198
|
className: PropTypes.string,
|
|
186
199
|
|
|
187
|
-
/**
|
|
200
|
+
/** Props for input. */
|
|
188
201
|
inputProps: PropTypes.object,
|
|
189
202
|
|
|
190
203
|
/** Callback fired when the state is changed.
|
|
@@ -195,10 +208,10 @@ Radio.propTypes = {
|
|
|
195
208
|
* */
|
|
196
209
|
onChange: PropTypes.func,
|
|
197
210
|
|
|
198
|
-
/**
|
|
199
|
-
|
|
211
|
+
/** Prevent all event if true. */
|
|
212
|
+
readOnly: PropTypes.bool,
|
|
200
213
|
|
|
201
|
-
/**
|
|
202
|
-
|
|
214
|
+
/** Props for Typography of label. */
|
|
215
|
+
labelProps: PropTypes.object
|
|
203
216
|
};
|
|
204
217
|
export default Radio;
|
|
@@ -26,79 +26,18 @@ const {
|
|
|
26
26
|
} = typography;
|
|
27
27
|
const {
|
|
28
28
|
system: {
|
|
29
|
-
active,
|
|
30
29
|
rest
|
|
31
30
|
},
|
|
32
|
-
semantic: {
|
|
33
|
-
success,
|
|
34
|
-
warning,
|
|
35
|
-
danger,
|
|
36
|
-
info
|
|
37
|
-
},
|
|
38
31
|
text: {
|
|
39
|
-
main
|
|
32
|
+
main,
|
|
33
|
+
tooltip: textTooltip
|
|
40
34
|
},
|
|
41
35
|
fill: {
|
|
42
36
|
tooltip: fillTooltip
|
|
43
|
-
},
|
|
44
|
-
text: {
|
|
45
|
-
tooltip: textTooltip
|
|
46
37
|
}
|
|
47
38
|
} = colors;
|
|
48
39
|
const typographyMap = new Map([['t1', title1], ['t2', title2], ['t3', title3], ['t4', title4], ['h1', heading1], ['h2', heading2], ['h3', heading3], ['h4', heading4], ['h5', heading5], ['h6', heading6], ['p1', paragraph1], ['p2', paragraph2], ['p3', paragraph3]]);
|
|
49
|
-
const colorMap = new Map([['default', main], ['
|
|
50
|
-
|
|
51
|
-
const getDirectionPopover = direction => {
|
|
52
|
-
switch (direction) {
|
|
53
|
-
case 'top':
|
|
54
|
-
return {
|
|
55
|
-
anchorOrigin: {
|
|
56
|
-
vertical: 'top',
|
|
57
|
-
horizontal: 'center'
|
|
58
|
-
},
|
|
59
|
-
transformOrigin: {
|
|
60
|
-
vertical: 'bottom',
|
|
61
|
-
horizontal: 'center'
|
|
62
|
-
}
|
|
63
|
-
};
|
|
64
|
-
|
|
65
|
-
case 'left':
|
|
66
|
-
return {
|
|
67
|
-
anchorOrigin: {
|
|
68
|
-
vertical: 'center',
|
|
69
|
-
horizontal: 'left'
|
|
70
|
-
},
|
|
71
|
-
transformOrigin: {
|
|
72
|
-
vertical: 'center',
|
|
73
|
-
horizontal: 'right'
|
|
74
|
-
}
|
|
75
|
-
};
|
|
76
|
-
|
|
77
|
-
case 'right':
|
|
78
|
-
return {
|
|
79
|
-
anchorOrigin: {
|
|
80
|
-
vertical: 'center',
|
|
81
|
-
horizontal: 'right'
|
|
82
|
-
},
|
|
83
|
-
transformOrigin: {
|
|
84
|
-
vertical: 'center',
|
|
85
|
-
horizontal: 'left'
|
|
86
|
-
}
|
|
87
|
-
};
|
|
88
|
-
|
|
89
|
-
default:
|
|
90
|
-
return {
|
|
91
|
-
anchorOrigin: {
|
|
92
|
-
vertical: 'bottom',
|
|
93
|
-
horizontal: 'center'
|
|
94
|
-
},
|
|
95
|
-
transformOrigin: {
|
|
96
|
-
vertical: 'top',
|
|
97
|
-
horizontal: 'center'
|
|
98
|
-
}
|
|
99
|
-
};
|
|
100
|
-
}
|
|
101
|
-
};
|
|
40
|
+
const colorMap = new Map([['default', main], ['secondary', rest]]);
|
|
102
41
|
|
|
103
42
|
const isTextClamped = elm => (elm === null || elm === void 0 ? void 0 : elm.scrollHeight) > (elm === null || elm === void 0 ? void 0 : elm.clientHeight);
|
|
104
43
|
|
|
@@ -119,6 +58,9 @@ const Typography = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
119
58
|
}, reference) => {
|
|
120
59
|
const ref = useRef(null);
|
|
121
60
|
const [openTooltip, setOpenTooltip] = useState(false);
|
|
61
|
+
|
|
62
|
+
const _TextRootCSS = TextRootCSS(color, type, lineClamp);
|
|
63
|
+
|
|
122
64
|
useImperativeHandle(reference, () => {
|
|
123
65
|
const currentRef = ref.current || {};
|
|
124
66
|
const _instance = {}; // methods
|
|
@@ -131,7 +73,9 @@ const Typography = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
131
73
|
|
|
132
74
|
const classNames = inTooltip => ['DGN-UI-Typography', center && 'DGN-Typography-center', fullWidth && 'DGN-Typography-fullWidth', `DGN-Typography-${type}`, uppercase && `DGN-Typography-Uppercase`, capitalize && 'DGN-Typography-Capitalize', !inTooltip && lineClamp && 'DGN-Typography-Clamp', className].join(' ').trim().replace(/\s+/g, ' ');
|
|
133
75
|
|
|
134
|
-
const setHoverTooltip = open => {
|
|
76
|
+
const setHoverTooltip = (open, isTooltip) => {
|
|
77
|
+
!isTooltip && setOpenTooltip(false);
|
|
78
|
+
|
|
135
79
|
if (hoverTooltip && isTextClamped(ref.current)) {
|
|
136
80
|
setOpenTooltip(open);
|
|
137
81
|
}
|
|
@@ -151,11 +95,11 @@ const Typography = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
151
95
|
style: {
|
|
152
96
|
color: textTooltip
|
|
153
97
|
},
|
|
154
|
-
onMouseEnter: () => setHoverTooltip(true),
|
|
155
|
-
onMouseLeave: () => setHoverTooltip(false),
|
|
156
|
-
|
|
98
|
+
onMouseEnter: () => setHoverTooltip(true, true),
|
|
99
|
+
onMouseLeave: () => setHoverTooltip(false, true),
|
|
100
|
+
direction: tooltipDirection
|
|
157
101
|
}, renderHTML(renderChildren(), mapping, {
|
|
158
|
-
css:
|
|
102
|
+
css: _TextRootCSS,
|
|
159
103
|
className: classNames(true),
|
|
160
104
|
style: {
|
|
161
105
|
color: textTooltip,
|
|
@@ -164,7 +108,7 @@ const Typography = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
164
108
|
})), [openTooltip, tooltipDirection, children, mapping, color, type, lineClamp]);
|
|
165
109
|
return jsx(Fragment, null, renderHTML(renderChildren(), mapping, {
|
|
166
110
|
ref: ref,
|
|
167
|
-
css:
|
|
111
|
+
css: _TextRootCSS,
|
|
168
112
|
className: classNames(false),
|
|
169
113
|
onMouseEnter: () => setHoverTooltip(true),
|
|
170
114
|
onMouseLeave: () => setHoverTooltip(false),
|
|
@@ -172,7 +116,7 @@ const Typography = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
172
116
|
}), hoverTooltip && renderTooltip);
|
|
173
117
|
}));
|
|
174
118
|
|
|
175
|
-
const
|
|
119
|
+
const TextRootCSS = (color, type, lineClamp) => css`
|
|
176
120
|
${displayInlineBlock};
|
|
177
121
|
${positionRelative};
|
|
178
122
|
${breakWord};
|
|
@@ -213,7 +157,7 @@ Typography.defaultProps = {
|
|
|
213
157
|
mapping: 'span',
|
|
214
158
|
className: '',
|
|
215
159
|
hoverTooltip: false,
|
|
216
|
-
tooltipDirection: '
|
|
160
|
+
tooltipDirection: 'bottom'
|
|
217
161
|
};
|
|
218
162
|
/** type of text<br/>
|
|
219
163
|
* h1: Title <br/>
|
|
@@ -246,7 +190,7 @@ Typography.propTypes = {
|
|
|
246
190
|
/** text-transform is uppercase if true */
|
|
247
191
|
uppercase: PropTypes.bool,
|
|
248
192
|
|
|
249
|
-
/** text-transform is
|
|
193
|
+
/** text-transform is capitalized if true (and uppercase is false) */
|
|
250
194
|
capitalize: PropTypes.bool,
|
|
251
195
|
|
|
252
196
|
/** The line-clamp property truncates text at a specific number of lines. */
|
|
@@ -256,7 +200,7 @@ Typography.propTypes = {
|
|
|
256
200
|
hoverTooltip: PropTypes.bool,
|
|
257
201
|
|
|
258
202
|
/** Tooltip direction */
|
|
259
|
-
tooltipDirection: PropTypes.oneOf(['top', '
|
|
203
|
+
tooltipDirection: PropTypes.oneOf(['top', 'bottom', 'left', 'right']),
|
|
260
204
|
|
|
261
205
|
/** allows maximum screen width if true */
|
|
262
206
|
fullWidth: PropTypes.bool,
|
package/package.json
CHANGED
package/readme.md
CHANGED
|
@@ -38,6 +38,16 @@ npm test
|
|
|
38
38
|
```
|
|
39
39
|
|
|
40
40
|
## Changelog
|
|
41
|
+
## 1.3.46
|
|
42
|
+
- \[Added\]: MenuIcon – MHRM09N1025
|
|
43
|
+
- \[Changed\]: Dropdown – Ref set value not in dataSource
|
|
44
|
+
- \[Changed\]: Dropdown – Add logic if multiple then selectBox is true
|
|
45
|
+
- \[Fixed\]: Typography – Fix bug tooltip show wrong when hover
|
|
46
|
+
- \[Fixed\]: Avatar – Fix bug flickering
|
|
47
|
+
- \[Fixed\]: Radio – Fix cursor pointer:none when readonly - Fix event onchange - Fix warning
|
|
48
|
+
- \[Fixed\]: Dropdown – Bug not reload dataSource when onClear
|
|
49
|
+
- \[Fixed\]: Dropdown – Fix bug scroll to top after load more
|
|
50
|
+
|
|
41
51
|
## 1.3.45
|
|
42
52
|
- \[Added\]: MenuIcon – MHRM00N0005, MHRM09N1015, MHRM09N1400, MHRP25L0101, MHRP25L0501, MHRM09N1020
|
|
43
53
|
- \[Changed\]: LineChart – Allow pointsColor, pathColor use CORE colors; Add prop className, style, pointHoverAlignment
|