diginet-core-ui 1.3.75-beta.5 → 1.3.76
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/form-control/attachment/index.js +1 -3
- package/components/form-control/date-range-picker/index.js +312 -325
- package/components/form-control/dropdown/index.js +7 -22
- package/components/form-control/label/index.js +6 -6
- package/components/popover/index.js +6 -17
- 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 +3 -3
- package/package.json +31 -61
- package/readme.md +11 -0
|
@@ -1774,14 +1774,12 @@ Attachment.defaultProps = {
|
|
|
1774
1774
|
maxFile: Infinity,
|
|
1775
1775
|
multiple: true,
|
|
1776
1776
|
readOnly: false,
|
|
1777
|
-
style: {},
|
|
1778
1777
|
uploadErrorInfo: {
|
|
1779
1778
|
maxFile: getGlobal(['errorDefault', 'maxFile']),
|
|
1780
1779
|
maxSize: getGlobal(['errorDefault', 'maxSize']),
|
|
1781
1780
|
fileType: getGlobal(['errorDefault', 'fileType']),
|
|
1782
1781
|
existingFile: getGlobal(['errorDefault', 'existingFile'])
|
|
1783
|
-
}
|
|
1784
|
-
viewType: 'detail'
|
|
1782
|
+
}
|
|
1785
1783
|
};
|
|
1786
1784
|
Attachment.propTypes = {
|
|
1787
1785
|
/** File types that can be accepted. */
|
|
@@ -8,100 +8,15 @@ import ControlComp from '../control';
|
|
|
8
8
|
import PropTypes from 'prop-types';
|
|
9
9
|
import theme from '../../../theme/settings';
|
|
10
10
|
import { render } from 'react-dom';
|
|
11
|
-
import { randomString, updatePosition, date as moment, capitalizeSentenceCase, isEqual
|
|
11
|
+
import { randomString, updatePosition, date as moment, capitalizeSentenceCase, isEqual } from '../../../utils';
|
|
12
12
|
import { getGlobal } from '../../../global';
|
|
13
13
|
import { generateCalendarCSS, onUpdateNavigator, renderHeader, renderNavigator } from '../calendar/function';
|
|
14
14
|
import locale from '../../../locale';
|
|
15
|
-
import {
|
|
15
|
+
import { useTheme } from '../../../theme';
|
|
16
16
|
const {
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
white
|
|
20
|
-
}
|
|
21
|
-
},
|
|
22
|
-
spacing,
|
|
23
|
-
zIndex: zIndexCORE
|
|
24
|
-
} = theme;
|
|
25
|
-
|
|
26
|
-
const toLocalTimestamp = t => {
|
|
27
|
-
if (typeof t === 'object' && t.getTime) {
|
|
28
|
-
t = t.getTime();
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
if (typeof t === 'string' && !t.match(/\d{13}/)) {
|
|
32
|
-
t = Date.parse(t).getTime();
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
t = parseInt(t, 10) - new Date().getTimezoneOffset() * 60 * 1000;
|
|
36
|
-
return t;
|
|
37
|
-
};
|
|
38
|
-
|
|
39
|
-
const getDaysFrom1970 = t => {
|
|
40
|
-
return Math.floor(toLocalTimestamp(t) / 86400000);
|
|
41
|
-
};
|
|
42
|
-
|
|
43
|
-
const countDays = (start, end, startFromZero) => {
|
|
44
|
-
return Math.abs(getDaysFrom1970(start) - getDaysFrom1970(end)) + (startFromZero ? 0 : 1);
|
|
45
|
-
};
|
|
46
|
-
|
|
47
|
-
const formatValue = (value, format, utc = false) => {
|
|
48
|
-
return moment(value).format(format, utc);
|
|
49
|
-
};
|
|
50
|
-
|
|
51
|
-
const getDateOfWeek = date => {
|
|
52
|
-
let day = date.getDay();
|
|
53
|
-
if (day === 0) day = 7;
|
|
54
|
-
return day - 1;
|
|
55
|
-
};
|
|
56
|
-
|
|
57
|
-
const isValidDate = v => {
|
|
58
|
-
if (!v || v === null) return false;
|
|
59
|
-
|
|
60
|
-
if (Object.prototype.toString.call(v) === '[object Date]') {
|
|
61
|
-
return true;
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
if (!isNaN(Date.parse(new Date(v)))) {
|
|
65
|
-
return true;
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
return false;
|
|
69
|
-
};
|
|
70
|
-
|
|
71
|
-
const isValidValues = v => {
|
|
72
|
-
if (!v || !Array.isArray(v) || v.length !== 2) {
|
|
73
|
-
return false;
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
if (isValidDate(v[0]) && isValidDate(v[1]) && +moment(v[0]).diff(v[1]) <= 0) {
|
|
77
|
-
return true;
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
return false;
|
|
81
|
-
};
|
|
82
|
-
|
|
83
|
-
const isToday = day => {
|
|
84
|
-
return +moment(day).diff(new Date().setHours(0, 0, 0, 0)) === 0 ? unique.day.today : '';
|
|
85
|
-
};
|
|
86
|
-
|
|
87
|
-
const isLimit = (day, max, min) => {
|
|
88
|
-
return isBefore(min, day) || isAfter(max, day) ? unique.day.limit : '';
|
|
89
|
-
};
|
|
90
|
-
|
|
91
|
-
const isBefore = (min, time) => {
|
|
92
|
-
return min && isValidDate(min) && moment(time).diff(min) < 0;
|
|
93
|
-
};
|
|
94
|
-
|
|
95
|
-
const isAfter = (max, time) => {
|
|
96
|
-
return max && isValidDate(max) && moment(time).diff(max) > 0;
|
|
97
|
-
};
|
|
98
|
-
|
|
99
|
-
const parseDate = day => {
|
|
100
|
-
return Date.parse(new Date(day));
|
|
101
|
-
};
|
|
102
|
-
|
|
17
|
+
zIndex
|
|
18
|
+
} = useTheme();
|
|
103
19
|
const DateRangePickerV2 = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
104
|
-
action = {},
|
|
105
20
|
actionIconAt,
|
|
106
21
|
controls,
|
|
107
22
|
clearAble,
|
|
@@ -109,7 +24,7 @@ const DateRangePickerV2 = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
109
24
|
disabled,
|
|
110
25
|
displayFormat,
|
|
111
26
|
error,
|
|
112
|
-
|
|
27
|
+
errorProps,
|
|
113
28
|
inputProps,
|
|
114
29
|
inputStyle,
|
|
115
30
|
label,
|
|
@@ -165,10 +80,196 @@ const DateRangePickerV2 = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
165
80
|
right: useRef(null),
|
|
166
81
|
content: useRef(null)
|
|
167
82
|
};
|
|
83
|
+
useImperativeHandle(reference, () => ({
|
|
84
|
+
get: () => {
|
|
85
|
+
return ref.current;
|
|
86
|
+
}
|
|
87
|
+
}));
|
|
88
|
+
const [id] = useState(randomString(6, {
|
|
89
|
+
allowSymbol: false
|
|
90
|
+
}));
|
|
91
|
+
const unique = {
|
|
92
|
+
backGr: 'DGN-UI-Portal',
|
|
93
|
+
close: 'DGN-UI-DateRangePickerV2-close',
|
|
94
|
+
cancel: 'DGN-UI-DateRangePickerV2-cancel',
|
|
95
|
+
confirm: 'DGN-UI-DateRangePickerV2-confirm',
|
|
96
|
+
divider: 'DGN-UI-DateRangePickerV2-Divider',
|
|
97
|
+
disabled: 'DGN-UI-DateRangePickerV2-disabled',
|
|
98
|
+
error: 'DGN-UI-DateRangePickerV2-error',
|
|
99
|
+
focus: 'DGN-UI-DateRangePickerV2-focus',
|
|
100
|
+
footer: 'DGN-UI-DateRangePickerV2-Footer',
|
|
101
|
+
picker: 'DGN-UI-DateRangePickerV2-Picker-' + id,
|
|
102
|
+
wrapper: 'DGN-UI-DateRangePickerV2-Wrapper',
|
|
103
|
+
container: 'DGN-UI-DateRangePickerV2',
|
|
104
|
+
icon: 'DGN-UI-DateRangePickerV2-Icon',
|
|
105
|
+
tooltip: 'DGN-UI-DateRangePickerV2-Tooltip',
|
|
106
|
+
navigator: {
|
|
107
|
+
navigator: 'DGN-UI-DateRangePickerV2-Navigator',
|
|
108
|
+
around: 'DGN-UI-DateRangePickerV2-Navigator-Around',
|
|
109
|
+
center: 'DGN-UI-DateRangePickerV2-Navigator-Center'
|
|
110
|
+
},
|
|
111
|
+
table: {
|
|
112
|
+
container: 'DGN-UI-DateRangePickerV2-Table-Container',
|
|
113
|
+
table: 'DGN-UI-DateRangePickerV2-Table-Table',
|
|
114
|
+
header: 'DGN-UI-DateRangePickerV2-Table-Header',
|
|
115
|
+
raw: 'DGN-UI-DateRangePickerV2-Table-Raw',
|
|
116
|
+
data: 'DGN-UI-DateRangePickerV2-Table-Data'
|
|
117
|
+
},
|
|
118
|
+
day: {
|
|
119
|
+
day: 'DGN-UI-DateRangePickerV2-Day',
|
|
120
|
+
week: 'DGN-UI-DateRangePickerV2-Week',
|
|
121
|
+
today: 'DGN-UI-DateRangePickerV2-Day-today',
|
|
122
|
+
active: 'DGN-UI-DateRangePickerV2-Day-active',
|
|
123
|
+
limit: 'DGN-UI-DateRangePickerV2-Day-limit',
|
|
124
|
+
from: 'DGN-UI-DateRangePickerV2-Day-from',
|
|
125
|
+
to: 'DGN-UI-DateRangePickerV2-Day-to',
|
|
126
|
+
between: 'DGN-UI-DateRangePickerV2-Day-between'
|
|
127
|
+
}
|
|
128
|
+
};
|
|
168
129
|
const closeText = getGlobal(['close']);
|
|
169
130
|
const cancelText = getGlobal(['cancel']);
|
|
170
131
|
const confirmText = getGlobal(['confirm']);
|
|
171
132
|
const unitText = getGlobal([unitCount]);
|
|
133
|
+
const iconAreaCSS = css`
|
|
134
|
+
align-items: center;
|
|
135
|
+
color: inherit;
|
|
136
|
+
display: flex;
|
|
137
|
+
width: 24px;
|
|
138
|
+
& span {
|
|
139
|
+
padding: 0;
|
|
140
|
+
}
|
|
141
|
+
.${unique.icon} {
|
|
142
|
+
cursor: pointer;
|
|
143
|
+
opacity: 0;
|
|
144
|
+
transition: display 50ms cubic-bezier(0.4, 0, 0.2, 1) 0ms,
|
|
145
|
+
opacity 300ms cubic-bezier(0.4, 0, 0.2, 1) 50ms;
|
|
146
|
+
display: none;
|
|
147
|
+
will-change: display, opacity;
|
|
148
|
+
}
|
|
149
|
+
.${unique.icon}-accept {
|
|
150
|
+
opacity: 1;
|
|
151
|
+
display: block;
|
|
152
|
+
}
|
|
153
|
+
`;
|
|
154
|
+
const hiddenStyle = {
|
|
155
|
+
opacity: 0,
|
|
156
|
+
display: 'none'
|
|
157
|
+
};
|
|
158
|
+
const activeStyle = {
|
|
159
|
+
opacity: 1,
|
|
160
|
+
pointerEvents: 'none',
|
|
161
|
+
display: 'block'
|
|
162
|
+
};
|
|
163
|
+
const controlContainerCSS = css`
|
|
164
|
+
display: flex;
|
|
165
|
+
justify-content: flex-end;
|
|
166
|
+
margin: 0 16px 16px;
|
|
167
|
+
`;
|
|
168
|
+
const buttonProps = {
|
|
169
|
+
style: {
|
|
170
|
+
display: 'none',
|
|
171
|
+
margin: '0 2px',
|
|
172
|
+
padding: '7px 8px',
|
|
173
|
+
visibility: 'hidden'
|
|
174
|
+
}
|
|
175
|
+
};
|
|
176
|
+
|
|
177
|
+
const typographyProps = className => {
|
|
178
|
+
return {
|
|
179
|
+
className,
|
|
180
|
+
color: 'inherit',
|
|
181
|
+
style: {
|
|
182
|
+
alignItems: 'center',
|
|
183
|
+
borderRadius: '50%',
|
|
184
|
+
display: 'flex',
|
|
185
|
+
height: 24,
|
|
186
|
+
justifyContent: 'center',
|
|
187
|
+
margin: 'auto',
|
|
188
|
+
pointerEvents: 'none',
|
|
189
|
+
transition: 'background-color 150ms linear',
|
|
190
|
+
width: 24
|
|
191
|
+
},
|
|
192
|
+
type: 'h6'
|
|
193
|
+
};
|
|
194
|
+
};
|
|
195
|
+
|
|
196
|
+
const dividerProps = {
|
|
197
|
+
direction: 'vertical',
|
|
198
|
+
className: unique.divider,
|
|
199
|
+
height: '100%',
|
|
200
|
+
style: {
|
|
201
|
+
height: '226px',
|
|
202
|
+
margin: '18px 2px 0px'
|
|
203
|
+
}
|
|
204
|
+
};
|
|
205
|
+
const pickerCSS = {
|
|
206
|
+
backGr: 'background-color: transparent; inset: 0px; pointer-events: auto; position: fixed; z-index: 9001;',
|
|
207
|
+
container: css`
|
|
208
|
+
background-color: ${theme.colors.white};
|
|
209
|
+
border-radius: ${theme.border.radius};
|
|
210
|
+
box-shadow: ${theme.boxShadows.large};
|
|
211
|
+
display: flex;
|
|
212
|
+
flex-flow: column;
|
|
213
|
+
.${unique.wrapper} {
|
|
214
|
+
display: flex;
|
|
215
|
+
min-width: 633px;
|
|
216
|
+
}
|
|
217
|
+
.${unique.tooltip} {
|
|
218
|
+
background-color: rgba(21, 26, 48, 0.9);
|
|
219
|
+
border-radius: ${theme.border.radius};
|
|
220
|
+
height: 18px;
|
|
221
|
+
min-width: 65px;
|
|
222
|
+
padding: 3px 6px;
|
|
223
|
+
pointer-events: none;
|
|
224
|
+
position: fixed;
|
|
225
|
+
text-align: center;
|
|
226
|
+
transition: left 0.05s ease-in, top 0.05s ease-in;
|
|
227
|
+
user-select: none;
|
|
228
|
+
vertical-align: middle;
|
|
229
|
+
visibility: hidden;
|
|
230
|
+
white-space: nowrap;
|
|
231
|
+
will-change: left top visibility;
|
|
232
|
+
z-index: ${zIndex(3)};
|
|
233
|
+
}
|
|
234
|
+
@media only screen and (max-width: 599px) {
|
|
235
|
+
max-width: 400px;
|
|
236
|
+
.${unique.wrapper} {
|
|
237
|
+
flex-direction: column;
|
|
238
|
+
min-width: 260px;
|
|
239
|
+
}
|
|
240
|
+
.${unique.divider} {
|
|
241
|
+
height: 1px !important;
|
|
242
|
+
margin: 0px 16px !important;
|
|
243
|
+
width: calc(100% - 32px) !important;
|
|
244
|
+
}
|
|
245
|
+
}
|
|
246
|
+
`,
|
|
247
|
+
picker: (position, width) => css`
|
|
248
|
+
border-radius: ${theme.border.radius};
|
|
249
|
+
height: max-content;
|
|
250
|
+
left: ${position.left}px;
|
|
251
|
+
max-width: 805px;
|
|
252
|
+
min-width: ${window.innerWidth <= 633 ? 300 : 633}px;
|
|
253
|
+
opacity: 0;
|
|
254
|
+
position: fixed;
|
|
255
|
+
top: ${position.top}px;
|
|
256
|
+
transform: scale(0);
|
|
257
|
+
transform-origin: ${position.transformOrigin};
|
|
258
|
+
transition: opacity 120ms cubic-bezier(0.4, 0, 0.2, 1) 0ms,
|
|
259
|
+
transform 200ms cubic-bezier(0.4, 0, 0.2, 1) 0ms;
|
|
260
|
+
width: ${width}px;
|
|
261
|
+
z-index: ${zIndex(2)};
|
|
262
|
+
`,
|
|
263
|
+
active: {
|
|
264
|
+
opacity: 1,
|
|
265
|
+
transform: 'scale(1)'
|
|
266
|
+
},
|
|
267
|
+
remove: {
|
|
268
|
+
opacity: 0,
|
|
269
|
+
pointerEvents: 'none',
|
|
270
|
+
transform: 'scale(0)'
|
|
271
|
+
}
|
|
272
|
+
};
|
|
172
273
|
const updateValues = useCallback(v => {
|
|
173
274
|
values.current = v;
|
|
174
275
|
setValues();
|
|
@@ -190,6 +291,63 @@ const DateRangePickerV2 = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
190
291
|
setValueTo();
|
|
191
292
|
}, [valueTo]);
|
|
192
293
|
|
|
294
|
+
const toLocalTimestamp = t => {
|
|
295
|
+
if (typeof t === 'object' && t.getTime) {
|
|
296
|
+
t = t.getTime();
|
|
297
|
+
}
|
|
298
|
+
|
|
299
|
+
if (typeof t === 'string' && !t.match(/\d{13}/)) {
|
|
300
|
+
t = Date.parse(t).getTime();
|
|
301
|
+
}
|
|
302
|
+
|
|
303
|
+
t = parseInt(t, 10) - new Date().getTimezoneOffset() * 60 * 1000;
|
|
304
|
+
return t;
|
|
305
|
+
};
|
|
306
|
+
|
|
307
|
+
const getDaysFrom1970 = t => {
|
|
308
|
+
return Math.floor(toLocalTimestamp(t) / 86400000);
|
|
309
|
+
};
|
|
310
|
+
|
|
311
|
+
const countDays = (start, end) => {
|
|
312
|
+
return Math.abs(getDaysFrom1970(start) - getDaysFrom1970(end)) + (startFromZero ? 0 : 1);
|
|
313
|
+
};
|
|
314
|
+
|
|
315
|
+
const formatValue = (value, format, utc = false) => {
|
|
316
|
+
return moment(value).format(format, utc);
|
|
317
|
+
};
|
|
318
|
+
|
|
319
|
+
const getDateOfWeek = date => {
|
|
320
|
+
let day = date.getDay();
|
|
321
|
+
if (day === 0) day = 7;
|
|
322
|
+
return day - 1;
|
|
323
|
+
};
|
|
324
|
+
|
|
325
|
+
const isValidDate = v => {
|
|
326
|
+
if (!v || v === null) return false;
|
|
327
|
+
|
|
328
|
+
if (Object.prototype.toString.call(v) === '[object Date]') {
|
|
329
|
+
return true;
|
|
330
|
+
}
|
|
331
|
+
|
|
332
|
+
if (!isNaN(Date.parse(new Date(v)))) {
|
|
333
|
+
return true;
|
|
334
|
+
}
|
|
335
|
+
|
|
336
|
+
return false;
|
|
337
|
+
};
|
|
338
|
+
|
|
339
|
+
const isValidValues = v => {
|
|
340
|
+
if (!v || !Array.isArray(v) || v.length !== 2) {
|
|
341
|
+
return false;
|
|
342
|
+
}
|
|
343
|
+
|
|
344
|
+
if (isValidDate(v[0]) && isValidDate(v[1]) && +moment(v[0]).diff(v[1]) <= 0) {
|
|
345
|
+
return true;
|
|
346
|
+
}
|
|
347
|
+
|
|
348
|
+
return false;
|
|
349
|
+
};
|
|
350
|
+
|
|
193
351
|
const isActive = day => {
|
|
194
352
|
if (values.current[0] && +moment(values.current[0]).diff(day) === 0) {
|
|
195
353
|
if (values.current[1] && +moment(values.current[0]).diff(values.current[1]) < 0) {
|
|
@@ -204,6 +362,10 @@ const DateRangePickerV2 = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
204
362
|
return '';
|
|
205
363
|
};
|
|
206
364
|
|
|
365
|
+
const isToday = day => {
|
|
366
|
+
return +moment(day).diff(new Date().setHours(0, 0, 0, 0)) === 0 ? unique.day.today : '';
|
|
367
|
+
};
|
|
368
|
+
|
|
207
369
|
const isBetween = dayParsed => {
|
|
208
370
|
if (values.current[0] && values.current[1] && parseDate(values.current[0]) < dayParsed && dayParsed < parseDate(values.current[1])) {
|
|
209
371
|
return unique.day.between;
|
|
@@ -212,6 +374,18 @@ const DateRangePickerV2 = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
212
374
|
return '';
|
|
213
375
|
};
|
|
214
376
|
|
|
377
|
+
const isLimit = (day, max, min) => {
|
|
378
|
+
return isBefore(min, day) || isAfter(max, day) ? unique.day.limit : '';
|
|
379
|
+
};
|
|
380
|
+
|
|
381
|
+
const isBefore = (min, time) => {
|
|
382
|
+
return min && isValidDate(min) && moment(time).diff(min) < 0;
|
|
383
|
+
};
|
|
384
|
+
|
|
385
|
+
const isAfter = (max, time) => {
|
|
386
|
+
return max && isValidDate(max) && moment(time).diff(max) > 0;
|
|
387
|
+
};
|
|
388
|
+
|
|
215
389
|
const countDay = v => {
|
|
216
390
|
if (v && Array.isArray(v) && v.length === 2) {
|
|
217
391
|
return Number(+moment(v[1]).diff(v[0]) + (startFromZero ? 0 : 1));
|
|
@@ -273,6 +447,10 @@ const DateRangePickerV2 = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
273
447
|
}
|
|
274
448
|
};
|
|
275
449
|
|
|
450
|
+
const parseDate = day => {
|
|
451
|
+
return Date.parse(new Date(day));
|
|
452
|
+
};
|
|
453
|
+
|
|
276
454
|
const renderCalendar = (time, type) => {
|
|
277
455
|
time = new Date(time);
|
|
278
456
|
const firstDay = new Date(new Date(time).setDate(1)),
|
|
@@ -294,7 +472,7 @@ const DateRangePickerV2 = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
294
472
|
tableData.push(jsx("td", {
|
|
295
473
|
key: `previous_month-${prevDate - i + 1}`,
|
|
296
474
|
"data-time": day - 1,
|
|
297
|
-
className:
|
|
475
|
+
className: `${[unique.table.data, 'previous_month', isBetween(day - 1)].join(' ').trim().replace(/ +(?= )/g, '')}`
|
|
298
476
|
}, jsx("span", {
|
|
299
477
|
className: unique.day.day
|
|
300
478
|
})));
|
|
@@ -309,23 +487,9 @@ const DateRangePickerV2 = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
309
487
|
tableData.push(jsx("td", {
|
|
310
488
|
key: `this_month-${i + 1}`,
|
|
311
489
|
"data-time": Date.parse(day),
|
|
312
|
-
className:
|
|
490
|
+
className: `${[unique.table.data, 'this_month', isToday(day), isActive(day), (max && max !== undefined || min && min !== undefined) && isLimit(day, new Date(max).setHours(0, 0, 0, 0), new Date(min).setHours(0, 0, 0, 0)), isBetween(Date.parse(day))].join(' ').trim().replace(/ +(?= )/g, '')}`,
|
|
313
491
|
onClick: onDayClick
|
|
314
|
-
}, jsx(Typography, {
|
|
315
|
-
className: unique.day.day,
|
|
316
|
-
color: 'inherit',
|
|
317
|
-
style: {
|
|
318
|
-
alignItems: 'center',
|
|
319
|
-
borderRadius: '50%',
|
|
320
|
-
display: 'flex',
|
|
321
|
-
height: 24,
|
|
322
|
-
justifyContent: 'center',
|
|
323
|
-
margin: 'auto',
|
|
324
|
-
pointerEvents: 'none',
|
|
325
|
-
transition: 'background-color 150ms linear',
|
|
326
|
-
width: 24
|
|
327
|
-
},
|
|
328
|
-
type: 'h6'
|
|
492
|
+
}, jsx(Typography, { ...typographyProps(unique.day.day)
|
|
329
493
|
}, i + 1)));
|
|
330
494
|
}
|
|
331
495
|
/**
|
|
@@ -338,7 +502,7 @@ const DateRangePickerV2 = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
338
502
|
tableData.push(jsx("td", {
|
|
339
503
|
key: `next_month-${i + 1}`,
|
|
340
504
|
"data-time": i < 6 - weekDateLast && day + 1,
|
|
341
|
-
className:
|
|
505
|
+
className: `${[unique.table.data, 'next_month', i < 6 - weekDateLast && isBetween(day + 1)].join(' ').trim().replace(/ +(?= )/g, '')}`
|
|
342
506
|
}, jsx("span", {
|
|
343
507
|
className: unique.day.day
|
|
344
508
|
})));
|
|
@@ -348,7 +512,7 @@ const DateRangePickerV2 = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
348
512
|
for (let j = 0; j < 7; j++) {
|
|
349
513
|
tableRaw.push(tableData[7 * i + j] || jsx("td", {
|
|
350
514
|
key: 7 * i + j,
|
|
351
|
-
className:
|
|
515
|
+
className: `${[unique.table.data, 'next_month'].join(' ').trim().replace(/ +(?= )/g, '')}`
|
|
352
516
|
}));
|
|
353
517
|
}
|
|
354
518
|
|
|
@@ -405,7 +569,7 @@ const DateRangePickerV2 = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
405
569
|
}
|
|
406
570
|
};
|
|
407
571
|
|
|
408
|
-
const getPickerStyle =
|
|
572
|
+
const getPickerStyle = () => {
|
|
409
573
|
const {
|
|
410
574
|
innerHeight,
|
|
411
575
|
innerWidth
|
|
@@ -415,8 +579,8 @@ const DateRangePickerV2 = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
415
579
|
height,
|
|
416
580
|
top,
|
|
417
581
|
width
|
|
418
|
-
} =
|
|
419
|
-
const pickerHeight =
|
|
582
|
+
} = ipConRef.current.getBoundingClientRect();
|
|
583
|
+
const pickerHeight = width < 567 ? controls ? 550 : 495 : controls ? 310 : 256;
|
|
420
584
|
let style = {};
|
|
421
585
|
style.left = left;
|
|
422
586
|
style.top = top + height + 4;
|
|
@@ -424,7 +588,7 @@ const DateRangePickerV2 = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
424
588
|
|
|
425
589
|
if (style.top + pickerHeight > innerHeight) {
|
|
426
590
|
if (top > pickerHeight) {
|
|
427
|
-
style.top =
|
|
591
|
+
style.top = top - pickerHeight - 4;
|
|
428
592
|
style.transformOrigin = '50% 80%';
|
|
429
593
|
} else {
|
|
430
594
|
style.top = Math.round((innerHeight - pickerHeight - 16) / 2);
|
|
@@ -467,10 +631,10 @@ const DateRangePickerV2 = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
467
631
|
return background;
|
|
468
632
|
};
|
|
469
633
|
|
|
470
|
-
const createPicker =
|
|
634
|
+
const createPicker = () => {
|
|
471
635
|
const picker = document.createElement('div');
|
|
472
636
|
picker.id = unique.picker;
|
|
473
|
-
picker.style.cssText = getPickerStyle(
|
|
637
|
+
picker.style.cssText = getPickerStyle();
|
|
474
638
|
return picker;
|
|
475
639
|
};
|
|
476
640
|
|
|
@@ -705,7 +869,7 @@ const DateRangePickerV2 = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
705
869
|
}
|
|
706
870
|
|
|
707
871
|
if (values.current[0] && !values.current[1]) {
|
|
708
|
-
const dates = Math.abs(countDays(new Date(values.current), new Date(currentTime)
|
|
872
|
+
const dates = Math.abs(countDays(new Date(values.current), new Date(currentTime)));
|
|
709
873
|
const tooltip = tooltipRef.current;
|
|
710
874
|
|
|
711
875
|
if (onShowTooltip && dates > 0) {
|
|
@@ -755,9 +919,9 @@ const DateRangePickerV2 = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
755
919
|
renderCalendar(valueTo.current, 'to');
|
|
756
920
|
};
|
|
757
921
|
|
|
758
|
-
const openPicker =
|
|
922
|
+
const openPicker = () => {
|
|
759
923
|
const backGr = createBackground();
|
|
760
|
-
const picker = createPicker(
|
|
924
|
+
const picker = createPicker();
|
|
761
925
|
render(pickerComp, backGr.appendChild(picker));
|
|
762
926
|
const arr = pickerRef.current.getElementsByTagName('td');
|
|
763
927
|
updateTempValues(values.current.length === 1 ? [values.current[0], values.current[0]] : values.current);
|
|
@@ -952,23 +1116,8 @@ const DateRangePickerV2 = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
952
1116
|
closePicker();
|
|
953
1117
|
};
|
|
954
1118
|
}, [actionIconAt, clearAble, controls, disabled, displayFormat, max, min, pressESCToClose, readOnly, startFromZero, unitCount, viewType]);
|
|
955
|
-
useImperativeHandle(reference, () => {
|
|
956
|
-
const currentRef = ref.current || {};
|
|
957
|
-
currentRef.element = ref.current;
|
|
958
|
-
currentRef.get = ref.current;
|
|
959
|
-
const _instance = {
|
|
960
|
-
show: el => openPicker(el),
|
|
961
|
-
close: closePicker,
|
|
962
|
-
...action
|
|
963
|
-
}; // methods
|
|
964
|
-
|
|
965
|
-
_instance.__proto__ = {}; // hidden methods
|
|
966
|
-
|
|
967
|
-
currentRef.instance = _instance;
|
|
968
|
-
return currentRef;
|
|
969
|
-
});
|
|
970
1119
|
const iconComp = jsx("div", {
|
|
971
|
-
css:
|
|
1120
|
+
css: iconAreaCSS,
|
|
972
1121
|
ref: iconRef
|
|
973
1122
|
}, jsx(ButtonIcon, {
|
|
974
1123
|
viewType: 'ghost',
|
|
@@ -986,7 +1135,7 @@ const DateRangePickerV2 = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
986
1135
|
const endIcon = actionIconAt === 'end' && iconComp;
|
|
987
1136
|
const startIcon = actionIconAt === 'start' && iconComp;
|
|
988
1137
|
const footerMemo = jsx("div", {
|
|
989
|
-
css:
|
|
1138
|
+
css: controlContainerCSS,
|
|
990
1139
|
className: unique.footer,
|
|
991
1140
|
ref: footerRef
|
|
992
1141
|
}, jsx(Button, { ...buttonProps,
|
|
@@ -1022,7 +1171,7 @@ const DateRangePickerV2 = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
1022
1171
|
className: unique.tooltip,
|
|
1023
1172
|
ref: tooltipRef
|
|
1024
1173
|
}, jsx(Typography, {
|
|
1025
|
-
color: white,
|
|
1174
|
+
color: theme.colors.white,
|
|
1026
1175
|
type: 'p2'
|
|
1027
1176
|
}));
|
|
1028
1177
|
const pickerComp = jsx("div", {
|
|
@@ -1030,14 +1179,7 @@ const DateRangePickerV2 = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
1030
1179
|
ref: pickerRef
|
|
1031
1180
|
}, jsx("div", {
|
|
1032
1181
|
className: unique.wrapper
|
|
1033
|
-
}, leftCalendarComp, jsx(Divider, {
|
|
1034
|
-
direction: 'vertical',
|
|
1035
|
-
className: unique.divider,
|
|
1036
|
-
height: '100%',
|
|
1037
|
-
style: {
|
|
1038
|
-
height: '226px',
|
|
1039
|
-
margin: spacing([4.5, 0.5, 0])
|
|
1040
|
-
}
|
|
1182
|
+
}, leftCalendarComp, jsx(Divider, { ...dividerProps
|
|
1041
1183
|
}), rightCalendarComp), tooltipComp, !!controls && footerMemo);
|
|
1042
1184
|
return jsx(ControlComp, { ...props,
|
|
1043
1185
|
disabled: disabled,
|
|
@@ -1067,162 +1209,10 @@ const DateRangePickerV2 = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
1067
1209
|
className: 'non-effect allow-disabled'
|
|
1068
1210
|
},
|
|
1069
1211
|
endIcon: endIcon
|
|
1070
|
-
}), !!error && jsx(HelperText, { ...
|
|
1212
|
+
}), !!error && jsx(HelperText, { ...errorProps,
|
|
1071
1213
|
disabled: disabled
|
|
1072
1214
|
}, error));
|
|
1073
1215
|
}));
|
|
1074
|
-
const unique = {
|
|
1075
|
-
backGr: 'DGN-UI-Portal',
|
|
1076
|
-
close: 'DGN-UI-DateRangePickerV2-close',
|
|
1077
|
-
cancel: 'DGN-UI-DateRangePickerV2-cancel',
|
|
1078
|
-
confirm: 'DGN-UI-DateRangePickerV2-confirm',
|
|
1079
|
-
divider: 'DGN-UI-DateRangePickerV2-Divider',
|
|
1080
|
-
disabled: 'DGN-UI-DateRangePickerV2-disabled',
|
|
1081
|
-
error: 'DGN-UI-DateRangePickerV2-error',
|
|
1082
|
-
focus: 'DGN-UI-DateRangePickerV2-focus',
|
|
1083
|
-
footer: 'DGN-UI-DateRangePickerV2-Footer',
|
|
1084
|
-
picker: 'DGN-UI-DateRangePickerV2-Picker-' + randomString(6, {
|
|
1085
|
-
allowSymbol: false
|
|
1086
|
-
}),
|
|
1087
|
-
wrapper: 'DGN-UI-DateRangePickerV2-Wrapper',
|
|
1088
|
-
container: 'DGN-UI-DateRangePickerV2',
|
|
1089
|
-
icon: 'DGN-UI-DateRangePickerV2-Icon',
|
|
1090
|
-
tooltip: 'DGN-UI-DateRangePickerV2-Tooltip',
|
|
1091
|
-
navigator: {
|
|
1092
|
-
navigator: 'DGN-UI-DateRangePickerV2-Navigator',
|
|
1093
|
-
around: 'DGN-UI-DateRangePickerV2-Navigator-Around',
|
|
1094
|
-
center: 'DGN-UI-DateRangePickerV2-Navigator-Center'
|
|
1095
|
-
},
|
|
1096
|
-
table: {
|
|
1097
|
-
container: 'DGN-UI-DateRangePickerV2-Table-Container',
|
|
1098
|
-
table: 'DGN-UI-DateRangePickerV2-Table-Table',
|
|
1099
|
-
header: 'DGN-UI-DateRangePickerV2-Table-Header',
|
|
1100
|
-
raw: 'DGN-UI-DateRangePickerV2-Table-Raw',
|
|
1101
|
-
data: 'DGN-UI-DateRangePickerV2-Table-Data'
|
|
1102
|
-
},
|
|
1103
|
-
day: {
|
|
1104
|
-
day: 'DGN-UI-DateRangePickerV2-Day',
|
|
1105
|
-
week: 'DGN-UI-DateRangePickerV2-Week',
|
|
1106
|
-
today: 'DGN-UI-DateRangePickerV2-Day-today',
|
|
1107
|
-
active: 'DGN-UI-DateRangePickerV2-Day-active',
|
|
1108
|
-
limit: 'DGN-UI-DateRangePickerV2-Day-limit',
|
|
1109
|
-
from: 'DGN-UI-DateRangePickerV2-Day-from',
|
|
1110
|
-
to: 'DGN-UI-DateRangePickerV2-Day-to',
|
|
1111
|
-
between: 'DGN-UI-DateRangePickerV2-Day-between'
|
|
1112
|
-
}
|
|
1113
|
-
};
|
|
1114
|
-
const hiddenStyle = {
|
|
1115
|
-
opacity: 0,
|
|
1116
|
-
display: 'none'
|
|
1117
|
-
};
|
|
1118
|
-
const activeStyle = {
|
|
1119
|
-
opacity: 1,
|
|
1120
|
-
pointerEvents: 'none',
|
|
1121
|
-
display: 'block'
|
|
1122
|
-
};
|
|
1123
|
-
const buttonProps = {
|
|
1124
|
-
style: {
|
|
1125
|
-
display: 'none',
|
|
1126
|
-
margin: spacing([0, 0.5]),
|
|
1127
|
-
padding: spacing([1.75, 2]),
|
|
1128
|
-
visibility: 'hidden'
|
|
1129
|
-
}
|
|
1130
|
-
};
|
|
1131
|
-
const IconAreaCSS = css`
|
|
1132
|
-
${flexRow};
|
|
1133
|
-
${alignCenter};
|
|
1134
|
-
${parseWidth(24)};
|
|
1135
|
-
color: inherit;
|
|
1136
|
-
& span {
|
|
1137
|
-
padding: 0;
|
|
1138
|
-
}
|
|
1139
|
-
.${unique.icon} {
|
|
1140
|
-
${displayNone};
|
|
1141
|
-
${cursorPointer};
|
|
1142
|
-
opacity: 0;
|
|
1143
|
-
transition: display 50ms cubic-bezier(0.4, 0, 0.2, 1) 0ms, opacity 300ms cubic-bezier(0.4, 0, 0.2, 1) 50ms;
|
|
1144
|
-
will-change: display, opacity;
|
|
1145
|
-
}
|
|
1146
|
-
.${unique.icon}-accept {
|
|
1147
|
-
${displayBlock};
|
|
1148
|
-
opacity: 1;
|
|
1149
|
-
}
|
|
1150
|
-
`;
|
|
1151
|
-
const ControlContainerCSS = css`
|
|
1152
|
-
${flexRow};
|
|
1153
|
-
${justifyEnd};
|
|
1154
|
-
margin: ${spacing([0, 4, 4])};
|
|
1155
|
-
`;
|
|
1156
|
-
const pickerCSS = {
|
|
1157
|
-
backGr: `
|
|
1158
|
-
background-color: transparent;
|
|
1159
|
-
inset: 0px; pointer-events: auto;
|
|
1160
|
-
position: fixed;
|
|
1161
|
-
z-index: ${zIndexCORE(1)};`,
|
|
1162
|
-
container: css`
|
|
1163
|
-
${flexCol};
|
|
1164
|
-
${borderRadius4px};
|
|
1165
|
-
background-color: ${white};
|
|
1166
|
-
box-shadow: ${theme.boxShadows.large};
|
|
1167
|
-
.${unique.wrapper} {
|
|
1168
|
-
${flexRow};
|
|
1169
|
-
min-width: 633px;
|
|
1170
|
-
}
|
|
1171
|
-
.${unique.tooltip} {
|
|
1172
|
-
${borderRadius4px};
|
|
1173
|
-
${pointerEventsNone};
|
|
1174
|
-
${positionFixed};
|
|
1175
|
-
${textCenter};
|
|
1176
|
-
${userSelectNone};
|
|
1177
|
-
${whiteSpaceNoWrap};
|
|
1178
|
-
background-color: rgba(21, 26, 48, 0.9);
|
|
1179
|
-
height: 18px;
|
|
1180
|
-
min-width: 65px;
|
|
1181
|
-
padding: ${spacing([0.75, 1.5])};
|
|
1182
|
-
transition: left 0.05s ease-in, top 0.05s ease-in;
|
|
1183
|
-
vertical-align: middle;
|
|
1184
|
-
visibility: hidden;
|
|
1185
|
-
will-change: left top visibility;
|
|
1186
|
-
z-index: ${zIndexCORE(3)};
|
|
1187
|
-
}
|
|
1188
|
-
@media only screen and (max-width: 599px) {
|
|
1189
|
-
max-width: 400px;
|
|
1190
|
-
.${unique.wrapper} {
|
|
1191
|
-
flex-direction: column;
|
|
1192
|
-
min-width: 260px;
|
|
1193
|
-
}
|
|
1194
|
-
.${unique.divider} {
|
|
1195
|
-
height: 1px !important;
|
|
1196
|
-
margin: ${spacing([0, 4])} !important;
|
|
1197
|
-
width: calc(100% - 32px) !important;
|
|
1198
|
-
}
|
|
1199
|
-
}
|
|
1200
|
-
`,
|
|
1201
|
-
picker: (position, width) => css`
|
|
1202
|
-
${borderRadius4px};
|
|
1203
|
-
${positionFixed};
|
|
1204
|
-
${parseWidth(width)};
|
|
1205
|
-
height: max-content;
|
|
1206
|
-
left: ${position.left}px;
|
|
1207
|
-
max-width: 805px;
|
|
1208
|
-
min-width: ${window.innerWidth <= 633 ? 300 : 633}px;
|
|
1209
|
-
opacity: 0;
|
|
1210
|
-
top: ${position.top}px;
|
|
1211
|
-
transform: scale(0);
|
|
1212
|
-
transform-origin: ${position.transformOrigin};
|
|
1213
|
-
transition: opacity 120ms cubic-bezier(0.4, 0, 0.2, 1) 0ms, transform 200ms cubic-bezier(0.4, 0, 0.2, 1) 0ms;
|
|
1214
|
-
z-index: ${zIndexCORE(2)};
|
|
1215
|
-
`,
|
|
1216
|
-
active: {
|
|
1217
|
-
opacity: 1,
|
|
1218
|
-
transform: 'scale(1)'
|
|
1219
|
-
},
|
|
1220
|
-
remove: {
|
|
1221
|
-
opacity: 0,
|
|
1222
|
-
pointerEvents: 'none',
|
|
1223
|
-
transform: 'scale(0)'
|
|
1224
|
-
}
|
|
1225
|
-
};
|
|
1226
1216
|
DateRangePickerV2.defaultProps = {
|
|
1227
1217
|
actionIconAt: 'end',
|
|
1228
1218
|
clearAble: false,
|
|
@@ -1241,85 +1231,82 @@ DateRangePickerV2.defaultProps = {
|
|
|
1241
1231
|
viewType: 'underlined'
|
|
1242
1232
|
};
|
|
1243
1233
|
DateRangePickerV2.propTypes = {
|
|
1244
|
-
/**
|
|
1234
|
+
/** action icons position */
|
|
1245
1235
|
actionIconAt: PropTypes.oneOf(['end', 'start']),
|
|
1246
1236
|
|
|
1247
|
-
/**
|
|
1237
|
+
/** display the clear icon if true */
|
|
1248
1238
|
clearAble: PropTypes.bool,
|
|
1249
1239
|
|
|
1250
|
-
/**
|
|
1240
|
+
/** if 'true' the calendar will have a footer controls */
|
|
1251
1241
|
controls: PropTypes.bool,
|
|
1252
1242
|
|
|
1253
|
-
/**
|
|
1243
|
+
/** the count unit when select */
|
|
1254
1244
|
unitCount: PropTypes.oneOf(['day', 'night']),
|
|
1255
1245
|
|
|
1256
|
-
/**
|
|
1246
|
+
/** the default value of the component */
|
|
1257
1247
|
defaultValue: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.instanceOf(Date)), PropTypes.arrayOf(PropTypes.string)]),
|
|
1258
1248
|
|
|
1259
|
-
/**
|
|
1249
|
+
/** if 'true' the form control will be disabled */
|
|
1260
1250
|
disabled: PropTypes.bool,
|
|
1261
1251
|
|
|
1262
|
-
/**
|
|
1252
|
+
/** format to display value */
|
|
1263
1253
|
displayFormat: PropTypes.oneOfType([PropTypes.oneOf(['DD/MM/YYYY', 'MM/DD/YYYY', 'YYYY/MM/DD', 'DD-MM-YYYY', 'MM-DD-YYYY', 'YYYY-MM-DD']), PropTypes.string]),
|
|
1264
1254
|
|
|
1265
|
-
/**
|
|
1255
|
+
/** error of the form control */
|
|
1266
1256
|
error: PropTypes.string,
|
|
1267
1257
|
|
|
1268
|
-
/**
|
|
1269
|
-
helperTextProps: PropTypes.object,
|
|
1270
|
-
|
|
1271
|
-
/** [Props](https://core.diginet.com.vn/ui/?path=/story/form-control-input-inputbase) of input base */
|
|
1258
|
+
/** inputProps are properties of the input element */
|
|
1272
1259
|
inputProps: PropTypes.object,
|
|
1273
1260
|
|
|
1274
|
-
/**
|
|
1261
|
+
/** inputStyle is style of input element */
|
|
1275
1262
|
inputStyle: PropTypes.object,
|
|
1276
1263
|
|
|
1277
|
-
/**
|
|
1264
|
+
/** content of the label element */
|
|
1278
1265
|
label: PropTypes.string,
|
|
1279
1266
|
|
|
1280
|
-
/**
|
|
1267
|
+
/** labelProps are properties if the label element */
|
|
1281
1268
|
labelProps: PropTypes.object,
|
|
1282
1269
|
|
|
1283
|
-
/**
|
|
1270
|
+
/** min value of date picker */
|
|
1284
1271
|
min: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.string]),
|
|
1285
1272
|
|
|
1286
|
-
/**
|
|
1273
|
+
/** max value of date picker */
|
|
1287
1274
|
max: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.string]),
|
|
1288
1275
|
|
|
1289
|
-
/**
|
|
1276
|
+
/** a callback function when value input change */
|
|
1290
1277
|
onChange: PropTypes.func,
|
|
1291
1278
|
|
|
1292
|
-
/**
|
|
1279
|
+
/** hints for input */
|
|
1293
1280
|
placeholder: PropTypes.string,
|
|
1294
1281
|
|
|
1295
|
-
/**
|
|
1282
|
+
/** allow close Popup when press ESC */
|
|
1296
1283
|
pressESCToClose: PropTypes.bool,
|
|
1297
1284
|
|
|
1298
|
-
/**
|
|
1285
|
+
/** status read only of input */
|
|
1299
1286
|
readOnly: PropTypes.bool,
|
|
1300
1287
|
|
|
1301
|
-
/**
|
|
1288
|
+
/** required state of the form control */
|
|
1302
1289
|
required: PropTypes.bool,
|
|
1303
1290
|
|
|
1304
|
-
/**
|
|
1291
|
+
/** format of the returned value */
|
|
1305
1292
|
returnFormat: PropTypes.oneOfType([PropTypes.oneOf(['DD/MM/YYYY', 'MM/DD/YYYY', 'YYYY/MM/DD', 'DD-MM-YYYY', 'MM-DD-YYYY', 'YYYY-MM-DD']), PropTypes.string]),
|
|
1306
1293
|
|
|
1307
1294
|
/** If `true`, show unit count. */
|
|
1308
1295
|
showUnitCount: PropTypes.bool,
|
|
1309
1296
|
|
|
1310
|
-
/**
|
|
1297
|
+
/** counter with start with 0 or 1 */
|
|
1311
1298
|
startFromZero: PropTypes.bool,
|
|
1312
1299
|
|
|
1313
|
-
/**
|
|
1300
|
+
/** style of the component */
|
|
1314
1301
|
style: PropTypes.object,
|
|
1315
1302
|
|
|
1316
|
-
/**
|
|
1303
|
+
/** text align of the input */
|
|
1317
1304
|
textAlign: PropTypes.oneOf(['center', 'end', 'start']),
|
|
1318
1305
|
|
|
1319
|
-
/**
|
|
1306
|
+
/** value of the component */
|
|
1320
1307
|
value: PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.string])),
|
|
1321
1308
|
|
|
1322
|
-
/**
|
|
1309
|
+
/** view type of the form control */
|
|
1323
1310
|
viewType: PropTypes.oneOf(['outlined', 'underlined'])
|
|
1324
1311
|
};
|
|
1325
1312
|
export default DateRangePickerV2;
|
|
@@ -57,13 +57,6 @@ const checkHasValue = value => {
|
|
|
57
57
|
return Array.isArray(value) ? value.length > 0 : value === 0 || !!value;
|
|
58
58
|
};
|
|
59
59
|
|
|
60
|
-
const convertData = (dt, valueExpr) => {
|
|
61
|
-
let data = dt || [];
|
|
62
|
-
let valueTemp = Array.isArray(data) ? data : [data];
|
|
63
|
-
valueTemp = valueTemp.map(i => i[valueExpr] || i);
|
|
64
|
-
return valueTemp;
|
|
65
|
-
};
|
|
66
|
-
|
|
67
60
|
const Dropdown = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
68
61
|
viewType,
|
|
69
62
|
itemMode,
|
|
@@ -137,10 +130,10 @@ const Dropdown = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
137
130
|
const [openState, setOpenState] = useState(false);
|
|
138
131
|
const [showClear, setShowClear] = useState(false);
|
|
139
132
|
const [textValue, setTextValue] = useState('');
|
|
140
|
-
let valueTemp = valueProp || defaultValue
|
|
133
|
+
let valueTemp = valueProp || defaultValue || [];
|
|
141
134
|
|
|
142
|
-
if (multiple) {
|
|
143
|
-
valueTemp =
|
|
135
|
+
if (multiple && valueTemp && !Array.isArray(valueTemp)) {
|
|
136
|
+
valueTemp = [valueTemp];
|
|
144
137
|
}
|
|
145
138
|
|
|
146
139
|
const [valueMulti, setValueMulti] = useState(valueTemp);
|
|
@@ -1219,7 +1212,7 @@ const Dropdown = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
1219
1212
|
}
|
|
1220
1213
|
|
|
1221
1214
|
if (multiple && valueProp) {
|
|
1222
|
-
setValueMulti(
|
|
1215
|
+
setValueMulti(!Array.isArray(valueProp) ? [valueProp] : valueProp);
|
|
1223
1216
|
} // Close dropdown treeview by children when select item
|
|
1224
1217
|
|
|
1225
1218
|
|
|
@@ -1377,18 +1370,10 @@ const Dropdown = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
1377
1370
|
let text = '';
|
|
1378
1371
|
|
|
1379
1372
|
if (data) {
|
|
1380
|
-
var
|
|
1381
|
-
|
|
1382
|
-
displayExpr = typeof renderSelectedItem === 'string' ? renderSelectedItem : displayExpr || valueExpr;
|
|
1383
|
-
let mask = data === null || data === void 0 ? void 0 : data[displayExpr]; // convert {id} - {name} to {<data[id]>} - {<data[name]>}
|
|
1384
|
-
|
|
1385
|
-
if (!mask && regexBetween.test(displayExpr)) {
|
|
1386
|
-
var _displayExpr4;
|
|
1387
|
-
|
|
1388
|
-
mask = (_displayExpr4 = displayExpr) === null || _displayExpr4 === void 0 ? void 0 : _displayExpr4.replace(regexBetween, _ => data[_]);
|
|
1389
|
-
}
|
|
1373
|
+
var _displayExpr4;
|
|
1390
1374
|
|
|
1391
|
-
|
|
1375
|
+
const mask = (data === null || data === void 0 ? void 0 : data[displayExpr]) || ((_displayExpr4 = displayExpr) === null || _displayExpr4 === void 0 ? void 0 : _displayExpr4.replace(regexBetween, _ => data[_]));
|
|
1376
|
+
text = mask === null || mask === void 0 ? void 0 : mask.replace(regexInclude, '');
|
|
1392
1377
|
}
|
|
1393
1378
|
|
|
1394
1379
|
let item = null;
|
|
@@ -23,16 +23,16 @@ const {
|
|
|
23
23
|
} = useTheme();
|
|
24
24
|
const Label = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
25
25
|
action = {},
|
|
26
|
-
children,
|
|
27
|
-
className,
|
|
28
|
-
color,
|
|
29
26
|
disabled,
|
|
30
|
-
hoverTooltip,
|
|
31
|
-
id,
|
|
32
|
-
lineClamp,
|
|
33
27
|
readOnly,
|
|
34
28
|
required,
|
|
29
|
+
className,
|
|
30
|
+
children,
|
|
35
31
|
type,
|
|
32
|
+
lineClamp,
|
|
33
|
+
hoverTooltip,
|
|
34
|
+
id,
|
|
35
|
+
color,
|
|
36
36
|
...props
|
|
37
37
|
}, reference) => {
|
|
38
38
|
const ref = useRef(null);
|
|
@@ -13,9 +13,6 @@ const {
|
|
|
13
13
|
colors: {
|
|
14
14
|
system: {
|
|
15
15
|
white
|
|
16
|
-
},
|
|
17
|
-
fill: {
|
|
18
|
-
tooltip: fillTooltip
|
|
19
16
|
}
|
|
20
17
|
},
|
|
21
18
|
typography: {
|
|
@@ -132,7 +129,6 @@ const getDirectionPopover = direction => {
|
|
|
132
129
|
}
|
|
133
130
|
};
|
|
134
131
|
|
|
135
|
-
const backgroundMap = new Map([['light', white], ['dark', fillTooltip]]);
|
|
136
132
|
const Popover = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
137
133
|
action = {},
|
|
138
134
|
anchor,
|
|
@@ -496,10 +492,7 @@ const Popover = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
496
492
|
const currentRef = ref.current || {};
|
|
497
493
|
currentRef.element = ref.current;
|
|
498
494
|
const _instance = {
|
|
499
|
-
show: el =>
|
|
500
|
-
if (el) setElement(el);
|
|
501
|
-
!openState && el ? updatePositionPopover(el, onOpenPopover()) : onOpenPopover();
|
|
502
|
-
},
|
|
495
|
+
show: el => !openState && el ? updatePositionPopover(el, onOpenPopover()) : onOpenPopover(),
|
|
503
496
|
close: () => onClosePopover(),
|
|
504
497
|
setPosition: el => updatePositionPopover(el),
|
|
505
498
|
...action
|
|
@@ -511,10 +504,7 @@ const Popover = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
511
504
|
|
|
512
505
|
currentRef.instance = _instance;
|
|
513
506
|
|
|
514
|
-
currentRef.show = el =>
|
|
515
|
-
if (el) setElement(el);
|
|
516
|
-
!openState && el ? updatePositionPopover(el, onOpenPopover()) : onOpenPopover();
|
|
517
|
-
};
|
|
507
|
+
currentRef.show = el => !openState && el ? updatePositionPopover(el, onOpenPopover()) : onOpenPopover();
|
|
518
508
|
|
|
519
509
|
currentRef.close = onClosePopover;
|
|
520
510
|
|
|
@@ -582,9 +572,8 @@ const PopoverContainerCSS = (bgColor, width, height) => css`
|
|
|
582
572
|
transition: opacity 0.3s ease;
|
|
583
573
|
pointer-events: initial;
|
|
584
574
|
opacity: 0;
|
|
585
|
-
background-color: ${
|
|
575
|
+
background-color: ${bgColor};
|
|
586
576
|
box-shadow: 0px 4px 4px rgba(0, 0, 0, 0.25);
|
|
587
|
-
${bgColor === 'dark' && `color: ${white};`}
|
|
588
577
|
`;
|
|
589
578
|
|
|
590
579
|
const PopoverArrowCSS = bgColor => css`
|
|
@@ -593,7 +582,7 @@ const PopoverArrowCSS = bgColor => css`
|
|
|
593
582
|
${parseWidthHeight(0)};
|
|
594
583
|
border-left: 6px solid transparent;
|
|
595
584
|
border-right: 6px solid transparent;
|
|
596
|
-
border-bottom: 6px solid ${
|
|
585
|
+
border-bottom: 6px solid ${bgColor};
|
|
597
586
|
`;
|
|
598
587
|
|
|
599
588
|
Popover.defaultProps = {
|
|
@@ -602,7 +591,7 @@ Popover.defaultProps = {
|
|
|
602
591
|
horizontal: 'center'
|
|
603
592
|
},
|
|
604
593
|
arrow: false,
|
|
605
|
-
bgColor:
|
|
594
|
+
bgColor: white,
|
|
606
595
|
className: '',
|
|
607
596
|
clickOutsideToClose: true,
|
|
608
597
|
fullScreen: false,
|
|
@@ -641,7 +630,7 @@ Popover.propTypes = {
|
|
|
641
630
|
arrow: PropTypes.bool,
|
|
642
631
|
|
|
643
632
|
/** Background color of the component. */
|
|
644
|
-
bgColor: PropTypes.
|
|
633
|
+
bgColor: PropTypes.string,
|
|
645
634
|
|
|
646
635
|
/** The content of the component. */
|
|
647
636
|
children: PropTypes.node,
|
package/components/tab/tab.js
CHANGED
|
@@ -111,7 +111,7 @@ const TabItem = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
111
111
|
css: _IndicatorCSS,
|
|
112
112
|
className: 'Indicator'
|
|
113
113
|
}));
|
|
114
|
-
}, [children, className, color, disabled, endIcon, index, label,
|
|
114
|
+
}, [children, className, color, disabled, endIcon, index, label, level, onClick, props, startIcon, style, isVertical, tabIndexState]);
|
|
115
115
|
}));
|
|
116
116
|
|
|
117
117
|
const TabButtonCSS = (color, isVertical) => css`
|
|
@@ -229,8 +229,8 @@ TabItem.propTypes = {
|
|
|
229
229
|
/** Any props else. */
|
|
230
230
|
props: PropTypes.any,
|
|
231
231
|
|
|
232
|
-
/**
|
|
233
|
-
* Ref methods.
|
|
232
|
+
/**
|
|
233
|
+
* Ref methods.
|
|
234
234
|
*/
|
|
235
235
|
reference: ref
|
|
236
236
|
};
|
package/package.json
CHANGED
|
@@ -1,72 +1,42 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "diginet-core-ui",
|
|
3
|
-
"version": "1.3.
|
|
4
|
-
"description": "",
|
|
3
|
+
"version": "1.3.76",
|
|
4
|
+
"description": "The DigiNet core ui",
|
|
5
|
+
"homepage": "https://diginet.com.vn",
|
|
5
6
|
"main": "index.js",
|
|
6
|
-
"license": "UNLICENSED",
|
|
7
7
|
"scripts": {
|
|
8
|
-
"start": "
|
|
9
|
-
"start
|
|
10
|
-
"build
|
|
11
|
-
"
|
|
12
|
-
"
|
|
13
|
-
"build:darwin:linux:default": "rm -rf dist && npm run compile && sass --style=compressed src/scss:dist/css && cp -rf src/assets dist/assets",
|
|
14
|
-
"compile": "babel src --out-dir dist --ignore **/*.stories.js",
|
|
15
|
-
"pack": "npm run build && cp *.md dist/ && npm run version:bump --silent && npm run version:add --silent && cd dist && npm pack",
|
|
16
|
-
"production-keep-version": "npm run build && cp *.md dist/ && cp package.json dist/ && cd dist && npm publish",
|
|
17
|
-
"beta": "npm run build && cp *.md dist/ && cp package.json dist/ && cd dist && npm publish --tag beta",
|
|
18
|
-
"production": "npm run build && cp *.md dist/ && npm run version:bump --silent && npm run version:add --silent && cd dist && npm publish",
|
|
19
|
-
"version:add": "run-script-os",
|
|
20
|
-
"version:add:windows": "cat package.json.tmp | sed \"s/0.0.0/%npm_package_version%/g\" > dist/package.json",
|
|
21
|
-
"version:add:darwin:linux:default": "VERSION=$(npm run version:extract --silent) && cat package.json.tmp | sed \"s/0.0.0/${VERSION}/g\" > dist/package.json",
|
|
22
|
-
"version:bump": "npm version patch --no-git-tag-version --silent",
|
|
23
|
-
"version:extract": "cat package.json | grep version | head -1 | awk -F: '{ print $2 }' | sed 's/[\",]//g' | tr -d '[[:space:]]'",
|
|
24
|
-
"test": "echo \"Error: no test specified\" && exit 1",
|
|
25
|
-
"lint": "eslint --fix --config .eslintrc.js \"**/*.js\"",
|
|
26
|
-
"eslint-test": "onchange \"src/**/*.{js,jsx,json}\" -- eslint . --fix",
|
|
27
|
-
"test-storybook": "test-storybook --url http://localhost:9050"
|
|
8
|
+
"start-js": "react-scripts start --max_old_space_size=4096",
|
|
9
|
+
"start": "npx npm-run-all -p start-js",
|
|
10
|
+
"build": "GENERATE_SOURCEMAP=false && react-scripts build --env=production --max_old_space_size=8192",
|
|
11
|
+
"eject": "react-scripts eject",
|
|
12
|
+
"test": "echo \"Error: no test specified\" && exit 1"
|
|
28
13
|
},
|
|
29
14
|
"dependencies": {
|
|
30
15
|
"@emotion/core": "^10.0.35",
|
|
31
16
|
"prop-types": "^15.7.2"
|
|
32
17
|
},
|
|
33
|
-
"
|
|
34
|
-
"
|
|
35
|
-
|
|
36
|
-
"git add"
|
|
37
|
-
]
|
|
18
|
+
"repository": {
|
|
19
|
+
"type": "git",
|
|
20
|
+
"url": "git+https://diginetvn@bitbucket.org/diginetvn/diginet-core-ui.git"
|
|
38
21
|
},
|
|
39
|
-
"
|
|
40
|
-
"
|
|
41
|
-
"
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
"husky": "^7.0.4",
|
|
60
|
-
"jest": "^27.5.1",
|
|
61
|
-
"lint-staged": "^12.1.2",
|
|
62
|
-
"mkdirp": "^1.0.4",
|
|
63
|
-
"npm-run-all": "^4.1.5",
|
|
64
|
-
"onchange": "^7.1.0",
|
|
65
|
-
"postcss-flexbugs-fixes": "^5.0.2",
|
|
66
|
-
"react": "^17.0.1",
|
|
67
|
-
"react-dom": "^17.0.1",
|
|
68
|
-
"rimraf": "^3.0.2",
|
|
69
|
-
"run-script-os": "^1.1.6",
|
|
70
|
-
"sass": "^1.37.0"
|
|
71
|
-
}
|
|
22
|
+
"keywords": [
|
|
23
|
+
"core ui",
|
|
24
|
+
"diginet"
|
|
25
|
+
],
|
|
26
|
+
"author": "rocachien",
|
|
27
|
+
"contributors": [
|
|
28
|
+
{
|
|
29
|
+
"name": "Chien Do",
|
|
30
|
+
"email": "rocachien@gmail.com"
|
|
31
|
+
},
|
|
32
|
+
{
|
|
33
|
+
"name": "Nhat Tran",
|
|
34
|
+
"email": "tranminhnhat1005@gmail.com"
|
|
35
|
+
},
|
|
36
|
+
{
|
|
37
|
+
"name": "Thuan Nguyen",
|
|
38
|
+
"email": "nt.thuan.hutech@gmail.com"
|
|
39
|
+
}
|
|
40
|
+
],
|
|
41
|
+
"license": "MIT"
|
|
72
42
|
}
|
package/readme.md
CHANGED
|
@@ -38,6 +38,17 @@ npm test
|
|
|
38
38
|
```
|
|
39
39
|
|
|
40
40
|
## Changelog
|
|
41
|
+
## 1.3.76
|
|
42
|
+
- \[Fixed\]: Checkbox – Fix bug not return e.target.value
|
|
43
|
+
- \[Fixed\]: NumberInput – Fix e.target in onChange is not element
|
|
44
|
+
- \[Changed\]: Tab – Add useMemo in TabContainer, TabHeader, TabItem, TabPanel
|
|
45
|
+
- \[Changed\]: CircularProgress – Allow prop color, percentColor use CUI colors
|
|
46
|
+
- \[Fixed\]: Tooltip – Fix tooltip container width height
|
|
47
|
+
- \[Fixed\]: Datepicker – Fix width related Tooltip
|
|
48
|
+
- \[Fixed\]: InputBase – Fix not receive new value state
|
|
49
|
+
- \[Fixed\]: HelperText – Fix margin top not match design
|
|
50
|
+
- \[Fixed\]: Dropdown – Fix placeholder show multiline
|
|
51
|
+
|
|
41
52
|
## 1.3.75
|
|
42
53
|
- \[Fixed\]: Typography – Fix word-break css
|
|
43
54
|
|