diginet-core-ui 1.3.43 → 1.3.45
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/MHRM00N0005.svg +11 -0
- package/assets/images/menu/dhr/MHRM09N1010.svg +12 -0
- package/assets/images/menu/dhr/MHRM09N1015.svg +18 -0
- package/assets/images/menu/dhr/MHRM09N1020.svg +13 -0
- package/assets/images/menu/dhr/MHRM09N1400.svg +11 -0
- package/assets/images/menu/dhr/MHRP25L0101.svg +15 -0
- package/assets/images/menu/dhr/MHRP25L0501.svg +14 -0
- package/components/button/icon.js +211 -216
- package/components/chart/line/Axis.js +11 -10
- package/components/chart/line/Grid.js +4 -3
- package/components/chart/line/Path.js +11 -10
- package/components/chart/line/Point.js +107 -80
- package/components/chart/line/index.js +36 -17
- package/components/form-control/checkbox/index.js +5 -5
- package/components/form-control/date-picker/index.js +131 -119
- package/components/form-control/dropdown/index.js +3 -4
- package/components/form-control/dropdown-box/index.js +1 -1
- package/components/form-control/helper-text/index.js +35 -33
- package/components/form-control/input-base/index.js +318 -317
- package/components/form-control/text-input/index.js +4 -4
- package/components/form-control/time-picker/index.js +10 -19
- package/components/modal/modal.js +10 -4
- package/components/paging/page-info.js +78 -41
- package/components/slider/slider-container.js +150 -126
- package/components/slider/slider-item.js +84 -89
- package/components/tree-view/css.js +17 -16
- package/components/tree-view/index.js +41 -23
- package/package.json +1 -1
- package/readme.md +20 -0
- package/theme/settings.js +3 -1
|
@@ -9,15 +9,28 @@ import { getGlobal } from '../../../global';
|
|
|
9
9
|
import { date as moment, capitalizeSentenceCase, randomString, updatePosition } from '../../../utils';
|
|
10
10
|
import CalendarComp from '../calendar';
|
|
11
11
|
import ControlComp from '../control';
|
|
12
|
-
import theme from '../../../theme/settings';
|
|
13
12
|
import { ButtonIcon, HelperText, InputBase, Label } from '../../index';
|
|
14
13
|
import Button from '../../button';
|
|
15
14
|
import Tooltip from '../../tooltip';
|
|
16
15
|
import { isValidDate } from '../calendar/function';
|
|
16
|
+
import { alignCenter, borderRadius4px, cursorPointer, displayBlock, displayNone, flexRow, justifyEnd, positionFixed } from '../../../styles/general';
|
|
17
|
+
import { color as colors } from '../../../styles/colors';
|
|
17
18
|
import { useTheme } from '../../../theme';
|
|
18
19
|
const {
|
|
19
20
|
zIndex
|
|
20
21
|
} = useTheme();
|
|
22
|
+
const {
|
|
23
|
+
system: {
|
|
24
|
+
white
|
|
25
|
+
}
|
|
26
|
+
} = colors;
|
|
27
|
+
const confirmText = getGlobal(['confirm']);
|
|
28
|
+
const cancelText = getGlobal(['cancel']);
|
|
29
|
+
|
|
30
|
+
const formatValue = (value, format, utc = false) => {
|
|
31
|
+
return moment(value).format(format, utc);
|
|
32
|
+
};
|
|
33
|
+
|
|
21
34
|
const DatePicker = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
22
35
|
actionIconAt,
|
|
23
36
|
clearAble,
|
|
@@ -74,91 +87,8 @@ const DatePicker = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
74
87
|
const [, setDisplayValue] = useState(Date.now());
|
|
75
88
|
const [, setFocusedValue] = useState(Date.now()); // const [actionsState, setActionsState] = useState(true);
|
|
76
89
|
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
return ref.current;
|
|
80
|
-
},
|
|
81
|
-
getInputContainer: () => {
|
|
82
|
-
return ipConRef.current;
|
|
83
|
-
},
|
|
84
|
-
getInput: () => {
|
|
85
|
-
return ipRef.current;
|
|
86
|
-
},
|
|
87
|
-
getCalendar: () => {
|
|
88
|
-
return calRef.current;
|
|
89
|
-
},
|
|
90
|
-
getIcon: () => {
|
|
91
|
-
return iconRef.current;
|
|
92
|
-
}
|
|
93
|
-
}));
|
|
94
|
-
const confirmText = getGlobal(['confirm']);
|
|
95
|
-
const cancelText = getGlobal(['cancel']);
|
|
96
|
-
const iconAreaCSS = css`
|
|
97
|
-
align-items: center;
|
|
98
|
-
color: inherit;
|
|
99
|
-
display: flex;
|
|
100
|
-
.${unique.icon} {
|
|
101
|
-
cursor: pointer;
|
|
102
|
-
opacity: 0;
|
|
103
|
-
transition: display 50ms cubic-bezier(0.4, 0, 0.2, 1) 0ms,
|
|
104
|
-
opacity 300ms cubic-bezier(0.4, 0, 0.2, 1) 50ms;
|
|
105
|
-
display: none;
|
|
106
|
-
will-change: display, opacity;
|
|
107
|
-
}
|
|
108
|
-
.${unique.icon}-accept {
|
|
109
|
-
opacity: 1;
|
|
110
|
-
display: block;
|
|
111
|
-
}
|
|
112
|
-
`;
|
|
113
|
-
const hiddenStyle = {
|
|
114
|
-
opacity: 0,
|
|
115
|
-
display: 'none'
|
|
116
|
-
};
|
|
117
|
-
const activeStyle = {
|
|
118
|
-
opacity: 1,
|
|
119
|
-
pointerEvents: 'none',
|
|
120
|
-
display: 'block'
|
|
121
|
-
};
|
|
122
|
-
const pickerCSS = {
|
|
123
|
-
backGr: `background-color: transparent; inset: 0px; pointer-events: auto; position: fixed; z-index: ${zIndex(1)};`,
|
|
124
|
-
picker: (position, left, width) => css`
|
|
125
|
-
background-color: ${theme.colors.white};
|
|
126
|
-
border-radius: ${theme.border.radius};
|
|
127
|
-
height: max-content;
|
|
128
|
-
left: ${left}px;
|
|
129
|
-
max-width: 400px;
|
|
130
|
-
min-width: ${window.innerWidth <= 599 ? 280 : 314}px;
|
|
131
|
-
opacity: 0;
|
|
132
|
-
position: fixed;
|
|
133
|
-
top: ${position.top}px;
|
|
134
|
-
transform: scale(0);
|
|
135
|
-
transform-origin: ${position.transformOrigin};
|
|
136
|
-
transition: opacity 120ms cubic-bezier(0.4, 0, 0.2, 1) 0ms,
|
|
137
|
-
transform 200ms cubic-bezier(0.4, 0, 0.2, 1) 0ms;
|
|
138
|
-
width: ${width}px;
|
|
139
|
-
z-index: ${zIndex(2)};
|
|
140
|
-
`,
|
|
141
|
-
active: {
|
|
142
|
-
opacity: 1,
|
|
143
|
-
transform: 'scale(1)'
|
|
144
|
-
},
|
|
145
|
-
remove: {
|
|
146
|
-
opacity: 0,
|
|
147
|
-
pointerEvents: 'none',
|
|
148
|
-
transform: 'scale(0)'
|
|
149
|
-
}
|
|
150
|
-
};
|
|
151
|
-
const controlContainerCSS = css`
|
|
152
|
-
display: flex;
|
|
153
|
-
justify-content: flex-end;
|
|
154
|
-
margin: 0 16px 16px;
|
|
155
|
-
`;
|
|
156
|
-
const buttonProps = {
|
|
157
|
-
style: {
|
|
158
|
-
margin: '0 2px',
|
|
159
|
-
padding: '7px 8px'
|
|
160
|
-
}
|
|
161
|
-
};
|
|
90
|
+
const _iconAreaCSS = iconAreaCSS(unique);
|
|
91
|
+
|
|
162
92
|
const handleDisplayValue = useCallback(value => {
|
|
163
93
|
displayValue.current = new Date(value);
|
|
164
94
|
setDisplayValue();
|
|
@@ -190,10 +120,6 @@ const DatePicker = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
190
120
|
closePicker();
|
|
191
121
|
};
|
|
192
122
|
|
|
193
|
-
const formatValue = (value, format, utc = false) => {
|
|
194
|
-
return moment(value).format(format, utc);
|
|
195
|
-
};
|
|
196
|
-
|
|
197
123
|
const setInputValue = e => {
|
|
198
124
|
ipRef.current.value = capitalizeSentenceCase(formatValue(e.value, displayFormat));
|
|
199
125
|
if (clearAble) onSwap(false);
|
|
@@ -213,7 +139,8 @@ const DatePicker = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
213
139
|
|
|
214
140
|
const getPickerStyle = () => {
|
|
215
141
|
const {
|
|
216
|
-
innerHeight
|
|
142
|
+
innerHeight,
|
|
143
|
+
innerWidth
|
|
217
144
|
} = window;
|
|
218
145
|
const {
|
|
219
146
|
left,
|
|
@@ -233,7 +160,7 @@ const DatePicker = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
233
160
|
}
|
|
234
161
|
}
|
|
235
162
|
|
|
236
|
-
return pickerCSS.picker(style, left, width).styles;
|
|
163
|
+
return pickerCSS.picker(style, left + 400 > innerWidth ? innerWidth - 400 : left, width).styles;
|
|
237
164
|
}; // const createPortal = () => {
|
|
238
165
|
// let portal = document.getElementById(unique.portal);
|
|
239
166
|
// if (!portal) {
|
|
@@ -268,7 +195,7 @@ const DatePicker = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
268
195
|
};
|
|
269
196
|
|
|
270
197
|
const pressESCHandler = event => {
|
|
271
|
-
if (event.key === 'Escape') {
|
|
198
|
+
if (event.key === 'Escape' || event.key === 'Tab') {
|
|
272
199
|
onClickOutside({
|
|
273
200
|
target: null
|
|
274
201
|
});
|
|
@@ -437,15 +364,17 @@ const DatePicker = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
437
364
|
};
|
|
438
365
|
|
|
439
366
|
const iconComp = jsx("div", {
|
|
440
|
-
css:
|
|
367
|
+
css: _iconAreaCSS,
|
|
441
368
|
ref: iconRef
|
|
442
369
|
}, jsx(ButtonIcon, {
|
|
370
|
+
disabled: disabled || readOnly,
|
|
443
371
|
viewType: 'ghost',
|
|
444
372
|
onClick: triggerFocus,
|
|
445
373
|
className: `${unique.icon} ${unique.icon}-accept`,
|
|
446
374
|
viewBox: true,
|
|
447
375
|
name: 'CalendarNew'
|
|
448
376
|
}), jsx(ButtonIcon, {
|
|
377
|
+
disabled: disabled || readOnly,
|
|
449
378
|
viewType: 'ghost',
|
|
450
379
|
onClick: onClear,
|
|
451
380
|
className: `${unique.icon} ${unique.icon}-cancel`,
|
|
@@ -552,6 +481,23 @@ const DatePicker = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
552
481
|
closePicker();
|
|
553
482
|
};
|
|
554
483
|
}, [actionIconAt, clearAble, controls, disabled, displayFormat, displayAnotherMonth, max, min, readOnly, returnFormat, viewType]);
|
|
484
|
+
useImperativeHandle(reference, () => ({
|
|
485
|
+
get: () => {
|
|
486
|
+
return ref.current;
|
|
487
|
+
},
|
|
488
|
+
getInputContainer: () => {
|
|
489
|
+
return ipConRef.current;
|
|
490
|
+
},
|
|
491
|
+
getInput: () => {
|
|
492
|
+
return ipRef.current;
|
|
493
|
+
},
|
|
494
|
+
getCalendar: () => {
|
|
495
|
+
return calRef.current;
|
|
496
|
+
},
|
|
497
|
+
getIcon: () => {
|
|
498
|
+
return iconRef.current;
|
|
499
|
+
}
|
|
500
|
+
}));
|
|
555
501
|
return jsx(ControlComp, { ...props,
|
|
556
502
|
disabled: disabled,
|
|
557
503
|
error: isError,
|
|
@@ -586,6 +532,72 @@ const DatePicker = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
586
532
|
disabled: disabled
|
|
587
533
|
}, error));
|
|
588
534
|
}));
|
|
535
|
+
const hiddenStyle = {
|
|
536
|
+
opacity: 0,
|
|
537
|
+
display: 'none'
|
|
538
|
+
};
|
|
539
|
+
const activeStyle = {
|
|
540
|
+
opacity: 1,
|
|
541
|
+
pointerEvents: 'none',
|
|
542
|
+
display: 'block'
|
|
543
|
+
};
|
|
544
|
+
const buttonProps = {
|
|
545
|
+
style: {
|
|
546
|
+
margin: '0 2px',
|
|
547
|
+
padding: '7px 8px'
|
|
548
|
+
}
|
|
549
|
+
};
|
|
550
|
+
|
|
551
|
+
const iconAreaCSS = unique => css`
|
|
552
|
+
${flexRow};
|
|
553
|
+
${alignCenter};
|
|
554
|
+
color: inherit;
|
|
555
|
+
.${unique.icon} {
|
|
556
|
+
${displayNone};
|
|
557
|
+
${cursorPointer};
|
|
558
|
+
opacity: 0;
|
|
559
|
+
transition: display 50ms cubic-bezier(0.4, 0, 0.2, 1) 0ms, opacity 300ms cubic-bezier(0.4, 0, 0.2, 1) 50ms;
|
|
560
|
+
will-change: display, opacity;
|
|
561
|
+
}
|
|
562
|
+
.${unique.icon}-accept {
|
|
563
|
+
${displayBlock};
|
|
564
|
+
opacity: 1;
|
|
565
|
+
}
|
|
566
|
+
`;
|
|
567
|
+
|
|
568
|
+
const controlContainerCSS = css`
|
|
569
|
+
${flexRow};
|
|
570
|
+
${justifyEnd};
|
|
571
|
+
margin: 0 16px 16px;
|
|
572
|
+
`;
|
|
573
|
+
const pickerCSS = {
|
|
574
|
+
backGr: `background-color: transparent; inset: 0px; pointer-events: auto; position: fixed; z-index: ${zIndex(1)};`,
|
|
575
|
+
picker: (position, left, width) => css`
|
|
576
|
+
${positionFixed};
|
|
577
|
+
${borderRadius4px};
|
|
578
|
+
background-color: ${white};
|
|
579
|
+
height: max-content;
|
|
580
|
+
width: ${width}px;
|
|
581
|
+
left: ${left}px;
|
|
582
|
+
top: ${position.top}px;
|
|
583
|
+
transform-origin: ${position.transformOrigin};
|
|
584
|
+
max-width: 400px;
|
|
585
|
+
min-width: ${window.innerWidth <= 599 ? 280 : 314}px;
|
|
586
|
+
opacity: 0;
|
|
587
|
+
transform: scale(0);
|
|
588
|
+
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: ${zIndex(2)};
|
|
590
|
+
`,
|
|
591
|
+
active: {
|
|
592
|
+
opacity: 1,
|
|
593
|
+
transform: 'scale(1)'
|
|
594
|
+
},
|
|
595
|
+
remove: {
|
|
596
|
+
opacity: 0,
|
|
597
|
+
pointerEvents: 'none',
|
|
598
|
+
transform: 'scale(0)'
|
|
599
|
+
}
|
|
600
|
+
};
|
|
589
601
|
DatePicker.defaultProps = {
|
|
590
602
|
actionIconAt: 'end',
|
|
591
603
|
clearAble: false,
|
|
@@ -601,76 +613,76 @@ DatePicker.defaultProps = {
|
|
|
601
613
|
viewType: 'underlined'
|
|
602
614
|
};
|
|
603
615
|
DatePicker.propTypes = {
|
|
604
|
-
/**
|
|
616
|
+
/** Action icons position. */
|
|
605
617
|
actionIconAt: PropTypes.oneOf(['end', 'start']),
|
|
606
618
|
|
|
607
|
-
/**
|
|
619
|
+
/** Display the clear icon if true. */
|
|
608
620
|
clearAble: PropTypes.bool,
|
|
609
621
|
|
|
610
|
-
/**
|
|
622
|
+
/** If 'true' the calendar will have a footer controls. */
|
|
611
623
|
controls: PropTypes.bool,
|
|
612
624
|
|
|
613
|
-
/**
|
|
625
|
+
/** The default value of the component. */
|
|
614
626
|
defaultValue: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.string, PropTypes.object]),
|
|
615
627
|
|
|
616
|
-
/**
|
|
628
|
+
/** If 'true' the form control will be disabled. */
|
|
617
629
|
disabled: PropTypes.bool,
|
|
618
630
|
|
|
619
|
-
/**
|
|
631
|
+
/** Format to display value. */
|
|
620
632
|
displayFormat: PropTypes.oneOfType([PropTypes.oneOf(['DD/MM/YYYY', 'MM/DD/YYYY', 'YYYY/MM/DD', 'DD-MM-YYYY', 'MM-DD-YYYY', 'YYYY-MM-DD']), PropTypes.string]),
|
|
621
633
|
|
|
622
|
-
/**
|
|
634
|
+
/** View days of previous or next month. */
|
|
623
635
|
displayAnotherMonth: PropTypes.bool,
|
|
624
636
|
|
|
625
|
-
/**
|
|
626
|
-
error: PropTypes.string,
|
|
637
|
+
/** Error of the form control. */
|
|
638
|
+
error: PropTypes.oneOfType([PropTypes.bool, PropTypes.string]),
|
|
627
639
|
|
|
628
|
-
/**
|
|
640
|
+
/** InputProps are properties of the input element. */
|
|
629
641
|
inputProps: PropTypes.object,
|
|
630
642
|
|
|
631
|
-
/**
|
|
643
|
+
/** InputStyle is style of input element. */
|
|
632
644
|
inputStyle: PropTypes.object,
|
|
633
645
|
|
|
634
|
-
/**
|
|
646
|
+
/** Content of the label element. */
|
|
635
647
|
label: PropTypes.oneOfType([PropTypes.string, PropTypes.node]),
|
|
636
648
|
|
|
637
|
-
/**
|
|
649
|
+
/** LabelProps are properties if the label element. */
|
|
638
650
|
labelProps: PropTypes.object,
|
|
639
651
|
|
|
640
|
-
/**
|
|
652
|
+
/** Min value of date picker. */
|
|
641
653
|
min: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.string, PropTypes.object]),
|
|
642
654
|
|
|
643
|
-
/**
|
|
655
|
+
/** Max value of date picker. */
|
|
644
656
|
max: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.string, PropTypes.object]),
|
|
645
657
|
|
|
646
|
-
/**
|
|
658
|
+
/** A callback function when value input change. */
|
|
647
659
|
onChange: PropTypes.func,
|
|
648
660
|
|
|
649
|
-
/**
|
|
661
|
+
/** Hints for input. */
|
|
650
662
|
placeholder: PropTypes.string,
|
|
651
663
|
|
|
652
|
-
/**
|
|
664
|
+
/** Allow close Popup when press ESC. */
|
|
653
665
|
pressESCToClose: PropTypes.bool,
|
|
654
666
|
|
|
655
|
-
/**
|
|
667
|
+
/** Status read only of input. */
|
|
656
668
|
readOnly: PropTypes.bool,
|
|
657
669
|
|
|
658
|
-
/**
|
|
670
|
+
/** Required state of the form control. */
|
|
659
671
|
required: PropTypes.bool,
|
|
660
672
|
|
|
661
|
-
/**
|
|
673
|
+
/** Format of the returned value. */
|
|
662
674
|
returnFormat: PropTypes.oneOfType([PropTypes.oneOf(['DD/MM/YYYY', 'MM/DD/YYYY', 'YYYY/MM/DD', 'DD-MM-YYYY', 'MM-DD-YYYY', 'YYYY-MM-DD']), PropTypes.string]),
|
|
663
675
|
|
|
664
|
-
/**
|
|
676
|
+
/** Style inline of component. */
|
|
665
677
|
style: PropTypes.object,
|
|
666
678
|
|
|
667
|
-
/**
|
|
679
|
+
/** Text align of the input. */
|
|
668
680
|
textAlign: PropTypes.oneOf(['center', 'end', 'start']),
|
|
669
681
|
|
|
670
|
-
/**
|
|
682
|
+
/** Value of the component. */
|
|
671
683
|
value: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.string, PropTypes.array, PropTypes.object]),
|
|
672
684
|
|
|
673
|
-
/**
|
|
685
|
+
/** View type of the form control. */
|
|
674
686
|
viewType: PropTypes.oneOf(['outlined', 'underlined'])
|
|
675
687
|
};
|
|
676
688
|
export default DatePicker;
|
|
@@ -459,7 +459,7 @@ const Dropdown = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
459
459
|
const icon = getIconFromData(data);
|
|
460
460
|
|
|
461
461
|
if (multiple && selectBox) {
|
|
462
|
-
const checked = currentValue[unique].includes(value);
|
|
462
|
+
const checked = Array.isArray(currentValue[unique]) ? currentValue[unique].includes(value) : [currentValue[unique]].includes(value);
|
|
463
463
|
items.push(jsx("div", {
|
|
464
464
|
key: index,
|
|
465
465
|
css: !itemDisabled ? _DropdownItemCSS : [DisabledCSS, _DropdownItemCSS],
|
|
@@ -616,7 +616,7 @@ const Dropdown = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
616
616
|
let item = null;
|
|
617
617
|
|
|
618
618
|
if (multiple && selectBox) {
|
|
619
|
-
const checked = currentValue[unique].includes(value);
|
|
619
|
+
const checked = Array.isArray(currentValue[unique]) ? currentValue[unique].includes(value) : [currentValue[unique]].includes(value);
|
|
620
620
|
item = jsx(Checkbox, {
|
|
621
621
|
defaultChecked: checked,
|
|
622
622
|
style: {
|
|
@@ -899,7 +899,7 @@ const Dropdown = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
899
899
|
}
|
|
900
900
|
}
|
|
901
901
|
|
|
902
|
-
if (closeAfterSelect) {
|
|
902
|
+
if (closeAfterSelect === true || closeAfterSelect === undefined && !multiple) {
|
|
903
903
|
closeDropdown();
|
|
904
904
|
}
|
|
905
905
|
};
|
|
@@ -1757,7 +1757,6 @@ Dropdown.defaultProps = {
|
|
|
1757
1757
|
multiple: false,
|
|
1758
1758
|
allowSearch: false,
|
|
1759
1759
|
selectBox: false,
|
|
1760
|
-
closeAfterSelect: true,
|
|
1761
1760
|
inputProps: {},
|
|
1762
1761
|
formStyle: {},
|
|
1763
1762
|
dataSource: [],
|
|
@@ -5,66 +5,68 @@ import { memo, forwardRef } from 'react';
|
|
|
5
5
|
import PropTypes from 'prop-types';
|
|
6
6
|
import { jsx, css } from '@emotion/core';
|
|
7
7
|
import { Typography } from '../../';
|
|
8
|
-
import theme from '../../../theme/settings';
|
|
9
8
|
import { getGlobal } from '../../../global';
|
|
9
|
+
import theme from '../../../theme/settings';
|
|
10
|
+
const {
|
|
11
|
+
colors: {
|
|
12
|
+
system: {
|
|
13
|
+
disabled: systemDisabled
|
|
14
|
+
},
|
|
15
|
+
semantic: {
|
|
16
|
+
success,
|
|
17
|
+
warning,
|
|
18
|
+
danger,
|
|
19
|
+
info
|
|
20
|
+
}
|
|
21
|
+
},
|
|
22
|
+
spacing
|
|
23
|
+
} = theme;
|
|
24
|
+
const colorMap = new Map([['default', danger], ['success', success], ['warning', warning], ['danger', danger], ['info', info]]);
|
|
10
25
|
const HelperText = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
11
26
|
disabled,
|
|
12
27
|
status,
|
|
13
28
|
className,
|
|
29
|
+
style,
|
|
14
30
|
children,
|
|
15
|
-
|
|
31
|
+
id
|
|
16
32
|
}, ref) => {
|
|
17
|
-
|
|
18
|
-
const HelperTextRoot = css`
|
|
19
|
-
margin-top: 4px;
|
|
20
|
-
&.info {
|
|
21
|
-
color: ${theme.colors.info};
|
|
22
|
-
}
|
|
23
|
-
&.success {
|
|
24
|
-
color: ${theme.colors.success};
|
|
25
|
-
}
|
|
26
|
-
&.warning {
|
|
27
|
-
color: ${theme.colors.warning};
|
|
28
|
-
}
|
|
29
|
-
&.danger {
|
|
30
|
-
color: ${theme.colors.danger};
|
|
31
|
-
}
|
|
32
|
-
&.disabled {
|
|
33
|
-
color: ${theme.colors.disabled};
|
|
34
|
-
}
|
|
35
|
-
`;
|
|
36
|
-
/* End styled */
|
|
37
|
-
|
|
33
|
+
const color = colorMap.get(status);
|
|
38
34
|
return jsx(Typography, {
|
|
39
35
|
ref: ref,
|
|
36
|
+
id: id,
|
|
40
37
|
type: 'p3',
|
|
41
|
-
color:
|
|
38
|
+
color: disabled ? systemDisabled : color,
|
|
42
39
|
fullWidth: false,
|
|
43
|
-
css:
|
|
44
|
-
className: ['DGN-UI-HelperText', className
|
|
45
|
-
|
|
40
|
+
css: HelperTextRootCSS,
|
|
41
|
+
className: ['DGN-UI-HelperText', className].join(' ').trim().replace(/\s+/g, ' '),
|
|
42
|
+
style: style,
|
|
43
|
+
lineClamp: 1
|
|
46
44
|
}, typeof children === 'boolean' ? getGlobal('thisFieldIsRequired') : children);
|
|
47
45
|
}));
|
|
46
|
+
const HelperTextRootCSS = css`
|
|
47
|
+
margin-top: ${spacing()}px;
|
|
48
|
+
`;
|
|
48
49
|
HelperText.defaultProps = {
|
|
49
50
|
disabled: false,
|
|
50
51
|
status: 'default',
|
|
51
52
|
className: '',
|
|
53
|
+
style: {},
|
|
52
54
|
children: ''
|
|
53
55
|
};
|
|
54
56
|
HelperText.propTypes = {
|
|
55
|
-
/**
|
|
57
|
+
/** If true, the component is disabled. */
|
|
56
58
|
disabled: PropTypes.bool,
|
|
57
59
|
|
|
58
60
|
/** status type to display color for input (only available for type is inform) */
|
|
59
61
|
status: PropTypes.oneOf(['default', 'warning', 'success', 'danger', 'info']),
|
|
60
62
|
|
|
61
|
-
/**
|
|
63
|
+
/** Class for component. */
|
|
62
64
|
className: PropTypes.string,
|
|
63
65
|
|
|
64
|
-
/**
|
|
65
|
-
|
|
66
|
+
/** Style inline of component. */
|
|
67
|
+
style: PropTypes.object,
|
|
66
68
|
|
|
67
|
-
/**
|
|
68
|
-
|
|
69
|
+
/** Content to display in component. */
|
|
70
|
+
children: PropTypes.oneOfType([PropTypes.string, PropTypes.bool])
|
|
69
71
|
};
|
|
70
72
|
export default HelperText;
|