diginet-core-ui 1.4.55 → 1.4.56-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.
@@ -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>
@@ -652,7 +652,7 @@ const renderNavigator = (className, refs, dbLeftFn, leftFn, rightFn, dbRightFn,
652
652
  color: 'primary',
653
653
  type: 'h3',
654
654
  ref: refs.content,
655
- format: ['lowercase']
655
+ format: ['sentence']
656
656
  }))), jsx("div", {
657
657
  className: className.navigator.around
658
658
  }, jsx(ButtonIcon, {
@@ -226,7 +226,7 @@ const Calendar = /*#__PURE__*/memo( /*#__PURE__*/forwardRef((inProps, reference)
226
226
  * START EFFECT
227
227
  */
228
228
  useEffect(() => {
229
- if (defaultValue && defaultValue !== '' && isValidDate(defaultValue)) {
229
+ if (defaultValue && defaultValue !== '' && isValidDate(defaultValue) && !value) {
230
230
  if (isBeforeLimit(min, defaultValue)) {
231
231
  onUpdate(min);
232
232
  } else if (isAfterLimit(max, defaultValue)) {
@@ -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;
@@ -725,10 +752,12 @@ const DateRangePicker = /*#__PURE__*/memo( /*#__PURE__*/forwardRef((inProps, ref
725
752
  }
726
753
  ipRef.current && ipRef.current.blur();
727
754
  updateTempValues([]);
755
+ setOpenState(false);
728
756
  };
729
757
  const onClickOutside = e => {
730
758
  if (ipConRef.current && !ipConRef.current.contains(e.target) && ipRef.current && !ipRef.current.contains(e.target) && pickerRef.current && !pickerRef.current.contains(e.target)) {
731
759
  controls ? onCancel() : closePicker();
760
+ setOpenState(false);
732
761
  }
733
762
  };
734
763
  const triggerFocus = () => {
@@ -743,9 +772,13 @@ const DateRangePicker = /*#__PURE__*/memo( /*#__PURE__*/forwardRef((inProps, ref
743
772
  const onInputFocus = () => {
744
773
  if (!isEnable) return;
745
774
  const el = ipConRef.current;
746
- if (!el.classList.contains(unique.focus)) {
747
- el.classList.add(unique.focus);
748
- openPicker();
775
+ if ((periodOptions === null || periodOptions === void 0 ? void 0 : periodOptions.enable) === true) {
776
+ openPeriodPicker();
777
+ } else {
778
+ if (!el.classList.contains(unique.focus)) {
779
+ el.classList.add(unique.focus);
780
+ openPicker();
781
+ }
749
782
  }
750
783
  };
751
784
  const setInputValue = (time, reset, unshift = false) => {
@@ -806,8 +839,8 @@ const DateRangePicker = /*#__PURE__*/memo( /*#__PURE__*/forwardRef((inProps, ref
806
839
  const firstday = new Date(currentDay.setDate(first)).setHours(0, 0, 0);
807
840
  const lastday = new Date(currentDay.setDate(last)).setHours(0, 0, 0);
808
841
  value = [firstday.valueOf(), lastday.valueOf()];
809
- valueFr.current = firstday;
810
- valueTo.current = lastday;
842
+ valueFr.current = new Date(firstday);
843
+ valueTo.current = new Date(lastday);
811
844
  break;
812
845
  }
813
846
  case 'thisMonth':
@@ -830,8 +863,8 @@ const DateRangePicker = /*#__PURE__*/memo( /*#__PURE__*/forwardRef((inProps, ref
830
863
  lastday = new Date(lastDayArray[2], lastDayArray[1], lastDayArray[0]);
831
864
  }
832
865
  value = [firstday.valueOf(), lastday.valueOf()];
833
- valueFr.current = firstday;
834
- valueTo.current = lastday;
866
+ valueFr.current = new Date(firstday);
867
+ valueTo.current = new Date(lastday);
835
868
  selectedPeriodIndex.current = `period${periodData === null || periodData === void 0 ? void 0 : periodData.idx}`;
836
869
  selectedPeriodRef.current = periodData === null || periodData === void 0 ? void 0 : periodData[periodOptions === null || periodOptions === void 0 ? void 0 : periodOptions.displayExpr];
837
870
  document.getElementById(selectedPeriodIndex.current).style.background = getColor('fill/hover');
@@ -915,6 +948,15 @@ const DateRangePicker = /*#__PURE__*/memo( /*#__PURE__*/forwardRef((inProps, ref
915
948
  closePicker();
916
949
  };
917
950
  }, [actionIconAt, clearAble, controls, disabled, displayFormat, max, min, pressESCToClose, readOnly, startFromZero, unitCount, viewType]);
951
+ useEffect(() => {
952
+ setLoadingState(periodOptions === null || periodOptions === void 0 ? void 0 : periodOptions.loading);
953
+ }, [periodOptions === null || periodOptions === void 0 ? void 0 : periodOptions.loading]);
954
+ useEffect(() => {
955
+ setTotalState(periodOptions === null || periodOptions === void 0 ? void 0 : periodOptions.total);
956
+ }, [periodOptions === null || periodOptions === void 0 ? void 0 : periodOptions.total]);
957
+ useEffect(() => {
958
+ setDataSourceState((periodOptions === null || periodOptions === void 0 ? void 0 : periodOptions.dataSource) || []);
959
+ }, [periodOptions === null || periodOptions === void 0 ? void 0 : periodOptions.dataSource]);
918
960
  useImperativeHandle(reference, () => {
919
961
  const currentRef = ref.current || {};
920
962
  currentRef.element = ref.current;
@@ -1030,6 +1072,33 @@ const DateRangePicker = /*#__PURE__*/memo( /*#__PURE__*/forwardRef((inProps, ref
1030
1072
  className: unique.table.table,
1031
1073
  ref: tableToRef
1032
1074
  }, renderHeader(unique), jsx("tbody", null))));
1075
+ const onLoadMoreHandler = e => {
1076
+ e.persist();
1077
+ if (loadMoreTimer.current) {
1078
+ clearTimeout(loadMoreTimer.current);
1079
+ }
1080
+ const {
1081
+ onLoadMore,
1082
+ limit
1083
+ } = periodOptions;
1084
+ loadMoreTimer.current = setTimeout(() => {
1085
+ if (onLoadMore && (dataSourceState === null || dataSourceState === void 0 ? void 0 : dataSourceState.length) < totalState && !loadingState) {
1086
+ const {
1087
+ scrollTop,
1088
+ scrollHeight,
1089
+ offsetHeight
1090
+ } = e.target;
1091
+ if (scrollHeight <= Math.ceil(scrollTop + 2) + offsetHeight && dropdownListRef.current) {
1092
+ var _dropdownListRef$curr;
1093
+ const length = (_dropdownListRef$curr = dropdownListRef.current.children) === null || _dropdownListRef$curr === void 0 ? void 0 : _dropdownListRef$curr.length;
1094
+ !!onLoadMore && onLoadMore({
1095
+ skip: length,
1096
+ limit: limit
1097
+ });
1098
+ }
1099
+ }
1100
+ }, 300);
1101
+ };
1033
1102
  const rightCalendarPeriodComp = jsx("div", {
1034
1103
  css: _PeriodContainerCSS
1035
1104
  }, jsx(Typography, {
@@ -1038,7 +1107,20 @@ const DateRangePicker = /*#__PURE__*/memo( /*#__PURE__*/forwardRef((inProps, ref
1038
1107
  style: {
1039
1108
  marginBottom: 8
1040
1109
  }
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) => {
1110
+ }, selectPeriodText), loadingState ? jsx("div", {
1111
+ css: LoadingProgressCSS,
1112
+ className: 'DGN-Dropdown-Loading-Progress'
1113
+ }, jsx(CircularProgress, {
1114
+ size: 24
1115
+ })) : null, jsx("div", {
1116
+ style: {
1117
+ width: '100%',
1118
+ maxHeight: 175,
1119
+ overflowY: 'scroll'
1120
+ },
1121
+ ref: dropdownListRef,
1122
+ onScroll: onLoadMoreHandler
1123
+ }, periodOptions === null || periodOptions === void 0 ? void 0 : (_periodOptions$dataSo = periodOptions.dataSource) === null || _periodOptions$dataSo === void 0 ? void 0 : _periodOptions$dataSo.map((p, idx) => {
1042
1124
  const isSelected = (p === null || p === void 0 ? void 0 : p[periodOptions === null || periodOptions === void 0 ? void 0 : periodOptions.displayExpr]) === selectedPeriodRef.current;
1043
1125
  return jsx("div", {
1044
1126
  id: `period${idx}`,
@@ -1055,7 +1137,7 @@ const DateRangePicker = /*#__PURE__*/memo( /*#__PURE__*/forwardRef((inProps, ref
1055
1137
  color: 'inherit',
1056
1138
  type: 'p1'
1057
1139
  }, p === null || p === void 0 ? void 0 : p[periodOptions === null || periodOptions === void 0 ? void 0 : periodOptions.displayExpr]));
1058
- }));
1140
+ })));
1059
1141
  const tooltipComp = jsx("div", {
1060
1142
  className: unique.tooltip,
1061
1143
  ref: tooltipRef
@@ -1087,7 +1169,40 @@ const DateRangePicker = /*#__PURE__*/memo( /*#__PURE__*/forwardRef((inProps, ref
1087
1169
  ...labelProps,
1088
1170
  disabled: disabled,
1089
1171
  required: required
1090
- }, label) : null, jsx(InputBase, {
1172
+ }, label) : null, periodOptions !== null && periodOptions !== void 0 && periodOptions.enable ? jsx(Popover, {
1173
+ open: openState,
1174
+ className: 'DGN-UI-Popover-Period',
1175
+ anchorOrigin: {
1176
+ horizontal: 'left',
1177
+ vertical: 'bottom'
1178
+ },
1179
+ anchor: jsx("div", null, jsx(InputBase, {
1180
+ inputProps: {
1181
+ placeholder: !readOnly && !disabled ? placeholder : '',
1182
+ ...inputProps
1183
+ },
1184
+ readOnly: true,
1185
+ ref: ipConRef,
1186
+ inputRef: ipRef,
1187
+ disabled: disabled,
1188
+ viewType: viewType,
1189
+ inputStyle: {
1190
+ textAlign: textAlign,
1191
+ textOverflow: 'ellipsis',
1192
+ ...inputStyle
1193
+ },
1194
+ startIcon: startIcon,
1195
+ startIconProps: {
1196
+ className: 'non-effect allow-disabled'
1197
+ },
1198
+ endIcon: endIcon,
1199
+ value: valueState
1200
+ }), error ? jsx(HelperText, {
1201
+ ...helperTextProps,
1202
+ disabled: disabled
1203
+ }, error) : null),
1204
+ onOpen: openPeriodPicker
1205
+ }, pickerComp) : jsx("div", null, jsx(InputBase, {
1091
1206
  inputProps: {
1092
1207
  placeholder: !readOnly && !disabled ? placeholder : '',
1093
1208
  ...inputProps
@@ -1112,7 +1227,7 @@ const DateRangePicker = /*#__PURE__*/memo( /*#__PURE__*/forwardRef((inProps, ref
1112
1227
  }), error ? jsx(HelperText, {
1113
1228
  ...helperTextProps,
1114
1229
  disabled: disabled
1115
- }, error) : null);
1230
+ }, error) : null));
1116
1231
  }));
1117
1232
  const unique = {
1118
1233
  backGr: 'DGN-UI-Portal',
@@ -1304,7 +1419,18 @@ const pickerCSS = {
1304
1419
  transform: 'scale(0)'
1305
1420
  }
1306
1421
  };
1307
-
1422
+ const LoadingProgressCSS = css`
1423
+ ${displayFlex};
1424
+ ${flexRow};
1425
+ ${justifyCenter};
1426
+ ${itemsCenter};
1427
+ ${positionAbsolute};
1428
+ ${borderRadius(4)};
1429
+ ${parseWidthHeight('100%')}
1430
+ ${bgColor('rgba(255, 255, 255, 0.6)')};
1431
+ ${z(2)};
1432
+ ${top(0)};
1433
+ `;
1308
1434
  // DateRangePicker.defaultProps = {
1309
1435
  // actionIconAt: 'end',
1310
1436
  // clearAble: false,
@@ -1365,7 +1491,12 @@ DateRangePicker.propTypes = {
1365
1491
  * displayExpr: "DisplayName",
1366
1492
  * valueFromExpr: "DateFrom",
1367
1493
  * valueToExpr: "DateTo",
1368
- * valueFormat: "DD/MM/YYYY"
1494
+ * valueFormat: "DD/MM/YYYY",
1495
+ * limit: 5,
1496
+ * skip: 0,
1497
+ * total: 100,
1498
+ * onLoadMore: () => {},
1499
+ * loading: false
1369
1500
  * }
1370
1501
  */
1371
1502
  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
@@ -297,10 +299,10 @@ const Dropdown = /*#__PURE__*/memo( /*#__PURE__*/forwardRef((inProps, reference)
297
299
  });
298
300
  };
299
301
 
300
- /**
301
- * So sánh text đầu vào cáo map với txtSearch
302
- * @param text
303
- * @return {boolean}
302
+ /**
303
+ * So sánh text đầu vào cáo map với txtSearch
304
+ * @param text
305
+ * @return {boolean}
304
306
  */
305
307
  const handleRenderBySearch = (text = '') => {
306
308
  if (text === null || text === undefined) text = '';
@@ -313,17 +315,18 @@ const Dropdown = /*#__PURE__*/memo( /*#__PURE__*/forwardRef((inProps, reference)
313
315
  } else return text.toLowerCase().includes(txtSearch.toLowerCase());
314
316
  };
315
317
 
316
- /**
317
- * Chuyển đổi data thành giá trị cần hiện thị dựa vào displayExpr [string, string object {field} - {field}], renderSelectedItem, displayExpr, valueExpr
318
- * @param data {object} rowData of dataSource
319
- * @return {string}
318
+ /**
319
+ * Chuyển đổi data thành giá trị cần hiện thị dựa vào displayExpr [string, string object {field} - {field}], renderSelectedItem, displayExpr, valueExpr
320
+ * @param data {object} rowData of dataSource
321
+ * @return {string}
320
322
  */
321
323
  const displayValue = data => {
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];
@@ -399,10 +425,11 @@ const Dropdown = /*#__PURE__*/memo( /*#__PURE__*/forwardRef((inProps, reference)
399
425
  data,
400
426
  index
401
427
  }) : jsx(Typography, {
428
+ lineClamp: 1,
402
429
  type: 'p1'
403
430
  }, displayText);
404
431
  if (multiple && selectBox) {
405
- let checked = valueMulti.includes(value);
432
+ let checked = typeOf(value, 'array') ? valueMulti.some(item => value.includes(item)) : valueMulti.includes(value);
406
433
  if (selectAll && value === 'all') checked = selectAll && value === 'all' && valueMulti.length > 0;
407
434
  const isMaximumSelection = maximumSelectionLength === (valueMulti === null || valueMulti === void 0 ? void 0 : valueMulti.length);
408
435
  itemDisabled = itemDisabled || isMaximumSelection && !checked;
@@ -423,7 +450,12 @@ const Dropdown = /*#__PURE__*/memo( /*#__PURE__*/forwardRef((inProps, reference)
423
450
  value: value,
424
451
  disabled: itemDisabled,
425
452
  onChange: e => onChangeValue(e, displayText, value, icon, data, index)
426
- }, icon, text)));
453
+ }, jsx("div", {
454
+ style: {
455
+ display: 'flex',
456
+ alignItems: 'center'
457
+ }
458
+ }, icon, text))));
427
459
  } else {
428
460
  items.push(jsx("div", {
429
461
  key: index,
@@ -486,7 +518,9 @@ const Dropdown = /*#__PURE__*/memo( /*#__PURE__*/forwardRef((inProps, reference)
486
518
  const dataSourceUsable = [...dataSourceState];
487
519
  // Nếu có load more thì đẩy đội tượng mặc định lên đầu
488
520
  let notExistItem = 0;
489
- if (onLoadMore && vlObjDefaultState !== null && vlObjDefaultState !== void 0 && vlObjDefaultState.length) {
521
+ if (onLoadMore && vlObjDefaultState !== null && vlObjDefaultState !== void 0 && vlObjDefaultState.length && isEmpty(txtSearch)) {
522
+ // Sẽ Xem Lại
523
+ // if (onLoadMore && vlObjDefaultState?.length) {
490
524
  const length = vlObjDefaultState.length;
491
525
  for (let index = length - 1; index >= 0; index--) {
492
526
  if (!dataSourceUsable.some(data => data[valueExpr] === vlObjDefaultState[index][valueExpr])) {
@@ -550,7 +584,7 @@ const Dropdown = /*#__PURE__*/memo( /*#__PURE__*/forwardRef((inProps, reference)
550
584
  } else {
551
585
  item = jsx(Fragment, null, icon, text);
552
586
  }
553
- if (!dropdownListRef.current) {
587
+ if (!dropdownListRef.current || isEmpty(txtSearch)) {
554
588
  return;
555
589
  }
556
590
  ReactDOM.render(item, dropdownListRef.current.appendChild(dropdownItem));
@@ -997,7 +1031,7 @@ const Dropdown = /*#__PURE__*/memo( /*#__PURE__*/forwardRef((inProps, reference)
997
1031
  if (valueProp !== undefined && (!dropdownListRef.current || children || JSON.stringify(valueProp) !== JSON.stringify(currentValue[unique]))) {
998
1032
  setValueIntoInput(valueProp);
999
1033
  if (oneLiner && multiple) {
1000
- const valueArray = sortMultiple(valueProp);
1034
+ const valueArray = sortMultiple(valueProp, true);
1001
1035
  setValueMultiDisplay(valueArray === null || valueArray === void 0 ? void 0 : valueArray.display);
1002
1036
  setValueMultiOverflow(valueArray === null || valueArray === void 0 ? void 0 : valueArray.overflow);
1003
1037
  if ((valueArray === null || valueArray === void 0 ? void 0 : valueArray.overflow.length) === 0 && openMultipleOverflow) {
@@ -1098,9 +1132,34 @@ const Dropdown = /*#__PURE__*/memo( /*#__PURE__*/forwardRef((inProps, reference)
1098
1132
  disabled: disabled,
1099
1133
  ...labelProps
1100
1134
  }, label) : null, [label, required, disabled, labelProps]);
1135
+ const isMultipleVal = (objData = {}) => {
1136
+ let status = false;
1137
+ 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])) {
1138
+ status = true;
1139
+ }
1140
+ return status;
1141
+ };
1101
1142
  const getData = () => {
1143
+ var _valObjDefault;
1102
1144
  let dataFilter = JSON.parse(JSON.stringify(dataSourceState));
1103
- dataFilter = uniqBy([...vlObjDefaultState, ...dataFilter], data => data === null || data === void 0 ? void 0 : data[valueExpr]);
1145
+ let valObjDefault = vlObjDefaultState;
1146
+ if (isMultipleVal((_valObjDefault = valObjDefault) === null || _valObjDefault === void 0 ? void 0 : _valObjDefault[0])) {
1147
+ var _vlObjDefaultState$;
1148
+ valObjDefault = [];
1149
+ const arr = (vlObjDefaultState === null || vlObjDefaultState === void 0 ? void 0 : (_vlObjDefaultState$ = vlObjDefaultState[0]) === null || _vlObjDefaultState$ === void 0 ? void 0 : _vlObjDefaultState$[valueExpr]) || [];
1150
+ for (let i = 0; i < arr.length; i++) {
1151
+ let objData = {};
1152
+ for (const name in vlObjDefaultState[0]) {
1153
+ var _vlObjDefaultState$2;
1154
+ if (name) objData[name] = (_vlObjDefaultState$2 = vlObjDefaultState[0]) === null || _vlObjDefaultState$2 === void 0 ? void 0 : _vlObjDefaultState$2[name][i];
1155
+ }
1156
+ if (!isEmpty(objData)) valObjDefault.push(objData);
1157
+ }
1158
+ }
1159
+ dataFilter = uniqBy([...valObjDefault, ...dataFilter], data => {
1160
+ let result = data === null || data === void 0 ? void 0 : data[valueExpr];
1161
+ return result;
1162
+ });
1104
1163
  return dataFilter;
1105
1164
  };
1106
1165
  const getTextWidth = text => {
@@ -1127,8 +1186,8 @@ const Dropdown = /*#__PURE__*/memo( /*#__PURE__*/forwardRef((inProps, reference)
1127
1186
  const inputWidth = inputElement === null || inputElement === void 0 ? void 0 : inputElement.clientWidth;
1128
1187
  const items = [];
1129
1188
  if ((valueMulti === null || valueMulti === void 0 ? void 0 : valueMulti.length) > 0) {
1189
+ const dataFilter = getData();
1130
1190
  value.map((vl, index) => {
1131
- const dataFilter = getData();
1132
1191
  const data = dataFilter.find(v => v[valueExpr] === vl || v === vl);
1133
1192
  if (data) {
1134
1193
  const displayText = displayValue(data);
@@ -1181,8 +1240,8 @@ const Dropdown = /*#__PURE__*/memo( /*#__PURE__*/forwardRef((inProps, reference)
1181
1240
  const renderMultipleItem = value => {
1182
1241
  const items = [];
1183
1242
  if ((valueMulti === null || valueMulti === void 0 ? void 0 : valueMulti.length) > 0) {
1243
+ const dataFilter = getData();
1184
1244
  value.map((vl, index) => {
1185
- const dataFilter = getData();
1186
1245
  const data = dataFilter.find(v => v[valueExpr] === vl || v === vl);
1187
1246
  if (data) {
1188
1247
  const displayText = displayValue(data);
@@ -1251,8 +1310,8 @@ const Dropdown = /*#__PURE__*/memo( /*#__PURE__*/forwardRef((inProps, reference)
1251
1310
  const renderOverflowPopover = value => {
1252
1311
  const items = [];
1253
1312
  if ((valueMulti === null || valueMulti === void 0 ? void 0 : valueMulti.length) > 0) {
1313
+ const dataFilter = getData();
1254
1314
  value.map((vl, index) => {
1255
- const dataFilter = getData();
1256
1315
  const data = dataFilter.find(v => v[valueExpr] === vl || v === vl);
1257
1316
  if (data) {
1258
1317
  const displayText = displayValue(data);
@@ -1743,9 +1802,9 @@ Dropdown.propTypes = {
1743
1802
  defaultValue: PropTypes.oneOfType([PropTypes.string, PropTypes.number, PropTypes.array]),
1744
1803
  /** If `true`, the component is disabled. */
1745
1804
  disabled: PropTypes.bool,
1746
- /** The field name used for displaying text in the dropdown list.<br/>
1747
- * Examples: 'name', '{id} - {name}', '{age} age(s)'<br/>
1748
- * Note: Do not use 'id - name', as it will return undefined.
1805
+ /** The field name used for displaying text in the dropdown list.<br/>
1806
+ * Examples: 'name', '{id} - {name}', '{age} age(s)'<br/>
1807
+ * Note: Do not use 'id - name', as it will return undefined.
1749
1808
  */
1750
1809
  displayExpr: PropTypes.oneOfType([PropTypes.string, PropTypes.number, PropTypes.array]),
1751
1810
  /** Inline style for dropdown items. */
@@ -1754,14 +1813,14 @@ Dropdown.propTypes = {
1754
1813
  error: PropTypes.oneOfType([PropTypes.bool, PropTypes.string]),
1755
1814
  /** Props applied to the [HelperText](https://core.diginet.com.vn/ui/?path=/story/form-control-text-helpertext) element. */
1756
1815
  helperTextProps: PropTypes.object,
1757
- /** The field name used for displaying icons.<br/>
1758
- * Example:<br/>
1759
- * &nbsp;&nbsp;string: 'icon'<br/>
1760
- * &nbsp;&nbsp;object: {<br/>
1761
- * &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;key: 'icon',<br/>
1762
- * &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;prefix: 'https://imglink.com',<br/>
1763
- * &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;suffix: '.jpg'<br/>
1764
- * &nbsp;&nbsp;}
1816
+ /** The field name used for displaying icons.<br/>
1817
+ * Example:<br/>
1818
+ * &nbsp;&nbsp;string: 'icon'<br/>
1819
+ * &nbsp;&nbsp;object: {<br/>
1820
+ * &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;key: 'icon',<br/>
1821
+ * &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;prefix: 'https://imglink.com',<br/>
1822
+ * &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;suffix: '.jpg'<br/>
1823
+ * &nbsp;&nbsp;}
1765
1824
  */
1766
1825
  iconExpr: PropTypes.oneOfType([PropTypes.string, PropTypes.shape({
1767
1826
  key: PropTypes.string,
@@ -1795,8 +1854,8 @@ Dropdown.propTypes = {
1795
1854
  onChange: PropTypes.func,
1796
1855
  /** Callback function fired when the dropdown is closed. */
1797
1856
  onClosed: PropTypes.func,
1798
- /** Callback function fired when the input value changes.<br/>
1799
- * If undefined, the filter function will run (default behavior).
1857
+ /** Callback function fired when the input value changes.<br/>
1858
+ * If undefined, the filter function will run (default behavior).
1800
1859
  */
1801
1860
  onInput: PropTypes.func,
1802
1861
  /** Callback function fired when a key is pressed down in the input. */
@@ -1809,21 +1868,21 @@ Dropdown.propTypes = {
1809
1868
  placeholder: PropTypes.string,
1810
1869
  /** If `true`, the component is read-only. */
1811
1870
  readOnly: PropTypes.bool,
1812
- /** Function used for custom rendering of items.<br/>
1813
- * Example: `(data, index) => data.name + ' - ' + data.role`<br/>
1814
- * This can be used as an alternative to `displayExpr`
1871
+ /** Function used for custom rendering of items.<br/>
1872
+ * Example: `(data, index) => data.name + ' - ' + data.role`<br/>
1873
+ * This can be used as an alternative to `displayExpr`
1815
1874
  */
1816
1875
  renderItem: PropTypes.func,
1817
- /** Function or field name used to display selected items.<br/>
1818
- * Example: `(data, index) => index + ' - ' + data.name`<br/>
1876
+ /** Function or field name used to display selected items.<br/>
1877
+ * Example: `(data, index) => index + ' - ' + data.name`<br/>
1819
1878
  */
1820
1879
  renderSelectedItem: PropTypes.oneOfType([PropTypes.func, PropTypes.string]),
1821
1880
  /** If `true`, the label will indicate that the input is required. */
1822
1881
  required: PropTypes.bool,
1823
- /**
1824
- * Duration to wait after entering search content before triggering a search.<br/>
1825
- * Example: 700 -> 700ms, '700ms' -> 700ms, '0.7s' -> 700ms, '1m' -> 60000ms
1826
- * If `true`, the default delayOnInput will be used.
1882
+ /**
1883
+ * Duration to wait after entering search content before triggering a search.<br/>
1884
+ * Example: 700 -> 700ms, '700ms' -> 700ms, '0.7s' -> 700ms, '1m' -> 60000ms
1885
+ * If `true`, the default delayOnInput will be used.
1827
1886
  */
1828
1887
  searchDelayTime: PropTypes.oneOfType([PropTypes.string, PropTypes.number, PropTypes.bool]),
1829
1888
  /** Specifies the field name or expression used to compare values with the search string. */
@@ -1854,19 +1913,19 @@ Dropdown.propTypes = {
1854
1913
  valueObjectDefault: PropTypes.oneOfType([PropTypes.object, PropTypes.array]),
1855
1914
  /** The variant to use. */
1856
1915
  viewType: PropTypes.oneOf(['underlined', 'outlined', 'none'])
1857
- /**
1858
- * ref methods
1859
- *
1860
- * how to get component element? ref.current
1861
- *
1862
- * how to call method? ref.current.instance.{method}
1863
- *
1864
- * * showDropdown(): Show dropdown
1865
- * * closeDropdown(): Close dropdown
1866
- * * onClear(): Clear selected value
1867
- * * setPreviousValue(): Set value to previous value
1868
- * * setValue(value): Set value of dropdown
1869
- * * @param {value} - string || number || array
1916
+ /**
1917
+ * ref methods
1918
+ *
1919
+ * how to get component element? ref.current
1920
+ *
1921
+ * how to call method? ref.current.instance.{method}
1922
+ *
1923
+ * * showDropdown(): Show dropdown
1924
+ * * closeDropdown(): Close dropdown
1925
+ * * onClear(): Clear selected value
1926
+ * * setPreviousValue(): Set value to previous value
1927
+ * * setValue(value): Set value of dropdown
1928
+ * * @param {value} - string || number || array
1870
1929
  */
1871
1930
  };
1872
1931
  export default Dropdown;
@@ -1,13 +1,15 @@
1
1
  /** @jsxRuntime classic */
2
2
  /** @jsx jsx */
3
3
  import { css, jsx } from '@emotion/core';
4
- import { ButtonIcon, InputBase, Label, Popover, PopoverBody } from "../..";
4
+ import { ButtonIcon, InputBase, Label, Popover, PopoverBody, HelperText } from "../..";
5
5
  import PropTypes from 'prop-types';
6
- import { Fragment, forwardRef, memo, useEffect, useImperativeHandle, useLayoutEffect, useRef, useState } from 'react';
6
+ import { Fragment, forwardRef, memo, useEffect, useImperativeHandle, useLayoutEffect, useRef, useState, useMemo } from 'react';
7
7
  import { animation, borderColor, displayBlock, overflowHidden, parseHeight, parseMinWidth, positionRelative, scaleX } from "../../../styles/general";
8
8
  import { useTheme } from "../../../theme";
9
9
  import useThemeProps from "../../../theme/utils/useThemeProps";
10
10
  import { classNames, getProp } from "../../../utils";
11
+ const regexBetween = /[^{}]+(?=})/g;
12
+ const regexInclude = /{|}/g;
11
13
  const DropdownBox = /*#__PURE__*/memo( /*#__PURE__*/forwardRef((inProps, reference) => {
12
14
  if (!reference) reference = useRef(null);
13
15
  const theme = useTheme();
@@ -22,10 +24,14 @@ const DropdownBox = /*#__PURE__*/memo( /*#__PURE__*/forwardRef((inProps, referen
22
24
  });
23
25
  const {
24
26
  action = {},
27
+ allowInput,
25
28
  bgColor: bgColorProp,
26
29
  children,
27
30
  className,
28
31
  delayOnInput,
32
+ disabled,
33
+ displayExpr: displayExprProp,
34
+ error,
29
35
  endIcon,
30
36
  inputProps,
31
37
  inputRef,
@@ -39,10 +45,19 @@ const DropdownBox = /*#__PURE__*/memo( /*#__PURE__*/forwardRef((inProps, referen
39
45
  placeholder,
40
46
  startIcon,
41
47
  style,
42
- value,
43
- viewType
48
+ value: valueProps,
49
+ valueExpr,
50
+ viewType,
51
+ helperTextProps
44
52
  } = props;
53
+ let displayExpr = displayExprProp;
45
54
  const bgColor = typeof bgColorProp === 'string' ? getProp(colors, bgColorProp, bgColorProp) : bgColorProp;
55
+ const ErrorView = useMemo(() => {
56
+ return error ? jsx(HelperText, {
57
+ ...helperTextProps,
58
+ disabled: disabled
59
+ }, error) : null;
60
+ }, [disabled, error, helperTextProps]);
46
61
  const ref = useRef(null);
47
62
  const dropdownBoxRef = useRef(null);
48
63
  const timer = useRef(null);
@@ -85,6 +100,28 @@ const DropdownBox = /*#__PURE__*/memo( /*#__PURE__*/forwardRef((inProps, referen
85
100
  onClosed === null || onClosed === void 0 ? void 0 : onClosed();
86
101
  }
87
102
  };
103
+
104
+ /**
105
+ * Chuyển đổi data thành giá trị cần hiện thị dựa vào displayExpr [string, string object {field} - {field}], renderSelectedItem, displayExpr, valueExpr
106
+ * @param data {object} rowData of dataSource
107
+ * @return {string}
108
+ */
109
+ const displayValue = data => {
110
+ let text = '';
111
+ if (data || data === 0) {
112
+ displayExpr = displayExpr || valueExpr;
113
+ let mask = data === null || data === void 0 ? void 0 : data[displayExpr];
114
+ // convert {id} - {name} to {<data[id]>} - {<data[name]>}
115
+ if (!mask && regexBetween.test(displayExpr)) {
116
+ var _displayExpr;
117
+ mask = (_displayExpr = displayExpr) === null || _displayExpr === void 0 ? void 0 : _displayExpr.replace(regexBetween, _ => (data === null || data === void 0 ? void 0 : data[_]) || '');
118
+ } else if (!mask) {
119
+ mask = typeof data !== 'object' ? data : '';
120
+ }
121
+ text = mask.toString().replace(regexInclude, '');
122
+ }
123
+ return text;
124
+ };
88
125
  useLayoutEffect(() => {
89
126
  if (ref.current) {
90
127
  const {
@@ -130,15 +167,17 @@ const DropdownBox = /*#__PURE__*/memo( /*#__PURE__*/forwardRef((inProps, referen
130
167
  onClick: openOnClickAt === 'icon' ? onTriggerDropdown : null
131
168
  }) : null;
132
169
  };
170
+ const value = displayValue(valueProps);
133
171
  return jsx(Fragment, null, jsx("div", {
134
172
  ref: ref,
135
173
  css: _DropdownBoxRootCSS,
136
- className: classNames('DGN-UI-Dropdown-Box', className),
174
+ className: classNames('DGN-UI-Dropdown-Box', className, error && 'error'),
137
175
  style: style
138
176
  }, label ? jsx(Label, {
139
177
  ...labelProps
140
178
  }, label) : null, jsx(InputBase, {
141
179
  ...inputProps,
180
+ readOnly: !allowInput,
142
181
  style: inputStyle,
143
182
  viewType: viewType,
144
183
  inputRef: inputRef,
@@ -157,7 +196,7 @@ const DropdownBox = /*#__PURE__*/memo( /*#__PURE__*/forwardRef((inProps, referen
157
196
  anchor: ref.current,
158
197
  width: popoverWidth,
159
198
  onClose: closeDropdownBox
160
- }, jsx(PopoverBody, null, children)));
199
+ }, jsx(PopoverBody, null, children)), ErrorView);
161
200
  }));
162
201
  const DropdownBoxRootCSS = (bgColorProp, {
163
202
  colors
@@ -166,6 +205,17 @@ const DropdownBoxRootCSS = (bgColorProp, {
166
205
  ${positionRelative};
167
206
  ${parseMinWidth(150)};
168
207
  ${parseHeight('max-content')};
208
+ &.error {
209
+ .DGN-UI-InputBase {
210
+ ${borderColor(getProp(colors, 'semantic/danger'))};
211
+ &::before {
212
+ ${borderColor(getProp(colors, 'semantic/danger'))};
213
+ }
214
+ &::after {
215
+ ${borderColor(getProp(colors, 'semantic/danger'))};
216
+ }
217
+ }
218
+ }
169
219
  .DGN-UI-InputBase {
170
220
  background: ${bgColorProp ? bgColorProp === true ? getProp(colors, 'fill/disabled') : bgColorProp : 'inherit'} !important;
171
221
  ${openState && css`
@@ -183,20 +233,6 @@ const DropdownBoxCSS = ({
183
233
  margin-top: ${spacing([1])};
184
234
  ${overflowHidden};
185
235
  `;
186
-
187
- // DropdownBox.defaultProps = {
188
- // className: '',
189
- // label: '',
190
- // placeholder: '',
191
- // startIcon: 'Search',
192
- // endIcon: 'ArrowDown',
193
- // openOnClickAt: 'icon',
194
- // viewType: 'underlined',
195
- // inputProps: {},
196
- // delayOnInput: 700,
197
- // zIndex: zIndexCORE(1),
198
- // };
199
-
200
236
  DropdownBox.propTypes = {
201
237
  /** class for dropdown */
202
238
  className: PropTypes.string,
@@ -233,6 +269,12 @@ DropdownBox.propTypes = {
233
269
  /** the function will run after open */
234
270
  onOpened: PropTypes.func,
235
271
  /** the function will run after close */
236
- onClosed: PropTypes.func
272
+ onClosed: PropTypes.func,
273
+ /** Error message displayed below the input. */
274
+ error: PropTypes.oneOfType([PropTypes.bool, PropTypes.string]),
275
+ /** If `true`, the component is disabled. */
276
+ disabled: PropTypes.bool,
277
+ /** If `true`, the input is enable. */
278
+ allowInput: PropTypes.bool
237
279
  };
238
280
  export default DropdownBox;
@@ -49,7 +49,7 @@ const NumberInput = /*#__PURE__*/forwardRef((inProps, reference) => {
49
49
  labelProps,
50
50
  max: maxProp,
51
51
  maxDigit,
52
- min,
52
+ min: minProp,
53
53
  nonStyle,
54
54
  onBlur,
55
55
  onChange,
@@ -69,9 +69,12 @@ const NumberInput = /*#__PURE__*/forwardRef((inProps, reference) => {
69
69
  viewType
70
70
  } = props;
71
71
  let max = maxProp;
72
+ let min = minProp;
72
73
  let thousandSymbol = thousandSeparator;
73
74
  let decimalSymbol = decimalSymbolProp;
74
75
  let valueProps = valueProp;
76
+ if (!min && min !== 0) min = -Infinity;
77
+ if (!max && max !== 0) max = Infinity;
75
78
  const pos = useRef(null);
76
79
  const ref = useRef(null);
77
80
  const globalRef = useRef({});
@@ -95,13 +98,13 @@ const NumberInput = /*#__PURE__*/forwardRef((inProps, reference) => {
95
98
 
96
99
  // if (valueProps || valueProps === 0) valueProps = clamp(valueProps, min, max);
97
100
 
98
- /**
99
- * Convert number to format money
100
- * @param vl {number} - value
101
- * @type {function}
102
- * @return {string}
103
- * @example 1200300.123 => 1,200,300.123
104
- * @example 1200300,123 => 1.200.300,123
101
+ /**
102
+ * Convert number to format money
103
+ * @param vl {number} - value
104
+ * @type {function}
105
+ * @return {string}
106
+ * @example 1200300.123 => 1,200,300.123
107
+ * @example 1200300,123 => 1.200.300,123
105
108
  */
106
109
  const parseNumberToMoney = useCallback((vl, isNumber) => {
107
110
  var _number, _number2, _number$, _number3;
@@ -149,13 +152,13 @@ const NumberInput = /*#__PURE__*/forwardRef((inProps, reference) => {
149
152
  return number;
150
153
  }, [decimalSymbol, max, value, decimalDigit, fixedDecimalDigit]);
151
154
 
152
- /**
153
- * Convert money to format number
154
- * @param vl {string} - value
155
- * @type {function}
156
- * @return {number}
157
- * @example 1,200,300.123 => 1200300.123
158
- * @example 1.200.300,123 => 1200300.123
155
+ /**
156
+ * Convert money to format number
157
+ * @param vl {string} - value
158
+ * @type {function}
159
+ * @return {number}
160
+ * @example 1,200,300.123 => 1200300.123
161
+ * @example 1.200.300,123 => 1200300.123
159
162
  */
160
163
  const convertMoneyToNumber = useCallback((vl, isNumber) => {
161
164
  var _number4, _number4$toString, _number4$toString$rep, _number4$toString$rep2, _number4$toString$rep3;
@@ -168,16 +171,19 @@ const NumberInput = /*#__PURE__*/forwardRef((inProps, reference) => {
168
171
  const _onInput = useCallback((e, flag) => {
169
172
  var _e$target$value;
170
173
  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;
174
+ if (disabledNegative && eval(valueT || 0) <= 0 || valueT.includes('-')) valueT = 0;
175
+ if ((min || min === 0) && eval(valueT) <= min || min === 0 && valueT.includes('-')) valueT = min;
176
+ if ((max || max === 0) && eval(valueT) >= max) valueT = max;
172
177
  valueT = parseNumberToMoney(valueT);
173
178
  const returnValue = convertMoneyToNumber(valueT);
174
179
  e.value = globalRef.current.value = !isNaN(parseFloat(returnValue)) ? parseFloat(returnValue) : null;
175
180
  // e.target.value = globalRef.current.valueString = valueT || '';
176
181
  // globalRef.current.returnValue = returnValue || '';
177
182
  e.target.value = globalRef.current.valueString = valueT || '';
183
+ e.value = valueT;
178
184
  globalRef.current.returnValue = returnValue || '';
179
185
  onInput === null || onInput === void 0 ? void 0 : onInput(e);
180
- setValue(valueT);
186
+ setValue(eval(valueT));
181
187
  if (flag) _onChange(e);
182
188
  }, [min, max, decimalDigit]);
183
189
  const _onBlur = useCallback(e => {
@@ -490,10 +496,10 @@ NumberInput.propTypes = {
490
496
  style: PropTypes.object,
491
497
  /** Thousand separator character. */
492
498
  thousandSeparator: PropTypes.oneOfType([PropTypes.bool, PropTypes.oneOf(['.', ','])]),
493
- /** Validation value, argument can:<br/>
494
- * * string: the validation rule. Example required.<br/>
495
- * * object: the validation rule insist name, property, message. Example {name: 'min', compareValue: 9, message: 'Error'} or {max: 99}<br/>
496
- * * array: the validation rule list, insist object/string
499
+ /** Validation value, argument can:<br/>
500
+ * * string: the validation rule. Example required.<br/>
501
+ * * object: the validation rule insist name, property, message. Example {name: 'min', compareValue: 9, message: 'Error'} or {max: 99}<br/>
502
+ * * array: the validation rule list, insist object/string
497
503
  */
498
504
  validates: PropTypes.oneOfType([PropTypes.string, PropTypes.object, PropTypes.array, PropTypes.func]),
499
505
  /** The value of the input element, required for a controlled component. */
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,44 +1,78 @@
1
- {
2
- "name": "diginet-core-ui",
3
- "version": "1.4.55",
4
- "description": "The DigiNet core ui",
5
- "homepage": "https://diginet.com.vn",
6
- "main": "index.js",
7
- "scripts": {
8
- "start-js": "react-scripts start --max_old_space_size=4096",
9
- "start": "npx npm-run-all -p start-js",
10
- "build": "GENERATE_SOURCEMAP=false && react-scripts build --env=production --max_old_space_size=8192",
11
- "eject": "react-scripts eject",
12
- "test": "echo \"Error: no test specified\" && exit 1"
13
- },
14
- "dependencies": {
15
- "@emotion/core": "^10.0.35",
16
- "prop-types": "^15.7.2",
17
- "@emotion/css": "^11.11.0",
18
- "@emotion/react": "^11.10.6"
19
- },
20
- "repository": {
21
- "type": "git",
22
- "url": "git+https://diginetvn@bitbucket.org/diginetvn/diginet-core-ui.git"
23
- },
24
- "keywords": [
25
- "core ui",
26
- "diginet"
27
- ],
28
- "author": "rocachien",
29
- "contributors": [
30
- {
31
- "name": "Chien Do",
32
- "email": "rocachien@gmail.com"
33
- },
34
- {
35
- "name": "Nhat Tran",
36
- "email": "tranminhnhat1005@gmail.com"
37
- },
38
- {
39
- "name": "Thuan Nguyen",
40
- "email": "nt.thuan.hutech@gmail.com"
41
- }
42
- ],
43
- "license": "MIT"
44
- }
1
+ {
2
+ "name": "diginet-core-ui",
3
+ "version": "1.4.56-beta.1",
4
+ "description": "",
5
+ "main": "index.js",
6
+ "license": "UNLICENSED",
7
+ "scripts": {
8
+ "start": "npm-run-all --parallel start-sb eslint-test",
9
+ "start-sb": "start-storybook -p 9050",
10
+ "build-storybook": "build-storybook -c .storybook -s src",
11
+ "build": "run-script-os",
12
+ "build:windows": "rimraf dist && mkdirp dist/components && npm run compile && sass --style=compressed src/scss:dist/css && xcopy src\\\\assets dist\\\\assets\\ /e /y",
13
+ "build:darwin:linux:default": "rm -rf dist && npm run compile && sass --style=compressed src/scss:dist/css && cp -rf src/assets dist/assets",
14
+ "compile": "babel src --out-dir dist --ignore **/*.stories.js",
15
+ "pack": "npm run build && cp *.md dist/ && npm run version:bump --silent && npm run version:add --silent && cd dist && npm pack",
16
+ "production-keep-version": "npm run build && cp *.md dist/ && cp package.json dist/ && cd dist && npm publish",
17
+ "beta": "npm run build && cp *.md dist/ && cp package.json dist/ && cd dist && npm publish --tag beta",
18
+ "production": "npm run build && cp *.md dist/ && npm run version:bump --silent && npm run version:add --silent && cd dist && npm publish",
19
+ "version:add": "run-script-os",
20
+ "version:add:windows": "cat package.json.tmp | sed \"s/0.0.0/%npm_package_version%/g\" > dist/package.json",
21
+ "version:add:darwin:linux:default": "VERSION=$(npm run version:extract --silent) && cat package.json.tmp | sed \"s/0.0.0/${VERSION}/g\" > dist/package.json",
22
+ "version:bump": "npm version patch --no-git-tag-version --silent",
23
+ "version:extract": "cat package.json | grep version | head -1 | awk -F: '{ print $2 }' | sed 's/[\",]//g' | tr -d '[[:space:]]'",
24
+ "test": "echo \"Error: no test specified\" && exit 1",
25
+ "lint": "eslint --fix --config .eslintrc.js \"**/*.js\"",
26
+ "eslint-test": "onchange \"src/**/*.{js,jsx,json}\" -- eslint . --fix",
27
+ "freshtall": "npm cache clean --force && rm -rf node_modules && rm -f package-lock.json && npm install",
28
+ "test-storybook": "test-storybook --url http://localhost:9050",
29
+ "preinstall": "echo {} > package-lock.json"
30
+ },
31
+ "dependencies": {
32
+ "@emotion/core": "^10.0.35",
33
+ "@emotion/css": "^11.11.0",
34
+ "@emotion/react": "^11.10.6",
35
+ "babel-plugin-module-resolver": "^4.1.0",
36
+ "date-fns": "^2.30.0",
37
+ "prop-types": "^15.7.2"
38
+ },
39
+ "lint-staged": {
40
+ "*/**/*.{js,jsx,json}": [
41
+ "prettier --write",
42
+ "git add"
43
+ ]
44
+ },
45
+ "devDependencies": {
46
+ "@babel/cli": "^7.14.3",
47
+ "@babel/plugin-proposal-class-properties": "^7.13.0",
48
+ "@babel/plugin-proposal-logical-assignment-operators": "^7.16.0",
49
+ "@babel/plugin-proposal-nullish-coalescing-operator": "^7.16.0",
50
+ "@babel/plugin-proposal-optional-chaining": "^7.14.2",
51
+ "@babel/plugin-proposal-private-methods": "^7.18.6",
52
+ "@babel/plugin-proposal-private-property-in-object": "^7.18.6",
53
+ "@babel/preset-react": "^7.13.13",
54
+ "@storybook/addon-actions": "6.2.9",
55
+ "@storybook/addon-essentials": "6.2.9",
56
+ "@storybook/addon-links": "6.2.9",
57
+ "@storybook/addon-postcss": "^2.0.0",
58
+ "@storybook/react": "6.2.9",
59
+ "@storybook/test-runner": "^0.7.1",
60
+ "autoprefixer": "^10.3.1",
61
+ "babel-loader": "^8.2.2",
62
+ "eslint": "^8.4.1",
63
+ "eslint-plugin-react": "^7.27.1",
64
+ "eslint-plugin-regex": "^1.10.0",
65
+ "husky": "^7.0.4",
66
+ "jest": "^27.5.1",
67
+ "lint-staged": "^12.1.2",
68
+ "mkdirp": "^1.0.4",
69
+ "npm-run-all": "^4.1.5",
70
+ "onchange": "^7.1.0",
71
+ "postcss-flexbugs-fixes": "^5.0.2",
72
+ "react": "^17.0.1",
73
+ "react-dom": "^17.0.1",
74
+ "rimraf": "^3.0.2",
75
+ "run-script-os": "^1.1.6",
76
+ "sass": "1.58.3"
77
+ }
78
+ }
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 };