@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/dist/index.mjs CHANGED
@@ -3380,17 +3380,24 @@ var styles29 = StyleSheet.create({
3380
3380
  root: { flexDirection: "row", flexWrap: "wrap", gap: 8 },
3381
3381
  scrollRow: { flexDirection: "row", flexWrap: "nowrap", gap: 8 },
3382
3382
  chip: { minHeight: MIN_TARGET_PX, justifyContent: "center", paddingHorizontal: 14, borderRadius: 999, borderWidth: 1 },
3383
- label: { fontSize: 14, fontWeight: "600" }
3383
+ label: { fontSize: 14, fontWeight: "600" },
3384
+ denseRow: { gap: 6 },
3385
+ denseChip: { paddingHorizontal: 12 },
3386
+ denseLabel: { fontSize: 13 }
3384
3387
  });
3385
3388
  function ariaSelected(selected) {
3386
3389
  return { "aria-selected": selected };
3387
3390
  }
3388
- var SectionChips = ({ sections, activeKey, groupLabel, itemHint, overflow = "wrap" /* Wrap */, activeColor, onSelect, testID }) => {
3391
+ function activeInk(active, dense, colors) {
3392
+ if (!active) return colors.text;
3393
+ return dense ? colors.surface : colors.background;
3394
+ }
3395
+ var SectionChips = ({ sections, activeKey, groupLabel, itemHint, overflow = "wrap" /* Wrap */, activeColor, dense = false, onSelect, testID }) => {
3389
3396
  const { theme } = useUi();
3390
3397
  const { colors } = theme;
3391
3398
  const fill = activeColor ?? colors.text;
3392
3399
  const scroll = overflow === "scroll" /* Scroll */;
3393
- const row = /* @__PURE__ */ jsx(View, { accessibilityRole: "tablist", accessibilityLabel: groupLabel, style: scroll ? styles29.scrollRow : styles29.root, testID: `${testID}-chips`, children: sections.map((entry) => {
3400
+ const row = /* @__PURE__ */ jsx(View, { accessibilityRole: "tablist", accessibilityLabel: groupLabel, style: [scroll ? styles29.scrollRow : styles29.root, dense && styles29.denseRow], testID: `${testID}-chips`, children: sections.map((entry) => {
3394
3401
  const active = entry.key === activeKey;
3395
3402
  return /* @__PURE__ */ jsx(
3396
3403
  Pressable,
@@ -3399,10 +3406,10 @@ var SectionChips = ({ sections, activeKey, groupLabel, itemHint, overflow = "wra
3399
3406
  accessibilityRole: "tab",
3400
3407
  accessibilityLabel: entry.title,
3401
3408
  accessibilityHint: itemHint,
3402
- style: [styles29.chip, { borderColor: colors.border, backgroundColor: active ? fill : colors.background }],
3409
+ style: [styles29.chip, dense && styles29.denseChip, { borderColor: colors.border, backgroundColor: active ? fill : colors.background }],
3403
3410
  testID: `${testID}-chip-${entry.key}`,
3404
3411
  onPress: () => onSelect(entry.key),
3405
- children: /* @__PURE__ */ jsx(Text, { style: [styles29.label, { color: active ? colors.background : colors.text }], children: entry.title })
3412
+ children: /* @__PURE__ */ jsx(Text, { style: [styles29.label, dense && styles29.denseLabel, { color: activeInk(active, dense, colors) }], children: entry.title })
3406
3413
  },
3407
3414
  entry.key
3408
3415
  );
@@ -3419,22 +3426,28 @@ var SectionDensity = /* @__PURE__ */ ((SectionDensity2) => {
3419
3426
  var SECTION_INDEX_WIDTH = 200;
3420
3427
  var ACTIVE_BAR = 3;
3421
3428
  var TRANSPARENT3 = "transparent";
3429
+ var DENSE_TARGET_PX = 24;
3422
3430
  var styles30 = StyleSheet.create({
3423
3431
  root: { flexShrink: 0, gap: 2, alignSelf: "flex-start" },
3424
3432
  heading: { fontSize: 12, fontWeight: "700", letterSpacing: 0.6, textTransform: "uppercase", paddingHorizontal: 10, paddingBottom: 6 },
3425
3433
  item: { minHeight: MIN_TARGET_PX, justifyContent: "center", paddingHorizontal: 10, borderLeftWidth: ACTIVE_BAR, borderRadius: 6 },
3426
3434
  label: { fontSize: 14 },
3427
- labelActive: { fontWeight: "700" }
3435
+ labelActive: { fontWeight: "700" },
3436
+ denseRoot: { gap: 0 },
3437
+ denseHeading: { fontSize: 11, fontWeight: "600", paddingBottom: 10 },
3438
+ denseItem: { minHeight: DENSE_TARGET_PX, paddingVertical: 7, paddingHorizontal: 7 },
3439
+ denseLabel: { fontSize: 13, lineHeight: 19 },
3440
+ denseLabelActive: { fontWeight: "600" }
3428
3441
  });
3429
3442
  function ariaCurrent(active) {
3430
3443
  return active ? { "aria-current": "location" } : {};
3431
3444
  }
3432
- var SectionIndex = ({ sections, activeKey, heading, itemHint, onSelect, testID, width = SECTION_INDEX_WIDTH, activeColor }) => {
3445
+ var SectionIndex = ({ sections, activeKey, heading, itemHint, onSelect, testID, width = SECTION_INDEX_WIDTH, activeColor, dense = false }) => {
3433
3446
  const { theme } = useUi();
3434
3447
  const { colors } = theme;
3435
3448
  const bar = activeColor ?? colors.text;
3436
- return /* @__PURE__ */ jsxs(View, { role: "navigation", accessibilityLabel: heading, style: [styles30.root, { width }], testID: `${testID}-index`, children: [
3437
- /* @__PURE__ */ jsx(Text, { style: [styles30.heading, { color: colors.textSecondary }], children: heading }),
3449
+ return /* @__PURE__ */ jsxs(View, { role: "navigation", accessibilityLabel: heading, style: [styles30.root, dense && styles30.denseRoot, { width }], testID: `${testID}-index`, children: [
3450
+ /* @__PURE__ */ jsx(Text, { style: [styles30.heading, dense && styles30.denseHeading, { color: colors.textSecondary }], children: heading }),
3438
3451
  sections.map((entry) => {
3439
3452
  const active = entry.key === activeKey;
3440
3453
  return /* @__PURE__ */ jsx(
@@ -3444,10 +3457,10 @@ var SectionIndex = ({ sections, activeKey, heading, itemHint, onSelect, testID,
3444
3457
  accessibilityRole: "link",
3445
3458
  accessibilityLabel: entry.title,
3446
3459
  accessibilityHint: itemHint,
3447
- style: [styles30.item, { borderLeftColor: active ? bar : TRANSPARENT3, backgroundColor: active ? colors.surface : TRANSPARENT3 }],
3460
+ style: [styles30.item, dense && styles30.denseItem, { borderLeftColor: active ? bar : TRANSPARENT3, backgroundColor: active ? colors.surface : TRANSPARENT3 }],
3448
3461
  testID: `${testID}-index-${entry.key}`,
3449
3462
  onPress: () => onSelect(entry.key),
3450
- children: /* @__PURE__ */ jsx(Text, { style: [styles30.label, active && styles30.labelActive, { color: active ? colors.text : colors.textSecondary }], children: entry.title })
3463
+ children: /* @__PURE__ */ jsx(Text, { style: [styles30.label, active && styles30.labelActive, dense && styles30.denseLabel, dense && active && styles30.denseLabelActive, { color: active ? colors.text : colors.textSecondary }], children: entry.title })
3451
3464
  },
3452
3465
  entry.key
3453
3466
  );
@@ -3472,6 +3485,7 @@ function scrollToSection(anchorId) {
3472
3485
  }
3473
3486
  var COMFORTABLE_GAP = 12;
3474
3487
  var DENSE_GAP = 8;
3488
+ var DENSE_WIDE_GAP = 14;
3475
3489
  var WEB_STICKY = { position: "sticky", top: 0 };
3476
3490
  var styles31 = StyleSheet.create({
3477
3491
  wide: { flexDirection: "row", alignItems: "flex-start", gap: 20 },
@@ -3482,6 +3496,7 @@ var SectionIndexLayout = ({
3482
3496
  indexHeading,
3483
3497
  itemHint,
3484
3498
  initialKey,
3499
+ collapsedKey,
3485
3500
  breakpoint = SECTION_INDEX_BREAKPOINT,
3486
3501
  density = "comfortable" /* Comfortable */,
3487
3502
  stickyIndex = false,
@@ -3491,9 +3506,10 @@ var SectionIndexLayout = ({
3491
3506
  testID = "section-index"
3492
3507
  }) => {
3493
3508
  const wide = useIsWideViewport(breakpoint);
3494
- const [picked, setPicked] = useState(initialKey);
3495
- const activeKey = resolveActiveKey(sections, picked);
3496
- const gap = { gap: density === "dense" /* Dense */ ? DENSE_GAP : COMFORTABLE_GAP };
3509
+ const [picked, setPicked] = useState(void 0);
3510
+ const activeKey = resolveActiveKey(sections, picked ?? (wide ? initialKey : collapsedKey ?? initialKey));
3511
+ const dense = density === "dense" /* Dense */;
3512
+ const gap = { gap: dense ? DENSE_GAP : COMFORTABLE_GAP };
3497
3513
  if (sections.length < 2) return /* @__PURE__ */ jsx(View, { testID, children: sections[0]?.content });
3498
3514
  if (!wide) {
3499
3515
  const active = sections.find((entry) => entry.key === activeKey);
@@ -3503,6 +3519,7 @@ var SectionIndexLayout = ({
3503
3519
  {
3504
3520
  activeColor,
3505
3521
  activeKey,
3522
+ dense,
3506
3523
  groupLabel: indexHeading,
3507
3524
  itemHint,
3508
3525
  overflow: chipOverflow,
@@ -3519,8 +3536,8 @@ var SectionIndexLayout = ({
3519
3536
  scrollToSection(sectionAnchorId(testID, key));
3520
3537
  };
3521
3538
  const sticky = stickyIndex && Platform.OS === "web" ? WEB_STICKY : null;
3522
- return /* @__PURE__ */ jsxs(View, { style: styles31.wide, testID, children: [
3523
- /* @__PURE__ */ jsx(View, { style: sticky, children: /* @__PURE__ */ jsx(SectionIndex, { activeColor, activeKey, heading: indexHeading, itemHint, sections, testID, width: indexWidth, onSelect: select }) }),
3539
+ return /* @__PURE__ */ jsxs(View, { style: [styles31.wide, dense && { gap: DENSE_WIDE_GAP }], testID, children: [
3540
+ /* @__PURE__ */ jsx(View, { style: sticky, children: /* @__PURE__ */ jsx(SectionIndex, { activeColor, activeKey, dense, heading: indexHeading, itemHint, sections, testID, width: indexWidth, onSelect: select }) }),
3524
3541
  /* @__PURE__ */ jsx(View, { style: [styles31.column, gap], children: sections.map((entry) => /* @__PURE__ */ jsx(View, { nativeID: sectionAnchorId(testID, entry.key), testID: sectionAnchorId(testID, entry.key), children: entry.content }, entry.key)) })
3525
3542
  ] });
3526
3543
  };