@banyan_cloud/roots 2.0.28 → 2.0.29

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.
package/dist/esm/index.js CHANGED
@@ -7201,10 +7201,10 @@ Reset.defaultProps = {
7201
7201
  className: ''
7202
7202
  };
7203
7203
 
7204
- var _excluded$1 = ["className"];
7204
+ var _excluded = ["className"];
7205
7205
  var SearchIcon = function SearchIcon(_ref) {
7206
7206
  var className = _ref.className,
7207
- rest = _objectWithoutProperties(_ref, _excluded$1);
7207
+ rest = _objectWithoutProperties(_ref, _excluded);
7208
7208
  return /*#__PURE__*/jsxs("svg", _objectSpread2(_objectSpread2({
7209
7209
  width: "25",
7210
7210
  height: "25",
@@ -19403,9 +19403,8 @@ var HierarchyItem = function HierarchyItem(props) {
19403
19403
  onDoubleClick = props.onDoubleClick,
19404
19404
  _props$active = props.active,
19405
19405
  active = _props$active === void 0 ? false : _props$active,
19406
- isLastItem = props.isLastItem;
19407
- props.isSingleItem;
19408
- var count = props.count,
19406
+ isLastItem = props.isLastItem,
19407
+ count = props.count,
19409
19408
  leftComponent = props.leftComponent,
19410
19409
  name = props.name,
19411
19410
  onSearchSubmit = props.onSearchSubmit,
@@ -19426,9 +19425,9 @@ var HierarchyItem = function HierarchyItem(props) {
19426
19425
  className: modules_6d03d164['expand-container'],
19427
19426
  children: [jsx(Button, {
19428
19427
  className: modules_6d03d164.expand,
19428
+ title: '',
19429
19429
  size: 'auto',
19430
19430
  variant: 'text',
19431
- color: 'default',
19432
19431
  onClick: function onClick() {
19433
19432
  setOpen(function (prevState) {
19434
19433
  var newState = !prevState;
@@ -19458,12 +19457,10 @@ var HierarchyItem = function HierarchyItem(props) {
19458
19457
  flexible: true,
19459
19458
  size: 'auto',
19460
19459
  className: classes(modules_6d03d164.header, count === undefined && modules_6d03d164.headerNoCount),
19461
- // component1={iconPlacement === 'left' ? icon : undefined}
19462
19460
  component1: list ? icon : undefined,
19463
19461
  component2: isSearching && open ? jsx("div", {
19464
19462
  className: modules_6d03d164.searchFieldWrapper,
19465
19463
  children: jsx(TextField$1, {
19466
- label: null,
19467
19464
  className: modules_6d03d164.searchInput,
19468
19465
  placeholder: "Search ".concat(name),
19469
19466
  size: 'md',
@@ -19487,8 +19484,7 @@ var HierarchyItem = function HierarchyItem(props) {
19487
19484
  }),
19488
19485
  onClick: handleSearchSubmit,
19489
19486
  variant: 'text',
19490
- size: 'auto',
19491
- color: 'default'
19487
+ size: 'auto'
19492
19488
  });
19493
19489
  }
19494
19490
  })
@@ -19497,7 +19493,7 @@ var HierarchyItem = function HierarchyItem(props) {
19497
19493
  flexible: true,
19498
19494
  size: 'auto',
19499
19495
  variant: 'text',
19500
- color: 'default',
19496
+ title: '',
19501
19497
  onClick: function onClick(event) {
19502
19498
  var detail = event.detail;
19503
19499
  if (detail === 1) _onClick === null || _onClick === void 0 || _onClick(open);else if (detail === 2) {
@@ -19515,7 +19511,6 @@ var HierarchyItem = function HierarchyItem(props) {
19515
19511
  component3: !isSearching && open ? jsx(Button, {
19516
19512
  size: 'auto',
19517
19513
  variant: 'text',
19518
- color: 'default',
19519
19514
  className: modules_6d03d164.searchWrapper,
19520
19515
  onClick: function onClick() {
19521
19516
  onSearchStart === null || onSearchStart === void 0 || onSearchStart(); // trigger search state in parent
@@ -19550,7 +19545,6 @@ var css$G = ".HierarchyBrowser_module_root__f9f89fa5 {\n display: flex;\n flex
19550
19545
  var modules_5e29d515 = {"root":"HierarchyBrowser_module_root__f9f89fa5","header":"HierarchyBrowser_module_header__f9f89fa5","body":"HierarchyBrowser_module_body__f9f89fa5","item":"HierarchyBrowser_module_item__f9f89fa5","item-icon":"HierarchyBrowser_module_itemIcon__f9f89fa5","item-title":"HierarchyBrowser_module_itemTitle__f9f89fa5","item-count":"HierarchyBrowser_module_itemCount__f9f89fa5","count-bg":"HierarchyBrowser_module_countBg__f9f89fa5","count-text":"HierarchyBrowser_module_countText__f9f89fa5","resizable":"HierarchyBrowser_module_resizable__f9f89fa5"};
19551
19546
  n(css$G,{});
19552
19547
 
19553
- var _excluded = ["leftComponent", "rightComponent", "title", "count"];
19554
19548
  var Title = function Title(_ref) {
19555
19549
  var leftComponent = _ref.leftComponent,
19556
19550
  title = _ref.title,
@@ -19581,9 +19575,13 @@ var HierarchyBrowser = function HierarchyBrowser(_ref2) {
19581
19575
  _ref2$metadata = _ref2.metadata,
19582
19576
  metadata = _ref2$metadata === void 0 ? [] : _ref2$metadata,
19583
19577
  _ref2$onItemClick = _ref2.onItemClick,
19584
- onItemClick = _ref2$onItemClick === void 0 ? function () {} : _ref2$onItemClick,
19578
+ onItemClick = _ref2$onItemClick === void 0 ? function () {
19579
+ // left blank
19580
+ } : _ref2$onItemClick,
19585
19581
  _ref2$onItemDoubleCli = _ref2.onItemDoubleClick,
19586
- onItemDoubleClick = _ref2$onItemDoubleCli === void 0 ? function () {} : _ref2$onItemDoubleCli,
19582
+ onItemDoubleClick = _ref2$onItemDoubleCli === void 0 ? function () {
19583
+ // left blank
19584
+ } : _ref2$onItemDoubleCli,
19587
19585
  _ref2$minWidth = _ref2.minWidth,
19588
19586
  minWidth = _ref2$minWidth === void 0 ? 220 : _ref2$minWidth,
19589
19587
  maxWidth = _ref2.maxWidth,
@@ -19593,33 +19591,31 @@ var HierarchyBrowser = function HierarchyBrowser(_ref2) {
19593
19591
  setItemProps = _ref2$setItemProps === void 0 ? function () {
19594
19592
  return {};
19595
19593
  } : _ref2$setItemProps;
19596
- _ref2.title;
19597
19594
  var browserRef = useRef(null);
19598
19595
  var _useState = useState({}),
19599
19596
  _useState2 = _slicedToArray(_useState, 2),
19600
19597
  searchResults = _useState2[0],
19601
19598
  setSearchResults = _useState2[1];
19599
+ var _useState3 = useState(null),
19600
+ _useState4 = _slicedToArray(_useState3, 2),
19601
+ activePath = _useState4[0],
19602
+ setActivePath = _useState4[1];
19602
19603
  useResize({
19603
19604
  ref: browserRef,
19604
19605
  styles: {
19605
19606
  minWidth: minWidth,
19606
19607
  maxWidth: maxWidth !== null && maxWidth !== void 0 ? maxWidth : document.documentElement.getBoundingClientRect().width,
19607
- borderSize: borderSize
19608
+ borderSize: borderSize !== null && borderSize !== void 0 ? borderSize : 0
19608
19609
  },
19609
- enabled: resizable
19610
+ enabled: resizable !== null && resizable !== void 0 ? resizable : true
19610
19611
  });
19611
- var _useState3 = useState(null),
19612
- _useState4 = _slicedToArray(_useState3, 2),
19613
- lastOpenedPath = _useState4[0],
19614
- setLastOpenedPath = _useState4[1];
19615
19612
  var _useState5 = useState(null),
19616
- _useState6 = _slicedToArray(_useState5, 2);
19617
- _useState6[0];
19618
- var setLastOpenedItem = _useState6[1];
19613
+ _useState6 = _slicedToArray(_useState5, 2),
19614
+ lastOpenedPath = _useState6[0],
19615
+ setLastOpenedPath = _useState6[1];
19619
19616
  var _useState7 = useState(new Set()),
19620
- _useState8 = _slicedToArray(_useState7, 2);
19621
- _useState8[0];
19622
- var setOpenPaths = _useState8[1];
19617
+ _useState8 = _slicedToArray(_useState7, 2),
19618
+ setOpenPaths = _useState8[1];
19623
19619
  var _useState9 = useState(null),
19624
19620
  _useState0 = _slicedToArray(_useState9, 2),
19625
19621
  searchingPath = _useState0[0],
@@ -19636,7 +19632,6 @@ var HierarchyBrowser = function HierarchyBrowser(_ref2) {
19636
19632
  if (open) {
19637
19633
  newPaths.add(pathString);
19638
19634
  setLastOpenedPath(pathString);
19639
- setLastOpenedItem(item);
19640
19635
  } else {
19641
19636
  Array.from(newPaths).forEach(function (p) {
19642
19637
  if (p === pathString || p.startsWith("".concat(pathString, "."))) {
@@ -19656,7 +19651,6 @@ var HierarchyBrowser = function HierarchyBrowser(_ref2) {
19656
19651
  setLastOpenedPath(fallback);
19657
19652
  } else {
19658
19653
  setLastOpenedPath(null);
19659
- setLastOpenedItem(null);
19660
19654
  }
19661
19655
  }
19662
19656
  }
@@ -19667,11 +19661,14 @@ var HierarchyBrowser = function HierarchyBrowser(_ref2) {
19667
19661
  var handleItemClick = function handleItemClick(item, pathString) {
19668
19662
  return function (open) {
19669
19663
  onItemClick(item, pathString, open);
19664
+ setActivePath(pathString);
19670
19665
  if (!open) {
19671
19666
  setSearchResults(function (prev) {
19672
- var updated = _objectSpread2({}, prev);
19673
- delete updated[pathString];
19674
- return updated;
19667
+ return Object.fromEntries(Object.entries(prev).filter(function (_ref3) {
19668
+ var _ref4 = _slicedToArray(_ref3, 1),
19669
+ key = _ref4[0];
19670
+ return key !== pathString;
19671
+ }));
19675
19672
  });
19676
19673
  }
19677
19674
  };
@@ -19683,22 +19680,21 @@ var HierarchyBrowser = function HierarchyBrowser(_ref2) {
19683
19680
  };
19684
19681
  var handleSearchSubmit = function handleSearchSubmit(searchText, pathString) {
19685
19682
  setSearchResults(function (prev) {
19686
- return _objectSpread2(_objectSpread2({}, prev), {}, _defineProperty({}, pathString, searchText.toLowerCase()));
19683
+ return _objectSpread2(_objectSpread2({}, prev), {}, _defineProperty({}, pathString, (searchText !== null && searchText !== void 0 ? searchText : '').toLowerCase()));
19687
19684
  });
19688
19685
  };
19689
19686
  var shouldDisplayItem = function shouldDisplayItem(item, searchText) {
19690
- var _item$title;
19687
+ var _item$title$toLowerCa, _item$title;
19691
19688
  if (!searchText) return true;
19692
- return (_item$title = item.title) === null || _item$title === void 0 ? void 0 : _item$title.toLowerCase().includes(searchText);
19689
+ return (_item$title$toLowerCa = (_item$title = item.title) === null || _item$title === void 0 ? void 0 : _item$title.toLowerCase().includes(searchText)) !== null && _item$title$toLowerCa !== void 0 ? _item$title$toLowerCa : false;
19693
19690
  };
19694
19691
  var _renderTree = function renderTree(data) {
19692
+ var _searchResults$curren, _data$list;
19695
19693
  var pathString = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
19696
19694
  var isLast = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
19697
- var isSingleItem = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : false;
19698
- if (!data) return null;
19699
19695
  var children = Array.isArray(data.list) ? data.list : [];
19700
19696
  var currentPath = pathString || 'metadata';
19701
- var searchText = searchResults[currentPath] || '';
19697
+ var searchText = (_searchResults$curren = searchResults[currentPath]) !== null && _searchResults$curren !== void 0 ? _searchResults$curren : '';
19702
19698
  var filteredChildren = searchText ? children.filter(function (child) {
19703
19699
  return shouldDisplayItem(child, searchText);
19704
19700
  }) : children;
@@ -19707,8 +19703,11 @@ var HierarchyBrowser = function HierarchyBrowser(_ref2) {
19707
19703
  rightComponent = _setItemProps.rightComponent,
19708
19704
  title = _setItemProps.title,
19709
19705
  count = _setItemProps.count;
19710
- _objectWithoutProperties(_setItemProps, _excluded);
19711
- return jsx(HierarchyItem, {
19706
+ return jsx(HierarchyItem
19707
+ // key={currentPath}
19708
+ , {
19709
+ // key={currentPath}
19710
+ pathString: currentPath,
19712
19711
  title: jsx(Title, {
19713
19712
  leftComponent: leftComponent,
19714
19713
  title: title,
@@ -19723,28 +19722,27 @@ var HierarchyBrowser = function HierarchyBrowser(_ref2) {
19723
19722
  handleItemDoubleClick(data, currentPath)(open);
19724
19723
  trackOpenState(data, currentPath, open);
19725
19724
  },
19725
+ active: activePath === currentPath,
19726
19726
  lastActive: lastOpenedPath === currentPath,
19727
19727
  isLastItem: isLast,
19728
- isSingleItem: isSingleItem,
19729
- count: count,
19728
+ count: count !== null && count !== void 0 ? count : 0,
19730
19729
  name: title,
19731
- list: data.list,
19730
+ list: (_data$list = data.list) !== null && _data$list !== void 0 ? _data$list : false,
19732
19731
  leftComponent: leftComponent,
19733
19732
  isSearching: searchingPath === currentPath,
19734
19733
  onSearchStart: function onSearchStart() {
19735
- return setSearchingPath(currentPath);
19734
+ setSearchingPath(currentPath);
19736
19735
  },
19737
19736
  onSearchSubmit: function onSearchSubmit(text) {
19738
19737
  handleSearchSubmit(text, currentPath);
19739
19738
  setSearchingPath(null);
19740
19739
  },
19741
- children: filteredChildren.map(function (child, index) {
19742
- var isLastItem = index === filteredChildren.length - 1;
19743
- var isSingleItem = filteredChildren.length === 1;
19744
- var nextPath = "".concat(currentPath, ".list[").concat(index, "]");
19745
- return _renderTree(child, nextPath, index === 0, isLastItem, isSingleItem);
19740
+ children: filteredChildren.map(function (child, idx) {
19741
+ var isLastChild = idx === filteredChildren.length - 1;
19742
+ var nextPath = "".concat(currentPath, ".list[").concat(String(idx), "]");
19743
+ return _renderTree(child, nextPath, idx === 0, isLastChild);
19746
19744
  })
19747
- }, currentPath);
19745
+ });
19748
19746
  };
19749
19747
  return jsx("div", {
19750
19748
  ref: browserRef,
@@ -19752,10 +19750,9 @@ var HierarchyBrowser = function HierarchyBrowser(_ref2) {
19752
19750
  children: jsx("div", {
19753
19751
  className: modules_5e29d515.body,
19754
19752
  "data-elem": 'body',
19755
- children: (metadata || []).map(function (item, index) {
19753
+ children: metadata.map(function (item, index) {
19756
19754
  var isLastItem = index === metadata.length - 1;
19757
- var isSingleItem = metadata.length === 1;
19758
- return _renderTree(item, "metadata[".concat(index, "]"), index === 0, isLastItem, isSingleItem);
19755
+ return _renderTree(item, "metadata[".concat(String(index), "]"), index === 0, isLastItem);
19759
19756
  })
19760
19757
  })
19761
19758
  });