@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
|
@@ -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
|
});
|
|
@@ -301,6 +313,201 @@ function getProcessedBlock({ block, context, shouldEvaluateBindings, localState,
|
|
|
301
313
|
else
|
|
302
314
|
return transformedBlock;
|
|
303
315
|
}
|
|
316
|
+
function throttle(func, wait, options = {}) {
|
|
317
|
+
let context;
|
|
318
|
+
let args;
|
|
319
|
+
let result;
|
|
320
|
+
let timeout = null;
|
|
321
|
+
let previous = 0;
|
|
322
|
+
const later = function() {
|
|
323
|
+
previous = options.leading === false ? 0 : Date.now();
|
|
324
|
+
timeout = null;
|
|
325
|
+
result = func.apply(context, args);
|
|
326
|
+
if (!timeout)
|
|
327
|
+
context = args = null;
|
|
328
|
+
};
|
|
329
|
+
return function() {
|
|
330
|
+
const now = Date.now();
|
|
331
|
+
if (!previous && options.leading === false)
|
|
332
|
+
previous = now;
|
|
333
|
+
const remaining = wait - (now - previous);
|
|
334
|
+
context = this;
|
|
335
|
+
args = arguments;
|
|
336
|
+
if (remaining <= 0 || remaining > wait) {
|
|
337
|
+
if (timeout) {
|
|
338
|
+
clearTimeout(timeout);
|
|
339
|
+
timeout = null;
|
|
340
|
+
}
|
|
341
|
+
previous = now;
|
|
342
|
+
result = func.apply(context, args);
|
|
343
|
+
if (!timeout)
|
|
344
|
+
context = args = null;
|
|
345
|
+
} else if (!timeout && options.trailing !== false)
|
|
346
|
+
timeout = setTimeout(later, remaining);
|
|
347
|
+
return result;
|
|
348
|
+
};
|
|
349
|
+
}
|
|
350
|
+
function assign(target, ..._args) {
|
|
351
|
+
const to = Object(target);
|
|
352
|
+
for (let index = 1; index < arguments.length; index++) {
|
|
353
|
+
const nextSource = arguments[index];
|
|
354
|
+
if (nextSource != null) {
|
|
355
|
+
for (const nextKey in nextSource)
|
|
356
|
+
if (Object.prototype.hasOwnProperty.call(nextSource, nextKey))
|
|
357
|
+
to[nextKey] = nextSource[nextKey];
|
|
358
|
+
}
|
|
359
|
+
}
|
|
360
|
+
return to;
|
|
361
|
+
}
|
|
362
|
+
const camelCaseToKebabCase = (str) => str ? str.replace(/([A-Z])/g, (g) => `-${g[0].toLowerCase()}`) : "";
|
|
363
|
+
function bindAnimations(animations) {
|
|
364
|
+
for (const animation of animations)
|
|
365
|
+
switch (animation.trigger) {
|
|
366
|
+
case "pageLoad":
|
|
367
|
+
triggerAnimation(animation);
|
|
368
|
+
break;
|
|
369
|
+
case "hover":
|
|
370
|
+
bindHoverAnimation(animation);
|
|
371
|
+
break;
|
|
372
|
+
case "scrollInView":
|
|
373
|
+
bindScrollInViewAnimation(animation);
|
|
374
|
+
break;
|
|
375
|
+
}
|
|
376
|
+
}
|
|
377
|
+
function warnElementNotPresent(id) {
|
|
378
|
+
console.warn(`Cannot animate element: element with ID ${id} not found!`);
|
|
379
|
+
}
|
|
380
|
+
function augmentAnimation(animation, element) {
|
|
381
|
+
const stylesUsed = getAllStylesUsed(animation);
|
|
382
|
+
const computedStyle = getComputedStyle(element);
|
|
383
|
+
const firstStyles = animation.steps[0].styles;
|
|
384
|
+
const lastStyles = animation.steps[animation.steps.length - 1].styles;
|
|
385
|
+
const bothStyles = [
|
|
386
|
+
firstStyles,
|
|
387
|
+
lastStyles
|
|
388
|
+
];
|
|
389
|
+
for (const styles of bothStyles) {
|
|
390
|
+
for (const style of stylesUsed)
|
|
391
|
+
if (!(style in styles))
|
|
392
|
+
styles[style] = computedStyle[style];
|
|
393
|
+
}
|
|
394
|
+
}
|
|
395
|
+
function getAllStylesUsed(animation) {
|
|
396
|
+
const properties = [];
|
|
397
|
+
for (const step of animation.steps) {
|
|
398
|
+
for (const key in step.styles)
|
|
399
|
+
if (properties.indexOf(key) === -1)
|
|
400
|
+
properties.push(key);
|
|
401
|
+
}
|
|
402
|
+
return properties;
|
|
403
|
+
}
|
|
404
|
+
function triggerAnimation(animation) {
|
|
405
|
+
const elements = Array.prototype.slice.call(document.getElementsByClassName(animation.elementId || animation.id || ""));
|
|
406
|
+
if (!elements.length) {
|
|
407
|
+
warnElementNotPresent(animation.elementId || animation.id || "");
|
|
408
|
+
return;
|
|
409
|
+
}
|
|
410
|
+
Array.from(elements).forEach((element) => {
|
|
411
|
+
augmentAnimation(animation, element);
|
|
412
|
+
element.style.transition = "none";
|
|
413
|
+
element.style.transitionDelay = "0";
|
|
414
|
+
assign(element.style, animation.steps[0].styles);
|
|
415
|
+
setTimeout(() => {
|
|
416
|
+
element.style.transition = `all ${animation.duration}s ${camelCaseToKebabCase(animation.easing)}`;
|
|
417
|
+
if (animation.delay)
|
|
418
|
+
element.style.transitionDelay = animation.delay + "s";
|
|
419
|
+
assign(element.style, animation.steps[1].styles);
|
|
420
|
+
setTimeout(() => {
|
|
421
|
+
element.style.transition = "";
|
|
422
|
+
element.style.transitionDelay = "";
|
|
423
|
+
}, (animation.delay || 0) * 1e3 + animation.duration * 1e3 + 100);
|
|
424
|
+
});
|
|
425
|
+
});
|
|
426
|
+
}
|
|
427
|
+
function bindHoverAnimation(animation) {
|
|
428
|
+
const elements = Array.prototype.slice.call(document.getElementsByClassName(animation.elementId || animation.id || ""));
|
|
429
|
+
if (!elements.length) {
|
|
430
|
+
warnElementNotPresent(animation.elementId || animation.id || "");
|
|
431
|
+
return;
|
|
432
|
+
}
|
|
433
|
+
Array.from(elements).forEach((element) => {
|
|
434
|
+
augmentAnimation(animation, element);
|
|
435
|
+
const defaultState = animation.steps[0].styles;
|
|
436
|
+
const hoverState = animation.steps[1].styles;
|
|
437
|
+
function attachDefaultState() {
|
|
438
|
+
assign(element.style, defaultState);
|
|
439
|
+
}
|
|
440
|
+
function attachHoverState() {
|
|
441
|
+
assign(element.style, hoverState);
|
|
442
|
+
}
|
|
443
|
+
attachDefaultState();
|
|
444
|
+
element.addEventListener("mouseenter", attachHoverState);
|
|
445
|
+
element.addEventListener("mouseleave", attachDefaultState);
|
|
446
|
+
setTimeout(() => {
|
|
447
|
+
element.style.transition = `all ${animation.duration}s ${camelCaseToKebabCase(animation.easing)}`;
|
|
448
|
+
if (animation.delay)
|
|
449
|
+
element.style.transitionDelay = animation.delay + "s";
|
|
450
|
+
});
|
|
451
|
+
});
|
|
452
|
+
}
|
|
453
|
+
function bindScrollInViewAnimation(animation) {
|
|
454
|
+
const elements = Array.prototype.slice.call(document.getElementsByClassName(animation.elementId || animation.id || ""));
|
|
455
|
+
if (!elements.length) {
|
|
456
|
+
warnElementNotPresent(animation.elementId || animation.id || "");
|
|
457
|
+
return;
|
|
458
|
+
}
|
|
459
|
+
Array.from(elements).forEach((element) => {
|
|
460
|
+
augmentAnimation(animation, element);
|
|
461
|
+
let triggered = false;
|
|
462
|
+
let pendingAnimation = false;
|
|
463
|
+
function immediateOnScroll() {
|
|
464
|
+
if (!triggered && isScrolledIntoView(element)) {
|
|
465
|
+
triggered = true;
|
|
466
|
+
pendingAnimation = true;
|
|
467
|
+
setTimeout(() => {
|
|
468
|
+
assign(element.style, animation.steps[1].styles);
|
|
469
|
+
if (!animation.repeat)
|
|
470
|
+
document.removeEventListener("scroll", onScroll);
|
|
471
|
+
setTimeout(() => {
|
|
472
|
+
pendingAnimation = false;
|
|
473
|
+
if (!animation.repeat) {
|
|
474
|
+
element.style.transition = "";
|
|
475
|
+
element.style.transitionDelay = "";
|
|
476
|
+
}
|
|
477
|
+
}, (animation.duration + (animation.delay || 0)) * 1e3 + 100);
|
|
478
|
+
});
|
|
479
|
+
} else if (animation.repeat && triggered && !pendingAnimation && !isScrolledIntoView(element)) {
|
|
480
|
+
triggered = false;
|
|
481
|
+
assign(element.style, animation.steps[0].styles);
|
|
482
|
+
}
|
|
483
|
+
}
|
|
484
|
+
const onScroll = throttle(immediateOnScroll, 200, {
|
|
485
|
+
leading: false
|
|
486
|
+
});
|
|
487
|
+
function isScrolledIntoView(elem) {
|
|
488
|
+
const rect = elem.getBoundingClientRect();
|
|
489
|
+
const windowHeight = window.innerHeight;
|
|
490
|
+
const thresholdPercent = (animation.thresholdPercent || 0) / 100;
|
|
491
|
+
const threshold = thresholdPercent * windowHeight;
|
|
492
|
+
return rect.bottom > threshold && rect.top < windowHeight - threshold;
|
|
493
|
+
}
|
|
494
|
+
const defaultState = animation.steps[0].styles;
|
|
495
|
+
function attachDefaultState() {
|
|
496
|
+
assign(element.style, defaultState);
|
|
497
|
+
}
|
|
498
|
+
attachDefaultState();
|
|
499
|
+
setTimeout(() => {
|
|
500
|
+
element.style.transition = `all ${animation.duration}s ${camelCaseToKebabCase(animation.easing)}`;
|
|
501
|
+
if (animation.delay)
|
|
502
|
+
element.style.transitionDelay = animation.delay + "s";
|
|
503
|
+
});
|
|
504
|
+
document.addEventListener("scroll", onScroll, {
|
|
505
|
+
capture: true,
|
|
506
|
+
passive: true
|
|
507
|
+
});
|
|
508
|
+
immediateOnScroll();
|
|
509
|
+
});
|
|
510
|
+
}
|
|
304
511
|
const getComponent = ({ block, context, registeredComponents }) => {
|
|
305
512
|
var _a;
|
|
306
513
|
const componentName = (_a = getProcessedBlock({
|
|
@@ -847,6 +1054,18 @@ const Block = /* @__PURE__ */ qwik.componentQrl(/* @__PURE__ */ qwik.inlinedQrl(
|
|
|
847
1054
|
props,
|
|
848
1055
|
state
|
|
849
1056
|
]));
|
|
1057
|
+
qwik.useVisibleTaskQrl(/* @__PURE__ */ qwik.inlinedQrl(() => {
|
|
1058
|
+
const [processedBlock2] = qwik.useLexicalScope();
|
|
1059
|
+
const blockId = processedBlock2.value.id;
|
|
1060
|
+
const animations = processedBlock2.value.animations;
|
|
1061
|
+
if (animations && blockId)
|
|
1062
|
+
bindAnimations(animations.filter((item) => item.trigger !== "hover").map((animation) => ({
|
|
1063
|
+
...animation,
|
|
1064
|
+
elementId: blockId
|
|
1065
|
+
})));
|
|
1066
|
+
}, "Block_component_useVisibleTask_hrTYvqw0Tbs", [
|
|
1067
|
+
processedBlock
|
|
1068
|
+
]));
|
|
850
1069
|
return /* @__PURE__ */ qwik._jsxC(jsxRuntime.Fragment, {
|
|
851
1070
|
children: canShowBlock.value ? /* @__PURE__ */ qwik._jsxC(jsxRuntime.Fragment, {
|
|
852
1071
|
children: [
|
|
@@ -3343,7 +3562,7 @@ const getInteractionPropertiesForEvent = (event) => {
|
|
|
3343
3562
|
}
|
|
3344
3563
|
};
|
|
3345
3564
|
};
|
|
3346
|
-
const SDK_VERSION = "0.12.
|
|
3565
|
+
const SDK_VERSION = "0.12.7";
|
|
3347
3566
|
const registry = {};
|
|
3348
3567
|
function register(type, info) {
|
|
3349
3568
|
let typeList = registry[type];
|
|
@@ -3528,6 +3747,9 @@ const processMessage = function processMessage2(props, state, elementRef, event)
|
|
|
3528
3747
|
state.forceReRenderCount = state.forceReRenderCount + 1;
|
|
3529
3748
|
break;
|
|
3530
3749
|
}
|
|
3750
|
+
case "builder.triggerAnimation":
|
|
3751
|
+
triggerAnimation(data.data);
|
|
3752
|
+
break;
|
|
3531
3753
|
case "builder.contentUpdate": {
|
|
3532
3754
|
const messageContent = data.data;
|
|
3533
3755
|
const key = messageContent.key || messageContent.alias || messageContent.entry || messageContent.modelName;
|
|
@@ -3738,7 +3960,6 @@ const EnableEditor = /* @__PURE__ */ qwik.componentQrl(/* @__PURE__ */ qwik.inli
|
|
|
3738
3960
|
var _a2, _b2;
|
|
3739
3961
|
return (_b2 = (_a2 = props2.builderContextSignal.content) == null ? void 0 : _a2.data) == null ? void 0 : _b2.jsCode;
|
|
3740
3962
|
});
|
|
3741
|
-
track2(() => props2.builderContextSignal.rootState);
|
|
3742
3963
|
evaluateJsCode(props2);
|
|
3743
3964
|
}, "EnableEditor_component_useTask_3_bQ0e5LHZwWE", [
|
|
3744
3965
|
elementRef,
|
|
@@ -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
|
});
|
|
@@ -299,6 +311,201 @@ function getProcessedBlock({ block, context, shouldEvaluateBindings, localState,
|
|
|
299
311
|
else
|
|
300
312
|
return transformedBlock;
|
|
301
313
|
}
|
|
314
|
+
function throttle(func, wait, options = {}) {
|
|
315
|
+
let context;
|
|
316
|
+
let args;
|
|
317
|
+
let result;
|
|
318
|
+
let timeout = null;
|
|
319
|
+
let previous = 0;
|
|
320
|
+
const later = function() {
|
|
321
|
+
previous = options.leading === false ? 0 : Date.now();
|
|
322
|
+
timeout = null;
|
|
323
|
+
result = func.apply(context, args);
|
|
324
|
+
if (!timeout)
|
|
325
|
+
context = args = null;
|
|
326
|
+
};
|
|
327
|
+
return function() {
|
|
328
|
+
const now = Date.now();
|
|
329
|
+
if (!previous && options.leading === false)
|
|
330
|
+
previous = now;
|
|
331
|
+
const remaining = wait - (now - previous);
|
|
332
|
+
context = this;
|
|
333
|
+
args = arguments;
|
|
334
|
+
if (remaining <= 0 || remaining > wait) {
|
|
335
|
+
if (timeout) {
|
|
336
|
+
clearTimeout(timeout);
|
|
337
|
+
timeout = null;
|
|
338
|
+
}
|
|
339
|
+
previous = now;
|
|
340
|
+
result = func.apply(context, args);
|
|
341
|
+
if (!timeout)
|
|
342
|
+
context = args = null;
|
|
343
|
+
} else if (!timeout && options.trailing !== false)
|
|
344
|
+
timeout = setTimeout(later, remaining);
|
|
345
|
+
return result;
|
|
346
|
+
};
|
|
347
|
+
}
|
|
348
|
+
function assign(target, ..._args) {
|
|
349
|
+
const to = Object(target);
|
|
350
|
+
for (let index = 1; index < arguments.length; index++) {
|
|
351
|
+
const nextSource = arguments[index];
|
|
352
|
+
if (nextSource != null) {
|
|
353
|
+
for (const nextKey in nextSource)
|
|
354
|
+
if (Object.prototype.hasOwnProperty.call(nextSource, nextKey))
|
|
355
|
+
to[nextKey] = nextSource[nextKey];
|
|
356
|
+
}
|
|
357
|
+
}
|
|
358
|
+
return to;
|
|
359
|
+
}
|
|
360
|
+
const camelCaseToKebabCase = (str) => str ? str.replace(/([A-Z])/g, (g) => `-${g[0].toLowerCase()}`) : "";
|
|
361
|
+
function bindAnimations(animations) {
|
|
362
|
+
for (const animation of animations)
|
|
363
|
+
switch (animation.trigger) {
|
|
364
|
+
case "pageLoad":
|
|
365
|
+
triggerAnimation(animation);
|
|
366
|
+
break;
|
|
367
|
+
case "hover":
|
|
368
|
+
bindHoverAnimation(animation);
|
|
369
|
+
break;
|
|
370
|
+
case "scrollInView":
|
|
371
|
+
bindScrollInViewAnimation(animation);
|
|
372
|
+
break;
|
|
373
|
+
}
|
|
374
|
+
}
|
|
375
|
+
function warnElementNotPresent(id) {
|
|
376
|
+
console.warn(`Cannot animate element: element with ID ${id} not found!`);
|
|
377
|
+
}
|
|
378
|
+
function augmentAnimation(animation, element) {
|
|
379
|
+
const stylesUsed = getAllStylesUsed(animation);
|
|
380
|
+
const computedStyle = getComputedStyle(element);
|
|
381
|
+
const firstStyles = animation.steps[0].styles;
|
|
382
|
+
const lastStyles = animation.steps[animation.steps.length - 1].styles;
|
|
383
|
+
const bothStyles = [
|
|
384
|
+
firstStyles,
|
|
385
|
+
lastStyles
|
|
386
|
+
];
|
|
387
|
+
for (const styles of bothStyles) {
|
|
388
|
+
for (const style of stylesUsed)
|
|
389
|
+
if (!(style in styles))
|
|
390
|
+
styles[style] = computedStyle[style];
|
|
391
|
+
}
|
|
392
|
+
}
|
|
393
|
+
function getAllStylesUsed(animation) {
|
|
394
|
+
const properties = [];
|
|
395
|
+
for (const step of animation.steps) {
|
|
396
|
+
for (const key in step.styles)
|
|
397
|
+
if (properties.indexOf(key) === -1)
|
|
398
|
+
properties.push(key);
|
|
399
|
+
}
|
|
400
|
+
return properties;
|
|
401
|
+
}
|
|
402
|
+
function triggerAnimation(animation) {
|
|
403
|
+
const elements = Array.prototype.slice.call(document.getElementsByClassName(animation.elementId || animation.id || ""));
|
|
404
|
+
if (!elements.length) {
|
|
405
|
+
warnElementNotPresent(animation.elementId || animation.id || "");
|
|
406
|
+
return;
|
|
407
|
+
}
|
|
408
|
+
Array.from(elements).forEach((element) => {
|
|
409
|
+
augmentAnimation(animation, element);
|
|
410
|
+
element.style.transition = "none";
|
|
411
|
+
element.style.transitionDelay = "0";
|
|
412
|
+
assign(element.style, animation.steps[0].styles);
|
|
413
|
+
setTimeout(() => {
|
|
414
|
+
element.style.transition = `all ${animation.duration}s ${camelCaseToKebabCase(animation.easing)}`;
|
|
415
|
+
if (animation.delay)
|
|
416
|
+
element.style.transitionDelay = animation.delay + "s";
|
|
417
|
+
assign(element.style, animation.steps[1].styles);
|
|
418
|
+
setTimeout(() => {
|
|
419
|
+
element.style.transition = "";
|
|
420
|
+
element.style.transitionDelay = "";
|
|
421
|
+
}, (animation.delay || 0) * 1e3 + animation.duration * 1e3 + 100);
|
|
422
|
+
});
|
|
423
|
+
});
|
|
424
|
+
}
|
|
425
|
+
function bindHoverAnimation(animation) {
|
|
426
|
+
const elements = Array.prototype.slice.call(document.getElementsByClassName(animation.elementId || animation.id || ""));
|
|
427
|
+
if (!elements.length) {
|
|
428
|
+
warnElementNotPresent(animation.elementId || animation.id || "");
|
|
429
|
+
return;
|
|
430
|
+
}
|
|
431
|
+
Array.from(elements).forEach((element) => {
|
|
432
|
+
augmentAnimation(animation, element);
|
|
433
|
+
const defaultState = animation.steps[0].styles;
|
|
434
|
+
const hoverState = animation.steps[1].styles;
|
|
435
|
+
function attachDefaultState() {
|
|
436
|
+
assign(element.style, defaultState);
|
|
437
|
+
}
|
|
438
|
+
function attachHoverState() {
|
|
439
|
+
assign(element.style, hoverState);
|
|
440
|
+
}
|
|
441
|
+
attachDefaultState();
|
|
442
|
+
element.addEventListener("mouseenter", attachHoverState);
|
|
443
|
+
element.addEventListener("mouseleave", attachDefaultState);
|
|
444
|
+
setTimeout(() => {
|
|
445
|
+
element.style.transition = `all ${animation.duration}s ${camelCaseToKebabCase(animation.easing)}`;
|
|
446
|
+
if (animation.delay)
|
|
447
|
+
element.style.transitionDelay = animation.delay + "s";
|
|
448
|
+
});
|
|
449
|
+
});
|
|
450
|
+
}
|
|
451
|
+
function bindScrollInViewAnimation(animation) {
|
|
452
|
+
const elements = Array.prototype.slice.call(document.getElementsByClassName(animation.elementId || animation.id || ""));
|
|
453
|
+
if (!elements.length) {
|
|
454
|
+
warnElementNotPresent(animation.elementId || animation.id || "");
|
|
455
|
+
return;
|
|
456
|
+
}
|
|
457
|
+
Array.from(elements).forEach((element) => {
|
|
458
|
+
augmentAnimation(animation, element);
|
|
459
|
+
let triggered = false;
|
|
460
|
+
let pendingAnimation = false;
|
|
461
|
+
function immediateOnScroll() {
|
|
462
|
+
if (!triggered && isScrolledIntoView(element)) {
|
|
463
|
+
triggered = true;
|
|
464
|
+
pendingAnimation = true;
|
|
465
|
+
setTimeout(() => {
|
|
466
|
+
assign(element.style, animation.steps[1].styles);
|
|
467
|
+
if (!animation.repeat)
|
|
468
|
+
document.removeEventListener("scroll", onScroll);
|
|
469
|
+
setTimeout(() => {
|
|
470
|
+
pendingAnimation = false;
|
|
471
|
+
if (!animation.repeat) {
|
|
472
|
+
element.style.transition = "";
|
|
473
|
+
element.style.transitionDelay = "";
|
|
474
|
+
}
|
|
475
|
+
}, (animation.duration + (animation.delay || 0)) * 1e3 + 100);
|
|
476
|
+
});
|
|
477
|
+
} else if (animation.repeat && triggered && !pendingAnimation && !isScrolledIntoView(element)) {
|
|
478
|
+
triggered = false;
|
|
479
|
+
assign(element.style, animation.steps[0].styles);
|
|
480
|
+
}
|
|
481
|
+
}
|
|
482
|
+
const onScroll = throttle(immediateOnScroll, 200, {
|
|
483
|
+
leading: false
|
|
484
|
+
});
|
|
485
|
+
function isScrolledIntoView(elem) {
|
|
486
|
+
const rect = elem.getBoundingClientRect();
|
|
487
|
+
const windowHeight = window.innerHeight;
|
|
488
|
+
const thresholdPercent = (animation.thresholdPercent || 0) / 100;
|
|
489
|
+
const threshold = thresholdPercent * windowHeight;
|
|
490
|
+
return rect.bottom > threshold && rect.top < windowHeight - threshold;
|
|
491
|
+
}
|
|
492
|
+
const defaultState = animation.steps[0].styles;
|
|
493
|
+
function attachDefaultState() {
|
|
494
|
+
assign(element.style, defaultState);
|
|
495
|
+
}
|
|
496
|
+
attachDefaultState();
|
|
497
|
+
setTimeout(() => {
|
|
498
|
+
element.style.transition = `all ${animation.duration}s ${camelCaseToKebabCase(animation.easing)}`;
|
|
499
|
+
if (animation.delay)
|
|
500
|
+
element.style.transitionDelay = animation.delay + "s";
|
|
501
|
+
});
|
|
502
|
+
document.addEventListener("scroll", onScroll, {
|
|
503
|
+
capture: true,
|
|
504
|
+
passive: true
|
|
505
|
+
});
|
|
506
|
+
immediateOnScroll();
|
|
507
|
+
});
|
|
508
|
+
}
|
|
302
509
|
const getComponent = ({ block, context, registeredComponents }) => {
|
|
303
510
|
var _a;
|
|
304
511
|
const componentName = (_a = getProcessedBlock({
|
|
@@ -845,6 +1052,18 @@ const Block = /* @__PURE__ */ componentQrl(/* @__PURE__ */ inlinedQrl((props) =>
|
|
|
845
1052
|
props,
|
|
846
1053
|
state
|
|
847
1054
|
]));
|
|
1055
|
+
useVisibleTaskQrl(/* @__PURE__ */ inlinedQrl(() => {
|
|
1056
|
+
const [processedBlock2] = useLexicalScope();
|
|
1057
|
+
const blockId = processedBlock2.value.id;
|
|
1058
|
+
const animations = processedBlock2.value.animations;
|
|
1059
|
+
if (animations && blockId)
|
|
1060
|
+
bindAnimations(animations.filter((item) => item.trigger !== "hover").map((animation) => ({
|
|
1061
|
+
...animation,
|
|
1062
|
+
elementId: blockId
|
|
1063
|
+
})));
|
|
1064
|
+
}, "Block_component_useVisibleTask_hrTYvqw0Tbs", [
|
|
1065
|
+
processedBlock
|
|
1066
|
+
]));
|
|
848
1067
|
return /* @__PURE__ */ _jsxC(Fragment, {
|
|
849
1068
|
children: canShowBlock.value ? /* @__PURE__ */ _jsxC(Fragment, {
|
|
850
1069
|
children: [
|
|
@@ -3341,7 +3560,7 @@ const getInteractionPropertiesForEvent = (event) => {
|
|
|
3341
3560
|
}
|
|
3342
3561
|
};
|
|
3343
3562
|
};
|
|
3344
|
-
const SDK_VERSION = "0.12.
|
|
3563
|
+
const SDK_VERSION = "0.12.7";
|
|
3345
3564
|
const registry = {};
|
|
3346
3565
|
function register(type, info) {
|
|
3347
3566
|
let typeList = registry[type];
|
|
@@ -3526,6 +3745,9 @@ const processMessage = function processMessage2(props, state, elementRef, event)
|
|
|
3526
3745
|
state.forceReRenderCount = state.forceReRenderCount + 1;
|
|
3527
3746
|
break;
|
|
3528
3747
|
}
|
|
3748
|
+
case "builder.triggerAnimation":
|
|
3749
|
+
triggerAnimation(data.data);
|
|
3750
|
+
break;
|
|
3529
3751
|
case "builder.contentUpdate": {
|
|
3530
3752
|
const messageContent = data.data;
|
|
3531
3753
|
const key = messageContent.key || messageContent.alias || messageContent.entry || messageContent.modelName;
|
|
@@ -3736,7 +3958,6 @@ const EnableEditor = /* @__PURE__ */ componentQrl(/* @__PURE__ */ inlinedQrl((pr
|
|
|
3736
3958
|
var _a2, _b2;
|
|
3737
3959
|
return (_b2 = (_a2 = props2.builderContextSignal.content) == null ? void 0 : _a2.data) == null ? void 0 : _b2.jsCode;
|
|
3738
3960
|
});
|
|
3739
|
-
track2(() => props2.builderContextSignal.rootState);
|
|
3740
3961
|
evaluateJsCode(props2);
|
|
3741
3962
|
}, "EnableEditor_component_useTask_3_bQ0e5LHZwWE", [
|
|
3742
3963
|
elementRef,
|