@vue/runtime-dom 3.3.4 → 3.3.6

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.
@@ -72,8 +72,274 @@ const nodeOps = {
72
72
  }
73
73
  };
74
74
 
75
+ const TRANSITION = "transition";
76
+ const ANIMATION = "animation";
77
+ const vtcKey = Symbol("_vtc");
78
+ const Transition = (props, { slots }) => runtimeCore.h(runtimeCore.BaseTransition, resolveTransitionProps(props), slots);
79
+ Transition.displayName = "Transition";
80
+ const DOMTransitionPropsValidators = {
81
+ name: String,
82
+ type: String,
83
+ css: {
84
+ type: Boolean,
85
+ default: true
86
+ },
87
+ duration: [String, Number, Object],
88
+ enterFromClass: String,
89
+ enterActiveClass: String,
90
+ enterToClass: String,
91
+ appearFromClass: String,
92
+ appearActiveClass: String,
93
+ appearToClass: String,
94
+ leaveFromClass: String,
95
+ leaveActiveClass: String,
96
+ leaveToClass: String
97
+ };
98
+ const TransitionPropsValidators = Transition.props = /* @__PURE__ */ shared.extend(
99
+ {},
100
+ runtimeCore.BaseTransitionPropsValidators,
101
+ DOMTransitionPropsValidators
102
+ );
103
+ const callHook = (hook, args = []) => {
104
+ if (shared.isArray(hook)) {
105
+ hook.forEach((h2) => h2(...args));
106
+ } else if (hook) {
107
+ hook(...args);
108
+ }
109
+ };
110
+ const hasExplicitCallback = (hook) => {
111
+ return hook ? shared.isArray(hook) ? hook.some((h2) => h2.length > 1) : hook.length > 1 : false;
112
+ };
113
+ function resolveTransitionProps(rawProps) {
114
+ const baseProps = {};
115
+ for (const key in rawProps) {
116
+ if (!(key in DOMTransitionPropsValidators)) {
117
+ baseProps[key] = rawProps[key];
118
+ }
119
+ }
120
+ if (rawProps.css === false) {
121
+ return baseProps;
122
+ }
123
+ const {
124
+ name = "v",
125
+ type,
126
+ duration,
127
+ enterFromClass = `${name}-enter-from`,
128
+ enterActiveClass = `${name}-enter-active`,
129
+ enterToClass = `${name}-enter-to`,
130
+ appearFromClass = enterFromClass,
131
+ appearActiveClass = enterActiveClass,
132
+ appearToClass = enterToClass,
133
+ leaveFromClass = `${name}-leave-from`,
134
+ leaveActiveClass = `${name}-leave-active`,
135
+ leaveToClass = `${name}-leave-to`
136
+ } = rawProps;
137
+ const durations = normalizeDuration(duration);
138
+ const enterDuration = durations && durations[0];
139
+ const leaveDuration = durations && durations[1];
140
+ const {
141
+ onBeforeEnter,
142
+ onEnter,
143
+ onEnterCancelled,
144
+ onLeave,
145
+ onLeaveCancelled,
146
+ onBeforeAppear = onBeforeEnter,
147
+ onAppear = onEnter,
148
+ onAppearCancelled = onEnterCancelled
149
+ } = baseProps;
150
+ const finishEnter = (el, isAppear, done) => {
151
+ removeTransitionClass(el, isAppear ? appearToClass : enterToClass);
152
+ removeTransitionClass(el, isAppear ? appearActiveClass : enterActiveClass);
153
+ done && done();
154
+ };
155
+ const finishLeave = (el, done) => {
156
+ el._isLeaving = false;
157
+ removeTransitionClass(el, leaveFromClass);
158
+ removeTransitionClass(el, leaveToClass);
159
+ removeTransitionClass(el, leaveActiveClass);
160
+ done && done();
161
+ };
162
+ const makeEnterHook = (isAppear) => {
163
+ return (el, done) => {
164
+ const hook = isAppear ? onAppear : onEnter;
165
+ const resolve = () => finishEnter(el, isAppear, done);
166
+ callHook(hook, [el, resolve]);
167
+ nextFrame(() => {
168
+ removeTransitionClass(el, isAppear ? appearFromClass : enterFromClass);
169
+ addTransitionClass(el, isAppear ? appearToClass : enterToClass);
170
+ if (!hasExplicitCallback(hook)) {
171
+ whenTransitionEnds(el, type, enterDuration, resolve);
172
+ }
173
+ });
174
+ };
175
+ };
176
+ return shared.extend(baseProps, {
177
+ onBeforeEnter(el) {
178
+ callHook(onBeforeEnter, [el]);
179
+ addTransitionClass(el, enterFromClass);
180
+ addTransitionClass(el, enterActiveClass);
181
+ },
182
+ onBeforeAppear(el) {
183
+ callHook(onBeforeAppear, [el]);
184
+ addTransitionClass(el, appearFromClass);
185
+ addTransitionClass(el, appearActiveClass);
186
+ },
187
+ onEnter: makeEnterHook(false),
188
+ onAppear: makeEnterHook(true),
189
+ onLeave(el, done) {
190
+ el._isLeaving = true;
191
+ const resolve = () => finishLeave(el, done);
192
+ addTransitionClass(el, leaveFromClass);
193
+ forceReflow();
194
+ addTransitionClass(el, leaveActiveClass);
195
+ nextFrame(() => {
196
+ if (!el._isLeaving) {
197
+ return;
198
+ }
199
+ removeTransitionClass(el, leaveFromClass);
200
+ addTransitionClass(el, leaveToClass);
201
+ if (!hasExplicitCallback(onLeave)) {
202
+ whenTransitionEnds(el, type, leaveDuration, resolve);
203
+ }
204
+ });
205
+ callHook(onLeave, [el, resolve]);
206
+ },
207
+ onEnterCancelled(el) {
208
+ finishEnter(el, false);
209
+ callHook(onEnterCancelled, [el]);
210
+ },
211
+ onAppearCancelled(el) {
212
+ finishEnter(el, true);
213
+ callHook(onAppearCancelled, [el]);
214
+ },
215
+ onLeaveCancelled(el) {
216
+ finishLeave(el);
217
+ callHook(onLeaveCancelled, [el]);
218
+ }
219
+ });
220
+ }
221
+ function normalizeDuration(duration) {
222
+ if (duration == null) {
223
+ return null;
224
+ } else if (shared.isObject(duration)) {
225
+ return [NumberOf(duration.enter), NumberOf(duration.leave)];
226
+ } else {
227
+ const n = NumberOf(duration);
228
+ return [n, n];
229
+ }
230
+ }
231
+ function NumberOf(val) {
232
+ const res = shared.toNumber(val);
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
+
75
341
  function patchClass(el, value, isSVG) {
76
- const transitionClasses = el._vtc;
342
+ const transitionClasses = el[vtcKey];
77
343
  if (transitionClasses) {
78
344
  value = (value ? [value, ...transitionClasses] : [...transitionClasses]).join(" ");
79
345
  }
@@ -86,6 +352,53 @@ function patchClass(el, value, isSVG) {
86
352
  }
87
353
  }
88
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
+
89
402
  function patchStyle(el, prev, next) {
90
403
  const style = el.style;
91
404
  const isCssString = shared.isString(next);
@@ -109,7 +422,7 @@ function patchStyle(el, prev, next) {
109
422
  } else if (prev) {
110
423
  el.removeAttribute("style");
111
424
  }
112
- if ("_vod" in el) {
425
+ if (vShowOldKey in el) {
113
426
  style.display = currentDisplay;
114
427
  }
115
428
  }
@@ -224,8 +537,9 @@ function addEventListener(el, event, handler, options) {
224
537
  function removeEventListener(el, event, handler, options) {
225
538
  el.removeEventListener(event, handler, options);
226
539
  }
540
+ const veiKey = Symbol("_vei");
227
541
  function patchEvent(el, rawName, prevValue, nextValue, instance = null) {
228
- const invokers = el._vei || (el._vei = {});
542
+ const invokers = el[veiKey] || (el[veiKey] = {});
229
543
  const existingInvoker = invokers[rawName];
230
544
  if (nextValue && existingInvoker) {
231
545
  existingInvoker.value = nextValue;
@@ -345,6 +659,8 @@ function shouldSetAsProp(el, key, value, isSVG) {
345
659
  return key in el;
346
660
  }
347
661
 
662
+ /*! #__NO_SIDE_EFFECTS__ */
663
+ // @__NO_SIDE_EFFECTS__
348
664
  function defineCustomElement(options, hydrate2) {
349
665
  const Comp = runtimeCore.defineComponent(options);
350
666
  class VueCustomElement extends VueElement {
@@ -355,8 +671,9 @@ function defineCustomElement(options, hydrate2) {
355
671
  VueCustomElement.def = Comp;
356
672
  return VueCustomElement;
357
673
  }
358
- const defineSSRCustomElement = (options) => {
359
- return defineCustomElement(options, hydrate);
674
+ /*! #__NO_SIDE_EFFECTS__ */
675
+ const defineSSRCustomElement = /* @__NO_SIDE_EFFECTS__ */ (options) => {
676
+ return /* @__PURE__ */ defineCustomElement(options, hydrate);
360
677
  };
361
678
  const BaseClass = typeof HTMLElement !== "undefined" ? HTMLElement : class {
362
679
  };
@@ -372,6 +689,7 @@ class VueElement extends BaseClass {
372
689
  this._connected = false;
373
690
  this._resolved = false;
374
691
  this._numberProps = null;
692
+ this._ob = null;
375
693
  if (this.shadowRoot && hydrate2) {
376
694
  hydrate2(this._createVNode(), this.shadowRoot);
377
695
  } else {
@@ -393,6 +711,10 @@ class VueElement extends BaseClass {
393
711
  }
394
712
  disconnectedCallback() {
395
713
  this._connected = false;
714
+ if (this._ob) {
715
+ this._ob.disconnect();
716
+ this._ob = null;
717
+ }
396
718
  runtimeCore.nextTick(() => {
397
719
  if (!this._connected) {
398
720
  render(null, this.shadowRoot);
@@ -408,11 +730,12 @@ class VueElement extends BaseClass {
408
730
  for (let i = 0; i < this.attributes.length; i++) {
409
731
  this._setAttr(this.attributes[i].name);
410
732
  }
411
- new MutationObserver((mutations) => {
733
+ this._ob = new MutationObserver((mutations) => {
412
734
  for (const m of mutations) {
413
735
  this._setAttr(m.attributeName);
414
736
  }
415
- }).observe(this, { attributes: true });
737
+ });
738
+ this._ob.observe(this, { attributes: true });
416
739
  const resolve = (def, isAsync = false) => {
417
740
  const { props, styles } = def;
418
741
  let numberProps;
@@ -447,385 +770,124 @@ class VueElement extends BaseClass {
447
770
  for (const key of Object.keys(this)) {
448
771
  if (key[0] !== "_" && declaredPropKeys.includes(key)) {
449
772
  this._setProp(key, this[key], true, false);
450
- }
451
- }
452
- for (const key of declaredPropKeys.map(shared.camelize)) {
453
- Object.defineProperty(this, key, {
454
- get() {
455
- return this._getProp(key);
456
- },
457
- set(val) {
458
- this._setProp(key, val);
459
- }
460
- });
461
- }
462
- }
463
- _setAttr(key) {
464
- let value = this.getAttribute(key);
465
- const camelKey = shared.camelize(key);
466
- if (this._numberProps && this._numberProps[camelKey]) {
467
- value = shared.toNumber(value);
468
- }
469
- this._setProp(camelKey, value, false);
470
- }
471
- /**
472
- * @internal
473
- */
474
- _getProp(key) {
475
- return this._props[key];
476
- }
477
- /**
478
- * @internal
479
- */
480
- _setProp(key, val, shouldReflect = true, shouldUpdate = true) {
481
- if (val !== this._props[key]) {
482
- this._props[key] = val;
483
- if (shouldUpdate && this._instance) {
484
- this._update();
485
- }
486
- if (shouldReflect) {
487
- if (val === true) {
488
- this.setAttribute(shared.hyphenate(key), "");
489
- } else if (typeof val === "string" || typeof val === "number") {
490
- this.setAttribute(shared.hyphenate(key), val + "");
491
- } else if (!val) {
492
- this.removeAttribute(shared.hyphenate(key));
493
- }
494
- }
495
- }
496
- }
497
- _update() {
498
- render(this._createVNode(), this.shadowRoot);
499
- }
500
- _createVNode() {
501
- const vnode = runtimeCore.createVNode(this._def, shared.extend({}, this._props));
502
- if (!this._instance) {
503
- vnode.ce = (instance) => {
504
- this._instance = instance;
505
- instance.isCE = true;
506
- const dispatch = (event, args) => {
507
- this.dispatchEvent(
508
- new CustomEvent(event, {
509
- detail: args
510
- })
511
- );
512
- };
513
- instance.emit = (event, ...args) => {
514
- dispatch(event, args);
515
- if (shared.hyphenate(event) !== event) {
516
- dispatch(shared.hyphenate(event), args);
517
- }
518
- };
519
- let parent = this;
520
- while (parent = parent && (parent.parentNode || parent.host)) {
521
- if (parent instanceof VueElement) {
522
- instance.parent = parent._instance;
523
- instance.provides = parent._instance.provides;
524
- break;
525
- }
526
- }
527
- };
528
- }
529
- return vnode;
530
- }
531
- _applyStyles(styles) {
532
- if (styles) {
533
- styles.forEach((css) => {
534
- const s = document.createElement("style");
535
- s.textContent = css;
536
- this.shadowRoot.appendChild(s);
537
- });
538
- }
539
- }
540
- }
541
-
542
- function useCssModule(name = "$style") {
543
- {
544
- const instance = runtimeCore.getCurrentInstance();
545
- if (!instance) {
546
- return shared.EMPTY_OBJ;
547
- }
548
- const modules = instance.type.__cssModules;
549
- if (!modules) {
550
- return shared.EMPTY_OBJ;
551
- }
552
- const mod = modules[name];
553
- if (!mod) {
554
- return shared.EMPTY_OBJ;
555
- }
556
- return mod;
557
- }
558
- }
559
-
560
- function useCssVars(getter) {
561
- return;
562
- }
563
-
564
- const TRANSITION = "transition";
565
- const ANIMATION = "animation";
566
- const Transition = (props, { slots }) => runtimeCore.h(runtimeCore.BaseTransition, resolveTransitionProps(props), slots);
567
- Transition.displayName = "Transition";
568
- const DOMTransitionPropsValidators = {
569
- name: String,
570
- type: String,
571
- css: {
572
- type: Boolean,
573
- default: true
574
- },
575
- duration: [String, Number, Object],
576
- enterFromClass: String,
577
- enterActiveClass: String,
578
- enterToClass: String,
579
- appearFromClass: String,
580
- appearActiveClass: String,
581
- appearToClass: String,
582
- leaveFromClass: String,
583
- leaveActiveClass: String,
584
- leaveToClass: String
585
- };
586
- const TransitionPropsValidators = Transition.props = /* @__PURE__ */ shared.extend(
587
- {},
588
- runtimeCore.BaseTransitionPropsValidators,
589
- DOMTransitionPropsValidators
590
- );
591
- const callHook = (hook, args = []) => {
592
- if (shared.isArray(hook)) {
593
- hook.forEach((h2) => h2(...args));
594
- } else if (hook) {
595
- hook(...args);
596
- }
597
- };
598
- const hasExplicitCallback = (hook) => {
599
- return hook ? shared.isArray(hook) ? hook.some((h2) => h2.length > 1) : hook.length > 1 : false;
600
- };
601
- function resolveTransitionProps(rawProps) {
602
- const baseProps = {};
603
- for (const key in rawProps) {
604
- if (!(key in DOMTransitionPropsValidators)) {
605
- baseProps[key] = rawProps[key];
606
- }
607
- }
608
- if (rawProps.css === false) {
609
- return baseProps;
610
- }
611
- const {
612
- name = "v",
613
- type,
614
- duration,
615
- enterFromClass = `${name}-enter-from`,
616
- enterActiveClass = `${name}-enter-active`,
617
- enterToClass = `${name}-enter-to`,
618
- appearFromClass = enterFromClass,
619
- appearActiveClass = enterActiveClass,
620
- appearToClass = enterToClass,
621
- leaveFromClass = `${name}-leave-from`,
622
- leaveActiveClass = `${name}-leave-active`,
623
- leaveToClass = `${name}-leave-to`
624
- } = rawProps;
625
- const durations = normalizeDuration(duration);
626
- const enterDuration = durations && durations[0];
627
- const leaveDuration = durations && durations[1];
628
- const {
629
- onBeforeEnter,
630
- onEnter,
631
- onEnterCancelled,
632
- onLeave,
633
- onLeaveCancelled,
634
- onBeforeAppear = onBeforeEnter,
635
- onAppear = onEnter,
636
- onAppearCancelled = onEnterCancelled
637
- } = baseProps;
638
- const finishEnter = (el, isAppear, done) => {
639
- removeTransitionClass(el, isAppear ? appearToClass : enterToClass);
640
- removeTransitionClass(el, isAppear ? appearActiveClass : enterActiveClass);
641
- done && done();
642
- };
643
- const finishLeave = (el, done) => {
644
- el._isLeaving = false;
645
- removeTransitionClass(el, leaveFromClass);
646
- removeTransitionClass(el, leaveToClass);
647
- removeTransitionClass(el, leaveActiveClass);
648
- done && done();
649
- };
650
- const makeEnterHook = (isAppear) => {
651
- return (el, done) => {
652
- const hook = isAppear ? onAppear : onEnter;
653
- const resolve = () => finishEnter(el, isAppear, done);
654
- callHook(hook, [el, resolve]);
655
- nextFrame(() => {
656
- removeTransitionClass(el, isAppear ? appearFromClass : enterFromClass);
657
- addTransitionClass(el, isAppear ? appearToClass : enterToClass);
658
- if (!hasExplicitCallback(hook)) {
659
- whenTransitionEnds(el, type, enterDuration, resolve);
660
- }
661
- });
662
- };
663
- };
664
- return shared.extend(baseProps, {
665
- onBeforeEnter(el) {
666
- callHook(onBeforeEnter, [el]);
667
- addTransitionClass(el, enterFromClass);
668
- addTransitionClass(el, enterActiveClass);
669
- },
670
- onBeforeAppear(el) {
671
- callHook(onBeforeAppear, [el]);
672
- addTransitionClass(el, appearFromClass);
673
- addTransitionClass(el, appearActiveClass);
674
- },
675
- onEnter: makeEnterHook(false),
676
- onAppear: makeEnterHook(true),
677
- onLeave(el, done) {
678
- el._isLeaving = true;
679
- const resolve = () => finishLeave(el, done);
680
- addTransitionClass(el, leaveFromClass);
681
- forceReflow();
682
- addTransitionClass(el, leaveActiveClass);
683
- nextFrame(() => {
684
- if (!el._isLeaving) {
685
- return;
686
- }
687
- removeTransitionClass(el, leaveFromClass);
688
- addTransitionClass(el, leaveToClass);
689
- if (!hasExplicitCallback(onLeave)) {
690
- whenTransitionEnds(el, type, leaveDuration, resolve);
773
+ }
774
+ }
775
+ for (const key of declaredPropKeys.map(shared.camelize)) {
776
+ Object.defineProperty(this, key, {
777
+ get() {
778
+ return this._getProp(key);
779
+ },
780
+ set(val) {
781
+ this._setProp(key, val);
691
782
  }
692
783
  });
693
- callHook(onLeave, [el, resolve]);
694
- },
695
- onEnterCancelled(el) {
696
- finishEnter(el, false);
697
- callHook(onEnterCancelled, [el]);
698
- },
699
- onAppearCancelled(el) {
700
- finishEnter(el, true);
701
- callHook(onAppearCancelled, [el]);
702
- },
703
- onLeaveCancelled(el) {
704
- finishLeave(el);
705
- callHook(onLeaveCancelled, [el]);
706
784
  }
707
- });
708
- }
709
- function normalizeDuration(duration) {
710
- if (duration == null) {
711
- return null;
712
- } else if (shared.isObject(duration)) {
713
- return [NumberOf(duration.enter), NumberOf(duration.leave)];
714
- } else {
715
- const n = NumberOf(duration);
716
- return [n, n];
717
785
  }
718
- }
719
- function NumberOf(val) {
720
- const res = shared.toNumber(val);
721
- return res;
722
- }
723
- function addTransitionClass(el, cls) {
724
- cls.split(/\s+/).forEach((c) => c && el.classList.add(c));
725
- (el._vtc || (el._vtc = /* @__PURE__ */ new Set())).add(cls);
726
- }
727
- function removeTransitionClass(el, cls) {
728
- cls.split(/\s+/).forEach((c) => c && el.classList.remove(c));
729
- const { _vtc } = el;
730
- if (_vtc) {
731
- _vtc.delete(cls);
732
- if (!_vtc.size) {
733
- el._vtc = void 0;
786
+ _setAttr(key) {
787
+ let value = this.getAttribute(key);
788
+ const camelKey = shared.camelize(key);
789
+ if (this._numberProps && this._numberProps[camelKey]) {
790
+ value = shared.toNumber(value);
734
791
  }
792
+ this._setProp(camelKey, value, false);
735
793
  }
736
- }
737
- function nextFrame(cb) {
738
- requestAnimationFrame(() => {
739
- requestAnimationFrame(cb);
740
- });
741
- }
742
- let endId = 0;
743
- function whenTransitionEnds(el, expectedType, explicitTimeout, resolve) {
744
- const id = el._endId = ++endId;
745
- const resolveIfNotStale = () => {
746
- if (id === el._endId) {
747
- resolve();
794
+ /**
795
+ * @internal
796
+ */
797
+ _getProp(key) {
798
+ return this._props[key];
799
+ }
800
+ /**
801
+ * @internal
802
+ */
803
+ _setProp(key, val, shouldReflect = true, shouldUpdate = true) {
804
+ if (val !== this._props[key]) {
805
+ this._props[key] = val;
806
+ if (shouldUpdate && this._instance) {
807
+ this._update();
808
+ }
809
+ if (shouldReflect) {
810
+ if (val === true) {
811
+ this.setAttribute(shared.hyphenate(key), "");
812
+ } else if (typeof val === "string" || typeof val === "number") {
813
+ this.setAttribute(shared.hyphenate(key), val + "");
814
+ } else if (!val) {
815
+ this.removeAttribute(shared.hyphenate(key));
816
+ }
817
+ }
748
818
  }
749
- };
750
- if (explicitTimeout) {
751
- return setTimeout(resolveIfNotStale, explicitTimeout);
752
819
  }
753
- const { type, timeout, propCount } = getTransitionInfo(el, expectedType);
754
- if (!type) {
755
- return resolve();
820
+ _update() {
821
+ render(this._createVNode(), this.shadowRoot);
756
822
  }
757
- const endEvent = type + "end";
758
- let ended = 0;
759
- const end = () => {
760
- el.removeEventListener(endEvent, onEnd);
761
- resolveIfNotStale();
762
- };
763
- const onEnd = (e) => {
764
- if (e.target === el && ++ended >= propCount) {
765
- end();
823
+ _createVNode() {
824
+ const vnode = runtimeCore.createVNode(this._def, shared.extend({}, this._props));
825
+ if (!this._instance) {
826
+ vnode.ce = (instance) => {
827
+ this._instance = instance;
828
+ instance.isCE = true;
829
+ const dispatch = (event, args) => {
830
+ this.dispatchEvent(
831
+ new CustomEvent(event, {
832
+ detail: args
833
+ })
834
+ );
835
+ };
836
+ instance.emit = (event, ...args) => {
837
+ dispatch(event, args);
838
+ if (shared.hyphenate(event) !== event) {
839
+ dispatch(shared.hyphenate(event), args);
840
+ }
841
+ };
842
+ let parent = this;
843
+ while (parent = parent && (parent.parentNode || parent.host)) {
844
+ if (parent instanceof VueElement) {
845
+ instance.parent = parent._instance;
846
+ instance.provides = parent._instance.provides;
847
+ break;
848
+ }
849
+ }
850
+ };
766
851
  }
767
- };
768
- setTimeout(() => {
769
- if (ended < propCount) {
770
- end();
852
+ return vnode;
853
+ }
854
+ _applyStyles(styles) {
855
+ if (styles) {
856
+ styles.forEach((css) => {
857
+ const s = document.createElement("style");
858
+ s.textContent = css;
859
+ this.shadowRoot.appendChild(s);
860
+ });
771
861
  }
772
- }, timeout + 1);
773
- el.addEventListener(endEvent, onEnd);
862
+ }
774
863
  }
775
- function getTransitionInfo(el, expectedType) {
776
- const styles = window.getComputedStyle(el);
777
- const getStyleProperties = (key) => (styles[key] || "").split(", ");
778
- const transitionDelays = getStyleProperties(`${TRANSITION}Delay`);
779
- const transitionDurations = getStyleProperties(`${TRANSITION}Duration`);
780
- const transitionTimeout = getTimeout(transitionDelays, transitionDurations);
781
- const animationDelays = getStyleProperties(`${ANIMATION}Delay`);
782
- const animationDurations = getStyleProperties(`${ANIMATION}Duration`);
783
- const animationTimeout = getTimeout(animationDelays, animationDurations);
784
- let type = null;
785
- let timeout = 0;
786
- let propCount = 0;
787
- if (expectedType === TRANSITION) {
788
- if (transitionTimeout > 0) {
789
- type = TRANSITION;
790
- timeout = transitionTimeout;
791
- propCount = transitionDurations.length;
864
+
865
+ function useCssModule(name = "$style") {
866
+ {
867
+ const instance = runtimeCore.getCurrentInstance();
868
+ if (!instance) {
869
+ return shared.EMPTY_OBJ;
792
870
  }
793
- } else if (expectedType === ANIMATION) {
794
- if (animationTimeout > 0) {
795
- type = ANIMATION;
796
- timeout = animationTimeout;
797
- propCount = animationDurations.length;
871
+ const modules = instance.type.__cssModules;
872
+ if (!modules) {
873
+ return shared.EMPTY_OBJ;
798
874
  }
799
- } else {
800
- timeout = Math.max(transitionTimeout, animationTimeout);
801
- type = timeout > 0 ? transitionTimeout > animationTimeout ? TRANSITION : ANIMATION : null;
802
- propCount = type ? type === TRANSITION ? transitionDurations.length : animationDurations.length : 0;
803
- }
804
- const hasTransform = type === TRANSITION && /\b(transform|all)(,|$)/.test(
805
- getStyleProperties(`${TRANSITION}Property`).toString()
806
- );
807
- return {
808
- type,
809
- timeout,
810
- propCount,
811
- hasTransform
812
- };
813
- }
814
- function getTimeout(delays, durations) {
815
- while (delays.length < durations.length) {
816
- delays = delays.concat(delays);
875
+ const mod = modules[name];
876
+ if (!mod) {
877
+ return shared.EMPTY_OBJ;
878
+ }
879
+ return mod;
817
880
  }
818
- return Math.max(...durations.map((d, i) => toMs(d) + toMs(delays[i])));
819
- }
820
- function toMs(s) {
821
- return Number(s.slice(0, -1).replace(",", ".")) * 1e3;
822
881
  }
823
- function forceReflow() {
824
- return document.body.offsetHeight;
882
+
883
+ function useCssVars(getter) {
884
+ return;
825
885
  }
826
886
 
827
887
  const positionMap = /* @__PURE__ */ new WeakMap();
828
888
  const newPositionMap = /* @__PURE__ */ new WeakMap();
889
+ const moveCbKey = Symbol("_moveCb");
890
+ const enterCbKey = Symbol("_enterCb");
829
891
  const TransitionGroupImpl = {
830
892
  name: "TransitionGroup",
831
893
  props: /* @__PURE__ */ shared.extend({}, TransitionPropsValidators, {
@@ -858,13 +920,13 @@ const TransitionGroupImpl = {
858
920
  const style = el.style;
859
921
  addTransitionClass(el, moveClass);
860
922
  style.transform = style.webkitTransform = style.transitionDuration = "";
861
- const cb = el._moveCb = (e) => {
923
+ const cb = el[moveCbKey] = (e) => {
862
924
  if (e && e.target !== el) {
863
925
  return;
864
926
  }
865
927
  if (!e || /transform$/.test(e.propertyName)) {
866
928
  el.removeEventListener("transitionend", cb);
867
- el._moveCb = null;
929
+ el[moveCbKey] = null;
868
930
  removeTransitionClass(el, moveClass);
869
931
  }
870
932
  };
@@ -905,11 +967,11 @@ const removeMode = (props) => delete props.mode;
905
967
  const TransitionGroup = TransitionGroupImpl;
906
968
  function callPendingCbs(c) {
907
969
  const el = c.el;
908
- if (el._moveCb) {
909
- el._moveCb();
970
+ if (el[moveCbKey]) {
971
+ el[moveCbKey]();
910
972
  }
911
- if (el._enterCb) {
912
- el._enterCb();
973
+ if (el[enterCbKey]) {
974
+ el[enterCbKey]();
913
975
  }
914
976
  }
915
977
  function recordPosition(c) {
@@ -929,8 +991,9 @@ function applyTranslation(c) {
929
991
  }
930
992
  function hasCSSTransform(el, root, moveClass) {
931
993
  const clone = el.cloneNode();
932
- if (el._vtc) {
933
- el._vtc.forEach((cls) => {
994
+ const _vtc = el[vtcKey];
995
+ if (_vtc) {
996
+ _vtc.forEach((cls) => {
934
997
  cls.split(/\s+/).forEach((c) => c && clone.classList.remove(c));
935
998
  });
936
999
  }
@@ -957,9 +1020,10 @@ function onCompositionEnd(e) {
957
1020
  target.dispatchEvent(new Event("input"));
958
1021
  }
959
1022
  }
1023
+ const assignKey = Symbol("_assign");
960
1024
  const vModelText = {
961
1025
  created(el, { modifiers: { lazy, trim, number } }, vnode) {
962
- el._assign = getModelAssigner(vnode);
1026
+ el[assignKey] = getModelAssigner(vnode);
963
1027
  const castToNumber = number || vnode.props && vnode.props.type === "number";
964
1028
  addEventListener(el, lazy ? "change" : "input", (e) => {
965
1029
  if (e.target.composing)
@@ -971,7 +1035,7 @@ const vModelText = {
971
1035
  if (castToNumber) {
972
1036
  domValue = shared.looseToNumber(domValue);
973
1037
  }
974
- el._assign(domValue);
1038
+ el[assignKey](domValue);
975
1039
  });
976
1040
  if (trim) {
977
1041
  addEventListener(el, "change", () => {
@@ -989,7 +1053,7 @@ const vModelText = {
989
1053
  el.value = value == null ? "" : value;
990
1054
  },
991
1055
  beforeUpdate(el, { value, modifiers: { lazy, trim, number } }, vnode) {
992
- el._assign = getModelAssigner(vnode);
1056
+ el[assignKey] = getModelAssigner(vnode);
993
1057
  if (el.composing)
994
1058
  return;
995
1059
  if (document.activeElement === el && el.type !== "range") {
@@ -1013,12 +1077,12 @@ const vModelCheckbox = {
1013
1077
  // #4096 array checkboxes need to be deep traversed
1014
1078
  deep: true,
1015
1079
  created(el, _, vnode) {
1016
- el._assign = getModelAssigner(vnode);
1080
+ el[assignKey] = getModelAssigner(vnode);
1017
1081
  addEventListener(el, "change", () => {
1018
1082
  const modelValue = el._modelValue;
1019
1083
  const elementValue = getValue(el);
1020
1084
  const checked = el.checked;
1021
- const assign = el._assign;
1085
+ const assign = el[assignKey];
1022
1086
  if (shared.isArray(modelValue)) {
1023
1087
  const index = shared.looseIndexOf(modelValue, elementValue);
1024
1088
  const found = index !== -1;
@@ -1045,7 +1109,7 @@ const vModelCheckbox = {
1045
1109
  // set initial checked on mount to wait for true-value/false-value
1046
1110
  mounted: setChecked,
1047
1111
  beforeUpdate(el, binding, vnode) {
1048
- el._assign = getModelAssigner(vnode);
1112
+ el[assignKey] = getModelAssigner(vnode);
1049
1113
  setChecked(el, binding, vnode);
1050
1114
  }
1051
1115
  };
@@ -1062,13 +1126,13 @@ function setChecked(el, { value, oldValue }, vnode) {
1062
1126
  const vModelRadio = {
1063
1127
  created(el, { value }, vnode) {
1064
1128
  el.checked = shared.looseEqual(value, vnode.props.value);
1065
- el._assign = getModelAssigner(vnode);
1129
+ el[assignKey] = getModelAssigner(vnode);
1066
1130
  addEventListener(el, "change", () => {
1067
- el._assign(getValue(el));
1131
+ el[assignKey](getValue(el));
1068
1132
  });
1069
1133
  },
1070
1134
  beforeUpdate(el, { value, oldValue }, vnode) {
1071
- el._assign = getModelAssigner(vnode);
1135
+ el[assignKey] = getModelAssigner(vnode);
1072
1136
  if (value !== oldValue) {
1073
1137
  el.checked = shared.looseEqual(value, vnode.props.value);
1074
1138
  }
@@ -1083,11 +1147,11 @@ const vModelSelect = {
1083
1147
  const selectedVal = Array.prototype.filter.call(el.options, (o) => o.selected).map(
1084
1148
  (o) => number ? shared.looseToNumber(getValue(o)) : getValue(o)
1085
1149
  );
1086
- el._assign(
1150
+ el[assignKey](
1087
1151
  el.multiple ? isSetModel ? new Set(selectedVal) : selectedVal : selectedVal[0]
1088
1152
  );
1089
1153
  });
1090
- el._assign = getModelAssigner(vnode);
1154
+ el[assignKey] = getModelAssigner(vnode);
1091
1155
  },
1092
1156
  // set value in mounted & updated because <select> relies on its children
1093
1157
  // <option>s.
@@ -1095,7 +1159,7 @@ const vModelSelect = {
1095
1159
  setSelected(el, value);
1096
1160
  },
1097
1161
  beforeUpdate(el, _binding, vnode) {
1098
- el._assign = getModelAssigner(vnode);
1162
+ el[assignKey] = getModelAssigner(vnode);
1099
1163
  },
1100
1164
  updated(el, { value }) {
1101
1165
  setSelected(el, value);
@@ -1253,52 +1317,6 @@ const withKeys = (fn, modifiers) => {
1253
1317
  };
1254
1318
  };
1255
1319
 
1256
- const vShow = {
1257
- beforeMount(el, { value }, { transition }) {
1258
- el._vod = el.style.display === "none" ? "" : el.style.display;
1259
- if (transition && value) {
1260
- transition.beforeEnter(el);
1261
- } else {
1262
- setDisplay(el, value);
1263
- }
1264
- },
1265
- mounted(el, { value }, { transition }) {
1266
- if (transition && value) {
1267
- transition.enter(el);
1268
- }
1269
- },
1270
- updated(el, { value, oldValue }, { transition }) {
1271
- if (!value === !oldValue)
1272
- return;
1273
- if (transition) {
1274
- if (value) {
1275
- transition.beforeEnter(el);
1276
- setDisplay(el, true);
1277
- transition.enter(el);
1278
- } else {
1279
- transition.leave(el, () => {
1280
- setDisplay(el, false);
1281
- });
1282
- }
1283
- } else {
1284
- setDisplay(el, value);
1285
- }
1286
- },
1287
- beforeUnmount(el, { value }) {
1288
- setDisplay(el, value);
1289
- }
1290
- };
1291
- function setDisplay(el, value) {
1292
- el.style.display = value ? el._vod : "none";
1293
- }
1294
- function initVShowForSSR() {
1295
- vShow.getSSRProps = ({ value }) => {
1296
- if (!value) {
1297
- return { style: { display: "none" } };
1298
- }
1299
- };
1300
- }
1301
-
1302
1320
  const rendererOptions = /* @__PURE__ */ shared.extend({ patchProp }, nodeOps);
1303
1321
  let renderer;
1304
1322
  let enabledHydration = false;
@@ -1385,5 +1403,5 @@ exports.vShow = vShow;
1385
1403
  exports.withKeys = withKeys;
1386
1404
  exports.withModifiers = withModifiers;
1387
1405
  Object.keys(runtimeCore).forEach(function (k) {
1388
- if (k !== 'default' && !exports.hasOwnProperty(k)) exports[k] = runtimeCore[k];
1406
+ if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) exports[k] = runtimeCore[k];
1389
1407
  });