@dloizides/ui-feedback 1.26.0 → 1.27.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/CHANGELOG.md +7 -0
- package/dist/index.d.mts +62 -1
- package/dist/index.d.ts +62 -1
- package/dist/index.js +172 -8
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +168 -12
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { createContext, useMemo, useContext, useState, useRef, useEffect, useCallback, useId, useSyncExternalStore, Component } from 'react';
|
|
2
|
-
import { jsx, jsxs } from 'react/jsx-runtime';
|
|
3
|
-
import { Platform, StyleSheet, TouchableOpacity, Text, View, ActivityIndicator, Modal, useWindowDimensions,
|
|
2
|
+
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
3
|
+
import { Platform, StyleSheet, TouchableOpacity, Text, View, ActivityIndicator, Modal, useWindowDimensions, Pressable, Animated } from 'react-native';
|
|
4
4
|
import { MIN_TOUCH_TARGET_PX } from '@dloizides/a11y';
|
|
5
5
|
import { Skeleton } from '@dloizides/ui-motion';
|
|
6
|
-
import { Z_INDEX, resolveOnBrand, UI_DEEP_STEP, UI_MAIN_STEP, isHexColor, canCarryAccessibleInk } from '@dloizides/design-tokens';
|
|
6
|
+
import { Z_INDEX, isFocusVisible, resolveFocusRingColor, resolveOnBrand, UI_DEEP_STEP, UI_MAIN_STEP, focusRingOutline, isHexColor, canCarryAccessibleInk } from '@dloizides/design-tokens';
|
|
7
7
|
import { createPortal } from 'react-dom';
|
|
8
8
|
import { LocalModelPhase } from '@dloizides/text-generation';
|
|
9
9
|
|
|
@@ -624,6 +624,32 @@ function confirmFill(theme, destructive) {
|
|
|
624
624
|
function confirmInk(theme, destructive) {
|
|
625
625
|
return resolveOnBrand(confirmFill(theme, destructive));
|
|
626
626
|
}
|
|
627
|
+
var LIGHT_BRAND_STEP = "300";
|
|
628
|
+
var NO_RING = { outlineWidth: 0 };
|
|
629
|
+
var NATIVE_RING = {};
|
|
630
|
+
function buildDialogRingStyle(visible, color, isWeb) {
|
|
631
|
+
if (!isWeb) return NATIVE_RING;
|
|
632
|
+
return visible ? focusRingOutline(color) : NO_RING;
|
|
633
|
+
}
|
|
634
|
+
function dialogRingColor(theme) {
|
|
635
|
+
const colors = theme.colors;
|
|
636
|
+
return resolveFocusRingColor({
|
|
637
|
+
focusRing: colors.focusRing,
|
|
638
|
+
primary: theme.palette.primary["500"],
|
|
639
|
+
primaryLight: theme.palette.primary[LIGHT_BRAND_STEP],
|
|
640
|
+
text: colors.text,
|
|
641
|
+
background: colors.background
|
|
642
|
+
});
|
|
643
|
+
}
|
|
644
|
+
function useDialogFocusRing(color) {
|
|
645
|
+
const [visible, setVisible] = useState(false);
|
|
646
|
+
const onFocus = useCallback((event) => {
|
|
647
|
+
setVisible(isFocusVisible(event?.target));
|
|
648
|
+
}, []);
|
|
649
|
+
const onBlur = useCallback(() => setVisible(false), []);
|
|
650
|
+
const ringStyle = useMemo(() => buildDialogRingStyle(visible, color, Platform.OS === "web"), [visible, color]);
|
|
651
|
+
return { ringStyle, onFocus, onBlur };
|
|
652
|
+
}
|
|
627
653
|
var DIALOG_MAX_WIDTH = 400;
|
|
628
654
|
var styles8 = StyleSheet.create({
|
|
629
655
|
overlay: {
|
|
@@ -692,6 +718,8 @@ var ConfirmDialog = ({
|
|
|
692
718
|
const { theme, t } = useFeedbackUi();
|
|
693
719
|
const titleId = useId();
|
|
694
720
|
const innerDialogRole = Platform.OS === "web" ? void 0 : "dialog";
|
|
721
|
+
const cancelRing = useDialogFocusRing(dialogRingColor(theme));
|
|
722
|
+
const confirmRing = useDialogFocusRing(dialogRingColor(theme));
|
|
695
723
|
const colorStyles = useMemo(
|
|
696
724
|
() => ({
|
|
697
725
|
dialog: { backgroundColor: theme.colors.surfaceElevated },
|
|
@@ -737,9 +765,12 @@ var ConfirmDialog = ({
|
|
|
737
765
|
style: [
|
|
738
766
|
styles8.button,
|
|
739
767
|
styles8.cancelButton,
|
|
740
|
-
colorStyles.cancelButton
|
|
768
|
+
colorStyles.cancelButton,
|
|
769
|
+
cancelRing.ringStyle
|
|
741
770
|
],
|
|
742
771
|
testID: FEEDBACK_TEST_IDS.cancelConfirmButton,
|
|
772
|
+
onBlur: cancelRing.onBlur,
|
|
773
|
+
onFocus: cancelRing.onFocus,
|
|
743
774
|
onPress: onCancel,
|
|
744
775
|
children: /* @__PURE__ */ jsx(Text, { style: [styles8.buttonText, colorStyles.cancelButtonText], children: resolvedCancelLabel })
|
|
745
776
|
}
|
|
@@ -756,9 +787,12 @@ var ConfirmDialog = ({
|
|
|
756
787
|
styles8.button,
|
|
757
788
|
styles8.confirmButton,
|
|
758
789
|
colorStyles.confirmButton,
|
|
759
|
-
isConfirmDisabled && styles8.disabledButton
|
|
790
|
+
isConfirmDisabled && styles8.disabledButton,
|
|
791
|
+
confirmRing.ringStyle
|
|
760
792
|
],
|
|
761
793
|
testID: FEEDBACK_TEST_IDS.confirmButton,
|
|
794
|
+
onBlur: confirmRing.onBlur,
|
|
795
|
+
onFocus: confirmRing.onFocus,
|
|
762
796
|
onPress: onConfirm,
|
|
763
797
|
children: loading ? /* @__PURE__ */ jsx(
|
|
764
798
|
ActivityIndicator,
|
|
@@ -1783,23 +1817,23 @@ var LocalModelGate = ({
|
|
|
1783
1817
|
const consent = useCallback(() => {
|
|
1784
1818
|
model.consent().catch(() => void 0);
|
|
1785
1819
|
}, [model]);
|
|
1786
|
-
const { Card, Text:
|
|
1820
|
+
const { Card, Text: Text19, Button } = slots;
|
|
1787
1821
|
switch (phase) {
|
|
1788
1822
|
case LocalModelPhase.Checking:
|
|
1789
1823
|
return null;
|
|
1790
1824
|
case LocalModelPhase.Blocked:
|
|
1791
|
-
return /* @__PURE__ */ jsx(Card, { testID: testIds.blocked, children: /* @__PURE__ */ jsx(
|
|
1825
|
+
return /* @__PURE__ */ jsx(Card, { testID: testIds.blocked, children: /* @__PURE__ */ jsx(Text19, { children: labels.blocked(block) }) });
|
|
1792
1826
|
case LocalModelPhase.Offer:
|
|
1793
1827
|
return /* @__PURE__ */ jsxs(Card, { testID: testIds.offer, children: [
|
|
1794
|
-
/* @__PURE__ */ jsx(
|
|
1795
|
-
/* @__PURE__ */ jsx(
|
|
1828
|
+
/* @__PURE__ */ jsx(Text19, { heading: true, children: labels.title }),
|
|
1829
|
+
/* @__PURE__ */ jsx(Text19, { children: labels.offerBody }),
|
|
1796
1830
|
/* @__PURE__ */ jsx(Button, { hint: labels.consentHint, label: labels.consent, testID: testIds.consent, onPress: consent })
|
|
1797
1831
|
] });
|
|
1798
1832
|
case LocalModelPhase.Loading:
|
|
1799
|
-
return /* @__PURE__ */ jsx(Card, { testID: testIds.loading, children: /* @__PURE__ */ jsx(
|
|
1833
|
+
return /* @__PURE__ */ jsx(Card, { testID: testIds.loading, children: /* @__PURE__ */ jsx(Text19, { children: labels.loading(String(Math.round(progress * PERCENT2))) }) });
|
|
1800
1834
|
case LocalModelPhase.Failed:
|
|
1801
1835
|
return /* @__PURE__ */ jsxs(Card, { testID: testIds.failed, children: [
|
|
1802
|
-
/* @__PURE__ */ jsx(
|
|
1836
|
+
/* @__PURE__ */ jsx(Text19, { children: labels.failed }),
|
|
1803
1837
|
/* @__PURE__ */ jsx(Button, { hint: labels.consentHint, label: labels.retry, testID: testIds.consent, onPress: consent })
|
|
1804
1838
|
] });
|
|
1805
1839
|
case LocalModelPhase.Ready:
|
|
@@ -1807,7 +1841,129 @@ var LocalModelGate = ({
|
|
|
1807
1841
|
return children;
|
|
1808
1842
|
}
|
|
1809
1843
|
};
|
|
1844
|
+
var RADIUS2 = 8;
|
|
1845
|
+
var PAD = 12;
|
|
1846
|
+
var GAP = 8;
|
|
1847
|
+
var MIN_HIT = 44;
|
|
1848
|
+
var TITLE_FONT = 14;
|
|
1849
|
+
var DETAIL_FONT = 12;
|
|
1850
|
+
var styles19 = StyleSheet.create({
|
|
1851
|
+
detail: { fontSize: DETAIL_FONT },
|
|
1852
|
+
row: { alignItems: "center", flexDirection: "row", justifyContent: "space-between" },
|
|
1853
|
+
tile: { flexBasis: 0, flexGrow: 1, minWidth: 0 },
|
|
1854
|
+
title: { fontSize: TITLE_FONT, fontWeight: "600" },
|
|
1855
|
+
words: { flexShrink: 1, gap: 2 },
|
|
1856
|
+
wrap: { borderRadius: RADIUS2, borderWidth: 1, gap: GAP, minHeight: MIN_HIT, padding: PAD }
|
|
1857
|
+
});
|
|
1858
|
+
var CheckStatus = (props) => {
|
|
1859
|
+
const { title, detail, status, variant = "tile", onPress, accessibilityLabel, accessibilityHint, testID } = props;
|
|
1860
|
+
const { theme } = useFeedbackUi();
|
|
1861
|
+
const style = [styles19.wrap, variant === "tile" ? styles19.tile : styles19.row, { backgroundColor: theme.colors.surface, borderColor: theme.colors.border }];
|
|
1862
|
+
const body = /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
1863
|
+
/* @__PURE__ */ jsxs(View, { style: styles19.words, children: [
|
|
1864
|
+
/* @__PURE__ */ jsx(Text, { style: [styles19.title, { color: theme.colors.text }], children: title }),
|
|
1865
|
+
detail === void 0 ? null : /* @__PURE__ */ jsx(Text, { style: [styles19.detail, { color: theme.colors.textSecondary }], children: detail })
|
|
1866
|
+
] }),
|
|
1867
|
+
status
|
|
1868
|
+
] });
|
|
1869
|
+
if (onPress === void 0) {
|
|
1870
|
+
return /* @__PURE__ */ jsx(View, { accessibilityHint, accessibilityLabel, style, testID, children: body });
|
|
1871
|
+
}
|
|
1872
|
+
return /* @__PURE__ */ jsx(Pressable, { accessibilityHint, accessibilityLabel, accessibilityRole: "button", style, testID, onPress, children: body });
|
|
1873
|
+
};
|
|
1874
|
+
|
|
1875
|
+
// src/CheckStatus/pipelineVariant.ts
|
|
1876
|
+
var PIPELINE_COLLAPSE_BREAKPOINT = 768;
|
|
1877
|
+
function pipelineVariant(width, breakpoint = PIPELINE_COLLAPSE_BREAKPOINT) {
|
|
1878
|
+
return width >= breakpoint ? "tile" : "row";
|
|
1879
|
+
}
|
|
1880
|
+
var styles20 = StyleSheet.create({
|
|
1881
|
+
list: { gap: 8 },
|
|
1882
|
+
row: { flexDirection: "row", gap: 12 }
|
|
1883
|
+
});
|
|
1884
|
+
var CheckPipeline = ({ items, breakpoint, accessibilityLabel, accessibilityHint, testID }) => {
|
|
1885
|
+
const variant = pipelineVariant(useWindowDimensions().width, breakpoint);
|
|
1886
|
+
return /* @__PURE__ */ jsx(View, { accessibilityHint, accessibilityLabel, accessibilityRole: "summary", style: variant === "tile" ? styles20.row : styles20.list, testID, children: items.map(({ id, ...item }) => /* @__PURE__ */ jsx(CheckStatus, { ...item, variant }, id)) });
|
|
1887
|
+
};
|
|
1888
|
+
|
|
1889
|
+
// src/CheckStatus/semanticScale.ts
|
|
1890
|
+
function semanticScale(theme, name) {
|
|
1891
|
+
const found = theme.semantic[name];
|
|
1892
|
+
return found?.["500"];
|
|
1893
|
+
}
|
|
1894
|
+
|
|
1895
|
+
// src/ThresholdMeter/meterScale.ts
|
|
1896
|
+
var PERCENT3 = 100;
|
|
1897
|
+
function meterPercent(value, max) {
|
|
1898
|
+
return max > 0 ? clampPercent(value / max * PERCENT3) : 0;
|
|
1899
|
+
}
|
|
1900
|
+
function meetsThreshold(value, threshold, lowerPasses) {
|
|
1901
|
+
return lowerPasses ? value <= threshold : value >= threshold;
|
|
1902
|
+
}
|
|
1903
|
+
var TRACK_HEIGHT = 8;
|
|
1904
|
+
var MARKER_WIDTH = 2;
|
|
1905
|
+
var MARKER_HEIGHT = 16;
|
|
1906
|
+
var MARKER_TOP = -4;
|
|
1907
|
+
var RADIUS3 = 999;
|
|
1908
|
+
var FONT = 12;
|
|
1909
|
+
var styles21 = StyleSheet.create({
|
|
1910
|
+
fill: { borderRadius: RADIUS3, height: "100%" },
|
|
1911
|
+
head: { flexDirection: "row", flexWrap: "wrap", gap: 8, justifyContent: "space-between" },
|
|
1912
|
+
marker: { height: MARKER_HEIGHT, marginLeft: -MARKER_WIDTH / 2, position: "absolute", top: MARKER_TOP, width: MARKER_WIDTH },
|
|
1913
|
+
text: { fontSize: FONT, fontVariant: ["tabular-nums"] },
|
|
1914
|
+
track: { borderRadius: RADIUS3, height: TRACK_HEIGHT },
|
|
1915
|
+
wrap: { gap: 6 }
|
|
1916
|
+
});
|
|
1917
|
+
function partId(testID, part) {
|
|
1918
|
+
return testID === void 0 ? void 0 : `${testID}-${part}`;
|
|
1919
|
+
}
|
|
1920
|
+
var ThresholdMeter = (props) => {
|
|
1921
|
+
const { value, threshold, max = 1, lowerPasses = false, label, valueText, accessibilityHint, testID } = props;
|
|
1922
|
+
const { theme } = useFeedbackUi();
|
|
1923
|
+
const passes = meetsThreshold(value, threshold, lowerPasses);
|
|
1924
|
+
const fill = passes ? semanticScale(theme, "success") ?? theme.palette.primary["500"] : theme.semantic.error["500"];
|
|
1925
|
+
return /* @__PURE__ */ jsxs(View, { accessibilityHint, accessibilityLabel: label, "aria-valuemax": max, "aria-valuemin": 0, "aria-valuenow": value, "aria-valuetext": valueText, role: "meter", style: styles21.wrap, testID, children: [
|
|
1926
|
+
/* @__PURE__ */ jsxs(View, { style: styles21.head, children: [
|
|
1927
|
+
/* @__PURE__ */ jsx(Text, { style: [styles21.text, { color: theme.colors.textSecondary }], children: label }),
|
|
1928
|
+
/* @__PURE__ */ jsx(Text, { style: [styles21.text, { color: theme.colors.text }], children: valueText })
|
|
1929
|
+
] }),
|
|
1930
|
+
/* @__PURE__ */ jsxs(View, { style: [styles21.track, { backgroundColor: theme.colors.border }], children: [
|
|
1931
|
+
/* @__PURE__ */ jsx(View, { style: [styles21.fill, { backgroundColor: fill, width: `${meterPercent(value, max)}%` }], testID: partId(testID, "fill") }),
|
|
1932
|
+
/* @__PURE__ */ jsx(View, { style: [styles21.marker, { backgroundColor: theme.colors.text, left: `${meterPercent(threshold, max)}%` }], testID: partId(testID, "threshold") })
|
|
1933
|
+
] })
|
|
1934
|
+
] });
|
|
1935
|
+
};
|
|
1936
|
+
var RADIUS4 = 12;
|
|
1937
|
+
var PAD2 = 16;
|
|
1938
|
+
var GAP2 = 8;
|
|
1939
|
+
var STACK_GAP = 12;
|
|
1940
|
+
var TITLE_FONT2 = 15;
|
|
1941
|
+
var HEADING_FONT = 16;
|
|
1942
|
+
var MESSAGE_FONT = 14;
|
|
1943
|
+
var styles22 = StyleSheet.create({
|
|
1944
|
+
card: { borderRadius: RADIUS4, borderWidth: 1, gap: GAP2, minWidth: 0, padding: PAD2 },
|
|
1945
|
+
head: { alignItems: "center", flexDirection: "row", flexWrap: "wrap", gap: GAP2, justifyContent: "space-between" },
|
|
1946
|
+
heading: { flexShrink: 1, fontSize: HEADING_FONT, fontWeight: "700" },
|
|
1947
|
+
message: { fontSize: MESSAGE_FONT },
|
|
1948
|
+
stack: { gap: STACK_GAP },
|
|
1949
|
+
title: { fontSize: TITLE_FONT2, fontWeight: "700" }
|
|
1950
|
+
});
|
|
1951
|
+
var AttentionCard = ({ title, heading, status, message, evidence, action, testID }) => {
|
|
1952
|
+
const { theme } = useFeedbackUi();
|
|
1953
|
+
return /* @__PURE__ */ jsxs(View, { style: [styles22.card, { backgroundColor: theme.colors.surfaceElevated, borderColor: theme.colors.border }], testID, children: [
|
|
1954
|
+
/* @__PURE__ */ jsx(Text, { accessibilityRole: "header", style: [styles22.title, { color: theme.colors.text }], children: title }),
|
|
1955
|
+
/* @__PURE__ */ jsxs(View, { style: styles22.stack, children: [
|
|
1956
|
+
heading === void 0 ? null : /* @__PURE__ */ jsxs(View, { style: styles22.head, testID: testID === void 0 ? void 0 : `${testID}-head`, children: [
|
|
1957
|
+
/* @__PURE__ */ jsx(Text, { style: [styles22.heading, { color: theme.colors.text }], children: heading }),
|
|
1958
|
+
status
|
|
1959
|
+
] }),
|
|
1960
|
+
/* @__PURE__ */ jsx(Text, { style: [styles22.message, { color: theme.colors.textSecondary }], children: message }),
|
|
1961
|
+
evidence,
|
|
1962
|
+
action
|
|
1963
|
+
] })
|
|
1964
|
+
] });
|
|
1965
|
+
};
|
|
1810
1966
|
|
|
1811
|
-
export { AppErrorBoundary, AsyncSurface, COPY_FEEDBACK_MS, ConfirmDialog, CopyStatus, DEFAULT_ERROR_BOUNDARY_LABELS, DISABLED_OPACITY, EmptyListState, ErrorNotice, ErrorReferenceRow, ErrorState, FEEDBACK_TEST_IDS, FeedbackUiProvider, LIVE_RUN_CARD_COMPACT_MAX_PX, LiveRunCard, LoadingFallback, LocalModelGate, MODAL_OVERLAY_COLOR, PageSkeleton, ProgressBar, ToastHost, FeedbackUiProvider as UiProvider, UiThemeOverride, WARMING_QUIET_PERIOD_MS, WarmingOverlay, barFraction, clampPercent, copyText, createToastBus, defaultGroupId, getWarmingSnapshot, mergeRunSteps, notifyWarming, progressPercent, readTraceId, runToneColor, settleWarming, splitShorterSteps, subscribeWarming, summariseDoneGroups, useCopyToClipboard, useFeedbackUi, useLocalModel, useFeedbackUi as useUi };
|
|
1967
|
+
export { AppErrorBoundary, AsyncSurface, AttentionCard, COPY_FEEDBACK_MS, CheckPipeline, CheckStatus, ConfirmDialog, CopyStatus, DEFAULT_ERROR_BOUNDARY_LABELS, DISABLED_OPACITY, EmptyListState, ErrorNotice, ErrorReferenceRow, ErrorState, FEEDBACK_TEST_IDS, FeedbackUiProvider, LIVE_RUN_CARD_COMPACT_MAX_PX, LiveRunCard, LoadingFallback, LocalModelGate, MODAL_OVERLAY_COLOR, PIPELINE_COLLAPSE_BREAKPOINT, PageSkeleton, ProgressBar, ThresholdMeter, ToastHost, FeedbackUiProvider as UiProvider, UiThemeOverride, WARMING_QUIET_PERIOD_MS, WarmingOverlay, barFraction, clampPercent, copyText, createToastBus, defaultGroupId, getWarmingSnapshot, meetsThreshold, mergeRunSteps, meterPercent, notifyWarming, pipelineVariant, progressPercent, readTraceId, runToneColor, settleWarming, splitShorterSteps, subscribeWarming, summariseDoneGroups, useCopyToClipboard, useFeedbackUi, useLocalModel, useFeedbackUi as useUi };
|
|
1812
1968
|
//# sourceMappingURL=index.mjs.map
|
|
1813
1969
|
//# sourceMappingURL=index.mjs.map
|