@botonic/plugin-flow-builder 0.27.8-alpha.1 → 0.27.8-alpha.2

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.
@@ -10,5 +10,5 @@ export declare class FlowHandoff extends ContentFieldsBase {
10
10
  static fromHubtypeCMS(cmsHandoff: HtHandoffNode, locale: string, cmsApi: FlowBuilderApi): FlowHandoff;
11
11
  private static getOnFinishPayload;
12
12
  doHandoff(request: ActionRequest): Promise<void>;
13
- toBotonic(): JSX.Element;
13
+ toBotonic(id: string, request: ActionRequest): JSX.Element;
14
14
  }
@@ -39,8 +39,8 @@ class FlowHandoff extends content_fields_base_1.ContentFieldsBase {
39
39
  }
40
40
  });
41
41
  }
42
- toBotonic() {
43
- return (0, jsx_runtime_1.jsx)(react_1.WebchatSettings, { enableUserInput: true });
42
+ toBotonic(id, request) {
43
+ return (0, core_1.isDev)(request.session) || (0, core_1.isWebchat)(request.session) ? ((0, jsx_runtime_1.jsx)(react_1.WebchatSettings, { enableUserInput: true }, id)) : ((0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, {}));
44
44
  }
45
45
  }
46
46
  exports.FlowHandoff = FlowHandoff;
@@ -1 +1 @@
1
- {"version":3,"file":"flow-handoff.js","sourceRoot":"","sources":["../../../src/content-fields/flow-handoff.tsx"],"names":[],"mappings":";;;;;AAAA,wCAA8C;AAC9C,0CAA+D;AAI/D,+DAAyD;AAGzD,MAAa,WAAY,SAAQ,uCAAiB;IAMhD,MAAM,CAAC,cAAc,CACnB,UAAyB,EACzB,MAAc,EACd,MAAsB;QAEtB,MAAM,UAAU,GAAG,IAAI,WAAW,CAAC,UAAU,CAAC,EAAE,CAAC,CAAA;QACjD,UAAU,CAAC,IAAI,GAAG,UAAU,CAAC,IAAI,CAAA;QACjC,UAAU,CAAC,KAAK,GAAG,IAAI,CAAC,gBAAgB,CAAC,MAAM,EAAE,UAAU,CAAC,OAAO,CAAC,KAAK,CAAC,CAAA;QAC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,QAAQ,EAAE,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,UAAU,CAAC,QAAQ;oBAClD,OAAO,EAAE,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,UAAU,CAAC,OAAO;iBACjD,CAAC,CAAA;gBACF,MAAM,cAAc,CAAC,OAAO,EAAE,CAAA;aAC/B;QACH,CAAC;KAAA;IAED,SAAS,CAAC,EAAU,EAAE,OAAsB;QAC1C,OAAO,IAAA,YAAK,EAAC,OAAO,CAAC,OAAO,CAAC,IAAI,IAAA,gBAAS,EAAC,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAC5D,uBAAC,uBAAe,IAAU,eAAe,EAAE,IAAI,IAAzB,EAAE,CAA2B,CACpD,CAAC,CAAC,CAAC,CACF,kDAAK,CACN,CAAA;IACH,CAAC;CACF;AAxDD,kCAwDC"}
@@ -1,3 +1,3 @@
1
1
  /// <reference types="react" />
2
2
  import { WebviewContentsContextType } from './types';
3
- export declare const WebviewContentsContext: import("react").Context<WebviewContentsContextType<unknown>>;
3
+ export declare const WebviewContentsContext: <T>() => import("react").Context<WebviewContentsContextType<T>>;
@@ -2,10 +2,35 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.WebviewContentsContext = void 0;
4
4
  const react_1 = require("react");
