@vue/runtime-dom 3.3.4 → 3.3.5

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.
@@ -1,6 +1,6 @@
1
- import { warn, camelize, callWithAsyncErrorHandling, defineComponent, nextTick, createVNode, getCurrentInstance, watchPostEffect, onMounted, onUnmounted, Fragment, Static, h, BaseTransition, BaseTransitionPropsValidators, assertNumber, useTransitionState, onUpdated, toRaw, getTransitionRawChildren, setTransitionHooks, resolveTransitionHooks, isRuntimeOnly, createRenderer, createHydrationRenderer } from '@vue/runtime-core';
1
+ import { h, BaseTransition, BaseTransitionPropsValidators, assertNumber, warn, camelize, callWithAsyncErrorHandling, defineComponent, nextTick, createVNode, getCurrentInstance, watchPostEffect, onMounted, onUnmounted, Fragment, Static, useTransitionState, onUpdated, toRaw, getTransitionRawChildren, setTransitionHooks, resolveTransitionHooks, isRuntimeOnly, createRenderer, createHydrationRenderer } from '@vue/runtime-core';
2
2
  export * from '@vue/runtime-core';
3
- import { isString, isArray, hyphenate, capitalize, isSpecialBooleanAttr, includeBooleanAttr, isOn, isModelListener, isFunction, camelize as camelize$1, toNumber, extend, EMPTY_OBJ, isObject, looseToNumber, looseIndexOf, isSet, looseEqual, invokeArrayFns, isHTMLTag, isSVGTag } from '@vue/shared';
3
+ import { extend, isObject, toNumber, isArray, isString, hyphenate, capitalize, isSpecialBooleanAttr, includeBooleanAttr, isOn, isModelListener, isFunction, camelize as camelize$1, EMPTY_OBJ, looseToNumber, looseIndexOf, isSet, looseEqual, invokeArrayFns, isHTMLTag, isSVGTag } from '@vue/shared';
4
4
 
5
5
  const svgNS = "http://www.w3.org/2000/svg";
6
6
  const doc = typeof document !== "undefined" ? document : null;
@@ -69,8 +69,277 @@ const nodeOps = {
69
69
  }
70
70
  };
71
71
 
