@opencx/widget 3.0.69 → 3.0.72

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/dist/react.cjs CHANGED
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./useUploadFiles-DH1k_nBL.cjs");function a(t,s,u){const{widgetCtx:{api:i}}=e.useWidget();return e._default(async o=>i.vote({action:o==="up"?"upvote":"downvote",messagePublicId:t,sessionId:s}).then(u),[i,t,s,u])}exports.WidgetProvider=e.WidgetProvider;exports.useConfig=e.useConfig;exports.useContact=e.useContact;exports.useIsAwaitingBotReply=e.useIsAwaitingBotReply;exports.useMessages=e.useMessages;exports.usePreludeData=e.usePreludeData;exports.usePrimitiveState=e.usePrimitiveState;exports.useSessions=e.useSessions;exports.useUploadFiles=e.useUploadFiles;exports.useWidget=e.useWidget;exports.useWidgetRouter=e.useWidgetRouter;exports.useVote=a;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./useWidgetTrigger-LQGdFooa.cjs");function g(t,i,s){const{widgetCtx:{api:u}}=e.useWidget();return e._default(async r=>u.vote({action:r==="up"?"upvote":"downvote",messagePublicId:t,sessionId:i}).then(s),[u,t,i,s])}exports.WidgetProvider=e.WidgetProvider;exports.WidgetTriggerProvider=e.WidgetTriggerProvider;exports.useConfig=e.useConfig;exports.useContact=e.useContact;exports.useIsAwaitingBotReply=e.useIsAwaitingBotReply;exports.useMessages=e.useMessages;exports.usePreludeData=e.usePreludeData;exports.usePrimitiveState=e.usePrimitiveState;exports.useSessions=e.useSessions;exports.useUploadFiles=e.useUploadFiles;exports.useWidget=e.useWidget;exports.useWidgetRouter=e.useWidgetRouter;exports.useWidgetTrigger=e.useWidgetTrigger;exports.useVote=g;
2
2
  //# sourceMappingURL=react.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"react.cjs","sources":["../src/headless/react/hooks/useVote.ts"],"sourcesContent":["import useAsyncFn from 'react-use/lib/useAsyncFn';\nimport { useWidget } from '../WidgetProvider';\n\n/**\n * @param id\n * @param onSuccess\n * @returns\n */\nexport function useVote(id: string, sessionId: string, onSuccess?: () => void) {\n const {\n widgetCtx: { api },\n } = useWidget();\n return useAsyncFn(\n async (action: 'up' | 'down') => {\n return api\n .vote({\n action: action === 'up' ? 'upvote' : 'downvote',\n messagePublicId: id,\n sessionId,\n })\n .then(onSuccess);\n },\n [api, id, sessionId, onSuccess],\n );\n}\n\n/**\n * @param id\n * @param onSuccess\n * @deprecated use useVote instead\n */\nexport function useUpvote(\n id: string,\n sessionId: string,\n onSuccess?: () => void,\n) {\n const {\n widgetCtx: { api },\n } = useWidget();\n return useAsyncFn(\n async () =>\n api\n .vote({ action: 'upvote', messagePublicId: id, sessionId })\n .then(onSuccess),\n [api, id, sessionId, onSuccess],\n );\n}\n\n/**\n * @param id\n * @param onSuccess\n * @deprecated use useVote instead\n */\nexport function useDownvote(\n id: string,\n sessionId: string,\n onSuccess?: () => void,\n) {\n const {\n widgetCtx: { api },\n } = useWidget();\n return useAsyncFn(\n async () =>\n api\n .vote({ action: 'downvote', messagePublicId: id, sessionId })\n .then(onSuccess),\n [api, id, sessionId, onSuccess],\n );\n}\n"],"names":["useVote","id","sessionId","onSuccess","api","useWidget","useAsyncFn","action"],"mappings":"iIAQgB,SAAAA,EAAQC,EAAYC,EAAmBC,EAAwB,CACvE,KAAA,CACJ,UAAW,CAAE,IAAAC,CAAI,GACfC,EAAU,UAAA,EACP,OAAAC,EAAA,SACL,MAAOC,GACEH,EACJ,KAAK,CACJ,OAAQG,IAAW,KAAO,SAAW,WACrC,gBAAiBN,EACjB,UAAAC,CAAA,CACD,EACA,KAAKC,CAAS,EAEnB,CAACC,EAAKH,EAAIC,EAAWC,CAAS,CAAA,CAElC"}
