@builder.io/sdk-qwik 0.12.5 → 0.12.7
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/index.qwik.cjs +232 -11
- package/lib/browser/index.qwik.mjs +233 -12
- package/lib/edge/index.qwik.cjs +232 -11
- package/lib/edge/index.qwik.mjs +233 -12
- package/lib/node/index.qwik.cjs +232 -11
- package/lib/node/index.qwik.mjs +233 -12
- package/package.json +1 -1
- package/types/src/components/block/animator.d.ts +5 -0
- package/types/src/constants/sdk-version.d.ts +1 -1
- package/types/src/functions/evaluate/browser-runtime/browser.d.ts +5 -1
- package/types/src/types/builder-block.d.ts +18 -1
package/lib/edge/index.qwik.cjs
CHANGED
|
@@ -182,24 +182,36 @@ const runInBrowser = ({ code, builder, context, event, localState, rootSetState,
|
|
|
182
182
|
builder,
|
|
183
183
|
context,
|
|
184
184
|
event,
|
|
185
|
-
state: flattenState(
|
|
185
|
+
state: flattenState({
|
|
186
|
+
rootState,
|
|
187
|
+
localState,
|
|
188
|
+
rootSetState
|
|
189
|
+
})
|
|
186
190
|
});
|
|
187
191
|
return new Function(...functionArgs.map(([name]) => name), code)(...functionArgs.map(([, value]) => value));
|
|
188
192
|
};
|
|
189
|
-
function flattenState(rootState, localState, rootSetState) {
|
|
190
|
-
if (rootState === localState)
|
|
191
|
-
throw new Error("rootState === localState");
|
|
193
|
+
function flattenState({ rootState, localState, rootSetState }) {
|
|
192
194
|
return new Proxy(rootState, {
|
|
193
|
-
get: (
|
|
195
|
+
get: (target, prop) => {
|
|
194
196
|
if (localState && prop in localState)
|
|
195
197
|
return localState[prop];
|
|
196
|
-
|
|
198
|
+
const val = target[prop];
|
|
199
|
+
if (typeof val === "object")
|
|
200
|
+
return flattenState({
|
|
201
|
+
rootState: val,
|
|
202
|
+
localState: void 0,
|
|
203
|
+
rootSetState: rootSetState ? (subState) => {
|
|
204
|
+
target[prop] = subState;
|
|
205
|
+
rootSetState(target);
|
|
206
|
+
} : void 0
|
|
207
|
+
});
|
|
208
|
+
return val;
|
|
197
209
|
},
|
|
198
|
-
set: (
|
|
210
|
+
set: (target, prop, value) => {
|
|
199
211
|
if (localState && prop in localState)
|
|
200
212
|
throw new Error("Writing to local state is not allowed as it is read-only.");
|
|
201
|
-
|
|
202
|
-
rootSetState == null ? void 0 : rootSetState(
|
|
213
|
+
target[prop] = value;
|
|
214
|
+
rootSetState == null ? void 0 : rootSetState(target);
|
|
203
215
|
return true;
|
|
204
216
|
}
|
|
205
217
|
});
|
|
@@ -3532,6 +3544,201 @@ function getProcessedBlock({ block, context, shouldEvaluateBindings, localState,
|
|
|
3532
3544
|
else
|
|
3533
3545
|
return transformedBlock;
|
|
3534
3546
|
}
|
|
3547
|
+
function throttle(func, wait, options = {}) {
|
|
3548
|
+
let context;
|
|
3549
|
+
let args;
|
|
3550
|
+
let result;
|
|
3551
|
+
let timeout = null;
|
|
3552
|
+
let previous = 0;
|
|
3553
|
+
const later = function() {
|
|
3554
|
+
previous = options.leading === false ? 0 : Date.now();
|
|
3555
|
+
timeout = null;
|
|
3556
|
+
result = func.apply(context, args);
|
|
3557
|
+
if (!timeout)
|
|
3558
|
+
context = args = null;
|
|
3559
|
+
};
|
|
3560
|
+
return function() {
|
|
3561
|
+
const now = Date.now();
|
|
3562
|
+
if (!previous && options.leading === false)
|
|
3563
|
+
previous = now;
|
|
3564
|
+
const remaining = wait - (now - previous);
|
|
3565
|
+
context = this;
|
|
3566
|
+
args = arguments;
|
|
3567
|
+
if (remaining <= 0 || remaining > wait) {
|
|
3568
|
+
if (timeout) {
|
|
3569
|
+
clearTimeout(timeout);
|
|
3570
|
+
timeout = null;
|
|
3571
|
+
}
|
|
3572
|
+
previous = now;
|
|
3573
|
+
result = func.apply(context, args);
|
|
3574
|
+
if (!timeout)
|
|
3575
|
+
context = args = null;
|
|
3576
|
+
} else if (!timeout && options.trailing !== false)
|
|
3577
|
+
timeout = setTimeout(later, remaining);
|
|
3578
|
+
return result;
|
|
3579
|
+
};
|
|
3580
|
+
}
|
|
3581
|
+
function assign(target, ..._args) {
|
|
3582
|
+
const to = Object(target);
|
|
3583
|
+
for (let index = 1; index < arguments.length; index++) {
|
|
3584
|
+
const nextSource = arguments[index];
|
|
3585
|
+
if (nextSource != null) {
|
|
3586
|
+
for (const nextKey in nextSource)
|
|
3587
|
+
if (Object.prototype.hasOwnProperty.call(nextSource, nextKey))
|
|
3588
|
+
to[nextKey] = nextSource[nextKey];
|
|
3589
|
+
}
|
|
3590
|
+
}
|
|
3591
|
+
return to;
|
|
3592
|
+
}
|
|
3593
|
+
const camelCaseToKebabCase = (str) => str ? str.replace(/([A-Z])/g, (g) => `-${g[0].toLowerCase()}`) : "";
|
|
3594
|
+
function bindAnimations(animations) {
|
|
3595
|
+
for (const animation of animations)
|
|
3596
|
+
switch (animation.trigger) {
|
|
3597
|
+
case "pageLoad":
|
|
3598
|
+
triggerAnimation(animation);
|
|
3599
|
+
break;
|
|
3600
|
+
case "hover":
|
|
3601
|
+
bindHoverAnimation(animation);
|
|
3602
|
+
break;
|
|
3603
|
+
case "scrollInView":
|
|
3604
|
+
bindScrollInViewAnimation(animation);
|
|
3605
|
+
break;
|
|
3606
|
+
}
|
|
3607
|
+
}
|
|
3608
|
+
function warnElementNotPresent(id2) {
|
|
3609
|
+
console.warn(`Cannot animate element: element with ID ${id2} not found!`);
|
|
3610
|
+
}
|
|
3611
|
+
function augmentAnimation(animation, element) {
|
|
3612
|
+
const stylesUsed = getAllStylesUsed(animation);
|
|
3613
|
+
const computedStyle = getComputedStyle(element);
|
|
3614
|
+
const firstStyles = animation.steps[0].styles;
|
|
3615
|
+
const lastStyles = animation.steps[animation.steps.length - 1].styles;
|
|
3616
|
+
const bothStyles = [
|
|
3617
|
+
firstStyles,
|
|
3618
|
+
lastStyles
|
|
3619
|
+
];
|
|
3620
|
+
for (const styles of bothStyles) {
|
|
3621
|
+
for (const style of stylesUsed)
|
|
3622
|
+
if (!(style in styles))
|
|
3623
|
+
styles[style] = computedStyle[style];
|
|
3624
|
+
}
|
|
3625
|
+
}
|
|
3626
|
+
function getAllStylesUsed(animation) {
|
|
3627
|
+
const properties = [];
|
|
3628
|
+
for (const step of animation.steps) {
|
|
3629
|
+
for (const key in step.styles)
|
|
3630
|
+
if (properties.indexOf(key) === -1)
|
|
3631
|
+
properties.push(key);
|
|
3632
|
+
}
|
|
3633
|
+
return properties;
|
|
3634
|
+
}
|
|
3635
|
+
function triggerAnimation(animation) {
|
|
3636
|
+
const elements = Array.prototype.slice.call(document.getElementsByClassName(animation.elementId || animation.id || ""));
|
|
3637
|
+
if (!elements.length) {
|
|
3638
|
+
warnElementNotPresent(animation.elementId || animation.id || "");
|
|
3639
|
+
return;
|
|
3640
|
+
}
|
|
3641
|
+
Array.from(elements).forEach((element) => {
|
|
3642
|
+
augmentAnimation(animation, element);
|
|
3643
|
+
element.style.transition = "none";
|
|
3644
|
+
element.style.transitionDelay = "0";
|
|
3645
|
+
assign(element.style, animation.steps[0].styles);
|
|
3646
|
+
setTimeout(() => {
|
|
3647
|
+
element.style.transition = `all ${animation.duration}s ${camelCaseToKebabCase(animation.easing)}`;
|
|
3648
|
+
if (animation.delay)
|
|
3649
|
+
element.style.transitionDelay = animation.delay + "s";
|
|
3650
|
+
assign(element.style, animation.steps[1].styles);
|
|
3651
|
+
setTimeout(() => {
|
|
3652
|
+
element.style.transition = "";
|
|
3653
|
+
element.style.transitionDelay = "";
|
|
3654
|
+
}, (animation.delay || 0) * 1e3 + animation.duration * 1e3 + 100);
|
|
3655
|
+
});
|
|
3656
|
+
});
|
|
3657
|
+
}
|
|
3658
|
+
function bindHoverAnimation(animation) {
|
|
3659
|
+
const elements = Array.prototype.slice.call(document.getElementsByClassName(animation.elementId || animation.id || ""));
|
|
3660
|
+
if (!elements.length) {
|
|
3661
|
+
warnElementNotPresent(animation.elementId || animation.id || "");
|
|
3662
|
+
return;
|
|
3663
|
+
}
|
|
3664
|
+
Array.from(elements).forEach((element) => {
|
|
3665
|
+
augmentAnimation(animation, element);
|
|
3666
|
+
const defaultState = animation.steps[0].styles;
|
|
3667
|
+
const hoverState = animation.steps[1].styles;
|
|
3668
|
+
function attachDefaultState() {
|
|
3669
|
+
assign(element.style, defaultState);
|
|
3670
|
+
}
|
|
3671
|
+
function attachHoverState() {
|
|
3672
|
+
assign(element.style, hoverState);
|
|
3673
|
+
}
|
|
3674
|
+
attachDefaultState();
|
|
3675
|
+
element.addEventListener("mouseenter", attachHoverState);
|
|
3676
|
+
element.addEventListener("mouseleave", attachDefaultState);
|
|
3677
|
+
setTimeout(() => {
|
|
3678
|
+
element.style.transition = `all ${animation.duration}s ${camelCaseToKebabCase(animation.easing)}`;
|
|
3679
|
+
if (animation.delay)
|
|
3680
|
+
element.style.transitionDelay = animation.delay + "s";
|
|
3681
|
+
});
|
|
3682
|
+
});
|
|
3683
|
+
}
|
|
3684
|
+
function bindScrollInViewAnimation(animation) {
|
|
3685
|
+
const elements = Array.prototype.slice.call(document.getElementsByClassName(animation.elementId || animation.id || ""));
|
|
3686
|
+
if (!elements.length) {
|
|
3687
|
+
warnElementNotPresent(animation.elementId || animation.id || "");
|
|
3688
|
+
return;
|
|
3689
|
+
}
|
|
3690
|
+
Array.from(elements).forEach((element) => {
|
|
3691
|
+
augmentAnimation(animation, element);
|
|
3692
|
+
let triggered = false;
|
|
3693
|
+
let pendingAnimation = false;
|
|
3694
|
+
function immediateOnScroll() {
|
|
3695
|
+
if (!triggered && isScrolledIntoView(element)) {
|
|
3696
|
+
triggered = true;
|
|
3697
|
+
pendingAnimation = true;
|
|
3698
|
+
setTimeout(() => {
|
|
3699
|
+
assign(element.style, animation.steps[1].styles);
|
|
3700
|
+
if (!animation.repeat)
|
|
3701
|
+
document.removeEventListener("scroll", onScroll);
|
|
3702
|
+
setTimeout(() => {
|
|
3703
|
+
pendingAnimation = false;
|
|
3704
|
+
if (!animation.repeat) {
|
|
3705
|
+
element.style.transition = "";
|
|
3706
|
+
element.style.transitionDelay = "";
|
|
3707
|
+
}
|
|
3708
|
+
}, (animation.duration + (animation.delay || 0)) * 1e3 + 100);
|
|
3709
|
+
});
|
|
3710
|
+
} else if (animation.repeat && triggered && !pendingAnimation && !isScrolledIntoView(element)) {
|
|
3711
|
+
triggered = false;
|
|
3712
|
+
assign(element.style, animation.steps[0].styles);
|
|
3713
|
+
}
|
|
3714
|
+
}
|
|
3715
|
+
const onScroll = throttle(immediateOnScroll, 200, {
|
|
3716
|
+
leading: false
|
|
3717
|
+
});
|
|
3718
|
+
function isScrolledIntoView(elem) {
|
|
3719
|
+
const rect = elem.getBoundingClientRect();
|
|
3720
|
+
const windowHeight = window.innerHeight;
|
|
3721
|
+
const thresholdPercent = (animation.thresholdPercent || 0) / 100;
|
|
3722
|
+
const threshold = thresholdPercent * windowHeight;
|
|
3723
|
+
return rect.bottom > threshold && rect.top < windowHeight - threshold;
|
|
3724
|
+
}
|
|
3725
|
+
const defaultState = animation.steps[0].styles;
|
|
3726
|
+
function attachDefaultState() {
|
|
3727
|
+
assign(element.style, defaultState);
|
|
3728
|
+
}
|
|
3729
|
+
attachDefaultState();
|
|
3730
|
+
setTimeout(() => {
|
|
3731
|
+
element.style.transition = `all ${animation.duration}s ${camelCaseToKebabCase(animation.easing)}`;
|
|
3732
|
+
if (animation.delay)
|
|
3733
|
+
element.style.transitionDelay = animation.delay + "s";
|
|
3734
|
+
});
|
|
3735
|
+
document.addEventListener("scroll", onScroll, {
|
|
3736
|
+
capture: true,
|
|
3737
|
+
passive: true
|
|
3738
|
+
});
|
|
3739
|
+
immediateOnScroll();
|
|
3740
|
+
});
|
|
3741
|
+
}
|
|
3535
3742
|
const getComponent = ({ block, context, registeredComponents }) => {
|
|
3536
3743
|
var _a;
|
|
3537
3744
|
const componentName = (_a = getProcessedBlock({
|
|
@@ -4078,6 +4285,18 @@ const Block = /* @__PURE__ */ qwik.componentQrl(/* @__PURE__ */ qwik.inlinedQrl(
|
|
|
4078
4285
|
props,
|
|
4079
4286
|
state
|
|
4080
4287
|
]));
|
|
4288
|
+
qwik.useVisibleTaskQrl(/* @__PURE__ */ qwik.inlinedQrl(() => {
|
|
4289
|
+
const [processedBlock2] = qwik.useLexicalScope();
|
|
4290
|
+
const blockId = processedBlock2.value.id;
|
|
4291
|
+
const animations = processedBlock2.value.animations;
|
|
4292
|
+
if (animations && blockId)
|
|
4293
|
+
bindAnimations(animations.filter((item) => item.trigger !== "hover").map((animation) => ({
|
|
4294
|
+
...animation,
|
|
4295
|
+
elementId: blockId
|
|
4296
|
+
})));
|
|
4297
|
+
}, "Block_component_useVisibleTask_hrTYvqw0Tbs", [
|
|
4298
|
+
processedBlock
|
|
4299
|
+
]));
|
|
4081
4300
|
return /* @__PURE__ */ qwik._jsxC(jsxRuntime.Fragment, {
|
|
4082
4301
|
children: canShowBlock.value ? /* @__PURE__ */ qwik._jsxC(jsxRuntime.Fragment, {
|
|
4083
4302
|
children: [
|
|
@@ -6574,7 +6793,7 @@ const getInteractionPropertiesForEvent = (event) => {
|
|
|
6574
6793
|
}
|
|
6575
6794
|
};
|
|
6576
6795
|
};
|
|
6577
|
-
const SDK_VERSION = "0.12.
|
|
6796
|
+
const SDK_VERSION = "0.12.7";
|
|
6578
6797
|
const registry = {};
|
|
6579
6798
|
function register(type, info) {
|
|
6580
6799
|
let typeList = registry[type];
|
|
@@ -6759,6 +6978,9 @@ const processMessage = function processMessage2(props, state, elementRef, event)
|
|
|
6759
6978
|
state.forceReRenderCount = state.forceReRenderCount + 1;
|
|
6760
6979
|
break;
|
|
6761
6980
|
}
|
|
6981
|
+
case "builder.triggerAnimation":
|
|
6982
|
+
triggerAnimation(data.data);
|
|
6983
|
+
break;
|
|
6762
6984
|
case "builder.contentUpdate": {
|
|
6763
6985
|
const messageContent = data.data;
|
|
6764
6986
|
const key = messageContent.key || messageContent.alias || messageContent.entry || messageContent.modelName;
|
|
@@ -6969,7 +7191,6 @@ const EnableEditor = /* @__PURE__ */ qwik.componentQrl(/* @__PURE__ */ qwik.inli
|
|
|
6969
7191
|
var _a2, _b2;
|
|
6970
7192
|
return (_b2 = (_a2 = props2.builderContextSignal.content) == null ? void 0 : _a2.data) == null ? void 0 : _b2.jsCode;
|
|
6971
7193
|
});
|
|
6972
|
-
track2(() => props2.builderContextSignal.rootState);
|
|
6973
7194
|
evaluateJsCode(props2);
|
|
6974
7195
|
}, "EnableEditor_component_useTask_3_bQ0e5LHZwWE", [
|
|
6975
7196
|
elementRef,
|
package/lib/edge/index.qwik.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { componentQrl, inlinedQrl, _jsxBranch, _jsxC, Slot as Slot$1, _fnSignal, _IMMUTABLE, createContextId, _jsxQ, useComputedQrl, useLexicalScope, useStore, useContextProvider, _wrapProp, useStylesScopedQrl, useContext, Fragment as Fragment$1, _jsxS, useSignal, useOn, useTaskQrl, createElement } from "@builder.io/qwik";
|
|
1
|
+
import { componentQrl, inlinedQrl, _jsxBranch, _jsxC, Slot as Slot$1, _fnSignal, _IMMUTABLE, createContextId, _jsxQ, useComputedQrl, useLexicalScope, useStore, useContextProvider, useVisibleTaskQrl, _wrapProp, useStylesScopedQrl, useContext, Fragment as Fragment$1, _jsxS, useSignal, useOn, useTaskQrl, createElement } from "@builder.io/qwik";
|
|
2
2
|
import { Fragment } from "@builder.io/qwik/jsx-runtime";
|
|
3
3
|
import { isBrowser as isBrowser$1 } from "@builder.io/qwik/build";
|
|
4
4
|
const EMPTY_HTML_ELEMENTS = /* @__PURE__ */ new Set([
|
|
@@ -180,24 +180,36 @@ const runInBrowser = ({ code, builder, context, event, localState, rootSetState,
|
|
|
180
180
|
builder,
|
|
181
181
|
context,
|
|
182
182
|
event,
|
|
183
|
-
state: flattenState(
|
|
183
|
+
state: flattenState({
|
|
184
|
+
rootState,
|
|
185
|
+
localState,
|
|
186
|
+
rootSetState
|
|
187
|
+
})
|
|
184
188
|
});
|
|
185
189
|
return new Function(...functionArgs.map(([name]) => name), code)(...functionArgs.map(([, value]) => value));
|
|
186
190
|
};
|
|
187
|
-
function flattenState(rootState, localState, rootSetState) {
|
|
188
|
-
if (rootState === localState)
|
|
189
|
-
throw new Error("rootState === localState");
|
|
191
|
+
function flattenState({ rootState, localState, rootSetState }) {
|
|
190
192
|
return new Proxy(rootState, {
|
|
191
|
-
get: (
|
|
193
|
+
get: (target, prop) => {
|
|
192
194
|
if (localState && prop in localState)
|
|
193
195
|
return localState[prop];
|
|
194
|
-
|
|
196
|
+
const val = target[prop];
|
|
197
|
+
if (typeof val === "object")
|
|
198
|
+
return flattenState({
|
|
199
|
+
rootState: val,
|
|
200
|
+
localState: void 0,
|
|
201
|
+
rootSetState: rootSetState ? (subState) => {
|
|
202
|
+
target[prop] = subState;
|
|
203
|
+
rootSetState(target);
|
|
204
|
+
} : void 0
|
|
205
|
+
});
|
|
206
|
+
return val;
|
|
195
207
|
},
|
|
196
|
-
set: (
|
|
208
|
+
set: (target, prop, value) => {
|
|
197
209
|
if (localState && prop in localState)
|
|
198
210
|
throw new Error("Writing to local state is not allowed as it is read-only.");
|
|
199
|
-
|
|
200
|
-
rootSetState == null ? void 0 : rootSetState(
|
|
211
|
+
target[prop] = value;
|
|
212
|
+
rootSetState == null ? void 0 : rootSetState(target);
|
|
201
213
|
return true;
|
|
202
214
|
}
|
|
203
215
|
});
|
|
@@ -3530,6 +3542,201 @@ function getProcessedBlock({ block, context, shouldEvaluateBindings, localState,
|
|
|
3530
3542
|
else
|
|
3531
3543
|
return transformedBlock;
|
|
3532
3544
|
}
|
|
3545
|
+
function throttle(func, wait, options = {}) {
|
|
3546
|
+
let context;
|
|
3547
|
+
let args;
|
|
3548
|
+
let result;
|
|
3549
|
+
let timeout = null;
|
|
3550
|
+
let previous = 0;
|
|
3551
|
+
const later = function() {
|
|
3552
|
+
previous = options.leading === false ? 0 : Date.now();
|
|
3553
|
+
timeout = null;
|
|
3554
|
+
result = func.apply(context, args);
|
|
3555
|
+
if (!timeout)
|
|
3556
|
+
context = args = null;
|
|
3557
|
+
};
|
|
3558
|
+
return function() {
|
|
3559
|
+
const now = Date.now();
|
|
3560
|
+
if (!previous && options.leading === false)
|
|
3561
|
+
previous = now;
|
|
3562
|
+
const remaining = wait - (now - previous);
|
|
3563
|
+
context = this;
|
|
3564
|
+
args = arguments;
|
|
3565
|
+
if (remaining <= 0 || remaining > wait) {
|
|
3566
|
+
if (timeout) {
|
|
3567
|
+
clearTimeout(timeout);
|
|
3568
|
+
timeout = null;
|
|
3569
|
+
}
|
|
3570
|
+
previous = now;
|
|
3571
|
+
result = func.apply(context, args);
|
|
3572
|
+
if (!timeout)
|
|
3573
|
+
context = args = null;
|
|
3574
|
+
} else if (!timeout && options.trailing !== false)
|
|
3575
|
+
timeout = setTimeout(later, remaining);
|
|
3576
|
+
return result;
|
|
3577
|
+
};
|
|
3578
|
+
}
|
|
3579
|
+
function assign(target, ..._args) {
|
|
3580
|
+
const to = Object(target);
|
|
3581
|
+
for (let index = 1; index < arguments.length; index++) {
|
|
3582
|
+
const nextSource = arguments[index];
|
|
3583
|
+
if (nextSource != null) {
|
|
3584
|
+
for (const nextKey in nextSource)
|
|
3585
|
+
if (Object.prototype.hasOwnProperty.call(nextSource, nextKey))
|
|
3586
|
+
to[nextKey] = nextSource[nextKey];
|
|
3587
|
+
}
|
|
3588
|
+
}
|
|
3589
|
+
return to;
|
|
3590
|
+
}
|
|
3591
|
+
const camelCaseToKebabCase = (str) => str ? str.replace(/([A-Z])/g, (g) => `-${g[0].toLowerCase()}`) : "";
|
|
3592
|
+
function bindAnimations(animations) {
|
|
3593
|
+
for (const animation of animations)
|
|
3594
|
+
switch (animation.trigger) {
|
|
3595
|
+
case "pageLoad":
|
|
3596
|
+
triggerAnimation(animation);
|
|
3597
|
+
break;
|
|
3598
|
+
case "hover":
|
|
3599
|
+
bindHoverAnimation(animation);
|
|
3600
|
+
break;
|
|
3601
|
+
case "scrollInView":
|
|
3602
|
+
bindScrollInViewAnimation(animation);
|
|
3603
|
+
break;
|
|
3604
|
+
}
|
|
3605
|
+
}
|
|
3606
|
+
function warnElementNotPresent(id2) {
|
|
3607
|
+
console.warn(`Cannot animate element: element with ID ${id2} not found!`);
|
|
3608
|
+
}
|
|
3609
|
+
function augmentAnimation(animation, element) {
|
|
3610
|
+
const stylesUsed = getAllStylesUsed(animation);
|
|
3611
|
+
const computedStyle = getComputedStyle(element);
|
|
3612
|
+
const firstStyles = animation.steps[0].styles;
|
|
3613
|
+
const lastStyles = animation.steps[animation.steps.length - 1].styles;
|
|
3614
|
+
const bothStyles = [
|
|
3615
|
+
firstStyles,
|
|
3616
|
+
lastStyles
|
|
3617
|
+
];
|
|
3618
|
+
for (const styles of bothStyles) {
|
|
3619
|
+
for (const style of stylesUsed)
|
|
3620
|
+
if (!(style in styles))
|
|
3621
|
+
styles[style] = computedStyle[style];
|
|
3622
|
+
}
|
|
3623
|
+
}
|
|
3624
|
+
function getAllStylesUsed(animation) {
|
|
3625
|
+
const properties = [];
|
|
3626
|
+
for (const step of animation.steps) {
|
|
3627
|
+
for (const key in step.styles)
|
|
3628
|
+
if (properties.indexOf(key) === -1)
|
|
3629
|
+
properties.push(key);
|
|
3630
|
+
}
|
|
3631
|
+
return properties;
|
|
3632
|
+
}
|
|
3633
|
+
function triggerAnimation(animation) {
|
|
3634
|
+
const elements = Array.prototype.slice.call(document.getElementsByClassName(animation.elementId || animation.id || ""));
|
|
3635
|
+
if (!elements.length) {
|
|
3636
|
+
warnElementNotPresent(animation.elementId || animation.id || "");
|
|
3637
|
+
return;
|
|
3638
|
+
}
|
|
3639
|
+
Array.from(elements).forEach((element) => {
|
|
3640
|
+
augmentAnimation(animation, element);
|
|
3641
|
+
element.style.transition = "none";
|
|
3642
|
+
element.style.transitionDelay = "0";
|
|
3643
|
+
assign(element.style, animation.steps[0].styles);
|
|
3644
|
+
setTimeout(() => {
|
|
3645
|
+
element.style.transition = `all ${animation.duration}s ${camelCaseToKebabCase(animation.easing)}`;
|
|
3646
|
+
if (animation.delay)
|
|
3647
|
+
element.style.transitionDelay = animation.delay + "s";
|
|
3648
|
+
assign(element.style, animation.steps[1].styles);
|
|
3649
|
+
setTimeout(() => {
|
|
3650
|
+
element.style.transition = "";
|
|
3651
|
+
element.style.transitionDelay = "";
|
|
3652
|
+
}, (animation.delay || 0) * 1e3 + animation.duration * 1e3 + 100);
|
|
3653
|
+
});
|
|
3654
|
+
});
|
|
3655
|
+
}
|
|
3656
|
+
function bindHoverAnimation(animation) {
|
|
3657
|
+
const elements = Array.prototype.slice.call(document.getElementsByClassName(animation.elementId || animation.id || ""));
|
|
3658
|
+
if (!elements.length) {
|
|
3659
|
+
warnElementNotPresent(animation.elementId || animation.id || "");
|
|
3660
|
+
return;
|
|
3661
|
+
}
|
|
3662
|
+
Array.from(elements).forEach((element) => {
|
|
3663
|
+
augmentAnimation(animation, element);
|
|
3664
|
+
const defaultState = animation.steps[0].styles;
|
|
3665
|
+
const hoverState = animation.steps[1].styles;
|
|
3666
|
+
function attachDefaultState() {
|
|
3667
|
+
assign(element.style, defaultState);
|
|
3668
|
+
}
|
|
3669
|
+
function attachHoverState() {
|
|
3670
|
+
assign(element.style, hoverState);
|
|
3671
|
+
}
|
|
3672
|
+
attachDefaultState();
|
|
3673
|
+
element.addEventListener("mouseenter", attachHoverState);
|
|
3674
|
+
element.addEventListener("mouseleave", attachDefaultState);
|
|
3675
|
+
setTimeout(() => {
|
|
3676
|
+
element.style.transition = `all ${animation.duration}s ${camelCaseToKebabCase(animation.easing)}`;
|
|
3677
|
+
if (animation.delay)
|
|
3678
|
+
element.style.transitionDelay = animation.delay + "s";
|
|
3679
|
+
});
|
|
3680
|
+
});
|
|
3681
|
+
}
|
|
3682
|
+
function bindScrollInViewAnimation(animation) {
|
|
3683
|
+
const elements = Array.prototype.slice.call(document.getElementsByClassName(animation.elementId || animation.id || ""));
|
|
3684
|
+
if (!elements.length) {
|
|
3685
|
+
warnElementNotPresent(animation.elementId || animation.id || "");
|
|
3686
|
+
return;
|
|
3687
|
+
}
|
|
3688
|
+
Array.from(elements).forEach((element) => {
|
|
3689
|
+
augmentAnimation(animation, element);
|
|
3690
|
+
let triggered = false;
|
|
3691
|
+
let pendingAnimation = false;
|
|
3692
|
+
function immediateOnScroll() {
|
|
3693
|
+
if (!triggered && isScrolledIntoView(element)) {
|
|
3694
|
+
triggered = true;
|
|
3695
|
+
pendingAnimation = true;
|
|
3696
|
+
setTimeout(() => {
|
|
3697
|
+
assign(element.style, animation.steps[1].styles);
|
|
3698
|
+
if (!animation.repeat)
|
|
3699
|
+
document.removeEventListener("scroll", onScroll);
|
|
3700
|
+
setTimeout(() => {
|
|
3701
|
+
pendingAnimation = false;
|
|
3702
|
+
if (!animation.repeat) {
|
|
3703
|
+
element.style.transition = "";
|
|
3704
|
+
element.style.transitionDelay = "";
|
|
3705
|
+
}
|
|
3706
|
+
}, (animation.duration + (animation.delay || 0)) * 1e3 + 100);
|
|
3707
|
+
});
|
|
3708
|
+
} else if (animation.repeat && triggered && !pendingAnimation && !isScrolledIntoView(element)) {
|
|
3709
|
+
triggered = false;
|
|
3710
|
+
assign(element.style, animation.steps[0].styles);
|
|
3711
|
+
}
|
|
3712
|
+
}
|
|
3713
|
+
const onScroll = throttle(immediateOnScroll, 200, {
|
|
3714
|
+
leading: false
|
|
3715
|
+
});
|
|
3716
|
+
function isScrolledIntoView(elem) {
|
|
3717
|
+
const rect = elem.getBoundingClientRect();
|
|
3718
|
+
const windowHeight = window.innerHeight;
|
|
3719
|
+
const thresholdPercent = (animation.thresholdPercent || 0) / 100;
|
|
3720
|
+
const threshold = thresholdPercent * windowHeight;
|
|
3721
|
+
return rect.bottom > threshold && rect.top < windowHeight - threshold;
|
|
3722
|
+
}
|
|
3723
|
+
const defaultState = animation.steps[0].styles;
|
|
3724
|
+
function attachDefaultState() {
|
|
3725
|
+
assign(element.style, defaultState);
|
|
3726
|
+
}
|
|
3727
|
+
attachDefaultState();
|
|
3728
|
+
setTimeout(() => {
|
|
3729
|
+
element.style.transition = `all ${animation.duration}s ${camelCaseToKebabCase(animation.easing)}`;
|
|
3730
|
+
if (animation.delay)
|
|
3731
|
+
element.style.transitionDelay = animation.delay + "s";
|
|
3732
|
+
});
|
|
3733
|
+
document.addEventListener("scroll", onScroll, {
|
|
3734
|
+
capture: true,
|
|
3735
|
+
passive: true
|
|
3736
|
+
});
|
|
3737
|
+
immediateOnScroll();
|
|
3738
|
+
});
|
|
3739
|
+
}
|
|
3533
3740
|
const getComponent = ({ block, context, registeredComponents }) => {
|
|
3534
3741
|
var _a;
|
|
3535
3742
|
const componentName = (_a = getProcessedBlock({
|
|
@@ -4076,6 +4283,18 @@ const Block = /* @__PURE__ */ componentQrl(/* @__PURE__ */ inlinedQrl((props) =>
|
|
|
4076
4283
|
props,
|
|
4077
4284
|
state
|
|
4078
4285
|
]));
|
|
4286
|
+
useVisibleTaskQrl(/* @__PURE__ */ inlinedQrl(() => {
|
|
4287
|
+
const [processedBlock2] = useLexicalScope();
|
|
4288
|
+
const blockId = processedBlock2.value.id;
|
|
4289
|
+
const animations = processedBlock2.value.animations;
|
|
4290
|
+
if (animations && blockId)
|
|
4291
|
+
bindAnimations(animations.filter((item) => item.trigger !== "hover").map((animation) => ({
|
|
4292
|
+
...animation,
|
|
4293
|
+
elementId: blockId
|
|
4294
|
+
})));
|
|
4295
|
+
}, "Block_component_useVisibleTask_hrTYvqw0Tbs", [
|
|
4296
|
+
processedBlock
|
|
4297
|
+
]));
|
|
4079
4298
|
return /* @__PURE__ */ _jsxC(Fragment, {
|
|
4080
4299
|
children: canShowBlock.value ? /* @__PURE__ */ _jsxC(Fragment, {
|
|
4081
4300
|
children: [
|
|
@@ -6572,7 +6791,7 @@ const getInteractionPropertiesForEvent = (event) => {
|
|
|
6572
6791
|
}
|
|
6573
6792
|
};
|
|
6574
6793
|
};
|
|
6575
|
-
const SDK_VERSION = "0.12.
|
|
6794
|
+
const SDK_VERSION = "0.12.7";
|
|
6576
6795
|
const registry = {};
|
|
6577
6796
|
function register(type, info) {
|
|
6578
6797
|
let typeList = registry[type];
|
|
@@ -6757,6 +6976,9 @@ const processMessage = function processMessage2(props, state, elementRef, event)
|
|
|
6757
6976
|
state.forceReRenderCount = state.forceReRenderCount + 1;
|
|
6758
6977
|
break;
|
|
6759
6978
|
}
|
|
6979
|
+
case "builder.triggerAnimation":
|
|
6980
|
+
triggerAnimation(data.data);
|
|
6981
|
+
break;
|
|
6760
6982
|
case "builder.contentUpdate": {
|
|
6761
6983
|
const messageContent = data.data;
|
|
6762
6984
|
const key = messageContent.key || messageContent.alias || messageContent.entry || messageContent.modelName;
|
|
@@ -6967,7 +7189,6 @@ const EnableEditor = /* @__PURE__ */ componentQrl(/* @__PURE__ */ inlinedQrl((pr
|
|
|
6967
7189
|
var _a2, _b2;
|
|
6968
7190
|
return (_b2 = (_a2 = props2.builderContextSignal.content) == null ? void 0 : _a2.data) == null ? void 0 : _b2.jsCode;
|
|
6969
7191
|
});
|
|
6970
|
-
track2(() => props2.builderContextSignal.rootState);
|
|
6971
7192
|
evaluateJsCode(props2);
|
|
6972
7193
|
}, "EnableEditor_component_useTask_3_bQ0e5LHZwWE", [
|
|
6973
7194
|
elementRef,
|