diginet-core-ui 1.4.55 → 1.4.56

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.
@@ -0,0 +1,18 @@
1
+ <svg width="39" height="39" viewBox="0 0 39 39" fill="none" xmlns="http://www.w3.org/2000/svg">
2
+ <g clip-path="url(#clip0_2399_73)">
3
+ <path d="M33.6 3.09998H31V5.69998C31 7.39998 29.6 8.69998 28 8.69998C26.3 8.69998 25 7.39998 25 5.69998V3.09998H14V5.69998C14 7.39998 12.7 8.69998 11 8.69998C9.4 8.69998 8 7.39998 8 5.69998V3.09998H5.4C2.4 3.09998 0 5.49998 0 8.39998V33.6C0 36.6 2.4 39 5.4 39H33.6C36.6 39 39 36.6 39 33.6V8.39998C39 5.49998 36.6 3.09998 33.6 3.09998ZM36.4 33.1C36.4 35 34.9 36.5 33 36.5H6C4.1 36.5 2.6 35 2.6 33.1V13H36.5V33.1H36.4Z" fill="#2680EB"/>
4
+ <path d="M30 5.9V1.8C30 0.8 29.2 0 28.2 0H27.8C26.8 0 26 0.8 26 1.8V5.9C26 6.9 26.8 7.7 27.8 7.7H28.2C29.2 7.7 30 6.9 30 5.9Z" fill="#7BC0F9"/>
5
+ <path d="M13 5.9V1.8C13 0.8 12.2 0 11.2 0H10.8C9.8 0 9 0.8 9 1.8V5.9C9 6.9 9.8 7.7 10.8 7.7H11.2C12.2 7.7 13 6.9 13 5.9Z" fill="#7BC0F9"/>
6
+ <path d="M7 17.7C7 17.3 7.3 17 7.7 17H22.4C22.8 17 23.1 17.3 23.1 17.7V20.4C23.1 20.8 22.8 21.1 22.4 21.1H7.7C7.3 21 7 20.7 7 20.3V17.7Z" fill="#FF8C00"/>
7
+ <path d="M24 17.7C24 17.3 24.3 17 24.7 17H27.4C27.8 17 28.1 17.3 28.1 17.7V20.4C28.1 20.8 27.8 21.1 27.4 21.1H24.7C24.3 21.1 24 20.8 24 20.4V17.7Z" fill="#FFC766"/>
8
+ <path d="M29 29.7C29 29.3 29.3 29 29.7 29H32.4C32.8 29 33.1 29.3 33.1 29.7V32.4C33.1 32.8 32.8 33.1 32.4 33.1H29.7C29.3 33.1 29 32.8 29 32.4V29.7Z" fill="#F79B91"/>
9
+ <path d="M12 23.7C12 23.3 12.3 23 12.7 23H15.4C15.8 23 16.1 23.3 16.1 23.7V26.4C16.1 26.8 15.8 27.1 15.4 27.1H12.7C12.3 27.1 12 26.8 12 26.4V23.7Z" fill="#CE8FEB"/>
10
+ <path d="M17 23.7C17 23.3 17.3 23 17.7 23H32.4C32.8 23 33.1 23.3 33.1 23.7V26.4C33.1 26.8 32.8 27.1 32.4 27.1H17.7C17.3 27.1 17 26.8 17 26.4V23.7Z" fill="#8A43BF"/>
11
+ <path d="M6 29.7C6 29.3 6.3 29 6.7 29H27.4C27.8 29 28.1 29.3 28.1 29.7V32.4C28.1 32.8 27.8 33.1 27.4 33.1H6.7C6.3 33 6 32.7 6 32.3V29.7Z" fill="#FF4444"/>
12
+ </g>
13
+ <defs>
14
+ <clipPath id="clip0_2399_73">
15
+ <rect width="39" height="39" fill="white"/>
16
+ </clipPath>
17
+ </defs>
18
+ </svg>
@@ -0,0 +1,18 @@
1
+ <svg width="39" height="39" viewBox="0 0 39 39" fill="none" xmlns="http://www.w3.org/2000/svg">
2
+ <g clip-path="url(#clip0_2399_72)">
3
+ <path d="M33.6 3.09998H31V5.69998C31 7.39998 29.6 8.69998 28 8.69998C26.3 8.69998 25 7.39998 25 5.69998V3.09998H14V5.69998C14 7.39998 12.7 8.69998 11 8.69998C9.4 8.69998 8 7.39998 8 5.69998V3.09998H5.4C2.4 3.09998 0 5.49998 0 8.39998V33.6C0 36.6 2.4 39 5.4 39H33.6C36.6 39 39 36.6 39 33.6V8.39998C39 5.49998 36.6 3.09998 33.6 3.09998ZM36.4 33.1C36.4 35 34.9 36.5 33 36.5H6C4.1 36.5 2.6 35 2.6 33.1V13H36.5V33.1H36.4Z" fill="#2680EB"/>
4
+ <path d="M30 5.9V1.8C30 0.8 29.2 0 28.2 0H27.8C26.8 0 26 0.8 26 1.8V5.9C26 6.9 26.8 7.7 27.8 7.7H28.2C29.2 7.7 30 6.9 30 5.9Z" fill="#7BC0F9"/>
5
+ <path d="M13 5.9V1.8C13 0.8 12.2 0 11.2 0H10.8C9.8 0 9 0.8 9 1.8V5.9C9 6.9 9.8 7.7 10.8 7.7H11.2C12.2 7.7 13 6.9 13 5.9Z" fill="#7BC0F9"/>
6
+ <path d="M7 17.7C7 17.3 7.3 17 7.7 17H22.4C22.8 17 23.1 17.3 23.1 17.7V20.4C23.1 20.8 22.8 21.1 22.4 21.1H7.7C7.3 21 7 20.7 7 20.3V17.7Z" fill="#FF8C00"/>
7
+ <path d="M24 17.7C24 17.3 24.3 17 24.7 17H27.4C27.8 17 28.1 17.3 28.1 17.7V20.4C28.1 20.8 27.8 21.1 27.4 21.1H24.7C24.3 21.1 24 20.8 24 20.4V17.7Z" fill="#FFC766"/>
8
+ <path d="M29 29.7C29 29.3 29.3 29 29.7 29H32.4C32.8 29 33.1 29.3 33.1 29.7V32.4C33.1 32.8 32.8 33.1 32.4 33.1H29.7C29.3 33.1 29 32.8 29 32.4V29.7Z" fill="#F79B91"/>
9
+ <path d="M12 23.7C12 23.3 12.3 23 12.7 23H15.4C15.8 23 16.1 23.3 16.1 23.7V26.4C16.1 26.8 15.8 27.1 15.4 27.1H12.7C12.3 27.1 12 26.8 12 26.4V23.7Z" fill="#CE8FEB"/>
10
+ <path d="M17 23.7C17 23.3 17.3 23 17.7 23H32.4C32.8 23 33.1 23.3 33.1 23.7V26.4C33.1 26.8 32.8 27.1 32.4 27.1H17.7C17.3 27.1 17 26.8 17 26.4V23.7Z" fill="#8A43BF"/>
11
+ <path d="M6 29.7C6 29.3 6.3 29 6.7 29H27.4C27.8 29 28.1 29.3 28.1 29.7V32.4C28.1 32.8 27.8 33.1 27.4 33.1H6.7C6.3 33 6 32.7 6 32.3V29.7Z" fill="#FF4444"/>
12
+ </g>
13
+ <defs>
14
+ <clipPath id="clip0_2399_72">
15
+ <rect width="39" height="39" fill="white"/>
16
+ </clipPath>
17
+ </defs>
18
+ </svg>
@@ -1,13 +1,13 @@
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, itemsCenter, left, parseHeight, parseMaxWidth, parseMinWidth, parseWidth, 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
13
  import { getColor } from "../../../styles/utils";
