@dmsi/wedgekit-react 0.0.1016 → 0.0.1018
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 +267 -21
- package/dist/components/NestedMenu.js +34 -11
- package/package.json +1 -1
|
@@ -914,11 +914,256 @@ var Button = (_a) => {
|
|
|
914
914
|
};
|
|
915
915
|
Button.displayName = "Button";
|
|
916
916
|
|
|
917
|
-
// src/components/
|
|
917
|
+
// src/components/Stack.tsx
|
|
918
|
+
var import_clsx8 = __toESM(require("clsx"), 1);
|
|
918
919
|
var import_jsx_runtime8 = require("react/jsx-runtime");
|
|
920
|
+
var getFlexClassNames = ({ items, justify, grow }) => (0, import_clsx8.default)(
|
|
921
|
+
"flex",
|
|
922
|
+
items === "start" && "items-start",
|
|
923
|
+
grow && "grow",
|
|
924
|
+
items === "start" && "items-start",
|
|
925
|
+
items === "center" && "items-center",
|
|
926
|
+
items === "end" && "items-end",
|
|
927
|
+
items === "start-center" && "items-start desktop:items-center",
|
|
928
|
+
justify === "start" && "justify-start",
|
|
929
|
+
justify === "center" && "justify-center",
|
|
930
|
+
justify === "end" && "justify-end",
|
|
931
|
+
justify === "end" && "justify-end",
|
|
932
|
+
justify === "between" && "justify-between",
|
|
933
|
+
justify === "around" && "justify-around"
|
|
934
|
+
);
|
|
935
|
+
var useGapClassNames = (sizing) => {
|
|
936
|
+
return (0, import_clsx8.default)(
|
|
937
|
+
sizing === "layout-group" && "gap-mobile-layout-group-gap desktop:gap-desktop-layout-group-gap compact:gap-compact-layout-group-gap",
|
|
938
|
+
sizing === "layout" && "gap-mobile-layout-gap desktop:gap-desktop-layout-gap compact:gap-compact-layout-gap",
|
|
939
|
+
sizing === "container" && "gap-mobile-container-gap desktop:gap-desktop-container-gap compact:gap-compact-container-gap",
|
|
940
|
+
sizing === "component" && "gap-mobile-component-gap desktop:gap-desktop-component-gap compact:gap-compact-component-gap"
|
|
941
|
+
);
|
|
942
|
+
};
|
|
943
|
+
var Stack = (_a) => {
|
|
944
|
+
var _b = _a, {
|
|
945
|
+
children,
|
|
946
|
+
items,
|
|
947
|
+
justify,
|
|
948
|
+
grow,
|
|
949
|
+
padding,
|
|
950
|
+
paddingX,
|
|
951
|
+
paddingY,
|
|
952
|
+
paddingBottom,
|
|
953
|
+
paddingTop,
|
|
954
|
+
paddingLeft,
|
|
955
|
+
paddingRight,
|
|
956
|
+
margin,
|
|
957
|
+
marginX,
|
|
958
|
+
marginY,
|
|
959
|
+
horizontal,
|
|
960
|
+
horizontalMobile,
|
|
961
|
+
elevation = 0,
|
|
962
|
+
rounded,
|
|
963
|
+
centered,
|
|
964
|
+
width,
|
|
965
|
+
minHeight,
|
|
966
|
+
maxWidth,
|
|
967
|
+
minWidth,
|
|
968
|
+
height,
|
|
969
|
+
maxHeight,
|
|
970
|
+
borderColor,
|
|
971
|
+
borderTopColor,
|
|
972
|
+
borderRightColor,
|
|
973
|
+
borderBottomColor,
|
|
974
|
+
borderLeftColor,
|
|
975
|
+
backgroundColor,
|
|
976
|
+
sizing = "none",
|
|
977
|
+
overflowY = "inherit",
|
|
978
|
+
overflowX = "inherit",
|
|
979
|
+
flexShrink,
|
|
980
|
+
flexGrow,
|
|
981
|
+
position,
|
|
982
|
+
top,
|
|
983
|
+
left,
|
|
984
|
+
id,
|
|
985
|
+
noGap,
|
|
986
|
+
marginTop,
|
|
987
|
+
marginBottom,
|
|
988
|
+
testid,
|
|
989
|
+
bottom,
|
|
990
|
+
zIndex,
|
|
991
|
+
flexWrap,
|
|
992
|
+
className,
|
|
993
|
+
unclipEdges
|
|
994
|
+
} = _b, props = __objRest(_b, [
|
|
995
|
+
"children",
|
|
996
|
+
"items",
|
|
997
|
+
"justify",
|
|
998
|
+
"grow",
|
|
999
|
+
"padding",
|
|
1000
|
+
"paddingX",
|
|
1001
|
+
"paddingY",
|
|
1002
|
+
"paddingBottom",
|
|
1003
|
+
"paddingTop",
|
|
1004
|
+
"paddingLeft",
|
|
1005
|
+
"paddingRight",
|
|
1006
|
+
"margin",
|
|
1007
|
+
"marginX",
|
|
1008
|
+
"marginY",
|
|
1009
|
+
"horizontal",
|
|
1010
|
+
"horizontalMobile",
|
|
1011
|
+
"elevation",
|
|
1012
|
+
"rounded",
|
|
1013
|
+
"centered",
|
|
1014
|
+
"width",
|
|
1015
|
+
"minHeight",
|
|
1016
|
+
"maxWidth",
|
|
1017
|
+
"minWidth",
|
|
1018
|
+
"height",
|
|
1019
|
+
"maxHeight",
|
|
1020
|
+
"borderColor",
|
|
1021
|
+
"borderTopColor",
|
|
1022
|
+
"borderRightColor",
|
|
1023
|
+
"borderBottomColor",
|
|
1024
|
+
"borderLeftColor",
|
|
1025
|
+
"backgroundColor",
|
|
1026
|
+
"sizing",
|
|
1027
|
+
"overflowY",
|
|
1028
|
+
"overflowX",
|
|
1029
|
+
"flexShrink",
|
|
1030
|
+
"flexGrow",
|
|
1031
|
+
"position",
|
|
1032
|
+
"top",
|
|
1033
|
+
"left",
|
|
1034
|
+
"id",
|
|
1035
|
+
"noGap",
|
|
1036
|
+
"marginTop",
|
|
1037
|
+
"marginBottom",
|
|
1038
|
+
"testid",
|
|
1039
|
+
"bottom",
|
|
1040
|
+
"zIndex",
|
|
1041
|
+
"flexWrap",
|
|
1042
|
+
"className",
|
|
1043
|
+
"unclipEdges"
|
|
1044
|
+
]);
|
|
1045
|
+
var _a2, _b2, _c, _d, _e, _f, _g;
|
|
1046
|
+
const flexClassNames = getFlexClassNames({ items, justify, grow });
|
|
1047
|
+
const gapClassNames = useGapClassNames(sizing);
|
|
1048
|
+
return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
1049
|
+
"div",
|
|
1050
|
+
__spreadProps(__spreadValues({
|
|
1051
|
+
id,
|
|
1052
|
+
"data-testid": testid
|
|
1053
|
+
}, props), {
|
|
1054
|
+
style: __spreadValues({
|
|
1055
|
+
height: height === "full" ? "100%" : height === void 0 ? void 0 : height === "fit" ? "fit-content" : `${height}px`,
|
|
1056
|
+
maxHeight: maxHeight !== void 0 ? isNaN(+maxHeight) ? maxHeight : `${maxHeight}px` : (_a2 = props.style) == null ? void 0 : _a2.maxHeight,
|
|
1057
|
+
maxWidth: maxWidth !== void 0 ? isNaN(+maxWidth) ? maxWidth : `${maxWidth}px` : (_b2 = props.style) == null ? void 0 : _b2.maxWidth,
|
|
1058
|
+
minHeight: minHeight !== void 0 ? isNaN(+minHeight) ? minHeight : `${minHeight}px` : (_c = props.style) == null ? void 0 : _c.minHeight,
|
|
1059
|
+
width: width !== void 0 && typeof width === "number" ? `${width}px` : void 0,
|
|
1060
|
+
minWidth: minWidth !== void 0 ? `${minWidth}px` : void 0,
|
|
1061
|
+
border: borderColor ? `1px solid var(--color-${borderColor})` : void 0,
|
|
1062
|
+
borderTop: borderTopColor ? `1px solid var(--color-${borderTopColor})` : void 0,
|
|
1063
|
+
borderRight: borderRightColor ? `1px solid var(--color-${borderRightColor})` : void 0,
|
|
1064
|
+
borderBottom: borderBottomColor ? `1px solid var(--color-${borderBottomColor})` : void 0,
|
|
1065
|
+
borderLeft: borderLeftColor ? `1px solid var(--color-${borderLeftColor})` : void 0,
|
|
1066
|
+
backgroundColor: backgroundColor ? `var(--color-${backgroundColor})` : void 0,
|
|
1067
|
+
flexGrow: flexGrow !== void 0 ? flexGrow : void 0,
|
|
1068
|
+
flexShrink: flexShrink !== void 0 ? flexShrink : void 0,
|
|
1069
|
+
position: position !== void 0 ? position : void 0,
|
|
1070
|
+
top: top !== void 0 ? `${top}px` : void 0,
|
|
1071
|
+
bottom: bottom !== void 0 ? `${bottom}px` : void 0,
|
|
1072
|
+
left: left !== void 0 ? `${left}px` : void 0,
|
|
1073
|
+
borderBlock: (_d = props.style) == null ? void 0 : _d.borderBlock,
|
|
1074
|
+
marginInline: (_e = props.style) == null ? void 0 : _e.marginInline,
|
|
1075
|
+
zIndex: zIndex !== void 0 ? zIndex : void 0,
|
|
1076
|
+
flexWrap,
|
|
1077
|
+
paddingInline: (_f = props.style) == null ? void 0 : _f.paddingInline,
|
|
1078
|
+
gap: (_g = props.style) == null ? void 0 : _g.gap
|
|
1079
|
+
}, props.style),
|
|
1080
|
+
className: (0, import_clsx8.default)(
|
|
1081
|
+
"scrollbar-thin",
|
|
1082
|
+
"max-w-screen",
|
|
1083
|
+
width !== "fit" && "w-full",
|
|
1084
|
+
width === "full" && "w-full",
|
|
1085
|
+
width === "max" && "w-max",
|
|
1086
|
+
centered && "mx-auto",
|
|
1087
|
+
overflowY == "auto" && "overflow-y-auto",
|
|
1088
|
+
overflowY == "hidden" && "overflow-y-hidden",
|
|
1089
|
+
overflowY == "scroll" && "overflow-y-scroll",
|
|
1090
|
+
overflowX == "auto" && "overflow-x-auto",
|
|
1091
|
+
overflowX == "hidden" && "overflow-x-hidden",
|
|
1092
|
+
overflowX == "scroll" && "overflow-x-scroll",
|
|
1093
|
+
padding && sizing === "container" && "p-mobile-container-padding desktop:p-desktop-container-padding compact:p-desktop-compact-container-padding",
|
|
1094
|
+
padding && sizing === "layout" && "p-mobile-layout-padding desktop:p-desktop-layout-padding compact:p-desktop-compact-layout-padding",
|
|
1095
|
+
padding && sizing === "layout-group" && "p-mobile-layout-group-padding desktop:p-desktop-layout-group-padding compact:p-desktop-compact-layout-group-padding",
|
|
1096
|
+
padding && sizing === "component" && "p-mobile-component-padding desktop:p-desktop-component-padding compact:p-desktop-compact-component-padding",
|
|
1097
|
+
paddingX && sizing === "container" && "px-mobile-container-padding desktop:px-desktop-container-padding compact:px-desktop-compact-container-padding",
|
|
1098
|
+
paddingX && sizing === "layout" && "px-mobile-layout-padding desktop:px-desktop-layout-padding compact:px-desktop-compact-layout-padding",
|
|
1099
|
+
paddingX && sizing === "layout-group" && "px-mobile-layout-group-padding desktop:px-desktop-layout-group-padding compact:px-desktop-compact-layout-group-padding",
|
|
1100
|
+
paddingX && sizing === "component" && "px-mobile-component-padding desktop:px-desktop-component-padding compact:px-desktop-compact-component-padding",
|
|
1101
|
+
paddingY && sizing === "container" && "py-mobile-container-padding desktop:py-desktop-container-padding compact:py-desktop-compact-container-padding",
|
|
1102
|
+
paddingY && sizing === "layout" && "py-mobile-layout-padding desktop:py-desktop-layout-padding compact:py-desktop-compact-layout-padding",
|
|
1103
|
+
paddingY && sizing === "layout-group" && paddingYUsingLayoutGroupGap,
|
|
1104
|
+
paddingY && sizing === "component" && "py-mobile-component-padding desktop:py-desktop-component-padding compact:py-desktop-compact-component-padding",
|
|
1105
|
+
paddingBottom && sizing === "container" && "pb-mobile-container-padding desktop:pb-desktop-container-padding compact:pb-desktop-compact-container-padding",
|
|
1106
|
+
paddingBottom && sizing === "layout" && "pb-mobile-layout-padding desktop:pb-desktop-layout-padding compact:pb-desktop-compact-layout-padding",
|
|
1107
|
+
paddingBottom && sizing === "layout-group" && "pb-mobile-layout-group-padding desktop:pb-desktop-layout-group-padding compact:pb-desktop-compact-layout-group-padding",
|
|
1108
|
+
paddingBottom && sizing === "component" && "pb-mobile-component-padding desktop:pb-desktop-component-padding compact:pb-desktop-compact-component-padding",
|
|
1109
|
+
paddingTop && sizing === "container" && "pt-mobile-container-padding desktop:pt-desktop-container-padding compact:pt-desktop-compact-container-padding",
|
|
1110
|
+
paddingTop && sizing === "layout" && "pt-mobile-layout-padding desktop:pt-desktop-layout-padding compact:pt-desktop-compact-layout-padding",
|
|
1111
|
+
paddingTop && sizing === "layout-group" && "pt-mobile-layout-group-padding desktop:pt-desktop-layout-group-padding compact:pt-desktop-compact-layout-group-padding",
|
|
1112
|
+
paddingTop && sizing === "component" && "pt-mobile-component-padding desktop:pt-desktop-component-padding compact:pt-desktop-compact-component-padding",
|
|
1113
|
+
paddingLeft && sizing === "container" && "pl-mobile-container-padding desktop:pl-desktop-container-padding compact:pl-desktop-compact-container-padding",
|
|
1114
|
+
paddingLeft && sizing === "layout" && "pl-mobile-layout-padding desktop:pl-desktop-layout-padding compact:pl-desktop-compact-layout-padding",
|
|
1115
|
+
paddingLeft && sizing === "layout-group" && "pl-mobile-layout-group-padding desktop:pl-desktop-layout-group-padding compact:pl-desktop-compact-layout-group-padding",
|
|
1116
|
+
paddingLeft && sizing === "component" && "pl-mobile-component-padding desktop:pl-desktop-component-padding compact:pl-desktop-compact-component-padding",
|
|
1117
|
+
paddingRight && sizing === "container" && "pr-mobile-container-padding desktop:pr-desktop-container-padding compact:pr-desktop-compact-container-padding",
|
|
1118
|
+
paddingRight && sizing === "layout" && "pr-mobile-layout-padding desktop:pr-desktop-layout-padding compact:pr-desktop-compact-layout-padding",
|
|
1119
|
+
paddingRight && sizing === "layout-group" && "pr-mobile-layout-group-padding desktop:pr-desktop-layout-group-padding compact:pr-desktop-compact-layout-group-padding",
|
|
1120
|
+
paddingRight && sizing === "component" && "pr-mobile-component-padding desktop:pr-desktop-component-padding compact:pr-desktop-compact-component-padding",
|
|
1121
|
+
margin && sizing === "container" && "m-mobile-container-padding desktop:m-desktop-container-padding compact:m-compact-container-padding",
|
|
1122
|
+
marginX && sizing === "container" && "mx-mobile-container-padding desktop:mx-desktop-container-padding compact:mx-compact-container-padding",
|
|
1123
|
+
marginTop && sizing === "container" && "mt-mobile-container-padding desktop:mt-desktop-container-padding compact:mt-compact-container-padding",
|
|
1124
|
+
marginBottom && sizing === "container" && "mb-mobile-container-padding desktop:mb-desktop-container-padding compact:mb-compact-container-padding",
|
|
1125
|
+
marginY && sizing === "container" && "my-mobile-container-padding desktop:my-desktop-container-padding compact:my-compact-container-padding",
|
|
1126
|
+
horizontal ? "desktop:flex-row" : "desktop:flex-col",
|
|
1127
|
+
horizontalMobile ? "flex-row" : "flex-col",
|
|
1128
|
+
flexClassNames,
|
|
1129
|
+
!noGap && gapClassNames,
|
|
1130
|
+
elevation === 0 && "shadow-none",
|
|
1131
|
+
elevation === 2 && "shadow-2",
|
|
1132
|
+
elevation === 4 && "shadow-4",
|
|
1133
|
+
elevation === 16 && "shadow-16",
|
|
1134
|
+
rounded && "rounded",
|
|
1135
|
+
unclipEdges && "-m-0.75 p-1",
|
|
1136
|
+
className
|
|
1137
|
+
),
|
|
1138
|
+
children
|
|
1139
|
+
})
|
|
1140
|
+
);
|
|
1141
|
+
};
|
|
1142
|
+
|
|
1143
|
+
// src/components/NestedMenu.tsx
|
|
1144
|
+
var import_jsx_runtime9 = require("react/jsx-runtime");
|
|
919
1145
|
function NestedMenu(props) {
|
|
920
|
-
const {
|
|
1146
|
+
const {
|
|
1147
|
+
onMenuClick,
|
|
1148
|
+
currentMenu,
|
|
1149
|
+
testid,
|
|
1150
|
+
shopAllUrl,
|
|
1151
|
+
shopAllLinkLabel,
|
|
1152
|
+
isQuoteMode = false
|
|
1153
|
+
} = props;
|
|
921
1154
|
const [selectedIndex, setSelectedIndex] = (0, import_react7.useState)(0);
|
|
1155
|
+
const normalizedShopAllUrl = shopAllUrl == null ? void 0 : shopAllUrl.trim();
|
|
1156
|
+
const hasTopLevelShopAllOption = Boolean(normalizedShopAllUrl) && currentMenu.previousMenu == null && !isQuoteMode;
|
|
1157
|
+
const menuItems = [
|
|
1158
|
+
...hasTopLevelShopAllOption ? [
|
|
1159
|
+
{
|
|
1160
|
+
id: "shop-all-top",
|
|
1161
|
+
label: (shopAllLinkLabel == null ? void 0 : shopAllLinkLabel.trim()) || "Shop All",
|
|
1162
|
+
url: normalizedShopAllUrl
|
|
1163
|
+
}
|
|
1164
|
+
] : [],
|
|
1165
|
+
...currentMenu.subEntries || []
|
|
1166
|
+
];
|
|
922
1167
|
useKeydown(
|
|
923
1168
|
{
|
|
924
1169
|
Escape: () => {
|
|
@@ -930,19 +1175,19 @@ function NestedMenu(props) {
|
|
|
930
1175
|
},
|
|
931
1176
|
ArrowDown: () => {
|
|
932
1177
|
setSelectedIndex((prev) => {
|
|
933
|
-
|
|
934
|
-
const entriesLength = ((_a = currentMenu.subEntries) == null ? void 0 : _a.length) || 0;
|
|
1178
|
+
const entriesLength = menuItems.length;
|
|
935
1179
|
if (prev === entriesLength - 1) return 0;
|
|
936
|
-
return Math.min(prev + 1,
|
|
1180
|
+
return Math.min(prev + 1, menuItems.length - 1);
|
|
937
1181
|
});
|
|
938
1182
|
},
|
|
939
1183
|
// "Space" is replaced with " " to handle spacebar.
|
|
940
1184
|
"Enter/Space": () => {
|
|
941
1185
|
var _a;
|
|
942
|
-
const item =
|
|
1186
|
+
const item = menuItems[selectedIndex];
|
|
943
1187
|
handleMenuClick(
|
|
944
1188
|
item || currentMenu.previousMenu,
|
|
945
|
-
!item && currentMenu.previousMenu !== null
|
|
1189
|
+
!item && currentMenu.previousMenu !== null,
|
|
1190
|
+
(item == null ? void 0 : item.url) ? "url" : void 0
|
|
946
1191
|
);
|
|
947
1192
|
if (!item && !((_a = currentMenu.previousMenu) == null ? void 0 : _a.previousMenu))
|
|
948
1193
|
setSelectedIndex(0);
|
|
@@ -955,18 +1200,19 @@ function NestedMenu(props) {
|
|
|
955
1200
|
},
|
|
956
1201
|
true
|
|
957
1202
|
);
|
|
958
|
-
function handleMenuClick(item, isPrevious = false) {
|
|
1203
|
+
function handleMenuClick(item, isPrevious = false, action) {
|
|
959
1204
|
onMenuClick(
|
|
960
|
-
item && __spreadValues(__spreadValues({}, item), !isPrevious && { previousMenu: currentMenu })
|
|
1205
|
+
item && __spreadValues(__spreadValues({}, item), !isPrevious && { previousMenu: currentMenu }),
|
|
1206
|
+
action
|
|
961
1207
|
);
|
|
962
1208
|
}
|
|
963
|
-
return /* @__PURE__ */ (0,
|
|
964
|
-
!currentMenu.removeBackOption && /* @__PURE__ */ (0,
|
|
1209
|
+
return /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { className: "flex flex-col w-full", children: [
|
|
1210
|
+
!currentMenu.removeBackOption && /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
|
965
1211
|
MenuOption,
|
|
966
1212
|
{
|
|
967
1213
|
testid: testid ? `${testid}-back` : void 0,
|
|
968
1214
|
variant: "normal",
|
|
969
|
-
before: /* @__PURE__ */ (0,
|
|
1215
|
+
before: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
|
970
1216
|
Icon,
|
|
971
1217
|
{
|
|
972
1218
|
name: "chevron_left",
|
|
@@ -979,10 +1225,10 @@ function NestedMenu(props) {
|
|
|
979
1225
|
return handleMenuClick((_a = currentMenu.previousMenu) != null ? _a : null, true);
|
|
980
1226
|
},
|
|
981
1227
|
selected: selectedIndex === -1,
|
|
982
|
-
children: /* @__PURE__ */ (0,
|
|
1228
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(Label, { color: "text-action-normal", children: currentMenu.previousMenu ? currentMenu.previousMenu.label : "Main Menu" })
|
|
983
1229
|
}
|
|
984
1230
|
),
|
|
985
|
-
currentMenu.title && /* @__PURE__ */ (0,
|
|
1231
|
+
currentMenu.title && /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
|
986
1232
|
MenuOption,
|
|
987
1233
|
{
|
|
988
1234
|
variant: "action",
|
|
@@ -990,16 +1236,16 @@ function NestedMenu(props) {
|
|
|
990
1236
|
children: currentMenu.title
|
|
991
1237
|
}
|
|
992
1238
|
),
|
|
993
|
-
|
|
1239
|
+
menuItems.map((item, idx) => {
|
|
994
1240
|
var _a;
|
|
995
1241
|
if (item.children == null) {
|
|
996
|
-
return /* @__PURE__ */ (0,
|
|
1242
|
+
return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
|
997
1243
|
MenuOption,
|
|
998
1244
|
{
|
|
999
1245
|
testid: testid ? `${testid}-${item.label}` : void 0,
|
|
1000
1246
|
variant: "normal",
|
|
1001
|
-
onClick: () => handleMenuClick(item),
|
|
1002
|
-
after: ((_a = item.subEntries) == null ? void 0 : _a.length) && /* @__PURE__ */ (0,
|
|
1247
|
+
onClick: () => handleMenuClick(item, false, item.url ? "url" : void 0),
|
|
1248
|
+
after: ((_a = item.subEntries) == null ? void 0 : _a.length) && /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
|
1003
1249
|
Button,
|
|
1004
1250
|
{
|
|
1005
1251
|
iconOnly: true,
|
|
@@ -1010,16 +1256,16 @@ function NestedMenu(props) {
|
|
|
1010
1256
|
onMenuClick(item, "subEntry");
|
|
1011
1257
|
},
|
|
1012
1258
|
className: "!p-0 w-full justify-end",
|
|
1013
|
-
leftIcon: /* @__PURE__ */ (0,
|
|
1259
|
+
leftIcon: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(Icon, { name: "chevron_right", className: "icon", size: 24 })
|
|
1014
1260
|
}
|
|
1015
1261
|
),
|
|
1016
1262
|
selected: selectedIndex === idx,
|
|
1017
|
-
children: item.label
|
|
1263
|
+
children: item.id === "shop-all-top" ? /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(Stack, { minHeight: 24, justify: "center", children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(Label, { color: "text-action-normal", padded: true, children: item.label }) }) : item.label
|
|
1018
1264
|
},
|
|
1019
1265
|
item.id
|
|
1020
1266
|
);
|
|
1021
1267
|
}
|
|
1022
|
-
return /* @__PURE__ */ (0,
|
|
1268
|
+
return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_react7.default.Fragment, { children: item.children }, item.id);
|
|
1023
1269
|
})
|
|
1024
1270
|
] });
|
|
1025
1271
|
}
|
|
@@ -17,6 +17,9 @@ import {
|
|
|
17
17
|
Button
|
|
18
18
|
} from "../chunk-ZMTHWJ7F.js";
|
|
19
19
|
import "../chunk-SBRRNFOP.js";
|
|
20
|
+
import {
|
|
21
|
+
Stack
|
|
22
|
+
} from "../chunk-BGBIXG5Y.js";
|
|
20
23
|
import "../chunk-WMPWWFUJ.js";
|
|
21
24
|
import {
|
|
22
25
|
Icon
|
|
@@ -30,8 +33,27 @@ import {
|
|
|
30
33
|
import React, { useState } from "react";
|
|
31
34
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
32
35
|
function NestedMenu(props) {
|
|
33
|
-
const {
|
|
36
|
+
const {
|
|
37
|
+
onMenuClick,
|
|
38
|
+
currentMenu,
|
|
39
|
+
testid,
|
|
40
|
+
shopAllUrl,
|
|
41
|
+
shopAllLinkLabel,
|
|
42
|
+
isQuoteMode = false
|
|
43
|
+
} = props;
|
|
34
44
|
const [selectedIndex, setSelectedIndex] = useState(0);
|
|
45
|
+
const normalizedShopAllUrl = shopAllUrl == null ? void 0 : shopAllUrl.trim();
|
|
46
|
+
const hasTopLevelShopAllOption = Boolean(normalizedShopAllUrl) && currentMenu.previousMenu == null && !isQuoteMode;
|
|
47
|
+
const menuItems = [
|
|
48
|
+
...hasTopLevelShopAllOption ? [
|
|
49
|
+
{
|
|
50
|
+
id: "shop-all-top",
|
|
51
|
+
label: (shopAllLinkLabel == null ? void 0 : shopAllLinkLabel.trim()) || "Shop All",
|
|
52
|
+
url: normalizedShopAllUrl
|
|
53
|
+
}
|
|
54
|
+
] : [],
|
|
55
|
+
...currentMenu.subEntries || []
|
|
56
|
+
];
|
|
35
57
|
useKeydown(
|
|
36
58
|
{
|
|
37
59
|
Escape: () => {
|
|
@@ -43,19 +65,19 @@ function NestedMenu(props) {
|
|
|
43
65
|
},
|
|
44
66
|
ArrowDown: () => {
|
|
45
67
|
setSelectedIndex((prev) => {
|
|
46
|
-
|
|
47
|
-
const entriesLength = ((_a = currentMenu.subEntries) == null ? void 0 : _a.length) || 0;
|
|
68
|
+
const entriesLength = menuItems.length;
|
|
48
69
|
if (prev === entriesLength - 1) return 0;
|
|
49
|
-
return Math.min(prev + 1,
|
|
70
|
+
return Math.min(prev + 1, menuItems.length - 1);
|
|
50
71
|
});
|
|
51
72
|
},
|
|
52
73
|
// "Space" is replaced with " " to handle spacebar.
|
|
53
74
|
"Enter/Space": () => {
|
|
54
75
|
var _a;
|
|
55
|
-
const item =
|
|
76
|
+
const item = menuItems[selectedIndex];
|
|
56
77
|
handleMenuClick(
|
|
57
78
|
item || currentMenu.previousMenu,
|
|
58
|
-
!item && currentMenu.previousMenu !== null
|
|
79
|
+
!item && currentMenu.previousMenu !== null,
|
|
80
|
+
(item == null ? void 0 : item.url) ? "url" : void 0
|
|
59
81
|
);
|
|
60
82
|
if (!item && !((_a = currentMenu.previousMenu) == null ? void 0 : _a.previousMenu))
|
|
61
83
|
setSelectedIndex(0);
|
|
@@ -68,9 +90,10 @@ function NestedMenu(props) {
|
|
|
68
90
|
},
|
|
69
91
|
true
|
|
70
92
|
);
|
|
71
|
-
function handleMenuClick(item, isPrevious = false) {
|
|
93
|
+
function handleMenuClick(item, isPrevious = false, action) {
|
|
72
94
|
onMenuClick(
|
|
73
|
-
item && __spreadValues(__spreadValues({}, item), !isPrevious && { previousMenu: currentMenu })
|
|
95
|
+
item && __spreadValues(__spreadValues({}, item), !isPrevious && { previousMenu: currentMenu }),
|
|
96
|
+
action
|
|
74
97
|
);
|
|
75
98
|
}
|
|
76
99
|
return /* @__PURE__ */ jsxs("div", { className: "flex flex-col w-full", children: [
|
|
@@ -103,7 +126,7 @@ function NestedMenu(props) {
|
|
|
103
126
|
children: currentMenu.title
|
|
104
127
|
}
|
|
105
128
|
),
|
|
106
|
-
|
|
129
|
+
menuItems.map((item, idx) => {
|
|
107
130
|
var _a;
|
|
108
131
|
if (item.children == null) {
|
|
109
132
|
return /* @__PURE__ */ jsx(
|
|
@@ -111,7 +134,7 @@ function NestedMenu(props) {
|
|
|
111
134
|
{
|
|
112
135
|
testid: testid ? `${testid}-${item.label}` : void 0,
|
|
113
136
|
variant: "normal",
|
|
114
|
-
onClick: () => handleMenuClick(item),
|
|
137
|
+
onClick: () => handleMenuClick(item, false, item.url ? "url" : void 0),
|
|
115
138
|
after: ((_a = item.subEntries) == null ? void 0 : _a.length) && /* @__PURE__ */ jsx(
|
|
116
139
|
Button,
|
|
117
140
|
{
|
|
@@ -127,7 +150,7 @@ function NestedMenu(props) {
|
|
|
127
150
|
}
|
|
128
151
|
),
|
|
129
152
|
selected: selectedIndex === idx,
|
|
130
|
-
children: item.label
|
|
153
|
+
children: item.id === "shop-all-top" ? /* @__PURE__ */ jsx(Stack, { minHeight: 24, justify: "center", children: /* @__PURE__ */ jsx(Label, { color: "text-action-normal", padded: true, children: item.label }) }) : item.label
|
|
131
154
|
},
|
|
132
155
|
item.id
|
|
133
156
|
);
|