diginet-core-ui 1.3.52 → 1.3.53-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.
@@ -82,7 +82,7 @@ const Accordion = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
82
82
  display: 'none'
83
83
  }
84
84
  })));
85
- }, [id, disabled, className, boxShadow, onClick, children, expanded, onExpand, onCollapse, expandState]);
85
+ }, [id, disabled, className, style, boxShadow, onClick, children, expanded, onExpand, onCollapse, expandState]);
86
86
  }));
87
87
  const AccordionRootCSS = css`
88
88
  ${displayBlock};
@@ -35,26 +35,25 @@ const AccordionSummary = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
35
35
  const _SummaryRootCSS = SummaryRootCSS(background);
36
36
 
37
37
  const _onClick = e => {
38
- if (!disabled) {
39
- const target = e.target;
38
+ if (disabled) return;
39
+ const target = e.target;
40
40
 
41
- if (onClickAccordion) {
42
- onClickAccordion();
43
- return;
44
- }
41
+ if (onClickAccordion) {
42
+ onClickAccordion();
43
+ return;
44
+ }
45
45
 
46
- if (onClick && (!expandIconRef.current || !expandIconRef.current.contains(target))) {
47
- onClick(e);
48
- return;
49
- }
46
+ if (onClick && (!expandIconRef.current || !expandIconRef.current.contains(target))) {
47
+ onClick(e);
48
+ return;
49
+ }
50
50
 
51
- if (expandState) {
52
- if (expanded === undefined) setExpandState(false);
53
- !!onCollapse && onCollapse(e);
54
- } else if (!expandState) {
55
- if (expanded === undefined) setExpandState(true);
56
- !!onExpand && onExpand(e);
57
- }
51
+ if (expandState) {
52
+ if (expanded === undefined) setExpandState(false);
53
+ !!onCollapse && onCollapse(e);
54
+ } else if (!expandState) {
55
+ if (expanded === undefined) setExpandState(true);
56
+ !!onExpand && onExpand(e);
58
57
  }
59
58
  };
60
59
 
@@ -137,7 +136,7 @@ const AccordionSummary = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
137
136
  }) : jsx("span", {
138
137
  className: 'Accordion-Collapse-Icon effect'
139
138
  }, collapseIcon)))));
140
- }, [id, expandIcon, expandIconAt, className, background, children, collapseIcon, expandIconProps, expandState]);
139
+ }, [id, expandIcon, expandIconAt, className, background, children, collapseIcon, expandIconProps, style, expandState, disabled]);
141
140
  }));
142
141
  AccordionSummary.defaultProps = {
143
142
  expandIconAt: 'start',
@@ -10,8 +10,8 @@ import ButtonIcon from '../button/icon';
10
10
  import Icon from '../../icons';
11
11
  import { hexToRGBA } from '../../styles/color-helper';
12
12
  import { typography } from '../../styles/typography';
13
- import { alignCenter, border, borderBox, borderRadius4px, breakWord, displayBlock, flexRow, justifyStart, positionRelative, userSelectNone } from '../../styles/general';
14
13
  import { useTheme } from '../../theme';
14
+ import { alignCenter, border, borderBox, borderRadius4px, breakWord, displayBlock, flexRow, justifyStart, positionRelative, userSelectNone } from '../../styles/general';
15
15
  const {
16
16
  heading3,
17
17
  heading4,
@@ -114,8 +114,7 @@ const Chip = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
114
114
  className: size
115
115
  }, jsx(Typography, {
116
116
  type: size === 'small' ? 'p2' : 'p1',
117
- color: 'inherit',
118
- lineClamp: 1
117
+ color: 'inherit'
119
118
  }, renderLabel()));
120
119
  }, [label, size, startIcon, endIcon, clearAble]);
121
120
  const endIconView = useMemo(() => {
@@ -41,8 +41,8 @@ const Checkbox = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
41
41
  children,
42
42
  inputProps,
43
43
  forTreeView,
44
- width,
45
44
  labelProps,
45
+ width,
46
46
  ...props
47
47
  }, reference) => {
48
48
  if (!inputRef) {
@@ -70,7 +70,6 @@ const Dropdown = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
70
70
  total,
71
71
  placeholder,
72
72
  error,
73
- keyExpr,
74
73
  displayExpr,
75
74
  subText,
76
75
  valueExpr,
@@ -155,11 +154,13 @@ const Dropdown = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
155
154
 
156
155
  const onClickInput = e => {
157
156
  if (!boxRef.current) {
158
- if (!multiple || !Array.from(inputRef.current.querySelectorAll('.DGN-UI-Chip')).some(item => item.contains(e.target))) {
159
- if ((renderSelectedItem || iconExpr && iconExpr !== 'none') && !multiple) {
157
+ if (!multiple || !Array.from(inputRef.current.querySelectorAll('.DGN-UI-Chip')).some(item => item.contains(e === null || e === void 0 ? void 0 : e.target))) {
158
+ if ((typeof renderSelectedItem === 'function' || iconExpr && iconExpr !== 'none') && !multiple) {
159
+ var _inputRef$current$chi;
160
+
160
161
  inputRef.current.innerHTML = inputRef.current.textContent.trim();
161
162
  inputRef.current.contentEditable = 'plaintext-only';
162
- const caret = inputRef.current.childNodes.length ? 1 : 0;
163
+ const caret = (_inputRef$current$chi = inputRef.current.childNodes) !== null && _inputRef$current$chi !== void 0 && _inputRef$current$chi.length ? 1 : 0;
163
164
  const range = document.createRange();
164
165
  range.setStart(inputRef.current, caret);
165
166
  range.setEnd(inputRef.current, caret);
@@ -281,7 +282,6 @@ const Dropdown = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
281
282
  window.addEventListener('resize', customizeWidthDropdown);
282
283
  document.addEventListener('wheel', onWheelHandler);
283
284
  document.addEventListener('mousedown', onClickOutsideOfInput);
284
- document.addEventListener('keydown', preventScroll);
285
285
  boxRef.current && boxRef.current.addEventListener('keydown', moveOnItem);
286
286
 
287
287
  if (onLoadMore && dataSource.length < total) {
@@ -306,15 +306,6 @@ const Dropdown = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
306
306
  }
307
307
  };
308
308
 
309
- const preventScroll = e => {
310
- if (/Arrow(Up|Down)/.test(e.key)) {
311
- e.preventDefault();
312
- return false;
313
- }
314
-
315
- return true;
316
- };
317
-
318
309
  const pressESCHandler = event => {
319
310
  if (event.key === 'Escape' || event.key === 'Tab') {
320
311
  closeDropdown();
@@ -339,11 +330,9 @@ const Dropdown = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
339
330
  };
340
331
 
341
332
  const closeDropdown = () => {
342
- const node = document.querySelector(`.DGN-Dropdown-${unique}`);
343
-
344
- if ((renderSelectedItem || iconExpr && iconExpr !== 'none') && !multiple && inputRef.current) {
345
- inputRef.current.contentEditable = true;
346
- }
333
+ const node = document.querySelector(`.DGN-Dropdown-${unique}`); // if ((renderSelectedItem || (iconExpr && iconExpr !== 'none')) && !multiple && inputRef.current && !disabled) {
334
+ // inputRef.current.contentEditable = true;
335
+ // }
347
336
 
348
337
  if (node) {
349
338
  node.style.pointerEvents = `none`;
@@ -359,7 +348,6 @@ const Dropdown = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
359
348
  document.removeEventListener('mousedown', onClickOutsideOfInput);
360
349
  window.removeEventListener('resize', customizeWidthDropdown);
361
350
  document.removeEventListener('wheel', onWheelHandler);
362
- document.removeEventListener('keydown', preventScroll);
363
351
 
364
352
  if (onLoadMore && boxRef.current) {
365
353
  boxRef.current.removeEventListener('scroll', onLoadMoreHandler);
@@ -400,12 +388,14 @@ const Dropdown = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
400
388
  };
401
389
 
402
390
  const mapDropdown = (pattern, keyArr) => {
391
+ var _currentObjectDefault;
392
+
403
393
  const items = [];
404
394
  const dataSourceUsable = [...dataSource];
405
395
 
406
396
  const _DropdownItemCSS = DropdownItemCSS(multiple, selectBox);
407
397
 
408
- if (currentObjectDefault[unique] && currentObjectDefault[unique].length) {
398
+ if (currentObjectDefault[unique] && (_currentObjectDefault = currentObjectDefault[unique]) !== null && _currentObjectDefault !== void 0 && _currentObjectDefault.length) {
409
399
  const length = currentObjectDefault[unique].length;
410
400
  let existItemQuantity = 0;
411
401
 
@@ -503,7 +493,7 @@ const Dropdown = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
503
493
  }, displayText)));
504
494
  }
505
495
 
506
- if (items.length === limit) {
496
+ if ((items === null || items === void 0 ? void 0 : items.length) === limit) {
507
497
  timerRef.current = setTimeout(() => {
508
498
  loadMoreItemsDropdown(index + 1, pattern);
509
499
  }, 1000);
@@ -514,7 +504,7 @@ const Dropdown = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
514
504
  return jsx("div", {
515
505
  css: DropdownBoxCSS,
516
506
  ref: boxRef
517
- }, items.length ? items : jsx("div", {
507
+ }, items !== null && items !== void 0 && items.length ? items : jsx("div", {
518
508
  css: _DropdownItemCSS,
519
509
  className: 'no-data'
520
510
  }, ' ', noDataText, ' '));
@@ -547,13 +537,13 @@ const Dropdown = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
547
537
  };
548
538
 
549
539
  const loadMoreItemsDropdown = (i = 0, pattern) => {
550
- var _displayExpr3;
540
+ var _currentObjectDefault2, _displayExpr3;
551
541
 
552
542
  const dataSourceUsable = [...dataSource]; // Nếu có load more thì đẩy đội tượng mặc định lên đầu
553
543
 
554
544
  let notExistItem = 0;
555
545
 
556
- if (onLoadMore && currentObjectDefault[unique].length) {
546
+ if (onLoadMore && (_currentObjectDefault2 = currentObjectDefault[unique]) !== null && _currentObjectDefault2 !== void 0 && _currentObjectDefault2.length) {
557
547
  const length = currentObjectDefault[unique].length;
558
548
 
559
549
  for (let index = length - 1; index >= 0; index--) {
@@ -744,7 +734,9 @@ const Dropdown = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
744
734
  const _DropdownItemCSS = DropdownItemCSS(multiple, selectBox);
745
735
 
746
736
  if (scrollHeight === Math.ceil(scrollTop) + offsetHeight && boxRef.current) {
747
- const length = boxRef.current.querySelectorAll(`.css-${_DropdownItemCSS.name}`).length;
737
+ var _boxRef$current$query;
738
+
739
+ const length = (_boxRef$current$query = boxRef.current.querySelectorAll(`.css-${_DropdownItemCSS.name}`)) === null || _boxRef$current$query === void 0 ? void 0 : _boxRef$current$query.length;
748
740
  boxRef.current.removeEventListener('scroll', onLoadMoreHandler);
749
741
  !!onLoadMore && onLoadMore({
750
742
  skip: length,
@@ -784,7 +776,7 @@ const Dropdown = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
784
776
 
785
777
  const value = e.target.value || e.target.textContent;
786
778
 
787
- if (renderSelectedItem && e.target.childNodes && Array.from(e.target.childNodes).some(node => node.toString() !== '[object Text]')) {
779
+ if (typeof renderSelectedItem === 'function' && e.target.childNodes && Array.from(e.target.childNodes).some(node => node.toString() !== '[object Text]')) {
788
780
  const cursor = document.getSelection().anchorOffset;
789
781
  e.target.innerHTML = value;
790
782
  document.getSelection().collapse(e.target, cursor);
@@ -824,7 +816,7 @@ const Dropdown = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
824
816
  if (valueProp === undefined) {
825
817
  let item = null;
826
818
 
827
- if (renderSelectedItem && typeof renderSelectedItem === 'function') {
819
+ if (typeof renderSelectedItem === 'function') {
828
820
  item = renderSelectedItem({
829
821
  data,
830
822
  index
@@ -926,7 +918,7 @@ const Dropdown = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
926
918
  };
927
919
 
928
920
  const onClear = e => {
929
- if (disabled || readOnly || loading) return;
921
+ if (disabled || readOnly || loading || !clearAble) return;
930
922
  currentValue[unique] = multiple ? [] : '';
931
923
 
932
924
  if (inputRef.current.tagName.toLowerCase() === 'div') {
@@ -940,6 +932,7 @@ const Dropdown = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
940
932
  } // onChangeValue('', '');
941
933
 
942
934
 
935
+ setShowClear(false);
943
936
  e && e.target && e.target.blur();
944
937
  updatePositionDropdown();
945
938
  onInput === null || onInput === void 0 ? void 0 : onInput({ ...(inputRef === null || inputRef === void 0 ? void 0 : inputRef.current),
@@ -963,7 +956,7 @@ const Dropdown = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
963
956
  inputRef.current.innerHTML = '';
964
957
  currentValue[unique] = [];
965
958
  } else {
966
- if (renderSelectedItem || iconExpr && iconExpr !== 'none' && !isSearch[unique]) {
959
+ if (typeof renderSelectedItem === 'function' || iconExpr && iconExpr !== 'none' && !isSearch[unique]) {
967
960
  inputRef.current.innerHTML = '';
968
961
  } else if (!isSearch[unique]) {
969
962
  inputRef.current.value = '';
@@ -976,7 +969,7 @@ const Dropdown = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
976
969
  }
977
970
 
978
971
  const length = dataSource.length;
979
- const displayKey = keyExpr || displayExpr;
972
+ const displayKey = typeof renderSelectedItem === 'string' ? renderSelectedItem : displayExpr;
980
973
 
981
974
  if (displayKey && Array.isArray(displayKey)) {
982
975
  displayExpr = displayExpr.join(' - ');
@@ -995,6 +988,8 @@ const Dropdown = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
995
988
  currentValue[unique] = [];
996
989
  inputRef.current.innerHTML = '';
997
990
  valueArr.forEach(v => {
991
+ var _currentObjectDefault3;
992
+
998
993
  for (let i = 0; i < length; i++) {
999
994
  if (typeof dataSource[i] === 'object' && dataSource[i][valueExpr] === v || dataSource[i] === v) {
1000
995
  setMultipleValueHandler(dataSource[i], v, keyArr, i);
@@ -1002,7 +997,7 @@ const Dropdown = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
1002
997
  }
1003
998
  }
1004
999
 
1005
- if (currentObjectDefault[unique].length) {
1000
+ if ((_currentObjectDefault3 = currentObjectDefault[unique]) !== null && _currentObjectDefault3 !== void 0 && _currentObjectDefault3.length) {
1006
1001
  const itemOfValue = currentObjectDefault[unique].find(valueObject => valueObject[valueExpr] === v || valueObject === v);
1007
1002
 
1008
1003
  if (itemOfValue) {
@@ -1011,6 +1006,8 @@ const Dropdown = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
1011
1006
  }
1012
1007
  });
1013
1008
  } else {
1009
+ var _currentObjectDefault4;
1010
+
1014
1011
  currentValue[unique] = source;
1015
1012
 
1016
1013
  for (let i = 0; i < length; i++) {
@@ -1020,7 +1017,7 @@ const Dropdown = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
1020
1017
  }
1021
1018
  }
1022
1019
 
1023
- if (currentObjectDefault[unique].length) {
1020
+ if ((_currentObjectDefault4 = currentObjectDefault[unique]) !== null && _currentObjectDefault4 !== void 0 && _currentObjectDefault4.length) {
1024
1021
  const itemOfValue = currentObjectDefault[unique].find(valueObject => valueObject[valueExpr] === source || valueObject === source);
1025
1022
 
1026
1023
  if (itemOfValue) {
@@ -1038,14 +1035,14 @@ const Dropdown = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
1038
1035
  const setMultipleValueHandler = (data, value, keyArr, index) => {
1039
1036
  let item = null;
1040
1037
 
1041
- if (renderSelectedItem && typeof renderSelectedItem === 'function') {
1038
+ if (typeof renderSelectedItem === 'function') {
1042
1039
  item = renderSelectedItem({
1043
1040
  data,
1044
1041
  index
1045
1042
  });
1046
1043
  } else {
1047
1044
  const icon = getIconFromData(data);
1048
- const text = keyArr ? renderData(data, keyArr) : data[keyExpr || displayExpr];
1045
+ const text = keyArr ? renderData(data, keyArr) : data[renderSelectedItem || displayExpr];
1049
1046
  item = jsx(Chip, {
1050
1047
  startIcon: icon,
1051
1048
  label: text,
@@ -1068,9 +1065,9 @@ const Dropdown = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
1068
1065
  };
1069
1066
 
1070
1067
  const setSingleValueHandler = (data, keyArr) => {
1071
- const text = keyArr ? renderData(data, keyArr) : data[keyExpr || displayExpr] || data[valueExpr] || data;
1068
+ const text = keyArr ? renderData(data, keyArr) : typeof renderSelectedItem === 'string' ? data[renderSelectedItem] : data[displayExpr || valueExpr] || data;
1072
1069
 
1073
- if (renderSelectedItem && typeof renderSelectedItem === 'function') {
1070
+ if (typeof renderSelectedItem === 'function') {
1074
1071
  inputRef.current.innerHTML = '';
1075
1072
  const item = renderSelectedItem({
1076
1073
  data
@@ -1286,15 +1283,17 @@ const Dropdown = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
1286
1283
  }
1287
1284
 
1288
1285
  if (boxRef.current) {
1286
+ var _boxRef$current$query2, _currentObjectDefault5;
1287
+
1289
1288
  if (!disabled && !readOnly) {
1290
1289
  inputRef.current.addEventListener('input', onChangeInput);
1291
1290
  }
1292
1291
 
1293
1292
  const _DropdownItemCSS = DropdownItemCSS(multiple, selectBox);
1294
1293
 
1295
- const length = boxRef.current.querySelectorAll(`.css-${_DropdownItemCSS.name}`).length;
1294
+ const length = (_boxRef$current$query2 = boxRef.current.querySelectorAll(`.css-${_DropdownItemCSS.name}`)) === null || _boxRef$current$query2 === void 0 ? void 0 : _boxRef$current$query2.length;
1296
1295
 
1297
- if (length < dataSource.length + currentObjectDefault[unique].length && !isSearch[unique]) {
1296
+ if (length < dataSource.length + ((_currentObjectDefault5 = currentObjectDefault[unique]) === null || _currentObjectDefault5 === void 0 ? void 0 : _currentObjectDefault5.length) && !isSearch[unique]) {
1298
1297
  loadMoreItemsDropdown(length);
1299
1298
  !!onLoadMore && dataSource.length < total && boxRef.current.addEventListener('scroll', onLoadMoreHandler);
1300
1299
  } else {
@@ -1325,11 +1324,11 @@ const Dropdown = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
1325
1324
  ...labelProps
1326
1325
  }, label) : null, [label, required, disabled, labelProps]);
1327
1326
  const inputComp = useMemo(() => {
1328
- const _InputCSS = InputCSS(multiple, renderSelectedItem);
1327
+ const _InputCSS = InputCSS(multiple, typeof renderSelectedItem === 'function');
1329
1328
 
1330
- const _DropdownFormCSS = DropdownFormCSS(viewType, multiple, placeholder, itemMultipleSize, renderSelectedItem, disabled);
1329
+ const _DropdownFormCSS = DropdownFormCSS(viewType, multiple, placeholder, itemMultipleSize, typeof renderSelectedItem === 'function', disabled);
1331
1330
 
1332
- const _DropdownInputCSS = DropdownInputCSS(viewType, multiple, placeholder, itemMultipleSize, renderSelectedItem);
1331
+ const _DropdownInputCSS = DropdownInputCSS(viewType, multiple, placeholder, itemMultipleSize, typeof renderSelectedItem === 'function', disabled);
1333
1332
 
1334
1333
  return jsx("div", {
1335
1334
  css: _DropdownFormCSS,
@@ -1352,8 +1351,8 @@ const Dropdown = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
1352
1351
  e.preventDefault();
1353
1352
  return false;
1354
1353
  }
1355
- }) : renderSelectedItem || iconExpr && iconExpr !== 'none' ? jsx("div", { ...inputProps,
1356
- contentEditable: true,
1354
+ }) : typeof renderSelectedItem === 'function' || iconExpr && iconExpr !== 'none' ? jsx("div", { ...inputProps,
1355
+ contentEditable: !disabled,
1357
1356
  style: inputStyle,
1358
1357
  ref: inputRef,
1359
1358
  css: _DropdownInputCSS,
@@ -1413,7 +1412,7 @@ const Dropdown = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
1413
1412
 
1414
1413
  return jsx(Fragment, null, jsx("div", {
1415
1414
  ref: dropdownRef,
1416
- css: DropdownRootCSS(viewType, multiple, placeholder, itemMultipleSize, renderSelectedItem, loading, showClear),
1415
+ css: DropdownRootCSS(viewType, multiple, placeholder, itemMultipleSize, typeof renderSelectedItem === 'function', loading, showClear),
1417
1416
  className: ['DGN-UI-Dropdown', className, error && 'error', loading && 'dgn-dropdown-loading', disabled ? 'disabled' : readOnly && 'readOnly'].join(' ').trim().replace(/\s+/g, ' '),
1418
1417
  style: style
1419
1418
  }, labelComp, inputComp, errorComp), dropdownComp);
@@ -1447,7 +1446,7 @@ const DropdownIconCSS = css`
1447
1446
  }