@@ -131,9 +131,15 @@ const DateRangePicker = /*#__PURE__*/memo( /*#__PURE__*/forwardRef((inProps, ref
131
131
  const [, setValueFr] = useState(Date.now());
132
132
  const [, setValueTo] = useState(Date.now());
133
133
  const [, setSelected] = useState(Date.now());
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);
134
138
  const selectedPeriodRef = useRef('');
135
139
  const selectedPeriodIndex = useRef(null);
136
140
  const focusBtnRef = useRef('today');
141
+ const loadMoreTimer = useRef(null);
142
+ const dropdownListRef = useRef(null);
137
143
  const [valueState, setValueState] = useState();
138
144
  const navigatorFromRefs = {
139
145
  doubleLeft: useRef(null),
@@ -218,6 +224,8 @@ const DateRangePicker = /*#__PURE__*/memo( /*#__PURE__*/forwardRef((inProps, ref
218
224
  const onDayClick = e => {
219
225
  const el = e.currentTarget;
220
226
  const v = parseInt(el.dataset.time, 10);
227
+ selectedPeriodRef.current = '';
228
+ focusBtnRef.current = '';
221
229
  if (values.current.length === 0) {
222
230
  //push
223
231
  el.classList.add(unique.day.active);
@@ -520,7 +528,8 @@ const DateRangePicker = /*#__PURE__*/memo( /*#__PURE__*/forwardRef((inProps, ref
520
528
  const setButtonState = () => {
521
529
  const isVisible = isEqual(values.current, tempValues.current);
522
530
  const query = function (selector) {
523
- return footerRef.current.querySelector(selector);
531
+ var _footerRef$current;
532
+ return (_footerRef$current = footerRef.current) === null || _footerRef$current === void 0 ? void 0 : _footerRef$current.querySelector(selector);
524
533
  };
525
534
  const close = query(`.${unique.close}`);
526
535
  const cancel = query(`.${unique.cancel}`);
@@ -534,19 +543,20 @@ const DateRangePicker = /*#__PURE__*/memo( /*#__PURE__*/forwardRef((inProps, ref
534
543
  visibility: 'visible'
535
544
  };
536
545
  if (isVisible) {
537
- Object.assign(close.style, visible);
538
- Object.assign(cancel.style, hidden);
539
- Object.assign(confirm.style, hidden);
546
+ Object.assign((close === null || close === void 0 ? void 0 : close.style) || {}, visible);
547
+ Object.assign((cancel === null || cancel === void 0 ? void 0 : cancel.style) || {}, hidden);
548
+ Object.assign((confirm === null || confirm === void 0 ? void 0 : confirm.style) || {}, hidden);
540
549
  } else {
541
- Object.assign(cancel.style, visible);
542
- Object.assign(confirm.style, visible);
543
- Object.assign(close.style, hidden);
550
+ Object.assign((cancel === null || cancel === void 0 ? void 0 : cancel.style) || {}, visible);
551
+ Object.assign((confirm === null || confirm === void 0 ? void 0 : confirm.style) || {}, visible);
552
+ Object.assign((close === null || close === void 0 ? void 0 : close.style) || {}, hidden);
544
553
  }
545
554
  };
546
555
  const onCancel = () => {
547
556
  updateValues(tempValues.current);
548
557
  setButtonState();
549
558
  closePicker();
559
+ setOpenState(false);
550
560
  };
551
561
  const onConfirm = () => {
552
562
  setButtonState();
@@ -556,6 +566,7 @@ const DateRangePicker = /*#__PURE__*/memo( /*#__PURE__*/forwardRef((inProps, ref
556
566
  onChangeValue(values.current);
557
567
  }
558
568
  closePicker();
569
+ setOpenState(false);
559
570
  };
560
571
  const onSwap = open => {
561
572
  if (!isEnable) return;
@@ -701,6 +712,22 @@ const DateRangePicker = /*#__PURE__*/memo( /*#__PURE__*/forwardRef((inProps, ref
701
712
  controls && setButtonState();
702
713
  });
703
714
  };
715
+ const openPeriodPicker = () => {
716
+ // const arr = pickerRef.current.getElementsByTagName('td');
717
+ updateTempValues(values.current.length === 1 ? [values.current[0], values.current[0]] : values.current);
718
+ setOpenState(true);
719
+ setTimeout(() => {
720
+ renderPicker();
721
+ // pickerRef.current.addEventListener('mouseover', e => onPickerHover(e, arr));
722
+ window.addEventListener('resize', onResize);
723
+ window.addEventListener('scroll', onScroll);
724
+ document.addEventListener('mousedown', onClickOutside);
725
+ if (pressESCToClose) {
726
+ document.addEventListener('keydown', pressESCHandler);
727
+ }
728
+ controls && setButtonState();
729
+ });
730
+ };
704
731
  const closePicker = () => {
705
732
  const backGr = document.getElementById(unique.backGr);
706
733
  if (!backGr) return;
@@ -729,6 +756,7 @@ const DateRangePicker = /*#__PURE__*/memo( /*#__PURE__*/forwardRef((inProps, ref
729
756
  const onClickOutside = e => {
730
757
  if (ipConRef.current && !ipConRef.current.contains(e.target) && ipRef.current && !ipRef.current.contains(e.target) && pickerRef.current && !pickerRef.current.contains(e.target)) {
731
758
  controls ? onCancel() : closePicker();
759
+ setOpenState(false);
732
760
  }
733
761
  };
734
762
  const triggerFocus = () => {
@@ -743,9 +771,13 @@ const DateRangePicker = /*#__PURE__*/memo( /*#__PURE__*/forwardRef((inProps, ref
743
771
  const onInputFocus = () => {
744
772
  if (!isEnable) return;
745
773
  const el = ipConRef.current;
746
- if (!el.classList.contains(unique.focus)) {
747
- el.classList.add(unique.focus);
748
- openPicker();
774
+ if ((periodOptions === null || periodOptions === void 0 ? void 0 : periodOptions.enable) === true) {
775
+ openPeriodPicker();
776
+ } else {
777
+ if (!el.classList.contains(unique.focus)) {
778
+ el.classList.add(unique.focus);
779
+ openPicker();
780
+ }
749
781
  }
750
782
  };
751
783
  const setInputValue = (time, reset, unshift = false) => {
@@ -806,8 +838,8 @@ const DateRangePicker = /*#__PURE__*/memo( /*#__PURE__*/forwardRef((inProps, ref
806
838
  const firstday = new Date(currentDay.setDate(first)).setHours(0, 0, 0);
807
839
  const lastday = new Date(currentDay.setDate(last)).setHours(0, 0, 0);
808
840
  value = [firstday.valueOf(), lastday.valueOf()];
809
- valueFr.current = firstday;
810
- valueTo.current = lastday;
841
+ valueFr.current = new Date(firstday);
842
+ valueTo.current = new Date(lastday);
811
843
  break;
812
844
  }
813
845
  case 'thisMonth':
@@ -830,8 +862,8 @@ const DateRangePicker = /*#__PURE__*/memo( /*#__PURE__*/forwardRef((inProps, ref
830
862
  lastday = new Date(lastDayArray[2], lastDayArray[1], lastDayArray[0]);
831
863
  }
832
864
  value = [firstday.valueOf(), lastday.valueOf()];
833
- valueFr.current = firstday;
834
- valueTo.current = lastday;
865
+ valueFr.current = new Date(firstday);
866
+ valueTo.current = new Date(lastday);
835
867
  selectedPeriodIndex.current = `period${periodData === null || periodData === void 0 ? void 0 : periodData.idx}`;
836
868
  selectedPeriodRef.current = periodData === null || periodData === void 0 ? void 0 : periodData[periodOptions === null || periodOptions === void 0 ? void 0 : periodOptions.displayExpr];
837
869
  document.getElementById(selectedPeriodIndex.current).style.background = getColor('fill/hover');
@@ -915,6 +947,15 @@ const DateRangePicker = /*#__PURE__*/memo( /*#__PURE__*/forwardRef((inProps, ref
915
947
  closePicker();
916
948
  };
917
949
  }, [actionIconAt, clearAble, controls, disabled, displayFormat, max, min, pressESCToClose, readOnly, startFromZero, unitCount, viewType]);
950
+ useEffect(() => {
951
+ setLoadingState(periodOptions === null || periodOptions === void 0 ? void 0 : periodOptions.loading);
952
+ }, [periodOptions === null || periodOptions === void 0 ? void 0 : periodOptions.loading]);
953
+ useEffect(() => {
954
+ setTotalState(periodOptions === null || periodOptions === void 0 ? void 0 : periodOptions.total);
955
+ }, [periodOptions === null || periodOptions === void 0 ? void 0 : periodOptions.total]);
956
+ useEffect(() => {
957
+ setDataSourceState((periodOptions === null || periodOptions === void 0 ? void 0 : periodOptions.dataSource) || []);
958
+ }, [periodOptions === null || periodOptions === void 0 ? void 0 : periodOptions.dataSource]);
918
959
  useImperativeHandle(reference, () => {
919
960
  const currentRef = ref.current || {};
920
961
  currentRef.element = ref.current;
@@ -1030,6 +1071,33 @@ const DateRangePicker = /*#__PURE__*/memo( /*#__PURE__*/forwardRef((inProps, ref
1030
1071
  className: unique.table.table,
1031
1072
  ref: tableToRef
1032
1073
  }, renderHeader(unique), jsx("tbody", null))));
1074
+ const onLoadMoreHandler = e => {
1075
+ e.persist();
1076
+ if (loadMoreTimer.current) {
1077
+ clearTimeout(loadMoreTimer.current);
1078
+ }
1079
+ const {
1080
+ onLoadMore,
1081
+ limit
1082
+ } = periodOptions;
1083
+ loadMoreTimer.current = setTimeout(() => {
1084
+ if (onLoadMore && (dataSourceState === null || dataSourceState === void 0 ? void 0 : dataSourceState.length) < totalState && !loadingState) {
1085
+ const {
1086
+ scrollTop,
1087
+ scrollHeight,
1088
+ offsetHeight
1089
+ } = e.target;
1090
+ if (scrollHeight <= Math.ceil(scrollTop + 2) + offsetHeight && dropdownListRef.current) {
1091
+ var _dropdownListRef$curr;
1092
+ const length = (_dropdownListRef$curr = dropdownListRef.current.children) === null || _dropdownListRef$curr === void 0 ? void 0 : _dropdownListRef$curr.length;
1093
+ !!onLoadMore && onLoadMore({
1094
+ skip: length,
1095
+ limit: limit
1096
+ });
1097
+ }
1098
+ }
1099
+ }, 300);
1100
+ };
1033
1101
  const rightCalendarPeriodComp = jsx("div", {
1034
1102
  css: _PeriodContainerCSS
1035
1103
  }, jsx(Typography, {
@@ -1038,7 +1106,20 @@ const DateRangePicker = /*#__PURE__*/memo( /*#__PURE__*/forwardRef((inProps, ref
1038
1106
  style: {
1039
1107
  marginBottom: 8
1040
1108
  }
1041
- }, selectPeriodText), periodOptions === null || periodOptions === void 0 ? void 0 : (_periodOptions$dataSo = periodOptions.dataSource) === null || _periodOptions$dataSo === void 0 ? void 0 : _periodOptions$dataSo.map((p, idx) => {
1109
+ }, selectPeriodText), loadingState ? jsx("div", {
1110
+ css: LoadingProgressCSS,
1111
+ className: 'DGN-Dropdown-Loading-Progress'
1112
+ }, jsx(CircularProgress, {
1113
+ size: 24
1114
+ })) : null, jsx("div", {
1115
+ style: {
1116
+ width: '100%',
1117
+ maxHeight: 175,
1118
+ overflowY: 'scroll'
1119
+ },
1120
+ ref: dropdownListRef,
1121
+ onScroll: onLoadMoreHandler
1122
+ }, periodOptions === null || periodOptions === void 0 ? void 0 : (_periodOptions$dataSo = periodOptions.dataSource) === null || _periodOptions$dataSo === void 0 ? void 0 : _periodOptions$dataSo.map((p, idx) => {
1042
1123
  const isSelected = (p === null || p === void 0 ? void 0 : p[periodOptions === null || periodOptions === void 0 ? void 0 : periodOptions.displayExpr]) === selectedPeriodRef.current;
1043
1124
  return jsx("div", {
1044
1125
  id: `period${idx}`,
@@ -1055,7 +1136,7 @@ const DateRangePicker = /*#__PURE__*/memo( /*#__PURE__*/forwardRef((inProps, ref
1055
1136
  color: 'inherit',
1056
1137
  type: 'p1'
1057
1138
  }, p === null || p === void 0 ? void 0 : p[periodOptions === null || periodOptions === void 0 ? void 0 : periodOptions.displayExpr]));
1058
- }));
1139
+ })));
1059
1140
  const tooltipComp = jsx("div", {
1060
1141
  className: unique.tooltip,
1061
1142
  ref: tooltipRef
@@ -1087,7 +1168,40 @@ const DateRangePicker = /*#__PURE__*/memo( /*#__PURE__*/forwardRef((inProps, ref
1087
1168
  ...labelProps,
1088
1169
  disabled: disabled,
1089
1170
  required: required
1090
- }, label) : null, jsx(InputBase, {
1171
+ }, label) : null, periodOptions !== null && periodOptions !== void 0 && periodOptions.enable ? jsx(Popover, {
1172
+ open: openState,
1173
+ className: 'DGN-UI-Popover-Period',
1174
+ anchorOrigin: {
1175
+ horizontal: 'left',
1176
+ vertical: 'bottom'
1177
+ },
1178
+ anchor: jsx("div", null, jsx(InputBase, {
1179
+ inputProps: {
1180
+ placeholder: !readOnly && !disabled ? placeholder : '',
1181
+ ...inputProps
1182
+ },
1183
+ readOnly: true,
1184
+ ref: ipConRef,
1185
+ inputRef: ipRef,
1186
+ disabled: disabled,
1187
+ viewType: viewType,
1188
+ inputStyle: {
1189
+ textAlign: textAlign,
1190
+ textOverflow: 'ellipsis',
1191
+ ...inputStyle
1192
+ },
1193
+ startIcon: startIcon,
1194
+ startIconProps: {
1195
+ className: 'non-effect allow-disabled'
1196
+ },
1197
+ endIcon: endIcon,
1198
+ value: valueState
1199
+ }), error ? jsx(HelperText, {
1200
+ ...helperTextProps,
1201
+ disabled: disabled
1202
+ }, error) : null),
1203
+ onOpen: openPeriodPicker
1204
+ }, pickerComp) : jsx("div", null, jsx(InputBase, {
1091
1205
  inputProps: {
1092
1206
  placeholder: !readOnly && !disabled ? placeholder : '',
1093
1207
  ...inputProps
@@ -1112,7 +1226,7 @@ const DateRangePicker = /*#__PURE__*/memo( /*#__PURE__*/forwardRef((inProps, ref
1112
1226
  }), error ? jsx(HelperText, {
1113
1227
  ...helperTextProps,
1114
1228
  disabled: disabled
1115
- }, error) : null);
1229
+ }, error) : null));
1116
1230
  }));
1117
1231
  const unique = {
1118
1232
  backGr: 'DGN-UI-Portal',
@@ -1304,7 +1418,18 @@ const pickerCSS = {
1304
1418
  transform: 'scale(0)'
1305
1419
  }
1306
1420
  };
1307
-
1421
+ const LoadingProgressCSS = css`
1422
+ ${displayFlex};
1423
+ ${flexRow};
1424
+ ${justifyCenter};
1425
+ ${itemsCenter};
1426
+ ${positionAbsolute};
1427
+ ${borderRadius(4)};
1428
+ ${parseWidthHeight('100%')}
1429
+ ${bgColor('rgba(255, 255, 255, 0.6)')};
1430
+ ${z(2)};
1431
+ ${top(0)};
1432
+ `;
1308
1433
  // DateRangePicker.defaultProps = {
1309
1434
  // actionIconAt: 'end',
1310
1435
  // clearAble: false,
@@ -1365,7 +1490,12 @@ DateRangePicker.propTypes = {
1365
1490
  * displayExpr: "DisplayName",
1366
1491
  * valueFromExpr: "DateFrom",
1367
1492
  * valueToExpr: "DateTo",
1368
- * valueFormat: "DD/MM/YYYY"
1493
+ * valueFormat: "DD/MM/YYYY",
1494
+ * limit: 5,
1495
+ * skip: 0,
1496
+ * total: 100,
1497
+ * onLoadMore: () => {},
1498
+ * loading: false
1369
1499
  * }
1370
1500
  */
1371
1501
  periodOptions: PropTypes.object,
@@ -11,6 +11,7 @@ import { animation, bgColor, border, borderBottom, borderBottomColor, borderColo
11
11
  import { useTheme } from "../../../theme";
12
12
  import useThemeProps from "../../../theme/utils/useThemeProps";
13
13
  import { classNames, getProp, isMobile, randomString } from "../../../utils";
14
+ import { isEmpty, typeOf } from "../../../utils/type";
14
15
  const currentValue = {},
15
16
  isSearch = {},
16
17
  allValue = {};
@@ -135,6 +136,7 @@ const Dropdown = /*#__PURE__*/memo( /*#__PURE__*/forwardRef((inProps, reference)
135
136
  const loadMoreTimer = useRef(null);
136
137
  const dataChosen = useRef([]);
137
138
  const popupRef = useRef(null);
139
+ const valueObjectDefaultInit = useRef({});
138
140
  const filter = useRef({
139
141
  skip: skip || 0,
140
142
  limit: limit || 50
@@ -322,8 +324,9 @@ const Dropdown = /*#__PURE__*/memo( /*#__PURE__*/forwardRef((inProps, reference)
322
324
  let text = '';
323
325
  let isReplace = true;
324
326
  if (data || data === 0) {
327
+ var _data$displayExpr;
325
328
  displayExpr = displayExpr || valueExpr;
326
- let mask = data === null || data === void 0 ? void 0 : data[displayExpr];
329
+ let mask = typeOf(data === null || data === void 0 ? void 0 : data[displayExpr], 'array') ? ((_data$displayExpr = data[displayExpr]) === null || _data$displayExpr === void 0 ? void 0 : _data$displayExpr[0]) || '' : data === null || data === void 0 ? void 0 : data[displayExpr];
327
330
  // convert {id} - {name} to {<data[id]>} - {<data[name]>}
328
331
  if (selectAll && (data === null || data === void 0 ? void 0 : data[valueExpr]) === 'all') {
329
332
  isReplace = false;
@@ -342,6 +345,43 @@ const Dropdown = /*#__PURE__*/memo( /*#__PURE__*/forwardRef((inProps, reference)
342
345
  var _dataSourceUsable2;
343
346
  const items = [];
344
347
  let dataSourceUsable = [...dataSourceState];
348
+ if (vlObjDefaultState && (vlObjDefaultState === null || vlObjDefaultState === void 0 ? void 0 : vlObjDefaultState.length) > 0 && isEmpty(txtSearch)) {
349
+ // Sẽ Xem Lại
350
+ // if (vlObjDefaultState && vlObjDefaultState?.length > 0) {
351
+ const length = vlObjDefaultState === null || vlObjDefaultState === void 0 ? void 0 : vlObjDefaultState.length;
352
+ let existItemQuantity = 0;
353
+ for (let index = length - 1; index >= 0; index--) {
354
+ if ((vlObjDefaultState[index][valueExpr] || vlObjDefaultState[index][valueExpr] === 0) && !dataSourceUsable.some(data => data[valueExpr] === vlObjDefaultState[index][valueExpr])) {
355
+ if (isMultipleVal(vlObjDefaultState[index])) {
356
+ if (isEmpty(valueObjectDefaultInit.current)) {
357
+ let dataCloneDeep = {};
358
+ for (const name in vlObjDefaultState[index]) {
359
+ var _vlObjDefaultState$in;
360
+ if (name) dataCloneDeep[name] = (((_vlObjDefaultState$in = vlObjDefaultState[index]) === null || _vlObjDefaultState$in === void 0 ? void 0 : _vlObjDefaultState$in[name]) || []).map(item => item);
361
+ }
362
+ if (!isEmpty(dataCloneDeep)) valueObjectDefaultInit.current = dataCloneDeep;
363
+ const valueObjectDefaultOrigin = {
364
+ ...valueObjectDefaultInit.current
365
+ } || {};
366
+ const arr = (valueObjectDefaultOrigin === null || valueObjectDefaultOrigin === void 0 ? void 0 : valueObjectDefaultOrigin[valueExpr]) || [];
367
+ for (let i = 0; i < arr.length; i++) {
368
+ let objData = {};
369
+ for (const name in valueObjectDefaultOrigin) {
370
+ var _valueObjectDefaultOr;
371
+ if (name) objData[name] = (valueObjectDefaultOrigin === null || valueObjectDefaultOrigin === void 0 ? void 0 : (_valueObjectDefaultOr = valueObjectDefaultOrigin[name]) === null || _valueObjectDefaultOr === void 0 ? void 0 : _valueObjectDefaultOr[i]) || '';
372
+ }
373
+ dataSourceUsable.unshift(objData);
374
+ }
375
+ }
376
+ } else dataSourceUsable.unshift(vlObjDefaultState[index]);
377
+ } else {
378
+ // Nếu số lượng phần tử của valueObjectDefault tồn tại trong dataSource nhiều hơn hoặc bằng limit thì không remove nữa
379
+ if (++existItemQuantity > limit) {
380
+ continue;
381
+ }
382
+ }
383
+ }
384
+ }
345
385
 
346
386
  // search dataSource dựa trên txtSearch
347
387
  if (!onInput) {
@@ -358,20 +398,6 @@ const Dropdown = /*#__PURE__*/memo( /*#__PURE__*/forwardRef((inProps, reference)
358
398
  });
359
399
  }
360
400
  }
361
- if (vlObjDefaultState && (vlObjDefaultState === null || vlObjDefaultState === void 0 ? void 0 : vlObjDefaultState.length) > 0) {
362
- const length = vlObjDefaultState === null || vlObjDefaultState === void 0 ? void 0 : vlObjDefaultState.length;
363
- let existItemQuantity = 0;
364
- for (let index = length - 1; index >= 0; index--) {
365
- if ((vlObjDefaultState[index][valueExpr] || vlObjDefaultState[index][valueExpr] === 0) && !dataSourceUsable.some(data => data[valueExpr] === vlObjDefaultState[index][valueExpr])) {
366
- dataSourceUsable.unshift(vlObjDefaultState[index]);
367
- } else {
368
- // Nếu số lượng phần tử của valueObjectDefault tồn tại trong dataSource nhiều hơn hoặc bằng limit thì không remove nữa
369
- if (++existItemQuantity > limit) {
370
- continue;
371
- }
372
- }
373
- }
374
- }
375
401
  const length = (_dataSourceUsable2 = dataSourceUsable) === null || _dataSourceUsable2 === void 0 ? void 0 : _dataSourceUsable2.length;
376
402
  for (let index = 0; index < length; index++) {
377
403
  const data = dataSourceUsable[index];
@@ -402,7 +428,7 @@ const Dropdown = /*#__PURE__*/memo( /*#__PURE__*/forwardRef((inProps, reference)
402
428
  type: 'p1'
403
429
  }, displayText);
404
430
  if (multiple && selectBox) {
405
- let checked = valueMulti.includes(value);
431
+ let checked = typeOf(value, 'array') ? valueMulti.some(item => value.includes(item)) : valueMulti.includes(value);
406
432
  if (selectAll && value === 'all') checked = selectAll && value === 'all' && valueMulti.length > 0;
407
433
  const isMaximumSelection = maximumSelectionLength === (valueMulti === null || valueMulti === void 0 ? void 0 : valueMulti.length);
408
434
  itemDisabled = itemDisabled || isMaximumSelection && !checked;
@@ -486,7 +512,9 @@ const Dropdown = /*#__PURE__*/memo( /*#__PURE__*/forwardRef((inProps, reference)
486
512
  const dataSourceUsable = [...dataSourceState];
487
513
  // Nếu có load more thì đẩy đội tượng mặc định lên đầu
488
514
  let notExistItem = 0;
489
- if (onLoadMore && vlObjDefaultState !== null && vlObjDefaultState !== void 0 && vlObjDefaultState.length) {
515
+ if (onLoadMore && vlObjDefaultState !== null && vlObjDefaultState !== void 0 && vlObjDefaultState.length && isEmpty(txtSearch)) {
516
+ // Sẽ Xem Lại
517
+ // if (onLoadMore && vlObjDefaultState?.length) {
490
518
  const length = vlObjDefaultState.length;
491
519
  for (let index = length - 1; index >= 0; index--) {
492
520
  if (!dataSourceUsable.some(data => data[valueExpr] === vlObjDefaultState[index][valueExpr])) {
@@ -550,7 +578,7 @@ const Dropdown = /*#__PURE__*/memo( /*#__PURE__*/forwardRef((inProps, reference)
550
578
  } else {
551
579
  item = jsx(Fragment, null, icon, text);
552
580
  }
553
- if (!dropdownListRef.current) {
581
+ if (!dropdownListRef.current || isEmpty(txtSearch)) {
554
582
  return;
555
583
  }
556
584
  ReactDOM.render(item, dropdownListRef.current.appendChild(dropdownItem));
@@ -997,7 +1025,7 @@ const Dropdown = /*#__PURE__*/memo( /*#__PURE__*/forwardRef((inProps, reference)
997
1025
  if (valueProp !== undefined && (!dropdownListRef.current || children || JSON.stringify(valueProp) !== JSON.stringify(currentValue[unique]))) {
998
1026
  setValueIntoInput(valueProp);
999
1027
  if (oneLiner && multiple) {
1000
- const valueArray = sortMultiple(valueProp);
1028
+ const valueArray = sortMultiple(valueProp, true);
1001
1029
  setValueMultiDisplay(valueArray === null || valueArray === void 0 ? void 0 : valueArray.display);
1002
1030
  setValueMultiOverflow(valueArray === null || valueArray === void 0 ? void 0 : valueArray.overflow);
1003
1031
  if ((valueArray === null || valueArray === void 0 ? void 0 : valueArray.overflow.length) === 0 && openMultipleOverflow) {
@@ -1098,9 +1126,34 @@ const Dropdown = /*#__PURE__*/memo( /*#__PURE__*/forwardRef((inProps, reference)
1098
1126
  disabled: disabled,
1099
1127
  ...labelProps
1100
1128
  }, label) : null, [label, required, disabled, labelProps]);
1129
+ const isMultipleVal = (objData = {}) => {
1130
+ let status = false;
1131
+ if (typeOf(objData === null || objData === void 0 ? void 0 : objData[valueExpr], 'array') && !isEmpty(objData === null || objData === void 0 ? void 0 : objData[valueExpr]) || typeOf(objData === null || objData === void 0 ? void 0 : objData[displayExpr], 'array') && !isEmpty(objData === null || objData === void 0 ? void 0 : objData[displayExpr])) {
1132
+ status = true;
1133
+ }
1134
+ return status;
1135
+ };
1101
1136
  const getData = () => {
1137
+ var _valObjDefault;
1102
1138
  let dataFilter = JSON.parse(JSON.stringify(dataSourceState));
1103
- dataFilter = uniqBy([...vlObjDefaultState, ...dataFilter], data => data === null || data === void 0 ? void 0 : data[valueExpr]);
1139
+ let valObjDefault = vlObjDefaultState;
1140
+ if (isMultipleVal((_valObjDefault = valObjDefault) === null || _valObjDefault === void 0 ? void 0 : _valObjDefault[0])) {
1141
+ var _vlObjDefaultState$;
1142
+ valObjDefault = [];
1143
+ const arr = (vlObjDefaultState === null || vlObjDefaultState === void 0 ? void 0 : (_vlObjDefaultState$ = vlObjDefaultState[0]) === null || _vlObjDefaultState$ === void 0 ? void 0 : _vlObjDefaultState$[valueExpr]) || [];
1144
+ for (let i = 0; i < arr.length; i++) {
1145
+ let objData = {};
1146
+ for (const name in vlObjDefaultState[0]) {
1147
+ var _vlObjDefaultState$2;
1148
+ if (name) objData[name] = (_vlObjDefaultState$2 = vlObjDefaultState[0]) === null || _vlObjDefaultState$2 === void 0 ? void 0 : _vlObjDefaultState$2[name][i];
1149
+ }
1150
+ if (!isEmpty(objData)) valObjDefault.push(objData);
1151
+ }
1152
+ }
1153
+ dataFilter = uniqBy([...valObjDefault, ...dataFilter], data => {
1154
+ let result = data === null || data === void 0 ? void 0 : data[valueExpr];
1155
+ return result;
1156
+ });
1104
1157
  return dataFilter;
1105
1158
  };
1106
1159
  const getTextWidth = text => {
@@ -1127,8 +1180,8 @@ const Dropdown = /*#__PURE__*/memo( /*#__PURE__*/forwardRef((inProps, reference)
1127
1180
  const inputWidth = inputElement === null || inputElement === void 0 ? void 0 : inputElement.clientWidth;
1128
1181
  const items = [];
1129
1182
  if ((valueMulti === null || valueMulti === void 0 ? void 0 : valueMulti.length) > 0) {
1183
+ const dataFilter = getData();
1130
1184
  value.map((vl, index) => {
1131
- const dataFilter = getData();
1132
1185
  const data = dataFilter.find(v => v[valueExpr] === vl || v === vl);
1133
1186
  if (data) {
1134
1187
  const displayText = displayValue(data);
@@ -1181,8 +1234,8 @@ const Dropdown = /*#__PURE__*/memo( /*#__PURE__*/forwardRef((inProps, reference)
1181
1234
  const renderMultipleItem = value => {
1182
1235
  const items = [];
1183
1236
  if ((valueMulti === null || valueMulti === void 0 ? void 0 : valueMulti.length) > 0) {
1237
+ const dataFilter = getData();
1184
1238
  value.map((vl, index) => {
1185
- const dataFilter = getData();
1186
1239
  const data = dataFilter.find(v => v[valueExpr] === vl || v === vl);
1187
1240
  if (data) {
1188
1241
  const displayText = displayValue(data);
@@ -1251,8 +1304,8 @@ const Dropdown = /*#__PURE__*/memo( /*#__PURE__*/forwardRef((inProps, reference)
1251
1304
  const renderOverflowPopover = value => {
1252
1305
  const items = [];
1253
1306
  if ((valueMulti === null || valueMulti === void 0 ? void 0 : valueMulti.length) > 0) {
1307
+ const dataFilter = getData();
1254
1308
  value.map((vl, index) => {
1255
- const dataFilter = getData();
1256
1309
  const data = dataFilter.find(v => v[valueExpr] === vl || v === vl);
1257
1310
  if (data) {
1258
1311
  const displayText = displayValue(data);
@@ -168,7 +168,9 @@ const NumberInput = /*#__PURE__*/forwardRef((inProps, reference) => {
168
168
  const _onInput = useCallback((e, flag) => {
169
169
  var _e$target$value;
170
170
  let valueT = (_e$target$value = e.target.value) !== null && _e$target$value !== void 0 ? _e$target$value : e.value;
171
- if (disabledNegative && Number(valueT || 0) < 0) return;
171
+ if (disabledNegative && eval(valueT || 0) <= 0 || valueT.includes('-')) valueT = 0;
172
+ if ((min || min === 0) && eval(valueT) <= min || min === 0 && valueT.includes('-')) valueT = min;
173
+ if ((max || max === 0) && eval(valueT) >= max) valueT = max;
172
174
  valueT = parseNumberToMoney(valueT);
173
175
  const returnValue = convertMoneyToNumber(valueT);
174
176
  e.value = globalRef.current.value = !isNaN(parseFloat(returnValue)) ? parseFloat(returnValue) : null;
package/icons/basic.js CHANGED
@@ -1430,6 +1430,32 @@ export const CancelUnderline = /*#__PURE__*/memo(({
1430
1430
  fill: fillColor(color)
1431
1431
  }));
1432
1432
  });
1433
+ export const CelebrationColor = /*#__PURE__*/memo(({
1434
+ width,
1435
+ height
1436
+ }) => {
1437
+ return /*#__PURE__*/React.createElement("svg", {
1438
+ width: width || 24,
1439
+ height: height || 24,
1440
+ viewBox: "0 0 24 24",
1441
+ fill: "none"
1442
+ }, /*#__PURE__*/React.createElement("path", {
1443
+ d: "M1 22.5L6 8.5L15 17.5L1 22.5Z",
1444
+ fill: "#111D5E"
1445
+ }), /*#__PURE__*/React.createElement("path", {
1446
+ d: "M10.1 9.05L9.05 8L9.65 7.4C9.88333 7.16667 10 6.88333 10 6.55C10 6.21667 9.88333 5.93333 9.65 5.7L9 5.05L10.05 4L10.7 4.65C11.2333 5.18333 11.5 5.81667 11.5 6.55C11.5 7.28333 11.2333 7.91667 10.7 8.45L10.1 9.05Z",
1447
+ fill: "#0095FF"
1448
+ }), /*#__PURE__*/React.createElement("path", {
1449
+ d: "M14.05 13.0501L13 12.0001L18.6 6.4001C19.1333 5.86676 19.775 5.6001 20.525 5.6001C21.275 5.6001 21.9167 5.86676 22.45 6.4001L23.05 7.0001L22 8.0501L21.4 7.4501C21.1667 7.21676 20.875 7.1001 20.525 7.1001C20.175 7.1001 19.8833 7.21676 19.65 7.4501L14.05 13.0501Z",
1450
+ fill: "#FFAA00"
1451
+ }), /*#__PURE__*/React.createElement("path", {
1452
+ d: "M16.05 14.95L15 13.9L16.6 12.3C17.1333 11.7667 17.775 11.5 18.525 11.5C19.275 11.5 19.9167 11.7667 20.45 12.3L22.05 13.9L21 14.95L19.4 13.35C19.1667 13.1167 18.875 13 18.525 13C18.175 13 17.8833 13.1167 17.65 13.35L16.05 14.95Z",
1453
+ fill: "#FF3D71"
1454
+ }), /*#__PURE__*/React.createElement("path", {
1455
+ d: "M12.05 11.05L11 10L14.6 6.4C14.8333 6.16667 14.95 5.875 14.95 5.525C14.95 5.175 14.8333 4.88333 14.6 4.65L13 3.05L14.05 2L15.65 3.6C16.1833 4.13333 16.45 4.775 16.45 5.525C16.45 6.275 16.1833 6.91667 15.65 7.45L12.05 11.05Z",
1456
+ fill: "#00C875"
1457
+ }));
1458
+ });
1433
1459
  export const Category = /*#__PURE__*/memo(({
1434
1460
  width,
1435
1461
  height,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "diginet-core-ui",
3
- "version": "1.4.55",
3
+ "version": "1.4.56",
4
4
  "description": "The DigiNet core ui",
5
5
  "homepage": "https://diginet.com.vn",
6
6
  "main": "index.js",
package/readme.md CHANGED
@@ -42,6 +42,13 @@ npm test
42
42
 
43
43
  ## Changelog
44
44
 
45
+ ## 1.4.56
46
+ - \[Added\]: Icon – Add IconMenu MHRP29N0033, MHRP29N0034
47
+ - \[Added\]: Icon – Add Icon CelebrationColor
48
+ - \[Fixed\]: Dropdown - Fix valueObjectDefault bug in Dropdown.
49
+ - \[Fixed\]: NumberInput – Fix issue where NumberInput allowed pasting negative values even when disabledNegative prop was enabled.
50
+ - \[Added\]: DateRangePicker – Add a new mode to change the UI of DateRangePicker
51
+
45
52
  ## 1.4.55
46
53
  - \[Added\]: Icon – Add IconMenu MHRM09N1401, MHRM09N1402
47
54
  - \[Added\]: Icon – Add Icon Book
package/utils/type.js CHANGED
@@ -33,6 +33,34 @@ const isNumeric = object => {
33
33
  const isObject = object => {
34
34
  return type(object) === 'object';
35
35
  };
36
+ const typeOf = (value, type) => {
37
+ const result = Object.prototype.toString.call(value).slice(8, -1).toLowerCase();
38
+ return type ? result === String(type).toLowerCase() : result;
39
+ };
40
+ const isEmpty = (value, escapeZero = false) => {
41
+ switch (typeOf(value)) {
42
+ case 'object':
43
+ {
44
+ return value && Object.keys(value).length <= 0 || !value;
45
+ }
46
+ case 'array':
47
+ {
48
+ return value.length <= 0;
49
+ }
50
+ case 'string':
51
+ {
52
+ return !value;
53
+ }
54
+ case 'number':
55
+ {
56
+ if (!escapeZero) return value === 0 ? false : !value;else return !value;
57
+ }
58
+ default:
59
+ {
60
+ return !value;
61
+ }
62
+ }
63
+ };
36
64
  const isEmptyObject = object => {
37
65
  let property;
38
66
  for (property in object) {
@@ -66,4 +94,4 @@ const isDeferred = object => {
66
94
  const isEvent = object => {
67
95
  return !!(object && object.preventDefault);
68
96
  };
69
- export { isBoolean, isExponential, isDate, isDefined, isFunction, isString, isNumeric, isObject, isEmptyObject, isPlainObject, isPrimitive, isWindow, isRenderer, isPromise, isDeferred, type, isEvent };
97
+ export { isBoolean, isExponential, isDate, isDefined, isFunction, isString, isNumeric, isObject, isEmptyObject, isPlainObject, isPrimitive, isWindow, isRenderer, isPromise, isDeferred, type, isEvent, isEmpty, typeOf };