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.
Files changed (30) hide show
  1. package/assets/images/menu/dhr/MHRM00N0005.svg +11 -0
  2. package/assets/images/menu/dhr/MHRM09N1010.svg +12 -0
  3. package/assets/images/menu/dhr/MHRM09N1015.svg +18 -0
  4. package/assets/images/menu/dhr/MHRM09N1020.svg +13 -0
  5. package/assets/images/menu/dhr/MHRM09N1400.svg +11 -0
  6. package/assets/images/menu/dhr/MHRP25L0101.svg +15 -0
  7. package/assets/images/menu/dhr/MHRP25L0501.svg +14 -0
  8. package/components/button/icon.js +211 -216
  9. package/components/chart/line/Axis.js +11 -10
  10. package/components/chart/line/Grid.js +4 -3
  11. package/components/chart/line/Path.js +11 -10
  12. package/components/chart/line/Point.js +107 -80
  13. package/components/chart/line/index.js +36 -17
  14. package/components/form-control/checkbox/index.js +5 -5
  15. package/components/form-control/date-picker/index.js +131 -119
  16. package/components/form-control/dropdown/index.js +3 -4
  17. package/components/form-control/dropdown-box/index.js +1 -1
  18. package/components/form-control/helper-text/index.js +35 -33
  19. package/components/form-control/input-base/index.js +318 -317
  20. package/components/form-control/text-input/index.js +4 -4
  21. package/components/form-control/time-picker/index.js +10 -19
  22. package/components/modal/modal.js +10 -4
  23. package/components/paging/page-info.js +78 -41
  24. package/components/slider/slider-container.js +150 -126
  25. package/components/slider/slider-item.js +84 -89
  26. package/components/tree-view/css.js +17 -16
  27. package/components/tree-view/index.js +41 -23
  28. package/package.json +1 -1
  29. package/readme.md +20 -0
  30. 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
- useImperativeHandle(reference, () => ({
78
- get: () => {
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: iconAreaCSS,
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
- /** action icons position */
616
+ /** Action icons position. */
605
617
  actionIconAt: PropTypes.oneOf(['end', 'start']),
606
618
 
607
- /** display the clear icon if true */
619
+ /** Display the clear icon if true. */
608
620
  clearAble: PropTypes.bool,
609
621
 
610
- /** if 'true' the calendar will have a footer controls */
622
+ /** If 'true' the calendar will have a footer controls. */
611
623
  controls: PropTypes.bool,
612
624
 
613
- /** the default value of the component */
625
+ /** The default value of the component. */
614
626
  defaultValue: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.string, PropTypes.object]),
615
627
 
616
- /** if 'true' the form control will be disabled */
628
+ /** If 'true' the form control will be disabled. */
617
629
  disabled: PropTypes.bool,
618
630
 
619
- /** format to display value */
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
- /** view days of previous or next month */
634
+ /** View days of previous or next month. */
623
635
  displayAnotherMonth: PropTypes.bool,
624
636
 
625
- /** error of the form control */
626
- error: PropTypes.string,
637
+ /** Error of the form control. */
638
+ error: PropTypes.oneOfType([PropTypes.bool, PropTypes.string]),
627
639
 
628
- /** inputProps are properties of the input element */
640
+ /** InputProps are properties of the input element. */
629
641
  inputProps: PropTypes.object,
630
642
 
631
- /** inputStyle is style of input element */
643
+ /** InputStyle is style of input element. */
632
644
  inputStyle: PropTypes.object,
633
645
 
634
- /** content of the label element */
646
+ /** Content of the label element. */
635
647
  label: PropTypes.oneOfType([PropTypes.string, PropTypes.node]),
636
648
 
637
- /** labelProps are properties if the label element */
649
+ /** LabelProps are properties if the label element. */
638
650
  labelProps: PropTypes.object,
639
651
 
640
- /** min value of date picker */
652
+ /** Min value of date picker. */
641
653
  min: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.string, PropTypes.object]),
642
654
 
643
- /** max value of date picker */
655
+ /** Max value of date picker. */
644
656
  max: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.string, PropTypes.object]),
645
657
 
646
- /** a callback function when value input change */
658
+ /** A callback function when value input change. */
647
659
  onChange: PropTypes.func,
648
660
 
649
- /** hints for input */
661
+ /** Hints for input. */
650
662
  placeholder: PropTypes.string,
651
663
 
652
- /** allow close Popup when press ESC */
664
+ /** Allow close Popup when press ESC. */
653
665
  pressESCToClose: PropTypes.bool,
654
666
 
655
- /** status read only of input */
667
+ /** Status read only of input. */
656
668
  readOnly: PropTypes.bool,
657
669
 
658
- /** required state of the form control */
670
+ /** Required state of the form control. */
659
671
  required: PropTypes.bool,
660
672
 
661
- /** format of the returned value */
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
- /** style of the component */
676
+ /** Style inline of component. */
665
677
  style: PropTypes.object,
666
678
 
667
- /** text align of the input */
679
+ /** Text align of the input. */
668
680
  textAlign: PropTypes.oneOf(['center', 'end', 'start']),
669
681
 
670
- /** value of the component */
682
+ /** Value of the component. */
671
683
  value: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.string, PropTypes.array, PropTypes.object]),
672
684
 
673
- /** view type of the form control */
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: [],
@@ -77,7 +77,7 @@ const DropdownBox = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
77
77
  };
78
78
 
79
79
  const pressESCHandler = event => {
80
- if (event.key === 'Escape' || event.key === 'Tab') {
80
+ if (event.key === 'Escape') {
81
81
  closeDropdownBox();
82
82
  }
83
83
  };
@@ -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
- ...props
31
+ id
16
32
  }, ref) => {
17
- /* Start styled */
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: theme.colors.danger,
38
+ color: disabled ? systemDisabled : color,
42
39
  fullWidth: false,
43
- css: HelperTextRoot,
44
- className: ['DGN-UI-HelperText', className, status, disabled ? 'disabled' : ''].join(' ').trim(),
45
- ...props
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
- /** prevent all event if true */
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
- /** class use in for helper text */
63
+ /** Class for component. */
62
64
  className: PropTypes.string,
63
65
 
64
- /** the content to display in HelperText */
65
- children: PropTypes.oneOfType([PropTypes.string, PropTypes.bool]),
66
+ /** Style inline of component. */
67
+ style: PropTypes.object,
66
68
 
67
- /** any props else */
68
- props: PropTypes.any
69
+ /** Content to display in component. */
70
+ children: PropTypes.oneOfType([PropTypes.string, PropTypes.bool])
69
71
  };
70
72
  export default HelperText;