@botonic/plugin-flow-builder 0.27.8-alpha.2 → 0.27.8-alpha.3
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/lib/cjs/webview/contents-context.d.ts +2 -2
- package/lib/cjs/webview/contents-context.js +3 -3
- package/lib/cjs/webview/contents-context.js.map +1 -1
- package/lib/cjs/webview/index.d.ts +1 -1
- package/lib/cjs/webview/index.js +2 -2
- package/lib/cjs/webview/index.js.map +1 -1
- package/lib/cjs/webview/types.d.ts +4 -3
- package/lib/cjs/webview/use-webview-contents.d.ts +2 -2
- package/lib/cjs/webview/use-webview-contents.js.map +1 -1
- package/lib/esm/webview/contents-context.d.ts +2 -2
- package/lib/esm/webview/contents-context.js +1 -1
- package/lib/esm/webview/contents-context.js.map +1 -1
- package/lib/esm/webview/index.d.ts +1 -1
- package/lib/esm/webview/index.js +1 -1
- package/lib/esm/webview/index.js.map +1 -1
- package/lib/esm/webview/types.d.ts +4 -3
- package/lib/esm/webview/use-webview-contents.d.ts +2 -2
- package/lib/esm/webview/use-webview-contents.js.map +1 -1
- package/package.json +1 -1
- package/src/webview/contents-context.ts +2 -2
- package/src/webview/index.ts +1 -1
- package/src/webview/types.ts +5 -3
- package/src/webview/use-webview-contents.ts +4 -3
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
import { WebviewContentsContextType } from './types';
|
|
3
|
-
export declare const
|
|
2
|
+
import { MapContentsType, WebviewContentsContextType } from './types';
|
|
3
|
+
export declare const createWebviewContentsContext: <T extends MapContentsType>() => import("react").Context<WebviewContentsContextType<T>>;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.createWebviewContentsContext = void 0;
|
|
4
4
|
const react_1 = require("react");
|
|
5
5
|
/*
|
|
6
6
|
Define a generic type parameter for your context
|
|
@@ -26,11 +26,11 @@ const react_1 = require("react");
|
|
|
26
26
|
|
|
27
27
|
const { contents } = useContext(MyWebviewContentsContext)
|
|
28
28
|
*/
|
|
29
|
-
const
|
|
29
|
+
const createWebviewContentsContext = () => (0, react_1.createContext)({
|
|
30
30
|
getTextContent: () => '',
|
|
31
31
|
getImageSrc: () => '',
|
|
32
32
|
setCurrentLocale: () => undefined,
|
|
33
33
|
contents: {},
|
|
34
34
|
});
|
|
35
|
-
exports.
|
|
35
|
+
exports.createWebviewContentsContext = createWebviewContentsContext;
|
|
36
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;AAIrC;;;;;;;;;;;;;;;;;;;;;;;EAuBE;AACK,MAAM,
|
|
1
|
+
{"version":3,"file":"contents-context.js","sourceRoot":"","sources":["../../../src/webview/contents-context.ts"],"names":[],"mappings":";;;AAAA,iCAAqC;AAIrC;;;;;;;;;;;;;;;;;;;;;;;EAuBE;AACK,MAAM,4BAA4B,GAAG,GAA8B,EAAE,CAC1E,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,4BAA4B,gCAMrC"}
|
package/lib/cjs/webview/index.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.useWebviewContents = exports.
|
|
3
|
+
exports.useWebviewContents = exports.createWebviewContentsContext = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
5
|
var contents_context_1 = require("./contents-context");
|
|
6
|
-
Object.defineProperty(exports, "
|
|
6
|
+
Object.defineProperty(exports, "createWebviewContentsContext", { enumerable: true, get: function () { return contents_context_1.createWebviewContentsContext; } });
|
|
7
7
|
tslib_1.__exportStar(require("./types"), exports);
|
|
8
8
|
var use_webview_contents_1 = require("./use-webview-contents");
|
|
9
9
|
Object.defineProperty(exports, "useWebviewContents", { enumerable: true, get: function () { return use_webview_contents_1.useWebviewContents; } });
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/webview/index.ts"],"names":[],"mappings":";;;;AAAA,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/webview/index.ts"],"names":[],"mappings":";;;;AAAA,uDAAiE;AAAxD,gIAAA,4BAA4B,OAAA;AACrC,kDAAuB;AACvB,+DAA2D;AAAlD,0HAAA,kBAAkB,OAAA"}
|
|
@@ -26,7 +26,8 @@ export interface WebviewImageContent {
|
|
|
26
26
|
}[];
|
|
27
27
|
};
|
|
28
28
|
}
|
|
29
|
-
export
|
|
29
|
+
export type MapContentsType = Record<string, string>;
|
|
30
|
+
export interface UseWebviewContentsProps<T extends MapContentsType> {
|
|
30
31
|
apiUrl?: string;
|
|
31
32
|
version?: FlowBuilderJSONVersion;
|
|
32
33
|
orgId: string;
|
|
@@ -35,12 +36,12 @@ export interface UseWebviewContentsProps<T> {
|
|
|
35
36
|
locale: string;
|
|
36
37
|
mapContents: Record<keyof T, string>;
|
|
37
38
|
}
|
|
38
|
-
export interface UseWebviewContents<T> {
|
|
39
|
+
export interface UseWebviewContents<T extends MapContentsType> {
|
|
39
40
|
isLoading: boolean;
|
|
40
41
|
error: boolean;
|
|
41
42
|
webviewContentsContext: WebviewContentsContextType<T>;
|
|
42
43
|
}
|
|
43
|
-
export interface WebviewContentsContextType<T> {
|
|
44
|
+
export interface WebviewContentsContextType<T extends MapContentsType> {
|
|
44
45
|
getTextContent: (code: string) => string;
|
|
45
46
|
getImageSrc: (code: string) => string;
|
|
46
47
|
setCurrentLocale: (locale: string) => void;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { UseWebviewContents, UseWebviewContentsProps } from './types';
|
|
2
|
-
export declare function useWebviewContents<T>({ apiUrl, version, orgId, botId, webviewId, locale, mapContents, }: UseWebviewContentsProps<T>): UseWebviewContents<T>;
|
|
1
|
+
import { MapContentsType, UseWebviewContents, UseWebviewContentsProps } from './types';
|
|
2
|
+
export declare function useWebviewContents<T extends MapContentsType>({ apiUrl, version, orgId, botId, webviewId, locale, mapContents, }: UseWebviewContentsProps<T>): UseWebviewContents<T>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-webview-contents.js","sourceRoot":"","sources":["../../../src/webview/use-webview-contents.ts"],"names":[],"mappings":";;;;AAAA,0DAAyB;AACzB,iCAA2C;AAE3C,4CAAwD;AACxD,oCAAiD;AACjD,
|
|
1
|
+
{"version":3,"file":"use-webview-contents.js","sourceRoot":"","sources":["../../../src/webview/use-webview-contents.ts"],"names":[],"mappings":";;;;AAAA,0DAAyB;AACzB,iCAA2C;AAE3C,4CAAwD;AACxD,oCAAiD;AACjD,mCAQgB;AAEhB,SAAgB,kBAAkB,CAA4B,EAC5D,MAAM,GAAG,qCAAyB,EAClC,OAAO,GAAG,8BAAsB,CAAC,MAAM,EACvC,KAAK,EACL,KAAK,EACL,SAAS,EACT,MAAM,EACN,WAAW,GACgB;IAC3B,MAAM,CAAC,YAAY,EAAE,eAAe,CAAC,GAAG,IAAA,gBAAQ,GAAwB,CAAA;IACxE,MAAM,CAAC,aAAa,EAAE,gBAAgB,CAAC,GAAG,IAAA,gBAAQ,GAAyB,CAAA;IAC3E,MAAM,CAAC,QAAQ,EAAE,WAAW,CAAC,GAAG,IAAA,gBAAQ,EACtC,EAA6B,CAC9B,CAAA;IACD,MAAM,CAAC,aAAa,EAAE,gBAAgB,CAAC,GAAG,IAAA,gBAAQ,EAAC,MAAM,CAAC,CAAA;IAC1D,MAAM,CAAC,SAAS,EA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1
|
/// <reference types="react" />
|
|
2
|
-
import { WebviewContentsContextType } from './types';
|
|
3
|
-
export declare const
|
|
2
|
+
import { MapContentsType, WebviewContentsContextType } from './types';
|
|
3
|
+
export declare const createWebviewContentsContext: <T extends MapContentsType>() => import("react").Context<WebviewContentsContextType<T>>;
|
|
@@ -23,7 +23,7 @@ import { createContext } from 'react';
|
|
|
23
23
|
|
|
24
24
|
const { contents } = useContext(MyWebviewContentsContext)
|
|
25
25
|
*/
|
|
26
|
-
export const
|
|
26
|
+
export const createWebviewContentsContext = () => createContext({
|
|
27
27
|
getTextContent: () => '',
|
|
28
28
|
getImageSrc: () => '',
|
|
29
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;;;;;;;;;;;;;;;;;;;;;;;EAuBE;AACF,MAAM,CAAC,MAAM,
|
|
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,4BAA4B,GAAG,GAA8B,EAAE,CAC1E,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/lib/esm/webview/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/webview/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/webview/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,4BAA4B,EAAE,MAAM,oBAAoB,CAAA;AACjE,cAAc,SAAS,CAAA;AACvB,OAAO,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAA"}
|
|
@@ -26,7 +26,8 @@ export interface WebviewImageContent {
|
|
|
26
26
|
}[];
|
|
27
27
|
};
|
|
28
28
|
}
|
|
29
|
-
export
|
|
29
|
+
export type MapContentsType = Record<string, string>;
|
|
30
|
+
export interface UseWebviewContentsProps<T extends MapContentsType> {
|
|
30
31
|
apiUrl?: string;
|
|
31
32
|
version?: FlowBuilderJSONVersion;
|
|
32
33
|
orgId: string;
|
|
@@ -35,12 +36,12 @@ export interface UseWebviewContentsProps<T> {
|
|
|
35
36
|
locale: string;
|
|
36
37
|
mapContents: Record<keyof T, string>;
|
|
37
38
|
}
|
|
38
|
-
export interface UseWebviewContents<T> {
|
|
39
|
+
export interface UseWebviewContents<T extends MapContentsType> {
|
|
39
40
|
isLoading: boolean;
|
|
40
41
|
error: boolean;
|
|
41
42
|
webviewContentsContext: WebviewContentsContextType<T>;
|
|
42
43
|
}
|
|
43
|
-
export interface WebviewContentsContextType<T> {
|
|
44
|
+
export interface WebviewContentsContextType<T extends MapContentsType> {
|
|
44
45
|
getTextContent: (code: string) => string;
|
|
45
46
|
getImageSrc: (code: string) => string;
|
|
46
47
|
setCurrentLocale: (locale: string) => void;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { UseWebviewContents, UseWebviewContentsProps } from './types';
|
|
2
|
-
export declare function useWebviewContents<T>({ apiUrl, version, orgId, botId, webviewId, locale, mapContents, }: UseWebviewContentsProps<T>): UseWebviewContents<T>;
|
|
1
|
+
import { MapContentsType, UseWebviewContents, UseWebviewContentsProps } from './types';
|
|
2
|
+
export declare function useWebviewContents<T extends MapContentsType>({ apiUrl, version, orgId, botId, webviewId, locale, mapContents, }: UseWebviewContentsProps<T>): UseWebviewContents<T>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-webview-contents.js","sourceRoot":"","sources":["../../../src/webview/use-webview-contents.ts"],"names":[],"mappings":";AAAA,OAAO,KAAK,MAAM,OAAO,CAAA;AACzB,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAA;AAE3C,OAAO,EAAE,yBAAyB,EAAE,MAAM,cAAc,CAAA;AACxD,OAAO,EAAE,sBAAsB,EAAE,MAAM,UAAU,CAAA;AACjD,OAAO,
|
|
1
|
+
{"version":3,"file":"use-webview-contents.js","sourceRoot":"","sources":["../../../src/webview/use-webview-contents.ts"],"names":[],"mappings":";AAAA,OAAO,KAAK,MAAM,OAAO,CAAA;AACzB,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAA;AAE3C,OAAO,EAAE,yBAAyB,EAAE,MAAM,cAAc,CAAA;AACxD,OAAO,EAAE,sBAAsB,EAAE,MAAM,UAAU,CAAA;AACjD,OAAO,EAKL,kBAAkB,GAGnB,MAAM,SAAS,CAAA;AAEhB,MAAM,UAAU,kBAAkB,CAA4B,EAC5D,MAAM,GAAG,yBAAyB,EAClC,OAAO,GAAG,sBAAsB,CAAC,MAAM,EACvC,KAAK,EACL,KAAK,EACL,SAAS,EACT,MAAM,EACN,WAAW,GACgB;IAC3B,MAAM,CAAC,YAAY,EAAE,eAAe,CAAC,GAAG,QAAQ,EAAwB,CAAA;IACxE,MAAM,CAAC,aAAa,EAAE,gBAAgB,CAAC,GAAG,QAAQ,EAAyB,CAAA;IAC3E,MAAM,CAAC,QAAQ,EAAE,WAAW,CAAC,GAAG,QAAQ,CACtC,EAA6B,CAC9B,CAAA;IACD,MAAM,CAAC,aAAa,EAAE,gBAAgB,CAAC,GAAG,QAAQ,CAAC,MAAM,CAAC,CAAA;IAC1D,MAAM,CAAC,SAAS,EAAE,UAAU,CAAC,GAAG,QAAQ,CAAC,IAAI,CAAC,CAAA;IAC9C,MAAM,C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B,GAAG,GAAS,EAAE;YACrC,MAAM,GAAG,GAAG,GAAG,MAAM,YAAY,OAAO,EAAE,CAAA;YAC1C,IAAI;gBACF,MAAM,QAAQ,GAAG,MAAM,KAAK,CAAC,GAAG,CAA0B,GAAG,EAAE;oBAC7D,MAAM,EAAE,EAAE,GAAG,EAAE,KAAK,EAAE,GAAG,EAAE,KAAK,EAAE,OAAO,EAAE,SAAS,EAAE;iBACvD,CAAC,CAAA;gBAEF,MAAM,oBAAoB,GAAG,QAAQ,CAAC,IAAI,CAAC,gBAAgB,CAAC,MAAM,CAChE,cAAc,CAAC,EAAE,CAAC,cAAc,CAAC,IAAI,KAAK,kBAAkB,CAAC,IAAI,CAC1C,CAAA;gBACzB,eAAe,CAAC,oBAAoB,CAAC,CAAA;gBAErC,MAAM,qBAAqB,GAAG,QAAQ,CAAC,IAAI,CAAC,gBAAgB,CAAC,MAAM,CACjE,cAAc,CAAC,EAAE,CAAC,cAAc,CAAC,IAAI,KAAK,kBAAkB,CAAC,KAAK,CAC1C,CAAA;gBAC1B,gBAAgB,CAAC,qBAAqB,CAAC,CAAA;aACxC;YAAC,OAAO,KAAK,EAAE;gBACd,OAAO,CAAC,KAAK,CAAC,kCAAkC,EAAE,KAAK,CAAC,CAAA;gBACxD,QAAQ,CAAC,IAAI,CAAC,CAAA;aACf;oBAAS;gBACR,UAAU,CAAC,KAAK,CAAC,CAAA;aAClB;QACH,CAAC,CAAA,CAAA;QACD,mBAAmB,EAAE,CAAA;IACvB,CAAC,EAAE,EAAE,CAAC,CAAA;IAEN,OAAO;QACL,SAAS;QACT,KAAK;QACL,sBAAsB,EAAE;YACtB,cAAc;YACd,WAAW;YACX,gBAAgB;YAChB,QAAQ;SACT;KACF,CAAA;AACH,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { createContext } from 'react'
|
|
2
2
|
|
|
3
|
-
import { WebviewContentsContextType } from './types'
|
|
3
|
+
import { MapContentsType, WebviewContentsContextType } from './types'
|
|
4
4
|
|
|
5
5
|
/*
|
|
6
6
|
Define a generic type parameter for your context
|
|
@@ -26,7 +26,7 @@ import { WebviewContentsContextType } from './types'
|
|
|
26
26
|
|
|
27
27
|
const { contents } = useContext(MyWebviewContentsContext)
|
|
28
28
|
*/
|
|
29
|
-
export const
|
|
29
|
+
export const createWebviewContentsContext = <T extends MapContentsType>() =>
|
|
30
30
|
createContext<WebviewContentsContextType<T>>({
|
|
31
31
|
getTextContent: () => '',
|
|
32
32
|
getImageSrc: () => '',
|
package/src/webview/index.ts
CHANGED
package/src/webview/types.ts
CHANGED
|
@@ -25,7 +25,9 @@ export interface WebviewImageContent {
|
|
|
25
25
|
}
|
|
26
26
|
}
|
|
27
27
|
|
|
28
|
-
export
|
|
28
|
+
export type MapContentsType = Record<string, string>
|
|
29
|
+
|
|
30
|
+
export interface UseWebviewContentsProps<T extends MapContentsType> {
|
|
29
31
|
apiUrl?: string
|
|
30
32
|
version?: FlowBuilderJSONVersion
|
|
31
33
|
orgId: string
|
|
@@ -35,13 +37,13 @@ export interface UseWebviewContentsProps<T> {
|
|
|
35
37
|
mapContents: Record<keyof T, string>
|
|
36
38
|
}
|
|
37
39
|
|
|
38
|
-
export interface UseWebviewContents<T> {
|
|
40
|
+
export interface UseWebviewContents<T extends MapContentsType> {
|
|
39
41
|
isLoading: boolean
|
|
40
42
|
error: boolean
|
|
41
43
|
webviewContentsContext: WebviewContentsContextType<T>
|
|
42
44
|
}
|
|
43
45
|
|
|
44
|
-
export interface WebviewContentsContextType<T> {
|
|
46
|
+
export interface WebviewContentsContextType<T extends MapContentsType> {
|
|
45
47
|
getTextContent: (code: string) => string
|
|
46
48
|
getImageSrc: (code: string) => string
|
|
47
49
|
setCurrentLocale: (locale: string) => void
|
|
@@ -4,6 +4,7 @@ import { useEffect, useState } from 'react'
|
|
|
4
4
|
import { FLOW_BUILDER_API_URL_PROD } from '../constants'
|
|
5
5
|
import { FlowBuilderJSONVersion } from '../types'
|
|
6
6
|
import {
|
|
7
|
+
MapContentsType,
|
|
7
8
|
UseWebviewContents,
|
|
8
9
|
UseWebviewContentsProps,
|
|
9
10
|
WebviewContentsResponse,
|
|
@@ -12,7 +13,7 @@ import {
|
|
|
12
13
|
WebviewTextContent,
|
|
13
14
|
} from './types'
|
|
14
15
|
|
|
15
|
-
export function useWebviewContents<T>({
|
|
16
|
+
export function useWebviewContents<T extends MapContentsType>({
|
|
16
17
|
apiUrl = FLOW_BUILDER_API_URL_PROD,
|
|
17
18
|
version = FlowBuilderJSONVersion.LATEST,
|
|
18
19
|
orgId,
|
|
@@ -50,11 +51,11 @@ export function useWebviewContents<T>({
|
|
|
50
51
|
|
|
51
52
|
useEffect(() => {
|
|
52
53
|
if (textContents || imageContents) {
|
|
53
|
-
const contentsObject = {}
|
|
54
|
+
const contentsObject = {}
|
|
54
55
|
for (const [key, value] of Object.entries<string>(mapContents)) {
|
|
55
56
|
contentsObject[key] = getTextContent(value) || getImageSrc(value)
|
|
56
57
|
}
|
|
57
|
-
setContents(contentsObject)
|
|
58
|
+
setContents(contentsObject as Record<keyof T, string>)
|
|
58
59
|
}
|
|
59
60
|
}, [textContents, imageContents, currentLocale])
|
|
60
61
|
|