@builder.io/sdk-svelte 1.0.23 → 1.0.25
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 +2 -2
- package/lib/browser/blocks/button/button.svelte +16 -15
- package/lib/browser/blocks/columns/columns.svelte +32 -24
- package/lib/browser/blocks/columns/columns.svelte.d.ts +1 -1
- package/lib/browser/blocks/columns/columns.types.d.ts +1 -1
- package/lib/browser/blocks/columns/helpers.d.ts +1 -0
- package/lib/browser/blocks/columns/helpers.js +3 -0
- package/lib/browser/blocks/image/image.svelte +1 -1
- package/lib/browser/blocks/symbol/symbol.helpers.js +1 -1
- package/lib/browser/blocks/symbol/symbol.svelte +9 -2
- package/lib/browser/blocks/tabs/component-info.d.ts +2 -0
- package/lib/browser/blocks/tabs/component-info.js +138 -0
- package/lib/browser/blocks/tabs/index.d.ts +1 -0
- package/lib/browser/blocks/tabs/index.js +1 -0
- package/lib/browser/blocks/tabs/tabs.svelte +76 -0
- package/lib/browser/blocks/tabs/tabs.svelte.d.ts +25 -0
- package/lib/browser/blocks/tabs/tabs.types.d.ts +13 -0
- package/lib/browser/blocks/tabs/tabs.types.js +1 -0
- package/lib/browser/blocks/text/text.types.d.ts +2 -1
- package/lib/browser/components/block/block.helpers.d.ts +4 -2
- package/lib/browser/components/block/block.helpers.js +6 -0
- package/lib/browser/components/block/block.svelte +4 -8
- package/lib/browser/components/block/components/interactive-element.svelte +20 -19
- package/lib/browser/components/content/components/enable-editor.svelte +13 -8
- package/lib/browser/components/content/components/enable-editor.svelte.d.ts +1 -1
- package/lib/browser/components/content/components/styles.helpers.d.ts +1 -0
- package/lib/browser/components/content/components/styles.helpers.js +3 -0
- package/lib/browser/components/content/content.svelte +1 -0
- package/lib/browser/components/dynamic-div.svelte +5 -0
- package/lib/browser/constants/builder-registered-components.js +7 -1
- package/lib/browser/constants/sdk-version.d.ts +1 -1
- package/lib/browser/constants/sdk-version.js +1 -1
- package/lib/browser/functions/evaluate/node-runtime/init.d.ts +17 -1
- package/lib/browser/functions/evaluate/node-runtime/init.js +2 -2
- package/lib/browser/functions/evaluate/node-runtime/node-runtime.d.ts +4 -1
- package/lib/browser/functions/evaluate/node-runtime/node-runtime.js +29 -18
- package/lib/browser/functions/get-class-prop-name.js +1 -0
- package/lib/browser/functions/get-style.js +1 -0
- package/lib/browser/types/targets.d.ts +1 -1
- package/lib/edge/blocks/button/button.svelte +16 -15
- package/lib/edge/blocks/columns/columns.svelte +32 -24
- package/lib/edge/blocks/columns/columns.svelte.d.ts +1 -1
- package/lib/edge/blocks/columns/columns.types.d.ts +1 -1
- package/lib/edge/blocks/columns/helpers.d.ts +1 -0
- package/lib/edge/blocks/columns/helpers.js +3 -0
- package/lib/edge/blocks/image/image.svelte +1 -1
- package/lib/edge/blocks/symbol/symbol.helpers.js +1 -1
- package/lib/edge/blocks/symbol/symbol.svelte +9 -2
- package/lib/edge/blocks/tabs/component-info.d.ts +2 -0
- package/lib/edge/blocks/tabs/component-info.js +138 -0
- package/lib/edge/blocks/tabs/index.d.ts +1 -0
- package/lib/edge/blocks/tabs/index.js +1 -0
- package/lib/edge/blocks/tabs/tabs.svelte +76 -0
- package/lib/edge/blocks/tabs/tabs.svelte.d.ts +25 -0
- package/lib/edge/blocks/tabs/tabs.types.d.ts +13 -0
- package/lib/edge/blocks/tabs/tabs.types.js +1 -0
- package/lib/edge/blocks/text/text.types.d.ts +2 -1
- package/lib/edge/components/block/block.helpers.d.ts +4 -2
- package/lib/edge/components/block/block.helpers.js +6 -0
- package/lib/edge/components/block/block.svelte +4 -8
- package/lib/edge/components/block/components/interactive-element.svelte +20 -19
- package/lib/edge/components/content/components/enable-editor.svelte +13 -8
- package/lib/edge/components/content/components/enable-editor.svelte.d.ts +1 -1
- package/lib/edge/components/content/components/styles.helpers.d.ts +1 -0
- package/lib/edge/components/content/components/styles.helpers.js +3 -0
- package/lib/edge/components/content/content.svelte +1 -0
- package/lib/edge/components/dynamic-div.svelte +5 -0
- package/lib/edge/constants/builder-registered-components.js +7 -1
- package/lib/edge/constants/sdk-version.d.ts +1 -1
- package/lib/edge/constants/sdk-version.js +1 -1
- package/lib/edge/functions/evaluate/node-runtime/init.d.ts +17 -1
- package/lib/edge/functions/evaluate/node-runtime/init.js +2 -2
- package/lib/edge/functions/evaluate/node-runtime/node-runtime.d.ts +4 -1
- package/lib/edge/functions/evaluate/node-runtime/node-runtime.js +29 -18
- package/lib/edge/functions/get-class-prop-name.js +1 -0
- package/lib/edge/functions/get-style.js +1 -0
- package/lib/edge/types/targets.d.ts +1 -1
- package/lib/node/blocks/button/button.svelte +16 -15
- package/lib/node/blocks/columns/columns.svelte +32 -24
- package/lib/node/blocks/columns/columns.svelte.d.ts +1 -1
- package/lib/node/blocks/columns/columns.types.d.ts +1 -1
- package/lib/node/blocks/columns/helpers.d.ts +1 -0
- package/lib/node/blocks/columns/helpers.js +3 -0
- package/lib/node/blocks/image/image.svelte +1 -1
- package/lib/node/blocks/symbol/symbol.helpers.js +1 -1
- package/lib/node/blocks/symbol/symbol.svelte +9 -2
- package/lib/node/blocks/tabs/component-info.d.ts +2 -0
- package/lib/node/blocks/tabs/component-info.js +138 -0
- package/lib/node/blocks/tabs/index.d.ts +1 -0
- package/lib/node/blocks/tabs/index.js +1 -0
- package/lib/node/blocks/tabs/tabs.svelte +76 -0
- package/lib/node/blocks/tabs/tabs.svelte.d.ts +25 -0
- package/lib/node/blocks/tabs/tabs.types.d.ts +13 -0
- package/lib/node/blocks/tabs/tabs.types.js +1 -0
- package/lib/node/blocks/text/text.types.d.ts +2 -1
- package/lib/node/components/block/block.helpers.d.ts +4 -2
- package/lib/node/components/block/block.helpers.js +6 -0
- package/lib/node/components/block/block.svelte +4 -8
- package/lib/node/components/block/components/interactive-element.svelte +20 -19
- package/lib/node/components/content/components/enable-editor.svelte +13 -8
- package/lib/node/components/content/components/enable-editor.svelte.d.ts +1 -1
- package/lib/node/components/content/components/styles.helpers.d.ts +1 -0
- package/lib/node/components/content/components/styles.helpers.js +3 -0
- package/lib/node/components/content/content.svelte +1 -0
- package/lib/node/components/dynamic-div.svelte +5 -0
- package/lib/node/constants/builder-registered-components.js +7 -1
- package/lib/node/constants/sdk-version.d.ts +1 -1
- package/lib/node/constants/sdk-version.js +1 -1
- package/lib/node/functions/evaluate/node-runtime/init.d.ts +17 -1
- package/lib/node/functions/evaluate/node-runtime/init.js +2 -2
- package/lib/node/functions/evaluate/node-runtime/node-runtime.d.ts +4 -1
- package/lib/node/functions/evaluate/node-runtime/node-runtime.js +29 -18
- package/lib/node/functions/get-class-prop-name.js +1 -0
- package/lib/node/functions/get-style.js +1 -0
- package/lib/node/types/targets.d.ts +1 -1
- package/package.json +1 -1
- package/src/blocks/button/button.svelte +19 -15
- package/src/blocks/columns/columns.svelte +34 -26
- package/src/blocks/columns/columns.types.ts +1 -1
- package/src/blocks/columns/helpers.ts +3 -0
- package/src/blocks/image/image.svelte +1 -1
- package/src/blocks/symbol/symbol.helpers.ts +1 -1
- package/src/blocks/symbol/symbol.svelte +9 -2
- package/src/blocks/tabs/component-info.ts +139 -0
- package/src/blocks/tabs/index.ts +1 -0
- package/src/blocks/tabs/tabs.svelte +83 -0
- package/src/blocks/tabs/tabs.types.ts +13 -0
- package/src/blocks/text/text.types.ts +2 -1
- package/src/components/block/block.helpers.ts +7 -1
- package/src/components/block/block.svelte +5 -7
- package/src/components/block/components/interactive-element.svelte +21 -19
- package/src/components/content/components/enable-editor.svelte +13 -8
- package/src/components/content/components/styles.helpers.ts +3 -0
- package/src/components/content/content.svelte +1 -0
- package/src/components/dynamic-div.svelte +19 -0
- package/src/constants/builder-registered-components.ts +7 -1
- package/src/constants/sdk-version.ts +1 -1
- package/src/functions/evaluate/node-runtime/init.ts +7 -2
- package/src/functions/evaluate/node-runtime/node-runtime.ts +34 -21
- package/src/functions/get-class-prop-name.ts +1 -0
- package/src/functions/get-style.ts +1 -0
- package/src/types/targets.ts +1 -1
|
@@ -18,6 +18,8 @@ import "../../../helpers/preview-lru-cache/set";
|
|
|
18
18
|
import { createEditorListener } from "../../../helpers/subscribe-to-editor";
|
|
19
19
|
import { registerInsertMenu, setupBrowserForEditing, } from "../../../scripts/init-editing";
|
|
20
20
|
import { triggerAnimation } from "../../block/animator";
|
|
21
|
+
import { getWrapperClassName } from "./styles.helpers";
|
|
22
|
+
import "../../dynamic-div.svelte";
|
|
21
23
|
export let builderContextSignal;
|
|
22
24
|
export let canTrack = undefined;
|
|
23
25
|
export let apiKey;
|
|
@@ -27,9 +29,9 @@ export let trustedHosts = undefined;
|
|
|
27
29
|
export let model = undefined;
|
|
28
30
|
export let content = undefined;
|
|
29
31
|
export let data = undefined;
|
|
32
|
+
export let showContent;
|
|
30
33
|
export let contentWrapper = undefined;
|
|
31
34
|
export let context = undefined;
|
|
32
|
-
export let showContent;
|
|
33
35
|
export let contentWrapperProps = undefined;
|
|
34
36
|
function mergeNewRootState(newData) {
|
|
35
37
|
const combinedState = {
|
|
@@ -224,6 +226,14 @@ function elementRef_onInitpreviewingbldr(event) {
|
|
|
224
226
|
});
|
|
225
227
|
}
|
|
226
228
|
}
|
|
229
|
+
$: showContentProps = () => {
|
|
230
|
+
return showContent
|
|
231
|
+
? {}
|
|
232
|
+
: {
|
|
233
|
+
hidden: true,
|
|
234
|
+
"aria-hidden": true,
|
|
235
|
+
};
|
|
236
|
+
};
|
|
227
237
|
let elementRef;
|
|
228
238
|
let ContentWrapper = contentWrapper || "div";
|
|
229
239
|
let httpReqsData = {};
|
|
@@ -326,14 +336,9 @@ onDestroy(() => {
|
|
|
326
336
|
builder-content-id={$builderContextSignal.content?.id}
|
|
327
337
|
builder-model={model}
|
|
328
338
|
{...{}}
|
|
329
|
-
{...
|
|
330
|
-
? {}
|
|
331
|
-
: {
|
|
332
|
-
hidden: true,
|
|
333
|
-
"aria-hidden": true,
|
|
334
|
-
}}
|
|
339
|
+
{...showContentProps()}
|
|
335
340
|
{...contentWrapperProps}
|
|
336
|
-
class={
|
|
341
|
+
class={getWrapperClassName(content?.testVariationId || content?.id)}
|
|
337
342
|
on:initeditingbldr={(event) => {
|
|
338
343
|
elementRef_onIniteditingbldr(event);
|
|
339
344
|
}}
|
|
@@ -18,9 +18,9 @@ declare const __propDef: {
|
|
|
18
18
|
model?: BuilderEditorProps["model"];
|
|
19
19
|
content?: BuilderEditorProps["content"];
|
|
20
20
|
data?: BuilderEditorProps["data"];
|
|
21
|
+
showContent: BuilderEditorProps["showContent"];
|
|
21
22
|
contentWrapper?: BuilderEditorProps["contentWrapper"];
|
|
22
23
|
context?: BuilderEditorProps["context"];
|
|
23
|
-
showContent: BuilderEditorProps["showContent"];
|
|
24
24
|
contentWrapperProps?: BuilderEditorProps["contentWrapperProps"];
|
|
25
25
|
};
|
|
26
26
|
events: {
|
|
@@ -14,3 +14,4 @@ export declare const getCss: ({ cssCode, contentId }: {
|
|
|
14
14
|
contentId?: string | undefined;
|
|
15
15
|
}) => string;
|
|
16
16
|
export declare const getDefaultStyles: (isNested: boolean | undefined) => "" | "\n.builder-button {\n all: unset;\n}\n\n.builder-text > p:first-of-type, .builder-text > .builder-paragraph:first-of-type {\n margin: 0;\n}\n.builder-text > p, .builder-text > .builder-paragraph {\n color: inherit;\n line-height: inherit;\n letter-spacing: inherit;\n font-weight: inherit;\n font-size: inherit;\n text-align: inherit;\n font-family: inherit;\n}\n";
|
|
17
|
+
export declare const getWrapperClassName: (variationId?: string) => string;
|
|
@@ -11,6 +11,7 @@ import EnableEditor from "./components/enable-editor.svelte";
|
|
|
11
11
|
import ContentStyles from "./components/styles.svelte";
|
|
12
12
|
import { getContentInitialValue, getRootStateInitialValue, } from "./content.helpers";
|
|
13
13
|
import "./wrap-component-ref";
|
|
14
|
+
import "../dynamic-div.svelte";
|
|
14
15
|
export let content = undefined;
|
|
15
16
|
export let customComponents = undefined;
|
|
16
17
|
export let data = undefined;
|
|
@@ -12,9 +12,12 @@ import { componentInfo as slotComponentInfo } from '../blocks/slot/component-inf
|
|
|
12
12
|
import { default as Slot } from '../blocks/slot/index';
|
|
13
13
|
import { componentInfo as symbolComponentInfo } from '../blocks/symbol/component-info';
|
|
14
14
|
import { default as Symbol } from '../blocks/symbol/index';
|
|
15
|
+
import { componentInfo as tabsComponentInfo } from '../blocks/tabs/component-info';
|
|
16
|
+
import { default as Tabs } from '../blocks/tabs/index';
|
|
15
17
|
import { componentInfo as textComponentInfo } from '../blocks/text/component-info';
|
|
16
18
|
import { default as Text } from '../blocks/text/index';
|
|
17
19
|
import { getExtraComponents } from './extra-components';
|
|
20
|
+
import { TARGET } from './target';
|
|
18
21
|
/**
|
|
19
22
|
* Returns a list of all registered components.
|
|
20
23
|
* NOTE: This needs to be a function to work around ESM circular dependencies.
|
|
@@ -43,4 +46,7 @@ export const getDefaultRegisteredComponents = () => [{
|
|
|
43
46
|
}, {
|
|
44
47
|
component: Text,
|
|
45
48
|
...textComponentInfo
|
|
46
|
-
}, ...
|
|
49
|
+
}, ...(TARGET === 'rsc' ? [] : [{
|
|
50
|
+
component: Tabs,
|
|
51
|
+
...tabsComponentInfo
|
|
52
|
+
}]), ...getExtraComponents()];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const SDK_VERSION = "1.0.
|
|
1
|
+
export declare const SDK_VERSION = "1.0.25";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export const SDK_VERSION = "1.0.
|
|
1
|
+
export const SDK_VERSION = "1.0.25";
|
|
@@ -1,3 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This file:
|
|
3
|
+
* - imports `isolated-vm`, which can only be made from a file that never runs
|
|
4
|
+
* on the client (e.g. Next's `_document.tsx`)
|
|
5
|
+
* - stores the ivm instance in a global variable using `setIvm`
|
|
6
|
+
*
|
|
7
|
+
* This is needed for when bundlers/meta-frameworks are not able to reliably
|
|
8
|
+
* import the `isolated-vm` package using our `safeDynamicRequire` trick.
|
|
9
|
+
*
|
|
10
|
+
* The `isolated-vm` import must exist in this separate file, or it will end up
|
|
11
|
+
* in the SDK's main entry point, causing errors for users.
|
|
12
|
+
*/
|
|
13
|
+
import ivm from 'isolated-vm';
|
|
14
|
+
import type { IsolateOptions } from 'isolated-vm';
|
|
1
15
|
/**
|
|
2
16
|
* This function initializes the SDK on a Node server. It handles importing the
|
|
3
17
|
* `isolated-vm` package which is needed for dynamic bindings.
|
|
@@ -7,4 +21,6 @@
|
|
|
7
21
|
* - The NextJS Pages router's `_document.tsx`
|
|
8
22
|
* - Your Remix route's `loader`
|
|
9
23
|
*/
|
|
10
|
-
export declare const initializeNodeRuntime: (
|
|
24
|
+
export declare const initializeNodeRuntime: ({ ivmIsolateOptions }: {
|
|
25
|
+
ivmIsolateOptions?: ivm.IsolateOptions | undefined;
|
|
26
|
+
}) => void;
|
|
@@ -21,6 +21,6 @@ import { setIvm } from './node-runtime';
|
|
|
21
21
|
* - The NextJS Pages router's `_document.tsx`
|
|
22
22
|
* - Your Remix route's `loader`
|
|
23
23
|
*/
|
|
24
|
-
export const initializeNodeRuntime = () => {
|
|
25
|
-
setIvm(ivm);
|
|
24
|
+
export const initializeNodeRuntime = ({ ivmIsolateOptions }) => {
|
|
25
|
+
setIvm(ivm, ivmIsolateOptions);
|
|
26
26
|
};
|
|
@@ -1,8 +1,11 @@
|
|
|
1
|
+
import type { IsolateOptions } from 'isolated-vm';
|
|
1
2
|
import type { ExecutorArgs } from '../helpers';
|
|
3
|
+
type IsolatedVMImport = typeof import('isolated-vm');
|
|
2
4
|
/**
|
|
3
5
|
* Set the `isolated-vm` instance to be used by the node runtime.
|
|
4
6
|
* This is useful for environments that are not able to rely on our
|
|
5
7
|
* `safeDynamicRequire` trick to import the `isolated-vm` package.
|
|
6
8
|
*/
|
|
7
|
-
export declare const setIvm: (ivm:
|
|
9
|
+
export declare const setIvm: (ivm: IsolatedVMImport, options?: IsolateOptions) => void;
|
|
8
10
|
export declare const runInNode: ({ code, builder, context, event, localState, rootSetState, rootState }: ExecutorArgs) => any;
|
|
11
|
+
export {};
|
|
@@ -45,23 +45,25 @@ function theFunction() {
|
|
|
45
45
|
${code}
|
|
46
46
|
}
|
|
47
47
|
|
|
48
|
-
|
|
48
|
+
const output = theFunction()
|
|
49
49
|
|
|
50
50
|
if (typeof output === 'object' && output !== null) {
|
|
51
|
-
|
|
51
|
+
return JSON.stringify(output.copySync ? output.copySync() : output);
|
|
52
|
+
} else {
|
|
53
|
+
return output;
|
|
52
54
|
}
|
|
53
|
-
|
|
54
|
-
output;
|
|
55
55
|
`;
|
|
56
56
|
};
|
|
57
57
|
let IVM_INSTANCE = null;
|
|
58
|
+
let IVM_CONTEXT = null;
|
|
58
59
|
/**
|
|
59
60
|
* Set the `isolated-vm` instance to be used by the node runtime.
|
|
60
61
|
* This is useful for environments that are not able to rely on our
|
|
61
62
|
* `safeDynamicRequire` trick to import the `isolated-vm` package.
|
|
62
63
|
*/
|
|
63
|
-
export const setIvm = (ivm) => {
|
|
64
|
+
export const setIvm = (ivm, options = {}) => {
|
|
64
65
|
IVM_INSTANCE = ivm;
|
|
66
|
+
setIsolateContext(options);
|
|
65
67
|
};
|
|
66
68
|
const getIvm = () => {
|
|
67
69
|
try {
|
|
@@ -83,12 +85,29 @@ const getIvm = () => {
|
|
|
83
85
|
Please see the documentation for more information: https://builder.io/c/docs/integration-tips#enabling-data-bindings-in-node-environments
|
|
84
86
|
`);
|
|
85
87
|
};
|
|
86
|
-
|
|
88
|
+
function setIsolateContext(options = {
|
|
89
|
+
memoryLimit: 128
|
|
90
|
+
}) {
|
|
87
91
|
const ivm = getIvm();
|
|
88
|
-
const isolate = new ivm.Isolate(
|
|
89
|
-
|
|
92
|
+
const isolate = new ivm.Isolate(options);
|
|
93
|
+
const context = isolate.createContextSync();
|
|
94
|
+
const jail = context.global;
|
|
95
|
+
// This makes the global object available in the context as `global`. We use `derefInto()` here
|
|
96
|
+
// because otherwise `global` would actually be a Reference{} object in the new isolate.
|
|
97
|
+
jail.setSync('global', jail.derefInto());
|
|
98
|
+
// We will create a basic `log` function for the new isolate to use.
|
|
99
|
+
jail.setSync('log', function (...logArgs) {
|
|
100
|
+
console.log(...logArgs);
|
|
90
101
|
});
|
|
91
|
-
|
|
102
|
+
jail.setSync(INJECTED_IVM_GLOBAL, ivm);
|
|
103
|
+
IVM_CONTEXT = context;
|
|
104
|
+
return context;
|
|
105
|
+
}
|
|
106
|
+
const getIsolateContext = () => {
|
|
107
|
+
if (IVM_CONTEXT)
|
|
108
|
+
return IVM_CONTEXT;
|
|
109
|
+
const context = setIsolateContext();
|
|
110
|
+
return context;
|
|
92
111
|
};
|
|
93
112
|
export const runInNode = ({ code, builder, context, event, localState, rootSetState, rootState }) => {
|
|
94
113
|
const ivm = getIvm();
|
|
@@ -104,13 +123,6 @@ export const runInNode = ({ code, builder, context, event, localState, rootSetSt
|
|
|
104
123
|
});
|
|
105
124
|
const isolateContext = getIsolateContext();
|
|
106
125
|
const jail = isolateContext.global;
|
|
107
|
-
// This makes the global object available in the context as `global`. We use `derefInto()` here
|
|
108
|
-
// because otherwise `global` would actually be a Reference{} object in the new isolate.
|
|
109
|
-
jail.setSync('global', jail.derefInto());
|
|
110
|
-
// We will create a basic `log` function for the new isolate to use.
|
|
111
|
-
jail.setSync('log', function (...logArgs) {
|
|
112
|
-
console.log(...logArgs);
|
|
113
|
-
});
|
|
114
126
|
/**
|
|
115
127
|
* Propagate state changes back to the reactive root state.
|
|
116
128
|
*/
|
|
@@ -130,12 +142,11 @@ export const runInNode = ({ code, builder, context, event, localState, rootSetSt
|
|
|
130
142
|
} : arg) : null;
|
|
131
143
|
jail.setSync(getSyncValName(key), val);
|
|
132
144
|
});
|
|
133
|
-
jail.setSync(INJECTED_IVM_GLOBAL, ivm);
|
|
134
145
|
const evalStr = processCode({
|
|
135
146
|
code,
|
|
136
147
|
args
|
|
137
148
|
});
|
|
138
|
-
const resultStr = isolateContext.
|
|
149
|
+
const resultStr = isolateContext.evalClosureSync(evalStr);
|
|
139
150
|
try {
|
|
140
151
|
// returning objects throw errors in isolated vm, so we stringify it and parse it back
|
|
141
152
|
const res = JSON.parse(resultStr);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export type Target = 'vue' | 'reactNative' | 'svelte' | 'qwik' | 'react' | 'solid' | 'rsc';
|
|
1
|
+
export type Target = 'vue' | 'reactNative' | 'svelte' | 'qwik' | 'react' | 'solid' | 'rsc' | 'angular';
|
|
@@ -6,24 +6,25 @@ export let link = undefined;
|
|
|
6
6
|
export let openLinkInNewTab = undefined;
|
|
7
7
|
export let builderLinkComponent = undefined;
|
|
8
8
|
export let text = undefined;
|
|
9
|
+
function attrs() {
|
|
10
|
+
return {
|
|
11
|
+
...filterAttrs(attributes, "on:", false),
|
|
12
|
+
[getClassPropName()]: `${link ? "" : "builder-button"} ${attributes[getClassPropName()] || ""}`,
|
|
13
|
+
...(link
|
|
14
|
+
? {
|
|
15
|
+
href: link,
|
|
16
|
+
target: openLinkInNewTab ? "_blank" : undefined,
|
|
17
|
+
role: "link",
|
|
18
|
+
}
|
|
19
|
+
: {
|
|
20
|
+
role: "button",
|
|
21
|
+
}),
|
|
22
|
+
};
|
|
23
|
+
}
|
|
9
24
|
</script>
|
|
10
25
|
|
|
11
26
|
<DynamicRenderer
|
|
12
|
-
attributes={
|
|
13
|
-
...filterAttrs(attributes, "on:", false),
|
|
14
|
-
[getClassPropName()]: `${link ? "" : "builder-button"} ${
|
|
15
|
-
attributes[getClassPropName()] || ""
|
|
16
|
-
}`,
|
|
17
|
-
...(link
|
|
18
|
-
? {
|
|
19
|
-
href: link,
|
|
20
|
-
target: openLinkInNewTab ? "_blank" : undefined,
|
|
21
|
-
role: "link",
|
|
22
|
-
}
|
|
23
|
-
: {
|
|
24
|
-
role: "button",
|
|
25
|
-
}),
|
|
26
|
-
}}
|
|
27
|
+
attributes={attrs()}
|
|
27
28
|
TagName={link ? builderLinkComponent || "a" : "button"}
|
|
28
29
|
actionAttributes={filterAttrs(attributes, "on:", true)}
|
|
29
30
|
>{text}</DynamicRenderer
|
|
@@ -8,13 +8,15 @@ import { TARGET } from "../../constants/target";
|
|
|
8
8
|
import "../../functions/deopt";
|
|
9
9
|
import { getClassPropName } from "../../functions/get-class-prop-name";
|
|
10
10
|
import { mapStyleObjToStrIfNeeded } from "../../functions/get-style";
|
|
11
|
+
import { getColumnsClass } from "./helpers";
|
|
12
|
+
import "../../components/dynamic-div.svelte";
|
|
11
13
|
export let space = undefined;
|
|
12
14
|
export let columns = undefined;
|
|
13
15
|
export let stackColumnsAt = undefined;
|
|
16
|
+
export let builderLinkComponent = undefined;
|
|
14
17
|
export let reverseColumnsWhenStacked = undefined;
|
|
15
18
|
export let builderContext;
|
|
16
19
|
export let builderBlock;
|
|
17
|
-
export let builderLinkComponent = undefined;
|
|
18
20
|
export let builderComponents;
|
|
19
21
|
function stringifyStyles(stylesObj) {
|
|
20
22
|
let styles = "";
|
|
@@ -26,6 +28,9 @@ function stringifyStyles(stylesObj) {
|
|
|
26
28
|
}
|
|
27
29
|
return styles;
|
|
28
30
|
}
|
|
31
|
+
function getTagName(column) {
|
|
32
|
+
return column.link ? builderLinkComponent || "a" : "div";
|
|
33
|
+
}
|
|
29
34
|
function getWidth(index) {
|
|
30
35
|
return cols[index]?.width || 100 / cols.length;
|
|
31
36
|
}
|
|
@@ -39,6 +44,15 @@ function getTabletStyle({ stackedStyle, desktopStyle, }) {
|
|
|
39
44
|
function getMobileStyle({ stackedStyle, desktopStyle, }) {
|
|
40
45
|
return stackAt === "never" ? desktopStyle : stackedStyle;
|
|
41
46
|
}
|
|
47
|
+
function columnsCssVars() {
|
|
48
|
+
return {
|
|
49
|
+
"--flex-dir": flexDir,
|
|
50
|
+
"--flex-dir-tablet": getTabletStyle({
|
|
51
|
+
stackedStyle: flexDir,
|
|
52
|
+
desktopStyle: "row",
|
|
53
|
+
}),
|
|
54
|
+
};
|
|
55
|
+
}
|
|
42
56
|
function columnCssVars(index) {
|
|
43
57
|
const gutter = index === 0 ? 0 : gutterSize;
|
|
44
58
|
const width = getColumnCssWidth(index);
|
|
@@ -77,16 +91,7 @@ function getWidthForBreakpointSize(size) {
|
|
|
77
91
|
const breakpointSizes = getSizesForBreakpoints($builderContext.content?.meta?.breakpoints || {});
|
|
78
92
|
return breakpointSizes[size].max;
|
|
79
93
|
}
|
|
80
|
-
|
|
81
|
-
return {
|
|
82
|
-
"--flex-dir": flexDir,
|
|
83
|
-
"--flex-dir-tablet": getTabletStyle({
|
|
84
|
-
stackedStyle: flexDir,
|
|
85
|
-
desktopStyle: "row",
|
|
86
|
-
}),
|
|
87
|
-
};
|
|
88
|
-
};
|
|
89
|
-
$: columnsStyles = () => {
|
|
94
|
+
function columnsStyles() {
|
|
90
95
|
return `
|
|
91
96
|
@media (max-width: ${getWidthForBreakpointSize("medium")}px) {
|
|
92
97
|
.${builderBlock.id}-breakpoints {
|
|
@@ -112,7 +117,19 @@ $: columnsStyles = () => {
|
|
|
112
117
|
}
|
|
113
118
|
},
|
|
114
119
|
`;
|
|
115
|
-
}
|
|
120
|
+
}
|
|
121
|
+
function getAttributes(column, index) {
|
|
122
|
+
return {
|
|
123
|
+
...{},
|
|
124
|
+
...(column.link
|
|
125
|
+
? {
|
|
126
|
+
href: column.link,
|
|
127
|
+
}
|
|
128
|
+
: {}),
|
|
129
|
+
[getClassPropName()]: "builder-column",
|
|
130
|
+
style: mapStyleObjToStrIfNeeded(columnCssVars(index)),
|
|
131
|
+
};
|
|
132
|
+
}
|
|
116
133
|
let gutterSize = typeof space === "number" ? space || 0 : 20;
|
|
117
134
|
let cols = columns || [];
|
|
118
135
|
let stackAt = stackColumnsAt || "tablet";
|
|
@@ -125,7 +142,7 @@ let flexDir = stackColumnsAt === "never"
|
|
|
125
142
|
|
|
126
143
|
<div
|
|
127
144
|
style={stringifyStyles(columnsCssVars())}
|
|
128
|
-
class={
|
|
145
|
+
class={getColumnsClass(builderBlock?.id) + " div"}
|
|
129
146
|
{...{}}
|
|
130
147
|
>
|
|
131
148
|
{#if TARGET !== "reactNative"}
|
|
@@ -133,18 +150,9 @@ let flexDir = stackColumnsAt === "never"
|
|
|
133
150
|
{/if}
|
|
134
151
|
{#each columns as column, index (index)}
|
|
135
152
|
<DynamicRenderer
|
|
136
|
-
TagName={column
|
|
153
|
+
TagName={getTagName(column)}
|
|
137
154
|
actionAttributes={{}}
|
|
138
|
-
attributes={
|
|
139
|
-
...{},
|
|
140
|
-
...(column.link
|
|
141
|
-
? {
|
|
142
|
-
href: column.link,
|
|
143
|
-
}
|
|
144
|
-
: {}),
|
|
145
|
-
[getClassPropName()]: "builder-column",
|
|
146
|
-
style: mapStyleObjToStrIfNeeded(columnCssVars(index)),
|
|
147
|
-
}}
|
|
155
|
+
attributes={getAttributes(column, index)}
|
|
148
156
|
><Blocks
|
|
149
157
|
path={`component.options.columns.${index}.blocks`}
|
|
150
158
|
parent={builderBlock.id}
|
|
@@ -5,10 +5,10 @@ declare const __propDef: {
|
|
|
5
5
|
space?: ColumnProps["space"];
|
|
6
6
|
columns?: ColumnProps["columns"];
|
|
7
7
|
stackColumnsAt?: ColumnProps["stackColumnsAt"];
|
|
8
|
+
builderLinkComponent?: ColumnProps["builderLinkComponent"];
|
|
8
9
|
reverseColumnsWhenStacked?: ColumnProps["reverseColumnsWhenStacked"];
|
|
9
10
|
builderContext: ColumnProps["builderContext"];
|
|
10
11
|
builderBlock: ColumnProps["builderBlock"];
|
|
11
|
-
builderLinkComponent?: ColumnProps["builderLinkComponent"];
|
|
12
12
|
builderComponents: ColumnProps["builderComponents"];
|
|
13
13
|
};
|
|
14
14
|
events: {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { BuilderBlock } from '../../types/builder-block';
|
|
2
2
|
import type { BuilderComponentsProp, BuilderDataProps, BuilderLinkComponentProp } from '../../types/builder-props';
|
|
3
|
-
type Column = {
|
|
3
|
+
export type Column = {
|
|
4
4
|
blocks: BuilderBlock[];
|
|
5
5
|
width?: number;
|
|
6
6
|
link?: string;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const getColumnsClass: (id?: string) => string;
|
|
@@ -4,6 +4,7 @@ import { filterAttrs } from "../helpers";
|
|
|
4
4
|
import { getClassPropName } from "../../functions/get-class-prop-name";
|
|
5
5
|
import { setAttrs } from "../helpers";
|
|
6
6
|
import { fetchSymbolContent } from "./symbol.helpers";
|
|
7
|
+
import "../../components/dynamic-div.svelte";
|
|
7
8
|
export let symbol = undefined;
|
|
8
9
|
export let attributes = undefined;
|
|
9
10
|
export let dynamic = undefined;
|
|
@@ -23,6 +24,12 @@ function setContent() {
|
|
|
23
24
|
}
|
|
24
25
|
});
|
|
25
26
|
}
|
|
27
|
+
$: blocksWrapper = () => {
|
|
28
|
+
return "div";
|
|
29
|
+
};
|
|
30
|
+
$: contentWrapper = () => {
|
|
31
|
+
return "div";
|
|
32
|
+
};
|
|
26
33
|
$: className = () => {
|
|
27
34
|
return [
|
|
28
35
|
...[attributes[getClassPropName()]],
|
|
@@ -66,7 +73,7 @@ $: onUpdateFn_0(...[symbol]);
|
|
|
66
73
|
model={symbol?.model}
|
|
67
74
|
content={contentToUse}
|
|
68
75
|
linkComponent={builderLinkComponent}
|
|
69
|
-
blocksWrapper={
|
|
70
|
-
contentWrapper={
|
|
76
|
+
blocksWrapper={blocksWrapper()}
|
|
77
|
+
contentWrapper={contentWrapper()}
|
|
71
78
|
/>
|
|
72
79
|
</div>
|
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
const defaultTab = {
|
|
2
|
+
'@type': '@builder.io/sdk:Element',
|
|
3
|
+
responsiveStyles: {
|
|
4
|
+
large: {
|
|
5
|
+
paddingLeft: '20px',
|
|
6
|
+
paddingRight: '20px',
|
|
7
|
+
paddingTop: '10px',
|
|
8
|
+
paddingBottom: '10px',
|
|
9
|
+
minWidth: '100px',
|
|
10
|
+
textAlign: 'center',
|
|
11
|
+
display: 'flex',
|
|
12
|
+
flexDirection: 'column',
|
|
13
|
+
cursor: 'pointer',
|
|
14
|
+
userSelect: 'none'
|
|
15
|
+
}
|
|
16
|
+
},
|
|
17
|
+
component: {
|
|
18
|
+
name: 'Text',
|
|
19
|
+
options: {
|
|
20
|
+
text: 'New tab'
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
};
|
|
24
|
+
const defaultElement = {
|
|
25
|
+
'@type': '@builder.io/sdk:Element',
|
|
26
|
+
responsiveStyles: {
|
|
27
|
+
large: {
|
|
28
|
+
height: '200px',
|
|
29
|
+
display: 'flex',
|
|
30
|
+
marginTop: '20px',
|
|
31
|
+
flexDirection: 'column'
|
|
32
|
+
}
|
|
33
|
+
},
|
|
34
|
+
component: {
|
|
35
|
+
name: 'Text',
|
|
36
|
+
options: {
|
|
37
|
+
text: 'New tab content '
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
};
|
|
41
|
+
export const componentInfo = {
|
|
42
|
+
name: 'Builder: Tabs',
|
|
43
|
+
inputs: [{
|
|
44
|
+
name: 'tabs',
|
|
45
|
+
type: 'list',
|
|
46
|
+
broadcast: true,
|
|
47
|
+
subFields: [{
|
|
48
|
+
name: 'label',
|
|
49
|
+
type: 'uiBlocks',
|
|
50
|
+
hideFromUI: true,
|
|
51
|
+
defaultValue: [defaultTab]
|
|
52
|
+
}, {
|
|
53
|
+
name: 'content',
|
|
54
|
+
type: 'uiBlocks',
|
|
55
|
+
hideFromUI: true,
|
|
56
|
+
defaultValue: [defaultElement]
|
|
57
|
+
}],
|
|
58
|
+
defaultValue: [{
|
|
59
|
+
label: [{
|
|
60
|
+
...defaultTab,
|
|
61
|
+
component: {
|
|
62
|
+
name: 'Text',
|
|
63
|
+
options: {
|
|
64
|
+
text: 'Tab 1'
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
}],
|
|
68
|
+
content: [{
|
|
69
|
+
...defaultElement,
|
|
70
|
+
component: {
|
|
71
|
+
name: 'Text',
|
|
72
|
+
options: {
|
|
73
|
+
text: 'Tab 1 content'
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
}]
|
|
77
|
+
}, {
|
|
78
|
+
label: [{
|
|
79
|
+
...defaultTab,
|
|
80
|
+
component: {
|
|
81
|
+
name: 'Text',
|
|
82
|
+
options: {
|
|
83
|
+
text: 'Tab 2'
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
}],
|
|
87
|
+
content: [{
|
|
88
|
+
...defaultElement,
|
|
89
|
+
component: {
|
|
90
|
+
name: 'Text',
|
|
91
|
+
options: {
|
|
92
|
+
text: 'Tab 2 content'
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
}]
|
|
96
|
+
}]
|
|
97
|
+
}, {
|
|
98
|
+
name: 'activeTabStyle',
|
|
99
|
+
type: 'uiStyle',
|
|
100
|
+
helperText: 'CSS styles for the active tab',
|
|
101
|
+
defaultValue: {
|
|
102
|
+
backgroundColor: 'rgba(0, 0, 0, 0.1)'
|
|
103
|
+
}
|
|
104
|
+
}, {
|
|
105
|
+
name: 'defaultActiveTab',
|
|
106
|
+
type: 'number',
|
|
107
|
+
helperText: 'Default tab to open to. Set to "1" for the first tab, "2" for the second, or choose "0" for none',
|
|
108
|
+
defaultValue: 1,
|
|
109
|
+
advanced: true
|
|
110
|
+
}, {
|
|
111
|
+
name: 'collapsible',
|
|
112
|
+
type: 'boolean',
|
|
113
|
+
helperText: 'If on, clicking an open tab closes it so no tabs are active',
|
|
114
|
+
defaultValue: false,
|
|
115
|
+
advanced: true
|
|
116
|
+
}, {
|
|
117
|
+
name: 'tabHeaderLayout',
|
|
118
|
+
type: 'enum',
|
|
119
|
+
helperText: 'Change the layout of the tab headers (uses justify-content)',
|
|
120
|
+
defaultValue: 'flex-start',
|
|
121
|
+
enum: [{
|
|
122
|
+
label: 'Center',
|
|
123
|
+
value: 'center'
|
|
124
|
+
}, {
|
|
125
|
+
label: 'Space between',
|
|
126
|
+
value: 'space-between'
|
|
127
|
+
}, {
|
|
128
|
+
label: 'Space around',
|
|
129
|
+
value: 'space-around'
|
|
130
|
+
}, {
|
|
131
|
+
label: 'Left',
|
|
132
|
+
value: 'flex-start'
|
|
133
|
+
}, {
|
|
134
|
+
label: 'Right',
|
|
135
|
+
value: 'flex-end'
|
|
136
|
+
}]
|
|
137
|
+
}]
|
|
138
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from './tabs.svelte';
|