1448
1447
  `;
1449
1448
 
1450
- const DropdownInputCSS = (viewType, multiple, placeholder, itemMultipleSize, renderSelectedItem) => css`
1449
+ const DropdownInputCSS = (viewType, multiple, placeholder, itemMultipleSize, renderSelectedItem, disabled) => css`
1451
1450
  ${flexRow};
1452
1451
  ${alignCenter};
1453
1452
  ${outlineNone};
@@ -1455,7 +1454,7 @@ const DropdownInputCSS = (viewType, multiple, placeholder, itemMultipleSize, ren
1455
1454
  ${borderNone};
1456
1455
  ${paragraph1};
1457
1456
  width: 100%;
1458
- color: ${main};
1457
+ color: ${disabled ? systemDisabled : main};
1459
1458
  padding-top: 0;
1460
1459
  padding-bottom: ${viewType !== 'outlined' ? 0 : 'inherit'};
1461
1460
  padding-left: ${viewType !== 'outlined' ? 0 : '16px'};
@@ -1489,7 +1488,19 @@ const DropdownInputCSS = (viewType, multiple, placeholder, itemMultipleSize, ren
1489
1488
  padding: ${itemMultipleSize === 'medium' ? 2 : 1}px;
1490
1489
  }
1491
1490
  }
1491
+ .DGN-UI-Typography {
1492
+ ${disabled && `
1493
+ color: ${systemDisabled}
1494
+ `}
1495
+ }
1492
1496
  .css-${DropdownIconCSS.name} {
1497
+ ${disabled && `
1498
+ svg {
1499
+ path {
1500
+ fill: ${systemDisabled};
1501
+ }
1502
+ }
1503
+ `}
1493
1504
  ${renderSelectedItem ? `
