diginet-core-ui 1.4.50 → 1.4.51-beta.0

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.
@@ -652,7 +652,7 @@ const renderNavigator = (className, refs, dbLeftFn, leftFn, rightFn, dbRightFn,
652
652
  color: 'primary',
653
653
  type: 'h3',
654
654
  ref: refs.content,
655
- format: ['lowercase']
655
+ format: ['sentence']
656
656
  }))), jsx("div", {
657
657
  className: className.navigator.around
658
658
  }, jsx(ButtonIcon, {
@@ -226,7 +226,7 @@ const Calendar = /*#__PURE__*/memo(/*#__PURE__*/forwardRef((inProps, reference)
226
226
  * START EFFECT
227
227
  */
228
228
  useEffect(() => {
229
- if (defaultValue && defaultValue !== '' && isValidDate(defaultValue)) {
229
+ if (defaultValue && defaultValue !== '' && isValidDate(defaultValue) && !value) {
230
230
  if (isBeforeLimit(min, defaultValue)) {
231
231
  onUpdate(min);
232
232
  } else if (isAfterLimit(max, defaultValue)) {
@@ -77,6 +77,7 @@ const Dropdown = /*#__PURE__*/memo(/*#__PURE__*/forwardRef((inProps, reference)
77
77
  inputStyle,
78
78
  itemMode,
79
79
  isInGrid,
80
+ isPaging,
80
81
  label,
81
82
  labelProps,
82
83
  limit,
@@ -135,6 +136,7 @@ const Dropdown = /*#__PURE__*/memo(/*#__PURE__*/forwardRef((inProps, reference)
135
136
  skip: skip || 0,
136
137
  limit: limit || 50
137
138
  });
139
+ const txtSearchRef = useRef(false);
138
140
  const [unique] = useState(randomString(6, {
139
141
  allowNumber: false,
140
142
  allowSymbol: false
@@ -170,7 +172,7 @@ const Dropdown = /*#__PURE__*/memo(/*#__PURE__*/forwardRef((inProps, reference)
170
172
  const _IconCSS = IconCSS(viewType, theme);
171
173
  const _DropdownFormCSS = viewType === 'outlined' ? DropdownFormOutlinedCSS(disabled, readOnly, placeholder, theme) : DropdownFormCSS(viewType, multiple, disabled, readOnly, placeholder, _DropdownInputCSS.name, theme);
172
174
  const _DropdownListCSS = DropdownListCSS(theme);
173
- const _DropdownBoxCSS = DropdownBoxCSS(loadingState, theme, itemMode);
175
+ const _DropdownBoxCSS = DropdownBoxCSS(loadingState, theme, itemMode, isPaging);
174
176
  const _DropdownItemCSS = DropdownItemCSS(multiple, selectBox, theme);
175
177
  const _DropdownRootCSS = DropdownRootCSS(_DropdownFormCSS.name, _DropdownInputCSS.name, theme);
176
178
  const _CheckBoxCSS = CheckBoxCSS(theme);
@@ -328,19 +330,21 @@ const Dropdown = /*#__PURE__*/memo(/*#__PURE__*/forwardRef((inProps, reference)
328
330
  let dataSourceUsable = [...dataSourceState];
329
331
 
330
332
  // search dataSource dựa trên txtSearch
331
- if (!onInput || action !== null && action !== void 0 && action.loadData) {
332
- var _dataSourceUsable;
333
- dataSourceUsable = (_dataSourceUsable = dataSourceUsable) === null || _dataSourceUsable === void 0 ? void 0 : _dataSourceUsable.filter(i => {
334
- if (searchExpr) {
335
- // nếu map đc vs 1 trong những <key>(data[key]) của searchExpr
336
- return !!searchExpr.find(j => handleRenderBySearch(i[j]));
337
- } else {
338
- // nếu map đc vs displayValue
339
- return handleRenderBySearch(displayValue(i)) || handleRenderBySearch(i === null || i === void 0 ? void 0 : i[valueExpr]);
340
- }
341
- });
333
+ if (!onInput) {
334
+ if (!(action !== null && action !== void 0 && action.loadData) || !onLoadMore) {
335
+ var _dataSourceUsable;
336
+ dataSourceUsable = (_dataSourceUsable = dataSourceUsable) === null || _dataSourceUsable === void 0 ? void 0 : _dataSourceUsable.filter(i => {
337
+ if (searchExpr) {
338
+ // nếu map đc vs 1 trong những <key>(data[key]) của searchExpr
339
+ return !!searchExpr.find(j => handleRenderBySearch(i[j]));
340
+ } else {
341
+ // nếu map đc vs displayValue
342
+ return handleRenderBySearch(displayValue(i)) || handleRenderBySearch(i === null || i === void 0 ? void 0 : i[valueExpr]);
343
+ }
344
+ });
345
+ }
342
346
  }
343
- if (vlObjDefaultState && vlObjDefaultState !== null && vlObjDefaultState !== void 0 && vlObjDefaultState.length) {
347
+ if (vlObjDefaultState && (vlObjDefaultState === null || vlObjDefaultState === void 0 ? void 0 : vlObjDefaultState.length) > 0) {
344
348
  const length = vlObjDefaultState === null || vlObjDefaultState === void 0 ? void 0 : vlObjDefaultState.length;
345
349
  let existItemQuantity = 0;
346
350
  for (let index = length - 1; index >= 0; index--) {
@@ -455,7 +459,8 @@ const Dropdown = /*#__PURE__*/memo(/*#__PURE__*/forwardRef((inProps, reference)
455
459
  parentID: treeViewParentID,
456
460
  value: typeof currentValue[unique] === 'string' ? [currentValue[unique]] : currentValue[unique],
457
461
  onChange: (e, value) => onChangeValue(e, '', multiple ? value : e.value),
458
- renderItem: renderItem
462
+ renderItem: renderItem,
463
+ isInDropdown: true
459
464
  }) : EmptyDataText);
460
465
  };
461
466
 
@@ -674,6 +679,7 @@ const Dropdown = /*#__PURE__*/memo(/*#__PURE__*/forwardRef((inProps, reference)
674
679
  var _e$target$value;
675
680
  if (!dropdownRef.current) return; // Kiểm tra nếu dropdown đóng trước searchDelayTime thì không chạy
676
681
  setTxtSearch((_e$target$value = e.target.value) !== null && _e$target$value !== void 0 ? _e$target$value : '');
682
+ txtSearchRef.current = !!e.target.value;
677
683
  if (onInput) {
678
684
  onInput(e);
679
685
  }
@@ -938,6 +944,13 @@ const Dropdown = /*#__PURE__*/memo(/*#__PURE__*/forwardRef((inProps, reference)
938
944
  return () => {
939
945
  allValue[unique] = null;
940
946
  closeDropdown(null, 'cleanup');
947
+ if (onInput && txtSearchRef.current) {
948
+ onInput({
949
+ target: {
950
+ value: ''
951
+ }
952
+ });
953
+ }
941
954
  };
942
955
  }, []);
943
956
  useEffect(() => {
@@ -1034,7 +1047,7 @@ const Dropdown = /*#__PURE__*/memo(/*#__PURE__*/forwardRef((inProps, reference)
1034
1047
  inputRef.current.removeEventListener('click', onClickInput);
1035
1048
  }
1036
1049
  };
1037
- }, [dataSourceState]);
1050
+ }, [dataSourceState, disabled]);
1038
1051
  useEffect(() => {
1039
1052
  if (!openState && txtSearch) {
1040
1053
  if (!onInput) {
@@ -1554,8 +1567,8 @@ const DropdownListCSS = ({
1554
1567
  `;
1555
1568
  const DropdownBoxCSS = (loading, {
1556
1569
  colors
1557
- }, itemMode) => css`
1558
- ${loading || itemMode === 'treeview' ? overflowHidden : overflowYScroll};
1570
+ }, itemMode, isPaging) => css`
1571
+ ${loading || itemMode === 'treeview' || isPaging ? overflowHidden : overflowYScroll};
1559
1572
  ${parseMaxHeight(280)};
1560
1573
  &::-webkit-scrollbar {
1561
1574
  ${borderRadius(4)};
@@ -1,13 +1,15 @@
1
1
  /** @jsxRuntime classic */
2
2
  /** @jsx jsx */
3
3
  import { css, jsx } from '@emotion/core';
4
- import { ButtonIcon, InputBase, Label, Popover, PopoverBody } from "../..";
4
+ import { ButtonIcon, InputBase, Label, Popover, PopoverBody, HelperText } from "../..";
5
5
  import PropTypes from 'prop-types';
6
- import { Fragment, forwardRef, memo, useEffect, useImperativeHandle, useLayoutEffect, useRef, useState } from 'react';
6
+ import { Fragment, forwardRef, memo, useEffect, useImperativeHandle, useLayoutEffect, useRef, useState, useMemo } from 'react';
7
7
  import { animation, borderColor, displayBlock, overflowHidden, parseHeight, parseMinWidth, positionRelative, scaleX } from "../../../styles/general";
8
8
  import { useTheme } from "../../../theme";
9
9
  import useThemeProps from "../../../theme/utils/useThemeProps";
10
10
  import { classNames, getProp } from "../../../utils";
11
+ const regexBetween = /[^{}]+(?=})/g;
12
+ const regexInclude = /{|}/g;
11
13
  const DropdownBox = /*#__PURE__*/memo(/*#__PURE__*/forwardRef((inProps, reference) => {
12
14
  if (!reference) reference = useRef(null);
13
15
  const theme = useTheme();
@@ -22,10 +24,14 @@ const DropdownBox = /*#__PURE__*/memo(/*#__PURE__*/forwardRef((inProps, referenc
22
24
  });
23
25
  const {
24
26
  action = {},
27
+ allowInput,
25
28
  bgColor: bgColorProp,
26
29
  children,
27
30
  className,
28
31
  delayOnInput,
32
+ disabled,
33
+ displayExpr: displayExprProp,
34
+ error,
29
35
  endIcon,
30
36
  inputProps,
31
37
  inputRef,
@@ -39,10 +45,19 @@ const DropdownBox = /*#__PURE__*/memo(/*#__PURE__*/forwardRef((inProps, referenc
39
45
  placeholder,
40
46
  startIcon,
41
47
  style,
42
- value,
43
- viewType
48
+ value: valueProps,
49
+ valueExpr,
50
+ viewType,
51
+ helperTextProps
44
52
  } = props;
53
+ let displayExpr = displayExprProp;
45
54
  const bgColor = typeof bgColorProp === 'string' ? getProp(colors, bgColorProp, bgColorProp) : bgColorProp;
55
+ const ErrorView = useMemo(() => {
56
+ return error ? jsx(HelperText, {
57
+ ...helperTextProps,
58
+ disabled: disabled
59
+ }, error) : null;
60
+ }, [disabled, error, helperTextProps]);
46
61
  const ref = useRef(null);
47
62
  const dropdownBoxRef = useRef(null);
48
63
  const timer = useRef(null);
@@ -85,6 +100,28 @@ const DropdownBox = /*#__PURE__*/memo(/*#__PURE__*/forwardRef((inProps, referenc
85
100
  onClosed === null || onClosed === void 0 ? void 0 : onClosed();
86
101
  }
87
102
  };
103
+
104
+ /**
105
+ * Chuyển đổi data thành giá trị cần hiện thị dựa vào displayExpr [string, string object {field} - {field}], renderSelectedItem, displayExpr, valueExpr
106
+ * @param data {object} rowData of dataSource
107
+ * @return {string}
108
+ */
109
+ const displayValue = data => {
110
+ let text = '';
111
+ if (data || data === 0) {
112
+ displayExpr = displayExpr || valueExpr;
113
+ let mask = data === null || data === void 0 ? void 0 : data[displayExpr];
114
+ // convert {id} - {name} to {<data[id]>} - {<data[name]>}
115
+ if (!mask && regexBetween.test(displayExpr)) {
116
+ var _displayExpr;
117
+ mask = (_displayExpr = displayExpr) === null || _displayExpr === void 0 ? void 0 : _displayExpr.replace(regexBetween, _ => (data === null || data === void 0 ? void 0 : data[_]) || '');
118
+ } else if (!mask) {
119
+ mask = typeof data !== 'object' ? data : '';
120
+ }
121
+ text = mask.toString().replace(regexInclude, '');
122
+ }
123
+ return text;
124
+ };
88
125
  useLayoutEffect(() => {
89
126
  if (ref.current) {
90
127
  const {
@@ -130,15 +167,17 @@ const DropdownBox = /*#__PURE__*/memo(/*#__PURE__*/forwardRef((inProps, referenc
130
167
  onClick: openOnClickAt === 'icon' ? onTriggerDropdown : null
131
168
  }) : null;
132
169
  };
170
+ const value = displayValue(valueProps);
133
171
  return jsx(Fragment, null, jsx("div", {
134
172
  ref: ref,
135
173
  css: _DropdownBoxRootCSS,
136
- className: classNames('DGN-UI-Dropdown-Box', className),
174
+ className: classNames('DGN-UI-Dropdown-Box', className, error && 'error'),
137
175
  style: style
138
176
  }, label ? jsx(Label, {
139
177
  ...labelProps
140
178
  }, label) : null, jsx(InputBase, {
141
179
  ...inputProps,
180
+ readOnly: !allowInput,
142
181
  style: inputStyle,
143
182
  viewType: viewType,
144
183
  inputRef: inputRef,
@@ -157,7 +196,7 @@ const DropdownBox = /*#__PURE__*/memo(/*#__PURE__*/forwardRef((inProps, referenc
157
196
  anchor: ref.current,
158
197
  width: popoverWidth,
159
198
  onClose: closeDropdownBox
160
- }, jsx(PopoverBody, null, children)));
199
+ }, jsx(PopoverBody, null, children)), ErrorView);
161
200
  }));
162
201
  const DropdownBoxRootCSS = (bgColorProp, {
163
202
  colors
@@ -166,6 +205,17 @@ const DropdownBoxRootCSS = (bgColorProp, {
166
205
  ${positionRelative};
167
206
  ${parseMinWidth(150)};
168
207
  ${parseHeight('max-content')};
208
+ &.error {
209
+ .DGN-UI-InputBase {
210
+ ${borderColor(getProp(colors, 'semantic/danger'))};
211
+ &::before {
212
+ ${borderColor(getProp(colors, 'semantic/danger'))};
213
+ }
214
+ &::after {
215
+ ${borderColor(getProp(colors, 'semantic/danger'))};
216
+ }
217
+ }
218
+ }
169
219
  .DGN-UI-InputBase {
170
220
  background: ${bgColorProp ? bgColorProp === true ? getProp(colors, 'fill/disabled') : bgColorProp : 'inherit'} !important;
171
221
  ${openState && css`
@@ -183,20 +233,6 @@ const DropdownBoxCSS = ({
183
233
  margin-top: ${spacing([1])};
184
234
  ${overflowHidden};
185
235
  `;
186
-
187
- // DropdownBox.defaultProps = {
188
- // className: '',
189
- // label: '',
190
- // placeholder: '',
191
- // startIcon: 'Search',
192
- // endIcon: 'ArrowDown',
193
- // openOnClickAt: 'icon',
194
- // viewType: 'underlined',
195
- // inputProps: {},
196
- // delayOnInput: 700,
197
- // zIndex: zIndexCORE(1),
198
- // };
199
-
200
236
  DropdownBox.propTypes = {
201
237
  /** class for dropdown */
202
238
  className: PropTypes.string,
@@ -233,6 +269,12 @@ DropdownBox.propTypes = {
233
269
  /** the function will run after open */
234
270
  onOpened: PropTypes.func,
235
271
  /** the function will run after close */
236
- onClosed: PropTypes.func
272
+ onClosed: PropTypes.func,
273
+ /** Error message displayed below the input. */
274
+ error: PropTypes.oneOfType([PropTypes.bool, PropTypes.string]),
275
+ /** If `true`, the component is disabled. */
276
+ disabled: PropTypes.bool,
277
+ /** If `true`, the input is enable. */
278
+ allowInput: PropTypes.bool
237
279
  };
238
280
  export default DropdownBox;
@@ -49,7 +49,7 @@ const NumberInput = /*#__PURE__*/forwardRef((inProps, reference) => {
49
49
  labelProps,
50
50
  max: maxProp,
51
51
  maxDigit,
52
- min,
52
+ min: minProp,
53
53
  nonStyle,
54
54
  onBlur,
55
55
  onChange,
@@ -69,9 +69,12 @@ const NumberInput = /*#__PURE__*/forwardRef((inProps, reference) => {
69
69
  viewType
70
70
  } = props;
71
71
  let max = maxProp;
72
+ let min = minProp;
72
73
  let thousandSymbol = thousandSeparator;
73
74
  let decimalSymbol = decimalSymbolProp;
74
75
  let valueProps = valueProp;
76
+ if (!min && min !== 0) min = -Infinity;
77
+ if (!max && max !== 0) max = Infinity;
75
78
  const pos = useRef(null);
76
79
  const ref = useRef(null);
77
80
  const globalRef = useRef({});
@@ -135,7 +138,7 @@ const NumberInput = /*#__PURE__*/forwardRef((inProps, reference) => {
135
138
  pos.current = selectionStart + (number.toString().length - 1 === vl.toString().length ? 1 : 0);
136
139
  }
137
140
  return number;
138
- }, [decimalSymbol, max, value]);
141
+ }, [decimalSymbol, max, value, decimalDigit]);
139
142
 
140
143
  /**
141
144
  * Convert money to format number
@@ -310,7 +313,7 @@ const NumberInput = /*#__PURE__*/forwardRef((inProps, reference) => {
310
313
  // setValue(parseNumberToMoney(valueProps?.toString().replace(regexValidNumber, ''), true));
311
314
  setValue(parseNumberToMoney((_valueProps = valueProps) === null || _valueProps === void 0 ? void 0 : _valueProps.toString().replace(regexValidNumber, ''), true));
312
315
  }
313
- }, [valueProps]);
316
+ }, [valueProps, decimalDigit]);
314
317
  useEffect(() => {
315
318
  setError(errorProp);
316
319
  }, [errorProp]);
@@ -398,6 +398,7 @@ const PagingInfo = /*#__PURE__*/memo(/*#__PURE__*/forwardRef(({
398
398
  height: 24,
399
399
  color: 'line/category'
400
400
  }) : getGlobal('lineNumber'), jsx(Dropdown, {
401
+ isPaging: true,
401
402
  allowSearch: false,
402
403
  viewType: 'underlined',
403
404
  dataSource: listPerPageData,
@@ -474,7 +475,7 @@ const PagingInfoCSS = (bgCl, typeShort, {
474
475
  .DGN-UI-Dropdown {
475
476
  margin-left: ${spacing([typeShort ? 0 : 2])};
476
477
  margin-bottom: 0px;
477
- ${parseMinWidth(52)};
478
+ ${parseMinWidth(60)};
478
479
  .DGN-UI-Dropdown-Form {
479
480
  ${parseMinHeight(24)};
480
481
  padding: ${spacing([0])};
@@ -202,7 +202,7 @@ const Popover = /*#__PURE__*/memo(/*#__PURE__*/forwardRef((inProps, reference) =
202
202
  }
203
203
  };
204
204
  const updatePositionPopover = (el = null, cb) => {
205
- var _window, _window2, _anchor6, _anchorRect, _anchorRect2, _anchor7, _anchorRect3, _anchorRect4, _anchorRect5, _anchorRect6, _anchorRect7, _anchorRect8, _anchorRect9, _anchorRect10, _anchorRect11, _anchorRect12, _newDirectionObject, _newDirectionObject$t, _transformOrigin, _newDirectionObject2, _newDirectionObject2$, _transformOrigin2;
205
+ var _window, _window2, _anchor6, _anchorRect, _anchorRect2, _anchor7, _anchorRect3, _anchorRect4, _anchorRect5, _anchorRect6, _anchorRect7, _anchorRect8, _anchorRect9, _anchorRect0, _anchorRect1, _anchorRect10, _newDirectionObject, _newDirectionObject$t, _transformOrigin, _newDirectionObject2, _newDirectionObject2$, _transformOrigin2;
206
206
  if (el instanceof Element) setElement(el);
207
207
  if (!ref.current) {
208
208
  window.removeEventListener('resize', updatePositionPopover);
@@ -336,36 +336,36 @@ const Popover = /*#__PURE__*/memo(/*#__PURE__*/forwardRef((inProps, reference) =
336
336
 
337
337
  // Valid mean popover not at top-left, top-right, bottom-left, bottom-right
338
338
  const validVerticalArrow = left >= ((_anchorRect5 = anchorRect) === null || _anchorRect5 === void 0 ? void 0 : _anchorRect5.left) + ((_anchorRect6 = anchorRect) === null || _anchorRect6 === void 0 ? void 0 : _anchorRect6.width) / 2 - popoverWidth && left <= ((_anchorRect7 = anchorRect) === null || _anchorRect7 === void 0 ? void 0 : _anchorRect7.right) - ((_anchorRect8 = anchorRect) === null || _anchorRect8 === void 0 ? void 0 : _anchorRect8.width) / 2 + popoverWidth;
339
- const validHorizontalArrow = top >= ((_anchorRect9 = anchorRect) === null || _anchorRect9 === void 0 ? void 0 : _anchorRect9.top) + ((_anchorRect10 = anchorRect) === null || _anchorRect10 === void 0 ? void 0 : _anchorRect10.height) / 2 - popoverHeight && top <= ((_anchorRect11 = anchorRect) === null || _anchorRect11 === void 0 ? void 0 : _anchorRect11.bottom) - ((_anchorRect12 = anchorRect) === null || _anchorRect12 === void 0 ? void 0 : _anchorRect12.height) / 2;
339
+ const validHorizontalArrow = top >= ((_anchorRect9 = anchorRect) === null || _anchorRect9 === void 0 ? void 0 : _anchorRect9.top) + ((_anchorRect0 = anchorRect) === null || _anchorRect0 === void 0 ? void 0 : _anchorRect0.height) / 2 - popoverHeight && top <= ((_anchorRect1 = anchorRect) === null || _anchorRect1 === void 0 ? void 0 : _anchorRect1.bottom) - ((_anchorRect10 = anchorRect) === null || _anchorRect10 === void 0 ? void 0 : _anchorRect10.height) / 2;
340
340
 
341
341
  // Get arrow's position
342
342
  if (arrow && translate) {
343
343
  switch (aPosition) {
344
344
  case 'top':
345
345
  if (validVerticalArrow) {
346
- var _anchorRect13, _anchorRect14;
347
- arrowPosition.left = ((_anchorRect13 = anchorRect) === null || _anchorRect13 === void 0 ? void 0 : _anchorRect13.width) / 2 + ((_anchorRect14 = anchorRect) === null || _anchorRect14 === void 0 ? void 0 : _anchorRect14.left) - arrowSize + 'px';
346
+ var _anchorRect11, _anchorRect12;
347
+ arrowPosition.left = ((_anchorRect11 = anchorRect) === null || _anchorRect11 === void 0 ? void 0 : _anchorRect11.width) / 2 + ((_anchorRect12 = anchorRect) === null || _anchorRect12 === void 0 ? void 0 : _anchorRect12.left) - arrowSize + 'px';
348
348
  arrowPosition.top = Math.round(top) - arrowSize + 'px';
349
349
  }
350
350
  break;
351
351
  case 'bottom':
352
352
  if (validVerticalArrow) {
353
- var _anchorRect15, _anchorRect16;
354
- arrowPosition.left = ((_anchorRect15 = anchorRect) === null || _anchorRect15 === void 0 ? void 0 : _anchorRect15.width) / 2 + ((_anchorRect16 = anchorRect) === null || _anchorRect16 === void 0 ? void 0 : _anchorRect16.left) - arrowSize + 'px';
353
+ var _anchorRect13, _anchorRect14;
354
+ arrowPosition.left = ((_anchorRect13 = anchorRect) === null || _anchorRect13 === void 0 ? void 0 : _anchorRect13.width) / 2 + ((_anchorRect14 = anchorRect) === null || _anchorRect14 === void 0 ? void 0 : _anchorRect14.left) - arrowSize + 'px';
355
355
  arrowPosition.top = Math.round(top) + popoverHeight + 'px';
356
356
  }
357
357
  break;
358
358
  case 'left':
359
359
  if (validHorizontalArrow) {
360
- var _anchorRect17, _anchorRect18;
361
- arrowPosition.top = ((_anchorRect17 = anchorRect) === null || _anchorRect17 === void 0 ? void 0 : _anchorRect17.height) / 2 + ((_anchorRect18 = anchorRect) === null || _anchorRect18 === void 0 ? void 0 : _anchorRect18.top) - arrowSize / 2 + 'px';
360
+ var _anchorRect15, _anchorRect16;
361
+ arrowPosition.top = ((_anchorRect15 = anchorRect) === null || _anchorRect15 === void 0 ? void 0 : _anchorRect15.height) / 2 + ((_anchorRect16 = anchorRect) === null || _anchorRect16 === void 0 ? void 0 : _anchorRect16.top) - arrowSize / 2 + 'px';
362
362
  arrowPosition.left = Math.round(left) - 1.5 * arrowSize + 'px';
363
363
  }
364
364
  break;
365
365
  case 'right':
366
366
  if (validHorizontalArrow) {
367
- var _anchorRect19, _anchorRect20;
368
- arrowPosition.top = ((_anchorRect19 = anchorRect) === null || _anchorRect19 === void 0 ? void 0 : _anchorRect19.height) / 2 + ((_anchorRect20 = anchorRect) === null || _anchorRect20 === void 0 ? void 0 : _anchorRect20.top) - arrowSize / 2 + 'px';
367
+ var _anchorRect17, _anchorRect18;
368
+ arrowPosition.top = ((_anchorRect17 = anchorRect) === null || _anchorRect17 === void 0 ? void 0 : _anchorRect17.height) / 2 + ((_anchorRect18 = anchorRect) === null || _anchorRect18 === void 0 ? void 0 : _anchorRect18.top) - arrowSize / 2 + 'px';
369
369
  arrowPosition.left = Math.round(left) + popoverWidth - arrowSize / 2 + 'px';
370
370
  }
371
371
  break;
@@ -495,15 +495,15 @@ const Popover = /*#__PURE__*/memo(/*#__PURE__*/forwardRef((inProps, reference) =
495
495
  return currentRef;
496
496
  });
497
497
  const renderAnchor = () => {
498
- var _anchor10, _anchor11, _anchor11$props;
499
- if (!((_anchor10 = anchor) !== null && _anchor10 !== void 0 && _anchor10.type)) return null;
498
+ var _anchor0, _anchor1, _anchor1$props;
499
+ if (!((_anchor0 = anchor) !== null && _anchor0 !== void 0 && _anchor0.type)) return null;
500
500
  const AnchorTag = /*#__PURE__*/React.cloneElement(anchor, {
501
501
  ref: ref => {
502
502
  anchor = ref;
503
503
  },
504
504
  style: {
505
505
  cursor: 'pointer',
506
- ...(((_anchor11 = anchor) === null || _anchor11 === void 0 ? void 0 : (_anchor11$props = _anchor11.props) === null || _anchor11$props === void 0 ? void 0 : _anchor11$props.style) || {})
506
+ ...(((_anchor1 = anchor) === null || _anchor1 === void 0 ? void 0 : (_anchor1$props = _anchor1.props) === null || _anchor1$props === void 0 ? void 0 : _anchor1$props.style) || {})
507
507
  }
508
508
  });
509
509
  return AnchorTag;
@@ -37,6 +37,7 @@ const TreeView = /*#__PURE__*/memo(/*#__PURE__*/forwardRef((inProps, reference)
37
37
  expand,
38
38
  expandIcon,
39
39
  id,
40
+ isInDropdown,
40
41
  multiple,
41
42
  multipleValueMode,
42
43
  onChange,
@@ -69,7 +70,7 @@ const TreeView = /*#__PURE__*/memo(/*#__PURE__*/forwardRef((inProps, reference)
69
70
  allowNumber: false,
70
71
  allowSymbol: false
71
72
  }));
72
- const _TreeViewRootCSS = TreeViewRootCSS(theme);
73
+ const _TreeViewRootCSS = TreeViewRootCSS(theme, isInDropdown);
73
74
  const determinateCheckbox = (input, determinate) => {
74
75
  if (multipleValueMode === 'multiple' || disabledRelevantValue) {
75
76
  input.classList[determinate ? 'add' : 'remove']('determinate');
@@ -793,7 +794,7 @@ const TreeView = /*#__PURE__*/memo(/*#__PURE__*/forwardRef((inProps, reference)
793
794
  const TreeViewRootCSS = ({
794
795
  colors,
795
796
  spacing
796
- }) => css`
797
+ }, isInDropdown) => css`
797
798
  ${displayBlock};
798
799
  ${positionRelative};
799
800
  .DGN-UI-Accordion {
@@ -833,7 +834,7 @@ const TreeViewRootCSS = ({
833
834
  .TreeView-Content {
834
835
  ${displayBlock};
835
836
  ${positionRelative};
836
- ${parseMaxHeight(240)};
837
+ ${isInDropdown && parseMaxHeight(240)};
837
838
  ${overflowYScroll};
838
839
  &::-webkit-scrollbar {
839
840
  ${borderRadius(4)};
package/package.json CHANGED
@@ -1,44 +1,78 @@
1
- {
2
- "name": "diginet-core-ui",
3
- "version": "1.4.50",
4
- "description": "The DigiNet core ui",
5
- "homepage": "https://diginet.com.vn",
6
- "main": "index.js",
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"
13
- },
14
- "dependencies": {
15
- "@emotion/core": "^10.0.35",
16
- "prop-types": "^15.7.2",
17
- "@emotion/css": "^11.11.0",
18
- "@emotion/react": "^11.10.6"
19
- },
20
- "repository": {
21
- "type": "git",
22
- "url": "git+https://diginetvn@bitbucket.org/diginetvn/diginet-core-ui.git"
23
- },
24
- "keywords": [
25
- "core ui",
26
- "diginet"
27
- ],
28
- "author": "rocachien",
29
- "contributors": [
30
- {
31
- "name": "Chien Do",
32
- "email": "rocachien@gmail.com"
33
- },
34
- {
35
- "name": "Nhat Tran",
36
- "email": "tranminhnhat1005@gmail.com"
37
- },
38
- {
39
- "name": "Thuan Nguyen",
40
- "email": "nt.thuan.hutech@gmail.com"
41
- }
42
- ],
43
- "license": "MIT"
44
- }
1
+ {
2
+ "name": "diginet-core-ui",
3
+ "version": "1.4.51-beta.0",
4
+ "description": "",
5
+ "main": "index.js",
6
+ "license": "UNLICENSED",
7
+ "scripts": {
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",
27
+ "freshtall": "npm cache clean --force && rm -rf node_modules && rm -f package-lock.json && npm install",
28
+ "test-storybook": "test-storybook --url http://localhost:9050",
29
+ "preinstall": "echo {} > package-lock.json"
30
+ },
31
+ "dependencies": {
32
+ "@emotion/core": "^10.0.35",
33
+ "@emotion/css": "^11.11.0",
34
+ "@emotion/react": "^11.10.6",
35
+ "babel-plugin-module-resolver": "^4.1.0",
36
+ "date-fns": "^2.30.0",
37
+ "prop-types": "^15.7.2"
38
+ },
39
+ "lint-staged": {
40
+ "*/**/*.{js,jsx,json}": [
41
+ "prettier --write",
42
+ "git add"
43
+ ]
44
+ },
45
+ "devDependencies": {
46
+ "@babel/cli": "^7.14.3",
47
+ "@babel/plugin-proposal-class-properties": "^7.13.0",
48
+ "@babel/plugin-proposal-logical-assignment-operators": "^7.16.0",
49
+ "@babel/plugin-proposal-nullish-coalescing-operator": "^7.16.0",
50
+ "@babel/plugin-proposal-optional-chaining": "^7.14.2",
51
+ "@babel/plugin-proposal-private-methods": "^7.18.6",
52
+ "@babel/plugin-proposal-private-property-in-object": "^7.18.6",
53
+ "@babel/preset-react": "^7.13.13",
54
+ "@storybook/addon-actions": "6.2.9",
55
+ "@storybook/addon-essentials": "6.2.9",
56
+ "@storybook/addon-links": "6.2.9",
57
+ "@storybook/addon-postcss": "^2.0.0",
58
+ "@storybook/react": "6.2.9",
59
+ "@storybook/test-runner": "^0.7.1",
60
+ "autoprefixer": "^10.3.1",
61
+ "babel-loader": "^8.2.2",
62
+ "eslint": "^8.4.1",
63
+ "eslint-plugin-react": "^7.27.1",
64
+ "eslint-plugin-regex": "^1.10.0",
65
+ "husky": "^7.0.4",
66
+ "jest": "^27.5.1",
67
+ "lint-staged": "^12.1.2",
68
+ "mkdirp": "^1.0.4",
69
+ "npm-run-all": "^4.1.5",
70
+ "onchange": "^7.1.0",
71
+ "postcss-flexbugs-fixes": "^5.0.2",
72
+ "react": "^17.0.1",
73
+ "react-dom": "^17.0.1",
74
+ "rimraf": "^3.0.2",
75
+ "run-script-os": "^1.1.6",
76
+ "sass": "1.58.3"
77
+ }
78
+ }