@antglobal/copilot-cards-web 1.0.3 → 1.0.4

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.
Files changed (3) hide show
  1. package/dist/index.d.ts +36 -32
  2. package/dist/index.js +405 -142
  3. package/package.json +2 -2
package/dist/index.d.ts CHANGED
@@ -29,6 +29,24 @@ interface WebActionContextOptions {
29
29
  */
30
30
  declare function createWebActionContext(options?: WebActionContextOptions): ActionRunnerContext;
31
31
 
32
+ interface ResponsiveMobileOptions {
33
+ readonly unit: 'rem';
34
+ readonly rootValue: number;
35
+ }
36
+ interface ResponsiveOptions {
37
+ readonly mobile?: ResponsiveMobileOptions;
38
+ }
39
+ interface ResponsiveContext {
40
+ readonly active: boolean;
41
+ readonly rootValue: number;
42
+ resolveLength(value: string | number): string;
43
+ convertCSS(value: string): string;
44
+ }
45
+ declare const DEFAULT_MOBILE_RESPONSIVE: ResponsiveMobileOptions;
46
+ /** Convert CSS px lengths while preserving strings, comments, and URLs. */
47
+ declare function convertPixelTokens(value: string, rootValue: number): string;
48
+ declare function createResponsiveContext(isMobile: boolean, responsive?: ResponsiveOptions): ResponsiveContext;
49
+
32
50
  /**
33
51
  * renderCard — the primary public API for @antglobal/copilot-cards-web.
34
52
  *
@@ -46,6 +64,8 @@ declare function createWebActionContext(options?: WebActionContextOptions): Acti
46
64
  interface RenderCardOptions extends WebActionContextOptions {
47
65
  /** Force mobile mode; auto-detected from viewport if omitted */
48
66
  isMobile?: boolean;
67
+ /** Mobile sizing conversion. `isMobile: true` defaults to rem/rootValue 100. */
68
+ responsive?: ResponsiveOptions;
49
69
  /** External variables to merge into schema.variables (overrides schema defaults) */
50
70
  variables?: Record<string, any>;
51
71
  /** Bot ID — used to look up bot-scoped action handlers */
@@ -422,16 +442,18 @@ declare abstract class BaseElement extends HTMLElement {
422
442
  protected _node: RenderTreeNode | null;
423
443
  protected _props: Record<string, any>;
424
444
  protected _isMobile: boolean;
445
+ protected _responsiveOptions?: ResponsiveOptions;
446
+ protected _responsive: ResponsiveContext;
425
447
  constructor();
426
448
  /**
427
449
  * Set component data and trigger render.
428
450
  * Called by the component renderer (from `renderCard` pipeline).
429
451
  */
430
- setData(node: RenderTreeNode, props: Record<string, any>, isMobile: boolean): void;
452
+ setData(node: RenderTreeNode, props: Record<string, any>, isMobile: boolean, responsive?: ResponsiveOptions): void;
431
453
  /**
432
454
  * Update props only (e.g. on variable change + re-render).
433
455
  */
434
- updateProps(props: Record<string, any>, isMobile?: boolean): void;
456
+ updateProps(props: Record<string, any>, isMobile?: boolean, responsive?: ResponsiveOptions): void;
435
457
  /**
436
458
  * Subclasses must implement this to render their UI into `this.shadowRoot`.
437
459
  */
@@ -445,6 +467,8 @@ declare abstract class BaseElement extends HTMLElement {
445
467
  protected buildInlineStyle(style?: Record<string, any>, isExpressionResult?: boolean): string;
446
468
  /** Resolve a single size value (number → px). */
447
469
  protected toCSS(value: string | number): string;
470
+ /** Assign component markup and convert only its CSS declarations. */
471
+ protected setShadowHTML(html: string): void;
448
472
  /**
449
473
  * Escape a value before interpolating it into a double-quoted HTML
450
474
  * attribute. Browsers decode the entities before parsing inline CSS, so
@@ -472,7 +496,7 @@ declare class CardText extends BaseElement {
472
496
  private _mdPendingUpdate;
473
497
  private _tooltipEl;
474
498
  private _tooltipTimer;
475
- setData(node: RenderTreeNode, props: Record<string, any>, isMobile: boolean): void;
499
+ setData(node: RenderTreeNode, props: Record<string, any>, isMobile: boolean, responsive?: ResponsiveOptions): void;
476
500
  protected render(): void;
477
501
  /**
478
502
  * Handle incremental content update in streaming mode.
@@ -500,7 +524,7 @@ declare class CardText extends BaseElement {
500
524
  * Remove cursor when streaming ends.
501
525
  * Called externally when streaming prop changes to false.
502
526
  */
503
- updateProps(props: Record<string, any>, isMobile?: boolean): void;
527
+ updateProps(props: Record<string, any>, isMobile?: boolean, responsive?: ResponsiveOptions): void;
504
528
  /**
505
529
  * Parse markdown to HTML using marked.
506
530
  */
@@ -789,30 +813,6 @@ declare class CardTag extends BaseElement {
789
813
  protected render(): void;
790
814
  }
791
815
 
792
- /**
793
- * CardSelect — Custom Element for a dropdown selector.
794
- *
795
- * Schema example:
796
- * ```json
797
- * {
798
- * "type": "Select",
799
- * "props": {
800
- * "placeholder": "请选择",
801
- * "options": [
802
- * { "label": "选项一", "value": "1" },
803
- * { "label": "选项二", "value": "2" }
804
- * ],
805
- * "value": ""
806
- * }
807
- * }
808
- * ```
809
- *
810
- * The value is semi-controlled: a user-picked option shows on the trigger
811
- * immediately even when no `onChange` action is wired, while any external
812
- * `props.value` change (e.g. a variable update re-render) overrides the
813
- * local pick.
814
- */
815
-
816
816
  declare class CardSelect extends BaseElement {
817
817
  private _open;
818
818
  private _activeIndex;
@@ -824,7 +824,7 @@ declare class CardSelect extends BaseElement {
824
824
  static readonly is = "ai-card-select";
825
825
  protected render(): void;
826
826
  disconnectedCallback(): void;
827
- updateProps(props: Record<string, any>, isMobile?: boolean): void;
827
+ updateProps(props: Record<string, any>, isMobile?: boolean, responsive?: ResponsiveOptions): void;
828
828
  private _setOpen;
829
829
  private openWithCurrentOption;
830
830
  private handleKeydown;
@@ -1191,6 +1191,8 @@ interface SelectStyles {
1191
1191
  option?: Record<string, any>;
1192
1192
  /** Style merged into the selected option */
1193
1193
  selectedOption?: Record<string, any>;
1194
+ /** Arrow wrapper style; overrides arrowSize for declared dimensions */
1195
+ arrow?: Record<string, any>;
1194
1196
  }
1195
1197
  interface SelectProps {
1196
1198
  /** Dropdown options list */
@@ -1217,6 +1219,8 @@ interface SelectProps {
1217
1219
  variant?: SelectVariant;
1218
1220
  /** Accent used for focus and selection states */
1219
1221
  accentColor?: string;
1222
+ /** Dropdown arrow size in px or as a CSS length */
1223
+ arrowSize?: number | string;
1220
1224
  /** Advanced semantic styles for internal parts */
1221
1225
  styles?: SelectStyles;
1222
1226
  }
@@ -1758,7 +1762,7 @@ declare class CardChoiceItem extends BaseElement {
1758
1762
  * for the `renderCard` pipeline to attach events and children.
1759
1763
  */
1760
1764
 
1761
- type ComponentRenderer = (node: RenderTreeNode, props: Record<string, any>, isMobile: boolean) => HTMLElement;
1765
+ type ComponentRenderer = (node: RenderTreeNode, props: Record<string, any>, isMobile: boolean, responsive?: ResponsiveOptions) => HTMLElement;
1762
1766
  declare const componentRenderers: Record<string, ComponentRenderer>;
1763
1767
  /**
1764
1768
  * Register a custom component renderer.
@@ -1775,5 +1779,5 @@ declare const componentRenderers: Record<string, ComponentRenderer>;
1775
1779
  */
1776
1780
  declare function registerComponent(type: string, renderer: ComponentRenderer): void;
1777
1781
 
1778
- export { BaseElement, BotSDK, CardButton, CardChoiceItem, CardChoiceList, CardCollapse, CardCounter, CardDivider, CardForm, CardHtml, CardIcon, CardImage, CardInput, CardLoading, CardPasscodeInput, CardProgress, CardRate, CardSelect, CardSteps, CardSwitch, CardTag, CardText, LocalActionConfigProvider, RemoteActionConfigProvider, buildStyleString, componentRenderers, connectSSE, connectStreaming, createWebActionContext, isMobileViewport, onViewportChange, pxToRem, pxToVw, registerComponent, renderCard, renderStreamingCard, resolveSize, sanitizeHtml, trimIncompleteTag };
1779
- export type { A2UIActionPayload, BotSDKOptions, ButtonProps, CardInstance, 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, SSEConnectOptions, SelectOption, SelectProps, SelectSize, SelectStyles, SelectVariant, StepIcon, StepItem, StepsProps, StreamingCardInstance, StreamingCardOptions, StreamingConnectOptions, StreamingConnection, SwitchProps, TagProps, TextProps, WebActionContextOptions };
1782
+ 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 };
1783
+ export type { A2UIActionPayload, BotSDKOptions, ButtonProps, CardInstance, 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 };