@dloizides/ui-layout 1.49.3 → 1.50.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.mjs CHANGED
@@ -277,14 +277,14 @@ function compositeOver(background, surface) {
277
277
  if (top === null || base === null) return null;
278
278
  return mix(base.channels, top.channels, top.alpha);
279
279
  }
280
- function readableRawInk(theme, ink, background) {
281
- const ground = compositeOver(background, theme.colors.surface);
280
+ function readableRawInk(theme, ink, background, ground = theme.colors.surface) {
281
+ const visible = compositeOver(background, ground);
282
282
  const source = isHexColor(ink) ? parseHex(ink) : null;
283
283
  const target = isHexColor(theme.colors.text) ? parseHex(theme.colors.text) : null;
284
- if (ground === null || source === null || target === null) return ink;
284
+ if (visible === null || source === null || target === null) return ink;
285
285
  for (let step = 0; step <= MIX_STEPS; step += 1) {
286
286
  const candidate = step === 0 ? ink : mix(source.channels, target.channels, step / MIX_STEPS);
287
- if (contrastRatio(candidate, ground) >= AA_NORMAL_TEXT_RATIO) return candidate;
287
+ if (contrastRatio(candidate, visible) >= AA_NORMAL_TEXT_RATIO) return candidate;
288
288
  }
289
289
  return theme.colors.text;
290
290
  }
@@ -450,12 +450,17 @@ var styles6 = StyleSheet.create({
450
450
  stackPane: { width: "100%", minWidth: 0 },
451
451
  fixedPane: { flexGrow: 0, flexShrink: 0, minWidth: 0 }
452
452
  });
453
+ function sidePaneStyle(weight, fixedWidth) {
454
+ if (fixedWidth === void 0) return [styles6.sidePane, { flexGrow: weight }];
455
+ return [styles6.fixedPane, { width: fixedWidth }];
456
+ }
453
457
  var SplitPanes = ({
454
458
  start,
455
459
  end,
456
460
  layout = "auto" /* Auto */,
457
461
  startWeight = DEFAULT_WEIGHT,
458
462
  endWeight = DEFAULT_WEIGHT,
463
+ startWidth,
459
464
  endWidth,
460
465
  gap = DEFAULT_GAP,
461
466
  breakpoint = LAYOUT_COLLAPSE_BREAKPOINT,
@@ -464,9 +469,8 @@ var SplitPanes = ({
464
469
  const { width } = useWindowDimensions();
465
470
  const isSide = isSplitSideBySide(layout, width, breakpoint);
466
471
  const container = useMemo(() => [isSide ? styles6.row : styles6.column, { gap }], [isSide, gap]);
467
- const startStyle = isSide ? [styles6.sidePane, { flexGrow: startWeight }] : styles6.stackPane;
468
- const sideEnd = endWidth === void 0 ? [styles6.sidePane, { flexGrow: endWeight }] : [styles6.fixedPane, { width: endWidth }];
469
- const endStyle = isSide ? sideEnd : styles6.stackPane;
472
+ const startStyle = isSide ? sidePaneStyle(startWeight, startWidth) : styles6.stackPane;
473
+ const endStyle = isSide ? sidePaneStyle(endWeight, endWidth) : styles6.stackPane;
470
474
  return /* @__PURE__ */ jsxs(View, { style: container, testID, children: [
471
475
  /* @__PURE__ */ jsx(View, { style: startStyle, testID: `${testID}-start`, children: start }),
472
476
  /* @__PURE__ */ jsx(View, { style: endStyle, testID: `${testID}-end`, children: end })
@@ -2794,6 +2798,11 @@ var CopyStatus = /* @__PURE__ */ ((CopyStatus2) => {
2794
2798
  CopyStatus2["Failed"] = "failed";
2795
2799
  return CopyStatus2;
2796
2800
  })(CopyStatus || {});
2801
+ function readableTone(tone, backgrounds, fallback) {
2802
+ if (!isHexColor(tone) || !backgrounds.every(isHexColor)) return tone;
2803
+ const readable = backgrounds.every((background) => contrastRatio(tone, background) >= AA_NORMAL_TEXT_RATIO);
2804
+ return readable ? tone : fallback;
2805
+ }
2797
2806
 
2798
2807
  // src/CopyableId/copyText.ts
2799
2808
  var OFFSCREEN_POSITION = "-9999px";
@@ -2964,7 +2973,7 @@ var CopyableId = ({
2964
2973
  accessibilityLabel: t(action.key),
2965
2974
  accessibilityHint: t(LAYOUT_I18N.copyHint),
2966
2975
  testID: `${testID}-copy`,
2967
- style: [styles24.action, { color: action.color }],
2976
+ style: [styles24.action, { color: readableTone(action.color, [colors.background, colors.surfaceElevated], colors.text) }],
2968
2977
  children: t(action.key)
2969
2978
  }
2970
2979
  )
@@ -3292,6 +3301,12 @@ var ListRow = ({
3292
3301
  ] });
3293
3302
  };
3294
3303
 
3304
+ // src/ListRow/utils/rowSelection.ts
3305
+ function rowSelection(isDesktop, rowKey, keys) {
3306
+ if (isDesktop) return { selected: keys.shownKey === rowKey, style: "accent-bar" /* AccentBar */ };
3307
+ return { selected: keys.selectedKey === rowKey, style: "outline" /* Outline */ };
3308
+ }
3309
+
3295
3310
  // src/SectionIndexLayout/ChipOverflow.ts
3296
3311
  var ChipOverflow = /* @__PURE__ */ ((ChipOverflow2) => {
3297
3312
  ChipOverflow2["Wrap"] = "wrap";
@@ -3642,6 +3657,30 @@ var IdChip = ({ label, value, testID, accessibilityLabel, accessibilityHint, dis
3642
3657
  }
3643
3658
  );
3644
3659
  };
3660
+ var STEP_WIDTH = 8;
3661
+ var STEP_OPACITIES = [0.35, 0.65, 0.9];
3662
+ var styles39 = StyleSheet.create({
3663
+ fade: { bottom: 0, flexDirection: "row", position: "absolute", right: 0, top: 0 },
3664
+ step: { width: STEP_WIDTH }
3665
+ });
3666
+ var EdgeFadeStrip = ({ color }) => /* @__PURE__ */ jsx(View, { "aria-hidden": true, pointerEvents: "none", style: styles39.fade, children: STEP_OPACITIES.map((opacity) => /* @__PURE__ */ jsx(View, { style: [styles39.step, { backgroundColor: color, opacity }] }, opacity)) });
3667
+ var SLACK_PX = 1;
3668
+ function showsEdgeFade({ contentWidth, viewportWidth, offset }) {
3669
+ return contentWidth - viewportWidth - offset > SLACK_PX;
3670
+ }
3671
+ function useEdgeFade() {
3672
+ const [metrics, setMetrics] = useState({ contentWidth: 0, viewportWidth: 0, offset: 0 });
3673
+ const onLayout = useCallback((event) => {
3674
+ const viewportWidth = event.nativeEvent.layout.width;
3675
+ setMetrics((prev) => ({ ...prev, viewportWidth }));
3676
+ }, []);
3677
+ const onContentSizeChange = useCallback((contentWidth) => setMetrics((prev) => ({ ...prev, contentWidth })), []);
3678
+ const onScroll = useCallback((event) => {
3679
+ const offset = event.nativeEvent.contentOffset.x;
3680
+ setMetrics((prev) => ({ ...prev, offset }));
3681
+ }, []);
3682
+ return { visible: showsEdgeFade(metrics), onLayout, onContentSizeChange, onScroll };
3683
+ }
3645
3684
  var UNDERLINE = 3;
3646
3685
  var PAD_H4 = 12;
3647
3686
  var GAP6 = 6;
@@ -3651,60 +3690,65 @@ var COUNT_MIN = 22;
3651
3690
  var COUNT_PAD = 6;
3652
3691
  var PILL = 999;
3653
3692
  var DEFAULT_UNDERLINE_STEP = "700";
3654
- var styles39 = StyleSheet.create({
3693
+ var SCROLL_THROTTLE_MS = 16;
3694
+ var styles40 = StyleSheet.create({
3655
3695
  count: { borderRadius: PILL, fontSize: COUNT_FONT, fontWeight: "700", minWidth: COUNT_MIN, paddingHorizontal: COUNT_PAD, textAlign: "center" },
3656
3696
  label: { fontSize: FONT_SIZE4, fontWeight: "600" },
3657
- strip: { borderBottomWidth: 1, width: "100%" },
3697
+ strip: { borderBottomWidth: 1, position: "relative", width: "100%" },
3658
3698
  tab: { alignItems: "center", borderBottomWidth: UNDERLINE, flexDirection: "row", gap: GAP6, justifyContent: "center", minHeight: MIN_TARGET_PX, minWidth: MIN_TARGET_PX, paddingHorizontal: PAD_H4 }
3659
3699
  });
3660
- var UnderlineTabs = ({ tabs, activeKey, onChange, accessibilityLabel, accessibilityHint, underlineColor, testID }) => {
3700
+ var UnderlineTabs = ({ tabs, activeKey, onChange, accessibilityLabel, accessibilityHint, underlineColor, fadeColor, testID }) => {
3661
3701
  const { theme } = useUi();
3662
3702
  const underline = underlineColor ?? theme.palette.primary[DEFAULT_UNDERLINE_STEP];
3663
- return /* @__PURE__ */ jsx(View, { style: [styles39.strip, { borderBottomColor: theme.colors.border }], testID, children: /* @__PURE__ */ jsx(ScrollView, { horizontal: true, accessibilityHint, accessibilityRole: "tablist", "aria-label": accessibilityLabel, showsHorizontalScrollIndicator: false, children: tabs.map((tab) => {
3664
- const selected = tab.key === activeKey;
3665
- return /* @__PURE__ */ jsxs(
3666
- Pressable,
3667
- {
3668
- accessibilityHint: tab.accessibilityHint,
3669
- accessibilityLabel: tab.label,
3670
- accessibilityRole: "tab",
3671
- accessibilityState: { selected },
3672
- "aria-selected": selected,
3673
- style: [styles39.tab, { borderBottomColor: selected ? underline : "transparent" }],
3674
- testID: tab.testID,
3675
- onPress: () => onChange(tab.key),
3676
- children: [
3677
- /* @__PURE__ */ jsx(Text, { style: [styles39.label, { color: selected ? theme.colors.text : theme.colors.textSecondary }], children: tab.label }),
3678
- tab.count === void 0 ? null : /* @__PURE__ */ jsx(Text, { style: [styles39.count, { backgroundColor: theme.colors.border, color: theme.colors.text }], children: String(tab.count) })
3679
- ]
3680
- },
3681
- tab.key
3682
- );
3683
- }) }) });
3703
+ const fade = useEdgeFade();
3704
+ return /* @__PURE__ */ jsxs(View, { style: [styles40.strip, { borderBottomColor: theme.colors.border }], testID, children: [
3705
+ /* @__PURE__ */ jsx(ScrollView, { horizontal: true, accessibilityHint, accessibilityRole: "tablist", "aria-label": accessibilityLabel, scrollEventThrottle: SCROLL_THROTTLE_MS, showsHorizontalScrollIndicator: false, onContentSizeChange: fade.onContentSizeChange, onLayout: fade.onLayout, onScroll: fade.onScroll, children: tabs.map((tab) => {
3706
+ const selected = tab.key === activeKey;
3707
+ return /* @__PURE__ */ jsxs(
3708
+ Pressable,
3709
+ {
3710
+ accessibilityHint: tab.accessibilityHint,
3711
+ accessibilityLabel: tab.label,
3712
+ accessibilityRole: "tab",
3713
+ accessibilityState: { selected },
3714
+ "aria-selected": selected,
3715
+ style: [styles40.tab, { borderBottomColor: selected ? underline : "transparent" }],
3716
+ testID: tab.testID,
3717
+ onPress: () => onChange(tab.key),
3718
+ children: [
3719
+ /* @__PURE__ */ jsx(Text, { style: [styles40.label, { color: selected ? theme.colors.text : theme.colors.textSecondary }], children: tab.label }),
3720
+ tab.count === void 0 ? null : /* @__PURE__ */ jsx(Text, { style: [styles40.count, { backgroundColor: theme.colors.border, color: theme.colors.text }], children: String(tab.count) })
3721
+ ]
3722
+ },
3723
+ tab.key
3724
+ );
3725
+ }) }),
3726
+ fade.visible ? /* @__PURE__ */ jsx(EdgeFadeStrip, { color: fadeColor ?? theme.colors.background }) : null
3727
+ ] });
3684
3728
  };
3685
3729
  var RADIUS3 = 12;
3686
3730
  var PAD = 16;
3687
3731
  var GAP7 = 8;
3688
3732
  var TITLE_FONT = 15;
3689
- var styles40 = StyleSheet.create({
3733
+ var styles41 = StyleSheet.create({
3690
3734
  card: { borderRadius: RADIUS3, borderWidth: 1, gap: GAP7, minWidth: 0, padding: PAD },
3691
- footer: { borderRadius: GAP7, borderWidth: 1, gap: GAP7, padding: PAD / 2 + GAP7 / 2 },
3735
+ footer: { alignItems: "flex-start", flexDirection: "row", flexWrap: "wrap", gap: GAP7 },
3692
3736
  head: { alignItems: "center", flexDirection: "row", gap: GAP7 },
3693
3737
  title: { flex: 1, fontSize: TITLE_FONT, fontWeight: "700" }
3694
3738
  });
3695
3739
  var WidgetCard = ({ title, children, icon, headerRight, footer, testID }) => {
3696
3740
  const { theme } = useUi();
3697
- return /* @__PURE__ */ jsxs(View, { style: [styles40.card, { backgroundColor: theme.colors.surfaceElevated, borderColor: theme.colors.border }], testID, children: [
3698
- /* @__PURE__ */ jsxs(View, { style: styles40.head, children: [
3741
+ return /* @__PURE__ */ jsxs(View, { style: [styles41.card, { backgroundColor: theme.colors.surfaceElevated, borderColor: theme.colors.border }], testID, children: [
3742
+ /* @__PURE__ */ jsxs(View, { style: styles41.head, children: [
3699
3743
  icon === void 0 ? null : /* @__PURE__ */ jsx(View, { "aria-hidden": true, children: icon }),
3700
- /* @__PURE__ */ jsx(Text, { accessibilityRole: "header", style: [styles40.title, { color: theme.colors.text }], children: title }),
3744
+ /* @__PURE__ */ jsx(Text, { accessibilityRole: "header", style: [styles41.title, { color: theme.colors.text }], children: title }),
3701
3745
  headerRight
3702
3746
  ] }),
3703
3747
  children,
3704
- footer === void 0 ? null : /* @__PURE__ */ jsx(View, { style: [styles40.footer, { backgroundColor: theme.colors.background, borderColor: theme.colors.border }], children: footer })
3748
+ footer === void 0 ? null : /* @__PURE__ */ jsx(View, { style: styles41.footer, children: footer })
3705
3749
  ] });
3706
3750
  };
3707
3751
 
3708
- export { A4_PAGE, API_COMMIT_SEPARATOR, Accordion, AccordionItem, AppText, BUILD_INFO_PREFIX, BadgeTone, BottomSheet, Breadcrumb, BuildInfoFooter, COPY_FEEDBACK_MS, ChipOverflow, ConfirmDialog, ConfirmDialogFocus, CopyStatus, CopyableId, CountBadge, DEFAULT_BILLING_ROUTE, DayCard, DropdownVariant, ELLIPSIS, FigureStrip, FormDialog, HEADER_STACK_BREAKPOINT, Heading, IdChip, LAYOUT_COLLAPSE_BREAKPOINT, LAYOUT_I18N, LAYOUT_TEST_IDS, ListRow, MIN_TARGET_PX, MODAL_FOOTER_STACK_BELOW, Modal, ModalDropdown, ModalShell, PageFrame, RecordActionButton, RecordHeader, RowSelectedStyle, SECTION_INDEX_BREAKPOINT, ScreenColumn, Section, SectionChips, SectionDensity, SectionIndex, SectionIndexLayout, SectionVariant, SegmentedControl, SelectedMarker, SideSheet, SplitLayout, SplitPanes, StatusBadge, StickyPreview, TYPE_SCALE_BREAKPOINT, Tabs, TabsCollapsedTrigger, TextKind, Timeline, ToggleSection, TruncatedText, UnderlineTabs, UpgradePrompt, WidgetCard, copyText, figureCell, formatBuildInfo, formatCount, formatUrlForDisplay, isKeyboardOpen, isModalFooterStacked, isRecordHeaderCompact, isSplitSideBySide, isWideWebViewport, pageScale, resolveActiveKey, resolveRowLook, resolveToneColors, scaledFrame, shortenCommit, trimTrailingSlash, truncateMiddle, useApiCommit, useCopyToClipboard, useFocusTrap, useIsWideViewport, useListRowTone, useVisibleViewport };
3752
+ export { A4_PAGE, API_COMMIT_SEPARATOR, Accordion, AccordionItem, AppText, BUILD_INFO_PREFIX, BadgeTone, BottomSheet, Breadcrumb, BuildInfoFooter, COPY_FEEDBACK_MS, ChipOverflow, ConfirmDialog, ConfirmDialogFocus, CopyStatus, CopyableId, CountBadge, DEFAULT_BILLING_ROUTE, DayCard, DropdownVariant, ELLIPSIS, FigureStrip, FormDialog, HEADER_STACK_BREAKPOINT, Heading, IdChip, LAYOUT_COLLAPSE_BREAKPOINT, LAYOUT_I18N, LAYOUT_TEST_IDS, ListRow, MIN_TARGET_PX, MODAL_FOOTER_STACK_BELOW, Modal, ModalDropdown, ModalShell, PageFrame, RecordActionButton, RecordHeader, RowSelectedStyle, SECTION_INDEX_BREAKPOINT, ScreenColumn, Section, SectionChips, SectionDensity, SectionIndex, SectionIndexLayout, SectionVariant, SegmentedControl, SelectedMarker, SideSheet, SplitLayout, SplitPanes, StatusBadge, StickyPreview, TYPE_SCALE_BREAKPOINT, Tabs, TabsCollapsedTrigger, TextKind, Timeline, ToggleSection, TruncatedText, UnderlineTabs, UpgradePrompt, WidgetCard, copyText, figureCell, formatBuildInfo, formatCount, formatUrlForDisplay, isKeyboardOpen, isModalFooterStacked, isRecordHeaderCompact, isSplitSideBySide, isWideWebViewport, pageScale, resolveActiveKey, resolveRowLook, resolveToneColors, rowSelection, scaledFrame, shortenCommit, trimTrailingSlash, truncateMiddle, useApiCommit, useCopyToClipboard, useFocusTrap, useIsWideViewport, useListRowTone, useVisibleViewport };
3709
3753
  //# sourceMappingURL=index.mjs.map
3710
3754
  //# sourceMappingURL=index.mjs.map