@dloizides/ui-feedback 1.25.1 → 1.26.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/CHANGELOG.md +4 -0
- package/dist/index.d.mts +50 -2
- package/dist/index.d.ts +50 -2
- package/dist/index.js +82 -2
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +82 -4
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 1.26.0
|
|
4
|
+
|
|
5
|
+
- `LocalModelGate` + `useLocalModel(model)` (INV-EXTRACT-1 W9): shows its children once a `@dloizides/text-generation` local model is ready, else the offer, download percent, failure retry or blocked reason; labels, test ids and the card/text/button slots come from the app.
|
|
6
|
+
|
|
3
7
|
## 1.24.0
|
|
4
8
|
|
|
5
9
|
- `UiThemeOverride({ map, children })` (INV-EXTRACT-1 W4, D-EXTRACT-2): re-provides the surrounding UI context with its theme passed through `map`; translate and navigate are kept. Generic over the host's theme type. Showcase story `src/showcase/UiThemeOverride.showcase.tsx`.
|
package/dist/index.d.mts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import React, { Component, ReactNode, ErrorInfo } from 'react';
|
|
1
|
+
import React, { Component, ReactNode, ErrorInfo, ComponentType, ReactElement } from 'react';
|
|
2
2
|
import { StyleProp, ViewStyle } from 'react-native';
|
|
3
|
+
import { LocalModel, LocalModelBlock, LocalModelState } from '@dloizides/text-generation';
|
|
3
4
|
|
|
4
5
|
/**
|
|
5
6
|
* The minimal theme surface the feedback components read. Each consuming app's
|
|
@@ -690,4 +691,51 @@ declare function LiveRunCard(props: LiveRunCardProps): React.ReactElement;
|
|
|
690
691
|
/** The theme colour for a step or group state; falls back to primary/text when a semantic scale is absent. */
|
|
691
692
|
declare function runToneColor(theme: FeedbackTheme, state: RunStepState): string;
|
|
692
693
|
|
|
693
|
-
|
|
694
|
+
interface LocalModelGateLabels {
|
|
695
|
+
blocked: (block: LocalModelBlock | null) => string;
|
|
696
|
+
title: string;
|
|
697
|
+
offerBody: string;
|
|
698
|
+
consent: string;
|
|
699
|
+
consentHint: string;
|
|
700
|
+
loading: (percent: string) => string;
|
|
701
|
+
failed: string;
|
|
702
|
+
retry: string;
|
|
703
|
+
}
|
|
704
|
+
interface LocalModelGateTestIds {
|
|
705
|
+
blocked: string;
|
|
706
|
+
offer: string;
|
|
707
|
+
loading: string;
|
|
708
|
+
failed: string;
|
|
709
|
+
consent: string;
|
|
710
|
+
}
|
|
711
|
+
interface LocalModelGateSlots {
|
|
712
|
+
Card: ComponentType<{
|
|
713
|
+
testID: string;
|
|
714
|
+
children: ReactNode;
|
|
715
|
+
}>;
|
|
716
|
+
Text: ComponentType<{
|
|
717
|
+
heading?: boolean;
|
|
718
|
+
children: string;
|
|
719
|
+
}>;
|
|
720
|
+
Button: ComponentType<{
|
|
721
|
+
label: string;
|
|
722
|
+
hint: string;
|
|
723
|
+
testID: string;
|
|
724
|
+
onPress: () => void;
|
|
725
|
+
}>;
|
|
726
|
+
}
|
|
727
|
+
interface LocalModelGateProps {
|
|
728
|
+
model: LocalModel;
|
|
729
|
+
labels: LocalModelGateLabels;
|
|
730
|
+
testIds: LocalModelGateTestIds;
|
|
731
|
+
slots: LocalModelGateSlots;
|
|
732
|
+
children: ReactElement;
|
|
733
|
+
}
|
|
734
|
+
|
|
735
|
+
/** Shows its children only once the local model is ready; before that it offers the download or says why it cannot run. */
|
|
736
|
+
declare const LocalModelGate: ({ model, labels, testIds, slots, children, }: LocalModelGateProps) => React.ReactElement | null;
|
|
737
|
+
|
|
738
|
+
/** Follows a local model and checks the browser on first use. */
|
|
739
|
+
declare function useLocalModel(model: LocalModel): LocalModelState;
|
|
740
|
+
|
|
741
|
+
export { AppErrorBoundary, type AppErrorBoundaryProps, AsyncSurface, type AsyncSurfaceProps, COPY_FEEDBACK_MS, ConfirmDialog, type ConfirmDialogProps, CopyStatus, type CopyToClipboard, DEFAULT_ERROR_BOUNDARY_LABELS, DISABLED_OPACITY, type DoneSummary, EmptyListState, type EmptyListStateProps, type ErrorBoundaryLabels, type ErrorFallbackState, ErrorNotice, type ErrorNoticeProps, ErrorReferenceRow, type ErrorReferenceRowProps, ErrorState, type ErrorStateAction, type ErrorStateProps, FEEDBACK_TEST_IDS, type FeedbackColorScale, type FeedbackNavigate, type FeedbackTheme, type FeedbackThemeColors, type FeedbackThemePalette, type FeedbackThemeSemantic, type FeedbackThemeSemanticText, type FeedbackTranslate, FeedbackUiProvider, type FeedbackUiProviderProps, type FeedbackUiValue, type FlatRunStep, LIVE_RUN_CARD_COMPACT_MAX_PX, LiveRunCard, type LiveRunCardLabels, type LiveRunCardProps, LoadingFallback, type LoadingFallbackProps, LocalModelGate, type LocalModelGateLabels, type LocalModelGateProps, type LocalModelGateSlots, type LocalModelGateTestIds, MODAL_OVERLAY_COLOR, PageSkeleton, type PageSkeletonProps, ProgressBar, type ProgressBarProps, type RunGroup, type RunStep, type RunStepState, type StepSplit, type ToastActionSpec, type ToastBus, ToastHost, type ToastHostProps, type ToastInput, type ToastPush, type ToastType, type FeedbackColorScale as UiColorScale, type FeedbackNavigate as UiNavigate, FeedbackUiProvider as UiProvider, type FeedbackUiProviderProps as UiProviderProps, type FeedbackTheme as UiTheme, type FeedbackThemeColors as UiThemeColors, UiThemeOverride, type UiThemeOverrideProps, type FeedbackThemePalette as UiThemePalette, type FeedbackThemeSemantic as UiThemeSemantic, type FeedbackThemeSemanticText as UiThemeSemanticText, type FeedbackTranslate as UiTranslate, type FeedbackUiValue as UiValue, WARMING_QUIET_PERIOD_MS, type WarmingInfo, WarmingOverlay, type WarmingOverlayLabels, type WarmingOverlayProps, type WarmingSnapshot, barFraction, clampPercent, copyText, createToastBus, defaultGroupId, getWarmingSnapshot, mergeRunSteps, notifyWarming, progressPercent, readTraceId, runToneColor, settleWarming, splitShorterSteps, subscribeWarming, summariseDoneGroups, useCopyToClipboard, useFeedbackUi, useLocalModel, useFeedbackUi as useUi };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import React, { Component, ReactNode, ErrorInfo } from 'react';
|
|
1
|
+
import React, { Component, ReactNode, ErrorInfo, ComponentType, ReactElement } from 'react';
|
|
2
2
|
import { StyleProp, ViewStyle } from 'react-native';
|
|
3
|
+
import { LocalModel, LocalModelBlock, LocalModelState } from '@dloizides/text-generation';
|
|
3
4
|
|
|
4
5
|
/**
|
|
5
6
|
* The minimal theme surface the feedback components read. Each consuming app's
|
|
@@ -690,4 +691,51 @@ declare function LiveRunCard(props: LiveRunCardProps): React.ReactElement;
|
|
|
690
691
|
/** The theme colour for a step or group state; falls back to primary/text when a semantic scale is absent. */
|
|
691
692
|
declare function runToneColor(theme: FeedbackTheme, state: RunStepState): string;
|
|
692
693
|
|
|
693
|
-
|
|
694
|
+
interface LocalModelGateLabels {
|
|
695
|
+
blocked: (block: LocalModelBlock | null) => string;
|
|
696
|
+
title: string;
|
|
697
|
+
offerBody: string;
|
|
698
|
+
consent: string;
|
|
699
|
+
consentHint: string;
|
|
700
|
+
loading: (percent: string) => string;
|
|
701
|
+
failed: string;
|
|
702
|
+
retry: string;
|
|
703
|
+
}
|
|
704
|
+
interface LocalModelGateTestIds {
|
|
705
|
+
blocked: string;
|
|
706
|
+
offer: string;
|
|
707
|
+
loading: string;
|
|
708
|
+
failed: string;
|
|
709
|
+
consent: string;
|
|
710
|
+
}
|
|
711
|
+
interface LocalModelGateSlots {
|
|
712
|
+
Card: ComponentType<{
|
|
713
|
+
testID: string;
|
|
714
|
+
children: ReactNode;
|
|
715
|
+
}>;
|
|
716
|
+
Text: ComponentType<{
|
|
717
|
+
heading?: boolean;
|
|
718
|
+
children: string;
|
|
719
|
+
}>;
|
|
720
|
+
Button: ComponentType<{
|
|
721
|
+
label: string;
|
|
722
|
+
hint: string;
|
|
723
|
+
testID: string;
|
|
724
|
+
onPress: () => void;
|
|
725
|
+
}>;
|
|
726
|
+
}
|
|
727
|
+
interface LocalModelGateProps {
|
|
728
|
+
model: LocalModel;
|
|
729
|
+
labels: LocalModelGateLabels;
|
|
730
|
+
testIds: LocalModelGateTestIds;
|
|
731
|
+
slots: LocalModelGateSlots;
|
|
732
|
+
children: ReactElement;
|
|
733
|
+
}
|
|
734
|
+
|
|
735
|
+
/** Shows its children only once the local model is ready; before that it offers the download or says why it cannot run. */
|
|
736
|
+
declare const LocalModelGate: ({ model, labels, testIds, slots, children, }: LocalModelGateProps) => React.ReactElement | null;
|
|
737
|
+
|
|
738
|
+
/** Follows a local model and checks the browser on first use. */
|
|
739
|
+
declare function useLocalModel(model: LocalModel): LocalModelState;
|
|
740
|
+
|
|
741
|
+
export { AppErrorBoundary, type AppErrorBoundaryProps, AsyncSurface, type AsyncSurfaceProps, COPY_FEEDBACK_MS, ConfirmDialog, type ConfirmDialogProps, CopyStatus, type CopyToClipboard, DEFAULT_ERROR_BOUNDARY_LABELS, DISABLED_OPACITY, type DoneSummary, EmptyListState, type EmptyListStateProps, type ErrorBoundaryLabels, type ErrorFallbackState, ErrorNotice, type ErrorNoticeProps, ErrorReferenceRow, type ErrorReferenceRowProps, ErrorState, type ErrorStateAction, type ErrorStateProps, FEEDBACK_TEST_IDS, type FeedbackColorScale, type FeedbackNavigate, type FeedbackTheme, type FeedbackThemeColors, type FeedbackThemePalette, type FeedbackThemeSemantic, type FeedbackThemeSemanticText, type FeedbackTranslate, FeedbackUiProvider, type FeedbackUiProviderProps, type FeedbackUiValue, type FlatRunStep, LIVE_RUN_CARD_COMPACT_MAX_PX, LiveRunCard, type LiveRunCardLabels, type LiveRunCardProps, LoadingFallback, type LoadingFallbackProps, LocalModelGate, type LocalModelGateLabels, type LocalModelGateProps, type LocalModelGateSlots, type LocalModelGateTestIds, MODAL_OVERLAY_COLOR, PageSkeleton, type PageSkeletonProps, ProgressBar, type ProgressBarProps, type RunGroup, type RunStep, type RunStepState, type StepSplit, type ToastActionSpec, type ToastBus, ToastHost, type ToastHostProps, type ToastInput, type ToastPush, type ToastType, type FeedbackColorScale as UiColorScale, type FeedbackNavigate as UiNavigate, FeedbackUiProvider as UiProvider, type FeedbackUiProviderProps as UiProviderProps, type FeedbackTheme as UiTheme, type FeedbackThemeColors as UiThemeColors, UiThemeOverride, type UiThemeOverrideProps, type FeedbackThemePalette as UiThemePalette, type FeedbackThemeSemantic as UiThemeSemantic, type FeedbackThemeSemanticText as UiThemeSemanticText, type FeedbackTranslate as UiTranslate, type FeedbackUiValue as UiValue, WARMING_QUIET_PERIOD_MS, type WarmingInfo, WarmingOverlay, type WarmingOverlayLabels, type WarmingOverlayProps, type WarmingSnapshot, barFraction, clampPercent, copyText, createToastBus, defaultGroupId, getWarmingSnapshot, mergeRunSteps, notifyWarming, progressPercent, readTraceId, runToneColor, settleWarming, splitShorterSteps, subscribeWarming, summariseDoneGroups, useCopyToClipboard, useFeedbackUi, useLocalModel, useFeedbackUi as useUi };
|
package/dist/index.js
CHANGED
|
@@ -7,6 +7,7 @@ var a11y = require('@dloizides/a11y');
|
|
|
7
7
|
var uiMotion = require('@dloizides/ui-motion');
|
|
8
8
|
var designTokens = require('@dloizides/design-tokens');
|
|
9
9
|
var reactDom = require('react-dom');
|
|
10
|
+
var textGeneration = require('@dloizides/text-generation');
|
|
10
11
|
|
|
11
12
|
// src/context/FeedbackUiContext.tsx
|
|
12
13
|
var DEFAULT_FEEDBACK_VALUE = {
|
|
@@ -625,6 +626,32 @@ function confirmFill(theme, destructive) {
|
|
|
625
626
|
function confirmInk(theme, destructive) {
|
|
626
627
|
return designTokens.resolveOnBrand(confirmFill(theme, destructive));
|
|
627
628
|
}
|
|
629
|
+
var LIGHT_BRAND_STEP = "300";
|
|
630
|
+
var NO_RING = { outlineWidth: 0 };
|
|
631
|
+
var NATIVE_RING = {};
|
|
632
|
+
function buildDialogRingStyle(visible, color, isWeb) {
|
|
633
|
+
if (!isWeb) return NATIVE_RING;
|
|
634
|
+
return visible ? designTokens.focusRingOutline(color) : NO_RING;
|
|
635
|
+
}
|
|
636
|
+
function dialogRingColor(theme) {
|
|
637
|
+
const colors = theme.colors;
|
|
638
|
+
return designTokens.resolveFocusRingColor({
|
|
639
|
+
focusRing: colors.focusRing,
|
|
640
|
+
primary: theme.palette.primary["500"],
|
|
641
|
+
primaryLight: theme.palette.primary[LIGHT_BRAND_STEP],
|
|
642
|
+
text: colors.text,
|
|
643
|
+
background: colors.background
|
|
644
|
+
});
|
|
645
|
+
}
|
|
646
|
+
function useDialogFocusRing(color) {
|
|
647
|
+
const [visible, setVisible] = react.useState(false);
|
|
648
|
+
const onFocus = react.useCallback((event) => {
|
|
649
|
+
setVisible(designTokens.isFocusVisible(event?.target));
|
|
650
|
+
}, []);
|
|
651
|
+
const onBlur = react.useCallback(() => setVisible(false), []);
|
|
652
|
+
const ringStyle = react.useMemo(() => buildDialogRingStyle(visible, color, reactNative.Platform.OS === "web"), [visible, color]);
|
|
653
|
+
return { ringStyle, onFocus, onBlur };
|
|
654
|
+
}
|
|
628
655
|
var DIALOG_MAX_WIDTH = 400;
|
|
629
656
|
var styles8 = reactNative.StyleSheet.create({
|
|
630
657
|
overlay: {
|
|
@@ -693,6 +720,8 @@ var ConfirmDialog = ({
|
|
|
693
720
|
const { theme, t } = useFeedbackUi();
|
|
694
721
|
const titleId = react.useId();
|
|
695
722
|
const innerDialogRole = reactNative.Platform.OS === "web" ? void 0 : "dialog";
|
|
723
|
+
const cancelRing = useDialogFocusRing(dialogRingColor(theme));
|
|
724
|
+
const confirmRing = useDialogFocusRing(dialogRingColor(theme));
|
|
696
725
|
const colorStyles = react.useMemo(
|
|
697
726
|
() => ({
|
|
698
727
|
dialog: { backgroundColor: theme.colors.surfaceElevated },
|
|
@@ -738,9 +767,12 @@ var ConfirmDialog = ({
|
|
|
738
767
|
style: [
|
|
739
768
|
styles8.button,
|
|
740
769
|
styles8.cancelButton,
|
|
741
|
-
colorStyles.cancelButton
|
|
770
|
+
colorStyles.cancelButton,
|
|
771
|
+
cancelRing.ringStyle
|
|
742
772
|
],
|
|
743
773
|
testID: FEEDBACK_TEST_IDS.cancelConfirmButton,
|
|
774
|
+
onBlur: cancelRing.onBlur,
|
|
775
|
+
onFocus: cancelRing.onFocus,
|
|
744
776
|
onPress: onCancel,
|
|
745
777
|
children: /* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { style: [styles8.buttonText, colorStyles.cancelButtonText], children: resolvedCancelLabel })
|
|
746
778
|
}
|
|
@@ -757,9 +789,12 @@ var ConfirmDialog = ({
|
|
|
757
789
|
styles8.button,
|
|
758
790
|
styles8.confirmButton,
|
|
759
791
|
colorStyles.confirmButton,
|
|
760
|
-
isConfirmDisabled && styles8.disabledButton
|
|
792
|
+
isConfirmDisabled && styles8.disabledButton,
|
|
793
|
+
confirmRing.ringStyle
|
|
761
794
|
],
|
|
762
795
|
testID: FEEDBACK_TEST_IDS.confirmButton,
|
|
796
|
+
onBlur: confirmRing.onBlur,
|
|
797
|
+
onFocus: confirmRing.onFocus,
|
|
763
798
|
onPress: onConfirm,
|
|
764
799
|
children: loading ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
765
800
|
reactNative.ActivityIndicator,
|
|
@@ -1765,6 +1800,49 @@ function LiveRunCard(props) {
|
|
|
1765
1800
|
showTimings && selected !== void 0 && selected.steps.length > 0 ? /* @__PURE__ */ jsxRuntime.jsx(RunStepBars, { steps: selected.steps, maxBars, labels, compact, testID: `${testID}-steps` }, selected.id) : null
|
|
1766
1801
|
] });
|
|
1767
1802
|
}
|
|
1803
|
+
function useLocalModel(model) {
|
|
1804
|
+
const state = react.useSyncExternalStore(model.subscribe, model.state);
|
|
1805
|
+
react.useEffect(() => {
|
|
1806
|
+
model.check().catch(() => void 0);
|
|
1807
|
+
}, [model]);
|
|
1808
|
+
return state;
|
|
1809
|
+
}
|
|
1810
|
+
var PERCENT2 = 100;
|
|
1811
|
+
var LocalModelGate = ({
|
|
1812
|
+
model,
|
|
1813
|
+
labels,
|
|
1814
|
+
testIds,
|
|
1815
|
+
slots,
|
|
1816
|
+
children
|
|
1817
|
+
}) => {
|
|
1818
|
+
const { phase, block, progress } = useLocalModel(model);
|
|
1819
|
+
const consent = react.useCallback(() => {
|
|
1820
|
+
model.consent().catch(() => void 0);
|
|
1821
|
+
}, [model]);
|
|
1822
|
+
const { Card, Text: Text16, Button } = slots;
|
|
1823
|
+
switch (phase) {
|
|
1824
|
+
case textGeneration.LocalModelPhase.Checking:
|
|
1825
|
+
return null;
|
|
1826
|
+
case textGeneration.LocalModelPhase.Blocked:
|
|
1827
|
+
return /* @__PURE__ */ jsxRuntime.jsx(Card, { testID: testIds.blocked, children: /* @__PURE__ */ jsxRuntime.jsx(Text16, { children: labels.blocked(block) }) });
|
|
1828
|
+
case textGeneration.LocalModelPhase.Offer:
|
|
1829
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(Card, { testID: testIds.offer, children: [
|
|
1830
|
+
/* @__PURE__ */ jsxRuntime.jsx(Text16, { heading: true, children: labels.title }),
|
|
1831
|
+
/* @__PURE__ */ jsxRuntime.jsx(Text16, { children: labels.offerBody }),
|
|
1832
|
+
/* @__PURE__ */ jsxRuntime.jsx(Button, { hint: labels.consentHint, label: labels.consent, testID: testIds.consent, onPress: consent })
|
|
1833
|
+
] });
|
|
1834
|
+
case textGeneration.LocalModelPhase.Loading:
|
|
1835
|
+
return /* @__PURE__ */ jsxRuntime.jsx(Card, { testID: testIds.loading, children: /* @__PURE__ */ jsxRuntime.jsx(Text16, { children: labels.loading(String(Math.round(progress * PERCENT2))) }) });
|
|
1836
|
+
case textGeneration.LocalModelPhase.Failed:
|
|
1837
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(Card, { testID: testIds.failed, children: [
|
|
1838
|
+
/* @__PURE__ */ jsxRuntime.jsx(Text16, { children: labels.failed }),
|
|
1839
|
+
/* @__PURE__ */ jsxRuntime.jsx(Button, { hint: labels.consentHint, label: labels.retry, testID: testIds.consent, onPress: consent })
|
|
1840
|
+
] });
|
|
1841
|
+
case textGeneration.LocalModelPhase.Ready:
|
|
1842
|
+
default:
|
|
1843
|
+
return children;
|
|
1844
|
+
}
|
|
1845
|
+
};
|
|
1768
1846
|
|
|
1769
1847
|
exports.AppErrorBoundary = AppErrorBoundary;
|
|
1770
1848
|
exports.AsyncSurface = AsyncSurface;
|
|
@@ -1782,6 +1860,7 @@ exports.FeedbackUiProvider = FeedbackUiProvider;
|
|
|
1782
1860
|
exports.LIVE_RUN_CARD_COMPACT_MAX_PX = LIVE_RUN_CARD_COMPACT_MAX_PX;
|
|
1783
1861
|
exports.LiveRunCard = LiveRunCard;
|
|
1784
1862
|
exports.LoadingFallback = LoadingFallback;
|
|
1863
|
+
exports.LocalModelGate = LocalModelGate;
|
|
1785
1864
|
exports.MODAL_OVERLAY_COLOR = MODAL_OVERLAY_COLOR;
|
|
1786
1865
|
exports.PageSkeleton = PageSkeleton;
|
|
1787
1866
|
exports.ProgressBar = ProgressBar;
|
|
@@ -1807,6 +1886,7 @@ exports.subscribeWarming = subscribeWarming;
|
|
|
1807
1886
|
exports.summariseDoneGroups = summariseDoneGroups;
|
|
1808
1887
|
exports.useCopyToClipboard = useCopyToClipboard;
|
|
1809
1888
|
exports.useFeedbackUi = useFeedbackUi;
|
|
1889
|
+
exports.useLocalModel = useLocalModel;
|
|
1810
1890
|
exports.useUi = useFeedbackUi;
|
|
1811
1891
|
//# sourceMappingURL=index.js.map
|
|
1812
1892
|
//# sourceMappingURL=index.js.map
|