@builder.io/sdk-qwik 0.0.36 → 0.0.37
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/index.qwik.cjs +75 -66
- package/lib/index.qwik.mjs +75 -66
- package/package.json +4 -8
- package/types/blocks/image/image.d.ts +8 -1
- package/types/components/render-block/render-block.d.ts +3 -0
- package/types/components/render-content/render-content.d.ts +2 -0
- package/types/functions/evaluate.d.ts +2 -1
- package/types/functions/get-block-actions-handler.d.ts +1 -1
- package/types/functions/get-block-styles.d.ts +5 -1
- package/types/functions/get-builder-search-params/index.d.ts +1 -1
- package/types/functions/get-content/index.d.ts +3 -0
- package/types/functions/get-content/types.d.ts +4 -0
- package/types/functions/mark-mutable.d.ts +2 -2
- package/types/functions/track.d.ts +6 -1
- package/types/scripts/init-editing.d.ts +4 -1
- package/types/talk/generators-updated.d.ts +1 -0
- package/types/talk/generators.d.ts +6 -0
- package/types-hacks.d.ts +13 -0
- package/types/blocks/avatar/avatar.d.ts +0 -267
- package/types/blocks/avatar/avatar.model.d.ts +0 -19
- package/types/functions/get-block-bindings.d.ts +0 -2
package/lib/index.qwik.cjs
CHANGED
|
@@ -68,7 +68,7 @@ const registerInsertMenu = ()=>{
|
|
|
68
68
|
});
|
|
69
69
|
};
|
|
70
70
|
let isSetupForEditing = false;
|
|
71
|
-
const setupBrowserForEditing = ()=>{
|
|
71
|
+
const setupBrowserForEditing = (options = {})=>{
|
|
72
72
|
if (isSetupForEditing) return;
|
|
73
73
|
isSetupForEditing = true;
|
|
74
74
|
if (isBrowser()) {
|
|
@@ -86,6 +86,12 @@ const setupBrowserForEditing = ()=>{
|
|
|
86
86
|
supportsCustomBreakpoints: true
|
|
87
87
|
}
|
|
88
88
|
}, '*');
|
|
89
|
+
window.parent?.postMessage({
|
|
90
|
+
type: 'builder.updateContent',
|
|
91
|
+
data: {
|
|
92
|
+
options
|
|
93
|
+
}
|
|
94
|
+
}, '*');
|
|
89
95
|
window.addEventListener('message', ({ data })=>{
|
|
90
96
|
if (!data?.type) return;
|
|
91
97
|
switch(data.type){
|
|
@@ -190,7 +196,7 @@ const getSizesForBreakpoints = ({ small , medium })=>{
|
|
|
190
196
|
return newSizes;
|
|
191
197
|
};
|
|
192
198
|
|
|
193
|
-
function evaluate({ code , context , state , event }) {
|
|
199
|
+
function evaluate({ code , context , state , event , isExpression =true }) {
|
|
194
200
|
if (code === '') {
|
|
195
201
|
console.warn('Skipping evaluation of empty code block.');
|
|
196
202
|
return;
|
|
@@ -202,12 +208,13 @@ function evaluate({ code , context , state , event }) {
|
|
|
202
208
|
};
|
|
203
209
|
// Be able to handle simple expressions like "state.foo" or "1 + 1"
|
|
204
210
|
// as well as full blocks like "var foo = "bar"; return foo"
|
|
205
|
-
const useReturn =
|
|
211
|
+
const useReturn = // we disable this for cases where we definitely don't want a return
|
|
212
|
+
isExpression && !(code.includes(';') || code.includes(' return ') || code.trim().startsWith('return '));
|
|
206
213
|
const useCode = useReturn ? `return (${code});` : code;
|
|
207
214
|
try {
|
|
208
215
|
return new Function('builder', 'Builder' /* <- legacy */ , 'state', 'context', 'event', useCode)(builder, builder, state, context, event);
|
|
209
216
|
} catch (e) {
|
|
210
|
-
console.warn('Builder custom code error: \n While Evaluating: \n ', useCode, '\n', e
|
|
217
|
+
console.warn('Builder custom code error: \n While Evaluating: \n ', useCode, '\n', e);
|
|
211
218
|
}
|
|
212
219
|
}
|
|
213
220
|
|
|
@@ -347,7 +354,7 @@ function capitalizeFirstLetter(string) {
|
|
|
347
354
|
}
|
|
348
355
|
const getEventHandlerName = (key)=>`on${capitalizeFirstLetter(key)}$`;
|
|
349
356
|
|
|
350
|
-
function
|
|
357
|
+
function createEventHandler(value, options) {
|
|
351
358
|
return qwik.inlinedQrl((event)=>{
|
|
352
359
|
const [options, value] = qwik.useLexicalScope();
|
|
353
360
|
return evaluate({
|
|
@@ -356,7 +363,7 @@ function crateEventHandler(value, options) {
|
|
|
356
363
|
state: options.state,
|
|
357
364
|
event
|
|
358
365
|
});
|
|
359
|
-
}, "
|
|
366
|
+
}, "createEventHandler_7wCAiJVliNE", [
|
|
360
367
|
options,
|
|
361
368
|
value
|
|
362
369
|
]);
|
|
@@ -369,33 +376,11 @@ function getBlockActions(options) {
|
|
|
369
376
|
// eslint-disable-next-line no-prototype-builtins
|
|
370
377
|
if (!optionActions.hasOwnProperty(key)) continue;
|
|
371
378
|
const value = optionActions[key];
|
|
372
|
-
obj[getEventHandlerName(key)] =
|
|
379
|
+
obj[getEventHandlerName(key)] = createEventHandler(value, options);
|
|
373
380
|
}
|
|
374
381
|
return obj;
|
|
375
382
|
}
|
|
376
383
|
|
|
377
|
-
function getBlockBindings(state, block) {
|
|
378
|
-
const props = {};
|
|
379
|
-
const bindings = block.bindings;
|
|
380
|
-
if (bindings) for(const key in bindings){
|
|
381
|
-
if (key.startsWith('component.')) ;
|
|
382
|
-
else if (key.startsWith('style.')) {
|
|
383
|
-
const styleKey = key.substring(6);
|
|
384
|
-
const style = props.style || (props.style = {});
|
|
385
|
-
style[styleKey] = evaluate({
|
|
386
|
-
code: bindings[key],
|
|
387
|
-
state,
|
|
388
|
-
context: {}
|
|
389
|
-
});
|
|
390
|
-
} else props[key] = evaluate({
|
|
391
|
-
code: bindings[key],
|
|
392
|
-
state,
|
|
393
|
-
context: {}
|
|
394
|
-
});
|
|
395
|
-
}
|
|
396
|
-
return props;
|
|
397
|
-
}
|
|
398
|
-
|
|
399
384
|
function getBlockComponentOptions(block) {
|
|
400
385
|
return {
|
|
401
386
|
...block.component?.options,
|
|
@@ -599,15 +584,16 @@ const useBlock = function useBlock(props, state) {
|
|
|
599
584
|
shouldEvaluateBindings: true
|
|
600
585
|
});
|
|
601
586
|
};
|
|
587
|
+
const actions = function actions(props, state) {
|
|
588
|
+
return getBlockActions({
|
|
589
|
+
block: useBlock(props),
|
|
590
|
+
state: props.context.state,
|
|
591
|
+
context: props.context.context
|
|
592
|
+
});
|
|
593
|
+
};
|
|
602
594
|
const attributes = function attributes(props, state) {
|
|
603
595
|
return {
|
|
604
596
|
...getBlockProperties(useBlock(props)),
|
|
605
|
-
...getBlockBindings(props.context.state, useBlock(props)),
|
|
606
|
-
...getBlockActions({
|
|
607
|
-
block: useBlock(props),
|
|
608
|
-
state: props.context.state,
|
|
609
|
-
context: props.context.context
|
|
610
|
-
}),
|
|
611
597
|
...{}
|
|
612
598
|
};
|
|
613
599
|
};
|
|
@@ -624,7 +610,10 @@ const renderComponentProps = function renderComponentProps(props, state) {
|
|
|
624
610
|
* These attributes are passed to the wrapper element when there is one. If `noWrap` is set to true, then
|
|
625
611
|
* they are provided to the component itself directly.
|
|
626
612
|
*/ ...shouldWrap(props) ? {} : {
|
|
627
|
-
attributes:
|
|
613
|
+
attributes: {
|
|
614
|
+
...attributes(props),
|
|
615
|
+
...actions(props)
|
|
616
|
+
}
|
|
628
617
|
}
|
|
629
618
|
},
|
|
630
619
|
context: childrenContext(props)
|
|
@@ -700,7 +689,8 @@ const RenderBlock = (props)=>{
|
|
|
700
689
|
children: shouldWrap(props) ? /*#__PURE__*/ jsxRuntime.jsxs(jsxRuntime.Fragment, {
|
|
701
690
|
children: [
|
|
702
691
|
isEmptyHtmlElement(tag(props)) ? /*#__PURE__*/ jsxRuntime.jsx(state.tag, {
|
|
703
|
-
...attributes(props)
|
|
692
|
+
...attributes(props),
|
|
693
|
+
...actions(props)
|
|
704
694
|
}) : null,
|
|
705
695
|
!isEmptyHtmlElement(tag(props)) && repeatItemData(props) ? (repeatItemData(props) || []).map(function(data, index) {
|
|
706
696
|
return /*#__PURE__*/ jsxRuntime.jsx(RenderRepeatedBlock$1, {
|
|
@@ -718,6 +708,7 @@ const RenderBlock = (props)=>{
|
|
|
718
708
|
}) : null,
|
|
719
709
|
!isEmptyHtmlElement(tag(props)) && !repeatItemData(props) ? /*#__PURE__*/ jsxRuntime.jsxs(state.tag, {
|
|
720
710
|
...attributes(props),
|
|
711
|
+
...actions(props),
|
|
721
712
|
children: [
|
|
722
713
|
/*#__PURE__*/ jsxRuntime.jsx(state.renderComponentTag, {
|
|
723
714
|
...renderComponentProps(props)
|
|
@@ -981,6 +972,17 @@ const webpSrcSet = function webpSrcSet(props, state) {
|
|
|
981
972
|
if (srcSetToUse(props)?.match(/builder\.io/) && !props.noWebp) return srcSetToUse(props).replace(/\?/g, "?format=webp&");
|
|
982
973
|
else return "";
|
|
983
974
|
};
|
|
975
|
+
const aspectRatioCss = function aspectRatioCss(props, state) {
|
|
976
|
+
const aspectRatioStyles = {
|
|
977
|
+
position: "absolute",
|
|
978
|
+
height: "100%",
|
|
979
|
+
width: "100%",
|
|
980
|
+
left: "0px",
|
|
981
|
+
top: "0px"
|
|
982
|
+
};
|
|
983
|
+
const out = props.aspectRatio ? aspectRatioStyles : undefined;
|
|
984
|
+
return out;
|
|
985
|
+
};
|
|
984
986
|
const Image = /*#__PURE__*/ qwik.componentQrl(qwik.inlinedQrl((props)=>{
|
|
985
987
|
qwik.useStylesScopedQrl(qwik.inlinedQrl(STYLES$1, "Image_component_useStylesScoped_fBMYiVf9fuU"));
|
|
986
988
|
return /*#__PURE__*/ jsxRuntime.jsxs(qwik.Fragment, {
|
|
@@ -998,8 +1000,9 @@ const Image = /*#__PURE__*/ qwik.componentQrl(qwik.inlinedQrl((props)=>{
|
|
|
998
1000
|
},
|
|
999
1001
|
role: props.altText ? "presentation" : undefined,
|
|
1000
1002
|
style: {
|
|
1001
|
-
objectPosition: props.
|
|
1002
|
-
objectFit: props.backgroundSize || "cover"
|
|
1003
|
+
objectPosition: props.backgroundPosition || "center",
|
|
1004
|
+
objectFit: props.backgroundSize || "cover",
|
|
1005
|
+
...aspectRatioCss(props)
|
|
1003
1006
|
},
|
|
1004
1007
|
class: "builder-image" + (props.className ? " " + props.className : "") + " img-Image",
|
|
1005
1008
|
get src () {
|
|
@@ -1023,8 +1026,8 @@ const Image = /*#__PURE__*/ qwik.componentQrl(qwik.inlinedQrl((props)=>{
|
|
|
1023
1026
|
props.aspectRatio && !(props.builderBlock?.children?.length && props.fitContent) ? /*#__PURE__*/ jsxRuntime.jsx("div", {
|
|
1024
1027
|
class: "builder-image-sizer div-Image",
|
|
1025
1028
|
style: {
|
|
1026
|
-
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
1027
|
-
|
|
1029
|
+
paddingTop: // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
1030
|
+
props.aspectRatio * 100 + "%"
|
|
1028
1031
|
}
|
|
1029
1032
|
}) : null,
|
|
1030
1033
|
props.builderBlock?.children?.length && props.fitContent ? /*#__PURE__*/ jsxRuntime.jsx(qwik.Slot, {}) : null,
|
|
@@ -1038,12 +1041,7 @@ const Image = /*#__PURE__*/ qwik.componentQrl(qwik.inlinedQrl((props)=>{
|
|
|
1038
1041
|
const Image$1 = Image;
|
|
1039
1042
|
const STYLES$1 = `.img-Image {
|
|
1040
1043
|
opacity: 1;
|
|
1041
|
-
transition: opacity 0.2s ease-in-out;
|
|
1042
|
-
position: absolute;
|
|
1043
|
-
height: 100%;
|
|
1044
|
-
width: 100%;
|
|
1045
|
-
top: 0px;
|
|
1046
|
-
left: 0px; }.div-Image {
|
|
1044
|
+
transition: opacity 0.2s ease-in-out; }.div-Image {
|
|
1047
1045
|
width: 100%;
|
|
1048
1046
|
pointer-events: none;
|
|
1049
1047
|
font-size: 0; }.div-Image-2 {
|
|
@@ -1656,18 +1654,9 @@ const componentInfo$6 = {
|
|
|
1656
1654
|
const SectionComponent = /*#__PURE__*/ qwik.componentQrl(qwik.inlinedQrl((props)=>{
|
|
1657
1655
|
return /*#__PURE__*/ jsxRuntime.jsx("section", {
|
|
1658
1656
|
...props.attributes,
|
|
1659
|
-
style: {
|
|
1660
|
-
|
|
1661
|
-
|
|
1662
|
-
flexGrow: "1",
|
|
1663
|
-
boxSizing: "border-box",
|
|
1664
|
-
maxWidth: `${props.maxWidth && typeof props.maxWidth === "number" ? props.maxWidth : 1200}px`,
|
|
1665
|
-
display: "flex",
|
|
1666
|
-
flexDirection: "column",
|
|
1667
|
-
alignItems: "stretch",
|
|
1668
|
-
marginLeft: "auto",
|
|
1669
|
-
marginRight: "auto"
|
|
1670
|
-
},
|
|
1657
|
+
style: (()=>{
|
|
1658
|
+
props.maxWidth && typeof props.maxWidth === "number" ? props.maxWidth : undefined;
|
|
1659
|
+
})(),
|
|
1671
1660
|
children: /*#__PURE__*/ jsxRuntime.jsx(qwik.Slot, {})
|
|
1672
1661
|
});
|
|
1673
1662
|
}, "SectionComponent_component_ZWF9iD5WeLg"));
|
|
@@ -2154,6 +2143,7 @@ const componentInfo = {
|
|
|
2154
2143
|
}
|
|
2155
2144
|
|
|
2156
2145
|
const BUILDER_SEARCHPARAMS_PREFIX = 'builder.';
|
|
2146
|
+
const BUILDER_OPTIONS_PREFIX = 'options.';
|
|
2157
2147
|
const convertSearchParamsToQueryObject = (searchParams)=>{
|
|
2158
2148
|
const options = {};
|
|
2159
2149
|
searchParams.forEach((value, key)=>{
|
|
@@ -2167,7 +2157,7 @@ const getBuilderSearchParams = (_options)=>{
|
|
|
2167
2157
|
const newOptions = {};
|
|
2168
2158
|
Object.keys(options).forEach((key)=>{
|
|
2169
2159
|
if (key.startsWith(BUILDER_SEARCHPARAMS_PREFIX)) {
|
|
2170
|
-
const trimmedKey = key.replace(BUILDER_SEARCHPARAMS_PREFIX, '');
|
|
2160
|
+
const trimmedKey = key.replace(BUILDER_SEARCHPARAMS_PREFIX, '').replace(BUILDER_OPTIONS_PREFIX, '');
|
|
2171
2161
|
newOptions[trimmedKey] = options[key];
|
|
2172
2162
|
}
|
|
2173
2163
|
});
|
|
@@ -2368,9 +2358,9 @@ async function getContent(options) {
|
|
|
2368
2358
|
})).results[0] || null;
|
|
2369
2359
|
}
|
|
2370
2360
|
const generateContentUrl = (options)=>{
|
|
2371
|
-
const { limit =30 , userAttributes , query , noTraverse =false , model , apiKey , includeRefs =true , } = options;
|
|
2361
|
+
const { limit =30 , userAttributes , query , noTraverse =false , model , apiKey , includeRefs =true , locale , } = options;
|
|
2372
2362
|
if (!apiKey) throw new Error('Missing API key');
|
|
2373
|
-
const url = new URL(`https://cdn.builder.io/api/v2/content/${model}?apiKey=${apiKey}&limit=${limit}&noTraverse=${noTraverse}&includeRefs=${includeRefs}`);
|
|
2363
|
+
const url = new URL(`https://cdn.builder.io/api/v2/content/${model}?apiKey=${apiKey}&limit=${limit}&noTraverse=${noTraverse}&includeRefs=${includeRefs}${locale ? `&locale=${locale}` : ''}`);
|
|
2374
2364
|
const queryOptions = {
|
|
2375
2365
|
...getBuilderSearchParamsFromWindow(),
|
|
2376
2366
|
...normalizeSearchParams(options.options || {})
|
|
@@ -2391,7 +2381,8 @@ async function getAllContent(options) {
|
|
|
2391
2381
|
const fetch = await getFetch();
|
|
2392
2382
|
const content = await fetch(url.href).then((res)=>res.json());
|
|
2393
2383
|
const canTrack = options.canTrack !== false;
|
|
2394
|
-
if (canTrack
|
|
2384
|
+
if (canTrack && // This makes sure we have a non-error response with the results array.
|
|
2385
|
+
Array.isArray(content.results)) for (const item of content.results)await handleABTesting({
|
|
2395
2386
|
item,
|
|
2396
2387
|
canTrack
|
|
2397
2388
|
});
|
|
@@ -2535,6 +2526,10 @@ const createEvent = async ({ type: eventType , canTrack , apiKey , metadata , ..
|
|
|
2535
2526
|
}
|
|
2536
2527
|
});
|
|
2537
2528
|
async function _track(eventProps) {
|
|
2529
|
+
if (!eventProps.apiKey) {
|
|
2530
|
+
console.error('[Builder.io]: Missing API key for track call. Please provide your API key.');
|
|
2531
|
+
return;
|
|
2532
|
+
}
|
|
2538
2533
|
if (!eventProps.canTrack) return;
|
|
2539
2534
|
if (isEditing()) return;
|
|
2540
2535
|
if (!(isBrowser() || TARGET === 'reactNative')) return;
|
|
@@ -2576,7 +2571,7 @@ const getCssFromFont = function getCssFromFont(props, state, font) {
|
|
|
2576
2571
|
if (font.files) for(const weight in font.files){
|
|
2577
2572
|
const isNumber = String(Number(weight)) === weight;
|
|
2578
2573
|
if (!isNumber) continue;
|
|
2579
|
-
|
|
2574
|
+
// TODO: maybe limit number loaded
|
|
2580
2575
|
const weightUrl = font.files[weight];
|
|
2581
2576
|
if (weightUrl && weightUrl !== url) str += `
|
|
2582
2577
|
@font-face {
|
|
@@ -2633,6 +2628,9 @@ const contentState = function contentState(props, state, elementRef) {
|
|
|
2633
2628
|
return {
|
|
2634
2629
|
...props.content?.data?.state,
|
|
2635
2630
|
...props.data,
|
|
2631
|
+
...props.locale ? {
|
|
2632
|
+
locale: props.locale
|
|
2633
|
+
} : {},
|
|
2636
2634
|
...state.overrideState
|
|
2637
2635
|
};
|
|
2638
2636
|
};
|
|
@@ -2642,6 +2640,7 @@ const contextContext = function contextContext(props, state, elementRef) {
|
|
|
2642
2640
|
const allRegisteredComponents = function allRegisteredComponents(props, state, elementRef) {
|
|
2643
2641
|
const allComponentsArray = [
|
|
2644
2642
|
...getDefaultRegisteredComponents(),
|
|
2643
|
+
// While this `components` object is deprecated, we must maintain support for it.
|
|
2645
2644
|
// Since users are able to override our default components, we need to make sure that we do not break such
|
|
2646
2645
|
// existing usage.
|
|
2647
2646
|
// This is why we spread `components` after the default Builder.io components, but before the `props.customComponents`,
|
|
@@ -2766,11 +2765,19 @@ const RenderContent = /*#__PURE__*/ qwik.componentQrl(qwik.inlinedQrl((props)=>{
|
|
|
2766
2765
|
}));
|
|
2767
2766
|
qwik.useClientEffectQrl(qwik.inlinedQrl(()=>{
|
|
2768
2767
|
const [elementRef, props, state] = qwik.useLexicalScope();
|
|
2768
|
+
if (!props.apiKey) console.error("[Builder.io]: No API key provided to `RenderContent` component. This can cause issues. Please provide an API key using the `apiKey` prop.");
|
|
2769
2769
|
if (isBrowser()) {
|
|
2770
2770
|
if (isEditing()) {
|
|
2771
2771
|
state.forceReRenderCount = state.forceReRenderCount + 1;
|
|
2772
2772
|
registerInsertMenu();
|
|
2773
|
-
setupBrowserForEditing(
|
|
2773
|
+
setupBrowserForEditing({
|
|
2774
|
+
...props.locale ? {
|
|
2775
|
+
locale: props.locale
|
|
2776
|
+
} : {},
|
|
2777
|
+
...props.includeRefs ? {
|
|
2778
|
+
includeRefs: props.includeRefs
|
|
2779
|
+
} : {}
|
|
2780
|
+
});
|
|
2774
2781
|
Object.values(allRegisteredComponents(props)).forEach((registeredComponent)=>{
|
|
2775
2782
|
const message = createRegisterComponentMessage(registeredComponent);
|
|
2776
2783
|
window.parent?.postMessage(message, "*");
|
|
@@ -2788,7 +2795,8 @@ const RenderContent = /*#__PURE__*/ qwik.componentQrl(qwik.inlinedQrl((props)=>{
|
|
|
2788
2795
|
apiKey: props.apiKey,
|
|
2789
2796
|
variationId: variationId !== contentId ? variationId : undefined
|
|
2790
2797
|
});
|
|
2791
|
-
}
|
|
2798
|
+
}
|
|
2799
|
+
// override normal content in preview mode
|
|
2792
2800
|
if (isPreviewing()) {
|
|
2793
2801
|
const searchParams = new URL(location.href).searchParams;
|
|
2794
2802
|
if (props.model && searchParams.get("builder.preview") === props.model) {
|
|
@@ -2813,6 +2821,7 @@ const RenderContent = /*#__PURE__*/ qwik.componentQrl(qwik.inlinedQrl((props)=>{
|
|
|
2813
2821
|
qwik.useWatchQrl(qwik.inlinedQrl(({ track })=>{
|
|
2814
2822
|
const [elementRef, props, state] = qwik.useLexicalScope();
|
|
2815
2823
|
state.useContent?.data && track(state.useContent?.data, "jsCode");
|
|
2824
|
+
state && track(state, "contentState");
|
|
2816
2825
|
evaluateJsCode(props, state);
|
|
2817
2826
|
}, "RenderContent_component_useWatch_OIBatobA0hE", [
|
|
2818
2827
|
elementRef,
|
package/lib/index.qwik.mjs
CHANGED
|
@@ -64,7 +64,7 @@ const registerInsertMenu = ()=>{
|
|
|
64
64
|
});
|
|
65
65
|
};
|
|
66
66
|
let isSetupForEditing = false;
|
|
67
|
-
const setupBrowserForEditing = ()=>{
|
|
67
|
+
const setupBrowserForEditing = (options = {})=>{
|
|
68
68
|
if (isSetupForEditing) return;
|
|
69
69
|
isSetupForEditing = true;
|
|
70
70
|
if (isBrowser()) {
|
|
@@ -82,6 +82,12 @@ const setupBrowserForEditing = ()=>{
|
|
|
82
82
|
supportsCustomBreakpoints: true
|
|
83
83
|
}
|
|
84
84
|
}, '*');
|
|
85
|
+
window.parent?.postMessage({
|
|
86
|
+
type: 'builder.updateContent',
|
|
87
|
+
data: {
|
|
88
|
+
options
|
|
89
|
+
}
|
|
90
|
+
}, '*');
|
|
85
91
|
window.addEventListener('message', ({ data })=>{
|
|
86
92
|
if (!data?.type) return;
|
|
87
93
|
switch(data.type){
|
|
@@ -186,7 +192,7 @@ const getSizesForBreakpoints = ({ small , medium })=>{
|
|
|
186
192
|
return newSizes;
|
|
187
193
|
};
|
|
188
194
|
|
|
189
|
-
function evaluate({ code , context , state , event }) {
|
|
195
|
+
function evaluate({ code , context , state , event , isExpression =true }) {
|
|
190
196
|
if (code === '') {
|
|
191
197
|
console.warn('Skipping evaluation of empty code block.');
|
|
192
198
|
return;
|
|
@@ -198,12 +204,13 @@ function evaluate({ code , context , state , event }) {
|
|
|
198
204
|
};
|
|
199
205
|
// Be able to handle simple expressions like "state.foo" or "1 + 1"
|
|
200
206
|
// as well as full blocks like "var foo = "bar"; return foo"
|
|
201
|
-
const useReturn =
|
|
207
|
+
const useReturn = // we disable this for cases where we definitely don't want a return
|
|
208
|
+
isExpression && !(code.includes(';') || code.includes(' return ') || code.trim().startsWith('return '));
|
|
202
209
|
const useCode = useReturn ? `return (${code});` : code;
|
|
203
210
|
try {
|
|
204
211
|
return new Function('builder', 'Builder' /* <- legacy */ , 'state', 'context', 'event', useCode)(builder, builder, state, context, event);
|
|
205
212
|
} catch (e) {
|
|
206
|
-
console.warn('Builder custom code error: \n While Evaluating: \n ', useCode, '\n', e
|
|
213
|
+
console.warn('Builder custom code error: \n While Evaluating: \n ', useCode, '\n', e);
|
|
207
214
|
}
|
|
208
215
|
}
|
|
209
216
|
|
|
@@ -343,7 +350,7 @@ function capitalizeFirstLetter(string) {
|
|
|
343
350
|
}
|
|
344
351
|
const getEventHandlerName = (key)=>`on${capitalizeFirstLetter(key)}$`;
|
|
345
352
|
|
|
346
|
-
function
|
|
353
|
+
function createEventHandler(value, options) {
|
|
347
354
|
return inlinedQrl((event)=>{
|
|
348
355
|
const [options, value] = useLexicalScope();
|
|
349
356
|
return evaluate({
|
|
@@ -352,7 +359,7 @@ function crateEventHandler(value, options) {
|
|
|
352
359
|
state: options.state,
|
|
353
360
|
event
|
|
354
361
|
});
|
|
355
|
-
}, "
|
|
362
|
+
}, "createEventHandler_7wCAiJVliNE", [
|
|
356
363
|
options,
|
|
357
364
|
value
|
|
358
365
|
]);
|
|
@@ -365,33 +372,11 @@ function getBlockActions(options) {
|
|
|
365
372
|
// eslint-disable-next-line no-prototype-builtins
|
|
366
373
|
if (!optionActions.hasOwnProperty(key)) continue;
|
|
367
374
|
const value = optionActions[key];
|
|
368
|
-
obj[getEventHandlerName(key)] =
|
|
375
|
+
obj[getEventHandlerName(key)] = createEventHandler(value, options);
|
|
369
376
|
}
|
|
370
377
|
return obj;
|
|
371
378
|
}
|
|
372
379
|
|
|
373
|
-
function getBlockBindings(state, block) {
|
|
374
|
-
const props = {};
|
|
375
|
-
const bindings = block.bindings;
|
|
376
|
-
if (bindings) for(const key in bindings){
|
|
377
|
-
if (key.startsWith('component.')) ;
|
|
378
|
-
else if (key.startsWith('style.')) {
|
|
379
|
-
const styleKey = key.substring(6);
|
|
380
|
-
const style = props.style || (props.style = {});
|
|
381
|
-
style[styleKey] = evaluate({
|
|
382
|
-
code: bindings[key],
|
|
383
|
-
state,
|
|
384
|
-
context: {}
|
|
385
|
-
});
|
|
386
|
-
} else props[key] = evaluate({
|
|
387
|
-
code: bindings[key],
|
|
388
|
-
state,
|
|
389
|
-
context: {}
|
|
390
|
-
});
|
|
391
|
-
}
|
|
392
|
-
return props;
|
|
393
|
-
}
|
|
394
|
-
|
|
395
380
|
function getBlockComponentOptions(block) {
|
|
396
381
|
return {
|
|
397
382
|
...block.component?.options,
|
|
@@ -595,15 +580,16 @@ const useBlock = function useBlock(props, state) {
|
|
|
595
580
|
shouldEvaluateBindings: true
|
|
596
581
|
});
|
|
597
582
|
};
|
|
583
|
+
const actions = function actions(props, state) {
|
|
584
|
+
return getBlockActions({
|
|
585
|
+
block: useBlock(props),
|
|
586
|
+
state: props.context.state,
|
|
587
|
+
context: props.context.context
|
|
588
|
+
});
|
|
589
|
+
};
|
|
598
590
|
const attributes = function attributes(props, state) {
|
|
599
591
|
return {
|
|
600
592
|
...getBlockProperties(useBlock(props)),
|
|
601
|
-
...getBlockBindings(props.context.state, useBlock(props)),
|
|
602
|
-
...getBlockActions({
|
|
603
|
-
block: useBlock(props),
|
|
604
|
-
state: props.context.state,
|
|
605
|
-
context: props.context.context
|
|
606
|
-
}),
|
|
607
593
|
...{}
|
|
608
594
|
};
|
|
609
595
|
};
|
|
@@ -620,7 +606,10 @@ const renderComponentProps = function renderComponentProps(props, state) {
|
|
|
620
606
|
* These attributes are passed to the wrapper element when there is one. If `noWrap` is set to true, then
|
|
621
607
|
* they are provided to the component itself directly.
|
|
622
608
|
*/ ...shouldWrap(props) ? {} : {
|
|
623
|
-
attributes:
|
|
609
|
+
attributes: {
|
|
610
|
+
...attributes(props),
|
|
611
|
+
...actions(props)
|
|
612
|
+
}
|
|
624
613
|
}
|
|
625
614
|
},
|
|
626
615
|
context: childrenContext(props)
|
|
@@ -696,7 +685,8 @@ const RenderBlock = (props)=>{
|
|
|
696
685
|
children: shouldWrap(props) ? /*#__PURE__*/ jsxs(Fragment$1, {
|
|
697
686
|
children: [
|
|
698
687
|
isEmptyHtmlElement(tag(props)) ? /*#__PURE__*/ jsx(state.tag, {
|
|
699
|
-
...attributes(props)
|
|
688
|
+
...attributes(props),
|
|
689
|
+
...actions(props)
|
|
700
690
|
}) : null,
|
|
701
691
|
!isEmptyHtmlElement(tag(props)) && repeatItemData(props) ? (repeatItemData(props) || []).map(function(data, index) {
|
|
702
692
|
return /*#__PURE__*/ jsx(RenderRepeatedBlock$1, {
|
|
@@ -714,6 +704,7 @@ const RenderBlock = (props)=>{
|
|
|
714
704
|
}) : null,
|
|
715
705
|
!isEmptyHtmlElement(tag(props)) && !repeatItemData(props) ? /*#__PURE__*/ jsxs(state.tag, {
|
|
716
706
|
...attributes(props),
|
|
707
|
+
...actions(props),
|
|
717
708
|
children: [
|
|
718
709
|
/*#__PURE__*/ jsx(state.renderComponentTag, {
|
|
719
710
|
...renderComponentProps(props)
|
|
@@ -977,6 +968,17 @@ const webpSrcSet = function webpSrcSet(props, state) {
|
|
|
977
968
|
if (srcSetToUse(props)?.match(/builder\.io/) && !props.noWebp) return srcSetToUse(props).replace(/\?/g, "?format=webp&");
|
|
978
969
|
else return "";
|
|
979
970
|
};
|
|
971
|
+
const aspectRatioCss = function aspectRatioCss(props, state) {
|
|
972
|
+
const aspectRatioStyles = {
|
|
973
|
+
position: "absolute",
|
|
974
|
+
height: "100%",
|
|
975
|
+
width: "100%",
|
|
976
|
+
left: "0px",
|
|
977
|
+
top: "0px"
|
|
978
|
+
};
|
|
979
|
+
const out = props.aspectRatio ? aspectRatioStyles : undefined;
|
|
980
|
+
return out;
|
|
981
|
+
};
|
|
980
982
|
const Image = /*#__PURE__*/ componentQrl(inlinedQrl((props)=>{
|
|
981
983
|
useStylesScopedQrl(inlinedQrl(STYLES$1, "Image_component_useStylesScoped_fBMYiVf9fuU"));
|
|
982
984
|
return /*#__PURE__*/ jsxs(Fragment$2, {
|
|
@@ -994,8 +996,9 @@ const Image = /*#__PURE__*/ componentQrl(inlinedQrl((props)=>{
|
|
|
994
996
|
},
|
|
995
997
|
role: props.altText ? "presentation" : undefined,
|
|
996
998
|
style: {
|
|
997
|
-
objectPosition: props.
|
|
998
|
-
objectFit: props.backgroundSize || "cover"
|
|
999
|
+
objectPosition: props.backgroundPosition || "center",
|
|
1000
|
+
objectFit: props.backgroundSize || "cover",
|
|
1001
|
+
...aspectRatioCss(props)
|
|
999
1002
|
},
|
|
1000
1003
|
class: "builder-image" + (props.className ? " " + props.className : "") + " img-Image",
|
|
1001
1004
|
get src () {
|
|
@@ -1019,8 +1022,8 @@ const Image = /*#__PURE__*/ componentQrl(inlinedQrl((props)=>{
|
|
|
1019
1022
|
props.aspectRatio && !(props.builderBlock?.children?.length && props.fitContent) ? /*#__PURE__*/ jsx("div", {
|
|
1020
1023
|
class: "builder-image-sizer div-Image",
|
|
1021
1024
|
style: {
|
|
1022
|
-
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
1023
|
-
|
|
1025
|
+
paddingTop: // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
1026
|
+
props.aspectRatio * 100 + "%"
|
|
1024
1027
|
}
|
|
1025
1028
|
}) : null,
|
|
1026
1029
|
props.builderBlock?.children?.length && props.fitContent ? /*#__PURE__*/ jsx(Slot, {}) : null,
|
|
@@ -1034,12 +1037,7 @@ const Image = /*#__PURE__*/ componentQrl(inlinedQrl((props)=>{
|
|
|
1034
1037
|
const Image$1 = Image;
|
|
1035
1038
|
const STYLES$1 = `.img-Image {
|
|
1036
1039
|
opacity: 1;
|
|
1037
|
-
transition: opacity 0.2s ease-in-out;
|
|
1038
|
-
position: absolute;
|
|
1039
|
-
height: 100%;
|
|
1040
|
-
width: 100%;
|
|
1041
|
-
top: 0px;
|
|
1042
|
-
left: 0px; }.div-Image {
|
|
1040
|
+
transition: opacity 0.2s ease-in-out; }.div-Image {
|
|
1043
1041
|
width: 100%;
|
|
1044
1042
|
pointer-events: none;
|
|
1045
1043
|
font-size: 0; }.div-Image-2 {
|
|
@@ -1652,18 +1650,9 @@ const componentInfo$6 = {
|
|
|
1652
1650
|
const SectionComponent = /*#__PURE__*/ componentQrl(inlinedQrl((props)=>{
|
|
1653
1651
|
return /*#__PURE__*/ jsx("section", {
|
|
1654
1652
|
...props.attributes,
|
|
1655
|
-
style: {
|
|
1656
|
-
|
|
1657
|
-
|
|
1658
|
-
flexGrow: "1",
|
|
1659
|
-
boxSizing: "border-box",
|
|
1660
|
-
maxWidth: `${props.maxWidth && typeof props.maxWidth === "number" ? props.maxWidth : 1200}px`,
|
|
1661
|
-
display: "flex",
|
|
1662
|
-
flexDirection: "column",
|
|
1663
|
-
alignItems: "stretch",
|
|
1664
|
-
marginLeft: "auto",
|
|
1665
|
-
marginRight: "auto"
|
|
1666
|
-
},
|
|
1653
|
+
style: (()=>{
|
|
1654
|
+
props.maxWidth && typeof props.maxWidth === "number" ? props.maxWidth : undefined;
|
|
1655
|
+
})(),
|
|
1667
1656
|
children: /*#__PURE__*/ jsx(Slot, {})
|
|
1668
1657
|
});
|
|
1669
1658
|
}, "SectionComponent_component_ZWF9iD5WeLg"));
|
|
@@ -2150,6 +2139,7 @@ const componentInfo = {
|
|
|
2150
2139
|
}
|
|
2151
2140
|
|
|
2152
2141
|
const BUILDER_SEARCHPARAMS_PREFIX = 'builder.';
|
|
2142
|
+
const BUILDER_OPTIONS_PREFIX = 'options.';
|
|
2153
2143
|
const convertSearchParamsToQueryObject = (searchParams)=>{
|
|
2154
2144
|
const options = {};
|
|
2155
2145
|
searchParams.forEach((value, key)=>{
|
|
@@ -2163,7 +2153,7 @@ const getBuilderSearchParams = (_options)=>{
|
|
|
2163
2153
|
const newOptions = {};
|
|
2164
2154
|
Object.keys(options).forEach((key)=>{
|
|
2165
2155
|
if (key.startsWith(BUILDER_SEARCHPARAMS_PREFIX)) {
|
|
2166
|
-
const trimmedKey = key.replace(BUILDER_SEARCHPARAMS_PREFIX, '');
|
|
2156
|
+
const trimmedKey = key.replace(BUILDER_SEARCHPARAMS_PREFIX, '').replace(BUILDER_OPTIONS_PREFIX, '');
|
|
2167
2157
|
newOptions[trimmedKey] = options[key];
|
|
2168
2158
|
}
|
|
2169
2159
|
});
|
|
@@ -2364,9 +2354,9 @@ async function getContent(options) {
|
|
|
2364
2354
|
})).results[0] || null;
|
|
2365
2355
|
}
|
|
2366
2356
|
const generateContentUrl = (options)=>{
|
|
2367
|
-
const { limit =30 , userAttributes , query , noTraverse =false , model , apiKey , includeRefs =true , } = options;
|
|
2357
|
+
const { limit =30 , userAttributes , query , noTraverse =false , model , apiKey , includeRefs =true , locale , } = options;
|
|
2368
2358
|
if (!apiKey) throw new Error('Missing API key');
|
|
2369
|
-
const url = new URL(`https://cdn.builder.io/api/v2/content/${model}?apiKey=${apiKey}&limit=${limit}&noTraverse=${noTraverse}&includeRefs=${includeRefs}`);
|
|
2359
|
+
const url = new URL(`https://cdn.builder.io/api/v2/content/${model}?apiKey=${apiKey}&limit=${limit}&noTraverse=${noTraverse}&includeRefs=${includeRefs}${locale ? `&locale=${locale}` : ''}`);
|
|
2370
2360
|
const queryOptions = {
|
|
2371
2361
|
...getBuilderSearchParamsFromWindow(),
|
|
2372
2362
|
...normalizeSearchParams(options.options || {})
|
|
@@ -2387,7 +2377,8 @@ async function getAllContent(options) {
|
|
|
2387
2377
|
const fetch = await getFetch();
|
|
2388
2378
|
const content = await fetch(url.href).then((res)=>res.json());
|
|
2389
2379
|
const canTrack = options.canTrack !== false;
|
|
2390
|
-
if (canTrack
|
|
2380
|
+
if (canTrack && // This makes sure we have a non-error response with the results array.
|
|
2381
|
+
Array.isArray(content.results)) for (const item of content.results)await handleABTesting({
|
|
2391
2382
|
item,
|
|
2392
2383
|
canTrack
|
|
2393
2384
|
});
|
|
@@ -2531,6 +2522,10 @@ const createEvent = async ({ type: eventType , canTrack , apiKey , metadata , ..
|
|
|
2531
2522
|
}
|
|
2532
2523
|
});
|
|
2533
2524
|
async function _track(eventProps) {
|
|
2525
|
+
if (!eventProps.apiKey) {
|
|
2526
|
+
console.error('[Builder.io]: Missing API key for track call. Please provide your API key.');
|
|
2527
|
+
return;
|
|
2528
|
+
}
|
|
2534
2529
|
if (!eventProps.canTrack) return;
|
|
2535
2530
|
if (isEditing()) return;
|
|
2536
2531
|
if (!(isBrowser() || TARGET === 'reactNative')) return;
|
|
@@ -2572,7 +2567,7 @@ const getCssFromFont = function getCssFromFont(props, state, font) {
|
|
|
2572
2567
|
if (font.files) for(const weight in font.files){
|
|
2573
2568
|
const isNumber = String(Number(weight)) === weight;
|
|
2574
2569
|
if (!isNumber) continue;
|
|
2575
|
-
|
|
2570
|
+
// TODO: maybe limit number loaded
|
|
2576
2571
|
const weightUrl = font.files[weight];
|
|
2577
2572
|
if (weightUrl && weightUrl !== url) str += `
|
|
2578
2573
|
@font-face {
|
|
@@ -2629,6 +2624,9 @@ const contentState = function contentState(props, state, elementRef) {
|
|
|
2629
2624
|
return {
|
|
2630
2625
|
...props.content?.data?.state,
|
|
2631
2626
|
...props.data,
|
|
2627
|
+
...props.locale ? {
|
|
2628
|
+
locale: props.locale
|
|
2629
|
+
} : {},
|
|
2632
2630
|
...state.overrideState
|
|
2633
2631
|
};
|
|
2634
2632
|
};
|
|
@@ -2638,6 +2636,7 @@ const contextContext = function contextContext(props, state, elementRef) {
|
|
|
2638
2636
|
const allRegisteredComponents = function allRegisteredComponents(props, state, elementRef) {
|
|
2639
2637
|
const allComponentsArray = [
|
|
2640
2638
|
...getDefaultRegisteredComponents(),
|
|
2639
|
+
// While this `components` object is deprecated, we must maintain support for it.
|
|
2641
2640
|
// Since users are able to override our default components, we need to make sure that we do not break such
|
|
2642
2641
|
// existing usage.
|
|
2643
2642
|
// This is why we spread `components` after the default Builder.io components, but before the `props.customComponents`,
|
|
@@ -2762,11 +2761,19 @@ const RenderContent = /*#__PURE__*/ componentQrl(inlinedQrl((props)=>{
|
|
|
2762
2761
|
}));
|
|
2763
2762
|
useClientEffectQrl(inlinedQrl(()=>{
|
|
2764
2763
|
const [elementRef, props, state] = useLexicalScope();
|
|
2764
|
+
if (!props.apiKey) console.error("[Builder.io]: No API key provided to `RenderContent` component. This can cause issues. Please provide an API key using the `apiKey` prop.");
|
|
2765
2765
|
if (isBrowser()) {
|
|
2766
2766
|
if (isEditing()) {
|
|
2767
2767
|
state.forceReRenderCount = state.forceReRenderCount + 1;
|
|
2768
2768
|
registerInsertMenu();
|
|
2769
|
-
setupBrowserForEditing(
|
|
2769
|
+
setupBrowserForEditing({
|
|
2770
|
+
...props.locale ? {
|
|
2771
|
+
locale: props.locale
|
|
2772
|
+
} : {},
|
|
2773
|
+
...props.includeRefs ? {
|
|
2774
|
+
includeRefs: props.includeRefs
|
|
2775
|
+
} : {}
|
|
2776
|
+
});
|
|
2770
2777
|
Object.values(allRegisteredComponents(props)).forEach((registeredComponent)=>{
|
|
2771
2778
|
const message = createRegisterComponentMessage(registeredComponent);
|
|
2772
2779
|
window.parent?.postMessage(message, "*");
|
|
@@ -2784,7 +2791,8 @@ const RenderContent = /*#__PURE__*/ componentQrl(inlinedQrl((props)=>{
|
|
|
2784
2791
|
apiKey: props.apiKey,
|
|
2785
2792
|
variationId: variationId !== contentId ? variationId : undefined
|
|
2786
2793
|
});
|
|
2787
|
-
}
|
|
2794
|
+
}
|
|
2795
|
+
// override normal content in preview mode
|
|
2788
2796
|
if (isPreviewing()) {
|
|
2789
2797
|
const searchParams = new URL(location.href).searchParams;
|
|
2790
2798
|
if (props.model && searchParams.get("builder.preview") === props.model) {
|
|
@@ -2809,6 +2817,7 @@ const RenderContent = /*#__PURE__*/ componentQrl(inlinedQrl((props)=>{
|
|
|
2809
2817
|
useWatchQrl(inlinedQrl(({ track })=>{
|
|
2810
2818
|
const [elementRef, props, state] = useLexicalScope();
|
|
2811
2819
|
state.useContent?.data && track(state.useContent?.data, "jsCode");
|
|
2820
|
+
state && track(state, "contentState");
|
|
2812
2821
|
evaluateJsCode(props, state);
|
|
2813
2822
|
}, "RenderContent_component_useWatch_OIBatobA0hE", [
|
|
2814
2823
|
elementRef,
|
package/package.json
CHANGED
|
@@ -1,16 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@builder.io/sdk-qwik",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.37",
|
|
4
4
|
"description": "Builder.io Qwik SDK",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./lib/index.qwik.cjs",
|
|
7
7
|
"module": "./lib/index.qwik.mjs",
|
|
8
8
|
"qwik": "./lib/index.qwik.mjs",
|
|
9
9
|
"types": "./types/index.d.ts",
|
|
10
|
-
"files": [
|
|
11
|
-
"lib",
|
|
12
|
-
"types"
|
|
13
|
-
],
|
|
14
10
|
"exports": {
|
|
15
11
|
".": {
|
|
16
12
|
"import": "./lib/index.qwik.mjs",
|
|
@@ -20,8 +16,8 @@
|
|
|
20
16
|
"scripts": {
|
|
21
17
|
"typecheck": "tsc --noEmit",
|
|
22
18
|
"build": "tsc && vite build --mode lib",
|
|
23
|
-
"release:patch": "yarn run build &&
|
|
24
|
-
"release:dev": "yarn run build && npm version prerelease && npm publish --tag latest --access public"
|
|
19
|
+
"release:patch": "yarn run build && npm version patch --no-git-tag-version && npm publish --access public",
|
|
20
|
+
"release:dev": "yarn run build && npm version prerelease --no-git-tag-version && npm publish --tag latest --access public"
|
|
25
21
|
},
|
|
26
22
|
"devDependencies": {
|
|
27
23
|
"@types/node": "latest",
|
|
@@ -29,6 +25,6 @@
|
|
|
29
25
|
"vite": "^3.0.4"
|
|
30
26
|
},
|
|
31
27
|
"peerDependencies": {
|
|
32
|
-
"@builder.io/qwik": ">=0.
|
|
28
|
+
"@builder.io/qwik": ">=0.0.108"
|
|
33
29
|
}
|
|
34
30
|
}
|
|
@@ -20,6 +20,13 @@ export interface ImageProps {
|
|
|
20
20
|
}
|
|
21
21
|
export declare const srcSetToUse: (props: any, state: any) => any;
|
|
22
22
|
export declare const webpSrcSet: (props: any, state: any) => any;
|
|
23
|
+
export declare const aspectRatioCss: (props: any, state: any) => {
|
|
24
|
+
position: string;
|
|
25
|
+
height: string;
|
|
26
|
+
width: string;
|
|
27
|
+
left: string;
|
|
28
|
+
top: string;
|
|
29
|
+
} | undefined;
|
|
23
30
|
export declare const Image: import("@builder.io/qwik").Component<ImageProps>;
|
|
24
31
|
export default Image;
|
|
25
|
-
export declare const STYLES = ".img-Image { \nopacity: 1;\ntransition: opacity 0.2s ease-in-out
|
|
32
|
+
export declare const STYLES = ".img-Image { \nopacity: 1;\ntransition: opacity 0.2s ease-in-out; }.div-Image { \nwidth: 100%;\npointer-events: none;\nfont-size: 0; }.div-Image-2 { \ndisplay: flex;\nflex-direction: column;\nalign-items: stretch;\nposition: absolute;\ntop: 0;\nleft: 0;\nwidth: 100%;\nheight: 100%; }";
|
|
@@ -9,6 +9,9 @@ export declare type RenderBlockProps = {
|
|
|
9
9
|
export declare const component: (props: any, state: any) => any;
|
|
10
10
|
export declare const tag: (props: any, state: any) => string;
|
|
11
11
|
export declare const useBlock: (props: any, state: any) => any;
|
|
12
|
+
export declare const actions: (props: any, state: any) => {
|
|
13
|
+
[index: string]: (event: Event) => any;
|
|
14
|
+
};
|
|
12
15
|
export declare const attributes: (props: any, state: any) => {
|
|
13
16
|
style?: CSSStyleDeclaration | Record<string, string | undefined> | undefined;
|
|
14
17
|
'builder-id': string | undefined;
|
|
@@ -11,6 +11,8 @@ export declare type RenderContentProps = {
|
|
|
11
11
|
apiKey: string;
|
|
12
12
|
customComponents?: RegisteredComponent[];
|
|
13
13
|
canTrack?: boolean;
|
|
14
|
+
locale?: string;
|
|
15
|
+
includeRefs?: boolean;
|
|
14
16
|
};
|
|
15
17
|
export declare const useContent: (props: any, state: any, elementRef: any) => BuilderContent | undefined;
|
|
16
18
|
export declare const canTrackToUse: (props: any, state: any, elementRef: any) => any;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { BuilderContextInterface } from '../context/types.js';
|
|
2
|
-
export declare function evaluate({ code, context, state, event, }: {
|
|
2
|
+
export declare function evaluate({ code, context, state, event, isExpression, }: {
|
|
3
3
|
code: string;
|
|
4
4
|
event?: Event;
|
|
5
|
+
isExpression?: boolean;
|
|
5
6
|
} & Pick<BuilderContextInterface, 'state' | 'context'>): any;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { BuilderContextInterface } from '../context/types.js';
|
|
2
2
|
import type { BuilderBlock } from '../types/builder-block.js';
|
|
3
|
-
export declare function
|
|
3
|
+
export declare function createEventHandler(value: string, options: {
|
|
4
4
|
block: BuilderBlock;
|
|
5
5
|
} & Pick<BuilderContextInterface, 'state' | 'context'>): (event: Event) => any;
|
|
@@ -1,2 +1,6 @@
|
|
|
1
|
+
import type { BuilderContextInterface } from '../context/types.js';
|
|
1
2
|
import type { BuilderBlock } from '../types/builder-block.js';
|
|
2
|
-
export declare function getBlockStyles(block
|
|
3
|
+
export declare function getBlockStyles({ block, context, }: {
|
|
4
|
+
block: BuilderBlock;
|
|
5
|
+
context: BuilderContextInterface;
|
|
6
|
+
}): Partial<CSSStyleDeclaration>;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
declare type QueryObject = Record<string, string>;
|
|
1
|
+
declare type QueryObject = Record<string, string | string[]>;
|
|
2
2
|
export declare const convertSearchParamsToQueryObject: (searchParams: URLSearchParams) => QueryObject;
|
|
3
3
|
export declare const getBuilderSearchParams: (_options: QueryObject | URLSearchParams | undefined) => QueryObject;
|
|
4
4
|
export declare const getBuilderSearchParamsFromWindow: () => QueryObject;
|
|
@@ -2,6 +2,9 @@ import type { BuilderContent } from '../../types/builder-content.js';
|
|
|
2
2
|
export declare type GetContentOptions = import('./types.js').GetContentOptions;
|
|
3
3
|
export declare function getContent(options: GetContentOptions): Promise<BuilderContent | null>;
|
|
4
4
|
export declare const generateContentUrl: (options: GetContentOptions) => URL;
|
|
5
|
+
/**
|
|
6
|
+
* TO-DO: Handle error responses.
|
|
7
|
+
*/
|
|
5
8
|
interface ContentResponse {
|
|
6
9
|
results: BuilderContent[];
|
|
7
10
|
}
|
|
@@ -32,4 +32,8 @@ export interface GetContentOptions {
|
|
|
32
32
|
* Include references in the response. Defaults to `true`.
|
|
33
33
|
*/
|
|
34
34
|
includeRefs?: boolean;
|
|
35
|
+
/**
|
|
36
|
+
* If provided, the API will auto-resolve localized objects to the value of this `locale` key.
|
|
37
|
+
*/
|
|
38
|
+
locale?: string;
|
|
35
39
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare function markMutable<T
|
|
2
|
-
export declare function markPropsMutable<T
|
|
1
|
+
export declare function markMutable<T>(value: T): T;
|
|
2
|
+
export declare function markPropsMutable<T>(props: T): T;
|
|
@@ -1,6 +1,11 @@
|
|
|
1
1
|
import type { CanTrack } from '../types/can-track.js';
|
|
2
2
|
interface Event {
|
|
3
|
-
|
|
3
|
+
/**
|
|
4
|
+
* The type of your event.
|
|
5
|
+
*
|
|
6
|
+
* Examples: `click`, `conversion`, `pageview`, `impression`
|
|
7
|
+
*/
|
|
8
|
+
type: string;
|
|
4
9
|
data: {
|
|
5
10
|
/**
|
|
6
11
|
* (Optional) The content's ID. Useful if this event pertains to a specific piece of content.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
declare const ON_MOUNT_CODE: "\n Object.values(props.customComponents).forEach((registeredComponent) => {\n sendComponentToVisualEditor(registeredComponent);\n });\n";
|
|
2
|
+
declare const REACT_CODE: string;
|
|
3
|
+
declare const VUE_CODE: string;
|
|
4
|
+
declare const SVELTE_CODE: string;
|
|
5
|
+
declare const SOLIDJS_CODE: string;
|
|
6
|
+
declare const QWIK_CODE: string;
|
package/types-hacks.d.ts
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
type Dictionary<T> = Record<string, T>;
|
|
2
|
+
type BuilderContent = any;
|
|
3
|
+
type BuilderBlock = any;
|
|
4
|
+
type RegisteredComponent = any;
|
|
5
|
+
type RegisteredComponents = any;
|
|
6
|
+
declare const builder: { env: 'dev'; apiKey: string };
|
|
7
|
+
// TODO(misko): HACKS to be removed
|
|
8
|
+
declare const get: (obj: any, key: string) => any;
|
|
9
|
+
declare const set: (obj: any, key: string, value: any) => void;
|
|
10
|
+
interface CSSProperties {
|
|
11
|
+
flexDirection: any;
|
|
12
|
+
}
|
|
13
|
+
declare const BuilderBlocks: (props: any) => any;
|
|
@@ -1,267 +0,0 @@
|
|
|
1
|
-
export declare const avatarService: any;
|
|
2
|
-
export declare const Avatar: import("@builder.io/qwik").Component<any>;
|
|
3
|
-
export default Avatar;
|
|
4
|
-
export declare const COMPONENT: {
|
|
5
|
-
"@type": string;
|
|
6
|
-
children: {
|
|
7
|
-
"@type": string;
|
|
8
|
-
bindings: {
|
|
9
|
-
when: {
|
|
10
|
-
code: string;
|
|
11
|
-
};
|
|
12
|
-
};
|
|
13
|
-
children: ({
|
|
14
|
-
"@type": string;
|
|
15
|
-
bindings: {
|
|
16
|
-
class?: undefined;
|
|
17
|
-
title?: undefined;
|
|
18
|
-
};
|
|
19
|
-
children: never[];
|
|
20
|
-
meta: {};
|
|
21
|
-
name: string;
|
|
22
|
-
properties: {
|
|
23
|
-
_text: string;
|
|
24
|
-
};
|
|
25
|
-
scope: {};
|
|
26
|
-
} | {
|
|
27
|
-
"@type": string;
|
|
28
|
-
bindings: {
|
|
29
|
-
class: {
|
|
30
|
-
code: string;
|
|
31
|
-
};
|
|
32
|
-
title: {
|
|
33
|
-
code: string;
|
|
34
|
-
};
|
|
35
|
-
};
|
|
36
|
-
children: ({
|
|
37
|
-
"@type": string;
|
|
38
|
-
bindings: {
|
|
39
|
-
when?: undefined;
|
|
40
|
-
};
|
|
41
|
-
children: never[];
|
|
42
|
-
meta: {};
|
|
43
|
-
name: string;
|
|
44
|
-
properties: {
|
|
45
|
-
_text: string;
|
|
46
|
-
};
|
|
47
|
-
scope: {};
|
|
48
|
-
} | {
|
|
49
|
-
"@type": string;
|
|
50
|
-
bindings: {
|
|
51
|
-
when: {
|
|
52
|
-
code: string;
|
|
53
|
-
};
|
|
54
|
-
};
|
|
55
|
-
children: ({
|
|
56
|
-
"@type": string;
|
|
57
|
-
bindings: {
|
|
58
|
-
class?: undefined;
|
|
59
|
-
style?: undefined;
|
|
60
|
-
};
|
|
61
|
-
children: never[];
|
|
62
|
-
meta: {};
|
|
63
|
-
name: string;
|
|
64
|
-
properties: {
|
|
65
|
-
_text: string;
|
|
66
|
-
};
|
|
67
|
-
scope: {};
|
|
68
|
-
} | {
|
|
69
|
-
"@type": string;
|
|
70
|
-
bindings: {
|
|
71
|
-
class: {
|
|
72
|
-
code: string;
|
|
73
|
-
};
|
|
74
|
-
style: {
|
|
75
|
-
code: string;
|
|
76
|
-
};
|
|
77
|
-
};
|
|
78
|
-
children: ({
|
|
79
|
-
"@type": string;
|
|
80
|
-
bindings: {
|
|
81
|
-
when?: undefined;
|
|
82
|
-
};
|
|
83
|
-
children: never[];
|
|
84
|
-
meta: {};
|
|
85
|
-
name: string;
|
|
86
|
-
properties: {
|
|
87
|
-
_text: string;
|
|
88
|
-
};
|
|
89
|
-
scope: {};
|
|
90
|
-
} | {
|
|
91
|
-
"@type": string;
|
|
92
|
-
bindings: {
|
|
93
|
-
when: {
|
|
94
|
-
code: string;
|
|
95
|
-
};
|
|
96
|
-
};
|
|
97
|
-
children: ({
|
|
98
|
-
"@type": string;
|
|
99
|
-
bindings: {
|
|
100
|
-
alt?: undefined;
|
|
101
|
-
src?: undefined;
|
|
102
|
-
};
|
|
103
|
-
children: never[];
|
|
104
|
-
meta: {};
|
|
105
|
-
name: string;
|
|
106
|
-
properties: {
|
|
107
|
-
_text: string;
|
|
108
|
-
class?: undefined;
|
|
109
|
-
};
|
|
110
|
-
scope: {};
|
|
111
|
-
} | {
|
|
112
|
-
"@type": string;
|
|
113
|
-
bindings: {
|
|
114
|
-
alt: {
|
|
115
|
-
code: string;
|
|
116
|
-
};
|
|
117
|
-
src: {
|
|
118
|
-
code: string;
|
|
119
|
-
};
|
|
120
|
-
};
|
|
121
|
-
children: never[];
|
|
122
|
-
meta: {};
|
|
123
|
-
name: string;
|
|
124
|
-
properties: {
|
|
125
|
-
class: string;
|
|
126
|
-
_text?: undefined;
|
|
127
|
-
};
|
|
128
|
-
scope: {};
|
|
129
|
-
})[];
|
|
130
|
-
meta: {};
|
|
131
|
-
name: string;
|
|
132
|
-
properties: {
|
|
133
|
-
_text?: undefined;
|
|
134
|
-
};
|
|
135
|
-
scope: {};
|
|
136
|
-
} | {
|
|
137
|
-
"@type": string;
|
|
138
|
-
bindings: {
|
|
139
|
-
when: {
|
|
140
|
-
code: string;
|
|
141
|
-
};
|
|
142
|
-
};
|
|
143
|
-
children: ({
|
|
144
|
-
"@type": string;
|
|
145
|
-
bindings: {};
|
|
146
|
-
children: never[];
|
|
147
|
-
meta: {};
|
|
148
|
-
name: string;
|
|
149
|
-
properties: {
|
|
150
|
-
_text: string;
|
|
151
|
-
};
|
|
152
|
-
scope: {};
|
|
153
|
-
} | {
|
|
154
|
-
"@type": string;
|
|
155
|
-
bindings: {};
|
|
156
|
-
children: {
|
|
157
|
-
"@type": string;
|
|
158
|
-
bindings: {
|
|
159
|
-
_text: {
|
|
160
|
-
code: string;
|
|
161
|
-
};
|
|
162
|
-
};
|
|
163
|
-
children: never[];
|
|
164
|
-
meta: {};
|
|
165
|
-
name: string;
|
|
166
|
-
properties: {};
|
|
167
|
-
scope: {};
|
|
168
|
-
}[];
|
|
169
|
-
meta: {};
|
|
170
|
-
name: string;
|
|
171
|
-
properties: {
|
|
172
|
-
_text?: undefined;
|
|
173
|
-
};
|
|
174
|
-
scope: {};
|
|
175
|
-
})[];
|
|
176
|
-
meta: {};
|
|
177
|
-
name: string;
|
|
178
|
-
properties: {
|
|
179
|
-
_text?: undefined;
|
|
180
|
-
};
|
|
181
|
-
scope: {};
|
|
182
|
-
})[];
|
|
183
|
-
meta: {};
|
|
184
|
-
name: string;
|
|
185
|
-
properties: {
|
|
186
|
-
_text?: undefined;
|
|
187
|
-
};
|
|
188
|
-
scope: {};
|
|
189
|
-
})[];
|
|
190
|
-
meta: {};
|
|
191
|
-
name: string;
|
|
192
|
-
properties: {
|
|
193
|
-
_text?: undefined;
|
|
194
|
-
};
|
|
195
|
-
scope: {};
|
|
196
|
-
})[];
|
|
197
|
-
meta: {};
|
|
198
|
-
name: string;
|
|
199
|
-
properties: {
|
|
200
|
-
_text?: undefined;
|
|
201
|
-
};
|
|
202
|
-
scope: {};
|
|
203
|
-
})[];
|
|
204
|
-
meta: {};
|
|
205
|
-
name: string;
|
|
206
|
-
properties: {};
|
|
207
|
-
scope: {};
|
|
208
|
-
}[];
|
|
209
|
-
context: {
|
|
210
|
-
get: {};
|
|
211
|
-
set: {};
|
|
212
|
-
};
|
|
213
|
-
exports: {
|
|
214
|
-
avatarService: {
|
|
215
|
-
code: string;
|
|
216
|
-
isFunction: boolean;
|
|
217
|
-
usedInLocal: boolean;
|
|
218
|
-
};
|
|
219
|
-
};
|
|
220
|
-
hooks: {
|
|
221
|
-
onMount: {
|
|
222
|
-
code: string;
|
|
223
|
-
};
|
|
224
|
-
};
|
|
225
|
-
imports: {
|
|
226
|
-
imports: {};
|
|
227
|
-
path: string;
|
|
228
|
-
}[];
|
|
229
|
-
inputs: never[];
|
|
230
|
-
meta: {
|
|
231
|
-
useMetadata: {
|
|
232
|
-
isAttachedToShadowDom: boolean;
|
|
233
|
-
};
|
|
234
|
-
};
|
|
235
|
-
name: string;
|
|
236
|
-
propsTypeRef: string;
|
|
237
|
-
refs: {};
|
|
238
|
-
state: {
|
|
239
|
-
classes: {
|
|
240
|
-
code: {
|
|
241
|
-
base: string;
|
|
242
|
-
container: string;
|
|
243
|
-
};
|
|
244
|
-
type: string;
|
|
245
|
-
};
|
|
246
|
-
initials: {
|
|
247
|
-
code: null;
|
|
248
|
-
type: string;
|
|
249
|
-
};
|
|
250
|
-
loaded: {
|
|
251
|
-
code: boolean;
|
|
252
|
-
type: string;
|
|
253
|
-
};
|
|
254
|
-
source: {
|
|
255
|
-
code: null;
|
|
256
|
-
type: string;
|
|
257
|
-
};
|
|
258
|
-
styles: {
|
|
259
|
-
code: {
|
|
260
|
-
container: null;
|
|
261
|
-
};
|
|
262
|
-
type: string;
|
|
263
|
-
};
|
|
264
|
-
};
|
|
265
|
-
subComponents: never[];
|
|
266
|
-
types: string[];
|
|
267
|
-
};
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import { BaseProps, BaseState, CSS, Dynamic, Variant } from '~/models';
|
|
2
|
-
export declare type AvatarProps = {
|
|
3
|
-
variant?: Dynamic<Variant>;
|
|
4
|
-
name?: string;
|
|
5
|
-
unavatar?: string;
|
|
6
|
-
url?: string;
|
|
7
|
-
disabled?: boolean;
|
|
8
|
-
} & BaseProps;
|
|
9
|
-
export declare type AvatarState = {
|
|
10
|
-
classes: {
|
|
11
|
-
base: string;
|
|
12
|
-
container: string;
|
|
13
|
-
};
|
|
14
|
-
styles: {
|
|
15
|
-
container: CSS;
|
|
16
|
-
};
|
|
17
|
-
initials: string;
|
|
18
|
-
source: string;
|
|
19
|
-
} & BaseState;
|