1494
1505
  min-height: 24px;
1495
1506
  min-width: 24px;
@@ -1538,10 +1549,9 @@ const DropdownFormCSS = (viewType, multiple, placeholder, itemMultipleSize, rend
1538
1549
  }
1539
1550
  .css-${DropdownInputCSS(viewType, multiple, placeholder, itemMultipleSize, renderSelectedItem).name} {
1540
1551
  color: ${active};
1552
+ }
1541
1553
  }
1542
- }
1543
1554
  `}
1544
-
1545
1555
  &:focus-within {
1546
1556
  border-bottom-color: ${focus};
1547
1557
  &::after {
@@ -1566,7 +1576,7 @@ const DropdownFormCSS = (viewType, multiple, placeholder, itemMultipleSize, rend
1566
1576
  left: 0;
1567
1577
  right: 0;
1568
1578
  bottom: 0;
1569
- border-bottom: 1px solid ${rest};
1579
+ border-bottom: 1px solid ${disabled ? systemDisabled : rest};
1570
1580
  }
1571
1581
  &::after {
1572
1582
  ${positionAbsolute};
@@ -1585,7 +1595,7 @@ const DropdownFormCSS = (viewType, multiple, placeholder, itemMultipleSize, rend
1585
1595
  ${positionRelative};
1586
1596
  ${borderRadius4px};
1587
1597
  ${borderBox};
1588
- ${border(1, rest)};
1598
+ ${border(1, disabled ? systemDisabled : rest)};
1589
1599
  width: 100%;
1590
1600
  min-height: 40px;
1591
1601
  ${!disabled && `
