diginet-core-ui 1.4.64-beta.6 → 1.4.65-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/components/button/more.js +28 -14
- package/components/form-control/date-picker/index.js +1 -1
- package/components/form-control/date-range-picker/index.js +41 -24
- package/components/form-control/dropdown/index.js +46 -46
- package/components/form-control/money-input/index.js +25 -19
- package/components/popup/v2/index.js +22 -18
- package/global/index.js +2 -1
- package/icons/basic.js +38 -0
- package/package.json +1 -1
- package/readme.md +13 -0
- package/theme/settings.js +1 -1
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/** @jsxRuntime classic */
|
|
2
2
|
/** @jsx jsx */
|
|
3
3
|
import { css, jsx } from '@emotion/core';
|
|
4
|
-
import { ButtonIcon, Icon, Popover, Tooltip, Typography } from "./..";
|
|
4
|
+
import { Button, ButtonIcon, Icon, Popover, Tooltip, Typography } from "./..";
|
|
5
5
|
import OptionWrapper from "../others/option-wrapper";
|
|
6
6
|
import PropTypes from 'prop-types';
|
|
7
7
|
import React, { forwardRef, isValidElement, memo, useImperativeHandle, useMemo, useRef, useState } from 'react';
|
|
@@ -30,7 +30,8 @@ const ButtonMore = /*#__PURE__*/memo( /*#__PURE__*/forwardRef((inProps, referenc
|
|
|
30
30
|
optionType,
|
|
31
31
|
popoverProp,
|
|
32
32
|
style,
|
|
33
|
-
onClick
|
|
33
|
+
onClick,
|
|
34
|
+
label
|
|
34
35
|
} = props;
|
|
35
36
|
const isOptionFull = optionType === 'full';
|
|
36
37
|
let anchor = anchorProp;
|
|
@@ -114,6 +115,28 @@ const ButtonMore = /*#__PURE__*/memo( /*#__PURE__*/forwardRef((inProps, referenc
|
|
|
114
115
|
});
|
|
115
116
|
return AnchorTag;
|
|
116
117
|
};
|
|
118
|
+
const renderBtnMore = () => {
|
|
119
|
+
const btnRef = {
|
|
120
|
+
ref: ref,
|
|
121
|
+
viewType: 'text',
|
|
122
|
+
id: id,
|
|
123
|
+
style: style,
|
|
124
|
+
disabled: disabled,
|
|
125
|
+
onClick: openPopover,
|
|
126
|
+
...buttonProps
|
|
127
|
+
};
|
|
128
|
+
const btn = label ? jsx(Button, {
|
|
129
|
+
label: label,
|
|
130
|
+
className: className,
|
|
131
|
+
...btnRef
|
|
132
|
+
}) : jsx(ButtonIcon, {
|
|
133
|
+
circular: true,
|
|
134
|
+
name: 'more',
|
|
135
|
+
className: classNames('DGN-UI-ButtonMore', className),
|
|
136
|
+
...btnRef
|
|
137
|
+
});
|
|
138
|
+
return btn;
|
|
139
|
+
};
|
|
117
140
|
return useMemo(() => {
|
|
118
141
|
return jsx(Popover, {
|
|
119
142
|
css: _PopoverCSS,
|
|
@@ -127,18 +150,7 @@ const ButtonMore = /*#__PURE__*/memo( /*#__PURE__*/forwardRef((inProps, referenc
|
|
|
127
150
|
vertical: 'top',
|
|
128
151
|
horizontal: 'left'
|
|
129
152
|
},
|
|
130
|
-
anchor: anchor ? renderAnchor() :
|
|
131
|
-
ref: ref,
|
|
132
|
-
circular: true,
|
|
133
|
-
name: 'more',
|
|
134
|
-
viewType: 'text',
|
|
135
|
-
id: id,
|
|
136
|
-
style: style,
|
|
137
|
-
className: classNames('DGN-UI-ButtonMore', className),
|
|
138
|
-
disabled: disabled,
|
|
139
|
-
onClick: openPopover,
|
|
140
|
-
...buttonProps
|
|
141
|
-
}),
|
|
153
|
+
anchor: anchor ? renderAnchor() : renderBtnMore(),
|
|
142
154
|
...popoverProp
|
|
143
155
|
}, renderOptions());
|
|
144
156
|
}, [buttonProps, className, disabled, id, options, optionType, popoverProp, style, iconState, openState, theme]);
|
|
@@ -195,6 +207,8 @@ ButtonMore.propTypes = {
|
|
|
195
207
|
className: PropTypes.string,
|
|
196
208
|
/** If `true`, the component is disabled. */
|
|
197
209
|
disabled: PropTypes.bool,
|
|
210
|
+
/** The content of the component. */
|
|
211
|
+
label: PropTypes.string,
|
|
198
212
|
/** [Props](https://core.diginet.com.vn/ui/?path=/docs/components-typography) applied to the `Typography` label. */
|
|
199
213
|
labelProp: PropTypes.object,
|
|
200
214
|
/** Option(s) in popover. */
|
|
@@ -192,7 +192,7 @@ const DatePicker = /*#__PURE__*/memo( /*#__PURE__*/forwardRef((inProps, referenc
|
|
|
192
192
|
});
|
|
193
193
|
const iconComp = jsx("div", {
|
|
194
194
|
css: _IconAreaCSS
|
|
195
|
-
}, clearAble && value ? jsx(ButtonIcon, {
|
|
195
|
+
}, clearAble && value && !disabled && !readOnly ? jsx(ButtonIcon, {
|
|
196
196
|
disabled: disabled || readOnly,
|
|
197
197
|
viewType: 'ghost',
|
|
198
198
|
onClick: onClear,
|
|
@@ -14,6 +14,9 @@ import { getColor } from "../../../styles/utils";
|
|
|
14
14
|
import { generateCalendarCSS, onUpdateNavigator, renderHeader, renderNavigator } from "../calendar/function";
|
|
15
15
|
import ControlComp from "../control";
|
|
16
16
|
import useThemeProps from "../../../theme/utils/useThemeProps";
|
|
17
|
+
const SINGLE_CALENDAR_BOARD_WIDTH = 360;
|
|
18
|
+
const SINGLE_CALENDAR_BOARD_HEIGHT = 295;
|
|
19
|
+
const CONTROL_BOARD_HEIGHT = 56;
|
|
17
20
|
const toLocalTimestamp = t => {
|
|
18
21
|
if (typeof t === 'object' && t.getTime) {
|
|
19
22
|
t = t.getTime();
|
|
@@ -140,6 +143,12 @@ const DateRangePicker = /*#__PURE__*/memo( /*#__PURE__*/forwardRef((inProps, ref
|
|
|
140
143
|
const focusBtnRef = useRef('today');
|
|
141
144
|
const loadMoreTimer = useRef(null);
|
|
142
145
|
const dropdownListRef = useRef(null);
|
|
146
|
+
const anchorInputDateRef = useRef(null);
|
|
147
|
+
const singleCalendarBoardInfoRef = useRef({
|
|
148
|
+
status: false,
|
|
149
|
+
width: SINGLE_CALENDAR_BOARD_WIDTH,
|
|
150
|
+
height: controls ? SINGLE_CALENDAR_BOARD_HEIGHT + CONTROL_BOARD_HEIGHT : SINGLE_CALENDAR_BOARD_HEIGHT
|
|
151
|
+
});
|
|
143
152
|
const [valueState, setValueState] = useState();
|
|
144
153
|
const navigatorFromRefs = {
|
|
145
154
|
doubleLeft: useRef(null),
|
|
@@ -278,8 +287,8 @@ const DateRangePicker = /*#__PURE__*/memo( /*#__PURE__*/forwardRef((inProps, ref
|
|
|
278
287
|
tableData = [],
|
|
279
288
|
weekDateFirst = getDateOfWeek(firstDay),
|
|
280
289
|
weekDateLast = getDateOfWeek(lastDay);
|
|
281
|
-
/**
|
|
282
|
-
* days of previous month
|
|
290
|
+
/**
|
|
291
|
+
* days of previous month
|
|
283
292
|
*/
|
|
284
293
|
for (let i = weekDateFirst; i > 0; i--) {
|
|
285
294
|
const day = Date.parse(new Date(time.getFullYear(), time.getMonth(), 1));
|
|
@@ -291,8 +300,8 @@ const DateRangePicker = /*#__PURE__*/memo( /*#__PURE__*/forwardRef((inProps, ref
|
|
|
291
300
|
className: unique.day.day
|
|
292
301
|
})));
|
|
293
302
|
}
|
|
294
|
-
/**
|
|
295
|
-
* days of current month
|
|
303
|
+
/**
|
|
304
|
+
* days of current month
|
|
296
305
|
*/
|
|
297
306
|
for (let i = 0; i < lastDate; i++) {
|
|
298
307
|
const day = new Date(time.getFullYear(), time.getMonth(), i + 1);
|
|
@@ -318,8 +327,8 @@ const DateRangePicker = /*#__PURE__*/memo( /*#__PURE__*/forwardRef((inProps, ref
|
|
|
318
327
|
type: 'h6'
|
|
319
328
|
}, i + 1)));
|
|
320
329
|
}
|
|
321
|
-
/**
|
|
322
|
-
* days of next month
|
|
330
|
+
/**
|
|
331
|
+
* days of next month
|
|
323
332
|
*/
|
|
324
333
|
for (let i = 0; i < 13 - weekDateLast; i++) {
|
|
325
334
|
const day = Date.parse(new Date(time.getFullYear(), time.getMonth() + 1, 0));
|
|
@@ -398,21 +407,32 @@ const DateRangePicker = /*#__PURE__*/memo( /*#__PURE__*/forwardRef((inProps, ref
|
|
|
398
407
|
height,
|
|
399
408
|
top
|
|
400
409
|
} = anchor instanceof Element ? anchor.getBoundingClientRect() : ref.current.getBoundingClientRect();
|
|
401
|
-
const pickerHeight = innerWidth < 567 ? controls ? 550 : 495 :
|
|
410
|
+
const pickerHeight = innerWidth < 567 ? controls ? 550 : 495 : singleCalendarBoardInfoRef.current.height;
|
|
402
411
|
let style = {};
|
|
403
412
|
style.left = left;
|
|
404
413
|
style.top = top + height + 4;
|
|
405
414
|
style.transformOrigin = '50% 20%';
|
|
406
415
|
if (style.top + pickerHeight > innerHeight) {
|
|
407
416
|
if (top > pickerHeight) {
|
|
408
|
-
|
|
417
|
+
var _anchorInputDateRef$c;
|
|
418
|
+
const anchorRef = (_anchorInputDateRef$c = anchorInputDateRef.current) !== null && _anchorInputDateRef$c !== void 0 ? _anchorInputDateRef$c : ipConRef.current;
|
|
419
|
+
const {
|
|
420
|
+
top: topInput
|
|
421
|
+
} = anchorRef.getBoundingClientRect() || {};
|
|
422
|
+
style.top = topInput - pickerHeight;
|
|
409
423
|
style.transformOrigin = '50% 80%';
|
|
410
424
|
} else {
|
|
411
425
|
style.top = Math.round((innerHeight - pickerHeight - 16) / 2);
|
|
412
426
|
style.transformOrigin = 'center';
|
|
413
427
|
}
|
|
414
428
|
}
|
|
415
|
-
const
|
|
429
|
+
const {
|
|
430
|
+
width: singleCalendarCompWidth
|
|
431
|
+
} = {
|
|
432
|
+
...singleCalendarBoardInfoRef.current
|
|
433
|
+
};
|
|
434
|
+
const fullCalendarComp = singleCalendarCompWidth * 2;
|
|
435
|
+
const pickerWidth = window.innerWidth <= fullCalendarComp ? singleCalendarCompWidth : fullCalendarComp;
|
|
416
436
|
if (left + pickerWidth > innerWidth) {
|
|
417
437
|
if (innerWidth > pickerWidth) {
|
|
418
438
|
style.left = (innerWidth - pickerWidth) / 2;
|
|
@@ -692,6 +712,7 @@ const DateRangePicker = /*#__PURE__*/memo( /*#__PURE__*/forwardRef((inProps, ref
|
|
|
692
712
|
renderCalendar(valueTo.current, 'to');
|
|
693
713
|
};
|
|
694
714
|
const openPicker = anchor => {
|
|
715
|
+
if (anchor) anchorInputDateRef.current = anchor;
|
|
695
716
|
const backGr = createBackground();
|
|
696
717
|
const picker = createPicker(anchor);
|
|
697
718
|
render(pickerComp, backGr.appendChild(picker));
|
|
@@ -1057,6 +1078,16 @@ const DateRangePicker = /*#__PURE__*/memo( /*#__PURE__*/forwardRef((inProps, ref
|
|
|
1057
1078
|
onClick: onConfirm
|
|
1058
1079
|
}, confirmText)));
|
|
1059
1080
|
const leftCalendarComp = jsx("div", {
|
|
1081
|
+
...(!singleCalendarBoardInfoRef.current.status ? {
|
|
1082
|
+
ref: ref => {
|
|
1083
|
+
var _ref$clientWidth;
|
|
1084
|
+
return singleCalendarBoardInfoRef.current = {
|
|
1085
|
+
...singleCalendarBoardInfoRef.current,
|
|
1086
|
+
status: true,
|
|
1087
|
+
width: (_ref$clientWidth = ref === null || ref === void 0 ? void 0 : ref.clientWidth) !== null && _ref$clientWidth !== void 0 ? _ref$clientWidth : SINGLE_CALENDAR_BOARD_WIDTH
|
|
1088
|
+
};
|
|
1089
|
+
}
|
|
1090
|
+
} : {}),
|
|
1060
1091
|
css: generateCalendarCSS(unique, false, false, theme)
|
|
1061
1092
|
}, renderNavigator(unique, navigatorFromRefs, e => setPrevTime(e, 'year', valueFr.current, 'from'), e => setPrevTime(e, 'month', valueFr.current, 'from'), e => setNextTime(e, 'month', valueFr.current, 'from'), e => setNextTime(e, 'year', valueFr.current, 'from')), jsx("div", {
|
|
1062
1093
|
className: unique.table.container
|
|
@@ -1484,21 +1515,7 @@ DateRangePicker.propTypes = {
|
|
|
1484
1515
|
placeholder: PropTypes.string,
|
|
1485
1516
|
/** If `true`, hitting escape will close component. */
|
|
1486
1517
|
pressESCToClose: PropTypes.bool,
|
|
1487
|
-
/** Options for period selector.
|
|
1488
|
-
* example: {
|
|
1489
|
-
* enable: true,
|
|
1490
|
-
* dataSource: [],
|
|
1491
|
-
* displayExpr: "DisplayName",
|
|
1492
|
-
* valueFromExpr: "DateFrom",
|
|
1493
|
-
* valueToExpr: "DateTo",
|
|
1494
|
-
* valueFormat: "DD/MM/YYYY",
|
|
1495
|
-
* limit: 5,
|
|
1496
|
-
* skip: 0,
|
|
1497
|
-
* total: 100,
|
|
1498
|
-
* onLoadMore: () => {},
|
|
1499
|
-
* loading: false
|
|
1500
|
-
* }
|
|
1501
|
-
*/
|
|
1518
|
+
/** Options for period selector. */
|
|
1502
1519
|
periodOptions: PropTypes.object,
|
|
1503
1520
|
/** If `true`, the component is readOnly. */
|
|
1504
1521
|
readOnly: PropTypes.bool,
|
|
@@ -29,7 +29,7 @@ const convertData = (dt, valueExpr) => {
|
|
|
29
29
|
};
|
|
30
30
|
const convertSearchDelayTime = searchDelayTime => {
|
|
31
31
|
var _searchDelayTime$matc, _searchDelayTime$matc2;
|
|
32
|
-
if (searchDelayTime === true) return getGlobal('
|
|
32
|
+
if (searchDelayTime === true) return getGlobal('delayOnSearchInput');
|
|
33
33
|
const units = {
|
|
34
34
|
m: 60000,
|
|
35
35
|
s: 1000,
|
|
@@ -122,10 +122,10 @@ const Dropdown = /*#__PURE__*/memo( /*#__PURE__*/forwardRef((inProps, reference)
|
|
|
122
122
|
} = props;
|
|
123
123
|
const selectBox = multiple && selectBoxProp === undefined ? true : selectBoxProp;
|
|
124
124
|
const searchExpr = typeof searchExprProp === 'string' ? [searchExprProp] : searchExprProp;
|
|
125
|
-
const searchDelayTime = convertSearchDelayTime(searchDelayTimeProp === undefined ? getGlobal('
|
|
125
|
+
const searchDelayTime = convertSearchDelayTime(searchDelayTimeProp === undefined ? getGlobal('delayOnSearchInput') : searchDelayTimeProp);
|
|
126
126
|
let displayExpr = displayExprProp;
|
|
127
127
|
const noDataText = noDataTextProp || getGlobal('noDataText');
|
|
128
|
-
const placeholder = placeholderProp || getGlobal('dropdownPlaceholder');
|
|
128
|
+
const placeholder = placeholderProp || !readOnly && !disabled && getGlobal('dropdownPlaceholder');
|
|
129
129
|
const ref = useRef(null);
|
|
130
130
|
const dropdownRef = useRef(null);
|
|
131
131
|
const timer = useRef(null);
|
|
@@ -301,10 +301,10 @@ const Dropdown = /*#__PURE__*/memo( /*#__PURE__*/forwardRef((inProps, reference)
|
|
|
301
301
|
});
|
|
302
302
|
};
|
|
303
303
|
|
|
304
|
-
/**
|
|
305
|
-
* So sánh text đầu vào cáo map với txtSearch
|
|
306
|
-
* @param text
|
|
307
|
-
* @return {boolean}
|
|
304
|
+
/**
|
|
305
|
+
* So sánh text đầu vào cáo map với txtSearch
|
|
306
|
+
* @param text
|
|
307
|
+
* @return {boolean}
|
|
308
308
|
*/
|
|
309
309
|
const handleRenderBySearch = (text = '') => {
|
|
310
310
|
if (text === null || text === undefined) text = '';
|
|
@@ -317,10 +317,10 @@ const Dropdown = /*#__PURE__*/memo( /*#__PURE__*/forwardRef((inProps, reference)
|
|
|
317
317
|
} else return text.toLowerCase().includes(txtSearch.toLowerCase());
|
|
318
318
|
};
|
|
319
319
|
|
|
320
|
-
/**
|
|
321
|
-
* 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
|
|
322
|
-
* @param data {object} rowData of dataSource
|
|
323
|
-
* @return {string}
|
|
320
|
+
/**
|
|
321
|
+
* 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
|
|
322
|
+
* @param data {object} rowData of dataSource
|
|
323
|
+
* @return {string}
|
|
324
324
|
*/
|
|
325
325
|
const displayValue = data => {
|
|
326
326
|
let text = '';
|
|
@@ -1805,9 +1805,9 @@ Dropdown.propTypes = {
|
|
|
1805
1805
|
defaultValue: PropTypes.oneOfType([PropTypes.string, PropTypes.number, PropTypes.array]),
|
|
1806
1806
|
/** If `true`, the component is disabled. */
|
|
1807
1807
|
disabled: PropTypes.bool,
|
|
1808
|
-
/** The field name used for displaying text in the dropdown list.<br/>
|
|
1809
|
-
* Examples: 'name', '{id} - {name}', '{age} age(s)'<br/>
|
|
1810
|
-
* Note: Do not use 'id - name', as it will return undefined.
|
|
1808
|
+
/** The field name used for displaying text in the dropdown list.<br/>
|
|
1809
|
+
* Examples: 'name', '{id} - {name}', '{age} age(s)'<br/>
|
|
1810
|
+
* Note: Do not use 'id - name', as it will return undefined.
|
|
1811
1811
|
*/
|
|
1812
1812
|
displayExpr: PropTypes.oneOfType([PropTypes.string, PropTypes.number, PropTypes.array]),
|
|
1813
1813
|
/** Inline style for dropdown items. */
|
|
@@ -1816,14 +1816,14 @@ Dropdown.propTypes = {
|
|
|
1816
1816
|
error: PropTypes.oneOfType([PropTypes.bool, PropTypes.string]),
|
|
1817
1817
|
/** Props applied to the [HelperText](https://core.diginet.com.vn/ui/?path=/story/form-control-text-helpertext) element. */
|
|
1818
1818
|
helperTextProps: PropTypes.object,
|
|
1819
|
-
/** The field name used for displaying icons.<br/>
|
|
1820
|
-
* Example:<br/>
|
|
1821
|
-
* string: 'icon'<br/>
|
|
1822
|
-
* object: {<br/>
|
|
1823
|
-
* key: 'icon',<br/>
|
|
1824
|
-
* prefix: 'https://imglink.com',<br/>
|
|
1825
|
-
* suffix: '.jpg'<br/>
|
|
1826
|
-
* }
|
|
1819
|
+
/** The field name used for displaying icons.<br/>
|
|
1820
|
+
* Example:<br/>
|
|
1821
|
+
* string: 'icon'<br/>
|
|
1822
|
+
* object: {<br/>
|
|
1823
|
+
* key: 'icon',<br/>
|
|
1824
|
+
* prefix: 'https://imglink.com',<br/>
|
|
1825
|
+
* suffix: '.jpg'<br/>
|
|
1826
|
+
* }
|
|
1827
1827
|
*/
|
|
1828
1828
|
iconExpr: PropTypes.oneOfType([PropTypes.string, PropTypes.shape({
|
|
1829
1829
|
key: PropTypes.string,
|
|
@@ -1859,8 +1859,8 @@ Dropdown.propTypes = {
|
|
|
1859
1859
|
onOpened: PropTypes.func,
|
|
1860
1860
|
/** Callback function fired when the dropdown is closed. */
|
|
1861
1861
|
onClosed: PropTypes.func,
|
|
1862
|
-
/** Callback function fired when the input value changes.<br/>
|
|
1863
|
-
* If undefined, the filter function will run (default behavior).
|
|
1862
|
+
/** Callback function fired when the input value changes.<br/>
|
|
1863
|
+
* If undefined, the filter function will run (default behavior).
|
|
1864
1864
|
*/
|
|
1865
1865
|
onInput: PropTypes.func,
|
|
1866
1866
|
/** Callback function fired when a key is pressed down in the input. */
|
|
@@ -1873,21 +1873,21 @@ Dropdown.propTypes = {
|
|
|
1873
1873
|
placeholder: PropTypes.string,
|
|
1874
1874
|
/** If `true`, the component is read-only. */
|
|
1875
1875
|
readOnly: PropTypes.bool,
|
|
1876
|
-
/** Function used for custom rendering of items.<br/>
|
|
1877
|
-
* Example: `(data, index) => data.name + ' - ' + data.role`<br/>
|
|
1878
|
-
* This can be used as an alternative to `displayExpr`
|
|
1876
|
+
/** Function used for custom rendering of items.<br/>
|
|
1877
|
+
* Example: `(data, index) => data.name + ' - ' + data.role`<br/>
|
|
1878
|
+
* This can be used as an alternative to `displayExpr`
|
|
1879
1879
|
*/
|
|
1880
1880
|
renderItem: PropTypes.func,
|
|
1881
|
-
/** Function or field name used to display selected items.<br/>
|
|
1882
|
-
* Example: `(data, index) => index + ' - ' + data.name`<br/>
|
|
1881
|
+
/** Function or field name used to display selected items.<br/>
|
|
1882
|
+
* Example: `(data, index) => index + ' - ' + data.name`<br/>
|
|
1883
1883
|
*/
|
|
1884
1884
|
renderSelectedItem: PropTypes.oneOfType([PropTypes.func, PropTypes.string]),
|
|
1885
1885
|
/** If `true`, the label will indicate that the input is required. */
|
|
1886
1886
|
required: PropTypes.bool,
|
|
1887
|
-
/**
|
|
1888
|
-
* Duration to wait after entering search content before triggering a search.<br/>
|
|
1889
|
-
* Example: 700 -> 700ms, '700ms' -> 700ms, '0.7s' -> 700ms, '1m' -> 60000ms
|
|
1890
|
-
* If `true`, the default delayOnInput will be used.
|
|
1887
|
+
/**
|
|
1888
|
+
* Duration to wait after entering search content before triggering a search.<br/>
|
|
1889
|
+
* Example: 700 -> 700ms, '700ms' -> 700ms, '0.7s' -> 700ms, '1m' -> 60000ms
|
|
1890
|
+
* If `true`, the default delayOnInput will be used.
|
|
1891
1891
|
*/
|
|
1892
1892
|
searchDelayTime: PropTypes.oneOfType([PropTypes.string, PropTypes.number, PropTypes.bool]),
|
|
1893
1893
|
/** Specifies the field name or expression used to compare values with the search string. */
|
|
@@ -1920,19 +1920,19 @@ Dropdown.propTypes = {
|
|
|
1920
1920
|
viewType: PropTypes.oneOf(['underlined', 'outlined', 'none']),
|
|
1921
1921
|
/** Custom icon to override the default arrow icon. */
|
|
1922
1922
|
endIcon: PropTypes.string
|
|
1923
|
-
/**
|
|
1924
|
-
* ref methods
|
|
1925
|
-
*
|
|
1926
|
-
* how to get component element? ref.current
|
|
1927
|
-
*
|
|
1928
|
-
* how to call method? ref.current.instance.{method}
|
|
1929
|
-
*
|
|
1930
|
-
* * showDropdown(): Show dropdown
|
|
1931
|
-
* * closeDropdown(): Close dropdown
|
|
1932
|
-
* * onClear(): Clear selected value
|
|
1933
|
-
* * setPreviousValue(): Set value to previous value
|
|
1934
|
-
* * setValue(value): Set value of dropdown
|
|
1935
|
-
* * @param {value} - string || number || array
|
|
1923
|
+
/**
|
|
1924
|
+
* ref methods
|
|
1925
|
+
*
|
|
1926
|
+
* how to get component element? ref.current
|
|
1927
|
+
*
|
|
1928
|
+
* how to call method? ref.current.instance.{method}
|
|
1929
|
+
*
|
|
1930
|
+
* * showDropdown(): Show dropdown
|
|
1931
|
+
* * closeDropdown(): Close dropdown
|
|
1932
|
+
* * onClear(): Clear selected value
|
|
1933
|
+
* * setPreviousValue(): Set value to previous value
|
|
1934
|
+
* * setValue(value): Set value of dropdown
|
|
1935
|
+
* * @param {value} - string || number || array
|
|
1936
1936
|
*/
|
|
1937
1937
|
};
|
|
1938
1938
|
export default Dropdown;
|
|
@@ -404,13 +404,7 @@ const MoneyInput = /*#__PURE__*/memo( /*#__PURE__*/forwardRef((inProps, referenc
|
|
|
404
404
|
}
|
|
405
405
|
const v = getValueWithDecimal(number.toString().replace('.', decimalSymbol));
|
|
406
406
|
if (convertToWords && !decimalDigit && (disabled || readOnly)) {
|
|
407
|
-
|
|
408
|
-
if (Number.isInteger(number)) {
|
|
409
|
-
const currentLocale = locale.get();
|
|
410
|
-
const converter = converters[currentLocale] || num2WordsVi; // fallback VN
|
|
411
|
-
valueConverted = converter.convert(number);
|
|
412
|
-
}
|
|
413
|
-
inputRef.current.value = parseValueWithFix(valueConverted);
|
|
407
|
+
inputRef.current.value = convertNumToWords(value);
|
|
414
408
|
} else {
|
|
415
409
|
inputRef.current.value = parseValueWithFix(thousandSeparator ? getThousandSeparator(v) : v);
|
|
416
410
|
}
|
|
@@ -427,13 +421,23 @@ const MoneyInput = /*#__PURE__*/memo( /*#__PURE__*/forwardRef((inProps, referenc
|
|
|
427
421
|
useImperativeHandle(reference, () => {
|
|
428
422
|
const currentRef = ref.current || {};
|
|
429
423
|
const _instance = {
|
|
430
|
-
getThousandSeparator: getThousandSeparator
|
|
424
|
+
getThousandSeparator: getThousandSeparator,
|
|
425
|
+
convertNumToWords
|
|
431
426
|
}; // methods
|
|
432
427
|
_instance.__proto__ = {}; // hidden methods
|
|
433
428
|
currentRef.instance = _instance;
|
|
434
429
|
currentRef.getThousandSeparator = getThousandSeparator;
|
|
435
430
|
return currentRef;
|
|
436
431
|
});
|
|
432
|
+
const convertNumToWords = number => {
|
|
433
|
+
let valueConverted = getGlobal('helperInvalid');
|
|
434
|
+
if (Number.isInteger(number)) {
|
|
435
|
+
const currentLocale = locale.get();
|
|
436
|
+
const converter = converters[currentLocale] || num2WordsVi; // fallback VN
|
|
437
|
+
valueConverted = Object.hasOwn(converter, 'convert') ? converter.convert(number) : converter(number);
|
|
438
|
+
}
|
|
439
|
+
return valueConverted;
|
|
440
|
+
};
|
|
437
441
|
const validateResult = validates && onValidate(value, validates, true);
|
|
438
442
|
return jsx("div", {
|
|
439
443
|
ref: ref,
|
|
@@ -543,6 +547,8 @@ MoneyInput.propTypes = {
|
|
|
543
547
|
required: PropTypes.bool,
|
|
544
548
|
/** Convert money from number to words when readOnly || disabled */
|
|
545
549
|
convertToWords: PropTypes.bool,
|
|
550
|
+
/** Convert number to words function */
|
|
551
|
+
convertNumToWords: PropTypes.number,
|
|
546
552
|
/** Add a string to first of value when convertToWords. */
|
|
547
553
|
prefix: PropTypes.string,
|
|
548
554
|
/** Add a string to last of value when convertToWords. */
|
|
@@ -551,10 +557,10 @@ MoneyInput.propTypes = {
|
|
|
551
557
|
inputProps: PropTypes.object,
|
|
552
558
|
/** style inline of input in MoneyInput component */
|
|
553
559
|
inputStyle: PropTypes.object,
|
|
554
|
-
/** validation value, argument can:<br/>
|
|
555
|
-
* * string: the validation rule. Example required.<br/>
|
|
556
|
-
* * object: the validation rule insist name, property, message. Example {name: 'min', compareValue: 9, message: 'Error'} or {max: 99}<br/>
|
|
557
|
-
* * array: the validation rule list, insist object/string
|
|
560
|
+
/** validation value, argument can:<br/>
|
|
561
|
+
* * string: the validation rule. Example required.<br/>
|
|
562
|
+
* * object: the validation rule insist name, property, message. Example {name: 'min', compareValue: 9, message: 'Error'} or {max: 99}<br/>
|
|
563
|
+
* * array: the validation rule list, insist object/string
|
|
558
564
|
*/
|
|
559
565
|
validates: PropTypes.oneOfType([PropTypes.string, PropTypes.object, PropTypes.array, PropTypes.func]),
|
|
560
566
|
/** on key down function */
|
|
@@ -563,13 +569,13 @@ MoneyInput.propTypes = {
|
|
|
563
569
|
onKeyUp: PropTypes.func,
|
|
564
570
|
/** on input function */
|
|
565
571
|
onInput: PropTypes.func,
|
|
566
|
-
/**
|
|
567
|
-
* on change function, return an object:<br/>
|
|
568
|
-
* {<br/>
|
|
569
|
-
* value: is a number or null value<br/>
|
|
570
|
-
* target.value: value of input<br/>
|
|
571
|
-
* ...element<br/>
|
|
572
|
-
* }
|
|
572
|
+
/**
|
|
573
|
+
* on change function, return an object:<br/>
|
|
574
|
+
* {<br/>
|
|
575
|
+
* value: is a number or null value<br/>
|
|
576
|
+
* target.value: value of input<br/>
|
|
577
|
+
* ...element<br/>
|
|
578
|
+
* }
|
|
573
579
|
*/
|
|
574
580
|
onChange: PropTypes.func,
|
|
575
581
|
/** on blur function */
|
|
@@ -36,6 +36,7 @@ const Popup = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
36
36
|
type,
|
|
37
37
|
width,
|
|
38
38
|
yesText,
|
|
39
|
+
showFullContent,
|
|
39
40
|
...props
|
|
40
41
|
}, reference) => {
|
|
41
42
|
if (!reference) reference = useRef(null);
|
|
@@ -43,7 +44,7 @@ const Popup = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
43
44
|
const statusAction = useRef('');
|
|
44
45
|
const [openState, setOpenState] = useState(open);
|
|
45
46
|
const [custom, setCustom] = useState(null);
|
|
46
|
-
const [showMoreDescription, setShowMoreDescription] = useState(
|
|
47
|
+
const [showMoreDescription, setShowMoreDescription] = useState(!showFullContent);
|
|
47
48
|
const [descriptionLines, setDescriptionLines] = useState(0);
|
|
48
49
|
const showPopup = useDelayUnmount(openState, 200);
|
|
49
50
|
const theme = useTheme();
|
|
@@ -100,7 +101,7 @@ const Popup = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
100
101
|
const onRefChange = useCallback(node => {
|
|
101
102
|
if (node) {
|
|
102
103
|
setDescriptionLines(Math.round((node === null || node === void 0 ? void 0 : node.offsetHeight) / 18)); //18 is line-height of Typography p2
|
|
103
|
-
setShowMoreDescription(
|
|
104
|
+
setShowMoreDescription(!showFullContent);
|
|
104
105
|
}
|
|
105
106
|
}, []);
|
|
106
107
|
useEffect(() => {
|
|
@@ -175,7 +176,7 @@ const Popup = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
175
176
|
ref: onRefChange,
|
|
176
177
|
type: 'p2',
|
|
177
178
|
className: 'DGN-UI-Popup-Body-Detail'
|
|
178
|
-
}, description), subtitle && descriptionLines > 1 || descriptionLines > 3 ? jsx("span", {
|
|
179
|
+
}, description), (subtitle && descriptionLines > 1 || descriptionLines > 3) && showFullContent ? jsx("span", {
|
|
179
180
|
className: 'DGN-More-Action',
|
|
180
181
|
onClick: () => setShowMoreDescription(!showMoreDescription)
|
|
181
182
|
}, getGlobal(showMoreDescription ? 'showLess' : 'showMore')) : null)));
|
|
@@ -343,7 +344,8 @@ Popup.defaultProps = {
|
|
|
343
344
|
style: {},
|
|
344
345
|
top: 56,
|
|
345
346
|
type: 'info',
|
|
346
|
-
width: 480
|
|
347
|
+
width: 480,
|
|
348
|
+
showFullContent: true
|
|
347
349
|
};
|
|
348
350
|
Popup.propTypes = {
|
|
349
351
|
/** If `true`, the component is shown. */
|
|
@@ -379,20 +381,22 @@ Popup.propTypes = {
|
|
|
379
381
|
/** Width of the component. */
|
|
380
382
|
width: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
|
|
381
383
|
/** Label of confirm button. */
|
|
382
|
-
yesText: PropTypes.string
|
|
383
|
-
/**
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
*
|
|
387
|
-
*
|
|
388
|
-
* how to
|
|
389
|
-
*
|
|
390
|
-
*
|
|
391
|
-
*
|
|
392
|
-
*
|
|
393
|
-
* * @param {
|
|
394
|
-
* *
|
|
395
|
-
*
|
|
384
|
+
yesText: PropTypes.string,
|
|
385
|
+
/** If `true`, show full content in popup */
|
|
386
|
+
showFullContent: PropTypes.bool
|
|
387
|
+
/**
|
|
388
|
+
* ref methods
|
|
389
|
+
*
|
|
390
|
+
* how to get component element? ref.current
|
|
391
|
+
*
|
|
392
|
+
* how to call method? ref.current.instance.{method}
|
|
393
|
+
*
|
|
394
|
+
* * show(options, callback): Show popup
|
|
395
|
+
* * @param {options} - object
|
|
396
|
+
* * {type, title, icon, yesNo, description, confirmProps, cancelProps, onCancel, onConfirm}
|
|
397
|
+
* * @param {callback} - func
|
|
398
|
+
* * Callback fired after click on button (callback(true) with confirm Button and callback(false) with cancel Button). Alternate both onCancel, onConfirm methods of options
|
|
399
|
+
* * close(): Close popup
|
|
396
400
|
*/
|
|
397
401
|
};
|
|
398
402
|
export default Popup;
|
package/global/index.js
CHANGED
|
@@ -245,7 +245,8 @@ const globalObject = {
|
|
|
245
245
|
dropdownPlaceholder: '请选择'
|
|
246
246
|
},
|
|
247
247
|
//Global variable
|
|
248
|
-
delayOnInput:
|
|
248
|
+
delayOnInput: 500,
|
|
249
|
+
delayOnSearchInput: 1200,
|
|
249
250
|
maxSizeUpload: Infinity
|
|
250
251
|
};
|
|
251
252
|
export const getGlobal = (key, language = locale.get()) => {
|
package/icons/basic.js
CHANGED
|
@@ -7312,6 +7312,44 @@ export const Inheritance = /*#__PURE__*/memo(({
|
|
|
7312
7312
|
fill: fillColor(color)
|
|
7313
7313
|
}));
|
|
7314
7314
|
});
|
|
7315
|
+
export const Import = /*#__PURE__*/memo(({
|
|
7316
|
+
width,
|
|
7317
|
+
height,
|
|
7318
|
+
color = 'system/rest',
|
|
7319
|
+
viewBox = false
|
|
7320
|
+
}) => {
|
|
7321
|
+
return viewBox ? /*#__PURE__*/React.createElement("svg", {
|
|
7322
|
+
width: width || 24,
|
|
7323
|
+
height: height || 24,
|
|
7324
|
+
viewBox: "0 0 24 24",
|
|
7325
|
+
fill: "none"
|
|
7326
|
+
}, /*#__PURE__*/React.createElement("path", {
|
|
7327
|
+
fillRule: "evenodd",
|
|
7328
|
+
clipRule: "evenodd",
|
|
7329
|
+
d: "M13 8.62059L8.28283 3.2307V6.41849L7.94949 6.39752L7.47475 6.36606C6.12121 6.28217 4.9697 5.97807 3.94949 5.43279C2.89899 4.87703 2 4.08008 1.23232 3L1 3.09438C1.41414 5.03432 2.24242 7.18398 3.85859 8.75691C4.81818 9.70067 6.07071 10.4452 7.68687 10.8122L7.86869 10.8541L8.28283 10.9485V14L13 8.62059Z",
|
|
7330
|
+
fill: fillColor(color)
|
|
7331
|
+
}), /*#__PURE__*/React.createElement("path", {
|
|
7332
|
+
fillRule: "evenodd",
|
|
7333
|
+
clipRule: "evenodd",
|
|
7334
|
+
d: "M5 11.4316V19C5 20.1046 5.89543 21 7 21H19C20.1046 21 21 20.1046 21 19V7C21 5.89543 20.1046 5 19 5H11.9165L13.6738 7H19V19H7V12.2796C6.54269 12.2796 5 11.5 5 11.4316Z",
|
|
7335
|
+
fill: fillColor(color)
|
|
7336
|
+
})) : /*#__PURE__*/React.createElement("svg", {
|
|
7337
|
+
width: width || 20,
|
|
7338
|
+
height: height || 18,
|
|
7339
|
+
viewBox: "0 0 20 18",
|
|
7340
|
+
fill: "none"
|
|
7341
|
+
}, /*#__PURE__*/React.createElement("path", {
|
|
7342
|
+
fillRule: "evenodd",
|
|
7343
|
+
clipRule: "evenodd",
|
|
7344
|
+
d: "M12 5.62059L7.28283 0.230696V3.41849L6.94949 3.39752L6.47475 3.36606C5.12121 3.28217 3.9697 2.97807 2.94949 2.43279C1.89899 1.87703 1 1.08008 0.232323 0L0 0.0943766C0.414141 2.03432 1.24242 4.18398 2.85859 5.75691C3.81818 6.70067 5.07071 7.44519 6.68687 7.8122L6.86869 7.85415L7.28283 7.94852V11L12 5.62059Z",
|
|
7345
|
+
fill: fillColor(color)
|
|
7346
|
+
}), /*#__PURE__*/React.createElement("path", {
|
|
7347
|
+
fillRule: "evenodd",
|
|
7348
|
+
clipRule: "evenodd",
|
|
7349
|
+
d: "M4 8.43156V16C4 17.1046 4.89543 18 6 18H18C19.1046 18 20 17.1046 20 16V4C20 2.89543 19.1046 2 18 2H10.9165L12.6738 4H18V16H6V9.27963C5.54269 9.27963 4 8.5 4 8.43156Z",
|
|
7350
|
+
fill: fillColor(color)
|
|
7351
|
+
}));
|
|
7352
|
+
});
|
|
7315
7353
|
export const Warning = /*#__PURE__*/memo(({
|
|
7316
7354
|
width,
|
|
7317
7355
|
height,
|
package/package.json
CHANGED
package/readme.md
CHANGED
|
@@ -41,6 +41,19 @@ npm test
|
|
|
41
41
|
```
|
|
42
42
|
|
|
43
43
|
## Changelog
|
|
44
|
+
## 1.4.65
|
|
45
|
+
- \[Added\]: Icon – Add Icon OpenNew
|
|
46
|
+
- \[Added\]: Icon – Add IconMenu WEO53TR001, WEO53APP01
|
|
47
|
+
- \[Added\]: Icon – Add IconMenu MHRM09N1404
|
|
48
|
+
- \[Added\]: Icon – Add IconMenu MHRP25N0010
|
|
49
|
+
- \[Added\]: Icon – Add IconMenu D95F3090, D95F3093, D06-2, D06-4, D95F3094, W102F1000, W103F1000, W104F1000, W105F1000, W106F1000, W107F1000, W108F1000
|
|
50
|
+
- \[Changed\]: ButtonMore - Allow custom ButtonMore
|
|
51
|
+
- \[Changed\]: Setting - Adjust the debounce/wait time when entering employee search information from 0.7s to 1.2s
|
|
52
|
+
- \[Changed\]: DatePicker, Dropdown - Adjust the behavior so that when DatePicker or Dropdown is in ReadOnly or Disabled state, the "Select" placeholder text and the clear (X) icon are still displayed
|
|
53
|
+
- \[Fixed\]: DateRangePicker - Display a popup for DateRangePicker
|
|
54
|
+
- \[Changed\]: MoneyInput - Add support for converting numbers into currency words/text in MoneyInput
|
|
55
|
+
- \[Changed\]: Popup - Add the showFullContent prop for Popup
|
|
56
|
+
|
|
44
57
|
## 1.4.64
|
|
45
58
|
- \[Added\]: Icon – Add Icon BloodMinus
|
|
46
59
|
- \[Changed\]: DatePicker - Allow manual input for the DatePicker (default value shows "Invalid Date" when typing) + add a "delayOnChange" prop.
|