diginet-core-ui 1.4.54 → 1.4.55-beta.2

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 (109) hide show
  1. package/assets/images/menu/dhr/MHRM09N1401.svg +14 -0
  2. package/assets/images/menu/dhr/MHRM09N1402.svg +15 -0
  3. package/assets/images/menu/dhr/MHRM21N0001.svg +13 -0
  4. package/components/accordion/details.js +1 -1
  5. package/components/accordion/group.js +1 -1
  6. package/components/accordion/index.js +1 -1
  7. package/components/accordion/summary.js +1 -1
  8. package/components/alert/index.js +1 -1
  9. package/components/alert/notify.js +1 -1
  10. package/components/avatar/index.js +2 -2
  11. package/components/badge/index.js +1 -1
  12. package/components/breadcrumb/index.js +1 -1
  13. package/components/button/icon.js +1 -1
  14. package/components/button/index.js +1 -1
  15. package/components/button/more.js +16 -7
  16. package/components/button/ripple-effect.js +1 -1
  17. package/components/card/body.js +1 -1
  18. package/components/card/extra.js +1 -1
  19. package/components/card/footer.js +1 -1
  20. package/components/card/header.js +1 -1
  21. package/components/card/index.js +1 -1
  22. package/components/chart/Pie/Circle.js +1 -1
  23. package/components/chart/Pie/Sector.js +1 -1
  24. package/components/chart/Pie/index.js +1 -1
  25. package/components/chart/Pie-v2/Circle.js +1 -1
  26. package/components/chart/Pie-v2/Sector.js +1 -1
  27. package/components/chart/Pie-v2/index.js +1 -1
  28. package/components/chart/bar/Bar.js +1 -1
  29. package/components/chart/bar/index.js +1 -1
  30. package/components/chart/bar-v2/Bar.js +1 -1
  31. package/components/chart/bar-v2/index.js +1 -1
  32. package/components/chart/line/index.js +1 -1
  33. package/components/chart/line-v2/index.js +1 -1
  34. package/components/check-text/index.js +1 -1
  35. package/components/check-text/interview-confirmation.js +1 -1
  36. package/components/check-text/interview-status.js +1 -1
  37. package/components/chip/index.js +1 -1
  38. package/components/collapse/index.js +1 -1
  39. package/components/divider/index.js +1 -1
  40. package/components/form-control/attachment/index.js +22 -22
  41. package/components/form-control/calendar/function.js +1 -1
  42. package/components/form-control/calendar/index.js +2 -2
  43. package/components/form-control/calendar/range.js +1 -1
  44. package/components/form-control/checkbox/index.js +1 -1
  45. package/components/form-control/control/index.js +1 -1
  46. package/components/form-control/date-input/index.js +1 -1
  47. package/components/form-control/date-picker/index.js +1 -1
  48. package/components/form-control/date-range-picker/index.js +274 -38
  49. package/components/form-control/dropdown/index.js +34 -11
  50. package/components/form-control/dropdown-box/index.js +64 -22
  51. package/components/form-control/form-group/index.js +1 -1
  52. package/components/form-control/helper-text/index.js +1 -1
  53. package/components/form-control/input-base/UncontrolledInputBase.js +1 -1
  54. package/components/form-control/input-base/index.js +1 -1
  55. package/components/form-control/label/index.js +1 -1
  56. package/components/form-control/money-input/index.js +1 -1
  57. package/components/form-control/number-input/index2.js +5 -2
  58. package/components/form-control/password-input/index.js +1 -1
  59. package/components/form-control/phone-input/index.js +1 -1
  60. package/components/form-control/radio/index.js +1 -1
  61. package/components/form-control/text-input/index.js +1 -1
  62. package/components/form-control/time-picker/index.js +1 -1
  63. package/components/form-control/time-picker/v2/index.js +1 -1
  64. package/components/form-control/toggle/index.js +1 -1
  65. package/components/form-view/input.js +1 -1
  66. package/components/grid/index.js +1 -1
  67. package/components/image/index.js +1 -1
  68. package/components/list/list-item-action.js +1 -1
  69. package/components/list/list-item-icon.js +1 -1
  70. package/components/list/list-item-text.js +1 -1
  71. package/components/list/list-item.js +1 -1
  72. package/components/list/list.js +1 -1
  73. package/components/list/sub-header.js +1 -1
  74. package/components/modal/body.js +1 -1
  75. package/components/modal/footer.js +1 -1
  76. package/components/modal/header.js +1 -1
  77. package/components/modal/index.js +1 -1
  78. package/components/modal/modal.js +1 -1
  79. package/components/others/option-wrapper/index.js +1 -1
  80. package/components/paging/page-info.js +35 -35
  81. package/components/paging/page-selector.js +1 -1
  82. package/components/paper/index.js +1 -1
  83. package/components/popover/body.js +1 -1
  84. package/components/popover/footer.js +1 -1
  85. package/components/popover/header.js +1 -1
  86. package/components/popover/index.js +14 -14
  87. package/components/popup/index.js +1 -1
  88. package/components/popup/v2/index.js +1 -1
  89. package/components/progress/circular.js +1 -1
  90. package/components/progress/linear.js +1 -1
  91. package/components/rating/index.js +1 -1
  92. package/components/skeleton/index.js +1 -1
  93. package/components/slider/slider-container.js +1 -1
  94. package/components/slider/slider-item.js +1 -1
  95. package/components/status/index.js +1 -1
  96. package/components/tab/tab-container.js +1 -1
  97. package/components/tab/tab-header.js +1 -1
  98. package/components/tab/tab-panel.js +1 -1
  99. package/components/tab/tab.js +1 -1
  100. package/components/tooltip/index.js +1 -1
  101. package/components/transfer/index.js +1 -1
  102. package/components/tree-view/index.js +1 -1
  103. package/components/typography/index.js +1 -1
  104. package/global/index.js +3 -0
  105. package/icons/basic.js +134 -0
  106. package/icons/effect.js +1 -1
  107. package/icons/menu/v2/index.js +1 -1
  108. package/package.json +78 -44
  109. package/readme.md +10 -0
