@dloizides/ui-layout 1.50.0 → 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.d.mts +2 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.js +69 -35
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +69 -35
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -1369,10 +1369,11 @@ interface UnderlineTabsProps {
|
|
|
1369
1369
|
accessibilityLabel: string;
|
|
1370
1370
|
accessibilityHint?: string;
|
|
1371
1371
|
underlineColor?: string;
|
|
1372
|
+
fadeColor?: string;
|
|
1372
1373
|
testID?: string;
|
|
1373
1374
|
}
|
|
1374
1375
|
/** A full-width tab strip with an underline on the selected tab and an optional count per tab. */
|
|
1375
|
-
declare const UnderlineTabs: ({ tabs, activeKey, onChange, accessibilityLabel, accessibilityHint, underlineColor, testID }: UnderlineTabsProps) => React.ReactElement;
|
|
1376
|
+
declare const UnderlineTabs: ({ tabs, activeKey, onChange, accessibilityLabel, accessibilityHint, underlineColor, fadeColor, testID }: UnderlineTabsProps) => React.ReactElement;
|
|
1376
1377
|
|
|
1377
1378
|
interface WidgetCardProps {
|
|
1378
1379
|
title: string;
|
package/dist/index.d.ts
CHANGED
|
@@ -1369,10 +1369,11 @@ interface UnderlineTabsProps {
|
|
|
1369
1369
|
accessibilityLabel: string;
|
|
1370
1370
|
accessibilityHint?: string;
|
|
1371
1371
|
underlineColor?: string;
|
|
1372
|
+
fadeColor?: string;
|
|
1372
1373
|
testID?: string;
|
|
1373
1374
|
}
|
|
1374
1375
|
/** A full-width tab strip with an underline on the selected tab and an optional count per tab. */
|
|
1375
|
-
declare const UnderlineTabs: ({ tabs, activeKey, onChange, accessibilityLabel, accessibilityHint, underlineColor, testID }: UnderlineTabsProps) => React.ReactElement;
|
|
1376
|
+
declare const UnderlineTabs: ({ tabs, activeKey, onChange, accessibilityLabel, accessibilityHint, underlineColor, fadeColor, testID }: UnderlineTabsProps) => React.ReactElement;
|
|
1376
1377
|
|
|
1377
1378
|
interface WidgetCardProps {
|
|
1378
1379
|
title: string;
|
package/dist/index.js
CHANGED
|
@@ -283,14 +283,14 @@ function compositeOver(background, surface) {
|
|
|
283
283
|
if (top === null || base === null) return null;
|
|
284
284
|
return mix(base.channels, top.channels, top.alpha);
|
|
285
285
|
}
|
|
286
|
-
function readableRawInk(theme, ink, background) {
|
|
287
|
-
const
|
|
286
|
+
function readableRawInk(theme, ink, background, ground = theme.colors.surface) {
|
|
287
|
+
const visible = compositeOver(background, ground);
|
|
288
288
|
const source = designTokens.isHexColor(ink) ? parseHex(ink) : null;
|
|
289
289
|
const target = designTokens.isHexColor(theme.colors.text) ? parseHex(theme.colors.text) : null;
|
|
290
|
-
if (
|
|
290
|
+
if (visible === null || source === null || target === null) return ink;
|
|
291
291
|
for (let step = 0; step <= MIX_STEPS; step += 1) {
|
|
292
292
|
const candidate = step === 0 ? ink : mix(source.channels, target.channels, step / MIX_STEPS);
|
|
293
|
-
if (designTokens.contrastRatio(candidate,
|
|
293
|
+
if (designTokens.contrastRatio(candidate, visible) >= designTokens.AA_NORMAL_TEXT_RATIO) return candidate;
|
|
294
294
|
}
|
|
295
295
|
return theme.colors.text;
|
|
296
296
|
}
|
|
@@ -2804,6 +2804,11 @@ var CopyStatus = /* @__PURE__ */ ((CopyStatus2) => {
|
|
|
2804
2804
|
CopyStatus2["Failed"] = "failed";
|
|
2805
2805
|
return CopyStatus2;
|
|
2806
2806
|
})(CopyStatus || {});
|
|
2807
|
+
function readableTone(tone, backgrounds, fallback) {
|
|
2808
|
+
if (!designTokens.isHexColor(tone) || !backgrounds.every(designTokens.isHexColor)) return tone;
|
|
2809
|
+
const readable = backgrounds.every((background) => designTokens.contrastRatio(tone, background) >= designTokens.AA_NORMAL_TEXT_RATIO);
|
|
2810
|
+
return readable ? tone : fallback;
|
|
2811
|
+
}
|
|
2807
2812
|
|
|
2808
2813
|
// src/CopyableId/copyText.ts
|
|
2809
2814
|
var OFFSCREEN_POSITION = "-9999px";
|
|
@@ -2974,7 +2979,7 @@ var CopyableId = ({
|
|
|
2974
2979
|
accessibilityLabel: t(action.key),
|
|
2975
2980
|
accessibilityHint: t(LAYOUT_I18N.copyHint),
|
|
2976
2981
|
testID: `${testID}-copy`,
|
|
2977
|
-
style: [styles24.action, { color: action.color }],
|
|
2982
|
+
style: [styles24.action, { color: readableTone(action.color, [colors.background, colors.surfaceElevated], colors.text) }],
|
|
2978
2983
|
children: t(action.key)
|
|
2979
2984
|
}
|
|
2980
2985
|
)
|
|
@@ -3658,6 +3663,30 @@ var IdChip = ({ label, value, testID, accessibilityLabel, accessibilityHint, dis
|
|
|
3658
3663
|
}
|
|
3659
3664
|
);
|
|
3660
3665
|
};
|
|
3666
|
+
var STEP_WIDTH = 8;
|
|
3667
|
+
var STEP_OPACITIES = [0.35, 0.65, 0.9];
|
|
3668
|
+
var styles39 = reactNative.StyleSheet.create({
|
|
3669
|
+
fade: { bottom: 0, flexDirection: "row", position: "absolute", right: 0, top: 0 },
|
|
3670
|
+
step: { width: STEP_WIDTH }
|
|
3671
|
+
});
|
|
3672
|
+
var EdgeFadeStrip = ({ color }) => /* @__PURE__ */ jsxRuntime.jsx(reactNative.View, { "aria-hidden": true, pointerEvents: "none", style: styles39.fade, children: STEP_OPACITIES.map((opacity) => /* @__PURE__ */ jsxRuntime.jsx(reactNative.View, { style: [styles39.step, { backgroundColor: color, opacity }] }, opacity)) });
|
|
3673
|
+
var SLACK_PX = 1;
|
|
3674
|
+
function showsEdgeFade({ contentWidth, viewportWidth, offset }) {
|
|
3675
|
+
return contentWidth - viewportWidth - offset > SLACK_PX;
|
|
3676
|
+
}
|
|
3677
|
+
function useEdgeFade() {
|
|
3678
|
+
const [metrics, setMetrics] = React16.useState({ contentWidth: 0, viewportWidth: 0, offset: 0 });
|
|
3679
|
+
const onLayout = React16.useCallback((event) => {
|
|
3680
|
+
const viewportWidth = event.nativeEvent.layout.width;
|
|
3681
|
+
setMetrics((prev) => ({ ...prev, viewportWidth }));
|
|
3682
|
+
}, []);
|
|
3683
|
+
const onContentSizeChange = React16.useCallback((contentWidth) => setMetrics((prev) => ({ ...prev, contentWidth })), []);
|
|
3684
|
+
const onScroll = React16.useCallback((event) => {
|
|
3685
|
+
const offset = event.nativeEvent.contentOffset.x;
|
|
3686
|
+
setMetrics((prev) => ({ ...prev, offset }));
|
|
3687
|
+
}, []);
|
|
3688
|
+
return { visible: showsEdgeFade(metrics), onLayout, onContentSizeChange, onScroll };
|
|
3689
|
+
}
|
|
3661
3690
|
var UNDERLINE = 3;
|
|
3662
3691
|
var PAD_H4 = 12;
|
|
3663
3692
|
var GAP6 = 6;
|
|
@@ -3667,57 +3696,62 @@ var COUNT_MIN = 22;
|
|
|
3667
3696
|
var COUNT_PAD = 6;
|
|
3668
3697
|
var PILL = 999;
|
|
3669
3698
|
var DEFAULT_UNDERLINE_STEP = "700";
|
|
3670
|
-
var
|
|
3699
|
+
var SCROLL_THROTTLE_MS = 16;
|
|
3700
|
+
var styles40 = reactNative.StyleSheet.create({
|
|
3671
3701
|
count: { borderRadius: PILL, fontSize: COUNT_FONT, fontWeight: "700", minWidth: COUNT_MIN, paddingHorizontal: COUNT_PAD, textAlign: "center" },
|
|
3672
3702
|
label: { fontSize: FONT_SIZE4, fontWeight: "600" },
|
|
3673
|
-
strip: { borderBottomWidth: 1, width: "100%" },
|
|
3703
|
+
strip: { borderBottomWidth: 1, position: "relative", width: "100%" },
|
|
3674
3704
|
tab: { alignItems: "center", borderBottomWidth: UNDERLINE, flexDirection: "row", gap: GAP6, justifyContent: "center", minHeight: MIN_TARGET_PX, minWidth: MIN_TARGET_PX, paddingHorizontal: PAD_H4 }
|
|
3675
3705
|
});
|
|
3676
|
-
var UnderlineTabs = ({ tabs, activeKey, onChange, accessibilityLabel, accessibilityHint, underlineColor, testID }) => {
|
|
3706
|
+
var UnderlineTabs = ({ tabs, activeKey, onChange, accessibilityLabel, accessibilityHint, underlineColor, fadeColor, testID }) => {
|
|
3677
3707
|
const { theme } = uiFeedback.useUi();
|
|
3678
3708
|
const underline = underlineColor ?? theme.palette.primary[DEFAULT_UNDERLINE_STEP];
|
|
3679
|
-
|
|
3680
|
-
|
|
3681
|
-
|
|
3682
|
-
|
|
3683
|
-
|
|
3684
|
-
|
|
3685
|
-
|
|
3686
|
-
|
|
3687
|
-
|
|
3688
|
-
|
|
3689
|
-
|
|
3690
|
-
|
|
3691
|
-
|
|
3692
|
-
|
|
3693
|
-
|
|
3694
|
-
|
|
3695
|
-
|
|
3696
|
-
|
|
3697
|
-
|
|
3698
|
-
|
|
3699
|
-
|
|
3709
|
+
const fade = useEdgeFade();
|
|
3710
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(reactNative.View, { style: [styles40.strip, { borderBottomColor: theme.colors.border }], testID, children: [
|
|
3711
|
+
/* @__PURE__ */ jsxRuntime.jsx(reactNative.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) => {
|
|
3712
|
+
const selected = tab.key === activeKey;
|
|
3713
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
3714
|
+
reactNative.Pressable,
|
|
3715
|
+
{
|
|
3716
|
+
accessibilityHint: tab.accessibilityHint,
|
|
3717
|
+
accessibilityLabel: tab.label,
|
|
3718
|
+
accessibilityRole: "tab",
|
|
3719
|
+
accessibilityState: { selected },
|
|
3720
|
+
"aria-selected": selected,
|
|
3721
|
+
style: [styles40.tab, { borderBottomColor: selected ? underline : "transparent" }],
|
|
3722
|
+
testID: tab.testID,
|
|
3723
|
+
onPress: () => onChange(tab.key),
|
|
3724
|
+
children: [
|
|
3725
|
+
/* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { style: [styles40.label, { color: selected ? theme.colors.text : theme.colors.textSecondary }], children: tab.label }),
|
|
3726
|
+
tab.count === void 0 ? null : /* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { style: [styles40.count, { backgroundColor: theme.colors.border, color: theme.colors.text }], children: String(tab.count) })
|
|
3727
|
+
]
|
|
3728
|
+
},
|
|
3729
|
+
tab.key
|
|
3730
|
+
);
|
|
3731
|
+
}) }),
|
|
3732
|
+
fade.visible ? /* @__PURE__ */ jsxRuntime.jsx(EdgeFadeStrip, { color: fadeColor ?? theme.colors.background }) : null
|
|
3733
|
+
] });
|
|
3700
3734
|
};
|
|
3701
3735
|
var RADIUS3 = 12;
|
|
3702
3736
|
var PAD = 16;
|
|
3703
3737
|
var GAP7 = 8;
|
|
3704
3738
|
var TITLE_FONT = 15;
|
|
3705
|
-
var
|
|
3739
|
+
var styles41 = reactNative.StyleSheet.create({
|
|
3706
3740
|
card: { borderRadius: RADIUS3, borderWidth: 1, gap: GAP7, minWidth: 0, padding: PAD },
|
|
3707
|
-
footer: {
|
|
3741
|
+
footer: { alignItems: "flex-start", flexDirection: "row", flexWrap: "wrap", gap: GAP7 },
|
|
3708
3742
|
head: { alignItems: "center", flexDirection: "row", gap: GAP7 },
|
|
3709
3743
|
title: { flex: 1, fontSize: TITLE_FONT, fontWeight: "700" }
|
|
3710
3744
|
});
|
|
3711
3745
|
var WidgetCard = ({ title, children, icon, headerRight, footer, testID }) => {
|
|
3712
3746
|
const { theme } = uiFeedback.useUi();
|
|
3713
|
-
return /* @__PURE__ */ jsxRuntime.jsxs(reactNative.View, { style: [
|
|
3714
|
-
/* @__PURE__ */ jsxRuntime.jsxs(reactNative.View, { style:
|
|
3747
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(reactNative.View, { style: [styles41.card, { backgroundColor: theme.colors.surfaceElevated, borderColor: theme.colors.border }], testID, children: [
|
|
3748
|
+
/* @__PURE__ */ jsxRuntime.jsxs(reactNative.View, { style: styles41.head, children: [
|
|
3715
3749
|
icon === void 0 ? null : /* @__PURE__ */ jsxRuntime.jsx(reactNative.View, { "aria-hidden": true, children: icon }),
|
|
3716
|
-
/* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { accessibilityRole: "header", style: [
|
|
3750
|
+
/* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { accessibilityRole: "header", style: [styles41.title, { color: theme.colors.text }], children: title }),
|
|
3717
3751
|
headerRight
|
|
3718
3752
|
] }),
|
|
3719
3753
|
children,
|
|
3720
|
-
footer === void 0 ? null : /* @__PURE__ */ jsxRuntime.jsx(reactNative.View, { style:
|
|
3754
|
+
footer === void 0 ? null : /* @__PURE__ */ jsxRuntime.jsx(reactNative.View, { style: styles41.footer, children: footer })
|
|
3721
3755
|
] });
|
|
3722
3756
|
};
|
|
3723
3757
|
|