diginet-core-ui 1.4.54-beta.3 → 1.4.55-beta.1

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.
Files changed (104) hide show
  1. package/components/accordion/details.js +1 -1
  2. package/components/accordion/group.js +1 -1
  3. package/components/accordion/index.js +1 -1
  4. package/components/accordion/summary.js +1 -1
  5. package/components/alert/index.js +1 -1
  6. package/components/alert/notify.js +1 -1
  7. package/components/avatar/index.js +2 -2
  8. package/components/badge/index.js +1 -1
  9. package/components/breadcrumb/index.js +1 -1
  10. package/components/button/icon.js +1 -1
  11. package/components/button/index.js +1 -1
  12. package/components/button/more.js +16 -7
  13. package/components/button/ripple-effect.js +1 -1
  14. package/components/card/body.js +1 -1
  15. package/components/card/extra.js +1 -1
  16. package/components/card/footer.js +1 -1
  17. package/components/card/header.js +1 -1
  18. package/components/card/index.js +1 -1
  19. package/components/chart/Pie/Circle.js +1 -1
  20. package/components/chart/Pie/Sector.js +1 -1
  21. package/components/chart/Pie/index.js +1 -1
  22. package/components/chart/Pie-v2/Circle.js +1 -1
  23. package/components/chart/Pie-v2/Sector.js +1 -1
  24. package/components/chart/Pie-v2/index.js +1 -1
  25. package/components/chart/bar/Bar.js +1 -1
  26. package/components/chart/bar/index.js +1 -1
  27. package/components/chart/bar-v2/Bar.js +1 -1
  28. package/components/chart/bar-v2/index.js +1 -1
  29. package/components/chart/line/index.js +1 -1
  30. package/components/chart/line-v2/index.js +1 -1
  31. package/components/check-text/index.js +1 -1
  32. package/components/check-text/interview-confirmation.js +1 -1
  33. package/components/check-text/interview-status.js +1 -1
  34. package/components/chip/index.js +1 -1
  35. package/components/collapse/index.js +1 -1
  36. package/components/divider/index.js +1 -1
  37. package/components/form-control/attachment/index.js +22 -22
  38. package/components/form-control/calendar/index.js +1 -1
  39. package/components/form-control/calendar/range.js +1 -1
  40. package/components/form-control/checkbox/index.js +1 -1
  41. package/components/form-control/control/index.js +1 -1
  42. package/components/form-control/date-input/index.js +1 -1
  43. package/components/form-control/date-picker/index.js +1 -1
  44. package/components/form-control/date-range-picker/index.js +273 -38
  45. package/components/form-control/dropdown/index.js +77 -54
  46. package/components/form-control/dropdown-box/index.js +1 -1
  47. package/components/form-control/form-group/index.js +1 -1
  48. package/components/form-control/helper-text/index.js +1 -1
  49. package/components/form-control/input-base/UncontrolledInputBase.js +1 -1
  50. package/components/form-control/input-base/index.js +1 -1
  51. package/components/form-control/label/index.js +1 -1
  52. package/components/form-control/money-input/index.js +1 -1
  53. package/components/form-control/number-input/index2.js +19 -19
  54. package/components/form-control/password-input/index.js +1 -1
  55. package/components/form-control/phone-input/index.js +1 -1
  56. package/components/form-control/radio/index.js +1 -1
  57. package/components/form-control/text-input/index.js +1 -1
  58. package/components/form-control/time-picker/index.js +1 -1
  59. package/components/form-control/time-picker/v2/index.js +1 -1
  60. package/components/form-control/toggle/index.js +1 -1
  61. package/components/form-view/input.js +1 -1
  62. package/components/grid/index.js +1 -1
  63. package/components/image/index.js +1 -1
  64. package/components/list/list-item-action.js +1 -1
  65. package/components/list/list-item-icon.js +1 -1
  66. package/components/list/list-item-text.js +1 -1
  67. package/components/list/list-item.js +1 -1
  68. package/components/list/list.js +1 -1
  69. package/components/list/sub-header.js +1 -1
  70. package/components/modal/body.js +1 -1
  71. package/components/modal/footer.js +1 -1
  72. package/components/modal/header.js +1 -1
  73. package/components/modal/index.js +1 -1
  74. package/components/modal/modal.js +1 -1
  75. package/components/others/option-wrapper/index.js +1 -1
  76. package/components/paging/page-info.js +35 -35
  77. package/components/paging/page-selector.js +1 -1
  78. package/components/paper/index.js +1 -1
  79. package/components/popover/body.js +1 -1
  80. package/components/popover/footer.js +1 -1
  81. package/components/popover/header.js +1 -1
  82. package/components/popover/index.js +14 -14
  83. package/components/popup/index.js +1 -1
  84. package/components/popup/v2/index.js +1 -1
  85. package/components/progress/circular.js +1 -1
  86. package/components/progress/linear.js +1 -1
  87. package/components/rating/index.js +1 -1
  88. package/components/skeleton/index.js +1 -1
  89. package/components/slider/slider-container.js +1 -1
  90. package/components/slider/slider-item.js +1 -1
  91. package/components/status/index.js +1 -1
  92. package/components/tab/tab-container.js +1 -1
  93. package/components/tab/tab-header.js +1 -1
  94. package/components/tab/tab-panel.js +1 -1
  95. package/components/tab/tab.js +1 -1
  96. package/components/tooltip/index.js +1 -1
  97. package/components/transfer/index.js +1 -1
  98. package/components/tree-view/index.js +1 -1
  99. package/components/typography/index.js +1 -1
  100. package/global/index.js +3 -0
  101. package/icons/effect.js +1 -1
  102. package/icons/menu/v2/index.js +1 -1
  103. package/package.json +1 -1
  104. package/readme.md +10 -0
