@dloizides/ui-feedback 1.25.1 → 1.26.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
@@ -5,6 +5,7 @@ import { MIN_TOUCH_TARGET_PX } from '@dloizides/a11y';
5
5
  import { Skeleton } from '@dloizides/ui-motion';
6
6
  import { Z_INDEX, resolveOnBrand, UI_DEEP_STEP, UI_MAIN_STEP, isHexColor, canCarryAccessibleInk } from '@dloizides/design-tokens';
7
7
  import { createPortal } from 'react-dom';
8
+ import { LocalModelPhase } from '@dloizides/text-generation';
8
9
 
9
10
  // src/context/FeedbackUiContext.tsx
10
11
  var DEFAULT_FEEDBACK_VALUE = {
@@ -1763,7 +1764,50 @@ function LiveRunCard(props) {
1763
1764
  showTimings && selected !== void 0 && selected.steps.length > 0 ? /* @__PURE__ */ jsx(RunStepBars, { steps: selected.steps, maxBars, labels, compact, testID: `${testID}-steps` }, selected.id) : null
1764
1765
  ] });
1765
1766
  }
1767
+ function useLocalModel(model) {
1768
+ const state = useSyncExternalStore(model.subscribe, model.state);
1769
+ useEffect(() => {
1770
+ model.check().catch(() => void 0);
1771
+ }, [model]);
1772
+ return state;
1773
+ }
1774
+ var PERCENT2 = 100;
1775
+ var LocalModelGate = ({
1776
+ model,
1777
+ labels,
1778
+ testIds,
1779
+ slots,
1780
+ children
1781
+ }) => {
1782
+ const { phase, block, progress } = useLocalModel(model);
1783
+ const consent = useCallback(() => {
1784
+ model.consent().catch(() => void 0);
1785
+ }, [model]);
1786
+ const { Card, Text: Text16, Button } = slots;
1787
+ switch (phase) {
1788
+ case LocalModelPhase.Checking:
1789
+ return null;
1790
+ case LocalModelPhase.Blocked:
1791
+ return /* @__PURE__ */ jsx(Card, { testID: testIds.blocked, children: /* @__PURE__ */ jsx(Text16, { children: labels.blocked(block) }) });
1792
+ case LocalModelPhase.Offer:
1793
+ return /* @__PURE__ */ jsxs(Card, { testID: testIds.offer, children: [
1794
+ /* @__PURE__ */ jsx(Text16, { heading: true, children: labels.title }),
1795
+ /* @__PURE__ */ jsx(Text16, { children: labels.offerBody }),
1796
+ /* @__PURE__ */ jsx(Button, { hint: labels.consentHint, label: labels.consent, testID: testIds.consent, onPress: consent })
1797
+ ] });
1798
+ case LocalModelPhase.Loading:
1799
+ return /* @__PURE__ */ jsx(Card, { testID: testIds.loading, children: /* @__PURE__ */ jsx(Text16, { children: labels.loading(String(Math.round(progress * PERCENT2))) }) });
1800
+ case LocalModelPhase.Failed:
1801
+ return /* @__PURE__ */ jsxs(Card, { testID: testIds.failed, children: [
1802
+ /* @__PURE__ */ jsx(Text16, { children: labels.failed }),
1803
+ /* @__PURE__ */ jsx(Button, { hint: labels.consentHint, label: labels.retry, testID: testIds.consent, onPress: consent })
1804
+ ] });
1805
+ case LocalModelPhase.Ready:
1806
+ default:
1807
+ return children;
1808
+ }
1809
+ };
1766
1810
 
1767
- 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, 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, useFeedbackUi as useUi };
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 };
1768
1812
  //# sourceMappingURL=index.mjs.map
1769
1813
  //# sourceMappingURL=index.mjs.map