@dloizides/ui-nav 1.10.1 → 1.11.0
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/CHANGELOG.md +45 -0
- package/dist/index.js +35 -4
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +35 -4
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -283,6 +283,10 @@ function hoverTransitionStyle(reducedMotion) {
|
|
|
283
283
|
function ariaCurrentProps(isActive) {
|
|
284
284
|
return isActive ? { "aria-current": "page" } : {};
|
|
285
285
|
}
|
|
286
|
+
function hasActiveDescendant(item, pathname) {
|
|
287
|
+
if (isRouteActive(pathname, item.route)) return true;
|
|
288
|
+
return (item.children ?? []).some((child) => hasActiveDescendant(child, pathname));
|
|
289
|
+
}
|
|
286
290
|
var NavExpandableItem = ({
|
|
287
291
|
item,
|
|
288
292
|
pathname,
|
|
@@ -293,7 +297,7 @@ var NavExpandableItem = ({
|
|
|
293
297
|
renderChevron,
|
|
294
298
|
depth = 0
|
|
295
299
|
}) => {
|
|
296
|
-
const [expanded, setExpanded] = useState(
|
|
300
|
+
const [expanded, setExpanded] = useState(() => hasActiveDescendant(item, pathname));
|
|
297
301
|
const [focused, setFocused] = useState(false);
|
|
298
302
|
const { theme } = useUi();
|
|
299
303
|
const colors = theme.colors;
|
|
@@ -998,6 +1002,9 @@ var MENU_MIN_TARGET = 44;
|
|
|
998
1002
|
var MENU_GLYPH_FONT_SIZE = 20;
|
|
999
1003
|
var MENU_TOGGLE_PADDING = 12;
|
|
1000
1004
|
var DRAWER_Z_INDEX = 50;
|
|
1005
|
+
var DRAWER_WIDTH = 280;
|
|
1006
|
+
var SCRIM_Z_INDEX = 1;
|
|
1007
|
+
var PANEL_Z_INDEX = 2;
|
|
1001
1008
|
var NAV_ACTIVATABLE_SELECTOR = 'a, [role="button"], [role="link"]';
|
|
1002
1009
|
var DEFAULT_DRAWER_LABELS = {
|
|
1003
1010
|
openLabel: "Menu",
|
|
@@ -1007,8 +1014,22 @@ var DEFAULT_DRAWER_LABELS = {
|
|
|
1007
1014
|
};
|
|
1008
1015
|
var styles2 = StyleSheet.create({
|
|
1009
1016
|
overlay: { ...StyleSheet.absoluteFillObject, zIndex: DRAWER_Z_INDEX },
|
|
1010
|
-
scrim
|
|
1011
|
-
|
|
1017
|
+
// The scrim's tap-to-close hit area is anchored to the RIGHT of the panel
|
|
1018
|
+
// (`left: DRAWER_WIDTH`), so it NEVER overlaps the panel: nav-item taps always
|
|
1019
|
+
// reach the Sidebar's TouchableOpacity, while taps beside the drawer still close.
|
|
1020
|
+
scrim: {
|
|
1021
|
+
position: "absolute",
|
|
1022
|
+
top: 0,
|
|
1023
|
+
bottom: 0,
|
|
1024
|
+
left: DRAWER_WIDTH,
|
|
1025
|
+
right: 0,
|
|
1026
|
+
backgroundColor: SCRIM_COLOR,
|
|
1027
|
+
zIndex: SCRIM_Z_INDEX
|
|
1028
|
+
},
|
|
1029
|
+
// The panel gets an explicit width (a real drawer) AND a zIndex above the scrim,
|
|
1030
|
+
// so on react-native-web it — and the nav leaves inside it — sit above the scrim
|
|
1031
|
+
// and receive presses instead of the scrim swallowing them.
|
|
1032
|
+
panel: { position: "absolute", top: 0, bottom: 0, left: 0, width: DRAWER_WIDTH, zIndex: PANEL_Z_INDEX },
|
|
1012
1033
|
menuToggle: {
|
|
1013
1034
|
minWidth: MENU_MIN_TARGET,
|
|
1014
1035
|
minHeight: MENU_MIN_TARGET,
|
|
@@ -1065,7 +1086,17 @@ var MobileDrawer = ({
|
|
|
1065
1086
|
onPress: onClose
|
|
1066
1087
|
}
|
|
1067
1088
|
),
|
|
1068
|
-
/* @__PURE__ */ jsx(
|
|
1089
|
+
/* @__PURE__ */ jsx(
|
|
1090
|
+
View,
|
|
1091
|
+
{
|
|
1092
|
+
ref: panelRef,
|
|
1093
|
+
"aria-modal": true,
|
|
1094
|
+
role: "dialog",
|
|
1095
|
+
style: [styles2.panel, { backgroundColor: theme.colors.surface }],
|
|
1096
|
+
testID: drawerTestID,
|
|
1097
|
+
children: renderTextSlot(sidebar, { color: theme.colors.text })
|
|
1098
|
+
}
|
|
1099
|
+
)
|
|
1069
1100
|
] });
|
|
1070
1101
|
};
|
|
1071
1102
|
|