@builder.io/sdk-svelte 1.0.27 → 1.0.29
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/browser/blocks/accordion/accordion.svelte +160 -0
- package/lib/browser/blocks/accordion/accordion.svelte.d.ts +24 -0
- package/lib/browser/blocks/accordion/accordion.types.d.ts +12 -0
- package/lib/browser/blocks/accordion/accordion.types.js +1 -0
- package/lib/browser/blocks/accordion/component-info.d.ts +2 -0
- package/lib/browser/blocks/accordion/component-info.js +123 -0
- package/lib/browser/blocks/accordion/helpers.d.ts +1 -0
- package/lib/browser/blocks/accordion/helpers.js +3 -0
- package/lib/browser/blocks/accordion/index.d.ts +1 -0
- package/lib/browser/blocks/accordion/index.js +1 -0
- package/lib/browser/blocks/columns/columns.svelte +1 -1
- package/lib/browser/blocks/form/form/form.svelte +3 -2
- package/lib/browser/blocks/symbol/symbol.svelte +1 -1
- package/lib/browser/blocks/tabs/tabs.svelte +13 -10
- package/lib/browser/blocks/tabs/tabs.svelte.d.ts +2 -2
- package/lib/browser/components/block/animator.d.ts +0 -1
- package/lib/browser/components/block/animator.js +3 -3
- package/lib/browser/components/block/block.helpers.js +2 -2
- package/lib/browser/components/block/block.svelte +1 -1
- package/lib/browser/components/block/components/block-styles.svelte +2 -2
- package/lib/browser/components/content/components/enable-editor.svelte +3 -3
- package/lib/browser/components/content/content.svelte +1 -1
- package/lib/browser/components/content-variants/content-variants.types.d.ts +1 -1
- package/lib/browser/constants/builder-registered-components.js +5 -0
- package/lib/browser/constants/sdk-version.d.ts +1 -1
- package/lib/browser/constants/sdk-version.js +1 -1
- package/lib/browser/functions/camel-to-kebab-case.d.ts +1 -1
- package/lib/browser/functions/camel-to-kebab-case.js +1 -1
- package/lib/edge/blocks/accordion/accordion.svelte +160 -0
- package/lib/edge/blocks/accordion/accordion.svelte.d.ts +24 -0
- package/lib/edge/blocks/accordion/accordion.types.d.ts +12 -0
- package/lib/edge/blocks/accordion/accordion.types.js +1 -0
- package/lib/edge/blocks/accordion/component-info.d.ts +2 -0
- package/lib/edge/blocks/accordion/component-info.js +123 -0
- package/lib/edge/blocks/accordion/helpers.d.ts +1 -0
- package/lib/edge/blocks/accordion/helpers.js +3 -0
- package/lib/edge/blocks/accordion/index.d.ts +1 -0
- package/lib/edge/blocks/accordion/index.js +1 -0
- package/lib/edge/blocks/columns/columns.svelte +1 -1
- package/lib/edge/blocks/form/form/form.svelte +3 -2
- package/lib/edge/blocks/symbol/symbol.svelte +1 -1
- package/lib/edge/blocks/tabs/tabs.svelte +13 -10
- package/lib/edge/blocks/tabs/tabs.svelte.d.ts +2 -2
- package/lib/edge/components/block/animator.d.ts +0 -1
- package/lib/edge/components/block/animator.js +3 -3
- package/lib/edge/components/block/block.helpers.js +2 -2
- package/lib/edge/components/block/block.svelte +1 -1
- package/lib/edge/components/block/components/block-styles.svelte +2 -2
- package/lib/edge/components/content/components/enable-editor.svelte +3 -3
- package/lib/edge/components/content/content.svelte +1 -1
- package/lib/edge/components/content-variants/content-variants.types.d.ts +1 -1
- package/lib/edge/constants/builder-registered-components.js +5 -0
- package/lib/edge/constants/sdk-version.d.ts +1 -1
- package/lib/edge/constants/sdk-version.js +1 -1
- package/lib/edge/functions/camel-to-kebab-case.d.ts +1 -1
- package/lib/edge/functions/camel-to-kebab-case.js +1 -1
- package/lib/node/blocks/accordion/accordion.svelte +160 -0
- package/lib/node/blocks/accordion/accordion.svelte.d.ts +24 -0
- package/lib/node/blocks/accordion/accordion.types.d.ts +12 -0
- package/lib/node/blocks/accordion/accordion.types.js +1 -0
- package/lib/node/blocks/accordion/component-info.d.ts +2 -0
- package/lib/node/blocks/accordion/component-info.js +123 -0
- package/lib/node/blocks/accordion/helpers.d.ts +1 -0
- package/lib/node/blocks/accordion/helpers.js +3 -0
- package/lib/node/blocks/accordion/index.d.ts +1 -0
- package/lib/node/blocks/accordion/index.js +1 -0
- package/lib/node/blocks/columns/columns.svelte +1 -1
- package/lib/node/blocks/form/form/form.svelte +3 -2
- package/lib/node/blocks/symbol/symbol.svelte +1 -1
- package/lib/node/blocks/tabs/tabs.svelte +13 -10
- package/lib/node/blocks/tabs/tabs.svelte.d.ts +2 -2
- package/lib/node/components/block/animator.d.ts +0 -1
- package/lib/node/components/block/animator.js +3 -3
- package/lib/node/components/block/block.helpers.js +2 -2
- package/lib/node/components/block/block.svelte +1 -1
- package/lib/node/components/block/components/block-styles.svelte +2 -2
- package/lib/node/components/content/components/enable-editor.svelte +3 -3
- package/lib/node/components/content/content.svelte +1 -1
- package/lib/node/components/content-variants/content-variants.types.d.ts +1 -1
- package/lib/node/constants/builder-registered-components.js +5 -0
- package/lib/node/constants/sdk-version.d.ts +1 -1
- package/lib/node/constants/sdk-version.js +1 -1
- package/lib/node/functions/camel-to-kebab-case.d.ts +1 -1
- package/lib/node/functions/camel-to-kebab-case.js +1 -1
- package/package.json +3 -3
- package/src/blocks/accordion/accordion.svelte +197 -0
- package/src/blocks/accordion/accordion.types.ts +12 -0
- package/src/blocks/accordion/component-info.ts +124 -0
- package/src/blocks/accordion/helpers.ts +3 -0
- package/src/blocks/accordion/index.ts +1 -0
- package/src/blocks/columns/columns.svelte +1 -1
- package/src/blocks/form/form/form.svelte +3 -4
- package/src/blocks/symbol/symbol.svelte +1 -1
- package/src/blocks/tabs/tabs.svelte +12 -10
- package/src/components/block/animator.ts +3 -3
- package/src/components/block/block.helpers.ts +2 -2
- package/src/components/block/block.svelte +1 -1
- package/src/components/block/components/block-styles.svelte +2 -2
- package/src/components/content/components/enable-editor.svelte +3 -3
- package/src/components/content/content.svelte +1 -1
- package/src/components/content-variants/content-variants.types.ts +1 -1
- package/src/constants/builder-registered-components.ts +5 -0
- package/src/constants/sdk-version.ts +1 -1
- package/src/functions/camel-to-kebab-case.ts +1 -1
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
<script>import Blocks from "../../components/blocks/index";
|
|
2
|
+
import "../../functions/camel-to-kebab-case";
|
|
3
|
+
import { convertOrderNumberToString } from "./helpers";
|
|
4
|
+
export let grid = undefined;
|
|
5
|
+
export let oneAtATime = undefined;
|
|
6
|
+
export let items;
|
|
7
|
+
export let gridRowWidth = undefined;
|
|
8
|
+
export let builderBlock;
|
|
9
|
+
export let builderContext;
|
|
10
|
+
export let builderComponents;
|
|
11
|
+
export let builderLinkComponent = undefined;
|
|
12
|
+
function stringifyStyles(stylesObj) {
|
|
13
|
+
let styles = "";
|
|
14
|
+
for (let key in stylesObj) {
|
|
15
|
+
const dashedKey = key.replace(/[A-Z]/g, function (match) {
|
|
16
|
+
return "-" + match.toLowerCase();
|
|
17
|
+
});
|
|
18
|
+
styles += dashedKey + ":" + stylesObj[key] + ";";
|
|
19
|
+
}
|
|
20
|
+
return styles;
|
|
21
|
+
}
|
|
22
|
+
function getAccordionTitleClassName(index) {
|
|
23
|
+
return `builder-accordion-title builder-accordion-title-${open.includes(index) ? "open" : "closed"}`;
|
|
24
|
+
}
|
|
25
|
+
function getAccordionDetailClassName(index) {
|
|
26
|
+
return `builder-accordion-detail builder-accordion-detail-${open.includes(index) ? "open" : "closed"}`;
|
|
27
|
+
}
|
|
28
|
+
function onClick(index) {
|
|
29
|
+
if (open.includes(index)) {
|
|
30
|
+
open = onlyOneAtATime() ? [] : open.filter((item) => item !== index);
|
|
31
|
+
}
|
|
32
|
+
else {
|
|
33
|
+
open = onlyOneAtATime() ? [index] : open.concat(index);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
$: onlyOneAtATime = () => {
|
|
37
|
+
return Boolean(grid || oneAtATime);
|
|
38
|
+
};
|
|
39
|
+
$: accordionStyles = () => {
|
|
40
|
+
const styles = {
|
|
41
|
+
display: "flex",
|
|
42
|
+
alignItems: "stretch",
|
|
43
|
+
flexDirection: "column",
|
|
44
|
+
...(grid && {
|
|
45
|
+
flexDirection: "row",
|
|
46
|
+
alignItems: "flex-start",
|
|
47
|
+
flexWrap: "wrap",
|
|
48
|
+
}),
|
|
49
|
+
};
|
|
50
|
+
return styles;
|
|
51
|
+
};
|
|
52
|
+
$: accordionTitleStyles = () => {
|
|
53
|
+
const shared = {
|
|
54
|
+
display: "flex",
|
|
55
|
+
flexDirection: "column",
|
|
56
|
+
};
|
|
57
|
+
const styles = {
|
|
58
|
+
...shared,
|
|
59
|
+
alignItems: "stretch",
|
|
60
|
+
cursor: "pointer",
|
|
61
|
+
};
|
|
62
|
+
return Object.fromEntries(Object.entries(styles).filter(([_, value]) => value !== undefined));
|
|
63
|
+
};
|
|
64
|
+
$: openGridItemOrder = () => {
|
|
65
|
+
let itemOrder = null;
|
|
66
|
+
const getOpenGridItemPosition = grid && open.length;
|
|
67
|
+
if (getOpenGridItemPosition && document) {
|
|
68
|
+
const openItemIndex = open[0];
|
|
69
|
+
const openItem = document.querySelector(`.builder-accordion-title[data-index="${openItemIndex}"]`);
|
|
70
|
+
let subjectItem = openItem;
|
|
71
|
+
itemOrder = openItemIndex;
|
|
72
|
+
if (subjectItem) {
|
|
73
|
+
let prevItemRect = subjectItem.getBoundingClientRect();
|
|
74
|
+
while ((subjectItem = subjectItem && subjectItem.nextElementSibling)) {
|
|
75
|
+
if (subjectItem) {
|
|
76
|
+
if (subjectItem.classList.contains("builder-accordion-detail")) {
|
|
77
|
+
continue;
|
|
78
|
+
}
|
|
79
|
+
const subjectItemRect = subjectItem.getBoundingClientRect();
|
|
80
|
+
if (subjectItemRect.left > prevItemRect.left) {
|
|
81
|
+
const index = parseInt(subjectItem.getAttribute("data-index") || "", 10);
|
|
82
|
+
if (!isNaN(index)) {
|
|
83
|
+
prevItemRect = subjectItemRect;
|
|
84
|
+
itemOrder = index;
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
else {
|
|
88
|
+
break;
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
if (typeof itemOrder === "number") {
|
|
95
|
+
itemOrder = itemOrder + 1;
|
|
96
|
+
}
|
|
97
|
+
return itemOrder;
|
|
98
|
+
};
|
|
99
|
+
$: accordionDetailStyles = () => {
|
|
100
|
+
const styles = {
|
|
101
|
+
...{
|
|
102
|
+
order: typeof openGridItemOrder() === "number"
|
|
103
|
+
? openGridItemOrder()
|
|
104
|
+
: undefined,
|
|
105
|
+
},
|
|
106
|
+
...(grid && {
|
|
107
|
+
width: "100%",
|
|
108
|
+
}),
|
|
109
|
+
};
|
|
110
|
+
return Object.fromEntries(Object.entries(styles).filter(([_, value]) => value !== undefined));
|
|
111
|
+
};
|
|
112
|
+
let open = [];
|
|
113
|
+
</script>
|
|
114
|
+
|
|
115
|
+
<div style={stringifyStyles(accordionStyles())} class="builder-accordion">
|
|
116
|
+
{#each items as item, index}
|
|
117
|
+
<div
|
|
118
|
+
style={stringifyStyles({
|
|
119
|
+
...accordionTitleStyles(),
|
|
120
|
+
width: grid ? gridRowWidth : undefined,
|
|
121
|
+
...{
|
|
122
|
+
order:
|
|
123
|
+
openGridItemOrder() !== null
|
|
124
|
+
? convertOrderNumberToString(index)
|
|
125
|
+
: convertOrderNumberToString(index + 1),
|
|
126
|
+
},
|
|
127
|
+
})}
|
|
128
|
+
class={getAccordionTitleClassName(index)}
|
|
129
|
+
data-index={index}
|
|
130
|
+
on:click={(event) => {
|
|
131
|
+
onClick(index);
|
|
132
|
+
}}
|
|
133
|
+
>
|
|
134
|
+
<Blocks
|
|
135
|
+
blocks={item.title}
|
|
136
|
+
path={`items.${index}.title`}
|
|
137
|
+
parent={builderBlock.id}
|
|
138
|
+
context={builderContext}
|
|
139
|
+
registeredComponents={builderComponents}
|
|
140
|
+
linkComponent={builderLinkComponent}
|
|
141
|
+
/>
|
|
142
|
+
</div>
|
|
143
|
+
|
|
144
|
+
{#if open.includes(index)}
|
|
145
|
+
<div
|
|
146
|
+
style={stringifyStyles(accordionDetailStyles())}
|
|
147
|
+
class={getAccordionDetailClassName(index)}
|
|
148
|
+
>
|
|
149
|
+
<Blocks
|
|
150
|
+
blocks={item.detail}
|
|
151
|
+
path={`items.${index}.detail`}
|
|
152
|
+
parent={builderBlock.id}
|
|
153
|
+
context={builderContext}
|
|
154
|
+
registeredComponents={builderComponents}
|
|
155
|
+
linkComponent={builderLinkComponent}
|
|
156
|
+
/>
|
|
157
|
+
</div>
|
|
158
|
+
{/if}
|
|
159
|
+
{/each}
|
|
160
|
+
</div>
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { SvelteComponent } from "svelte";
|
|
2
|
+
import type { AccordionProps } from "./accordion.types";
|
|
3
|
+
declare const __propDef: {
|
|
4
|
+
props: {
|
|
5
|
+
grid?: AccordionProps["grid"];
|
|
6
|
+
oneAtATime?: AccordionProps["oneAtATime"];
|
|
7
|
+
items: AccordionProps["items"];
|
|
8
|
+
gridRowWidth?: AccordionProps["gridRowWidth"];
|
|
9
|
+
builderBlock: AccordionProps["builderBlock"];
|
|
10
|
+
builderContext: AccordionProps["builderContext"];
|
|
11
|
+
builderComponents: AccordionProps["builderComponents"];
|
|
12
|
+
builderLinkComponent?: AccordionProps["builderLinkComponent"];
|
|
13
|
+
};
|
|
14
|
+
events: {
|
|
15
|
+
[evt: string]: CustomEvent<any>;
|
|
16
|
+
};
|
|
17
|
+
slots: {};
|
|
18
|
+
};
|
|
19
|
+
type AccordionProps_ = typeof __propDef.props;
|
|
20
|
+
export { AccordionProps_ as AccordionProps };
|
|
21
|
+
export type AccordionEvents = typeof __propDef.events;
|
|
22
|
+
export type AccordionSlots = typeof __propDef.slots;
|
|
23
|
+
export default class Accordion extends SvelteComponent<AccordionProps, AccordionEvents, AccordionSlots> {
|
|
24
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { BuilderBlock } from '../../types/builder-block';
|
|
2
|
+
import type { BuilderComponentsProp, BuilderDataProps, BuilderLinkComponentProp } from '../../types/builder-props';
|
|
3
|
+
export interface AccordionProps extends BuilderComponentsProp, BuilderLinkComponentProp, BuilderDataProps {
|
|
4
|
+
items: {
|
|
5
|
+
title: BuilderBlock[];
|
|
6
|
+
detail: BuilderBlock[];
|
|
7
|
+
}[];
|
|
8
|
+
oneAtATime?: boolean;
|
|
9
|
+
grid?: boolean;
|
|
10
|
+
gridRowWidth?: string;
|
|
11
|
+
useChildrenForItems?: boolean;
|
|
12
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
const defaultTitle = {
|
|
2
|
+
'@type': '@builder.io/sdk:Element',
|
|
3
|
+
layerName: 'Accordion item title',
|
|
4
|
+
responsiveStyles: {
|
|
5
|
+
large: {
|
|
6
|
+
marginTop: '10px',
|
|
7
|
+
position: 'relative',
|
|
8
|
+
display: 'flex',
|
|
9
|
+
alignItems: 'stretch',
|
|
10
|
+
flexDirection: 'column',
|
|
11
|
+
paddingBottom: '10px'
|
|
12
|
+
}
|
|
13
|
+
},
|
|
14
|
+
children: [{
|
|
15
|
+
'@type': '@builder.io/sdk:Element',
|
|
16
|
+
responsiveStyles: {
|
|
17
|
+
large: {
|
|
18
|
+
textAlign: 'left',
|
|
19
|
+
display: 'flex',
|
|
20
|
+
flexDirection: 'column'
|
|
21
|
+
}
|
|
22
|
+
},
|
|
23
|
+
component: {
|
|
24
|
+
name: 'Text',
|
|
25
|
+
options: {
|
|
26
|
+
text: 'I am an accordion title. Click me!'
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
}]
|
|
30
|
+
};
|
|
31
|
+
const defaultDetail = {
|
|
32
|
+
'@type': '@builder.io/sdk:Element',
|
|
33
|
+
layerName: 'Accordion item detail',
|
|
34
|
+
responsiveStyles: {
|
|
35
|
+
large: {
|
|
36
|
+
position: 'relative',
|
|
37
|
+
display: 'flex',
|
|
38
|
+
alignItems: 'stretch',
|
|
39
|
+
flexDirection: 'column',
|
|
40
|
+
marginTop: '10px',
|
|
41
|
+
paddingBottom: '10px'
|
|
42
|
+
}
|
|
43
|
+
},
|
|
44
|
+
children: [{
|
|
45
|
+
'@type': '@builder.io/sdk:Element',
|
|
46
|
+
responsiveStyles: {
|
|
47
|
+
large: {
|
|
48
|
+
paddingTop: '50px',
|
|
49
|
+
textAlign: 'left',
|
|
50
|
+
display: 'flex',
|
|
51
|
+
flexDirection: 'column',
|
|
52
|
+
paddingBottom: '50px'
|
|
53
|
+
}
|
|
54
|
+
},
|
|
55
|
+
component: {
|
|
56
|
+
name: 'Text',
|
|
57
|
+
options: {
|
|
58
|
+
text: 'I am an accordion detail, hello!'
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
}]
|
|
62
|
+
};
|
|
63
|
+
export const componentInfo = {
|
|
64
|
+
name: 'Builder:Accordion',
|
|
65
|
+
canHaveChildren: true,
|
|
66
|
+
image: 'https://cdn.builder.io/api/v1/image/assets%2FagZ9n5CUKRfbL9t6CaJOyVSK4Es2%2Ffab6c1fd3fe542408cbdec078bca7f35',
|
|
67
|
+
defaultStyles: {
|
|
68
|
+
display: 'flex',
|
|
69
|
+
flexDirection: 'column',
|
|
70
|
+
alignItems: 'stretch'
|
|
71
|
+
},
|
|
72
|
+
inputs: [{
|
|
73
|
+
name: 'items',
|
|
74
|
+
type: 'list',
|
|
75
|
+
broadcast: true,
|
|
76
|
+
subFields: [{
|
|
77
|
+
name: 'title',
|
|
78
|
+
type: 'uiBlocks',
|
|
79
|
+
hideFromUI: true,
|
|
80
|
+
defaultValue: [defaultTitle]
|
|
81
|
+
}, {
|
|
82
|
+
name: 'detail',
|
|
83
|
+
type: 'uiBlocks',
|
|
84
|
+
hideFromUI: true,
|
|
85
|
+
defaultValue: [defaultDetail]
|
|
86
|
+
}],
|
|
87
|
+
defaultValue: [{
|
|
88
|
+
title: [defaultTitle],
|
|
89
|
+
detail: [defaultDetail]
|
|
90
|
+
}, {
|
|
91
|
+
title: [defaultTitle],
|
|
92
|
+
detail: [defaultDetail]
|
|
93
|
+
}],
|
|
94
|
+
showIf: (options) => !options.get('useChildrenForItems')
|
|
95
|
+
}, {
|
|
96
|
+
name: 'oneAtATime',
|
|
97
|
+
helperText: 'Only allow opening one at a time (collapse all others when new item openned)',
|
|
98
|
+
type: 'boolean',
|
|
99
|
+
defaultValue: false
|
|
100
|
+
}, {
|
|
101
|
+
name: 'grid',
|
|
102
|
+
helperText: 'Display as a grid',
|
|
103
|
+
type: 'boolean',
|
|
104
|
+
defaultValue: false
|
|
105
|
+
}, {
|
|
106
|
+
name: 'gridRowWidth',
|
|
107
|
+
helperText: 'Display as a grid',
|
|
108
|
+
type: 'string',
|
|
109
|
+
showIf: (options) => options.get('grid'),
|
|
110
|
+
defaultValue: '25%'
|
|
111
|
+
}, {
|
|
112
|
+
name: 'useChildrenForItems',
|
|
113
|
+
type: 'boolean',
|
|
114
|
+
helperText: 'Use child elements for each slide, instead of the array. Useful for dynamically repeating items',
|
|
115
|
+
advanced: true,
|
|
116
|
+
defaultValue: false,
|
|
117
|
+
onChange: (options) => {
|
|
118
|
+
if (options.get('useChildrenForItems') === true) {
|
|
119
|
+
options.set('items', []);
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
}]
|
|
123
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const convertOrderNumberToString: (order: number) => string;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from './accordion.svelte';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from './accordion.svelte';
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
<script context="module"></script>
|
|
2
2
|
|
|
3
3
|
<script>import Blocks from "../../components/blocks/blocks.svelte";
|
|
4
|
+
import "../../components/dynamic-div.svelte";
|
|
4
5
|
import DynamicRenderer from "../../components/dynamic-renderer/dynamic-renderer.svelte";
|
|
5
6
|
import InlinedStyles from "../../components/inlined-styles.svelte";
|
|
6
7
|
import { getSizesForBreakpoints } from "../../constants/device-sizes";
|
|
@@ -9,7 +10,6 @@ import "../../functions/deopt";
|
|
|
9
10
|
import { getClassPropName } from "../../functions/get-class-prop-name";
|
|
10
11
|
import { mapStyleObjToStrIfNeeded } from "../../functions/get-style";
|
|
11
12
|
import { getColumnsClass } from "./helpers";
|
|
12
|
-
import "../../components/dynamic-div.svelte";
|
|
13
13
|
export let space = undefined;
|
|
14
14
|
export let columns = undefined;
|
|
15
15
|
export let stackColumnsAt = undefined;
|
|
@@ -58,12 +58,12 @@ function onSubmit(event) {
|
|
|
58
58
|
return;
|
|
59
59
|
}
|
|
60
60
|
event.preventDefault();
|
|
61
|
-
const el = event.currentTarget;
|
|
61
|
+
const el = event.currentTarget || event.target;
|
|
62
62
|
const headers = customHeaders || {};
|
|
63
63
|
let body;
|
|
64
64
|
const formData = new FormData(el);
|
|
65
65
|
// TODO: maybe support null
|
|
66
|
-
const formPairs = Array.from(
|
|
66
|
+
const formPairs = Array.from(el.querySelectorAll("input,select,textarea"))
|
|
67
67
|
.filter((el) => !!el.name)
|
|
68
68
|
.map((el) => {
|
|
69
69
|
let value;
|
|
@@ -247,6 +247,7 @@ let formErrorMessage = "";
|
|
|
247
247
|
on:submit={(event) => {
|
|
248
248
|
onSubmit(event);
|
|
249
249
|
}}
|
|
250
|
+
{...{}}
|
|
250
251
|
{...filterAttrs(attributes, "on:", false)}
|
|
251
252
|
use:setAttrs={filterAttrs(attributes, "on:", true)}
|
|
252
253
|
>
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
<script>import { onMount } from "svelte";
|
|
2
2
|
import ContentVariants from "../../components/content-variants/index";
|
|
3
3
|
import { filterAttrs } from "../helpers";
|
|
4
|
+
import "../../components/dynamic-div.svelte";
|
|
4
5
|
import { getClassPropName } from "../../functions/get-class-prop-name";
|
|
5
6
|
import { setAttrs } from "../helpers";
|
|
6
7
|
import { fetchSymbolContent } from "./symbol.helpers";
|
|
7
|
-
import "../../components/dynamic-div.svelte";
|
|
8
8
|
export let symbol = undefined;
|
|
9
9
|
export let attributes = undefined;
|
|
10
10
|
export let dynamic = undefined;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
<script>import Blocks from "../../components/blocks/blocks.svelte";
|
|
2
2
|
export let defaultActiveTab = undefined;
|
|
3
3
|
export let tabs;
|
|
4
|
-
export let activeTabStyle = undefined;
|
|
5
|
-
export let tabHeaderLayout = undefined;
|
|
6
4
|
export let collapsible = undefined;
|
|
5
|
+
export let tabHeaderLayout = undefined;
|
|
6
|
+
export let activeTabStyle = undefined;
|
|
7
7
|
export let builderBlock;
|
|
8
8
|
export let builderContext;
|
|
9
9
|
export let builderComponents;
|
|
@@ -21,8 +21,13 @@ function stringifyStyles(stylesObj) {
|
|
|
21
21
|
function activeTabContent(active) {
|
|
22
22
|
return tabs && tabs[active].content;
|
|
23
23
|
}
|
|
24
|
-
function
|
|
25
|
-
|
|
24
|
+
function onClick(index) {
|
|
25
|
+
if (index === activeTab && collapsible) {
|
|
26
|
+
activeTab = -1;
|
|
27
|
+
}
|
|
28
|
+
else {
|
|
29
|
+
activeTab = index;
|
|
30
|
+
}
|
|
26
31
|
}
|
|
27
32
|
let activeTab = defaultActiveTab ? defaultActiveTab - 1 : 0;
|
|
28
33
|
</script>
|
|
@@ -39,16 +44,14 @@ let activeTab = defaultActiveTab ? defaultActiveTab - 1 : 0;
|
|
|
39
44
|
>
|
|
40
45
|
{#each tabs as tab, index (index)}
|
|
41
46
|
<span
|
|
42
|
-
style={stringifyStyles(
|
|
47
|
+
style={stringifyStyles({
|
|
48
|
+
...(activeTab === index ? activeTabStyle : {}),
|
|
49
|
+
})}
|
|
43
50
|
class={`builder-tab-wrap ${
|
|
44
51
|
activeTab === index ? "builder-tab-active" : ""
|
|
45
52
|
}`}
|
|
46
53
|
on:click={(event) => {
|
|
47
|
-
|
|
48
|
-
activeTab = -1;
|
|
49
|
-
} else {
|
|
50
|
-
activeTab = index;
|
|
51
|
-
}
|
|
54
|
+
onClick(index);
|
|
52
55
|
}}
|
|
53
56
|
><Blocks
|
|
54
57
|
parent={builderBlock.id}
|
|
@@ -4,9 +4,9 @@ declare const __propDef: {
|
|
|
4
4
|
props: {
|
|
5
5
|
defaultActiveTab?: TabsProps["defaultActiveTab"];
|
|
6
6
|
tabs: TabsProps["tabs"];
|
|
7
|
-
activeTabStyle?: TabsProps["activeTabStyle"];
|
|
8
|
-
tabHeaderLayout?: TabsProps["tabHeaderLayout"];
|
|
9
7
|
collapsible?: TabsProps["collapsible"];
|
|
8
|
+
tabHeaderLayout?: TabsProps["tabHeaderLayout"];
|
|
9
|
+
activeTabStyle?: TabsProps["activeTabStyle"];
|
|
10
10
|
builderBlock: TabsProps["builderBlock"];
|
|
11
11
|
builderContext: TabsProps["builderContext"];
|
|
12
12
|
builderComponents: TabsProps["builderComponents"];
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import type { BuilderAnimation } from '../../types/builder-block';
|
|
2
|
-
export declare const camelCaseToKebabCase: (str?: string) => string;
|
|
3
2
|
export declare function bindAnimations(animations: BuilderAnimation[]): void;
|
|
4
3
|
export declare function triggerAnimation(animation: BuilderAnimation): void;
|
|
5
4
|
export declare function bindScrollInViewAnimation(animation: BuilderAnimation): void;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { camelToKebabCase } from '../../functions/camel-to-kebab-case';
|
|
1
2
|
// eslint-disable-next-line @typescript-eslint/ban-types
|
|
2
3
|
function throttle(func, wait, options = {}) {
|
|
3
4
|
let context;
|
|
@@ -54,7 +55,6 @@ function assign(target, ..._args) {
|
|
|
54
55
|
}
|
|
55
56
|
return to;
|
|
56
57
|
}
|
|
57
|
-
export const camelCaseToKebabCase = (str) => str ? str.replace(/([A-Z])/g, g => `-${g[0].toLowerCase()}`) : '';
|
|
58
58
|
export function bindAnimations(animations) {
|
|
59
59
|
for (const animation of animations) {
|
|
60
60
|
switch (animation.trigger) {
|
|
@@ -120,7 +120,7 @@ export function triggerAnimation(animation) {
|
|
|
120
120
|
// TODO: only include properties explicitly set in the animation
|
|
121
121
|
// using Object.keys(styles)
|
|
122
122
|
setTimeout(() => {
|
|
123
|
-
element.style.transition = `all ${animation.duration}s ${
|
|
123
|
+
element.style.transition = `all ${animation.duration}s ${camelToKebabCase(animation.easing)}`;
|
|
124
124
|
if (animation.delay) {
|
|
125
125
|
element.style.transitionDelay = animation.delay + 's';
|
|
126
126
|
}
|
|
@@ -193,7 +193,7 @@ export function bindScrollInViewAnimation(animation) {
|
|
|
193
193
|
attachDefaultState();
|
|
194
194
|
// TODO: queue/batch these timeouts!
|
|
195
195
|
setTimeout(() => {
|
|
196
|
-
element.style.transition = `all ${animation.duration}s ${
|
|
196
|
+
element.style.transition = `all ${animation.duration}s ${camelToKebabCase(animation.easing)}`;
|
|
197
197
|
if (animation.delay) {
|
|
198
198
|
element.style.transitionDelay = animation.delay + 's';
|
|
199
199
|
}
|
|
@@ -74,8 +74,8 @@ export const getInheritedStyles = ({ block, context }) => {
|
|
|
74
74
|
return extractTextStyles(style);
|
|
75
75
|
};
|
|
76
76
|
export const shouldPassLinkComponent = (block) => {
|
|
77
|
-
return block && (block.isRSC || ['Core:Button', 'Symbol', 'Columns', 'Form:Form', 'Builder: Tabs'].includes(block.name));
|
|
77
|
+
return block && (block.isRSC || ['Core:Button', 'Symbol', 'Columns', 'Form:Form', 'Builder: Tabs', 'Builder:Accordion'].includes(block.name));
|
|
78
78
|
};
|
|
79
79
|
export const shouldPassRegisteredComponents = (block) => {
|
|
80
|
-
return block && (block.isRSC || ['Symbol', 'Columns', 'Form:Form', 'Builder: Tabs'].includes(block.name));
|
|
80
|
+
return block && (block.isRSC || ['Symbol', 'Columns', 'Form:Form', 'Builder: Tabs', 'Builder:Accordion'].includes(block.name));
|
|
81
81
|
};
|
|
@@ -3,13 +3,13 @@
|
|
|
3
3
|
<script>import { onMount } from "svelte";
|
|
4
4
|
import { getBlockComponentOptions } from "../../functions/get-block-component-options";
|
|
5
5
|
import { getProcessedBlock } from "../../functions/get-processed-block";
|
|
6
|
+
import "../dynamic-div.svelte";
|
|
6
7
|
import { bindAnimations } from "./animator";
|
|
7
8
|
import { getComponent, getRepeatItemData, shouldPassLinkComponent, shouldPassRegisteredComponents, } from "./block.helpers";
|
|
8
9
|
import BlockStyles from "./components/block-styles.svelte";
|
|
9
10
|
import BlockWrapper from "./components/block-wrapper.svelte";
|
|
10
11
|
import ComponentRef from "./components/component-ref/component-ref.svelte";
|
|
11
12
|
import RepeatedBlock from "./components/repeated-block.svelte";
|
|
12
|
-
import "../dynamic-div.svelte";
|
|
13
13
|
export let block;
|
|
14
14
|
export let context;
|
|
15
15
|
export let registeredComponents;
|
|
@@ -2,11 +2,11 @@
|
|
|
2
2
|
|
|
3
3
|
<script>import { getMaxWidthQueryForSize, getSizesForBreakpoints, } from "../../../constants/device-sizes";
|
|
4
4
|
import { TARGET } from "../../../constants/target";
|
|
5
|
+
import { camelToKebabCase } from "../../../functions/camel-to-kebab-case";
|
|
5
6
|
import { getProcessedBlock } from "../../../functions/get-processed-block";
|
|
6
7
|
import { createCssClass } from "../../../helpers/css";
|
|
7
8
|
import { checkIsDefined } from "../../../helpers/nullable";
|
|
8
9
|
import InlinedStyles from "../../inlined-styles.svelte";
|
|
9
|
-
import { camelCaseToKebabCase } from "../animator";
|
|
10
10
|
export let block;
|
|
11
11
|
export let context;
|
|
12
12
|
$: canShowBlock = () => {
|
|
@@ -76,7 +76,7 @@ $: css = () => {
|
|
|
76
76
|
className: `${className}:hover`,
|
|
77
77
|
styles: {
|
|
78
78
|
...hoverStyles,
|
|
79
|
-
transition: `all ${hoverAnimation.duration}s ${
|
|
79
|
+
transition: `all ${hoverAnimation.duration}s ${camelToKebabCase(hoverAnimation.easing)}`,
|
|
80
80
|
transitionDelay: hoverAnimation.delay
|
|
81
81
|
? `${hoverAnimation.delay}s`
|
|
82
82
|
: "0s",
|
|
@@ -18,8 +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
21
|
import "../../dynamic-div.svelte";
|
|
22
|
+
import { getWrapperClassName } from "./styles.helpers";
|
|
23
23
|
export let builderContextSignal;
|
|
24
24
|
export let canTrack = undefined;
|
|
25
25
|
export let apiKey;
|
|
@@ -201,7 +201,7 @@ function elementRef_onIniteditingbldr(event) {
|
|
|
201
201
|
function elementRef_onInitpreviewingbldr(event) {
|
|
202
202
|
const searchParams = new URL(location.href).searchParams;
|
|
203
203
|
const searchParamPreviewModel = searchParams.get("builder.preview");
|
|
204
|
-
const searchParamPreviewId = searchParams.get(`builder.
|
|
204
|
+
const searchParamPreviewId = searchParams.get(`builder.overrides.${searchParamPreviewModel}`);
|
|
205
205
|
const previewApiKey = searchParams.get("apiKey") || searchParams.get("builder.space");
|
|
206
206
|
/**
|
|
207
207
|
* Make sure that:
|
|
@@ -272,7 +272,7 @@ onMount(() => {
|
|
|
272
272
|
});
|
|
273
273
|
onMount(() => {
|
|
274
274
|
if (!apiKey) {
|
|
275
|
-
logger.error("No API key provided to `
|
|
275
|
+
logger.error("No API key provided to `Content` component. This can cause issues. Please provide an API key using the `apiKey` prop.");
|
|
276
276
|
}
|
|
277
277
|
evaluateJsCode();
|
|
278
278
|
runHttpRequests();
|
|
@@ -6,12 +6,12 @@ import ComponentsContext from "../../context/components.context";
|
|
|
6
6
|
import { serializeComponentInfo } from "../../functions/register-component";
|
|
7
7
|
import Blocks from "../blocks/blocks.svelte";
|
|
8
8
|
import { getUpdateVariantVisibilityScript } from "../content-variants/helpers";
|
|
9
|
+
import "../dynamic-div.svelte";
|
|
9
10
|
import InlinedScript from "../inlined-script.svelte";
|
|
10
11
|
import EnableEditor from "./components/enable-editor.svelte";
|
|
11
12
|
import ContentStyles from "./components/styles.svelte";
|
|
12
13
|
import { getContentInitialValue, getRootStateInitialValue, } from "./content.helpers";
|
|
13
14
|
import "./wrap-component-ref";
|
|
14
|
-
import "../dynamic-div.svelte";
|
|
15
15
|
export let content = undefined;
|
|
16
16
|
export let customComponents = undefined;
|
|
17
17
|
export let data = undefined;
|
|
@@ -22,7 +22,7 @@ export interface ContentVariantsPrps {
|
|
|
22
22
|
*/
|
|
23
23
|
context?: BuilderRenderContext;
|
|
24
24
|
/**
|
|
25
|
-
* Your API Key: needed to dynamically fetch symbols (required).
|
|
25
|
+
* Your API Key: needed to enable visual editing, and to dynamically fetch symbols (required).
|
|
26
26
|
*/
|
|
27
27
|
apiKey: string;
|
|
28
28
|
apiVersion?: ApiVersion;
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { componentInfo as accordionComponentInfo } from '../blocks/accordion/component-info';
|
|
2
|
+
import { default as Accordion } from '../blocks/accordion/index';
|
|
1
3
|
import { componentInfo as buttonComponentInfo } from '../blocks/button/component-info';
|
|
2
4
|
import { default as Button } from '../blocks/button/index';
|
|
3
5
|
import { componentInfo as columnsComponentInfo } from '../blocks/columns/component-info';
|
|
@@ -49,4 +51,7 @@ export const getDefaultRegisteredComponents = () => [{
|
|
|
49
51
|
}, ...(TARGET === 'rsc' ? [] : [{
|
|
50
52
|
component: Tabs,
|
|
51
53
|
...tabsComponentInfo
|
|
54
|
+
}, {
|
|
55
|
+
component: Accordion,
|
|
56
|
+
...accordionComponentInfo
|
|
52
57
|
}]), ...getExtraComponents()];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const SDK_VERSION = "1.0.
|
|
1
|
+
export declare const SDK_VERSION = "1.0.29";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export const SDK_VERSION = "1.0.
|
|
1
|
+
export const SDK_VERSION = "1.0.29";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const camelToKebabCase: (
|
|
1
|
+
export declare const camelToKebabCase: (str?: string) => string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export const camelToKebabCase = (
|
|
1
|
+
export const camelToKebabCase = (str) => str ? str.replace(/([a-z0-9]|(?=[A-Z]))([A-Z])/g, '$1-$2').toLowerCase() : '';
|