@@ -1,15 +1,16 @@
1
1
  /** @jsxRuntime classic */
2
2
  /** @jsx jsx */
3
3
  import { css, jsx } from '@emotion/core';
4
- import { Button, ButtonIcon, Divider, HelperText, InputBase, Label, Typography } from "../..";
4
+ import { Button, ButtonIcon, Divider, HelperText, InputBase, Label, Typography, CircularProgress, Popover } from "../..";
5
5
  import { getGlobal } from "../../../global";
6
6
  import locale from "../../../locale";
7
7
  import PropTypes from 'prop-types';
8
8
  import { forwardRef, memo, useCallback, useEffect, useImperativeHandle, useRef, useState } from 'react';
9
9
  import { render } from 'react-dom';
10
- import { bgColor, borderRadius4px, cursorPointer, displayBlock, displayFlex, displayNone, flexCol, flexRow, invisible, justifyBetween, justifyEnd, left, parseHeight, parseMaxWidth, parseMinWidth, pointerEventsNone, positionFixed, shadowLarge, textCenter, top, userSelectNone, whiteSpaceNoWrap, z } from "../../../styles/general";
10
+ import { bgColor, borderRadius4px, cursorPointer, displayBlock, displayFlex, displayNone, flexCol, flexRow, invisible, justifyBetween, justifyEnd, itemsCenter, left, parseHeight, parseMaxWidth, parseMinWidth, parseWidth, pointerEventsNone, positionFixed, shadowLarge, textCenter, top, userSelectNone, whiteSpaceNoWrap, z, justifyCenter, positionAbsolute, borderRadius, parseWidthHeight } from "../../../styles/general";
11
11
  import { useTheme } from "../../../theme";
12
12
  import { capitalizeSentenceCase, classNames, isEqual, date as moment, randomString, updatePosition } from "../../../utils";
13
+ import { getColor } from "../../../styles/utils";
13
14
  import { generateCalendarCSS, onUpdateNavigator, renderHeader, renderNavigator } from "../calendar/function";
14
15
  import ControlComp from "../control";
15
16
  import useThemeProps from "../../../theme/utils/useThemeProps";
