diginet-core-ui 1.3.65 → 1.3.66
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/index.js +13 -14
- package/components/button/more.js +16 -16
- package/components/button/ripple-effect.js +2 -0
- package/components/card/card.js +30 -28
- package/components/card/index.js +1 -0
- package/components/chart/Pie/Circle.js +2 -1
- package/components/chart/Pie-v2/Circle.js +4 -5
- package/components/chart/Pie-v2/Sector.js +21 -27
- package/components/chart/Pie-v2/Sectors.js +16 -15
- package/components/chart/Pie-v2/index.js +141 -16
- package/components/chart/bar/Bar.js +20 -18
- package/components/chart/bar/Labels.js +20 -18
- package/components/chart/bar/index.js +3 -2
- package/components/chart/bar-v2/Bar.js +23 -21
- package/components/chart/bar-v2/Labels.js +21 -19
- package/components/chart/bar-v2/index.js +3 -2
- package/components/chart/line/Labels.js +21 -18
- package/components/chart/line/Path.js +7 -6
- package/components/chart/line/Point.js +2 -0
- package/components/chart/line/Title.js +1 -2
- package/components/chart/line/index.js +22 -1
- package/components/chart/line-v2/Labels.js +21 -18
- package/components/chart/line-v2/Path.js +15 -14
- package/components/chart/line-v2/Point.js +4 -2
- package/components/chart/line-v2/Title.js +1 -2
- package/components/chart/line-v2/index.js +8 -7
- package/components/check-text/index.js +22 -21
- package/components/chip/attach.js +8 -8
- package/components/form-control/calendar/index.js +17 -17
- package/components/form-control/calendar/range.js +33 -33
- package/components/form-control/dropdown/index.js +2 -1
- package/components/form-control/form/index.js +1 -0
- package/components/form-control/input-base/index.js +39 -30
- package/components/form-control/label/index.js +67 -43
- package/components/form-control/number-input/index.js +16 -29
- package/components/form-control/phone-input/index.js +20 -34
- package/components/form-control/text-input/index.js +9 -6
- package/components/form-control/time-picker/index.js +2 -1
- package/components/form-control/time-picker/swiper.js +80 -76
- package/components/form-view/helper-text.js +1 -0
- package/components/grid/Col.js +1 -1
- package/components/index.js +4 -1
- package/components/modal/index.js +1 -0
- package/components/others/extra/index.js +2 -0
- package/components/others/scrollbar/index.js +25 -26
- package/components/popover/body.js +74 -0
- package/components/popover/footer.js +76 -0
- package/components/popover/header.js +79 -0
- package/components/popover/index.js +119 -86
- package/components/popup/danger_popup.js +3 -1
- package/components/popup/index.js +2 -2
- package/components/popup/proposals_popup.js +1 -0
- package/components/progress/circular.js +14 -12
- package/components/status/index.js +92 -89
- package/components/tooltip/index.js +8 -3
- package/components/transfer/index.js +86 -94
- package/icons/effect.js +32 -34
- package/icons/general/clock/clock.js +1 -0
- package/icons/general/color-handler/background.js +1 -0
- package/icons/general/color-handler/text.js +1 -0
- package/icons/general/emoji/emoji.js +1 -0
- package/icons/general/font-properties/bold.js +1 -0
- package/icons/general/font-properties/font-family.js +1 -0
- package/icons/general/font-properties/font-size.js +1 -0
- package/icons/general/font-properties/italic.js +1 -0
- package/icons/general/font-properties/underline.js +1 -0
- package/icons/general/hyperlink/hyperlink.js +1 -0
- package/icons/general/indent/decrease.js +1 -0
- package/icons/general/indent/increase.js +1 -0
- package/icons/general/list/bullets.js +1 -0
- package/icons/general/list/numbering.js +1 -0
- package/icons/general/picture/picture.js +1 -0
- package/icons/general/steps/redo.js +1 -0
- package/icons/general/steps/undo.js +1 -0
- package/icons/general/text-align/center.js +1 -0
- package/icons/general/text-align/justify.js +1 -0
- package/icons/general/text-align/left.js +1 -0
- package/icons/general/text-align/right.js +1 -0
- package/icons/menu/dhr.js +2 -1
- package/icons/menu/erp.js +1 -0
- package/package.json +1 -1
- package/readme.md +15 -0
- package/styles/animation.js +2 -1
- package/styles/color-helper.js +108 -106
- package/styles/font.js +5 -4
- package/theme/index.js +1 -3
- package/theme/make-styles.js +25 -105
- package/theme/theme-provider.js +0 -9
- package/utils/console.js +0 -1
- package/utils/error/error.js +2 -3
- package/utils/index.js +0 -1
- package/utils/promisify.js +2 -1
- package/utils/renderIcon.js +13 -11
- package/styles/media-queries.js +0 -10
- package/theme/with-styles.js +0 -15
- package/theme/with-theme.js +0 -9
- package/utils/number.js +0 -63
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/** @jsxRuntime classic */
|
|
2
2
|
|
|
3
3
|
/** @jsx jsx */
|
|
4
|
-
import { Fragment, memo, useMemo, useRef, useState
|
|
4
|
+
import { Fragment, memo, useMemo, useRef, useState } from 'react';
|
|
5
5
|
import PropTypes from 'prop-types';
|
|
6
6
|
import { jsx, css } from '@emotion/core';
|
|
7
7
|
import Chip from './';
|
|
@@ -27,7 +27,7 @@ const AttachChip = /*#__PURE__*/memo(({
|
|
|
27
27
|
}) => {
|
|
28
28
|
const moreActionRef = useRef(null);
|
|
29
29
|
const [open, setOpen] = useState(false);
|
|
30
|
-
const MoreAction = css`
|
|
30
|
+
const MoreAction = css`
|
|
31
31
|
display: none;
|
|
32
32
|
justify-content: space-evenly;
|
|
33
33
|
align-items: center;
|
|
@@ -36,7 +36,7 @@ const AttachChip = /*#__PURE__*/memo(({
|
|
|
36
36
|
right: -1px;
|
|
37
37
|
width: 120px;
|
|
38
38
|
height: 36px;
|
|
39
|
-
background: #
|
|
39
|
+
background: #ffffff;
|
|
40
40
|
box-shadow: 0px 2px 2px rgba(0, 0, 0, 0.1);
|
|
41
41
|
border-radius: 4px;
|
|
42
42
|
&.DGN-UI-Chip-show {
|
|
@@ -156,11 +156,11 @@ const AttachChip = /*#__PURE__*/memo(({
|
|
|
156
156
|
}))), attachView);
|
|
157
157
|
});
|
|
158
158
|
AttachChip.propTypes = {
|
|
159
|
-
/** the file info, such as:<br/>
|
|
160
|
-
* {<br/>
|
|
161
|
-
* URL: https://url.com/pathname,<br/>
|
|
162
|
-
* FileName: file.name,<br/>
|
|
163
|
-
* }
|
|
159
|
+
/** the file info, such as:<br/>
|
|
160
|
+
* {<br/>
|
|
161
|
+
* URL: https://url.com/pathname,<br/>
|
|
162
|
+
* FileName: file.name,<br/>
|
|
163
|
+
* }
|
|
164
164
|
*/
|
|
165
165
|
file: PropTypes.shape({
|
|
166
166
|
URL: PropTypes.string.isRequired,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/** @jsxRuntime classic */
|
|
2
2
|
|
|
3
3
|
/** @jsx jsx */
|
|
4
|
-
import {
|
|
4
|
+
import { jsx } from '@emotion/core';
|
|
5
5
|
import PropTypes from 'prop-types';
|
|
6
6
|
import { forwardRef, memo, useCallback, useEffect, useImperativeHandle, useRef, useState } from 'react';
|
|
7
7
|
import { date as moment } from '../../../utils';
|
|
@@ -41,8 +41,8 @@ const Calendar = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
41
41
|
limit: 'DGN-UI-Calendar-Day-limit'
|
|
42
42
|
}
|
|
43
43
|
};
|
|
44
|
-
/**
|
|
45
|
-
* START REFERENCE
|
|
44
|
+
/**
|
|
45
|
+
* START REFERENCE
|
|
46
46
|
*/
|
|
47
47
|
|
|
48
48
|
const ref = useRef(null);
|
|
@@ -61,12 +61,12 @@ const Calendar = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
61
61
|
};
|
|
62
62
|
const firstDayOfMax = new Date(new Date(max).setDate(1)).setHours(0, 0, 0, 0);
|
|
63
63
|
const firstDayOfMin = new Date(new Date(min).setDate(1)).setHours(0, 0, 0, 0);
|
|
64
|
-
/**
|
|
65
|
-
* END REFERENCE
|
|
64
|
+
/**
|
|
65
|
+
* END REFERENCE
|
|
66
66
|
*/
|
|
67
67
|
|
|
68
|
-
/**
|
|
69
|
-
* START FUNCTION
|
|
68
|
+
/**
|
|
69
|
+
* START FUNCTION
|
|
70
70
|
*/
|
|
71
71
|
|
|
72
72
|
const onUpdateNavigatorValue = useCallback(value => {
|
|
@@ -152,12 +152,12 @@ const Calendar = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
152
152
|
onUpdateCalendar(time, navigatorRefs, min, max, tableRef.current, activeValue.current, unique, displayAnotherMonth, onDayClick, onUpdateNavigatorValue);
|
|
153
153
|
}
|
|
154
154
|
};
|
|
155
|
-
/**
|
|
156
|
-
* END FUNCTION
|
|
155
|
+
/**
|
|
156
|
+
* END FUNCTION
|
|
157
157
|
*/
|
|
158
158
|
|
|
159
|
-
/**
|
|
160
|
-
* START EFFECT
|
|
159
|
+
/**
|
|
160
|
+
* START EFFECT
|
|
161
161
|
*/
|
|
162
162
|
|
|
163
163
|
|
|
@@ -198,12 +198,12 @@ const Calendar = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
198
198
|
onUpdate(activeValue.current);
|
|
199
199
|
}
|
|
200
200
|
}, [onClick, min, max]);
|
|
201
|
-
/**
|
|
202
|
-
* END FUNCTION
|
|
201
|
+
/**
|
|
202
|
+
* END FUNCTION
|
|
203
203
|
*/
|
|
204
204
|
|
|
205
|
-
/**
|
|
206
|
-
* START COMPONENT
|
|
205
|
+
/**
|
|
206
|
+
* START COMPONENT
|
|
207
207
|
*/
|
|
208
208
|
|
|
209
209
|
const tableMemo = jsx("div", {
|
|
@@ -212,8 +212,8 @@ const Calendar = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
212
212
|
className: unique.table.table,
|
|
213
213
|
ref: tableRef
|
|
214
214
|
}, renderHeader(unique), jsx("tbody", null)));
|
|
215
|
-
/**
|
|
216
|
-
* END COMPONENT
|
|
215
|
+
/**
|
|
216
|
+
* END COMPONENT
|
|
217
217
|
*/
|
|
218
218
|
|
|
219
219
|
return jsx("div", { ...props,
|
|
@@ -4,16 +4,9 @@
|
|
|
4
4
|
import { css, jsx } from '@emotion/core';
|
|
5
5
|
import PropTypes from 'prop-types';
|
|
6
6
|
import { forwardRef, memo, useCallback, useEffect, useImperativeHandle, useRef, useState } from 'react';
|
|
7
|
-
import { render } from 'react-dom';
|
|
8
7
|
import { Divider } from '../..';
|
|
9
|
-
import { getGlobal } from '../../../global';
|
|
10
|
-
import Icon from '../../../icons';
|
|
11
|
-
import locale from '../../../locale';
|
|
12
8
|
import theme from '../../../theme/settings';
|
|
13
|
-
import { date as moment, randomString } from '../../../utils';
|
|
14
|
-
import Typography from '../../typography';
|
|
15
9
|
import { generateCalendarCSS, isValidDate, onUpdateCalendar, renderHeader, renderNavigator } from './function';
|
|
16
|
-
import Calendar from './index';
|
|
17
10
|
const CalendarRange = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
18
11
|
actions,
|
|
19
12
|
defaultValue,
|
|
@@ -104,19 +97,19 @@ const CalendarRange = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
104
97
|
}
|
|
105
98
|
};
|
|
106
99
|
const containerCSS = css`
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
100
|
+
background-color: ${theme.colors.white};
|
|
101
|
+
border-radius: ${theme.border.radius};
|
|
102
|
+
box-shadow: ${theme.boxShadows.large};
|
|
103
|
+
display: flex;
|
|
104
|
+
@media only screen and (max-width: 599px) {
|
|
105
|
+
flex-direction: column;
|
|
106
|
+
.${unique.divider} {
|
|
107
|
+
height: 1px !important;
|
|
108
|
+
margin: 0px 16px !important;
|
|
109
|
+
width: calc(100% - 32px) !important;
|
|
110
|
+
}
|
|
117
111
|
}
|
|
118
|
-
|
|
119
|
-
`;
|
|
112
|
+
`;
|
|
120
113
|
const dividerProps = {
|
|
121
114
|
direction: 'vertical',
|
|
122
115
|
className: unique.divider,
|
|
@@ -172,8 +165,8 @@ const CalendarRange = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
172
165
|
}
|
|
173
166
|
};
|
|
174
167
|
|
|
175
|
-
const onDayHover =
|
|
176
|
-
|
|
168
|
+
const onDayHover = () => {// const hoverTime = parseInt(e.target.dataset.time, 10);
|
|
169
|
+
// console.log(hoverTime);
|
|
177
170
|
};
|
|
178
171
|
|
|
179
172
|
const onPickerHover = e => {
|
|
@@ -182,19 +175,17 @@ const CalendarRange = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
182
175
|
} else {
|
|
183
176
|
clearHovering(e.currentTarget);
|
|
184
177
|
}
|
|
185
|
-
};
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
178
|
+
}; // const onUpdateFrom = (value) => {
|
|
179
|
+
// const newValue = new Date(value).setHours(0, 0, 0, 0);
|
|
180
|
+
// onUpdateActiveValueFr(newValue);
|
|
181
|
+
// onUpdateCalendar(newValue, navigatorFromRefs, min, max, tableFrRef.current, [activeValueFr.current, activeValueTo.current], unique.from, displayAnotherMonth, onCalFrClick, onUpdateNavigatorValueFr);
|
|
182
|
+
// };
|
|
183
|
+
// const onUpdateTo = (value) => {
|
|
184
|
+
// const newValue = new Date(value).setHours(0, 0, 0, 0);
|
|
185
|
+
// onUpdateActiveValueTo(newValue);
|
|
186
|
+
// onUpdateCalendar(newValue, navigatorToRefs, min, max, tableToRef.current, [activeValueFr.current, activeValueTo.current], unique.to, displayAnotherMonth, onCalToClick, onUpdateNavigatorValueTo);
|
|
187
|
+
// };
|
|
192
188
|
|
|
193
|
-
const onUpdateTo = value => {
|
|
194
|
-
const newValue = new Date(value).setHours(0, 0, 0, 0);
|
|
195
|
-
onUpdateActiveValueTo(newValue);
|
|
196
|
-
onUpdateCalendar(newValue, navigatorToRefs, min, max, tableToRef.current, [activeValueFr.current, activeValueTo.current], unique.to, displayAnotherMonth, onCalToClick, onUpdateNavigatorValueTo);
|
|
197
|
-
};
|
|
198
189
|
|
|
199
190
|
const onUpdateNavigatorValue = values => {
|
|
200
191
|
const fr = new Date(values[0]);
|
|
@@ -254,6 +245,15 @@ const CalendarRange = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
254
245
|
onUpdate(defaultValue);
|
|
255
246
|
}
|
|
256
247
|
}, []);
|
|
248
|
+
useImperativeHandle(reference, () => {
|
|
249
|
+
const currentRef = ref.current || {};
|
|
250
|
+
const _instance = {}; // methods
|
|
251
|
+
|
|
252
|
+
_instance.__proto__ = {}; // hidden methods
|
|
253
|
+
|
|
254
|
+
currentRef.instance = _instance;
|
|
255
|
+
return currentRef;
|
|
256
|
+
});
|
|
257
257
|
return jsx("div", { ...props,
|
|
258
258
|
className: unique.container,
|
|
259
259
|
onMouseOver: onPickerHover,
|
|
@@ -358,6 +358,7 @@ const Dropdown = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
358
358
|
}
|
|
359
359
|
|
|
360
360
|
document.documentElement.style.overflow = 'auto';
|
|
361
|
+
if (searchRef.current) lastSearchRef.current = '';
|
|
361
362
|
onClosed === null || onClosed === void 0 ? void 0 : onClosed();
|
|
362
363
|
};
|
|
363
364
|
|
|
@@ -1411,7 +1412,7 @@ const DropdownInputCSS = (viewType, multiple, placeholder, itemMultipleSize, ren
|
|
|
1411
1412
|
${borderNone};
|
|
1412
1413
|
${paragraph1};
|
|
1413
1414
|
width: 100%;
|
|
1414
|
-
color: ${
|
|
1415
|
+
color: ${main};
|
|
1415
1416
|
padding-top: 0;
|
|
1416
1417
|
padding-bottom: ${viewType !== 'outlined' ? 0 : 'inherit'};
|
|
1417
1418
|
padding-left: ${viewType !== 'outlined' ? 0 : spacing([4])};
|
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
/** @jsxRuntime classic */
|
|
2
2
|
|
|
3
3
|
/** @jsx jsx */
|
|
4
|
-
import { memo, useEffect,
|
|
4
|
+
import { forwardRef, memo, useEffect, useImperativeHandle, useMemo, useRef } from 'react';
|
|
5
5
|
import useInput from '../../../utils/useInput';
|
|
6
6
|
import PropTypes from 'prop-types';
|
|
7
7
|
import { jsx, css } from '@emotion/core';
|
|
8
|
-
import { renderIcon } from '../../../utils';
|
|
9
8
|
import theme from '../../../theme/settings';
|
|
10
9
|
import { typography } from '../../../styles/typography';
|
|
11
10
|
const {
|
|
12
11
|
colors
|
|
13
12
|
} = theme;
|
|
14
13
|
import { getGlobal } from '../../../global';
|
|
14
|
+
import Icon from '../../../icons';
|
|
15
15
|
const InputBase = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
16
16
|
type,
|
|
17
17
|
viewType,
|
|
@@ -557,26 +557,46 @@ const InputBase = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
557
557
|
onFocus: onFocus,
|
|
558
558
|
...bind
|
|
559
559
|
}));
|
|
560
|
+
const StartIcon = useMemo(() => {
|
|
561
|
+
let node = startIcon;
|
|
562
|
+
|
|
563
|
+
if (typeof node === 'string') {
|
|
564
|
+
node = jsx(Icon, {
|
|
565
|
+
name: startIcon,
|
|
566
|
+
style: iconStyle
|
|
567
|
+
});
|
|
568
|
+
}
|
|
569
|
+
|
|
570
|
+
return jsx("div", {
|
|
571
|
+
css: inputBaseIconCSS,
|
|
572
|
+
...startIconProps,
|
|
573
|
+
className: ['start-icon', startIconProps.className ? startIconProps.className : ''].join(' ').trim()
|
|
574
|
+
}, node);
|
|
575
|
+
}, [startIcon]);
|
|
576
|
+
const EndIcon = useMemo(() => {
|
|
577
|
+
let node = endIcon;
|
|
578
|
+
|
|
579
|
+
if (typeof node === 'string') {
|
|
580
|
+
node = jsx(Icon, {
|
|
581
|
+
name: endIcon,
|
|
582
|
+
style: iconStyle
|
|
583
|
+
});
|
|
584
|
+
}
|
|
585
|
+
|
|
586
|
+
return jsx("div", {
|
|
587
|
+
css: inputBaseIconCSS,
|
|
588
|
+
...endIconProps,
|
|
589
|
+
className: ['end-icon', endIconProps.className ? endIconProps.className : ''].join(' ').trim()
|
|
590
|
+
}, ' ', node, ' ');
|
|
591
|
+
}, [endIcon]);
|
|
560
592
|
const InputComp = jsx("div", {
|
|
561
593
|
css: inputBaseRoot,
|
|
562
594
|
ref: ref,
|
|
563
595
|
...props,
|
|
564
596
|
className: ['DGN-UI-InputBase', newClass, className, status].join(' ').trim()
|
|
565
|
-
}, jsx("div", {
|
|
597
|
+
}, startIcon && StartIcon, jsx("div", {
|
|
566
598
|
css: inputBaseCSS
|
|
567
|
-
},
|
|
568
|
-
css: inputBaseIconCSS,
|
|
569
|
-
...startIconProps,
|
|
570
|
-
className: 'start-icon ' + (startIconProps.className ? startIconProps.className : '')
|
|
571
|
-
}, renderIcon(startIcon, typeof startIcon === 'string' && startIcon.length < 20 ? 'effect' : null, {
|
|
572
|
-
onClick: startIconProps.onClick ? null : () => inputBaseRef.current.focus(),
|
|
573
|
-
style: {
|
|
574
|
-
padding: 0,
|
|
575
|
-
minHeight: '24px',
|
|
576
|
-
...iconStyle
|
|
577
|
-
},
|
|
578
|
-
viewBox: true
|
|
579
|
-
})), jsx("input", {
|
|
599
|
+
}, jsx("input", {
|
|
580
600
|
type: type,
|
|
581
601
|
autoComplete: autoComplete,
|
|
582
602
|
placeholder: isEnabled ? placeholder : '',
|
|
@@ -593,18 +613,7 @@ const InputBase = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
593
613
|
onBlur: onBlur,
|
|
594
614
|
onFocus: onFocus,
|
|
595
615
|
...bind
|
|
596
|
-
})),
|
|
597
|
-
css: inputBaseIconCSS,
|
|
598
|
-
...endIconProps,
|
|
599
|
-
className: 'end-icon ' + (endIconProps.className ? endIconProps.className : '')
|
|
600
|
-
}, renderIcon(endIcon, null, {
|
|
601
|
-
style: {
|
|
602
|
-
padding: 0,
|
|
603
|
-
minHeight: '24px',
|
|
604
|
-
...iconStyle
|
|
605
|
-
},
|
|
606
|
-
viewBox: true
|
|
607
|
-
})));
|
|
616
|
+
})), endIcon && EndIcon);
|
|
608
617
|
const InputBaseComp = multiline ? MultipleInputComp : InputComp;
|
|
609
618
|
/* End component */
|
|
610
619
|
|
|
@@ -690,10 +699,10 @@ InputBase.propTypes = {
|
|
|
690
699
|
required: PropTypes.bool,
|
|
691
700
|
|
|
692
701
|
/** icon element display in the left of input */
|
|
693
|
-
startIcon: PropTypes.
|
|
702
|
+
startIcon: PropTypes.oneOfType([PropTypes.string, PropTypes.node]),
|
|
694
703
|
|
|
695
704
|
/** icon element display in the right of input */
|
|
696
|
-
endIcon: PropTypes.
|
|
705
|
+
endIcon: PropTypes.oneOfType([PropTypes.string, PropTypes.node]),
|
|
697
706
|
|
|
698
707
|
/** props of input in InputBase component */
|
|
699
708
|
inputProps: PropTypes.object,
|
|
@@ -1,59 +1,77 @@
|
|
|
1
1
|
/** @jsxRuntime classic */
|
|
2
2
|
|
|
3
3
|
/** @jsx jsx */
|
|
4
|
-
import { memo, useMemo,
|
|
4
|
+
import { forwardRef, memo, useImperativeHandle, useMemo, useRef } from 'react';
|
|
5
5
|
import PropTypes from 'prop-types';
|
|
6
6
|
import { jsx, css } from '@emotion/core';
|
|
7
|
+
import OptionWrapper from '../../others/option-wrapper';
|
|
7
8
|
import { Typography } from '../../';
|
|
8
|
-
import {
|
|
9
|
+
import { flexRow } from '../../../styles/general';
|
|
10
|
+
import theme from '../../../theme/settings';
|
|
9
11
|
const {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
12
|
+
colors: {
|
|
13
|
+
system: {
|
|
14
|
+
disabled: systemDisabled
|
|
15
|
+
},
|
|
16
|
+
semantic: {
|
|
17
|
+
danger
|
|
18
|
+
},
|
|
19
|
+
text: {
|
|
20
|
+
normal_label
|
|
21
|
+
}
|
|
18
22
|
}
|
|
19
|
-
} =
|
|
23
|
+
} = theme;
|
|
20
24
|
const Label = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
21
|
-
required,
|
|
22
|
-
children,
|
|
23
25
|
disabled,
|
|
24
26
|
readOnly,
|
|
27
|
+
required,
|
|
25
28
|
className,
|
|
29
|
+
children,
|
|
30
|
+
type,
|
|
26
31
|
lineClamp,
|
|
32
|
+
hoverTooltip,
|
|
33
|
+
id,
|
|
34
|
+
color,
|
|
27
35
|
...props
|
|
28
|
-
},
|
|
29
|
-
const
|
|
30
|
-
|
|
36
|
+
}, reference) => {
|
|
37
|
+
const ref = useRef(null);
|
|
38
|
+
useImperativeHandle(reference, () => ({
|
|
39
|
+
element: ref.current,
|
|
40
|
+
instance: {}
|
|
41
|
+
}));
|
|
42
|
+
return useMemo(() => jsx("div", {
|
|
43
|
+
css: LabelContainerCSS,
|
|
44
|
+
className: 'DGN-UI-Label-Container'
|
|
45
|
+
}, jsx(Typography, {
|
|
46
|
+
css: LabelRootCSS,
|
|
31
47
|
ref: ref,
|
|
48
|
+
id: id,
|
|
49
|
+
fullWidth: false,
|
|
32
50
|
mapping: 'label',
|
|
33
|
-
|
|
51
|
+
color: readOnly || disabled ? systemDisabled : color,
|
|
34
52
|
lineClamp: lineClamp,
|
|
53
|
+
hoverTooltip: hoverTooltip,
|
|
54
|
+
type: type,
|
|
35
55
|
className: ['DGN-UI-Label', className, readOnly ? 'read-only' : '', disabled ? 'disabled' : ''].join(' ').trim().replace(/\s+/g, ' '),
|
|
36
56
|
...props
|
|
37
|
-
}, children, required
|
|
57
|
+
}, children), required && jsx("span", {
|
|
38
58
|
className: 'required'
|
|
39
|
-
}, " *")
|
|
40
|
-
return LabelComp;
|
|
59
|
+
}, " *")), [disabled, readOnly, required, className, children, type, lineClamp, hoverTooltip, color, props]);
|
|
41
60
|
}));
|
|
42
|
-
const
|
|
43
|
-
|
|
44
|
-
margin: 0px;
|
|
45
|
-
&.read-only,
|
|
46
|
-
&.disabled {
|
|
47
|
-
color: ${systemDisabled};
|
|
48
|
-
}
|
|
61
|
+
const LabelContainerCSS = css`
|
|
62
|
+
${flexRow};
|
|
49
63
|
.required {
|
|
50
64
|
color: ${danger};
|
|
51
65
|
}
|
|
66
|
+
`;
|
|
67
|
+
const LabelRootCSS = css`
|
|
68
|
+
min-height: 16px;
|
|
52
69
|
& + .DGN-UI-InputBase.outlined {
|
|
53
70
|
margin-top: 2px;
|
|
54
71
|
}
|
|
72
|
+
word-break: break-all;
|
|
55
73
|
`;
|
|
56
|
-
Label.defaultProps = {
|
|
74
|
+
Label.defaultProps = {
|
|
57
75
|
type: 'h6',
|
|
58
76
|
color: normal_label,
|
|
59
77
|
lineClamp: 1,
|
|
@@ -63,28 +81,34 @@ Label.defaultProps = { ...Typography.defaultProps,
|
|
|
63
81
|
className: '',
|
|
64
82
|
children: ''
|
|
65
83
|
};
|
|
84
|
+
const arrTypeTypography = ['t1', 't2', 't3', 't4', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'p1', 'p2', 'p3', 'title1', 'title2', 'title3', 'title4', 'heading1', 'heading2', 'heading3', 'heading4', 'heading5', 'heading6', 'paragraph1', 'paragraph2', 'paragraph3'];
|
|
66
85
|
Label.propTypes = {
|
|
67
|
-
/**
|
|
86
|
+
/** The content of the component. */
|
|
87
|
+
children: PropTypes.node,
|
|
88
|
+
|
|
89
|
+
/** Class for component. */
|
|
90
|
+
className: PropTypes.string,
|
|
91
|
+
|
|
92
|
+
/** If `true`, the component is disabled. */
|
|
68
93
|
disabled: PropTypes.bool,
|
|
69
94
|
|
|
70
|
-
/**
|
|
95
|
+
/** If `true`, the component is readonly. */
|
|
71
96
|
readOnly: PropTypes.bool,
|
|
72
97
|
|
|
73
|
-
/**
|
|
98
|
+
/** If `true`, the label will indicate that the input is required. */
|
|
74
99
|
required: PropTypes.bool,
|
|
75
100
|
|
|
76
|
-
/**
|
|
77
|
-
|
|
101
|
+
/** Consult [Typography's](https://core.diginet.com.vn/ui/?path=/docs/typography) documents. */
|
|
102
|
+
color: PropTypes.string,
|
|
78
103
|
|
|
79
|
-
/**
|
|
80
|
-
|
|
104
|
+
/** Consult [Typography's](https://core.diginet.com.vn/ui/?path=/docs/typography) documents. */
|
|
105
|
+
lineClamp: PropTypes.number,
|
|
106
|
+
|
|
107
|
+
/** Consult [Typography's](https://core.diginet.com.vn/ui/?path=/docs/typography) documents. */
|
|
108
|
+
hoverTooltip: PropTypes.bool,
|
|
81
109
|
|
|
82
|
-
/**
|
|
83
|
-
|
|
84
|
-
// Reuse from Typography
|
|
85
|
-
type: Typography.propTypes.type,
|
|
86
|
-
lineClamp: Typography.propTypes.lineClamp,
|
|
87
|
-
hoverTooltip: Typography.propTypes.hoverTooltip,
|
|
88
|
-
color: Typography.propTypes.color
|
|
110
|
+
/** Consult [Typography's](https://core.diginet.com.vn/ui/?path=/docs/typography) documents. */
|
|
111
|
+
type: PropTypes.oneOf(arrTypeTypography)
|
|
89
112
|
};
|
|
90
|
-
export
|
|
113
|
+
export { Label };
|
|
114
|
+
export default OptionWrapper(Label);
|
|
@@ -24,17 +24,13 @@ const NumberInput = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
24
24
|
startIcon,
|
|
25
25
|
endIcon,
|
|
26
26
|
valueTypeReturn,
|
|
27
|
-
autoComplete,
|
|
28
27
|
autoFocus,
|
|
29
28
|
disabled,
|
|
30
29
|
readOnly,
|
|
31
30
|
refs,
|
|
32
31
|
inputRef,
|
|
33
32
|
inputProps,
|
|
34
|
-
iconStyle,
|
|
35
33
|
inputStyle,
|
|
36
|
-
labelProps,
|
|
37
|
-
errorProps,
|
|
38
34
|
error,
|
|
39
35
|
format,
|
|
40
36
|
onChange,
|
|
@@ -61,14 +57,14 @@ const NumberInput = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
61
57
|
const separatorSymbol = useRef(decimalSymbol === '.' ? ',' : '.');
|
|
62
58
|
const updated = useRef(false);
|
|
63
59
|
const [decimalDigit, setDecimalDigit] = useState(decimalDigitProp);
|
|
64
|
-
const formatPattern = new RegExp(`[0-9]|Backspace|Delete|Arrow|Home|End|Tab${decimalDigit === 0 ? '' : '|\\' + decimalSymbol}${disabledNegative ? '' : '
|
|
60
|
+
const formatPattern = new RegExp(`[0-9]|Backspace|Delete|Arrow|Home|End|Tab${decimalDigit === 0 ? '' : '|\\' + decimalSymbol}${disabledNegative ? '' : '|-'}`);
|
|
65
61
|
/* Start styled */
|
|
66
62
|
|
|
67
63
|
const NumberInputRoot = css`
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
64
|
+
display: block;
|
|
65
|
+
position: relative;
|
|
66
|
+
margin-bottom: 20px;
|
|
67
|
+
`;
|
|
72
68
|
/* End styled */
|
|
73
69
|
|
|
74
70
|
/* Start handler */
|
|
@@ -552,9 +548,6 @@ NumberInput.propTypes = {
|
|
|
552
548
|
/** error for input */
|
|
553
549
|
error: PropTypes.oneOfType([PropTypes.bool, PropTypes.string]),
|
|
554
550
|
|
|
555
|
-
/** type auto complete of input (like new-password) */
|
|
556
|
-
autoComplete: PropTypes.string,
|
|
557
|
-
|
|
558
551
|
/** icon at start */
|
|
559
552
|
startIcon: PropTypes.any,
|
|
560
553
|
|
|
@@ -585,29 +578,23 @@ NumberInput.propTypes = {
|
|
|
585
578
|
/** style inline of input in NumberInput component */
|
|
586
579
|
inputStyle: PropTypes.object,
|
|
587
580
|
|
|
588
|
-
/**
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
* the format to display value<br/>
|
|
596
|
-
* * function: value => function(value)<br/>
|
|
597
|
-
* * string: Example: '#.###', '# ###', '#.### 2%', '#.### %%'<br/>
|
|
598
|
-
* #: integer part digit<br/>
|
|
599
|
-
* . / '_': separator symbol<br/>
|
|
600
|
-
* %: decimal digit, '2%' === '%%'
|
|
581
|
+
/**
|
|
582
|
+
* the format to display value<br/>
|
|
583
|
+
* * function: value => function(value)<br/>
|
|
584
|
+
* * string: Example: '#.###', '# ###', '#.### 2%', '#.### %%'<br/>
|
|
585
|
+
* #: integer part digit<br/>
|
|
586
|
+
* . / '_': separator symbol<br/>
|
|
587
|
+
* %: decimal digit, '2%' === '%%'
|
|
601
588
|
*/
|
|
602
589
|
format: PropTypes.oneOfType([PropTypes.string, PropTypes.func]),
|
|
603
590
|
|
|
604
591
|
/** The function to get ref of NumberInput component */
|
|
605
592
|
refs: PropTypes.func,
|
|
606
593
|
|
|
607
|
-
/** validation value, argument can:<br/>
|
|
608
|
-
* * string: the validation rule. Example required.<br/>
|
|
609
|
-
* * object: the validation rule insist name, property, message. Example {name: 'min', compareValue: 9, message: 'Error'} or {max: 99}<br/>
|
|
610
|
-
* * array: the validation rule list, insist object/string
|
|
594
|
+
/** validation value, argument can:<br/>
|
|
595
|
+
* * string: the validation rule. Example required.<br/>
|
|
596
|
+
* * object: the validation rule insist name, property, message. Example {name: 'min', compareValue: 9, message: 'Error'} or {max: 99}<br/>
|
|
597
|
+
* * array: the validation rule list, insist object/string
|
|
611
598
|
*/
|
|
612
599
|
validates: PropTypes.oneOfType([PropTypes.string, PropTypes.object, PropTypes.array, PropTypes.func]),
|
|
613
600
|
|