diginet-core-ui 1.3.73 → 1.3.74

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 (58) hide show
  1. package/assets/images/menu/dhr/MHRP29N0026.svg +13 -0
  2. package/assets/images/menu/dhr/MHRP29N0027.svg +14 -0
  3. package/assets/images/menu/dhr/MHRP29N0028.svg +15 -0
  4. package/components/accordion/details.js +19 -10
  5. package/components/accordion/group.js +15 -6
  6. package/components/accordion/index.js +20 -11
  7. package/components/accordion/summary.js +18 -9
  8. package/components/avatar/index.js +1 -1
  9. package/components/badge/index.js +17 -9
  10. package/components/button/icon.js +33 -25
  11. package/components/button/index.js +25 -17
  12. package/components/card/body.js +12 -4
  13. package/components/card/extra.js +12 -4
  14. package/components/card/footer.js +12 -4
  15. package/components/card/header.js +12 -4
  16. package/components/card/index.js +12 -4
  17. package/components/chip/index.js +6 -6
  18. package/components/form-control/attachment/index.js +197 -192
  19. package/components/form-control/date-picker/index.js +4 -2
  20. package/components/form-control/date-range-picker/index.js +15 -8
  21. package/components/form-control/dropdown/index.js +34 -13
  22. package/components/form-control/input-base/index.js +505 -483
  23. package/components/form-control/label/index.js +27 -21
  24. package/components/form-control/text-input/index.js +4 -1
  25. package/components/grid/Col.js +8 -7
  26. package/components/grid/Container.js +16 -15
  27. package/components/grid/Row.js +16 -15
  28. package/components/grid/index.js +17 -36
  29. package/components/image/index.js +164 -0
  30. package/components/index.js +3 -1
  31. package/components/modal/body.js +12 -9
  32. package/components/modal/footer.js +22 -11
  33. package/components/modal/header.js +25 -13
  34. package/components/modal/index.js +32 -30
  35. package/components/modal/modal.js +29 -25
  36. package/components/others/option-wrapper/index.js +5 -18
  37. package/components/paging/page-info.js +45 -33
  38. package/components/paging/page-selector2.js +45 -33
  39. package/components/popover/body.js +14 -6
  40. package/components/popover/footer.js +15 -6
  41. package/components/popover/header.js +17 -7
  42. package/components/popover/index.js +242 -109
  43. package/components/status/index.js +12 -4
  44. package/components/tab/tab-container.js +29 -27
  45. package/components/tab/tab-header.js +33 -28
  46. package/components/tab/tab-panel.js +31 -27
  47. package/components/tab/tab.js +45 -35
  48. package/components/tree-view/index.js +108 -73
  49. package/components/typography/index.js +36 -25
  50. package/icons/basic.js +248 -0
  51. package/icons/effect.js +44 -36
  52. package/package.json +1 -1
  53. package/readme.md +40 -0
  54. package/styles/general.js +23 -0
  55. package/theme/index.js +1 -1
  56. package/theme/set-theme.js +2 -1
  57. package/utils/index.js +13 -10
  58. package/utils/useMediaQuery.js +4 -2
@@ -6,52 +6,60 @@ import { render } from 'react-dom';
6
6
  import PropTypes from 'prop-types';
7
7
  import { jsx, css } from '@emotion/core';
8
8
  import { Accordion, AccordionSummary, AccordionDetails, Typography, Checkbox, Divider, InputBase, ButtonIcon } from '..';
9
- import { mapParent, randomString, removeUnicode } from '../../utils';
9
+ import { classNames, mapParent, randomString, removeUnicode } from '../../utils';
10
10
  import { getGlobal } from '../../global';
11
11
  import { alignCenter, borderBox, cursorPointer, displayBlock, displayInlineBlock, flexRow, positionRelative } from '../../styles/general';
12
12
  import theme from '../../theme/settings';