@@ -7,7 +7,7 @@ import PropTypes from 'prop-types';
7
7
  import { displayBlock, pointerEventsNone, positionRelative, textColor, userSelectNone } from "../../../styles/general";
8
8
  import { getProp } from "../../../utils";
9
9
  import { useTheme } from "../../../theme";
10
- const Control = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
10
+ const Control = /*#__PURE__*/memo(/*#__PURE__*/forwardRef(({
11
11
  children,
12
12
  className,
13
13
  disabled,
@@ -14,7 +14,7 @@ import useDateInputState from "./useDateInputState";
14
14
  import useIsFocused from "./useIsFocused";
15
15
  import useKeyboardInputEvent from "./useKeyboardInputEvent";
16
16
  import { getInputSelectedState, isFieldFullValue, useEventCallback, useInputSelection, validateDateTime } from "./utils";
17
- const DateInput = /*#__PURE__*/memo( /*#__PURE__*/forwardRef((inProps, reference) => {
17
+ const DateInput = /*#__PURE__*/memo(/*#__PURE__*/forwardRef((inProps, reference) => {
18
18
  if (!reference) reference = useRef(null);
19
19
 
20
20
  // props priority: `inProps` > `themeDefaultProps`
@@ -64,7 +64,7 @@ const getDateFormats = (locale, minZoom) => {
64
64
  }
65
65
  return formatMap.get(minZoom);
66
66
  };
67
- const DatePicker = /*#__PURE__*/memo( /*#__PURE__*/forwardRef((inProps, reference) => {
67
+ const DatePicker = /*#__PURE__*/memo(/*#__PURE__*/forwardRef((inProps, reference) => {
68
68
  var _getDateFormats, _pickerReturnFormat$g, _ipRef$current, _ipRef$current2;
69
69
  if (!reference) reference = useRef(null);
70
70
  const theme = useTheme();
@@ -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,7 +708,24 @@ 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 = () => {
728
+ setOpenState(false);
697
729
  const backGr = document.getElementById(unique.backGr);
698
730
  if (!backGr) return;
699
731
  const picker = backGr.querySelector(`#${unique.picker}`);
@@ -717,6 +749,7 @@ const DateRangePicker = /*#__PURE__*/memo( /*#__PURE__*/forwardRef((inProps, ref
717
749
  }
718
750
  ipRef.current && ipRef.current.blur();
719
751
  updateTempValues([]);
752
+ setOpenState(false);
720
753
  };
721
754
  const onClickOutside = e => {
722
755
  if (ipConRef.current && !ipConRef.current.contains(e.target) && ipRef.current && !ipRef.current.contains(e.target) && pickerRef.current && !pickerRef.current.contains(e.target)) {
@@ -735,21 +768,26 @@ const DateRangePicker = /*#__PURE__*/memo( /*#__PURE__*/forwardRef((inProps, ref
735
768
  const onInputFocus = () => {
736
769
  if (!isEnable) return;
737
770
  const el = ipConRef.current;
738
- if (!el.classList.contains(unique.focus)) {
739
- el.classList.add(unique.focus);
740
- openPicker();
771
+ if ((periodOptions === null || periodOptions === void 0 ? void 0 : periodOptions.enable) === true) {
772
+ openPeriodPicker();
773
+ } else {
774
+ if (!el.classList.contains(unique.focus)) {
775
+ el.classList.add(unique.focus);
776
+ openPicker();
777
+ }
741
778
  }
742
779
  };
743
780
  const setInputValue = (time, reset, unshift = false) => {
744
781
  if (!ipRef.current) return;
745
782
  const el = ipRef.current;
746
783
  let enUnitText = locale.get() === 'en' && selected.current > 1 ? unitText + 's' : unitText;
784
+ const showPeriod = periodOptions === null || periodOptions === void 0 ? void 0 : periodOptions.enable;
747
785
  let tempValue;
748
786
  if (!reset) {
749
787
  if (unshift) {
750
- tempValue = formatValue(time, displayFormat) + ' - ' + el.value + (showUnitCount ? ` (${selected.current} ${enUnitText})` : '');
788
+ tempValue = `${showPeriod && selectedPeriodRef.current ? `${selectedPeriodRef.current} (` : ''}` + formatValue(time, displayFormat) + ' - ' + el.value + (showUnitCount ? ` (${selected.current} ${enUnitText})` : '') + `${showPeriod ? ')' : ''}`;
751
789
  } else {
752
- tempValue = el.value + ' - ' + formatValue(time, displayFormat) + (showUnitCount ? ` (${selected.current} ${enUnitText})` : '');
790
+ tempValue = `${showPeriod && selectedPeriodRef.current ? `${selectedPeriodRef.current} (` : ''}` + el.value + ' - ' + formatValue(time, displayFormat) + (showUnitCount ? ` (${selected.current} ${enUnitText})` : '') + `${showPeriod && selectedPeriodRef.current ? ')' : ''}`;
753
791
  }
754
792
  } else {
755
793
  tempValue = formatValue(time, displayFormat);
@@ -768,14 +806,20 @@ const DateRangePicker = /*#__PURE__*/memo( /*#__PURE__*/forwardRef((inProps, ref
768
806
  !!onChange && onChange(e);
769
807
  onSwap(true);
770
808
  };
771
- const onClickPresetDate = type => {
809
+ const onClickPresetDate = (type, periodData) => {
772
810
  if (!type) return;
773
- setFocusBtn(type);
774
811
  let value = [];
775
812
  const currentDay = new Date();
813
+ if (focusBtnRef.current) {
814
+ document.getElementById(focusBtnRef.current).style.color = getColor('system/dark');
815
+ }
816
+ if (selectedPeriodIndex.current) {
817
+ document.getElementById(selectedPeriodIndex.current).style.background = getColor('white');
818
+ }
776
819
  switch (type) {
777
820
  case 'today':
778
821
  value = [new Date(Date.now() - 25200000).valueOf()];
822
+ valueFr.current = new Date(Date.now() - 25200000);
779
823
  break;
780
824
  case 'yesterday':
781
825
  {
@@ -788,21 +832,48 @@ const DateRangePicker = /*#__PURE__*/memo( /*#__PURE__*/forwardRef((inProps, ref
788
832
  {
789
833
  const first = currentDay.getDate() - currentDay.getDay() + 1; // First day is the day of the month - the day of the week
790
834
  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];
835
+ const firstday = new Date(currentDay.setDate(first)).setHours(0, 0, 0);
836
+ const lastday = new Date(currentDay.setDate(last)).setHours(0, 0, 0);
837
+ value = [firstday.valueOf(), lastday.valueOf()];
838
+ valueFr.current = firstday;
839
+ valueTo.current = lastday;
794
840
  break;
795
841
  }
796
842
  case 'thisMonth':
797
843
  {
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];
844
+ let firstday = new Date(currentDay.getFullYear(), currentDay.getMonth(), 1);
845
+ let lastday = new Date(currentDay.getFullYear(), currentDay.getMonth() + 1, 0);
846
+ value = [firstday.valueOf(), lastday.valueOf()];
847
+ valueFr.current = firstday;
848
+ valueTo.current = lastday;
849
+ break;
850
+ }
851
+ case 'period':
852
+ {
853
+ let firstday = periodData === null || periodData === void 0 ? void 0 : periodData[periodOptions === null || periodOptions === void 0 ? void 0 : periodOptions.valueFromExpr];
854
+ let lastday = periodData === null || periodData === void 0 ? void 0 : periodData[periodOptions === null || periodOptions === void 0 ? void 0 : periodOptions.valueToExpr];
855
+ if ((periodOptions === null || periodOptions === void 0 ? void 0 : periodOptions.valueFormat) === 'DD/MM/YYYY') {
856
+ const firstDayArray = firstday.split('/');
857
+ const lastDayArray = lastday.split('/');
858
+ firstday = new Date(firstDayArray[2], firstDayArray[1], firstDayArray[0]);
859
+ lastday = new Date(lastDayArray[2], lastDayArray[1], lastDayArray[0]);
860
+ }
861
+ value = [firstday.valueOf(), lastday.valueOf()];
862
+ valueFr.current = firstday;
863
+ valueTo.current = lastday;
864
+ selectedPeriodIndex.current = `period${periodData === null || periodData === void 0 ? void 0 : periodData.idx}`;
865
+ selectedPeriodRef.current = periodData === null || periodData === void 0 ? void 0 : periodData[periodOptions === null || periodOptions === void 0 ? void 0 : periodOptions.displayExpr];
866
+ document.getElementById(selectedPeriodIndex.current).style.background = getColor('fill/hover');
801
867
  break;
802
868
  }
803
869
  default:
804
870
  break;
805
871
  }
872
+ if (type !== 'period') {
873
+ selectedPeriodRef.current = '';
874
+ focusBtnRef.current = type;
875
+ document.getElementById(focusBtnRef.current).style.color = getColor('primary');
876
+ }
806
877
  updateValues(value);
807
878
  updateSelected(countDay(values.current));
808
879
  renderPicker();
@@ -873,6 +944,15 @@ const DateRangePicker = /*#__PURE__*/memo( /*#__PURE__*/forwardRef((inProps, ref
873
944
  closePicker();
874
945
  };
875
946
  }, [actionIconAt, clearAble, controls, disabled, displayFormat, max, min, pressESCToClose, readOnly, startFromZero, unitCount, viewType]);
947
+ useEffect(() => {
948
+ setLoadingState(periodOptions === null || periodOptions === void 0 ? void 0 : periodOptions.loading);
949
+ }, [periodOptions === null || periodOptions === void 0 ? void 0 : periodOptions.loading]);
950
+ useEffect(() => {
951
+ setTotalState(periodOptions === null || periodOptions === void 0 ? void 0 : periodOptions.total);
952
+ }, [periodOptions === null || periodOptions === void 0 ? void 0 : periodOptions.total]);
953
+ useEffect(() => {
954
+ setDataSourceState((periodOptions === null || periodOptions === void 0 ? void 0 : periodOptions.dataSource) || []);
955
+ }, [periodOptions === null || periodOptions === void 0 ? void 0 : periodOptions.dataSource]);
876
956
  useImperativeHandle(reference, () => {
877
957
  const currentRef = ref.current || {};
878
958
  currentRef.element = ref.current;
@@ -909,6 +989,7 @@ const DateRangePicker = /*#__PURE__*/memo( /*#__PURE__*/forwardRef((inProps, ref
909
989
  }, jsx("div", {
910
990
  css: _DateOptionsCSS
911
991
  }, jsx(Button, {
992
+ id: 'today',
912
993
  size: "medium",
913
994
  labelProps: {
914
995
  type: 'h4',
@@ -917,8 +998,9 @@ const DateRangePicker = /*#__PURE__*/memo( /*#__PURE__*/forwardRef((inProps, ref
917
998
  }
918
999
  },
919
1000
  onClick: () => onClickPresetDate('today'),
920
- color: focusBtn === 'today' && 'primary'
1001
+ color: focusBtnRef.current === 'today' && 'primary'
921
1002
  }, todayText), jsx(Button, {
1003
+ id: 'yesterday',
922
1004
  size: "medium",
923
1005
  labelProps: {
924
1006
  type: 'h4',
@@ -927,8 +1009,9 @@ const DateRangePicker = /*#__PURE__*/memo( /*#__PURE__*/forwardRef((inProps, ref
927
1009
  }
928
1010
  },
929
1011
  onClick: () => onClickPresetDate('yesterday'),
930
- color: focusBtn === 'yesterday' && 'primary'
1012
+ color: focusBtnRef.current === 'yesterday' && 'primary'
931
1013
  }, yesterdayText), jsx(Button, {
1014
+ id: 'thisWeek',
932
1015
  size: "medium",
933
1016
  labelProps: {
934
1017
  type: 'h4',
@@ -937,8 +1020,9 @@ const DateRangePicker = /*#__PURE__*/memo( /*#__PURE__*/forwardRef((inProps, ref
937
1020
  }
938
1021
  },
939
1022
  onClick: () => onClickPresetDate('thisWeek'),
940
- color: focusBtn === 'thisWeek' && 'primary'
1023
+ color: focusBtnRef.current === 'thisWeek' && 'primary'
941
1024
  }, thisWeekText), jsx(Button, {
1025
+ id: 'thisMonth',
942
1026
  size: "medium",
943
1027
  labelProps: {
944
1028
  type: 'h4',
@@ -947,7 +1031,7 @@ const DateRangePicker = /*#__PURE__*/memo( /*#__PURE__*/forwardRef((inProps, ref
947
1031
  }
948
1032
  },
949
1033
  onClick: () => onClickPresetDate('thisMonth'),
950
- color: focusBtn === 'thisMonth' && 'primary'
1034
+ color: focusBtnRef.current === 'thisMonth' && 'primary'
951
1035
  }, thisMonthText)), jsx("div", {
952
1036
  css: _ControlContainerCSS,
953
1037
  className: unique.footer,
@@ -984,6 +1068,74 @@ const DateRangePicker = /*#__PURE__*/memo( /*#__PURE__*/forwardRef((inProps, ref
984
1068
  className: unique.table.table,
985
1069
  ref: tableToRef
986
1070
  }, renderHeader(unique), jsx("tbody", null))));
1071
+ const onLoadMoreHandler = e => {
1072
+ e.persist();
1073
+ if (loadMoreTimer.current) {
1074
+ clearTimeout(loadMoreTimer.current);
1075
+ }
1076
+ const {
1077
+ onLoadMore,
1078
+ limit
1079
+ } = periodOptions;
1080
+ loadMoreTimer.current = setTimeout(() => {
1081
+ if (onLoadMore && (dataSourceState === null || dataSourceState === void 0 ? void 0 : dataSourceState.length) < totalState && !loadingState) {
1082
+ const {
1083
+ scrollTop,
1084
+ scrollHeight,
1085
+ offsetHeight
1086
+ } = e.target;
1087
+ if (scrollHeight <= Math.ceil(scrollTop) + offsetHeight && dropdownListRef.current) {
1088
+ var _dropdownListRef$curr;
1089
+ const length = (_dropdownListRef$curr = dropdownListRef.current.children) === null || _dropdownListRef$curr === void 0 ? void 0 : _dropdownListRef$curr.length;
1090
+ !!onLoadMore && onLoadMore({
1091
+ skip: length,
1092
+ limit: limit
1093
+ });
1094
+ }
1095
+ }
1096
+ }, 300);
1097
+ };
1098
+ const rightCalendarPeriodComp = jsx("div", {
1099
+ css: _PeriodContainerCSS
1100
+ }, jsx(Typography, {
1101
+ color: 'inherit',
1102
+ type: 'h3',
1103
+ style: {
1104
+ marginBottom: 8
1105
+ }
1106
+ }, selectPeriodText), loadingState ? jsx("div", {
1107
+ css: LoadingProgressCSS,
1108
+ className: 'DGN-Dropdown-Loading-Progress'
1109
+ }, jsx(CircularProgress, {
1110
+ size: 24
1111
+ })) : null, jsx("div", {
1112
+ style: {
1113
+ width: '100%',
1114
+ maxHeight: 190,
1115
+ overflowY: 'scroll',
1116
+ boxSizing: 'border-box',
1117
+ paddingBottom: 36
1118
+ },
1119
+ ref: dropdownListRef,
1120
+ onScroll: onLoadMoreHandler
1121
+ }, periodOptions === null || periodOptions === void 0 ? void 0 : (_periodOptions$dataSo = periodOptions.dataSource) === null || _periodOptions$dataSo === void 0 ? void 0 : _periodOptions$dataSo.map((p, idx) => {
1122
+ const isSelected = (p === null || p === void 0 ? void 0 : p[periodOptions === null || periodOptions === void 0 ? void 0 : periodOptions.displayExpr]) === selectedPeriodRef.current;
1123
+ return jsx("div", {
1124
+ id: `period${idx}`,
1125
+ key: `period${idx}`,
1126
+ style: {
1127
+ background: isSelected ? getColor('fill/hover') : ''
1128
+ },
1129
+ css: _PeriodItemCSS,
1130
+ onClick: () => onClickPresetDate('period', {
1131
+ ...p,
1132
+ idx
1133
+ })
1134
+ }, jsx(Typography, {
1135
+ color: 'inherit',
1136
+ type: 'p1'
1137
+ }, p === null || p === void 0 ? void 0 : p[periodOptions === null || periodOptions === void 0 ? void 0 : periodOptions.displayExpr]));
1138
+ })));
987
1139
  const tooltipComp = jsx("div", {
988
1140
  className: unique.tooltip,
989
1141
  ref: tooltipRef
@@ -1004,7 +1156,7 @@ const DateRangePicker = /*#__PURE__*/memo( /*#__PURE__*/forwardRef((inProps, ref
1004
1156
  height: '226px',
1005
1157
  margin: spacing([4.5, 0.5, 0])
1006
1158
  }
1007
- }), rightCalendarComp), tooltipComp, controls ? footerMemo : null);
1159
+ }), controls && periodOptions !== null && periodOptions !== void 0 && periodOptions.enable ? rightCalendarPeriodComp : rightCalendarComp), tooltipComp, controls ? footerMemo : null);
1008
1160
  return jsx(ControlComp, {
1009
1161
  ...other,
1010
1162
  disabled: disabled,
@@ -1015,7 +1167,40 @@ const DateRangePicker = /*#__PURE__*/memo( /*#__PURE__*/forwardRef((inProps, ref
1015
1167
  ...labelProps,
1016
1168
  disabled: disabled,
1017
1169
  required: required
1018
- }, label) : null, jsx(InputBase, {
1170
+ }, label) : null, periodOptions !== null && periodOptions !== void 0 && periodOptions.enable ? jsx(Popover, {
1171
+ open: openState,
1172
+ className: 'DGN-UI-Popover-Period',
1173
+ anchorOrigin: {
1174
+ horizontal: 'left',
1175
+ vertical: 'bottom'
1176
+ },
1177
+ anchor: jsx("div", null, jsx(InputBase, {
1178
+ inputProps: {
1179
+ placeholder: !readOnly && !disabled ? placeholder : '',
1180
+ ...inputProps
1181
+ },
1182
+ readOnly: true,
1183
+ ref: ipConRef,
1184
+ inputRef: ipRef,
1185
+ disabled: disabled,
1186
+ viewType: viewType,
1187
+ inputStyle: {
1188
+ textAlign: textAlign,
1189
+ textOverflow: 'ellipsis',
1190
+ ...inputStyle
1191
+ },
1192
+ startIcon: startIcon,
1193
+ startIconProps: {
1194
+ className: 'non-effect allow-disabled'
1195
+ },
1196
+ endIcon: endIcon,
1197
+ value: valueState
1198
+ }), error ? jsx(HelperText, {
1199
+ ...helperTextProps,
1200
+ disabled: disabled
1201
+ }, error) : null),
1202
+ onOpen: openPeriodPicker
1203
+ }, pickerComp) : jsx("div", null, jsx(InputBase, {
1019
1204
  inputProps: {
1020
1205
  placeholder: !readOnly && !disabled ? placeholder : '',
1021
1206
  ...inputProps
@@ -1040,7 +1225,7 @@ const DateRangePicker = /*#__PURE__*/memo( /*#__PURE__*/forwardRef((inProps, ref
1040
1225
  }), error ? jsx(HelperText, {
1041
1226
  ...helperTextProps,
1042
1227
  disabled: disabled
1043
- }, error) : null);
1228
+ }, error) : null));
1044
1229
  }));
1045
1230
  const unique = {
1046
1231
  backGr: 'DGN-UI-Portal',
@@ -1057,6 +1242,7 @@ const unique = {
1057
1242
  }),
1058
1243
  wrapper: 'DGN-UI-DateRangePicker-Wrapper',
1059
1244
  container: 'DGN-UI-DateRangePicker',
1245
+ periodContainer: 'DGN-UI-DateRangePicker-Period',
1060
1246
  icon: 'DGN-UI-DateRangePicker-Icon',
1061
1247
  tooltip: 'DGN-UI-DateRangePicker-Tooltip',
1062
1248
  navigator: {
@@ -1132,6 +1318,29 @@ const DateOptionsCSS = ({
1132
1318
  ${displayFlex};
1133
1319
  padding-left: ${spacing(4)}px;
1134
1320
  `;
1321
+ const PeriodContainerCSS = ({
1322
+ spacing
1323
+ }) => css`
1324
+ ${displayFlex};
1325
+ ${flexCol};
1326
+ ${parseWidth('100%')};
1327
+ ${itemsCenter}
1328
+ margin: ${spacing([4, 0, 0, 0])} !important;
1329
+ `;
1330
+ const PeriodItemCSS = ({
1331
+ spacing
1332
+ }) => css`
1333
+ ${parseHeight(36)};
1334
+ ${displayFlex};
1335
+ ${itemsCenter};
1336
+ ${parseWidth('100%')};
1337
+ padding: ${spacing([2, 4])};
1338
+ box-sizing: border-box;
1339
+ &:hover {
1340
+ ${bgColor(getColor('fill/hover'))};
1341
+ ${cursorPointer};
1342
+ }
1343
+ `;
1135
1344
  const pickerCSS = {
1136
1345
  backGr: ({
1137
1346
  zIndex
@@ -1208,7 +1417,18 @@ const pickerCSS = {
1208
1417
  transform: 'scale(0)'
1209
1418
  }
1210
1419
  };
1211
-
1420
+ const LoadingProgressCSS = css`
1421
+ ${displayFlex};
1422
+ ${flexRow};
1423
+ ${justifyCenter};
1424
+ ${itemsCenter};
1425
+ ${positionAbsolute};
1426
+ ${borderRadius(4)};
1427
+ ${parseWidthHeight('100%')}
1428
+ ${bgColor('rgba(255, 255, 255, 0.6)')};
1429
+ ${z(2)};
1430
+ ${top(0)};
1431
+ `;
1212
1432
  // DateRangePicker.defaultProps = {
1213
1433
  // actionIconAt: 'end',
1214
1434
  // clearAble: false,
@@ -1262,6 +1482,22 @@ DateRangePicker.propTypes = {
1262
1482
  placeholder: PropTypes.string,
1263
1483
  /** If `true`, hitting escape will close component. */
1264
1484
  pressESCToClose: PropTypes.bool,
1485
+ /** Options for period selector.
1486
+ * example: {
1487
+ * enable: true,
1488
+ * dataSource: [],
1489
+ * displayExpr: "DisplayName",
1490
+ * valueFromExpr: "DateFrom",
1491
+ * valueToExpr: "DateTo",
1492
+ * valueFormat: "DD/MM/YYYY",
1493
+ * limit: 5,
1494
+ * skip: 0,
1495
+ * total: 100,
1496
+ * onLoadMore: () => {},
1497
+ * loading: false
1498
+ * }
1499
+ */
1500
+ periodOptions: PropTypes.object,
1265
1501
  /** If `true`, the component is readOnly. */
1266
1502
  readOnly: PropTypes.bool,
1267
1503
  /** If `true`, the input element is required. */