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