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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,14 @@
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_2363_38)">
3
+ <path d="M39 9.7C38.9 9.1 38.9 8.4 38.7 7.7C37.6 3.4 33.8 0.3 29.2 0H29C28.9 0 28.8 0 28.6 0C27.9 0 27.5 0.5 27.5 1.1C27.5 1.7 28 2.1 28.6 2.1H28.7C29 2.1 29.3 2.1 29.6 2.2C33.7 2.7 36.8 6.1 36.9 10.1C36.9 10.8 37.3 11.2 37.9 11.2C38.2 11.2 38.5 11.1 38.7 10.9C39 10.6 39 10.3 39 9.9V9.7Z" fill="#FFC766"/>
4
+ <path d="M35.3 10.1C35.3 10 35.3 9.9 35.3 9.7C34.9 7.3 33.6 5.6 31.4 4.5C30.4 4 29.3 3.8 28.1 3.8C27.5 3.8 27.1 4.2 27.1 4.7C27.1 5.2 27.4 5.7 27.9 5.8C28 5.8 28.1 5.8 28.2 5.8H28.3C29.9 5.9 31.2 6.5 32.2 7.6C32.9 8.4 33.3 9.4 33.3 10.4C33.3 11 33.7 11.5 34.3 11.5C34.9 11.5 35.3 11 35.3 10.4V10.1Z" fill="#FFC766"/>
5
+ <path d="M0 29.3C0.1 29.9 0.1 30.6 0.3 31.3C1.4 35.6 5.2 38.7 9.8 39H10C10.1 39 10.2 39 10.4 39C11.1 39 11.5 38.5 11.5 37.9C11.5 37.3 11 36.9 10.4 36.9H10.3C10 36.9 9.7 36.9 9.4 36.8C5.2 36.4 2.1 33 2.1 29C2.1 28.3 1.7 27.9 1.1 27.9C0.8 27.9 0.5 28 0.3 28.2C0.1 28.4 0 28.7 0 29V29.3Z" fill="#FFC766"/>
6
+ <path d="M3.7 28.9C3.7 29 3.7 29.1 3.7 29.3C4.1 31.7 5.4 33.4 7.6 34.5C8.6 35 9.7 35.2 10.9 35.2C11.5 35.2 11.9 34.8 11.9 34.3C11.9 33.8 11.6 33.3 11.1 33.2C11 33.2 10.9 33.2 10.8 33.2H10.7C9.1 33.1 7.8 32.5 6.8 31.4C6.1 30.6 5.7 29.6 5.7 28.6C5.7 28 5.3 27.5 4.7 27.5C4.1 27.5 3.7 28 3.7 28.6V28.9Z" fill="#FFC766"/>
7
+ <path d="M31.8001 26.9999C31.8001 29.8999 30.6001 32.1999 28.2001 33.7999C24.7001 36.1999 20.4001 35.7999 17.3001 32.6999L11.1001 26.4999L9.30009 24.6999C7.70009 23.0999 6.10009 21.4999 4.50009 19.8999C4.10009 19.3999 3.90009 18.9999 4.00009 18.3999C4.10009 17.7999 4.50009 17.3999 5.10009 17.1999C5.70009 16.9999 6.30009 17.1999 6.70009 17.5999C8.20009 19.0999 9.70009 20.5999 11.2001 22.0999L13.0001 23.8999C13.0001 23.9999 13.1001 23.9999 13.2001 24.0999C13.5001 24.2999 13.8001 24.2999 14.1001 24.0999C14.4001 23.7999 14.4001 23.4999 14.2001 23.1999C14.2001 23.0999 14.1001 23.0999 14.0001 22.9999L7.40009 16.3999C6.50009 15.4999 5.70009 14.6999 4.80009 13.7999C4.40009 13.3999 4.30009 12.8999 4.40009 12.3999C4.50009 11.8999 4.80009 11.4999 5.30009 11.1999C5.90009 10.8999 6.60009 11.0999 7.20009 11.5999L12.9001 17.2999L16.2001 20.5999C16.3001 20.6999 16.3001 20.6999 16.4001 20.7999C16.7001 20.9999 17.0001 20.9999 17.3001 20.7999C17.6001 20.5999 17.6001 20.1999 17.4001 19.9999C17.4001 19.8999 17.3001 19.8999 17.2001 19.7999L7.40009 9.99994C7.30009 9.89994 7.20009 9.69994 7.10009 9.59994C6.70009 9.09994 6.70009 8.29994 7.10009 7.69994C7.40009 7.29994 7.80009 7.09994 8.20009 7.09994C8.70009 7.09994 9.20009 7.29994 9.60009 7.59994C11.9001 9.99994 14.4001 12.3999 16.7001 14.6999L19.4001 17.2999L19.6001 17.4999C19.9001 17.7999 20.3001 17.7999 20.5001 17.4999C20.8001 17.1999 20.8001 16.8999 20.5001 16.4999C20.4001 16.3999 20.4001 16.3999 20.3001 16.2999L12.8001 8.99994C12.4001 8.59994 12.2001 8.09994 12.3001 7.59994C12.4001 6.99994 12.8001 6.49994 13.4001 6.29994C14.0001 6.09994 14.6001 6.19994 15.0001 6.69994C18.9001 10.5999 22.8001 14.4999 26.7001 18.3999C26.9001 18.5999 27.2001 18.8999 27.6001 18.6999C28.0001 18.4999 28.0001 18.0999 28.0001 17.8999V17.3999C28.0001 16.0999 28.0001 14.6999 28.0001 13.3999C28.0001 12.2999 28.8001 11.4999 29.9001 11.4999C31.0001 11.4999 31.8001 12.2999 31.8001 13.3999V16.3999C31.8001 19.7999 31.8001 23.3999 31.8001 26.9999Z" fill="#FFAA00"/>
8
+ </g>
9
+ <defs>
10
+ <clipPath id="clip0_2363_38">
11
+ <rect width="39" height="39" fill="white"/>
12
+ </clipPath>
13
+ </defs>
14
+ </svg>
@@ -0,0 +1,15 @@
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_2363_39)">
3
+ <path d="M38.6992 9.52442L29.5758 0.401028C29.275 0.100257 28.9743 0 28.6735 0H12.6324C10.7275 0 9.22363 1.50386 9.22363 3.40874V6.01542C9.72492 6.11568 10.2262 6.3162 10.527 6.71722L11.4293 7.61954V3.40874C11.4293 2.8072 11.9306 2.30591 12.5321 2.30591H27.4704V8.02057C27.4704 9.92545 28.9743 11.4293 30.8792 11.4293H36.5938V35.6915C36.5938 36.2931 36.0925 36.7943 35.491 36.7943H12.6324C12.0308 36.7943 11.5295 36.2931 11.5295 35.6915V31.8817C11.4293 31.7815 11.329 31.6812 11.2288 31.581L9.22363 29.5758V35.5913C9.22363 37.4961 10.7275 39 12.6324 39H35.5912C37.4961 39 39 37.4961 39 35.5913V10.3265C39 10.0257 38.8997 9.72493 38.6992 9.52442ZM30.9794 9.12339C30.3779 9.12339 29.7763 8.62211 29.7763 8.02057V3.91003L34.9897 9.12339H30.9794Z" fill="#2680EB"/>
4
+ <path d="M34.0002 26.3C34.0002 26.9 33.5002 27.4 32.9002 27.4H25.8002C25.9002 26.8 26.0002 26.2 26.0002 25.6V25.1H32.9002C33.5002 25.2 34.0002 25.7 34.0002 26.3Z" fill="#2680EB"/>
5
+ <path d="M34.0002 21.2C34.0002 21.8 33.5002 22.3 32.9002 22.3H26.0002C26.0002 21.5 26.0002 20.8 26.0002 20H32.9002C33.5002 20.1 34.0002 20.6 34.0002 21.2Z" fill="#2680EB"/>
6
+ <path d="M34.0002 16.1C34.0002 16.7 33.5002 17.3 32.9002 17.3H26.0002V15H32.9002C33.5002 15 34.0002 15.5 34.0002 16.1Z" fill="#2680EB"/>
7
+ <path d="M29.4002 31.4C29.4002 32 28.9002 32.5 28.3002 32.5H22.4002C23.3002 31.8 24.1002 31.1 24.7002 30.2H28.3002C28.9002 30.3 29.4002 30.8 29.4002 31.4Z" fill="#2680EB"/>
8
+ <path d="M25.0001 25.7C25.0001 28.3 23.9001 30.4 21.8001 31.8C18.7001 34 14.8001 33.6 12.1001 30.9L4.9001 23.7C3.5001 22.3 2.0001 20.8 0.600098 19.4C0.100098 18.9 -0.0999023 18.5 9.76566e-05 18C0.100098 17.4 0.400098 17.1 1.0001 16.9C1.6001 16.7 2.1001 16.9 2.5001 17.3C3.8001 18.6 5.2001 20 6.6001 21.3L8.3001 23C8.6001 23.2 8.9001 23.2 9.1001 23C9.4001 22.8 9.4001 22.5 9.2001 22.2C9.1001 22.2 9.0001 22.1 9.0001 22L3.0001 16.1C2.2001 15.3 1.4001 14.5 0.700098 13.8C0.400098 13.5 0.200098 13 0.300098 12.6C0.400098 12.1 0.700098 11.8 1.1001 11.6C1.7001 11.3 2.3001 11.5 2.8001 12L8.0001 17L11.0001 20C11.1001 20.1 11.1001 20.1 11.2001 20.2C11.5001 20.4 11.7001 20.4 12.0001 20.2C12.2001 20 12.3001 19.7 12.1001 19.4C12.1001 19.3 12.0001 19.3 11.9001 19.2L3.2001 10.4C3.1001 10.3 3.0001 10.2 2.9001 10.1C2.5001 9.6 2.6001 8.9 2.9001 8.4C3.2001 8.1 3.5001 7.9 3.9001 7.9C4.3001 7.9 4.8001 8.1 5.1001 8.4C7.2001 10.5 9.4001 12.7 11.5001 14.8L14.1001 17.4C14.4001 17.6 14.7001 17.6 14.9001 17.4C15.1001 17.2 15.1001 16.8 14.9001 16.5C14.8001 16.4 14.8001 16.4 14.7001 16.3L7.9001 9.5C7.6001 9.1 7.4001 8.7 7.5001 8.2C7.6001 7.6 7.9001 7.2 8.5001 7.1C9.0001 6.9 9.5001 7 9.9001 7.4C13.4001 10.9 16.9001 14.4 20.4001 17.9C20.6001 18.1 20.8001 18.3 21.2001 18.2C21.6001 18 21.6001 17.7 21.6001 17.5V17C21.6001 15.8 21.6001 14.6 21.6001 13.4C21.6001 12.4 22.3001 11.7 23.3001 11.7C24.3001 11.7 25.0001 12.4 25.0001 13.4V16.1C25.0001 19.2 25.0001 22.5 25.0001 25.7Z" fill="#FFAA00"/>
9
+ </g>
10
+ <defs>
11
+ <clipPath id="clip0_2363_39">
12
+ <rect width="39" height="39" fill="white"/>
13
+ </clipPath>
14
+ </defs>
15
+ </svg>
@@ -1442,17 +1442,17 @@ Attachment.propTypes = {
1442
1442
  allowSort: PropTypes.bool,
1443
1443
  /** Class for component. */
1444
1444
  className: PropTypes.string,
1445
- /** List attachment:<br />
1446
- * [{<br />
1447
- * &nbsp;&nbsp;&nbsp;&nbsp;"AttachmentID": "ATT2U8O7YPTF1KSNCW3X",<br />
1448
- * &nbsp;&nbsp;&nbsp;&nbsp;"URL": "https://apricot.diginet.com.vn/cdn-dev/file/demo.jpg",<br />
1449
- * &nbsp;&nbsp;&nbsp;&nbsp;"FileName": "8a07bee1eeff17a14eee.jpg",<br />
1450
- * &nbsp;&nbsp;&nbsp;&nbsp;"FileSize": 248837,<br />
1451
- * &nbsp;&nbsp;&nbsp;&nbsp;"KeyID": "W39OAD3YGLCWAQKV1D6PGEKNW4RLGVTZTUWLYEVFQ2QG8AOCXW",<br />
1452
- * &nbsp;&nbsp;&nbsp;&nbsp;"CreateUserID": "LEMONADMIN",<br />
1453
- * &nbsp;&nbsp;&nbsp;&nbsp;"CreateDate": "2020-08-24T11:54:04.307Z",<br />
1454
- * &nbsp;&nbsp;&nbsp;&nbsp;"UserName": "Quản trị hệ thống"<br />
1455
- * }, ...]
1445
+ /** List attachment:<br />
1446
+ * [{<br />
1447
+ * &nbsp;&nbsp;&nbsp;&nbsp;"AttachmentID": "ATT2U8O7YPTF1KSNCW3X",<br />
1448
+ * &nbsp;&nbsp;&nbsp;&nbsp;"URL": "https://apricot.diginet.com.vn/cdn-dev/file/demo.jpg",<br />
1449
+ * &nbsp;&nbsp;&nbsp;&nbsp;"FileName": "8a07bee1eeff17a14eee.jpg",<br />
1450
+ * &nbsp;&nbsp;&nbsp;&nbsp;"FileSize": 248837,<br />
1451
+ * &nbsp;&nbsp;&nbsp;&nbsp;"KeyID": "W39OAD3YGLCWAQKV1D6PGEKNW4RLGVTZTUWLYEVFQ2QG8AOCXW",<br />
1452
+ * &nbsp;&nbsp;&nbsp;&nbsp;"CreateUserID": "LEMONADMIN",<br />
1453
+ * &nbsp;&nbsp;&nbsp;&nbsp;"CreateDate": "2020-08-24T11:54:04.307Z",<br />
1454
+ * &nbsp;&nbsp;&nbsp;&nbsp;"UserName": "Quản trị hệ thống"<br />
1455
+ * }, ...]
1456
1456
  */
1457
1457
  data: PropTypes.array,
1458
1458
  /** The message to display when deleting files. */
@@ -1483,16 +1483,16 @@ Attachment.propTypes = {
1483
1483
  onChange: PropTypes.func,
1484
1484
  /** Download attached event, if not it will use default. */
1485
1485
  onDownload: PropTypes.func,
1486
- /**
1487
- * event when removed file(s)
1488
- *
1489
- * return data: {<br/>
1490
- * &nbsp;&nbsp;&nbsp;&nbsp;attached: [Files] (insist old and all new files )<br/>
1491
- * &nbsp;&nbsp;&nbsp;&nbsp;allNewAttached: [Files]<br/>
1492
- * &nbsp;&nbsp;&nbsp;&nbsp;oldAttached: [Files]<br/>
1493
- * &nbsp;&nbsp;&nbsp;&nbsp;removedAttached: [Files]<br/>
1494
- * &nbsp;&nbsp;&nbsp;&nbsp;element: [NodeList (just removed)]<br/>
1495
- * }
1486
+ /**
1487
+ * event when removed file(s)
1488
+ *
1489
+ * return data: {<br/>
1490
+ * &nbsp;&nbsp;&nbsp;&nbsp;attached: [Files] (insist old and all new files )<br/>
1491
+ * &nbsp;&nbsp;&nbsp;&nbsp;allNewAttached: [Files]<br/>
1492
+ * &nbsp;&nbsp;&nbsp;&nbsp;oldAttached: [Files]<br/>
1493
+ * &nbsp;&nbsp;&nbsp;&nbsp;removedAttached: [Files]<br/>
1494
+ * &nbsp;&nbsp;&nbsp;&nbsp;element: [NodeList (just removed)]<br/>
1495
+ * }
1496
1496
  */
1497
1497
  onRemove: PropTypes.func,
1498
1498
  /** View attached event, if not it will use default. */
@@ -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,10 +1,10 @@
1
1
  import { useEffect } from 'react';
2
- import { addDays, addHours, addMinutes, addMonths, addSeconds, addYears, format, isLastDayOfMonth, isValid, lastDayOfMonth } from 'date-fns';
3
- import { enUS, vi } from 'date-fns/locale';
2
+ import { addDays, addHours, addMinutes, addMonths, addSeconds, addYears, isLastDayOfMonth, isValid, lastDayOfMonth } from 'date-fns';
4
3
  import { getGlobal } from "../../../global";
5
4
  import { capitalize } from "../../../utils";
6
5
  import { patternMap, useDateField } from "./DateField";
7
6
  import { lowerCaseDayYear } from "./utils";
7
+ import { parseDateString } from "../../../utils/getLang";
8
8
  export const useDateInputState = ({
9
9
  formatStr,
10
10
  locale,
@@ -95,9 +95,7 @@ export const useDateInputState = ({
95
95
  };
96
96
  const toControlledDateString = () => {
97
97
  if (date && isValid(date)) {
98
- return format(date, lowerCaseDayYear(formatStr), {
99
- locale: locale === 'vi' ? vi : enUS
100
- });
98
+ return parseDateString(date, lowerCaseDayYear(formatStr), locale);
101
99
  }
102
100
  // if date is not valid, return uncontrolled date string
103
101
  return toDateString();
@@ -2,8 +2,7 @@
2
2
  /** @jsx jsx */
3
3
  import { css, jsx } from '@emotion/core';
4
4
  import { Button, ButtonIcon, DateInput, HelperText, InputBase, Label, Popover, Tooltip } from "../..";
5
- import { format, isValid, parse } from 'date-fns';
6
- import { enUS, vi } from 'date-fns/locale';
5
+ import { isValid, parse } from 'date-fns';
7
6
  import { getGlobal } from "../../../global";
8
7
  import locale from "../../../locale";
9
8
  import PropTypes from 'prop-types';
@@ -14,6 +13,7 @@ import useThemeProps from "../../../theme/utils/useThemeProps";
14
13
  import { capitalizeSentenceCase, classNames, isValidDate, useControlled } from "../../../utils";
15
14
  import Calendar from "../calendar";
16
15
  import { lowerCaseDayYear } from "../date-input/utils";
16
+ import { parseDateString } from "../../../utils/getLang";
17
17
  const unique = {
18
18
  footer: 'DGN-UI-DatePicker-Footer',
19
19
  cancel: 'DGN-UI-DatePicker-cancel',
@@ -23,6 +23,10 @@ const unique = {
23
23
  const confirmText = getGlobal(['confirm']);
24
24
  const cancelText = getGlobal(['cancel']);
25
25
  const viDisplayFormat = new Map([['year', 'YYYY'], ['quarter', 'Q-YYYY'], ['month', 'MM-YYYY']]);
26
+ const zhDisplayFormat = new Map([['year', 'YYYY年'], ['quarter', 'YYYY年第Q季度'], ['month', 'YYYY年MM月']]);
27
+ const enDisplayFormat = new Map([['year', 'YYYY'], ['quarter', 'YYYY [Q]Q'],
28
+ // Exp: 2025 Q1
29
+ ['month', 'MM/YYYY']]);
26
30
  const pickerReturnFormat = new Map([['year', 'YYYY'], ['quarter', 'YYYY-Q'], ['month', 'YYYY-MM']]);
27
31
  const parseValueToDate = valueProp => {
28
32
  if (!valueProp) return null;else if (isValidDate(valueProp)) {
@@ -42,8 +46,26 @@ const parseValueToDate = valueProp => {
42
46
  return valueProp;
43
47
  }
44
48
  };
49
+ const getDateFormats = (locale, minZoom) => {
50
+ let formatMap;
51
+ switch (locale) {
52
+ case 'vi':
53
+ formatMap = viDisplayFormat;
54
+ break;
55
+ case 'zh':
56
+ formatMap = zhDisplayFormat;
57
+ break;
58
+ case 'en':
59
+ formatMap = enDisplayFormat;
60
+ break;
61
+ default:
62
+ formatMap = pickerReturnFormat; // fallback
63
+ break;
64
+ }
65
+ return formatMap.get(minZoom);
66
+ };
45
67
  const DatePicker = /*#__PURE__*/memo( /*#__PURE__*/forwardRef((inProps, reference) => {
46
- var _ref, _pickerReturnFormat$g, _ipRef$current, _ipRef$current2;
68
+ var _getDateFormats, _pickerReturnFormat$g, _ipRef$current, _ipRef$current2;
47
69
  if (!reference) reference = useRef(null);
48
70
  const theme = useTheme();
49
71
 
@@ -87,7 +109,7 @@ const DatePicker = /*#__PURE__*/memo( /*#__PURE__*/forwardRef((inProps, referenc
87
109
  ...other
88
110
  } = props;
89
111
  const dateLocale = locale.get();
90
- const displayFormat = (_ref = dateLocale === 'vi' ? viDisplayFormat.get(minZoom) : pickerReturnFormat.get(minZoom)) !== null && _ref !== void 0 ? _ref : displayFormatProp;
112
+ const displayFormat = (_getDateFormats = getDateFormats(dateLocale, minZoom)) !== null && _getDateFormats !== void 0 ? _getDateFormats : displayFormatProp;
91
113
  const returnFormat = (_pickerReturnFormat$g = pickerReturnFormat.get(minZoom)) !== null && _pickerReturnFormat$g !== void 0 ? _pickerReturnFormat$g : returnFormatProp;
92
114
  const placeholder = placeholderProp !== null && placeholderProp !== void 0 ? placeholderProp : displayFormat;
93
115
  const [value, setValue] = useControlled(parseValueToDate(valueProp), parseValueToDate(defaultValue));
@@ -112,9 +134,7 @@ const DatePicker = /*#__PURE__*/memo( /*#__PURE__*/forwardRef((inProps, referenc
112
134
  };
113
135
  const formatValue = (value, formatStr) => {
114
136
  // return moment(value).format(format, utc = false);
115
- return format(value, lowerCaseDayYear(formatStr), {
116
- locale: dateLocale === 'vi' ? vi : enUS
117
- });
137
+ return parseDateString(value, lowerCaseDayYear(formatStr), dateLocale);
118
138
  };
119
139
  const onChangeValue = e => {
120
140
  const vl = (e === null || e === void 0 ? void 0 : e.value) || e;
@@ -262,8 +262,8 @@ const DateRangePicker = /*#__PURE__*/memo( /*#__PURE__*/forwardRef((inProps, ref
262
262
  tableData = [],
263
263
  weekDateFirst = getDateOfWeek(firstDay),
264
264
  weekDateLast = getDateOfWeek(lastDay);
265
- /**
266
- * days of previous month
265
+ /**
266
+ * days of previous month
267
267
  */
268
268
  for (let i = weekDateFirst; i > 0; i--) {
269
269
  const day = Date.parse(new Date(time.getFullYear(), time.getMonth(), 1));
@@ -275,8 +275,8 @@ const DateRangePicker = /*#__PURE__*/memo( /*#__PURE__*/forwardRef((inProps, ref
275
275
  className: unique.day.day
276
276
  })));
277
277
  }
278
- /**
279
- * days of current month
278
+ /**
279
+ * days of current month
280
280
  */
281
281
  for (let i = 0; i < lastDate; i++) {
282
282
  const day = new Date(time.getFullYear(), time.getMonth(), i + 1);
@@ -302,8 +302,8 @@ const DateRangePicker = /*#__PURE__*/memo( /*#__PURE__*/forwardRef((inProps, ref
302
302
  type: 'h6'
303
303
  }, i + 1)));
304
304
  }
305
- /**
306
- * days of next month
305
+ /**
306
+ * days of next month
307
307
  */
308
308
  for (let i = 0; i < 13 - weekDateLast; i++) {
309
309
  const day = Date.parse(new Date(time.getFullYear(), time.getMonth() + 1, 0));
@@ -294,6 +294,7 @@ const Dropdown = /*#__PURE__*/memo( /*#__PURE__*/forwardRef((inProps, reference)
294
294
  * @return {boolean}
295
295
  */
296
296
  const handleRenderBySearch = (text = '') => {
297
+ if (text === null || text === undefined) text = '';
297
298
  if (typeof text !== 'string') text = text.toString();
298
299
  if (!txtSearch) return true;
299
300
  if (searchMode === 'startswith') {
@@ -436,6 +437,7 @@ const Dropdown = /*#__PURE__*/memo( /*#__PURE__*/forwardRef((inProps, reference)
436
437
  }, items !== null && items !== void 0 && items.length ? items : EmptyDataText);
437
438
  };
438
439
  const mapTreeView = () => {
440
+ console.log('here');
439
441
  return jsx("div", {
440
442
  css: _DropdownListCSS,
441
443
  ref: dropdownListRef,
@@ -459,7 +461,8 @@ const Dropdown = /*#__PURE__*/memo( /*#__PURE__*/forwardRef((inProps, reference)
459
461
  parentID: treeViewParentID,
460
462
  value: typeof currentValue[unique] === 'string' ? [currentValue[unique]] : currentValue[unique],
461
463
  onChange: (e, value) => onChangeValue(e, '', multiple ? value : e.value),
462
- renderItem: renderItem
464
+ renderItem: renderItem,
465
+ isInDropdown: true
463
466
  }) : EmptyDataText);
464
467
  };
465
468
 
@@ -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;
@@ -10,6 +10,7 @@ import { forwardRef, memo, useEffect, useImperativeHandle, useRef } from 'react'
10
10
  import { displayBlock, positionRelative } from "../../../styles/general";
11
11
  import useThemeProps from "../../../theme/utils/useThemeProps";
12
12
  import { onValidate } from "../../../utils";
13
+ import { getThousandSeparatorByCountry } from "../../../utils/getLang";
13
14
  const num2WordsVi = function () {
14
15
  let t = ['không', 'một', 'hai', 'ba', 'bốn', 'năm', 'sáu', 'bảy', 'tám', 'chín'],
15
16
  r = function (r, n) {
@@ -72,6 +73,61 @@ const num2WordsEn = n => {
72
73
  if (n === '0') return 'zero';
73
74
  return comp(chunk(3))(reverse)(arr(n)).map(makeGroup).map(thousand).filter(comp(not)(isEmpty)).reverse().join(' ');
74
75
  };
76
+ const num2WordsZh = (() => {
77
+ const t = ['零', '一', '二', '三', '四', '五', '六', '七', '八', '九'];
78
+ const units = ['', '十', '百', '千'];
79
+ const bigUnits = ['', '万', '亿', '兆'];
80
+ const readSection = num => {
81
+ let str = '';
82
+ let zero = true;
83
+ for (let i = 0; i < 4 && num > 0; i++) {
84
+ const digit = num % 10;
85
+ if (digit === 0) {
86
+ if (!zero) {
87
+ zero = true;
88
+ str = t[0] + str;
89
+ }
90
+ } else {
91
+ zero = false;
92
+ str = t[digit] + units[i] + str;
93
+ }
94
+ num = Math.floor(num / 10);
95
+ }
96
+ return str;
97
+ };
98
+ return {
99
+ convert: num => {
100
+ if (num === 0) return t[0];
101
+ let str = '';
102
+ let unitPos = 0;
103
+ let needZero = false;
104
+ while (num > 0) {
105
+ const section = num % 10000;
106
+ if (section === 0) {
107
+ if (needZero) {
108
+ str = t[0] + str;
109
+ needZero = false;
110
+ }
111
+ } else {
112
+ const sectionStr = readSection(section) + bigUnits[unitPos];
113
+ str = sectionStr + str;
114
+ needZero = true;
115
+ }
116
+ num = Math.floor(num / 10000);
117
+ unitPos++;
118
+ }
119
+
120
+ // Special cases
121
+ str = str.replace(/^一十/, '十'); // "一十X" => "十X"
122
+ return str;
123
+ }
124
+ };
125
+ })();
126
+ const converters = {
127
+ vi: num2WordsVi,
128
+ en: num2WordsEn,
129
+ zh: num2WordsZh
130
+ };
75
131
  const MoneyInput = /*#__PURE__*/memo( /*#__PURE__*/forwardRef((inProps, reference) => {
76
132
  if (!reference) reference = useRef(null);
77
133
 
@@ -126,7 +182,7 @@ const MoneyInput = /*#__PURE__*/memo( /*#__PURE__*/forwardRef((inProps, referenc
126
182
  isPaste: false,
127
183
  clipboardText: ''
128
184
  });
129
- const separatorSymbol = typeof thousandSeparator === 'string' ? thousandSeparator : locale.get() === 'vi' ? '.' : ',';
185
+ const separatorSymbol = typeof thousandSeparator === 'string' ? thousandSeparator : getThousandSeparatorByCountry(locale.get());
130
186
  const decimalSymbol = separatorSymbol === '.' ? ',' : '.';
131
187
  const thousandSeparatorPattern = new RegExp(`[0-9]|Backspace|Delete|Arrow|Home|End|Tab${decimalDigit === 0 ? '' : '|\\' + decimalSymbol}${disabledNegative ? '' : '|-'}`);
132
188
  const isError = !!error && !value && value !== 0;
@@ -350,7 +406,9 @@ const MoneyInput = /*#__PURE__*/memo( /*#__PURE__*/forwardRef((inProps, referenc
350
406
  if (convertToWords && !decimalDigit && (disabled || readOnly)) {
351
407
  let valueConverted = getGlobal('helperInvalid');
352
408
  if (Number.isInteger(number)) {
353
- valueConverted = locale.get() === 'vi' ? num2WordsVi.convert(number) : num2WordsEn(number);
409
+ const currentLocale = locale.get();
410
+ const converter = converters[currentLocale] || num2WordsVi; // fallback VN
411
+ valueConverted = converter.convert(number);
354
412
  }
355
413
  inputRef.current.value = parseValueWithFix(valueConverted);
356
414
  } else {
@@ -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({});
@@ -533,22 +533,22 @@ PagingInfo.propTypes = {
533
533
  onChangePage: PropTypes.func,
534
534
  /** Callback fired when quantity on per page changed. */
535
535
  onChangePerPage: PropTypes.func,
536
- /**
537
- * Callback fired when page number is changing.
538
- *
539
- * * prevPage: Page before changed
540
- * * newPage: Page after changed
541
- * * cancel(value): Function cancel change page
542
- * * @param {value} - bool
536
+ /**
537
+ * Callback fired when page number is changing.
538
+ *
539
+ * * prevPage: Page before changed
540
+ * * newPage: Page after changed
541
+ * * cancel(value): Function cancel change page
542
+ * * @param {value} - bool
543
543
  */
544
544
  onChangingPage: PropTypes.func,
545
- /**
546
- * Callback fired when quantity on item per page is changing.
547
- *
548
- * * prevPerPage: Items per page before changed
549
- * * newPerPage: Items per page after changed
550
- * * cancel(value): Function cancel change items per page
551
- * * @param {value} - bool
545
+ /**
546
+ * Callback fired when quantity on item per page is changing.
547
+ *
548
+ * * prevPerPage: Items per page before changed
549
+ * * newPerPage: Items per page after changed
550
+ * * cancel(value): Function cancel change items per page
551
+ * * @param {value} - bool
552
552
  */
553
553
  onChangingPerPage: PropTypes.func,
554
554
  /** Style inline of component. */
@@ -557,26 +557,26 @@ PagingInfo.propTypes = {
557
557
  totalItems: PropTypes.number,
558
558
  /** Compact type for mobile. */
559
559
  typeShort: PropTypes.bool
560
- /**
561
- * ref methods (ref.current.instance.*method*)
562
- *
563
- * * onChangePage(page): Change page number
564
- * * @param {page} - number
565
- * * onChangePerPage(per): Change quantity on per page
566
- * * @param {per} - number
567
- * * setTotalItems(items): Set total items
568
- * * @param {items} - number
569
- *
570
- * * option(): Gets all UI component properties
571
- * * Returns value - object
572
- * * option(optionName): Gets the value of a single property
573
- * * @param {optionName} - string
574
- * * Returns value - any
575
- * * option(optionName, optionValue): Updates the value of a single property
576
- * * @param {optionName} - string
577
- * * @param {optionValue} - any
578
- * * option(options): Updates the values of several properties
579
- * * @param {options} - object
560
+ /**
561
+ * ref methods (ref.current.instance.*method*)
562
+ *
563
+ * * onChangePage(page): Change page number
564
+ * * @param {page} - number
565
+ * * onChangePerPage(per): Change quantity on per page
566
+ * * @param {per} - number
567
+ * * setTotalItems(items): Set total items
568
+ * * @param {items} - number
569
+ *
570
+ * * option(): Gets all UI component properties
571
+ * * Returns value - object
572
+ * * option(optionName): Gets the value of a single property
573
+ * * @param {optionName} - string
574
+ * * Returns value - any
575
+ * * option(optionName, optionValue): Updates the value of a single property
576
+ * * @param {optionName} - string
577
+ * * @param {optionValue} - any
578
+ * * option(options): Updates the values of several properties
579
+ * * @param {options} - object
580
580
  */
581
581
  };
582
582
  export { PagingInfo };