@returnflows/shop-overlay 1.0.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/README.md +976 -0
- package/dist/index.esm.css +3 -0
- package/dist/index.esm.js +12494 -0
- package/dist/index.esm.js.map +1 -0
- package/dist/messages/da.json +1 -0
- package/dist/messages/de.json +1 -0
- package/dist/messages/en.json +1 -0
- package/dist/messages/es.json +1 -0
- package/dist/messages/fi.json +1 -0
- package/dist/messages/fr.json +1 -0
- package/dist/messages/it.json +1 -0
- package/dist/messages/nb.json +1 -0
- package/dist/messages/nl.json +1 -0
- package/dist/messages/pl.json +1 -0
- package/dist/messages/sv.json +1 -0
- package/dist/types/api/index.d.ts +6 -0
- package/dist/types/api/state-bridge.d.ts +37 -0
- package/dist/types/api/storefront-cart.d.ts +3 -0
- package/dist/types/api/types.d.ts +402 -0
- package/dist/types/api/widget-api.d.ts +20 -0
- package/dist/types/index.d.ts +2 -0
- package/dist/types/widget/components/dialog/common/dialog-backdrop.d.ts +6 -0
- package/dist/types/widget/components/dialog/common/dialog-button.d.ts +6 -0
- package/dist/types/widget/components/dialog/common/dialog-modal.d.ts +9 -0
- package/dist/types/widget/components/dialog/common/dialog-subtitle.d.ts +2 -0
- package/dist/types/widget/components/dialog/common/dialog-title.d.ts +2 -0
- package/dist/types/widget/components/dialog/common/index.d.ts +10 -0
- package/dist/types/widget/components/dialog/return-decision-dialog.d.ts +2 -0
- package/dist/types/widget/components/drawer/adjustments/exchange-adjustments.d.ts +2 -0
- package/dist/types/widget/components/drawer/adjustments/exchange-banner.d.ts +2 -0
- package/dist/types/widget/components/drawer/adjustments/table/adjustments-table-skeleton.d.ts +2 -0
- package/dist/types/widget/components/drawer/adjustments/table/adjustments-table.d.ts +2 -0
- package/dist/types/widget/components/drawer/annoucement-bar.d.ts +2 -0
- package/dist/types/widget/components/drawer/error-screen.d.ts +6 -0
- package/dist/types/widget/components/drawer/exchange-confirmation.d.ts +2 -0
- package/dist/types/widget/components/drawer/exchange-drawer.d.ts +5 -0
- package/dist/types/widget/components/drawer/exchange-header.d.ts +2 -0
- package/dist/types/widget/components/drawer/exchange-placeholder.d.ts +2 -0
- package/dist/types/widget/components/drawer/product/product-actions.d.ts +8 -0
- package/dist/types/widget/components/drawer/product/product-attributes.d.ts +14 -0
- package/dist/types/widget/components/drawer/product/product-errors.d.ts +2 -0
- package/dist/types/widget/components/drawer/product/product-image.d.ts +7 -0
- package/dist/types/widget/components/drawer/product/product-list.d.ts +2 -0
- package/dist/types/widget/components/drawer/product/product.d.ts +9 -0
- package/dist/types/widget/components/drawer/product/quantity-picker.d.ts +20 -0
- package/dist/types/widget/components/drawer/return/return-product-actions.d.ts +10 -0
- package/dist/types/widget/components/drawer/return/return-product-badge.d.ts +7 -0
- package/dist/types/widget/components/drawer/return/return-product-list.d.ts +2 -0
- package/dist/types/widget/components/drawer/return/return-product-skeleton.d.ts +2 -0
- package/dist/types/widget/components/drawer/return/return-product.d.ts +14 -0
- package/dist/types/widget/components/drawer/scroll-indicator.d.ts +5 -0
- package/dist/types/widget/components/handlers/dialog-handler.d.ts +2 -0
- package/dist/types/widget/components/handlers/initialization-handler.d.ts +2 -0
- package/dist/types/widget/components/icons/arrow-down.d.ts +2 -0
- package/dist/types/widget/components/icons/arrow-left.d.ts +2 -0
- package/dist/types/widget/components/icons/arrow-right.d.ts +2 -0
- package/dist/types/widget/components/icons/bag.d.ts +2 -0
- package/dist/types/widget/components/icons/banner/action.d.ts +2 -0
- package/dist/types/widget/components/icons/banner/info.d.ts +2 -0
- package/dist/types/widget/components/icons/cart.d.ts +2 -0
- package/dist/types/widget/components/icons/chevron.d.ts +2 -0
- package/dist/types/widget/components/icons/giftcard.d.ts +2 -0
- package/dist/types/widget/components/icons/icon.d.ts +17 -0
- package/dist/types/widget/components/icons/spinner.d.ts +2 -0
- package/dist/types/widget/components/icons/star.d.ts +2 -0
- package/dist/types/widget/components/icons/warning.d.ts +2 -0
- package/dist/types/widget/components/icons/x.d.ts +2 -0
- package/dist/types/widget/components/is-mounted.d.ts +4 -0
- package/dist/types/widget/components/providers/error-provider.d.ts +4 -0
- package/dist/types/widget/components/providers/return-context-provider.d.ts +17 -0
- package/dist/types/widget/components/providers/root-provider.d.ts +2 -0
- package/dist/types/widget/components/providers/widget-context-provider.d.ts +6 -0
- package/dist/types/widget/components/return-avatar-stack.d.ts +2 -0
- package/dist/types/widget/components/summary/back-button.d.ts +2 -0
- package/dist/types/widget/components/summary/exchange-summary.d.ts +2 -0
- package/dist/types/widget/components/summary/exchange-total-skeleton.d.ts +2 -0
- package/dist/types/widget/components/summary/exchange-total.d.ts +2 -0
- package/dist/types/widget/components/toast/toast-container.d.ts +2 -0
- package/dist/types/widget/components/toast/toast-provider.d.ts +4 -0
- package/dist/types/widget/components/toast/toast.d.ts +16 -0
- package/dist/types/widget/components/ui/avatar/avatar-stack-skeleton.d.ts +2 -0
- package/dist/types/widget/components/ui/avatar/avatar-stack.d.ts +12 -0
- package/dist/types/widget/components/ui/avatar/avatar.d.ts +10 -0
- package/dist/types/widget/components/ui/banner/banner-skeleton.d.ts +2 -0
- package/dist/types/widget/components/ui/banner/banner.d.ts +13 -0
- package/dist/types/widget/components/ui/button.d.ts +11 -0
- package/dist/types/widget/components/ui/expander.d.ts +8 -0
- package/dist/types/widget/components/ui/image.d.ts +5 -0
- package/dist/types/widget/components/ui/link.d.ts +7 -0
- package/dist/types/widget/components/ui/price.d.ts +7 -0
- package/dist/types/widget/components/ui/skeleton/skeleton-container.d.ts +6 -0
- package/dist/types/widget/components/ui/skeleton/skeleton.d.ts +2 -0
- package/dist/types/widget/components/widget-container.d.ts +3 -0
- package/dist/types/widget/components/widget.d.ts +2 -0
- package/dist/types/widget/lib/constants.d.ts +13 -0
- package/dist/types/widget/lib/context/dialog-context.d.ts +3 -0
- package/dist/types/widget/lib/context/error-context.d.ts +10 -0
- package/dist/types/widget/lib/context/return-context.d.ts +12 -0
- package/dist/types/widget/lib/context/root-context.d.ts +2 -0
- package/dist/types/widget/lib/context/toast-context.d.ts +13 -0
- package/dist/types/widget/lib/context/widget-context.d.ts +9 -0
- package/dist/types/widget/lib/hooks/common/use-array.d.ts +14 -0
- package/dist/types/widget/lib/hooks/common/use-async-state.d.ts +40 -0
- package/dist/types/widget/lib/hooks/common/use-dialog.d.ts +11 -0
- package/dist/types/widget/lib/hooks/common/use-is-mounted.d.ts +2 -0
- package/dist/types/widget/lib/hooks/common/use-once.d.ts +3 -0
- package/dist/types/widget/lib/hooks/common/use-value-state.d.ts +7 -0
- package/dist/types/widget/lib/hooks/common/use-y-scrollable.d.ts +10 -0
- package/dist/types/widget/lib/hooks/context/use-calculation.d.ts +12 -0
- package/dist/types/widget/lib/hooks/context/use-cart-items.d.ts +9 -0
- package/dist/types/widget/lib/hooks/context/use-currency.d.ts +12 -0
- package/dist/types/widget/lib/hooks/context/use-errors.d.ts +2 -0
- package/dist/types/widget/lib/hooks/context/use-navigation.d.ts +6 -0
- package/dist/types/widget/lib/hooks/context/use-return-context.d.ts +2 -0
- package/dist/types/widget/lib/hooks/context/use-root.d.ts +2 -0
- package/dist/types/widget/lib/hooks/context/use-theme.d.ts +5 -0
- package/dist/types/widget/lib/hooks/context/use-toast.d.ts +2 -0
- package/dist/types/widget/lib/hooks/context/use-widget-context.d.ts +2 -0
- package/dist/types/widget/lib/hooks/feature/use-api-bridge.d.ts +6 -0
- package/dist/types/widget/lib/hooks/feature/use-cart-activator.d.ts +2 -0
- package/dist/types/widget/lib/hooks/feature/use-external-events.d.ts +2 -0
- package/dist/types/widget/lib/hooks/feature/use-fetch-interceptor.d.ts +4 -0
- package/dist/types/widget/lib/hooks/feature/use-override-scroll-blocking.d.ts +2 -0
- package/dist/types/widget/lib/types.d.ts +382 -0
- package/dist/types/widget/lib/utils/api.d.ts +26 -0
- package/dist/types/widget/lib/utils/cart-provider-store.d.ts +3 -0
- package/dist/types/widget/lib/utils/cart.d.ts +17 -0
- package/dist/types/widget/lib/utils/custom-events.d.ts +48 -0
- package/dist/types/widget/lib/utils/dom.d.ts +2 -0
- package/dist/types/widget/lib/utils/errors.d.ts +6 -0
- package/dist/types/widget/lib/utils/helpers.d.ts +24 -0
- package/dist/types/widget/lib/utils/i18n.d.ts +8 -0
- package/dist/types/widget/lib/utils/initialization/dataset.d.ts +5 -0
- package/dist/types/widget/lib/utils/initialization/font.d.ts +7 -0
- package/dist/types/widget/lib/utils/initialization/index.d.ts +6 -0
- package/dist/types/widget/lib/utils/initialization/styles.d.ts +4 -0
- package/dist/types/widget/lib/utils/initialization/types.d.ts +51 -0
- package/dist/types/widget/lib/utils/interceptor/fetch.d.ts +5 -0
- package/dist/types/widget/lib/utils/interceptor/index.d.ts +26 -0
- package/dist/types/widget/lib/utils/interceptor/xhr.d.ts +5 -0
- package/dist/types/widget/lib/utils/logger.d.ts +13 -0
- package/dist/types/widget/lib/utils/navigation.d.ts +7 -0
- package/dist/types/widget/lib/utils/session.d.ts +54 -0
- package/dist/types/widget/lib/utils/shopify.d.ts +6 -0
- package/dist/types/widget/lib/utils/storage.d.ts +33 -0
- package/dist/variables.css +1 -0
- package/dist/widget.css +3 -0
- package/dist/widget.js +12006 -0
- package/package.json +112 -0
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
interface ErrorScreenProps extends React.HTMLAttributes<HTMLDivElement> {
|
|
2
|
+
errorMessage?: string;
|
|
3
|
+
instructionMessage?: string;
|
|
4
|
+
}
|
|
5
|
+
declare const ErrorScreen: ({ className, errorMessage, instructionMessage, ...props }: ErrorScreenProps) => import("preact").JSX.Element;
|
|
6
|
+
export default ErrorScreen;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { ShopifyCartItem } from "../../../lib/types";
|
|
2
|
+
interface ProductActionsProps {
|
|
3
|
+
variantId: number;
|
|
4
|
+
quantity?: number;
|
|
5
|
+
quantityRule: ShopifyCartItem["quantity_rule"];
|
|
6
|
+
}
|
|
7
|
+
declare const _default: ({ variantId, quantity, quantityRule }: ProductActionsProps) => import("preact").JSX.Element | null;
|
|
8
|
+
export default _default;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export interface ProductAttributesAttributes {
|
|
2
|
+
title: string;
|
|
3
|
+
variantTitle: string | null | undefined;
|
|
4
|
+
pending?: boolean;
|
|
5
|
+
price: number | null | undefined;
|
|
6
|
+
compareAtPrice: number | null | undefined;
|
|
7
|
+
quantity: number;
|
|
8
|
+
handle?: string;
|
|
9
|
+
}
|
|
10
|
+
interface ProductAttributesProps extends Omit<React.HTMLAttributes<HTMLDivElement>, "children" | "title">, ProductAttributesAttributes {
|
|
11
|
+
showQuantity?: boolean;
|
|
12
|
+
}
|
|
13
|
+
declare const _default: ({ title, variantTitle, pending, price, compareAtPrice, className, quantity, handle, showQuantity, ...props }: ProductAttributesProps) => import("preact").JSX.Element;
|
|
14
|
+
export default _default;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { CalculationExchangeProduct, ShopifyCartItem } from "../../../lib/types";
|
|
2
|
+
export interface ExtendedShopifyProduct extends ShopifyCartItem {
|
|
3
|
+
calculation: Omit<CalculationExchangeProduct, "coverage"> | undefined;
|
|
4
|
+
}
|
|
5
|
+
interface ProductProps extends Omit<React.HTMLAttributes<HTMLLIElement>, "children" | "title" | "id" | "key"> {
|
|
6
|
+
product: ExtendedShopifyProduct;
|
|
7
|
+
}
|
|
8
|
+
declare const Product: ({ product: { calculation, ...product }, className, ...props }: ProductProps) => import("preact").JSX.Element;
|
|
9
|
+
export default Product;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
export interface QuantityPickerConstraints {
|
|
2
|
+
min: {
|
|
3
|
+
limit: number;
|
|
4
|
+
disabled: boolean;
|
|
5
|
+
};
|
|
6
|
+
max: {
|
|
7
|
+
limit: number;
|
|
8
|
+
disabled: boolean;
|
|
9
|
+
};
|
|
10
|
+
}
|
|
11
|
+
interface QuantityPickerProps extends React.HTMLAttributes<HTMLDivElement> {
|
|
12
|
+
onIncrement: (isAtBound: boolean) => void | Promise<void>;
|
|
13
|
+
onDecrement: (isAtBound: boolean) => void | Promise<void>;
|
|
14
|
+
quantity: number;
|
|
15
|
+
constraints?: QuantityPickerConstraints;
|
|
16
|
+
pending?: boolean;
|
|
17
|
+
disabled?: boolean;
|
|
18
|
+
}
|
|
19
|
+
declare const QuantityPicker: ({ onIncrement, onDecrement, constraints, quantity, pending, disabled, className, ...props }: QuantityPickerProps) => import("preact").JSX.Element;
|
|
20
|
+
export default QuantityPicker;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { ProductBadgeProps } from "./return-product-badge";
|
|
2
|
+
interface ReturnProductActionsProps extends ProductBadgeProps {
|
|
3
|
+
pending?: boolean;
|
|
4
|
+
deleted?: boolean;
|
|
5
|
+
onDeletedClick?: () => void;
|
|
6
|
+
href: string;
|
|
7
|
+
handleAnchorClick: () => void;
|
|
8
|
+
}
|
|
9
|
+
declare const ReturnProductActions: ({ pending, deleted, href, onDeletedClick, handleAnchorClick, ...rest }: ReturnProductActionsProps) => import("preact").JSX.Element;
|
|
10
|
+
export default ReturnProductActions;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export type BadgeType = "giftcard";
|
|
2
|
+
export interface ProductBadgeProps {
|
|
3
|
+
type: BadgeType | null;
|
|
4
|
+
}
|
|
5
|
+
type ReturnProductBadgeProps = React.HTMLAttributes<HTMLDivElement> & ProductBadgeProps;
|
|
6
|
+
declare const ReturnProductBadge: ({ className, type, ...props }: ReturnProductBadgeProps) => import("preact").JSX.Element | null;
|
|
7
|
+
export default ReturnProductBadge;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { CalculationLineItem, OrderProduct } from "../../../lib/types";
|
|
2
|
+
export interface ExtendedCalculationLineItem extends OrderProduct {
|
|
3
|
+
calculation: CalculationLineItem | undefined;
|
|
4
|
+
}
|
|
5
|
+
export interface IReturnProductAttributes {
|
|
6
|
+
handle: string;
|
|
7
|
+
imageSource: string;
|
|
8
|
+
}
|
|
9
|
+
interface ReturnProductProps extends Omit<React.HTMLAttributes<HTMLLIElement>, "children" | "title"> {
|
|
10
|
+
product: ExtendedCalculationLineItem;
|
|
11
|
+
allProducts: ExtendedCalculationLineItem[];
|
|
12
|
+
}
|
|
13
|
+
declare const ReturnProduct: ({ product: { calculation, ...product }, allProducts, className, ...props }: ReturnProductProps) => import("preact").JSX.Element;
|
|
14
|
+
export default ReturnProduct;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { VariantProps } from "class-variance-authority";
|
|
2
|
+
declare const iconVariants: (props?: ({
|
|
3
|
+
variant?: "primary" | "solid" | "solid-inverse" | null | undefined;
|
|
4
|
+
size?: "sm" | "md" | null | undefined;
|
|
5
|
+
} & import("class-variance-authority/types").ClassProp) | undefined) => string;
|
|
6
|
+
interface IconAttributesWithChildren {
|
|
7
|
+
icon?: never;
|
|
8
|
+
children: preact.ComponentChildren;
|
|
9
|
+
}
|
|
10
|
+
interface IconAttributesWithoutChildren {
|
|
11
|
+
icon: (props: React.SVGProps<SVGSVGElement>) => React.JSX.Element;
|
|
12
|
+
children?: never;
|
|
13
|
+
}
|
|
14
|
+
type IconAttributes = IconAttributesWithChildren | IconAttributesWithoutChildren;
|
|
15
|
+
type IconProps = Omit<React.HTMLAttributes<HTMLDivElement>, "children"> & VariantProps<typeof iconVariants> & IconAttributes;
|
|
16
|
+
declare const Icon: ({ icon: IconComponent, variant, size, className, children, ...props }: IconProps) => import("preact").JSX.Element;
|
|
17
|
+
export default Icon;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { ShopifyCart, ShopifyCartChangeResponse } from "../../lib/types";
|
|
2
|
+
import { ReturnDataState } from "../../lib/utils/session";
|
|
3
|
+
interface ReturnContextProviderProps {
|
|
4
|
+
children: preact.ComponentChildren;
|
|
5
|
+
}
|
|
6
|
+
export interface CalculationParams {
|
|
7
|
+
cart: ShopifyCart;
|
|
8
|
+
orderId: string;
|
|
9
|
+
lineItems: ReturnDataState["items"];
|
|
10
|
+
}
|
|
11
|
+
type Cart = ShopifyCart | ShopifyCartChangeResponse;
|
|
12
|
+
export interface CartState {
|
|
13
|
+
transformed: Cart;
|
|
14
|
+
original: Cart;
|
|
15
|
+
}
|
|
16
|
+
declare const ReturnContextProvider: ({ children }: ReturnContextProviderProps) => import("preact").JSX.Element;
|
|
17
|
+
export default ReturnContextProvider;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { WidgetConfiguration } from "../../lib/utils/initialization/types";
|
|
2
|
+
interface WidgetContextProviderProps extends WidgetConfiguration {
|
|
3
|
+
children: preact.ComponentChildren;
|
|
4
|
+
}
|
|
5
|
+
declare const WidgetContextProvider: ({ children, ...config }: WidgetContextProviderProps) => import("preact").JSX.Element;
|
|
6
|
+
export default WidgetContextProvider;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { BannerTone } from "../ui/banner/banner";
|
|
2
|
+
export interface ToastOptions {
|
|
3
|
+
id: string;
|
|
4
|
+
message: preact.ComponentChildren;
|
|
5
|
+
tone?: BannerTone;
|
|
6
|
+
duration?: number;
|
|
7
|
+
onClose?: () => void;
|
|
8
|
+
}
|
|
9
|
+
export interface ToastQueue extends ToastOptions {
|
|
10
|
+
isVisible: boolean;
|
|
11
|
+
}
|
|
12
|
+
export interface ToastProps extends React.HTMLAttributes<HTMLDivElement> {
|
|
13
|
+
options: ToastQueue;
|
|
14
|
+
}
|
|
15
|
+
declare const Toast: ({ options: { id, tone, message, isVisible }, className, style, ...props }: ToastProps) => import("preact").JSX.Element;
|
|
16
|
+
export default Toast;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { AvatarVariants } from "./avatar";
|
|
2
|
+
export interface AvatarImage {
|
|
3
|
+
src: string | undefined;
|
|
4
|
+
alt: string;
|
|
5
|
+
}
|
|
6
|
+
interface AvatarStackProps extends Omit<React.HTMLAttributes<HTMLDivElement>, "children">, AvatarVariants {
|
|
7
|
+
images: AvatarImage[];
|
|
8
|
+
maxVisibleAvatars?: number | null;
|
|
9
|
+
pending?: boolean;
|
|
10
|
+
}
|
|
11
|
+
declare const AvatarStack: ({ images, variant, maxVisibleAvatars, className, pending, ...props }: AvatarStackProps) => import("preact").JSX.Element;
|
|
12
|
+
export default AvatarStack;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { VariantProps } from "class-variance-authority";
|
|
2
|
+
declare const avatarVariants: (props?: ({
|
|
3
|
+
variant?: "light" | "dark" | null | undefined;
|
|
4
|
+
} & import("class-variance-authority/types").ClassProp) | undefined) => string;
|
|
5
|
+
export type AvatarVariants = VariantProps<typeof avatarVariants>;
|
|
6
|
+
interface AvatarProps extends React.HTMLAttributes<HTMLDivElement>, AvatarVariants {
|
|
7
|
+
children: preact.ComponentChildren;
|
|
8
|
+
}
|
|
9
|
+
declare const _default: ({ children, className, variant, ...props }: AvatarProps) => import("preact").JSX.Element;
|
|
10
|
+
export default _default;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { VariantProps } from "class-variance-authority";
|
|
2
|
+
declare const variants: (props?: ({
|
|
3
|
+
tone?: "giftcard" | "error" | "info" | "tip" | "action" | null | undefined;
|
|
4
|
+
border?: "dashed" | null | undefined;
|
|
5
|
+
} & import("class-variance-authority/types").ClassProp) | undefined) => string;
|
|
6
|
+
type Variants = VariantProps<typeof variants>;
|
|
7
|
+
export type BannerTone = NonNullable<Variants["tone"]>;
|
|
8
|
+
interface BannerProps extends React.HTMLAttributes<HTMLElement>, Variants {
|
|
9
|
+
icon?: BannerTone;
|
|
10
|
+
pending?: boolean;
|
|
11
|
+
}
|
|
12
|
+
declare const _default: ({ className, children, tone, border, icon, pending, ...props }: BannerProps) => import("preact").JSX.Element;
|
|
13
|
+
export default _default;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { type VariantProps } from "class-variance-authority";
|
|
2
|
+
declare const buttonVariants: (props?: ({
|
|
3
|
+
variant?: "outline" | "primary" | "ghost" | null | undefined;
|
|
4
|
+
} & import("class-variance-authority/types").ClassProp) | undefined) => string;
|
|
5
|
+
export interface ButtonProps extends React.ButtonHTMLAttributes<HTMLButtonElement>, VariantProps<typeof buttonVariants> {
|
|
6
|
+
icon?: (props: React.SVGProps<SVGSVGElement>) => React.JSX.Element;
|
|
7
|
+
iconPosition?: "left" | "right";
|
|
8
|
+
pending?: boolean;
|
|
9
|
+
}
|
|
10
|
+
declare const _default: ({ children, className, icon: Icon, variant, pending, disabled, iconPosition, ...props }: ButtonProps) => import("preact").JSX.Element;
|
|
11
|
+
export default _default;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
interface ExpanderProps extends Omit<React.HTMLAttributes<HTMLDivElement>, "onToggle"> {
|
|
2
|
+
isOpen: boolean;
|
|
3
|
+
collapseDelay?: number;
|
|
4
|
+
autoCloseAfter?: number;
|
|
5
|
+
onToggle?: (isOpen: boolean) => void;
|
|
6
|
+
}
|
|
7
|
+
declare const Expander: ({ isOpen, className, style, children, collapseDelay, autoCloseAfter, onToggle, ...props }: ExpanderProps) => import("preact").JSX.Element | null;
|
|
8
|
+
export default Expander;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
interface LinkProps extends React.AnchorHTMLAttributes<HTMLAnchorElement> {
|
|
2
|
+
disabled?: boolean;
|
|
3
|
+
unstyled?: boolean;
|
|
4
|
+
onDisabledClick?: (e: React.MouseEvent<HTMLAnchorElement>) => void;
|
|
5
|
+
}
|
|
6
|
+
declare const Link: ({ className, href, unstyled, onClick, onDisabledClick, disabled, ...props }: LinkProps) => import("preact").JSX.Element;
|
|
7
|
+
export default Link;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
interface PriceProps extends Omit<React.HTMLAttributes<HTMLSpanElement>, "children"> {
|
|
2
|
+
value?: number;
|
|
3
|
+
compareAtValue?: number;
|
|
4
|
+
pending?: boolean;
|
|
5
|
+
}
|
|
6
|
+
declare const _default: ({ value, compareAtValue, pending, className, ...props }: PriceProps) => import("preact").JSX.Element;
|
|
7
|
+
export default _default;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export declare function resolveEnvVar<T = undefined>(varKey: string, fallback?: T): string | T;
|
|
2
|
+
export declare const IMAGE_FALLBACK_URL = "https://cdn.shopify.com/s/files/1/0849/6526/1638/files/RF-SO-Placeholder2.png?v=1735826638";
|
|
3
|
+
export declare const API_URL: string;
|
|
4
|
+
export declare const PLATFORM_URL: string;
|
|
5
|
+
export declare const WIDGET_BASE_URL: string;
|
|
6
|
+
export declare const SEARCH_PARAM_ID_NAME = "rflowsId";
|
|
7
|
+
export declare const LEGACY_PARAMS: string[];
|
|
8
|
+
export declare const ROOT_ELEMENT_ID = "root";
|
|
9
|
+
export declare const SHADOW_ROOT_ELEMENT_ID = "shadow-root";
|
|
10
|
+
export declare const CONTAINER_ELEMENT_ID = "rf-overlay-widget";
|
|
11
|
+
export declare const CUSTOM_CSS_DATA_ATTR = "rf-custom-css";
|
|
12
|
+
export declare const SCRIPT_ID = "rf-embedded-script";
|
|
13
|
+
export declare const SETTINGS_SCRIPT_ID = "rf-settings-json";
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { UseArrayReturn } from "../hooks/common/use-array";
|
|
2
|
+
export type CustomError = {
|
|
3
|
+
id: string;
|
|
4
|
+
message: preact.ComponentChildren;
|
|
5
|
+
blocking?: boolean;
|
|
6
|
+
};
|
|
7
|
+
export interface IErrorContext extends Omit<UseArrayReturn<CustomError>, "array"> {
|
|
8
|
+
errors: UseArrayReturn<CustomError>["array"];
|
|
9
|
+
}
|
|
10
|
+
export declare const ErrorContext: import("preact").Context<IErrorContext>;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { CalculationParams, CartState } from "../../components/providers/return-context-provider";
|
|
2
|
+
import { IUseAsyncStateReturn } from "../hooks/common/use-async-state";
|
|
3
|
+
import { CalculationResponse } from "../types";
|
|
4
|
+
import { ProcessOrderInitializationReturn } from "../utils/api";
|
|
5
|
+
export interface IReturnContext {
|
|
6
|
+
orderState: IUseAsyncStateReturn<ProcessOrderInitializationReturn>;
|
|
7
|
+
cartState: IUseAsyncStateReturn<CartState, ProcessOrderInitializationReturn>;
|
|
8
|
+
calculationState: IUseAsyncStateReturn<CalculationResponse, CalculationParams>;
|
|
9
|
+
isPending: boolean;
|
|
10
|
+
hasFailed: boolean;
|
|
11
|
+
}
|
|
12
|
+
export declare const ReturnContext: import("preact").Context<IReturnContext>;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { ToastOptions, ToastQueue } from "../../components/toast/toast";
|
|
2
|
+
export interface ToastConfiguration extends Omit<ToastOptions, "id"> {
|
|
3
|
+
id?: string;
|
|
4
|
+
}
|
|
5
|
+
export declare const DEFAULT_TOAST_DURATION = 5000;
|
|
6
|
+
export declare const TOAST_ANIMATION_DURATION = 300;
|
|
7
|
+
export interface IToastContext {
|
|
8
|
+
queue: ToastQueue[];
|
|
9
|
+
add: (options: ToastConfiguration) => string;
|
|
10
|
+
remove: (id: string) => void;
|
|
11
|
+
clear: () => void;
|
|
12
|
+
}
|
|
13
|
+
export declare const ToastContext: import("preact").Context<IToastContext>;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { ValueState } from "../hooks/common/use-value-state";
|
|
2
|
+
import { ReturnViewState, WidgetViewState } from "../types";
|
|
3
|
+
import { WidgetConfiguration } from "../utils/initialization/types";
|
|
4
|
+
export interface IWidgetContext {
|
|
5
|
+
widgetViewState: ValueState<WidgetViewState>;
|
|
6
|
+
returnViewState: ValueState<ReturnViewState>;
|
|
7
|
+
config: WidgetConfiguration;
|
|
8
|
+
}
|
|
9
|
+
export declare const WidgetContext: import("preact").Context<IWidgetContext>;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
type ArrayId = string | number;
|
|
2
|
+
interface ArrayItem {
|
|
3
|
+
id: ArrayId;
|
|
4
|
+
}
|
|
5
|
+
export interface UseArrayReturn<T extends ArrayItem> {
|
|
6
|
+
array: T[];
|
|
7
|
+
set: (newArray: T[]) => void;
|
|
8
|
+
push: (item: T) => void;
|
|
9
|
+
remove: (id: ArrayId) => void;
|
|
10
|
+
clear: () => void;
|
|
11
|
+
has: (id: ArrayId) => boolean;
|
|
12
|
+
}
|
|
13
|
+
declare const useArray: <T extends ArrayItem>(initialArray?: T[]) => UseArrayReturn<T>;
|
|
14
|
+
export default useArray;
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
type IAsyncStatePending<T> = {
|
|
2
|
+
data: T | null;
|
|
3
|
+
pending: true;
|
|
4
|
+
error: null;
|
|
5
|
+
};
|
|
6
|
+
type IAsyncStateResolved<T> = {
|
|
7
|
+
data: T | null;
|
|
8
|
+
pending: false;
|
|
9
|
+
error: null;
|
|
10
|
+
};
|
|
11
|
+
type IAsyncStateError = {
|
|
12
|
+
data: null;
|
|
13
|
+
pending: false;
|
|
14
|
+
error: Error;
|
|
15
|
+
};
|
|
16
|
+
export type IAsyncState<T> = IAsyncStatePending<T> | IAsyncStateResolved<T> | IAsyncStateError;
|
|
17
|
+
type TAsyncStateCommonProps<T> = {
|
|
18
|
+
id?: string;
|
|
19
|
+
initialValue?: T | null;
|
|
20
|
+
queryOnInit?: boolean;
|
|
21
|
+
startCount?: number;
|
|
22
|
+
onError?: (error: Error) => void;
|
|
23
|
+
};
|
|
24
|
+
type TUseAsyncStatePropsWithoutParams<T> = TAsyncStateCommonProps<T> & {
|
|
25
|
+
queryFn: (count: number) => T | Promise<T>;
|
|
26
|
+
};
|
|
27
|
+
type TUseAsyncStatePropsWithParams<T, P = undefined> = TAsyncStateCommonProps<T> & {
|
|
28
|
+
queryFn: (count: number, params: P) => T | Promise<T>;
|
|
29
|
+
initialParams?: P;
|
|
30
|
+
};
|
|
31
|
+
type TUseAsyncStateProps<T, P = undefined> = P extends undefined ? TUseAsyncStatePropsWithoutParams<T> : TUseAsyncStatePropsWithParams<T, P>;
|
|
32
|
+
export interface IUseAsyncStateReturn<T, P = undefined> {
|
|
33
|
+
value: IAsyncState<T>;
|
|
34
|
+
set: React.Dispatch<React.SetStateAction<IAsyncState<T>>>;
|
|
35
|
+
query: P extends undefined ? () => Promise<T> : (params: P) => Promise<T>;
|
|
36
|
+
initialFetch: boolean;
|
|
37
|
+
count: number;
|
|
38
|
+
}
|
|
39
|
+
declare const useAsyncState: <T, Params = undefined>(props: TUseAsyncStateProps<T, Params>) => IUseAsyncStateReturn<T, Params>;
|
|
40
|
+
export default useAsyncState;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { ValueState } from "./use-value-state";
|
|
2
|
+
export interface UseDialogRegisterReturn {
|
|
3
|
+
isOpen: boolean;
|
|
4
|
+
onClose: () => void;
|
|
5
|
+
}
|
|
6
|
+
export interface UseDialogReturn {
|
|
7
|
+
register: () => UseDialogRegisterReturn;
|
|
8
|
+
state: ValueState<boolean>;
|
|
9
|
+
}
|
|
10
|
+
declare const useDialog: (initialState?: boolean) => UseDialogReturn;
|
|
11
|
+
export default useDialog;
|