diginet-core-ui 1.4.53 → 1.4.54-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.
- package/assets/images/menu/dhr/MHRM09N1401.svg +14 -0
- package/assets/images/menu/dhr/MHRM09N1402.svg +15 -0
- package/components/form-control/attachment/index.js +21 -21
- package/components/form-control/calendar/function.js +1 -1
- package/components/form-control/calendar/index.js +1 -1
- package/components/form-control/date-input/useDateInputState.js +3 -5
- package/components/form-control/date-picker/index.js +27 -7
- package/components/form-control/date-range-picker/index.js +6 -6
- package/components/form-control/dropdown/index.js +4 -1
- package/components/form-control/dropdown-box/index.js +63 -21
- package/components/form-control/money-input/index.js +60 -2
- package/components/form-control/number-input/index2.js +4 -1
- package/components/paging/page-info.js +34 -34
- package/components/tree-view/index.js +81 -45
- package/global/index.js +80 -0
- package/icons/basic.js +48 -0
- package/locale/index.js +1 -1
- package/package.json +78 -44
- package/readme.md +7 -0
- package/theme/settings.js +4 -3
- package/utils/getLang.js +69 -0
- package/utils/index.js +1 -0
|
@@ -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
|
-
* "AttachmentID": "ATT2U8O7YPTF1KSNCW3X",<br />
|
|
1448
|
-
* "URL": "https://apricot.diginet.com.vn/cdn-dev/file/demo.jpg",<br />
|
|
1449
|
-
* "FileName": "8a07bee1eeff17a14eee.jpg",<br />
|
|
1450
|
-
* "FileSize": 248837,<br />
|
|
1451
|
-
* "KeyID": "W39OAD3YGLCWAQKV1D6PGEKNW4RLGVTZTUWLYEVFQ2QG8AOCXW",<br />
|
|
1452
|
-
* "CreateUserID": "LEMONADMIN",<br />
|
|
1453
|
-
* "CreateDate": "2020-08-24T11:54:04.307Z",<br />
|
|
1454
|
-
* "UserName": "Quản trị hệ thống"<br />
|
|
1455
|
-
* }, ...]
|
|
1445
|
+
/** List attachment:<br />
|
|
1446
|
+
* [{<br />
|
|
1447
|
+
* "AttachmentID": "ATT2U8O7YPTF1KSNCW3X",<br />
|
|
1448
|
+
* "URL": "https://apricot.diginet.com.vn/cdn-dev/file/demo.jpg",<br />
|
|
1449
|
+
* "FileName": "8a07bee1eeff17a14eee.jpg",<br />
|
|
1450
|
+
* "FileSize": 248837,<br />
|
|
1451
|
+
* "KeyID": "W39OAD3YGLCWAQKV1D6PGEKNW4RLGVTZTUWLYEVFQ2QG8AOCXW",<br />
|
|
1452
|
+
* "CreateUserID": "LEMONADMIN",<br />
|
|
1453
|
+
* "CreateDate": "2020-08-24T11:54:04.307Z",<br />
|
|
1454
|
+
* "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
|
-
* attached: [Files] (insist old and all new files )<br/>
|
|
1491
|
-
* allNewAttached: [Files]<br/>
|
|
1492
|
-
* oldAttached: [Files]<br/>
|
|
1493
|
-
* removedAttached: [Files]<br/>
|
|
1494
|
-
* element: [NodeList (just removed)]<br/>
|
|
1495
|
-
* }
|
|
1486
|
+
/**
|
|
1487
|
+
* event when removed file(s)
|
|
1488
|
+
*
|
|
1489
|
+
* return data: {<br/>
|
|
1490
|
+
* attached: [Files] (insist old and all new files )<br/>
|
|
1491
|
+
* allNewAttached: [Files]<br/>
|
|
1492
|
+
* oldAttached: [Files]<br/>
|
|
1493
|
+
* removedAttached: [Files]<br/>
|
|
1494
|
+
* 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: ['
|
|
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,
|
|
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
|
|
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 {
|
|
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
|
|
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 = (
|
|
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
|
|
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
|
-
|
|
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()
|
|
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
|
-
|
|
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 };
|
|
@@ -54,6 +54,7 @@ const TreeView = /*#__PURE__*/memo( /*#__PURE__*/forwardRef((inProps, reference)
|
|
|
54
54
|
showSelectedItems,
|
|
55
55
|
value: valueProp,
|
|
56
56
|
valueExpr,
|
|
57
|
+
isInDropdown: isInDropDownProps,
|
|
57
58
|
...other
|
|
58
59
|
} = props;
|
|
59
60
|
let searchDelayTime = searchDelayTimeProp;
|
|
@@ -69,7 +70,10 @@ const TreeView = /*#__PURE__*/memo( /*#__PURE__*/forwardRef((inProps, reference)
|
|
|
69
70
|
allowNumber: false,
|
|
70
71
|
allowSymbol: false
|
|
71
72
|
}));
|
|
72
|
-
const
|
|
73
|
+
const [isChanged, setIsChanged] = useState(false);
|
|
74
|
+
const [isChecked, setIsChecked] = useState(false);
|
|
75
|
+
const [isInDropdown, setIsInDropdown] = useState(isInDropDownProps);
|
|
76
|
+
const _TreeViewRootCSS = TreeViewRootCSS(theme, isInDropdown);
|
|
73
77
|
const determinateCheckbox = (input, determinate) => {
|
|
74
78
|
if (multipleValueMode === 'multiple' || disabledRelevantValue) {
|
|
75
79
|
input.classList[determinate ? 'add' : 'remove']('determinate');
|
|
@@ -212,7 +216,7 @@ const TreeView = /*#__PURE__*/memo( /*#__PURE__*/forwardRef((inProps, reference)
|
|
|
212
216
|
el.firstChild.firstChild.lastChild.firstChild.firstChild.firstChild.classList[isChecked ? 'add' : 'remove']('disabled');
|
|
213
217
|
el.firstChild.firstChild.lastChild.firstChild.firstChild.firstChild.disabled = isChecked;
|
|
214
218
|
Array.from(el.childNodes).forEach(e => {
|
|
215
|
-
e.classList[isChecked ? 'add' : 'remove']('
|
|
219
|
+
e.classList[isChecked ? 'add' : 'remove']('disabled');
|
|
216
220
|
});
|
|
217
221
|
} else {
|
|
218
222
|
el.firstChild.firstChild.firstChild.firstChild.disabled = isChecked;
|
|
@@ -233,12 +237,14 @@ const TreeView = /*#__PURE__*/memo( /*#__PURE__*/forwardRef((inProps, reference)
|
|
|
233
237
|
const checkbox = node.firstChild.firstChild.lastChild.firstChild.firstChild.firstChild;
|
|
234
238
|
if (checkbox) {
|
|
235
239
|
var _node$querySelectorAl;
|
|
236
|
-
// Trường hợp phải set về false để xét các input đã check không bao gồm node này
|
|
237
|
-
checkbox.firstChild.checked = isChecked;
|
|
238
240
|
const mustDisabled = !!((_node$querySelectorAl = node.querySelectorAll('input:checked')) !== null && _node$querySelectorAl !== void 0 && _node$querySelectorAl.length);
|
|
239
|
-
//
|
|
240
|
-
checkbox.firstChild.checked =
|
|
241
|
+
// // Trường hợp phải set về false để xét các input đã check không bao gồm node này
|
|
242
|
+
checkbox.firstChild.checked = isChecked;
|
|
241
243
|
determinateCheckbox(checkbox.firstChild, !mustDisabled);
|
|
244
|
+
setTimeout(() => {
|
|
245
|
+
// Nếu có ít nhất một input con được check thì phải checked cho input này
|
|
246
|
+
checkbox.firstChild.checked = mustDisabled;
|
|
247
|
+
}, 200);
|
|
242
248
|
node.classList[mustDisabled || isChecked ? 'add' : 'remove']('disabled');
|
|
243
249
|
checkbox.classList[mustDisabled || isChecked ? 'add' : 'remove']('disabled');
|
|
244
250
|
Array.from(node.childNodes).forEach(e => {
|
|
@@ -347,6 +353,8 @@ const TreeView = /*#__PURE__*/memo( /*#__PURE__*/forwardRef((inProps, reference)
|
|
|
347
353
|
} else {
|
|
348
354
|
currentValue[unique][value] = checked;
|
|
349
355
|
if (disabledRelevantValue) {
|
|
356
|
+
setIsChanged(!isChanged);
|
|
357
|
+
setIsChecked(checked);
|
|
350
358
|
// Disabled/Enabled parent and children node
|
|
351
359
|
if (!currentTarget.classList.contains('non-child')) {
|
|
352
360
|
handleDisabledChildren(currentTarget.nextElementSibling, checked);
|
|
@@ -619,7 +627,7 @@ const TreeView = /*#__PURE__*/memo( /*#__PURE__*/forwardRef((inProps, reference)
|
|
|
619
627
|
return jsx("div", {
|
|
620
628
|
className: classNames('TreeView-Item', 'non-child', focusClass),
|
|
621
629
|
style: {
|
|
622
|
-
paddingLeft: 34 + 16 * level
|
|
630
|
+
paddingLeft: multipleValueMode === 'single' && !parentID ? 16 : 34 + 16 * level
|
|
623
631
|
},
|
|
624
632
|
onClick: multiple || selectBox || onChange ? e => onClickHandler(e, data) : undefined,
|
|
625
633
|
key: index,
|
|
@@ -634,6 +642,14 @@ const TreeView = /*#__PURE__*/memo( /*#__PURE__*/forwardRef((inProps, reference)
|
|
|
634
642
|
})) : null, renderContent(data, keyArr, index));
|
|
635
643
|
};
|
|
636
644
|
useEffect(() => {
|
|
645
|
+
if (isInDropdown === false) {
|
|
646
|
+
var _Array$from;
|
|
647
|
+
const treeViewNode = (_Array$from = Array.from(document.getElementsByClassName('DGN-UI-TreeView'))) === null || _Array$from === void 0 ? void 0 : _Array$from[0];
|
|
648
|
+
const treeViewParentNode = treeViewNode === null || treeViewNode === void 0 ? void 0 : treeViewNode.parentNode;
|
|
649
|
+
if (treeViewParentNode && treeViewParentNode !== null && treeViewParentNode !== void 0 && treeViewParentNode.className.includes('DGN-Dropdown-List')) {
|
|
650
|
+
setIsInDropdown(true);
|
|
651
|
+
}
|
|
652
|
+
}
|
|
637
653
|
currentValue[unique] = {};
|
|
638
654
|
return () => {
|
|
639
655
|
currentValue[unique] = null;
|
|
@@ -687,17 +703,32 @@ const TreeView = /*#__PURE__*/memo( /*#__PURE__*/forwardRef((inProps, reference)
|
|
|
687
703
|
}
|
|
688
704
|
};
|
|
689
705
|
} else if (disabledRelevantValue) {
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
if (
|
|
693
|
-
|
|
706
|
+
setTimeout(() => {
|
|
707
|
+
Array.from(ref.current.querySelectorAll('.TreeView-Item.non-child, .DGN-UI-Accordion')).forEach(el => {
|
|
708
|
+
if (el.firstChild.querySelector('input').checked) {
|
|
709
|
+
if (!el.classList.contains('non-child')) {
|
|
710
|
+
handleDisabledChildren(el, true);
|
|
711
|
+
}
|
|
712
|
+
handleDisabledParent(el.parentNode, true);
|
|
694
713
|
}
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
});
|
|
714
|
+
});
|
|
715
|
+
}, 200);
|
|
698
716
|
}
|
|
699
717
|
}
|
|
700
718
|
}, []);
|
|
719
|
+
useEffect(() => {
|
|
720
|
+
if (value && multiple) {
|
|
721
|
+
if (disabledRelevantValue) {
|
|
722
|
+
setTimeout(() => {
|
|
723
|
+
Array.from(ref.current.querySelectorAll('.TreeView-Item.non-child, .DGN-UI-Accordion')).forEach(el => {
|
|
724
|
+
if (el.firstChild.querySelector('input').checked) {
|
|
725
|
+
handleDisabledParent(el.parentNode, isChecked);
|
|
726
|
+
}
|
|
727
|
+
});
|
|
728
|
+
});
|
|
729
|
+
}
|
|
730
|
+
}
|
|
731
|
+
}, [isChanged, isChecked]);
|
|
701
732
|
useEffect(() => {
|
|
702
733
|
if (selectAllRef.current) {
|
|
703
734
|
checkedSelectAllCheckbox();
|
|
@@ -793,7 +824,7 @@ const TreeView = /*#__PURE__*/memo( /*#__PURE__*/forwardRef((inProps, reference)
|
|
|
793
824
|
const TreeViewRootCSS = ({
|
|
794
825
|
colors,
|
|
795
826
|
spacing
|
|
796
|
-
}) => css`
|
|
827
|
+
}, isInDD) => css`
|
|
797
828
|
${displayBlock};
|
|
798
829
|
${positionRelative};
|
|
799
830
|
.DGN-UI-Accordion {
|
|
@@ -806,6 +837,12 @@ const TreeViewRootCSS = ({
|
|
|
806
837
|
&.focus {
|
|
807
838
|
${bgColor(getProp(colors, 'fill/focus'))};
|
|
808
839
|
}
|
|
840
|
+
&.disabled {
|
|
841
|
+
.TreeView-Item {
|
|
842
|
+
${textColor(getProp(colors, 'system/disabled'))};
|
|
843
|
+
}
|
|
844
|
+
${bgColor(getProp(colors, 'system/white'))};
|
|
845
|
+
}
|
|
809
846
|
.Accordion-Icon-Root {
|
|
810
847
|
${displayFlex};
|
|
811
848
|
${flexRow};
|
|
@@ -833,7 +870,7 @@ const TreeViewRootCSS = ({
|
|
|
833
870
|
.TreeView-Content {
|
|
834
871
|
${displayBlock};
|
|
835
872
|
${positionRelative};
|
|
836
|
-
${parseMaxHeight(240)};
|
|
873
|
+
${isInDD ? parseMaxHeight(240) : parseHeight('100%')};
|
|
837
874
|
${overflowYScroll};
|
|
838
875
|
&::-webkit-scrollbar {
|
|
839
876
|
${borderRadius(4)};
|
|
@@ -904,35 +941,34 @@ const TreeViewRootCSS = ({
|
|
|
904
941
|
}
|
|
905
942
|
}
|
|
906
943
|
`;
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
//
|
|
910
|
-
//
|
|
911
|
-
//
|
|
912
|
-
//
|
|
913
|
-
//
|
|
914
|
-
//
|
|
915
|
-
//
|
|
916
|
-
//
|
|
917
|
-
//
|
|
918
|
-
//
|
|
919
|
-
//
|
|
920
|
-
//
|
|
921
|
-
//
|
|
922
|
-
//
|
|
923
|
-
//
|
|
924
|
-
//
|
|
925
|
-
//
|
|
926
|
-
//
|
|
927
|
-
//
|
|
928
|
-
//
|
|
929
|
-
//
|
|
930
|
-
//
|
|
931
|
-
//
|
|
932
|
-
//
|
|
933
|
-
//
|
|
934
|
-
|
|
935
|
-
|
|
944
|
+
TreeView.defaultProps = {
|
|
945
|
+
isInDropdown: false
|
|
946
|
+
// allowSearch: false,
|
|
947
|
+
// autoExpandToResult: true,
|
|
948
|
+
// className: '',
|
|
949
|
+
// dataSource: [],
|
|
950
|
+
// disabled: false,
|
|
951
|
+
// disabledBoldResult: false,
|
|
952
|
+
// disabledRelevantValue: false,
|
|
953
|
+
// displayExpr: 'name',
|
|
954
|
+
// expand: false,
|
|
955
|
+
// expandIcon: 'ArrowDown',
|
|
956
|
+
// id: 'id',
|
|
957
|
+
// multiple: false,
|
|
958
|
+
// multipleValueMode: 'multiple',
|
|
959
|
+
// parentID: 'parentID',
|
|
960
|
+
// renderAsyncFromLevel: 2,
|
|
961
|
+
// renderAsyncWithLength: 200,
|
|
962
|
+
// searchMode: 'contains',
|
|
963
|
+
// searchProps: {},
|
|
964
|
+
// selectAll: false,
|
|
965
|
+
// selectAllLabel: getGlobal('selectAll'),
|
|
966
|
+
// selectBox: false,
|
|
967
|
+
// showChildrenOfResult: false,
|
|
968
|
+
// showSelectedItems: false,
|
|
969
|
+
// value: [],
|
|
970
|
+
// valueExpr: '',
|
|
971
|
+
};
|
|
936
972
|
TreeView.propTypes = {
|
|
937
973
|
/** If `true`, display input box search. */
|
|
938
974
|
allowSearch: PropTypes.bool,
|
package/global/index.js
CHANGED
|
@@ -161,6 +161,86 @@ const globalObject = {
|
|
|
161
161
|
inputPlaceholder: 'Type something',
|
|
162
162
|
dropdownPlaceholder: 'Select'
|
|
163
163
|
},
|
|
164
|
+
zh: {
|
|
165
|
+
agree: '同意',
|
|
166
|
+
cancel: '取消',
|
|
167
|
+
close: '关闭',
|
|
168
|
+
confirm: '确认',
|
|
169
|
+
error: '错误',
|
|
170
|
+
unknownError: '未知错误',
|
|
171
|
+
no: '否',
|
|
172
|
+
noDataText: '无数据',
|
|
173
|
+
notify: '通知',
|
|
174
|
+
ok: '确定',
|
|
175
|
+
showLess: '收起',
|
|
176
|
+
showMore: '展开',
|
|
177
|
+
yes: '是',
|
|
178
|
+
warning: '警告',
|
|
179
|
+
// attachment
|
|
180
|
+
dropFileHere: '将文件拖到此处',
|
|
181
|
+
deleteNotifyText: '您确定要删除此附件吗?',
|
|
182
|
+
attachText: '附件',
|
|
183
|
+
noFileText: '无附件',
|
|
184
|
+
byName: '按名称',
|
|
185
|
+
byType: '按类型',
|
|
186
|
+
bySize: '按大小',
|
|
187
|
+
byDate: '按日期',
|
|
188
|
+
byOwner: '按所有者',
|
|
189
|
+
errorDefault: {
|
|
190
|
+
maxFile: ' 超过允许的数量!',
|
|
191
|
+
maxSize: ' 文件过大!',
|
|
192
|
+
fileType: ' 文件格式不正确!',
|
|
193
|
+
existingFile: ' 已经添加!'
|
|
194
|
+
},
|
|
195
|
+
// Paging
|
|
196
|
+
lineNumber: '每页条数',
|
|
197
|
+
total: '总计',
|
|
198
|
+
// Transfer
|
|
199
|
+
choices: '可选',
|
|
200
|
+
chosen: '已选',
|
|
201
|
+
selected: '已选择',
|
|
202
|
+
// Date Picker
|
|
203
|
+
helperInvalid: '无效',
|
|
204
|
+
helperValid: '有效',
|
|
205
|
+
label: '时间',
|
|
206
|
+
weekdaysLong: ['周一', '周二', '周三', '周四', '周五', '周六', '周日'],
|
|
207
|
+
weekdaysShort: ['一', '二', '三', '四', '五', '六', '日'],
|
|
208
|
+
// Daterange Picker
|
|
209
|
+
today: '今天',
|
|
210
|
+
yesterday: '昨天',
|
|
211
|
+
thisWeek: '本周',
|
|
212
|
+
thisMonth: '本月',
|
|
213
|
+
// Time Picker
|
|
214
|
+
months: {
|
|
215
|
+
full: ['一月', '二月', '三月', '四月', '五月', '六月', '七月', '八月', '九月', '十月', '十一月', '十二月'],
|
|
216
|
+
notFull: ['1月', '2月', '3月', '4月', '5月', '6月', '7月', '8月', '9月', '10月', '11月', '12月']
|
|
217
|
+
},
|
|
218
|
+
days: {
|
|
219
|
+
full: ['星期日', '星期一', '星期二', '星期三', '星期四', '星期五', '星期六'],
|
|
220
|
+
notFull: ['日', '一', '二', '三', '四', '五', '六']
|
|
221
|
+
},
|
|
222
|
+
night: '夜',
|
|
223
|
+
day: '日',
|
|
224
|
+
month: '月',
|
|
225
|
+
year: '年',
|
|
226
|
+
save: '保存',
|
|
227
|
+
now: '现在',
|
|
228
|
+
// Localize
|
|
229
|
+
selectAll: '全选',
|
|
230
|
+
thisFieldIsRequired: '此字段为必填项',
|
|
231
|
+
validate: {
|
|
232
|
+
isEmail: '邮箱无效',
|
|
233
|
+
isNotEmptyString: '不能为空',
|
|
234
|
+
isNotEmptyObject: '必须包含至少一个属性',
|
|
235
|
+
isNotEmptyArray: '必须包含至少一个元素',
|
|
236
|
+
invalidInput: '输入值不正确',
|
|
237
|
+
max: '超过允许的最大值',
|
|
238
|
+
min: '未达到允许的最小值',
|
|
239
|
+
required: '此字段为必填项'
|
|
240
|
+
},
|
|
241
|
+
inputPlaceholder: '请输入内容',
|
|
242
|
+
dropdownPlaceholder: '请选择'
|
|
243
|
+
},
|
|
164
244
|
//Global variable
|
|
165
245
|
delayOnInput: 500,
|
|
166
246
|
maxSizeUpload: Infinity
|
package/icons/basic.js
CHANGED
|
@@ -1454,6 +1454,30 @@ export const Category = /*#__PURE__*/memo(({
|
|
|
1454
1454
|
fill: fillColor(color)
|
|
1455
1455
|
}));
|
|
1456
1456
|
});
|
|
1457
|
+
export const Camera = /*#__PURE__*/memo(({
|
|
1458
|
+
width,
|
|
1459
|
+
height,
|
|
1460
|
+
color = 'system/rest',
|
|
1461
|
+
viewBox = false
|
|
1462
|
+
}) => {
|
|
1463
|
+
return viewBox ? /*#__PURE__*/React.createElement("svg", {
|
|
1464
|
+
width: width || 24,
|
|
1465
|
+
height: height || 24,
|
|
1466
|
+
viewBox: "0 0 24 24",
|
|
1467
|
+
fill: "none"
|
|
1468
|
+
}, /*#__PURE__*/React.createElement("path", {
|
|
1469
|
+
d: "M16.8301 4H20C21.1 4 22 4.9 22 6V18C22 19.1 21.1 20 20 20H4C2.9 20 2 19.1 2 18V6C2 4.9 2.9 4 4 4H7.16992L9 2H15L16.8301 4ZM12 7C9.24 7 7 9.24 7 12C7 14.76 9.24 17 12 17C14.76 17 17 14.76 17 12C17 9.24 14.76 7 12 7ZM12 9C13.6569 9 15 10.3431 15 12C15 13.6569 13.6569 15 12 15C10.3431 15 9 13.6569 9 12C9 10.3431 10.3431 9 12 9Z",
|
|
1470
|
+
fill: fillColor(color)
|
|
1471
|
+
})) : /*#__PURE__*/React.createElement("svg", {
|
|
1472
|
+
width: width || 20,
|
|
1473
|
+
height: height || 18,
|
|
1474
|
+
viewBox: "0 0 20 18",
|
|
1475
|
+
fill: "none"
|
|
1476
|
+
}, /*#__PURE__*/React.createElement("path", {
|
|
1477
|
+
d: "M14.8301 2H18C19.1 2 20 2.9 20 4V16C20 17.1 19.1 18 18 18H2C0.9 18 0 17.1 0 16V4C0 2.9 0.9 2 2 2H5.16992L7 0H13L14.8301 2ZM10 5C7.24 5 5 7.24 5 10C5 12.76 7.24 15 10 15C12.76 15 15 12.76 15 10C15 7.24 12.76 5 10 5ZM10 7C11.6569 7 13 8.34315 13 10C13 11.6569 11.6569 13 10 13C8.34315 13 7 11.6569 7 10C7 8.34315 8.34315 7 10 7Z",
|
|
1478
|
+
fill: fillColor(color)
|
|
1479
|
+
}));
|
|
1480
|
+
});
|
|
1457
1481
|
export const CenterFocus = /*#__PURE__*/memo(({
|
|
1458
1482
|
width,
|
|
1459
1483
|
height,
|
|
@@ -7355,6 +7379,30 @@ export const Bank = /*#__PURE__*/memo(({
|
|
|
7355
7379
|
fill: fillColor(color)
|
|
7356
7380
|
}));
|
|
7357
7381
|
});
|
|
7382
|
+
export const Book = /*#__PURE__*/memo(({
|
|
7383
|
+
width,
|
|
7384
|
+
height,
|
|
7385
|
+
color = 'system/rest',
|
|
7386
|
+
viewBox = false
|
|
7387
|
+
}) => {
|
|
7388
|
+
return viewBox ? /*#__PURE__*/React.createElement("svg", {
|
|
7389
|
+
width: width || 24,
|
|
7390
|
+
height: height || 24,
|
|
7391
|
+
viewBox: "0 0 24 24",
|
|
7392
|
+
fill: "none"
|
|
7393
|
+
}, /*#__PURE__*/React.createElement("path", {
|
|
7394
|
+
d: "M12.8667 17.5168C13.6667 17.1223 14.457 16.8264 15.2375 16.6293C16.018 16.4319 16.8388 16.3333 17.7 16.3333C18.3222 16.3333 18.9541 16.3833 19.5958 16.4832C20.2374 16.5833 20.8166 16.7222 21.3333 16.9V6.45C20.7723 6.18333 20.182 5.98608 19.5625 5.85825C18.943 5.73058 18.3222 5.66675 17.7 5.66675C16.8388 5.66675 15.9999 5.79175 15.1833 6.04175C14.3666 6.29175 13.5944 6.65008 12.8667 7.11675V17.5168ZM12.0332 20C11.1999 19.3667 10.2944 18.8778 9.31675 18.5333C8.33892 18.1889 7.33333 18.0167 6.3 18.0167C5.42783 18.0167 4.4945 18.1862 3.5 18.525C2.5055 18.8638 1.67217 19.2722 1 19.75V5.38325C1.71117 4.94992 2.54308 4.61108 3.49575 4.36675C4.44858 4.12225 5.38333 4 6.3 4C7.32217 4 8.318 4.13608 9.2875 4.40825C10.257 4.68058 11.1722 5.0945 12.0332 5.65C12.8833 5.0945 13.7874 4.68058 14.7458 4.40825C15.7041 4.13608 16.6888 4 17.7 4C18.6167 4 19.5514 4.125 20.5042 4.375C21.4569 4.625 22.2888 4.96108 23 5.38325V19.75C22.3445 19.2612 21.5153 18.8501 20.5125 18.5167C19.5097 18.1834 18.5722 18.0167 17.7 18.0167C16.6667 18.0167 15.6722 18.1917 14.7168 18.5417C13.7611 18.8917 12.8666 19.3778 12.0332 20ZM14 9.73325V8.36675C14.55 8.13342 15.1125 7.95842 15.6875 7.84175C16.2625 7.72508 16.8667 7.66675 17.5 7.66675C17.9333 7.66675 18.3583 7.70008 18.775 7.76675C19.1917 7.83342 19.6 7.91675 20 8.01675V9.28325C19.6 9.13325 19.1958 9.02075 18.7875 8.94575C18.3792 8.87075 17.95 8.83325 17.5 8.83325C16.8667 8.83325 16.2583 8.91242 15.675 9.07075C15.0917 9.22908 14.5333 9.44992 14 9.73325ZM14 15.2332V13.85C14.55 13.6167 15.1125 13.4444 15.6875 13.3333C16.2625 13.2222 16.8667 13.1668 17.5 13.1668C17.9333 13.1668 18.3583 13.2001 18.775 13.2668C19.1917 13.3334 19.6 13.4168 20 13.5168V14.7832C19.6 14.6333 19.1958 14.5208 18.7875 14.4458C18.3792 14.3707 17.95 14.3333 17.5 14.3333C16.8667 14.3333 16.2583 14.4082 15.675 14.5582C15.0917 14.7083 14.5333 14.9332 14 15.2332ZM14 12.4832V11.1167C14.55 10.8834 15.1125 10.7084 15.6875 10.5917C16.2625 10.4751 16.8667 10.4167 17.5 10.4167C17.9333 10.4167 18.3583 10.4501 18.775 10.5167C19.1917 10.5834 19.6 10.6667 20 10.7667V12.0332C19.6 11.8832 19.1958 11.7707 18.7875 11.6957C18.3792 11.6207 17.95 11.5832 17.5 11.5832C16.8667 11.5832 16.2583 11.6624 15.675 11.8207C15.0917 11.9791 14.5333 12.1999 14 12.4832Z",
|
|
7395
|
+
fill: fillColor(color)
|
|
7396
|
+
})) : /*#__PURE__*/React.createElement("svg", {
|
|
7397
|
+
width: width || 22,
|
|
7398
|
+
height: height || 16,
|
|
7399
|
+
viewBox: "0 0 22 16",
|
|
7400
|
+
fill: "none"
|
|
7401
|
+
}, /*#__PURE__*/React.createElement("path", {
|
|
7402
|
+
d: "M11.8667 13.5168C12.6667 13.1223 13.457 12.8264 14.2375 12.6293C15.018 12.4319 15.8388 12.3333 16.7 12.3333C17.3222 12.3333 17.9541 12.3833 18.5958 12.4832C19.2374 12.5833 19.8166 12.7222 20.3333 12.9V2.45C19.7723 2.18333 19.182 1.98608 18.5625 1.85825C17.943 1.73058 17.3222 1.66675 16.7 1.66675C15.8388 1.66675 14.9999 1.79175 14.1833 2.04175C13.3666 2.29175 12.5944 2.65008 11.8667 3.11675V13.5168ZM11.0332 16C10.1999 15.3667 9.29442 14.8778 8.31675 14.5333C7.33892 14.1889 6.33333 14.0167 5.3 14.0167C4.42783 14.0167 3.4945 14.1862 2.5 14.525C1.5055 14.8638 0.672167 15.2722 0 15.75V1.38325C0.711167 0.949917 1.54308 0.611083 2.49575 0.36675C3.44858 0.12225 4.38333 0 5.3 0C6.32217 0 7.318 0.136084 8.2875 0.40825C9.257 0.680584 10.1722 1.0945 11.0332 1.65C11.8833 1.0945 12.7874 0.680584 13.7458 0.40825C14.7041 0.136084 15.6888 0 16.7 0C17.6167 0 18.5514 0.125 19.5042 0.375C20.4569 0.625 21.2888 0.961084 22 1.38325V15.75C21.3445 15.2612 20.5153 14.8501 19.5125 14.5167C18.5097 14.1834 17.5722 14.0167 16.7 14.0167C15.6667 14.0167 14.6722 14.1917 13.7168 14.5417C12.7611 14.8917 11.8666 15.3778 11.0332 16ZM13 5.73325V4.36675C13.55 4.13342 14.1125 3.95842 14.6875 3.84175C15.2625 3.72508 15.8667 3.66675 16.5 3.66675C16.9333 3.66675 17.3583 3.70008 17.775 3.76675C18.1917 3.83342 18.6 3.91675 19 4.01675V5.28325C18.6 5.13325 18.1958 5.02075 17.7875 4.94575C17.3792 4.87075 16.95 4.83325 16.5 4.83325C15.8667 4.83325 15.2583 4.91242 14.675 5.07075C14.0917 5.22908 13.5333 5.44992 13 5.73325ZM13 11.2332V9.85C13.55 9.61667 14.1125 9.44442 14.6875 9.33325C15.2625 9.22225 15.8667 9.16675 16.5 9.16675C16.9333 9.16675 17.3583 9.20008 17.775 9.26675C18.1917 9.33342 18.6 9.41675 19 9.51675V10.7832C18.6 10.6333 18.1958 10.5208 17.7875 10.4458C17.3792 10.3707 16.95 10.3333 16.5 10.3333C15.8667 10.3333 15.2583 10.4082 14.675 10.5582C14.0917 10.7083 13.5333 10.9332 13 11.2332ZM13 8.48325V7.11675C13.55 6.88342 14.1125 6.70842 14.6875 6.59175C15.2625 6.47508 15.8667 6.41675 16.5 6.41675C16.9333 6.41675 17.3583 6.45008 17.775 6.51675C18.1917 6.58342 18.6 6.66675 19 6.76675V8.03325C18.6 7.88325 18.1958 7.77075 17.7875 7.69575C17.3792 7.62075 16.95 7.58325 16.5 7.58325C15.8667 7.58325 15.2583 7.66242 14.675 7.82075C14.0917 7.97908 13.5333 8.19992 13 8.48325Z",
|
|
7403
|
+
fill: fillColor(color)
|
|
7404
|
+
}));
|
|
7405
|
+
});
|
|
7358
7406
|
export const Bookmark = /*#__PURE__*/memo(({
|
|
7359
7407
|
width,
|
|
7360
7408
|
height,
|
package/locale/index.js
CHANGED
package/package.json
CHANGED
|
@@ -1,44 +1,78 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "diginet-core-ui",
|
|
3
|
-
"version": "1.4.
|
|
4
|
-
"description": "
|
|
5
|
-
"
|
|
6
|
-
"
|
|
7
|
-
"scripts": {
|
|
8
|
-
"start
|
|
9
|
-
"start": "
|
|
10
|
-
"build": "
|
|
11
|
-
"
|
|
12
|
-
"
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
"
|
|
16
|
-
"
|
|
17
|
-
"
|
|
18
|
-
"
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
"
|
|
22
|
-
"
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
"
|
|
26
|
-
"
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "diginet-core-ui",
|
|
3
|
+
"version": "1.4.54-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.54
|
|
46
|
+
- \[Added\]: Icon – Add Icon Camera
|
|
47
|
+
- \[Fixed\]: Treeview - Fix bug Treeview keeps the search bar visible while scrolling
|
|
48
|
+
- \[Fixed\]: Dropdown – Fix Dropdown treeview size
|
|
49
|
+
- \[Added\]: Paging, TextInput, Label, Dropdown,... – Update Chinese language
|
|
50
|
+
|
|
51
|
+
|
|
45
52
|
## 1.4.53
|
|
46
53
|
- \[Added\]: Icon – Add IconMenu MHRP09N0036, MHRP09N0037
|
|
47
54
|
- \[Added\]: Icon – Add IconMenu MHRP25N0009
|
package/theme/settings.js
CHANGED
|
@@ -3,6 +3,7 @@ import { font } from "../styles/font";
|
|
|
3
3
|
import { typography as typographies } from "../styles/typography";
|
|
4
4
|
import createTheme from "./createTheme";
|
|
5
5
|
import locale from "../locale";
|
|
6
|
+
import { getFormatDateByCountry, getDecimalSymbolByCountry } from "../utils/getLang";
|
|
6
7
|
// import { getGlobal } from 'global';
|
|
7
8
|
const {
|
|
8
9
|
fontSize,
|
|
@@ -345,7 +346,7 @@ const settings = {
|
|
|
345
346
|
className: '',
|
|
346
347
|
disabled: false,
|
|
347
348
|
error: '',
|
|
348
|
-
format: locale.get()
|
|
349
|
+
format: getFormatDateByCountry(locale.get()),
|
|
349
350
|
label: '',
|
|
350
351
|
readOnly: false,
|
|
351
352
|
required: false,
|
|
@@ -360,7 +361,7 @@ const settings = {
|
|
|
360
361
|
controls: false,
|
|
361
362
|
disabled: false,
|
|
362
363
|
displayAnotherMonth: true,
|
|
363
|
-
displayFormat: locale.get()
|
|
364
|
+
displayFormat: getFormatDateByCountry(locale.get()),
|
|
364
365
|
pressESCToClose: true,
|
|
365
366
|
readOnly: false,
|
|
366
367
|
required: false,
|
|
@@ -596,7 +597,7 @@ const settings = {
|
|
|
596
597
|
autoFocus: false,
|
|
597
598
|
className: '',
|
|
598
599
|
decimalDigit: Infinity,
|
|
599
|
-
decimalSymbol: locale.get()
|
|
600
|
+
decimalSymbol: getDecimalSymbolByCountry(locale.get()),
|
|
600
601
|
disabled: false,
|
|
601
602
|
disabledNegative: false,
|
|
602
603
|
endIcon: '',
|
package/utils/getLang.js
ADDED
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import { format } from 'date-fns';
|
|
2
|
+
import { lowerCaseDayYear } from "../components/form-control/date-input/utils";
|
|
3
|
+
import { enUS, zhCN, vi, ja } from 'date-fns/locale';
|
|
4
|
+
const getFormatDateByCountry = (lang, isDateFns = false) => {
|
|
5
|
+
let result = '';
|
|
6
|
+
switch (lang) {
|
|
7
|
+
case 'en':
|
|
8
|
+
result = isDateFns ? enUS : 'MM/DD/YYYY';
|
|
9
|
+
break;
|
|
10
|
+
case 'zh':
|
|
11
|
+
result = isDateFns ? zhCN : 'YYYY/MM/DD';
|
|
12
|
+
break;
|
|
13
|
+
case 'ja':
|
|
14
|
+
result = isDateFns ? ja : 'YYYY/MM/DD';
|
|
15
|
+
break;
|
|
16
|
+
case 'vi':
|
|
17
|
+
result = isDateFns ? vi : 'DD/MM/YYYY';
|
|
18
|
+
break;
|
|
19
|
+
default:
|
|
20
|
+
result = 'DD/MM/YYYY';
|
|
21
|
+
break;
|
|
22
|
+
}
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
const parseDateString = (date, formatStr, locale) => {
|
|
26
|
+
return format(date, lowerCaseDayYear(formatStr), {
|
|
27
|
+
locale: getFormatDateByCountry(locale, true)
|
|
28
|
+
});
|
|
29
|
+
};
|
|
30
|
+
const getDecimalSymbolByCountry = lang => {
|
|
31
|
+
let result = '';
|
|
32
|
+
switch (lang) {
|
|
33
|
+
case 'vi': // Việt Nam
|
|
34
|
+
case 'de': // Đức
|
|
35
|
+
case 'fr': // Pháp
|
|
36
|
+
case 'it': // Ý
|
|
37
|
+
case 'es': // Tây Ban Nha
|
|
38
|
+
case 'ru':
|
|
39
|
+
// Nga
|
|
40
|
+
result = ','; // Dấu phẩy làm thập phân
|
|
41
|
+
break;
|
|
42
|
+
case 'en': // Anh, Mỹ
|
|
43
|
+
case 'zh': // Trung Quốc
|
|
44
|
+
case 'ja': // Nhật Bản
|
|
45
|
+
default:
|
|
46
|
+
result = '.'; // Dấu chấm làm thập phân
|
|
47
|
+
break;
|
|
48
|
+
}
|
|
49
|
+
return result;
|
|
50
|
+
};
|
|
51
|
+
const getThousandSeparatorByCountry = lang => {
|
|
52
|
+
switch (lang) {
|
|
53
|
+
case 'vi': // Việt Nam
|
|
54
|
+
case 'de': // Đức
|
|
55
|
+
case 'es':
|
|
56
|
+
// Tây Ban Nha
|
|
57
|
+
return '.';
|
|
58
|
+
case 'fr':
|
|
59
|
+
// Pháp
|
|
60
|
+
return '\u00A0';
|
|
61
|
+
// space không ngắt
|
|
62
|
+
case 'en': // Anh, Mỹ
|
|
63
|
+
case 'zh': // Trung Quốc
|
|
64
|
+
case 'ja': // Nhật
|
|
65
|
+
default:
|
|
66
|
+
return ',';
|
|
67
|
+
}
|
|
68
|
+
};
|
|
69
|
+
export { getFormatDateByCountry, parseDateString, getDecimalSymbolByCountry, getThousandSeparatorByCountry };
|