13
13
  const {
14
14
  colors: {
15
+ system: {
16
+ disabled: systemDisabled
17
+ },
15
18
  fill: {
16
19
  focus: fillFocus,
17
20
  hover: fillHover,
18
21
  pressed: fillPressed
22
+ },
23
+ text: {
24
+ main: textMain
19
25
  }
20
- }
26
+ },
27
+ spacing
21
28
  } = theme;
22
29
  const separatorPattern = /\{\w+\}/g;
23
30
  const currentValue = {},
24
31
  itemsRenderAsync = {};
25
32
  const TreeView = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
26
- expand,
27
- disabled,
28
- selectBox,
29
- multiple,
30
- selectAll,
33
+ action = {},
31
34
  allowSearch,
32
- showSelectedItems,
33
- disabledRelevantValue,
34
- disabledBoldResult,
35
35
  autoExpandToResult,
36
- showChildrenOfResult,
36
+ className,
37
+ collapseIcon,
38
+ dataSource,
39
+ disabled,
40
+ disabledBoldResult,
41
+ disabledRelevantValue,
37
42
  displayExpr,
38
- valueExpr,
43
+ expand,
44
+ expandIcon,
39
45
  id,
40
- parentID,
41
- className,
42
- selectAllLabel,
46
+ multiple,
43
47
  multipleValueMode,
44
- searchMode,
45
- searchDelayTime,
46
- renderAsyncWithLength,
48
+ onChange,
49
+ parentID,
47
50
  renderAsyncFromLevel,
48
- expandIcon,
49
- collapseIcon,
50
- dataSource,
51
- value,
51
+ renderAsyncWithLength,
52
52
  renderItem,
53
- onChange,
53
+ searchDelayTime,
54
+ searchMode,
54
55
  searchProps,
56
+ selectAll,
57
+ selectAllLabel,
58
+ selectBox,
59
+ showChildrenOfResult,
60
+ showSelectedItems,
61
+ value,
62
+ valueExpr,
55
63
  ...props
56
64
  }, reference) => {
57
65
  const ref = useRef(null);
@@ -248,6 +256,12 @@ const TreeView = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
248
256
  if (node.classList.contains('DGN-UI-Accordion') && node.firstChild.classList.contains('DGN-UI-Accordion-Summary')) {
249
257
  var _node$querySelectorAl;
250
258
 
259
+ const summaryEl = node.firstChild;
260
+
261
+ if (!summaryEl.classList.contains('expanding')) {
262
+ summaryEl.lastChild.firstChild.click();
263
+ }
264
+
251
265
  const checkbox = node.firstChild.firstChild.lastChild.firstChild.firstChild.firstChild; // Trường hợp phải set về false để xét các input đã check không bao gồm node này
252
266
 
253
267
  checkbox.firstChild.checked = isChecked;
@@ -258,13 +272,10 @@ const TreeView = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
258
272
  node.classList[mustDisabled || isChecked ? 'add' : 'remove']('disabled');
259
273
  checkbox.classList[mustDisabled || isChecked ? 'add' : 'remove']('disabled');
260
274
  Array.from(node.childNodes).forEach(e => {
261
- e.classList[mustDisabled || isChecked ? 'add' : 'remove']('treeview-disabled');
275
+ setTimeout(() => {
276
+ e.classList[mustDisabled || isChecked ? 'add' : 'remove']('treeview-disabled');
277
+ });
262
278
  });
263
- const summaryEl = node.firstChild;
264
-
265
- if (!summaryEl.classList.contains('expanding')) {
266
- summaryEl.lastChild.firstChild.click();
267
- }
268
279
  }
269
280
  }
270
281
  };
@@ -646,6 +657,7 @@ const TreeView = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
646
657
 
647
658
  const keyArr = displayExpr.match(separatorPattern);
648
659
  const isTrue = value.includes(data[valueExpr] || data);
660
+ const isParentTrue = value.includes(data[parentID]);
649
661
  const focusClass = isTrue && !selectBox && !multiple ? 'focus' : '';
650
662
  const childItems = data.childItems; // is Summary
651
663
 