5
- exports.WebviewContentsContext = (0, react_1.createContext)({
5
+ /*
6
+ Define a generic type parameter for your context
7
+ WebviewContentsContext is a function that returns a context object with the type parameter T
8
+ It is necessary to create the context outside the component
9
+ e.g.
10
+
11
+ interface WebviewContents {
12
+ textIntro: string
13
+ image2: string
14
+ headerWebview: string
15
+ image: string
16
+ }
17
+
18
+ export const MyWebviewContentsContext = WebviewContentsContext<WebviewContents>()
19
+
20
+ Then you can use it in your component like this:
21
+ <MyWebviewContentsContext.Provider value={webviewContentsContext}>
22
+ ...// your components
23
+ </MyWebviewContentsContext.Provider>
24
+
25
+ In your components you can use the context to read contents like this:
26
+
27
+ const { contents } = useContext(MyWebviewContentsContext)
28
+ */
29
+ const WebviewContentsContext = () => (0, react_1.createContext)({
6
30
  getTextContent: () => '',
7
31
  getImageSrc: () => '',
8
32
  setCurrentLocale: () => undefined,
9
33
  contents: {},
10
34
  });
35
+ exports.WebviewContentsContext = WebviewContentsContext;
11
36
  //# sourceMappingURL=contents-context.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"contents-context.js","sourceRoot":"","sources":["../../../src/webview/contents-context.ts"],"names":[],"mappings":";;;AAAA,iCAAqC;AAIxB,QAAA,sBAAsB,GAAG,IAAA,qBAAa,EAEjD;IACA,cAAc,EAAE,GAAG,EAAE,CAAC,EAAE;IACxB,WAAW,EAAE,GAAG,EAAE,CAAC,EAAE;IACrB,gBAAgB,EAAE,GAAG,EAAE,CAAC,SAAS;IACjC,QAAQ,EAAE,EAAE;CACb,CAAC,CAAA"}
1
+ {"version":3,"file":"contents-context.js","sourceRoot":"","sources":["../../../src/webview/contents-context.ts"],"names":[],"mappings":";;;AAAA,iCAAqC;AAIrC;;;;;;;;;;;;;;;;;;;;;;;EAuBE;AACK,MAAM,sBAAsB,GAAG,GAAM,EAAE,CAC5C,IAAA,qBAAa,EAAgC;IAC3C,cAAc,EAAE,GAAG,EAAE,CAAC,EAAE;IACxB,WAAW,EAAE,GAAG,EAAE,CAAC,EAAE;IACrB,gBAAgB,EAAE,GAAG,EAAE,CAAC,SAAS;IACjC,QAAQ,EAAE,EAA6B;CACxC,CAAC,CAAA;AANS,QAAA,sBAAsB,0BAM/B"}
@@ -10,5 +10,5 @@ export declare class FlowHandoff extends ContentFieldsBase {
10
10
  static fromHubtypeCMS(cmsHandoff: HtHandoffNode, locale: string, cmsApi: FlowBuilderApi): FlowHandoff;
11
11
  private static getOnFinishPayload;
12
12
  doHandoff(request: ActionRequest): Promise<void>;
13
- toBotonic(): JSX.Element;
13
+ toBotonic(id: string, request: ActionRequest): JSX.Element;
14
14
  }
@@ -1,6 +1,6 @@
1
1
  import { __awaiter } from "tslib";
2
- import { jsx as _jsx } from "react/jsx-runtime";
3
- import { HandOffBuilder } from '@botonic/core';
2
+ import { jsx as _jsx, Fragment as _Fragment } from "react/jsx-runtime";
3
+ import { HandOffBuilder, isDev, isWebchat } from '@botonic/core';
4
4
  import { WebchatSettings } from '@botonic/react';
5
5
  import { ContentFieldsBase } from './content-fields-base';
6
6
  export class FlowHandoff extends ContentFieldsBase {
@@ -36,8 +36,8 @@ export class FlowHandoff extends ContentFieldsBase {
36
36
  }
37
37
  });
38
38
  }
39
- toBotonic() {
40
- return _jsx(WebchatSettings, { enableUserInput: true });
39
+ toBotonic(id, request) {
40
+ return isDev(request.session) || isWebchat(request.session) ? (_jsx(WebchatSettings, { enableUserInput: true }, id)) : (_jsx(_Fragment, {}));
41
41
  }
42
42
  }
