diginet-core-ui 1.3.69-beta.7 → 1.3.69-beta.9

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.
@@ -541,8 +541,10 @@ const DatePicker = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
541
541
  width: 'none'
542
542
  }
543
543
  }, jsx(InputBase, {
544
- placeholder: placeholder,
545
- ...inputProps,
544
+ inputProps: {
545
+ placeholder: !readOnly && !disabled ? placeholder : '',
546
+ ...inputProps
547
+ },
546
548
  ref: ipConRef,
547
549
  inputRef: ipRef,
548
550
  disabled: disabled,
@@ -8,6 +8,8 @@ import OptionWrapper from '../../others/option-wrapper';
8
8
  import { Typography } from '../../';
9
9
  import { flexRow } from '../../../styles/general';
10
10
  import theme from '../../../theme/settings';
11
+ import { classNames } from '../../../utils';
12
+ import { arrTypeTypography as typesTypography } from '../../typography';
11
13
  const {
12
14
  colors: {
13
15
  system: {
@@ -19,20 +21,21 @@ const {
19
21
  text: {
20
22
  normal_label
21
23
  }
22
- }
24
+ },
25
+ spacing
23
26
  } = theme;
24
27
  const Label = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
25
28
  action = {},
29
+ children,
30
+ className,
31
+ color,
26
32
  disabled,
33
+ hoverTooltip,
34
+ id,
35
+ lineClamp,
27
36
  readOnly,
28
37
  required,
29
- className,
30
- children,
31
38
  type,
32
- lineClamp,
33
- hoverTooltip,
34
- id,
35
- color,
36
39
  ...props
37
40
  }, reference) => {
38
41
  const ref = useRef(null);
@@ -60,23 +63,24 @@ const Label = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
60
63
  lineClamp: lineClamp,
61
64
  hoverTooltip: hoverTooltip,
62
65
  type: type,
63
- className: ['DGN-UI-Label', className, readOnly ? 'read-only' : '', disabled ? 'disabled' : ''].join(' ').trim().replace(/\s+/g, ' '),
66
+ className: classNames('DGN-UI-Label', className, readOnly && 'read-only', disabled && 'disabled'),
64
67
  ...props
65
68
  }, children), required && jsx("span", {
66
69
  className: 'required'
67
- }, " *")), [disabled, readOnly, required, className, children, type, lineClamp, hoverTooltip, color, props]);
70
+ }, " *")), [children, className, color, disabled, hoverTooltip, id, lineClamp, readOnly, required, type, props]);
68
71
  }));
69
72
  const LabelContainerCSS = css`
70
73
  ${flexRow};
71
74
  .required {
72
75
  color: ${danger};
73
76
  }
77
+ & + .DGN-UI-InputBase.outlined {
78
+ margin-top: ${spacing([0.5])};
79
+ }
74
80
  `;
75
81
  const LabelRootCSS = css`
76
82
  min-height: 16px;
77
- & + .DGN-UI-InputBase.outlined {
78
- margin-top: 2px;
79
- }
83
+ margin: 0;
80
84
  word-break: break-all;
81
85
  `;
82
86
  Label.defaultProps = {
@@ -89,7 +93,6 @@ Label.defaultProps = {
89
93
  className: '',
90
94
  children: ''
91
95
  };
92
- 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'];
93
96
  Label.propTypes = {
94
97
  /** The content of the component. */
95
98
  children: PropTypes.node,
@@ -116,7 +119,7 @@ Label.propTypes = {
116
119
  hoverTooltip: PropTypes.bool,
117
120
 
118
121
  /** Consult [Typography's](https://core.diginet.com.vn/ui/?path=/docs/typography) documents. */
119
- type: PropTypes.oneOf(arrTypeTypography)
122
+ type: PropTypes.oneOf(typesTypography)
120
123
  };
121
124
  export { Label };
122
125
  export default OptionWrapper(Label);
@@ -446,12 +446,10 @@ const MoneyInput = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
446
446
  onKeyDown: onKeyDownHandler,
447
447
  onKeyUp: onKeyUp,
448
448
  onPaste: onPasteHandler
449
- }), isError && jsx(HelperText, {
450
- disabled: disabled,
451
- ...helperTextProps
452
- }, error), !isError && validateResult && jsx(HelperText, {
453
- disabled: disabled,
454
- ...helperTextProps
449
+ }), isError && jsx(HelperText, { ...helperTextProps,
450
+ disabled: disabled
451
+ }, error), !isError && validateResult && jsx(HelperText, { ...helperTextProps,
452
+ disabled: disabled
455
453
  }, validateResult));
456
454
  }));
