diginet-core-ui 1.3.78 → 1.3.79
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/accordion/details.js +2 -6
- package/components/accordion/group.js +2 -9
- package/components/accordion/index.js +2 -15
- package/components/accordion/summary.js +4 -27
- package/components/alert/index.js +98 -137
- package/components/alert/notify.js +97 -166
- package/components/avatar/index.js +4 -63
- package/components/badge/index.js +7 -34
- package/components/button/icon.js +120 -186
- package/components/button/index.js +136 -205
- package/components/button/more.js +0 -12
- package/components/button/ripple-effect.js +46 -44
- package/components/card/body.js +2 -7
- package/components/card/extra.js +2 -7
- package/components/card/footer.js +2 -7
- package/components/card/header.js +2 -7
- package/components/card/index.js +2 -22
- package/components/chart/Pie/Circle.js +0 -1
- package/components/chart/Pie/Sector.js +0 -17
- package/components/chart/Pie/Sectors.js +0 -10
- package/components/chart/Pie/index.js +4 -36
- package/components/chart/Pie-v2/Circle.js +0 -1
- package/components/chart/Pie-v2/Sector.js +0 -13
- package/components/chart/Pie-v2/Sectors.js +0 -20
- package/components/chart/Pie-v2/index.js +11 -38
- package/components/chart/bar/Axis.js +0 -12
- package/components/chart/bar/Bar.js +13 -35
- package/components/chart/bar/Grid.js +0 -18
- package/components/chart/bar/Labels.js +0 -18
- package/components/chart/bar/Points.js +0 -17
- package/components/chart/bar/index.js +6 -26
- package/components/chart/bar-v2/Axis.js +0 -12
- package/components/chart/bar-v2/Bar.js +15 -36
- package/components/chart/bar-v2/Grid.js +0 -18
- package/components/chart/bar-v2/Labels.js +0 -18
- package/components/chart/bar-v2/Points.js +0 -17
- package/components/chart/bar-v2/index.js +6 -26
- package/components/chart/line/Axis.js +4 -16
- package/components/chart/line/Grid.js +2 -19
- package/components/chart/line/Labels.js +0 -18
- package/components/chart/line/Path.js +23 -33
- package/components/chart/line/Point.js +6 -40
- package/components/chart/line/Title.js +0 -3
- package/components/chart/line/index.js +12 -35
- package/components/chart/line-v2/Axis.js +0 -13
- package/components/chart/line-v2/Grid.js +0 -18
- package/components/chart/line-v2/Labels.js +0 -18
- package/components/chart/line-v2/Path.js +23 -33
- package/components/chart/line-v2/Point.js +6 -35
- package/components/chart/line-v2/Title.js +0 -3
- package/components/chart/line-v2/index.js +12 -30
- package/components/check-text/index.js +0 -8
- package/components/check-text/interview-confirmation.js +0 -7
- package/components/check-text/interview-status.js +0 -7
- package/components/chip/attach.js +4 -17
- package/components/chip/index.js +6 -33
- package/components/collapse/index.js +0 -13
- package/components/divider/index.js +0 -8
- package/components/form-control/attachment/index.js +24 -202
- package/components/form-control/calendar/function.js +40 -94
- package/components/form-control/calendar/index.js +5 -30
- package/components/form-control/calendar/range.js +11 -28
- package/components/form-control/checkbox/index.js +4 -37
- package/components/form-control/control/index.js +3 -13
- package/components/form-control/date-picker/index-old.js +18 -0
- package/components/form-control/date-picker/index.js +23 -99
- package/components/form-control/date-range-picker/index.js +86 -221
- package/components/form-control/dropdown/index.js +72 -289
- package/components/form-control/dropdown-box/index.js +6 -35
- package/components/form-control/form/index.js +0 -2
- package/components/form-control/form-group/index.js +1 -6
- package/components/form-control/helper-text/index.js +2 -9
- package/components/form-control/input-base/index.js +218 -399
- package/components/form-control/label/index.js +2 -12
- package/components/form-control/money-input/index.js +43 -132
- package/components/form-control/number-input/index.js +15 -113
- package/components/form-control/number-input/index2.js +78 -119
- package/components/form-control/phone-input/index.js +16 -78
- package/components/form-control/radio/index.js +4 -23
- package/components/form-control/text-input/index.js +33 -256
- package/components/form-control/time-picker/index.js +14 -71
- package/components/form-control/time-picker/swiper.js +21 -73
- package/components/form-control/toggle/index.js +4 -19
- package/components/form-view/helper-text.js +2 -2
- package/components/form-view/index.js +0 -14
- package/components/form-view/input.js +2 -13
- package/components/form-view/label.js +0 -2
- package/components/grid/Col.js +2 -15
- package/components/grid/Container.js +2 -21
- package/components/grid/Row.js +2 -21
- package/components/grid/index.js +2 -43
- package/components/image/index.js +2 -22
- package/components/index.js +62 -31
- package/components/list/list-item-action.js +0 -9
- package/components/list/list-item-icon.js +0 -9
- package/components/list/list-item-text.js +0 -5
- package/components/list/list-item.js +0 -11
- package/components/list/list.js +0 -13
- package/components/list/sub-header.js +0 -4
- package/components/modal/body.js +2 -6
- package/components/modal/footer.js +2 -11
- package/components/modal/header.js +2 -12
- package/components/modal/index.js +2 -10
- package/components/modal/modal.js +11 -52
- package/components/others/extra/index.js +3 -10
- package/components/others/import/index.js +0 -7
- package/components/others/option-wrapper/index.js +4 -7
- package/components/others/scrollbar/index.js +0 -3
- package/components/paging/page-info.js +39 -101
- package/components/paging/page-selector.js +7 -35
- package/components/paging/page-selector2.js +35 -74
- package/components/paper/index.js +0 -11
- package/components/popover/body.js +2 -6
- package/components/popover/footer.js +2 -11
- package/components/popover/header.js +2 -7
- package/components/popover/index.js +39 -123
- package/components/popup/danger_popup.js +0 -19
- package/components/popup/index.js +2 -48
- package/components/popup/proposals_popup.js +10 -49
- package/components/popup/v2/index.js +0 -31
- package/components/progress/circular.js +19 -81
- package/components/progress/linear.js +4 -20
- package/components/rating/index.js +0 -24
- package/components/slider/slider-container.js +3 -40
- package/components/slider/slider-item.js +10 -25
- package/components/status/index.js +2 -16
- package/components/tab/tab-container.js +2 -16
- package/components/tab/tab-header.js +4 -24
- package/components/tab/tab-panel.js +4 -16
- package/components/tab/tab.js +4 -28
- package/components/tooltip/index.js +12 -97
- package/components/tooltip/portal.js +0 -2
- package/components/transfer/index.js +22 -67
- package/components/tree-view/index.js +62 -202
- package/components/typography/index.js +3 -31
- package/global/index.js +0 -8
- package/icons/basic.js +0 -48
- package/icons/effect.js +17 -29
- package/icons/general/clock/clock.js +0 -2
- package/icons/general/color-handler/background.js +0 -2
- package/icons/general/color-handler/text.js +0 -2
- package/icons/general/emoji/emoji.js +0 -2
- package/icons/general/font-properties/bold.js +0 -2
- package/icons/general/font-properties/font-family.js +0 -2
- package/icons/general/font-properties/font-size.js +0 -2
- package/icons/general/font-properties/italic.js +0 -2
- package/icons/general/font-properties/underline.js +0 -2
- package/icons/general/hyperlink/hyperlink.js +0 -2
- package/icons/general/indent/decrease.js +0 -2
- package/icons/general/indent/increase.js +0 -2
- package/icons/general/list/bullets.js +0 -2
- package/icons/general/list/numbering.js +0 -2
- package/icons/general/picture/picture.js +0 -2
- package/icons/general/steps/redo.js +0 -2
- package/icons/general/steps/undo.js +0 -2
- package/icons/general/text-align/center.js +0 -2
- package/icons/general/text-align/justify.js +0 -2
- package/icons/general/text-align/left.js +0 -2
- package/icons/general/text-align/right.js +0 -2
- package/icons/menu/dhr.js +2 -1
- package/icons/menu/index.js +2 -2
- package/icons/menu/v2/index.js +0 -10
- package/package.json +1 -1
- package/readme.md +11 -1
- package/styles/animation.js +15 -58
- package/styles/color-helper.js +24 -54
- package/styles/colors.js +17 -9
- package/styles/general.js +6 -2
- package/styles/typography.js +4 -4
- package/styles/utils.js +2 -2
- package/theme/createBreakpoints.js +7 -18
- package/theme/make-styles.js +2 -5
- package/theme/set-theme.js +3 -6
- package/theme/settings.js +3 -2
- package/theme/theme-provider.js +0 -1
- package/utils/array/array.js +14 -23
- package/utils/classNames.js +0 -5
- package/utils/console.js +0 -6
- package/utils/date.js +13 -82
- package/utils/error/error.js +1 -9
- package/utils/error/errors.js +1 -48
- package/utils/getFileType.js +0 -9
- package/utils/handleBreakpoints.js +0 -5
- package/utils/intersectionObserver.js +0 -5
- package/utils/iterator.js +0 -9
- package/utils/map-parent.js +3 -10
- package/utils/object/extend.js +0 -10
- package/utils/object/object.js +12 -11
- package/utils/parseHTML.js +0 -1
- package/utils/promisify.js +0 -5
- package/utils/randomString.js +0 -7
- package/utils/remove-unicode.js +0 -1
- package/utils/render-portal.js +1 -9
- package/utils/renderHTML.js +4 -6
- package/utils/renderIcon.js +4 -14
- package/utils/sb-template.js +6 -5
- package/utils/string/capitalize.js +0 -1
- package/utils/string/capitalizeSentenceCase.js +0 -2
- package/utils/string/string.js +0 -13
- package/utils/type.js +0 -21
- package/utils/updatePosition.js +4 -5
- package/utils/useDelayUnmount.js +0 -4
- package/utils/useElementSize.js +9 -3
- package/utils/useEventListener.js +12 -6
- package/utils/useInput.js +0 -6
- package/utils/useMediaQuery.js +8 -10
- package/utils/useOnClickOutside.js +0 -2
- package/utils/usePortal.js +3 -10
- package/utils/validate.js +6 -20
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/** @jsxRuntime classic */
|
|
2
|
-
|
|
3
2
|
/** @jsx jsx */
|
|
3
|
+
|
|
4
4
|
import { css, jsx } from '@emotion/core';
|
|
5
5
|
import { render } from 'react-dom';
|
|
6
6
|
import { Button, ButtonIcon, Typography } from '../..';
|
|
@@ -31,6 +31,7 @@ const {
|
|
|
31
31
|
danger8,
|
|
32
32
|
info8
|
|
33
33
|
} = colors;
|
|
34
|
+
|
|
34
35
|
/**
|
|
35
36
|
* START STYLE
|
|
36
37
|
*/
|
|
@@ -41,7 +42,6 @@ const {
|
|
|
41
42
|
* @param {Boolean} boxShadow
|
|
42
43
|
* @returns
|
|
43
44
|
*/
|
|
44
|
-
|
|
45
45
|
const generateCalendarCSS = (unique, boxShadow = true, onClickActive = true) => css`
|
|
46
46
|
${borderRadius4px}
|
|
47
47
|
${borderBox}
|
|
@@ -253,8 +253,6 @@ const generateCalendarCSS = (unique, boxShadow = true, onClickActive = true) =>
|
|
|
253
253
|
* @param {String} className
|
|
254
254
|
* @returns {Object} props of the typography
|
|
255
255
|
*/
|
|
256
|
-
|
|
257
|
-
|
|
258
256
|
const typographyProps = className => {
|
|
259
257
|
return {
|
|
260
258
|
className,
|
|
@@ -278,8 +276,6 @@ const typographyProps = className => {
|
|
|
278
276
|
* @param {String} className
|
|
279
277
|
* @returns {Object} props of the button icon
|
|
280
278
|
*/
|
|
281
|
-
|
|
282
|
-
|
|
283
279
|
const buttonIconProps = className => {
|
|
284
280
|
return {
|
|
285
281
|
className,
|
|
@@ -296,8 +292,6 @@ const buttonIconProps = className => {
|
|
|
296
292
|
* @param {Function} fn
|
|
297
293
|
* @returns {Object} props of the button text
|
|
298
294
|
*/
|
|
299
|
-
|
|
300
|
-
|
|
301
295
|
const buttonTextProps = fn => {
|
|
302
296
|
return {
|
|
303
297
|
onClick: fn,
|
|
@@ -311,13 +305,12 @@ const buttonTextProps = fn => {
|
|
|
311
305
|
}
|
|
312
306
|
};
|
|
313
307
|
};
|
|
308
|
+
|
|
314
309
|
/**
|
|
315
310
|
* @description detect value is a Date object
|
|
316
311
|
* @param {String | Number | Array} value
|
|
317
312
|
* @returns boolean
|
|
318
313
|
*/
|
|
319
|
-
|
|
320
|
-
|
|
321
314
|
const isValidDate = value => {
|
|
322
315
|
return new Date(value) instanceof Date && !isNaN(new Date(value));
|
|
323
316
|
};
|
|
@@ -327,8 +320,6 @@ const isValidDate = value => {
|
|
|
327
320
|
* @param {Date} date
|
|
328
321
|
* @returns number of day from 0 (Monday) to 6 (Sunday).
|
|
329
322
|
*/
|
|
330
|
-
|
|
331
|
-
|
|
332
323
|
const getDateOfWeek = date => {
|
|
333
324
|
let day = date.getDay();
|
|
334
325
|
if (day === 0) day = 7;
|
|
@@ -342,8 +333,6 @@ const getDateOfWeek = date => {
|
|
|
342
333
|
* @param {String} className
|
|
343
334
|
* @returns {Boolean} is today
|
|
344
335
|
*/
|
|
345
|
-
|
|
346
|
-
|
|
347
336
|
const isToday = (day, today, className) => {
|
|
348
337
|
return +moment(day).diff(today) === 0 ? className : '';
|
|
349
338
|
};
|
|
@@ -355,19 +344,15 @@ const isToday = (day, today, className) => {
|
|
|
355
344
|
* @param {String} className
|
|
356
345
|
* @returns {Boolean} is active day
|
|
357
346
|
*/
|
|
358
|
-
|
|
359
|
-
|
|
360
347
|
const isActive = (day, active, className) => {
|
|
361
348
|
if (Array.isArray(active)) {
|
|
362
349
|
if (+moment(day).diff(active[0]) === 0 || +moment(day).diff(active[1]) === 0) {
|
|
363
350
|
return className;
|
|
364
351
|
}
|
|
365
352
|
}
|
|
366
|
-
|
|
367
353
|
if (+moment(day).diff(active) === 0) {
|
|
368
354
|
return className;
|
|
369
355
|
}
|
|
370
|
-
|
|
371
356
|
return '';
|
|
372
357
|
};
|
|
373
358
|
/**
|
|
@@ -379,32 +364,24 @@ const isActive = (day, active, className) => {
|
|
|
379
364
|
* @param {Object} className
|
|
380
365
|
* @returns {Boolean} is limited day
|
|
381
366
|
*/
|
|
382
|
-
|
|
383
|
-
|
|
384
367
|
const isLimit = (day, max, min, className) => {
|
|
385
368
|
return isBeforeLimit(min, day) || isAfterLimit(max, day) ? className : '';
|
|
386
369
|
};
|
|
387
|
-
|
|
388
370
|
const isBetween = (day, from, to, className) => {
|
|
389
371
|
if (from && isValidDate(from) && +moment(day).diff(from) === 0) {
|
|
390
372
|
return className.from;
|
|
391
373
|
}
|
|
392
|
-
|
|
393
374
|
if (to && isValidDate(to) && +moment(day).diff(to) === 0) {
|
|
394
375
|
return className.to;
|
|
395
376
|
}
|
|
396
|
-
|
|
397
377
|
if (from && to && isValidDate(from) && isValidDate(to) && +moment(day).diff(from) > 0 && +moment(day).diff(to) < 0) {
|
|
398
378
|
return className.between;
|
|
399
379
|
}
|
|
400
|
-
|
|
401
380
|
return '';
|
|
402
381
|
};
|
|
403
|
-
|
|
404
382
|
const isBeforeLimit = (min, time) => {
|
|
405
383
|
return min && isValidDate(min) && moment(time).diff(new Date(min).setHours(0, 0, 0, 0)) < 0;
|
|
406
384
|
};
|
|
407
|
-
|
|
408
385
|
const isAfterLimit = (max, time) => {
|
|
409
386
|
return max && isValidDate(max) && moment(time).diff(new Date(max).setHours(0, 0, 0, 0)) > 0;
|
|
410
387
|
};
|
|
@@ -420,46 +397,40 @@ const isAfterLimit = (max, time) => {
|
|
|
420
397
|
* @param {Date} max
|
|
421
398
|
* @returns {Element}
|
|
422
399
|
*/
|
|
423
|
-
|
|
424
|
-
|
|
425
400
|
const renderTableBody = (time, activeValue, className, displayAnotherMonth, onTableDataClick, min, max) => {
|
|
426
401
|
time = new Date(time);
|
|
427
402
|
const firstDay = new Date(new Date(time).setDate(1)),
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
403
|
+
lastDay = new Date(firstDay.getFullYear(), firstDay.getMonth() + 1, 0),
|
|
404
|
+
prevDay = new Date(firstDay.getFullYear(), firstDay.getMonth(), 0),
|
|
405
|
+
today = new Date().setHours(0, 0, 0, 0),
|
|
406
|
+
lastDate = lastDay.getDate(),
|
|
407
|
+
prevDate = prevDay.getDate();
|
|
433
408
|
let active = Array.isArray(activeValue) ? new Date(activeValue[0]) : new Date(activeValue);
|
|
434
409
|
let tableBody = [],
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
410
|
+
tableRaw = [],
|
|
411
|
+
tableData = [],
|
|
412
|
+
weekDateFirst = getDateOfWeek(firstDay),
|
|
413
|
+
weekDateLast = getDateOfWeek(lastDay);
|
|
440
414
|
if (activeValue && Array.isArray(activeValue) && activeValue.length === 2 && activeValue[0] !== activeValue[1]) {
|
|
441
415
|
/**
|
|
442
416
|
* days of previous month
|
|
443
417
|
*/
|
|
444
418
|
active = activeValue;
|
|
445
|
-
|
|
446
419
|
for (let i = weekDateFirst; i > 0; i--) {
|
|
447
|
-
const day = new Date(time.getFullYear(), time.getMonth() - 1,
|
|
420
|
+
const day = new Date(time.getFullYear(), time.getMonth() - 1,
|
|
421
|
+
// displayAnotherMonth ? prevDate - i + 1 : 1
|
|
448
422
|
1);
|
|
449
423
|
tableData.push(jsx("td", {
|
|
450
424
|
key: `previous_month-${prevDate - i + 1}`,
|
|
451
|
-
"data-time": Date.parse(day) - 1
|
|
452
|
-
/*(displayAnotherMonth ? 0 : 1)*/
|
|
453
|
-
,
|
|
425
|
+
"data-time": Date.parse(day) - 1 /*(displayAnotherMonth ? 0 : 1)*/,
|
|
454
426
|
className: `${[className.table.data, 'previous_month', isToday(day, today, className.day.today), isActive(day, active, className.day.active), isBetween(day, active[0], active[1], className.day)].join(' ')}`
|
|
455
|
-
}, jsx(Typography, {
|
|
427
|
+
}, jsx(Typography, {
|
|
428
|
+
...typographyProps(className.day.day)
|
|
456
429
|
}, '')));
|
|
457
430
|
}
|
|
458
431
|
/**
|
|
459
432
|
* days of this month
|
|
460
433
|
*/
|
|
461
|
-
|
|
462
|
-
|
|
463
434
|
for (let i = 0; i < lastDate; i++) {
|
|
464
435
|
const day = new Date(time.getFullYear(), time.getMonth(), i + 1);
|
|
465
436
|
tableData.push(jsx("td", {
|
|
@@ -467,24 +438,23 @@ const renderTableBody = (time, activeValue, className, displayAnotherMonth, onTa
|
|
|
467
438
|
"data-time": Date.parse(day),
|
|
468
439
|
className: `${[className.table.data, 'this_month', isToday(day, today, className.day.today), isActive(day, active, className.day.active), isLimit(day, max, min, className.day.limit), isBetween(day, active[0], active[1], className.day)].join(' ')}`,
|
|
469
440
|
onClick: onTableDataClick
|
|
470
|
-
}, jsx(Typography, {
|
|
441
|
+
}, jsx(Typography, {
|
|
442
|
+
...typographyProps(className.day.day)
|
|
471
443
|
}, i + 1)));
|
|
472
444
|
}
|
|
473
445
|
/**
|
|
474
446
|
* days of next month
|
|
475
447
|
*/
|
|
476
|
-
|
|
477
|
-
|
|
478
448
|
for (let i = 0; i < 20 - weekDateLast; i++) {
|
|
479
|
-
const day = new Date(time.getFullYear(), time.getMonth() + 1,
|
|
449
|
+
const day = new Date(time.getFullYear(), time.getMonth() + 1,
|
|
450
|
+
// displayAnotherMonth ? i + 1 : 6 - weekDateLast
|
|
480
451
|
6 - weekDateLast);
|
|
481
452
|
tableData.push(jsx("td", {
|
|
482
453
|
key: `next_month-${i + 1}`,
|
|
483
|
-
"data-time": Date.parse(day) + 1
|
|
484
|
-
/*(displayAnotherMonth ? 0 : 1)*/
|
|
485
|
-
,
|
|
454
|
+
"data-time": Date.parse(day) + 1 /*(displayAnotherMonth ? 0 : 1)*/,
|
|
486
455
|
className: `${[className.table.data, 'next_month', isToday(day, today, className.day.today), isActive(day, active, className.day.active), isBetween(day, active[0], active[1], className.day)].join(' ')}`
|
|
487
|
-
}, jsx(Typography, {
|
|
456
|
+
}, jsx(Typography, {
|
|
457
|
+
...typographyProps(className.day.day)
|
|
488
458
|
}, '')));
|
|
489
459
|
}
|
|
490
460
|
} else {
|
|
@@ -498,14 +468,13 @@ const renderTableBody = (time, activeValue, className, displayAnotherMonth, onTa
|
|
|
498
468
|
"data-time": Date.parse(day) - (displayAnotherMonth ? 0 : 1),
|
|
499
469
|
className: `${[className.table.data, 'previous_month', isToday(day, today, className.day.today), isActive(day, active, className.day.active), isLimit(day, max, min, className.day.limit)].join(' ')}`,
|
|
500
470
|
onClick: onTableDataClick
|
|
501
|
-
}, jsx(Typography, {
|
|
471
|
+
}, jsx(Typography, {
|
|
472
|
+
...typographyProps(className.day.day)
|
|
502
473
|
}, displayAnotherMonth ? prevDate - i + 1 : '')));
|
|
503
474
|
}
|
|
504
475
|
/**
|
|
505
476
|
* days of this month
|
|
506
477
|
*/
|
|
507
|
-
|
|
508
|
-
|
|
509
478
|
for (let i = 0; i < lastDate; i++) {
|
|
510
479
|
const day = new Date(time.getFullYear(), time.getMonth(), i + 1);
|
|
511
480
|
tableData.push(jsx("td", {
|
|
@@ -513,14 +482,13 @@ const renderTableBody = (time, activeValue, className, displayAnotherMonth, onTa
|
|
|
513
482
|
"data-time": Date.parse(day),
|
|
514
483
|
className: `${[className.table.data, 'this_month', isToday(day, today, className.day.today), isActive(day, active, className.day.active), isLimit(day, max, min, className.day.limit)].join(' ')}`,
|
|
515
484
|
onClick: onTableDataClick
|
|
516
|
-
}, jsx(Typography, {
|
|
485
|
+
}, jsx(Typography, {
|
|
486
|
+
...typographyProps(className.day.day)
|
|
517
487
|
}, i + 1)));
|
|
518
488
|
}
|
|
519
489
|
/**
|
|
520
490
|
* days of next month
|
|
521
491
|
*/
|
|
522
|
-
|
|
523
|
-
|
|
524
492
|
for (let i = 0; i < 20 - weekDateLast; i++) {
|
|
525
493
|
const day = new Date(time.getFullYear(), time.getMonth() + 1, displayAnotherMonth ? i + 1 : 6 - weekDateLast);
|
|
526
494
|
tableData.push(jsx("td", {
|
|
@@ -528,23 +496,21 @@ const renderTableBody = (time, activeValue, className, displayAnotherMonth, onTa
|
|
|
528
496
|
"data-time": Date.parse(day) + (displayAnotherMonth ? 0 : 1),
|
|
529
497
|
className: `${[className.table.data, 'next_month', isToday(day, today, className.day.today), isActive(day, active, className.day.active), isLimit(day, max, min, className.day.limit)].join(' ')}`,
|
|
530
498
|
onClick: onTableDataClick
|
|
531
|
-
}, jsx(Typography, {
|
|
499
|
+
}, jsx(Typography, {
|
|
500
|
+
...typographyProps(className.day.day)
|
|
532
501
|
}, displayAnotherMonth ? i + 1 : '')));
|
|
533
502
|
}
|
|
534
503
|
}
|
|
535
|
-
|
|
536
504
|
for (let i = 0; i < 6; i++) {
|
|
537
505
|
for (let j = 0; j < 7; j++) {
|
|
538
506
|
tableRaw.push(tableData[7 * i + j]);
|
|
539
507
|
}
|
|
540
|
-
|
|
541
508
|
tableBody.push(jsx("tr", {
|
|
542
509
|
key: i,
|
|
543
510
|
className: className.day.week
|
|
544
511
|
}, tableRaw));
|
|
545
512
|
tableRaw = [];
|
|
546
513
|
}
|
|
547
|
-
|
|
548
514
|
return tableBody;
|
|
549
515
|
};
|
|
550
516
|
/**
|
|
@@ -552,12 +518,9 @@ const renderTableBody = (time, activeValue, className, displayAnotherMonth, onTa
|
|
|
552
518
|
* @param {Object} className
|
|
553
519
|
* @returns
|
|
554
520
|
*/
|
|
555
|
-
|
|
556
|
-
|
|
557
521
|
const renderHeader = className => {
|
|
558
522
|
const weekdays = getGlobal(['weekdaysLong']);
|
|
559
523
|
const tableHeader = [];
|
|
560
|
-
|
|
561
524
|
for (let i in weekdays) {
|
|
562
525
|
tableHeader.push(jsx("th", {
|
|
563
526
|
key: i,
|
|
@@ -567,7 +530,6 @@ const renderHeader = className => {
|
|
|
567
530
|
type: 'h6'
|
|
568
531
|
}, weekdays[i])));
|
|
569
532
|
}
|
|
570
|
-
|
|
571
533
|
const header = jsx("thead", null, jsx("tr", {
|
|
572
534
|
className: className.table.raw
|
|
573
535
|
}, tableHeader));
|
|
@@ -583,34 +545,37 @@ const renderHeader = className => {
|
|
|
583
545
|
* @param {Function} dbRightFn
|
|
584
546
|
* @returns navigator
|
|
585
547
|
*/
|
|
586
|
-
|
|
587
|
-
|
|
588
548
|
const renderNavigator = (className, refs, dbLeftFn, leftFn, rightFn, dbRightFn, fn) => jsx("div", {
|
|
589
549
|
className: className.navigator.navigator
|
|
590
550
|
}, jsx("div", {
|
|
591
551
|
className: className.navigator.around
|
|
592
|
-
}, jsx(ButtonIcon, {
|
|
552
|
+
}, jsx(ButtonIcon, {
|
|
553
|
+
...buttonIconProps(className.icon),
|
|
593
554
|
name: 'ArrowDoubleLeft',
|
|
594
555
|
onClick: dbLeftFn,
|
|
595
556
|
ref: refs.doubleLeft
|
|
596
|
-
}), jsx(ButtonIcon, {
|
|
557
|
+
}), jsx(ButtonIcon, {
|
|
558
|
+
...buttonIconProps(className.icon),
|
|
597
559
|
name: 'ArrowLeft',
|
|
598
560
|
onClick: leftFn,
|
|
599
561
|
ref: refs.left
|
|
600
562
|
})), jsx("div", {
|
|
601
563
|
className: className.navigator.center
|
|
602
|
-
}, jsx(Button, {
|
|
564
|
+
}, jsx(Button, {
|
|
565
|
+
...buttonTextProps(fn)
|
|
603
566
|
}, jsx(Typography, {
|
|
604
567
|
color: 'primary',
|
|
605
568
|
type: 'h3',
|
|
606
569
|
ref: refs.content
|
|
607
570
|
}))), jsx("div", {
|
|
608
571
|
className: className.navigator.around
|
|
609
|
-
}, jsx(ButtonIcon, {
|
|
572
|
+
}, jsx(ButtonIcon, {
|
|
573
|
+
...buttonIconProps(className.icon),
|
|
610
574
|
name: 'ArrowRight',
|
|
611
575
|
onClick: rightFn,
|
|
612
576
|
ref: refs.right
|
|
613
|
-
}), jsx(ButtonIcon, {
|
|
577
|
+
}), jsx(ButtonIcon, {
|
|
578
|
+
...buttonIconProps(className.icon),
|
|
614
579
|
name: 'ArrowDoubleRight',
|
|
615
580
|
onClick: dbRightFn,
|
|
616
581
|
ref: refs.doubleRight
|
|
@@ -620,8 +585,6 @@ const renderNavigator = (className, refs, dbLeftFn, leftFn, rightFn, dbRightFn,
|
|
|
620
585
|
* @param {Date} time
|
|
621
586
|
* @returns {String} month year
|
|
622
587
|
*/
|
|
623
|
-
|
|
624
|
-
|
|
625
588
|
const renderNavigatorContent = time => {
|
|
626
589
|
const value = new Date(time);
|
|
627
590
|
const months = getGlobal(['months', 'full']);
|
|
@@ -634,51 +597,38 @@ const renderNavigatorContent = time => {
|
|
|
634
597
|
* @param {Date} min
|
|
635
598
|
* @param {Date} max
|
|
636
599
|
*/
|
|
637
|
-
|
|
638
|
-
|
|
639
600
|
const onUpdateNavigator = (time, refs, min, max) => {
|
|
640
601
|
var _refs$doubleLeft$curr, _refs$doubleLeft$curr2, _refs$doubleRight$cur, _refs$doubleRight$cur2, _refs$left$current, _refs$left$current$in, _refs$right$current, _refs$right$current$i;
|
|
641
|
-
|
|
642
602
|
const el = refs.content.current;
|
|
643
603
|
const vl = renderNavigatorContent(time);
|
|
644
604
|
const year = locale.get() === 'vi' ? ` ${getGlobal(['year'])} ` : '';
|
|
645
|
-
|
|
646
605
|
if (el) {
|
|
647
606
|
el.innerHTML = `${vl[0]} ${year}${vl[1]}`;
|
|
648
607
|
}
|
|
649
|
-
|
|
650
608
|
const firstDayOfMin = new Date(new Date(new Date(min).setDate(1)).setHours(0, 0, 0, 0));
|
|
651
609
|
const firstDayOfMax = new Date(new Date(new Date(max).setDate(1)).setHours(0, 0, 0, 0));
|
|
652
610
|
(_refs$doubleLeft$curr = refs.doubleLeft.current) === null || _refs$doubleLeft$curr === void 0 ? void 0 : (_refs$doubleLeft$curr2 = _refs$doubleLeft$curr.instance) === null || _refs$doubleLeft$curr2 === void 0 ? void 0 : _refs$doubleLeft$curr2.option('disabled', false);
|
|
653
611
|
(_refs$doubleRight$cur = refs.doubleRight.current) === null || _refs$doubleRight$cur === void 0 ? void 0 : (_refs$doubleRight$cur2 = _refs$doubleRight$cur.instance) === null || _refs$doubleRight$cur2 === void 0 ? void 0 : _refs$doubleRight$cur2.option('disabled', false);
|
|
654
612
|
(_refs$left$current = refs.left.current) === null || _refs$left$current === void 0 ? void 0 : (_refs$left$current$in = _refs$left$current.instance) === null || _refs$left$current$in === void 0 ? void 0 : _refs$left$current$in.option('disabled', false);
|
|
655
613
|
(_refs$right$current = refs.right.current) === null || _refs$right$current === void 0 ? void 0 : (_refs$right$current$i = _refs$right$current.instance) === null || _refs$right$current$i === void 0 ? void 0 : _refs$right$current$i.option('disabled', false);
|
|
656
|
-
|
|
657
614
|
if (min && isValidDate(min)) {
|
|
658
615
|
if (moment(time).diff(firstDayOfMin) < 365) {
|
|
659
616
|
var _refs$doubleLeft$curr3, _refs$doubleLeft$curr4;
|
|
660
|
-
|
|
661
617
|
(_refs$doubleLeft$curr3 = refs.doubleLeft.current) === null || _refs$doubleLeft$curr3 === void 0 ? void 0 : (_refs$doubleLeft$curr4 = _refs$doubleLeft$curr3.instance) === null || _refs$doubleLeft$curr4 === void 0 ? void 0 : _refs$doubleLeft$curr4.option('disabled', true);
|
|
662
618
|
}
|
|
663
|
-
|
|
664
619
|
if (moment(time).diff(firstDayOfMin) <= 28) {
|
|
665
620
|
var _refs$doubleLeft$curr5, _refs$doubleLeft$curr6, _refs$left$current2, _refs$left$current2$i;
|
|
666
|
-
|
|
667
621
|
(_refs$doubleLeft$curr5 = refs.doubleLeft.current) === null || _refs$doubleLeft$curr5 === void 0 ? void 0 : (_refs$doubleLeft$curr6 = _refs$doubleLeft$curr5.instance) === null || _refs$doubleLeft$curr6 === void 0 ? void 0 : _refs$doubleLeft$curr6.option('disabled', true);
|
|
668
622
|
(_refs$left$current2 = refs.left.current) === null || _refs$left$current2 === void 0 ? void 0 : (_refs$left$current2$i = _refs$left$current2.instance) === null || _refs$left$current2$i === void 0 ? void 0 : _refs$left$current2$i.option('disabled', true);
|
|
669
623
|
}
|
|
670
624
|
}
|
|
671
|
-
|
|
672
625
|
if (max && isValidDate(max)) {
|
|
673
626
|
if (moment(time).diff(firstDayOfMax) > -334) {
|
|
674
627
|
var _refs$doubleRight$cur3, _refs$doubleRight$cur4;
|
|
675
|
-
|
|
676
628
|
(_refs$doubleRight$cur3 = refs.doubleRight.current) === null || _refs$doubleRight$cur3 === void 0 ? void 0 : (_refs$doubleRight$cur4 = _refs$doubleRight$cur3.instance) === null || _refs$doubleRight$cur4 === void 0 ? void 0 : _refs$doubleRight$cur4.option('disabled', true);
|
|
677
629
|
}
|
|
678
|
-
|
|
679
630
|
if (moment(time).diff(firstDayOfMax) > -1) {
|
|
680
631
|
var _refs$doubleRight$cur5, _refs$doubleRight$cur6, _refs$right$current2, _refs$right$current2$;
|
|
681
|
-
|
|
682
632
|
(_refs$doubleRight$cur5 = refs.doubleRight.current) === null || _refs$doubleRight$cur5 === void 0 ? void 0 : (_refs$doubleRight$cur6 = _refs$doubleRight$cur5.instance) === null || _refs$doubleRight$cur6 === void 0 ? void 0 : _refs$doubleRight$cur6.option('disabled', true);
|
|
683
633
|
(_refs$right$current2 = refs.right.current) === null || _refs$right$current2 === void 0 ? void 0 : (_refs$right$current2$ = _refs$right$current2.instance) === null || _refs$right$current2$ === void 0 ? void 0 : _refs$right$current2$.option('disabled', true);
|
|
684
634
|
}
|
|
@@ -697,17 +647,13 @@ const onUpdateNavigator = (time, refs, min, max) => {
|
|
|
697
647
|
* @param {Function} onTableDataClick
|
|
698
648
|
* @param {Function} onUpdateNavigatorValue
|
|
699
649
|
*/
|
|
700
|
-
|
|
701
|
-
|
|
702
650
|
const onUpdateCalendar = (time, navigatorRefs, min, max, table, activeValue, className, displayAnotherMonth, onTableDataClick, onUpdateNavigatorValue) => {
|
|
703
651
|
onUpdateNavigator(time, navigatorRefs, min, max);
|
|
704
652
|
onUpdateNavigatorValue(time);
|
|
705
|
-
|
|
706
653
|
if (table) {
|
|
707
654
|
const child = renderTableBody(time, activeValue, className, displayAnotherMonth, onTableDataClick, min, max);
|
|
708
655
|
table.querySelector('tbody').remove();
|
|
709
656
|
render(child, table.appendChild(document.createElement('tbody')));
|
|
710
657
|
}
|
|
711
658
|
};
|
|
712
|
-
|
|
713
659
|
export { renderTableBody, renderHeader, renderNavigator, onUpdateNavigator, renderNavigatorContent, onUpdateCalendar, isBeforeLimit, isAfterLimit, isValidDate, generateCalendarCSS };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/** @jsxRuntime classic */
|
|
2
|
-
|
|
3
2
|
/** @jsx jsx */
|
|
3
|
+
|
|
4
4
|
import { jsx } from '@emotion/core';
|
|
5
5
|
import PropTypes from 'prop-types';
|
|
6
6
|
import { forwardRef, memo, useCallback, useEffect, useImperativeHandle, useRef, useState } from 'react';
|
|
@@ -41,10 +41,10 @@ const Calendar = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
41
41
|
limit: 'DGN-UI-Calendar-Day-limit'
|
|
42
42
|
}
|
|
43
43
|
};
|
|
44
|
+
|
|
44
45
|
/**
|
|
45
46
|
* START REFERENCE
|
|
46
47
|
*/
|
|
47
|
-
|
|
48
48
|
const ref = useRef(null);
|
|
49
49
|
const tableRef = useRef(null);
|
|
50
50
|
const activeValue = useRef(null);
|
|
@@ -68,7 +68,6 @@ const Calendar = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
68
68
|
/**
|
|
69
69
|
* START FUNCTION
|
|
70
70
|
*/
|
|
71
|
-
|
|
72
71
|
const onUpdateNavigatorValue = useCallback(value => {
|
|
73
72
|
navigatorValue.current = value;
|
|
74
73
|
setNavigatorValue();
|
|
@@ -77,18 +76,15 @@ const Calendar = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
77
76
|
activeValue.current = value;
|
|
78
77
|
setActiveValue();
|
|
79
78
|
}, [activeValue]);
|
|
80
|
-
|
|
81
79
|
const onUpdate = value => {
|
|
82
80
|
const newValue = new Date(value).setHours(0, 0, 0, 0);
|
|
83
81
|
onUpdateActiveValue(newValue);
|
|
84
82
|
onUpdateCalendar(newValue, navigatorRefs, min, max, tableRef.current, activeValue.current, unique, displayAnotherMonth, onDayClick, onUpdateNavigatorValue);
|
|
85
83
|
};
|
|
86
|
-
|
|
87
84
|
const getCurrentTime = () => {
|
|
88
85
|
const time = new Date(navigatorValue.current);
|
|
89
86
|
return [time.getDate(), time.getMonth(), time.getFullYear()];
|
|
90
87
|
};
|
|
91
|
-
|
|
92
88
|
const onDayClick = e => {
|
|
93
89
|
const node = e.currentTarget;
|
|
94
90
|
tableRef.current.querySelectorAll(`td.${unique.day.active}`).forEach(element => {
|
|
@@ -97,61 +93,50 @@ const Calendar = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
97
93
|
node.classList.add(unique.day.active);
|
|
98
94
|
const timeStamp = Number(node.dataset.time);
|
|
99
95
|
const objNewDate = new Date(timeStamp);
|
|
100
|
-
|
|
101
96
|
const _navigatorValue = new Date(navigatorValue.current);
|
|
102
|
-
|
|
103
97
|
const objNewDateMonth = objNewDate.getMonth() + 1;
|
|
104
98
|
const objNewDateYear = objNewDate.getFullYear();
|
|
105
99
|
const navigatorMonth = _navigatorValue.getMonth() + 1;
|
|
106
|
-
|
|
107
100
|
const navigatorYear = _navigatorValue.getFullYear();
|
|
108
|
-
|
|
109
101
|
onUpdateActiveValue(objNewDate);
|
|
110
102
|
if (objNewDateMonth > navigatorMonth || objNewDateYear > navigatorYear) setNextMonth();else if (objNewDateMonth < navigatorMonth || objNewDateYear < navigatorYear) setPrevMonth();
|
|
111
103
|
!!onClick && onClick({
|
|
112
104
|
value: objNewDate
|
|
113
105
|
});
|
|
114
106
|
};
|
|
115
|
-
|
|
116
107
|
const setPrevYear = e => {
|
|
117
108
|
const time = new Date(getCurrentTime()[2] - 1, getCurrentTime()[1]);
|
|
118
|
-
|
|
119
109
|
if (min && isValidDate(min) && moment(time).diff(firstDayOfMin) < 0) {
|
|
120
110
|
e.preventDefault();
|
|
121
111
|
} else {
|
|
122
112
|
onUpdateCalendar(time, navigatorRefs, min, max, tableRef.current, activeValue.current, unique, displayAnotherMonth, onDayClick, onUpdateNavigatorValue);
|
|
123
113
|
}
|
|
124
114
|
};
|
|
125
|
-
|
|
126
115
|
const setNextYear = e => {
|
|
127
116
|
const time = new Date(getCurrentTime()[2] + 1, getCurrentTime()[1]);
|
|
128
|
-
|
|
129
117
|
if (max && isValidDate(max) && moment(time).diff(firstDayOfMax) > 0) {
|
|
130
118
|
e.preventDefault();
|
|
131
119
|
} else {
|
|
132
120
|
onUpdateCalendar(time, navigatorRefs, min, max, tableRef.current, activeValue.current, unique, displayAnotherMonth, onDayClick, onUpdateNavigatorValue);
|
|
133
121
|
}
|
|
134
122
|
};
|
|
135
|
-
|
|
136
123
|
const setPrevMonth = e => {
|
|
137
124
|
const time = new Date(getCurrentTime()[2], getCurrentTime()[1] - 1);
|
|
138
|
-
|
|
139
125
|
if (min && isValidDate(min) && moment(time).diff(firstDayOfMin) < 0) {
|
|
140
126
|
e.preventDefault();
|
|
141
127
|
} else {
|
|
142
128
|
onUpdateCalendar(time, navigatorRefs, min, max, tableRef.current, activeValue.current, unique, displayAnotherMonth, onDayClick, onUpdateNavigatorValue);
|
|
143
129
|
}
|
|
144
130
|
};
|
|
145
|
-
|
|
146
131
|
const setNextMonth = e => {
|
|
147
132
|
const time = new Date(getCurrentTime()[2], getCurrentTime()[1] + 1);
|
|
148
|
-
|
|
149
133
|
if (max && isValidDate(max) && moment(time).diff(firstDayOfMax) > 0) {
|
|
150
134
|
e.preventDefault();
|
|
151
135
|
} else {
|
|
152
136
|
onUpdateCalendar(time, navigatorRefs, min, max, tableRef.current, activeValue.current, unique, displayAnotherMonth, onDayClick, onUpdateNavigatorValue);
|
|
153
137
|
}
|
|
154
138
|
};
|
|
139
|
+
|
|
155
140
|
/**
|
|
156
141
|
* END FUNCTION
|
|
157
142
|
*/
|
|
@@ -159,8 +144,6 @@ const Calendar = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
159
144
|
/**
|
|
160
145
|
* START EFFECT
|
|
161
146
|
*/
|
|
162
|
-
|
|
163
|
-
|
|
164
147
|
useEffect(() => {
|
|
165
148
|
if (defaultValue && defaultValue !== '' && isValidDate(defaultValue)) {
|
|
166
149
|
if (isBeforeLimit(min, defaultValue)) {
|
|
@@ -205,7 +188,6 @@ const Calendar = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
205
188
|
/**
|
|
206
189
|
* START COMPONENT
|
|
207
190
|
*/
|
|
208
|
-
|
|
209
191
|
const tableMemo = jsx("div", {
|
|
210
192
|
className: unique.table.container
|
|
211
193
|
}, jsx("table", {
|
|
@@ -215,8 +197,8 @@ const Calendar = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
215
197
|
/**
|
|
216
198
|
* END COMPONENT
|
|
217
199
|
*/
|
|
218
|
-
|
|
219
|
-
|
|
200
|
+
return jsx("div", {
|
|
201
|
+
...props,
|
|
220
202
|
className: [unique.container, className].join(' ').trim().replace(/\s+/g, ' '),
|
|
221
203
|
css: generateCalendarCSS(unique),
|
|
222
204
|
ref: ref
|
|
@@ -230,25 +212,18 @@ Calendar.defaultProps = {
|
|
|
230
212
|
Calendar.propTypes = {
|
|
231
213
|
/** the footer actions */
|
|
232
214
|
actions: PropTypes.oneOfType([PropTypes.element, PropTypes.node]),
|
|
233
|
-
|
|
234
215
|
/** class for calendar */
|
|
235
216
|
className: PropTypes.string,
|
|
236
|
-
|
|
237
217
|
/** the default value of the calendar */
|
|
238
218
|
defaultValue: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.string, PropTypes.array]),
|
|
239
|
-
|
|
240
219
|
/** display days of previous or next month */
|
|
241
220
|
displayAnotherMonth: PropTypes.bool,
|
|
242
|
-
|
|
243
221
|
/** the last date that can be selected within the UI component. */
|
|
244
222
|
max: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.string, PropTypes.array]),
|
|
245
|
-
|
|
246
223
|
/** the minimum date that can be selected within the UI component. */
|
|
247
224
|
min: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.string, PropTypes.array]),
|
|
248
|
-
|
|
249
225
|
/** a callback function when click on a day of calendar */
|
|
250
226
|
onClick: PropTypes.func,
|
|
251
|
-
|
|
252
227
|
/** value of the calendar */
|
|
253
228
|
value: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.string, PropTypes.array])
|
|
254
229
|
};
|