@builder.io/sdk-svelte 1.0.23 → 1.0.24
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 +2 -0
- 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/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 +2 -0
- 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/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 +2 -0
- 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/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 +6 -0
- 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/get-class-prop-name.ts +1 -0
- package/src/functions/get-style.ts +1 -0
- package/src/types/targets.ts +1 -1
|
@@ -2,29 +2,30 @@
|
|
|
2
2
|
|
|
3
3
|
<script>import { getBlockActions } from "../../../functions/get-block-actions";
|
|
4
4
|
import { getBlockProperties } from "../../../functions/get-block-properties";
|
|
5
|
-
export let wrapperProps;
|
|
6
5
|
export let includeBlockProps;
|
|
7
6
|
export let block;
|
|
8
7
|
export let context;
|
|
8
|
+
export let wrapperProps;
|
|
9
9
|
export let Wrapper;
|
|
10
|
+
$: attributes = () => {
|
|
11
|
+
return includeBlockProps
|
|
12
|
+
? {
|
|
13
|
+
...getBlockProperties({
|
|
14
|
+
block: block,
|
|
15
|
+
context: $context,
|
|
16
|
+
}),
|
|
17
|
+
...getBlockActions({
|
|
18
|
+
block: block,
|
|
19
|
+
rootState: $context.rootState,
|
|
20
|
+
rootSetState: $context.rootSetState,
|
|
21
|
+
localState: $context.localState,
|
|
22
|
+
context: $context.context,
|
|
23
|
+
}),
|
|
24
|
+
}
|
|
25
|
+
: {};
|
|
26
|
+
};
|
|
10
27
|
</script>
|
|
11
28
|
|
|
12
|
-
<svelte:component
|
|
13
|
-
|
|
14
|
-
{...wrapperProps}
|
|
15
|
-
attributes={includeBlockProps
|
|
16
|
-
? {
|
|
17
|
-
...getBlockProperties({
|
|
18
|
-
block: block,
|
|
19
|
-
context: $context,
|
|
20
|
-
}),
|
|
21
|
-
...getBlockActions({
|
|
22
|
-
block: block,
|
|
23
|
-
rootState: $context.rootState,
|
|
24
|
-
rootSetState: $context.rootSetState,
|
|
25
|
-
localState: $context.localState,
|
|
26
|
-
context: $context.context,
|
|
27
|
-
}),
|
|
28
|
-
}
|
|
29
|
-
: {}}><slot /></svelte:component
|
|
29
|
+
<svelte:component this={Wrapper} {...wrapperProps} attributes={attributes()}
|
|
30
|
+
><slot /></svelte:component
|
|
30
31
|
>
|
|
@@ -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.24";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export const SDK_VERSION = "1.0.
|
|
1
|
+
export const SDK_VERSION = "1.0.24";
|
|
@@ -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';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from './tabs.svelte';
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
<script>import Blocks from "../../components/blocks/blocks.svelte";
|
|
2
|
+
export let defaultActiveTab = undefined;
|
|
3
|
+
export let tabs;
|
|
4
|
+
export let activeTabStyle = undefined;
|
|
5
|
+
export let tabHeaderLayout = undefined;
|
|
6
|
+
export let collapsible = undefined;
|
|
7
|
+
export let builderBlock;
|
|
8
|
+
export let builderContext;
|
|
9
|
+
export let builderComponents;
|
|
10
|
+
export let builderLinkComponent = undefined;
|
|
11
|
+
function stringifyStyles(stylesObj) {
|
|
12
|
+
let styles = "";
|
|
13
|
+
for (let key in stylesObj) {
|
|
14
|
+
const dashedKey = key.replace(/[A-Z]/g, function (match) {
|
|
15
|
+
return "-" + match.toLowerCase();
|
|
16
|
+
});
|
|
17
|
+
styles += dashedKey + ":" + stylesObj[key] + ";";
|
|
18
|
+
}
|
|
19
|
+
return styles;
|
|
20
|
+
}
|
|
21
|
+
function activeTabContent(active) {
|
|
22
|
+
return tabs && tabs[active].content;
|
|
23
|
+
}
|
|
24
|
+
function getActiveTabStyle(index) {
|
|
25
|
+
return activeTab === index ? activeTabStyle : {};
|
|
26
|
+
}
|
|
27
|
+
let activeTab = defaultActiveTab ? defaultActiveTab - 1 : 0;
|
|
28
|
+
</script>
|
|
29
|
+
|
|
30
|
+
<div>
|
|
31
|
+
<div
|
|
32
|
+
style={stringifyStyles({
|
|
33
|
+
display: "flex",
|
|
34
|
+
flexDirection: "row",
|
|
35
|
+
justifyContent: tabHeaderLayout || "flex-start",
|
|
36
|
+
overflow: "auto",
|
|
37
|
+
})}
|
|
38
|
+
class="builder-tabs-wrap"
|
|
39
|
+
>
|
|
40
|
+
{#each tabs as tab, index (index)}
|
|
41
|
+
<span
|
|
42
|
+
style={stringifyStyles(getActiveTabStyle(index))}
|
|
43
|
+
class={`builder-tab-wrap ${
|
|
44
|
+
activeTab === index ? "builder-tab-active" : ""
|
|
45
|
+
}`}
|
|
46
|
+
on:click={(event) => {
|
|
47
|
+
if (index === activeTab && collapsible) {
|
|
48
|
+
activeTab = -1;
|
|
49
|
+
} else {
|
|
50
|
+
activeTab = index;
|
|
51
|
+
}
|
|
52
|
+
}}
|
|
53
|
+
><Blocks
|
|
54
|
+
parent={builderBlock.id}
|
|
55
|
+
path={`component.options.tabs.${index}.label`}
|
|
56
|
+
blocks={tab.label}
|
|
57
|
+
context={builderContext}
|
|
58
|
+
registeredComponents={builderComponents}
|
|
59
|
+
linkComponent={builderLinkComponent}
|
|
60
|
+
/></span
|
|
61
|
+
>
|
|
62
|
+
{/each}
|
|
63
|
+
</div>
|
|
64
|
+
{#if activeTabContent(activeTab)}
|
|
65
|
+
<div>
|
|
66
|
+
<Blocks
|
|
67
|
+
parent={builderBlock.id}
|
|
68
|
+
path={`component.options.tabs.${activeTab}.content`}
|
|
69
|
+
blocks={activeTabContent(activeTab)}
|
|
70
|
+
context={builderContext}
|
|
71
|
+
registeredComponents={builderComponents}
|
|
72
|
+
linkComponent={builderLinkComponent}
|
|
73
|
+
/>
|
|
74
|
+
</div>
|
|
75
|
+
{/if}
|
|
76
|
+
</div>
|