457
455
  const MoneyInputRoot = css`
@@ -552,10 +550,10 @@ MoneyInput.propTypes = {
552
550
  /** style inline of input in MoneyInput component */
553
551
  inputStyle: PropTypes.object,
554
552
 
555
- /** validation value, argument can:<br/>
556
- * * string: the validation rule. Example required.<br/>
557
- * * object: the validation rule insist name, property, message. Example {name: 'min', compareValue: 9, message: 'Error'} or {max: 99}<br/>
558
- * * array: the validation rule list, insist object/string
553
+ /** validation value, argument can:<br/>
554
+ * * string: the validation rule. Example required.<br/>
555
+ * * object: the validation rule insist name, property, message. Example {name: 'min', compareValue: 9, message: 'Error'} or {max: 99}<br/>
556
+ * * array: the validation rule list, insist object/string
559
557
  */
560
558
  validates: PropTypes.oneOfType([PropTypes.string, PropTypes.object, PropTypes.array, PropTypes.func]),
561
559
 
@@ -568,13 +566,13 @@ MoneyInput.propTypes = {
568
566
  /** on input function */
569
567
  onInput: PropTypes.func,
570
568
 
571
- /**
572
- * on change function, return an object:<br/>
573
- * {<br/>
574
- * &nbsp;&nbsp;&nbsp;&nbsp;value: is a number or null value<br/>
575
- * &nbsp;&nbsp;&nbsp;&nbsp;target.value: value of input<br/>
576
- * &nbsp;&nbsp;&nbsp;&nbsp;...element<br/>
577
- * }
569
+ /**
570
+ * on change function, return an object:<br/>
571
+ * {<br/>
572
+ * &nbsp;&nbsp;&nbsp;&nbsp;value: is a number or null value<br/>
573
+ * &nbsp;&nbsp;&nbsp;&nbsp;target.value: value of input<br/>
574
+ * &nbsp;&nbsp;&nbsp;&nbsp;...element<br/>
575
+ * }
578
576
  */
579
577
  onChange: PropTypes.func,
580
578
 
@@ -53,7 +53,8 @@ const NumberInput = /*#__PURE__*/forwardRef(({
53
53
  className,
54
54
  maxDigit,
55
55
  autoWidth,
56
- labelProps
56
+ labelProps,
57
+ helperTextProps
57
58
  }, reference) => {
58
59
  inputRef = inputRef || useRef(null);
59
60
  const pos = useRef(null);
@@ -79,13 +80,13 @@ const NumberInput = /*#__PURE__*/forwardRef(({
79
80
  const clamp = (num, min, max) => Math.min(Math.max(num, min), max);
80
81
 
81
82
  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
83
+ /**
84
+ * Convert number to format money
85
+ * @param vl {number} - value
86
+ * @type {function(*): number}
87
+ * @return {string}
88
+ * @example 1200300.123 => 1,200,300.123
89
+ * @example 1200300,123 => 1.200.300,123
89
90
  */
90
91
 
91
92
  const parseNumberToMoney = useCallback((vl, isNumber) => {
@@ -119,13 +120,13 @@ const NumberInput = /*#__PURE__*/forwardRef(({
119
120
 
120
121
  return number;
121
122
  }, [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
123
+ /**
124
+ * Convert money to format number
125
+ * @param vl {string} - value
126
+ * @type {function(*): number}
127
+ * @return {number}
128
+ * @example 1,200,300.123 => 1200300.123
129
+ * @example 1.200.300,123 => 1200300.123
129
130
  */
130
131
 
131
132
  const convertMoneyToNumber = useCallback((vl, isNumber) => {
@@ -305,9 +306,9 @@ const NumberInput = /*#__PURE__*/forwardRef(({
305
306
  });
306
307
  },
307
308
  onBlur: e => _onBlur(e)
308
- }), !!error && jsx(HelperText, {
309
+ }), !!error && jsx(HelperText, { ...helperTextProps,
309
310
  disabled: disabled
310
- }, error), !error && validateResult && jsx(HelperText, {
311
+ }, error), !error && validateResult && jsx(HelperText, { ...helperTextProps,
311
312
  disabled: disabled
312
313
  }, validateResult));
313
314
  });
@@ -397,10 +398,10 @@ NumberInput.propTypes = {
397
398
  /** style inline of input in NumberInput component */
398
399
  inputStyle: PropTypes.object,
399
400
 
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
401
+ /** validation value, argument can:<br/>
402
+ * * string: the validation rule. Example required.<br/>
403
+ * * object: the validation rule insist name, property, message. Example {name: 'min', compareValue: 9, message: 'Error'} or {max: 99}<br/>
404
+ * * array: the validation rule list, insist object/string
404
405
  */
405
406
  validates: PropTypes.oneOfType([PropTypes.string, PropTypes.object, PropTypes.array, PropTypes.func]),
406
407
 
@@ -444,6 +445,9 @@ NumberInput.propTypes = {
444
445
  autoWidth: PropTypes.bool,
445
446
 
446
447
  /** [Props](https://core.diginet.com.vn/ui/?path=/docs/form-control-text-label) of label. */
447
- labelProps: PropTypes.object
448
+ labelProps: PropTypes.object,
449
+
450
+ /** [Props](https://core.diginet.com.vn/ui/?path=/story/form-control-text-helpertext) of helper text. */
451
+ helperTextProps: PropTypes.object
448
452
  };
449
453
  export default NumberInput;
@@ -43,6 +43,7 @@ const PhoneInput = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
43
43
  onKeyDown,
44
44
  onKeyUp,
45
45
  labelProps,
46
+ helperTextProps,
46
47
  ...props
47
48
  }, reference) => {
48
49
  const ref = useRef(null);
@@ -324,7 +325,7 @@ const PhoneInput = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
324
325
  startIconProps: {
325
326
  className: 'non-effect'
326
327
  }
327
- }), !!error && jsx(HelperText, {
328
+ }), !!error && jsx(HelperText, { ...helperTextProps,
328
329
  disabled: disabled
329
330
  }, error));
330
331
  }));
@@ -397,13 +398,13 @@ PhoneInput.propTypes = {
397
398
  /** on input function */
398
399
  onInput: PropTypes.func,
399
400
 
400
- /**
401
- * on change function. Return a object, example:<br/>
402
- * {<br/>
403
- * &nbsp;&nbsp;&nbsp;&nbsp;target: {value: "(+84) 123 456 789", ...}<br/>
404
- * &nbsp;&nbsp;&nbsp;&nbsp;value: 0123456789<br/>
405
- * &nbsp;&nbsp;&nbsp;&nbsp;countryCode: 84<br/>
406
- * }
401
+ /**
402
+ * on change function. Return a object, example:<br/>
403
+ * {<br/>
404
+ * &nbsp;&nbsp;&nbsp;&nbsp;target: {value: "(+84) 123 456 789", ...}<br/>
405
+ * &nbsp;&nbsp;&nbsp;&nbsp;value: 0123456789<br/>
406
+ * &nbsp;&nbsp;&nbsp;&nbsp;countryCode: 84<br/>
407
+ * }
407
408
  */
408
409
  onChange: PropTypes.func,
409
410
 
@@ -417,6 +418,9 @@ PhoneInput.propTypes = {
417
418
  inputRef: PropTypes.any,
418
419
 
419
420
  /** [Props](https://core.diginet.com.vn/ui/?path=/docs/form-control-text-label) of label. */
420
- labelProps: PropTypes.object
421
+ labelProps: PropTypes.object,
422
+
423
+ /** [Props](https://core.diginet.com.vn/ui/?path=/story/form-control-text-helpertext) of helper text. */
424
+ helperTextProps: PropTypes.object
421
425
  };
422
426
  export default PhoneInput;
@@ -17,6 +17,7 @@ const TextInput = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
17
17
  endIcon,
18
18
  endIconProps,
19
19
  error,
20
+ helperTextProps,
20
21
  icon,
21
22
  iconStyle,
22
23
  inputProps,
@@ -276,10 +277,10 @@ const TextInput = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
276
277
  onKeyUp: onKeyUp,
277
278
  onPaste: onPaste,
278
279
  value: valueProp
279
- }), isError && jsx(HelperText, {
280
+ }), isError && jsx(HelperText, { ...helperTextProps,
280
281
  disabled: disabled,
281
282
  status: status
282
- }, error), !isError && validateResult && jsx(HelperText, {
283
+ }, error), !isError && validateResult && jsx(HelperText, { ...helperTextProps,
283
284
  disabled: disabled
284
285
  }, validateResult));
285
286
  }));
@@ -354,6 +355,9 @@ TextInput.propTypes = {
354
355
  /** Error displayed below input. */
355
356
  error: PropTypes.oneOfType([PropTypes.bool, PropTypes.string]),
356
357
 
358
+ /** [Props](https://core.diginet.com.vn/ui/?path=/story/form-control-text-helpertext) of helper text. */
359
+ helperTextProps: PropTypes.object,
360
+
357
361
  /** Icon element display in the end of input (only use for type is inform, if not, use startIcon instead). */
358
362
  icon: PropTypes.any,
359
363
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "diginet-core-ui",
3
- "version": "1.3.69-beta.7",
3
+ "version": "1.3.69-beta.9",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "license": "UNLICENSED",