@dloizides/ui-layout 1.60.1 → 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/dist/index.d.mts CHANGED
@@ -1261,8 +1261,10 @@ interface SectionIndexProps {
1261
1261
  testID: string;
1262
1262
  width?: number;
1263
1263
  activeColor?: string;
1264
+ /** Dense: 11/600 heading, 13 px items at a 24 px desktop target. */
1265
+ dense?: boolean;
1264
1266
  }
1265
- 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;
1266
1268
 
1267
1269
  interface SectionChipsProps {
1268
1270
  sections: ReadonlyArray<SectionIndexEntry>;
@@ -1271,10 +1273,12 @@ interface SectionChipsProps {
1271
1273
  itemHint: string;
1272
1274
  overflow?: ChipOverflow;
1273
1275
  activeColor?: string;
1276
+ /** Dense: 13 px labels, 12 px chip padding, 6 px gutter, active label on the surface colour. */
1277
+ dense?: boolean;
1274
1278
  onSelect: (key: string) => void;
1275
1279
  testID: string;
1276
1280
  }
1277
- 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;
1278
1282
 
1279
1283
  declare const SECTION_INDEX_BREAKPOINT = 1024;
1280
1284
  declare function resolveActiveKey(sections: ReadonlyArray<SectionIndexEntry>, wanted: string | undefined): string;
package/dist/index.d.ts CHANGED
@@ -1261,8 +1261,10 @@ interface SectionIndexProps {
1261
1261
  testID: string;
1262
1262
  width?: number;
1263
1263
  activeColor?: string;
1264
+ /** Dense: 11/600 heading, 13 px items at a 24 px desktop target. */
1265
+ dense?: boolean;
1264
1266
  }
1265
- 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;
1266
1268
 
1267
1269
  interface SectionChipsProps {
1268
1270
  sections: ReadonlyArray<SectionIndexEntry>;
@@ -1271,10 +1273,12 @@ interface SectionChipsProps {
1271
1273
  itemHint: string;
1272
1274
  overflow?: ChipOverflow;
1273
1275
  activeColor?: string;
1276
+ /** Dense: 13 px labels, 12 px chip padding, 6 px gutter, active label on the surface colour. */
1277
+ dense?: boolean;
1274
1278
  onSelect: (key: string) => void;
1275
1279
  testID: string;
1276
1280
  }
1277
- 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;
1278
1282
 
1279
1283
  declare const SECTION_INDEX_BREAKPOINT = 1024;
1280
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 },
@@ -3500,7 +3514,8 @@ var SectionIndexLayout = ({
3500
3514
  const wide = useIsWideViewport(breakpoint);
3501
3515
  const [picked, setPicked] = React16.useState(void 0);
3502
3516
  const activeKey = resolveActiveKey(sections, picked ?? (wide ? initialKey : collapsedKey ?? initialKey));
3503
- const gap = { gap: density === "dense" /* Dense */ ? DENSE_GAP : COMFORTABLE_GAP };
3517
+ const dense = density === "dense" /* Dense */;
3518
+ const gap = { gap: dense ? DENSE_GAP : COMFORTABLE_GAP };
3504
3519
  if (sections.length < 2) return /* @__PURE__ */ jsxRuntime.jsx(reactNative.View, { testID, children: sections[0]?.content });
3505
3520
  if (!wide) {
3506
3521
  const active = sections.find((entry) => entry.key === activeKey);
@@ -3510,6 +3525,7 @@ var SectionIndexLayout = ({
3510
3525
  {
3511
3526
  activeColor,
3512
3527
  activeKey,
3528
+ dense,
3513
3529
  groupLabel: indexHeading,
3514
3530
  itemHint,
3515
3531
  overflow: chipOverflow,
@@ -3526,8 +3542,8 @@ var SectionIndexLayout = ({
3526
3542
  scrollToSection(sectionAnchorId(testID, key));
3527
3543
  };
3528
3544
  const sticky = stickyIndex && reactNative.Platform.OS === "web" ? WEB_STICKY : null;
3529
- return /* @__PURE__ */ jsxRuntime.jsxs(reactNative.View, { style: styles31.wide, testID, children: [
3530
- /* @__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 }) }),
3531
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)) })
3532
3548
  ] });
3533
3549
  };