@builder.io/sdk-solid 3.0.1 → 3.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +12 -1
- package/lib/browser/dev.js +108 -67
- package/lib/browser/dev.jsx +152 -115
- package/lib/browser/index.js +108 -67
- package/lib/browser/index.jsx +152 -115
- package/lib/edge/dev.js +109 -70
- package/lib/edge/dev.jsx +153 -118
- package/lib/edge/index.js +109 -70
- package/lib/edge/index.jsx +153 -118
- package/lib/node/dev.js +108 -67
- package/lib/node/dev.jsx +152 -115
- package/lib/node/index.js +108 -67
- package/lib/node/index.jsx +152 -115
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -124,6 +124,16 @@ interface Input {
|
|
|
124
124
|
/** @hidden */
|
|
125
125
|
autoFocus?: boolean;
|
|
126
126
|
subFields?: Input[];
|
|
127
|
+
/**
|
|
128
|
+
* When input is of `type` `object`, use this field to collapse multiple inputs
|
|
129
|
+
* in the Visual Editor by default and preserve screen space.
|
|
130
|
+
*/
|
|
131
|
+
folded?: boolean;
|
|
132
|
+
/**
|
|
133
|
+
* When input is of `type` `object`, provide guidance in the Visual Editor
|
|
134
|
+
* on how to edit this object's contents.
|
|
135
|
+
*/
|
|
136
|
+
keysHelperText?: string;
|
|
127
137
|
/**
|
|
128
138
|
* Additional text to render in the UI to give guidance on how to use this
|
|
129
139
|
*
|
|
@@ -263,6 +273,7 @@ interface BuilderContent extends BuilderContentVariation {
|
|
|
263
273
|
published?: 'published' | 'draft' | 'archived';
|
|
264
274
|
modelId?: string;
|
|
265
275
|
priority?: number;
|
|
276
|
+
firstPublished?: number;
|
|
266
277
|
lastUpdated?: number;
|
|
267
278
|
startDate?: number;
|
|
268
279
|
endDate?: number;
|
|
@@ -1093,4 +1104,4 @@ declare const _processContentResult: (options: GetContentOptions, content: Conte
|
|
|
1093
1104
|
*/
|
|
1094
1105
|
declare function fetchEntries(options: GetContentOptions): Promise<BuilderContent[]>;
|
|
1095
1106
|
|
|
1096
|
-
export { Blocks, BlocksProps, BuilderBlock, BuilderContent, _default as BuilderContext, Button, ButtonProps, ColumnProps, Columns, ComponentInfo, ContentVariants as Content, ContentVariantsPrps as ContentProps, FragmentComponent as Fragment, FragmentProps, GetContentOptions, Image, ImageProps, InsertMenuConfig, InsertMenuItem, RegisteredComponent, SectionComponent as Section, SectionProps, Settings, Symbol, SymbolProps, Text, TextProps, Video, VideoProps, _processContentResult, createRegisterComponentMessage, fetchBuilderProps, fetchEntries, fetchOneEntry, getBuilderSearchParams, isEditing, isPreviewing, register, setEditorSettings, subscribeToEditor, track };
|
|
1107
|
+
export { Blocks, BlocksProps, BuilderBlock, BuilderContent, _default as BuilderContext, BuilderContextInterface, Button, ButtonProps, ColumnProps, Columns, ComponentInfo, ContentVariants as Content, ContentVariantsPrps as ContentProps, FragmentComponent as Fragment, FragmentProps, GetContentOptions, Image, ImageProps, InsertMenuConfig, InsertMenuItem, RegisteredComponent, RegisteredComponents, SectionComponent as Section, SectionProps, Settings, Symbol, SymbolProps, Text, TextProps, Video, VideoProps, _processContentResult, createRegisterComponentMessage, fetchBuilderProps, fetchEntries, fetchOneEntry, getBuilderSearchParams, isEditing, isPreviewing, register, setEditorSettings, subscribeToEditor, track };
|
package/lib/browser/dev.js
CHANGED
|
@@ -119,23 +119,6 @@ var builder_context_default = createContext({
|
|
|
119
119
|
});
|
|
120
120
|
var components_context_default = createContext({ registeredComponents: {} });
|
|
121
121
|
|
|
122
|
-
// src/functions/get-block-component-options.ts
|
|
123
|
-
function getBlockComponentOptions(block) {
|
|
124
|
-
return {
|
|
125
|
-
...block.component?.options,
|
|
126
|
-
...block.options
|
|
127
|
-
};
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
// src/helpers/omit.ts
|
|
131
|
-
function omit(obj, ...values) {
|
|
132
|
-
const newObject = Object.assign({}, obj);
|
|
133
|
-
for (const key of values) {
|
|
134
|
-
delete newObject[key];
|
|
135
|
-
}
|
|
136
|
-
return newObject;
|
|
137
|
-
}
|
|
138
|
-
|
|
139
122
|
// src/helpers/logger.ts
|
|
140
123
|
var MSG_PREFIX = "[Builder.io]: ";
|
|
141
124
|
var logger = {
|
|
@@ -402,6 +385,38 @@ function evaluate({
|
|
|
402
385
|
}
|
|
403
386
|
}
|
|
404
387
|
|
|
388
|
+
// src/functions/get-block-component-options.ts
|
|
389
|
+
function getBlockComponentOptions(block, context) {
|
|
390
|
+
return {
|
|
391
|
+
...block.component?.options,
|
|
392
|
+
...block.options,
|
|
393
|
+
...evaluateTextComponentTextOption(block, context)
|
|
394
|
+
};
|
|
395
|
+
}
|
|
396
|
+
var evaluateTextComponentTextOption = (block, context) => {
|
|
397
|
+
if (block.component?.name === "Text" && block.component.options?.text && typeof block.component.options.text === "string") {
|
|
398
|
+
return {
|
|
399
|
+
...block.component.options,
|
|
400
|
+
text: block.component.options.text.replace(/{{([^}]+)}}/g, (_match, group) => evaluate({
|
|
401
|
+
code: group,
|
|
402
|
+
context,
|
|
403
|
+
localState: context.localState,
|
|
404
|
+
rootState: context.rootState,
|
|
405
|
+
rootSetState: context.rootSetState
|
|
406
|
+
}))
|
|
407
|
+
};
|
|
408
|
+
}
|
|
409
|
+
};
|
|
410
|
+
|
|
411
|
+
// src/helpers/omit.ts
|
|
412
|
+
function omit(obj, ...values) {
|
|
413
|
+
const newObject = Object.assign({}, obj);
|
|
414
|
+
for (const key of values) {
|
|
415
|
+
delete newObject[key];
|
|
416
|
+
}
|
|
417
|
+
return newObject;
|
|
418
|
+
}
|
|
419
|
+
|
|
405
420
|
// src/functions/traverse.ts
|
|
406
421
|
function traverse(obj, callback, parent2 = null, key = null, visited = /* @__PURE__ */ new WeakSet()) {
|
|
407
422
|
if (obj == null || typeof obj !== "object") {
|
|
@@ -566,24 +581,19 @@ var evaluateBindings = ({
|
|
|
566
581
|
function getProcessedBlock({
|
|
567
582
|
block,
|
|
568
583
|
context,
|
|
569
|
-
shouldEvaluateBindings,
|
|
570
584
|
localState,
|
|
571
585
|
rootState,
|
|
572
586
|
rootSetState
|
|
573
587
|
}) {
|
|
574
588
|
let transformedBlock = resolveLocalizedValues(block, rootState.locale);
|
|
575
589
|
transformedBlock = transformBlock(transformedBlock);
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
});
|
|
584
|
-
} else {
|
|
585
|
-
return transformedBlock;
|
|
586
|
-
}
|
|
590
|
+
return evaluateBindings({
|
|
591
|
+
block: transformedBlock,
|
|
592
|
+
localState,
|
|
593
|
+
rootState,
|
|
594
|
+
rootSetState,
|
|
595
|
+
context
|
|
596
|
+
});
|
|
587
597
|
}
|
|
588
598
|
|
|
589
599
|
// src/functions/camel-to-kebab-case.ts
|
|
@@ -1363,8 +1373,7 @@ function Block(props) {
|
|
|
1363
1373
|
localState: props.context.localState,
|
|
1364
1374
|
rootState: props.context.rootState,
|
|
1365
1375
|
rootSetState: props.context.rootSetState,
|
|
1366
|
-
context: props.context.context
|
|
1367
|
-
shouldEvaluateBindings: true
|
|
1376
|
+
context: props.context.context
|
|
1368
1377
|
});
|
|
1369
1378
|
return blockToUse;
|
|
1370
1379
|
});
|
|
@@ -1401,7 +1410,7 @@ function Block(props) {
|
|
|
1401
1410
|
blockChildren: processedBlock().children ?? [],
|
|
1402
1411
|
componentRef: blockComponent()?.component,
|
|
1403
1412
|
componentOptions: {
|
|
1404
|
-
...getBlockComponentOptions(processedBlock()),
|
|
1413
|
+
...getBlockComponentOptions(processedBlock(), props.context),
|
|
1405
1414
|
...provideBuilderBlock(blockComponent(), processedBlock()),
|
|
1406
1415
|
...provideBuilderContext(blockComponent(), props.context),
|
|
1407
1416
|
...provideLinkComponent(blockComponent(), props.linkComponent),
|
|
@@ -1607,7 +1616,7 @@ function Block(props) {
|
|
|
1607
1616
|
});
|
|
1608
1617
|
}
|
|
1609
1618
|
var block_default = Block;
|
|
1610
|
-
var _tmpl$2 = /* @__PURE__ */ template(`<style>.dynamic-
|
|
1619
|
+
var _tmpl$2 = /* @__PURE__ */ template(`<style>.dynamic-3c4beb0c {
|
|
1611
1620
|
display: flex;
|
|
1612
1621
|
flex-direction: column;
|
|
1613
1622
|
align-items: stretch;
|
|
@@ -1650,7 +1659,7 @@ function BlocksWrapper(props) {
|
|
|
1650
1659
|
});
|
|
1651
1660
|
return [createComponent(Dynamic, mergeProps({
|
|
1652
1661
|
get ["class"]() {
|
|
1653
|
-
return className() + " dynamic-
|
|
1662
|
+
return className() + " dynamic-3c4beb0c";
|
|
1654
1663
|
},
|
|
1655
1664
|
ref(r$) {
|
|
1656
1665
|
const _ref$ = blocksWrapperRef;
|
|
@@ -1749,7 +1758,7 @@ var getColumnsClass = (id) => {
|
|
|
1749
1758
|
|
|
1750
1759
|
// src/blocks/columns/columns.tsx
|
|
1751
1760
|
var _tmpl$3 = /* @__PURE__ */ template(`<div>`);
|
|
1752
|
-
var _tmpl$22 = /* @__PURE__ */ template(`<style>.div-
|
|
1761
|
+
var _tmpl$22 = /* @__PURE__ */ template(`<style>.div-3e5f33a4 {
|
|
1753
1762
|
display: flex;
|
|
1754
1763
|
line-height: normal;
|
|
1755
1764
|
}`);
|
|
@@ -1878,7 +1887,7 @@ function Columns(props) {
|
|
|
1878
1887
|
const _el$ = _tmpl$3();
|
|
1879
1888
|
spread(_el$, mergeProps({
|
|
1880
1889
|
get ["class"]() {
|
|
1881
|
-
return getColumnsClass(props.builderBlock?.id) + " div-
|
|
1890
|
+
return getColumnsClass(props.builderBlock?.id) + " div-3e5f33a4";
|
|
1882
1891
|
},
|
|
1883
1892
|
get style() {
|
|
1884
1893
|
return columnsCssVars();
|
|
@@ -2003,16 +2012,16 @@ function getSrcSet(url) {
|
|
|
2003
2012
|
// src/blocks/image/image.tsx
|
|
2004
2013
|
var _tmpl$5 = /* @__PURE__ */ template(`<source type=image/webp>`);
|
|
2005
2014
|
var _tmpl$23 = /* @__PURE__ */ template(`<picture><img>`);
|
|
2006
|
-
var _tmpl$32 = /* @__PURE__ */ template(`<div class="builder-image-sizer div-
|
|
2007
|
-
var _tmpl$42 = /* @__PURE__ */ template(`<div class=div-
|
|
2008
|
-
var _tmpl$52 = /* @__PURE__ */ template(`<style>.img-
|
|
2015
|
+
var _tmpl$32 = /* @__PURE__ */ template(`<div class="builder-image-sizer div-56e07140">`);
|
|
2016
|
+
var _tmpl$42 = /* @__PURE__ */ template(`<div class=div-56e07140-2>`);
|
|
2017
|
+
var _tmpl$52 = /* @__PURE__ */ template(`<style>.img-56e07140 {
|
|
2009
2018
|
opacity: 1;
|
|
2010
2019
|
transition: opacity 0.2s ease-in-out;
|
|
2011
|
-
}.div-
|
|
2020
|
+
}.div-56e07140 {
|
|
2012
2021
|
width: 100%;
|
|
2013
2022
|
pointer-events: none;
|
|
2014
2023
|
font-size: 0;
|
|
2015
|
-
}.div-
|
|
2024
|
+
}.div-56e07140-2 {
|
|
2016
2025
|
display: flex;
|
|
2017
2026
|
flex-direction: column;
|
|
2018
2027
|
align-items: stretch;
|
|
@@ -2077,7 +2086,7 @@ function Image(props) {
|
|
|
2077
2086
|
}
|
|
2078
2087
|
}), _el$3);
|
|
2079
2088
|
effect((_p$) => {
|
|
2080
|
-
const _v$ = "builder-image" + (props.className ? " " + props.className : "") + " img-
|
|
2089
|
+
const _v$ = "builder-image" + (props.className ? " " + props.className : "") + " img-56e07140", _v$2 = props.highPriority ? "eager" : "lazy", _v$3 = props.highPriority ? "high" : "auto", _v$4 = props.altText, _v$5 = props.altText ? void 0 : "presentation", _v$6 = {
|
|
2081
2090
|
"object-position": props.backgroundPosition || "center",
|
|
2082
2091
|
"object-fit": props.backgroundSize || "cover",
|
|
2083
2092
|
...aspectRatioCss()
|
|
@@ -3481,26 +3490,10 @@ var componentInfo10 = {
|
|
|
3481
3490
|
};
|
|
3482
3491
|
var _tmpl$10 = /* @__PURE__ */ template(`<div class=builder-text>`);
|
|
3483
3492
|
function Text(props) {
|
|
3484
|
-
const processedText = createMemo(() => {
|
|
3485
|
-
const context = props.builderContext;
|
|
3486
|
-
const {
|
|
3487
|
-
context: contextContext,
|
|
3488
|
-
localState,
|
|
3489
|
-
rootState,
|
|
3490
|
-
rootSetState
|
|
3491
|
-
} = context;
|
|
3492
|
-
return String(props.text?.toString() || "").replace(/{{([^}]+)}}/g, (match, group) => evaluate({
|
|
3493
|
-
code: group,
|
|
3494
|
-
context: contextContext,
|
|
3495
|
-
localState,
|
|
3496
|
-
rootState,
|
|
3497
|
-
rootSetState
|
|
3498
|
-
}));
|
|
3499
|
-
});
|
|
3500
3493
|
return (() => {
|
|
3501
3494
|
const _el$ = _tmpl$10();
|
|
3502
3495
|
_el$.style.setProperty("outline", "none");
|
|
3503
|
-
effect(() => _el$.innerHTML =
|
|
3496
|
+
effect(() => _el$.innerHTML = props.text?.toString() || "");
|
|
3504
3497
|
return _el$;
|
|
3505
3498
|
})();
|
|
3506
3499
|
}
|
|
@@ -3909,9 +3902,9 @@ function logFetch(url) {
|
|
|
3909
3902
|
}
|
|
3910
3903
|
|
|
3911
3904
|
// src/blocks/form/form/form.tsx
|
|
3912
|
-
var _tmpl$13 = /* @__PURE__ */ template(`<pre class="builder-form-error-text pre-
|
|
3905
|
+
var _tmpl$13 = /* @__PURE__ */ template(`<pre class="builder-form-error-text pre-27d18614">`);
|
|
3913
3906
|
var _tmpl$26 = /* @__PURE__ */ template(`<form>`);
|
|
3914
|
-
var _tmpl$34 = /* @__PURE__ */ template(`<style>.pre-
|
|
3907
|
+
var _tmpl$34 = /* @__PURE__ */ template(`<style>.pre-27d18614 {
|
|
3915
3908
|
padding: 10px;
|
|
3916
3909
|
color: red;
|
|
3917
3910
|
text-align: center;
|
|
@@ -4885,7 +4878,7 @@ function getPreviewContent(_searchParams) {
|
|
|
4885
4878
|
}
|
|
4886
4879
|
|
|
4887
4880
|
// src/constants/sdk-version.ts
|
|
4888
|
-
var SDK_VERSION = "3.0.
|
|
4881
|
+
var SDK_VERSION = "3.0.3";
|
|
4889
4882
|
|
|
4890
4883
|
// src/helpers/sdk-headers.ts
|
|
4891
4884
|
var getSdkHeaders = () => ({
|
|
@@ -4950,6 +4943,23 @@ function flattenMongoQuery(obj, _current, _res = {}) {
|
|
|
4950
4943
|
}
|
|
4951
4944
|
return _res;
|
|
4952
4945
|
}
|
|
4946
|
+
function unflatten(obj) {
|
|
4947
|
+
const result = {};
|
|
4948
|
+
for (const key in obj) {
|
|
4949
|
+
const parts = key.split(".");
|
|
4950
|
+
let current = result;
|
|
4951
|
+
for (let i = 0; i < parts.length; i++) {
|
|
4952
|
+
const part = parts[i];
|
|
4953
|
+
if (i === parts.length - 1) {
|
|
4954
|
+
current[part] = obj[key];
|
|
4955
|
+
} else {
|
|
4956
|
+
current[part] = current[part] || {};
|
|
4957
|
+
current = current[part];
|
|
4958
|
+
}
|
|
4959
|
+
}
|
|
4960
|
+
}
|
|
4961
|
+
return result;
|
|
4962
|
+
}
|
|
4953
4963
|
|
|
4954
4964
|
// src/types/api-version.ts
|
|
4955
4965
|
var DEFAULT_API_VERSION = "v3";
|
|
@@ -5014,7 +5024,7 @@ var generateContentUrl = (options) => {
|
|
|
5014
5024
|
url.searchParams.set("noTraverse", String(noTraverse));
|
|
5015
5025
|
url.searchParams.set("includeRefs", String(true));
|
|
5016
5026
|
const finalLocale = locale || userAttributes?.locale;
|
|
5017
|
-
let finalUserAttributes = userAttributes;
|
|
5027
|
+
let finalUserAttributes = userAttributes || {};
|
|
5018
5028
|
if (finalLocale) {
|
|
5019
5029
|
url.searchParams.set("locale", finalLocale);
|
|
5020
5030
|
finalUserAttributes = {
|
|
@@ -5052,11 +5062,15 @@ var generateContentUrl = (options) => {
|
|
|
5052
5062
|
...getBuilderSearchParamsFromWindow(),
|
|
5053
5063
|
...normalizeSearchParams(options.options || {})
|
|
5054
5064
|
};
|
|
5065
|
+
finalUserAttributes = {
|
|
5066
|
+
...finalUserAttributes,
|
|
5067
|
+
...getUserAttributesAsJSON(queryOptions)
|
|
5068
|
+
};
|
|
5055
5069
|
const flattened = flatten(queryOptions);
|
|
5056
5070
|
for (const key in flattened) {
|
|
5057
5071
|
url.searchParams.set(key, String(flattened[key]));
|
|
5058
5072
|
}
|
|
5059
|
-
if (finalUserAttributes) {
|
|
5073
|
+
if (Object.keys(finalUserAttributes).length > 0) {
|
|
5060
5074
|
url.searchParams.set("userAttributes", JSON.stringify(finalUserAttributes));
|
|
5061
5075
|
}
|
|
5062
5076
|
if (query) {
|
|
@@ -5069,6 +5083,28 @@ var generateContentUrl = (options) => {
|
|
|
5069
5083
|
}
|
|
5070
5084
|
return url;
|
|
5071
5085
|
};
|
|
5086
|
+
var getUserAttributesFromQueryOptions = (queryOptions) => {
|
|
5087
|
+
const newUserAttributes = {};
|
|
5088
|
+
for (const key in queryOptions) {
|
|
5089
|
+
if (key.startsWith("userAttributes.")) {
|
|
5090
|
+
newUserAttributes[key] = queryOptions[key];
|
|
5091
|
+
delete queryOptions[key];
|
|
5092
|
+
}
|
|
5093
|
+
}
|
|
5094
|
+
return newUserAttributes;
|
|
5095
|
+
};
|
|
5096
|
+
var getUserAttributesAsJSON = (queryOptions) => {
|
|
5097
|
+
if (isBrowser() && queryOptions["preview"] === "BUILDER_STUDIO") {
|
|
5098
|
+
queryOptions["userAttributes.urlPath"] = window.location.pathname;
|
|
5099
|
+
queryOptions["userAttributes.host"] = window.location.host;
|
|
5100
|
+
const queryOptionsForUserAttributes = getUserAttributesFromQueryOptions(queryOptions);
|
|
5101
|
+
const {
|
|
5102
|
+
userAttributes
|
|
5103
|
+
} = unflatten(queryOptionsForUserAttributes);
|
|
5104
|
+
return userAttributes;
|
|
5105
|
+
}
|
|
5106
|
+
return {};
|
|
5107
|
+
};
|
|
5072
5108
|
|
|
5073
5109
|
// src/functions/get-content/index.ts
|
|
5074
5110
|
var checkContentHasResults = (content) => "results" in content;
|
|
@@ -5870,11 +5906,16 @@ function EnableEditor(props) {
|
|
|
5870
5906
|
const searchParamPreviewModel = searchParams.get("builder.preview");
|
|
5871
5907
|
const searchParamPreviewId = searchParams.get(`builder.overrides.${searchParamPreviewModel}`);
|
|
5872
5908
|
const previewApiKey = searchParams.get("apiKey") || searchParams.get("builder.space");
|
|
5873
|
-
if (searchParamPreviewModel === props.model && previewApiKey === props.apiKey && (!props.content || searchParamPreviewId === props.content.id)) {
|
|
5909
|
+
if (searchParamPreviewModel === "BUILDER_STUDIO" || searchParamPreviewModel === props.model && previewApiKey === props.apiKey && (!props.content || searchParamPreviewId === props.content.id)) {
|
|
5874
5910
|
fetchOneEntry({
|
|
5875
|
-
model: props.model,
|
|
5911
|
+
model: props.model || "",
|
|
5876
5912
|
apiKey: props.apiKey,
|
|
5877
|
-
apiVersion: props.builderContextSignal.apiVersion
|
|
5913
|
+
apiVersion: props.builderContextSignal.apiVersion,
|
|
5914
|
+
...searchParamPreviewModel === "BUILDER_STUDIO" && props.context?.symbolId ? {
|
|
5915
|
+
query: {
|
|
5916
|
+
id: props.context.symbolId
|
|
5917
|
+
}
|
|
5918
|
+
} : {}
|
|
5878
5919
|
}).then((content) => {
|
|
5879
5920
|
if (content) {
|
|
5880
5921
|
mergeNewContent(content);
|