43
43
  //# sourceMappingURL=flow-handoff.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"flow-handoff.js","sourceRoot":"","sources":["../../../src/content-fields/flow-handoff.tsx"],"names":[],"mappings":";;AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,eAAe,CAAA;AAC9C,OAAO,EAAiB,eAAe,EAAE,MAAM,gBAAgB,CAAA;AAI/D,OAAO,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAA;AAGzD,MAAM,OAAO,WAAY,SAAQ,iBAAiB;IAMhD,MAAM,CAAC,cAAc,CACnB,UAAyB,EACzB,MAAc,EACd,MAAsB;QAEtB,MAAM,UAAU,GAAG,IAAI,WAAW,CAAC,UAAU,CAAC,EAAE,CAAC,CAAA;QACjD,UAAU,CAAC,IAAI,GAAG,UAAU,CAAC,IAAI,CAAA;QACjC,UAAU,CAAC,KAAK,GAAG,IAAI,CAAC,gBAAgB,CAAC,MAAM,EAAE,UAAU,CAAC,OAAO,CAAC,KAAK,CAAC,CAAA;QAC1E,UAAU,CAAC,eAAe,GAAG,IAAI,CAAC,kBAAkB,CAAC,UAAU,EAAE,MAAM,CAAC,CAAA;QACxE,UAAU,CAAC,iBAAiB,GAAG,UAAU,CAAC,OAAO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AO,CAAC,OAAO,CAAC,IAAI,CAAC,UAAU,CAAC,QAAQ;oBAClD,OAAO,EAAE,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,UAAU,CAAC,OAAO;iBACjD,CAAC,CAAA;gBACF,MAAM,cAAc,CAAC,OAAO,EAAE,CAAA;aAC/B;QACH,CAAC;KAAA;IAED,SAAS,CAAC,EAAU,EAAE,OAAsB;QAC1C,OAAO,KAAK,CAAC,OAAO,CAAC,OAAO,CAAC,IAAI,SAAS,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAC5D,KAAC,eAAe,IAAU,eAAe,EAAE,IAAI,IAAzB,EAAE,CAA2B,CACpD,CAAC,CAAC,CAAC,CACF,mBAAK,CACN,CAAA;IACH,CAAC;CACF"}
@@ -1,3 +1,3 @@
1
1
  /// <reference types="react" />
2
2
  import { WebviewContentsContextType } from './types';
3
- export declare const WebviewContentsContext: import("react").Context<WebviewContentsContextType<unknown>>;
3
+ export declare const WebviewContentsContext: <T>() => import("react").Context<WebviewContentsContextType<T>>;
@@ -1,5 +1,29 @@
1
1
  import { createContext } from 'react';