@@ -65,7 +66,8 @@ const isAfter = (max, time) => {
65
66
  const parseDate = day => {
66
67
  return Date.parse(new Date(day));
67
68
  };
68
- const DateRangePicker = /*#__PURE__*/memo( /*#__PURE__*/forwardRef((inProps, reference) => {
69
+ const DateRangePicker = /*#__PURE__*/memo(/*#__PURE__*/forwardRef((inProps, reference) => {
70
+ var _periodOptions$dataSo;
69
71
  // props priority: `inProps` > `themeDefaultProps`
70
72
  const props = useThemeProps({
71
73
  props: inProps,
@@ -101,6 +103,7 @@ const DateRangePicker = /*#__PURE__*/memo( /*#__PURE__*/forwardRef((inProps, ref
101
103
  unitCount,
102
104
  value,
103
105
  viewType,
106
+ periodOptions,
104
107
  ...other
105
108
  } = props;
106
109
  const placeholder = placeholderProp !== null && placeholderProp !== void 0 ? placeholderProp : `${displayFormat} - ${displayFormat}`;
@@ -128,7 +131,15 @@ const DateRangePicker = /*#__PURE__*/memo( /*#__PURE__*/forwardRef((inProps, ref
128
131
  const [, setValueFr] = useState(Date.now());
129
132
  const [, setValueTo] = useState(Date.now());
130
133
  const [, setSelected] = useState(Date.now());
131
- const [focusBtn, setFocusBtn] = useState('today');
134
+ const [loadingState, setLoadingState] = useState(periodOptions === null || periodOptions === void 0 ? void 0 : periodOptions.loading);
135
+ const [totalState, setTotalState] = useState(periodOptions === null || periodOptions === void 0 ? void 0 : periodOptions.total);
136
+ const [dataSourceState, setDataSourceState] = useState((periodOptions === null || periodOptions === void 0 ? void 0 : periodOptions.dataSource) || []);
137
+ const [openState, setOpenState] = useState(false);
138
+ const selectedPeriodRef = useRef('');
139
+ const selectedPeriodIndex = useRef(null);
140
+ const focusBtnRef = useRef('today');
141
+ const loadMoreTimer = useRef(null);
142
+ const dropdownListRef = useRef(null);
132
143
  const [valueState, setValueState] = useState();
133
144
  const navigatorFromRefs = {
134
145
  doubleLeft: useRef(null),
@@ -153,9 +164,12 @@ const DateRangePicker = /*#__PURE__*/memo( /*#__PURE__*/forwardRef((inProps, ref
153
164
  const yesterdayText = getGlobal(['yesterday']);
154
165
  const thisWeekText = getGlobal(['thisWeek']);
155
166
  const thisMonthText = getGlobal(['thisMonth']);
167
+ const selectPeriodText = getGlobal(['selectPeriod']);
156
168
  const _ControlContainerCSS = ControlContainerCSS(theme);
157
169
  const _FooterContainerCSS = FooterContainerCSS(theme);
158
170
  const _DateOptionsCSS = DateOptionsCSS(theme);
171
+ const _PeriodContainerCSS = PeriodContainerCSS(theme);
172
+ const _PeriodItemCSS = PeriodItemCSS(theme);
159
173
  const updateValues = useCallback(v => {
160
174
  values.current = v;
161
175
  setValues();
@@ -262,8 +276,8 @@ const DateRangePicker = /*#__PURE__*/memo( /*#__PURE__*/forwardRef((inProps, ref
262
276
  tableData = [],
263
277
  weekDateFirst = getDateOfWeek(firstDay),
264
278
  weekDateLast = getDateOfWeek(lastDay);
265
- /**
266
- * days of previous month
279
+ /**
280
+ * days of previous month
267
281
  */
268
282
  for (let i = weekDateFirst; i > 0; i--) {
269
283
  const day = Date.parse(new Date(time.getFullYear(), time.getMonth(), 1));
@@ -275,8 +289,8 @@ const DateRangePicker = /*#__PURE__*/memo( /*#__PURE__*/forwardRef((inProps, ref
275
289
  className: unique.day.day
276
290
  })));
277
291
  }
278
- /**
279
- * days of current month
292
+ /**
293
+ * days of current month
280
294
  */
281
295
  for (let i = 0; i < lastDate; i++) {
282
296
  const day = new Date(time.getFullYear(), time.getMonth(), i + 1);
@@ -302,8 +316,8 @@ const DateRangePicker = /*#__PURE__*/memo( /*#__PURE__*/forwardRef((inProps, ref
302
316
  type: 'h6'
303
317
  }, i + 1)));
304
318
  }
305
- /**
306
- * days of next month
319
+ /**
320
+ * days of next month
307
321
  */
308
322
  for (let i = 0; i < 13 - weekDateLast; i++) {
309
323
  const day = Date.parse(new Date(time.getFullYear(), time.getMonth() + 1, 0));
@@ -512,7 +526,8 @@ const DateRangePicker = /*#__PURE__*/memo( /*#__PURE__*/forwardRef((inProps, ref
512
526
  const setButtonState = () => {
513
527
  const isVisible = isEqual(values.current, tempValues.current);
514
528
  const query = function (selector) {
515
- return footerRef.current.querySelector(selector);
529
+ var _footerRef$current;
530
+ return (_footerRef$current = footerRef.current) === null || _footerRef$current === void 0 ? void 0 : _footerRef$current.querySelector(selector);
516
531
  };
517
532
  const close = query(`.${unique.close}`);
518
533
  const cancel = query(`.${unique.cancel}`);
@@ -526,13 +541,13 @@ const DateRangePicker = /*#__PURE__*/memo( /*#__PURE__*/forwardRef((inProps, ref
526
541
  visibility: 'visible'
527
542
  };
528
543
  if (isVisible) {
529
- Object.assign(close.style, visible);
530
- Object.assign(cancel.style, hidden);
531
- Object.assign(confirm.style, hidden);
544
+ Object.assign((close === null || close === void 0 ? void 0 : close.style) || {}, visible);
545
+ Object.assign((cancel === null || cancel === void 0 ? void 0 : cancel.style) || {}, hidden);
546
+ Object.assign((confirm === null || confirm === void 0 ? void 0 : confirm.style) || {}, hidden);
532
547
  } else {
533
- Object.assign(cancel.style, visible);
534
- Object.assign(confirm.style, visible);
535
- Object.assign(close.style, hidden);
548
+ Object.assign((cancel === null || cancel === void 0 ? void 0 : cancel.style) || {}, visible);
549
+ Object.assign((confirm === null || confirm === void 0 ? void 0 : confirm.style) || {}, visible);
550
+ Object.assign((close === null || close === void 0 ? void 0 : close.style) || {}, hidden);
536
551
  }
537
552
  };
538
553
  const onCancel = () => {
@@ -693,6 +708,22 @@ const DateRangePicker = /*#__PURE__*/memo( /*#__PURE__*/forwardRef((inProps, ref
693
708
  controls && setButtonState();
694
709
  });
695
710
  };
711
+ const openPeriodPicker = () => {
712
+ // const arr = pickerRef.current.getElementsByTagName('td');
713
+ updateTempValues(values.current.length === 1 ? [values.current[0], values.current[0]] : values.current);
714
+ setOpenState(true);
715
+ setTimeout(() => {
716
+ renderPicker();
717
+ // pickerRef.current.addEventListener('mouseover', e => onPickerHover(e, arr));
718
+ window.addEventListener('resize', onResize);
719
+ window.addEventListener('scroll', onScroll);
720
+ document.addEventListener('mousedown', onClickOutside);
721
+ if (pressESCToClose) {
722
+ document.addEventListener('keydown', pressESCHandler);
723
+ }
724
+ controls && setButtonState();
725
+ });
726
+ };
696
727
  const closePicker = () => {
697
728
  const backGr = document.getElementById(unique.backGr);
698
729
  if (!backGr) return;
@@ -717,6 +748,7 @@ const DateRangePicker = /*#__PURE__*/memo( /*#__PURE__*/forwardRef((inProps, ref
717
748
  }
718
749
  ipRef.current && ipRef.current.blur();
719
750
  updateTempValues([]);
751
+ setOpenState(false);
720
752
  };
721
753
  const onClickOutside = e => {
722
754
  if (ipConRef.current && !ipConRef.current.contains(e.target) && ipRef.current && !ipRef.current.contains(e.target) && pickerRef.current && !pickerRef.current.contains(e.target)) {
@@ -735,21 +767,26 @@ const DateRangePicker = /*#__PURE__*/memo( /*#__PURE__*/forwardRef((inProps, ref
735
767
  const onInputFocus = () => {
736
768
  if (!isEnable) return;
737
769
  const el = ipConRef.current;
738
- if (!el.classList.contains(unique.focus)) {
739
- el.classList.add(unique.focus);
740
- openPicker();
770
+ if ((periodOptions === null || periodOptions === void 0 ? void 0 : periodOptions.enable) === true) {
771
+ openPeriodPicker();
772
+ } else {
773
+ if (!el.classList.contains(unique.focus)) {
774
+ el.classList.add(unique.focus);
775
+ openPicker();
776
+ }
741
777
  }
742
778
  };
743
779
  const setInputValue = (time, reset, unshift = false) => {
744
780
  if (!ipRef.current) return;
745
781
  const el = ipRef.current;
746
782
  let enUnitText = locale.get() === 'en' && selected.current > 1 ? unitText + 's' : unitText;
783
+ const showPeriod = periodOptions === null || periodOptions === void 0 ? void 0 : periodOptions.enable;
747
784
  let tempValue;
748
785
  if (!reset) {
749
786
  if (unshift) {
750
- tempValue = formatValue(time, displayFormat) + ' - ' + el.value + (showUnitCount ? ` (${selected.current} ${enUnitText})` : '');
787
+ tempValue = `${showPeriod && selectedPeriodRef.current ? `${selectedPeriodRef.current} (` : ''}` + formatValue(time, displayFormat) + ' - ' + el.value + (showUnitCount ? ` (${selected.current} ${enUnitText})` : '') + `${showPeriod ? ')' : ''}`;
751
788
  } else {
752
- tempValue = el.value + ' - ' + formatValue(time, displayFormat) + (showUnitCount ? ` (${selected.current} ${enUnitText})` : '');
789
+ tempValue = `${showPeriod && selectedPeriodRef.current ? `${selectedPeriodRef.current} (` : ''}` + el.value + ' - ' + formatValue(time, displayFormat) + (showUnitCount ? ` (${selected.current} ${enUnitText})` : '') + `${showPeriod && selectedPeriodRef.current ? ')' : ''}`;
753
790
  }
754
791
  } else {
755
792
  tempValue = formatValue(time, displayFormat);
@@ -768,14 +805,20 @@ const DateRangePicker = /*#__PURE__*/memo( /*#__PURE__*/forwardRef((inProps, ref
768
805
  !!onChange && onChange(e);
769
806
  onSwap(true);
770
807
  };
771
- const onClickPresetDate = type => {
808
+ const onClickPresetDate = (type, periodData) => {
772
809
  if (!type) return;
773
- setFocusBtn(type);
774
810
  let value = [];
775
811
  const currentDay = new Date();
812
+ if (focusBtnRef.current) {
813
+ document.getElementById(focusBtnRef.current).style.color = getColor('system/dark');
814
+ }
815
+ if (selectedPeriodIndex.current) {
816
+ document.getElementById(selectedPeriodIndex.current).style.background = getColor('white');
817
+ }
776
818
  switch (type) {
777
819
  case 'today':
778
820
  value = [new Date(Date.now() - 25200000).valueOf()];
821
+ valueFr.current = new Date(Date.now() - 25200000);
779
822
  break;
780
823
  case 'yesterday':
781
824
  {
@@ -788,21 +831,48 @@ const DateRangePicker = /*#__PURE__*/memo( /*#__PURE__*/forwardRef((inProps, ref
788
831
  {
789
832
  const first = currentDay.getDate() - currentDay.getDay() + 1; // First day is the day of the month - the day of the week
790
833
  const last = first + 6; // last day is the first day + 6
791
- const firstday = new Date(currentDay.setDate(first)).setHours(0, 0, 0).valueOf();
792
- const lastday = new Date(currentDay.setDate(last)).setHours(0, 0, 0).valueOf();
793
- value = [firstday, lastday];
834
+ const firstday = new Date(currentDay.setDate(first)).setHours(0, 0, 0);
835
+ const lastday = new Date(currentDay.setDate(last)).setHours(0, 0, 0);
836
+ value = [firstday.valueOf(), lastday.valueOf()];
837
+ valueFr.current = firstday;
838
+ valueTo.current = lastday;
794
839
  break;
795
840
  }
796
841
  case 'thisMonth':
797
842
  {
798
- let firstday = new Date(currentDay.getFullYear(), currentDay.getMonth(), 1).valueOf();
799
- let lastday = new Date(currentDay.getFullYear(), currentDay.getMonth() + 1, 0).valueOf();
800
- value = [firstday, lastday];
843
+ let firstday = new Date(currentDay.getFullYear(), currentDay.getMonth(), 1);
844
+ let lastday = new Date(currentDay.getFullYear(), currentDay.getMonth() + 1, 0);
845
+ value = [firstday.valueOf(), lastday.valueOf()];
846
+ valueFr.current = firstday;
847
+ valueTo.current = lastday;
848
+ break;
849
+ }
850
+ case 'period':
851
+ {
852
+ let firstday = periodData === null || periodData === void 0 ? void 0 : periodData[periodOptions === null || periodOptions === void 0 ? void 0 : periodOptions.valueFromExpr];
853
+ let lastday = periodData === null || periodData === void 0 ? void 0 : periodData[periodOptions === null || periodOptions === void 0 ? void 0 : periodOptions.valueToExpr];
854
+ if ((periodOptions === null || periodOptions === void 0 ? void 0 : periodOptions.valueFormat) === 'DD/MM/YYYY') {
855
+ const firstDayArray = firstday.split('/');
856
+ const lastDayArray = lastday.split('/');
857
+ firstday = new Date(firstDayArray[2], firstDayArray[1], firstDayArray[0]);
858
+ lastday = new Date(lastDayArray[2], lastDayArray[1], lastDayArray[0]);
859
+ }
860
+ value = [firstday.valueOf(), lastday.valueOf()];
861
+ valueFr.current = firstday;
862
+ valueTo.current = lastday;
863
+ selectedPeriodIndex.current = `period${periodData === null || periodData === void 0 ? void 0 : periodData.idx}`;
864
+ selectedPeriodRef.current = periodData === null || periodData === void 0 ? void 0 : periodData[periodOptions === null || periodOptions === void 0 ? void 0 : periodOptions.displayExpr];
865
+ document.getElementById(selectedPeriodIndex.current).style.background = getColor('fill/hover');
801
866
  break;
802
867
  }
803
868
  default:
804
869
  break;
805
870
  }
871
+ if (type !== 'period') {
872
+ selectedPeriodRef.current = '';
873
+ focusBtnRef.current = type;
874
+ document.getElementById(focusBtnRef.current).style.color = getColor('primary');
875
+ }
806
876
  updateValues(value);
807
877
  updateSelected(countDay(values.current));
808
878
  renderPicker();
@@ -873,6 +943,15 @@ const DateRangePicker = /*#__PURE__*/memo( /*#__PURE__*/forwardRef((inProps, ref
873
943
  closePicker();
874
944
  };
875
945
  }, [actionIconAt, clearAble, controls, disabled, displayFormat, max, min, pressESCToClose, readOnly, startFromZero, unitCount, viewType]);
946
+ useEffect(() => {
947
+ setLoadingState(periodOptions === null || periodOptions === void 0 ? void 0 : periodOptions.loading);
948
+ }, [periodOptions === null || periodOptions === void 0 ? void 0 : periodOptions.loading]);
949
+ useEffect(() => {
950
+ setTotalState(periodOptions === null || periodOptions === void 0 ? void 0 : periodOptions.total);
951
+ }, [periodOptions === null || periodOptions === void 0 ? void 0 : periodOptions.total]);
952
+ useEffect(() => {
953
+ setDataSourceState((periodOptions === null || periodOptions === void 0 ? void 0 : periodOptions.dataSource) || []);
954
+ }, [periodOptions === null || periodOptions === void 0 ? void 0 : periodOptions.dataSource]);
876
955
  useImperativeHandle(reference, () => {
877
956
  const currentRef = ref.current || {};
878
957
  currentRef.element = ref.current;
@@ -909,6 +988,7 @@ const DateRangePicker = /*#__PURE__*/memo( /*#__PURE__*/forwardRef((inProps, ref
909
988
  }, jsx("div", {
910
989
  css: _DateOptionsCSS
911
990
  }, jsx(Button, {
991
+ id: 'today',
912
992
  size: "medium",
913
993
  labelProps: {
914
994
  type: 'h4',
@@ -917,8 +997,9 @@ const DateRangePicker = /*#__PURE__*/memo( /*#__PURE__*/forwardRef((inProps, ref
917
997
  }
918
998
  },
919
999
  onClick: () => onClickPresetDate('today'),
920
- color: focusBtn === 'today' && 'primary'
1000
+ color: focusBtnRef.current === 'today' && 'primary'
921
1001
  }, todayText), jsx(Button, {
1002
+ id: 'yesterday',
922
1003
  size: "medium",
923
1004
  labelProps: {
924
1005
  type: 'h4',
@@ -927,8 +1008,9 @@ const DateRangePicker = /*#__PURE__*/memo( /*#__PURE__*/forwardRef((inProps, ref
927
1008
  }
928
1009
  },
929
1010
  onClick: () => onClickPresetDate('yesterday'),
930
- color: focusBtn === 'yesterday' && 'primary'
1011
+ color: focusBtnRef.current === 'yesterday' && 'primary'
931
1012
  }, yesterdayText), jsx(Button, {
1013
+ id: 'thisWeek',
932
1014
  size: "medium",
933
1015
  labelProps: {
934
1016
  type: 'h4',
@@ -937,8 +1019,9 @@ const DateRangePicker = /*#__PURE__*/memo( /*#__PURE__*/forwardRef((inProps, ref
937
1019
  }
938
1020
  },
939
1021
  onClick: () => onClickPresetDate('thisWeek'),
940
- color: focusBtn === 'thisWeek' && 'primary'
1022
+ color: focusBtnRef.current === 'thisWeek' && 'primary'
941
1023
  }, thisWeekText), jsx(Button, {
1024
+ id: 'thisMonth',
942
1025
  size: "medium",
943
1026
  labelProps: {
944
1027
  type: 'h4',
@@ -947,7 +1030,7 @@ const DateRangePicker = /*#__PURE__*/memo( /*#__PURE__*/forwardRef((inProps, ref
947
1030
  }
948
1031
  },
949
1032
  onClick: () => onClickPresetDate('thisMonth'),
950
- color: focusBtn === 'thisMonth' && 'primary'
1033
+ color: focusBtnRef.current === 'thisMonth' && 'primary'
951
1034
  }, thisMonthText)), jsx("div", {
952
1035
  css: _ControlContainerCSS,
953
1036
  className: unique.footer,
@@ -984,6 +1067,74 @@ const DateRangePicker = /*#__PURE__*/memo( /*#__PURE__*/forwardRef((inProps, ref
984
1067
  className: unique.table.table,
985
1068
  ref: tableToRef
986
1069
  }, renderHeader(unique), jsx("tbody", null))));
1070
+ const onLoadMoreHandler = e => {
1071
+ e.persist();
1072
+ if (loadMoreTimer.current) {
1073
+ clearTimeout(loadMoreTimer.current);
1074
+ }
1075
+ const {
1076
+ onLoadMore,
1077
+ limit
1078
+ } = periodOptions;
1079
+ loadMoreTimer.current = setTimeout(() => {
1080
+ if (onLoadMore && (dataSourceState === null || dataSourceState === void 0 ? void 0 : dataSourceState.length) < totalState && !loadingState) {
1081
+ const {
1082
+ scrollTop,
1083
+ scrollHeight,
1084
+ offsetHeight
1085
+ } = e.target;
1086
+ if (scrollHeight <= Math.ceil(scrollTop) + offsetHeight && dropdownListRef.current) {
1087
+ var _dropdownListRef$curr;
1088
+ const length = (_dropdownListRef$curr = dropdownListRef.current.children) === null || _dropdownListRef$curr === void 0 ? void 0 : _dropdownListRef$curr.length;
1089
+ !!onLoadMore && onLoadMore({
1090
+ skip: length,
1091
+ limit: limit
1092
+ });
1093
+ }
1094
+ }
1095
+ }, 300);
1096
+ };
1097
+ const rightCalendarPeriodComp = jsx("div", {
1098
+ css: _PeriodContainerCSS
1099
+ }, jsx(Typography, {
1100
+ color: 'inherit',
1101
+ type: 'h3',
1102
+ style: {
1103
+ marginBottom: 8
1104
+ }
1105
+ }, selectPeriodText), loadingState ? jsx("div", {
1106
+ css: LoadingProgressCSS,
1107
+ className: 'DGN-Dropdown-Loading-Progress'
1108
+ }, jsx(CircularProgress, {
1109
+ size: 24
1110
+ })) : null, jsx("div", {
1111
+ style: {
1112
+ width: '100%',
1113
+ maxHeight: 190,
1114
+ overflowY: 'scroll',
1115
+ boxSizing: 'border-box',
1116
+ paddingBottom: 36
1117
+ },
1118
+ ref: dropdownListRef,
1119
+ onScroll: onLoadMoreHandler
1120
+ }, periodOptions === null || periodOptions === void 0 ? void 0 : (_periodOptions$dataSo = periodOptions.dataSource) === null || _periodOptions$dataSo === void 0 ? void 0 : _periodOptions$dataSo.map((p, idx) => {
1121
+ const isSelected = (p === null || p === void 0 ? void 0 : p[periodOptions === null || periodOptions === void 0 ? void 0 : periodOptions.displayExpr]) === selectedPeriodRef.current;
1122
+ return jsx("div", {
1123
+ id: `period${idx}`,
1124
+ key: `period${idx}`,
1125
+ style: {
1126
+ background: isSelected ? getColor('fill/hover') : ''
1127
+ },
1128
+ css: _PeriodItemCSS,
1129
+ onClick: () => onClickPresetDate('period', {
1130
+ ...p,
1131
+ idx
1132
+ })
1133
+ }, jsx(Typography, {
1134
+ color: 'inherit',
1135
+ type: 'p1'
1136
+ }, p === null || p === void 0 ? void 0 : p[periodOptions === null || periodOptions === void 0 ? void 0 : periodOptions.displayExpr]));
1137
+ })));
987
1138
  const tooltipComp = jsx("div", {
988
1139
  className: unique.tooltip,
989
1140
  ref: tooltipRef
@@ -1004,7 +1155,7 @@ const DateRangePicker = /*#__PURE__*/memo( /*#__PURE__*/forwardRef((inProps, ref
1004
1155
  height: '226px',
1005
1156
  margin: spacing([4.5, 0.5, 0])
1006
1157
  }
1007
- }), rightCalendarComp), tooltipComp, controls ? footerMemo : null);
1158
+ }), controls && periodOptions !== null && periodOptions !== void 0 && periodOptions.enable ? rightCalendarPeriodComp : rightCalendarComp), tooltipComp, controls ? footerMemo : null);
1008
1159
  return jsx(ControlComp, {
1009
1160
  ...other,
1010
1161
  disabled: disabled,
@@ -1015,7 +1166,40 @@ const DateRangePicker = /*#__PURE__*/memo( /*#__PURE__*/forwardRef((inProps, ref
1015
1166
  ...labelProps,
1016
1167
  disabled: disabled,
1017
1168
  required: required
1018
- }, label) : null, jsx(InputBase, {
1169
+ }, label) : null, periodOptions !== null && periodOptions !== void 0 && periodOptions.enable ? jsx(Popover, {
1170
+ open: openState,
1171
+ className: 'DGN-UI-Popover-Period',
1172
+ anchorOrigin: {
1173
+ horizontal: 'left',
1174
+ vertical: 'bottom'
1175
+ },
1176
+ anchor: jsx("div", null, jsx(InputBase, {
1177
+ inputProps: {
1178
+ placeholder: !readOnly && !disabled ? placeholder : '',
1179
+ ...inputProps
1180
+ },
1181
+ readOnly: true,
1182
+ ref: ipConRef,
1183
+ inputRef: ipRef,
1184
+ disabled: disabled,
1185
+ viewType: viewType,
1186
+ inputStyle: {
1187
+ textAlign: textAlign,
1188
+ textOverflow: 'ellipsis',
1189
+ ...inputStyle
1190
+ },
1191
+ startIcon: startIcon,
1192
+ startIconProps: {
1193
+ className: 'non-effect allow-disabled'
1194
+ },
1195
+ endIcon: endIcon,
1196
+ value: valueState
1197
+ }), error ? jsx(HelperText, {
1198
+ ...helperTextProps,
1199
+ disabled: disabled
1200
+ }, error) : null),
1201
+ onOpen: openPeriodPicker
1202
+ }, pickerComp) : jsx("div", null, jsx(InputBase, {
1019
1203
  inputProps: {
1020
1204
  placeholder: !readOnly && !disabled ? placeholder : '',
1021
1205
  ...inputProps
@@ -1040,7 +1224,7 @@ const DateRangePicker = /*#__PURE__*/memo( /*#__PURE__*/forwardRef((inProps, ref
1040
1224
  }), error ? jsx(HelperText, {
1041
1225
  ...helperTextProps,
1042
1226
  disabled: disabled
1043
- }, error) : null);
1227
+ }, error) : null));
1044
1228
  }));
1045
1229
  const unique = {
1046
1230
  backGr: 'DGN-UI-Portal',
@@ -1057,6 +1241,7 @@ const unique = {
1057
1241
  }),
1058
1242
  wrapper: 'DGN-UI-DateRangePicker-Wrapper',
1059
1243
  container: 'DGN-UI-DateRangePicker',
1244
+ periodContainer: 'DGN-UI-DateRangePicker-Period',
1060
1245
  icon: 'DGN-UI-DateRangePicker-Icon',
1061
1246
  tooltip: 'DGN-UI-DateRangePicker-Tooltip',
1062
1247
  navigator: {
@@ -1132,6 +1317,29 @@ const DateOptionsCSS = ({
1132
1317
  ${displayFlex};
1133
1318
  padding-left: ${spacing(4)}px;
1134
1319
  `;
1320
+ const PeriodContainerCSS = ({
1321
+ spacing
1322
+ }) => css`
1323
+ ${displayFlex};
1324
+ ${flexCol};
1325
+ ${parseWidth('100%')};
1326
+ ${itemsCenter}
1327
+ margin: ${spacing([4, 0, 0, 0])} !important;
1328
+ `;
1329
+ const PeriodItemCSS = ({
1330
+ spacing
1331
+ }) => css`
1332
+ ${parseHeight(36)};
1333
+ ${displayFlex};
1334
+ ${itemsCenter};
1335
+ ${parseWidth('100%')};
1336
+ padding: ${spacing([2, 4])};
1337
+ box-sizing: border-box;
1338
+ &:hover {
1339
+ ${bgColor(getColor('fill/hover'))};
1340
+ ${cursorPointer};
1341
+ }
1342
+ `;
1135
1343
  const pickerCSS = {
1136
1344
  backGr: ({
1137
1345
  zIndex
@@ -1208,7 +1416,18 @@ const pickerCSS = {
1208
1416
  transform: 'scale(0)'
1209
1417
  }
1210
1418
  };
1211
-
1419
+ const LoadingProgressCSS = css`
1420
+ ${displayFlex};
1421
+ ${flexRow};
1422
+ ${justifyCenter};
1423
+ ${itemsCenter};
1424
+ ${positionAbsolute};
1425
+ ${borderRadius(4)};
1426
+ ${parseWidthHeight('100%')}
1427
+ ${bgColor('rgba(255, 255, 255, 0.6)')};
1428
+ ${z(2)};
1429
+ ${top(0)};
1430
+ `;
1212
1431
  // DateRangePicker.defaultProps = {
1213
1432
  // actionIconAt: 'end',
1214
1433
  // clearAble: false,
@@ -1262,6 +1481,22 @@ DateRangePicker.propTypes = {
1262
1481
  placeholder: PropTypes.string,
1263
1482
  /** If `true`, hitting escape will close component. */
1264
1483
  pressESCToClose: PropTypes.bool,
1484
+ /** Options for period selector.
1485
+ * example: {
1486
+ * enable: true,
1487
+ * dataSource: [],
1488
+ * displayExpr: "DisplayName",
1489
+ * valueFromExpr: "DateFrom",
1490
+ * valueToExpr: "DateTo",
1491
+ * valueFormat: "DD/MM/YYYY",
1492
+ * limit: 5,
1493
+ * skip: 0,
1494
+ * total: 100,
1495
+ * onLoadMore: () => {},
1496
+ * loading: false
1497
+ * }
1498
+ */
1499
+ periodOptions: PropTypes.object,
1265
1500
  /** If `true`, the component is readOnly. */
1266
1501
  readOnly: PropTypes.bool,
1267
1502
  /** If `true`, the input element is required. */