diginet-core-ui 1.3.68 → 1.3.69-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.
@@ -12,6 +12,7 @@ import Ripple from './ripple-effect';
12
12
  import CircularProgress from '../progress/circular';
13
13
  import Icon from '../../icons';
14
14
  import { flexRow, alignCenter, justifyCenter, positionRelative, borderRadius4px, borderBox, noPadding, noBorder, cursorPointer, overflowHidden, pointerEventsNone, outlineNone, userSelectNone, backgroundTransparent, inlineFlex, noMargin } from '../../styles/general';
15
+ import { classNames } from '../../utils';
15
16
  import theme from '../../theme/settings';
16
17
  const {
17
18
  colors: {
@@ -33,7 +34,8 @@ const {
33
34
  },
34
35
  typography: {
35
36
  uppercase
36
- }
37
+ },
38
+ spacing
37
39
  } = theme;
38
40
  export const getRippleColor = (color, viewType, colors) => {
39
41
  if (!isColor(color) && !isColorName(color)) {
@@ -83,12 +85,13 @@ export const getClassNameFromColor = color => {
83
85
  return !isColor(color) && !isColorName(color) ? color : 'custom-color';
84
86
  };
85
87
  const colorMap = new Map([['primary', active], ['success', success], ['warning', warning], ['danger', danger], ['info', info]]);
86
- const iconSizeMap = new Map([['tiny', '16px'], ['small', '20px'], ['medium', '24px'], ['large', '32px'], ['giant', '40px']]);
87
- const paddingSizeMap = new Map([['tiny', '4px 8px'], ['small', '6px 12px'], ['medium', '8px 16px'], ['large', '8px 20px'], ['giant', '8px 24px']]);
88
- const outlinedPaddingSizeMap = new Map([['tiny', '3px 7px'], ['small', '5px 11px'], ['medium', '7px 15px'], ['large', '7px 19px'], ['giant', '7px 23px']]);
88
+ const iconSizeMap = new Map([['tiny', spacing([4])], ['small', spacing([5])], ['medium', spacing([6])], ['large', spacing([8])], ['giant', spacing([10])]]);
89
+ const paddingSizeMap = new Map([['tiny', spacing([1, 2])], ['small', spacing([1.5, 3])], ['medium', spacing([2, 4])], ['large', spacing([2, 5])], ['giant', spacing([2, 6])]]);
90
+ const outlinedPaddingSizeMap = new Map([['tiny', spacing([0.75, 1.75])], ['small', spacing([1.25, 2.75])], ['medium', spacing([1.75, 3.75])], ['large', spacing([1.75, 4.75])], ['giant', spacing([1.75, 5.75])]]);
89
91
  const iconMarginSizeMap = new Map([['tiny', '4px'], ['small', '4px'], ['medium', '4px'], ['large', '6px'], ['giant', '8px']]);
90
92
  const typographySizeMap = new Map([['tiny', 'heading5'], ['small', 'heading5'], ['medium', 'heading4'], ['large', 'heading2'], ['giant', 'heading1']]);
91
93
  const minHeightSizeMap = new Map([['tiny', '24px'], ['small', '32px'], ['medium', '40px'], ['large', '48px'], ['giant', '56px']]);
94
+ const minHeightSizeLinkMap = new Map([['tiny', '16px'], ['small', '20px'], ['medium', '24px'], ['large', '32px'], ['giant', '40px']]);
92
95
  const alphaArr = {
93
96
  hover: 0.1,
94
97
  focus: 0.2,
@@ -121,10 +124,11 @@ const Button = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
121
124
  const typographySize = typographySizeMap.get(size);
122
125
  const iconMarginSize = iconMarginSizeMap.get(size);
123
126
  const minHeightSize = minHeightSizeMap.get(size);
127
+ const minHeightSizeLink = minHeightSizeLinkMap.get(size);
124
128
 
125
129
  const _ButtonText = ButtonText(loading, iconMarginSize);
126
130
 
127
- const _ButtonRoot = ButtonRoot(viewType, size, paddingSize, minHeightSize, outlinedPaddingSize, endIcon, label, iconMarginSize, startIcon, iconSize, color);
131
+ const _ButtonRoot = ButtonRoot(viewType, size, paddingSize, minHeightSize, minHeightSizeLink, outlinedPaddingSize, endIcon, label, iconMarginSize, startIcon, iconSize, color);
128
132
 
129
133
  useImperativeHandle(reference, () => ({
130
134
  element: ref.current,
@@ -219,7 +223,7 @@ const Button = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
219
223
  onClick: _onClick,
220
224
  id: id,
221
225
  type: type,
222
- className: ['DGN-UI-Button', viewType, getClassNameFromColor(color), size, loading && 'button--loading', disabled && 'button--disabled', className].join(' ').trim().replace(/\s+/g, ' '),
226
+ className: classNames('DGN-UI-Button', viewType, getClassNameFromColor(color), size, loading && 'button--loading', disabled && 'button--disabled', className),
223
227
  ...props
224
228
  }, start, jsx(Typography, {
225
229
  css: _ButtonText,
@@ -228,7 +232,7 @@ const Button = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
228
232
  }, children || label), end && end, !disabled && !loading && viewType !== 'link' && jsx(Ripple, {
229
233
  color: getRippleColor(color, viewType, allColors)
230
234
  }));
231
- }, [size, viewType, color, disabled, onClick, loading, startIcon, endIcon, label, type, className, children, id]);
235
+ }, [children, className, color, disabled, endIcon, id, label, loading, onClick, size, startIcon, type, viewType]);
232
236
  }));
