diginet-core-ui 1.3.34 → 1.3.35-beta.4
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/MHRP09N0032.svg +7 -0
- package/assets/images/menu/erp/W05F0013N0000.svg +9 -0
- package/components/alert/index.js +57 -52
- package/components/alert/notify.js +5 -1
- package/components/avatar/index.js +167 -127
- package/components/badge/index.js +56 -59
- package/components/button/icon.js +21 -21
- package/components/button/index.js +168 -168
- package/components/button/ripple-effect.js +23 -23
- package/components/chart/Pie-v2/index.js +40 -42
- package/components/chip/index.js +129 -134
- package/components/form-control/attachment/index.js +469 -425
- package/components/form-control/calendar/function.js +69 -46
- package/components/form-control/calendar/index.js +12 -3
- package/components/form-control/control/index.js +35 -23
- package/components/form-control/date-picker/index.js +42 -38
- package/components/form-control/date-range-picker/index.js +82 -80
- package/components/form-control/dropdown/index.js +489 -454
- package/components/form-control/dropdown-box/index.js +99 -98
- package/components/form-control/input-base/index.js +350 -344
- package/components/form-control/label/index.js +16 -15
- package/components/form-control/money-input/index.js +106 -7
- package/components/form-control/number-input/index2.js +446 -0
- package/components/form-control/radio/index.js +122 -125
- package/components/form-control/text-input/index.js +31 -32
- package/components/form-control/time-picker/index.js +305 -300
- package/components/form-control/toggle/index.js +103 -104
- package/components/index.js +1 -1
- package/components/modal/modal.js +93 -138
- package/components/paging/page-selector.js +53 -49
- package/components/popover/index.js +232 -125
- package/components/popup/index.js +77 -77
- package/components/popup/proposals_popup.js +50 -48
- package/components/popup/v2/index.js +105 -103
- package/components/progress/circular.js +55 -56
- package/components/tab/tab-container.js +32 -14
- package/components/tab/tab-header.js +81 -56
- package/components/tab/tab-panel.js +46 -17
- package/components/tab/tab.js +105 -87
- package/components/tooltip/index.js +162 -156
- package/components/typography/index.js +164 -52
- package/icons/basic.js +148 -27
- package/icons/effect.js +11 -11
- package/package.json +55 -35
- package/readme.md +17 -0
- package/styles/colors.js +7 -7
- package/styles/general.js +21 -0
- package/theme/settings.js +11 -17
- package/utils/intersectionObserver.js +41 -0
- package/utils/number.js +7 -8
- package/utils/render-portal.js +5 -1
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
<svg width="39" height="39" viewBox="0 0 39 39" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
2
|
+
<path d="M17 23.14H8C7.37 23.14 6.86 23.65 6.86 24.28C6.86 24.91 7.37 25.43 8 25.43H17C17.63 25.43 18.14 24.91 18.14 24.28C18.14 23.65 17.63 23.14 17 23.14ZM21.71 18.57H8C7.37 18.57 6.86 19.08 6.86 19.71C6.86 20.34 7.37 20.86 8 20.86H21.71C22.34 20.86 22.85 20.34 22.85 19.71C22.85 19.08 22.34 18.57 21.71 18.57ZM21.71 14H8C7.37 14 6.86 14.51 6.86 15.14C6.86 15.77 7.37 16.29 8 16.29H21.71C22.34 16.29 22.85 15.77 22.85 15.14C22.85 14.51 22.34 14 21.71 14ZM8 16.29H21.71C22.34 16.29 22.85 15.77 22.85 15.14C22.85 14.51 22.34 14 21.71 14H8C7.37 14 6.86 14.51 6.86 15.14C6.86 15.77 7.37 16.29 8 16.29ZM21.71 18.57H8C7.37 18.57 6.86 19.08 6.86 19.71C6.86 20.34 7.37 20.86 8 20.86H21.71C22.34 20.86 22.85 20.34 22.85 19.71C22.85 19.08 22.34 18.57 21.71 18.57ZM17 23.14H8C7.37 23.14 6.86 23.65 6.86 24.28C6.86 24.91 7.37 25.43 8 25.43H17C17.63 25.43 18.14 24.91 18.14 24.28C18.14 23.65 17.63 23.14 17 23.14ZM29.56 25.16L29.46 25.28L29.39 25.36L29.41 25.38L28.64 26.23C28.22 26.69 27.82 27.12 27.42 27.52V35.57C27.42 36.2 26.91 36.71 26.28 36.71H3.43C2.8 36.71 2.29 36.2 2.29 35.57V3.43C2.29 2.8 2.8 2.29 3.43 2.29H18.28V8C18.28 9.89 19.82 11.43 21.71 11.43H27.01C27.28 11.09 27.53 10.78 27.77 10.49C28.18 9.99 28.58 9.52 28.96 9.07L20.23 0.33C20.02 0.12 19.73 0 19.42 0H3.43C1.54 0 0 1.54 0 3.43V35.57C0 37.46 1.54 39 3.43 39H26.28C28.17 39 29.71 37.46 29.71 35.57V24.99C29.67 25.05 29.62 25.1 29.56 25.16ZM20.57 3.9L25.81 9.14H21.71C21.08 9.14 20.57 8.63 20.57 8V3.9ZM21.71 14H8C7.37 14 6.86 14.51 6.86 15.14C6.86 15.77 7.37 16.29 8 16.29H21.71C22.34 16.29 22.85 15.77 22.85 15.14C22.85 14.51 22.34 14 21.71 14ZM22.85 19.71C22.85 19.08 22.34 18.57 21.71 18.57H8C7.37 18.57 6.86 19.08 6.86 19.71C6.86 20.34 7.37 20.86 8 20.86H21.71C22.34 20.86 22.85 20.34 22.85 19.71ZM8 23.14C7.37 23.14 6.86 23.65 6.86 24.28C6.86 24.91 7.37 25.43 8 25.43H17C17.63 25.43 18.14 24.91 18.14 24.28C18.14 23.65 17.63 23.14 17 23.14H8Z" fill="#2680EB"/>
|
|
3
|
+
<path d="M11.61 31.37C10.73 31.43 10.2 31.99 9.70997 32.57C9.41997 32.92 9.23997 33.37 8.92997 33.7C8.76997 33.88 8.43997 33.9 8.18997 34C8.12997 33.73 7.93997 33.41 8.01997 33.21C8.50997 32.08 9.26997 31.16 10.38 30.58C11.71 29.89 12.55 30.3 12.85 31.76C12.88 31.88 12.91 32.01 12.93 32.06C13.63 31.76 14.29 31.37 15.01 31.21C16.17 30.94 17.26 31.35 18.26 31.93C18.42 32.02 18.42 32.4 18.5 32.64C18.26 32.71 17.99 32.89 17.78 32.84C17.23 32.72 16.71 32.48 16.17 32.32C15.45 32.11 14.79 32.31 14.18 32.71C13.98 32.84 13.79 32.99 13.58 33.1C12.78 33.53 12.2 33.29 11.92 32.41C11.8 32.08 11.71 31.74 11.61 31.37Z" fill="#FF8C00"/>
|
|
4
|
+
<path d="M35.16 6.17998C35.31 6.27998 35.44 6.35999 35.55 6.45999C35.69 6.57999 35.8 6.56998 35.95 6.44998C36.34 6.12998 36.74 5.81998 37.15 5.51998C37.63 5.16998 38.1 5.15998 38.53 5.44998C38.94 5.72998 39.09 6.20999 38.93 6.77999C38.19 9.51999 37.01 12.07 35.66 14.55C33.77 18.03 31.54 21.27 28.99 24.3C28.9 24.4 28.82 24.5 28.7 24.63C27.17 23.58 25.65 22.53 24.09 21.46C26.72 16.65 29.91 12.28 33.79 8.37998C33.58 8.22998 33.39 8.09998 33.18 7.94998C32.89 8.23998 32.58 8.50998 32.32 8.81998C30.96 10.4 29.61 11.99 28.26 13.58C28.2 13.65 28.16 13.72 28.1 13.79C27.85 14.06 27.48 14.09 27.21 13.88C26.94 13.67 26.88 13.28 27.09 12.99C27.56 12.36 28.04 11.74 28.54 11.14C30.55 8.68999 32.7 6.38998 35.24 4.46998C35.38 4.35998 35.52 4.25998 35.67 4.15998C36 3.93998 36.37 3.98998 36.58 4.26998C36.81 4.57998 36.76 4.94998 36.43 5.19998C36.12 5.44998 35.8 5.67998 35.48 5.91998C35.38 5.98998 35.28 6.06998 35.16 6.17998Z" fill="#FF8C00"/>
|
|
5
|
+
<path d="M27.9 25.55C26.35 27.25 24.74 28.83 22.93 30.19C22.84 30.25 22.66 30.3 22.59 30.26C22.02 29.89 21.46 29.49 20.9 29.11C21.21 27.64 22.66 24.04 23.54 22.55C24.99 23.55 26.43 24.55 27.9 25.55Z" fill="#FF8C00"/>
|
|
6
|
+
<path d="M21.89 31.23C21.37 31.7 20.92 32.12 20.46 32.52C20.27 32.68 20.01 32.77 19.83 32.58C19.71 32.44 19.62 32.16 19.67 32C19.86 31.4 20.11 30.83 20.32 30.29C20.83 30.61 21.32 30.9 21.89 31.23Z" fill="#FF8C00"/>
|
|
7
|
+
</svg>
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
<svg width="40" height="39" viewBox="0 0 40 39" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
2
|
+
<path d="M39.12 8.22L34.84 2.84C34.44 2.34 33.79 2 33.15 2H11.19C10.55 2 9.93998 2.34 9.53998 2.84L5.15998 8.2C4.71998 8.75 4.22998 9.81 4.22998 10.6V14.5C4.89998 13.97 5.18998 13.57 5.77998 13.37C5.80998 12.92 6.00998 12.49 6.23998 12.1C6.63998 11.41 7.31998 10.93 8.07998 10.73C8.35998 10.66 8.62998 10.62 8.87998 10.62C9.88998 10.62 10.82 11.14 11.35 11.95C11.51 11.92 11.68 11.91 11.84 11.91C12.34 11.91 12.81 12.04 13.22 12.28L15.57 11.67C15.87 11.59 16.17 11.55 16.48 11.55C18.1 11.55 19.53 12.65 19.94 14.23L24.55 31.95C24.79 32.88 24.65 33.84 24.17 34.66C23.69 35.49 22.91 36.19 21.99 36.43L19.93 37.09H37.21C38.67 37.09 40 35.66 40 34.2V10.53C40 9.81 39.56 8.78 39.12 8.22ZM28.5 27.62C29.13 26.52 29.75 25.45 30.39 24.35C31.02 25.45 31.64 26.52 32.27 27.61H31.05V32.56H29.74V27.62H28.5V27.62ZM36.98 34.35H28.51V33.35H36.98V34.35ZM35.76 27.62V32.57H34.46V27.62H33.21C33.85 26.52 34.47 25.45 35.11 24.35C35.74 25.45 36.36 26.52 37 27.62H35.76ZM6.67998 8.07L8.08998 6.72H17.68L18.63 4.7H9.32998L10.37 3.57C10.57 3.32 10.87 3.35 11.19 3.35H33.15C33.47 3.35 33.77 3.32 33.97 3.57L35.01 4.7H25.54L26.07 6.72H36.25L37.66 8.07H6.67998Z" fill="#FF8C00"/>
|
|
3
|
+
<path d="M7.10995 14.69L6.51995 14.84C5.87995 15 5.49995 15.65 5.66995 16.28L5.67994 16.3C5.83994 16.93 6.48995 17.31 7.11995 17.15L12.1499 15.84C12.7799 15.68 13.1599 15.03 12.9999 14.4L12.9899 14.38C12.8299 13.75 12.1799 13.37 11.5499 13.53L10.9599 13.68C10.6399 13.76 10.3199 13.57 10.2399 13.26L10.2299 13.24C10.0399 12.5 9.28995 12.06 8.54995 12.25L8.51995 12.26C7.77995 12.45 7.33995 13.2 7.52995 13.94L7.53995 13.96C7.61995 14.28 7.42995 14.6 7.10995 14.69Z" fill="#2680EB"/>
|
|
4
|
+
<path d="M16.1499 31.26C16.2099 31.47 16.0799 31.69 15.8699 31.75L8.54994 33.65C8.33994 33.71 8.11994 33.58 8.05994 33.36L7.95994 32.97C7.89994 32.76 8.02994 32.54 8.24994 32.48L15.5699 30.58C15.7799 30.52 15.9999 30.65 16.0599 30.86L16.1499 31.26Z" fill="#2680EB"/>
|
|
5
|
+
<path d="M17.04 23.62L17.14 24.01C17.2 24.22 17.07 24.44 16.85 24.5L6.84003 27.1C6.63003 27.16 6.41003 27.03 6.35003 26.81L6.25003 26.42C6.20003 26.21 6.32003 26 6.54003 25.94L16.56 23.33C16.77 23.28 16.98 23.41 17.04 23.62Z" fill="#2680EB"/>
|
|
6
|
+
<path d="M15.9501 21.02L5.94008 23.63C5.73008 23.69 5.51008 23.56 5.45008 23.34L5.35008 22.95C5.29008 22.74 5.42008 22.52 5.64008 22.46L15.6601 19.85C15.8701 19.79 16.0901 19.92 16.1501 20.14L16.2501 20.53C16.2901 20.75 16.1701 20.97 15.9501 21.02Z" fill="#2680EB"/>
|
|
7
|
+
<path d="M15.73 28.07L7.64001 30.17C7.43001 30.23 7.21001 30.1 7.15001 29.88L7.05001 29.49C7.00001 29.3 7.13001 29.08 7.34001 29.02L15.43 26.92C15.64 26.86 15.86 26.99 15.92 27.21L16.02 27.6C16.07 27.8 15.94 28.02 15.73 28.07Z" fill="#2680EB"/>
|
|
8
|
+
<path d="M23.0101 32.35L18.4001 14.63C18.1201 13.57 17.0401 12.93 15.9701 13.2L13.6201 13.81C13.6801 13.92 13.7201 14.05 13.7501 14.17C14.0301 15.25 13.4001 16.33 12.3401 16.61L7.39008 17.9C6.38008 18.16 5.29008 17.64 4.95008 16.65C4.89008 16.46 4.85008 16.28 4.84008 16.09L2.49008 16.7C1.43008 16.98 0.790078 18.06 1.06008 19.13L5.67008 36.85C5.95008 37.91 7.03008 38.55 8.10008 38.28L21.5801 34.77C22.6501 34.5 23.2901 33.41 23.0101 32.35ZM7.60008 36.36L3.59008 20.95L17.0701 17.44L21.0801 32.85L7.60008 36.36Z" fill="#2680EB"/>
|
|
9
|
+
</svg>
|
|
@@ -11,6 +11,7 @@ import * as Icons from '../../icons';
|
|
|
11
11
|
import { capitalize } from '../../utils';
|
|
12
12
|
import { hexToRGBA } from '../../styles/color-helper';
|
|
13
13
|
import { typography } from '../../styles/typography';
|
|
14
|
+
import { useTheme } from '../../theme';
|
|
14
15
|
const {
|
|
15
16
|
heading3,
|
|
16
17
|
heading4,
|
|
@@ -30,6 +31,9 @@ const {
|
|
|
30
31
|
info
|
|
31
32
|
}
|
|
32
33
|
} = colors;
|
|
34
|
+
const {
|
|
35
|
+
zIndex
|
|
36
|
+
} = useTheme();
|
|
33
37
|
const colorMap = new Map([['info', info], ['success', success], ['warning', warning], ['danger', danger]]);
|
|
34
38
|
const iconMap = new Map([['info', 'Info'], ['success', 'ApprovalFilled'], ['warning', 'Warning'], ['danger', 'CancelFilled']]);
|
|
35
39
|
const maxWidthMap = new Map([['tiny', 320], ['small', 400], ['medium', 480]]);
|
|
@@ -56,66 +60,67 @@ const Alert = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
56
60
|
const [percentState, setPercentState] = useState(100);
|
|
57
61
|
const mainColor = colorMap.get(color);
|
|
58
62
|
const AlertContainer = css`
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
63
|
+
position: relative;
|
|
64
|
+
display: block;
|
|
65
|
+
margin-bottom: 1rem;
|
|
66
|
+
transition: opacity ${progressing ? duration / 2 + 1 : duration * 1}s ease
|
|
67
|
+
${progressing ? duration / 2 : 0}s;
|
|
68
|
+
pointer-events: auto;
|
|
69
|
+
z-index: ${zIndex(1)};
|
|
70
|
+
max-width: ${maxWidthMap.get(size)}px;
|
|
71
|
+
`;
|
|
67
72
|
const AlertInfo = css`
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
73
|
+
display: flex;
|
|
74
|
+
position: relative;
|
|
75
|
+
width: 100%;
|
|
76
|
+
min-width: 320px;
|
|
77
|
+
border: 1px solid ${mainColor};
|
|
78
|
+
color: ${mainColor};
|
|
79
|
+
background-color: ${hexToRGBA(mainColor, 0.15)};
|
|
80
|
+
box-sizing: border-box;
|
|
81
|
+
border-radius: 4px;
|
|
82
|
+
padding: 0 4px 0 16px;
|
|
83
|
+
opacity: 1;
|
|
84
|
+
word-break: break-word;
|
|
85
|
+
`;
|
|
81
86
|
const AlertIcon = css`
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
87
|
+
display: inherit;
|
|
88
|
+
margin-right: 10px;
|
|
89
|
+
padding: 8px 0;
|
|
90
|
+
`;
|
|
86
91
|
const AlertText = css`
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
92
|
+
display: block;
|
|
93
|
+
margin-right: ${clearAble ? '10px' : 0};
|
|
94
|
+
padding: 8px 0;
|
|
95
|
+
`;
|
|
91
96
|
const AlertPrimary = css`
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
97
|
+
display: flex;
|
|
98
|
+
position: relative;
|
|
99
|
+
align-items: center;
|
|
100
|
+
justify-content: flex-start;
|
|
101
|
+
user-select: none;
|
|
102
|
+
${secondary ? primaryTypoMap.get(size) : paragraph1}
|
|
103
|
+
`;
|
|
99
104
|
const AlertSecondary = css`
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
105
|
+
display: block;
|
|
106
|
+
user-select: none;
|
|
107
|
+
${size === 'tiny' ? paragraph3 : paragraph2}
|
|
108
|
+
`;
|
|
104
109
|
const AlertClearIcon = css`
|
|
105
|
-
|
|
106
|
-
|
|
110
|
+
margin-left: auto;
|
|
111
|
+
`;
|
|
107
112
|
const linearProgressStyle = css`
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
+
display: block;
|
|
114
|
+
position: relative;
|
|
115
|
+
margin-top: ${size === 'medium' ? '4px' : '2px'};
|
|
116
|
+
padding: 0 5px;
|
|
117
|
+
`;
|
|
113
118
|
const NotFoundIcon = css`
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
+
display: block;
|
|
120
|
+
width: 70%;
|
|
121
|
+
height: 70%;
|
|
122
|
+
border: 1px dashed ${rest};
|
|
123
|
+
`;
|
|
119
124
|
|
|
120
125
|
const onClearAlert = (el, urgency) => {
|
|
121
126
|
var _el$parentNode;
|
|
@@ -3,10 +3,14 @@ import ReactDOM from 'react-dom';
|
|
|
3
3
|
import PropTypes from 'prop-types';
|
|
4
4
|
import Alert from './';
|
|
5
5
|
import { randomString } from '../../utils';
|
|
6
|
+
import { useTheme } from '../../theme';
|
|
7
|
+
const {
|
|
8
|
+
zIndex
|
|
9
|
+
} = useTheme();
|
|
6
10
|
const positions = {
|
|
7
11
|
general: {
|
|
8
12
|
position: 'fixed',
|
|
9
|
-
zIndex:
|
|
13
|
+
zIndex: zIndex(2),
|
|
10
14
|
backgroundColor: 'transparent',
|
|
11
15
|
pointerEvents: 'none'
|
|
12
16
|
},
|
|
@@ -3,12 +3,14 @@
|
|
|
3
3
|
/** @jsx jsx */
|
|
4
4
|
import { Fragment, memo, useRef, forwardRef, useState, useEffect, useMemo, useImperativeHandle } from 'react';
|
|
5
5
|
import PropTypes from 'prop-types';
|
|
6
|
-
import { jsx, css } from '@emotion/core';
|
|
6
|
+
import { jsx, css, keyframes } from '@emotion/core';
|
|
7
7
|
import OptionWrapper from '../others/option-wrapper';
|
|
8
|
+
import { useIntersection } from '../../utils/intersectionObserver';
|
|
8
9
|
import { ButtonIcon, ModalSample, Popover, Popup, Typography } from '../';
|
|
9
10
|
import { randomString } from '../../utils';
|
|
10
11
|
import { getGlobal } from '../../global';
|
|
11
|
-
import
|
|
12
|
+
import AvatarDefault from '../../assets/avatar/default.svg';
|
|
13
|
+
import { alignCenter, borderNone, displayBlock, displayNone, flexCol, inlineFlex, overflowHidden, parseWidthHeight, pointerEventsNone, positionAbsolute, positionRelative, userSelectNone } from '../../styles/general';
|
|
12
14
|
import isMobile from '../../utils/isMobile';
|
|
13
15
|
import { color as colors } from '../../styles/colors';
|
|
14
16
|
const {
|
|
@@ -78,8 +80,14 @@ const getDirection = direction => {
|
|
|
78
80
|
}
|
|
79
81
|
};
|
|
80
82
|
|
|
83
|
+
const blurKeyframe = keyframes`
|
|
84
|
+
0% { -webkit-filter: blur(4px);}
|
|
85
|
+
25% { -webkit-filter: blur(3px);}
|
|
86
|
+
50% { -webkit-filter: blur(2px);}
|
|
87
|
+
75% { -webkit-filter: blur(1px);}
|
|
88
|
+
100% { -webkit-filter: blur(0px);}
|
|
89
|
+
`;
|
|
81
90
|
const Avatar = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
82
|
-
refs,
|
|
83
91
|
src,
|
|
84
92
|
defaultSrc,
|
|
85
93
|
outlined,
|
|
@@ -100,8 +108,10 @@ const Avatar = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
100
108
|
hoverAble,
|
|
101
109
|
readOnly,
|
|
102
110
|
disabled,
|
|
111
|
+
lazyLoading,
|
|
103
112
|
...props
|
|
104
113
|
}, reference) => {
|
|
114
|
+
if (!defaultSrc) defaultSrc = AvatarDefault;
|
|
105
115
|
const ref = useRef(null);
|
|
106
116
|
const inputRef = useRef(null);
|
|
107
117
|
const avatarRef = useRef(null);
|
|
@@ -112,81 +122,14 @@ const Avatar = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
112
122
|
const [viewAvatar, setViewAvatar] = useState(false);
|
|
113
123
|
const [viewMoreInfo, setViewMoreInfo] = useState(false);
|
|
114
124
|
const [srcState, setSrcState] = useState(src);
|
|
125
|
+
const [isInView, setIsInView] = useState(false);
|
|
126
|
+
const [onLoaded, setOnLoaded] = useState(false);
|
|
127
|
+
useIntersection(ref, () => {
|
|
128
|
+
setIsInView(true);
|
|
129
|
+
});
|
|
115
130
|
|
|
116
131
|
const _isMobile = isMobile.any();
|
|
117
132
|
|
|
118
|
-
if (!defaultSrc) defaultSrc = require('../../assets/avatar/default.svg');
|
|
119
|
-
|
|
120
|
-
if (width && !height) {
|
|
121
|
-
height = width;
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
if (!width && height) {
|
|
125
|
-
width = height;
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
const ActionIcon = css`
|
|
129
|
-
${positionAbsolute}
|
|
130
|
-
right: -36px;
|
|
131
|
-
transition: opacity 0.5s;
|
|
132
|
-
opacity: 0;
|
|
133
|
-
.icon-delete {
|
|
134
|
-
display: flex;
|
|
135
|
-
}
|
|
136
|
-
`;
|
|
137
|
-
const AvatarPreview = css`
|
|
138
|
-
${displayBlock}
|
|
139
|
-
${positionRelative}
|
|
140
|
-
${overflowHidden}
|
|
141
|
-
width: 100%;
|
|
142
|
-
height: 100%;
|
|
143
|
-
border-radius: 50%;
|
|
144
|
-
cursor: ${readOnly ? 'initial' : 'pointer'};
|
|
145
|
-
`;
|
|
146
|
-
const AvatarContainer = css`
|
|
147
|
-
${inlineFlex}
|
|
148
|
-
${positionRelative}
|
|
149
|
-
${alignCenter}
|
|
150
|
-
&.disabled {
|
|
151
|
-
.css-${AvatarPreview.name} {
|
|
152
|
-
${pointerEventsNone}
|
|
153
|
-
cursor: inherit;
|
|
154
|
-
}
|
|
155
|
-
.css-${ActionIcon.name} {
|
|
156
|
-
display: none !important;
|
|
157
|
-
}
|
|
158
|
-
}
|
|
159
|
-
&:hover {
|
|
160
|
-
.css-${ActionIcon.name} {
|
|
161
|
-
opacity: 1;
|
|
162
|
-
}
|
|
163
|
-
}
|
|
164
|
-
`;
|
|
165
|
-
const AvatarRoot = css`
|
|
166
|
-
${displayBlock}
|
|
167
|
-
${positionRelative}
|
|
168
|
-
${overflowHidden}
|
|
169
|
-
${userSelectNone}
|
|
170
|
-
${borderNone}
|
|
171
|
-
border-radius: 50%;
|
|
172
|
-
width: ${isNaN(width) ? width : width + 'px'};
|
|
173
|
-
height: ${isNaN(height) ? height : height + 'px'};
|
|
174
|
-
box-sizing: content-box;
|
|
175
|
-
border: ${typeof outlined === 'boolean' && outlined ? `1px solid ${white}` : outlined};
|
|
176
|
-
input {
|
|
177
|
-
display: none;
|
|
178
|
-
}
|
|
179
|
-
img {
|
|
180
|
-
width: 100%;
|
|
181
|
-
height: 100%;
|
|
182
|
-
}
|
|
183
|
-
`;
|
|
184
|
-
const MoreInfo = css`
|
|
185
|
-
${displayBlock}
|
|
186
|
-
${positionRelative}
|
|
187
|
-
padding: 8px;
|
|
188
|
-
`;
|
|
189
|
-
|
|
190
133
|
const triggerInput = e => {
|
|
191
134
|
if (e || !existed[unique]) {
|
|
192
135
|
inputRef.current.click();
|
|
@@ -260,6 +203,39 @@ const Avatar = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
260
203
|
}, getGlobal('noDataText'));
|
|
261
204
|
};
|
|
262
205
|
|
|
206
|
+
const renderImage = () => {
|
|
207
|
+
if (lazyLoading) {
|
|
208
|
+
return isInView ? jsx(Fragment, null, !onLoaded && jsx("img", {
|
|
209
|
+
src: AvatarDefault,
|
|
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,
|
|
224
|
+
alt: '',
|
|
225
|
+
style: {
|
|
226
|
+
objectFit: 'cover'
|
|
227
|
+
}
|
|
228
|
+
});
|
|
229
|
+
} else return jsx("img", {
|
|
230
|
+
css: blurAnimation,
|
|
231
|
+
src: srcState || defaultSrc,
|
|
232
|
+
alt: srcState || defaultSrc,
|
|
233
|
+
style: {
|
|
234
|
+
objectFit: 'cover'
|
|
235
|
+
}
|
|
236
|
+
});
|
|
237
|
+
};
|
|
238
|
+
|
|
263
239
|
const showMoreInfo = () => {
|
|
264
240
|
if (hoverAble) setViewMoreInfo(true);
|
|
265
241
|
};
|
|
@@ -284,25 +260,24 @@ const Avatar = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
284
260
|
if (!_isMobile) closeMoreInfo();
|
|
285
261
|
};
|
|
286
262
|
|
|
287
|
-
useEffect(() => {
|
|
288
|
-
if (refs) refs(ref);
|
|
289
|
-
}, []);
|
|
290
263
|
useEffect(() => {
|
|
291
264
|
if (src) {
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
265
|
+
if (isInView || !lazyLoading) {
|
|
266
|
+
inputRef.current.value = '';
|
|
267
|
+
const img = document.createElement('img');
|
|
268
|
+
urlAvatar[unique] = src;
|
|
269
|
+
img.src = src;
|
|
270
|
+
img.alt = '';
|
|
271
|
+
setSrcState(src);
|
|
272
|
+
existed[unique] = true;
|
|
273
|
+
|
|
274
|
+
img.onerror = () => {
|
|
275
|
+
setSrcState(null);
|
|
276
|
+
existed[unique] = false;
|
|
277
|
+
};
|
|
278
|
+
}
|
|
304
279
|
}
|
|
305
|
-
}, [src]);
|
|
280
|
+
}, [src, lazyLoading, isInView]);
|
|
306
281
|
useImperativeHandle(reference, () => {
|
|
307
282
|
const currentRef = ref.current || {};
|
|
308
283
|
const _instance = {}; // methods
|
|
@@ -313,12 +288,12 @@ const Avatar = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
313
288
|
return currentRef;
|
|
314
289
|
});
|
|
315
290
|
const AvatarView = useMemo(() => jsx("div", {
|
|
316
|
-
css: AvatarContainer,
|
|
291
|
+
css: AvatarContainer(readOnly, actionIconWidth),
|
|
317
292
|
ref: ref,
|
|
318
293
|
id: unique,
|
|
319
294
|
className: disabled ? 'disabled' : ''
|
|
320
295
|
}, jsx("div", {
|
|
321
|
-
css: AvatarRoot,
|
|
296
|
+
css: AvatarRoot(width, height, outlined),
|
|
322
297
|
className: ['DGN-UI-Avatar', className].join(' ').trim().replace(/\s+/g, ' '),
|
|
323
298
|
...props
|
|
324
299
|
}, jsx("input", {
|
|
@@ -328,21 +303,15 @@ const Avatar = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
328
303
|
accept: 'image/*',
|
|
329
304
|
onChange: onChangeAvatar
|
|
330
305
|
}), jsx("div", {
|
|
331
|
-
css: AvatarPreview,
|
|
306
|
+
css: AvatarPreview(readOnly),
|
|
332
307
|
onClick: _onClick,
|
|
333
308
|
ref: avatarRef,
|
|
334
309
|
onMouseEnter: _onMouseEnter,
|
|
335
310
|
onMouseLeave: _onMouseLeave,
|
|
336
311
|
tabIndex: "-1",
|
|
337
312
|
onBlur: closeMoreInfo
|
|
338
|
-
}, jsx("
|
|
339
|
-
|
|
340
|
-
alt: srcState || defaultSrc,
|
|
341
|
-
style: {
|
|
342
|
-
objectFit: 'cover'
|
|
343
|
-
}
|
|
344
|
-
}))), !readOnly && !disabled && jsx("span", {
|
|
345
|
-
css: ActionIcon
|
|
313
|
+
}, renderImage())), !readOnly && !disabled && jsx("span", {
|
|
314
|
+
css: ActionIcon(actionIconWidth)
|
|
346
315
|
}, jsx(ButtonIcon, {
|
|
347
316
|
viewType: 'ghost',
|
|
348
317
|
name: 'Edit',
|
|
@@ -360,7 +329,7 @@ const Avatar = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
360
329
|
style: {
|
|
361
330
|
marginTop: '8px'
|
|
362
331
|
}
|
|
363
|
-
}))), [width, height, readOnly, disabled, clearAble, maxSize, matchType, hoverAble, outlined, srcState]);
|
|
332
|
+
}))), [width, height, readOnly, disabled, clearAble, maxSize, matchType, hoverAble, outlined, actionIconWidth, actionIconHeight, lazyLoading, srcState, isInView, onLoaded]);
|
|
364
333
|
const ModalView = useMemo(() => jsx(ModalSample, {
|
|
365
334
|
open: viewAvatar,
|
|
366
335
|
onClose: () => setViewAvatar(false),
|
|
@@ -394,9 +363,77 @@ const Avatar = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
394
363
|
title: maxSizeError,
|
|
395
364
|
icon: 'danger',
|
|
396
365
|
fullScreen: true
|
|
397
|
-
}), []);
|
|
366
|
+
}), [maxSizeError]);
|
|
398
367
|
return jsx(Fragment, null, AvatarView, ModalView, hoverAble && MoreInfoView, !disabled && !readOnly && PopupView);
|
|
399
368
|
}));
|
|
369
|
+
|
|
370
|
+
const ActionIcon = actionIconWidth => css`
|
|
371
|
+
${flexCol}
|
|
372
|
+
${positionAbsolute}
|
|
373
|
+
right: ${-actionIconWidth}px;
|
|
374
|
+
min-width: ${actionIconWidth}px;
|
|
375
|
+
transition: opacity 0.5s;
|
|
376
|
+
opacity: 0;
|
|
377
|
+
z-index: 9002;
|
|
378
|
+
`;
|
|
379
|
+
|
|
380
|
+
const AvatarPreview = readOnly => css`
|
|
381
|
+
${displayBlock}
|
|
382
|
+
${positionRelative}
|
|
383
|
+
${overflowHidden}
|
|
384
|
+
width: 100%;
|
|
385
|
+
height: 100%;
|
|
386
|
+
border-radius: 50%;
|
|
387
|
+
cursor: ${readOnly ? 'initial' : 'pointer'};
|
|
388
|
+
`;
|
|
389
|
+
|
|
390
|
+
const AvatarContainer = (readOnly, actionIconWidth) => css`
|
|
391
|
+
${inlineFlex}
|
|
392
|
+
${positionRelative}
|
|
393
|
+
${alignCenter}
|
|
394
|
+
&.disabled {
|
|
395
|
+
.css-${AvatarPreview(readOnly).name} {
|
|
396
|
+
${pointerEventsNone}
|
|
397
|
+
cursor: inherit;
|
|
398
|
+
}
|
|
399
|
+
.css-${ActionIcon(actionIconWidth).name} {
|
|
400
|
+
display: none !important;
|
|
401
|
+
}
|
|
402
|
+
}
|
|
403
|
+
&:hover {
|
|
404
|
+
.css-${ActionIcon(actionIconWidth).name} {
|
|
405
|
+
opacity: 1;
|
|
406
|
+
}
|
|
407
|
+
}
|
|
408
|
+
`;
|
|
409
|
+
|
|
410
|
+
const AvatarRoot = (width, height, outlined) => css`
|
|
411
|
+
${displayBlock}
|
|
412
|
+
${positionRelative}
|
|
413
|
+
${overflowHidden}
|
|
414
|
+
${userSelectNone}
|
|
415
|
+
${borderNone}
|
|
416
|
+
${parseWidthHeight(width, height)}
|
|
417
|
+
border: ${typeof outlined === 'boolean' && outlined ? `1px solid ${white}` : outlined};
|
|
418
|
+
border-radius: 50%;
|
|
419
|
+
box-sizing: content-box;
|
|
420
|
+
input {
|
|
421
|
+
${displayNone}
|
|
422
|
+
}
|
|
423
|
+
img {
|
|
424
|
+
width: 100%;
|
|
425
|
+
height: 100%;
|
|
426
|
+
}
|
|
427
|
+
`;
|
|
428
|
+
|
|
429
|
+
const MoreInfo = css`
|
|
430
|
+
${displayBlock}
|
|
431
|
+
${positionRelative}
|
|
432
|
+
padding: 8px;
|
|
433
|
+
`;
|
|
434
|
+
const blurAnimation = css`
|
|
435
|
+
animation: ${blurKeyframe} 1s ease;
|
|
436
|
+
`;
|
|
400
437
|
Avatar.defaultProps = {
|
|
401
438
|
disabled: false,
|
|
402
439
|
readOnly: false,
|
|
@@ -405,12 +442,15 @@ Avatar.defaultProps = {
|
|
|
405
442
|
outlined: false,
|
|
406
443
|
width: 48,
|
|
407
444
|
height: 48,
|
|
445
|
+
actionIconWidth: 24,
|
|
446
|
+
actionIconHeight: 24,
|
|
408
447
|
className: '',
|
|
409
448
|
direction: 'down',
|
|
410
449
|
maxSizeError: `File ${getGlobal(['errorDefault', 'maxSize'])}`,
|
|
411
450
|
wrongTypeError: `File ${getGlobal(['errorDefault', 'fileType'])}`,
|
|
412
451
|
matchType: /^image\/(gif|jpe?g|tiff?|png|webp|bmp|svg(\+xml)?)$/i,
|
|
413
|
-
data: {}
|
|
452
|
+
data: {},
|
|
453
|
+
lazyLoading: false
|
|
414
454
|
};
|
|
415
455
|
Avatar.propTypes = {
|
|
416
456
|
/** prevent all events, only view */
|
|
@@ -458,46 +498,46 @@ Avatar.propTypes = {
|
|
|
458
498
|
/** source of file (http:// or https://) */
|
|
459
499
|
src: PropTypes.string,
|
|
460
500
|
|
|
461
|
-
/**
|
|
462
|
-
* it is used to display the default if there is no src<br />
|
|
463
|
-
* if undefined, will display icons available in the icons store
|
|
501
|
+
/**
|
|
502
|
+
* it is used to display the default if there is no src<br />
|
|
503
|
+
* if undefined, will display icons available in the icons store
|
|
464
504
|
*/
|
|
465
505
|
defaultSrc: PropTypes.string,
|
|
466
506
|
|
|
467
507
|
/** the direction to display more info */
|
|
468
508
|
direction: PropTypes.oneOf(['top', 'down', 'left', 'right']),
|
|
469
509
|
|
|
470
|
-
/**
|
|
471
|
-
* data to display when hoverAble is true<br />
|
|
472
|
-
* data is an object or function return a jsx element
|
|
510
|
+
/**
|
|
511
|
+
* data to display when hoverAble is true<br />
|
|
512
|
+
* data is an object or function return a jsx element
|
|
473
513
|
*/
|
|
474
514
|
data: PropTypes.oneOfType([PropTypes.object, PropTypes.func]),
|
|
475
515
|
|
|
476
|
-
/** refs is a function to get ref of avatar component */
|
|
477
|
-
refs: PropTypes.func,
|
|
478
|
-
|
|
479
516
|
/** will run after remove avatar */
|
|
480
517
|
onRemove: PropTypes.func,
|
|
481
518
|
|
|
482
519
|
/** will run after change avatar */
|
|
483
520
|
onChange: PropTypes.func,
|
|
484
521
|
|
|
522
|
+
/** lazy loading */
|
|
523
|
+
lazyLoading: PropTypes.bool,
|
|
524
|
+
|
|
485
525
|
/** any props else */
|
|
486
526
|
props: PropTypes.any,
|
|
487
527
|
|
|
488
|
-
/**
|
|
489
|
-
* ref methods
|
|
490
|
-
*
|
|
491
|
-
* * option(): Gets all UI component properties
|
|
492
|
-
* * Returns value - object
|
|
493
|
-
* * option(optionName): Gets the value of a single property
|
|
494
|
-
* * @param {optionName} - string
|
|
495
|
-
* * Returns value - any
|
|
496
|
-
* * option(optionName, optionValue): Updates the value of a single property
|
|
497
|
-
* * @param {optionName} - string
|
|
498
|
-
* * @param {optionValue} - any
|
|
499
|
-
* * option(options): Updates the values of several properties
|
|
500
|
-
* * @param {options} - object
|
|
528
|
+
/**
|
|
529
|
+
* ref methods
|
|
530
|
+
*
|
|
531
|
+
* * option(): Gets all UI component properties
|
|
532
|
+
* * Returns value - object
|
|
533
|
+
* * option(optionName): Gets the value of a single property
|
|
534
|
+
* * @param {optionName} - string
|
|
535
|
+
* * Returns value - any
|
|
536
|
+
* * option(optionName, optionValue): Updates the value of a single property
|
|
537
|
+
* * @param {optionName} - string
|
|
538
|
+
* * @param {optionValue} - any
|
|
539
|
+
* * option(options): Updates the values of several properties
|
|
540
|
+
* * @param {options} - object
|
|
501
541
|
*/
|
|
502
542
|
reference: PropTypes.oneOfType([PropTypes.func, PropTypes.shape({
|
|
503
543
|
current: PropTypes.instanceOf(Element)
|