diginet-core-ui 1.3.90 → 1.3.91
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/avatar/index.js +56 -135
- package/components/button/icon.js +21 -21
- package/components/form-control/calendar/function.js +87 -141
- package/components/form-control/date-picker/index.js +28 -62
- package/components/form-control/date-range-picker/index.js +1 -1
- package/components/form-control/number-input/index2.js +18 -18
- package/components/form-control/radio/index.js +5 -5
- package/components/form-control/toggle/index.js +4 -4
- package/components/grid/index.js +3 -1
- package/components/image/index.js +13 -15
- package/components/index.js +1 -1
- package/components/others/option-wrapper/index.js +3 -1
- package/components/popup/v2/index.js +43 -38
- package/components/rating/index.js +8 -8
- package/components/tab/tab-container.js +2 -2
- package/components/tab/tab-header.js +2 -2
- package/components/tab/tab-panel.js +2 -2
- package/components/tab/tab.js +2 -2
- package/components/transfer/index.js +3 -3
- package/components/tree-view/index.js +103 -107
- package/components/typography/index.js +4 -6
- package/global/index.js +2 -2
- package/package.json +1 -1
- package/readme.md +10 -0
- package/styles/general.js +5 -2
- package/styles/sx/index.js +23 -0
- package/styles/utils.js +15 -15
- package/utils/index.js +1 -0
- package/utils/intersectionObserver.js +3 -2
- package/components/popup/proposals_popup.js +0 -321
- package/components/tree-view/css.js +0 -107
|
@@ -1,321 +0,0 @@
|
|
|
1
|
-
/** @jsxRuntime classic */
|
|
2
|
-
/** @jsx jsx */
|
|
3
|
-
import { memo, useEffect, useMemo, useRef, forwardRef } from 'react';
|
|
4
|
-
import PropTypes from 'prop-types';
|
|
5
|
-
import { jsx, css } from '@emotion/core';
|
|
6
|
-
import theme from "../../theme/settings";
|
|
7
|
-
import { Button, ButtonIcon } from "../";
|
|
8
|
-
import { Close, Approval } from "../../icons";
|
|
9
|
-
import TextInput from "../form-control/text-input";
|
|
10
|
-
import { useTheme } from "../../theme";
|
|
11
|
-
const {
|
|
12
|
-
zIndex
|
|
13
|
-
} = useTheme();
|
|
14
|
-
const ProposalsPopup = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
15
|
-
open,
|
|
16
|
-
clearAble,
|
|
17
|
-
pressESCToClose,
|
|
18
|
-
readOnly,
|
|
19
|
-
disabled,
|
|
20
|
-
style,
|
|
21
|
-
popupStyle,
|
|
22
|
-
anchor,
|
|
23
|
-
anchorOrigin,
|
|
24
|
-
transformOrigin,
|
|
25
|
-
refs,
|
|
26
|
-
onClose,
|
|
27
|
-
onConfirm,
|
|
28
|
-
onCancel,
|
|
29
|
-
value,
|
|
30
|
-
defaultValue,
|
|
31
|
-
type,
|
|
32
|
-
viewType,
|
|
33
|
-
error,
|
|
34
|
-
label,
|
|
35
|
-
buttonText,
|
|
36
|
-
placeholder,
|
|
37
|
-
...props
|
|
38
|
-
}, ref) => {
|
|
39
|
-
if (!ref) {
|
|
40
|
-
ref = useRef(null);
|
|
41
|
-
}
|
|
42
|
-
const PopupContainer = css`
|
|
43
|
-
display: flex;
|
|
44
|
-
position: fixed;
|
|
45
|
-
width: 80%;
|
|
46
|
-
max-width: 480px;
|
|
47
|
-
z-index: ${zIndex()};
|
|
48
|
-
transform: scale(0);
|
|
49
|
-
transition: transform 0.2s linear;
|
|
50
|
-
&.open {
|
|
51
|
-
transform: scale(1);
|
|
52
|
-
}
|
|
53
|
-
`;
|
|
54
|
-
const PopupFrame = css`
|
|
55
|
-
display: block;
|
|
56
|
-
align-items: baseline;
|
|
57
|
-
position: relative;
|
|
58
|
-
background: #ffffff;
|
|
59
|
-
width: 100%;
|
|
60
|
-
box-shadow: 0px 4px 4px rgba(0, 0, 0, 0.25);
|
|
61
|
-
border-radius: 4px;
|
|
62
|
-
padding: 24px 16px;
|
|
63
|
-
`;
|
|
64
|
-
const PopupContent = css`
|
|
65
|
-
width: 100%;
|
|
66
|
-
height: 100%;
|
|
67
|
-
display: flex;
|
|
68
|
-
flex-direction: column;
|
|
69
|
-
justify-content: space-between;
|
|
70
|
-
padding: 0 24px;
|
|
71
|
-
box-sizing: border-box;
|
|
72
|
-
`;
|
|
73
|
-
const PopupInput = css`
|
|
74
|
-
display: block;
|
|
75
|
-
width: 100%;
|
|
76
|
-
`;
|
|
77
|
-
const PopupAction = css`
|
|
78
|
-
display: block;
|
|
79
|
-
margin-left: auto;
|
|
80
|
-
`;
|
|
81
|
-
const PopupClearIcon = css`
|
|
82
|
-
display: block;
|
|
83
|
-
position: absolute;
|
|
84
|
-
width: 24px;
|
|
85
|
-
height: 24px;
|
|
86
|
-
top: 16px;
|
|
87
|
-
right: 24px;
|
|
88
|
-
color: ${theme.colors.system.rest};
|
|
89
|
-
cursor: pointer;
|
|
90
|
-
&:hover {
|
|
91
|
-
color: '#404456' !important;
|
|
92
|
-
}
|
|
93
|
-
`;
|
|
94
|
-
const onClosePopup = () => {
|
|
95
|
-
if (onClose) onClose();
|
|
96
|
-
};
|
|
97
|
-
const onProposals = () => {
|
|
98
|
-
// eslint-disable-next-line no-undef
|
|
99
|
-
const input = PopupInputRef.current.querySelector('input');
|
|
100
|
-
if (/^cancel$/i.test(type)) {
|
|
101
|
-
if (onCancel) onCancel(input);
|
|
102
|
-
} else if (onConfirm) onConfirm(input);
|
|
103
|
-
};
|
|
104
|
-
const pressESCHandler = event => {
|
|
105
|
-
if (event.key === 'Escape') {
|
|
106
|
-
onClosePopup();
|
|
107
|
-
}
|
|
108
|
-
};
|
|
109
|
-
const calPosition = (position, originBounding) => {
|
|
110
|
-
switch (position) {
|
|
111
|
-
case 'bottom':
|
|
112
|
-
case 'right':
|
|
113
|
-
{
|
|
114
|
-
return [originBounding.height, originBounding.width];
|
|
115
|
-
}
|
|
116
|
-
case 'center':
|
|
117
|
-
{
|
|
118
|
-
return [originBounding.height / 2, originBounding.width / 2];
|
|
119
|
-
}
|
|
120
|
-
default:
|
|
121
|
-
return [0, 0];
|
|
122
|
-
}
|
|
123
|
-
};
|
|
124
|
-
useEffect(() => {
|
|
125
|
-
if (refs) refs(ref);
|
|
126
|
-
}, []);
|
|
127
|
-
useEffect(() => {
|
|
128
|
-
if (open && ref.current) {
|
|
129
|
-
let top = 0,
|
|
130
|
-
left = 0,
|
|
131
|
-
vertical = 0,
|
|
132
|
-
horizontal = 0;
|
|
133
|
-
|
|
134
|
-
// Position's anchor
|
|
135
|
-
if (anchorOrigin && anchor) {
|
|
136
|
-
if (anchor.current) {
|
|
137
|
-
anchor = anchor.current;
|
|
138
|
-
}
|
|
139
|
-
if (anchorOrigin === 'center') {
|
|
140
|
-
anchorOrigin = {
|
|
141
|
-
vertical: 'center',
|
|
142
|
-
horizontal: 'center'
|
|
143
|
-
};
|
|
144
|
-
}
|
|
145
|
-
const anchorBounding = anchor.getBoundingClientRect();
|
|
146
|
-
vertical = anchorBounding.y + calPosition(anchorOrigin.vertical, anchorBounding)[0];
|
|
147
|
-
horizontal = anchorBounding.x + calPosition(anchorOrigin.horizontal, anchorBounding)[1];
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
// Position's transform
|
|
151
|
-
if (transformOrigin) {
|
|
152
|
-
if (transformOrigin === 'center') {
|
|
153
|
-
transformOrigin = {
|
|
154
|
-
vertical: 'center',
|
|
155
|
-
horizontal: 'center'
|
|
156
|
-
};
|
|
157
|
-
}
|
|
158
|
-
const offsetHeight = ref.current.offsetHeight;
|
|
159
|
-
const offsetWidth = ref.current.offsetWidth;
|
|
160
|
-
switch (transformOrigin.vertical) {
|
|
161
|
-
case 'center':
|
|
162
|
-
top = vertical - offsetHeight / 2;
|
|
163
|
-
break;
|
|
164
|
-
case 'bottom':
|
|
165
|
-
top = vertical - offsetHeight;
|
|
166
|
-
break;
|
|
167
|
-
default:
|
|
168
|
-
top = vertical;
|
|
169
|
-
}
|
|
170
|
-
switch (transformOrigin.horizontal) {
|
|
171
|
-
case 'center':
|
|
172
|
-
left = horizontal - offsetWidth / 2;
|
|
173
|
-
break;
|
|
174
|
-
case 'right':
|
|
175
|
-
left = horizontal - offsetWidth;
|
|
176
|
-
break;
|
|
177
|
-
default:
|
|
178
|
-
left = horizontal;
|
|
179
|
-
}
|
|
180
|
-
|
|
181
|
-
// Reset position if the element overflow window screen size
|
|
182
|
-
if (top < 0) {
|
|
183
|
-
top = 0;
|
|
184
|
-
} else if (top + offsetHeight > window.innerHeight) {
|
|
185
|
-
top = window.innerHeight - offsetHeight;
|
|
186
|
-
}
|
|
187
|
-
if (left < 0) {
|
|
188
|
-
left = 0;
|
|
189
|
-
} else if (left + offsetWidth > window.innerWidth) {
|
|
190
|
-
left = window.innerWidth - offsetWidth;
|
|
191
|
-
}
|
|
192
|
-
ref.current.style.top = top + 'px';
|
|
193
|
-
ref.current.style.left = left + 'px';
|
|
194
|
-
ref.current.style.transformOrigin = `${transformOrigin.horizontal || 'left'} ${transformOrigin.vertical || 'top'}`;
|
|
195
|
-
}
|
|
196
|
-
ref.current.classList.add('open');
|
|
197
|
-
|
|
198
|
-
// Allow press ESC to close popup
|
|
199
|
-
if (pressESCToClose) {
|
|
200
|
-
document.addEventListener('keydown', pressESCHandler);
|
|
201
|
-
}
|
|
202
|
-
}
|
|
203
|
-
return () => {
|
|
204
|
-
if (open && ref.current) {
|
|
205
|
-
ref.current.classList.remove('open');
|
|
206
|
-
if (pressESCToClose) {
|
|
207
|
-
document.removeEventListener('keydown', pressESCHandler);
|
|
208
|
-
}
|
|
209
|
-
}
|
|
210
|
-
};
|
|
211
|
-
}, [open]);
|
|
212
|
-
const popupInput = useMemo(() => jsx("div", {
|
|
213
|
-
css: PopupInput
|
|
214
|
-
}, jsx(TextInput, {
|
|
215
|
-
error: error,
|
|
216
|
-
viewType: viewType,
|
|
217
|
-
label: label,
|
|
218
|
-
value: value,
|
|
219
|
-
defaultValue: defaultValue,
|
|
220
|
-
placeholder: placeholder,
|
|
221
|
-
disabled: disabled,
|
|
222
|
-
readOnly: readOnly,
|
|
223
|
-
style: {
|
|
224
|
-
marginLeft: 0,
|
|
225
|
-
marginRight: 0,
|
|
226
|
-
marginTop: 0
|
|
227
|
-
}
|
|
228
|
-
})), [label, placeholder, value, error, disabled]);
|
|
229
|
-
const popupAction = useMemo(() => {
|
|
230
|
-
const IconName = /cancel/i.test(type) ? Close : Approval;
|
|
231
|
-
const text = buttonText || (/cancel/i.test(type) ? 'Từ chối' : 'Duyệt');
|
|
232
|
-
return jsx("div", {
|
|
233
|
-
css: PopupAction
|
|
234
|
-
}, jsx(Button, {
|
|
235
|
-
viewType: 'outlined',
|
|
236
|
-
style: {
|
|
237
|
-
border: 'none',
|
|
238
|
-
padding: 0,
|
|
239
|
-
minWidth: 'auto',
|
|
240
|
-
backgroundColor: 'transparent'
|
|
241
|
-
},
|
|
242
|
-
color: /cancel/i.test(type) ? 'danger' : 'success',
|
|
243
|
-
onClick: onProposals,
|
|
244
|
-
disabled: disabled,
|
|
245
|
-
startIcon: jsx(IconName, {
|
|
246
|
-
color: 'currentColor',
|
|
247
|
-
viewBox: true,
|
|
248
|
-
bgFill: 'none',
|
|
249
|
-
outline: true
|
|
250
|
-
})
|
|
251
|
-
}, text));
|
|
252
|
-
}, [type, buttonText, disabled]);
|
|
253
|
-
const popupClearIcon = useMemo(() => clearAble && jsx("div", {
|
|
254
|
-
css: PopupClearIcon
|
|
255
|
-
}, jsx(ButtonIcon, {
|
|
256
|
-
viewType: 'ghost',
|
|
257
|
-
name: 'Close',
|
|
258
|
-
onClick: onClosePopup
|
|
259
|
-
})), [clearAble]);
|
|
260
|
-
return jsx("div", {
|
|
261
|
-
css: PopupContainer,
|
|
262
|
-
ref: ref,
|
|
263
|
-
style: style
|
|
264
|
-
}, jsx("div", {
|
|
265
|
-
css: PopupFrame,
|
|
266
|
-
...props,
|
|
267
|
-
style: popupStyle
|
|
268
|
-
}, jsx("div", {
|
|
269
|
-
css: PopupContent
|
|
270
|
-
}, popupInput, popupAction), popupClearIcon));
|
|
271
|
-
}));
|
|
272
|
-
ProposalsPopup.defaultProps = {
|
|
273
|
-
type: 'confirm',
|
|
274
|
-
viewType: 'underlined',
|
|
275
|
-
clearAble: true,
|
|
276
|
-
open: false,
|
|
277
|
-
pressESCToClose: true,
|
|
278
|
-
anchorOrigin: {},
|
|
279
|
-
transformOrigin: {}
|
|
280
|
-
};
|
|
281
|
-
ProposalsPopup.propTypes = {
|
|
282
|
-
/** type of Popup, corresponding to the button */
|
|
283
|
-
type: PropTypes.oneOf(['confirm', 'cancel']),
|
|
284
|
-
/** type of TextInput */
|
|
285
|
-
viewType: PropTypes.oneOf(['underlined', 'outlined']),
|
|
286
|
-
/** placeholder to display in TextInput */
|
|
287
|
-
placeholder: PropTypes.string,
|
|
288
|
-
/** label to display on TextInput */
|
|
289
|
-
label: PropTypes.string,
|
|
290
|
-
/** the content to display in button */
|
|
291
|
-
buttonText: PropTypes.string,
|
|
292
|
-
/** value to display in TextInput */
|
|
293
|
-
value: PropTypes.string,
|
|
294
|
-
/** display clear icon if true */
|
|
295
|
-
clearAble: PropTypes.bool,
|
|
296
|
-
/** show Popup if true */
|
|
297
|
-
open: PropTypes.bool,
|
|
298
|
-
/** allow close Popup when press ESC */
|
|
299
|
-
pressESCToClose: PropTypes.bool,
|
|
300
|
-
/** style inline for Popup container */
|
|
301
|
-
style: PropTypes.object,
|
|
302
|
-
/** style inline for Popup */
|
|
303
|
-
popupStyle: PropTypes.object,
|
|
304
|
-
/** positions are displayed under this object */
|
|
305
|
-
anchor: PropTypes.object,
|
|
306
|
-
/** The root is displayed according to the position of the anchor */
|
|
307
|
-
anchorOrigin: PropTypes.oneOfType([PropTypes.object, PropTypes.string]),
|
|
308
|
-
// {vertical: 'top', horizontal: 'left'}
|
|
309
|
-
/** Popup's native display */
|
|
310
|
-
transformOrigin: PropTypes.oneOfType([PropTypes.object, PropTypes.string]),
|
|
311
|
-
// {vertical: 'bottom', horizontal: 'right'}
|
|
312
|
-
/** the function to get ref of Popup */
|
|
313
|
-
refs: PropTypes.func,
|
|
314
|
-
/** the function run when close Popup */
|
|
315
|
-
onClose: PropTypes.func,
|
|
316
|
-
/** the function run when click confirm button */
|
|
317
|
-
onConfirm: PropTypes.func,
|
|
318
|
-
/** the function run when click cancel button */
|
|
319
|
-
onCancel: PropTypes.func
|
|
320
|
-
};
|
|
321
|
-
export default ProposalsPopup;
|
|
@@ -1,107 +0,0 @@
|
|
|
1
|
-
import { css } from '@emotion/core';
|
|
2
|
-
import { itemsCenter, boxBorder, cursorPointer, displayBlock, displayInlineBlock, flexRow, positionRelative } from "../../styles/general";
|
|
3
|
-
import theme from "../../theme/settings";
|
|
4
|
-
const {
|
|
5
|
-
colors: {
|
|
6
|
-
fill: {
|
|
7
|
-
focus: fillFocus,
|
|
8
|
-
hover: fillHover,
|
|
9
|
-
pressed: fillPressed
|
|
10
|
-
}
|
|
11
|
-
}
|
|
12
|
-
} = theme;
|
|
13
|
-
export const TreeViewRootCSS = css`
|
|
14
|
-
${displayBlock};
|
|
15
|
-
${positionRelative};
|
|
16
|
-
.DGN-UI-Accordion {
|
|
17
|
-
box-shadow: none !important;
|
|
18
|
-
.DGN-UI-Accordion-Summary {
|
|
19
|
-
${itemsCenter};
|
|
20
|
-
min-height: 40px;
|
|
21
|
-
padding: 0;
|
|
22
|
-
border-radius: 0;
|
|
23
|
-
&.focus {
|
|
24
|
-
background-color: ${theme.colors.focus};
|
|
25
|
-
}
|
|
26
|
-
.Accordion-Icon-Root {
|
|
27
|
-
${flexRow};
|
|
28
|
-
margin-right: 4px;
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
.DGN-UI-Accordion-Details-Content {
|
|
32
|
-
padding: 0;
|
|
33
|
-
border-radius: 0;
|
|
34
|
-
}
|
|
35
|
-
.Accordion-Icon-Root {
|
|
36
|
-
${flexRow};
|
|
37
|
-
transition: opacity 0.2s ease-out;
|
|
38
|
-
opacity: 1;
|
|
39
|
-
&.DGN-Invisible {
|
|
40
|
-
opacity: 0;
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
&.DGN-Hidden {
|
|
44
|
-
display: none !important;
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
.TreeView-All,
|
|
48
|
-
.TreeView-Content {
|
|
49
|
-
${displayBlock};
|
|
50
|
-
${positionRelative};
|
|
51
|
-
.DGN-UI-Accordion {
|
|
52
|
-
margin-bottom: 0;
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
.TreeView-Item-Checkbox {
|
|
56
|
-
${displayInlineBlock};
|
|
57
|
-
${positionRelative};
|
|
58
|
-
height: 100%;
|
|
59
|
-
margin-right: 8px;
|
|
60
|
-
}
|
|
61
|
-
.TreeView-Item {
|
|
62
|
-
${flexRow};
|
|
63
|
-
${positionRelative};
|
|
64
|
-
${itemsCenter};
|
|
65
|
-
${boxBorder};
|
|
66
|
-
min-height: 40px;
|
|
67
|
-
text-align: left;
|
|
68
|
-
color: ${theme.colors.text.main};
|
|
69
|
-
width: 100%;
|
|
70
|
-
&.non-child {
|
|
71
|
-
${cursorPointer};
|
|
72
|
-
transition: background-color 300ms ease;
|
|
73
|
-
&.disabled {
|
|
74
|
-
color: ${theme.colors.disabled};
|
|
75
|
-
cursor: no-drop;
|
|
76
|
-
}
|
|
77
|
-
&:not(.disabled) {
|
|
78
|
-
&:hover {
|
|
79
|
-
background-color: ${fillHover};
|
|
80
|
-
}
|
|
81
|
-
&:focus {
|
|
82
|
-
background-color: ${fillFocus};
|
|
83
|
-
}
|
|
84
|
-
&:active {
|
|
85
|
-
background-color: ${fillPressed};
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
&.DGN-Hidden {
|
|
89
|
-
display: none !important;
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
&.focus {
|
|
93
|
-
background-color: ${theme.colors.focus};
|
|
94
|
-
}
|
|
95
|
-
&.TreeView-Item-active .DGN-UI-Typography {
|
|
96
|
-
font-weight: bold;
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
&.expand-able {
|
|
100
|
-
.TreeView-All {
|
|
101
|
-
margin-left: 34px;
|
|
102
|
-
}
|
|
103
|
-
.TreeView-Item.non-child {
|
|
104
|
-
padding-left: 34px;
|
|
105
|
-
}
|
|
106
|
-
}
|
|
107
|
-
`;
|