@antglobal/copilot-cards-web 1.0.8 → 1.0.9
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/README.md +35 -1
- package/dist/index.d.ts +20 -1
- package/dist/index.js +794 -109
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -7,7 +7,7 @@ The package includes the core schema and action APIs, responsive rendering, Shad
|
|
|
7
7
|
## Installation
|
|
8
8
|
|
|
9
9
|
```bash
|
|
10
|
-
npm install @antglobal/copilot-cards-web@1.0.
|
|
10
|
+
npm install @antglobal/copilot-cards-web@1.0.8
|
|
11
11
|
```
|
|
12
12
|
|
|
13
13
|
`@antglobal/copilot-cards-core` is installed automatically.
|
|
@@ -113,10 +113,44 @@ Renders a complete schema and returns a `CardInstance`:
|
|
|
113
113
|
```ts
|
|
114
114
|
interface CardInstance {
|
|
115
115
|
updateVariables(variables: Record<string, unknown>): void;
|
|
116
|
+
onScroll(nodeId: string, listener: CardScrollListener): () => void;
|
|
116
117
|
dispose(): void;
|
|
117
118
|
}
|
|
118
119
|
```
|
|
119
120
|
|
|
121
|
+
`CardScrollEvent` and `CardScrollListener` are top-level package exports. The
|
|
122
|
+
event contains readonly `node`, `scrollTop`, `scrollLeft`, `scrollHeight`,
|
|
123
|
+
`scrollWidth`, `clientHeight`, and `clientWidth` values:
|
|
124
|
+
|
|
125
|
+
```ts
|
|
126
|
+
import type {
|
|
127
|
+
CardScrollEvent,
|
|
128
|
+
CardScrollListener,
|
|
129
|
+
} from "@antglobal/copilot-cards-web";
|
|
130
|
+
|
|
131
|
+
const unsubscribe = card.onScroll("friendsList", event => {
|
|
132
|
+
const remaining =
|
|
133
|
+
event.scrollHeight - event.clientHeight - event.scrollTop;
|
|
134
|
+
});
|
|
135
|
+
|
|
136
|
+
unsubscribe(); // Idempotent; card.dispose() also removes the subscription.
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
The subscription follows the logical node ID across physical replacement and
|
|
140
|
+
reports native-frequency values. It does not emit an initial, render, resize,
|
|
141
|
+
or `updateVariables` callback. Generated internal scroll tracks and scroll
|
|
142
|
+
ports inside Shadow DOM are not observed. Thresholds, throttling, requests,
|
|
143
|
+
locks, cursors, retries, and deduplication remain host responsibilities.
|
|
144
|
+
|
|
145
|
+
For pagination, continue passing the complete next array to `updateVariables`.
|
|
146
|
+
The SDK retains the Repeat owner and old prefix only when it can strictly prove
|
|
147
|
+
a structurally equal tail extension whose retained rendering is unchanged, on
|
|
148
|
+
a default-rendered `Container` with an unambiguous direct-child `default` or
|
|
149
|
+
`flex` layout. Every unproven case uses the existing replacement behavior; this
|
|
150
|
+
is not a general keyed diff or public append API. A trailing control object is
|
|
151
|
+
eligible only when it does not change retained rows. Put temporary loading UI
|
|
152
|
+
outside the Repeat owner when scroll identity matters.
|
|
153
|
+
|
|
120
154
|
Common render options include:
|
|
121
155
|
|
|
122
156
|
| Option | Purpose |
|
package/dist/index.d.ts
CHANGED
|
@@ -55,6 +55,23 @@ interface CardFocusChangeEvent {
|
|
|
55
55
|
previousNode: CardNodeHandle | null;
|
|
56
56
|
}
|
|
57
57
|
type CardFocusChangeListener = (event: CardFocusChangeEvent) => void;
|
|
58
|
+
interface CardScrollEvent {
|
|
59
|
+
/** Stable logical handle for the scrolling card node. */
|
|
60
|
+
readonly node: CardNodeHandle;
|
|
61
|
+
/** Raw native vertical scroll offset. */
|
|
62
|
+
readonly scrollTop: number;
|
|
63
|
+
/** Raw native horizontal scroll offset, including negative RTL values. */
|
|
64
|
+
readonly scrollLeft: number;
|
|
65
|
+
/** Raw native scrollable content height. */
|
|
66
|
+
readonly scrollHeight: number;
|
|
67
|
+
/** Raw native scrollable content width. */
|
|
68
|
+
readonly scrollWidth: number;
|
|
69
|
+
/** Raw native viewport height. */
|
|
70
|
+
readonly clientHeight: number;
|
|
71
|
+
/** Raw native viewport width. */
|
|
72
|
+
readonly clientWidth: number;
|
|
73
|
+
}
|
|
74
|
+
type CardScrollListener = (event: CardScrollEvent) => void;
|
|
58
75
|
|
|
59
76
|
interface ResponsiveMobileOptions {
|
|
60
77
|
readonly unit: 'rem';
|
|
@@ -108,6 +125,8 @@ interface CardInstance {
|
|
|
108
125
|
getNode: (id: string) => CardNodeHandle;
|
|
109
126
|
/** Observe logical focus changes within this card. */
|
|
110
127
|
onFocusChange: (listener: CardFocusChangeListener) => () => void;
|
|
128
|
+
/** Observe native scroll metrics for one logical card node. */
|
|
129
|
+
onScroll: (nodeId: string, listener: CardScrollListener) => () => void;
|
|
111
130
|
}
|
|
112
131
|
/**
|
|
113
132
|
* Render a card schema into a container element.
|
|
@@ -1841,4 +1860,4 @@ declare const componentRenderers: Record<string, ComponentRenderer>;
|
|
|
1841
1860
|
declare function registerComponent(type: string, renderer: ComponentRenderer): void;
|
|
1842
1861
|
|
|
1843
1862
|
export { BaseElement, BotSDK, CardButton, CardChoiceItem, CardChoiceList, CardCollapse, CardCounter, CardDivider, CardForm, CardHtml, CardIcon, CardImage, CardInput, CardLoading, CardPasscodeInput, CardProgress, CardRate, CardSelect, CardSteps, CardSwitch, CardTag, CardText, DEFAULT_MOBILE_RESPONSIVE, LocalActionConfigProvider, RemoteActionConfigProvider, buildStyleString, componentRenderers, connectSSE, connectStreaming, convertPixelTokens, createResponsiveContext, createWebActionContext, isMobileViewport, onViewportChange, pxToRem, pxToVw, registerComponent, renderCard, renderStreamingCard, resolveSize, sanitizeHtml, trimIncompleteTag };
|
|
1844
|
-
export type { A2UIActionPayload, BotSDKOptions, ButtonProps, CardFocusChangeEvent, CardFocusChangeListener, CardInstance, CardNodeHandle, ChoiceIndicatorIcon, ChoiceItemProps, ChoiceListProps, ChoiceListValue, CollapseProps, ComponentRenderer, ConnectorConfig, CounterIcon, CounterProps, DividerProps, FormField, FormProps, FormRule, HtmlProps, IconProps, ImageProps, InputAffix, InputAffixConfig, InputProps, LoadingProps, PartialFinalizeResult, PasscodeInputProps, ProgressProps, ProgressSegment, RateProps, RenderCardOptions, ResponsiveContext, ResponsiveMobileOptions, ResponsiveOptions, SSEConnectOptions, SelectOption, SelectProps, SelectSize, SelectStyles, SelectVariant, StepIcon, StepItem, StepsProps, StreamingCardInstance, StreamingCardOptions, StreamingConnectOptions, StreamingConnection, SwitchProps, TagProps, TextProps, WebActionContextOptions };
|
|
1863
|
+
export type { A2UIActionPayload, BotSDKOptions, ButtonProps, CardFocusChangeEvent, CardFocusChangeListener, CardInstance, CardNodeHandle, CardScrollEvent, CardScrollListener, ChoiceIndicatorIcon, ChoiceItemProps, ChoiceListProps, ChoiceListValue, CollapseProps, ComponentRenderer, ConnectorConfig, CounterIcon, CounterProps, DividerProps, FormField, FormProps, FormRule, HtmlProps, IconProps, ImageProps, InputAffix, InputAffixConfig, InputProps, LoadingProps, PartialFinalizeResult, PasscodeInputProps, ProgressProps, ProgressSegment, RateProps, RenderCardOptions, ResponsiveContext, ResponsiveMobileOptions, ResponsiveOptions, SSEConnectOptions, SelectOption, SelectProps, SelectSize, SelectStyles, SelectVariant, StepIcon, StepItem, StepsProps, StreamingCardInstance, StreamingCardOptions, StreamingConnectOptions, StreamingConnection, SwitchProps, TagProps, TextProps, WebActionContextOptions };
|