@apexcura/ui-components 0.0.16-Beta51 → 0.0.16-Beta52
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 +12 -20
- package/dist/index.mjs +12 -20
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -778,21 +778,22 @@ 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 [
|
|
782
|
-
const handleChange = (item,
|
|
783
|
-
|
|
781
|
+
const [selectedPath, setSelectedPath] = (0, import_react16.useState)([]);
|
|
782
|
+
const handleChange = (item, keyPath) => {
|
|
783
|
+
setSelectedPath(keyPath);
|
|
784
784
|
if (props.onChange) {
|
|
785
785
|
props.onChange(item);
|
|
786
786
|
}
|
|
787
787
|
};
|
|
788
|
-
function getItem(label, key, icon, children, item
|
|
788
|
+
function getItem(label, key, icon, children, item) {
|
|
789
|
+
const isSelected = selectedPath.includes(key.toString());
|
|
789
790
|
return {
|
|
790
791
|
key,
|
|
791
792
|
icon: icon ? /* @__PURE__ */ import_react16.default.createElement(
|
|
792
793
|
"span",
|
|
793
794
|
{
|
|
794
795
|
className: props.iconsClassName,
|
|
795
|
-
style:
|
|
796
|
+
style: isSelected ? {
|
|
796
797
|
filter: "brightness(0) saturate(100%) invert(22%) sepia(87%) saturate(7476%) hue-rotate(209deg) brightness(97%) contrast(107%)"
|
|
797
798
|
} : {}
|
|
798
799
|
},
|
|
@@ -800,21 +801,19 @@ var Sidebar = (props) => {
|
|
|
800
801
|
) : null,
|
|
801
802
|
children,
|
|
802
803
|
label,
|
|
803
|
-
onClick: children ? void 0 : () => handleChange(item,
|
|
804
|
-
// Only set onClick for leaf nodes
|
|
804
|
+
onClick: children ? void 0 : () => handleChange(item, key.toString().split("-"))
|
|
805
805
|
};
|
|
806
806
|
}
|
|
807
|
-
function mapItems(items2,
|
|
807
|
+
function mapItems(items2, parentKey = "") {
|
|
808
808
|
return items2.map((eachItem, index) => {
|
|
809
|
-
const key =
|
|
809
|
+
const key = parentKey ? `${parentKey}-${index}` : index.toString();
|
|
810
810
|
const childItems = eachItem.items ? mapItems(eachItem.items, key) : void 0;
|
|
811
811
|
return getItem(
|
|
812
812
|
eachItem.label,
|
|
813
|
-
key
|
|
813
|
+
key,
|
|
814
814
|
eachItem.icon ? icons[eachItem.icon] || /* @__PURE__ */ import_react16.default.createElement("img", { src: eachItem.icon, alt: "" }) : null,
|
|
815
815
|
childItems,
|
|
816
|
-
eachItem
|
|
817
|
-
key
|
|
816
|
+
eachItem
|
|
818
817
|
);
|
|
819
818
|
});
|
|
820
819
|
}
|
|
@@ -829,14 +828,7 @@ var Sidebar = (props) => {
|
|
|
829
828
|
},
|
|
830
829
|
/* @__PURE__ */ import_react16.default.createElement("div", { className: "demo-logo-vertical" }),
|
|
831
830
|
/* @__PURE__ */ import_react16.default.createElement("img", { src: props.img, alt: "", className: props.imgClassName }),
|
|
832
|
-
/* @__PURE__ */ import_react16.default.createElement(
|
|
833
|
-
import_antd11.Menu,
|
|
834
|
-
{
|
|
835
|
-
mode: "inline",
|
|
836
|
-
items,
|
|
837
|
-
selectedKeys: selectedKeys.map((key) => key.split("-").pop())
|
|
838
|
-
}
|
|
839
|
-
)
|
|
831
|
+
/* @__PURE__ */ import_react16.default.createElement(import_antd11.Menu, { mode: "inline", items, selectedKeys: [selectedPath[selectedPath.length - 1] || ""] })
|
|
840
832
|
));
|
|
841
833
|
};
|
|
842
834
|
|
package/dist/index.mjs
CHANGED
|
@@ -707,21 +707,22 @@ import { Layout, Menu } from "antd";
|
|
|
707
707
|
var { Sider } = Layout;
|
|
708
708
|
var Sidebar = (props) => {
|
|
709
709
|
const [collapsed, setCollapsed] = useState5(false);
|
|
710
|
-
const [
|
|
711
|
-
const handleChange = (item,
|
|
712
|
-
|
|
710
|
+
const [selectedPath, setSelectedPath] = useState5([]);
|
|
711
|
+
const handleChange = (item, keyPath) => {
|
|
712
|
+
setSelectedPath(keyPath);
|
|
713
713
|
if (props.onChange) {
|
|
714
714
|
props.onChange(item);
|
|
715
715
|
}
|
|
716
716
|
};
|
|
717
|
-
function getItem(label, key, icon, children, item
|
|
717
|
+
function getItem(label, key, icon, children, item) {
|
|
718
|
+
const isSelected = selectedPath.includes(key.toString());
|
|
718
719
|
return {
|
|
719
720
|
key,
|
|
720
721
|
icon: icon ? /* @__PURE__ */ React15.createElement(
|
|
721
722
|
"span",
|
|
722
723
|
{
|
|
723
724
|
className: props.iconsClassName,
|
|
724
|
-
style:
|
|
725
|
+
style: isSelected ? {
|
|
725
726
|
filter: "brightness(0) saturate(100%) invert(22%) sepia(87%) saturate(7476%) hue-rotate(209deg) brightness(97%) contrast(107%)"
|
|
726
727
|
} : {}
|
|
727
728
|
},
|
|
@@ -729,21 +730,19 @@ var Sidebar = (props) => {
|
|
|
729
730
|
) : null,
|
|
730
731
|
children,
|
|
731
732
|
label,
|
|
732
|
-
onClick: children ? void 0 : () => handleChange(item,
|
|
733
|
-
// Only set onClick for leaf nodes
|
|
733
|
+
onClick: children ? void 0 : () => handleChange(item, key.toString().split("-"))
|
|
734
734
|
};
|
|
735
735
|
}
|
|
736
|
-
function mapItems(items2,
|
|
736
|
+
function mapItems(items2, parentKey = "") {
|
|
737
737
|
return items2.map((eachItem, index) => {
|
|
738
|
-
const key =
|
|
738
|
+
const key = parentKey ? `${parentKey}-${index}` : index.toString();
|
|
739
739
|
const childItems = eachItem.items ? mapItems(eachItem.items, key) : void 0;
|
|
740
740
|
return getItem(
|
|
741
741
|
eachItem.label,
|
|
742
|
-
key
|
|
742
|
+
key,
|
|
743
743
|
eachItem.icon ? icons[eachItem.icon] || /* @__PURE__ */ React15.createElement("img", { src: eachItem.icon, alt: "" }) : null,
|
|
744
744
|
childItems,
|
|
745
|
-
eachItem
|
|
746
|
-
key
|
|
745
|
+
eachItem
|
|
747
746
|
);
|
|
748
747
|
});
|
|
749
748
|
}
|
|
@@ -758,14 +757,7 @@ var Sidebar = (props) => {
|
|
|
758
757
|
},
|
|
759
758
|
/* @__PURE__ */ React15.createElement("div", { className: "demo-logo-vertical" }),
|
|
760
759
|
/* @__PURE__ */ React15.createElement("img", { src: props.img, alt: "", className: props.imgClassName }),
|
|
761
|
-
/* @__PURE__ */ React15.createElement(
|
|
762
|
-
Menu,
|
|
763
|
-
{
|
|
764
|
-
mode: "inline",
|
|
765
|
-
items,
|
|
766
|
-
selectedKeys: selectedKeys.map((key) => key.split("-").pop())
|
|
767
|
-
}
|
|
768
|
-
)
|
|
760
|
+
/* @__PURE__ */ React15.createElement(Menu, { mode: "inline", items, selectedKeys: [selectedPath[selectedPath.length - 1] || ""] })
|
|
769
761
|
));
|
|
770
762
|
};
|
|
771
763
|
|