@apexcura/ui-components 0.0.16-Beta38 → 0.0.16-Beta39

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/index.js CHANGED
@@ -778,37 +778,37 @@ var import_antd11 = require("antd");
778
778
  var { Sider } = import_antd11.Layout;
779
779
  var Sidebar = (props) => {
780
780
  const [collapsed, setCollapsed] = (0, import_react16.useState)(false);
781
+ const handleChange = (item) => {
782
+ if (props.onChange) {
783
+ props.onChange(item);
784
+ }
785
+ };
781
786
  function getItem(label, key, icon, children, item) {
782
787
  return {
783
788
  key,
784
789
  icon: icon ? /* @__PURE__ */ import_react16.default.createElement("span", { className: props.iconsClassName }, icon) : null,
785
790
  children,
786
- label
791
+ label,
792
+ onClick: () => handleChange(item || { label, key })
787
793
  };
788
794
  }
789
795
  const items = props.items?.map((eachItem, index) => {
790
796
  return getItem(
791
797
  eachItem.label,
792
798
  index.toString(),
793
- eachItem.icon ? icons[eachItem.icon] || /* @__PURE__ */ import_react16.default.createElement("img", { src: eachItem.icon, alt: eachItem.label }) : "",
799
+ eachItem.icon ? icons[eachItem.icon] || /* @__PURE__ */ import_react16.default.createElement("img", { src: eachItem.icon }) : "",
800
+ eachItem,
794
801
  eachItem.items?.map(
795
802
  (child, childIndex) => getItem(
796
803
  child.label,
797
804
  `${index}-${childIndex}`,
798
- child.icon ? icons[child.icon] || /* @__PURE__ */ import_react16.default.createElement("img", { src: child.icon, alt: child.label }) : "",
805
+ eachItem.icon ? icons[eachItem.icon] || /* @__PURE__ */ import_react16.default.createElement("img", { src: eachItem.icon }) : "",
799
806
  void 0,
800
807
  child
801
808
  )
802
- ),
803
- eachItem
809
+ )
804
810
  );
805
811
  });
806
- const handleClick = (e) => {
807
- const clickedItem = props.items?.find(
808
- (item, index) => index.toString() === e.key
809
- );
810
- console.log("Clicked item:", clickedItem);
811
- };
812
812
  return /* @__PURE__ */ import_react16.default.createElement(import_antd11.Layout, { style: { minHeight: "100vh" } }, /* @__PURE__ */ import_react16.default.createElement(
813
813
  Sider,
814
814
  {
@@ -821,10 +821,9 @@ var Sidebar = (props) => {
821
821
  import_antd11.Menu,
822
822
  {
823
823
  theme: "dark",
824
- defaultSelectedKeys: ["0"],
824
+ defaultSelectedKeys: ["1"],
825
825
  mode: "inline",
826
- items,
827
- onClick: handleClick
826
+ items
828
827
  }
829
828
  )
830
829
  ));
package/dist/index.mjs CHANGED
@@ -707,37 +707,37 @@ import { Layout, Menu } from "antd";
707
707
  var { Sider } = Layout;
708
708
  var Sidebar = (props) => {
709
709
  const [collapsed, setCollapsed] = useState5(false);
710
+ const handleChange = (item) => {
711
+ if (props.onChange) {
712
+ props.onChange(item);
713
+ }
714
+ };
710
715
  function getItem(label, key, icon, children, item) {
711
716
  return {
712
717
  key,
713
718
  icon: icon ? /* @__PURE__ */ React15.createElement("span", { className: props.iconsClassName }, icon) : null,
714
719
  children,
715
- label
720
+ label,
721
+ onClick: () => handleChange(item || { label, key })
716
722
  };
717
723
  }
718
724
  const items = props.items?.map((eachItem, index) => {
719
725
  return getItem(
720
726
  eachItem.label,
721
727
  index.toString(),
722
- eachItem.icon ? icons[eachItem.icon] || /* @__PURE__ */ React15.createElement("img", { src: eachItem.icon, alt: eachItem.label }) : "",
728
+ eachItem.icon ? icons[eachItem.icon] || /* @__PURE__ */ React15.createElement("img", { src: eachItem.icon }) : "",
729
+ eachItem,
723
730
  eachItem.items?.map(
724
731
  (child, childIndex) => getItem(
725
732
  child.label,
726
733
  `${index}-${childIndex}`,
727
- child.icon ? icons[child.icon] || /* @__PURE__ */ React15.createElement("img", { src: child.icon, alt: child.label }) : "",
734
+ eachItem.icon ? icons[eachItem.icon] || /* @__PURE__ */ React15.createElement("img", { src: eachItem.icon }) : "",
728
735
  void 0,
729
736
  child
730
737
  )
731
- ),
732
- eachItem
738
+ )
733
739
  );
734
740
  });
735
- const handleClick = (e) => {
736
- const clickedItem = props.items?.find(
737
- (item, index) => index.toString() === e.key
738
- );
739
- console.log("Clicked item:", clickedItem);
740
- };
741
741
  return /* @__PURE__ */ React15.createElement(Layout, { style: { minHeight: "100vh" } }, /* @__PURE__ */ React15.createElement(
742
742
  Sider,
743
743
  {
@@ -750,10 +750,9 @@ var Sidebar = (props) => {
750
750
  Menu,
751
751
  {
752
752
  theme: "dark",
753
- defaultSelectedKeys: ["0"],
753
+ defaultSelectedKeys: ["1"],
754
754
  mode: "inline",
755
- items,
756
- onClick: handleClick
755
+ items
757
756
  }
758
757
  )
759
758
  ));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@apexcura/ui-components",
3
- "version": "0.0.16-Beta38",
3
+ "version": "0.0.16-Beta39",
4
4
  "description": "Apex cura React components library",
5
5
  "keywords": [
6
6
  "apex cura",