@@ -657,7 +669,17 @@ const TreeView = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
657
669
  return jsx(Accordion, {
658
670
  key: index,
659
671
  className: focusClass,
660
- expand: expand || data.expand
672
+ expand: expand || data.expand,
673
+ onExpand: e => {
674
+ if (disabledRelevantValue && !isTrue && !isParentTrue) {
675
+ handleDisabledParent(e, isTrue);
676
+ }
677
+ },
678
+ onCollapse: e => {
679
+ if (disabledRelevantValue && !isTrue && !isParentTrue) {
680
+ handleDisabledParent(e, isTrue);
681
+ }
682
+ }
661
683
  }, jsx(AccordionSummary, {
662
684
  expandIcon: expandIcon,
663
685
  collapseIcon: collapseIcon,
@@ -776,7 +798,7 @@ const TreeView = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
776
798
  });
777
799
  }
778
800
  }
779
- }, [value]);
801
+ }, []);
780
802
  useEffect(() => {
781
803
  if (selectAllRef.current) {
782
804
  checkedSelectAllCheckbox();
@@ -803,18 +825,32 @@ const TreeView = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
803
825
  });
804
826
  }
805
827
  }, [dataSource, value, multiple, selectBox, onChange]);
806
- useImperativeHandle(reference, () => ({
807
- disabled,
808
- displayExpr,
809
- valueExpr,
810
- id,
811
- parentID,
812
- value,
813
- getValue: () => Object.keys(currentValue[unique]).filter(v => currentValue[unique][v]),
814
- setValue,
815
- handleCheckbox,
816
- get: () => ref.current
817
- }));
828
+ useImperativeHandle(reference, () => {
829
+ const currentRef = ref.current || {};
830
+ currentRef.element = ref.current;
831
+ const _instance = { ...action
832
+ }; // methods
833
+
834
+ _instance.__proto__ = {}; // hidden methods
835
+
836
+ currentRef.instance = _instance; // keep old method
837
+
838
+ currentRef.disabled = disabled;
839
+ currentRef.displayExpr = displayExpr;
840
+ currentRef.valueExpr = valueExpr;
841
+ currentRef.id = id;
842
+ currentRef.parentID = parentID;
843
+ currentRef.value = value;
844
+
845
+ currentRef.getValue = () => Object.keys(currentValue[unique]).filter(v => currentValue[unique][v]);
846
+
847
+ currentRef.setValue = setValue;
848
+ currentRef.handleCheckbox = handleCheckbox;
849
+
850
+ currentRef.get = () => ref.current;
851
+
852
+ return currentRef;
853
+ });
818
854
  return useMemo(() => {
819
855
  var _value3;
820
856
 
@@ -830,7 +866,7 @@ const TreeView = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
830
866
  const sync = (dataSource === null || dataSource === void 0 ? void 0 : dataSource.length) > renderAsyncWithLength;
831
867
  return jsx("div", {
832
868
  css: TreeViewRootCSS,
833
- className: 'DGN-UI-TreeView' + (disabled ? ' disabled' : '')
869
+ className: classNames('DGN-UI-TreeView', disabled && 'disabled')
834
870
  }, showSelectedItems && jsx(InputBase, {
835
871
  inputRef: inputValueRef,
836
872
  viewType: 'outlined',
@@ -866,9 +902,9 @@ const TreeView = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
866
902
  })), jsx(Divider, null)), jsx("div", {
867
903
  ref: ref,
868
904
  ...props,
869
- className: ['TreeView-Content', disabled ? 'disabled' : '', className].join(' ').trim().replace(/\s+/g, ' ')
905
+ className: classNames('TreeView-Content', disabled && 'disabled', className)
870
906
  }, mapParent(dataSource, id, parentID, true).map((data, index) => renderTreeView(data, index.toString(), 0, sync))));
871
- }, [dataSource, value, renderAsyncWithLength, disabled, showSelectedItems, allowSearch, multiple, selectAll, selectAllLabel, className, selectBox, id, parentID, disabledBoldResult, autoExpandToResult, showChildrenOfResult, searchMode, onChange, searchProps]);
907
+ }, [allowSearch, autoExpandToResult, className, collapseIcon, dataSource, disabled, disabledBoldResult, disabledRelevantValue, displayExpr, expandIcon, id, multiple, multipleValueMode, onChange, parentID, renderAsyncFromLevel, renderAsyncWithLength, renderItem, searchMode, searchProps, selectAll, selectAllLabel, selectBox, showChildrenOfResult, showSelectedItems, value, valueExpr]);
872
908
  }));
