@botonic/webviews 2.23.1

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.
@@ -0,0 +1,3 @@
1
+ export { WebviewBody, type WebviewBodyProps } from './webview-body';
2
+ export { WebviewFrame, type WebviewFrameProps } from './webview-frame';
3
+ export { WebviewHeader, type WebviewHeaderProps } from './webview-header';
@@ -0,0 +1,2 @@
1
+ export type { WebviewBodyProps } from './webview-body';
2
+ export { WebviewBody } from './webview-body';
@@ -0,0 +1,7 @@
1
+ import { ReactNode } from 'react';
2
+ export interface WebviewBodyProps {
3
+ children: ReactNode;
4
+ className?: string;
5
+ variant?: 'default' | 'padded' | 'scrollable';
6
+ }
7
+ export declare function WebviewBody({ children, className, variant, }: WebviewBodyProps): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,2 @@
1
+ export type { WebviewFrameProps } from './webview-frame';
2
+ export { WebviewFrame } from './webview-frame';
@@ -0,0 +1,6 @@
1
+ import { ReactNode } from 'react';
2
+ export interface WebviewFrameProps {
3
+ children: ReactNode;
4
+ className?: string;
5
+ }
6
+ export declare function WebviewFrame({ children, className }: WebviewFrameProps): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,2 @@
1
+ export type { WebviewHeaderProps } from './webview-header';
2
+ export { WebviewHeader } from './webview-header';
@@ -0,0 +1,8 @@
1
+ import { ConfirmCloseOption } from '../../../../../../webchat-core/src/index.ts';
2
+ export interface WebviewHeaderProps {
3
+ title?: string;
4
+ icon?: string;
5
+ allowClose?: boolean;
6
+ confirmClose?: ConfirmCloseOption;
7
+ }
8
+ export declare function WebviewHeader({ title, icon, allowClose, confirmClose, }: WebviewHeaderProps): null;
@@ -0,0 +1 @@
1
+ export { WebviewBody, type WebviewBodyProps, WebviewFrame, type WebviewFrameProps, WebviewHeader, type WebviewHeaderProps, } from './content';
@@ -0,0 +1,3 @@
1
+ export declare const useBotSession: () => {
2
+ botSession: any;
3
+ };
@@ -0,0 +1,6 @@
1
+ export interface CloseWebviewOptions {
2
+ payload?: any;
3
+ path?: string;
4
+ params?: Record<string, string>;
5
+ }
6
+ export declare function useWebviewClose(session: any): (options?: CloseWebviewOptions) => Promise<void>;
@@ -0,0 +1,8 @@
1
+ import { MapContentsType, UseWebviewContents } from './types';
2
+ export interface UseWebviewContentsProps<T extends MapContentsType> {
3
+ botSession: Record<string, any>;
4
+ params: Record<string, string>;
5
+ version?: 'draft' | 'latest' | string;
6
+ mapContents: Record<keyof T, string>;
7
+ }
8
+ export declare function useWebviewContents<T extends MapContentsType>({ botSession, params, version, mapContents, }: UseWebviewContentsProps<T>): UseWebviewContents<T>;
@@ -0,0 +1,2 @@
1
+ export * from './hook';
2
+ export * from './types';
@@ -0,0 +1,37 @@
1
+ export declare enum WebviewContentType {
2
+ TEXT = "webview-text",
3
+ IMAGE = "webview-image"
4
+ }
5
+ export type WebviewContentsResponse = (WebviewTextContent | WebviewImageContent)[];
6
+ export interface WebviewTextContent {
7
+ code: string;
8
+ type: WebviewContentType.TEXT;
9
+ content: {
10
+ text: {
11
+ message: string;
12
+ locale: string;
13
+ }[];
14
+ };
15
+ }
16
+ export interface WebviewImageContent {
17
+ code: string;
18
+ type: WebviewContentType.IMAGE;
19
+ content: {
20
+ image: {
21
+ file: string;
22
+ locale: string;
23
+ }[];
24
+ };
25
+ }
26
+ export type MapContentsType = Record<string, string>;
27
+ export interface UseWebviewContents<T extends MapContentsType> {
28
+ isLoading: boolean;
29
+ error: boolean;
30
+ webviewContentsContext: WebviewContentsContextType<T>;
31
+ }
32
+ export interface WebviewContentsContextType<T extends MapContentsType> {
33
+ getTextContent: (code: string) => string;
34
+ getImageSrc: (code: string) => string;
35
+ setCurrentLocale: (locale: string) => void;
36
+ contents: Record<keyof T, string>;
37
+ }
package/lib/index.d.ts ADDED
@@ -0,0 +1,7 @@
1
+ export * from './components';
2
+ export * from './hooks/use-bot-session';
3
+ export * from './hooks/use-webview-close';
4
+ export * from './hooks/use-webview-contents';
5
+ export * from './webview-context';
6
+ export * from './webview-provider';
7
+ export * from './webviews';
@@ -0,0 +1,18 @@
1
+ import { ConfirmCloseOption } from '../../../webchat-core/src/index.ts';
2
+ import { CloseWebviewOptions } from './hooks/use-webview-close';
3
+ import { WebviewDefinition } from './webviews';
4
+ export interface WebviewContextType {
5
+ botSession: Record<string, any>;
6
+ params: Record<string, string>;
7
+ closeWebview: (options?: CloseWebviewOptions) => Promise<void>;
8
+ setWebviewTitle: (title: string) => void;
9
+ setWebviewIcon: (icon: string) => void;
10
+ setWebviewAllowClose: (allow: boolean) => void;
11
+ setWebviewConfirmClose: (config: ConfirmCloseOption) => void;
12
+ sendWebviewPayload: (payload: any) => Promise<void>;
13
+ navigateTo: (path: string, params?: Record<string, string>) => void;
14
+ webviewName: string;
15
+ webviewConfig: WebviewDefinition | null;
16
+ }
17
+ export declare const WebviewContext: import('react').Context<WebviewContextType | undefined>;
18
+ export declare function useWebviewRequest(): WebviewContextType;
@@ -0,0 +1,8 @@
1
+ import { FC, ReactNode } from 'react';
2
+ import { WebviewDefinition } from './webviews';
3
+ interface WebviewProviderProps {
4
+ children: ReactNode;
5
+ webviews?: WebviewDefinition[];
6
+ }
7
+ export declare const WebviewProvider: FC<WebviewProviderProps>;
8
+ export {};
@@ -0,0 +1,27 @@
1
+ import { ConfirmCloseOption } from '../../../webchat-core/src/index.ts';
2
+ import { ComponentType, FC, ReactNode } from 'react';
3
+ export interface WebviewDefinition {
4
+ /** The path for this webview (e.g., 'demo' or 'form') */
5
+ path: string;
6
+ /** The React component to render for this webview */
7
+ component: ComponentType;
8
+ /** Optional title shown in the overlay header */
9
+ title?: string;
10
+ /** Optional icon shown in the overlay header */
11
+ icon?: string;
12
+ /** Whether the close button is shown (default: true) */
13
+ allowClose?: boolean;
14
+ /** Configuration for close confirmation dialog */
15
+ confirmClose?: ConfirmCloseOption;
16
+ /** Callback when the webview opens */
17
+ onOpen?: () => void;
18
+ /** Callback when the webview closes */
19
+ onClose?: () => void;
20
+ }
21
+ export interface WebviewAppProps {
22
+ /** Array of webview definitions */
23
+ webviews: WebviewDefinition[];
24
+ /** Custom loading component shown while webviews load */
25
+ loadingComponent?: ReactNode;
26
+ }
27
+ export declare const WebviewApp: FC<WebviewAppProps>;
package/package.json ADDED
@@ -0,0 +1,28 @@
1
+ {
2
+ "name": "@botonic/webviews",
3
+ "version": "2.23.1",
4
+ "type": "module",
5
+ "types": "./index.d.ts",
6
+ "module": "./index.js",
7
+ "main": "./index.js",
8
+ "exports": {
9
+ ".": {
10
+ "types": "./index.d.ts",
11
+ "import": "./index.js"
12
+ }
13
+ },
14
+ "dependencies": {
15
+ "@botonic/core": "2.23.1",
16
+ "@botonic/webchat-core": "2.23.1",
17
+ "@lilara/foundations": ">=0.3.1",
18
+ "class-variance-authority": "^0.7.0",
19
+ "react": "18.3.1"
20
+ },
21
+ "peerDependencies": {
22
+ "react": ">=18.0.0",
23
+ "react-dom": ">=18.0.0"
24
+ },
25
+ "publishConfig": {
26
+ "access": "public"
27
+ }
28
+ }