@dloizides/ui-layout 1.34.0 → 1.36.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.mjs CHANGED
@@ -340,6 +340,7 @@ var StickyPreview = ({
340
340
  forceCompact = false,
341
341
  topOffset = 0,
342
342
  accessibilityLabel,
343
+ accessibilityHint,
343
344
  testID = LAYOUT_TEST_IDS.stickyPreview
344
345
  }) => {
345
346
  const { theme } = useUi();
@@ -355,6 +356,7 @@ var StickyPreview = ({
355
356
  /* @__PURE__ */ jsx(
356
357
  View,
357
358
  {
359
+ accessibilityHint,
358
360
  accessibilityLabel,
359
361
  role: "region",
360
362
  style: [
@@ -2388,7 +2390,223 @@ var BuildInfoFooter = ({
2388
2390
  }
2389
2391
  );
2390
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/rowLook.ts
2453
+ var BAR_WIDTH = 4;
2454
+ var OUTLINE_WIDTH = 2;
2455
+ var FOCUS_GAP = 2;
2456
+ var FOCUS_WIDTH = 4;
2457
+ var CARD_RADIUS = 8;
2458
+ var CARD_INSET_V = 4;
2459
+ var CARD_INSET_H = 8;
2460
+ var CARD_SHADOW = "0px 2px 8px rgba(20, 30, 50, 0.16)";
2461
+ var TRANSPARENT2 = "transparent";
2462
+ function inset(width, color) {
2463
+ return `inset 0px 0px 0px ${String(width)}px ${color}`;
2464
+ }
2465
+ function interactionFill(state, palette) {
2466
+ if (state.pressed) return palette.pressed;
2467
+ if (state.hovered) return palette.hover;
2468
+ return void 0;
2469
+ }
2470
+ function selectedContainer(style, palette) {
2471
+ switch (style) {
2472
+ case "accent-bar" /* AccentBar */:
2473
+ return { backgroundColor: palette.accentTint, borderLeftColor: palette.accent };
2474
+ case "filled" /* Filled */:
2475
+ return { backgroundColor: palette.accent };
2476
+ case "raised" /* Raised */:
2477
+ return { backgroundColor: palette.background, borderColor: palette.accent, boxShadow: CARD_SHADOW };
2478
+ case "outline" /* Outline */:
2479
+ return { backgroundColor: palette.background, boxShadow: inset(OUTLINE_WIDTH, palette.accent) };
2480
+ case "check" /* Check */:
2481
+ return { backgroundColor: palette.background };
2482
+ default:
2483
+ return { backgroundColor: palette.surface };
2484
+ }
2485
+ }
2486
+ function baseContainer(style) {
2487
+ if (style === "accent-bar" /* AccentBar */) return { borderLeftWidth: BAR_WIDTH, borderLeftColor: TRANSPARENT2 };
2488
+ if (style !== "raised" /* Raised */) return {};
2489
+ return {
2490
+ borderWidth: 1,
2491
+ borderColor: TRANSPARENT2,
2492
+ borderRadius: CARD_RADIUS,
2493
+ marginVertical: CARD_INSET_V,
2494
+ marginHorizontal: CARD_INSET_H
2495
+ };
2496
+ }
2497
+ function withFocus(container, focused, palette) {
2498
+ if (!focused) return container;
2499
+ const ring = `${inset(FOCUS_GAP, palette.background)}, ${inset(FOCUS_WIDTH, palette.focus)}`;
2500
+ const existing = typeof container.boxShadow === "string" ? container.boxShadow : void 0;
2501
+ const keepsInset = existing?.startsWith("inset") === true;
2502
+ return { ...container, boxShadow: keepsInset ? `${ring}, ${String(existing)}` : ring };
2503
+ }
2504
+ function resolveRowLook(style, state, palette) {
2505
+ const inverse = state.selected && style === "filled" /* Filled */;
2506
+ const selected = state.selected ? selectedContainer(style, palette) : {};
2507
+ const fill = inverse ? void 0 : interactionFill(state, palette);
2508
+ const fillStyle = fill === void 0 ? {} : { backgroundColor: fill };
2509
+ const container = { ...baseContainer(style), ...selected, ...fillStyle };
2510
+ const accentsTitle = state.selected && style === "accent-bar" /* AccentBar */;
2511
+ const textColor = inverse ? palette.background : palette.text;
2512
+ return {
2513
+ container: withFocus(container, state.focused, palette),
2514
+ titleColor: accentsTitle ? palette.accent : textColor,
2515
+ textColor,
2516
+ inverse,
2517
+ showCheck: style === "check" /* Check */,
2518
+ checkFilled: style === "check" /* Check */ && state.selected
2519
+ };
2520
+ }
2521
+ var FONT = 15;
2522
+ var PAD_H = 16;
2523
+ var PAD_V = 12;
2524
+ var GAP = 4;
2525
+ var MARK_GAP = 12;
2526
+ var LINE_GAP = 8;
2527
+ var styles22 = StyleSheet.create({
2528
+ row: {
2529
+ flexDirection: "row",
2530
+ alignItems: "center",
2531
+ gap: MARK_GAP,
2532
+ paddingHorizontal: PAD_H,
2533
+ paddingVertical: PAD_V,
2534
+ borderTopWidth: 1,
2535
+ minHeight: MIN_TARGET_PX
2536
+ },
2537
+ body: { flex: 1, minWidth: 0, gap: GAP },
2538
+ line: { flexDirection: "row", justifyContent: "space-between", alignItems: "center", gap: LINE_GAP },
2539
+ shrink: { flexShrink: 1, minWidth: 0 },
2540
+ strong: { fontSize: FONT, fontWeight: "600" },
2541
+ badges: { flexDirection: "row", flexWrap: "wrap", gap: GAP, justifyContent: "flex-end" }
2542
+ });
2543
+ function pressedProps(selected) {
2544
+ return { "aria-pressed": selected };
2545
+ }
2546
+ function slot(node, color, strong) {
2547
+ if (typeof node !== "string") return node;
2548
+ return /* @__PURE__ */ jsx(Text, { style: [styles22.shrink, strong ? styles22.strong : null, { color }], children: node });
2549
+ }
2550
+ var ListRow = ({
2551
+ title,
2552
+ trailing,
2553
+ meta,
2554
+ badges,
2555
+ after,
2556
+ selected,
2557
+ selectedStyle = "surface" /* Surface */,
2558
+ onPress,
2559
+ accessibilityLabel,
2560
+ accessibilityHint,
2561
+ testID
2562
+ }) => {
2563
+ const palette = useRowPalette();
2564
+ const { colors } = useUi().theme;
2565
+ const [focused, setFocused] = useState(false);
2566
+ const rest = resolveRowLook(selectedStyle, { selected, hovered: false, pressed: false, focused }, palette);
2567
+ const tone = useMemo(() => ({ textColor: rest.textColor, inverse: rest.inverse }), [rest.textColor, rest.inverse]);
2568
+ const checkTestId = testID === void 0 ? void 0 : `${testID}-check`;
2569
+ return /* @__PURE__ */ jsxs(ListRowToneContext.Provider, { value: tone, children: [
2570
+ /* @__PURE__ */ jsxs(
2571
+ Pressable,
2572
+ {
2573
+ accessibilityHint,
2574
+ accessibilityLabel,
2575
+ accessibilityRole: "button",
2576
+ accessibilityState: { selected },
2577
+ style: (state) => {
2578
+ const { pressed, hovered } = state;
2579
+ const look = resolveRowLook(selectedStyle, { selected, pressed, focused, hovered: hovered === true }, palette);
2580
+ return [styles22.row, { borderTopColor: colors.border }, look.container];
2581
+ },
2582
+ testID,
2583
+ onBlur: () => {
2584
+ setFocused(false);
2585
+ },
2586
+ onFocus: () => {
2587
+ setFocused(true);
2588
+ },
2589
+ onPress,
2590
+ ...pressedProps(selected),
2591
+ children: [
2592
+ rest.showCheck ? /* @__PURE__ */ jsx(CheckMark, { accent: palette.accent, filled: rest.checkFilled, glyphColor: palette.background, ring: palette.border, testID: checkTestId }) : null,
2593
+ /* @__PURE__ */ jsxs(View, { style: styles22.body, children: [
2594
+ /* @__PURE__ */ jsxs(View, { style: styles22.line, children: [
2595
+ slot(title, rest.titleColor, true),
2596
+ slot(trailing, rest.textColor, true)
2597
+ ] }),
2598
+ /* @__PURE__ */ jsxs(View, { style: styles22.line, children: [
2599
+ /* @__PURE__ */ jsx(View, { style: styles22.shrink, children: slot(meta, rest.textColor, false) }),
2600
+ badges === void 0 ? null : /* @__PURE__ */ jsx(View, { style: styles22.badges, children: badges })
2601
+ ] })
2602
+ ] })
2603
+ ]
2604
+ }
2605
+ ),
2606
+ after ?? null
2607
+ ] });
2608
+ };
2391
2609
 
2392
- 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 };
2610
+ 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 };
2393
2611
  //# sourceMappingURL=index.mjs.map
2394
2612
  //# sourceMappingURL=index.mjs.map