233
237
  const ButtonIcon = css`
234
238
  ${flexRow};
@@ -244,7 +248,7 @@ const ButtonText = (loading, iconMarginSize) => css`
244
248
  margin: 0 ${loading ? iconMarginSize : 0};
245
249
  `;
246
250
 
247
- const ButtonRoot = (viewType, size, paddingSize, minHeightSize, outlinedPaddingSize, endIcon, label, iconMarginSize, startIcon, iconSize, color) => css`
251
+ const ButtonRoot = (viewType, size, paddingSize, minHeightSize, minHeightSizeLink, outlinedPaddingSize, endIcon, label, iconMarginSize, startIcon, iconSize, color) => css`
248
252
  ${inlineFlex};
249
253
  ${alignCenter};
250
254
  ${justifyCenter};
@@ -413,6 +417,7 @@ const ButtonRoot = (viewType, size, paddingSize, minHeightSize, outlinedPaddingS
413
417
  }
414
418
  }
415
419
  &.link {
420
+ min-height: ${minHeightSizeLink};
416
421
  ${backgroundTransparent};
417
422
  ${noBorder};
418
423
  ${noPadding};
@@ -6,34 +6,33 @@ import PropTypes from 'prop-types';
6
6
  import { jsx, css } from '@emotion/core';
7
7
  import { ButtonIcon, Typography } from '../';
8
8
  import Icon from '../../icons';
9
- import { alignCenter, border, borderBox, flexRow, inlineFlex, justifyCenter, positionRelative, userSelectNone, whiteSpaceNoWrap } from '../../styles/general';
10
- import { color as colors } from '../../styles/colors';
11
- import { darken } from '../../styles/color-helper';
9
+ import { alignCenter, border, borderBox, flexRow, inlineFlex, justifyCenter, positionRelative, userSelectNone, whiteSpaceNoWrap, cursorNotAllowed, positionAbsolute } from '../../styles/general';
10
+ import { hexToRGBA } from '../../styles/color-helper';
11
+ import { useTheme } from '../../theme';
12
12
  const {
13
- system: {
14
- active,
15
- rest,
16
- white
17
- },
18
- semantic: {
19
- danger
20
- },
21
- fill: {
22
- disabled: fillDisabled,
23
- hover: fillHover
24
- },
25
- line: {
26
- normal,
27
- disabled: lineDisabled
13
+ colors: {
14
+ danger,
15
+ info,
16
+ success,
17
+ warning,
18
+ system: {
19
+ active,
20
+ rest,
21
+ white,
22
+ disabled: disabledCl,
23
+ dark
24
+ }
28
25
  },
29
- text: {
30
- disabled: textDisabled
31
- }
32
- } = colors;
33
- const iconSizeMap = new Map([['small', '12px'], ['medium', '16px']]);
26
+ spacing
27
+ } = useTheme();
28
+ const colorMap = new Map([['default', active], ['primary', active], ['success', success], ['warning', warning], ['danger', danger], ['info', info]]);
29
+ const iconSizeMap = new Map([['small', `${spacing(4)}px`], ['medium', `${spacing(5)}px`], ['large', `${spacing(6)}px`]]);
30
+ const typographySizeMap = new Map([['small', 'p3'], ['medium', 'p2'], ['large', 'p1']]);
31
+ const paddingSizeMap = new Map([['small', `0px ${spacing(1.5)}px`], ['medium', `0px ${spacing(2)}px`], ['large', `0px ${spacing(2.5)}px`]]);
32
+ const minHeightSizeMap = new Map([['small', `${spacing(5)}px`], ['medium', `${spacing(6)}px`], ['large', `${spacing(7)}px`]]);
34
33
  const Chip = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
35
34
  viewType,
36
- color,
35
+ color: colorProps,
37
36
  size,
38
37
  label,
39
38
  className,
@@ -41,21 +40,44 @@ const Chip = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
41
40
  onClick,
42
41
  onDbClick,
43
42
  onDoubleClick,
44
- maxLength,
45
43
  startIcon,
46
44
  endIcon,
47
45
  clearAble,
48
46
  disabled,
49
47
  readOnly,
50
48
  children,
51
- style
49
+ style,
50
+ labelProps
52
51
  }, reference) => {
53
52
  const ref = useRef(null);
54
53
  const IconRef = useRef(null);
55
54
  if (!onDbClick && onDoubleClick) onDbClick = onDoubleClick;
55
+ const color = colorMap.get(colorProps) || colorProps;
56
+ const infoChip = {
57
+ color: colorMap.get(colorProps) || colorProps,
58
+ contentColor: viewType !== 'filled' ? color : white,
59
+ backgroundColor: viewType !== 'filled' ? white : color,
60
+ iconSize: iconSizeMap.get(size),
61
+ paddingSize: paddingSizeMap.get(size),
62
+ typographySize: typographySizeMap.get(size),
63
+ minHeightSize: minHeightSizeMap.get(size),
64
+ viewType
65
+ };
66
+ infoChip.border = viewType === 'ghost' ? 'transparent !important' : colorProps === 'default' ? rest : infoChip === null || infoChip === void 0 ? void 0 : infoChip.color;
67
+ infoChip.contentColor = colorProps === 'default' && viewType === 'outlined' ? rest : infoChip === null || infoChip === void 0 ? void 0 : infoChip.contentColor;
68
+ infoChip.backgroundColor = colorProps === 'default' && viewType === 'filled' ? rest : infoChip === null || infoChip === void 0 ? void 0 : infoChip.backgroundColor;
69
+ useImperativeHandle(reference, () => {
70
+ const currentRef = ref.current || {};
71
+ const _instance = {}; // methods
72
+
73
+ _instance.__proto__ = {}; // hidden methods
74
+
75
+ currentRef.instance = _instance;
76
+ return currentRef;
77
+ });
56
78
 
57
79
  const onRemoveHandler = () => {
58
- if (onRemove) onRemove(ref.current);
80
+ if (onRemove || disabled) onRemove(ref.current);
59
81
  setTimeout(() => {
60
82
  ref.current && ref.current.remove();
61
83
  }, 0);
@@ -71,213 +93,158 @@ const Chip = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
71
93
  onDbClick && event.stopPropagation();
72
94
  if (disabled) return;
73
95
  onDbClick && onDbClick(event);
74
- };
96
+ }; // Start Icon
75
97
 
76
- const renderLabel = () => {
77
- if (maxLength && label && label.length > maxLength) {
78
- label = label.slice(0, maxLength) + '...';
79
- }
80
-
81
- return label;
82
- };
83
98
 
84
- useImperativeHandle(reference, () => {
85
- const currentRef = ref.current || {};
86
- const _instance = {}; // methods
87
-
88
- _instance.__proto__ = {}; // hidden methods
89
-
90
- currentRef.instance = _instance;
91
- return currentRef;
92
- });
93
99
  const startIconView = useMemo(() => {
94
- let node = startIcon;
95
-
96
- if (typeof node === 'string') {
97
- node = jsx(Icon, {
98
- name: node,
99
- width: iconSizeMap.get(size),
100
- height: iconSizeMap.get(size),
101
- color: 'currentColor',
102
- viewBox: false
100
+ if (typeof startIcon === 'string') {
101
+ return jsx(Icon, {
102
+ name: startIcon,
103
+ width: infoChip.iconSize,
104
+ height: infoChip.iconSize,
105
+ color: 'currentColor'
103
106
  });
104
- }
107
+ } else return jsx("div", {
108
+ css: ChipIconCSS(info)
109
+ }, startIcon);
110
+ }, [startIcon, size]); // Label
105
111
 
106
- return startIcon && jsx("div", {
107
- css: ChipIconCSS,
108
- className: size
109
- }, node);
110
- }, [startIcon, size]);
111
112
  const labelView = useMemo(() => {
112
- return jsx("div", {
113
- css: ChipLabelCSS(startIcon, endIcon, clearAble),
114
- className: size
115
- }, jsx(Typography, {
116
- type: size === 'small' ? 'p2' : 'p1',
113
+ return jsx(Typography, {
114
+ css: ChipLabelCSS,
115
+ type: infoChip.typographySize,
117
116
  color: 'inherit',
118
- lineClamp: 1
119
- }, renderLabel()));
120
- }, [label, size, startIcon, endIcon, clearAble]);
117
+ lineClamp: 1,
118
+ ...labelProps
119
+ }, label);
120
+ }, [label, size, startIcon, endIcon, clearAble]); // End Icon
121
+
121
122
  const endIconView = useMemo(() => {
122
123
  let node = endIcon;
123
124
 
124
125
  if (typeof node === 'string') {
125
- node = jsx(Icon, {
126
+ return jsx(Icon, {
126
127
  name: node,
127
- width: iconSizeMap.get(size),
128
- height: iconSizeMap.get(size),
129
- color: 'currentColor',
130
- viewBox: false
128
+ width: infoChip.iconSize,
129
+ height: infoChip.iconSize,
130
+ color: infoChip.contentColor,
131
+ viewBox: true
131
132
  });
132
133
  }
133
134
 
134
- return clearAble ? jsx("div", {
135
- css: ChipIconCSS,
136
- className: 'end-icon ' + size,
137
- ref: IconRef
138
- }, jsx(ButtonIcon, {
135
+ return clearAble ? jsx(ButtonIcon, {
136
+ ref: IconRef,
137
+ className: 'end-icon',
139
138
  viewType: 'ghost',
140
139
  name: 'Close',
141
- color: viewType === 'outlined' && color ? 'inherit' : undefined,
140
+ width: infoChip.iconSize,
141
+ height: infoChip.iconSize,
142
+ color: infoChip.contentColor,
142
143
  disabled: disabled,
144
+ viewBox: true,
143
145
  onClick: onRemoveHandler
144
- })) : endIcon && jsx("div", {
145
- css: ChipIconCSS,
146
+ }) : node && jsx("div", {
147
+ css: ChipIconCSS(size),
146
148
  className: 'end-icon ' + size,
147
149
  ref: IconRef
148
150
  }, node);
149
151
  }, [clearAble, viewType, color, endIcon, size, disabled]);
150
152
  return jsx("div", {
151
- css: ChipRootCSS(onClick, onDbClick, color),
153
+ css: ChipRootCSS(onClick, onDbClick, colorProps, infoChip),
152
154
  ref: ref,
153
- className: ['DGN-UI-Chip', size, className, color && color !== 'default' && color, color && color !== 'default' && viewType, disabled && 'chip--disabled', readOnly && 'chip--readOnly'].join(' ').trim().replace(/\s+/g, ' '),
155
+ className: ['DGN-UI-Chip', className, disabled && 'chip--disabled', readOnly && 'chip--readOnly', viewType === 'filled' && 'chip--filled'].join(' '),
154
156
  style: style,
155
157
  onClick: _onClick,
156
158
  onDoubleClick: _onDbClick
157
- }, startIconView, labelView, endIconView, children);
159
+ }, !!startIcon && startIconView, !!label && labelView, (!!endIcon || !!clearAble) && endIconView, children);
158
160
  }));
159
- const ChipIconCSS = css`
160
- ${flexRow};
161
- ${justifyCenter};
162
- ${alignCenter};
163
- ${positionRelative};
164
- ${borderBox};
165
- padding: 0 2px;
166
- color: inherit;
167
- img {
168
- border-radius: 50%;
169
- }
170
- &.small {
171
- width: 24px;
172
- height: 24px;
173
- img {
174
- width: 20px;
175
- height: 20px;
176
- }
177
- }
178
- &.medium {
179
- max-width: 32px;
180
- max-height: 32px;
181
- img {
182
- min-width: 24px;
183
- min-height: 24px;
184
- }
185
- &:not(.end-icon) {
186
- margin-right: 4px;
187
- }
188
- &.end-icon {
189
- width: 32px;
190
- height: 26px;
191
- }
192
- }
193
- `;
194
-
195
- const ChipLabelCSS = (startIcon, endIcon, clearAble) => css`
161
+ const ChipLabelCSS = css`
196
162
  ${flexRow};
197
163
  ${alignCenter};
198
164
  ${positionRelative};
199
165
  ${userSelectNone};
200
166
  ${whiteSpaceNoWrap};
201
- padding-right: ${endIcon || clearAble ? 2 : 10}px;
202
- padding-left: ${startIcon ? 2 : 10}px;
203
- &.small {
204
- max-height: 24px;
205
- }
206
- &.medium {
207
- max-height: 32px;
208
- }
209
167
  `;