1
+ {"version":3,"file":"react.cjs","sources":["../src/headless/react/hooks/useVote.ts"],"sourcesContent":["import useAsyncFn from 'react-use/lib/useAsyncFn';\nimport { useWidget } from '../WidgetProvider';\n\n/**\n * @param id\n * @param onSuccess\n * @returns\n */\nexport function useVote(id: string, sessionId: string, onSuccess?: () => void) {\n const {\n widgetCtx: { api },\n } = useWidget();\n return useAsyncFn(\n async (action: 'up' | 'down') => {\n return api\n .vote({\n action: action === 'up' ? 'upvote' : 'downvote',\n messagePublicId: id,\n sessionId,\n })\n .then(onSuccess);\n },\n [api, id, sessionId, onSuccess],\n );\n}\n\n/**\n * @param id\n * @param onSuccess\n * @deprecated use useVote instead\n */\nexport function useUpvote(\n id: string,\n sessionId: string,\n onSuccess?: () => void,\n) {\n const {\n widgetCtx: { api },\n } = useWidget();\n return useAsyncFn(\n async () =>\n api\n .vote({ action: 'upvote', messagePublicId: id, sessionId })\n .then(onSuccess),\n [api, id, sessionId, onSuccess],\n );\n}\n\n/**\n * @param id\n * @param onSuccess\n * @deprecated use useVote instead\n */\nexport function useDownvote(\n id: string,\n sessionId: string,\n onSuccess?: () => void,\n) {\n const {\n widgetCtx: { api },\n } = useWidget();\n return useAsyncFn(\n async () =>\n api\n .vote({ action: 'downvote', messagePublicId: id, sessionId })\n .then(onSuccess),\n [api, id, sessionId, onSuccess],\n );\n}\n"],"names":["useVote","id","sessionId","onSuccess","api","useWidget","useAsyncFn","action"],"mappings":"mIAQgB,SAAAA,EAAQC,EAAYC,EAAmBC,EAAwB,CACvE,KAAA,CACJ,UAAW,CAAE,IAAAC,CAAI,GACfC,EAAU,UAAA,EACP,OAAAC,EAAA,SACL,MAAOC,GACEH,EACJ,KAAK,CACJ,OAAQG,IAAW,KAAO,SAAW,WACrC,gBAAiBN,EACjB,UAAAC,CAAA,CACD,EACA,KAAKC,CAAS,EAEnB,CAACC,EAAKH,EAAIC,EAAWC,CAAS,CAAA,CAElC"}
package/dist/react.js CHANGED
@@ -1,12 +1,12 @@
1
- import { u as o, _ as i } from "./useUploadFiles-CoBUxfoW.js";
2
- import { W as p, a as f, b as l, c, d as m, e as v, f as P, g as W, i as w, h as x } from "./useUploadFiles-CoBUxfoW.js";
3
- function n(e, s, t) {
1
+ import { u, _ as r } from "./useWidgetTrigger-DdX73dQq.js";
2
+ import { W as p, k as f, a as l, b as v, c as W, d as c, e as m, f as P, g as w, i as x, h as C, j as b } from "./useWidgetTrigger-DdX73dQq.js";
3
+ function g(e, s, t) {
4
4
  const {
5
5
  widgetCtx: { api: a }
6
- } = o();
7
- return i(
8
- async (u) => a.vote({
9
- action: u === "up" ? "upvote" : "downvote",
6
+ } = u();
7
+ return r(
8
+ async (i) => a.vote({
9
+ action: i === "up" ? "upvote" : "downvote",
10
10
  messagePublicId: e,
11
11
  sessionId: s
12
12
  }).then(t),
@@ -15,16 +15,18 @@ function n(e, s, t) {
15
15
  }
16
16
  export {
17
17
  p as WidgetProvider,
18
- f as useConfig,
19
- l as useContact,
20
- c as useIsAwaitingBotReply,
21
- m as useMessages,
22
- v as usePreludeData,
18
+ f as WidgetTriggerProvider,
19
+ l as useConfig,
20
+ v as useContact,
21
+ W as useIsAwaitingBotReply,
22
+ c as useMessages,
23
+ m as usePreludeData,
23
24
  P as usePrimitiveState,
24
- W as useSessions,
25
- w as useUploadFiles,
26
- n as useVote,
27
- o as useWidget,
28
- x as useWidgetRouter
25
+ w as useSessions,
26
+ x as useUploadFiles,
27
+ g as useVote,
28
+ u as useWidget,
29
+ C as useWidgetRouter,
30
+ b as useWidgetTrigger
29
31
  };
30
32
  //# sourceMappingURL=react.js.map
@@ -0,0 +1,2 @@
1
+ import { default as React } from 'react';
2
+ export declare function WidgetPopoverAnchor(): React.JSX.Element;
@@ -0,0 +1,2 @@
1
+ import { default as React } from 'react';
2
+ export declare function WidgetPopoverContent(): React.JSX.Element;
@@ -1,5 +1,3 @@
1
1
  import { default as React } from 'react';
2
- declare function WidgetPopoverTrigger({ isOpen }: {
3
- isOpen: boolean;
4
- }): React.JSX.Element;
2
+ declare function WidgetPopoverTrigger(): React.JSX.Element;
5
3
  export { WidgetPopoverTrigger };
@@ -1,8 +1,8 @@
1
1
  import { VariantProps } from 'class-variance-authority';
2
2
  import * as React from 'react';
3
3
  declare const buttonVariants: (props?: ({
4
- variant?: "default" | "link" | "outline" | "destructive" | "secondary" | "ghost" | null | undefined;
5
- size?: "default" | "icon" | "sm" | "lg" | "fit" | "free" | null | undefined;
4
+ variant?: "default" | "link" | "destructive" | "outline" | "secondary" | "ghost" | null | undefined;
5
+ size?: "default" | "sm" | "lg" | "icon" | "fit" | "free" | "selfless" | null | undefined;
6
6
  } & import('class-variance-authority/types').ClassProp) | undefined) => string;
7
7
  export interface ButtonProps extends React.ButtonHTMLAttributes<HTMLButtonElement>, VariantProps<typeof buttonVariants> {
8
8
  asChild?: boolean;
@@ -0,0 +1,3 @@
1
+ export declare function useIsSmallScreen(): {
2
+ isSmallScreen: boolean;
3
+ };
@@ -6,17 +6,23 @@ export declare function useTheme(): {
6
6
  theme: {
7
7
  primaryColor: string;
8
8
  widgetTrigger: {
9
+ zIndex: number;
9
10
  offset: {
10
- bottom: string;
11
- right: string;
11
+ bottom: number;
12
+ right: number;
12
13
  };
13
14
  size: {
14
- button: string;
15
- icon: string;
15
+ button: number;
16
+ icon: number;
16
17
  };
17
18
  };
18
19
  widgetContentContainer: {
19
- offset: number;
20
+ borderRadius: string;
21
+ zIndex: number;
22
+ offset: {
23
+ side: number;
24
+ align: number;
25
+ };
20
26
  };
21
27
  screens: {
22
28
  welcome: {
@@ -1,6 +1,6 @@
1
1
  import { default as React } from 'react';
2
- import { WidgetComponentType } from '../../headless/react';
3
2
  import { WidgetConfig } from '../../headless/core';
3
+ import { WidgetComponentType } from '../../headless/react';
4
4
  declare function WidgetWrapper({ options, components, }: {
5
5
  options: WidgetConfig;
6
6
  components?: WidgetComponentType[];
@@ -38,18 +38,29 @@ export interface WidgetConfig {
38
38
  theme?: {
39
39
  primaryColor?: string;
40
40
  widgetTrigger?: {
41
+ zIndex?: number;
41
42
  offset?: {
42
- right?: string;
43
- bottom?: string;
43
+ /** number in pixels */
44
+ right?: number;
45
+ /** number in pixels */
46
+ bottom?: number;
44
47
  };
45
48
  size?: {
46
- button?: string;
47
- icon?: string;
49
+ /** number in pixels */
50
+ button?: number;
51
+ /** number in pixels */
52
+ icon?: number;
48
53
  };
49
54
  };
50
55
  widgetContentContainer?: {
51
- /** The distance between the widget content and the widget trigger */
52
- offset?: number;
56
+ borderRadius?: string;
57
+ zIndex?: number;
58
+ offset?: {
59
+ /** number in pixels */
60
+ side?: number;
61
+ /** number in pixels */
62
+ align?: number;
63
+ };
53
64
  };
54
65
  screens?: {
55
66
  welcome?: {
@@ -8,6 +8,7 @@ interface WidgetProviderValue {
8
8
  componentStore: ComponentRegistry;
9
9
  theme: WidgetConfig['theme'];
10
10
  version: string;
11
+ contentIframeRef?: React.MutableRefObject<HTMLIFrameElement | null>;
11
12
  }
12
13
  declare const useWidget: () => WidgetProviderValue;
13
14
  declare function WidgetProvider({ options: config, children, components, storage, }: {
@@ -0,0 +1,10 @@
1
+ import { default as React, Dispatch, ReactNode, SetStateAction } from 'react';
2
+ type WidgetTriggerCtx = {
3
+ isOpen: boolean;
4
+ setIsOpen: Dispatch<SetStateAction<boolean>>;
5
+ };
6
+ export declare const useWidgetTrigger: () => WidgetTriggerCtx, SafeProvider: React.Provider<WidgetTriggerCtx>;
7
+ export declare function WidgetTriggerProvider({ children }: {
8
+ children: ReactNode;
9
+ }): React.JSX.Element;
10
+ export {};
@@ -10,3 +10,4 @@ export { useSessions } from './hooks/useSessions';
10
10
  export { useWidgetRouter } from './hooks/useWidgetRouter';
11
11
  export { useVote } from './hooks/useVote';
12
12
  export { type FileWithProgress, useUploadFiles } from './hooks/useUploadFiles';
13
+ export { useWidgetTrigger, WidgetTriggerProvider, } from './hooks/useWidgetTrigger';