873
909
  const TreeViewRootCSS = css`
874
910
  ${displayBlock};
@@ -881,11 +917,11 @@ const TreeViewRootCSS = css`
881
917
  padding: 0;
882
918
  border-radius: 0;
883
919
  &.focus {
884
- background-color: ${theme.colors.focus};
920
+ background-color: ${fillFocus};
885
921
  }
886
922
  .Accordion-Icon-Root {
887
923
  ${flexRow};
888
- margin-right: 4px;
924
+ margin-right: ${spacing([1])};
889
925
  }
890
926
  }
891
927
  .DGN-UI-Accordion-Details-Content {
@@ -916,7 +952,7 @@ const TreeViewRootCSS = css`
916
952
  ${displayInlineBlock};
917
953
  ${positionRelative};
918
954
  height: 100%;
919
- margin-right: 8px;
955
+ margin-right: ${spacing([2])};
920
956
  }
921
957
  .TreeView-Item {
922
958
  ${flexRow};
@@ -925,13 +961,13 @@ const TreeViewRootCSS = css`
925
961
  ${borderBox};
926
962
  min-height: 40px;
927
963
  text-align: left;
928
- color: ${theme.colors.text.main};
964
+ color: ${textMain};
929
965
  width: 100%;
930
966
  &.non-child {
931
967
  ${cursorPointer};
932
968
  transition: background-color 300ms ease;
933
969
  &.disabled {
934
- color: ${theme.colors.disabled};
970
+ color: ${systemDisabled};
935
971
  cursor: no-drop;
936
972
  }
937
973
  &:not(.disabled) {
@@ -950,7 +986,7 @@ const TreeViewRootCSS = css`
950
986
  }
951
987
  }
952
988
  &.focus {
953
- background-color: ${theme.colors.focus};
989
+ background-color: ${fillFocus};
954
990
  }
955
991
  &.TreeView-Item-active .DGN-UI-Typography {
956
992
  font-weight: bold;
@@ -958,40 +994,39 @@ const TreeViewRootCSS = css`
958
994
  }
959
995
  &.expand-able {
960
996
  .TreeView-All {
961
- margin-left: 34px;
997
+ margin-left: ${spacing([8.5])};
962
998
  }
963
999
  .TreeView-Item.non-child {
964
- padding-left: 34px;
1000
+ padding-left: ${spacing([8.5])};
965
1001
  }
966
1002
  }
967
1003
  `;
968
1004
  TreeView.defaultProps = {
969
- expand: false,
970
- disabled: false,
971
- disabledMap: false,
972
- selectBox: false,
973
- multiple: false,
974
- selectAll: false,
975
1005
  allowSearch: false,
976
- showSelectedItems: false,
977
- disabledRelevantValue: false,
978
- disabledBoldResult: false,
979
1006
  autoExpandToResult: true,
980
- showChildrenOfResult: false,
981
- displayExpr: 'name',
982
- id: 'id',
983
- parentID: 'parentID',
984
- valueExpr: '',
985
1007
  className: '',
986
- selectAllLabel: getGlobal('selectAll'),
987
1008
  dataSource: [],
988
- value: [],
1009
+ disabled: false,
1010
+ disabledBoldResult: false,
1011
+ disabledRelevantValue: false,
1012
+ displayExpr: 'name',
1013
+ expand: false,
989
1014
  expandIcon: 'ArrowDown',
1015
+ id: 'id',
1016
+ multiple: false,
990
1017
  multipleValueMode: 'multiple',
991
- searchMode: 'contains',
992
- renderAsyncWithLength: 200,
1018
+ parentID: 'parentID',
993
1019
  renderAsyncFromLevel: 2,
994
- searchProps: {}
1020
+ renderAsyncWithLength: 200,
1021
+ searchMode: 'contains',
1022
+ searchProps: {},
1023
+ selectAll: false,
1024
+ selectAllLabel: getGlobal('selectAll'),
1025
+ selectBox: false,
1026
+ showChildrenOfResult: false,
1027
+ showSelectedItems: false,
1028
+ value: [],
1029
+ valueExpr: ''
995
1030
  };
996
1031
  TreeView.propTypes = {
997
1032
  /** expand immediate if true */
@@ -4,9 +4,9 @@
4
4
  import { memo, useRef, forwardRef, useImperativeHandle, Fragment, useMemo, useState } from 'react';
5
5
  import PropTypes from 'prop-types';
6
6
  import { jsx, css } from '@emotion/core';
7
- import { renderHTML } from '../../utils';
7
+ import { classNames, renderHTML } from '../../utils';
8
8
  import { Popover } from '..';
9
- import { breakWord, displayBlock, displayInlineBlock, overflowHidden, positionRelative, textCapitalize, textCenter, textUppercase } from '../../styles/general';
9
+ import { breakWord, cursorPointer, displayBlock, displayInlineBlock, overflowHidden, positionRelative, textCapitalize, textCenter, textUppercase } from '../../styles/general';
10
10
  import { color as colors } from '../../styles/colors';
11
11
  import theme from '../../theme/settings';
12
12
  const {
@@ -36,7 +36,8 @@ const {
36
36
  paragraph1,
37
37
  paragraph2,
38
38
  paragraph3
39
- }
39
+ },
40
+ spacing
40
41
  } = theme;
41
42
  const typographyMap = new Map([['t1', title1], ['t2', title2], ['t3', title3], ['t4', title4], ['h1', heading1], ['h2', heading2], ['h3', heading3], ['h4', heading4], ['h5', heading5], ['h6', heading6], ['p1', paragraph1], ['p2', paragraph2], ['p3', paragraph3]]);
42
43
  const colorMap = new Map([['default', main], ['secondary', rest]]);
@@ -44,28 +45,32 @@ const colorMap = new Map([['default', main], ['secondary', rest]]);
44
45
  const isTextClamped = elm => (elm === null || elm === void 0 ? void 0 : elm.scrollHeight) > (elm === null || elm === void 0 ? void 0 : elm.clientHeight);
45
46
 
46
47
  const Typography = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
47
- type,
48
- color,
49
- center,
50
- uppercase,
48
+ action = {},
51
49
  capitalize,
52
- fullWidth,
53
- mapping,
54
- className,
55
- lineClamp,
50
+ center,
56
51
  children,
52
+ className,
53
+ color,
54
+ fullWidth,
57
55
  hoverTooltip,
56
+ lineClamp,
57
+ mapping,
58
+ onClick,
58
59
  tooltipDirection,
60
+ type,
61
+ uppercase,
59
62
  ...props
60
63
  }, reference) => {
61
64
  const ref = useRef(null);
62
65
  const [openTooltip, setOpenTooltip] = useState(false);
63
66
 
64
- const _TextRootCSS = TextRootCSS(color, type, lineClamp);
67
+ const _TextRootCSS = TextRootCSS(color, type, lineClamp, onClick);
65
68
 
66
69
  useImperativeHandle(reference, () => {
67
70
  const currentRef = ref.current || {};
68
- const _instance = {}; // methods
71
+ currentRef.element = ref.current;
72
+ const _instance = { ...action
73
+ }; // methods
69
74
 
70
75
  _instance.__proto__ = {}; // hidden methods
71
76
 
@@ -73,7 +78,7 @@ const Typography = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
73
78
  return currentRef;
74
79
  });
75
80
 
76
- const classNames = inTooltip => ['DGN-UI-Typography', center && 'DGN-Typography-center', fullWidth && 'DGN-Typography-fullWidth', `DGN-Typography-${type}`, uppercase && `DGN-Typography-Uppercase`, capitalize && 'DGN-Typography-Capitalize', !inTooltip && lineClamp && 'DGN-Typography-Clamp', className].join(' ').trim().replace(/\s+/g, ' ');
81
+ const classes = inTooltip => classNames('DGN-UI-Typography', center && 'DGN-Typography-center', fullWidth && 'DGN-Typography-fullWidth', `DGN-Typography-${type}`, uppercase && `DGN-Typography-Uppercase`, capitalize && 'DGN-Typography-Capitalize', !inTooltip && lineClamp && 'DGN-Typography-Clamp', className);
77
82
 
78
83
  const setHoverTooltip = (open, isTooltip) => {
79
84
  !isTooltip && setOpenTooltip(false);
@@ -105,28 +110,31 @@ const Typography = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
105
110
  direction: tooltipDirection
106
111
  }, renderHTML(renderChildren(), mapping, {
107
112
  css: _TextRootCSS,
108
- className: classNames(true),
113
+ className: classes(true),
109
114
  style: {
110
115
  color: textTooltip,
111
- padding: '4px 6px'
116
+ padding: spacing([1, 1.5]),
117
+ height: 'fit-content'
112
118
  }
113
119
  }));
114
- }, [openTooltip, tooltipDirection, children, mapping, color, type, lineClamp]);
120
+ }, [openTooltip, capitalize, center, children, className, color, fullWidth, hoverTooltip, lineClamp, mapping, onClick, tooltipDirection, type, uppercase]);
115
121
  return jsx(Fragment, null, renderHTML(renderChildren(), mapping, {
116
122
  ref: ref,
117
123
  css: _TextRootCSS,
118
- className: classNames(false),
124
+ className: classes(false),
119
125
  onMouseEnter: () => setHoverTooltip(true),
120
126
  onMouseLeave: () => setHoverTooltip(false),
127
+ onClick: onClick,
121
128
  ...props
122
129
  }), hoverTooltip && renderTooltip);
123
130
  }));
124
131
 
125
- const TextRootCSS = (color, type, lineClamp) => css`
132
+ const TextRootCSS = (color, type, lineClamp, onClick) => css`
126
133
  ${displayInlineBlock};
127
134
  ${positionRelative};
128
135
  ${breakWord};
129
136
  ${paragraph1};
137
+ ${onClick && cursorPointer};
130
138
  white-space: break-spaces;
131
139
  color: ${colorMap.get(color) || colors[color] || color};
132
140
  max-width: max-content;
@@ -155,14 +163,14 @@ const TextRootCSS = (color, type, lineClamp) => css`
155
163
  `;
156
164
 
157
165
  Typography.defaultProps = {
158
- type: 'p1',
159
- color: 'default',
160
166
  center: false,
161
- fullWidth: true,
162
- mapping: 'span',
163
167
  className: '',
168
+ color: 'default',
169
+ fullWidth: true,
164
170
  hoverTooltip: false,
165
- tooltipDirection: 'bottom'
171
+ mapping: 'span',
172
+ tooltipDirection: 'bottom',
173
+ type: 'p1'
166
174
  };
167
175
  /** type of text<br/>
168
176
  * h1: Title <br/>
@@ -193,7 +201,7 @@ Typography.propTypes = {
193
201
  /** Color of text ['primary', 'secondary', 'success', 'warning', 'danger', 'info', '#hex', rgb(#,#,#)]. */
194
202
  color: PropTypes.string,
195
203
 
196
- /** If true, the component will take up the full width of its container. */
204
+ /** If `true`, the component will take up the full width of its container. */
197
205
  fullWidth: PropTypes.bool,
198
206
 
199
207
  /** If `true`, hover will show tooltip when text clamped. */
@@ -205,6 +213,9 @@ Typography.propTypes = {
205
213
  /** The component used for the root node. Either a string to use a HTML element or a component. */
206
214
  mapping: PropTypes.string,
207
215
 
216
+ /** Callback fired when the component is clicked. */
217
+ onClick: PropTypes.func,
218
+
208
219
  /** Accepts all props which `mapping` tag support. */
209
220
  props: PropTypes.object,
210
221