@40rty/ams-ui 0.3.2 → 0.4.3
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/agent.js +5 -5
- package/dist/{chunk-MHUEIBJ3.js → chunk-GQURT3IR.js} +3 -47
- package/dist/{chunk-BFZ3YCUY.js → chunk-H6MSAD5M.js} +1 -40
- package/dist/{chunk-ORIOBWTD.js → chunk-PHXP2SKS.js} +5 -1
- package/dist/{chunk-OKP7MC72.js → chunk-RKPDCXL4.js} +241 -195
- package/dist/{chunk-TEPH476O.js → chunk-RMJDSHLA.js} +6 -36
- package/dist/hooks.js +4 -4
- package/dist/index.js +172 -338
- package/dist/presence.js +3 -4
- package/dist/shell.js +411 -537
- package/dist/thread-panel.js +3 -3
- package/dist/types/agent/presence/AgentAsk.d.ts +13 -0
- package/dist/types/agent/presence/index.d.ts +3 -1
- package/dist/types/agent/presence/read-data.d.ts +5 -0
- package/dist/types/components/ecommerce/cart/CartFoot.d.ts +1 -2
- package/dist/types/components/ecommerce/cart/CartLineRow.d.ts +1 -1
- package/dist/types/hooks/index.d.ts +1 -1
- package/dist/types/index.d.ts +2 -2
- package/dist/types/labels.d.ts +6 -0
- package/dist/types/shell/Composer.d.ts +1 -1
- package/dist/types/shell/ShellScaffold.d.ts +5 -2
- package/dist/types/shell/TurnAsk.d.ts +14 -0
- package/dist/types/shell/composer/AttachmentStrip.d.ts +1 -1
- package/dist/types/shell/dock-context.d.ts +1 -1
- package/dist/types/shell/index.d.ts +2 -2
- package/dist/types/shell/mobile/DefaultMobileShell.d.ts +4 -0
- package/dist/types/shell/mobile/IslandComposeGroup.d.ts +1 -1
- package/dist/types/shell/mobile/IslandInputBar.d.ts +1 -1
- package/dist/types/shell/mobile/MorphIsland.d.ts +1 -1
- package/dist/types/shell/mobile/PageComposerDock.d.ts +13 -0
- package/dist/types/shell/mobile/RestIsland.d.ts +1 -1
- package/dist/types/shell/slots.d.ts +1 -5
- package/package.json +3 -4
- package/dist/types/agent/presence/use-forget-fact.d.ts +0 -56
- package/dist/types/components/ecommerce/cart/use-cart-view.d.ts +0 -50
- package/dist/types/hooks/use-projection.d.ts +0 -24
- package/dist/types/shell/composer/heic-convert.d.ts +0 -6
- package/dist/types/shell/composer/useComposerAttachments.d.ts +0 -37
- package/dist/types/shell/composer/usePromptComposer.d.ts +0 -51
- package/dist/types/shell/use-dock-state.d.ts +0 -54
- package/dist/types/utils/use-is-seed-home.d.ts +0 -13
- package/dist/types/utils/use-safe-cart.d.ts +0 -17
- package/dist/types/utils/use-safe-facts.d.ts +0 -9
- package/dist/types/utils/use-safe-fourty-session.d.ts +0 -15
package/dist/thread-panel.js
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
import {
|
|
3
|
-
SideDock
|
|
4
|
-
|
|
5
|
-
} from "./chunk-BFZ3YCUY.js";
|
|
3
|
+
SideDock
|
|
4
|
+
} from "./chunk-H6MSAD5M.js";
|
|
6
5
|
import {
|
|
7
6
|
stopHostKeys,
|
|
8
7
|
useHostShell,
|
|
@@ -12,6 +11,7 @@ import {
|
|
|
12
11
|
// src/shell/SpacefrontThreadPanel.tsx
|
|
13
12
|
import * as React2 from "react";
|
|
14
13
|
import { DockPersistenceProvider, useFormFactor } from "@40rty/ams-sdk";
|
|
14
|
+
import { useDockState } from "@40rty/ams-sdk";
|
|
15
15
|
|
|
16
16
|
// src/shell/ThreadPanelConversation.tsx
|
|
17
17
|
import * as React from "react";
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
/**
|
|
3
|
+
* AgentAsk — the default widget that CONSUMES the `agent_ask` signal (a generic
|
|
4
|
+
* deciding question + optional quick replies). It is a plain signal consumer:
|
|
5
|
+
* `useConsumeStandingSignal('agent_ask')`, read `ask` / `suggestions` straight
|
|
6
|
+
* off the payload, render. No ask store, no ask hook — `agent_ask` is just a
|
|
7
|
+
* signal, and this is just the widget that happens to render it.
|
|
8
|
+
*
|
|
9
|
+
* Emits `fourty-ask*` class-hooked markup with ZERO skin; the THEME stylesheet
|
|
10
|
+
* owns the look. Brand-specific prompts are their own signals consumed by their
|
|
11
|
+
* own widgets (e.g. the wardrobe's keep-offer).
|
|
12
|
+
*/
|
|
13
|
+
export declare function AgentAsk(): React.ReactElement | null;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
export { DefaultNotch } from './DefaultNotch';
|
|
2
2
|
export { PresenceNotch } from './notch/PresenceNotch';
|
|
3
|
+
export { AgentAsk } from './AgentAsk';
|
|
3
4
|
export { AgentPresenceWidget, type AgentPresenceWidgetProps } from './AgentPresenceWidget';
|
|
4
5
|
export { registerDefaultPresenceForms } from './forms';
|
|
5
6
|
export { PresenceStream, streamLeadLine } from './StreamRead';
|
|
@@ -35,5 +36,6 @@ export { CompactStream } from './CompactRead';
|
|
|
35
36
|
export { presenceClass } from './class-names';
|
|
36
37
|
export { useMeasuredHeight } from './use-measured-height';
|
|
37
38
|
export { FactChips } from './CompactRead';
|
|
38
|
-
export {
|
|
39
|
+
export { useVisibleFacts } from './read-data';
|
|
40
|
+
export { useForgetFact, useVisibleFactList, type ForgetFactApi } from '@40rty/ams-sdk';
|
|
39
41
|
export { PresenceBriefRail } from './KnowledgePeek';
|
|
@@ -46,3 +46,8 @@ export declare function readLabel(frame: AgentPresenceFrame): string;
|
|
|
46
46
|
* reuses the instance and the text/facts hard-swap in place (the harsh,
|
|
47
47
|
* un-animated update). */
|
|
48
48
|
export declare function readKey(frame: AgentPresenceFrame): string;
|
|
49
|
+
/**
|
|
50
|
+
* The facts to render off a frame: the agent's read, minus what the visitor
|
|
51
|
+
* dismissed — `readFacts` through the SDK's one list rule (`useVisibleFactList`).
|
|
52
|
+
*/
|
|
53
|
+
export declare function useVisibleFacts(frame: AgentPresenceFrame | null): Fact[];
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import type { Cart } from '../../../types/commerce';
|
|
2
|
-
|
|
3
|
-
export type ExitPending = 'checkout' | 'store' | null;
|
|
2
|
+
import type { ExitPending } from '@40rty/ams-sdk';
|
|
4
3
|
export interface CartFootProps {
|
|
5
4
|
lines: Cart['lines'];
|
|
6
5
|
/** Applied discount codes (from `cart.discountCodes`). */
|
|
@@ -10,7 +10,7 @@ export interface CartLineRowProps {
|
|
|
10
10
|
* CartLineRow — one line item inside the cart drawer body: image +
|
|
11
11
|
* brand + name + variant/sku + qty stepper + price.
|
|
12
12
|
*
|
|
13
|
-
* A dumb presentational row — the `
|
|
13
|
+
* A dumb presentational row — the `useCommerceActions` runtime seam (the
|
|
14
14
|
* harness) owns what tapping a line means (navigate to the product);
|
|
15
15
|
* the row just reports it.
|
|
16
16
|
*/
|
|
@@ -4,5 +4,5 @@ export { useFocusOnChange } from './use-focus-on-change';
|
|
|
4
4
|
export { useFocusTrap } from './use-focus-trap';
|
|
5
5
|
export { useScrollThreshold } from './use-scroll-threshold';
|
|
6
6
|
export { useTextareaAutosize } from './use-textarea-autosize';
|
|
7
|
-
export { useProjection, type ProjectionView } from '
|
|
7
|
+
export { useProjection, type ProjectionView } from '@40rty/ams-sdk';
|
|
8
8
|
export { useContainerWidth } from './use-container-width';
|
package/dist/types/index.d.ts
CHANGED
|
@@ -2,7 +2,7 @@ export { components, catalog, componentMap, STRUCTURAL_BASELINE_RENDERERS } from
|
|
|
2
2
|
export { PendingTurn, ShellTop, ComposerDock, ErrorBanner, CartPill, HistoryMenu, BaseMark, ShellMark, type ShellMarkProps, parseBaseShell, type BaseShellConfig, } from './components/shell';
|
|
3
3
|
export { DefaultNotch, PresenceNotch, AgentPresenceWidget, type AgentPresenceWidgetProps, registerDefaultPresenceForms, InlinePresenceRead, LayoutMorphSkeleton, Eyebrow, Rule, Fallback, Thought, Dossier, FoldedRead, BriefHandle, PresenceBriefBody, PresenceBriefDrawer, colorSwatch, readFacts, readLabel, type Fact, presenceClass, useMeasuredHeight, FactChips, useVisibleFacts, ProseSurface, type ProseSurfaceProps, } from './agent';
|
|
4
4
|
export { ComposerModeProvider, useComposerMode, type ComposerMode, } from './utils/use-composer-mode';
|
|
5
|
-
export { useIsSeedHome } from '
|
|
5
|
+
export { useIsSeedHome } from '@40rty/ams-sdk';
|
|
6
6
|
export { BackdropPresenceProvider, useBackdropPresence, type BackdropVariant, } from './utils/use-backdrop-presence';
|
|
7
7
|
export type { Money, Image, ProductVariant, Product, Collection, CartLine, Cart, } from './types/commerce';
|
|
8
8
|
export { cn } from './utils/cn';
|
|
@@ -48,7 +48,7 @@ export { CartSummary, type CartSummaryProps } from './components/ecommerce/cart/
|
|
|
48
48
|
export { CartDrawer, type CartDrawerProps } from './components/ecommerce/cart/CartDrawer';
|
|
49
49
|
export { CartContent, type CartContentProps } from './components/ecommerce/cart/CartContent';
|
|
50
50
|
export { CartLineRow } from './components/ecommerce/cart/CartLineRow';
|
|
51
|
-
export { useCartView, type CartViewModel } from '
|
|
51
|
+
export { useCartView, type CartViewModel } from '@40rty/ams-sdk';
|
|
52
52
|
export { formatPrice } from './components/ecommerce/cart/cart-format';
|
|
53
53
|
export { default as CartWidget } from './components/ecommerce/cart/CartWidget';
|
|
54
54
|
export { VariantPickerModal } from './components/ecommerce/cart/VariantPickerModal';
|
package/dist/types/labels.d.ts
CHANGED
|
@@ -169,6 +169,12 @@ export interface Labels {
|
|
|
169
169
|
* Same shapes, said the way a person would.
|
|
170
170
|
*/
|
|
171
171
|
composing: readonly string[];
|
|
172
|
+
/** The default deciding-question widget (`<AgentAsk>`). */
|
|
173
|
+
ask: {
|
|
174
|
+
/** Shown when the agent raised an ask without its own question text. */
|
|
175
|
+
fallback: string;
|
|
176
|
+
dismiss: string;
|
|
177
|
+
};
|
|
172
178
|
};
|
|
173
179
|
menu: {
|
|
174
180
|
/** Leading row inside a department's expanded accordion (touch menu) that
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import { SuggestionAction } from '@40rty/ams-sdk';
|
|
3
|
-
import { type ComposerAttachmentsApi } from '
|
|
3
|
+
import { type ComposerAttachmentsApi } from '@40rty/ams-sdk';
|
|
4
4
|
/** Render-prop signature for the thread-message list. Composer owns the
|
|
5
5
|
* scroller element; the brand supplies the row layout / empty state by
|
|
6
6
|
* rendering inside the scroller using the provided ref. */
|
|
@@ -13,7 +13,8 @@
|
|
|
13
13
|
* of copying the skeleton.
|
|
14
14
|
*/
|
|
15
15
|
import React from 'react';
|
|
16
|
-
import {
|
|
16
|
+
import { type ShellDockState } from '@40rty/ams-sdk';
|
|
17
|
+
import { resolveShellSlot, type ShellSlot } from './slots';
|
|
17
18
|
export { resolveShellSlot };
|
|
18
19
|
export type { ShellSlot, ShellDockState };
|
|
19
20
|
export interface ShellScaffoldProps {
|
|
@@ -26,7 +27,9 @@ export interface ShellScaffoldProps {
|
|
|
26
27
|
* of the canvas scroll. For a shell whose conversation IS the canvas (each
|
|
27
28
|
* turn a page with its own answer). The side dock stays available as an
|
|
28
29
|
* optional view of the thread: it never opens by itself, only on the
|
|
29
|
-
* visitor's toggle.
|
|
30
|
+
* visitor's toggle. A phone keeps this same input, pinned to the bottom of the
|
|
31
|
+
* screen (`PageComposerDock`), in place of the island: the conversation is the
|
|
32
|
+
* page on every screen.
|
|
30
33
|
*/
|
|
31
34
|
canvasComposer?: ShellSlot;
|
|
32
35
|
/** Ref attached to the scrolling `<main>` — the platform scroll container
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { type TurnAsk as TurnAskData } from '@40rty/ams-sdk';
|
|
3
|
+
/**
|
|
4
|
+
* The question a turn closed on, for a shell that draws it itself
|
|
5
|
+
* (`turnAsk: 'shell'`): one more line of the agent's prose, whose bracketed
|
|
6
|
+
* words are the visitor's replies. A tap on one sends that word as the reply;
|
|
7
|
+
* the question itself is never a button. `answerable` is false on any turn but
|
|
8
|
+
* the newest settled one: answering an old question would reply to a
|
|
9
|
+
* conversation that moved on, so its words read as plain text.
|
|
10
|
+
*/
|
|
11
|
+
export declare function TurnAsk({ ask, answerable }: {
|
|
12
|
+
ask: TurnAskData;
|
|
13
|
+
answerable: boolean;
|
|
14
|
+
}): React.ReactElement;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
import type { ComposerAttachment } from '
|
|
2
|
+
import type { ComposerAttachment } from '@40rty/ams-sdk';
|
|
3
3
|
export interface AttachmentStripProps {
|
|
4
4
|
attachments: ComposerAttachment[];
|
|
5
5
|
onRemove: (localId: string) => void;
|
|
@@ -9,12 +9,12 @@ export { DragSheet, type DragSheetProps } from './DragSheet';
|
|
|
9
9
|
export { BottomSheet, type BottomSheetProps, type BottomSheetApi, } from './BottomSheet';
|
|
10
10
|
export { InlineCompletion, type InlineCompletionProps } from './InlineCompletion';
|
|
11
11
|
export { ComposerChipStrip } from './ComposerChipStrip';
|
|
12
|
+
export { TurnAsk } from './TurnAsk';
|
|
12
13
|
export { AnimatedPlaceholder } from './AnimatedPlaceholder';
|
|
13
14
|
export { TypedPlaceholder } from './TypedPlaceholder';
|
|
14
|
-
export { useComposerAttachments, type ComposerAttachmentsApi, type ComposerAttachment, } from './composer/useComposerAttachments';
|
|
15
15
|
export { AttachButton, type AttachButtonProps } from './composer/AttachButton';
|
|
16
16
|
export { AttachmentStrip, type AttachmentStripProps } from './composer/AttachmentStrip';
|
|
17
|
-
export { usePromptComposer, type UsePromptComposerApi, type UsePromptComposerOptions, } from '
|
|
17
|
+
export { usePromptComposer, type UsePromptComposerApi, type UsePromptComposerOptions, } from '@40rty/ams-sdk';
|
|
18
18
|
export { ClearSessionButton, type ClearSessionButtonProps } from './composer/ClearSessionButton';
|
|
19
19
|
export { ConversationHistoryButton, type ConversationHistoryButtonProps } from './composer/ConversationHistoryButton';
|
|
20
20
|
export { SideDock, useSideDockSpacing, SIDE_DOCK_REVEAL_MS, SIDE_DOCK_EASE, type SideDockProps, } from './SideDock';
|
|
@@ -14,6 +14,10 @@ export interface DefaultMobileShellProps {
|
|
|
14
14
|
* already looking at the thread when they'd want to see it. Carries the
|
|
15
15
|
* standing knowledge (dossier) chips. Omit to render none. */
|
|
16
16
|
presenceNotch?: React.ReactNode;
|
|
17
|
+
/** The shell's page composer (`ShellScaffold`'s `canvasComposer`). When the
|
|
18
|
+
* shell asks from the page, a phone keeps that same input, pinned to the
|
|
19
|
+
* bottom (`PageComposerDock`), and the island is not mounted. */
|
|
20
|
+
canvasComposer?: ShellSlot;
|
|
17
21
|
/** Control cluster (cart / wishlist / account) — the top chrome's right cell.
|
|
18
22
|
* Expected IN FLOW (see `LauncherDock`): the cell centres it on the bar's own
|
|
19
23
|
* line, alongside the hamburger and the brand mark. */
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
import { type ComposerAttachmentsApi } from '
|
|
2
|
+
import { type ComposerAttachmentsApi } from '@40rty/ams-sdk';
|
|
3
3
|
/**
|
|
4
4
|
* IslandComposeGroup — the resting island's compose pair: the leading `+` add
|
|
5
5
|
* button and the REAL inline textarea (the visitor types straight into it, no
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
import { type ComposerAttachmentsApi } from '
|
|
2
|
+
import { type ComposerAttachmentsApi } from '@40rty/ams-sdk';
|
|
3
3
|
/**
|
|
4
4
|
* IslandInputBar — the resting island's one input row, composed of exactly
|
|
5
5
|
* two swappable groups plus a trailing cluster:
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
/**
|
|
3
|
+
* The brand's own page composer, pinned to the bottom of a phone screen — the
|
|
4
|
+
* mobile home of a shell's `canvasComposer`. A shell that asks from the page
|
|
5
|
+
* (the conversation is the page: each turn heads its own) keeps that same input
|
|
6
|
+
* on a phone, in place of the platform island. Lifted by the keyboard / browser
|
|
7
|
+
* chrome inset; reports its height so the canvas keeps clear of it.
|
|
8
|
+
*/
|
|
9
|
+
export declare function PageComposerDock({ bottom, onHeightChange, children, }: {
|
|
10
|
+
bottom: number;
|
|
11
|
+
onHeightChange: (height: number) => void;
|
|
12
|
+
children: React.ReactNode;
|
|
13
|
+
}): React.ReactElement;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import { SuggestionAction } from '@40rty/ams-sdk';
|
|
3
|
-
import { type ComposerAttachmentsApi } from '
|
|
3
|
+
import { type ComposerAttachmentsApi } from '@40rty/ams-sdk';
|
|
4
4
|
/**
|
|
5
5
|
* RestIsland — the island FACE of the morph surface. The resting island NEVER
|
|
6
6
|
* expands for a running turn — it's the same single-line footprint idle or
|
|
@@ -1,14 +1,10 @@
|
|
|
1
1
|
import type React from 'react';
|
|
2
|
+
import type { ShellDockState } from '@40rty/ams-sdk';
|
|
2
3
|
/**
|
|
3
4
|
* Shell slot contract — shared by the desktop `ShellScaffold` and the mobile
|
|
4
5
|
* `DefaultMobileShell` so both resolve chrome the same way (and so the mobile
|
|
5
6
|
* shell can import the contract without a cycle back through ShellScaffold).
|
|
6
7
|
*/
|
|
7
|
-
/** Dock state handed to slots that can open/close the composer surface. */
|
|
8
|
-
export interface ShellDockState {
|
|
9
|
-
open: boolean;
|
|
10
|
-
toggle: () => void;
|
|
11
|
-
}
|
|
12
8
|
/** A slot is either static markup or a function of the dock state. */
|
|
13
9
|
export type ShellSlot = React.ReactNode | ((dock: ShellDockState) => React.ReactNode);
|
|
14
10
|
/** Resolve a slot to markup: static nodes pass through, function slots receive
|
package/package.json
CHANGED
|
@@ -62,8 +62,7 @@
|
|
|
62
62
|
"dependencies": {
|
|
63
63
|
"@radix-ui/react-slot": "^1.1.0",
|
|
64
64
|
"clsx": "^2.1.0",
|
|
65
|
-
"framer-motion": "^12.
|
|
66
|
-
"heic2any": "^0.0.4",
|
|
65
|
+
"framer-motion": "^12.34.5",
|
|
67
66
|
"isomorphic-dompurify": "^3.18.0",
|
|
68
67
|
"react-use-measure": "^2.1.1",
|
|
69
68
|
"streamdown": "^2.5.0",
|
|
@@ -72,12 +71,12 @@
|
|
|
72
71
|
"zod": "^3.23.0"
|
|
73
72
|
},
|
|
74
73
|
"peerDependencies": {
|
|
75
|
-
"@40rty/ams-sdk": "0.3
|
|
74
|
+
"@40rty/ams-sdk": "0.4.3",
|
|
76
75
|
"lucide-react": ">=0.400.0",
|
|
77
76
|
"react": ">=18.0.0",
|
|
78
77
|
"react-dom": ">=18.0.0"
|
|
79
78
|
},
|
|
80
|
-
"version": "0.3
|
|
79
|
+
"version": "0.4.3",
|
|
81
80
|
"homepage": "https://docs.40rty.ai",
|
|
82
81
|
"license": "UNLICENSED",
|
|
83
82
|
"engines": {
|
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
import { type AgentPresenceFrame } from '@40rty/ams-sdk';
|
|
2
|
-
import { type Fact } from './read-data';
|
|
3
|
-
/**
|
|
4
|
-
* The facts to render: the agent's read, minus what the visitor dismissed. ONE
|
|
5
|
-
* rule, ONE list, every surface.
|
|
6
|
-
*
|
|
7
|
-
* THE OPTIMISTIC BRIDGE IS GONE FROM THIS SURFACE. It wrote a chip the instant a
|
|
8
|
-
* variant was tapped, ahead of the agent's own read, to cover a ~1-2s gap — and
|
|
9
|
-
* it was confusing in exactly the way a second source of truth always is: the
|
|
10
|
-
* band showed a pick the brief did not, the `+N` counted entries its destination
|
|
11
|
-
* could not show, a visitor clicking through four sizes accumulated four live
|
|
12
|
-
* "facts" about themselves, and none of it was anything the agent had actually
|
|
13
|
-
* concluded. The notch's whole claim is "here is what I understand about you";
|
|
14
|
-
* a client-side guess wearing the same chip as a derived fact undoes that claim
|
|
15
|
-
* to save a second.
|
|
16
|
-
*
|
|
17
|
-
* What remains is the agent's own derivation, live — which is the thing that has
|
|
18
|
-
* to work, and the thing the bridge was hiding the failure of.
|
|
19
|
-
*/
|
|
20
|
-
export declare function useVisibleFacts(frame: AgentPresenceFrame | null): Fact[];
|
|
21
|
-
/**
|
|
22
|
-
* The same rule over a fact list the caller already has — the ELEMENT-stream
|
|
23
|
-
* path, where facts arrive as typed `PresenceFactElement`s rather than off a
|
|
24
|
-
* frame's untyped `data` bag.
|
|
25
|
-
*
|
|
26
|
-
* Both entry points share one body so a dismissed chip can never vanish from one
|
|
27
|
-
* surface and linger on another.
|
|
28
|
-
*/
|
|
29
|
-
export declare function useVisibleFactList<T extends Pick<Fact, 'label'>>(facts: T[]): T[];
|
|
30
|
-
/** The brief's set — identical to the band's, now that neither carries a bridge.
|
|
31
|
-
* Kept as its own name because the two surfaces ASK different questions ("what
|
|
32
|
-
* may I draw" vs "what will the drawer show") and the `+N` is derived from the
|
|
33
|
-
* difference; collapsing the names would hide that the count has a source. */
|
|
34
|
-
export declare const useUndismissedFacts: typeof useVisibleFactList;
|
|
35
|
-
export interface ForgetFactApi {
|
|
36
|
-
forget: (f: Pick<Fact, 'label' | 'value'>) => void;
|
|
37
|
-
}
|
|
38
|
-
export declare function useForgetFact(): ForgetFactApi;
|
|
39
|
-
/**
|
|
40
|
-
* Retire optimistic dismissals once the agent's held read no longer shows them.
|
|
41
|
-
* Pass the read's CURRENT (unfiltered) fact labels, or `null` while there's no
|
|
42
|
-
* held read so the optimism survives the gap. Call once where the frame is known.
|
|
43
|
-
*/
|
|
44
|
-
export declare function useReconcileDismissed(presentLabels: string[] | null): void;
|
|
45
|
-
/**
|
|
46
|
-
* What the visitor has forgotten, by label.
|
|
47
|
-
*
|
|
48
|
-
* The slot registry needs this explicitly (`fact-slots.ts`): it retains a chip
|
|
49
|
-
* through the projection's silences, so "gone from the list" no longer means
|
|
50
|
-
* "gone". A dismissal is the one departure the visitor authors, and it has to be
|
|
51
|
-
* able to say so rather than be inferred from an absence that now means
|
|
52
|
-
* something else.
|
|
53
|
-
*/
|
|
54
|
-
export declare function useDismissedLabels(): {
|
|
55
|
-
has: (label: string) => boolean;
|
|
56
|
-
};
|
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
import type { Cart } from '../../../types/commerce';
|
|
2
|
-
import type { ExitPending } from './CartFoot';
|
|
3
|
-
/**
|
|
4
|
-
* useCartView — the cart drawer's LOGIC, extracted so any renderer (the base
|
|
5
|
-
* `CartContent`, a brand's own dumb cart markup) shares one implementation of the
|
|
6
|
-
* things that must never diverge: line/count/total derivation, discount-aware
|
|
7
|
-
* money, and the exit-navigation flows (checkout + official-store handoff, with
|
|
8
|
-
* their framed-vs-standalone behavior and the in-flight `exitPending` state).
|
|
9
|
-
*
|
|
10
|
-
* A brand package stays DUMB UI: it calls this hook and renders its own head /
|
|
11
|
-
* body / foot around the returned view-model — it never re-implements checkout,
|
|
12
|
-
* promo, or the money math. `onCheckout` is the host override (framed embeds);
|
|
13
|
-
* when absent the hook navigates `cart.checkoutUrl` itself.
|
|
14
|
-
*/
|
|
15
|
-
export interface CartViewModel {
|
|
16
|
-
lines: Cart['lines'];
|
|
17
|
-
count: number;
|
|
18
|
-
/**
|
|
19
|
-
* The backend's pre-discount subtotal — never a client re-derivation.
|
|
20
|
-
*
|
|
21
|
-
* This used to sum the line totals, and that is what let three unsettled
|
|
22
|
-
* lines quietly drag a cart's subtotal below the rows the visitor was
|
|
23
|
-
* looking at: a pending line contributes no money, so the footer showed a
|
|
24
|
-
* confident figure for a cart that did not exist. The adapter already
|
|
25
|
-
* returns `cart.cost.subtotalAmount`; the number the visitor is asked to
|
|
26
|
-
* pay comes from whoever will charge it.
|
|
27
|
-
*/
|
|
28
|
-
subtotal: number;
|
|
29
|
-
/**
|
|
30
|
-
* True while any line is still awaiting the backend. The money above
|
|
31
|
-
* describes the SETTLED cart only, so a surface showing totals must say they
|
|
32
|
-
* are still moving rather than present them as final.
|
|
33
|
-
*/
|
|
34
|
-
totalsPending: boolean;
|
|
35
|
-
currency: string;
|
|
36
|
-
discountCodes: Cart['discountCodes'];
|
|
37
|
-
/** Backend post-discount total; undefined when the backend doesn't distinguish it. */
|
|
38
|
-
backendTotal: number | undefined;
|
|
39
|
-
/** Discount the applied code actually removed (backend truth), else 0. */
|
|
40
|
-
discountAmount: number;
|
|
41
|
-
/** The real total to charge — backendTotal when present, else subtotal. */
|
|
42
|
-
effectiveTotal: number;
|
|
43
|
-
/** Which exit CTA is mid-navigation; both disable while set. */
|
|
44
|
-
exitPending: ExitPending;
|
|
45
|
-
/** Online-store cart handoff URL — undefined hides the store CTA. */
|
|
46
|
-
storeCartUrl: string | undefined;
|
|
47
|
-
handleCheckout: () => void;
|
|
48
|
-
handleGoToStore: () => void;
|
|
49
|
-
}
|
|
50
|
-
export declare function useCartView(cart: Cart | null, onCheckout?: () => void | Promise<void>): CartViewModel;
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
export interface ProjectionView {
|
|
2
|
-
/** True when a standing projection is hiding part of this entity. */
|
|
3
|
-
active: boolean;
|
|
4
|
-
/** True when the visitor toggled "show all" on this element. */
|
|
5
|
-
expanded: boolean;
|
|
6
|
-
/** How many items the projection hides. */
|
|
7
|
-
hiddenCount: number;
|
|
8
|
-
/** Axes the projection narrowed — render these as a label when
|
|
9
|
-
* collapsed; leave natively single-value axes hidden. */
|
|
10
|
-
trimmedAxes: string[];
|
|
11
|
-
/** The un-projected entity — render this instead of the trimmed prop
|
|
12
|
-
* when `expanded`. Typed `unknown`: the caller parses it with its own
|
|
13
|
-
* schema (the same one it already applies to the trimmed prop). */
|
|
14
|
-
fullEntity: unknown;
|
|
15
|
-
/** Flip trimmed ⇄ full for this element. */
|
|
16
|
-
toggle: () => void;
|
|
17
|
-
}
|
|
18
|
-
/**
|
|
19
|
-
* `useProjection(projectionProp, entity)` — projection state for a
|
|
20
|
-
* component's primary entity. Pass the component's `__projection` prop and
|
|
21
|
-
* its (trimmed) entity prop. Returns `active: false` when nothing is
|
|
22
|
-
* projected.
|
|
23
|
-
*/
|
|
24
|
-
export declare function useProjection(projectionProp: unknown, entity: unknown): ProjectionView;
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
/** True for an iPhone HEIC/HEIF file — by MIME, or by extension when the
|
|
2
|
-
* browser reports an empty type (which it does for HEIC). */
|
|
3
|
-
export declare function isHeic(file: File): boolean;
|
|
4
|
-
/** Decode a HEIC file to a JPEG `File` (renamed `.jpg`). Throws if libheif
|
|
5
|
-
* can't decode it — the caller falls back to the original. */
|
|
6
|
-
export declare function heicToJpeg(file: File): Promise<File>;
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
import { type AttachmentRef } from '@40rty/ams-sdk';
|
|
2
|
-
export type AttachmentStatus = 'uploading' | 'ready' | 'error';
|
|
3
|
-
/** One composer attachment through its lifecycle: picked → uploading → ready /
|
|
4
|
-
* error. The composer renders these as thumbnails; only `ready` ones are sent. */
|
|
5
|
-
export interface ComposerAttachment {
|
|
6
|
-
localId: string;
|
|
7
|
-
name: string;
|
|
8
|
-
mimeType: string;
|
|
9
|
-
size: number;
|
|
10
|
-
/** Object URL for an image preview; null for non-image files. */
|
|
11
|
-
previewUrl: string | null;
|
|
12
|
-
status: AttachmentStatus;
|
|
13
|
-
/** Set once the upload resolves (`status === 'ready'`). */
|
|
14
|
-
ref: AttachmentRef | null;
|
|
15
|
-
/** Visitor-safe failure message (`status === 'error'`). */
|
|
16
|
-
error: string | null;
|
|
17
|
-
}
|
|
18
|
-
export interface ComposerAttachmentsApi {
|
|
19
|
-
attachments: ComposerAttachment[];
|
|
20
|
-
/** Validate + start uploading each file; rejects show as error thumbnails. */
|
|
21
|
-
addFiles: (files: FileList | File[]) => void;
|
|
22
|
-
remove: (localId: string) => void;
|
|
23
|
-
/** Drop everything (after send) and revoke object URLs. */
|
|
24
|
-
clear: () => void;
|
|
25
|
-
/** True while any upload is in flight — the composer blocks send. */
|
|
26
|
-
hasPending: boolean;
|
|
27
|
-
/** Refs for the successfully-uploaded files, in order. */
|
|
28
|
-
readyRefs: AttachmentRef[];
|
|
29
|
-
}
|
|
30
|
-
/** The accept attribute for a file input — derived from the shared allow-list. */
|
|
31
|
-
export declare const ATTACHMENT_ACCEPT: string;
|
|
32
|
-
/**
|
|
33
|
-
* Composer attachment state machine. Owns picking, client validation, the
|
|
34
|
-
* upload (via `session.uploadAttachment`), removal, and object-URL lifecycle.
|
|
35
|
-
* The composer stays presentational — it renders `attachments` and calls back.
|
|
36
|
-
*/
|
|
37
|
-
export declare function useComposerAttachments(): ComposerAttachmentsApi;
|
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
import * as React from 'react';
|
|
2
|
-
import { type ComposerAttachmentsApi } from './useComposerAttachments';
|
|
3
|
-
export interface UsePromptComposerOptions {
|
|
4
|
-
/**
|
|
5
|
-
* External attachments controller. Provide it to run in "controlled" mode —
|
|
6
|
-
* a brand shell that LIFTS `useComposerAttachments()` (e.g. the mobile shell
|
|
7
|
-
* sharing one state between a rest-island camera trigger and the composer)
|
|
8
|
-
* passes the shared controller here. Omit and the hook owns its own. The
|
|
9
|
-
* internal instance always runs (an idle controller when controlled —
|
|
10
|
-
* harmless) since hooks can't be conditional.
|
|
11
|
-
*/
|
|
12
|
-
attachments?: ComposerAttachmentsApi;
|
|
13
|
-
}
|
|
14
|
-
export interface UsePromptComposerApi {
|
|
15
|
-
/** Current draft text. */
|
|
16
|
-
value: string;
|
|
17
|
-
/** Set the draft. Wire to the textarea `onChange` and any type-to-focus path. */
|
|
18
|
-
setValue: (next: string) => void;
|
|
19
|
-
/** Attachment state machine (controlled or internal — see options). */
|
|
20
|
-
attachments: ComposerAttachmentsApi;
|
|
21
|
-
/** Speech-to-text state for a `DictationButton`. */
|
|
22
|
-
dictation: {
|
|
23
|
-
listening: boolean;
|
|
24
|
-
supported: boolean;
|
|
25
|
-
toggle: () => void;
|
|
26
|
-
};
|
|
27
|
-
/** Clipboard handler — promotes pasted image/file bytes into attachments. */
|
|
28
|
-
onPaste: (e: React.ClipboardEvent<HTMLTextAreaElement>) => void;
|
|
29
|
-
/**
|
|
30
|
-
* Sendable when there's text OR a ready attachment, and no upload is still in
|
|
31
|
-
* flight (so a file never gets left out of the turn it was attached to).
|
|
32
|
-
*/
|
|
33
|
-
canSend: boolean;
|
|
34
|
-
/** Send the turn (text + ready attachment refs), then clear draft + strip. */
|
|
35
|
-
submit: () => void;
|
|
36
|
-
}
|
|
37
|
-
/**
|
|
38
|
-
* `usePromptComposer` — the headless behavior shared by every prompt-input
|
|
39
|
-
* surface (the side-dock `Composer`, a hero-embedded entry box, a mobile voice
|
|
40
|
-
* island). Owns the cross-cutting wiring — draft state, attachment
|
|
41
|
-
* upload lifecycle, dictation that appends onto typed text, paste-to-attach,
|
|
42
|
-
* the send gate, and the send-then-clear — over the ONE `FourtySession`.
|
|
43
|
-
*
|
|
44
|
-
* It is presentation-free: a consumer renders its own chrome (textarea, send
|
|
45
|
-
* button, `AttachButton` / `DictationButton` / `AttachmentStrip`) and wires the
|
|
46
|
-
* returned handlers in. Surface-specific behavior (type-to-focus, a streaming
|
|
47
|
-
* stop/abort morph, autosize policy, agent-placeholder rotation) stays in the
|
|
48
|
-
* consumer — this hook is only the shared core, so the brand connects through
|
|
49
|
-
* ONE composition hook rather than re-deriving the upload + dictation plumbing.
|
|
50
|
-
*/
|
|
51
|
-
export declare function usePromptComposer(options?: UsePromptComposerOptions): UsePromptComposerApi;
|
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
import type { ShellDockState } from './slots';
|
|
2
|
-
/**
|
|
3
|
-
* When is the side dock open?
|
|
4
|
-
*
|
|
5
|
-
* Four inputs, and the whole difficulty is telling some of them apart:
|
|
6
|
-
*
|
|
7
|
-
* - the HOST's persisted answer (`useDockPersistence`) — the panel as the
|
|
8
|
-
* visitor left it, known on the very first render, server included;
|
|
9
|
-
* - ENGAGEMENT — has the visitor chatted or navigated (`useHasLeftSeedHome`);
|
|
10
|
-
* - a NEW user turn, which reopens the panel for shells that opt in;
|
|
11
|
-
* - whether an external agent is DRIVING the page (`useAgentDriven`).
|
|
12
|
-
*
|
|
13
|
-
* ── WHY AN AGENT TURN IS NOT ENGAGEMENT ────────────────────────────────────
|
|
14
|
-
*
|
|
15
|
-
* The last input is the newest and it exists because of a bug that shipped: a
|
|
16
|
-
* WebMCP client calling `send_message` writes a user message, which trips BOTH
|
|
17
|
-
* of the other two — it reads as the visitor having chatted, and as a brand new
|
|
18
|
-
* user turn. So the side dock opened on every agent call, sliding a chat panel
|
|
19
|
-
* over the canvas while `ComposerDock` was correctly folding its own composer to
|
|
20
|
-
* a bubble. Half the shell stood down and the other half threw itself open.
|
|
21
|
-
*
|
|
22
|
-
* There is nobody on this page to read that panel: the conversation is happening
|
|
23
|
-
* in the agent's client, and the dock is reserving a third of the viewport for
|
|
24
|
-
* it. So an agent-driven page keeps the panel shut — INCLUDING over a persisted
|
|
25
|
-
* "open", because a remembered preference is about the visitor's own browsing,
|
|
26
|
-
* not about a session someone else is driving.
|
|
27
|
-
*
|
|
28
|
-
* The visitor's own toggle still outranks all of it. That is the same contract
|
|
29
|
-
* the composer keeps: agent-driven folds the surface, and it stays folded until
|
|
30
|
-
* the human opens it THEMSELVES, after which nothing an agent does closes it.
|
|
31
|
-
*
|
|
32
|
-
* Engagement is derived from session state that does not exist during the
|
|
33
|
-
* server render and does not exist on the client's first render either: it
|
|
34
|
-
* arrives when the session restores, a few hundred milliseconds after paint.
|
|
35
|
-
* So a returning visitor's page painted dock-shut and then snapped it open,
|
|
36
|
-
* shoving the canvas — and it did that even to someone who had deliberately
|
|
37
|
-
* folded the panel, because replayed history is indistinguishable from live
|
|
38
|
-
* engagement if you only look at the current value.
|
|
39
|
-
*
|
|
40
|
-
* The session becoming known is the moment this load's own history has
|
|
41
|
-
* finished arriving, so it is the BASELINE: engagement already true at the
|
|
42
|
-
* baseline is history (accounted for by the persisted answer), and only what
|
|
43
|
-
* happens after it counts as the visitor engaging now.
|
|
44
|
-
*
|
|
45
|
-
* With NO persisted answer (`initialOpen: null` — a host that persists
|
|
46
|
-
* nothing, or a visitor we have never seen) there is nothing to account for
|
|
47
|
-
* and any engagement latches, exactly as it always did.
|
|
48
|
-
*/
|
|
49
|
-
/**
|
|
50
|
-
* `autoOpen: false` — the dock never opens by itself (engagement, a new message):
|
|
51
|
-
* only the visitor's own toggle opens it. For a shell whose conversation already
|
|
52
|
-
* lives in the page, where the dock is an optional view of the thread.
|
|
53
|
-
*/
|
|
54
|
-
export declare function useDockState(reopenOnMessage: boolean, autoOpen: boolean): ShellDockState;
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* `true` when the visitor is on the canonical welcome layout — turn 0,
|
|
3
|
-
* no userMessage, displayed layout structurally equal to the seed.
|
|
4
|
-
*
|
|
5
|
-
* After ANY click-driven `navigate` (productDetail / productGrid /
|
|
6
|
-
* articleDetail / etc.), the displayed layout diverges from `seedLayout`,
|
|
7
|
-
* so this returns false and the composer leaves hero placement.
|
|
8
|
-
*
|
|
9
|
-
* Reference-compare is unreliable (JSON round-trip breaks identity),
|
|
10
|
-
* so structural-compare via JSON.stringify — both payloads are small
|
|
11
|
-
* enough that the cost is irrelevant.
|
|
12
|
-
*/
|
|
13
|
-
export declare function useIsSeedHome(): boolean;
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import type { Cart } from '@40rty/ams-sdk';
|
|
2
|
-
export interface CartShape {
|
|
3
|
-
cart: Cart | null;
|
|
4
|
-
totalQuantity: number;
|
|
5
|
-
updateLine: (lineId: string, quantity: number) => Promise<unknown> | void;
|
|
6
|
-
removeLine: (lineId: string) => Promise<unknown> | void;
|
|
7
|
-
applyDiscountCode: (code: string) => Promise<unknown> | void;
|
|
8
|
-
removeDiscountCode: (code: string) => Promise<unknown> | void;
|
|
9
|
-
isDiscountPending: boolean;
|
|
10
|
-
}
|
|
11
|
-
/**
|
|
12
|
-
* useSafeCart — calls useCart() but degrades to null when no
|
|
13
|
-
* CommerceProvider is mounted. Shell components rely on this so the
|
|
14
|
-
* shell renders cleanly in storybook / preview contexts without a
|
|
15
|
-
* commerce client wired up.
|
|
16
|
-
*/
|
|
17
|
-
export declare function useSafeCart(): CartShape | null;
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Wraps `useFacts()` with provider-presence safety.
|
|
3
|
-
*
|
|
4
|
-
* Returns the live fact map if a `<FourtyProvider>` is mounted upstream.
|
|
5
|
-
* Returns an empty object and logs a one-shot console warning otherwise —
|
|
6
|
-
* mirrors `useSafeFourtySession`, used by catalog components that read
|
|
7
|
-
* facts inside storybook / preview sandboxes without a provider.
|
|
8
|
-
*/
|
|
9
|
-
export declare function useSafeFacts(): Record<string, unknown>;
|