UNPKG

@cw-parcelpanel/headless-react

Version:

ParcelPanel Headless React Component - EDD & Tracking widgets for Shopify stores with TypeScript support

77 lines (76 loc) 2.83 kB
import React from 'react'; import { ParcelPanelEDDSDK, SDKConfig, SDKProductInfo } from '../sdk'; /** * Props interface for ParcelPanel EDD React component */ export interface ParcelPanelEDDProps extends Omit<SDKConfig, 'shopDomain'> { /** Shopify shop domain (required), e.g., "example.myshopify.com" */ shopDomain: string; /** CSS class name for the component */ className?: string; /** Inline styles for the component */ style?: React.CSSProperties; /** Address selector configuration options */ selectorOptions?: { /** Default country code */ country?: string; /** Default province/state code */ province?: string; /** JSON string of additional settings */ settings?: string; }; /** Callback fired when the component is successfully loaded */ onLoaded?: (sdk: ParcelPanelEDDSDK) => void; /** Callback fired when an error occurs */ onError?: (error: Error) => void; /** Callback fired when the address/location changes */ onLocationChange?: (location: { country: string; province: string; }) => void; } /** * Ref interface for ParcelPanel EDD React component methods */ export interface ParcelPanelEDDRef { /** Get the SDK instance */ getSDK: () => ParcelPanelEDDSDK | null; /** Set product information */ setProduct: (productInfo: SDKProductInfo) => void; /** Update customer information */ setCustomer: (customer: SDKConfig['customer']) => void; /** Update styling settings */ setSettings: (settings: SDKConfig['settings']) => void; /** Update SDK configuration */ updateConfig: (config: Partial<SDKConfig>) => void; /** Destroy the component and clean up resources */ destroy: () => void; } export declare const ParcelPanelEDD: React.ForwardRefExoticComponent<ParcelPanelEDDProps & React.RefAttributes<ParcelPanelEDDRef>>; export type { SDKConfig, SDKProductInfo }; export { ParcelPanelEDDSDK } from '../sdk'; export interface TrackingWidgetProps { /** 语言简码,如 'zh-CN', 'en', 'ja' 等 */ locale?: string; /** 店铺域名地址,如 'yourstorename.myshopify.com' */ shopDomain: string; /** 组件的CSS类名 */ className?: string; /** 组件的样式 */ style?: React.CSSProperties; /** 当组件加载完成时的回调 */ onLoaded?: () => void; /** 当出现错误时的回调 */ onError?: (error: Error) => void; } declare function TrackingWidget(props: TrackingWidgetProps): React.DetailedReactHTMLElement<{ ref: React.RefObject<HTMLDivElement>; className: string; style: React.CSSProperties; 'data-testid': string; }, HTMLDivElement>; declare namespace TrackingWidget { var displayName: string; } export { TrackingWidget }; export default ParcelPanelEDD;