@dmsi/wedgekit-react 0.0.563 → 0.0.565
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/components/NestedMenu.cjs +12 -13
- package/dist/components/NestedMenu.js +12 -13
- package/package.json +1 -1
|
@@ -886,7 +886,6 @@ Button.displayName = "Button";
|
|
|
886
886
|
// src/components/NestedMenu.tsx
|
|
887
887
|
var import_jsx_runtime8 = require("react/jsx-runtime");
|
|
888
888
|
function NestedMenu(props) {
|
|
889
|
-
var _a;
|
|
890
889
|
const { onMenuClick, currentMenu, testid } = props;
|
|
891
890
|
const [selectedIndex, setSelectedIndex] = (0, import_react6.useState)(0);
|
|
892
891
|
useKeydown(
|
|
@@ -900,26 +899,26 @@ function NestedMenu(props) {
|
|
|
900
899
|
},
|
|
901
900
|
ArrowDown: () => {
|
|
902
901
|
setSelectedIndex((prev) => {
|
|
903
|
-
var
|
|
904
|
-
const entriesLength = ((
|
|
902
|
+
var _a;
|
|
903
|
+
const entriesLength = ((_a = currentMenu.subEntries) == null ? void 0 : _a.length) || 0;
|
|
905
904
|
if (prev === entriesLength - 1) return 0;
|
|
906
905
|
return Math.min(prev + 1, (currentMenu.subEntries || []).length - 1);
|
|
907
906
|
});
|
|
908
907
|
},
|
|
909
908
|
// "Space" is replaced with " " to handle spacebar.
|
|
910
909
|
"Enter/Space": () => {
|
|
911
|
-
var
|
|
910
|
+
var _a;
|
|
912
911
|
const item = (currentMenu.subEntries || [])[selectedIndex];
|
|
913
912
|
handleMenuClick(
|
|
914
913
|
item || currentMenu.previousMenu,
|
|
915
914
|
!item && currentMenu.previousMenu !== null
|
|
916
915
|
);
|
|
917
|
-
if (!item && !((
|
|
916
|
+
if (!item && !((_a = currentMenu.previousMenu) == null ? void 0 : _a.previousMenu))
|
|
918
917
|
setSelectedIndex(0);
|
|
919
918
|
},
|
|
920
919
|
Backspace: () => {
|
|
921
|
-
var
|
|
922
|
-
handleMenuClick((
|
|
920
|
+
var _a, _b;
|
|
921
|
+
handleMenuClick((_a = currentMenu.previousMenu) != null ? _a : null, true);
|
|
923
922
|
if (!((_b = currentMenu.previousMenu) == null ? void 0 : _b.previousMenu)) setSelectedIndex(0);
|
|
924
923
|
}
|
|
925
924
|
},
|
|
@@ -945,30 +944,30 @@ function NestedMenu(props) {
|
|
|
945
944
|
}
|
|
946
945
|
),
|
|
947
946
|
onClick: () => {
|
|
948
|
-
var
|
|
949
|
-
return handleMenuClick((
|
|
947
|
+
var _a;
|
|
948
|
+
return handleMenuClick((_a = currentMenu.previousMenu) != null ? _a : null, true);
|
|
950
949
|
},
|
|
951
950
|
selected: selectedIndex === -1,
|
|
952
951
|
children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(Label, { color: "text-action-normal", children: currentMenu.previousMenu ? currentMenu.previousMenu.label : "Main Menu" })
|
|
953
952
|
}
|
|
954
953
|
),
|
|
955
|
-
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
954
|
+
currentMenu.title && /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
956
955
|
MenuOption,
|
|
957
956
|
{
|
|
958
957
|
variant: "action",
|
|
959
958
|
testid: testid ? `${testid}-title` : void 0,
|
|
960
|
-
children:
|
|
959
|
+
children: currentMenu.title
|
|
961
960
|
}
|
|
962
961
|
),
|
|
963
962
|
(currentMenu.subEntries || []).map((item, idx) => {
|
|
964
|
-
var
|
|
963
|
+
var _a;
|
|
965
964
|
return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
966
965
|
MenuOption,
|
|
967
966
|
{
|
|
968
967
|
testid: testid ? `${testid}-${item.label}` : void 0,
|
|
969
968
|
variant: "normal",
|
|
970
969
|
onClick: () => handleMenuClick(item),
|
|
971
|
-
after: ((
|
|
970
|
+
after: ((_a = item.subEntries) == null ? void 0 : _a.length) && /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
972
971
|
Button,
|
|
973
972
|
{
|
|
974
973
|
iconOnly: true,
|
|
@@ -29,7 +29,6 @@ import {
|
|
|
29
29
|
import { useState } from "react";
|
|
30
30
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
31
31
|
function NestedMenu(props) {
|
|
32
|
-
var _a;
|
|
33
32
|
const { onMenuClick, currentMenu, testid } = props;
|
|
34
33
|
const [selectedIndex, setSelectedIndex] = useState(0);
|
|
35
34
|
useKeydown(
|
|
@@ -43,26 +42,26 @@ function NestedMenu(props) {
|
|
|
43
42
|
},
|
|
44
43
|
ArrowDown: () => {
|
|
45
44
|
setSelectedIndex((prev) => {
|
|
46
|
-
var
|
|
47
|
-
const entriesLength = ((
|
|
45
|
+
var _a;
|
|
46
|
+
const entriesLength = ((_a = currentMenu.subEntries) == null ? void 0 : _a.length) || 0;
|
|
48
47
|
if (prev === entriesLength - 1) return 0;
|
|
49
48
|
return Math.min(prev + 1, (currentMenu.subEntries || []).length - 1);
|
|
50
49
|
});
|
|
51
50
|
},
|
|
52
51
|
// "Space" is replaced with " " to handle spacebar.
|
|
53
52
|
"Enter/Space": () => {
|
|
54
|
-
var
|
|
53
|
+
var _a;
|
|
55
54
|
const item = (currentMenu.subEntries || [])[selectedIndex];
|
|
56
55
|
handleMenuClick(
|
|
57
56
|
item || currentMenu.previousMenu,
|
|
58
57
|
!item && currentMenu.previousMenu !== null
|
|
59
58
|
);
|
|
60
|
-
if (!item && !((
|
|
59
|
+
if (!item && !((_a = currentMenu.previousMenu) == null ? void 0 : _a.previousMenu))
|
|
61
60
|
setSelectedIndex(0);
|
|
62
61
|
},
|
|
63
62
|
Backspace: () => {
|
|
64
|
-
var
|
|
65
|
-
handleMenuClick((
|
|
63
|
+
var _a, _b;
|
|
64
|
+
handleMenuClick((_a = currentMenu.previousMenu) != null ? _a : null, true);
|
|
66
65
|
if (!((_b = currentMenu.previousMenu) == null ? void 0 : _b.previousMenu)) setSelectedIndex(0);
|
|
67
66
|
}
|
|
68
67
|
},
|
|
@@ -88,30 +87,30 @@ function NestedMenu(props) {
|
|
|
88
87
|
}
|
|
89
88
|
),
|
|
90
89
|
onClick: () => {
|
|
91
|
-
var
|
|
92
|
-
return handleMenuClick((
|
|
90
|
+
var _a;
|
|
91
|
+
return handleMenuClick((_a = currentMenu.previousMenu) != null ? _a : null, true);
|
|
93
92
|
},
|
|
94
93
|
selected: selectedIndex === -1,
|
|
95
94
|
children: /* @__PURE__ */ jsx(Label, { color: "text-action-normal", children: currentMenu.previousMenu ? currentMenu.previousMenu.label : "Main Menu" })
|
|
96
95
|
}
|
|
97
96
|
),
|
|
98
|
-
/* @__PURE__ */ jsx(
|
|
97
|
+
currentMenu.title && /* @__PURE__ */ jsx(
|
|
99
98
|
MenuOption,
|
|
100
99
|
{
|
|
101
100
|
variant: "action",
|
|
102
101
|
testid: testid ? `${testid}-title` : void 0,
|
|
103
|
-
children:
|
|
102
|
+
children: currentMenu.title
|
|
104
103
|
}
|
|
105
104
|
),
|
|
106
105
|
(currentMenu.subEntries || []).map((item, idx) => {
|
|
107
|
-
var
|
|
106
|
+
var _a;
|
|
108
107
|
return /* @__PURE__ */ jsx(
|
|
109
108
|
MenuOption,
|
|
110
109
|
{
|
|
111
110
|
testid: testid ? `${testid}-${item.label}` : void 0,
|
|
112
111
|
variant: "normal",
|
|
113
112
|
onClick: () => handleMenuClick(item),
|
|
114
|
-
after: ((
|
|
113
|
+
after: ((_a = item.subEntries) == null ? void 0 : _a.length) && /* @__PURE__ */ jsx(
|
|
115
114
|
Button,
|
|
116
115
|
{
|
|
117
116
|
iconOnly: true,
|