@getlupa/client 1.10.3 → 1.11.0

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.
@@ -102,6 +102,10 @@ const looseToNumber = (val) => {
102
102
  const n = parseFloat(val);
103
103
  return isNaN(n) ? val : n;
104
104
  };
105
+ const toNumber = (val) => {
106
+ const n = isString(val) ? Number(val) : NaN;
107
+ return isNaN(n) ? val : n;
108
+ };
105
109
  let _globalThis;
106
110
  const getGlobalThis = () => {
107
111
  return _globalThis || (_globalThis = typeof globalThis !== "undefined" ? globalThis : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : typeof global !== "undefined" ? global : {});
@@ -2000,6 +2004,319 @@ function invokeDirectiveHook(vnode, prevVNode, instance, name) {
2000
2004
  }
2001
2005
  }
2002
2006
  }
2007
+ function useTransitionState() {
2008
+ const state = {
2009
+ isMounted: false,
2010
+ isLeaving: false,
2011
+ isUnmounting: false,
2012
+ leavingVNodes: /* @__PURE__ */ new Map()
2013
+ };
2014
+ onMounted(() => {
2015
+ state.isMounted = true;
2016
+ });
2017
+ onBeforeUnmount(() => {
2018
+ state.isUnmounting = true;
2019
+ });
2020
+ return state;
2021
+ }
2022
+ const TransitionHookValidator = [Function, Array];
2023
+ const BaseTransitionPropsValidators = {
2024
+ mode: String,
2025
+ appear: Boolean,
2026
+ persisted: Boolean,
2027
+ // enter
2028
+ onBeforeEnter: TransitionHookValidator,
2029
+ onEnter: TransitionHookValidator,
2030
+ onAfterEnter: TransitionHookValidator,
2031
+ onEnterCancelled: TransitionHookValidator,
2032
+ // leave
2033
+ onBeforeLeave: TransitionHookValidator,
2034
+ onLeave: TransitionHookValidator,
2035
+ onAfterLeave: TransitionHookValidator,
2036
+ onLeaveCancelled: TransitionHookValidator,
2037
+ // appear
2038
+ onBeforeAppear: TransitionHookValidator,
2039
+ onAppear: TransitionHookValidator,
2040
+ onAfterAppear: TransitionHookValidator,
2041
+ onAppearCancelled: TransitionHookValidator
2042
+ };
2043
+ const BaseTransitionImpl = {
2044
+ name: `BaseTransition`,
2045
+ props: BaseTransitionPropsValidators,
2046
+ setup(props, { slots }) {
2047
+ const instance = getCurrentInstance();
2048
+ const state = useTransitionState();
2049
+ let prevTransitionKey;
2050
+ return () => {
2051
+ const children = slots.default && getTransitionRawChildren(slots.default(), true);
2052
+ if (!children || !children.length) {
2053
+ return;
2054
+ }
2055
+ let child = children[0];
2056
+ if (children.length > 1) {
2057
+ for (const c2 of children) {
2058
+ if (c2.type !== Comment) {
2059
+ child = c2;
2060
+ break;
2061
+ }
2062
+ }
2063
+ }
2064
+ const rawProps = toRaw(props);
2065
+ const { mode } = rawProps;
2066
+ if (state.isLeaving) {
2067
+ return emptyPlaceholder(child);
2068
+ }
2069
+ const innerChild = getKeepAliveChild(child);
2070
+ if (!innerChild) {
2071
+ return emptyPlaceholder(child);
2072
+ }
2073
+ const enterHooks = resolveTransitionHooks(
2074
+ innerChild,
2075
+ rawProps,
2076
+ state,
2077
+ instance
2078
+ );
2079
+ setTransitionHooks(innerChild, enterHooks);
2080
+ const oldChild = instance.subTree;
2081
+ const oldInnerChild = oldChild && getKeepAliveChild(oldChild);
2082
+ let transitionKeyChanged = false;
2083
+ const { getTransitionKey } = innerChild.type;
2084
+ if (getTransitionKey) {
2085
+ const key = getTransitionKey();
2086
+ if (prevTransitionKey === void 0) {
2087
+ prevTransitionKey = key;
2088
+ } else if (key !== prevTransitionKey) {
2089
+ prevTransitionKey = key;
2090
+ transitionKeyChanged = true;
2091
+ }
2092
+ }
2093
+ if (oldInnerChild && oldInnerChild.type !== Comment && (!isSameVNodeType(innerChild, oldInnerChild) || transitionKeyChanged)) {
2094
+ const leavingHooks = resolveTransitionHooks(
2095
+ oldInnerChild,
2096
+ rawProps,
2097
+ state,
2098
+ instance
2099
+ );
2100
+ setTransitionHooks(oldInnerChild, leavingHooks);
2101
+ if (mode === "out-in") {
2102
+ state.isLeaving = true;
2103
+ leavingHooks.afterLeave = () => {
2104
+ state.isLeaving = false;
2105
+ if (instance.update.active !== false) {
2106
+ instance.update();
2107
+ }
2108
+ };
2109
+ return emptyPlaceholder(child);
2110
+ } else if (mode === "in-out" && innerChild.type !== Comment) {
2111
+ leavingHooks.delayLeave = (el, earlyRemove, delayedLeave) => {
2112
+ const leavingVNodesCache = getLeavingNodesForType(
2113
+ state,
2114
+ oldInnerChild
2115
+ );
2116
+ leavingVNodesCache[String(oldInnerChild.key)] = oldInnerChild;
2117
+ el._leaveCb = () => {
2118
+ earlyRemove();
2119
+ el._leaveCb = void 0;
2120
+ delete enterHooks.delayedLeave;
2121
+ };
2122
+ enterHooks.delayedLeave = delayedLeave;
2123
+ };
2124
+ }
2125
+ }
2126
+ return child;
2127
+ };
2128
+ }
2129
+ };
2130
+ const BaseTransition = BaseTransitionImpl;
2131
+ function getLeavingNodesForType(state, vnode) {
2132
+ const { leavingVNodes } = state;
2133
+ let leavingVNodesCache = leavingVNodes.get(vnode.type);
2134
+ if (!leavingVNodesCache) {
2135
+ leavingVNodesCache = /* @__PURE__ */ Object.create(null);
2136
+ leavingVNodes.set(vnode.type, leavingVNodesCache);
2137
+ }
2138
+ return leavingVNodesCache;
2139
+ }
2140
+ function resolveTransitionHooks(vnode, props, state, instance) {
2141
+ const {
2142
+ appear,
2143
+ mode,
2144
+ persisted = false,
2145
+ onBeforeEnter,
2146
+ onEnter,
2147
+ onAfterEnter,
2148
+ onEnterCancelled,
2149
+ onBeforeLeave,
2150
+ onLeave,
2151
+ onAfterLeave,
2152
+ onLeaveCancelled,
2153
+ onBeforeAppear,
2154
+ onAppear,
2155
+ onAfterAppear,
2156
+ onAppearCancelled
2157
+ } = props;
2158
+ const key = String(vnode.key);
2159
+ const leavingVNodesCache = getLeavingNodesForType(state, vnode);
2160
+ const callHook2 = (hook, args) => {
2161
+ hook && callWithAsyncErrorHandling(
2162
+ hook,
2163
+ instance,
2164
+ 9,
2165
+ args
2166
+ );
2167
+ };
2168
+ const callAsyncHook = (hook, args) => {
2169
+ const done = args[1];
2170
+ callHook2(hook, args);
2171
+ if (isArray(hook)) {
2172
+ if (hook.every((hook2) => hook2.length <= 1))
2173
+ done();
2174
+ } else if (hook.length <= 1) {
2175
+ done();
2176
+ }
2177
+ };
2178
+ const hooks = {
2179
+ mode,
2180
+ persisted,
2181
+ beforeEnter(el) {
2182
+ let hook = onBeforeEnter;
2183
+ if (!state.isMounted) {
2184
+ if (appear) {
2185
+ hook = onBeforeAppear || onBeforeEnter;
2186
+ } else {
2187
+ return;
2188
+ }
2189
+ }
2190
+ if (el._leaveCb) {
2191
+ el._leaveCb(
2192
+ true
2193
+ /* cancelled */
2194
+ );
2195
+ }
2196
+ const leavingVNode = leavingVNodesCache[key];
2197
+ if (leavingVNode && isSameVNodeType(vnode, leavingVNode) && leavingVNode.el._leaveCb) {
2198
+ leavingVNode.el._leaveCb();
2199
+ }
2200
+ callHook2(hook, [el]);
2201
+ },
2202
+ enter(el) {
2203
+ let hook = onEnter;
2204
+ let afterHook = onAfterEnter;
2205
+ let cancelHook = onEnterCancelled;
2206
+ if (!state.isMounted) {
2207
+ if (appear) {
2208
+ hook = onAppear || onEnter;
2209
+ afterHook = onAfterAppear || onAfterEnter;
2210
+ cancelHook = onAppearCancelled || onEnterCancelled;
2211
+ } else {
2212
+ return;
2213
+ }
2214
+ }
2215
+ let called = false;
2216
+ const done = el._enterCb = (cancelled) => {
2217
+ if (called)
2218
+ return;
2219
+ called = true;
2220
+ if (cancelled) {
2221
+ callHook2(cancelHook, [el]);
2222
+ } else {
2223
+ callHook2(afterHook, [el]);
2224
+ }
2225
+ if (hooks.delayedLeave) {
2226
+ hooks.delayedLeave();
2227
+ }
2228
+ el._enterCb = void 0;
2229
+ };
2230
+ if (hook) {
2231
+ callAsyncHook(hook, [el, done]);
2232
+ } else {
2233
+ done();
2234
+ }
2235
+ },
2236
+ leave(el, remove2) {
2237
+ const key2 = String(vnode.key);
2238
+ if (el._enterCb) {
2239
+ el._enterCb(
2240
+ true
2241
+ /* cancelled */
2242
+ );
2243
+ }
2244
+ if (state.isUnmounting) {
2245
+ return remove2();
2246
+ }
2247
+ callHook2(onBeforeLeave, [el]);
2248
+ let called = false;
2249
+ const done = el._leaveCb = (cancelled) => {
2250
+ if (called)
2251
+ return;
2252
+ called = true;
2253
+ remove2();
2254
+ if (cancelled) {
2255
+ callHook2(onLeaveCancelled, [el]);
2256
+ } else {
2257
+ callHook2(onAfterLeave, [el]);
2258
+ }
2259
+ el._leaveCb = void 0;
2260
+ if (leavingVNodesCache[key2] === vnode) {
2261
+ delete leavingVNodesCache[key2];
2262
+ }
2263
+ };
2264
+ leavingVNodesCache[key2] = vnode;
2265
+ if (onLeave) {
2266
+ callAsyncHook(onLeave, [el, done]);
2267
+ } else {
2268
+ done();
2269
+ }
2270
+ },
2271
+ clone(vnode2) {
2272
+ return resolveTransitionHooks(vnode2, props, state, instance);
2273
+ }
2274
+ };
2275
+ return hooks;
2276
+ }
2277
+ function emptyPlaceholder(vnode) {
2278
+ if (isKeepAlive(vnode)) {
2279
+ vnode = cloneVNode(vnode);
2280
+ vnode.children = null;
2281
+ return vnode;
2282
+ }
2283
+ }
2284
+ function getKeepAliveChild(vnode) {
2285
+ return isKeepAlive(vnode) ? vnode.children ? vnode.children[0] : void 0 : vnode;
2286
+ }
2287
+ function setTransitionHooks(vnode, hooks) {
2288
+ if (vnode.shapeFlag & 6 && vnode.component) {
2289
+ setTransitionHooks(vnode.component.subTree, hooks);
2290
+ } else if (vnode.shapeFlag & 128) {
2291
+ vnode.ssContent.transition = hooks.clone(vnode.ssContent);
2292
+ vnode.ssFallback.transition = hooks.clone(vnode.ssFallback);
2293
+ } else {
2294
+ vnode.transition = hooks;
2295
+ }
2296
+ }
2297
+ function getTransitionRawChildren(children, keepComment = false, parentKey) {
2298
+ let ret = [];
2299
+ let keyedFragmentCount = 0;
2300
+ for (let i = 0; i < children.length; i++) {
2301
+ let child = children[i];
2302
+ const key = parentKey == null ? child.key : String(parentKey) + String(child.key != null ? child.key : i);
2303
+ if (child.type === Fragment) {
2304
+ if (child.patchFlag & 128)
2305
+ keyedFragmentCount++;
2306
+ ret = ret.concat(
2307
+ getTransitionRawChildren(child.children, keepComment, key)
2308
+ );
2309
+ } else if (keepComment || child.type !== Comment) {
2310
+ ret.push(key != null ? cloneVNode(child, { key }) : child);
2311
+ }
2312
+ }
2313
+ if (keyedFragmentCount > 1) {
2314
+ for (let i = 0; i < ret.length; i++) {
2315
+ ret[i].patchFlag = -2;
2316
+ }
2317
+ }
2318
+ return ret;
2319
+ }
2003
2320
  function defineComponent(options, extraOptions) {
2004
2321
  return isFunction(options) ? (
2005
2322
  // #8326: extend call and options.name access are considered side-effects
@@ -2371,7 +2688,7 @@ function applyOptions(instance) {
2371
2688
  const ctx = instance.ctx;
2372
2689
  shouldCacheAccess = false;
2373
2690
  if (options.beforeCreate) {
2374
- callHook(options.beforeCreate, instance, "bc");
2691
+ callHook$1(options.beforeCreate, instance, "bc");
2375
2692
  }
2376
2693
  const {
2377
2694
  // state
@@ -2458,7 +2775,7 @@ function applyOptions(instance) {
2458
2775
  });
2459
2776
  }
2460
2777
  if (created) {
2461
- callHook(created, instance, "c");
2778
+ callHook$1(created, instance, "c");
2462
2779
  }
2463
2780
  function registerLifecycleHook(register, hook) {
2464
2781
  if (isArray(hook)) {
@@ -2536,7 +2853,7 @@ function resolveInjections(injectOptions, ctx, checkDuplicateProperties = NOOP)
2536
2853
  }
2537
2854
  }
2538
2855
  }
2539
- function callHook(hook, instance, type) {
2856
+ function callHook$1(hook, instance, type) {
2540
2857
  callWithAsyncErrorHandling(
2541
2858
  isArray(hook) ? hook.map((h2) => h2.bind(instance.proxy)) : hook.bind(instance.proxy),
2542
2859
  instance,
@@ -5038,6 +5355,7 @@ function createComponentInstance(vnode, parent, suspense) {
5038
5355
  return instance;
5039
5356
  }
5040
5357
  let currentInstance = null;
5358
+ const getCurrentInstance = () => currentInstance || currentRenderingInstance;
5041
5359
  let internalSetCurrentInstance;
5042
5360
  let globalCurrentInstanceSetters;
5043
5361
  let settersKey = "__VUE_INSTANCE_SETTERS__";
@@ -5568,6 +5886,268 @@ function shouldSetAsProp(el, key, value, isSVG) {
5568
5886
  }
5569
5887
  return key in el;
5570
5888
  }
5889
+ const TRANSITION = "transition";
5890
+ const ANIMATION = "animation";
5891
+ const Transition = (props, { slots }) => h$1(BaseTransition, resolveTransitionProps(props), slots);
5892
+ Transition.displayName = "Transition";
5893
+ const DOMTransitionPropsValidators = {
5894
+ name: String,
5895
+ type: String,
5896
+ css: {
5897
+ type: Boolean,
5898
+ default: true
5899
+ },
5900
+ duration: [String, Number, Object],
5901
+ enterFromClass: String,
5902
+ enterActiveClass: String,
5903
+ enterToClass: String,
5904
+ appearFromClass: String,
5905
+ appearActiveClass: String,
5906
+ appearToClass: String,
5907
+ leaveFromClass: String,
5908
+ leaveActiveClass: String,
5909
+ leaveToClass: String
5910
+ };
5911
+ Transition.props = /* @__PURE__ */ extend(
5912
+ {},
5913
+ BaseTransitionPropsValidators,
5914
+ DOMTransitionPropsValidators
5915
+ );
5916
+ const callHook = (hook, args = []) => {
5917
+ if (isArray(hook)) {
5918
+ hook.forEach((h2) => h2(...args));
5919
+ } else if (hook) {
5920
+ hook(...args);
5921
+ }
5922
+ };
5923
+ const hasExplicitCallback = (hook) => {
5924
+ return hook ? isArray(hook) ? hook.some((h2) => h2.length > 1) : hook.length > 1 : false;
5925
+ };
5926
+ function resolveTransitionProps(rawProps) {
5927
+ const baseProps = {};
5928
+ for (const key in rawProps) {
5929
+ if (!(key in DOMTransitionPropsValidators)) {
5930
+ baseProps[key] = rawProps[key];
5931
+ }
5932
+ }
5933
+ if (rawProps.css === false) {
5934
+ return baseProps;
5935
+ }
5936
+ const {
5937
+ name = "v",
5938
+ type,
5939
+ duration,
5940
+ enterFromClass = `${name}-enter-from`,
5941
+ enterActiveClass = `${name}-enter-active`,
5942
+ enterToClass = `${name}-enter-to`,
5943
+ appearFromClass = enterFromClass,
5944
+ appearActiveClass = enterActiveClass,
5945
+ appearToClass = enterToClass,
5946
+ leaveFromClass = `${name}-leave-from`,
5947
+ leaveActiveClass = `${name}-leave-active`,
5948
+ leaveToClass = `${name}-leave-to`
5949
+ } = rawProps;
5950
+ const durations = normalizeDuration(duration);
5951
+ const enterDuration = durations && durations[0];
5952
+ const leaveDuration = durations && durations[1];
5953
+ const {
5954
+ onBeforeEnter,
5955
+ onEnter,
5956
+ onEnterCancelled,
5957
+ onLeave,
5958
+ onLeaveCancelled,
5959
+ onBeforeAppear = onBeforeEnter,
5960
+ onAppear = onEnter,
5961
+ onAppearCancelled = onEnterCancelled
5962
+ } = baseProps;
5963
+ const finishEnter = (el, isAppear, done) => {
5964
+ removeTransitionClass(el, isAppear ? appearToClass : enterToClass);
5965
+ removeTransitionClass(el, isAppear ? appearActiveClass : enterActiveClass);
5966
+ done && done();
5967
+ };
5968
+ const finishLeave = (el, done) => {
5969
+ el._isLeaving = false;
5970
+ removeTransitionClass(el, leaveFromClass);
5971
+ removeTransitionClass(el, leaveToClass);
5972
+ removeTransitionClass(el, leaveActiveClass);
5973
+ done && done();
5974
+ };
5975
+ const makeEnterHook = (isAppear) => {
5976
+ return (el, done) => {
5977
+ const hook = isAppear ? onAppear : onEnter;
5978
+ const resolve2 = () => finishEnter(el, isAppear, done);
5979
+ callHook(hook, [el, resolve2]);
5980
+ nextFrame(() => {
5981
+ removeTransitionClass(el, isAppear ? appearFromClass : enterFromClass);
5982
+ addTransitionClass(el, isAppear ? appearToClass : enterToClass);
5983
+ if (!hasExplicitCallback(hook)) {
5984
+ whenTransitionEnds(el, type, enterDuration, resolve2);
5985
+ }
5986
+ });
5987
+ };
5988
+ };
5989
+ return extend(baseProps, {
5990
+ onBeforeEnter(el) {
5991
+ callHook(onBeforeEnter, [el]);
5992
+ addTransitionClass(el, enterFromClass);
5993
+ addTransitionClass(el, enterActiveClass);
5994
+ },
5995
+ onBeforeAppear(el) {
5996
+ callHook(onBeforeAppear, [el]);
5997
+ addTransitionClass(el, appearFromClass);
5998
+ addTransitionClass(el, appearActiveClass);
5999
+ },
6000
+ onEnter: makeEnterHook(false),
6001
+ onAppear: makeEnterHook(true),
6002
+ onLeave(el, done) {
6003
+ el._isLeaving = true;
6004
+ const resolve2 = () => finishLeave(el, done);
6005
+ addTransitionClass(el, leaveFromClass);
6006
+ forceReflow();
6007
+ addTransitionClass(el, leaveActiveClass);
6008
+ nextFrame(() => {
6009
+ if (!el._isLeaving) {
6010
+ return;
6011
+ }
6012
+ removeTransitionClass(el, leaveFromClass);
6013
+ addTransitionClass(el, leaveToClass);
6014
+ if (!hasExplicitCallback(onLeave)) {
6015
+ whenTransitionEnds(el, type, leaveDuration, resolve2);
6016
+ }
6017
+ });
6018
+ callHook(onLeave, [el, resolve2]);
6019
+ },
6020
+ onEnterCancelled(el) {
6021
+ finishEnter(el, false);
6022
+ callHook(onEnterCancelled, [el]);
6023
+ },
6024
+ onAppearCancelled(el) {
6025
+ finishEnter(el, true);
6026
+ callHook(onAppearCancelled, [el]);
6027
+ },
6028
+ onLeaveCancelled(el) {
6029
+ finishLeave(el);
6030
+ callHook(onLeaveCancelled, [el]);
6031
+ }
6032
+ });
6033
+ }
6034
+ function normalizeDuration(duration) {
6035
+ if (duration == null) {
6036
+ return null;
6037
+ } else if (isObject(duration)) {
6038
+ return [NumberOf(duration.enter), NumberOf(duration.leave)];
6039
+ } else {
6040
+ const n = NumberOf(duration);
6041
+ return [n, n];
6042
+ }
6043
+ }
6044
+ function NumberOf(val) {
6045
+ const res = toNumber(val);
6046
+ return res;
6047
+ }
6048
+ function addTransitionClass(el, cls) {
6049
+ cls.split(/\s+/).forEach((c2) => c2 && el.classList.add(c2));
6050
+ (el._vtc || (el._vtc = /* @__PURE__ */ new Set())).add(cls);
6051
+ }
6052
+ function removeTransitionClass(el, cls) {
6053
+ cls.split(/\s+/).forEach((c2) => c2 && el.classList.remove(c2));
6054
+ const { _vtc } = el;
6055
+ if (_vtc) {
6056
+ _vtc.delete(cls);
6057
+ if (!_vtc.size) {
6058
+ el._vtc = void 0;
6059
+ }
6060
+ }
6061
+ }
6062
+ function nextFrame(cb) {
6063
+ requestAnimationFrame(() => {
6064
+ requestAnimationFrame(cb);
6065
+ });
6066
+ }
6067
+ let endId = 0;
6068
+ function whenTransitionEnds(el, expectedType, explicitTimeout, resolve2) {
6069
+ const id = el._endId = ++endId;
6070
+ const resolveIfNotStale = () => {
6071
+ if (id === el._endId) {
6072
+ resolve2();
6073
+ }
6074
+ };
6075
+ if (explicitTimeout) {
6076
+ return setTimeout(resolveIfNotStale, explicitTimeout);
6077
+ }
6078
+ const { type, timeout, propCount } = getTransitionInfo(el, expectedType);
6079
+ if (!type) {
6080
+ return resolve2();
6081
+ }
6082
+ const endEvent = type + "end";
6083
+ let ended = 0;
6084
+ const end = () => {
6085
+ el.removeEventListener(endEvent, onEnd);
6086
+ resolveIfNotStale();
6087
+ };
6088
+ const onEnd = (e) => {
6089
+ if (e.target === el && ++ended >= propCount) {
6090
+ end();
6091
+ }
6092
+ };
6093
+ setTimeout(() => {
6094
+ if (ended < propCount) {
6095
+ end();
6096
+ }
6097
+ }, timeout + 1);
6098
+ el.addEventListener(endEvent, onEnd);
6099
+ }
6100
+ function getTransitionInfo(el, expectedType) {
6101
+ const styles = window.getComputedStyle(el);
6102
+ const getStyleProperties = (key) => (styles[key] || "").split(", ");
6103
+ const transitionDelays = getStyleProperties(`${TRANSITION}Delay`);
6104
+ const transitionDurations = getStyleProperties(`${TRANSITION}Duration`);
6105
+ const transitionTimeout = getTimeout(transitionDelays, transitionDurations);
6106
+ const animationDelays = getStyleProperties(`${ANIMATION}Delay`);
6107
+ const animationDurations = getStyleProperties(`${ANIMATION}Duration`);
6108
+ const animationTimeout = getTimeout(animationDelays, animationDurations);
6109
+ let type = null;
6110
+ let timeout = 0;
6111
+ let propCount = 0;
6112
+ if (expectedType === TRANSITION) {
6113
+ if (transitionTimeout > 0) {
6114
+ type = TRANSITION;
6115
+ timeout = transitionTimeout;
6116
+ propCount = transitionDurations.length;
6117
+ }
6118
+ } else if (expectedType === ANIMATION) {
6119
+ if (animationTimeout > 0) {
6120
+ type = ANIMATION;
6121
+ timeout = animationTimeout;
6122
+ propCount = animationDurations.length;
6123
+ }
6124
+ } else {
6125
+ timeout = Math.max(transitionTimeout, animationTimeout);
6126
+ type = timeout > 0 ? transitionTimeout > animationTimeout ? TRANSITION : ANIMATION : null;
6127
+ propCount = type ? type === TRANSITION ? transitionDurations.length : animationDurations.length : 0;
6128
+ }
6129
+ const hasTransform = type === TRANSITION && /\b(transform|all)(,|$)/.test(
6130
+ getStyleProperties(`${TRANSITION}Property`).toString()
6131
+ );
6132
+ return {
6133
+ type,
6134
+ timeout,
6135
+ propCount,
6136
+ hasTransform
6137
+ };
6138
+ }
6139
+ function getTimeout(delays, durations) {
6140
+ while (delays.length < durations.length) {
6141
+ delays = delays.concat(delays);
6142
+ }
6143
+ return Math.max(...durations.map((d2, i) => toMs(d2) + toMs(delays[i])));
6144
+ }
6145
+ function toMs(s) {
6146
+ return Number(s.slice(0, -1).replace(",", ".")) * 1e3;
6147
+ }
6148
+ function forceReflow() {
6149
+ return document.body.offsetHeight;
6150
+ }
5571
6151
  const getModelAssigner = (vnode) => {
5572
6152
  const fn = vnode.props["onUpdate:modelValue"] || false;
5573
6153
  return isArray(fn) ? (value) => invokeArrayFns(fn, value) : fn;
@@ -8422,6 +9002,21 @@ const joinUrlParts = (...parts) => {
8422
9002
  }
8423
9003
  return (_c = (_b = (_a = parts == null ? void 0 : parts.map((part) => part.replace(/(^\/+|\/+$)/g, ""))) == null ? void 0 : _a.filter((part) => part !== "")) == null ? void 0 : _b.join("/")) != null ? _c : "";
8424
9004
  };
9005
+ const checkHasFullImageUrl = (imageUrl) => typeof imageUrl === "string" && (imageUrl.indexOf("http://") === 0 || imageUrl.indexOf("https://") === 0);
9006
+ const computeImageUrl = (imageUrl, rootImageUrl) => {
9007
+ const mainUrl = Array.isArray(imageUrl) ? imageUrl[0] : imageUrl;
9008
+ if (checkHasFullImageUrl(mainUrl)) {
9009
+ return mainUrl;
9010
+ }
9011
+ return rootImageUrl ? joinUrlParts(rootImageUrl, mainUrl) : `/${mainUrl}`;
9012
+ };
9013
+ const replaceImageWithPlaceholder = (e, placeholder) => {
9014
+ var _a;
9015
+ const targetImage = e == null ? void 0 : e.target;
9016
+ if (targetImage && !((_a = targetImage == null ? void 0 : targetImage.src) == null ? void 0 : _a.includes(placeholder))) {
9017
+ targetImage.src = placeholder;
9018
+ }
9019
+ };
8425
9020
  const _hoisted_1$17 = ["src"];
8426
9021
  const _sfc_main$1d = /* @__PURE__ */ defineComponent({
8427
9022
  __name: "ProductImage",
@@ -8433,33 +9028,73 @@ const _sfc_main$1d = /* @__PURE__ */ defineComponent({
8433
9028
  },
8434
9029
  setup(__props) {
8435
9030
  const props = __props;
9031
+ const isHover = ref(false);
9032
+ const hoverImageIndex = ref(0);
9033
+ const hoverInterval = ref(0);
8436
9034
  const rootImageUrl = computed(() => props.options.baseUrl);
8437
9035
  const image = computed(() => props.item[props.options.key]);
8438
9036
  const hasFullImageUrl = computed(() => {
8439
- const imageUrl2 = image.value;
8440
- return typeof imageUrl2 === "string" && (imageUrl2.indexOf("http://") === 0 || imageUrl2.indexOf("https://") === 0);
9037
+ return checkHasFullImageUrl(image.value);
8441
9038
  });
8442
9039
  const imageUrl = computed(() => {
8443
- const imageUrl2 = image.value;
8444
- if (hasFullImageUrl.value) {
8445
- return imageUrl2;
8446
- }
8447
- return rootImageUrl.value ? joinUrlParts(rootImageUrl.value, imageUrl2) : `/${imageUrl2}`;
9040
+ return computeImageUrl(image.value, rootImageUrl.value);
8448
9041
  });
8449
9042
  const hasImage = computed(() => Boolean(hasFullImageUrl.value || image.value));
8450
9043
  const placeholder = computed(() => props.options.placeholder);
8451
- const finalUrl = computed(() => {
9044
+ const finalMainImageUrl = computed(() => {
8452
9045
  if (props.options.customUrl) {
8453
9046
  return props.options.customUrl(props.item);
8454
9047
  }
8455
9048
  return hasImage.value ? imageUrl.value : placeholder.value;
8456
9049
  });
8457
- const replaceWithPlaceholder = (e) => {
9050
+ const hoverImages = computed(() => {
9051
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l;
9052
+ if ((_a = props.options.hoverImages) == null ? void 0 : _a.key) {
9053
+ return (_g = (_f = (_e = props.item[(_b = props.options.hoverImages) == null ? void 0 : _b.key]) == null ? void 0 : _e.slice(0, (_d = (_c = props.options.hoverImages) == null ? void 0 : _c.maxImages) != null ? _d : 5)) == null ? void 0 : _f.map((i) => computeImageUrl(i, rootImageUrl.value))) != null ? _g : [];
9054
+ }
9055
+ if (props.options.hoverImages) {
9056
+ return (_l = (_k = (_h = props.options.hoverImages) == null ? void 0 : _h.display(props.item)) == null ? void 0 : _k.slice(0, (_j = (_i = props.options.hoverImages) == null ? void 0 : _i.maxImages) != null ? _j : 5)) != null ? _l : [];
9057
+ }
9058
+ return [];
9059
+ });
9060
+ const hasHoverImages = computed(() => {
8458
9061
  var _a;
8459
- const targetImage = e == null ? void 0 : e.target;
8460
- if (targetImage && !((_a = targetImage == null ? void 0 : targetImage.src) == null ? void 0 : _a.includes(placeholder.value))) {
8461
- targetImage.src = placeholder.value;
9062
+ return Boolean((_a = hoverImages.value) == null ? void 0 : _a.length);
9063
+ });
9064
+ const replaceWithPlaceholder = (e) => {
9065
+ replaceImageWithPlaceholder(e, placeholder.value);
9066
+ };
9067
+ const setNextHoverImage = () => {
9068
+ hoverImageIndex.value = (hoverImageIndex.value + 1) % hoverImages.value.length;
9069
+ };
9070
+ const currentHoverImage = computed(() => {
9071
+ return hoverImages.value[hoverImageIndex.value];
9072
+ });
9073
+ const finalUrl = computed(() => {
9074
+ return isHover.value ? currentHoverImage.value : finalMainImageUrl.value;
9075
+ });
9076
+ const handleMouseEnter = () => {
9077
+ var _a, _b;
9078
+ if (!hasHoverImages.value) {
9079
+ return;
8462
9080
  }
9081
+ isHover.value = true;
9082
+ hoverImageIndex.value = 0;
9083
+ if (hoverInterval.value) {
9084
+ return;
9085
+ }
9086
+ hoverInterval.value = setInterval(
9087
+ setNextHoverImage,
9088
+ (_b = (_a = props.options.hoverImages) == null ? void 0 : _a.cycleInterval) != null ? _b : 2e3
9089
+ );
9090
+ };
9091
+ const handleMouseLeave = () => {
9092
+ if (!hasHoverImages.value) {
9093
+ return;
9094
+ }
9095
+ isHover.value = false;
9096
+ clearInterval(hoverInterval.value);
9097
+ hoverInterval.value = 0;
8463
9098
  };
8464
9099
  const imageAlt = computed(() => {
8465
9100
  const alt = props.options.alt;
@@ -8468,16 +9103,44 @@ const _sfc_main$1d = /* @__PURE__ */ defineComponent({
8468
9103
  }
8469
9104
  return "";
8470
9105
  });
9106
+ const preloadImages = (images) => {
9107
+ images.forEach((src) => {
9108
+ const img = new Image();
9109
+ img.src = src;
9110
+ });
9111
+ };
9112
+ onMounted(() => {
9113
+ if (hasHoverImages.value) {
9114
+ preloadImages(hoverImages.value);
9115
+ }
9116
+ });
9117
+ watch(hoverImages, (newImages) => {
9118
+ if (newImages.length) {
9119
+ preloadImages(newImages);
9120
+ }
9121
+ });
9122
+ onBeforeUnmount(() => {
9123
+ clearInterval(hoverInterval.value);
9124
+ });
8471
9125
  return (_ctx, _cache) => {
8472
- var _a, _b;
8473
9126
  return openBlock(), createElementBlock("div", {
8474
- class: normalizeClass((_a = _ctx.wrapperClass) != null ? _a : "")
9127
+ class: normalizeClass({ [_ctx.wrapperClass]: Boolean(_ctx.wrapperClass), "lupa-images-hover": isHover.value }),
9128
+ onMouseenter: handleMouseEnter,
9129
+ onMouseleave: handleMouseLeave
8475
9130
  }, [
8476
- createBaseVNode("img", mergeProps({
8477
- class: (_b = _ctx.imageClass) != null ? _b : "",
8478
- src: finalUrl.value
8479
- }, { alt: imageAlt.value ? imageAlt.value : void 0 }, { onError: replaceWithPlaceholder }), null, 16, _hoisted_1$17)
8480
- ], 2);
9131
+ createVNode(Transition, { name: "lupa-fade" }, {
9132
+ default: withCtx(() => [
9133
+ (openBlock(), createElementBlock("img", mergeProps({
9134
+ class: ["lupa-images-hover-image", { [_ctx.imageClass]: true, "lupa-images-hover-image": isHover.value }],
9135
+ src: finalUrl.value
9136
+ }, { alt: imageAlt.value ? imageAlt.value : void 0 }, {
9137
+ onError: replaceWithPlaceholder,
9138
+ key: finalUrl.value
9139
+ }), null, 16, _hoisted_1$17))
9140
+ ]),
9141
+ _: 1
9142
+ })
9143
+ ], 34);
8481
9144
  };
8482
9145
  }
8483
9146
  });
@@ -17310,8 +17973,8 @@ lodash$1.exports;
17310
17973
  function createRelationalOperation(operator) {
17311
17974
  return function(value, other) {
17312
17975
  if (!(typeof value == "string" && typeof other == "string")) {
17313
- value = toNumber(value);
17314
- other = toNumber(other);
17976
+ value = toNumber2(value);
17977
+ other = toNumber2(other);
17315
17978
  }
17316
17979
  return operator(value, other);
17317
17980
  };
@@ -17345,7 +18008,7 @@ lodash$1.exports;
17345
18008
  function createRound(methodName) {
17346
18009
  var func = Math2[methodName];
17347
18010
  return function(number, precision) {
17348
- number = toNumber(number);
18011
+ number = toNumber2(number);
17349
18012
  precision = precision == null ? 0 : nativeMin(toInteger(precision), 292);
17350
18013
  if (precision && nativeIsFinite(number)) {
17351
18014
  var pair = (toString(number) + "e").split("e"), value = func(pair[0] + "e" + (+pair[1] + precision));
@@ -18703,11 +19366,11 @@ lodash$1.exports;
18703
19366
  if (typeof func != "function") {
18704
19367
  throw new TypeError2(FUNC_ERROR_TEXT);
18705
19368
  }
18706
- wait = toNumber(wait) || 0;
19369
+ wait = toNumber2(wait) || 0;
18707
19370
  if (isObject2(options)) {
18708
19371
  leading = !!options.leading;
18709
19372
  maxing = "maxWait" in options;
18710
- maxWait = maxing ? nativeMax(toNumber(options.maxWait) || 0, wait) : maxWait;
19373
+ maxWait = maxing ? nativeMax(toNumber2(options.maxWait) || 0, wait) : maxWait;
18711
19374
  trailing = "trailing" in options ? !!options.trailing : trailing;
18712
19375
  }
18713
19376
  function invokeFunc(time) {
@@ -18783,7 +19446,7 @@ lodash$1.exports;
18783
19446
  return baseDelay(func, 1, args);
18784
19447
  });
18785
19448
  var delay = baseRest(function(func, wait, args) {
18786
- return baseDelay(func, toNumber(wait) || 0, args);
19449
+ return baseDelay(func, toNumber2(wait) || 0, args);
18787
19450
  });
18788
19451
  function flip(func) {
18789
19452
  return createWrap(func, WRAP_FLIP_FLAG);
@@ -19080,7 +19743,7 @@ lodash$1.exports;
19080
19743
  if (!value) {
19081
19744
  return value === 0 ? value : 0;
19082
19745
  }
19083
- value = toNumber(value);
19746
+ value = toNumber2(value);
19084
19747
  if (value === INFINITY || value === -INFINITY) {
19085
19748
  var sign = value < 0 ? -1 : 1;
19086
19749
  return sign * MAX_INTEGER;
@@ -19094,7 +19757,7 @@ lodash$1.exports;
19094
19757
  function toLength(value) {
19095
19758
  return value ? baseClamp(toInteger(value), 0, MAX_ARRAY_LENGTH) : 0;
19096
19759
  }
19097
- function toNumber(value) {
19760
+ function toNumber2(value) {
19098
19761
  if (typeof value == "number") {
19099
19762
  return value;
19100
19763
  }
@@ -19357,14 +20020,14 @@ lodash$1.exports;
19357
20020
  lower = undefined$1;
19358
20021
  }
19359
20022
  if (upper !== undefined$1) {
19360
- upper = toNumber(upper);
20023
+ upper = toNumber2(upper);
19361
20024
  upper = upper === upper ? upper : 0;
19362
20025
  }
19363
20026
  if (lower !== undefined$1) {
19364
- lower = toNumber(lower);
20027
+ lower = toNumber2(lower);
19365
20028
  lower = lower === lower ? lower : 0;
19366
20029
  }
19367
- return baseClamp(toNumber(number), lower, upper);
20030
+ return baseClamp(toNumber2(number), lower, upper);
19368
20031
  }
19369
20032
  function inRange(number, start, end) {
19370
20033
  start = toFinite(start);
@@ -19374,7 +20037,7 @@ lodash$1.exports;
19374
20037
  } else {
19375
20038
  end = toFinite(end);
19376
20039
  }
19377
- number = toNumber(number);
20040
+ number = toNumber2(number);
19378
20041
  return baseInRange(number, start, end);
19379
20042
  }
19380
20043
  function random(lower, upper, floating) {
@@ -20160,7 +20823,7 @@ lodash$1.exports;
20160
20823
  lodash2.toInteger = toInteger;
20161
20824
  lodash2.toLength = toLength;
20162
20825
  lodash2.toLower = toLower;
20163
- lodash2.toNumber = toNumber;
20826
+ lodash2.toNumber = toNumber2;
20164
20827
  lodash2.toSafeInteger = toSafeInteger;
20165
20828
  lodash2.toString = toString;
20166
20829
  lodash2.toUpper = toUpper;
@@ -24306,8 +24969,8 @@ lodash.exports;
24306
24969
  function createRelationalOperation(operator) {
24307
24970
  return function(value, other) {
24308
24971
  if (!(typeof value == "string" && typeof other == "string")) {
24309
- value = toNumber(value);
24310
- other = toNumber(other);
24972
+ value = toNumber2(value);
24973
+ other = toNumber2(other);
24311
24974
  }
24312
24975
  return operator(value, other);
24313
24976
  };
@@ -24341,7 +25004,7 @@ lodash.exports;
24341
25004
  function createRound(methodName) {
24342
25005
  var func = Math2[methodName];
24343
25006
  return function(number, precision) {
24344
- number = toNumber(number);
25007
+ number = toNumber2(number);
24345
25008
  precision = precision == null ? 0 : nativeMin(toInteger(precision), 292);
24346
25009
  if (precision && nativeIsFinite(number)) {
24347
25010
  var pair = (toString(number) + "e").split("e"), value = func(pair[0] + "e" + (+pair[1] + precision));
@@ -25699,11 +26362,11 @@ lodash.exports;
25699
26362
  if (typeof func != "function") {
25700
26363
  throw new TypeError2(FUNC_ERROR_TEXT);
25701
26364
  }
25702
- wait = toNumber(wait) || 0;
26365
+ wait = toNumber2(wait) || 0;
25703
26366
  if (isObject2(options)) {
25704
26367
  leading = !!options.leading;
25705
26368
  maxing = "maxWait" in options;
25706
- maxWait = maxing ? nativeMax(toNumber(options.maxWait) || 0, wait) : maxWait;
26369
+ maxWait = maxing ? nativeMax(toNumber2(options.maxWait) || 0, wait) : maxWait;
25707
26370
  trailing = "trailing" in options ? !!options.trailing : trailing;
25708
26371
  }
25709
26372
  function invokeFunc(time) {
@@ -25779,7 +26442,7 @@ lodash.exports;
25779
26442
  return baseDelay(func, 1, args);
25780
26443
  });
25781
26444
  var delay = baseRest(function(func, wait, args) {
25782
- return baseDelay(func, toNumber(wait) || 0, args);
26445
+ return baseDelay(func, toNumber2(wait) || 0, args);
25783
26446
  });
25784
26447
  function flip(func) {
25785
26448
  return createWrap(func, WRAP_FLIP_FLAG);
@@ -26076,7 +26739,7 @@ lodash.exports;
26076
26739
  if (!value) {
26077
26740
  return value === 0 ? value : 0;
26078
26741
  }
26079
- value = toNumber(value);
26742
+ value = toNumber2(value);
26080
26743
  if (value === INFINITY || value === -INFINITY) {
26081
26744
  var sign = value < 0 ? -1 : 1;
26082
26745
  return sign * MAX_INTEGER;
@@ -26090,7 +26753,7 @@ lodash.exports;
26090
26753
  function toLength(value) {
26091
26754
  return value ? baseClamp(toInteger(value), 0, MAX_ARRAY_LENGTH) : 0;
26092
26755
  }
26093
- function toNumber(value) {
26756
+ function toNumber2(value) {
26094
26757
  if (typeof value == "number") {
26095
26758
  return value;
26096
26759
  }
@@ -26353,14 +27016,14 @@ lodash.exports;
26353
27016
  lower = undefined$1;
26354
27017
  }
26355
27018
  if (upper !== undefined$1) {
26356
- upper = toNumber(upper);
27019
+ upper = toNumber2(upper);
26357
27020
  upper = upper === upper ? upper : 0;
26358
27021
  }
26359
27022
  if (lower !== undefined$1) {
26360
- lower = toNumber(lower);
27023
+ lower = toNumber2(lower);
26361
27024
  lower = lower === lower ? lower : 0;
26362
27025
  }
26363
- return baseClamp(toNumber(number), lower, upper);
27026
+ return baseClamp(toNumber2(number), lower, upper);
26364
27027
  }
26365
27028
  function inRange(number, start, end) {
26366
27029
  start = toFinite(start);
@@ -26370,7 +27033,7 @@ lodash.exports;
26370
27033
  } else {
26371
27034
  end = toFinite(end);
26372
27035
  }
26373
- number = toNumber(number);
27036
+ number = toNumber2(number);
26374
27037
  return baseInRange(number, start, end);
26375
27038
  }
26376
27039
  function random(lower, upper, floating) {
@@ -27156,7 +27819,7 @@ lodash.exports;
27156
27819
  lodash2.toInteger = toInteger;
27157
27820
  lodash2.toLength = toLength;
27158
27821
  lodash2.toLower = toLower;
27159
- lodash2.toNumber = toNumber;
27822
+ lodash2.toNumber = toNumber2;
27160
27823
  lodash2.toSafeInteger = toSafeInteger;
27161
27824
  lodash2.toString = toString;
27162
27825
  lodash2.toUpper = toUpper;