72
+ const TRANSITION = "transition";
73
+ const ANIMATION = "animation";
74
+ const vtcKey = Symbol("_vtc");
75
+ const Transition = (props, { slots }) => h(BaseTransition, resolveTransitionProps(props), slots);
76
+ Transition.displayName = "Transition";
77
+ const DOMTransitionPropsValidators = {
78
+ name: String,
79
+ type: String,
80
+ css: {
81
+ type: Boolean,
82
+ default: true
83
+ },
84
+ duration: [String, Number, Object],
85
+ enterFromClass: String,
86
+ enterActiveClass: String,
87
+ enterToClass: String,
88
+ appearFromClass: String,
89
+ appearActiveClass: String,
90
+ appearToClass: String,
91
+ leaveFromClass: String,
92
+ leaveActiveClass: String,
93
+ leaveToClass: String
94
+ };
95
+ const TransitionPropsValidators = Transition.props = /* @__PURE__ */ extend(
96
+ {},
97
+ BaseTransitionPropsValidators,
98
+ DOMTransitionPropsValidators
99
+ );
100
+ const callHook = (hook, args = []) => {
101
+ if (isArray(hook)) {
102
+ hook.forEach((h2) => h2(...args));
103
+ } else if (hook) {
104
+ hook(...args);
105
+ }
106
+ };
107
+ const hasExplicitCallback = (hook) => {
108
+ return hook ? isArray(hook) ? hook.some((h2) => h2.length > 1) : hook.length > 1 : false;
109
+ };
110
+ function resolveTransitionProps(rawProps) {
111
+ const baseProps = {};
112
+ for (const key in rawProps) {
113
+ if (!(key in DOMTransitionPropsValidators)) {
114
+ baseProps[key] = rawProps[key];
115
+ }
116
+ }
117
+ if (rawProps.css === false) {
118
+ return baseProps;
119
+ }
120
+ const {
121
+ name = "v",
122
+ type,
123
+ duration,
124
+ enterFromClass = `${name}-enter-from`,
125
+ enterActiveClass = `${name}-enter-active`,
126
+ enterToClass = `${name}-enter-to`,
127
+ appearFromClass = enterFromClass,
128
+ appearActiveClass = enterActiveClass,
129
+ appearToClass = enterToClass,
130
+ leaveFromClass = `${name}-leave-from`,
131
+ leaveActiveClass = `${name}-leave-active`,
132
+ leaveToClass = `${name}-leave-to`
133
+ } = rawProps;
134
+ const durations = normalizeDuration(duration);
135
+ const enterDuration = durations && durations[0];
136
+ const leaveDuration = durations && durations[1];
137
+ const {
138
+ onBeforeEnter,
139
+ onEnter,
140
+ onEnterCancelled,
141
+ onLeave,
142
+ onLeaveCancelled,
143
+ onBeforeAppear = onBeforeEnter,
144
+ onAppear = onEnter,
145
+ onAppearCancelled = onEnterCancelled
146
+ } = baseProps;
147
+ const finishEnter = (el, isAppear, done) => {
148
+ removeTransitionClass(el, isAppear ? appearToClass : enterToClass);
149
+ removeTransitionClass(el, isAppear ? appearActiveClass : enterActiveClass);
150
+ done && done();
151
+ };
152
+ const finishLeave = (el, done) => {
153
+ el._isLeaving = false;
154
+ removeTransitionClass(el, leaveFromClass);
155
+ removeTransitionClass(el, leaveToClass);
156
+ removeTransitionClass(el, leaveActiveClass);
157
+ done && done();
158
+ };
159
+ const makeEnterHook = (isAppear) => {
160
+ return (el, done) => {
161
+ const hook = isAppear ? onAppear : onEnter;
162
+ const resolve = () => finishEnter(el, isAppear, done);
163
+ callHook(hook, [el, resolve]);
164
+ nextFrame(() => {
165
+ removeTransitionClass(el, isAppear ? appearFromClass : enterFromClass);
166
+ addTransitionClass(el, isAppear ? appearToClass : enterToClass);
167
+ if (!hasExplicitCallback(hook)) {
168
+ whenTransitionEnds(el, type, enterDuration, resolve);
169
+ }
170
+ });
171
+ };
172
+ };
173
+ return extend(baseProps, {
174
+ onBeforeEnter(el) {
175
+ callHook(onBeforeEnter, [el]);
176
+ addTransitionClass(el, enterFromClass);
177
+ addTransitionClass(el, enterActiveClass);
178
+ },
179
+ onBeforeAppear(el) {
180
+ callHook(onBeforeAppear, [el]);
181
+ addTransitionClass(el, appearFromClass);
182
+ addTransitionClass(el, appearActiveClass);
183
+ },
184
+ onEnter: makeEnterHook(false),
185
+ onAppear: makeEnterHook(true),
186
+ onLeave(el, done) {
187
+ el._isLeaving = true;
188
+ const resolve = () => finishLeave(el, done);
189
+ addTransitionClass(el, leaveFromClass);
190
+ forceReflow();
191
+ addTransitionClass(el, leaveActiveClass);
192
+ nextFrame(() => {
193
+ if (!el._isLeaving) {
194
+ return;
195
+ }
196
+ removeTransitionClass(el, leaveFromClass);
197
+ addTransitionClass(el, leaveToClass);
198
+ if (!hasExplicitCallback(onLeave)) {
199
+ whenTransitionEnds(el, type, leaveDuration, resolve);
200
+ }
201
+ });
202
+ callHook(onLeave, [el, resolve]);
203
+ },
204
+ onEnterCancelled(el) {
205
+ finishEnter(el, false);
206
+ callHook(onEnterCancelled, [el]);
207
+ },
208
+ onAppearCancelled(el) {
209
+ finishEnter(el, true);
210
+ callHook(onAppearCancelled, [el]);
211
+ },
212
+ onLeaveCancelled(el) {
213
+ finishLeave(el);
214
+ callHook(onLeaveCancelled, [el]);
215
+ }
216
+ });
217
+ }
218
+ function normalizeDuration(duration) {
219
+ if (duration == null) {
220
+ return null;
221
+ } else if (isObject(duration)) {
222
+ return [NumberOf(duration.enter), NumberOf(duration.leave)];
223
+ } else {
224
+ const n = NumberOf(duration);
225
+ return [n, n];
226
+ }
227
+ }
228
+ function NumberOf(val) {
229
+ const res = toNumber(val);
230
+ if (!!(process.env.NODE_ENV !== "production")) {
231
+ assertNumber(res, "<transition> explicit duration");
232
+ }
233
+ return res;
234
+ }
235
+ function addTransitionClass(el, cls) {
236
+ cls.split(/\s+/).forEach((c) => c && el.classList.add(c));
237
+ (el[vtcKey] || (el[vtcKey] = /* @__PURE__ */ new Set())).add(cls);
238
+ }
239
+ function removeTransitionClass(el, cls) {
240
+ cls.split(/\s+/).forEach((c) => c && el.classList.remove(c));
241
+ const _vtc = el[vtcKey];
242
+ if (_vtc) {
243
+ _vtc.delete(cls);
244
+ if (!_vtc.size) {
245
+ el[vtcKey] = void 0;
246
+ }
247
+ }
248
+ }
249
+ function nextFrame(cb) {
250
+ requestAnimationFrame(() => {
251
+ requestAnimationFrame(cb);
252
+ });
253
+ }
254
+ let endId = 0;
255
+ function whenTransitionEnds(el, expectedType, explicitTimeout, resolve) {
256
+ const id = el._endId = ++endId;
257
+ const resolveIfNotStale = () => {
258
+ if (id === el._endId) {
259
+ resolve();
260
+ }
261
+ };
262
+ if (explicitTimeout) {
263
+ return setTimeout(resolveIfNotStale, explicitTimeout);
264
+ }
265
+ const { type, timeout, propCount } = getTransitionInfo(el, expectedType);
266
+ if (!type) {
267
+ return resolve();
268
+ }
269
+ const endEvent = type + "end";
270
+ let ended = 0;
271
+ const end = () => {
272
+ el.removeEventListener(endEvent, onEnd);
273
+ resolveIfNotStale();
274
+ };
275
+ const onEnd = (e) => {
276
+ if (e.target === el && ++ended >= propCount) {
277
+ end();
278
+ }
279
+ };
280
+ setTimeout(() => {
281
+ if (ended < propCount) {
282
+ end();
283
+ }
284
+ }, timeout + 1);
285
+ el.addEventListener(endEvent, onEnd);
286
+ }
287
+ function getTransitionInfo(el, expectedType) {
288
+ const styles = window.getComputedStyle(el);
289
+ const getStyleProperties = (key) => (styles[key] || "").split(", ");
290
+ const transitionDelays = getStyleProperties(`${TRANSITION}Delay`);
291
+ const transitionDurations = getStyleProperties(`${TRANSITION}Duration`);
292
+ const transitionTimeout = getTimeout(transitionDelays, transitionDurations);
293
+ const animationDelays = getStyleProperties(`${ANIMATION}Delay`);
294
+ const animationDurations = getStyleProperties(`${ANIMATION}Duration`);
295
+ const animationTimeout = getTimeout(animationDelays, animationDurations);
296
+ let type = null;
297
+ let timeout = 0;
298
+ let propCount = 0;
299
+ if (expectedType === TRANSITION) {
300
+ if (transitionTimeout > 0) {
301
+ type = TRANSITION;
302
+ timeout = transitionTimeout;
303
+ propCount = transitionDurations.length;
304
+ }
305
+ } else if (expectedType === ANIMATION) {
306
+ if (animationTimeout > 0) {
307
+ type = ANIMATION;
308
+ timeout = animationTimeout;
309
+ propCount = animationDurations.length;
310
+ }
311
+ } else {
312
+ timeout = Math.max(transitionTimeout, animationTimeout);
313
+ type = timeout > 0 ? transitionTimeout > animationTimeout ? TRANSITION : ANIMATION : null;
314
+ propCount = type ? type === TRANSITION ? transitionDurations.length : animationDurations.length : 0;
315
+ }
316
+ const hasTransform = type === TRANSITION && /\b(transform|all)(,|$)/.test(
317
+ getStyleProperties(`${TRANSITION}Property`).toString()
318
+ );
319
+ return {
320
+ type,
321
+ timeout,
322
+ propCount,
323
+ hasTransform
324
+ };
325
+ }
326
+ function getTimeout(delays, durations) {
327
+ while (delays.length < durations.length) {
328
+ delays = delays.concat(delays);
329
+ }
330
+ return Math.max(...durations.map((d, i) => toMs(d) + toMs(delays[i])));
331
+ }
332
+ function toMs(s) {
333
+ if (s === "auto")
334
+ return 0;
335
+ return Number(s.slice(0, -1).replace(",", ".")) * 1e3;
336
+ }
337
+ function forceReflow() {
338
+ return document.body.offsetHeight;
339
+ }
340
+
72
341
  function patchClass(el, value, isSVG) {
73
- const transitionClasses = el._vtc;
342
+ const transitionClasses = el[vtcKey];
74
343
  if (transitionClasses) {
75
344
  value = (value ? [value, ...transitionClasses] : [...transitionClasses]).join(" ");
76
345
  }
@@ -83,6 +352,53 @@ function patchClass(el, value, isSVG) {
83
352
  }
84
353
  }