@@ -1821,9 +1831,6 @@ Dropdown.propTypes = {
1821
1831
  /** the displayed value for each change */
1822
1832
  value: PropTypes.oneOfType([PropTypes.string, PropTypes.number, PropTypes.array]),
1823
1833
 
1824
- /** field name used for text display in input */
1825
- keyExpr: PropTypes.oneOfType([PropTypes.string, PropTypes.number, PropTypes.array]),
1826
-
1827
1834
  /** field name used for text display<br/>
1828
1835
  * Example: 'name', '{id} - {name}', '{age} age(s)'<br/>
1829
1836
  * Note: don't use 'id - name', return undefined
@@ -1915,7 +1922,7 @@ Dropdown.propTypes = {
1915
1922
  /** function displays selected items by custom, example:<br/>
1916
1923
  * renderItem={(data, index) => index + ' - ' + data.name}<br/>
1917
1924
  */
1918
- renderSelectedItem: PropTypes.func,
1925
+ renderSelectedItem: PropTypes.oneOfType([PropTypes.func, PropTypes.string]),
1919
1926
 
1920
1927
  /** the function will run when entering input<br/>
1921
1928
  * if undefined: the filter function will run (default)
@@ -45,7 +45,7 @@ const FormGroup = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
45
45
  margin-bottom: 0 !important;
46
46
  }
47
47
  }
48
- .DGN-UI-TextInput {
48
+ &.DGN-UI-TextInput {
49
49
  display: flex;
50
50
  flex-direction: column;
51
51
  justify-content: space-between;
@@ -53,6 +53,7 @@ const InputBase = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
53
53
  defaultValue,
54
54
  valueProp,
55
55
  onChange,
56
+ onInput,
56
57
  delayOnChange
57
58
  });
58
59
  if (!inputBaseRef) inputBaseRef = useRef(null);
@@ -4,9 +4,37 @@
4
4
  import PropTypes from 'prop-types';
5
5
  import { jsx } from '@emotion/core';
6
6
  import Grid from '.';
7
+ import { makeStyles } from '../../theme';
8
+ const useStyles = makeStyles({
9
+ customCol: {
10
+ '& .DGN-UI-Control': {
11
+ marginBottom: 0
12
+ },
13
+ '& .DGN-UI-TextInput': {
14
+ marginBottom: 0
15
+ },
16
+ '& .DGN-UI-Dropdown': {
17
+ marginBottom: 0
18
+ },
19
+ '& .DGN-UI-FormGroup': {
20
+ marginBottom: 0
21
+ },
22
+ '& .DGN-UI-Money-Input': {
23
+ marginBottom: 0
24
+ },
25
+ '& .DGN-UI-NumberInput': {
26
+ marginBottom: 0
27
+ }
28
+ }
29
+ });
30
+ const classes = useStyles();
7
31
 
8
32
  const Col = props => {
33
+ const {
34
+ className
35
+ } = props;
9
36
  return jsx(Grid, { ...props,
37
+ className: [`DGN-UI-Col ${classes.customCol}`, className].join(' ').trim().replace(/\s+/g, ' '),
10
38
  item: true
11
39
  });
12
40
  };
@@ -19,7 +47,7 @@ Col.defaultProps = {
19
47
  md: false,
20
48
  sm: false,
21
49
  xl: false,
22
- xs: false,
50
+ xs: true,
23
51
  zeroMinWidth: false,
24
52
  wrap: 'wrap'
25
53
  };
@@ -5,10 +5,25 @@ import PropTypes from 'prop-types';
5
5
  import { jsx } from '@emotion/core';
6
6
  import Grid from '.';
7
7
 
8
+ const checkChildren = children => {
9
+ if (!children) return false;
10
+
11
+ if (Array.isArray(children)) {
12
+ return !children.every(v => v === false);
13
+ }
14
+
15
+ return true;
16
+ };
17
+
8
18
  const Row = props => {
9
- return jsx(Grid, { ...props,
19
+ const {
20
+ className,
21
+ children
22
+ } = props;
23
+ return checkChildren(children) ? jsx(Grid, { ...props,
24
+ className: ['DGN-UI-Row', className].join(' ').trim().replace(/\s+/g, ' '),
10
25
  container: true
11
- });
26
+ }) : null;
12
27
  };
13
28
 
14
29
  Row.defaultProps = {
@@ -24,8 +39,20 @@ Row.defaultProps = {
24
39
  spacing: 0,
25
40
  direction: 'row',
26
41
  wrap: 'wrap',
27
- columnSpacing: 4,
28
- rowSpacing: 4
42
+ columnSpacing: {
43
+ xs: 4,
44
+ sm: 4,
45
+ md: 4,
46
+ lg: 4,
47
+ xl: 6
48
+ },
49
+ rowSpacing: {
50
+ xs: 4,
51
+ sm: 4,
52
+ md: 4,
53
+ lg: 4,
54
+ xl: 6
55
+ }
29
56
  };
30
57
  Row.propTypes = {
31
58
  /** The content of the component. */
@@ -8,6 +8,10 @@ import { jsx, css } from '@emotion/core';
8
8
  import ModalContext from './context';
9
9
  import { animations } from '../../styles/animation';
10
10
  import { typography } from '../../styles/typography';
11
+ import { useTheme } from '../../theme';
12
+ const {
13
+ zIndex: zIndexCORE
14
+ } = useTheme();
11
15
  import { borderBox, borderRadius4px, flexCol, flexRow, justifyCenter, parseWidth, positionFixed, positionRelative } from '../../styles/general';
12
16
  import { color as colors } from '../../styles/colors';
13
17
  const {
@@ -19,10 +23,6 @@ const {
19
23
  }
20
24
  } = colors;
21
25
  const fadeInDown = animations.fadeInDown;
22
- import { useTheme } from '../../theme';
23
- const {
24
- zIndex: zIndexCORE
25
- } = useTheme();
26
26
  const Modal = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
27
27
  open,
28
28
  moveable,
@@ -40,7 +40,6 @@ const getLastPage = (totalItems, itemsPerPage) => {
40
40
  return _lastPage + 1;
41
41
  };
42
42
 
43
- let timeout = null;
44
43
  const PagingInfo = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
45
44
  id,
46
45
  typeShort,
@@ -52,11 +51,14 @@ const PagingInfo = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
52
51
  currentPage,
53
52
  listPerPage,
54
53
  onChangePage,
55
- onChangePerPage
54
+ onChangePerPage,
55
+ onChangingPage,
56
+ onChangingPerPage
56
57
  }, reference) => {
57
58
  var _currentPageState$toS;
58
59
 
59
60
  const ref = useRef(null);
61
+ const timer = useRef(null);
60
62
  const [totalItemsState, setTotalItemsState] = useState(totalItems);
61
63
  const [itemsPerPageState, setItemsPerPageState] = useState(itemsPerPage || listPerPage[0] || 10);
62
64
  const [currentPageState, setCurrentPageState] = useState(currentPage);
@@ -68,7 +70,7 @@ const PagingInfo = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
68
70
 
69
71
  const _dynamicWidthCSS = dynamicWidthCSS(((_currentPageState$toS = currentPageState.toString()) === null || _currentPageState$toS === void 0 ? void 0 : _currentPageState$toS.length) || 3);
70
72
 
71
- const _onChangePage = (page, isInit = false) => {
73
+ const _onChangePage = async (page, isInit = false, e) => {
72
74
  const lastPage = getLastPage(totalItemsState, itemsPerPageState);
73
75
  let disablePrev = false;
74
76
  let disableNext = false; // If last page = 1. Disable all
@@ -88,13 +90,28 @@ const PagingInfo = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
88
90
  disablePrev = true;
89
91
  }
90
92
 
93
+ if (onChangingPage && !isInit) {
94
+ const event = { ...e,
95
+ cancel: false,
96
+ prevPage: currentPageState,
97
+ newPage: page
98
+ };
99
+ await onChangingPage(event);
100
+
101
+ if (event.cancel) {
102
+ if (e !== null && e !== void 0 && e.reset) e.reset();
103
+ setCurrentPageState(currentPageState);
104
+ return;
105
+ }
106
+ }
107
+
91
108
  setCurrentPageState(page);
92
109
  setDisablePrevState(disablePrev);
93
110
  setDisableNextState(disableNext);
94
111
  if (onChangePage && !isInit) onChangePage(page);
95
112
  };
96
113
 
97
- const _onChangePerPage = per => {
114
+ const _onChangePerPage = async per => {
98
115
  const lastPage = getLastPage(totalItemsState, per);
99
116
  per = parseInt(per, 10);
100
117
  let disableNext = false; // If last page = 1. Disable all
@@ -103,6 +120,19 @@ const PagingInfo = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
103
120
  disableNext = true;
104
121
  }
105
122
 
123
+ if (onChangingPerPage) {
124
+ const event = {
125
+ cancel: false,
126
+ prevPerPage: itemsPerPageState,
127
+ newPerPage: per
128
+ };
129
+ await onChangingPerPage(event);
130
+
131
+ if (event.cancel) {
132
+ return;
133
+ }
134
+ }
135
+
106
136
  setItemsPerPageState(per);
107
137
  setCurrentPageState(0);
108
138
  setDisablePrevState(true);
@@ -110,13 +140,19 @@ const PagingInfo = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
110
140
  if (onChangePerPage) onChangePerPage(per);
111
141
  };
112
142
 
113
- const onTypePaging = (value, isInit = false) => {
114
- clearTimeout(timeout);
143
+ const onTypePaging = (e, isInit = false) => {
144
+ var _e$value;
145
+
146
+ if (timer.current) {
147
+ clearTimeout(timer.current);
148
+ }
149
+
150
+ const value = (_e$value = e === null || e === void 0 ? void 0 : e.value) !== null && _e$value !== void 0 ? _e$value : e;
115
151
  const lastPage = getLastPage(totalItemsState, itemsPerPageState);
116
152
  const page = !value || parseInt(value) < 0 ? 1 : parseInt(value) > lastPage ? lastPage : parseInt(value);
117
153
  currentPage = page - 1;
118
- timeout = setTimeout(() => {
119
- _onChangePage(page - 1, isInit);
154
+ timer.current = setTimeout(() => {
155
+ _onChangePage(page - 1, isInit, e);
120
156
  }, 500);
121
157
  };
122
158
 
@@ -130,8 +166,12 @@ const PagingInfo = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
130
166
  setTotalItemsState(totalItems);
131
167
  }, [totalItems]);
132
168
  useEffect(() => {
133
- timeout = setTimeout(() => {
134
- _onChangePage(0, true);
169
+ if (timer.current) {
170
+ clearTimeout(timer.current);
171
+ }
172
+
173
+ timer.current = setTimeout(() => {
174
+ _onChangePage(currentPageState !== null && currentPageState !== void 0 ? currentPageState : 0, true);
135
175
  }, 500);
136
176
  }, [totalItemsState, itemsPerPageState]);
137
177
  useEffect(() => {
@@ -188,14 +228,14 @@ const PagingInfo = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
188
228
  size: 'small',
189
229
  name: 'ArrowDoubleLeft',
190
230
  disabled: disablePrevState,
191
- onClick: () => _onChangePage(0)
231
+ onClick: e => _onChangePage(0, false, e)
192
232
  }), jsx(ButtonIcon, {
193
233
  circular: true,
194
234
  viewType: 'text',
195
235
  size: 'small',
196
236
  name: 'ArrowLeft',
197
237
  disabled: disablePrevState,
198
- onClick: () => _onChangePage(currentPageState - 1)
238
+ onClick: e => _onChangePage(currentPageState - 1, false, e)
199
239
  }), jsx(NumberInput, {
200
240
  css: _dynamicWidthCSS,
201
241
  disabledNegative: true,
@@ -204,7 +244,7 @@ const PagingInfo = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
204
244
  min: 1,
205
245
  max: lastPage,
206
246
  onKeyDown: checkKeyPress,
207
- onChange: e => onTypePaging(e === null || e === void 0 ? void 0 : e.value)
247
+ onChange: e => onTypePaging(e, false)
208
248
  }), "/", jsx(Typography, {
209
249
  type: 'p2',
210
250
  style: {
@@ -216,14 +256,14 @@ const PagingInfo = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
216
256
  size: 'small',
217
257
  name: 'ArrowRight',
218
258
  disabled: disableNextState,
219
- onClick: () => _onChangePage(currentPageState + 1)
259
+ onClick: e => _onChangePage(currentPageState + 1, false, e)
220
260
  }), jsx(ButtonIcon, {
221
261
  circular: true,
222
262
  viewType: 'text',
223
263
  size: 'small',
224
264
  name: 'ArrowDoubleRight',
225
265
  disabled: disableNextState,
226
- onClick: () => _onChangePage(lastPage - 1)
266
+ onClick: e => _onChangePage(lastPage - 1, false, e)
227
267
  }), typeShort && jsx(Divider, {
228
268
  direction: 'vertical',
229
269
  height: 24,
@@ -330,36 +370,56 @@ PagingInfo.defaultProps = {
330
370
  listPerPage: [10, 15, 20, 30, 50]
331
371
  };
332
372
  PagingInfo.propTypes = {
333
- /** Compact type for mobile. */
334
- typeShort: PropTypes.bool,
335
-
336
- /** Background color for paging. */
373
+ /** Background color for component. */
337
374
  bgColor: PropTypes.string,
338
375
 
339
- /** Style inline of component. */
340
- style: PropTypes.object,
341
-
342
376
  /** Class for component. */
343
377
  className: PropTypes.string,
344
378
 
345
379
  /** Specifies the current page. */
346
380
  currentPage: PropTypes.number,
347
381
 
348
- /** Total items of paging. */
349
- totalItems: PropTypes.number,
350
-
351
382
  /** The quantity of items per page. */
352
383
  itemsPerPage: PropTypes.number,
353
384
 
354
385
  /** The list to choose the number of elements to display per page. */
355
386
  listPerPage: PropTypes.array,
356
387
 
357
- /** The function will run after change page number. */
388
+ /** Callback fired when page number changed. */
358
389
  onChangePage: PropTypes.func,
359
390
 
360
- /** The function will run after change quantity on per page. */
391
+ /** Callback fired when quantity on per page changed. */
361
392
  onChangePerPage: PropTypes.func,
362
393
 
394
+ /**
395
+ * Callback fired when page number is changing.
396
+ *
397
+ * * prevPage: Page before changed
398
+ * * newPage: Page after changed
399
+ * * cancel(value): Function cancel change page
400
+ * * @param {value} - bool
401
+ */
402
+ onChangingPage: PropTypes.func,
403
+
404
+ /**
405
+ * Callback fired when quantity on item per page is changing.
406
+ *
407
+ * * prevPerPage: Items per page before changed
408
+ * * newPerPage: Items per page after changed
409
+ * * cancel(value): Function cancel change items per page
410
+ * * @param {value} - bool
411
+ */
412
+ onChangingPerPage: PropTypes.func,
413
+
414
+ /** Style inline of component. */
415
+ style: PropTypes.object,
416
+
417
+ /** Total items. */
418
+ totalItems: PropTypes.number,
419
+
420
+ /** Compact type for mobile. */
421
+ typeShort: PropTypes.bool,
422
+
363
423
  /**
364
424
  * ref methods (ref.current.instance.*method*)
365
425
  *
@@ -1,19 +1,23 @@
1
1
  /** @jsxRuntime classic */
2
2
 
3
3
  /** @jsx jsx */
4
- import { memo, useState, useEffect, useMemo, useRef, forwardRef, useImperativeHandle } from 'react';
4
+ import React, { memo, useState, useEffect, useMemo, useRef, forwardRef, useImperativeHandle } from 'react';
5
5
  import { createPortal } from 'react-dom';
6
6
  import PropTypes from 'prop-types';
7
7
  import { jsx, css } from '@emotion/core';
8
- import { typography } from '../../styles/typography';
9
8
  import { borderRadius4px, displayBlock, flexRow, parseWidthHeight, positionAbsolute, positionFixed, positionRelative } from '../../styles/general';
10
- import { useTheme } from '../../theme';
9
+ import theme from '../../theme/settings';
11
10
  const {
11
+ colors: {
12
+ system: {
13
+ white
14
+ }
15
+ },
16
+ typography: {
17
+ paragraph1
18
+ },
12
19
  zIndex: zIndexCORE
13
- } = useTheme();
14
- const {
15
- paragraph1
16
- } = typography;
20
+ } = theme;
17
21
 
18
22
  const getArrowPosition = (anchorOrigin, transformOrigin, translate) => {
19
23
  if (anchorOrigin.horizontal === 'right' && transformOrigin.horizontal === 'left') {
@@ -131,6 +135,14 @@ const Popover = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
131
135
  const [openState, setOpenState] = useState(open);
132
136
  const [element, setElement] = useState(null);
133
137
 
138
+ const _PortalPopoverCSS = PortalPopoverCSS(zIndex, fullScreen);
139
+
140
+ const _PopoverContainerCSS = PopoverContainerCSS(width, height);
141
+
142
+ const _PopoverRootCSS = PopoverRootCSS(bgColor);
143
+
144
+ const _PopoverArrowCSS = PopoverArrowCSS(bgColor);
145
+
134
146
  if (direction) {
135
147
  const directionObject = getDirectionPopover(direction);
136
148
  anchorOrigin = directionObject.anchorOrigin;
@@ -272,7 +284,7 @@ const Popover = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
272
284
  break;
273
285
  }
274
286
 
275
- Object.assign(ref.current.querySelector(`.css-${PopoverArrowCSS(bgColor).name}`).style, arrowPosition, {
287
+ Object.assign(ref.current.querySelector(`.css-${_PopoverArrowCSS.name}`).style, arrowPosition, {
276
288
  transform: translate.transform
277
289
  });
278
290
  }
@@ -341,27 +353,43 @@ const Popover = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
341
353
 
342
354
  return currentRef;
343
355
  });
356
+
357
+ const renderAnchor = () => {
358
+ var _anchor;
359
+
360
+ if (!((_anchor = anchor) !== null && _anchor !== void 0 && _anchor.type)) return null;
361
+ const AnchorTag = /*#__PURE__*/React.cloneElement(anchor, {
362
+ onClick: () => {
363
+ setOpenState(true);
364
+ },
365
+ ref: ref => {
366
+ anchor = ref;
367
+ }
368
+ });
369
+ return AnchorTag;
370
+ };
371
+
344
372
  const PopoverView = useMemo(() => {
345
373
  if (openState) {
346
374
  const node = jsx("div", {
347
375
  className: 'DGN-UI-Portal DGN-UI-Popover',
348
- css: PortalPopoverCSS(zIndex, fullScreen)
376
+ css: _PortalPopoverCSS
349
377
  }, jsx("div", {
350
- css: PopoverContainerCSS(width, height),
378
+ css: _PopoverContainerCSS,
351
379
  ref: ref,
352
380
  ...props
353
381
  }, jsx("div", {
354
- css: PopoverRootCSS(bgColor),
382
+ css: _PopoverRootCSS,
355
383
  style: style
356
384
  }, arrow && jsx("span", {
357
- css: PopoverArrowCSS(bgColor)
385
+ css: _PopoverArrowCSS
358
386
  }), children)));
359
387
  return /*#__PURE__*/createPortal(node, document.body);
360
388
  }
361
389
 
362
390
  return null;
363
391
  }, [openState, zIndex, fullScreen, style, arrow, children, width, height, bgColor]);
364
- return PopoverView;
392
+ return jsx(React.Fragment, null, renderAnchor(), PopoverView);
365
393
  }));
366
394
 
367
395
  const PortalPopoverCSS = (zIndex, fullScreen) => css`
@@ -410,7 +438,7 @@ Popover.defaultProps = {
410
438
  arrow: false,
411
439
  width: 150,
412
440
  height: 'auto',
413
- bgColor: '#FFF',
441
+ bgColor: white,
414
442
  zIndex: zIndexCORE(1),
415
443
  anchorOrigin: {
416
444
  vertical: 'bottom',
@@ -423,10 +451,10 @@ Popover.defaultProps = {
423
451
  style: {}
424
452
  };
425
453
  Popover.propTypes = {
426
- /** If true, the component is shown. */
454
+ /** If `true`, the component is shown. */
427
455
  open: PropTypes.bool,
428
456
 
429
- /** If true, arrow is shown. */
457
+ /** If `true`, arrow is shown. */
430
458
  arrow: PropTypes.bool,
431
459
 
432
460
  /** allow close Popover when press ESC. */
@@ -439,7 +467,7 @@ Popover.propTypes = {
439
467
  style: PropTypes.object,
440
468
 
441
469
  /** An HTML element, or a function that returns one. It's used to set the position of the popover. */
442
- anchor: PropTypes.oneOfType([PropTypes.instanceOf(Element), PropTypes.func, PropTypes.object]),
470
+ anchor: PropTypes.oneOfType([PropTypes.instanceOf(Element), PropTypes.func, PropTypes.object, PropTypes.node]),
443
471
 
444
472
  /**
445
473
  * This is the point on the anchor where the popover's anchor will attach to.
package/package.json CHANGED
@@ -1,42 +1,65 @@
1
1
  {
2
2
  "name": "diginet-core-ui",
3
- "version": "1.3.52",
4
- "description": "The DigiNet core ui",
5
- "homepage": "https://diginet.com.vn",
3
+ "version": "1.3.53-beta.1",
4
+ "description": "",
6
5
  "main": "index.js",
6
+ "license": "UNLICENSED",
7
7
  "scripts": {
8
- "start-js": "react-scripts start --max_old_space_size=4096",
9
- "start": "npx npm-run-all -p start-js",
10
- "build": "GENERATE_SOURCEMAP=false && react-scripts build --env=production --max_old_space_size=8192",
11
- "eject": "react-scripts eject",
12
- "test": "echo \"Error: no test specified\" && exit 1"
8
+ "start": "npm-run-all --parallel start-sb eslint-test",
9
+ "start-sb": "start-storybook -p 9050",
10
+ "build-storybook": "build-storybook -c .storybook -s src",
11
+ "build": "run-script-os",
12
+ "build:windows": "rimraf dist && mkdirp dist/components && npm run compile && sass --style=compressed src/scss:dist/css && xcopy src\\\\assets dist\\\\assets\\ /e /y",
13
+ "build:darwin:linux:default": "rm -rf dist && npm run compile && sass --style=compressed src/scss:dist/css && cp -rf src/assets dist/assets",
14
+ "compile": "babel src --out-dir dist --ignore **/*.stories.js",
15
+ "pack": "npm run build && cp *.md dist/ && npm run version:bump --silent && npm run version:add --silent && cd dist && npm pack",
16
+ "production-keep-version": "npm run build && cp *.md dist/ && cp package.json dist/ && cd dist && npm publish",
17
+ "beta": "npm run build && cp *.md dist/ && cp package.json dist/ && cd dist && npm publish --tag beta",
18
+ "production": "npm run build && cp *.md dist/ && npm run version:bump --silent && npm run version:add --silent && cd dist && npm publish",
19
+ "version:add": "run-script-os",
20
+ "version:add:windows": "cat package.json.tmp | sed \"s/0.0.0/%npm_package_version%/g\" > dist/package.json",
21
+ "version:add:darwin:linux:default": "VERSION=$(npm run version:extract --silent) && cat package.json.tmp | sed \"s/0.0.0/${VERSION}/g\" > dist/package.json",
22
+ "version:bump": "npm version patch --no-git-tag-version --silent",
23
+ "version:extract": "cat package.json | grep version | head -1 | awk -F: '{ print $2 }' | sed 's/[\",]//g' | tr -d '[[:space:]]'",
24
+ "test": "echo \"Error: no test specified\" && exit 1",
25
+ "lint": "eslint --fix --config .eslintrc.js \"**/*.js\"",
26
+ "eslint-test": "onchange \"src/**/*.{js,jsx,json}\" -- eslint . --fix"
13
27
  },
14
28
  "dependencies": {
15
29
  "@emotion/core": "^10.0.35",
16
30
  "prop-types": "^15.7.2"
17
31
  },
18
- "repository": {
19
- "type": "git",
20
- "url": "git+https://diginetvn@bitbucket.org/diginetvn/diginet-core-ui.git"
32
+ "lint-staged": {
33
+ "*/**/*.{js,jsx,json}": [
34
+ "prettier --write",
35
+ "git add"
36
+ ]
21
37
  },
22
- "keywords": [
23
- "core ui",
24
- "diginet"
25
- ],
26
- "author": "rocachien",
27
- "contributors": [
28
- {
29
- "name": "Chien Do",
30
- "email": "rocachien@gmail.com"
31
- },
32
- {
33
- "name": "Nhat Tran",
34
- "email": "tranminhnhat1005@gmail.com"
35
- },
36
- {
37
- "name": "Thuan Nguyen",
38
- "email": "nt.thuan.hutech@gmail.com"
39
- }
40
- ],
41
- "license": "MIT"
38
+ "devDependencies": {
39
+ "@babel/cli": "^7.14.3",
40
+ "@babel/plugin-proposal-class-properties": "^7.13.0",
41
+ "@babel/plugin-proposal-logical-assignment-operators": "^7.16.0",
42
+ "@babel/plugin-proposal-nullish-coalescing-operator": "^7.16.0",
43
+ "@babel/plugin-proposal-optional-chaining": "^7.14.2",
44
+ "@babel/preset-react": "^7.13.13",
45
+ "@storybook/addon-actions": "6.2.9",
46
+ "@storybook/addon-essentials": "6.2.9",
47
+ "@storybook/addon-links": "6.2.9",
48
+ "@storybook/addon-postcss": "^2.0.0",
49
+ "@storybook/react": "6.2.9",
50
+ "autoprefixer": "^10.3.1",
51
+ "babel-loader": "^8.2.2",
52
+ "eslint": "^8.4.1",
53
+ "eslint-plugin-react": "^7.27.1",
54
+ "husky": "^7.0.4",
55
+ "lint-staged": "^12.1.2",
56
+ "mkdirp": "^1.0.4",
57
+ "postcss-flexbugs-fixes": "^5.0.2",
58
+ "react": "^17.0.1",
59
+ "react-dom": "^17.0.1",
60
+ "rimraf": "^3.0.2",
61
+ "run-script-os": "^1.1.6",
62
+ "sass": "^1.37.0",
63
+ "onchange": "^7.1.0"
64
+ }
42
65
  }
package/readme.md CHANGED
@@ -38,6 +38,9 @@ npm test
38
38
  ```
39
39
 
40
40
  ## Changelog
41
+ ## 1.3.53
42
+ - \[Fixed\]: Dropdown – Fix bug icon Arrow not clickable when multiple
43
+
41
44
  ## 1.3.52
42
45
  - \[Fixed\]: Avatar – Add props onClick, allowEdit
43
46
  - \[Fixed\]: Typography – Fix tooltip width fit Typography
package/styles/general.js CHANGED
@@ -4,10 +4,10 @@ import { color } from './colors';
4
4
  import { parseToPixel } from './utils';
5
5
  export const rootSpacing = 4;
6
6
  export let rootZIndex = 1500;
7
- /**
8
- * get value spacing with rootZIndex
9
- * @param number
10
- * @return {number}
7
+ /**
8
+ * get value spacing with rootZIndex
9
+ * @param number
10
+ * @return {number}
11
11
  */
12
12
 
13
13
  export const zIndex = number => {
@@ -15,10 +15,10 @@ export const zIndex = number => {
15
15
  if (isNaN(number)) return rootZIndex;
16
16
  return rootZIndex + number;
17
17
  };
18
- /**
19
- * get value spacing with rootSpacing
20
- * @param {(number|number[])} vl - default 1
21
- * @returns {(number|string)}
18
+ /**
19
+ * get value spacing with rootSpacing
20
+ * @param {(number|number[])} vl - default 1
21
+ * @returns {(number|string)}
22
22
  */
23
23
 
24
24
  export const getSpacing = (vl = 1) => {
@@ -27,9 +27,9 @@ export const getSpacing = (vl = 1) => {
27
27
  return `${vl.flatMap(i => Number(i !== null && i !== void 0 ? i : 0) * rootSpacing).join('px ')}px`;
28
28
  }
29
29
  };
30
- /**
31
- * replace rootZIndex
32
- * @param number
30
+ /**
31
+ * replace rootZIndex
32
+ * @param number
33
33
  */
34
34
 
35
35
  export const setZIndex = number => {
@@ -46,6 +46,10 @@ export const flexCol = css`
46
46
  display: flex;
47
47
  flex-direction: column;
48
48
  `;
49
+ export const flexColReverse = css`
50
+ display: flex;
51
+ flex-direction: column-reverse;
52
+ `;
49
53
  export const flexRowReverse = css`
50
54
  flex-direction: row-reverse;
51
55
  `;
package/utils/useInput.js CHANGED
@@ -5,7 +5,8 @@ const useInput = props => {
5
5
  defaultValue,
6
6
  valueProp,
7
7
  delayOnChange,
8
- onChange
8
+ onChange,
9
+ onInput
9
10
  } = props;
10
11
  const [value, setValue] = useState(defaultValue || valueProp);
11
12
  const timer = useRef(null);
@@ -21,6 +22,7 @@ const useInput = props => {
21
22
  e.reset = () => {
22
23
  setValue(valueProp);
23
24
  e.target.value = valueProp;
25
+ onInput === null || onInput === void 0 ? void 0 : onInput(e);
24
26
  };
25
27
 
26
28
  onChange === null || onChange === void 0 ? void 0 : onChange(e);