diginet-core-ui 1.3.61-beta.2 → 1.3.62-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.
@@ -1,66 +1,106 @@
1
1
  /** @jsxRuntime classic */
2
2
 
3
3
  /** @jsx jsx */
4
- import { memo, useEffect, useRef, forwardRef } from 'react';
4
+ import { forwardRef, memo, useEffect, useImperativeHandle, useMemo, useRef } from 'react';
5
+ import { css, jsx } from '@emotion/core';
5
6
  import PropTypes from 'prop-types';
6
- import { jsx, css } from '@emotion/core';
7
+ import { displayBlock, parseWidthHeight, positionRelative } from '../../styles/general';
7
8
  const Collapse = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
8
- open,
9
9
  children,
10
- ...props
11
- }, ref) => {
12
- if (!ref) {
13
- ref = useRef(null);
14
- }
10
+ className,
11
+ id,
12
+ onClosed,
13
+ onOpened,
14
+ open,
15
+ style
16
+ }, reference) => {
17
+ const ref = useRef(null);
18
+ const timer = useRef(null);
19
+
20
+ const _onOpen = () => {
21
+ if (timer.current) {
22
+ clearTimeout(timer.current);
23
+ }
24
+
25
+ const scrollHeight = ref.current.scrollHeight;
26
+ const duration = Math.min(scrollHeight, 1500);
27
+ ref.current.style.transitionDuration = duration + 'ms';
28
+ ref.current.style.height = scrollHeight + 'px';
29
+ timer.current = setTimeout(() => {
30
+ if (ref.current) {
31
+ ref.current.style.height = 'auto';
32
+ }
33
+
34
+ onOpened && onOpened(ref.current);
35
+ }, duration);
36
+ };
37
+
38
+ const _onClose = () => {
39
+ if (ref.current) {
40
+ if (timer.current) {
41
+ clearTimeout(timer.current);
42
+ }
15
43
 
16
- const CollapseRoot = css`
17
- display: block;
18
- position: relative;
19
- width: 100%;
20
- height: 0;
21
- transition: height 250ms cubic-bezier(0.4, 0, 0.2, 1) 0ms;
22
- overflow-y: clip;
23
- `;
24
- useEffect(() => {
25
- if (open) {
26
44
  const scrollHeight = ref.current.scrollHeight;
27
- const duration = Math.min(scrollHeight, 1500);
28
- ref.current.style.transitionDuration = duration + 'ms';
29
45
  ref.current.style.height = scrollHeight + 'px';
30
- setTimeout(() => {
46
+ timer.current = setTimeout(() => {
31
47
  if (ref.current) {
32
- ref.current.style.height = 'auto';
48
+ ref.current.style.height = null;
33
49
  }
34
- }, duration);
35
- return () => {
36
- if (ref.current) {
37
- ref.current.style.height = scrollHeight + 'px';
38
- setTimeout(() => {
39
- if (ref.current) {
40
- ref.current.style.height = null;
41
- }
42
- }, 0);
43
- }
44
- };
50
+
51
+ onClosed && onClosed(ref.current);
52
+ });
53
+ }
54
+ };
55
+
56
+ useEffect(() => {
57
+ if (open) {
58
+ _onOpen();
59
+ } else {
60
+ _onClose();
45
61
  }
46
62
  }, [open]);
47
- return jsx("div", {
63
+ useImperativeHandle(reference, () => ({
64
+ element: ref.current,
65
+ instance: {}
66
+ }));
67
+ return useMemo(() => jsx("div", {
48
68
  css: CollapseRoot,
49
69
  ref: ref,
50
- ...props
51
- }, children);
70
+ id: id,
71
+ style: style,
72
+ className: ['DGN-UI-Collapse', className].join(' ').trim().replace(/\s+/g, ' ')
73
+ }, children), [children, className, id, onClosed, onOpened, open, style]);
52
74
  }));
75
+ const CollapseRoot = css`
76
+ ${displayBlock};
77
+ ${positionRelative};
78
+ ${parseWidthHeight('100%', 0)};
79
+ transition: height 250ms cubic-bezier(0.4, 0, 0.2, 1) 0ms;
80
+ overflow-y: clip;
81
+ `;
53
82
  Collapse.defaultProps = {
54
- open: false
83
+ className: '',
84
+ open: false,
85
+ style: {}
55
86
  };
56
87
  Collapse.propTypes = {
57
- /** expand content if true */
58
- open: PropTypes.bool,
59
-
60
- /** The element to display in alert like text props (priority) */
88
+ /** The content of the component. */
61
89
  children: PropTypes.node,
62
90
 
63
- /** any props else */
64
- props: PropTypes.any
91
+ /** Class for component. */
92
+ className: PropTypes.string,
93
+
94
+ /** Callback fired when the component closed. */
95
+ onClosed: PropTypes.func,
96
+
97
+ /** Callback fired when the component opened. */
98
+ onOpened: PropTypes.func,
99
+
100
+ /** If `true`, the content is shown. */
101
+ open: PropTypes.bool,
102
+
103
+ /** Style inline of component. */
104
+ style: PropTypes.object
65
105
  };
66
106
  export default Collapse;
@@ -534,7 +534,6 @@ const DatePicker = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
534
534
  }, jsx(InputBase, {
535
535
  placeholder: placeholder,
536
536
  ...inputProps,
537
- readOnly: true,
538
537
  ref: ipConRef,
539
538
  inputRef: ipRef,
540
539
  disabled: disabled,
@@ -544,7 +543,8 @@ const DatePicker = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
544
543
  ...inputStyle
545
544
  },
546
545
  startIcon: startIcon,
547
- endIcon: endIcon
546
+ endIcon: endIcon,
547
+ onKeyDown: e => e.preventDefault()
548
548
  })), isError && jsx(HelperText, { ...errorProps,
549
549
  style: {
550
550
  minHeight: 16,
@@ -123,6 +123,7 @@ const MoneyInput = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
123
123
  convertToWords,
124
124
  prefix,
125
125
  suffix,
126
+ labelProps,
126
127
  ...props
127
128
  }, reference) => {
128
129
  const ref = useRef(null);
@@ -418,7 +419,7 @@ const MoneyInput = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
418
419
  css: MoneyInputRoot,
419
420
  className: ['DGN-UI-Money-Input', className].join(' ').trim().replace(/\s+/g, ' '),
420
421
  ...props
421
- }, !!label && jsx(Label, {
422
+ }, !!label && jsx(Label, { ...labelProps,
422
423
  required: required,
423
424
  disabled: disabled
424
425
  }, label), jsx(InputBase, {
@@ -581,6 +582,9 @@ MoneyInput.propTypes = {
581
582
  onFocus: PropTypes.func,
582
583
 
583
584
  /** inputRef of MoneyInput component */
584
- inputRef: PropTypes.any
585
+ inputRef: PropTypes.any,
586
+
587
+ /** [Props](https://core.diginet.com.vn/ui/?path=/docs/form-control-text-label) of label. */
588
+ labelProps: PropTypes.object
585
589
  };
586
590
  export default MoneyInput;
@@ -51,7 +51,8 @@ const NumberInput = /*#__PURE__*/forwardRef(({
51
51
  delayOnChange,
52
52
  fixedDecimalDigit,
53
53
  className,
54
- maxDigit
54
+ maxDigit,
55
+ labelProps
55
56
  }, reference) => {
56
57
  inputRef = inputRef || useRef(null);
57
58
  const pos = useRef(null);
@@ -269,7 +270,7 @@ const NumberInput = /*#__PURE__*/forwardRef(({
269
270
  ref: ref,
270
271
  css: NumberInputRoot,
271
272
  className: ['DGN-UI-NumberInput', className].join(' ').trim().replace(/\s+/g, ' ')
272
- }, !!label && jsx(Label, {
273
+ }, !!label && jsx(Label, { ...labelProps,
273
274
  required: required,
274
275
  disabled: disabled
275
276
  }, label), jsx(InputBase, {
@@ -435,6 +436,9 @@ NumberInput.propTypes = {
435
436
  className: PropTypes.string,
436
437
 
437
438
  /** max character is number of NumberInput component */
438
- maxDigit: PropTypes.number
439
+ maxDigit: PropTypes.number,
440
+
441
+ /** [Props](https://core.diginet.com.vn/ui/?path=/docs/form-control-text-label) of label. */
442
+ labelProps: PropTypes.object
439
443
  };
440
444
  export default NumberInput;
@@ -35,6 +35,7 @@ const PhoneInput = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
35
35
  inputRef,
36
36
  inputProps,
37
37
  inputStyle,
38
+ labelProps,
38
39
  error,
39
40
  onChange,
40
41
  onBlur,
@@ -295,7 +296,7 @@ const PhoneInput = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
295
296
  marginBottom: '20px'
296
297
  },
297
298
  ...props
298
- }, jsx(Label, {
299
+ }, jsx(Label, { ...labelProps,
299
300
  required: required,
300
301
  disabled: disabled
301
302
  }, label), jsx(InputBase, {
@@ -413,6 +414,9 @@ PhoneInput.propTypes = {
413
414
  onFocus: PropTypes.func,
414
415
 
415
416
  /** inputRef of PhoneInput component */
416
- inputRef: PropTypes.any
417
+ inputRef: PropTypes.any,
418
+
419
+ /** [Props](https://core.diginet.com.vn/ui/?path=/docs/form-control-text-label) of label. */
420
+ labelProps: PropTypes.object
417
421
  };
418
422
  export default PhoneInput;
@@ -488,9 +488,9 @@ Popover.propTypes = {
488
488
  /** An HTML element, or a function that returns one. It's used to set the position of the popover. */
489
489
  anchor: PropTypes.oneOfType([PropTypes.instanceOf(Element), PropTypes.func, PropTypes.object, PropTypes.node]),
490
490
 
491
- /**
492
- * This is the point on the anchor where the popover's anchor will attach to.
493
- * Options: vertical: [top, center, bottom]; horizontal: [left, center, right].
491
+ /**
492
+ * This is the point on the anchor where the popover's anchor will attach to.
493
+ * Options: vertical: [top, center, bottom]; horizontal: [left, center, right].
494
494
  */
495
495
  anchorOrigin: PropTypes.shape({
496
496
  horizontal: PropTypes.oneOf(['center', 'left', 'right']),
@@ -509,14 +509,14 @@ Popover.propTypes = {
509
509
  /** If `true`, click outside will close component. */
510
510
  clickOutsideToClose: PropTypes.bool,
511
511
 
512
- /**
513
- * Direction when Popover shown.
514
- * Note: This prop will overwrite anchorOrigin & transformOrigin.
515
- *
516
- * * top: anchorOrigin: { vertical: 'top', horizontal: 'center' }, transformOrigin: { vertical: 'bottom', horizontal: 'center' }
517
- * * left: anchorOrigin: { vertical: 'center', horizontal: 'left' }, transformOrigin: { vertical: 'center', horizontal: 'right' }
518
- * * right: anchorOrigin: { vertical: 'center', horizontal: 'right' }, transformOrigin: { vertical: 'center', horizontal: 'left' }
519
- * * right: anchorOrigin: { vertical: 'bottom', horizontal: 'center' }, transformOrigin: { vertical: 'top', horizontal: 'center' }
512
+ /**
513
+ * Direction when Popover shown.
514
+ * Note: This prop will overwrite anchorOrigin & transformOrigin.
515
+ *
516
+ * * top: anchorOrigin: { vertical: 'top', horizontal: 'center' }, transformOrigin: { vertical: 'bottom', horizontal: 'center' }
517
+ * * left: anchorOrigin: { vertical: 'center', horizontal: 'left' }, transformOrigin: { vertical: 'center', horizontal: 'right' }
518
+ * * right: anchorOrigin: { vertical: 'center', horizontal: 'right' }, transformOrigin: { vertical: 'center', horizontal: 'left' }
519
+ * * right: anchorOrigin: { vertical: 'bottom', horizontal: 'center' }, transformOrigin: { vertical: 'top', horizontal: 'center' }
520
520
  */
521
521
  direction: PropTypes.oneOf(['top', 'left', 'right', 'bottom']),
522
522
 
@@ -532,9 +532,9 @@ Popover.propTypes = {
532
532
  /** Style inline of component. */
533
533
  style: PropTypes.object,
534
534
 
535
- /**
536
- * This is the point on the popover which will attach to the anchor's origin.
537
- * Options: vertical: [top, center, bottom]; horizontal: [left, center, right].
535
+ /**
536
+ * This is the point on the popover which will attach to the anchor's origin.
537
+ * Options: vertical: [top, center, bottom]; horizontal: [left, center, right].
538
538
  */
539
539
  transformOrigin: PropTypes.shape({
540
540
  horizontal: PropTypes.oneOf(['center', 'left', 'right']),
@@ -547,13 +547,13 @@ Popover.propTypes = {
547
547
  /** Config z-index of the component. */
548
548
  zIndex: PropTypes.number,
549
549
 
550
- /**
551
- * ref methods (ref.current.instance.*method*)
552
- *
553
- * * show: Show popover
554
- * * close: Close popover
555
- * * setPosition(element): Set position of popover
556
- * * @param {element} - element
550
+ /**
551
+ * ref methods (ref.current.instance.*method*)
552
+ *
553
+ * * show: Show popover
554
+ * * close: Close popover
555
+ * * setPosition(element): Set position of popover
556
+ * * @param {element} - element
557
557
  */
558
558
  reference: PropTypes.oneOfType([PropTypes.func, PropTypes.shape({
559
559
  current: PropTypes.instanceOf(Element)
@@ -70,6 +70,7 @@ const Tooltip = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
70
70
  tooltipMaxWidth,
71
71
  viewportPadding,
72
72
  className,
73
+ disabled,
73
74
  ...props
74
75
  }, reference) => {
75
76
  const Id = randomString(6, {
@@ -439,6 +440,7 @@ const Tooltip = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
439
440
  };
440
441
 
441
442
  const setOpenTrue = () => {
443
+ if (disabled) return;
442
444
  setOpen(true);
443
445
  };
444
446
 
@@ -540,7 +542,8 @@ Tooltip.defaultProps = {
540
542
  textAlign: 'center',
541
543
  viewportPadding: defaultViewPadding,
542
544
  className: '',
543
- style: {}
545
+ style: {},
546
+ disabled: false
544
547
  };
545
548
  Tooltip.propTypes = {
546
549
  /** alignMode use to set align-items of the tooltip*/
@@ -564,6 +567,9 @@ Tooltip.propTypes = {
564
567
  /** initialize direction of the tooltip */
565
568
  direction: PropTypes.oneOf(['down', 'left', 'right', 'up']),
566
569
 
570
+ /** If `true`, the component is disabled. */
571
+ disabled: PropTypes.bool,
572
+
567
573
  /** distance between the tooltip and the children */
568
574
  distance: PropTypes.number,
569
575
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "diginet-core-ui",
3
- "version": "1.3.61-beta.2",
3
+ "version": "1.3.62-beta.1",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "license": "UNLICENSED",
package/readme.md CHANGED
@@ -38,6 +38,9 @@ npm test
38
38
  ```
39
39
 
40
40
  ## Changelog
41
+ ## 1.3.62
42
+ - \[Changed\]: Radio – Add value to event target
43
+
41
44
  ## 1.3.61
42
45
  - \[Added\]: MenuIcon – MHRM09N1035
43
46
  - \[Fixed\]: Dropdown – Fix bug not support Firefox browser
package/styles/colors.js CHANGED
@@ -253,7 +253,17 @@ export const color = {
253
253
  blue17: '#B5D9FF',
254
254
  blue18: '#ABD3FF',
255
255
  blue19: '#A0CEFF',
256
- blue20: '#96C8FF'
256
+ blue20: '#96C8FF',
257
+ //aqua
258
+ aqua5: '#00C4DF',
259
+ //pistachio
260
+ pistachio5: '#94C800',
261
+ //pumpkin
262
+ pumpkin5: '#FF7612',
263
+ //magenta
264
+ magenta5: '#DA30B4',
265
+ //violet
266
+ violet5: '#A430FF'
257
267
  };
258
268
  color.semantic = {
259
269
  danger: color.danger5,