@evergis/uilib-gl 1.0.78 → 1.0.80

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.
@@ -63,6 +63,7 @@ export interface IPopup {
63
63
  bottomBind?: boolean;
64
64
  menuHeight?: string;
65
65
  width?: string;
66
+ minWidth?: string;
66
67
  containerRef?: (ref: HTMLDivElement | null) => void;
67
68
  root?: HTMLElement | null;
68
69
  onRequestClose?: VoidFunction;
@@ -47,6 +47,7 @@ export declare type TreeProps<T = any> = {
47
47
  data: TreeItemProps<T>[];
48
48
  setData?: Dispatch<SetStateAction<TreeItemProps<T>[]>>;
49
49
  loadNode?: (item: TreeItemProps<T>, offset?: number) => Promisable<PartialLoadData<T>>;
50
+ partialNodeMerge?: boolean;
50
51
  withLoadMore?: boolean;
51
52
  expanded?: TreeId[];
52
53
  allExpanded?: boolean;
@@ -11,7 +11,7 @@ import de from 'date-fns/locale/de';
11
11
  import Locale from 'date-fns/locale/ru';
12
12
  import AutosuggestHighlightMatch from 'autosuggest-highlight/match';
13
13
  import AutosuggestHighlightParse from 'autosuggest-highlight/parse';
14
- import { debounce as debounce$1, throttle, isEqual, isNil, unescape, defaults, keyBy } from 'lodash-es';
14
+ import { debounce as debounce$1, throttle, isEqual, isNil, unescape, defaults, keyBy, isEmpty } from 'lodash-es';
15
15
  import { CSSTransition as CSSTransition$1, TransitionGroup } from 'react-transition-group';
16
16
  import Transition from 'react-transition-group/Transition';
17
17
  import { background, border, color, flexbox, fontSize, fontWeight, fontStyle, space, layout, textAlign, position, lineHeight, padding } from 'styled-system';
@@ -13709,7 +13709,7 @@ const Box = styled.span`
13709
13709
  borderRadius
13710
13710
  }
13711
13711
  } = _ref3;
13712
- return borderRadius.medium;
13712
+ return borderRadius.xSmall;
13713
13713
  }};
13714
13714
  box-sizing: border-box;
13715
13715
  overflow: hidden;
@@ -18783,7 +18783,7 @@ const OptionContainer = styled.div`
18783
18783
  justify-content: flex-start;
18784
18784
  align-items: center;
18785
18785
  min-height: 1.25em;
18786
- padding: 0.75rem 1rem;
18786
+ padding: 0.625rem 1rem;
18787
18787
  color: ${_ref => {
18788
18788
  let {
18789
18789
  theme: {
@@ -18856,7 +18856,6 @@ const OptionContainer = styled.div`
18856
18856
  }};
18857
18857
  `;
18858
18858
  const OptionIcon = styled.span`
18859
- margin-right: 0.5rem;
18860
18859
  min-width: 1.5rem;
18861
18860
  text-overflow: unset !important;
18862
18861
  `;
@@ -21086,16 +21085,22 @@ const classNames = {
21086
21085
  };
21087
21086
  const Menu$1 = /*#__PURE__*/styled(Blank)`
21088
21087
  position: relative;
21089
- min-width: ${_ref => {
21088
+ width: ${_ref => {
21090
21089
  let {
21091
- minWidth
21090
+ width
21092
21091
  } = _ref;
21092
+ return width ?? "auto";
21093
+ }};
21094
+ min-width: ${_ref2 => {
21095
+ let {
21096
+ minWidth
21097
+ } = _ref2;
21093
21098
  return minWidth;
21094
21099
  }};
21095
- max-height: ${_ref2 => {
21100
+ max-height: ${_ref3 => {
21096
21101
  let {
21097
21102
  maxHeight
21098
- } = _ref2;
21103
+ } = _ref3;
21099
21104
  return maxHeight;
21100
21105
  }};
21101
21106
  padding: 0.625rem 0;
@@ -21114,6 +21119,7 @@ const PopupComponent = _ref => {
21114
21119
  bottomBind,
21115
21120
  menuHeight,
21116
21121
  width,
21122
+ minWidth,
21117
21123
  anchor,
21118
21124
  children,
21119
21125
  containerRef,
@@ -21132,7 +21138,8 @@ const PopupComponent = _ref => {
21132
21138
  root: root,
21133
21139
  onRequestClose: onRequestClose
21134
21140
  }, React.createElement(Menu$1, Object.assign({
21135
- minWidth: width,
21141
+ width: width,
21142
+ minWidth: minWidth,
21136
21143
  maxHeight: menuHeight,
21137
21144
  ref: containerRef
21138
21145
  }, props), children));
@@ -28507,7 +28514,6 @@ const TreeExpand = /*#__PURE__*/styled(Icon)`
28507
28514
  width: 0.875rem;
28508
28515
  height: 0.875rem;
28509
28516
  margin-top: -0.125rem;
28510
- margin-right: 0.5rem;
28511
28517
  cursor: pointer;
28512
28518
 
28513
28519
  &:after {
@@ -28517,6 +28523,7 @@ const TreeExpand = /*#__PURE__*/styled(Icon)`
28517
28523
  const TreeContent = /*#__PURE__*/styled(Flex)`
28518
28524
  align-items: center;
28519
28525
  gap: 0 0.25rem;
28526
+ min-width: 1px;
28520
28527
  `;
28521
28528
  const TreeText = styled.div`
28522
28529
  font-size: 0.75rem;
@@ -28785,6 +28792,7 @@ const TreeComponent = _ref => {
28785
28792
  setExpanded,
28786
28793
  setSelected,
28787
28794
  withLoadMore,
28795
+ partialNodeMerge = true,
28788
28796
  onItemClick,
28789
28797
  onExpand,
28790
28798
  Item = TreeItem
@@ -28816,10 +28824,25 @@ const TreeComponent = _ref => {
28816
28824
  children,
28817
28825
  totalCount
28818
28826
  } = await loadNode(item);
28819
- onItemUpdate(item.id, currentItem => ({ ...currentItem,
28820
- children,
28821
- totalCount
28822
- }));
28827
+ onItemUpdate(item.id, currentItem => {
28828
+ const newChildren = children == null ? void 0 : children.map(item => {
28829
+ var _currentItem$children;
28830
+
28831
+ const oldItem = (_currentItem$children = currentItem.children) == null ? void 0 : _currentItem$children.find(_ref2 => {
28832
+ let {
28833
+ id
28834
+ } = _ref2;
28835
+ return id === item.id;
28836
+ });
28837
+ return { ...item,
28838
+ children: !isEmpty(oldItem == null ? void 0 : oldItem.children) && partialNodeMerge ? oldItem == null ? void 0 : oldItem.children : item == null ? void 0 : item.children
28839
+ };
28840
+ }, []);
28841
+ return { ...currentItem,
28842
+ children: newChildren,
28843
+ totalCount
28844
+ };
28845
+ });
28823
28846
  } finally {
28824
28847
  onItemUpdate(item.id, currentItem => ({ ...currentItem,
28825
28848
  loading: false
@@ -28828,7 +28851,7 @@ const TreeComponent = _ref => {
28828
28851
  }
28829
28852
 
28830
28853
  onExpand == null ? void 0 : onExpand(item, isExpanded, onlyReload);
28831
- }, [expand, onExpand, onItemUpdate, loadNode]);
28854
+ }, [expand, onExpand, onItemUpdate, loadNode, partialNodeMerge]);
28832
28855
  const onLoadMore = useCallback(async item => {
28833
28856
  if (!loadNode) {
28834
28857
  return;
@@ -28860,39 +28883,39 @@ const TreeComponent = _ref => {
28860
28883
  return [...result, item, ...getChildren(item.children)];
28861
28884
  }, []);
28862
28885
  }, []);
28863
- const getIsSomeSelected = useCallback(items => items.some(_ref2 => {
28886
+ const getIsSomeSelected = useCallback(items => items.some(_ref3 => {
28864
28887
  let {
28865
28888
  id,
28866
28889
  disabled,
28867
28890
  children
28868
- } = _ref2;
28891
+ } = _ref3;
28869
28892
  return disabled ? false : children != null && children.length ? getIsSomeSelected(children) : selected == null ? void 0 : selected.includes(id);
28870
28893
  }), [selected]);
28871
- const getIsSomeDeselected = useCallback(items => items.some(_ref3 => {
28894
+ const getIsSomeDeselected = useCallback(items => items.some(_ref4 => {
28872
28895
  let {
28873
28896
  id,
28874
28897
  disabled,
28875
28898
  children
28876
- } = _ref3;
28899
+ } = _ref4;
28877
28900
  return disabled ? false : children != null && children.length ? getIsSomeDeselected(children) : !(selected != null && selected.includes(id));
28878
28901
  }), [selected]);
28879
28902
  const getIsIndeterminate = useCallback(items => {
28880
28903
  if (!(items != null && items.length)) return false;
28881
28904
  return getIsSomeSelected(items) && getIsSomeDeselected(items);
28882
28905
  }, [getIsSomeDeselected, getIsSomeSelected]);
28883
- const getIsDisabled = useCallback(_ref4 => {
28906
+ const getIsDisabled = useCallback(_ref5 => {
28884
28907
  let {
28885
28908
  disabled,
28886
28909
  children
28887
- } = _ref4;
28910
+ } = _ref5;
28888
28911
  return disabled || !!(children != null && children.length) && (children == null ? void 0 : children.every(child => getIsDisabled(child)));
28889
28912
  }, []);
28890
- const addItem = useCallback((_ref5, selected) => {
28913
+ const addItem = useCallback((_ref6, selected) => {
28891
28914
  let {
28892
28915
  id,
28893
28916
  disabled,
28894
28917
  children
28895
- } = _ref5;
28918
+ } = _ref6;
28896
28919
  return disabled ? selected : children != null && children.length || selected.includes(id) ? selected : [...selected, id];
28897
28920
  }, []);
28898
28921
  const removeItem = useCallback((item, selected) => {