@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.js
CHANGED
|
@@ -6,6 +6,7 @@ var uiFeedback = require('@dloizides/ui-feedback');
|
|
|
6
6
|
var jsxRuntime = require('react/jsx-runtime');
|
|
7
7
|
var uiMotion = require('@dloizides/ui-motion');
|
|
8
8
|
var uiLayout = require('@dloizides/ui-layout');
|
|
9
|
+
var designTokens = require('@dloizides/design-tokens');
|
|
9
10
|
var authWeb = require('@dloizides/auth-web');
|
|
10
11
|
|
|
11
12
|
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
@@ -148,13 +149,19 @@ var navBarStyles = reactNative.StyleSheet.create({
|
|
|
148
149
|
overflowChevron: { fontSize: 12, fontWeight: "700" },
|
|
149
150
|
// Collapsed (below breakpoint): links drop onto their own full-width line,
|
|
150
151
|
// stacked vertically — mirrors the v1 `.gn-links` responsive behaviour.
|
|
152
|
+
// SHOWCASE-1: this is a ScrollView — `maxHeight` (viewport minus bar) is applied at render time,
|
|
153
|
+
// so a long menu scrolls within the viewport instead of running off a body:overflow:hidden page.
|
|
151
154
|
linksStacked: {
|
|
152
155
|
width: "100%",
|
|
153
156
|
flexBasis: "100%",
|
|
157
|
+
flexGrow: 0,
|
|
158
|
+
flexShrink: 0,
|
|
159
|
+
marginTop: 8
|
|
160
|
+
},
|
|
161
|
+
linksStackedContent: {
|
|
154
162
|
flexDirection: "column",
|
|
155
163
|
alignItems: "stretch",
|
|
156
|
-
rowGap: 2
|
|
157
|
-
marginTop: 8
|
|
164
|
+
rowGap: 2
|
|
158
165
|
},
|
|
159
166
|
link: {
|
|
160
167
|
paddingVertical: 8,
|
|
@@ -1184,9 +1191,24 @@ function useNavOverflow(itemCount, gap) {
|
|
|
1184
1191
|
);
|
|
1185
1192
|
return { visibleCount, setAvailableWidth, setItemWidth, setMoreWidth };
|
|
1186
1193
|
}
|
|
1194
|
+
|
|
1195
|
+
// src/stackedMenuMaxHeight.ts
|
|
1196
|
+
var DEFAULT_BAR_HEIGHT = 64;
|
|
1197
|
+
var MIN_STACKED_MENU_HEIGHT = 3 * 44;
|
|
1198
|
+
function computeStackedMenuMaxHeight({
|
|
1199
|
+
windowHeight,
|
|
1200
|
+
barHeight,
|
|
1201
|
+
reservedBelow
|
|
1202
|
+
}) {
|
|
1203
|
+
const bar = barHeight > 0 ? barHeight : DEFAULT_BAR_HEIGHT;
|
|
1204
|
+
const reserved = Math.max(0, reservedBelow);
|
|
1205
|
+
return Math.max(MIN_STACKED_MENU_HEIGHT, windowHeight - bar - reserved);
|
|
1206
|
+
}
|
|
1187
1207
|
var LINKS_REGION_ID = "navbar-links-region";
|
|
1188
1208
|
var DEFAULT_COLLAPSE_BELOW = 760;
|
|
1189
1209
|
var MENU_GLYPH = "\u2630";
|
|
1210
|
+
var STACKED_MENU_CHROME = 12;
|
|
1211
|
+
var STACKED_RIGHT_CHROME = 8;
|
|
1190
1212
|
function ariaControlsProps(id) {
|
|
1191
1213
|
return { "aria-controls": id };
|
|
1192
1214
|
}
|
|
@@ -1210,13 +1232,22 @@ var NavBarInner = ({
|
|
|
1210
1232
|
const { theme } = uiFeedback.useUi();
|
|
1211
1233
|
const colors = theme.colors;
|
|
1212
1234
|
const primaryColor = theme.palette.primary["500"];
|
|
1213
|
-
const { width } = reactNative.useWindowDimensions();
|
|
1235
|
+
const { width, height } = reactNative.useWindowDimensions();
|
|
1214
1236
|
const reducedMotion = useReducedMotion();
|
|
1215
1237
|
const [open, setOpen] = React.useState(false);
|
|
1216
1238
|
const [toggleFocused, setToggleFocused] = React.useState(false);
|
|
1217
1239
|
const { visibleCount, setAvailableWidth, setItemWidth, setMoreWidth } = useNavOverflow(items.length, NAV_LINK_GAP);
|
|
1218
1240
|
const collapsed = width < collapseBelow;
|
|
1219
1241
|
const showLinks = !collapsed || open;
|
|
1242
|
+
const [barHeight, setBarHeight] = React.useState(0);
|
|
1243
|
+
const [rightHeight, setRightHeight] = React.useState(0);
|
|
1244
|
+
const hasRight = right !== void 0;
|
|
1245
|
+
const stackedMaxHeight = computeStackedMenuMaxHeight({
|
|
1246
|
+
windowHeight: height,
|
|
1247
|
+
barHeight,
|
|
1248
|
+
reservedBelow: STACKED_MENU_CHROME + (hasRight ? STACKED_RIGHT_CHROME + rightHeight : 0)
|
|
1249
|
+
});
|
|
1250
|
+
const measureBar = collapsed && !open;
|
|
1220
1251
|
const innerCapStyle = React.useMemo(
|
|
1221
1252
|
() => contentMaxWidth === void 0 ? null : { maxWidth: contentMaxWidth, width: "100%", alignSelf: "center" },
|
|
1222
1253
|
[contentMaxWidth]
|
|
@@ -1251,6 +1282,7 @@ var NavBarInner = ({
|
|
|
1251
1282
|
{ backgroundColor: colors.surface, borderBottomColor: colors.border },
|
|
1252
1283
|
containerStyle
|
|
1253
1284
|
],
|
|
1285
|
+
onLayout: measureBar ? (event) => setBarHeight(event.nativeEvent.layout.height) : void 0,
|
|
1254
1286
|
children: /* @__PURE__ */ jsxRuntime.jsxs(reactNative.View, { style: [navBarStyles.inner, collapsed ? null : navBarStyles.innerNoWrap, innerCapStyle], children: [
|
|
1255
1287
|
brand !== void 0 ? /* @__PURE__ */ jsxRuntime.jsx(reactNative.View, { style: navBarStyles.brand, children: renderTextSlot(brand, { color: colors.text }) }) : null,
|
|
1256
1288
|
collapsed ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
@@ -1285,7 +1317,16 @@ var NavBarInner = ({
|
|
|
1285
1317
|
}
|
|
1286
1318
|
);
|
|
1287
1319
|
if (collapsed) {
|
|
1288
|
-
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
1320
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
1321
|
+
reactNative.ScrollView,
|
|
1322
|
+
{
|
|
1323
|
+
contentContainerStyle: navBarStyles.linksStackedContent,
|
|
1324
|
+
nativeID: LINKS_REGION_ID,
|
|
1325
|
+
style: [navBarStyles.linksStacked, { maxHeight: stackedMaxHeight }],
|
|
1326
|
+
testID: NAV_TEST_IDS.navBarLinks,
|
|
1327
|
+
children: items.map((item) => /* @__PURE__ */ jsxRuntime.jsx(React__default.default.Fragment, { children: renderLink(item) }, item.key))
|
|
1328
|
+
}
|
|
1329
|
+
);
|
|
1289
1330
|
}
|
|
1290
1331
|
const visibleItems = items.slice(0, visibleCount);
|
|
1291
1332
|
const overflowItems = items.slice(visibleCount);
|
|
@@ -1329,7 +1370,14 @@ var NavBarInner = ({
|
|
|
1329
1370
|
}
|
|
1330
1371
|
);
|
|
1331
1372
|
})() : null,
|
|
1332
|
-
showLinks &&
|
|
1373
|
+
showLinks && hasRight ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
1374
|
+
reactNative.View,
|
|
1375
|
+
{
|
|
1376
|
+
style: collapsed ? navBarStyles.rightStacked : navBarStyles.right,
|
|
1377
|
+
onLayout: collapsed ? (event) => setRightHeight(event.nativeEvent.layout.height) : void 0,
|
|
1378
|
+
children: renderTextSlot(right, { color: colors.text })
|
|
1379
|
+
}
|
|
1380
|
+
) : null
|
|
1333
1381
|
] })
|
|
1334
1382
|
}
|
|
1335
1383
|
);
|
|
@@ -1413,7 +1461,7 @@ var SCRIM_COLOR = "rgba(0, 0, 0, 0.5)";
|
|
|
1413
1461
|
var MENU_GLYPH2 = "\u2630";
|
|
1414
1462
|
var MENU_GLYPH_FONT_SIZE = 20;
|
|
1415
1463
|
var MENU_TOGGLE_PADDING = 12;
|
|
1416
|
-
var DRAWER_Z_INDEX =
|
|
1464
|
+
var DRAWER_Z_INDEX = designTokens.Z_INDEX.drawer;
|
|
1417
1465
|
var DRAWER_WIDTH = 280;
|
|
1418
1466
|
var SCRIM_Z_INDEX = 1;
|
|
1419
1467
|
var PANEL_Z_INDEX = 2;
|
|
@@ -1930,7 +1978,7 @@ function filterCommands(items, query) {
|
|
|
1930
1978
|
});
|
|
1931
1979
|
}
|
|
1932
1980
|
var SCRIM_COLOR2 = "rgba(0, 0, 0, 0.5)";
|
|
1933
|
-
var OVERLAY_Z_INDEX =
|
|
1981
|
+
var OVERLAY_Z_INDEX = designTokens.Z_INDEX.palette;
|
|
1934
1982
|
var PANEL_MAX_WIDTH = 560;
|
|
1935
1983
|
var PANEL_TOP_OFFSET = 88;
|
|
1936
1984
|
var LIST_MAX_HEIGHT = 360;
|