@dloizides/ui-layout 1.60.1 → 1.61.0
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 +13 -4
- package/dist/index.d.ts +13 -4
- package/dist/index.js +41 -16
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +41 -16
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
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
|
-
|
|
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
|
|
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,29 @@ 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;
|
|
3430
|
+
var DENSE_LINE = 19;
|
|
3422
3431
|
var styles30 = StyleSheet.create({
|
|
3423
3432
|
root: { flexShrink: 0, gap: 2, alignSelf: "flex-start" },
|
|
3424
3433
|
heading: { fontSize: 12, fontWeight: "700", letterSpacing: 0.6, textTransform: "uppercase", paddingHorizontal: 10, paddingBottom: 6 },
|
|
3425
3434
|
item: { minHeight: MIN_TARGET_PX, justifyContent: "center", paddingHorizontal: 10, borderLeftWidth: ACTIVE_BAR, borderRadius: 6 },
|
|
3426
3435
|
label: { fontSize: 14 },
|
|
3427
|
-
labelActive: { fontWeight: "700" }
|
|
3436
|
+
labelActive: { fontWeight: "700" },
|
|
3437
|
+
denseRoot: { gap: 2 },
|
|
3438
|
+
denseHeading: { fontSize: 11, fontWeight: "600", letterSpacing: 0.66, lineHeight: 16, paddingBottom: 6 },
|
|
3439
|
+
denseItem: { minHeight: DENSE_TARGET_PX, paddingVertical: 6, paddingLeft: 7, paddingRight: 10, borderRadius: 7 },
|
|
3440
|
+
denseLabel: { fontSize: 13, lineHeight: DENSE_LINE },
|
|
3441
|
+
denseLabelActive: { fontWeight: "600" }
|
|
3428
3442
|
});
|
|
3429
3443
|
function ariaCurrent(active) {
|
|
3430
3444
|
return active ? { "aria-current": "location" } : {};
|
|
3431
3445
|
}
|
|
3432
|
-
var SectionIndex = ({ sections, activeKey, heading, itemHint, onSelect, testID, width = SECTION_INDEX_WIDTH, activeColor }) => {
|
|
3446
|
+
var SectionIndex = ({ sections, activeKey, heading, itemHint, onSelect, testID, width = SECTION_INDEX_WIDTH, activeColor, dense = false }) => {
|
|
3433
3447
|
const { theme } = useUi();
|
|
3434
3448
|
const { colors } = theme;
|
|
3435
3449
|
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 }),
|
|
3450
|
+
return /* @__PURE__ */ jsxs(View, { role: "navigation", accessibilityLabel: heading, style: [styles30.root, dense && styles30.denseRoot, { width }], testID: `${testID}-index`, children: [
|
|
3451
|
+
/* @__PURE__ */ jsx(Text, { style: [styles30.heading, dense && styles30.denseHeading, { color: colors.textSecondary }], children: heading }),
|
|
3438
3452
|
sections.map((entry) => {
|
|
3439
3453
|
const active = entry.key === activeKey;
|
|
3440
3454
|
return /* @__PURE__ */ jsx(
|
|
@@ -3444,10 +3458,10 @@ var SectionIndex = ({ sections, activeKey, heading, itemHint, onSelect, testID,
|
|
|
3444
3458
|
accessibilityRole: "link",
|
|
3445
3459
|
accessibilityLabel: entry.title,
|
|
3446
3460
|
accessibilityHint: itemHint,
|
|
3447
|
-
style: [styles30.item, { borderLeftColor: active ? bar : TRANSPARENT3, backgroundColor: active ? colors.surface : TRANSPARENT3 }],
|
|
3461
|
+
style: [styles30.item, dense && styles30.denseItem, { borderLeftColor: active ? bar : TRANSPARENT3, backgroundColor: active ? colors.surface : TRANSPARENT3 }],
|
|
3448
3462
|
testID: `${testID}-index-${entry.key}`,
|
|
3449
3463
|
onPress: () => onSelect(entry.key),
|
|
3450
|
-
children: /* @__PURE__ */ jsx(Text, { style: [styles30.label, active && styles30.labelActive, { color: active ? colors.text : colors.textSecondary }], children: entry.title })
|
|
3464
|
+
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
3465
|
},
|
|
3452
3466
|
entry.key
|
|
3453
3467
|
);
|
|
@@ -3472,11 +3486,17 @@ function scrollToSection(anchorId) {
|
|
|
3472
3486
|
}
|
|
3473
3487
|
var COMFORTABLE_GAP = 12;
|
|
3474
3488
|
var DENSE_GAP = 8;
|
|
3489
|
+
var DENSE_WIDE_GAP = 16;
|
|
3475
3490
|
var WEB_STICKY = { position: "sticky", top: 0 };
|
|
3491
|
+
var NO_STACK = Number.POSITIVE_INFINITY;
|
|
3476
3492
|
var styles31 = StyleSheet.create({
|
|
3477
3493
|
wide: { flexDirection: "row", alignItems: "flex-start", gap: 20 },
|
|
3478
3494
|
column: { flex: 1, minWidth: 0 }
|
|
3479
3495
|
});
|
|
3496
|
+
function toFold(breakpoint) {
|
|
3497
|
+
return typeof breakpoint === "number" ? { wide: breakpoint, stackFrom: NO_STACK } : breakpoint;
|
|
3498
|
+
}
|
|
3499
|
+
var SectionColumn = ({ sections, testID, style }) => /* @__PURE__ */ jsx(View, { style, testID: `${testID}-column`, children: sections.map((entry) => /* @__PURE__ */ jsx(View, { nativeID: sectionAnchorId(testID, entry.key), testID: sectionAnchorId(testID, entry.key), children: entry.content }, entry.key)) });
|
|
3480
3500
|
var SectionIndexLayout = ({
|
|
3481
3501
|
sections,
|
|
3482
3502
|
indexHeading,
|
|
@@ -3491,11 +3511,15 @@ var SectionIndexLayout = ({
|
|
|
3491
3511
|
activeColor,
|
|
3492
3512
|
testID = "section-index"
|
|
3493
3513
|
}) => {
|
|
3494
|
-
const
|
|
3514
|
+
const fold = toFold(breakpoint);
|
|
3515
|
+
const wide = useIsWideViewport(fold.wide);
|
|
3516
|
+
const stacked = useIsWideViewport(fold.stackFrom);
|
|
3495
3517
|
const [picked, setPicked] = useState(void 0);
|
|
3496
3518
|
const activeKey = resolveActiveKey(sections, picked ?? (wide ? initialKey : collapsedKey ?? initialKey));
|
|
3497
|
-
const
|
|
3519
|
+
const dense = density === "dense" /* Dense */;
|
|
3520
|
+
const gap = { gap: dense ? DENSE_GAP : COMFORTABLE_GAP };
|
|
3498
3521
|
if (sections.length < 2) return /* @__PURE__ */ jsx(View, { testID, children: sections[0]?.content });
|
|
3522
|
+
if (!wide && stacked) return /* @__PURE__ */ jsx(View, { testID, children: /* @__PURE__ */ jsx(SectionColumn, { sections, style: gap, testID }) });
|
|
3499
3523
|
if (!wide) {
|
|
3500
3524
|
const active = sections.find((entry) => entry.key === activeKey);
|
|
3501
3525
|
return /* @__PURE__ */ jsxs(View, { style: gap, testID, children: [
|
|
@@ -3504,6 +3528,7 @@ var SectionIndexLayout = ({
|
|
|
3504
3528
|
{
|
|
3505
3529
|
activeColor,
|
|
3506
3530
|
activeKey,
|
|
3531
|
+
dense,
|
|
3507
3532
|
groupLabel: indexHeading,
|
|
3508
3533
|
itemHint,
|
|
3509
3534
|
overflow: chipOverflow,
|
|
@@ -3520,9 +3545,9 @@ var SectionIndexLayout = ({
|
|
|
3520
3545
|
scrollToSection(sectionAnchorId(testID, key));
|
|
3521
3546
|
};
|
|
3522
3547
|
const sticky = stickyIndex && Platform.OS === "web" ? WEB_STICKY : null;
|
|
3523
|
-
return /* @__PURE__ */ jsxs(View, { style: styles31.wide, testID, children: [
|
|
3524
|
-
/* @__PURE__ */ jsx(View, { style: sticky, children: /* @__PURE__ */ jsx(SectionIndex, { activeColor, activeKey, heading: indexHeading, itemHint, sections, testID, width: indexWidth, onSelect: select }) }),
|
|
3525
|
-
/* @__PURE__ */ jsx(
|
|
3548
|
+
return /* @__PURE__ */ jsxs(View, { style: [styles31.wide, dense && { gap: DENSE_WIDE_GAP }], testID, children: [
|
|
3549
|
+
/* @__PURE__ */ jsx(View, { style: sticky, children: /* @__PURE__ */ jsx(SectionIndex, { activeColor, activeKey, dense, heading: indexHeading, itemHint, sections, testID, width: indexWidth, onSelect: select }) }),
|
|
3550
|
+
/* @__PURE__ */ jsx(SectionColumn, { sections, style: StyleSheet.flatten([styles31.column, gap]), testID })
|
|
3526
3551
|
] });
|
|
3527
3552
|
};
|
|
3528
3553
|
|