@dloizides/ui-nav 1.22.0 → 1.23.1
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 +515 -494
- package/dist/index.js +55 -7
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +55 -7
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -1
package/dist/index.mjs
CHANGED
|
@@ -4,6 +4,7 @@ import { useUi, UiProvider } from '@dloizides/ui-feedback';
|
|
|
4
4
|
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
5
5
|
import { Collapse } from '@dloizides/ui-motion';
|
|
6
6
|
import { LAYOUT_COLLAPSE_BREAKPOINT, ModalDropdown } from '@dloizides/ui-layout';
|
|
7
|
+
import { Z_INDEX } from '@dloizides/design-tokens';
|
|
7
8
|
import { resolveAccessibleRoutes } from '@dloizides/auth-web';
|
|
8
9
|
|
|
9
10
|
// src/Sidebar.tsx
|
|
@@ -142,13 +143,19 @@ var navBarStyles = StyleSheet.create({
|
|
|
142
143
|
overflowChevron: { fontSize: 12, fontWeight: "700" },
|
|
143
144
|
// Collapsed (below breakpoint): links drop onto their own full-width line,
|
|
144
145
|
// stacked vertically — mirrors the v1 `.gn-links` responsive behaviour.
|
|
146
|
+
// SHOWCASE-1: this is a ScrollView — `maxHeight` (viewport minus bar) is applied at render time,
|
|
147
|
+
// so a long menu scrolls within the viewport instead of running off a body:overflow:hidden page.
|
|
145
148
|
linksStacked: {
|
|
146
149
|
width: "100%",
|
|
147
150
|
flexBasis: "100%",
|
|
151
|
+
flexGrow: 0,
|
|
152
|
+
flexShrink: 0,
|
|
153
|
+
marginTop: 8
|
|
154
|
+
},
|
|
155
|
+
linksStackedContent: {
|
|
148
156
|
flexDirection: "column",
|
|
149
157
|
alignItems: "stretch",
|
|
150
|
-
rowGap: 2
|
|
151
|
-
marginTop: 8
|
|
158
|
+
rowGap: 2
|
|
152
159
|
},
|
|
153
160
|
link: {
|
|
154
161
|
paddingVertical: 8,
|
|
@@ -1178,9 +1185,24 @@ function useNavOverflow(itemCount, gap) {
|
|
|
1178
1185
|
);
|
|
1179
1186
|
return { visibleCount, setAvailableWidth, setItemWidth, setMoreWidth };
|
|
1180
1187
|
}
|
|
1188
|
+
|
|
1189
|
+
// src/stackedMenuMaxHeight.ts
|
|
1190
|
+
var DEFAULT_BAR_HEIGHT = 64;
|
|
1191
|
+
var MIN_STACKED_MENU_HEIGHT = 3 * 44;
|
|
1192
|
+
function computeStackedMenuMaxHeight({
|
|
1193
|
+
windowHeight,
|
|
1194
|
+
barHeight,
|
|
1195
|
+
reservedBelow
|
|
1196
|
+
}) {
|
|
1197
|
+
const bar = barHeight > 0 ? barHeight : DEFAULT_BAR_HEIGHT;
|
|
1198
|
+
const reserved = Math.max(0, reservedBelow);
|
|
1199
|
+
return Math.max(MIN_STACKED_MENU_HEIGHT, windowHeight - bar - reserved);
|
|
1200
|
+
}
|
|
1181
1201
|
var LINKS_REGION_ID = "navbar-links-region";
|
|
1182
1202
|
var DEFAULT_COLLAPSE_BELOW = 760;
|
|
1183
1203
|
var MENU_GLYPH = "\u2630";
|
|
1204
|
+
var STACKED_MENU_CHROME = 12;
|
|
1205
|
+
var STACKED_RIGHT_CHROME = 8;
|
|
1184
1206
|
function ariaControlsProps(id) {
|
|
1185
1207
|
return { "aria-controls": id };
|
|
1186
1208
|
}
|
|
@@ -1204,13 +1226,22 @@ var NavBarInner = ({
|
|
|
1204
1226
|
const { theme } = useUi();
|
|
1205
1227
|
const colors = theme.colors;
|
|
1206
1228
|
const primaryColor = theme.palette.primary["500"];
|
|
1207
|
-
const { width } = useWindowDimensions();
|
|
1229
|
+
const { width, height } = useWindowDimensions();
|
|
1208
1230
|
const reducedMotion = useReducedMotion();
|
|
1209
1231
|
const [open, setOpen] = useState(false);
|
|
1210
1232
|
const [toggleFocused, setToggleFocused] = useState(false);
|
|
1211
1233
|
const { visibleCount, setAvailableWidth, setItemWidth, setMoreWidth } = useNavOverflow(items.length, NAV_LINK_GAP);
|
|
1212
1234
|
const collapsed = width < collapseBelow;
|
|
1213
1235
|
const showLinks = !collapsed || open;
|
|
1236
|
+
const [barHeight, setBarHeight] = useState(0);
|
|
1237
|
+
const [rightHeight, setRightHeight] = useState(0);
|
|
1238
|
+
const hasRight = right !== void 0;
|
|
1239
|
+
const stackedMaxHeight = computeStackedMenuMaxHeight({
|
|
1240
|
+
windowHeight: height,
|
|
1241
|
+
barHeight,
|
|
1242
|
+
reservedBelow: STACKED_MENU_CHROME + (hasRight ? STACKED_RIGHT_CHROME + rightHeight : 0)
|
|
1243
|
+
});
|
|
1244
|
+
const measureBar = collapsed && !open;
|
|
1214
1245
|
const innerCapStyle = useMemo(
|
|
1215
1246
|
() => contentMaxWidth === void 0 ? null : { maxWidth: contentMaxWidth, width: "100%", alignSelf: "center" },
|
|
1216
1247
|
[contentMaxWidth]
|
|
@@ -1245,6 +1276,7 @@ var NavBarInner = ({
|
|
|
1245
1276
|
{ backgroundColor: colors.surface, borderBottomColor: colors.border },
|
|
1246
1277
|
containerStyle
|
|
1247
1278
|
],
|
|
1279
|
+
onLayout: measureBar ? (event) => setBarHeight(event.nativeEvent.layout.height) : void 0,
|
|
1248
1280
|
children: /* @__PURE__ */ jsxs(View, { style: [navBarStyles.inner, collapsed ? null : navBarStyles.innerNoWrap, innerCapStyle], children: [
|
|
1249
1281
|
brand !== void 0 ? /* @__PURE__ */ jsx(View, { style: navBarStyles.brand, children: renderTextSlot(brand, { color: colors.text }) }) : null,
|
|
1250
1282
|
collapsed ? /* @__PURE__ */ jsx(
|
|
@@ -1279,7 +1311,16 @@ var NavBarInner = ({
|
|
|
1279
1311
|
}
|
|
1280
1312
|
);
|
|
1281
1313
|
if (collapsed) {
|
|
1282
|
-
return /* @__PURE__ */ jsx(
|
|
1314
|
+
return /* @__PURE__ */ jsx(
|
|
1315
|
+
ScrollView,
|
|
1316
|
+
{
|
|
1317
|
+
contentContainerStyle: navBarStyles.linksStackedContent,
|
|
1318
|
+
nativeID: LINKS_REGION_ID,
|
|
1319
|
+
style: [navBarStyles.linksStacked, { maxHeight: stackedMaxHeight }],
|
|
1320
|
+
testID: NAV_TEST_IDS.navBarLinks,
|
|
1321
|
+
children: items.map((item) => /* @__PURE__ */ jsx(React.Fragment, { children: renderLink(item) }, item.key))
|
|
1322
|
+
}
|
|
1323
|
+
);
|
|
1283
1324
|
}
|
|
1284
1325
|
const visibleItems = items.slice(0, visibleCount);
|
|
1285
1326
|
const overflowItems = items.slice(visibleCount);
|
|
@@ -1323,7 +1364,14 @@ var NavBarInner = ({
|
|
|
1323
1364
|
}
|
|
1324
1365
|
);
|
|
1325
1366
|
})() : null,
|
|
1326
|
-
showLinks &&
|
|
1367
|
+
showLinks && hasRight ? /* @__PURE__ */ jsx(
|
|
1368
|
+
View,
|
|
1369
|
+
{
|
|
1370
|
+
style: collapsed ? navBarStyles.rightStacked : navBarStyles.right,
|
|
1371
|
+
onLayout: collapsed ? (event) => setRightHeight(event.nativeEvent.layout.height) : void 0,
|
|
1372
|
+
children: renderTextSlot(right, { color: colors.text })
|
|
1373
|
+
}
|
|
1374
|
+
) : null
|
|
1327
1375
|
] })
|
|
1328
1376
|
}
|
|
1329
1377
|
);
|
|
@@ -1407,7 +1455,7 @@ var SCRIM_COLOR = "rgba(0, 0, 0, 0.5)";
|
|
|
1407
1455
|
var MENU_GLYPH2 = "\u2630";
|
|
1408
1456
|
var MENU_GLYPH_FONT_SIZE = 20;
|
|
1409
1457
|
var MENU_TOGGLE_PADDING = 12;
|
|
1410
|
-
var DRAWER_Z_INDEX =
|
|
1458
|
+
var DRAWER_Z_INDEX = Z_INDEX.drawer;
|
|
1411
1459
|
var DRAWER_WIDTH = 280;
|
|
1412
1460
|
var SCRIM_Z_INDEX = 1;
|
|
1413
1461
|
var PANEL_Z_INDEX = 2;
|
|
@@ -1924,7 +1972,7 @@ function filterCommands(items, query) {
|
|
|
1924
1972
|
});
|
|
1925
1973
|
}
|
|
1926
1974
|
var SCRIM_COLOR2 = "rgba(0, 0, 0, 0.5)";
|
|
1927
|
-
var OVERLAY_Z_INDEX =
|
|
1975
|
+
var OVERLAY_Z_INDEX = Z_INDEX.palette;
|
|
1928
1976
|
var PANEL_MAX_WIDTH = 560;
|
|
1929
1977
|
var PANEL_TOP_OFFSET = 88;
|
|
1930
1978
|
var LIST_MAX_HEIGHT = 360;
|