85
354
 
355
+ const vShowOldKey = Symbol("_vod");
356
+ const vShow = {
357
+ beforeMount(el, { value }, { transition }) {
358
+ el[vShowOldKey] = el.style.display === "none" ? "" : el.style.display;
359
+ if (transition && value) {
360
+ transition.beforeEnter(el);
361
+ } else {
362
+ setDisplay(el, value);
363
+ }
364
+ },
365
+ mounted(el, { value }, { transition }) {
366
+ if (transition && value) {
367
+ transition.enter(el);
368
+ }
369
+ },
370
+ updated(el, { value, oldValue }, { transition }) {
371
+ if (!value === !oldValue)
372
+ return;
373
+ if (transition) {
374
+ if (value) {
375
+ transition.beforeEnter(el);
376
+ setDisplay(el, true);
377
+ transition.enter(el);
378
+ } else {
379
+ transition.leave(el, () => {
380
+ setDisplay(el, false);
381
+ });
382
+ }
383
+ } else {
384
+ setDisplay(el, value);
385
+ }
386
+ },
387
+ beforeUnmount(el, { value }) {
388
+ setDisplay(el, value);
389
+ }
390
+ };
391
+ function setDisplay(el, value) {
392
+ el.style.display = value ? el[vShowOldKey] : "none";
393
+ }
394
+ function initVShowForSSR() {
395
+ vShow.getSSRProps = ({ value }) => {
396
+ if (!value) {
397
+ return { style: { display: "none" } };
398
+ }
399
+ };
400
+ }
401
+
86
402
  function patchStyle(el, prev, next) {
87
403
  const style = el.style;
88
404
  const isCssString = isString(next);
@@ -106,7 +422,7 @@ function patchStyle(el, prev, next) {
106
422
  } else if (prev) {
107
423
  el.removeAttribute("style");
108
424
  }
109
- if ("_vod" in el) {
425
+ if (vShowOldKey in el) {
110
426
  style.display = currentDisplay;
111
427
  }
112
428
  }
@@ -235,8 +551,9 @@ function addEventListener(el, event, handler, options) {
235
551
  function removeEventListener(el, event, handler, options) {
236
552
  el.removeEventListener(event, handler, options);
237
553
  }
554
+ const veiKey = Symbol("_vei");
238
555
  function patchEvent(el, rawName, prevValue, nextValue, instance = null) {
239
- const invokers = el._vei || (el._vei = {});
556
+ const invokers = el[veiKey] || (el[veiKey] = {});
240
557
  const existingInvoker = invokers[rawName];
241
558
  if (nextValue && existingInvoker) {
242
559
  existingInvoker.value = nextValue;
@@ -356,6 +673,8 @@ function shouldSetAsProp(el, key, value, isSVG) {
356
673
  return key in el;
357
674
  }
358
675
 
676
+ /*! #__NO_SIDE_EFFECTS__ */
677
+ // @__NO_SIDE_EFFECTS__
359
678
  function defineCustomElement(options, hydrate2) {
360
679
  const Comp = defineComponent(options);
361
680
  class VueCustomElement extends VueElement {
@@ -366,8 +685,9 @@ function defineCustomElement(options, hydrate2) {
366
685
  VueCustomElement.def = Comp;
367
686
  return VueCustomElement;
368
687
  }
369
- const defineSSRCustomElement = (options) => {
370
- return defineCustomElement(options, hydrate);
688
+ /*! #__NO_SIDE_EFFECTS__ */
689
+ const defineSSRCustomElement = /* @__NO_SIDE_EFFECTS__ */ (options) => {
690
+ return /* @__PURE__ */ defineCustomElement(options, hydrate);
371
691
  };
372
692
  const BaseClass = typeof HTMLElement !== "undefined" ? HTMLElement : class {
373
693
  };
@@ -383,6 +703,7 @@ class VueElement extends BaseClass {
383
703
  this._connected = false;
384
704
  this._resolved = false;
385
705
  this._numberProps = null;
706
+ this._ob = null;
386
707
  if (this.shadowRoot && hydrate2) {
387
708
  hydrate2(this._createVNode(), this.shadowRoot);
388
709
  } else {
@@ -409,6 +730,10 @@ class VueElement extends BaseClass {
409
730
  }
410
731
  disconnectedCallback() {
411
732
  this._connected = false;
733
+ if (this._ob) {
734
+ this._ob.disconnect();
735
+ this._ob = null;
736
+ }
412
737
  nextTick(() => {
413
738
  if (!this._connected) {
414
739
  render(null, this.shadowRoot);
@@ -424,11 +749,12 @@ class VueElement extends BaseClass {
424
749
  for (let i = 0; i < this.attributes.length; i++) {
425
750
  this._setAttr(this.attributes[i].name);
426
751
  }
427
- new MutationObserver((mutations) => {
752
+ this._ob = new MutationObserver((mutations) => {
428
753
  for (const m of mutations) {
429
754
  this._setAttr(m.attributeName);
430
755
  }
431
- }).observe(this, { attributes: true });
756
+ });
757
+ this._ob.observe(this, { attributes: true });
432
758
  const resolve = (def, isAsync = false) => {
433
759
  const { props, styles } = def;
434
760
  let numberProps;
@@ -539,384 +865,120 @@ class VueElement extends BaseClass {
539
865
  };
540
866
  instance.emit = (event, ...args) => {
541
867
  dispatch(event, args);
542
- if (hyphenate(event) !== event) {
543
- dispatch(hyphenate(event), args);
544
- }
545
- };
546
- let parent = this;
547
- while (parent = parent && (parent.parentNode || parent.host)) {
548
- if (parent instanceof VueElement) {
549
- instance.parent = parent._instance;
550
- instance.provides = parent._instance.provides;
551
- break;
552
- }
553
- }
554
- };
555
- }
556
- return vnode;
557
- }
558
- _applyStyles(styles) {
559
- if (styles) {
560
- styles.forEach((css) => {
561
- const s = document.createElement("style");
562
- s.textContent = css;
563
- this.shadowRoot.appendChild(s);
564
- if (!!(process.env.NODE_ENV !== "production")) {
565
- (this._styles || (this._styles = [])).push(s);
566
- }
567
- });
568
- }
569
- }
570
- }
571
-
572
- function useCssModule(name = "$style") {
573
- {
574
- const instance = getCurrentInstance();
575
- if (!instance) {
576
- !!(process.env.NODE_ENV !== "production") && warn(`useCssModule must be called inside setup()`);
577
- return EMPTY_OBJ;
578
- }
579
- const modules = instance.type.__cssModules;
580
- if (!modules) {
581
- !!(process.env.NODE_ENV !== "production") && warn(`Current instance does not have CSS modules injected.`);
582
- return EMPTY_OBJ;
583
- }
584
- const mod = modules[name];
585
- if (!mod) {
586
- !!(process.env.NODE_ENV !== "production") && warn(`Current instance does not have CSS module named "${name}".`);
587
- return EMPTY_OBJ;
588
- }
589
- return mod;
590
- }
591
- }
592
-
593
- function useCssVars(getter) {
594
- const instance = getCurrentInstance();
595
- if (!instance) {
596
- !!(process.env.NODE_ENV !== "production") && warn(`useCssVars is called without current active component instance.`);
597
- return;
598
- }
599
- const updateTeleports = instance.ut = (vars = getter(instance.proxy)) => {
600
- Array.from(
601
- document.querySelectorAll(`[data-v-owner="${instance.uid}"]`)
602
- ).forEach((node) => setVarsOnNode(node, vars));
603
- };
604
- const setVars = () => {
605
- const vars = getter(instance.proxy);
606
- setVarsOnVNode(instance.subTree, vars);
607
- updateTeleports(vars);
608
- };
609
- watchPostEffect(setVars);
610
- onMounted(() => {
611
- const ob = new MutationObserver(setVars);
612
- ob.observe(instance.subTree.el.parentNode, { childList: true });
613
- onUnmounted(() => ob.disconnect());
614
- });
615
- }
616
- function setVarsOnVNode(vnode, vars) {
617
- if (vnode.shapeFlag & 128) {
618
- const suspense = vnode.suspense;
619
- vnode = suspense.activeBranch;
620
- if (suspense.pendingBranch && !suspense.isHydrating) {
621
- suspense.effects.push(() => {
622
- setVarsOnVNode(suspense.activeBranch, vars);
623
- });
624
- }
625
- }
626
- while (vnode.component) {
627
- vnode = vnode.component.subTree;
628
- }
629
- if (vnode.shapeFlag & 1 && vnode.el) {
630
- setVarsOnNode(vnode.el, vars);
631
- } else if (vnode.type === Fragment) {
632
- vnode.children.forEach((c) => setVarsOnVNode(c, vars));
633
- } else if (vnode.type === Static) {
634
- let { el, anchor } = vnode;
635
- while (el) {
636
- setVarsOnNode(el, vars);
637
- if (el === anchor)
638
- break;
639
- el = el.nextSibling;
640
- }
641
- }
642
- }
643
- function setVarsOnNode(el, vars) {
644
- if (el.nodeType === 1) {
645
- const style = el.style;
646
- for (const key in vars) {
647
- style.setProperty(`--${key}`, vars[key]);
648
- }
649
- }
650
- }
651
-
652
- const TRANSITION = "transition";
653
- const ANIMATION = "animation";
654
- const Transition = (props, { slots }) => h(BaseTransition, resolveTransitionProps(props), slots);
655
- Transition.displayName = "Transition";
656
- const DOMTransitionPropsValidators = {
657
- name: String,
658
- type: String,
659
- css: {
660
- type: Boolean,
661
- default: true
662
- },
663
- duration: [String, Number, Object],
664
- enterFromClass: String,
665
- enterActiveClass: String,
666
- enterToClass: String,
667
- appearFromClass: String,
668
- appearActiveClass: String,
669
- appearToClass: String,
670
- leaveFromClass: String,
671
- leaveActiveClass: String,
672
- leaveToClass: String
673
- };
674
- const TransitionPropsValidators = Transition.props = /* @__PURE__ */ extend(
675
- {},
676
- BaseTransitionPropsValidators,
677
- DOMTransitionPropsValidators
678
- );
679
- const callHook = (hook, args = []) => {
680
- if (isArray(hook)) {
681
- hook.forEach((h2) => h2(...args));
682
- } else if (hook) {
683
- hook(...args);
684
- }
685
- };
686
- const hasExplicitCallback = (hook) => {
687
- return hook ? isArray(hook) ? hook.some((h2) => h2.length > 1) : hook.length > 1 : false;
688
- };
689
- function resolveTransitionProps(rawProps) {
690
- const baseProps = {};
691
- for (const key in rawProps) {
692
- if (!(key in DOMTransitionPropsValidators)) {
693
- baseProps[key] = rawProps[key];
694
- }
695
- }
696
- if (rawProps.css === false) {
697
- return baseProps;
698
- }
699
- const {
700
- name = "v",
701
- type,
702
- duration,
703
- enterFromClass = `${name}-enter-from`,
704
- enterActiveClass = `${name}-enter-active`,
705
- enterToClass = `${name}-enter-to`,
706
- appearFromClass = enterFromClass,
707
- appearActiveClass = enterActiveClass,
708
- appearToClass = enterToClass,
709
- leaveFromClass = `${name}-leave-from`,
710
- leaveActiveClass = `${name}-leave-active`,
711
- leaveToClass = `${name}-leave-to`
712
- } = rawProps;
713
- const durations = normalizeDuration(duration);
714
- const enterDuration = durations && durations[0];
715
- const leaveDuration = durations && durations[1];
716
- const {
717
- onBeforeEnter,
718
- onEnter,
719
- onEnterCancelled,
720
- onLeave,
721
- onLeaveCancelled,
722
- onBeforeAppear = onBeforeEnter,
723
- onAppear = onEnter,
724
- onAppearCancelled = onEnterCancelled
725
- } = baseProps;
726
- const finishEnter = (el, isAppear, done) => {
727
- removeTransitionClass(el, isAppear ? appearToClass : enterToClass);
728
- removeTransitionClass(el, isAppear ? appearActiveClass : enterActiveClass);
729
- done && done();
730
- };
731
- const finishLeave = (el, done) => {
732
- el._isLeaving = false;
733
- removeTransitionClass(el, leaveFromClass);
734
- removeTransitionClass(el, leaveToClass);
735
- removeTransitionClass(el, leaveActiveClass);
736
- done && done();
737
- };
738
- const makeEnterHook = (isAppear) => {
739
- return (el, done) => {
740
- const hook = isAppear ? onAppear : onEnter;
741
- const resolve = () => finishEnter(el, isAppear, done);
742
- callHook(hook, [el, resolve]);
743
- nextFrame(() => {
744
- removeTransitionClass(el, isAppear ? appearFromClass : enterFromClass);
745
- addTransitionClass(el, isAppear ? appearToClass : enterToClass);
746
- if (!hasExplicitCallback(hook)) {
747
- whenTransitionEnds(el, type, enterDuration, resolve);
748
- }
749
- });
750
- };
751
- };
752
- return extend(baseProps, {
753
- onBeforeEnter(el) {
754
- callHook(onBeforeEnter, [el]);
755
- addTransitionClass(el, enterFromClass);
756
- addTransitionClass(el, enterActiveClass);
757
- },
758
- onBeforeAppear(el) {
759
- callHook(onBeforeAppear, [el]);
760
- addTransitionClass(el, appearFromClass);
761
- addTransitionClass(el, appearActiveClass);
762
- },
763
- onEnter: makeEnterHook(false),
764
- onAppear: makeEnterHook(true),
765
- onLeave(el, done) {
766
- el._isLeaving = true;
767
- const resolve = () => finishLeave(el, done);
768
- addTransitionClass(el, leaveFromClass);
769
- forceReflow();
770
- addTransitionClass(el, leaveActiveClass);
771
- nextFrame(() => {
772
- if (!el._isLeaving) {
773
- return;
868
+ if (hyphenate(event) !== event) {
869
+ dispatch(hyphenate(event), args);
870
+ }
871
+ };
872
+ let parent = this;
873
+ while (parent = parent && (parent.parentNode || parent.host)) {
874
+ if (parent instanceof VueElement) {
875
+ instance.parent = parent._instance;
876
+ instance.provides = parent._instance.provides;
877
+ break;
878
+ }
774
879
  }
775
- removeTransitionClass(el, leaveFromClass);
776
- addTransitionClass(el, leaveToClass);
777
- if (!hasExplicitCallback(onLeave)) {
778
- whenTransitionEnds(el, type, leaveDuration, resolve);
880
+ };
881
+ }
882
+ return vnode;
883
+ }
884
+ _applyStyles(styles) {
885
+ if (styles) {
886
+ styles.forEach((css) => {
887
+ const s = document.createElement("style");
888
+ s.textContent = css;
889
+ this.shadowRoot.appendChild(s);
890
+ if (!!(process.env.NODE_ENV !== "production")) {
891
+ (this._styles || (this._styles = [])).push(s);
779
892
  }
780
893
  });
781
- callHook(onLeave, [el, resolve]);
782
- },
783
- onEnterCancelled(el) {
784
- finishEnter(el, false);
785
- callHook(onEnterCancelled, [el]);
786
- },
787
- onAppearCancelled(el) {
788
- finishEnter(el, true);
789
- callHook(onAppearCancelled, [el]);
790
- },
791
- onLeaveCancelled(el) {
792
- finishLeave(el);
793
- callHook(onLeaveCancelled, [el]);
794
894
  }
795
- });
796
- }
797
- function normalizeDuration(duration) {
798
- if (duration == null) {
799
- return null;
800
- } else if (isObject(duration)) {
801
- return [NumberOf(duration.enter), NumberOf(duration.leave)];
802
- } else {
803
- const n = NumberOf(duration);
804
- return [n, n];
805
- }
806
- }
807
- function NumberOf(val) {
808
- const res = toNumber(val);
809
- if (!!(process.env.NODE_ENV !== "production")) {
810
- assertNumber(res, "<transition> explicit duration");
811
895
  }
812
- return res;
813
- }
814
- function addTransitionClass(el, cls) {
815
- cls.split(/\s+/).forEach((c) => c && el.classList.add(c));
816
- (el._vtc || (el._vtc = /* @__PURE__ */ new Set())).add(cls);
817
896
  }
818
- function removeTransitionClass(el, cls) {
819
- cls.split(/\s+/).forEach((c) => c && el.classList.remove(c));
820
- const { _vtc } = el;
821
- if (_vtc) {
822
- _vtc.delete(cls);
823
- if (!_vtc.size) {
824
- el._vtc = void 0;
897
+
898
+ function useCssModule(name = "$style") {
899
+ {
900
+ const instance = getCurrentInstance();
901
+ if (!instance) {
902
+ !!(process.env.NODE_ENV !== "production") && warn(`useCssModule must be called inside setup()`);
903
+ return EMPTY_OBJ;
825
904
  }
826
- }
827
- }
828
- function nextFrame(cb) {
829
- requestAnimationFrame(() => {
830
- requestAnimationFrame(cb);
831
- });
832
- }
833
- let endId = 0;
834
- function whenTransitionEnds(el, expectedType, explicitTimeout, resolve) {
835
- const id = el._endId = ++endId;
836
- const resolveIfNotStale = () => {
837
- if (id === el._endId) {
838
- resolve();
905
+ const modules = instance.type.__cssModules;
906
+ if (!modules) {
907
+ !!(process.env.NODE_ENV !== "production") && warn(`Current instance does not have CSS modules injected.`);
908
+ return EMPTY_OBJ;
839
909
  }
840
- };
841
- if (explicitTimeout) {
842
- return setTimeout(resolveIfNotStale, explicitTimeout);
910
+ const mod = modules[name];
911
+ if (!mod) {
912
+ !!(process.env.NODE_ENV !== "production") && warn(`Current instance does not have CSS module named "${name}".`);
913
+ return EMPTY_OBJ;
914
+ }
915
+ return mod;
843
916
  }
844
- const { type, timeout, propCount } = getTransitionInfo(el, expectedType);
845
- if (!type) {
846
- return resolve();
917
+ }
918
+
919
+ function useCssVars(getter) {
920
+ const instance = getCurrentInstance();
921
+ if (!instance) {
922
+ !!(process.env.NODE_ENV !== "production") && warn(`useCssVars is called without current active component instance.`);
923
+ return;
847
924
  }
848
- const endEvent = type + "end";
849
- let ended = 0;
850
- const end = () => {
851
- el.removeEventListener(endEvent, onEnd);
852
- resolveIfNotStale();
925
+ const updateTeleports = instance.ut = (vars = getter(instance.proxy)) => {
926
+ Array.from(
927
+ document.querySelectorAll(`[data-v-owner="${instance.uid}"]`)
928
+ ).forEach((node) => setVarsOnNode(node, vars));
853
929
  };
854
- const onEnd = (e) => {
855
- if (e.target === el && ++ended >= propCount) {
856
- end();
857
- }
930
+ const setVars = () => {
931
+ const vars = getter(instance.proxy);
932
+ setVarsOnVNode(instance.subTree, vars);
933
+ updateTeleports(vars);
858
934
  };
859
- setTimeout(() => {
860
- if (ended < propCount) {
861
- end();
862
- }
863
- }, timeout + 1);
864
- el.addEventListener(endEvent, onEnd);
935
+ watchPostEffect(setVars);
936
+ onMounted(() => {
937
+ const ob = new MutationObserver(setVars);
938
+ ob.observe(instance.subTree.el.parentNode, { childList: true });
939
+ onUnmounted(() => ob.disconnect());
940
+ });
865
941
  }
866
- function getTransitionInfo(el, expectedType) {
867
- const styles = window.getComputedStyle(el);
868
- const getStyleProperties = (key) => (styles[key] || "").split(", ");
869
- const transitionDelays = getStyleProperties(`${TRANSITION}Delay`);
870
- const transitionDurations = getStyleProperties(`${TRANSITION}Duration`);
871
- const transitionTimeout = getTimeout(transitionDelays, transitionDurations);
872
- const animationDelays = getStyleProperties(`${ANIMATION}Delay`);
873
- const animationDurations = getStyleProperties(`${ANIMATION}Duration`);
874
- const animationTimeout = getTimeout(animationDelays, animationDurations);
875
- let type = null;
876
- let timeout = 0;
877
- let propCount = 0;
878
- if (expectedType === TRANSITION) {
879
- if (transitionTimeout > 0) {
880
- type = TRANSITION;
881
- timeout = transitionTimeout;
882
- propCount = transitionDurations.length;
942
+ function setVarsOnVNode(vnode, vars) {
943
+ if (vnode.shapeFlag & 128) {
944
+ const suspense = vnode.suspense;
945
+ vnode = suspense.activeBranch;
946
+ if (suspense.pendingBranch && !suspense.isHydrating) {
947
+ suspense.effects.push(() => {
948
+ setVarsOnVNode(suspense.activeBranch, vars);
949
+ });
883
950
  }
884
- } else if (expectedType === ANIMATION) {
885
- if (animationTimeout > 0) {
886
- type = ANIMATION;
887
- timeout = animationTimeout;
888
- propCount = animationDurations.length;
951
+ }
952
+ while (vnode.component) {
953
+ vnode = vnode.component.subTree;
954
+ }
955
+ if (vnode.shapeFlag & 1 && vnode.el) {
956
+ setVarsOnNode(vnode.el, vars);
957
+ } else if (vnode.type === Fragment) {
958
+ vnode.children.forEach((c) => setVarsOnVNode(c, vars));
959
+ } else if (vnode.type === Static) {
960
+ let { el, anchor } = vnode;
961
+ while (el) {
962
+ setVarsOnNode(el, vars);
963
+ if (el === anchor)
964
+ break;
965
+ el = el.nextSibling;
889
966
  }
890
- } else {
891
- timeout = Math.max(transitionTimeout, animationTimeout);
892
- type = timeout > 0 ? transitionTimeout > animationTimeout ? TRANSITION : ANIMATION : null;
893
- propCount = type ? type === TRANSITION ? transitionDurations.length : animationDurations.length : 0;
894
967
  }
895
- const hasTransform = type === TRANSITION && /\b(transform|all)(,|$)/.test(
896
- getStyleProperties(`${TRANSITION}Property`).toString()
897
- );
898
- return {
899
- type,
900
- timeout,
901
- propCount,
902
- hasTransform
903
- };
904
968
  }
905
- function getTimeout(delays, durations) {
906
- while (delays.length < durations.length) {
907
- delays = delays.concat(delays);
969
+ function setVarsOnNode(el, vars) {
970
+ if (el.nodeType === 1) {
971
+ const style = el.style;
972
+ for (const key in vars) {
973
+ style.setProperty(`--${key}`, vars[key]);
974
+ }
908
975
  }
909
- return Math.max(...durations.map((d, i) => toMs(d) + toMs(delays[i])));
910
- }
911
- function toMs(s) {
912
- return Number(s.slice(0, -1).replace(",", ".")) * 1e3;
913
- }
914
- function forceReflow() {
915
- return document.body.offsetHeight;
916
976
  }
917
977
 
918
978
  const positionMap = /* @__PURE__ */ new WeakMap();
919
979
  const newPositionMap = /* @__PURE__ */ new WeakMap();
980
+ const moveCbKey = Symbol("_moveCb");
981
+ const enterCbKey = Symbol("_enterCb");
920
982
  const TransitionGroupImpl = {
921
983
  name: "TransitionGroup",
922
984
  props: /* @__PURE__ */ extend({}, TransitionPropsValidators, {
@@ -949,13 +1011,13 @@ const TransitionGroupImpl = {
949
1011
  const style = el.style;
950
1012
  addTransitionClass(el, moveClass);
951
1013
  style.transform = style.webkitTransform = style.transitionDuration = "";
952
- const cb = el._moveCb = (e) => {
1014
+ const cb = el[moveCbKey] = (e) => {
953
1015
  if (e && e.target !== el) {
954
1016
  return;
955
1017
  }
956
1018
  if (!e || /transform$/.test(e.propertyName)) {
957
1019
  el.removeEventListener("transitionend", cb);
958
- el._moveCb = null;
1020
+ el[moveCbKey] = null;
959
1021
  removeTransitionClass(el, moveClass);
960
1022
  }
961
1023
  };
@@ -998,11 +1060,11 @@ const removeMode = (props) => delete props.mode;
998
1060
  const TransitionGroup = TransitionGroupImpl;
999
1061
  function callPendingCbs(c) {
1000
1062
  const el = c.el;
1001
- if (el._moveCb) {
1002
- el._moveCb();
1063
+ if (el[moveCbKey]) {
1064
+ el[moveCbKey]();
1003
1065
  }
1004
- if (el._enterCb) {
1005
- el._enterCb();
1066
+ if (el[enterCbKey]) {
1067
+ el[enterCbKey]();
1006
1068
  }
1007
1069
  }
1008
1070
  function recordPosition(c) {
@@ -1022,8 +1084,9 @@ function applyTranslation(c) {
1022
1084
  }
1023
1085
  function hasCSSTransform(el, root, moveClass) {
1024
1086
  const clone = el.cloneNode();
1025
- if (el._vtc) {
1026
- el._vtc.forEach((cls) => {
1087
+ const _vtc = el[vtcKey];
1088
+ if (_vtc) {
1089
+ _vtc.forEach((cls) => {
1027
1090
  cls.split(/\s+/).forEach((c) => c && clone.classList.remove(c));
1028
1091
  });
1029
1092
  }
@@ -1050,9 +1113,10 @@ function onCompositionEnd(e) {
1050
1113
  target.dispatchEvent(new Event("input"));
1051
1114
  }
1052
1115
  }
1116
+ const assignKey = Symbol("_assign");
1053
1117
  const vModelText = {
1054
1118
  created(el, { modifiers: { lazy, trim, number } }, vnode) {
1055
- el._assign = getModelAssigner(vnode);
1119
+ el[assignKey] = getModelAssigner(vnode);
1056
1120
  const castToNumber = number || vnode.props && vnode.props.type === "number";
1057
1121
  addEventListener(el, lazy ? "change" : "input", (e) => {
1058
1122
  if (e.target.composing)
@@ -1064,7 +1128,7 @@ const vModelText = {
1064
1128
  if (castToNumber) {
1065
1129
  domValue = looseToNumber(domValue);
1066
1130
  }
1067
- el._assign(domValue);
1131
+ el[assignKey](domValue);
1068
1132
  });
1069
1133
  if (trim) {
1070
1134
  addEventListener(el, "change", () => {
@@ -1082,7 +1146,7 @@ const vModelText = {
1082
1146
  el.value = value == null ? "" : value;
1083
1147
  },
1084
1148
  beforeUpdate(el, { value, modifiers: { lazy, trim, number } }, vnode) {
1085
- el._assign = getModelAssigner(vnode);
1149
+ el[assignKey] = getModelAssigner(vnode);
1086
1150
  if (el.composing)
1087
1151
  return;
1088
1152
  if (document.activeElement === el && el.type !== "range") {
@@ -1106,12 +1170,12 @@ const vModelCheckbox = {
1106
1170
  // #4096 array checkboxes need to be deep traversed
1107
1171
  deep: true,
1108
1172
  created(el, _, vnode) {
1109
- el._assign = getModelAssigner(vnode);
1173
+ el[assignKey] = getModelAssigner(vnode);
1110
1174
  addEventListener(el, "change", () => {
1111
1175
  const modelValue = el._modelValue;
1112
1176
  const elementValue = getValue(el);
1113
1177
  const checked = el.checked;
1114
- const assign = el._assign;
1178
+ const assign = el[assignKey];
1115
1179
  if (isArray(modelValue)) {
1116
1180
  const index = looseIndexOf(modelValue, elementValue);
1117
1181
  const found = index !== -1;
@@ -1138,7 +1202,7 @@ const vModelCheckbox = {
1138
1202
  // set initial checked on mount to wait for true-value/false-value
1139
1203
  mounted: setChecked,
1140
1204
  beforeUpdate(el, binding, vnode) {
1141
- el._assign = getModelAssigner(vnode);
1205
+ el[assignKey] = getModelAssigner(vnode);
1142
1206
  setChecked(el, binding, vnode);
1143
1207
  }
1144
1208
  };
@@ -1155,13 +1219,13 @@ function setChecked(el, { value, oldValue }, vnode) {
1155
1219
  const vModelRadio = {
1156
1220
  created(el, { value }, vnode) {
1157
1221
  el.checked = looseEqual(value, vnode.props.value);
1158
- el._assign = getModelAssigner(vnode);
1222
+ el[assignKey] = getModelAssigner(vnode);
1159
1223
  addEventListener(el, "change", () => {
1160
- el._assign(getValue(el));
1224
+ el[assignKey](getValue(el));
1161
1225
  });
1162
1226
  },
1163
1227
  beforeUpdate(el, { value, oldValue }, vnode) {
1164
- el._assign = getModelAssigner(vnode);
1228
+ el[assignKey] = getModelAssigner(vnode);
1165
1229
  if (value !== oldValue) {
1166
1230
  el.checked = looseEqual(value, vnode.props.value);
1167
1231
  }
@@ -1176,11 +1240,11 @@ const vModelSelect = {
1176
1240
  const selectedVal = Array.prototype.filter.call(el.options, (o) => o.selected).map(
1177
1241
  (o) => number ? looseToNumber(getValue(o)) : getValue(o)
1178
1242
  );
1179
- el._assign(
1243
+ el[assignKey](
1180
1244
  el.multiple ? isSetModel ? new Set(selectedVal) : selectedVal : selectedVal[0]
1181
1245
  );
1182
1246
  });
1183
- el._assign = getModelAssigner(vnode);
1247
+ el[assignKey] = getModelAssigner(vnode);
1184
1248
  },
1185
1249
  // set value in mounted & updated because <select> relies on its children
1186
1250
  // <option>s.
@@ -1188,7 +1252,7 @@ const vModelSelect = {
1188
1252
  setSelected(el, value);
1189
1253
  },
1190
1254
  beforeUpdate(el, _binding, vnode) {
1191
- el._assign = getModelAssigner(vnode);
1255
+ el[assignKey] = getModelAssigner(vnode);
1192
1256
  },
1193
1257
  updated(el, { value }) {
1194
1258
  setSelected(el, value);
@@ -1349,52 +1413,6 @@ const withKeys = (fn, modifiers) => {
1349
1413
  };
1350
1414
  };
1351
1415
 
1352
- const vShow = {
1353
- beforeMount(el, { value }, { transition }) {
1354
- el._vod = el.style.display === "none" ? "" : el.style.display;
1355
- if (transition && value) {
1356
- transition.beforeEnter(el);
1357
- } else {
1358
- setDisplay(el, value);
1359
- }
1360
- },
1361
- mounted(el, { value }, { transition }) {
1362
- if (transition && value) {
1363
- transition.enter(el);
1364
- }
1365
- },
1366
- updated(el, { value, oldValue }, { transition }) {
1367
- if (!value === !oldValue)
1368
- return;
1369
- if (transition) {
1370
- if (value) {
1371
- transition.beforeEnter(el);
1372
- setDisplay(el, true);
1373
- transition.enter(el);
1374
- } else {
1375
- transition.leave(el, () => {
1376
- setDisplay(el, false);
1377
- });
1378
- }
1379
- } else {
1380
- setDisplay(el, value);
1381
- }
1382
- },
1383
- beforeUnmount(el, { value }) {
1384
- setDisplay(el, value);
1385
- }
1386
- };
1387
- function setDisplay(el, value) {
1388
- el.style.display = value ? el._vod : "none";
1389
- }
1390
- function initVShowForSSR() {
1391
- vShow.getSSRProps = ({ value }) => {
1392
- if (!value) {
1393
- return { style: { display: "none" } };
1394
- }
1395
- };
1396
- }
1397
-
1398
1416
  const rendererOptions = /* @__PURE__ */ extend({ patchProp }, nodeOps);
1399
1417
  let renderer;
1400
1418
  let enabledHydration = false;