@dloizides/ui-layout 1.59.0 → 1.60.2

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 CHANGED
@@ -1,5 +1,13 @@
1
1
  # Changelog
2
2
 
3
+ ## 1.60.1
4
+
5
+ - Ships the 1.60.0 `SectionIndexLayout` `collapsedKey` change; 1.60.0 never reached npm (its test used a wrong index testID).
6
+
7
+ ## 1.60.0
8
+
9
+ - MODC-1 D-MC-743 "S-7 owner sighting findings" F1. `SectionIndexLayout` takes `collapsedKey`: the section the collapsed (chips) layout opens on, so a screen whose primary section differs from its first index entry keeps it on screen below the index breakpoint. `initialKey` still marks the wide index. The picked key stays unset until the user picks, so resizing across the breakpoint follows the layout. Optional, default unchanged.
10
+
3
11
  ## 1.58.0
4
12
 
5
13
  - MODC-1 D-MC-728 "Layout gaps in the package". All new props optional, defaults unchanged.
package/dist/index.d.mts CHANGED
@@ -1240,6 +1240,7 @@ interface SectionIndexLayoutProps {
1240
1240
  indexHeading: string;
1241
1241
  itemHint: string;
1242
1242
  initialKey?: string;
1243
+ collapsedKey?: string;
1243
1244
  breakpoint?: number;
1244
1245
  density?: SectionDensity;
1245
1246
  stickyIndex?: boolean;
@@ -1248,7 +1249,7 @@ interface SectionIndexLayoutProps {
1248
1249
  activeColor?: string;
1249
1250
  testID?: string;
1250
1251
  }
1251
- declare const SectionIndexLayout: ({ sections, indexHeading, itemHint, initialKey, breakpoint, density, stickyIndex, chipOverflow, indexWidth, activeColor, testID, }: SectionIndexLayoutProps) => React.ReactElement;
1252
+ declare const SectionIndexLayout: ({ sections, indexHeading, itemHint, initialKey, collapsedKey, breakpoint, density, stickyIndex, chipOverflow, indexWidth, activeColor, testID, }: SectionIndexLayoutProps) => React.ReactElement;
1252
1253
 
1253
1254
  declare const SECTION_INDEX_WIDTH = 200;
1254
1255
  interface SectionIndexProps {
@@ -1260,8 +1261,10 @@ interface SectionIndexProps {
1260
1261
  testID: string;
1261
1262
  width?: number;
1262
1263
  activeColor?: string;
1264
+ /** Dense: 11/600 heading, 13 px items at a 24 px desktop target. */
1265
+ dense?: boolean;
1263
1266
  }
1264
- declare const SectionIndex: ({ sections, activeKey, heading, itemHint, onSelect, testID, width, activeColor }: SectionIndexProps) => React.ReactElement;
1267
+ declare const SectionIndex: ({ sections, activeKey, heading, itemHint, onSelect, testID, width, activeColor, dense }: SectionIndexProps) => React.ReactElement;
1265
1268
 
1266
1269
  interface SectionChipsProps {
1267
1270
  sections: ReadonlyArray<SectionIndexEntry>;
@@ -1270,10 +1273,12 @@ interface SectionChipsProps {
1270
1273
  itemHint: string;
1271
1274
  overflow?: ChipOverflow;
1272
1275
  activeColor?: string;
1276
+ /** Dense: 13 px labels, 12 px chip padding, 6 px gutter, active label on the surface colour. */
1277
+ dense?: boolean;
1273
1278
  onSelect: (key: string) => void;
1274
1279
  testID: string;
1275
1280
  }
1276
- declare const SectionChips: ({ sections, activeKey, groupLabel, itemHint, overflow, activeColor, onSelect, testID }: SectionChipsProps) => React.ReactElement;
1281
+ declare const SectionChips: ({ sections, activeKey, groupLabel, itemHint, overflow, activeColor, dense, onSelect, testID }: SectionChipsProps) => React.ReactElement;
1277
1282
 
1278
1283
  declare const SECTION_INDEX_BREAKPOINT = 1024;
1279
1284
  declare function resolveActiveKey(sections: ReadonlyArray<SectionIndexEntry>, wanted: string | undefined): string;
package/dist/index.d.ts CHANGED
@@ -1240,6 +1240,7 @@ interface SectionIndexLayoutProps {
1240
1240
  indexHeading: string;
1241
1241
  itemHint: string;
1242
1242
  initialKey?: string;
1243
+ collapsedKey?: string;
1243
1244
  breakpoint?: number;
1244
1245
  density?: SectionDensity;
1245
1246
  stickyIndex?: boolean;
@@ -1248,7 +1249,7 @@ interface SectionIndexLayoutProps {
1248
1249
  activeColor?: string;
1249
1250
  testID?: string;
1250
1251
  }
1251
- declare const SectionIndexLayout: ({ sections, indexHeading, itemHint, initialKey, breakpoint, density, stickyIndex, chipOverflow, indexWidth, activeColor, testID, }: SectionIndexLayoutProps) => React.ReactElement;
1252
+ declare const SectionIndexLayout: ({ sections, indexHeading, itemHint, initialKey, collapsedKey, breakpoint, density, stickyIndex, chipOverflow, indexWidth, activeColor, testID, }: SectionIndexLayoutProps) => React.ReactElement;
1252
1253
 
1253
1254
  declare const SECTION_INDEX_WIDTH = 200;
1254
1255
  interface SectionIndexProps {
@@ -1260,8 +1261,10 @@ interface SectionIndexProps {
1260
1261
  testID: string;
1261
1262
  width?: number;
1262
1263
  activeColor?: string;
1264
+ /** Dense: 11/600 heading, 13 px items at a 24 px desktop target. */
1265
+ dense?: boolean;
1263
1266
  }
1264
- declare const SectionIndex: ({ sections, activeKey, heading, itemHint, onSelect, testID, width, activeColor }: SectionIndexProps) => React.ReactElement;
1267
+ declare const SectionIndex: ({ sections, activeKey, heading, itemHint, onSelect, testID, width, activeColor, dense }: SectionIndexProps) => React.ReactElement;
1265
1268
 
1266
1269
  interface SectionChipsProps {
1267
1270
  sections: ReadonlyArray<SectionIndexEntry>;
@@ -1270,10 +1273,12 @@ interface SectionChipsProps {
1270
1273
  itemHint: string;
1271
1274
  overflow?: ChipOverflow;
1272
1275
  activeColor?: string;
1276
+ /** Dense: 13 px labels, 12 px chip padding, 6 px gutter, active label on the surface colour. */
1277
+ dense?: boolean;
1273
1278
  onSelect: (key: string) => void;
1274
1279
  testID: string;
1275
1280
  }
1276
- declare const SectionChips: ({ sections, activeKey, groupLabel, itemHint, overflow, activeColor, onSelect, testID }: SectionChipsProps) => React.ReactElement;
1281
+ declare const SectionChips: ({ sections, activeKey, groupLabel, itemHint, overflow, activeColor, dense, onSelect, testID }: SectionChipsProps) => React.ReactElement;
1277
1282
 
1278
1283
  declare const SECTION_INDEX_BREAKPOINT = 1024;
1279
1284
  declare function resolveActiveKey(sections: ReadonlyArray<SectionIndexEntry>, wanted: string | undefined): string;
package/dist/index.js CHANGED
@@ -3386,17 +3386,24 @@ var styles29 = reactNative.StyleSheet.create({
3386
3386
  root: { flexDirection: "row", flexWrap: "wrap", gap: 8 },
3387
3387
  scrollRow: { flexDirection: "row", flexWrap: "nowrap", gap: 8 },
3388
3388
  chip: { minHeight: MIN_TARGET_PX, justifyContent: "center", paddingHorizontal: 14, borderRadius: 999, borderWidth: 1 },
3389
- label: { fontSize: 14, fontWeight: "600" }
3389
+ label: { fontSize: 14, fontWeight: "600" },
3390
+ denseRow: { gap: 6 },
3391
+ denseChip: { paddingHorizontal: 12 },
3392
+ denseLabel: { fontSize: 13 }
3390
3393
  });
3391
3394
  function ariaSelected(selected) {
3392
3395
  return { "aria-selected": selected };
3393
3396
  }
3394
- var SectionChips = ({ sections, activeKey, groupLabel, itemHint, overflow = "wrap" /* Wrap */, activeColor, onSelect, testID }) => {
3397
+ function activeInk(active, dense, colors) {
3398
+ if (!active) return colors.text;
3399
+ return dense ? colors.surface : colors.background;
3400
+ }
3401
+ var SectionChips = ({ sections, activeKey, groupLabel, itemHint, overflow = "wrap" /* Wrap */, activeColor, dense = false, onSelect, testID }) => {
3395
3402
  const { theme } = uiFeedback.useUi();
3396
3403
  const { colors } = theme;
3397
3404
  const fill = activeColor ?? colors.text;
3398
3405
  const scroll = overflow === "scroll" /* Scroll */;
3399
- const row = /* @__PURE__ */ jsxRuntime.jsx(reactNative.View, { accessibilityRole: "tablist", accessibilityLabel: groupLabel, style: scroll ? styles29.scrollRow : styles29.root, testID: `${testID}-chips`, children: sections.map((entry) => {
3406
+ const row = /* @__PURE__ */ jsxRuntime.jsx(reactNative.View, { accessibilityRole: "tablist", accessibilityLabel: groupLabel, style: [scroll ? styles29.scrollRow : styles29.root, dense && styles29.denseRow], testID: `${testID}-chips`, children: sections.map((entry) => {
3400
3407
  const active = entry.key === activeKey;
3401
3408
  return /* @__PURE__ */ jsxRuntime.jsx(
3402
3409
  reactNative.Pressable,
@@ -3405,10 +3412,10 @@ var SectionChips = ({ sections, activeKey, groupLabel, itemHint, overflow = "wra
3405
3412
  accessibilityRole: "tab",
3406
3413
  accessibilityLabel: entry.title,
3407
3414
  accessibilityHint: itemHint,
3408
- style: [styles29.chip, { borderColor: colors.border, backgroundColor: active ? fill : colors.background }],
3415
+ style: [styles29.chip, dense && styles29.denseChip, { borderColor: colors.border, backgroundColor: active ? fill : colors.background }],
3409
3416
  testID: `${testID}-chip-${entry.key}`,
3410
3417
  onPress: () => onSelect(entry.key),
3411
- children: /* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { style: [styles29.label, { color: active ? colors.background : colors.text }], children: entry.title })
3418
+ children: /* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { style: [styles29.label, dense && styles29.denseLabel, { color: activeInk(active, dense, colors) }], children: entry.title })
3412
3419
  },
3413
3420
  entry.key
3414
3421
  );
@@ -3425,22 +3432,28 @@ var SectionDensity = /* @__PURE__ */ ((SectionDensity2) => {
3425
3432
  var SECTION_INDEX_WIDTH = 200;
3426
3433
  var ACTIVE_BAR = 3;
3427
3434
  var TRANSPARENT3 = "transparent";
3435
+ var DENSE_TARGET_PX = 24;
3428
3436
  var styles30 = reactNative.StyleSheet.create({
3429
3437
  root: { flexShrink: 0, gap: 2, alignSelf: "flex-start" },
3430
3438
  heading: { fontSize: 12, fontWeight: "700", letterSpacing: 0.6, textTransform: "uppercase", paddingHorizontal: 10, paddingBottom: 6 },
3431
3439
  item: { minHeight: MIN_TARGET_PX, justifyContent: "center", paddingHorizontal: 10, borderLeftWidth: ACTIVE_BAR, borderRadius: 6 },
3432
3440
  label: { fontSize: 14 },
3433
- labelActive: { fontWeight: "700" }
3441
+ labelActive: { fontWeight: "700" },
3442
+ denseRoot: { gap: 0 },
3443
+ denseHeading: { fontSize: 11, fontWeight: "600", paddingBottom: 10 },
3444
+ denseItem: { minHeight: DENSE_TARGET_PX, paddingVertical: 7, paddingHorizontal: 7 },
3445
+ denseLabel: { fontSize: 13, lineHeight: 19 },
3446
+ denseLabelActive: { fontWeight: "600" }
3434
3447
  });
3435
3448
  function ariaCurrent(active) {
3436
3449
  return active ? { "aria-current": "location" } : {};
3437
3450
  }
3438
- var SectionIndex = ({ sections, activeKey, heading, itemHint, onSelect, testID, width = SECTION_INDEX_WIDTH, activeColor }) => {
3451
+ var SectionIndex = ({ sections, activeKey, heading, itemHint, onSelect, testID, width = SECTION_INDEX_WIDTH, activeColor, dense = false }) => {
3439
3452
  const { theme } = uiFeedback.useUi();
3440
3453
  const { colors } = theme;
3441
3454
  const bar = activeColor ?? colors.text;
3442
- return /* @__PURE__ */ jsxRuntime.jsxs(reactNative.View, { role: "navigation", accessibilityLabel: heading, style: [styles30.root, { width }], testID: `${testID}-index`, children: [
3443
- /* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { style: [styles30.heading, { color: colors.textSecondary }], children: heading }),
3455
+ return /* @__PURE__ */ jsxRuntime.jsxs(reactNative.View, { role: "navigation", accessibilityLabel: heading, style: [styles30.root, dense && styles30.denseRoot, { width }], testID: `${testID}-index`, children: [
3456
+ /* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { style: [styles30.heading, dense && styles30.denseHeading, { color: colors.textSecondary }], children: heading }),
3444
3457
  sections.map((entry) => {
3445
3458
  const active = entry.key === activeKey;
3446
3459
  return /* @__PURE__ */ jsxRuntime.jsx(
@@ -3450,10 +3463,10 @@ var SectionIndex = ({ sections, activeKey, heading, itemHint, onSelect, testID,
3450
3463
  accessibilityRole: "link",
3451
3464
  accessibilityLabel: entry.title,
3452
3465
  accessibilityHint: itemHint,
3453
- style: [styles30.item, { borderLeftColor: active ? bar : TRANSPARENT3, backgroundColor: active ? colors.surface : TRANSPARENT3 }],
3466
+ style: [styles30.item, dense && styles30.denseItem, { borderLeftColor: active ? bar : TRANSPARENT3, backgroundColor: active ? colors.surface : TRANSPARENT3 }],
3454
3467
  testID: `${testID}-index-${entry.key}`,
3455
3468
  onPress: () => onSelect(entry.key),
3456
- children: /* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { style: [styles30.label, active && styles30.labelActive, { color: active ? colors.text : colors.textSecondary }], children: entry.title })
3469
+ children: /* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { style: [styles30.label, active && styles30.labelActive, dense && styles30.denseLabel, dense && active && styles30.denseLabelActive, { color: active ? colors.text : colors.textSecondary }], children: entry.title })
3457
3470
  },
3458
3471
  entry.key
3459
3472
  );
@@ -3478,6 +3491,7 @@ function scrollToSection(anchorId) {
3478
3491
  }
3479
3492
  var COMFORTABLE_GAP = 12;
3480
3493
  var DENSE_GAP = 8;
3494
+ var DENSE_WIDE_GAP = 14;
3481
3495
  var WEB_STICKY = { position: "sticky", top: 0 };
3482
3496
  var styles31 = reactNative.StyleSheet.create({
3483
3497
  wide: { flexDirection: "row", alignItems: "flex-start", gap: 20 },
@@ -3488,6 +3502,7 @@ var SectionIndexLayout = ({
3488
3502
  indexHeading,
3489
3503
  itemHint,
3490
3504
  initialKey,
3505
+ collapsedKey,
3491
3506
  breakpoint = SECTION_INDEX_BREAKPOINT,
3492
3507
  density = "comfortable" /* Comfortable */,
3493
3508
  stickyIndex = false,
@@ -3497,9 +3512,10 @@ var SectionIndexLayout = ({
3497
3512
  testID = "section-index"
3498
3513
  }) => {
3499
3514
  const wide = useIsWideViewport(breakpoint);
3500
- const [picked, setPicked] = React16.useState(initialKey);
3501
- const activeKey = resolveActiveKey(sections, picked);
3502
- const gap = { gap: density === "dense" /* Dense */ ? DENSE_GAP : COMFORTABLE_GAP };
3515
+ const [picked, setPicked] = React16.useState(void 0);
3516
+ const activeKey = resolveActiveKey(sections, picked ?? (wide ? initialKey : collapsedKey ?? initialKey));
3517
+ const dense = density === "dense" /* Dense */;
3518
+ const gap = { gap: dense ? DENSE_GAP : COMFORTABLE_GAP };
3503
3519
  if (sections.length < 2) return /* @__PURE__ */ jsxRuntime.jsx(reactNative.View, { testID, children: sections[0]?.content });
3504
3520
  if (!wide) {
3505
3521
  const active = sections.find((entry) => entry.key === activeKey);
@@ -3509,6 +3525,7 @@ var SectionIndexLayout = ({
3509
3525
  {
3510
3526
  activeColor,
3511
3527
  activeKey,
3528
+ dense,
3512
3529
  groupLabel: indexHeading,
3513
3530
  itemHint,
3514
3531
  overflow: chipOverflow,
@@ -3525,8 +3542,8 @@ var SectionIndexLayout = ({
3525
3542
  scrollToSection(sectionAnchorId(testID, key));
3526
3543
  };
3527
3544
  const sticky = stickyIndex && reactNative.Platform.OS === "web" ? WEB_STICKY : null;
3528
- return /* @__PURE__ */ jsxRuntime.jsxs(reactNative.View, { style: styles31.wide, testID, children: [
3529
- /* @__PURE__ */ jsxRuntime.jsx(reactNative.View, { style: sticky, children: /* @__PURE__ */ jsxRuntime.jsx(SectionIndex, { activeColor, activeKey, heading: indexHeading, itemHint, sections, testID, width: indexWidth, onSelect: select }) }),
3545
+ return /* @__PURE__ */ jsxRuntime.jsxs(reactNative.View, { style: [styles31.wide, dense && { gap: DENSE_WIDE_GAP }], testID, children: [
3546
+ /* @__PURE__ */ jsxRuntime.jsx(reactNative.View, { style: sticky, children: /* @__PURE__ */ jsxRuntime.jsx(SectionIndex, { activeColor, activeKey, dense, heading: indexHeading, itemHint, sections, testID, width: indexWidth, onSelect: select }) }),
3530
3547
  /* @__PURE__ */ jsxRuntime.jsx(reactNative.View, { style: [styles31.column, gap], children: sections.map((entry) => /* @__PURE__ */ jsxRuntime.jsx(reactNative.View, { nativeID: sectionAnchorId(testID, entry.key), testID: sectionAnchorId(testID, entry.key), children: entry.content }, entry.key)) })
3531
3548
  ] });
3532
3549
  };