210
168
 
211
- const ChipRootCSS = (onClick, onDbClick, color) => css`
169
+ const ChipRootCSS = (onClick, onDbClick, colorProps, info) => css`
212
170
  ${inlineFlex};
213
171
  ${alignCenter};
214
172
  ${positionRelative};
215
173
  ${borderBox};
216
- ${border(1, normal)};
174
+ ${border('1px', info.border)};
217
175
  width: max-content;
218
- margin-right: 15px;
219
- padding: 0 6px;
220
- color: ${rest};
221
- background: ${white};
222
- border-radius: 20px;
176
+ padding: ${info === null || info === void 0 ? void 0 : info.paddingSize};
177
+ color: ${info === null || info === void 0 ? void 0 : info.contentColor};
178
+ background: ${info === null || info === void 0 ? void 0 : info.backgroundColor};
179
+ border-radius: ${spacing(4)}px;
223
180
  cursor: ${onClick || onDbClick ? 'pointer' : 'unset'};
224
- &.small {
225
- height: 24px;
226
- }
227
- &.medium {
228
- min-height: 32px;
229
- padding-top: 2px;
230
- padding-bottom: 2px;
231
- }
232
- &:hover {
233
- background: ${fillHover};
234
- border-color: ${active};
235
- }
236
- &.chip--disabled {
237
- color: ${textDisabled} !important;
238
- background-color: ${fillDisabled} !important;
239
- border-color: ${lineDisabled} !important;
240
- pointer-events: none !important;
241
- .css-${ChipIconCSS.name} {
242
- path {
243
- fill: ${textDisabled} !important;
181
+ height: ${info === null || info === void 0 ? void 0 : info.minHeightSize};
182
+ min-height: ${info === null || info === void 0 ? void 0 : info.minHeightSize};
183
+ gap: ${spacing()}px;
184
+ &.chip--filled {
185
+ &:not(.chip--disabled):not(.chip--readOnly) {
186
+ &::after {
187
+ border-radius: ${spacing(4)}px;
188
+ ${positionAbsolute};
189
+ top: 0;
190
+ left: 0;
191
+ content: '';
192
+ width: 100%;
193
+ height: 100%;
194
+ }
195
+ &:hover::after,
196
+ &:focus::after {
197
+ background: ${hexToRGBA(dark, 0.15)};
198
+ }
199
+ &:active::after {
200
+ background: ${hexToRGBA(dark, 0.3)};
244
201
  }
245
202
  }
246
203
  }
247
- &.chip--readOnly {
248
- cursor: unset !important;
249
- .css-${ChipIconCSS.name} {
250
- pointer-events: none !important;
204
+ &:not(.chip--filled) {
205
+ &:not(.chip--disabled):not(.chip--readOnly):hover {
206
+ ${border('1px', info === null || info === void 0 ? void 0 : info.color)};
207
+ background: ${hexToRGBA(info === null || info === void 0 ? void 0 : info.color, 0.1)};
208
+ color: ${info === null || info === void 0 ? void 0 : info.color};
251
209
  }
252
- }
253
- &.outlined {
254
- &.${color} {
255
- color: ${colors[color] || color};
256
- border-color: ${colors[color] || color};
210
+ &:not(.chip--disabled):not(.chip--readOnly):active {
211
+ ${border('1px', info === null || info === void 0 ? void 0 : info.color)};
212
+ background: ${hexToRGBA(info === null || info === void 0 ? void 0 : info.color, 0.3)};
213
+ color: ${info === null || info === void 0 ? void 0 : info.color};
257
214
  }
258
- }
259
- &.filled {
260
- color: ${white};
261
- .clear-icon {
262
- color: ${white};
263
- &:hover {
264
- color: ${danger};
265
- }
266
- }
267
- &.${color} {
268
- background-color: ${colors[color] || color};
269
- border-color: ${darken(colors[color] || color, 0.22)};
215
+ &:not(.chip--disabled):not(.chip--readOnly):focus {
216
+ ${border('1px', info === null || info === void 0 ? void 0 : info.color)};
217
+ background: ${hexToRGBA(info === null || info === void 0 ? void 0 : info.color, 0.2)};
218
+ color: ${info === null || info === void 0 ? void 0 : info.color};
270
219
  }
271
220
  }
221
+ &.chip--disabled {
222
+ color: ${disabledCl} !important;
223
+ background-color: ${white} !important;
224
+ ${border('1px', disabledCl)};
225
+ }
226
+ &.chip--readOnly,
227
+ &.chip--disabled {
228
+ ${cursorNotAllowed}
229
+ }
230
+ `;
231
+
232
+ const ChipIconCSS = info => css`
233
+ ${flexRow};
234
+ ${justifyCenter};
235
+ ${alignCenter};
236
+ ${positionRelative};
237
+ ${borderBox};
238
+ width: ${info === null || info === void 0 ? void 0 : info.iconSize};
239
+ min-width: ${info === null || info === void 0 ? void 0 : info.iconSize};
240
+ height: ${info === null || info === void 0 ? void 0 : info.iconSize};
241
+ min-height: ${info === null || info === void 0 ? void 0 : info.iconSize};
272
242
  `;
273
243
 
274
244
  Chip.defaultProps = {
275
- label: '',
276
- className: '',
277
- style: {},
278
245
  viewType: 'outlined',
279
- size: 'small',
280
- clearAble: false
246
+ size: 'medium',
247
+ color: 'default'
281
248
  };
282
249
  Chip.propTypes = {
283
250
  /** content to display in Chip */
@@ -290,7 +257,6 @@ Chip.propTypes = {
290
257
 
291
258
  /** style inline of component */
292
259
  style: PropTypes.object,
293
- maxLength: PropTypes.number,
294
260
 
295
261
  /** the icon display at head of Chip */
296
262
  startIcon: PropTypes.any,
@@ -299,13 +265,13 @@ Chip.propTypes = {
299
265
  endIcon: PropTypes.any,
300
266
 
301
267
  /** type of chip */
302
- viewType: PropTypes.oneOf(['outlined', 'filled']),
268
+ viewType: PropTypes.oneOf(['ghost', 'outlined', 'filled']),
303
269
 
304
270
  /** color for text or background of Chip */
305
271
  color: PropTypes.oneOf(['default', 'primary', 'info', 'success', 'warning', 'danger']),
306
272
 
307
273
  /** size of Chip */
308
- size: PropTypes.oneOf(['small', 'medium']),
274
+ size: PropTypes.oneOf(['small', 'medium', 'large']),
309
275
 
310
276
  /** show clear icon if true */
311
277
  clearAble: PropTypes.bool,
@@ -332,6 +298,9 @@ Chip.propTypes = {
332
298
  onDoubleClick: PropTypes.func,
333
299
 
334
300
  /** content to display on Chip (the same to label) */
335
- children: PropTypes.node
301
+ children: PropTypes.node,
302
+
303
+ /** props for Typography of label */
304
+ labelProps: PropTypes.object
336
305
  };
337
306
  export default Chip;
@@ -42,8 +42,8 @@ const Checkbox = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
42
42
  children,
43
43
  inputProps,
44
44
  forTreeView,
45
- width,
46
45
  labelProps,
46
+ width,
47
47
  stopPropagation,
48
48
  ...props
49
49
  }, reference) => {
@@ -55,7 +55,7 @@ const DatePicker = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
55
55
  returnFormat,
56
56
  style,
57
57
  textAlign,
58
- value,
58
+ value: valueProp,
59
59
  viewType,
60
60
  ...props
61
61
  }, reference) => {
@@ -86,6 +86,7 @@ const DatePicker = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
86
86
  const focusedValue = useRef(null);
87
87
  const [, setDisplayValue] = useState(Date.now());
88
88
  const [, setFocusedValue] = useState(Date.now());
89
+ const [value, setValue] = useState(valueProp || defaultValue);
89
90
 
90
91
  const _IconAreaCSS = IconAreaCSS(unique);
91
92
 
@@ -126,7 +127,12 @@ const DatePicker = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
126
127
  };
127
128
 
128
129
  const onChangeValue = e => {
129
- setInputValue(e);
130
+ if (valueProp) {
131
+ closePicker();
132
+ } else {
133
+ setValue(e.value);
134
+ }
135
+
130
136
  !!onChange && onChange({
131
137
  value: formatValue(e.value, returnFormat)
132
138
  });
@@ -436,6 +442,9 @@ const DatePicker = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
436
442
  closePicker();
437
443
  }
438
444
  }, [value]);
445
+ useEffect(() => {
446
+ setValue(valueProp);
447
+ }, [valueProp]);
439
448
  useEffect(() => {
440
449
  if (!readOnly) {
441
450
  ipRef.current.addEventListener('focus', onInputFocus);
@@ -534,7 +543,6 @@ const DatePicker = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
534
543
  }, jsx(InputBase, {
535
544
  placeholder: placeholder,
536
545
  ...inputProps,
537
- readOnly: true,
538
546
  ref: ipConRef,
539
547
  inputRef: ipRef,
540
548
  disabled: disabled,
@@ -544,7 +552,9 @@ const DatePicker = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
544
552
  ...inputStyle
545
553
  },
546
554
  startIcon: startIcon,
547
- endIcon: endIcon
555
+ endIcon: endIcon,
556
+ onKeyDown: e => e.preventDefault(),
557
+ readOnly: true
548
558
  })), isError && jsx(HelperText, { ...errorProps,
549
559
  style: {
550
560
  minHeight: 16,
@@ -79,13 +79,13 @@ const NumberInput = /*#__PURE__*/forwardRef(({
79
79
  const clamp = (num, min, max) => Math.min(Math.max(num, min), max);
80
80
 
81
81
  if (valueProps || valueProps === 0) valueProps = clamp(valueProps, min, max);
82
- /**
83
- * Convert number to format money
84
- * @param vl {number} - value
85
- * @type {function(*): number}
86
- * @return {string}
87
- * @example 1200300.123 => 1,200,300.123
88
- * @example 1200300,123 => 1.200.300,123
82
+ /**
83
+ * Convert number to format money
84
+ * @param vl {number} - value
85
+ * @type {function(*): number}
86
+ * @return {string}
87
+ * @example 1200300.123 => 1,200,300.123
88
+ * @example 1200300,123 => 1.200.300,123
89
89
  */
90
90
 
91
91
  const parseNumberToMoney = useCallback((vl, isNumber) => {
@@ -119,13 +119,13 @@ const NumberInput = /*#__PURE__*/forwardRef(({
119
119
 
120
120
  return number;
121
121
  }, [decimalSymbol, max, value]);
122
- /**
123
- * Convert money to format number
124
- * @param vl {string} - value
125
- * @type {function(*): number}
126
- * @return {number}
127
- * @example 1,200,300.123 => 1200300.123
128
- * @example 1.200.300,123 => 1200300.123
122
+ /**
123
+ * Convert money to format number
124
+ * @param vl {string} - value
125
+ * @type {function(*): number}
126
+ * @return {number}
127
+ * @example 1,200,300.123 => 1200300.123
128
+ * @example 1.200.300,123 => 1200300.123
129
129
  */
130
130
 
131
131
  const convertMoneyToNumber = useCallback((vl, isNumber) => {
@@ -397,10 +397,10 @@ NumberInput.propTypes = {
397
397
  /** style inline of input in NumberInput component */
398
398
  inputStyle: PropTypes.object,
399
399
 
400
- /** validation value, argument can:<br/>
401
- * * string: the validation rule. Example required.<br/>
402
- * * object: the validation rule insist name, property, message. Example {name: 'min', compareValue: 9, message: 'Error'} or {max: 99}<br/>
403
- * * array: the validation rule list, insist object/string
400
+ /** validation value, argument can:<br/>
401
+ * * string: the validation rule. Example required.<br/>
402
+ * * object: the validation rule insist name, property, message. Example {name: 'min', compareValue: 9, message: 'Error'} or {max: 99}<br/>
403
+ * * array: the validation rule list, insist object/string
404
404
  */
405
405
  validates: PropTypes.oneOfType([PropTypes.string, PropTypes.object, PropTypes.array, PropTypes.func]),
406
406