grep-components 1.27.0-GREPF-2104.1 → 1.27.0-GREPF-2104.2

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.
@@ -4,7 +4,7 @@ export interface SidebarProps {
4
4
  currentPageId?: number;
5
5
  pages: NavigationProps[];
6
6
  onPageClick: (page: NavigationProps) => any;
7
- expandAndClick?: boolean;
7
+ expandOnIcon?: boolean;
8
8
  }
9
- declare const Sidebar: ({ pages, onPageClick, currentPageId, expandAndClick }: SidebarProps) => JSX.Element;
9
+ declare const Sidebar: ({ pages, onPageClick, currentPageId, expandOnIcon }: SidebarProps) => JSX.Element;
10
10
  export default Sidebar;
package/dist/index.js CHANGED
@@ -4727,7 +4727,7 @@ var useStyles$6 = makeStyles()(function (_a, _props, classes) {
4727
4727
  });
4728
4728
 
4729
4729
  var Sidebar = function (_a) {
4730
- var pages = _a.pages, onPageClick = _a.onPageClick, currentPageId = _a.currentPageId, expandAndClick = _a.expandAndClick;
4730
+ var pages = _a.pages, onPageClick = _a.onPageClick, currentPageId = _a.currentPageId, expandOnIcon = _a.expandOnIcon;
4731
4731
  var _b = __read(React.useState([]), 2), expanded = _b[0], setExpanded = _b[1];
4732
4732
  var classes = useStyles$6().classes;
4733
4733
  React.useEffect(function () {
@@ -4746,8 +4746,7 @@ var Sidebar = function (_a) {
4746
4746
  }
4747
4747
  };
4748
4748
  var handleClick = function (page) {
4749
- if (expandAndClick) {
4750
- toggleExpand(page.id);
4749
+ if (expandOnIcon) {
4751
4750
  onPageClick(page);
4752
4751
  }
4753
4752
  else {
@@ -4757,13 +4756,34 @@ var Sidebar = function (_a) {
4757
4756
  var renderItem = function (page) { return (React.createElement(React.Fragment, null,
4758
4757
  page.linkIcon && (React.createElement(ListItemIcon, { className: classes.icon }, page.linkIcon)),
4759
4758
  React.createElement(ListItemText$1, { sx: { outline: 'none !important' }, tabIndex: -1, disableTypography: true, primary: page.label, className: page.id === currentPageId ? classes.selected : classes.text }))); };
4759
+ var renderExpandIcon = function (page) {
4760
+ if (page.children) {
4761
+ if (expanded.includes(page.id)) {
4762
+ if (expandOnIcon) {
4763
+ return React.createElement(ExpandLess, { onClick: function (e) { e.stopPropagation(), toggleExpand(page.id); } });
4764
+ }
4765
+ else {
4766
+ return React.createElement(ExpandLess, null);
4767
+ }
4768
+ }
4769
+ else {
4770
+ if (expandOnIcon) {
4771
+ return React.createElement(ExpandMore, { onClick: function (e) { e.stopPropagation(), toggleExpand(page.id); } });
4772
+ }
4773
+ else {
4774
+ return React.createElement(ExpandMore, null);
4775
+ }
4776
+ }
4777
+ }
4778
+ return null;
4779
+ };
4760
4780
  return (React.createElement(Box$1, { className: classes.container },
4761
4781
  React.createElement(List$1, null, pages.map(function (page) {
4762
4782
  var _a;
4763
4783
  return (React.createElement("div", { key: page.id },
4764
4784
  React.createElement(ListItem$1, { key: page.id, tabIndex: 0, className: classes.item, onClick: function () { return handleClick(page); }, onKeyPress: keyboard.onActivation(function () { return handleClick(page); }) },
4765
4785
  renderItem(page),
4766
- page.children ? (expanded.includes(page.id) ? (React.createElement(ExpandLess, null)) : (React.createElement(ExpandMore, null))) : null),
4786
+ renderExpandIcon(page)),
4767
4787
  React.createElement(Collapse, { in: expanded.includes(page.id), timeout: "auto", unmountOnExit: true },
4768
4788
  React.createElement(List$1, { disablePadding: true }, (_a = page.children) === null || _a === void 0 ? void 0 : _a.map(function (child) { return (React.createElement(ListItem$1, { key: child.id, style: { paddingLeft: '30px' }, tabIndex: 0, className: classes.item, onClick: function () { return handleClick(child); }, onKeyPress: keyboard.onActivation(function () { return handleClick(child); }) }, renderItem(child))); })))));
4769
4789
  }))));