diginet-core-ui 1.3.56 → 1.3.57
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/MHRM29N0005.svg +13 -0
- package/components/alert/index.js +25 -24
- package/components/alert/notify.js +8 -6
- package/components/button/icon.js +21 -21
- package/components/form-control/attachment/index.js +554 -671
- package/components/form-control/date-picker/index.js +75 -59
- package/components/form-control/dropdown/index.js +35 -35
- package/components/form-control/money-input/index.js +41 -31
- package/package.json +1 -1
- package/readme.md +7 -0
|
@@ -13,17 +13,17 @@ import { ButtonIcon, HelperText, InputBase, Label } from '../../index';
|
|
|
13
13
|
import Button from '../../button';
|
|
14
14
|
import Tooltip from '../../tooltip';
|
|
15
15
|
import { isValidDate } from '../calendar/function';
|
|
16
|
-
import { alignCenter, borderRadius4px, cursorPointer, displayBlock, displayNone, flexRow, justifyEnd, positionFixed } from '../../../styles/general';
|
|
17
|
-
import
|
|
18
|
-
import { useTheme } from '../../../theme';
|
|
16
|
+
import { alignCenter, borderRadius4px, cursorPointer, displayBlock, displayNone, flexRow, justifyEnd, parseWidth, positionFixed } from '../../../styles/general';
|
|
17
|
+
import theme from '../../../theme/settings';
|
|
19
18
|
const {
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
19
|
+
colors: {
|
|
20
|
+
system: {
|
|
21
|
+
white
|
|
22
|
+
}
|
|
23
|
+
},
|
|
24
|
+
spacing,
|
|
25
|
+
zIndex: zIndexCORE
|
|
26
|
+
} = theme;
|
|
27
27
|
const confirmText = getGlobal(['confirm']);
|
|
28
28
|
const cancelText = getGlobal(['cancel']);
|
|
29
29
|
|
|
@@ -85,9 +85,9 @@ const DatePicker = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
85
85
|
const displayValue = useRef();
|
|
86
86
|
const focusedValue = useRef(null);
|
|
87
87
|
const [, setDisplayValue] = useState(Date.now());
|
|
88
|
-
const [, setFocusedValue] = useState(Date.now());
|
|
88
|
+
const [, setFocusedValue] = useState(Date.now());
|
|
89
89
|
|
|
90
|
-
const
|
|
90
|
+
const _IconAreaCSS = IconAreaCSS(unique);
|
|
91
91
|
|
|
92
92
|
const handleDisplayValue = useCallback(value => {
|
|
93
93
|
displayValue.current = new Date(value);
|
|
@@ -160,7 +160,7 @@ const DatePicker = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
160
160
|
}
|
|
161
161
|
}
|
|
162
162
|
|
|
163
|
-
return
|
|
163
|
+
return PickerCSS.picker(style, left + 400 > innerWidth ? innerWidth - 400 : left, width).styles;
|
|
164
164
|
}; // const createPortal = () => {
|
|
165
165
|
// let portal = document.getElementById(unique.portal);
|
|
166
166
|
// if (!portal) {
|
|
@@ -183,7 +183,7 @@ const DatePicker = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
183
183
|
document.body.appendChild(background);
|
|
184
184
|
}
|
|
185
185
|
|
|
186
|
-
background.style.cssText =
|
|
186
|
+
background.style.cssText = PickerCSS.backGr;
|
|
187
187
|
return background;
|
|
188
188
|
};
|
|
189
189
|
|
|
@@ -241,7 +241,7 @@ const DatePicker = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
241
241
|
onClick: onCalendarClick
|
|
242
242
|
}), backGr.appendChild(picker));
|
|
243
243
|
setTimeout(() => {
|
|
244
|
-
Object.assign(picker.style, { ...
|
|
244
|
+
Object.assign(picker.style, { ...PickerCSS.active
|
|
245
245
|
});
|
|
246
246
|
window.addEventListener('resize', onResize);
|
|
247
247
|
window.addEventListener('scroll', onScroll);
|
|
@@ -260,7 +260,7 @@ const DatePicker = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
260
260
|
if (!backGr) return;
|
|
261
261
|
const picker = backGr.querySelector(`#${unique.picker}`);
|
|
262
262
|
if (!picker) return;
|
|
263
|
-
Object.assign(picker.style, { ...
|
|
263
|
+
Object.assign(picker.style, { ...PickerCSS.remove
|
|
264
264
|
});
|
|
265
265
|
|
|
266
266
|
if (pressESCToClose) {
|
|
@@ -330,7 +330,7 @@ const DatePicker = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
330
330
|
|
|
331
331
|
if (!el.classList.contains(unique.focus)) {
|
|
332
332
|
el.classList.add(unique.focus);
|
|
333
|
-
el.style.zIndex =
|
|
333
|
+
el.style.zIndex = zIndexCORE(2);
|
|
334
334
|
openPicker();
|
|
335
335
|
}
|
|
336
336
|
};
|
|
@@ -364,7 +364,7 @@ const DatePicker = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
364
364
|
};
|
|
365
365
|
|
|
366
366
|
const iconComp = jsx("div", {
|
|
367
|
-
css:
|
|
367
|
+
css: _IconAreaCSS,
|
|
368
368
|
ref: iconRef
|
|
369
369
|
}, jsx(ButtonIcon, {
|
|
370
370
|
disabled: disabled || readOnly,
|
|
@@ -372,7 +372,7 @@ const DatePicker = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
372
372
|
onClick: triggerFocus,
|
|
373
373
|
className: `${unique.icon} ${unique.icon}-accept`,
|
|
374
374
|
viewBox: true,
|
|
375
|
-
name: '
|
|
375
|
+
name: 'Calendar'
|
|
376
376
|
}), jsx(ButtonIcon, {
|
|
377
377
|
disabled: disabled || readOnly,
|
|
378
378
|
viewType: 'ghost',
|
|
@@ -384,13 +384,13 @@ const DatePicker = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
384
384
|
const endIcon = actionIconAt === 'end' && iconComp;
|
|
385
385
|
const startIcon = actionIconAt === 'start' && iconComp;
|
|
386
386
|
const footerMemo = jsx("div", {
|
|
387
|
-
css:
|
|
387
|
+
css: ControlContainerCSS,
|
|
388
388
|
className: unique.footer,
|
|
389
389
|
ref: footerRef
|
|
390
|
-
}, jsx(Button, {
|
|
390
|
+
}, jsx(Button, {
|
|
391
391
|
className: unique.cancel,
|
|
392
392
|
onClick: onCancel
|
|
393
|
-
}, cancelText), jsx(Button, {
|
|
393
|
+
}, cancelText), jsx(Button, {
|
|
394
394
|
color: 'info',
|
|
395
395
|
className: unique.confirm,
|
|
396
396
|
onClick: onConfirm
|
|
@@ -481,31 +481,51 @@ const DatePicker = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
481
481
|
closePicker();
|
|
482
482
|
};
|
|
483
483
|
}, [actionIconAt, clearAble, controls, disabled, displayFormat, displayAnotherMonth, max, min, readOnly, returnFormat, viewType]);
|
|
484
|
-
useImperativeHandle(reference, () =>
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
484
|
+
useImperativeHandle(reference, () => {
|
|
485
|
+
const currentRef = ref.current || {};
|
|
486
|
+
const _instance = {
|
|
487
|
+
get: () => {
|
|
488
|
+
return ref.current;
|
|
489
|
+
},
|
|
490
|
+
getInputContainer: () => {
|
|
491
|
+
return ipConRef.current;
|
|
492
|
+
},
|
|
493
|
+
getInput: () => {
|
|
494
|
+
return ipRef.current;
|
|
495
|
+
},
|
|
496
|
+
getCalendar: () => {
|
|
497
|
+
return calRef.current;
|
|
498
|
+
},
|
|
499
|
+
getIcon: () => {
|
|
500
|
+
return iconRef.current;
|
|
501
|
+
}
|
|
502
|
+
}; // methods
|
|
503
|
+
|
|
504
|
+
_instance.__proto__ = {}; // hidden methods
|
|
505
|
+
|
|
506
|
+
currentRef.instance = _instance;
|
|
507
|
+
|
|
508
|
+
currentRef.get = () => ref.current;
|
|
509
|
+
|
|
510
|
+
currentRef.getInputContainer = () => ipConRef.current;
|
|
511
|
+
|
|
512
|
+
currentRef.getInput = () => ipRef.current;
|
|
513
|
+
|
|
514
|
+
currentRef.getCalendar = () => calRef.current;
|
|
515
|
+
|
|
516
|
+
currentRef.getIcon = () => iconRef.current;
|
|
517
|
+
|
|
518
|
+
return currentRef;
|
|
519
|
+
});
|
|
501
520
|
return jsx(ControlComp, { ...props,
|
|
502
521
|
disabled: disabled,
|
|
503
522
|
error: isError,
|
|
504
523
|
ref: ref,
|
|
505
524
|
style: style
|
|
506
|
-
}, !!label && jsx(Label, {
|
|
525
|
+
}, !!label && jsx(Label, {
|
|
507
526
|
disabled: disabled,
|
|
508
|
-
required: required
|
|
527
|
+
required: required,
|
|
528
|
+
...labelProps
|
|
509
529
|
}, label), jsx(Tooltip, {
|
|
510
530
|
title: (ipRef === null || ipRef === void 0 ? void 0 : (_ipRef$current = ipRef.current) === null || _ipRef$current === void 0 ? void 0 : _ipRef$current.clientWidth) < 200 ? ipRef === null || ipRef === void 0 ? void 0 : (_ipRef$current2 = ipRef.current) === null || _ipRef$current2 === void 0 ? void 0 : _ipRef$current2.value : '',
|
|
511
531
|
style: {
|
|
@@ -524,11 +544,13 @@ const DatePicker = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
524
544
|
...inputStyle
|
|
525
545
|
},
|
|
526
546
|
startIcon: startIcon,
|
|
527
|
-
startIconProps: {
|
|
528
|
-
className: 'non-effect allow-disabled'
|
|
529
|
-
},
|
|
530
547
|
endIcon: endIcon
|
|
531
548
|
})), isError && jsx(HelperText, { ...errorProps,
|
|
549
|
+
style: {
|
|
550
|
+
minHeight: 16,
|
|
551
|
+
position: 'absolute',
|
|
552
|
+
top: '100%'
|
|
553
|
+
},
|
|
532
554
|
disabled: disabled
|
|
533
555
|
}, error));
|
|
534
556
|
}));
|
|
@@ -541,14 +563,8 @@ const activeStyle = {
|
|
|
541
563
|
pointerEvents: 'none',
|
|
542
564
|
display: 'block'
|
|
543
565
|
};
|
|
544
|
-
const buttonProps = {
|
|
545
|
-
style: {
|
|
546
|
-
margin: '0 2px',
|
|
547
|
-
padding: '7px 8px'
|
|
548
|
-
}
|
|
549
|
-
};
|
|
550
566
|
|
|
551
|
-
const
|
|
567
|
+
const IconAreaCSS = unique => css`
|
|
552
568
|
${flexRow};
|
|
553
569
|
${alignCenter};
|
|
554
570
|
color: inherit;
|
|
@@ -565,19 +581,19 @@ const iconAreaCSS = unique => css`
|
|
|
565
581
|
}
|
|
566
582
|
`;
|
|
567
583
|
|
|
568
|
-
const
|
|
584
|
+
const ControlContainerCSS = css`
|
|
569
585
|
${flexRow};
|
|
570
586
|
${justifyEnd};
|
|
571
|
-
margin: 0
|
|
587
|
+
margin: ${spacing([0, 4, 4])};
|
|
572
588
|
`;
|
|
573
|
-
const
|
|
574
|
-
backGr: `background-color: transparent; inset: 0px; pointer-events: auto; position: fixed; z-index: ${
|
|
589
|
+
const PickerCSS = {
|
|
590
|
+
backGr: `background-color: transparent; inset: 0px; pointer-events: auto; position: fixed; z-index: ${zIndexCORE(1)};`,
|
|
575
591
|
picker: (position, left, width) => css`
|
|
576
592
|
${positionFixed};
|
|
577
593
|
${borderRadius4px};
|
|
594
|
+
${parseWidth(width)};
|
|
578
595
|
background-color: ${white};
|
|
579
596
|
height: max-content;
|
|
580
|
-
width: ${width}px;
|
|
581
597
|
left: ${left}px;
|
|
582
598
|
top: ${position.top}px;
|
|
583
599
|
transform-origin: ${position.transformOrigin};
|
|
@@ -586,7 +602,7 @@ const pickerCSS = {
|
|
|
586
602
|
opacity: 0;
|
|
587
603
|
transform: scale(0);
|
|
588
604
|
transition: opacity 120ms cubic-bezier(0.4, 0, 0.2, 1) 0ms, transform 200ms cubic-bezier(0.4, 0, 0.2, 1) 0ms;
|
|
589
|
-
z-index: ${
|
|
605
|
+
z-index: ${zIndexCORE(2)};
|
|
590
606
|
`,
|
|
591
607
|
active: {
|
|
592
608
|
opacity: 1,
|
|
@@ -619,13 +635,13 @@ DatePicker.propTypes = {
|
|
|
619
635
|
/** Display the clear icon if true. */
|
|
620
636
|
clearAble: PropTypes.bool,
|
|
621
637
|
|
|
622
|
-
/** If
|
|
638
|
+
/** If `true`, the calendar will have a footer controls. */
|
|
623
639
|
controls: PropTypes.bool,
|
|
624
640
|
|
|
625
641
|
/** The default value of the component. */
|
|
626
642
|
defaultValue: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.string, PropTypes.object]),
|
|
627
643
|
|
|
628
|
-
/** If
|
|
644
|
+
/** If `true`, the form control will be disabled. */
|
|
629
645
|
disabled: PropTypes.bool,
|
|
630
646
|
|
|
631
647
|
/** Format to display value. */
|
|
@@ -1785,14 +1785,14 @@ Dropdown.propTypes = {
|
|
|
1785
1785
|
/** The icon to display if not found the icon follow `iconExpr`. */
|
|
1786
1786
|
iconDefault: PropTypes.string,
|
|
1787
1787
|
|
|
1788
|
-
/** Field name used for icon display.<br/>
|
|
1789
|
-
* Example:<br/>
|
|
1790
|
-
* string: 'icon'<br/>
|
|
1791
|
-
* object: {<br/>
|
|
1792
|
-
* key: 'icon',<br/>
|
|
1793
|
-
* prefix: 'https://imglink.com',<br/>
|
|
1794
|
-
* suffix: '.jpg'<br/>
|
|
1795
|
-
* }
|
|
1788
|
+
/** Field name used for icon display.<br/>
|
|
1789
|
+
* Example:<br/>
|
|
1790
|
+
* string: 'icon'<br/>
|
|
1791
|
+
* object: {<br/>
|
|
1792
|
+
* key: 'icon',<br/>
|
|
1793
|
+
* prefix: 'https://imglink.com',<br/>
|
|
1794
|
+
* suffix: '.jpg'<br/>
|
|
1795
|
+
* }
|
|
1796
1796
|
*/
|
|
1797
1797
|
iconExpr: PropTypes.oneOfType([PropTypes.string, PropTypes.shape({
|
|
1798
1798
|
key: PropTypes.string,
|
|
@@ -1807,9 +1807,9 @@ Dropdown.propTypes = {
|
|
|
1807
1807
|
/** The displayed value of component. */
|
|
1808
1808
|
value: PropTypes.oneOfType([PropTypes.string, PropTypes.number, PropTypes.array]),
|
|
1809
1809
|
|
|
1810
|
-
/** Field name used for text display in dropdown list.<br/>
|
|
1811
|
-
* Example: 'name', '{id} - {name}', '{age} age(s)'<br/>
|
|
1812
|
-
* Note: don't use 'id - name', return undefined
|
|
1810
|
+
/** Field name used for text display in dropdown list.<br/>
|
|
1811
|
+
* Example: 'name', '{id} - {name}', '{age} age(s)'<br/>
|
|
1812
|
+
* Note: don't use 'id - name', return undefined
|
|
1813
1813
|
*/
|
|
1814
1814
|
displayExpr: PropTypes.oneOfType([PropTypes.string, PropTypes.number, PropTypes.array]),
|
|
1815
1815
|
|
|
@@ -1819,10 +1819,10 @@ Dropdown.propTypes = {
|
|
|
1819
1819
|
/** The field name used for the returned result. */
|
|
1820
1820
|
valueExpr: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
|
|
1821
1821
|
|
|
1822
|
-
/**
|
|
1823
|
-
* Duration wait enter search content on search.<br/>
|
|
1824
|
-
* Example: 700 -> 700ms, '700ms' -> 700ms, '0.7s' -> 700ms, '1m' -> 60000ms
|
|
1825
|
-
* If `true`, used default delayOnInput.
|
|
1822
|
+
/**
|
|
1823
|
+
* Duration wait enter search content on search.<br/>
|
|
1824
|
+
* Example: 700 -> 700ms, '700ms' -> 700ms, '0.7s' -> 700ms, '1m' -> 60000ms
|
|
1825
|
+
* If `true`, used default delayOnInput.
|
|
1826
1826
|
*/
|
|
1827
1827
|
searchDelayTime: PropTypes.oneOfType([PropTypes.string, PropTypes.number, PropTypes.bool]),
|
|
1828
1828
|
|
|
@@ -1889,19 +1889,19 @@ Dropdown.propTypes = {
|
|
|
1889
1889
|
/** The array of elements that appear in the dropdown list. */
|
|
1890
1890
|
dataSource: PropTypes.array,
|
|
1891
1891
|
|
|
1892
|
-
/** Function displays items by custom.<br/>
|
|
1893
|
-
* renderItem={(data, index) => data.name + ' - ' + data.role}<br/>
|
|
1894
|
-
* --> such as: displayExpr={'name - role'}
|
|
1892
|
+
/** Function displays items by custom.<br/>
|
|
1893
|
+
* renderItem={(data, index) => data.name + ' - ' + data.role}<br/>
|
|
1894
|
+
* --> such as: displayExpr={'name - role'}
|
|
1895
1895
|
*/
|
|
1896
1896
|
renderItem: PropTypes.func,
|
|
1897
1897
|
|
|
1898
|
-
/** Function or field name used for display selected items, example:<br/>
|
|
1899
|
-
* renderSelectedItem={(data, index) => index + ' - ' + data.name}<br/>
|
|
1898
|
+
/** Function or field name used for display selected items, example:<br/>
|
|
1899
|
+
* renderSelectedItem={(data, index) => index + ' - ' + data.name}<br/>
|
|
1900
1900
|
*/
|
|
1901
1901
|
renderSelectedItem: PropTypes.oneOfType([PropTypes.func, PropTypes.string]),
|
|
1902
1902
|
|
|
1903
|
-
/** Callback fired when the input value changes.<br/>
|
|
1904
|
-
* if undefined: the filter function will run (default)
|
|
1903
|
+
/** Callback fired when the input value changes.<br/>
|
|
1904
|
+
* if undefined: the filter function will run (default)
|
|
1905
1905
|
*/
|
|
1906
1906
|
onInput: PropTypes.func,
|
|
1907
1907
|
|
|
@@ -1920,19 +1920,19 @@ Dropdown.propTypes = {
|
|
|
1920
1920
|
/** The contents in Dropdown box (Exp: TreeView). */
|
|
1921
1921
|
children: PropTypes.node,
|
|
1922
1922
|
|
|
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
|
reference: PropTypes.oneOfType([PropTypes.func, PropTypes.shape({
|
|
1938
1938
|
current: PropTypes.instanceOf(Element)
|
|
@@ -78,7 +78,7 @@ const num2WordsEn = n => {
|
|
|
78
78
|
|
|
79
79
|
let makeGroup = ([ones, tens, huns]) => {
|
|
80
80
|
return [num(huns) === 0 ? '' : a[huns] + ' hundred ', num(ones) === 0 ? b[tens] : b[tens] && b[tens] + '-' || '', a[tens + ones] || a[ones]].join('');
|
|
81
|
-
}; // "thousands" constructor; no real good names for this,
|
|
81
|
+
}; // "thousands" constructor; no real good names for this, I guess
|
|
82
82
|
|
|
83
83
|
|
|
84
84
|
let thousand = (group, i) => group === '' ? group : `${group} ${g[i]}`; // execute !
|
|
@@ -109,7 +109,6 @@ const MoneyInput = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
109
109
|
disabled,
|
|
110
110
|
readOnly,
|
|
111
111
|
multiline,
|
|
112
|
-
refs,
|
|
113
112
|
inputRef,
|
|
114
113
|
inputProps,
|
|
115
114
|
inputStyle,
|
|
@@ -122,6 +121,8 @@ const MoneyInput = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
122
121
|
onKeyUp,
|
|
123
122
|
validates,
|
|
124
123
|
convertToWords,
|
|
124
|
+
prefix,
|
|
125
|
+
suffix,
|
|
125
126
|
...props
|
|
126
127
|
}, reference) => {
|
|
127
128
|
const ref = useRef(null);
|
|
@@ -140,15 +141,6 @@ const MoneyInput = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
140
141
|
const decimalSymbol = separatorSymbol === '.' ? ',' : '.';
|
|
141
142
|
const thousandSeparatorPattern = new RegExp(`[0-9]|Backspace|Delete|Arrow|Home|End|Tab${decimalDigit === 0 ? '' : '|\\' + decimalSymbol}${disabledNegative ? '' : '|-'}`);
|
|
142
143
|
const isError = !!error && !value && value !== 0;
|
|
143
|
-
/* Start styled */
|
|
144
|
-
|
|
145
|
-
const MoneyInputRoot = css`
|
|
146
|
-
${displayBlock}
|
|
147
|
-
${positionRelative}
|
|
148
|
-
margin-bottom: 20px;
|
|
149
|
-
`;
|
|
150
|
-
/* End styled */
|
|
151
|
-
|
|
152
144
|
/* Start handler */
|
|
153
145
|
|
|
154
146
|
const getThousandSeparator = number => {
|
|
@@ -250,6 +242,12 @@ const MoneyInput = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
250
242
|
!!onKeyDown && onKeyDown(e);
|
|
251
243
|
};
|
|
252
244
|
|
|
245
|
+
const parseValueWithFix = value => {
|
|
246
|
+
if (!value) return value;
|
|
247
|
+
if (!prefix && !suffix) return value;
|
|
248
|
+
return `${prefix ? prefix + ' ' : ''}${value}${suffix ? ' ' + suffix : ''}`;
|
|
249
|
+
};
|
|
250
|
+
|
|
253
251
|
const onPasteHandler = e => {
|
|
254
252
|
var _local$current$clipbo;
|
|
255
253
|
|
|
@@ -365,8 +363,6 @@ const MoneyInput = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
365
363
|
};
|
|
366
364
|
|
|
367
365
|
useEffect(() => {
|
|
368
|
-
!!refs && refs(ref);
|
|
369
|
-
|
|
370
366
|
if (defaultValue !== undefined && defaultValue !== '') {
|
|
371
367
|
const v = getValueWithDecimal(defaultValue.toString().replace('.', decimalSymbol));
|
|
372
368
|
inputRef.current.value = thousandSeparator ? getThousandSeparator(v) : v;
|
|
@@ -385,13 +381,19 @@ const MoneyInput = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
385
381
|
const v = getValueWithDecimal(value.toString().replace('.', decimalSymbol));
|
|
386
382
|
|
|
387
383
|
if (convertToWords && !decimalDigit && (disabled || readOnly)) {
|
|
388
|
-
|
|
384
|
+
let valueConverted = getGlobal('helperInvalid');
|
|
385
|
+
|
|
386
|
+
if (Number.isInteger(value)) {
|
|
387
|
+
valueConverted = locale.get() === 'vi' ? num2WordsVi.convert(value) : num2WordsEn(value);
|
|
388
|
+
}
|
|
389
|
+
|
|
390
|
+
inputRef.current.value = parseValueWithFix(valueConverted);
|
|
389
391
|
} else {
|
|
390
|
-
inputRef.current.value = thousandSeparator ? getThousandSeparator(v) : v;
|
|
392
|
+
inputRef.current.value = parseValueWithFix(thousandSeparator ? getThousandSeparator(v) : v);
|
|
391
393
|
}
|
|
392
394
|
}
|
|
393
395
|
}
|
|
394
|
-
}, [disabled, readOnly, value]);
|
|
396
|
+
}, [disabled, readOnly, value, prefix, suffix]);
|
|
395
397
|
useEffect(() => {
|
|
396
398
|
const valueInput = inputRef.current.value;
|
|
397
399
|
inputRef.current.value = getValueWithDecimal(valueInput);
|
|
@@ -414,7 +416,7 @@ const MoneyInput = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
414
416
|
return jsx("div", {
|
|
415
417
|
ref: ref,
|
|
416
418
|
css: MoneyInputRoot,
|
|
417
|
-
className:
|
|
419
|
+
className: ['DGN-UI-Money-Input', className].join(' ').trim().replace(/\s+/g, ' '),
|
|
418
420
|
...props
|
|
419
421
|
}, !!label && jsx(Label, {
|
|
420
422
|
required: required,
|
|
@@ -448,6 +450,11 @@ const MoneyInput = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
448
450
|
disabled: disabled
|
|
449
451
|
}, validateResult));
|
|
450
452
|
}));
|
|
453
|
+
const MoneyInputRoot = css`
|
|
454
|
+
${displayBlock};
|
|
455
|
+
${positionRelative};
|
|
456
|
+
margin-bottom: 20px;
|
|
457
|
+
`;
|
|
451
458
|
MoneyInput.defaultProps = {
|
|
452
459
|
viewType: 'underlined',
|
|
453
460
|
valueTypeReturn: 'number',
|
|
@@ -529,19 +536,22 @@ MoneyInput.propTypes = {
|
|
|
529
536
|
/** Convert money from number to words when readOnly || disabled */
|
|
530
537
|
convertToWords: PropTypes.bool,
|
|
531
538
|
|
|
539
|
+
/** Add a string to first of value when convertToWords. */
|
|
540
|
+
prefix: PropTypes.string,
|
|
541
|
+
|
|
542
|
+
/** Add a string to last of value when convertToWords. */
|
|
543
|
+
suffix: PropTypes.string,
|
|
544
|
+
|
|
532
545
|
/** props of input in MoneyInput component */
|
|
533
546
|
inputProps: PropTypes.object,
|
|
534
547
|
|
|
535
548
|
/** style inline of input in MoneyInput component */
|
|
536
549
|
inputStyle: PropTypes.object,
|
|
537
550
|
|
|
538
|
-
/**
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
* * string: the validation rule. Example required.<br/>
|
|
543
|
-
* * object: the validation rule insist name, property, message. Example {name: 'min', compareValue: 9, message: 'Error'} or {max: 99}<br/>
|
|
544
|
-
* * array: the validation rule list, insist object/string
|
|
551
|
+
/** validation value, argument can:<br/>
|
|
552
|
+
* * string: the validation rule. Example required.<br/>
|
|
553
|
+
* * object: the validation rule insist name, property, message. Example {name: 'min', compareValue: 9, message: 'Error'} or {max: 99}<br/>
|
|
554
|
+
* * array: the validation rule list, insist object/string
|
|
545
555
|
*/
|
|
546
556
|
validates: PropTypes.oneOfType([PropTypes.string, PropTypes.object, PropTypes.array, PropTypes.func]),
|
|
547
557
|
|
|
@@ -554,13 +564,13 @@ MoneyInput.propTypes = {
|
|
|
554
564
|
/** on input function */
|
|
555
565
|
onInput: PropTypes.func,
|
|
556
566
|
|
|
557
|
-
/**
|
|
558
|
-
* on change function, return an object:<br/>
|
|
559
|
-
* {<br/>
|
|
560
|
-
* value: is a number or null value<br/>
|
|
561
|
-
* target.value: value of input<br/>
|
|
562
|
-
* ...element<br/>
|
|
563
|
-
* }
|
|
567
|
+
/**
|
|
568
|
+
* on change function, return an object:<br/>
|
|
569
|
+
* {<br/>
|
|
570
|
+
* value: is a number or null value<br/>
|
|
571
|
+
* target.value: value of input<br/>
|
|
572
|
+
* ...element<br/>
|
|
573
|
+
* }
|
|
564
574
|
*/
|
|
565
575
|
onChange: PropTypes.func,
|
|
566
576
|
|
package/package.json
CHANGED
package/readme.md
CHANGED
|
@@ -38,6 +38,13 @@ npm test
|
|
|
38
38
|
```
|
|
39
39
|
|
|
40
40
|
## Changelog
|
|
41
|
+
## 1.3.57
|
|
42
|
+
- \[Added\]: MenuIcon – MHRM29N0005
|
|
43
|
+
- \[Changed\]: MoneyInput – Update PagingSelector with new design
|
|
44
|
+
- \[Fixed\]: Attachment – Fix bug not set overflow when close
|
|
45
|
+
- \[Fixed\]: Alert, Notify – Fix bug not set overflow when close
|
|
46
|
+
- \[Fixed\]: Datepicker – Fix bug not set overflow when close
|
|
47
|
+
|
|
41
48
|
## 1.3.56
|
|
42
49
|
- \[Changed\]: PagingSelector – Update PagingSelector with new design
|
|
43
50
|
- \[Changed\]: NumberInput – Return e.valueString
|