2
- export const WebviewContentsContext = createContext({
2
+ /*
3
+ Define a generic type parameter for your context
4
+ WebviewContentsContext is a function that returns a context object with the type parameter T
5
+ It is necessary to create the context outside the component
6
+ e.g.
7
+
8
+ interface WebviewContents {
9
+ textIntro: string
10
+ image2: string
11
+ headerWebview: string
12
+ image: string
13
+ }
14
+
15
+ export const MyWebviewContentsContext = WebviewContentsContext<WebviewContents>()
16
+
17
+ Then you can use it in your component like this:
18
+ <MyWebviewContentsContext.Provider value={webviewContentsContext}>
19
+ ...// your components
20
+ </MyWebviewContentsContext.Provider>
21
+
22
+ In your components you can use the context to read contents like this:
23
+
24
+ const { contents } = useContext(MyWebviewContentsContext)
25
+ */
26
+ export const WebviewContentsContext = () => createContext({
3
27
  getTextContent: () => '',
4
28
  getImageSrc: () => '',
5
29
  setCurrentLocale: () => undefined,
@@ -1 +1 @@
1
- {"version":3,"file":"contents-context.js","sourceRoot":"","sources":["../../../src/webview/contents-context.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,OAAO,CAAA;AAIrC,MAAM,CAAC,MAAM,sBAAsB,GAAG,aAAa,CAEjD;IACA,cAAc,EAAE,GAAG,EAAE,CAAC,EAAE;IACxB,WAAW,EAAE,GAAG,EAAE,CAAC,EAAE;IACrB,gBAAgB,EAAE,GAAG,EAAE,CAAC,SAAS;IACjC,QAAQ,EAAE,EAAE;CACb,CAAC,CAAA"}
1
+ {"version":3,"file":"contents-context.js","sourceRoot":"","sources":["../../../src/webview/contents-context.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,OAAO,CAAA;AAIrC;;;;;;;;;;;;;;;;;;;;;;;EAuBE;AACF,MAAM,CAAC,MAAM,sBAAsB,GAAG,GAAM,EAAE,CAC5C,aAAa,CAAgC;IAC3C,cAAc,EAAE,GAAG,EAAE,CAAC,EAAE;IACxB,WAAW,EAAE,GAAG,EAAE,CAAC,EAAE;IACrB,gBAAgB,EAAE,GAAG,EAAE,CAAC,SAAS;IACjC,QAAQ,EAAE,EAA6B;CACxC,CAAC,CAAA"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@botonic/plugin-flow-builder",
3
- "version": "0.27.8-alpha.1",
3
+ "version": "0.27.8-alpha.2",
4
4
  "main": "./lib/cjs/index.js",
5
5
  "module": "./lib/esm/index.js",
6
6
  "description": "Use Flow Builder to show your contents",
@@ -1,4 +1,4 @@
1
- import { HandOffBuilder } from '@botonic/core'
1
+ import { HandOffBuilder, isDev, isWebchat } from '@botonic/core'
2
2
  import { ActionRequest, WebchatSettings } from '@botonic/react'
3
3
  import React from 'react'
4
4
 
@@ -55,7 +55,11 @@ export class FlowHandoff extends ContentFieldsBase {
55
55
  }
56
56
  }
57
57
 
58
- toBotonic(): JSX.Element {
59
- return <WebchatSettings enableUserInput={true} />
58
+ toBotonic(id: string, request: ActionRequest): JSX.Element {
59
+ return isDev(request.session) || isWebchat(request.session) ? (
60
+ <WebchatSettings key={id} enableUserInput={true} />
61
+ ) : (
62
+ <></>
63
+ )
60
64
  }
61
65
  }
@@ -2,11 +2,34 @@ import { createContext } from 'react'
2
2
 
3
3
  import { WebviewContentsContextType } from './types'
4
4
 
5
- export const WebviewContentsContext = createContext<
6
- WebviewContentsContextType<unknown>
7
- >({
8
- getTextContent: () => '',
9
- getImageSrc: () => '',
10
- setCurrentLocale: () => undefined,
11
- contents: {},
12
- })
5
+ /*
6
+ Define a generic type parameter for your context
7
+ WebviewContentsContext is a function that returns a context object with the type parameter T
8
+ It is necessary to create the context outside the component
9
+ e.g.
10
+
11
+ interface WebviewContents {
12
+ textIntro: string
13
+ image2: string
14
+ headerWebview: string
15
+ image: string
16
+ }
17
+
18
+ export const MyWebviewContentsContext = WebviewContentsContext<WebviewContents>()
19
+
20
+ Then you can use it in your component like this:
21
+ <MyWebviewContentsContext.Provider value={webviewContentsContext}>
22
+ ...// your components
23
+ </MyWebviewContentsContext.Provider>
24
+
25
+ In your components you can use the context to read contents like this:
26
+
27
+ const { contents } = useContext(MyWebviewContentsContext)
28
+ */
29
+ export const WebviewContentsContext = <T>() =>
30
+ createContext<WebviewContentsContextType<T>>({
31
+ getTextContent: () => '',
32
+ getImageSrc: () => '',
33
+ setCurrentLocale: () => undefined,
34
+ contents: {} as Record<keyof T, string>,
35
+ })