@dloizides/ui-layout 1.35.0 → 1.36.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/dist/index.d.mts +61 -1
- package/dist/index.d.ts +61 -1
- package/dist/index.js +236 -0
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +233 -1
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -2390,7 +2390,239 @@ var BuildInfoFooter = ({
|
|
|
2390
2390
|
}
|
|
2391
2391
|
);
|
|
2392
2392
|
};
|
|
2393
|
+
var SIZE = 22;
|
|
2394
|
+
var BORDER = 2;
|
|
2395
|
+
var GLYPH_SIZE = 14;
|
|
2396
|
+
var GLYPH_LINE = 16;
|
|
2397
|
+
var TICK = "\u2713";
|
|
2398
|
+
var styles21 = StyleSheet.create({
|
|
2399
|
+
circle: {
|
|
2400
|
+
width: SIZE,
|
|
2401
|
+
height: SIZE,
|
|
2402
|
+
borderRadius: SIZE / 2,
|
|
2403
|
+
borderWidth: BORDER,
|
|
2404
|
+
alignItems: "center",
|
|
2405
|
+
justifyContent: "center"
|
|
2406
|
+
},
|
|
2407
|
+
glyph: { fontSize: GLYPH_SIZE, fontWeight: "700", lineHeight: GLYPH_LINE }
|
|
2408
|
+
});
|
|
2409
|
+
var CheckMark = ({ filled, accent, ring, glyphColor, testID }) => /* @__PURE__ */ jsx(
|
|
2410
|
+
View,
|
|
2411
|
+
{
|
|
2412
|
+
"aria-hidden": true,
|
|
2413
|
+
accessibilityElementsHidden: true,
|
|
2414
|
+
importantForAccessibility: "no-hide-descendants",
|
|
2415
|
+
style: [styles21.circle, { borderColor: filled ? accent : ring, backgroundColor: filled ? accent : void 0 }],
|
|
2416
|
+
testID,
|
|
2417
|
+
children: filled ? /* @__PURE__ */ jsx(Text, { style: [styles21.glyph, { color: glyphColor }], children: TICK }) : null
|
|
2418
|
+
}
|
|
2419
|
+
);
|
|
2420
|
+
var ListRowToneContext = createContext(null);
|
|
2421
|
+
function useListRowTone() {
|
|
2422
|
+
return useContext(ListRowToneContext);
|
|
2423
|
+
}
|
|
2424
|
+
function useRowPalette() {
|
|
2425
|
+
const { colors, palette, semantic } = useUi().theme;
|
|
2426
|
+
const accent = palette.primary["500"];
|
|
2427
|
+
const tint = palette.primary["50"] ?? colors.surface;
|
|
2428
|
+
return {
|
|
2429
|
+
accent,
|
|
2430
|
+
accentTint: tint,
|
|
2431
|
+
background: colors.background,
|
|
2432
|
+
surface: colors.surface,
|
|
2433
|
+
border: colors.border,
|
|
2434
|
+
text: colors.text,
|
|
2435
|
+
hover: tint,
|
|
2436
|
+
pressed: palette.primary["100"] ?? colors.surfaceElevated,
|
|
2437
|
+
focus: semantic.info?.["500"] ?? accent
|
|
2438
|
+
};
|
|
2439
|
+
}
|
|
2440
|
+
|
|
2441
|
+
// src/ListRow/RowSelectedStyle.ts
|
|
2442
|
+
var RowSelectedStyle = /* @__PURE__ */ ((RowSelectedStyle2) => {
|
|
2443
|
+
RowSelectedStyle2["Surface"] = "surface";
|
|
2444
|
+
RowSelectedStyle2["AccentBar"] = "accent-bar";
|
|
2445
|
+
RowSelectedStyle2["Filled"] = "filled";
|
|
2446
|
+
RowSelectedStyle2["Raised"] = "raised";
|
|
2447
|
+
RowSelectedStyle2["Outline"] = "outline";
|
|
2448
|
+
RowSelectedStyle2["Check"] = "check";
|
|
2449
|
+
return RowSelectedStyle2;
|
|
2450
|
+
})(RowSelectedStyle || {});
|
|
2451
|
+
|
|
2452
|
+
// src/ListRow/utils/focusVisible.ts
|
|
2453
|
+
function canMatch(target) {
|
|
2454
|
+
return typeof target === "object" && target !== null && typeof target.matches === "function";
|
|
2455
|
+
}
|
|
2456
|
+
function isFocusVisible(target) {
|
|
2457
|
+
if (!canMatch(target)) return true;
|
|
2458
|
+
try {
|
|
2459
|
+
return target.matches(":focus-visible");
|
|
2460
|
+
} catch {
|
|
2461
|
+
return true;
|
|
2462
|
+
}
|
|
2463
|
+
}
|
|
2464
|
+
|
|
2465
|
+
// src/ListRow/utils/rowLook.ts
|
|
2466
|
+
var BAR_WIDTH = 4;
|
|
2467
|
+
var OUTLINE_WIDTH = 2;
|
|
2468
|
+
var FOCUS_GAP = 2;
|
|
2469
|
+
var FOCUS_WIDTH = 4;
|
|
2470
|
+
var CARD_RADIUS = 8;
|
|
2471
|
+
var CARD_INSET_V = 4;
|
|
2472
|
+
var CARD_INSET_H = 8;
|
|
2473
|
+
var CARD_SHADOW = "0px 2px 8px rgba(20, 30, 50, 0.16)";
|
|
2474
|
+
var TRANSPARENT2 = "transparent";
|
|
2475
|
+
function inset(width, color) {
|
|
2476
|
+
return `inset 0px 0px 0px ${String(width)}px ${color}`;
|
|
2477
|
+
}
|
|
2478
|
+
function interactionFill(state, palette) {
|
|
2479
|
+
if (state.pressed) return palette.pressed;
|
|
2480
|
+
if (state.hovered) return palette.hover;
|
|
2481
|
+
return void 0;
|
|
2482
|
+
}
|
|
2483
|
+
function selectedContainer(style, palette) {
|
|
2484
|
+
switch (style) {
|
|
2485
|
+
case "accent-bar" /* AccentBar */:
|
|
2486
|
+
return { backgroundColor: palette.accentTint, borderLeftColor: palette.accent };
|
|
2487
|
+
case "filled" /* Filled */:
|
|
2488
|
+
return { backgroundColor: palette.accent };
|
|
2489
|
+
case "raised" /* Raised */:
|
|
2490
|
+
return { backgroundColor: palette.background, borderColor: palette.accent, boxShadow: CARD_SHADOW };
|
|
2491
|
+
case "outline" /* Outline */:
|
|
2492
|
+
return { backgroundColor: palette.background, boxShadow: inset(OUTLINE_WIDTH, palette.accent) };
|
|
2493
|
+
case "check" /* Check */:
|
|
2494
|
+
return { backgroundColor: palette.background };
|
|
2495
|
+
default:
|
|
2496
|
+
return { backgroundColor: palette.surface };
|
|
2497
|
+
}
|
|
2498
|
+
}
|
|
2499
|
+
function baseContainer(style) {
|
|
2500
|
+
if (style === "accent-bar" /* AccentBar */) return { borderLeftWidth: BAR_WIDTH, borderLeftColor: TRANSPARENT2 };
|
|
2501
|
+
if (style !== "raised" /* Raised */) return {};
|
|
2502
|
+
return {
|
|
2503
|
+
borderWidth: 1,
|
|
2504
|
+
borderColor: TRANSPARENT2,
|
|
2505
|
+
borderRadius: CARD_RADIUS,
|
|
2506
|
+
marginVertical: CARD_INSET_V,
|
|
2507
|
+
marginHorizontal: CARD_INSET_H
|
|
2508
|
+
};
|
|
2509
|
+
}
|
|
2510
|
+
function withFocus(container, focused, palette) {
|
|
2511
|
+
if (!focused) return container;
|
|
2512
|
+
const ring = `${inset(FOCUS_GAP, palette.background)}, ${inset(FOCUS_WIDTH, palette.focus)}`;
|
|
2513
|
+
const existing = typeof container.boxShadow === "string" ? container.boxShadow : void 0;
|
|
2514
|
+
const keepsInset = existing?.startsWith("inset") === true;
|
|
2515
|
+
return { ...container, boxShadow: keepsInset ? `${ring}, ${String(existing)}` : ring };
|
|
2516
|
+
}
|
|
2517
|
+
function resolveRowLook(style, state, palette) {
|
|
2518
|
+
const inverse = state.selected && style === "filled" /* Filled */;
|
|
2519
|
+
const selected = state.selected ? selectedContainer(style, palette) : {};
|
|
2520
|
+
const fill = inverse ? void 0 : interactionFill(state, palette);
|
|
2521
|
+
const fillStyle = fill === void 0 ? {} : { backgroundColor: fill };
|
|
2522
|
+
const container = { ...baseContainer(style), ...selected, ...fillStyle };
|
|
2523
|
+
const accentsTitle = state.selected && style === "accent-bar" /* AccentBar */;
|
|
2524
|
+
const textColor = inverse ? palette.background : palette.text;
|
|
2525
|
+
return {
|
|
2526
|
+
container: withFocus(container, state.focused, palette),
|
|
2527
|
+
titleColor: accentsTitle ? palette.accent : textColor,
|
|
2528
|
+
textColor,
|
|
2529
|
+
inverse,
|
|
2530
|
+
showCheck: style === "check" /* Check */,
|
|
2531
|
+
checkFilled: style === "check" /* Check */ && state.selected
|
|
2532
|
+
};
|
|
2533
|
+
}
|
|
2534
|
+
var FONT = 15;
|
|
2535
|
+
var PAD_H = 16;
|
|
2536
|
+
var PAD_V = 12;
|
|
2537
|
+
var GAP = 4;
|
|
2538
|
+
var MARK_GAP = 12;
|
|
2539
|
+
var LINE_GAP = 8;
|
|
2540
|
+
var styles22 = StyleSheet.create({
|
|
2541
|
+
row: {
|
|
2542
|
+
flexDirection: "row",
|
|
2543
|
+
alignItems: "center",
|
|
2544
|
+
gap: MARK_GAP,
|
|
2545
|
+
paddingHorizontal: PAD_H,
|
|
2546
|
+
paddingVertical: PAD_V,
|
|
2547
|
+
borderTopWidth: 1,
|
|
2548
|
+
minHeight: MIN_TARGET_PX
|
|
2549
|
+
},
|
|
2550
|
+
body: { flex: 1, minWidth: 0, gap: GAP },
|
|
2551
|
+
line: { flexDirection: "row", justifyContent: "space-between", alignItems: "center", gap: LINE_GAP },
|
|
2552
|
+
shrink: { flexShrink: 1, minWidth: 0 },
|
|
2553
|
+
strong: { fontSize: FONT, fontWeight: "600" },
|
|
2554
|
+
badges: { flexDirection: "row", flexWrap: "wrap", gap: GAP, justifyContent: "flex-end" }
|
|
2555
|
+
});
|
|
2556
|
+
function pressedProps(selected) {
|
|
2557
|
+
return { "aria-pressed": selected };
|
|
2558
|
+
}
|
|
2559
|
+
function focusTarget(event) {
|
|
2560
|
+
return event?.nativeEvent?.target;
|
|
2561
|
+
}
|
|
2562
|
+
function slot(node, color, strong) {
|
|
2563
|
+
if (typeof node !== "string") return node;
|
|
2564
|
+
return /* @__PURE__ */ jsx(Text, { style: [styles22.shrink, strong ? styles22.strong : null, { color }], children: node });
|
|
2565
|
+
}
|
|
2566
|
+
var ListRow = ({
|
|
2567
|
+
title,
|
|
2568
|
+
trailing,
|
|
2569
|
+
meta,
|
|
2570
|
+
badges,
|
|
2571
|
+
after,
|
|
2572
|
+
selected,
|
|
2573
|
+
selectedStyle = "surface" /* Surface */,
|
|
2574
|
+
onPress,
|
|
2575
|
+
accessibilityLabel,
|
|
2576
|
+
accessibilityHint,
|
|
2577
|
+
testID
|
|
2578
|
+
}) => {
|
|
2579
|
+
const palette = useRowPalette();
|
|
2580
|
+
const { colors } = useUi().theme;
|
|
2581
|
+
const [focused, setFocused] = useState(false);
|
|
2582
|
+
const rest = resolveRowLook(selectedStyle, { selected, hovered: false, pressed: false, focused }, palette);
|
|
2583
|
+
const tone = useMemo(() => ({ textColor: rest.textColor, inverse: rest.inverse }), [rest.textColor, rest.inverse]);
|
|
2584
|
+
const checkTestId = testID === void 0 ? void 0 : `${testID}-check`;
|
|
2585
|
+
return /* @__PURE__ */ jsxs(ListRowToneContext.Provider, { value: tone, children: [
|
|
2586
|
+
/* @__PURE__ */ jsxs(
|
|
2587
|
+
Pressable,
|
|
2588
|
+
{
|
|
2589
|
+
accessibilityHint,
|
|
2590
|
+
accessibilityLabel,
|
|
2591
|
+
accessibilityRole: "button",
|
|
2592
|
+
accessibilityState: { selected },
|
|
2593
|
+
style: (state) => {
|
|
2594
|
+
const { pressed, hovered } = state;
|
|
2595
|
+
const look = resolveRowLook(selectedStyle, { selected, pressed, focused, hovered: hovered === true }, palette);
|
|
2596
|
+
return [styles22.row, { borderTopColor: colors.border }, look.container];
|
|
2597
|
+
},
|
|
2598
|
+
testID,
|
|
2599
|
+
onBlur: () => {
|
|
2600
|
+
setFocused(false);
|
|
2601
|
+
},
|
|
2602
|
+
onFocus: (event) => {
|
|
2603
|
+
setFocused(isFocusVisible(focusTarget(event)));
|
|
2604
|
+
},
|
|
2605
|
+
onPress,
|
|
2606
|
+
...pressedProps(selected),
|
|
2607
|
+
children: [
|
|
2608
|
+
rest.showCheck ? /* @__PURE__ */ jsx(CheckMark, { accent: palette.accent, filled: rest.checkFilled, glyphColor: palette.background, ring: palette.border, testID: checkTestId }) : null,
|
|
2609
|
+
/* @__PURE__ */ jsxs(View, { style: styles22.body, children: [
|
|
2610
|
+
/* @__PURE__ */ jsxs(View, { style: styles22.line, children: [
|
|
2611
|
+
slot(title, rest.titleColor, true),
|
|
2612
|
+
slot(trailing, rest.textColor, true)
|
|
2613
|
+
] }),
|
|
2614
|
+
/* @__PURE__ */ jsxs(View, { style: styles22.line, children: [
|
|
2615
|
+
/* @__PURE__ */ jsx(View, { style: styles22.shrink, children: slot(meta, rest.textColor, false) }),
|
|
2616
|
+
badges === void 0 ? null : /* @__PURE__ */ jsx(View, { style: styles22.badges, children: badges })
|
|
2617
|
+
] })
|
|
2618
|
+
] })
|
|
2619
|
+
]
|
|
2620
|
+
}
|
|
2621
|
+
),
|
|
2622
|
+
after ?? null
|
|
2623
|
+
] });
|
|
2624
|
+
};
|
|
2393
2625
|
|
|
2394
|
-
export { API_COMMIT_SEPARATOR, Accordion, AccordionItem, AppText, BUILD_INFO_PREFIX, BuildInfoFooter, COPY_FEEDBACK_MS, ConfirmDialog, CopyStatus, CopyableId, DEFAULT_BILLING_ROUTE, DropdownVariant, ELLIPSIS, Heading, LAYOUT_COLLAPSE_BREAKPOINT, LAYOUT_I18N, LAYOUT_TEST_IDS, MIN_TARGET_PX, Modal3 as Modal, ModalDropdown, ModalShell, ScreenColumn, Section, SectionVariant, SegmentedControl, SelectedMarker, StatusBadge, StickyPreview, TYPE_SCALE_BREAKPOINT, Tabs, TabsCollapsedTrigger, TextKind, TruncatedText, UpgradePrompt, copyText, formatBuildInfo, formatUrlForDisplay, isKeyboardOpen, isWideWebViewport, shortenCommit, trimTrailingSlash, truncateMiddle, useApiCommit, useCopyToClipboard, useFocusTrap, useIsWideViewport, useVisibleViewport };
|
|
2626
|
+
export { API_COMMIT_SEPARATOR, Accordion, AccordionItem, AppText, BUILD_INFO_PREFIX, BuildInfoFooter, COPY_FEEDBACK_MS, ConfirmDialog, CopyStatus, CopyableId, DEFAULT_BILLING_ROUTE, DropdownVariant, ELLIPSIS, Heading, LAYOUT_COLLAPSE_BREAKPOINT, LAYOUT_I18N, LAYOUT_TEST_IDS, ListRow, MIN_TARGET_PX, Modal3 as Modal, ModalDropdown, ModalShell, RowSelectedStyle, ScreenColumn, Section, SectionVariant, SegmentedControl, SelectedMarker, StatusBadge, StickyPreview, TYPE_SCALE_BREAKPOINT, Tabs, TabsCollapsedTrigger, TextKind, TruncatedText, UpgradePrompt, copyText, formatBuildInfo, formatUrlForDisplay, isKeyboardOpen, isWideWebViewport, resolveRowLook, shortenCommit, trimTrailingSlash, truncateMiddle, useApiCommit, useCopyToClipboard, useFocusTrap, useIsWideViewport, useListRowTone, useVisibleViewport };
|
|
2395
2627
|
//# sourceMappingURL=index.mjs.map
|
|
2396
2628
|
//# sourceMappingURL=index.mjs.map
|