@vue/runtime-dom 3.6.0-alpha.7 → 3.6.0-beta.10

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,22 +1,18 @@
1
1
  /**
2
- * @vue/runtime-dom v3.6.0-alpha.7
3
- * (c) 2018-present Yuxi (Evan) You and Vue contributors
4
- * @license MIT
5
- **/
6
- import { warn, BaseTransitionPropsValidators, assertNumber, h, BaseTransition, getCurrentInstance, onBeforeUpdate, queuePostFlushCb, onMounted, watch, onUnmounted, Fragment, Static, camelize, callWithAsyncErrorHandling, defineComponent, useInstanceOption, createVNode, nextTick, unref, useTransitionState, onUpdated, toRaw, getTransitionRawChildren, setTransitionHooks, resolveTransitionHooks, Text, createRenderer, createHydrationRenderer, isRuntimeOnly } from '@vue/runtime-core';
7
- export * from '@vue/runtime-core';
8
- import { extend, isObject, isArray, toNumber, NOOP, normalizeCssVarValue, isString, hyphenate, capitalize, isSpecialBooleanAttr, includeBooleanAttr, isSymbol, canSetValueDirectly, isFunction, isOn, isModelListener, camelize as camelize$1, isNativeOn, shouldSetAsAttr, isPlainObject, hasOwn, EMPTY_OBJ, looseEqual, looseToNumber, looseIndexOf, isSet, invokeArrayFns, isHTMLTag, isSVGTag, isMathMLTag } from '@vue/shared';
9
-
2
+ * @vue/runtime-dom v3.6.0-beta.10
3
+ * (c) 2018-present Yuxi (Evan) You and Vue contributors
4
+ * @license MIT
5
+ **/
6
+ import { BaseTransition, BaseTransitionPropsValidators, Fragment, Static, Text, assertNumber, callWithAsyncErrorHandling, camelize, createHydrationRenderer, createRenderer, createVNode, defineComponent, getCurrentInstance, getTransitionRawChildren, h, isRuntimeOnly, nextTick, onBeforeUpdate, onMounted, onUnmounted, onUpdated, queuePostFlushCb, resolveTransitionHooks, setIsHydratingEnabled, setTransitionHooks, toRaw, unref, useInstanceOption, useTransitionState, warn, watch } from "@vue/runtime-core";
7
+ import { EMPTY_OBJ, NOOP, camelize as camelize$1, canSetValueDirectly, capitalize, extend, hasOwn, hyphenate, includeBooleanAttr, invokeArrayFns, isArray, isFunction, isHTMLTag, isMathMLTag, isModelListener, isNativeOn, isObject, isOn, isPlainObject, isSVGTag, isSet, isSpecialBooleanAttr, isString, isSymbol, looseEqual, looseIndexOf, looseToNumber, normalizeCssVarValue, shouldSetAsAttr, toNumber } from "@vue/shared";
8
+ export * from "@vue/runtime-core";
9
+ //#region packages/runtime-dom/src/nodeOps.ts
10
10
  let policy = void 0;
11
11
  const tt = typeof window !== "undefined" && window.trustedTypes;
12
- if (tt) {
13
- try {
14
- policy = /* @__PURE__ */ tt.createPolicy("vue", {
15
- createHTML: (val) => val
16
- });
17
- } catch (e) {
18
- !!(process.env.NODE_ENV !== "production") && warn(`Error creating trusted types policy: ${e}`);
19
- }
12
+ if (tt) try {
13
+ policy = /* @__PURE__ */ tt.createPolicy("vue", { createHTML: (val) => val });
14
+ } catch (e) {
15
+ process.env.NODE_ENV !== "production" && warn(`Error creating trusted types policy: ${e}`);
20
16
  }
21
17
  const unsafeToTrustedHTML = policy ? (val) => policy.createHTML(val) : (val) => val;
22
18
  const svgNS = "http://www.w3.org/2000/svg";
@@ -24,1977 +20,1610 @@ const mathmlNS = "http://www.w3.org/1998/Math/MathML";
24
20
  const doc = typeof document !== "undefined" ? document : null;
25
21
  const templateContainer = doc && /* @__PURE__ */ doc.createElement("template");
26
22
  const nodeOps = {
27
- insert: (child, parent, anchor) => {
28
- parent.insertBefore(child, anchor || null);
29
- },
30
- remove: (child) => {
31
- const parent = child.parentNode;
32
- if (parent) {
33
- parent.removeChild(child);
34
- }
35
- },
36
- createElement: (tag, namespace, is, props) => {
37
- const el = namespace === "svg" ? doc.createElementNS(svgNS, tag) : namespace === "mathml" ? doc.createElementNS(mathmlNS, tag) : is ? doc.createElement(tag, { is }) : doc.createElement(tag);
38
- if (tag === "select" && props && props.multiple != null) {
39
- el.setAttribute("multiple", props.multiple);
40
- }
41
- return el;
42
- },
43
- createText: (text) => doc.createTextNode(text),
44
- createComment: (text) => doc.createComment(text),
45
- setText: (node, text) => {
46
- node.nodeValue = text;
47
- },
48
- setElementText: (el, text) => {
49
- el.textContent = text;
50
- },
51
- parentNode: (node) => node.parentNode,
52
- nextSibling: (node) => node.nextSibling,
53
- querySelector: (selector) => doc.querySelector(selector),
54
- setScopeId(el, id) {
55
- el.setAttribute(id, "");
56
- },
57
- // __UNSAFE__
58
- // Reason: innerHTML.
59
- // Static content here can only come from compiled templates.
60
- // As long as the user only uses trusted templates, this is safe.
61
- insertStaticContent(content, parent, anchor, namespace, start, end) {
62
- const before = anchor ? anchor.previousSibling : parent.lastChild;
63
- if (start && (start === end || start.nextSibling)) {
64
- while (true) {
65
- parent.insertBefore(start.cloneNode(true), anchor);
66
- if (start === end || !(start = start.nextSibling)) break;
67
- }
68
- } else {
69
- templateContainer.innerHTML = unsafeToTrustedHTML(
70
- namespace === "svg" ? `<svg>${content}</svg>` : namespace === "mathml" ? `<math>${content}</math>` : content
71
- );
72
- const template = templateContainer.content;
73
- if (namespace === "svg" || namespace === "mathml") {
74
- const wrapper = template.firstChild;
75
- while (wrapper.firstChild) {
76
- template.appendChild(wrapper.firstChild);
77
- }
78
- template.removeChild(wrapper);
79
- }
80
- parent.insertBefore(template, anchor);
81
- }
82
- return [
83
- // first
84
- before ? before.nextSibling : parent.firstChild,
85
- // last
86
- anchor ? anchor.previousSibling : parent.lastChild
87
- ];
88
- }
23
+ insert: (child, parent, anchor) => {
24
+ parent.insertBefore(child, anchor || null);
25
+ },
26
+ remove: (child) => {
27
+ const parent = child.parentNode;
28
+ if (parent) parent.removeChild(child);
29
+ },
30
+ createElement: (tag, namespace, is, props) => {
31
+ const el = namespace === "svg" ? doc.createElementNS(svgNS, tag) : namespace === "mathml" ? doc.createElementNS(mathmlNS, tag) : is ? doc.createElement(tag, { is }) : doc.createElement(tag);
32
+ if (tag === "select" && props && props.multiple != null) el.setAttribute("multiple", props.multiple);
33
+ return el;
34
+ },
35
+ createText: (text) => doc.createTextNode(text),
36
+ createComment: (text) => doc.createComment(text),
37
+ setText: (node, text) => {
38
+ node.nodeValue = text;
39
+ },
40
+ setElementText: (el, text) => {
41
+ el.textContent = text;
42
+ },
43
+ parentNode: (node) => node.parentNode,
44
+ nextSibling: (node) => node.nextSibling,
45
+ querySelector: (selector) => doc.querySelector(selector),
46
+ setScopeId(el, id) {
47
+ el.setAttribute(id, "");
48
+ },
49
+ insertStaticContent(content, parent, anchor, namespace, start, end) {
50
+ const before = anchor ? anchor.previousSibling : parent.lastChild;
51
+ if (start && (start === end || start.nextSibling)) while (true) {
52
+ parent.insertBefore(start.cloneNode(true), anchor);
53
+ if (start === end || !(start = start.nextSibling)) break;
54
+ }
55
+ else {
56
+ templateContainer.innerHTML = unsafeToTrustedHTML(namespace === "svg" ? `<svg>${content}</svg>` : namespace === "mathml" ? `<math>${content}</math>` : content);
57
+ const template = templateContainer.content;
58
+ if (namespace === "svg" || namespace === "mathml") {
59
+ const wrapper = template.firstChild;
60
+ while (wrapper.firstChild) template.appendChild(wrapper.firstChild);
61
+ template.removeChild(wrapper);
62
+ }
63
+ parent.insertBefore(template, anchor);
64
+ }
65
+ return [before ? before.nextSibling : parent.firstChild, anchor ? anchor.previousSibling : parent.lastChild];
66
+ }
89
67
  };
90
-
68
+ //#endregion
69
+ //#region packages/runtime-dom/src/components/Transition.ts
91
70
  const TRANSITION = "transition";
92
71
  const ANIMATION = "animation";
93
72
  const vtcKey = Symbol("_vtc");
94
73
  const DOMTransitionPropsValidators = {
95
- name: String,
96
- type: String,
97
- css: {
98
- type: Boolean,
99
- default: true
100
- },
101
- duration: [String, Number, Object],
102
- enterFromClass: String,
103
- enterActiveClass: String,
104
- enterToClass: String,
105
- appearFromClass: String,
106
- appearActiveClass: String,
107
- appearToClass: String,
108
- leaveFromClass: String,
109
- leaveActiveClass: String,
110
- leaveToClass: String
74
+ name: String,
75
+ type: String,
76
+ css: {
77
+ type: Boolean,
78
+ default: true
79
+ },
80
+ duration: [
81
+ String,
82
+ Number,
83
+ Object
84
+ ],
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
111
94
  };
112
- const TransitionPropsValidators = /* @__PURE__ */ extend(
113
- {},
114
- BaseTransitionPropsValidators,
115
- DOMTransitionPropsValidators
116
- );
95
+ const TransitionPropsValidators = /* @__PURE__ */ extend({}, BaseTransitionPropsValidators, DOMTransitionPropsValidators);
96
+ /**
97
+ * Wrap logic that attaches extra properties to Transition in a function
98
+ * so that it can be annotated as pure
99
+ */
117
100
  const decorate$1 = (t) => {
118
- t.displayName = "Transition";
119
- t.props = TransitionPropsValidators;
120
- return t;
101
+ t.displayName = "Transition";
102
+ t.props = TransitionPropsValidators;
103
+ return t;
121
104
  };
122
- const Transition = /* @__PURE__ */ decorate$1(
123
- (props, { slots }) => h(BaseTransition, resolveTransitionProps(props), slots)
124
- );
105
+ /**
106
+ * DOM Transition is a higher-order-component based on the platform-agnostic
107
+ * base Transition component, with DOM-specific logic.
108
+ */
109
+ const Transition = /* @__PURE__ */ decorate$1((props, { slots }) => h(BaseTransition, resolveTransitionProps(props), slots));
110
+ /**
111
+ * #3227 Incoming hooks may be merged into arrays when wrapping Transition
112
+ * with custom HOCs.
113
+ */
125
114
  const callHook = (hook, args = []) => {
126
- if (isArray(hook)) {
127
- hook.forEach((h2) => h2(...args));
128
- } else if (hook) {
129
- hook(...args);
130
- }
115
+ if (isArray(hook)) hook.forEach((h) => h(...args));
116
+ else if (hook) hook(...args);
131
117
  };
118
+ /**
119
+ * Check if a hook expects a callback (2nd arg), which means the user
120
+ * intends to explicitly control the end of the transition.
121
+ */
132
122
  const hasExplicitCallback = (hook) => {
133
- return hook ? isArray(hook) ? hook.some((h2) => h2.length > 1) : hook.length > 1 : false;
123
+ return hook ? isArray(hook) ? hook.some((h) => h.length > 1) : hook.length > 1 : false;
134
124
  };
135
125
  function resolveTransitionProps(rawProps) {
136
- const baseProps = {};
137
- for (const key in rawProps) {
138
- if (!(key in DOMTransitionPropsValidators)) {
139
- baseProps[key] = rawProps[key];
140
- }
141
- }
142
- if (rawProps.css === false) {
143
- return baseProps;
144
- }
145
- const {
146
- name = "v",
147
- type,
148
- duration,
149
- enterFromClass = `${name}-enter-from`,
150
- enterActiveClass = `${name}-enter-active`,
151
- enterToClass = `${name}-enter-to`,
152
- appearFromClass = enterFromClass,
153
- appearActiveClass = enterActiveClass,
154
- appearToClass = enterToClass,
155
- leaveFromClass = `${name}-leave-from`,
156
- leaveActiveClass = `${name}-leave-active`,
157
- leaveToClass = `${name}-leave-to`
158
- } = rawProps;
159
- const durations = normalizeDuration(duration);
160
- const enterDuration = durations && durations[0];
161
- const leaveDuration = durations && durations[1];
162
- const {
163
- onBeforeEnter,
164
- onEnter,
165
- onEnterCancelled,
166
- onLeave,
167
- onLeaveCancelled,
168
- onBeforeAppear = onBeforeEnter,
169
- onAppear = onEnter,
170
- onAppearCancelled = onEnterCancelled
171
- } = baseProps;
172
- const finishEnter = (el, isAppear, done, isCancelled) => {
173
- el._enterCancelled = isCancelled;
174
- removeTransitionClass(el, isAppear ? appearToClass : enterToClass);
175
- removeTransitionClass(el, isAppear ? appearActiveClass : enterActiveClass);
176
- done && done();
177
- };
178
- const finishLeave = (el, done) => {
179
- el._isLeaving = false;
180
- removeTransitionClass(el, leaveFromClass);
181
- removeTransitionClass(el, leaveToClass);
182
- removeTransitionClass(el, leaveActiveClass);
183
- done && done();
184
- };
185
- const makeEnterHook = (isAppear) => {
186
- return (el, done) => {
187
- const hook = isAppear ? onAppear : onEnter;
188
- const resolve = () => finishEnter(el, isAppear, done);
189
- callHook(hook, [el, resolve]);
190
- nextFrame(() => {
191
- removeTransitionClass(el, isAppear ? appearFromClass : enterFromClass);
192
- addTransitionClass(el, isAppear ? appearToClass : enterToClass);
193
- if (!hasExplicitCallback(hook)) {
194
- whenTransitionEnds(el, type, enterDuration, resolve);
195
- }
196
- });
197
- };
198
- };
199
- return extend(baseProps, {
200
- onBeforeEnter(el) {
201
- callHook(onBeforeEnter, [el]);
202
- addTransitionClass(el, enterFromClass);
203
- addTransitionClass(el, enterActiveClass);
204
- },
205
- onBeforeAppear(el) {
206
- callHook(onBeforeAppear, [el]);
207
- addTransitionClass(el, appearFromClass);
208
- addTransitionClass(el, appearActiveClass);
209
- },
210
- onEnter: makeEnterHook(false),
211
- onAppear: makeEnterHook(true),
212
- onLeave(el, done) {
213
- el._isLeaving = true;
214
- const resolve = () => finishLeave(el, done);
215
- addTransitionClass(el, leaveFromClass);
216
- if (!el._enterCancelled) {
217
- forceReflow(el);
218
- addTransitionClass(el, leaveActiveClass);
219
- } else {
220
- addTransitionClass(el, leaveActiveClass);
221
- forceReflow(el);
222
- }
223
- nextFrame(() => {
224
- if (!el._isLeaving) {
225
- return;
226
- }
227
- removeTransitionClass(el, leaveFromClass);
228
- addTransitionClass(el, leaveToClass);
229
- if (!hasExplicitCallback(onLeave)) {
230
- whenTransitionEnds(el, type, leaveDuration, resolve);
231
- }
232
- });
233
- callHook(onLeave, [el, resolve]);
234
- },
235
- onEnterCancelled(el) {
236
- finishEnter(el, false, void 0, true);
237
- callHook(onEnterCancelled, [el]);
238
- },
239
- onAppearCancelled(el) {
240
- finishEnter(el, true, void 0, true);
241
- callHook(onAppearCancelled, [el]);
242
- },
243
- onLeaveCancelled(el) {
244
- finishLeave(el);
245
- callHook(onLeaveCancelled, [el]);
246
- }
247
- });
126
+ const baseProps = {};
127
+ for (const key in rawProps) if (!(key in DOMTransitionPropsValidators)) baseProps[key] = rawProps[key];
128
+ if (rawProps.css === false) return baseProps;
129
+ const { name = "v", type, duration, enterFromClass = `${name}-enter-from`, enterActiveClass = `${name}-enter-active`, enterToClass = `${name}-enter-to`, appearFromClass = enterFromClass, appearActiveClass = enterActiveClass, appearToClass = enterToClass, leaveFromClass = `${name}-leave-from`, leaveActiveClass = `${name}-leave-active`, leaveToClass = `${name}-leave-to` } = rawProps;
130
+ const durations = normalizeDuration(duration);
131
+ const enterDuration = durations && durations[0];
132
+ const leaveDuration = durations && durations[1];
133
+ const { onBeforeEnter, onEnter, onEnterCancelled, onLeave, onLeaveCancelled, onBeforeAppear = onBeforeEnter, onAppear = onEnter, onAppearCancelled = onEnterCancelled } = baseProps;
134
+ const finishEnter = (el, isAppear, done, isCancelled) => {
135
+ el._enterCancelled = isCancelled;
136
+ removeTransitionClass(el, isAppear ? appearToClass : enterToClass);
137
+ removeTransitionClass(el, isAppear ? appearActiveClass : enterActiveClass);
138
+ done && done();
139
+ };
140
+ const finishLeave = (el, done) => {
141
+ el._isLeaving = false;
142
+ removeTransitionClass(el, leaveFromClass);
143
+ removeTransitionClass(el, leaveToClass);
144
+ removeTransitionClass(el, leaveActiveClass);
145
+ done && done();
146
+ };
147
+ const makeEnterHook = (isAppear) => {
148
+ return (el, done) => {
149
+ const hook = isAppear ? onAppear : onEnter;
150
+ const resolve = () => finishEnter(el, isAppear, done);
151
+ callHook(hook, [el, resolve]);
152
+ nextFrame(() => {
153
+ removeTransitionClass(el, isAppear ? appearFromClass : enterFromClass);
154
+ addTransitionClass(el, isAppear ? appearToClass : enterToClass);
155
+ if (!hasExplicitCallback(hook)) whenTransitionEnds(el, type, enterDuration, resolve);
156
+ });
157
+ };
158
+ };
159
+ return extend(baseProps, {
160
+ onBeforeEnter(el) {
161
+ callHook(onBeforeEnter, [el]);
162
+ addTransitionClass(el, enterFromClass);
163
+ addTransitionClass(el, enterActiveClass);
164
+ },
165
+ onBeforeAppear(el) {
166
+ callHook(onBeforeAppear, [el]);
167
+ addTransitionClass(el, appearFromClass);
168
+ addTransitionClass(el, appearActiveClass);
169
+ },
170
+ onEnter: makeEnterHook(false),
171
+ onAppear: makeEnterHook(true),
172
+ onLeave(el, done) {
173
+ el._isLeaving = true;
174
+ const resolve = () => finishLeave(el, done);
175
+ addTransitionClass(el, leaveFromClass);
176
+ if (!el._enterCancelled) {
177
+ forceReflow(el);
178
+ addTransitionClass(el, leaveActiveClass);
179
+ } else {
180
+ addTransitionClass(el, leaveActiveClass);
181
+ forceReflow(el);
182
+ }
183
+ nextFrame(() => {
184
+ if (!el._isLeaving) return;
185
+ removeTransitionClass(el, leaveFromClass);
186
+ addTransitionClass(el, leaveToClass);
187
+ if (!hasExplicitCallback(onLeave)) whenTransitionEnds(el, type, leaveDuration, resolve);
188
+ });
189
+ callHook(onLeave, [el, resolve]);
190
+ },
191
+ onEnterCancelled(el) {
192
+ finishEnter(el, false, void 0, true);
193
+ callHook(onEnterCancelled, [el]);
194
+ },
195
+ onAppearCancelled(el) {
196
+ finishEnter(el, true, void 0, true);
197
+ callHook(onAppearCancelled, [el]);
198
+ },
199
+ onLeaveCancelled(el) {
200
+ finishLeave(el);
201
+ callHook(onLeaveCancelled, [el]);
202
+ }
203
+ });
248
204
  }
249
205
  function normalizeDuration(duration) {
250
- if (duration == null) {
251
- return null;
252
- } else if (isObject(duration)) {
253
- return [NumberOf(duration.enter), NumberOf(duration.leave)];
254
- } else {
255
- const n = NumberOf(duration);
256
- return [n, n];
257
- }
206
+ if (duration == null) return null;
207
+ else if (isObject(duration)) return [NumberOf(duration.enter), NumberOf(duration.leave)];
208
+ else {
209
+ const n = NumberOf(duration);
210
+ return [n, n];
211
+ }
258
212
  }
259
213
  function NumberOf(val) {
260
- const res = toNumber(val);
261
- if (!!(process.env.NODE_ENV !== "production")) {
262
- assertNumber(res, "<transition> explicit duration");
263
- }
264
- return res;
214
+ const res = toNumber(val);
215
+ if (!!(process.env.NODE_ENV !== "production")) assertNumber(res, "<transition> explicit duration");
216
+ return res;
265
217
  }
266
218
  function addTransitionClass(el, cls) {
267
- cls.split(/\s+/).forEach((c) => c && el.classList.add(c));
268
- (el[vtcKey] || (el[vtcKey] = /* @__PURE__ */ new Set())).add(cls);
219
+ cls.split(/\s+/).forEach((c) => c && el.classList.add(c));
220
+ (el[vtcKey] || (el[vtcKey] = /* @__PURE__ */ new Set())).add(cls);
269
221
  }
270
222
  function removeTransitionClass(el, cls) {
271
- cls.split(/\s+/).forEach((c) => c && el.classList.remove(c));
272
- const _vtc = el[vtcKey];
273
- if (_vtc) {
274
- _vtc.delete(cls);
275
- if (!_vtc.size) {
276
- el[vtcKey] = void 0;
277
- }
278
- }
223
+ cls.split(/\s+/).forEach((c) => c && el.classList.remove(c));
224
+ const _vtc = el[vtcKey];
225
+ if (_vtc) {
226
+ _vtc.delete(cls);
227
+ if (!_vtc.size) el[vtcKey] = void 0;
228
+ }
279
229
  }
280
230
  function nextFrame(cb) {
281
- requestAnimationFrame(() => {
282
- requestAnimationFrame(cb);
283
- });
231
+ requestAnimationFrame(() => {
232
+ requestAnimationFrame(cb);
233
+ });
284
234
  }
285
235
  let endId = 0;
286
236
  function whenTransitionEnds(el, expectedType, explicitTimeout, resolve) {
287
- const id = el._endId = ++endId;
288
- const resolveIfNotStale = () => {
289
- if (id === el._endId) {
290
- resolve();
291
- }
292
- };
293
- if (explicitTimeout != null) {
294
- return setTimeout(resolveIfNotStale, explicitTimeout);
295
- }
296
- const { type, timeout, propCount } = getTransitionInfo(el, expectedType);
297
- if (!type) {
298
- return resolve();
299
- }
300
- const endEvent = type + "end";
301
- let ended = 0;
302
- const end = () => {
303
- el.removeEventListener(endEvent, onEnd);
304
- resolveIfNotStale();
305
- };
306
- const onEnd = (e) => {
307
- if (e.target === el && ++ended >= propCount) {
308
- end();
309
- }
310
- };
311
- setTimeout(() => {
312
- if (ended < propCount) {
313
- end();
314
- }
315
- }, timeout + 1);
316
- el.addEventListener(endEvent, onEnd);
237
+ const id = el._endId = ++endId;
238
+ const resolveIfNotStale = () => {
239
+ if (id === el._endId) resolve();
240
+ };
241
+ if (explicitTimeout != null) return setTimeout(resolveIfNotStale, explicitTimeout);
242
+ const { type, timeout, propCount } = getTransitionInfo(el, expectedType);
243
+ if (!type) return resolve();
244
+ const endEvent = type + "end";
245
+ let ended = 0;
246
+ const end = () => {
247
+ el.removeEventListener(endEvent, onEnd);
248
+ resolveIfNotStale();
249
+ };
250
+ const onEnd = (e) => {
251
+ if (e.target === el && ++ended >= propCount) end();
252
+ };
253
+ setTimeout(() => {
254
+ if (ended < propCount) end();
255
+ }, timeout + 1);
256
+ el.addEventListener(endEvent, onEnd);
317
257
  }
318
258
  function getTransitionInfo(el, expectedType) {
319
- const styles = window.getComputedStyle(el);
320
- const getStyleProperties = (key) => (styles[key] || "").split(", ");
321
- const transitionDelays = getStyleProperties(`${TRANSITION}Delay`);
322
- const transitionDurations = getStyleProperties(`${TRANSITION}Duration`);
323
- const transitionTimeout = getTimeout(transitionDelays, transitionDurations);
324
- const animationDelays = getStyleProperties(`${ANIMATION}Delay`);
325
- const animationDurations = getStyleProperties(`${ANIMATION}Duration`);
326
- const animationTimeout = getTimeout(animationDelays, animationDurations);
327
- let type = null;
328
- let timeout = 0;
329
- let propCount = 0;
330
- if (expectedType === TRANSITION) {
331
- if (transitionTimeout > 0) {
332
- type = TRANSITION;
333
- timeout = transitionTimeout;
334
- propCount = transitionDurations.length;
335
- }
336
- } else if (expectedType === ANIMATION) {
337
- if (animationTimeout > 0) {
338
- type = ANIMATION;
339
- timeout = animationTimeout;
340
- propCount = animationDurations.length;
341
- }
342
- } else {
343
- timeout = Math.max(transitionTimeout, animationTimeout);
344
- type = timeout > 0 ? transitionTimeout > animationTimeout ? TRANSITION : ANIMATION : null;
345
- propCount = type ? type === TRANSITION ? transitionDurations.length : animationDurations.length : 0;
346
- }
347
- const hasTransform = type === TRANSITION && /\b(?:transform|all)(?:,|$)/.test(
348
- getStyleProperties(`${TRANSITION}Property`).toString()
349
- );
350
- return {
351
- type,
352
- timeout,
353
- propCount,
354
- hasTransform
355
- };
259
+ const styles = window.getComputedStyle(el);
260
+ const getStyleProperties = (key) => (styles[key] || "").split(", ");
261
+ const transitionDelays = getStyleProperties(`${TRANSITION}Delay`);
262
+ const transitionDurations = getStyleProperties(`${TRANSITION}Duration`);
263
+ const transitionTimeout = getTimeout(transitionDelays, transitionDurations);
264
+ const animationDelays = getStyleProperties(`${ANIMATION}Delay`);
265
+ const animationDurations = getStyleProperties(`${ANIMATION}Duration`);
266
+ const animationTimeout = getTimeout(animationDelays, animationDurations);
267
+ let type = null;
268
+ let timeout = 0;
269
+ let propCount = 0;
270
+ if (expectedType === TRANSITION) {
271
+ if (transitionTimeout > 0) {
272
+ type = TRANSITION;
273
+ timeout = transitionTimeout;
274
+ propCount = transitionDurations.length;
275
+ }
276
+ } else if (expectedType === ANIMATION) {
277
+ if (animationTimeout > 0) {
278
+ type = ANIMATION;
279
+ timeout = animationTimeout;
280
+ propCount = animationDurations.length;
281
+ }
282
+ } else {
283
+ timeout = Math.max(transitionTimeout, animationTimeout);
284
+ type = timeout > 0 ? transitionTimeout > animationTimeout ? TRANSITION : ANIMATION : null;
285
+ propCount = type ? type === TRANSITION ? transitionDurations.length : animationDurations.length : 0;
286
+ }
287
+ const hasTransform = type === TRANSITION && /\b(?:transform|all)(?:,|$)/.test(getStyleProperties(`${TRANSITION}Property`).toString());
288
+ return {
289
+ type,
290
+ timeout,
291
+ propCount,
292
+ hasTransform
293
+ };
356
294
  }
357
295
  function getTimeout(delays, durations) {
358
- while (delays.length < durations.length) {
359
- delays = delays.concat(delays);
360
- }
361
- return Math.max(...durations.map((d, i) => toMs(d) + toMs(delays[i])));
296
+ while (delays.length < durations.length) delays = delays.concat(delays);
297
+ return Math.max(...durations.map((d, i) => toMs(d) + toMs(delays[i])));
362
298
  }
363
299
  function toMs(s) {
364
- if (s === "auto") return 0;
365
- return Number(s.slice(0, -1).replace(",", ".")) * 1e3;
300
+ if (s === "auto") return 0;
301
+ return Number(s.slice(0, -1).replace(",", ".")) * 1e3;
366
302
  }
367
303
  function forceReflow(el) {
368
- const targetDocument = el ? el.ownerDocument : document;
369
- return targetDocument.body.offsetHeight;
304
+ return (el ? el.ownerDocument : document).body.offsetHeight;
370
305
  }
371
-
306
+ //#endregion
307
+ //#region packages/runtime-dom/src/modules/class.ts
372
308
  function patchClass(el, value, isSVG) {
373
- const transitionClasses = el[vtcKey];
374
- if (transitionClasses) {
375
- value = (value ? [value, ...transitionClasses] : [...transitionClasses]).join(" ");
376
- }
377
- if (value == null) {
378
- el.removeAttribute("class");
379
- } else if (isSVG) {
380
- el.setAttribute("class", value);
381
- } else {
382
- el.className = value;
383
- }
309
+ const transitionClasses = el[vtcKey];
310
+ if (transitionClasses) value = (value ? [value, ...transitionClasses] : [...transitionClasses]).join(" ");
311
+ if (value == null) el.removeAttribute("class");
312
+ else if (isSVG) el.setAttribute("class", value);
313
+ else el.className = value;
384
314
  }
385
-
315
+ //#endregion
316
+ //#region packages/runtime-dom/src/directives/vShow.ts
386
317
  const vShowOriginalDisplay = Symbol("_vod");
387
318
  const vShowHidden = Symbol("_vsh");
388
319
  const vShow = {
389
- // used for prop mismatch check during hydration
390
- name: "show",
391
- beforeMount(el, { value }, { transition }) {
392
- el[vShowOriginalDisplay] = el.style.display === "none" ? "" : el.style.display;
393
- if (transition && value) {
394
- transition.beforeEnter(el);
395
- } else {
396
- setDisplay(el, value);
397
- }
398
- },
399
- mounted(el, { value }, { transition }) {
400
- if (transition && value) {
401
- transition.enter(el);
402
- }
403
- },
404
- updated(el, { value, oldValue }, { transition }) {
405
- if (!value === !oldValue) return;
406
- if (transition) {
407
- if (value) {
408
- transition.beforeEnter(el);
409
- setDisplay(el, true);
410
- transition.enter(el);
411
- } else {
412
- transition.leave(el, () => {
413
- setDisplay(el, false);
414
- });
415
- }
416
- } else {
417
- setDisplay(el, value);
418
- }
419
- },
420
- beforeUnmount(el, { value }) {
421
- setDisplay(el, value);
422
- }
320
+ name: "show",
321
+ beforeMount(el, { value }, { transition }) {
322
+ el[vShowOriginalDisplay] = el.style.display === "none" ? "" : el.style.display;
323
+ if (transition && value) transition.beforeEnter(el);
324
+ else setDisplay(el, value);
325
+ },
326
+ mounted(el, { value }, { transition }) {
327
+ if (transition && value) transition.enter(el);
328
+ },
329
+ updated(el, { value, oldValue }, { transition }) {
330
+ if (!value === !oldValue) return;
331
+ if (transition) if (value) {
332
+ transition.beforeEnter(el);
333
+ setDisplay(el, true);
334
+ transition.enter(el);
335
+ } else transition.leave(el, () => {
336
+ setDisplay(el, false);
337
+ });
338
+ else setDisplay(el, value);
339
+ },
340
+ beforeUnmount(el, { value }) {
341
+ setDisplay(el, value);
342
+ }
423
343
  };
424
344
  function setDisplay(el, value) {
425
- el.style.display = value ? el[vShowOriginalDisplay] : "none";
426
- el[vShowHidden] = !value;
345
+ el.style.display = value ? el[vShowOriginalDisplay] : "none";
346
+ el[vShowHidden] = !value;
427
347
  }
428
348
  function initVShowForSSR() {
429
- vShow.getSSRProps = ({ value }) => {
430
- if (!value) {
431
- return { style: { display: "none" } };
432
- }
433
- };
349
+ vShow.getSSRProps = ({ value }) => {
350
+ if (!value) return { style: { display: "none" } };
351
+ };
434
352
  }
435
-
353
+ //#endregion
354
+ //#region packages/runtime-dom/src/helpers/useCssVars.ts
436
355
  const CSS_VAR_TEXT = Symbol(!!(process.env.NODE_ENV !== "production") ? "CSS_VAR_TEXT" : "");
356
+ /**
357
+ * Runtime helper for SFC's CSS variable injection feature.
358
+ * @private
359
+ */
437
360
  function useCssVars(getter) {
438
- const instance = getCurrentInstance();
439
- const getVars = () => getter(instance.proxy);
440
- const setVars = (vars) => {
441
- if (instance.ce) {
442
- setVarsOnNode(instance.ce, vars);
443
- } else {
444
- setVarsOnVNode(instance.subTree, vars);
445
- }
446
- };
447
- baseUseCssVars(
448
- instance,
449
- () => instance.subTree.el.parentNode,
450
- getVars,
451
- setVars
452
- );
361
+ const instance = getCurrentInstance();
362
+ const getVars = () => getter(instance.proxy);
363
+ const setVars = (vars) => {
364
+ if (instance.ce) setVarsOnNode(instance.ce, vars);
365
+ else setVarsOnVNode(instance.subTree, vars);
366
+ };
367
+ baseUseCssVars(instance, () => instance.subTree.el.parentNode, getVars, setVars);
453
368
  }
454
369
  function setVarsOnVNode(vnode, vars) {
455
- if (vnode.shapeFlag & 128) {
456
- const suspense = vnode.suspense;
457
- vnode = suspense.activeBranch;
458
- if (suspense.pendingBranch && !suspense.isHydrating) {
459
- suspense.effects.push(() => {
460
- setVarsOnVNode(suspense.activeBranch, vars);
461
- });
462
- }
463
- }
464
- while (vnode.component) {
465
- vnode = vnode.component.subTree;
466
- }
467
- if (vnode.shapeFlag & 1 && vnode.el) {
468
- setVarsOnNode(vnode.el, vars);
469
- } else if (vnode.type === Fragment) {
470
- vnode.children.forEach((c) => setVarsOnVNode(c, vars));
471
- } else if (vnode.type === Static) {
472
- let { el, anchor } = vnode;
473
- while (el) {
474
- setVarsOnNode(el, vars);
475
- if (el === anchor) break;
476
- el = el.nextSibling;
477
- }
478
- }
370
+ if (vnode.shapeFlag & 128) {
371
+ const suspense = vnode.suspense;
372
+ vnode = suspense.activeBranch;
373
+ if (suspense.pendingBranch && !suspense.isHydrating) suspense.effects.push(() => {
374
+ setVarsOnVNode(suspense.activeBranch, vars);
375
+ });
376
+ }
377
+ while (vnode.component) vnode = vnode.component.subTree;
378
+ if (vnode.shapeFlag & 1 && vnode.el) setVarsOnNode(vnode.el, vars);
379
+ else if (vnode.type === Fragment) vnode.children.forEach((c) => setVarsOnVNode(c, vars));
380
+ else if (vnode.type === Static) {
381
+ let { el, anchor } = vnode;
382
+ while (el) {
383
+ setVarsOnNode(el, vars);
384
+ if (el === anchor) break;
385
+ el = el.nextSibling;
386
+ }
387
+ }
479
388
  }
389
+ /**
390
+ * @internal
391
+ * shared between vdom and vapor
392
+ */
480
393
  function baseUseCssVars(instance, getParentNode, getVars, setVars) {
481
- if (!instance) {
482
- !!(process.env.NODE_ENV !== "production") && warn(`useCssVars is called without current active component instance.`);
483
- return;
484
- }
485
- if (!!(process.env.NODE_ENV !== "production")) {
486
- instance.getCssVars = getVars;
487
- }
488
- const updateTeleports = instance.ut = (vars = getVars()) => {
489
- Array.from(
490
- document.querySelectorAll(`[data-v-owner="${instance.uid}"]`)
491
- ).forEach((node) => setVarsOnNode(node, vars));
492
- };
493
- const applyCssCars = () => {
494
- const vars = getVars();
495
- setVars(vars);
496
- updateTeleports(vars);
497
- };
498
- onBeforeUpdate(() => {
499
- queuePostFlushCb(applyCssCars);
500
- });
501
- onMounted(() => {
502
- watch(applyCssCars, NOOP, { flush: "post" });
503
- const ob = new MutationObserver(applyCssCars);
504
- ob.observe(getParentNode(), { childList: true });
505
- onUnmounted(() => ob.disconnect());
506
- });
394
+ /* v8 ignore start */
395
+ if (!instance) {
396
+ process.env.NODE_ENV !== "production" && warn(`useCssVars is called without current active component instance.`);
397
+ return;
398
+ }
399
+ /* v8 ignore stop */
400
+ if (!!(process.env.NODE_ENV !== "production")) instance.getCssVars = getVars;
401
+ const updateTeleports = instance.ut = (vars = getVars()) => {
402
+ Array.from(document.querySelectorAll(`[data-v-owner="${instance.uid}"]`)).forEach((node) => setVarsOnNode(node, vars));
403
+ };
404
+ const applyCssVars = (vars = getVars()) => {
405
+ setVars(vars);
406
+ updateTeleports(vars);
407
+ };
408
+ onBeforeUpdate(() => {
409
+ queuePostFlushCb(applyCssVars);
410
+ });
411
+ onMounted(() => {
412
+ watch(() => {
413
+ const vars = getVars();
414
+ extend({}, vars);
415
+ applyCssVars(vars);
416
+ }, NOOP, { flush: "post" });
417
+ const ob = new MutationObserver(() => applyCssVars());
418
+ ob.observe(getParentNode(), { childList: true });
419
+ onUnmounted(() => ob.disconnect());
420
+ });
507
421
  }
422
+ /**
423
+ * @internal
424
+ * shared between vdom and vapor
425
+ */
508
426
  function setVarsOnNode(el, vars) {
509
- if (el.nodeType === 1) {
510
- const style = el.style;
511
- let cssText = "";
512
- for (const key in vars) {
513
- const value = normalizeCssVarValue(vars[key]);
514
- style.setProperty(`--${key}`, value);
515
- cssText += `--${key}: ${value};`;
516
- }
517
- style[CSS_VAR_TEXT] = cssText;
518
- }
427
+ if (el.nodeType === 1) {
428
+ const style = el.style;
429
+ let cssText = "";
430
+ for (const key in vars) {
431
+ const value = normalizeCssVarValue(vars[key]);
432
+ style.setProperty(`--${key}`, value);
433
+ cssText += `--${key}: ${value};`;
434
+ }
435
+ style[CSS_VAR_TEXT] = cssText;
436
+ }
519
437
  }
520
-
438
+ //#endregion
439
+ //#region packages/runtime-dom/src/modules/style.ts
521
440
  const displayRE = /(?:^|;)\s*display\s*:/;
522
441
  function patchStyle(el, prev, next) {
523
- const style = el.style;
524
- const isCssString = isString(next);
525
- let hasControlledDisplay = false;
526
- if (next && !isCssString) {
527
- if (prev) {
528
- if (!isString(prev)) {
529
- for (const key in prev) {
530
- if (next[key] == null) {
531
- setStyle(style, key, "");
532
- }
533
- }
534
- } else {
535
- for (const prevStyle of prev.split(";")) {
536
- const key = prevStyle.slice(0, prevStyle.indexOf(":")).trim();
537
- if (next[key] == null) {
538
- setStyle(style, key, "");
539
- }
540
- }
541
- }
542
- }
543
- for (const key in next) {
544
- if (key === "display") {
545
- hasControlledDisplay = true;
546
- }
547
- setStyle(style, key, next[key]);
548
- }
549
- } else {
550
- if (isCssString) {
551
- if (prev !== next) {
552
- const cssVarText = style[CSS_VAR_TEXT];
553
- if (cssVarText) {
554
- next += ";" + cssVarText;
555
- }
556
- style.cssText = next;
557
- hasControlledDisplay = displayRE.test(next);
558
- }
559
- } else if (prev) {
560
- el.removeAttribute("style");
561
- }
562
- }
563
- if (vShowOriginalDisplay in el) {
564
- el[vShowOriginalDisplay] = hasControlledDisplay ? style.display : "";
565
- if (el[vShowHidden]) {
566
- style.display = "none";
567
- }
568
- }
442
+ const style = el.style;
443
+ const isCssString = isString(next);
444
+ let hasControlledDisplay = false;
445
+ if (next && !isCssString) {
446
+ if (prev) if (!isString(prev)) {
447
+ for (const key in prev) if (next[key] == null) setStyle(style, key, "");
448
+ } else for (const prevStyle of prev.split(";")) {
449
+ const key = prevStyle.slice(0, prevStyle.indexOf(":")).trim();
450
+ if (next[key] == null) setStyle(style, key, "");
451
+ }
452
+ for (const key in next) {
453
+ if (key === "display") hasControlledDisplay = true;
454
+ setStyle(style, key, next[key]);
455
+ }
456
+ } else if (isCssString) {
457
+ if (prev !== next) {
458
+ const cssVarText = style[CSS_VAR_TEXT];
459
+ if (cssVarText) next += ";" + cssVarText;
460
+ style.cssText = next;
461
+ hasControlledDisplay = displayRE.test(next);
462
+ }
463
+ } else if (prev) el.removeAttribute("style");
464
+ if (vShowOriginalDisplay in el) {
465
+ el[vShowOriginalDisplay] = hasControlledDisplay ? style.display : "";
466
+ if (el[vShowHidden]) style.display = "none";
467
+ }
569
468
  }
570
469
  const semicolonRE = /[^\\];\s*$/;
571
470
  const importantRE = /\s*!important$/;
572
471
  function setStyle(style, name, rawVal) {
573
- if (isArray(rawVal)) {
574
- rawVal.forEach((v) => setStyle(style, name, v));
575
- } else {
576
- const val = rawVal == null ? "" : String(rawVal);
577
- if (!!(process.env.NODE_ENV !== "production")) {
578
- if (semicolonRE.test(val)) {
579
- warn(
580
- `Unexpected semicolon at the end of '${name}' style value: '${val}'`
581
- );
582
- }
583
- }
584
- if (name.startsWith("--")) {
585
- style.setProperty(name, val);
586
- } else {
587
- const prefixed = autoPrefix(style, name);
588
- if (importantRE.test(val)) {
589
- style.setProperty(
590
- hyphenate(prefixed),
591
- val.replace(importantRE, ""),
592
- "important"
593
- );
594
- } else {
595
- style[prefixed] = val;
596
- }
597
- }
598
- }
472
+ if (isArray(rawVal)) rawVal.forEach((v) => setStyle(style, name, v));
473
+ else {
474
+ const val = rawVal == null ? "" : String(rawVal);
475
+ if (!!(process.env.NODE_ENV !== "production")) {
476
+ if (semicolonRE.test(val)) warn(`Unexpected semicolon at the end of '${name}' style value: '${val}'`);
477
+ }
478
+ if (name.startsWith("--")) style.setProperty(name, val);
479
+ else {
480
+ const prefixed = autoPrefix(style, name);
481
+ if (importantRE.test(val)) style.setProperty(hyphenate(prefixed), val.replace(importantRE, ""), "important");
482
+ else style[prefixed] = val;
483
+ }
484
+ }
599
485
  }
600
- const prefixes = ["Webkit", "Moz", "ms"];
486
+ const prefixes = [
487
+ "Webkit",
488
+ "Moz",
489
+ "ms"
490
+ ];
601
491
  const prefixCache = {};
602
492
  function autoPrefix(style, rawName) {
603
- const cached = prefixCache[rawName];
604
- if (cached) {
605
- return cached;
606
- }
607
- let name = camelize(rawName);
608
- if (name !== "filter" && name in style) {
609
- return prefixCache[rawName] = name;
610
- }
611
- name = capitalize(name);
612
- for (let i = 0; i < prefixes.length; i++) {
613
- const prefixed = prefixes[i] + name;
614
- if (prefixed in style) {
615
- return prefixCache[rawName] = prefixed;
616
- }
617
- }
618
- return rawName;
493
+ const cached = prefixCache[rawName];
494
+ if (cached) return cached;
495
+ let name = camelize(rawName);
496
+ if (name !== "filter" && name in style) return prefixCache[rawName] = name;
497
+ name = capitalize(name);
498
+ for (let i = 0; i < prefixes.length; i++) {
499
+ const prefixed = prefixes[i] + name;
500
+ if (prefixed in style) return prefixCache[rawName] = prefixed;
501
+ }
502
+ return rawName;
619
503
  }
620
-
504
+ //#endregion
505
+ //#region packages/runtime-dom/src/modules/attrs.ts
621
506
  const xlinkNS = "http://www.w3.org/1999/xlink";
622
507
  function patchAttr(el, key, value, isSVG, instance, isBoolean = isSpecialBooleanAttr(key)) {
623
- if (isSVG && key.startsWith("xlink:")) {
624
- if (value == null) {
625
- el.removeAttributeNS(xlinkNS, key.slice(6, key.length));
626
- } else {
627
- el.setAttributeNS(xlinkNS, key, value);
628
- }
629
- } else {
630
- if (value == null || isBoolean && !includeBooleanAttr(value)) {
631
- el.removeAttribute(key);
632
- } else {
633
- el.setAttribute(
634
- key,
635
- isBoolean ? "" : isSymbol(value) ? String(value) : value
636
- );
637
- }
638
- }
508
+ if (isSVG && key.startsWith("xlink:")) if (value == null) el.removeAttributeNS(xlinkNS, key.slice(6, key.length));
509
+ else el.setAttributeNS(xlinkNS, key, value);
510
+ else if (value == null || isBoolean && !includeBooleanAttr(value)) el.removeAttribute(key);
511
+ else el.setAttribute(key, isBoolean ? "" : isSymbol(value) ? String(value) : value);
639
512
  }
640
-
513
+ //#endregion
514
+ //#region packages/runtime-dom/src/modules/props.ts
641
515
  function patchDOMProp(el, key, value, parentComponent, attrName) {
642
- if (key === "innerHTML" || key === "textContent") {
643
- if (value != null) {
644
- el[key] = key === "innerHTML" ? unsafeToTrustedHTML(value) : value;
645
- }
646
- return;
647
- }
648
- const tag = el.tagName;
649
- if (key === "value" && canSetValueDirectly(tag)) {
650
- const oldValue = tag === "OPTION" ? el.getAttribute("value") || "" : el.value;
651
- const newValue = value == null ? (
652
- // #11647: value should be set as empty string for null and undefined,
653
- // but <input type="checkbox"> should be set as 'on'.
654
- el.type === "checkbox" ? "on" : ""
655
- ) : String(value);
656
- if (oldValue !== newValue || !("_value" in el)) {
657
- el.value = newValue;
658
- }
659
- if (value == null) {
660
- el.removeAttribute(key);
661
- }
662
- el._value = value;
663
- return;
664
- }
665
- let needRemove = false;
666
- if (value === "" || value == null) {
667
- const type = typeof el[key];
668
- if (type === "boolean") {
669
- value = includeBooleanAttr(value);
670
- } else if (value == null && type === "string") {
671
- value = "";
672
- needRemove = true;
673
- } else if (type === "number") {
674
- value = 0;
675
- needRemove = true;
676
- }
677
- }
678
- try {
679
- el[key] = value;
680
- } catch (e) {
681
- if (!!(process.env.NODE_ENV !== "production") && !needRemove) {
682
- warn(
683
- `Failed setting prop "${key}" on <${tag.toLowerCase()}>: value ${value} is invalid.`,
684
- e
685
- );
686
- }
687
- }
688
- needRemove && el.removeAttribute(attrName || key);
516
+ if (key === "innerHTML" || key === "textContent") {
517
+ if (value != null) el[key] = key === "innerHTML" ? unsafeToTrustedHTML(value) : value;
518
+ return;
519
+ }
520
+ const tag = el.tagName;
521
+ if (key === "value" && canSetValueDirectly(tag)) {
522
+ const oldValue = tag === "OPTION" ? el.getAttribute("value") || "" : el.value;
523
+ const newValue = value == null ? el.type === "checkbox" ? "on" : "" : String(value);
524
+ if (oldValue !== newValue || !("_value" in el)) el.value = newValue;
525
+ if (value == null) el.removeAttribute(key);
526
+ el._value = value;
527
+ return;
528
+ }
529
+ let needRemove = false;
530
+ if (value === "" || value == null) {
531
+ const type = typeof el[key];
532
+ if (type === "boolean") value = includeBooleanAttr(value);
533
+ else if (value == null && type === "string") {
534
+ value = "";
535
+ needRemove = true;
536
+ } else if (type === "number") {
537
+ value = 0;
538
+ needRemove = true;
539
+ }
540
+ }
541
+ try {
542
+ el[key] = value;
543
+ } catch (e) {
544
+ if (!!(process.env.NODE_ENV !== "production") && !needRemove) warn(`Failed setting prop "${key}" on <${tag.toLowerCase()}>: value ${value} is invalid.`, e);
545
+ }
546
+ needRemove && el.removeAttribute(attrName || key);
689
547
  }
690
-
548
+ //#endregion
549
+ //#region packages/runtime-dom/src/modules/events.ts
691
550
  function addEventListener(el, event, handler, options) {
692
- el.addEventListener(event, handler, options);
551
+ el.addEventListener(event, handler, options);
693
552
  }
694
553
  function removeEventListener(el, event, handler, options) {
695
- el.removeEventListener(event, handler, options);
554
+ el.removeEventListener(event, handler, options);
696
555
  }
697
556
  const veiKey = Symbol("_vei");
698
557
  function patchEvent(el, rawName, prevValue, nextValue, instance = null) {
699
- const invokers = el[veiKey] || (el[veiKey] = {});
700
- const existingInvoker = invokers[rawName];
701
- if (nextValue && existingInvoker) {
702
- existingInvoker.value = !!(process.env.NODE_ENV !== "production") ? sanitizeEventValue(nextValue, rawName) : nextValue;
703
- } else {
704
- const [name, options] = parseName(rawName);
705
- if (nextValue) {
706
- const invoker = invokers[rawName] = createInvoker(
707
- !!(process.env.NODE_ENV !== "production") ? sanitizeEventValue(nextValue, rawName) : nextValue,
708
- instance
709
- );
710
- addEventListener(el, name, invoker, options);
711
- } else if (existingInvoker) {
712
- removeEventListener(el, name, existingInvoker, options);
713
- invokers[rawName] = void 0;
714
- }
715
- }
558
+ const invokers = el[veiKey] || (el[veiKey] = {});
559
+ const existingInvoker = invokers[rawName];
560
+ if (nextValue && existingInvoker) existingInvoker.value = !!(process.env.NODE_ENV !== "production") ? sanitizeEventValue(nextValue, rawName) : nextValue;
561
+ else {
562
+ const [name, options] = parseName(rawName);
563
+ if (nextValue) addEventListener(el, name, invokers[rawName] = createInvoker(!!(process.env.NODE_ENV !== "production") ? sanitizeEventValue(nextValue, rawName) : nextValue, instance), options);
564
+ else if (existingInvoker) {
565
+ removeEventListener(el, name, existingInvoker, options);
566
+ invokers[rawName] = void 0;
567
+ }
568
+ }
716
569
  }
717
570
  const optionsModifierRE = /(?:Once|Passive|Capture)$/;
718
571
  function parseName(name) {
719
- let options;
720
- if (optionsModifierRE.test(name)) {
721
- options = {};
722
- let m;
723
- while (m = name.match(optionsModifierRE)) {
724
- name = name.slice(0, name.length - m[0].length);
725
- options[m[0].toLowerCase()] = true;
726
- }
727
- }
728
- const event = name[2] === ":" ? name.slice(3) : hyphenate(name.slice(2));
729
- return [event, options];
572
+ let options;
573
+ if (optionsModifierRE.test(name)) {
574
+ options = {};
575
+ let m;
576
+ while (m = name.match(optionsModifierRE)) {
577
+ name = name.slice(0, name.length - m[0].length);
578
+ options[m[0].toLowerCase()] = true;
579
+ }
580
+ }
581
+ return [name[2] === ":" ? name.slice(3) : hyphenate(name.slice(2)), options];
730
582
  }
731
583
  let cachedNow = 0;
732
584
  const p = /* @__PURE__ */ Promise.resolve();
733
585
  const getNow = () => cachedNow || (p.then(() => cachedNow = 0), cachedNow = Date.now());
734
586
  function createInvoker(initialValue, instance) {
735
- const invoker = (e) => {
736
- if (!e._vts) {
737
- e._vts = Date.now();
738
- } else if (e._vts <= invoker.attached) {
739
- return;
740
- }
741
- callWithAsyncErrorHandling(
742
- patchStopImmediatePropagation(e, invoker.value),
743
- instance,
744
- 5,
745
- [e]
746
- );
747
- };
748
- invoker.value = initialValue;
749
- invoker.attached = getNow();
750
- return invoker;
587
+ const invoker = (e) => {
588
+ if (!e._vts) e._vts = Date.now();
589
+ else if (e._vts <= invoker.attached) return;
590
+ callWithAsyncErrorHandling(patchStopImmediatePropagation(e, invoker.value), instance, 5, [e]);
591
+ };
592
+ invoker.value = initialValue;
593
+ invoker.attached = getNow();
594
+ return invoker;
751
595
  }
752
596
  function sanitizeEventValue(value, propName) {
753
- if (isFunction(value) || isArray(value)) {
754
- return value;
755
- }
756
- warn(
757
- `Wrong type passed as event handler to ${propName} - did you forget @ or : in front of your prop?
758
- Expected function or array of functions, received type ${typeof value}.`
759
- );
760
- return NOOP;
597
+ if (isFunction(value) || isArray(value)) return value;
598
+ warn(`Wrong type passed as event handler to ${propName} - did you forget @ or : in front of your prop?\nExpected function or array of functions, received type ${typeof value}.`);
599
+ return NOOP;
761
600
  }
762
601
  function patchStopImmediatePropagation(e, value) {
763
- if (isArray(value)) {
764
- const originalStop = e.stopImmediatePropagation;
765
- e.stopImmediatePropagation = () => {
766
- originalStop.call(e);
767
- e._stopped = true;
768
- };
769
- return value.map(
770
- (fn) => (e2) => !e2._stopped && fn && fn(e2)
771
- );
772
- } else {
773
- return value;
774
- }
602
+ if (isArray(value)) {
603
+ const originalStop = e.stopImmediatePropagation;
604
+ e.stopImmediatePropagation = () => {
605
+ originalStop.call(e);
606
+ e._stopped = true;
607
+ };
608
+ return value.map((fn) => (e) => !e._stopped && fn && fn(e));
609
+ } else return value;
775
610
  }
776
-
611
+ //#endregion
612
+ //#region packages/runtime-dom/src/patchProp.ts
777
613
  const patchProp = (el, key, prevValue, nextValue, namespace, parentComponent) => {
778
- const isSVG = namespace === "svg";
779
- if (key === "class") {
780
- patchClass(el, nextValue, isSVG);
781
- } else if (key === "style") {
782
- patchStyle(el, prevValue, nextValue);
783
- } else if (isOn(key)) {
784
- if (!isModelListener(key)) {
785
- patchEvent(el, key, prevValue, nextValue, parentComponent);
786
- }
787
- } else if (key[0] === "." ? (key = key.slice(1), true) : key[0] === "^" ? (key = key.slice(1), false) : shouldSetAsProp(el, key, nextValue, isSVG)) {
788
- patchDOMProp(el, key, nextValue);
789
- if (!el.tagName.includes("-") && (key === "value" || key === "checked" || key === "selected")) {
790
- patchAttr(el, key, nextValue, isSVG, parentComponent, key !== "value");
791
- }
792
- } else if (
793
- // #11081 force set props for possible async custom element
794
- el._isVueCE && (/[A-Z]/.test(key) || !isString(nextValue))
795
- ) {
796
- patchDOMProp(el, camelize$1(key), nextValue, parentComponent, key);
797
- } else {
798
- if (key === "true-value") {
799
- el._trueValue = nextValue;
800
- } else if (key === "false-value") {
801
- el._falseValue = nextValue;
802
- }
803
- patchAttr(el, key, nextValue, isSVG);
804
- }
614
+ const isSVG = namespace === "svg";
615
+ if (key === "class") patchClass(el, nextValue, isSVG);
616
+ else if (key === "style") patchStyle(el, prevValue, nextValue);
617
+ else if (isOn(key)) {
618
+ if (!isModelListener(key)) patchEvent(el, key, prevValue, nextValue, parentComponent);
619
+ } else if (key[0] === "." ? (key = key.slice(1), true) : key[0] === "^" ? (key = key.slice(1), false) : shouldSetAsProp(el, key, nextValue, isSVG)) {
620
+ patchDOMProp(el, key, nextValue, parentComponent);
621
+ if (!el.tagName.includes("-") && (key === "value" || key === "checked" || key === "selected")) patchAttr(el, key, nextValue, isSVG, parentComponent, key !== "value");
622
+ } else if (el._isVueCE && (shouldSetAsPropForVueCE(el, key) || el._def.__asyncLoader && (/[A-Z]/.test(key) || !isString(nextValue)))) patchDOMProp(el, camelize$1(key), nextValue, parentComponent, key);
623
+ else {
624
+ if (key === "true-value") el._trueValue = nextValue;
625
+ else if (key === "false-value") el._falseValue = nextValue;
626
+ patchAttr(el, key, nextValue, isSVG, parentComponent);
627
+ }
805
628
  };
806
629
  function shouldSetAsProp(el, key, value, isSVG) {
807
- if (isSVG) {
808
- if (key === "innerHTML" || key === "textContent") {
809
- return true;
810
- }
811
- if (key in el && isNativeOn(key) && isFunction(value)) {
812
- return true;
813
- }
814
- return false;
815
- }
816
- if (shouldSetAsAttr(el.tagName, key)) {
817
- return false;
818
- }
819
- if (isNativeOn(key) && isString(value)) {
820
- return false;
821
- }
822
- return key in el;
630
+ if (isSVG) {
631
+ if (key === "innerHTML" || key === "textContent") return true;
632
+ if (key in el && isNativeOn(key) && isFunction(value)) return true;
633
+ return false;
634
+ }
635
+ if (shouldSetAsAttr(el.tagName, key)) return false;
636
+ if (isNativeOn(key) && isString(value)) return false;
637
+ return key in el;
823
638
  }
824
-
639
+ function shouldSetAsPropForVueCE(el, key) {
640
+ const props = el._def.props;
641
+ if (!props) return false;
642
+ const camelKey = camelize$1(key);
643
+ return Array.isArray(props) ? props.some((prop) => camelize$1(prop) === camelKey) : Object.keys(props).some((prop) => camelize$1(prop) === camelKey);
644
+ }
645
+ //#endregion
646
+ //#region packages/runtime-dom/src/apiCustomElement.ts
825
647
  const REMOVAL = {};
826
- // @__NO_SIDE_EFFECTS__
648
+ /* @__NO_SIDE_EFFECTS__ */
827
649
  function defineCustomElement(options, extraOptions, _createApp) {
828
- let Comp = defineComponent(options, extraOptions);
829
- if (isPlainObject(Comp)) Comp = extend({}, Comp, extraOptions);
830
- class VueCustomElement extends VueElement {
831
- constructor(initialProps) {
832
- super(Comp, initialProps, _createApp);
833
- }
834
- }
835
- VueCustomElement.def = Comp;
836
- return VueCustomElement;
650
+ let Comp = defineComponent(options, extraOptions);
651
+ if (isPlainObject(Comp)) Comp = extend({}, Comp, extraOptions);
652
+ class VueCustomElement extends VueElement {
653
+ constructor(initialProps) {
654
+ super(Comp, initialProps, _createApp);
655
+ }
656
+ }
657
+ VueCustomElement.def = Comp;
658
+ return VueCustomElement;
837
659
  }
838
- const defineSSRCustomElement = (/* @__NO_SIDE_EFFECTS__ */ (options, extraOptions) => {
839
- return /* @__PURE__ */ defineCustomElement(options, extraOptions, createSSRApp);
660
+ const defineSSRCustomElement = ((options, extraOptions) => {
661
+ return /* @__PURE__ */ defineCustomElement(options, extraOptions, createSSRApp);
840
662
  });
841
- const BaseClass = typeof HTMLElement !== "undefined" ? HTMLElement : class {
663
+ const BaseClass = typeof HTMLElement !== "undefined" ? HTMLElement : class {};
664
+ var VueElementBase = class VueElementBase extends BaseClass {
665
+ constructor(def, props = {}, createAppFn) {
666
+ super();
667
+ this._isVueCE = true;
668
+ this._instance = null;
669
+ this._app = null;
670
+ this._connected = false;
671
+ this._resolved = false;
672
+ this._numberProps = null;
673
+ this._styleChildren = /* @__PURE__ */ new WeakSet();
674
+ this._styleAnchors = /* @__PURE__ */ new WeakMap();
675
+ this._patching = false;
676
+ this._dirty = false;
677
+ this._ob = null;
678
+ this._def = def;
679
+ this._props = props;
680
+ this._createApp = createAppFn;
681
+ this._nonce = def.nonce;
682
+ if (this._needsHydration()) this._root = this.shadowRoot;
683
+ else if (def.shadowRoot !== false) {
684
+ this.attachShadow(extend({}, def.shadowRootOptions, { mode: "open" }));
685
+ this._root = this.shadowRoot;
686
+ } else this._root = this;
687
+ }
688
+ connectedCallback() {
689
+ if (!this.isConnected) return;
690
+ if (!this.shadowRoot && !this._resolved) this._parseSlots();
691
+ this._connected = true;
692
+ let parent = this;
693
+ while (parent = parent && (parent.assignedSlot || parent.parentNode || parent.host)) if (parent instanceof VueElementBase) {
694
+ this._parent = parent;
695
+ break;
696
+ }
697
+ if (!this._instance) if (this._resolved) this._mountComponent(this._def);
698
+ else if (parent && parent._pendingResolve) this._pendingResolve = parent._pendingResolve.then(() => {
699
+ this._pendingResolve = void 0;
700
+ this._resolveDef();
701
+ });
702
+ else this._resolveDef();
703
+ }
704
+ disconnectedCallback() {
705
+ this._connected = false;
706
+ nextTick(() => {
707
+ if (!this._connected) {
708
+ if (this._ob) {
709
+ this._ob.disconnect();
710
+ this._ob = null;
711
+ }
712
+ this._unmount();
713
+ if (this._teleportTargets) {
714
+ this._teleportTargets.clear();
715
+ this._teleportTargets = void 0;
716
+ }
717
+ }
718
+ });
719
+ }
720
+ _setParent(parent = this._parent) {
721
+ if (parent && this._instance) {
722
+ this._instance.parent = parent._instance;
723
+ this._inheritParentContext(parent);
724
+ }
725
+ }
726
+ _inheritParentContext(parent = this._parent) {
727
+ if (parent && this._app) Object.setPrototypeOf(this._app._context.provides, parent._instance.provides);
728
+ }
729
+ _processMutations(mutations) {
730
+ for (const m of mutations) this._setAttr(m.attributeName);
731
+ }
732
+ /**
733
+ * resolve inner component definition (handle possible async component)
734
+ */
735
+ _resolveDef() {
736
+ if (this._pendingResolve) return;
737
+ for (let i = 0; i < this.attributes.length; i++) this._setAttr(this.attributes[i].name);
738
+ this._ob = new MutationObserver(this._processMutations.bind(this));
739
+ this._ob.observe(this, { attributes: true });
740
+ const resolve = (def) => {
741
+ this._resolved = true;
742
+ this._pendingResolve = void 0;
743
+ const { props, styles } = def;
744
+ let numberProps;
745
+ if (props && !isArray(props)) for (const key in props) {
746
+ const opt = props[key];
747
+ if (opt === Number || opt && opt.type === Number) {
748
+ if (key in this._props) this._props[key] = toNumber(this._props[key]);
749
+ (numberProps || (numberProps = Object.create(null)))[camelize$1(key)] = true;
750
+ }
751
+ }
752
+ this._numberProps = numberProps;
753
+ this._resolveProps(def);
754
+ if (this.shadowRoot) this._applyStyles(styles);
755
+ else if (!!(process.env.NODE_ENV !== "production") && styles) warn("Custom element style injection is not supported when using shadowRoot: false");
756
+ this._mountComponent(def);
757
+ };
758
+ const asyncDef = this._def.__asyncLoader;
759
+ if (asyncDef) {
760
+ const { configureApp } = this._def;
761
+ this._pendingResolve = asyncDef().then((def) => {
762
+ def.configureApp = configureApp;
763
+ this._def = def;
764
+ resolve(def);
765
+ });
766
+ } else resolve(this._def);
767
+ }
768
+ _mountComponent(def) {
769
+ this._mount(def);
770
+ this._processExposed();
771
+ }
772
+ _processExposed() {
773
+ const exposed = this._instance && this._instance.exposed;
774
+ if (!exposed) return;
775
+ for (const key in exposed) if (!hasOwn(this, key)) Object.defineProperty(this, key, { get: () => unref(exposed[key]) });
776
+ else if (!!(process.env.NODE_ENV !== "production")) warn(`Exposed property "${key}" already exists on custom element.`);
777
+ }
778
+ _processInstance() {
779
+ this._instance.ce = this;
780
+ this._instance.isCE = true;
781
+ if (!!(process.env.NODE_ENV !== "production")) this._instance.ceReload = (newStyles) => {
782
+ if (this._styles) {
783
+ this._styles.forEach((s) => this._root.removeChild(s));
784
+ this._styles.length = 0;
785
+ }
786
+ this._styleAnchors.delete(this._def);
787
+ this._applyStyles(newStyles);
788
+ if (!this._instance.vapor) this._instance = null;
789
+ this._update();
790
+ };
791
+ const dispatch = (event, args) => {
792
+ this.dispatchEvent(new CustomEvent(event, isPlainObject(args[0]) ? extend({ detail: args }, args[0]) : { detail: args }));
793
+ };
794
+ this._instance.emit = (event, ...args) => {
795
+ dispatch(event, args);
796
+ if (hyphenate(event) !== event) dispatch(hyphenate(event), args);
797
+ };
798
+ this._setParent();
799
+ }
800
+ _resolveProps(def) {
801
+ const { props } = def;
802
+ const declaredPropKeys = isArray(props) ? props : Object.keys(props || {});
803
+ for (const key of Object.keys(this)) if (key[0] !== "_" && declaredPropKeys.includes(key)) this._setProp(key, this[key]);
804
+ for (const key of declaredPropKeys.map(camelize$1)) Object.defineProperty(this, key, {
805
+ get() {
806
+ return this._getProp(key);
807
+ },
808
+ set(val) {
809
+ this._setProp(key, val, true, !this._patching);
810
+ }
811
+ });
812
+ }
813
+ _setAttr(key) {
814
+ if (key.startsWith("data-v-")) return;
815
+ const has = this.hasAttribute(key);
816
+ let value = has ? this.getAttribute(key) : REMOVAL;
817
+ const camelKey = camelize$1(key);
818
+ if (has && this._numberProps && this._numberProps[camelKey]) value = toNumber(value);
819
+ this._setProp(camelKey, value, false, true);
820
+ }
821
+ /**
822
+ * @internal
823
+ */
824
+ _getProp(key) {
825
+ return this._props[key];
826
+ }
827
+ /**
828
+ * @internal
829
+ */
830
+ _setProp(key, val, shouldReflect = true, shouldUpdate = false) {
831
+ if (val !== this._props[key]) {
832
+ this._dirty = true;
833
+ if (val === REMOVAL) delete this._props[key];
834
+ else {
835
+ this._props[key] = val;
836
+ if (key === "key" && this._app && this._app._ceVNode) this._app._ceVNode.key = val;
837
+ }
838
+ if (shouldUpdate && this._instance) this._update();
839
+ if (shouldReflect) {
840
+ const ob = this._ob;
841
+ if (ob) {
842
+ this._processMutations(ob.takeRecords());
843
+ ob.disconnect();
844
+ }
845
+ if (val === true) this.setAttribute(hyphenate(key), "");
846
+ else if (typeof val === "string" || typeof val === "number") this.setAttribute(hyphenate(key), val + "");
847
+ else if (!val) this.removeAttribute(hyphenate(key));
848
+ ob && ob.observe(this, { attributes: true });
849
+ }
850
+ }
851
+ }
852
+ _applyStyles(styles, owner, parentComp) {
853
+ if (!styles) return;
854
+ if (owner) {
855
+ if (owner === this._def || this._styleChildren.has(owner)) return;
856
+ this._styleChildren.add(owner);
857
+ }
858
+ const nonce = this._nonce;
859
+ const root = this.shadowRoot;
860
+ const insertionAnchor = parentComp ? this._getStyleAnchor(parentComp) || this._getStyleAnchor(this._def) : this._getRootStyleInsertionAnchor(root);
861
+ let last = null;
862
+ for (let i = styles.length - 1; i >= 0; i--) {
863
+ const s = document.createElement("style");
864
+ if (nonce) s.setAttribute("nonce", nonce);
865
+ s.textContent = styles[i];
866
+ root.insertBefore(s, last || insertionAnchor);
867
+ last = s;
868
+ if (i === 0) {
869
+ if (!parentComp) this._styleAnchors.set(this._def, s);
870
+ if (owner) this._styleAnchors.set(owner, s);
871
+ }
872
+ if (!!(process.env.NODE_ENV !== "production")) if (owner) {
873
+ if (owner.__hmrId) {
874
+ if (!this._childStyles) this._childStyles = /* @__PURE__ */ new Map();
875
+ let entry = this._childStyles.get(owner.__hmrId);
876
+ if (!entry) this._childStyles.set(owner.__hmrId, entry = []);
877
+ entry.push(s);
878
+ }
879
+ } else (this._styles || (this._styles = [])).push(s);
880
+ }
881
+ }
882
+ _getStyleAnchor(comp) {
883
+ if (!comp) return null;
884
+ const anchor = this._styleAnchors.get(comp);
885
+ if (anchor && anchor.parentNode === this.shadowRoot) return anchor;
886
+ if (anchor) this._styleAnchors.delete(comp);
887
+ return null;
888
+ }
889
+ _getRootStyleInsertionAnchor(root) {
890
+ for (let i = 0; i < root.childNodes.length; i++) {
891
+ const node = root.childNodes[i];
892
+ if (!(node instanceof HTMLStyleElement)) return node;
893
+ }
894
+ return null;
895
+ }
896
+ /**
897
+ * Only called when shadowRoot is false
898
+ */
899
+ _parseSlots() {
900
+ const slots = this._slots = {};
901
+ let n;
902
+ while (n = this.firstChild) {
903
+ const slotName = n.nodeType === 1 && n.getAttribute("slot") || "default";
904
+ (slots[slotName] || (slots[slotName] = [])).push(n);
905
+ this.removeChild(n);
906
+ }
907
+ }
908
+ /**
909
+ * Only called when shadowRoot is false
910
+ */
911
+ _renderSlots() {
912
+ const outlets = this._getSlots();
913
+ const scopeId = this._instance.type.__scopeId;
914
+ const slotReplacements = /* @__PURE__ */ new Map();
915
+ for (let i = 0; i < outlets.length; i++) {
916
+ const o = outlets[i];
917
+ const slotName = o.getAttribute("name") || "default";
918
+ const content = this._slots[slotName];
919
+ const parent = o.parentNode;
920
+ const replacementNodes = [];
921
+ if (content) for (const n of content) {
922
+ if (scopeId && n.nodeType === 1) {
923
+ const id = scopeId + "-s";
924
+ const walker = document.createTreeWalker(n, 1);
925
+ n.setAttribute(id, "");
926
+ let child;
927
+ while (child = walker.nextNode()) child.setAttribute(id, "");
928
+ }
929
+ parent.insertBefore(n, o);
930
+ replacementNodes.push(n);
931
+ }
932
+ else while (o.firstChild) {
933
+ const child = o.firstChild;
934
+ parent.insertBefore(child, o);
935
+ replacementNodes.push(child);
936
+ }
937
+ parent.removeChild(o);
938
+ slotReplacements.set(o, replacementNodes);
939
+ }
940
+ this._updateSlotNodes(slotReplacements);
941
+ }
942
+ /**
943
+ * @internal
944
+ */
945
+ _getSlots() {
946
+ const roots = [this];
947
+ if (this._teleportTargets) roots.push(...this._teleportTargets);
948
+ const slots = /* @__PURE__ */ new Set();
949
+ for (const root of roots) {
950
+ const found = root.querySelectorAll("slot");
951
+ for (let i = 0; i < found.length; i++) slots.add(found[i]);
952
+ }
953
+ return Array.from(slots);
954
+ }
955
+ /**
956
+ * @internal
957
+ */
958
+ _injectChildStyle(comp, parentComp) {
959
+ this._applyStyles(comp.styles, comp, parentComp);
960
+ }
961
+ /**
962
+ * @internal
963
+ */
964
+ _beginPatch() {
965
+ this._patching = true;
966
+ this._dirty = false;
967
+ }
968
+ /**
969
+ * @internal
970
+ */
971
+ _endPatch() {
972
+ this._patching = false;
973
+ if (this._dirty && this._instance) this._update();
974
+ }
975
+ /**
976
+ * @internal
977
+ */
978
+ _hasShadowRoot() {
979
+ return this._def.shadowRoot !== false;
980
+ }
981
+ /**
982
+ * @internal
983
+ */
984
+ _removeChildStyle(comp) {
985
+ if (!!(process.env.NODE_ENV !== "production")) {
986
+ this._styleChildren.delete(comp);
987
+ this._styleAnchors.delete(comp);
988
+ if (this._childStyles && comp.__hmrId) {
989
+ const oldStyles = this._childStyles.get(comp.__hmrId);
990
+ if (oldStyles) {
991
+ oldStyles.forEach((s) => this._root.removeChild(s));
992
+ oldStyles.length = 0;
993
+ }
994
+ }
995
+ }
996
+ }
997
+ };
998
+ var VueElement = class extends VueElementBase {
999
+ constructor(def, props = {}, createAppFn = createApp) {
1000
+ super(def, props, createAppFn);
1001
+ }
1002
+ _needsHydration() {
1003
+ if (this.shadowRoot && this._createApp !== createApp) return true;
1004
+ else if (!!(process.env.NODE_ENV !== "production") && this.shadowRoot) warn("Custom element has pre-rendered declarative shadow root but is not defined as hydratable. Use `defineSSRCustomElement`.");
1005
+ return false;
1006
+ }
1007
+ _mount(def) {
1008
+ if ((!!(process.env.NODE_ENV !== "production") || __VUE_PROD_DEVTOOLS__) && !def.name) def.name = "VueElement";
1009
+ this._app = this._createApp(def);
1010
+ this._inheritParentContext();
1011
+ if (def.configureApp) def.configureApp(this._app);
1012
+ this._app._ceVNode = this._createVNode();
1013
+ this._app.mount(this._root);
1014
+ }
1015
+ _update() {
1016
+ if (!this._app) return;
1017
+ const vnode = this._createVNode();
1018
+ vnode.appContext = this._app._context;
1019
+ render(vnode, this._root);
1020
+ }
1021
+ _unmount() {
1022
+ if (this._app) this._app.unmount();
1023
+ if (this._instance && this._instance.ce) this._instance.ce = void 0;
1024
+ this._app = this._instance = null;
1025
+ }
1026
+ /**
1027
+ * Only called when shadowRoot is false
1028
+ */
1029
+ _updateSlotNodes(replacements) {}
1030
+ _createVNode() {
1031
+ const baseProps = {};
1032
+ if (!this.shadowRoot) baseProps.onVnodeMounted = baseProps.onVnodeUpdated = this._renderSlots.bind(this);
1033
+ const vnode = createVNode(this._def, extend(baseProps, this._props));
1034
+ if (!this._instance) vnode.ce = (instance) => {
1035
+ this._instance = instance;
1036
+ this._processInstance();
1037
+ };
1038
+ return vnode;
1039
+ }
842
1040
  };
843
- class VueElementBase extends BaseClass {
844
- constructor(def, props = {}, createAppFn) {
845
- super();
846
- this._isVueCE = true;
847
- /**
848
- * @internal
849
- */
850
- this._instance = null;
851
- /**
852
- * @internal
853
- */
854
- this._app = null;
855
- this._connected = false;
856
- this._resolved = false;
857
- this._numberProps = null;
858
- this._styleChildren = /* @__PURE__ */ new WeakSet();
859
- this._patching = false;
860
- this._dirty = false;
861
- this._ob = null;
862
- this._def = def;
863
- this._props = props;
864
- this._createApp = createAppFn;
865
- this._nonce = def.nonce;
866
- if (this._needsHydration()) {
867
- this._root = this.shadowRoot;
868
- } else {
869
- if (def.shadowRoot !== false) {
870
- this.attachShadow(
871
- extend({}, def.shadowRootOptions, {
872
- mode: "open"
873
- })
874
- );
875
- this._root = this.shadowRoot;
876
- } else {
877
- this._root = this;
878
- }
879
- }
880
- }
881
- connectedCallback() {
882
- if (!this.isConnected) return;
883
- if (!this.shadowRoot && !this._resolved) {
884
- this._parseSlots();
885
- }
886
- this._connected = true;
887
- let parent = this;
888
- while (parent = parent && (parent.parentNode || parent.host)) {
889
- if (parent instanceof VueElementBase) {
890
- this._parent = parent;
891
- break;
892
- }
893
- }
894
- if (!this._instance) {
895
- if (this._resolved) {
896
- this._mountComponent(this._def);
897
- } else {
898
- if (parent && parent._pendingResolve) {
899
- this._pendingResolve = parent._pendingResolve.then(() => {
900
- this._pendingResolve = void 0;
901
- this._resolveDef();
902
- });
903
- } else {
904
- this._resolveDef();
905
- }
906
- }
907
- }
908
- }
909
- disconnectedCallback() {
910
- this._connected = false;
911
- nextTick(() => {
912
- if (!this._connected) {
913
- if (this._ob) {
914
- this._ob.disconnect();
915
- this._ob = null;
916
- }
917
- this._unmount();
918
- if (this._teleportTargets) {
919
- this._teleportTargets.clear();
920
- this._teleportTargets = void 0;
921
- }
922
- }
923
- });
924
- }
925
- _setParent(parent = this._parent) {
926
- if (parent && this._instance) {
927
- this._instance.parent = parent._instance;
928
- this._inheritParentContext(parent);
929
- }
930
- }
931
- _inheritParentContext(parent = this._parent) {
932
- if (parent && this._app) {
933
- Object.setPrototypeOf(
934
- this._app._context.provides,
935
- parent._instance.provides
936
- );
937
- }
938
- }
939
- _processMutations(mutations) {
940
- for (const m of mutations) {
941
- this._setAttr(m.attributeName);
942
- }
943
- }
944
- /**
945
- * resolve inner component definition (handle possible async component)
946
- */
947
- _resolveDef() {
948
- if (this._pendingResolve) {
949
- return;
950
- }
951
- for (let i = 0; i < this.attributes.length; i++) {
952
- this._setAttr(this.attributes[i].name);
953
- }
954
- this._ob = new MutationObserver(this._processMutations.bind(this));
955
- this._ob.observe(this, { attributes: true });
956
- const resolve = (def) => {
957
- this._resolved = true;
958
- this._pendingResolve = void 0;
959
- const { props, styles } = def;
960
- let numberProps;
961
- if (props && !isArray(props)) {
962
- for (const key in props) {
963
- const opt = props[key];
964
- if (opt === Number || opt && opt.type === Number) {
965
- if (key in this._props) {
966
- this._props[key] = toNumber(this._props[key]);
967
- }
968
- (numberProps || (numberProps = /* @__PURE__ */ Object.create(null)))[camelize$1(key)] = true;
969
- }
970
- }
971
- }
972
- this._numberProps = numberProps;
973
- this._resolveProps(def);
974
- if (this.shadowRoot) {
975
- this._applyStyles(styles);
976
- } else if (!!(process.env.NODE_ENV !== "production") && styles) {
977
- warn(
978
- "Custom element style injection is not supported when using shadowRoot: false"
979
- );
980
- }
981
- this._mountComponent(def);
982
- };
983
- const asyncDef = this._def.__asyncLoader;
984
- if (asyncDef) {
985
- const { configureApp } = this._def;
986
- this._pendingResolve = asyncDef().then((def) => {
987
- def.configureApp = configureApp;
988
- this._def = def;
989
- resolve(def);
990
- });
991
- } else {
992
- resolve(this._def);
993
- }
994
- }
995
- _mountComponent(def) {
996
- this._mount(def);
997
- this._processExposed();
998
- }
999
- _processExposed() {
1000
- const exposed = this._instance && this._instance.exposed;
1001
- if (!exposed) return;
1002
- for (const key in exposed) {
1003
- if (!hasOwn(this, key)) {
1004
- Object.defineProperty(this, key, {
1005
- // unwrap ref to be consistent with public instance behavior
1006
- get: () => unref(exposed[key])
1007
- });
1008
- } else if (!!(process.env.NODE_ENV !== "production")) {
1009
- warn(`Exposed property "${key}" already exists on custom element.`);
1010
- }
1011
- }
1012
- }
1013
- _processInstance() {
1014
- this._instance.ce = this;
1015
- this._instance.isCE = true;
1016
- if (!!(process.env.NODE_ENV !== "production")) {
1017
- this._instance.ceReload = (newStyles) => {
1018
- if (this._styles) {
1019
- this._styles.forEach((s) => this._root.removeChild(s));
1020
- this._styles.length = 0;
1021
- }
1022
- this._applyStyles(newStyles);
1023
- if (!this._instance.vapor) {
1024
- this._instance = null;
1025
- }
1026
- this._update();
1027
- };
1028
- }
1029
- const dispatch = (event, args) => {
1030
- this.dispatchEvent(
1031
- new CustomEvent(
1032
- event,
1033
- isPlainObject(args[0]) ? extend({ detail: args }, args[0]) : { detail: args }
1034
- )
1035
- );
1036
- };
1037
- this._instance.emit = (event, ...args) => {
1038
- dispatch(event, args);
1039
- if (hyphenate(event) !== event) {
1040
- dispatch(hyphenate(event), args);
1041
- }
1042
- };
1043
- this._setParent();
1044
- }
1045
- _resolveProps(def) {
1046
- const { props } = def;
1047
- const declaredPropKeys = isArray(props) ? props : Object.keys(props || {});
1048
- for (const key of Object.keys(this)) {
1049
- if (key[0] !== "_" && declaredPropKeys.includes(key)) {
1050
- this._setProp(key, this[key]);
1051
- }
1052
- }
1053
- for (const key of declaredPropKeys.map(camelize$1)) {
1054
- Object.defineProperty(this, key, {
1055
- get() {
1056
- return this._getProp(key);
1057
- },
1058
- set(val) {
1059
- this._setProp(key, val, true, !this._patching);
1060
- }
1061
- });
1062
- }
1063
- }
1064
- _setAttr(key) {
1065
- if (key.startsWith("data-v-")) return;
1066
- const has = this.hasAttribute(key);
1067
- let value = has ? this.getAttribute(key) : REMOVAL;
1068
- const camelKey = camelize$1(key);
1069
- if (has && this._numberProps && this._numberProps[camelKey]) {
1070
- value = toNumber(value);
1071
- }
1072
- this._setProp(camelKey, value, false, true);
1073
- }
1074
- /**
1075
- * @internal
1076
- */
1077
- _getProp(key) {
1078
- return this._props[key];
1079
- }
1080
- /**
1081
- * @internal
1082
- */
1083
- _setProp(key, val, shouldReflect = true, shouldUpdate = false) {
1084
- if (val !== this._props[key]) {
1085
- this._dirty = true;
1086
- if (val === REMOVAL) {
1087
- delete this._props[key];
1088
- } else {
1089
- this._props[key] = val;
1090
- if (key === "key" && this._app && this._app._ceVNode) {
1091
- this._app._ceVNode.key = val;
1092
- }
1093
- }
1094
- if (shouldUpdate && this._instance) {
1095
- this._update();
1096
- }
1097
- if (shouldReflect) {
1098
- const ob = this._ob;
1099
- if (ob) {
1100
- this._processMutations(ob.takeRecords());
1101
- ob.disconnect();
1102
- }
1103
- if (val === true) {
1104
- this.setAttribute(hyphenate(key), "");
1105
- } else if (typeof val === "string" || typeof val === "number") {
1106
- this.setAttribute(hyphenate(key), val + "");
1107
- } else if (!val) {
1108
- this.removeAttribute(hyphenate(key));
1109
- }
1110
- ob && ob.observe(this, { attributes: true });
1111
- }
1112
- }
1113
- }
1114
- _applyStyles(styles, owner) {
1115
- if (!styles) return;
1116
- if (owner) {
1117
- if (owner === this._def || this._styleChildren.has(owner)) {
1118
- return;
1119
- }
1120
- this._styleChildren.add(owner);
1121
- }
1122
- const nonce = this._nonce;
1123
- for (let i = styles.length - 1; i >= 0; i--) {
1124
- const s = document.createElement("style");
1125
- if (nonce) s.setAttribute("nonce", nonce);
1126
- s.textContent = styles[i];
1127
- this.shadowRoot.prepend(s);
1128
- if (!!(process.env.NODE_ENV !== "production")) {
1129
- if (owner) {
1130
- if (owner.__hmrId) {
1131
- if (!this._childStyles) this._childStyles = /* @__PURE__ */ new Map();
1132
- let entry = this._childStyles.get(owner.__hmrId);
1133
- if (!entry) {
1134
- this._childStyles.set(owner.__hmrId, entry = []);
1135
- }
1136
- entry.push(s);
1137
- }
1138
- } else {
1139
- (this._styles || (this._styles = [])).push(s);
1140
- }
1141
- }
1142
- }
1143
- }
1144
- /**
1145
- * Only called when shadowRoot is false
1146
- */
1147
- _parseSlots() {
1148
- const slots = this._slots = {};
1149
- let n;
1150
- while (n = this.firstChild) {
1151
- const slotName = n.nodeType === 1 && n.getAttribute("slot") || "default";
1152
- (slots[slotName] || (slots[slotName] = [])).push(n);
1153
- this.removeChild(n);
1154
- }
1155
- }
1156
- /**
1157
- * Only called when shadowRoot is false
1158
- */
1159
- _renderSlots() {
1160
- const outlets = this._getSlots();
1161
- const scopeId = this._instance.type.__scopeId;
1162
- const slotReplacements = /* @__PURE__ */ new Map();
1163
- for (let i = 0; i < outlets.length; i++) {
1164
- const o = outlets[i];
1165
- const slotName = o.getAttribute("name") || "default";
1166
- const content = this._slots[slotName];
1167
- const parent = o.parentNode;
1168
- const replacementNodes = [];
1169
- if (content) {
1170
- for (const n of content) {
1171
- if (scopeId && n.nodeType === 1) {
1172
- const id = scopeId + "-s";
1173
- const walker = document.createTreeWalker(n, 1);
1174
- n.setAttribute(id, "");
1175
- let child;
1176
- while (child = walker.nextNode()) {
1177
- child.setAttribute(id, "");
1178
- }
1179
- }
1180
- parent.insertBefore(n, o);
1181
- replacementNodes.push(n);
1182
- }
1183
- } else {
1184
- while (o.firstChild) {
1185
- const child = o.firstChild;
1186
- parent.insertBefore(child, o);
1187
- replacementNodes.push(child);
1188
- }
1189
- }
1190
- parent.removeChild(o);
1191
- slotReplacements.set(o, replacementNodes);
1192
- }
1193
- this._updateSlotNodes(slotReplacements);
1194
- }
1195
- /**
1196
- * @internal
1197
- */
1198
- _getSlots() {
1199
- const roots = [this];
1200
- if (this._teleportTargets) {
1201
- roots.push(...this._teleportTargets);
1202
- }
1203
- const slots = /* @__PURE__ */ new Set();
1204
- for (const root of roots) {
1205
- const found = root.querySelectorAll("slot");
1206
- for (let i = 0; i < found.length; i++) {
1207
- slots.add(found[i]);
1208
- }
1209
- }
1210
- return Array.from(slots);
1211
- }
1212
- /**
1213
- * @internal
1214
- */
1215
- _injectChildStyle(comp) {
1216
- this._applyStyles(comp.styles, comp);
1217
- }
1218
- /**
1219
- * @internal
1220
- */
1221
- _beginPatch() {
1222
- this._patching = true;
1223
- this._dirty = false;
1224
- }
1225
- /**
1226
- * @internal
1227
- */
1228
- _endPatch() {
1229
- this._patching = false;
1230
- if (this._dirty && this._instance) {
1231
- this._update();
1232
- }
1233
- }
1234
- /**
1235
- * @internal
1236
- */
1237
- _removeChildStyle(comp) {
1238
- if (!!(process.env.NODE_ENV !== "production")) {
1239
- this._styleChildren.delete(comp);
1240
- if (this._childStyles && comp.__hmrId) {
1241
- const oldStyles = this._childStyles.get(comp.__hmrId);
1242
- if (oldStyles) {
1243
- oldStyles.forEach((s) => this._root.removeChild(s));
1244
- oldStyles.length = 0;
1245
- }
1246
- }
1247
- }
1248
- }
1249
- }
1250
- class VueElement extends VueElementBase {
1251
- constructor(def, props = {}, createAppFn = createApp) {
1252
- super(def, props, createAppFn);
1253
- }
1254
- _needsHydration() {
1255
- if (this.shadowRoot && this._createApp !== createApp) {
1256
- return true;
1257
- } else {
1258
- if (!!(process.env.NODE_ENV !== "production") && this.shadowRoot) {
1259
- warn(
1260
- `Custom element has pre-rendered declarative shadow root but is not defined as hydratable. Use \`defineSSRCustomElement\`.`
1261
- );
1262
- }
1263
- }
1264
- return false;
1265
- }
1266
- _mount(def) {
1267
- if ((!!(process.env.NODE_ENV !== "production") || __VUE_PROD_DEVTOOLS__) && !def.name) {
1268
- def.name = "VueElement";
1269
- }
1270
- this._app = this._createApp(def);
1271
- this._inheritParentContext();
1272
- if (def.configureApp) {
1273
- def.configureApp(this._app);
1274
- }
1275
- this._app._ceVNode = this._createVNode();
1276
- this._app.mount(this._root);
1277
- }
1278
- _update() {
1279
- if (!this._app) return;
1280
- const vnode = this._createVNode();
1281
- vnode.appContext = this._app._context;
1282
- render(vnode, this._root);
1283
- }
1284
- _unmount() {
1285
- if (this._app) {
1286
- this._app.unmount();
1287
- }
1288
- if (this._instance && this._instance.ce) {
1289
- this._instance.ce = void 0;
1290
- }
1291
- this._app = this._instance = null;
1292
- }
1293
- /**
1294
- * Only called when shadowRoot is false
1295
- */
1296
- _updateSlotNodes(replacements) {
1297
- }
1298
- _createVNode() {
1299
- const baseProps = {};
1300
- if (!this.shadowRoot) {
1301
- baseProps.onVnodeMounted = baseProps.onVnodeUpdated = this._renderSlots.bind(this);
1302
- }
1303
- const vnode = createVNode(this._def, extend(baseProps, this._props));
1304
- if (!this._instance) {
1305
- vnode.ce = (instance) => {
1306
- this._instance = instance;
1307
- this._processInstance();
1308
- };
1309
- }
1310
- return vnode;
1311
- }
1312
- }
1313
1041
  function useHost(caller) {
1314
- const { hasInstance, value } = useInstanceOption("ce", true);
1315
- const el = value;
1316
- if (el) {
1317
- return el;
1318
- } else if (!!(process.env.NODE_ENV !== "production")) {
1319
- if (!hasInstance) {
1320
- warn(
1321
- `${caller || "useHost"} called without an active component instance.`
1322
- );
1323
- } else {
1324
- warn(
1325
- `${caller || "useHost"} can only be used in components defined via defineCustomElement.`
1326
- );
1327
- }
1328
- }
1329
- return null;
1042
+ const { hasInstance, value } = useInstanceOption("ce", true);
1043
+ const el = value;
1044
+ if (el) return el;
1045
+ else if (!!(process.env.NODE_ENV !== "production")) if (!hasInstance) warn(`${caller || "useHost"} called without an active component instance.`);
1046
+ else warn(`${caller || "useHost"} can only be used in components defined via defineCustomElement.`);
1047
+ return null;
1330
1048
  }
1049
+ /**
1050
+ * Retrieve the shadowRoot of the current custom element. Only usable in setup()
1051
+ * of a `defineCustomElement` component.
1052
+ */
1331
1053
  function useShadowRoot() {
1332
- const el = !!(process.env.NODE_ENV !== "production") ? useHost("useShadowRoot") : useHost();
1333
- return el && el.shadowRoot;
1054
+ const el = !!(process.env.NODE_ENV !== "production") ? useHost("useShadowRoot") : useHost();
1055
+ return el && el.shadowRoot;
1334
1056
  }
1335
-
1057
+ //#endregion
1058
+ //#region packages/runtime-dom/src/helpers/useCssModule.ts
1336
1059
  function useCssModule(name = "$style") {
1337
- {
1338
- const { hasInstance, value: type } = useInstanceOption("type", true);
1339
- if (!hasInstance) {
1340
- !!(process.env.NODE_ENV !== "production") && warn(`useCssModule must be called inside setup()`);
1341
- return EMPTY_OBJ;
1342
- }
1343
- const modules = type.__cssModules;
1344
- if (!modules) {
1345
- !!(process.env.NODE_ENV !== "production") && warn(`Current instance does not have CSS modules injected.`);
1346
- return EMPTY_OBJ;
1347
- }
1348
- const mod = modules[name];
1349
- if (!mod) {
1350
- !!(process.env.NODE_ENV !== "production") && warn(`Current instance does not have CSS module named "${name}".`);
1351
- return EMPTY_OBJ;
1352
- }
1353
- return mod;
1354
- }
1060
+ {
1061
+ const { hasInstance, value: type } = useInstanceOption("type", true);
1062
+ if (!hasInstance) {
1063
+ process.env.NODE_ENV !== "production" && warn(`useCssModule must be called inside setup()`);
1064
+ return EMPTY_OBJ;
1065
+ }
1066
+ const modules = type.__cssModules;
1067
+ if (!modules) {
1068
+ process.env.NODE_ENV !== "production" && warn(`Current instance does not have CSS modules injected.`);
1069
+ return EMPTY_OBJ;
1070
+ }
1071
+ const mod = modules[name];
1072
+ if (!mod) {
1073
+ process.env.NODE_ENV !== "production" && warn(`Current instance does not have CSS module named "${name}".`);
1074
+ return EMPTY_OBJ;
1075
+ }
1076
+ return mod;
1077
+ }
1355
1078
  }
1356
-
1079
+ //#endregion
1080
+ //#region packages/runtime-dom/src/components/TransitionGroup.ts
1357
1081
  const positionMap = /* @__PURE__ */ new WeakMap();
1358
1082
  const newPositionMap = /* @__PURE__ */ new WeakMap();
1359
1083
  const moveCbKey = Symbol("_moveCb");
1360
1084
  const enterCbKey = Symbol("_enterCb");
1085
+ /**
1086
+ * Wrap logic that modifies TransitionGroup properties in a function
1087
+ * so that it can be annotated as pure
1088
+ */
1361
1089
  const decorate = (t) => {
1362
- delete t.props.mode;
1363
- return t;
1090
+ delete t.props.mode;
1091
+ return t;
1364
1092
  };
1365
- const TransitionGroupImpl = /* @__PURE__ */ decorate({
1366
- name: "TransitionGroup",
1367
- props: /* @__PURE__ */ extend({}, TransitionPropsValidators, {
1368
- tag: String,
1369
- moveClass: String
1370
- }),
1371
- setup(props, { slots }) {
1372
- const instance = getCurrentInstance();
1373
- const state = useTransitionState();
1374
- let prevChildren;
1375
- let children;
1376
- onUpdated(() => {
1377
- if (!prevChildren.length) {
1378
- return;
1379
- }
1380
- const moveClass = props.moveClass || `${props.name || "v"}-move`;
1381
- if (!hasCSSTransform(
1382
- prevChildren[0].el,
1383
- instance.vnode.el,
1384
- moveClass
1385
- )) {
1386
- prevChildren = [];
1387
- return;
1388
- }
1389
- prevChildren.forEach((vnode) => callPendingCbs(vnode.el));
1390
- prevChildren.forEach(recordPosition);
1391
- const movedChildren = prevChildren.filter(applyTranslation);
1392
- forceReflow(instance.vnode.el);
1393
- movedChildren.forEach((c) => {
1394
- const el = c.el;
1395
- handleMovedChildren(el, moveClass);
1396
- });
1397
- prevChildren = [];
1398
- });
1399
- return () => {
1400
- const rawProps = toRaw(props);
1401
- const cssTransitionProps = resolveTransitionProps(rawProps);
1402
- let tag = rawProps.tag || Fragment;
1403
- prevChildren = [];
1404
- if (children) {
1405
- for (let i = 0; i < children.length; i++) {
1406
- const child = children[i];
1407
- if (child.el && child.el instanceof Element) {
1408
- prevChildren.push(child);
1409
- setTransitionHooks(
1410
- child,
1411
- resolveTransitionHooks(
1412
- child,
1413
- cssTransitionProps,
1414
- state,
1415
- instance
1416
- )
1417
- );
1418
- positionMap.set(child, {
1419
- left: child.el.offsetLeft,
1420
- top: child.el.offsetTop
1421
- });
1422
- }
1423
- }
1424
- }
1425
- children = slots.default ? getTransitionRawChildren(slots.default()) : [];
1426
- for (let i = 0; i < children.length; i++) {
1427
- const child = children[i];
1428
- if (child.key != null) {
1429
- setTransitionHooks(
1430
- child,
1431
- resolveTransitionHooks(child, cssTransitionProps, state, instance)
1432
- );
1433
- } else if (!!(process.env.NODE_ENV !== "production") && child.type !== Text) {
1434
- warn(`<TransitionGroup> children must be keyed.`);
1435
- }
1436
- }
1437
- return createVNode(tag, null, children);
1438
- };
1439
- }
1093
+ const TransitionGroup = /* @__PURE__ */ decorate({
1094
+ name: "TransitionGroup",
1095
+ props: /* @__PURE__ */ extend({}, TransitionPropsValidators, {
1096
+ tag: String,
1097
+ moveClass: String
1098
+ }),
1099
+ setup(props, { slots }) {
1100
+ const instance = getCurrentInstance();
1101
+ const state = useTransitionState();
1102
+ let prevChildren;
1103
+ let children;
1104
+ onUpdated(() => {
1105
+ if (!prevChildren.length) return;
1106
+ const moveClass = props.moveClass || `${props.name || "v"}-move`;
1107
+ if (!hasCSSTransform(prevChildren[0].el, instance.vnode.el, moveClass)) {
1108
+ prevChildren = [];
1109
+ return;
1110
+ }
1111
+ prevChildren.forEach((vnode) => callPendingCbs(vnode.el));
1112
+ prevChildren.forEach(recordPosition);
1113
+ const movedChildren = prevChildren.filter(applyTranslation);
1114
+ forceReflow(instance.vnode.el);
1115
+ movedChildren.forEach((c) => {
1116
+ const el = c.el;
1117
+ handleMovedChildren(el, moveClass);
1118
+ });
1119
+ prevChildren = [];
1120
+ });
1121
+ return () => {
1122
+ const rawProps = toRaw(props);
1123
+ const cssTransitionProps = resolveTransitionProps(rawProps);
1124
+ let tag = rawProps.tag || Fragment;
1125
+ prevChildren = [];
1126
+ if (children) for (let i = 0; i < children.length; i++) {
1127
+ const child = children[i];
1128
+ if (child.el && child.el instanceof Element) {
1129
+ prevChildren.push(child);
1130
+ setTransitionHooks(child, resolveTransitionHooks(child, cssTransitionProps, state, instance));
1131
+ positionMap.set(child, getPosition(child.el));
1132
+ }
1133
+ }
1134
+ children = slots.default ? getTransitionRawChildren(slots.default()) : [];
1135
+ for (let i = 0; i < children.length; i++) {
1136
+ const child = children[i];
1137
+ if (child.key != null) setTransitionHooks(child, resolveTransitionHooks(child, cssTransitionProps, state, instance));
1138
+ else if (!!(process.env.NODE_ENV !== "production") && child.type !== Text) warn(`<TransitionGroup> children must be keyed.`);
1139
+ }
1140
+ return createVNode(tag, null, children);
1141
+ };
1142
+ }
1440
1143
  });
1441
- const TransitionGroup = TransitionGroupImpl;
1442
1144
  function callPendingCbs(el) {
1443
- if (el[moveCbKey]) {
1444
- el[moveCbKey]();
1445
- }
1446
- if (el[enterCbKey]) {
1447
- el[enterCbKey]();
1448
- }
1145
+ if (el[moveCbKey]) el[moveCbKey]();
1146
+ if (el[enterCbKey]) el[enterCbKey]();
1449
1147
  }
1450
1148
  function recordPosition(c) {
1451
- newPositionMap.set(c, {
1452
- left: c.el.offsetLeft,
1453
- top: c.el.offsetTop
1454
- });
1149
+ newPositionMap.set(c, getPosition(c.el));
1455
1150
  }
1456
1151
  function applyTranslation(c) {
1457
- if (baseApplyTranslation(
1458
- positionMap.get(c),
1459
- newPositionMap.get(c),
1460
- c.el
1461
- )) {
1462
- return c;
1463
- }
1152
+ if (baseApplyTranslation(positionMap.get(c), newPositionMap.get(c), c.el)) return c;
1464
1153
  }
1465
1154
  function baseApplyTranslation(oldPos, newPos, el) {
1466
- const dx = oldPos.left - newPos.left;
1467
- const dy = oldPos.top - newPos.top;
1468
- if (dx || dy) {
1469
- const s = el.style;
1470
- s.transform = s.webkitTransform = `translate(${dx}px,${dy}px)`;
1471
- s.transitionDuration = "0s";
1472
- return true;
1473
- }
1474
- return false;
1155
+ const dx = oldPos.left - newPos.left;
1156
+ const dy = oldPos.top - newPos.top;
1157
+ if (dx || dy) {
1158
+ const s = el.style;
1159
+ const rect = el.getBoundingClientRect();
1160
+ let scaleX = 1;
1161
+ let scaleY = 1;
1162
+ if (el.offsetWidth) scaleX = rect.width / el.offsetWidth;
1163
+ if (el.offsetHeight) scaleY = rect.height / el.offsetHeight;
1164
+ if (!Number.isFinite(scaleX) || scaleX === 0) scaleX = 1;
1165
+ if (!Number.isFinite(scaleY) || scaleY === 0) scaleY = 1;
1166
+ if (Math.abs(scaleX - 1) < .01) scaleX = 1;
1167
+ if (Math.abs(scaleY - 1) < .01) scaleY = 1;
1168
+ s.transform = s.webkitTransform = `translate(${dx / scaleX}px,${dy / scaleY}px)`;
1169
+ s.transitionDuration = "0s";
1170
+ return true;
1171
+ }
1172
+ return false;
1173
+ }
1174
+ function getPosition(el) {
1175
+ const rect = el.getBoundingClientRect();
1176
+ return {
1177
+ left: rect.left,
1178
+ top: rect.top
1179
+ };
1475
1180
  }
1476
1181
  function hasCSSTransform(el, root, moveClass) {
1477
- const clone = el.cloneNode();
1478
- const _vtc = el[vtcKey];
1479
- if (_vtc) {
1480
- _vtc.forEach((cls) => {
1481
- cls.split(/\s+/).forEach((c) => c && clone.classList.remove(c));
1482
- });
1483
- }
1484
- moveClass.split(/\s+/).forEach((c) => c && clone.classList.add(c));
1485
- clone.style.display = "none";
1486
- const container = root.nodeType === 1 ? root : root.parentNode;
1487
- container.appendChild(clone);
1488
- const { hasTransform } = getTransitionInfo(clone);
1489
- container.removeChild(clone);
1490
- return hasTransform;
1182
+ const clone = el.cloneNode();
1183
+ const _vtc = el[vtcKey];
1184
+ if (_vtc) _vtc.forEach((cls) => {
1185
+ cls.split(/\s+/).forEach((c) => c && clone.classList.remove(c));
1186
+ });
1187
+ moveClass.split(/\s+/).forEach((c) => c && clone.classList.add(c));
1188
+ clone.style.display = "none";
1189
+ const container = root.nodeType === 1 ? root : root.parentNode;
1190
+ container.appendChild(clone);
1191
+ const { hasTransform } = getTransitionInfo(clone);
1192
+ container.removeChild(clone);
1193
+ return hasTransform;
1491
1194
  }
1492
1195
  const handleMovedChildren = (el, moveClass) => {
1493
- const style = el.style;
1494
- addTransitionClass(el, moveClass);
1495
- style.transform = style.webkitTransform = style.transitionDuration = "";
1496
- const cb = el[moveCbKey] = (e) => {
1497
- if (e && e.target !== el) {
1498
- return;
1499
- }
1500
- if (!e || e.propertyName.endsWith("transform")) {
1501
- el.removeEventListener("transitionend", cb);
1502
- el[moveCbKey] = null;
1503
- removeTransitionClass(el, moveClass);
1504
- }
1505
- };
1506
- el.addEventListener("transitionend", cb);
1196
+ const style = el.style;
1197
+ addTransitionClass(el, moveClass);
1198
+ style.transform = style.webkitTransform = style.transitionDuration = "";
1199
+ const cb = el[moveCbKey] = (e) => {
1200
+ if (e && e.target !== el) return;
1201
+ if (!e || e.propertyName.endsWith("transform")) {
1202
+ el.removeEventListener("transitionend", cb);
1203
+ el[moveCbKey] = null;
1204
+ removeTransitionClass(el, moveClass);
1205
+ }
1206
+ };
1207
+ el.addEventListener("transitionend", cb);
1507
1208
  };
1508
-
1209
+ //#endregion
1210
+ //#region packages/runtime-dom/src/directives/vModel.ts
1509
1211
  const getModelAssigner = (vnode) => {
1510
- const fn = vnode.props["onUpdate:modelValue"] || false;
1511
- return isArray(fn) ? (value) => invokeArrayFns(fn, value) : fn;
1212
+ const fn = vnode.props["onUpdate:modelValue"] || false;
1213
+ return isArray(fn) ? (value) => invokeArrayFns(fn, value) : fn;
1512
1214
  };
1513
1215
  function onCompositionStart(e) {
1514
- e.target.composing = true;
1216
+ e.target.composing = true;
1515
1217
  }
1516
1218
  function onCompositionEnd(e) {
1517
- const target = e.target;
1518
- if (target.composing) {
1519
- target.composing = false;
1520
- target.dispatchEvent(new Event("input"));
1521
- }
1219
+ const target = e.target;
1220
+ if (target.composing) {
1221
+ target.composing = false;
1222
+ target.dispatchEvent(new Event("input"));
1223
+ }
1522
1224
  }
1523
1225
  const assignKey = Symbol("_assign");
1524
1226
  const vModelText = {
1525
- created(el, { modifiers: { lazy, trim, number } }, vnode) {
1526
- el[assignKey] = getModelAssigner(vnode);
1527
- vModelTextInit(
1528
- el,
1529
- trim,
1530
- number || !!(vnode.props && vnode.props.type === "number"),
1531
- lazy
1532
- );
1533
- },
1534
- // set value on mounted so it's after min/max for type="range"
1535
- mounted(el, { value }) {
1536
- el.value = value == null ? "" : value;
1537
- },
1538
- beforeUpdate(el, { value, oldValue, modifiers: { lazy, trim, number } }, vnode) {
1539
- el[assignKey] = getModelAssigner(vnode);
1540
- vModelTextUpdate(el, oldValue, value, trim, number, lazy);
1541
- }
1227
+ created(el, { modifiers: { lazy, trim, number } }, vnode) {
1228
+ el[assignKey] = getModelAssigner(vnode);
1229
+ vModelTextInit(el, trim, number || !!(vnode.props && vnode.props.type === "number"), lazy);
1230
+ },
1231
+ mounted(el, { value }) {
1232
+ el.value = value == null ? "" : value;
1233
+ },
1234
+ beforeUpdate(el, { value, oldValue, modifiers: { lazy, trim, number } }, vnode) {
1235
+ el[assignKey] = getModelAssigner(vnode);
1236
+ vModelTextUpdate(el, oldValue, value, trim, number, lazy);
1237
+ }
1542
1238
  };
1543
1239
  function castValue(value, trim, number) {
1544
- if (trim) value = value.trim();
1545
- if (number) value = looseToNumber(value);
1546
- return value;
1240
+ if (trim) value = value.trim();
1241
+ if (number) value = looseToNumber(value);
1242
+ return value;
1547
1243
  }
1244
+ /**
1245
+ * @internal
1246
+ */
1548
1247
  const vModelTextInit = (el, trim, number, lazy, set) => {
1549
- addEventListener(el, lazy ? "change" : "input", (e) => {
1550
- if (e.target.composing) return;
1551
- (set || el[assignKey])(
1552
- castValue(el.value, trim, number || el.type === "number")
1553
- );
1554
- });
1555
- if (trim || number) {
1556
- addEventListener(el, "change", () => {
1557
- el.value = castValue(el.value, trim, number || el.type === "number");
1558
- });
1559
- }
1560
- if (!lazy) {
1561
- addEventListener(el, "compositionstart", onCompositionStart);
1562
- addEventListener(el, "compositionend", onCompositionEnd);
1563
- addEventListener(el, "change", onCompositionEnd);
1564
- }
1248
+ addEventListener(el, lazy ? "change" : "input", (e) => {
1249
+ if (e.target.composing) return;
1250
+ (set || el[assignKey])(castValue(el.value, trim, number || el.type === "number"));
1251
+ });
1252
+ if (trim || number) addEventListener(el, "change", () => {
1253
+ el.value = castValue(el.value, trim, number || el.type === "number");
1254
+ });
1255
+ if (!lazy) {
1256
+ addEventListener(el, "compositionstart", onCompositionStart);
1257
+ addEventListener(el, "compositionend", onCompositionEnd);
1258
+ addEventListener(el, "change", onCompositionEnd);
1259
+ }
1565
1260
  };
1261
+ /**
1262
+ * @internal
1263
+ */
1566
1264
  const vModelTextUpdate = (el, oldValue, value, trim, number, lazy) => {
1567
- if (el.composing) return;
1568
- const elValue = (number || el.type === "number") && !/^0\d/.test(el.value) ? looseToNumber(el.value) : el.value;
1569
- const newValue = value == null ? "" : value;
1570
- if (elValue === newValue) {
1571
- return;
1572
- }
1573
- if (document.activeElement === el && el.type !== "range") {
1574
- if (lazy && value === oldValue) {
1575
- return;
1576
- }
1577
- if (trim && el.value.trim() === newValue) {
1578
- return;
1579
- }
1580
- }
1581
- el.value = newValue;
1265
+ if (el.composing) return;
1266
+ const elValue = (number || el.type === "number") && !/^0\d/.test(el.value) ? looseToNumber(el.value) : el.value;
1267
+ const newValue = value == null ? "" : value;
1268
+ if (elValue === newValue) return;
1269
+ const rootNode = el.getRootNode();
1270
+ if ((rootNode instanceof Document || rootNode instanceof ShadowRoot) && rootNode.activeElement === el && el.type !== "range") {
1271
+ if (lazy && value === oldValue) return;
1272
+ if (trim && el.value.trim() === newValue) return;
1273
+ }
1274
+ el.value = newValue;
1582
1275
  };
1583
1276
  const vModelCheckbox = {
1584
- // #4096 array checkboxes need to be deep traversed
1585
- deep: true,
1586
- created(el, _, vnode) {
1587
- el[assignKey] = getModelAssigner(vnode);
1588
- vModelCheckboxInit(el);
1589
- },
1590
- // set initial checked on mount to wait for true-value/false-value
1591
- mounted(el, binding, vnode) {
1592
- vModelCheckboxUpdate(
1593
- el,
1594
- binding.oldValue,
1595
- binding.value,
1596
- vnode.props.value
1597
- );
1598
- },
1599
- beforeUpdate(el, binding, vnode) {
1600
- el[assignKey] = getModelAssigner(vnode);
1601
- vModelCheckboxUpdate(
1602
- el,
1603
- binding.oldValue,
1604
- binding.value,
1605
- vnode.props.value
1606
- );
1607
- }
1277
+ deep: true,
1278
+ created(el, _, vnode) {
1279
+ el[assignKey] = getModelAssigner(vnode);
1280
+ vModelCheckboxInit(el);
1281
+ },
1282
+ mounted(el, binding, vnode) {
1283
+ vModelCheckboxUpdate(el, binding.oldValue, binding.value, vnode.props.value);
1284
+ },
1285
+ beforeUpdate(el, binding, vnode) {
1286
+ el[assignKey] = getModelAssigner(vnode);
1287
+ vModelCheckboxUpdate(el, binding.oldValue, binding.value, vnode.props.value);
1288
+ }
1608
1289
  };
1290
+ /**
1291
+ * @internal
1292
+ */
1609
1293
  const vModelCheckboxInit = (el, set) => {
1610
- addEventListener(el, "change", () => {
1611
- const assign = set || el[assignKey];
1612
- const modelValue = el._modelValue;
1613
- const elementValue = getValue(el);
1614
- const checked = el.checked;
1615
- if (isArray(modelValue)) {
1616
- const index = looseIndexOf(modelValue, elementValue);
1617
- const found = index !== -1;
1618
- if (checked && !found) {
1619
- assign(modelValue.concat(elementValue));
1620
- } else if (!checked && found) {
1621
- const filtered = [...modelValue];
1622
- filtered.splice(index, 1);
1623
- assign(filtered);
1624
- }
1625
- } else if (isSet(modelValue)) {
1626
- const cloned = new Set(modelValue);
1627
- if (checked) {
1628
- cloned.add(elementValue);
1629
- } else {
1630
- cloned.delete(elementValue);
1631
- }
1632
- assign(cloned);
1633
- } else {
1634
- assign(getCheckboxValue(el, checked));
1635
- }
1636
- });
1294
+ addEventListener(el, "change", () => {
1295
+ const assign = set || el[assignKey];
1296
+ const modelValue = el._modelValue;
1297
+ const elementValue = getValue(el);
1298
+ const checked = el.checked;
1299
+ if (isArray(modelValue)) {
1300
+ const index = looseIndexOf(modelValue, elementValue);
1301
+ const found = index !== -1;
1302
+ if (checked && !found) assign(modelValue.concat(elementValue));
1303
+ else if (!checked && found) {
1304
+ const filtered = [...modelValue];
1305
+ filtered.splice(index, 1);
1306
+ assign(filtered);
1307
+ }
1308
+ } else if (isSet(modelValue)) {
1309
+ const cloned = new Set(modelValue);
1310
+ if (checked) cloned.add(elementValue);
1311
+ else cloned.delete(elementValue);
1312
+ assign(cloned);
1313
+ } else assign(getCheckboxValue(el, checked));
1314
+ });
1637
1315
  };
1316
+ /**
1317
+ * @internal
1318
+ */
1638
1319
  const vModelCheckboxUpdate = (el, oldValue, value, rawValue = getValue(el)) => {
1639
- el._modelValue = value;
1640
- let checked;
1641
- if (isArray(value)) {
1642
- checked = looseIndexOf(value, rawValue) > -1;
1643
- } else if (isSet(value)) {
1644
- checked = value.has(rawValue);
1645
- } else {
1646
- if (value === oldValue) return;
1647
- checked = looseEqual(value, getCheckboxValue(el, true));
1648
- }
1649
- if (el.checked !== checked) {
1650
- el.checked = checked;
1651
- }
1320
+ el._modelValue = value;
1321
+ let checked;
1322
+ if (isArray(value)) checked = looseIndexOf(value, rawValue) > -1;
1323
+ else if (isSet(value)) checked = value.has(rawValue);
1324
+ else {
1325
+ if (value === oldValue) return;
1326
+ checked = looseEqual(value, getCheckboxValue(el, true));
1327
+ }
1328
+ if (el.checked !== checked) el.checked = checked;
1652
1329
  };
1653
1330
  const vModelRadio = {
1654
- created(el, { value }, vnode) {
1655
- el.checked = looseEqual(value, vnode.props.value);
1656
- el[assignKey] = getModelAssigner(vnode);
1657
- addEventListener(el, "change", () => {
1658
- el[assignKey](getValue(el));
1659
- });
1660
- },
1661
- beforeUpdate(el, { value, oldValue }, vnode) {
1662
- el[assignKey] = getModelAssigner(vnode);
1663
- if (value !== oldValue) {
1664
- el.checked = looseEqual(value, vnode.props.value);
1665
- }
1666
- }
1331
+ created(el, { value }, vnode) {
1332
+ el.checked = looseEqual(value, vnode.props.value);
1333
+ el[assignKey] = getModelAssigner(vnode);
1334
+ addEventListener(el, "change", () => {
1335
+ el[assignKey](getValue(el));
1336
+ });
1337
+ },
1338
+ beforeUpdate(el, { value, oldValue }, vnode) {
1339
+ el[assignKey] = getModelAssigner(vnode);
1340
+ if (value !== oldValue) el.checked = looseEqual(value, vnode.props.value);
1341
+ }
1667
1342
  };
1668
1343
  const vModelSelect = {
1669
- // <select multiple> value need to be deep traversed
1670
- deep: true,
1671
- created(el, { value, modifiers: { number } }, vnode) {
1672
- vModelSelectInit(el, value, number);
1673
- el[assignKey] = getModelAssigner(vnode);
1674
- },
1675
- // set value in mounted & updated because <select> relies on its children
1676
- // <option>s.
1677
- mounted(el, { value }) {
1678
- vModelSetSelected(el, value);
1679
- },
1680
- beforeUpdate(el, _binding, vnode) {
1681
- el[assignKey] = getModelAssigner(vnode);
1682
- },
1683
- updated(el, { value }) {
1684
- vModelSetSelected(el, value);
1685
- }
1344
+ deep: true,
1345
+ created(el, { value, modifiers: { number } }, vnode) {
1346
+ vModelSelectInit(el, value, number);
1347
+ el[assignKey] = getModelAssigner(vnode);
1348
+ },
1349
+ mounted(el, { value }) {
1350
+ vModelSetSelected(el, value);
1351
+ },
1352
+ beforeUpdate(el, _binding, vnode) {
1353
+ el[assignKey] = getModelAssigner(vnode);
1354
+ },
1355
+ updated(el, { value }) {
1356
+ vModelSetSelected(el, value);
1357
+ }
1686
1358
  };
1359
+ /**
1360
+ * @internal
1361
+ */
1687
1362
  const vModelSelectInit = (el, value, number, set) => {
1688
- const isSetModel = isSet(value);
1689
- addEventListener(el, "change", () => {
1690
- const selectedVal = Array.prototype.filter.call(el.options, (o) => o.selected).map(
1691
- (o) => number ? looseToNumber(getValue(o)) : getValue(o)
1692
- );
1693
- (set || el[assignKey])(
1694
- el.multiple ? isSetModel ? new Set(selectedVal) : selectedVal : selectedVal[0]
1695
- );
1696
- el._assigning = true;
1697
- nextTick(() => {
1698
- el._assigning = false;
1699
- });
1700
- });
1363
+ const isSetModel = isSet(value);
1364
+ addEventListener(el, "change", () => {
1365
+ const selectedVal = Array.prototype.filter.call(el.options, (o) => o.selected).map((o) => number ? looseToNumber(getValue(o)) : getValue(o));
1366
+ (set || el[assignKey])(el.multiple ? isSetModel ? new Set(selectedVal) : selectedVal : selectedVal[0]);
1367
+ el._assigning = true;
1368
+ nextTick(() => {
1369
+ el._assigning = false;
1370
+ });
1371
+ });
1701
1372
  };
1373
+ /**
1374
+ * @internal
1375
+ */
1702
1376
  const vModelSetSelected = (el, value) => {
1703
- if (el._assigning) return;
1704
- const isMultiple = el.multiple;
1705
- const isArrayValue = isArray(value);
1706
- if (isMultiple && !isArrayValue && !isSet(value)) {
1707
- !!(process.env.NODE_ENV !== "production") && warn(
1708
- `<select multiple v-model> expects an Array or Set value for its binding, but got ${Object.prototype.toString.call(value).slice(8, -1)}.`
1709
- );
1710
- return;
1711
- }
1712
- for (let i = 0, l = el.options.length; i < l; i++) {
1713
- const option = el.options[i];
1714
- const optionValue = getValue(option);
1715
- if (isMultiple) {
1716
- if (isArrayValue) {
1717
- const optionType = typeof optionValue;
1718
- if (optionType === "string" || optionType === "number") {
1719
- option.selected = value.some((v) => String(v) === String(optionValue));
1720
- } else {
1721
- option.selected = looseIndexOf(value, optionValue) > -1;
1722
- }
1723
- } else {
1724
- option.selected = value.has(optionValue);
1725
- }
1726
- } else if (looseEqual(getValue(option), value)) {
1727
- if (el.selectedIndex !== i) el.selectedIndex = i;
1728
- return;
1729
- }
1730
- }
1731
- if (!isMultiple && el.selectedIndex !== -1) {
1732
- el.selectedIndex = -1;
1733
- }
1377
+ if (el._assigning) return;
1378
+ const isMultiple = el.multiple;
1379
+ const isArrayValue = isArray(value);
1380
+ if (isMultiple && !isArrayValue && !isSet(value)) {
1381
+ process.env.NODE_ENV !== "production" && warn(`<select multiple v-model> expects an Array or Set value for its binding, but got ${Object.prototype.toString.call(value).slice(8, -1)}.`);
1382
+ return;
1383
+ }
1384
+ for (let i = 0, l = el.options.length; i < l; i++) {
1385
+ const option = el.options[i];
1386
+ const optionValue = getValue(option);
1387
+ if (isMultiple) if (isArrayValue) {
1388
+ const optionType = typeof optionValue;
1389
+ if (optionType === "string" || optionType === "number") option.selected = value.some((v) => String(v) === String(optionValue));
1390
+ else option.selected = looseIndexOf(value, optionValue) > -1;
1391
+ } else option.selected = value.has(optionValue);
1392
+ else if (looseEqual(getValue(option), value)) {
1393
+ if (el.selectedIndex !== i) el.selectedIndex = i;
1394
+ return;
1395
+ }
1396
+ }
1397
+ if (!isMultiple && el.selectedIndex !== -1) el.selectedIndex = -1;
1734
1398
  };
1399
+ /**
1400
+ * @internal retrieve raw value set via :value bindings
1401
+ */
1735
1402
  function getValue(el) {
1736
- return "_value" in el ? el._value : el.value;
1403
+ return "_value" in el ? el._value : el.value;
1737
1404
  }
1738
1405
  function getCheckboxValue(el, checked) {
1739
- const key = checked ? "_trueValue" : "_falseValue";
1740
- if (key in el) {
1741
- return el[key];
1742
- }
1743
- const attr = checked ? "true-value" : "false-value";
1744
- if (el.hasAttribute(attr)) {
1745
- return el.getAttribute(attr);
1746
- }
1747
- return checked;
1406
+ const key = checked ? "_trueValue" : "_falseValue";
1407
+ if (key in el) return el[key];
1408
+ const attr = checked ? "true-value" : "false-value";
1409
+ if (el.hasAttribute(attr)) return el.getAttribute(attr);
1410
+ return checked;
1748
1411
  }
1749
1412
  const vModelDynamic = {
1750
- created(el, binding, vnode) {
1751
- callModelHook(el, binding, vnode, null, "created");
1752
- },
1753
- mounted(el, binding, vnode) {
1754
- callModelHook(el, binding, vnode, null, "mounted");
1755
- },
1756
- beforeUpdate(el, binding, vnode, prevVNode) {
1757
- callModelHook(el, binding, vnode, prevVNode, "beforeUpdate");
1758
- },
1759
- updated(el, binding, vnode, prevVNode) {
1760
- callModelHook(el, binding, vnode, prevVNode, "updated");
1761
- }
1413
+ created(el, binding, vnode) {
1414
+ callModelHook(el, binding, vnode, null, "created");
1415
+ },
1416
+ mounted(el, binding, vnode) {
1417
+ callModelHook(el, binding, vnode, null, "mounted");
1418
+ },
1419
+ beforeUpdate(el, binding, vnode, prevVNode) {
1420
+ callModelHook(el, binding, vnode, prevVNode, "beforeUpdate");
1421
+ },
1422
+ updated(el, binding, vnode, prevVNode) {
1423
+ callModelHook(el, binding, vnode, prevVNode, "updated");
1424
+ }
1762
1425
  };
1763
1426
  function resolveDynamicModel(tagName, type) {
1764
- switch (tagName) {
1765
- case "SELECT":
1766
- return vModelSelect;
1767
- case "TEXTAREA":
1768
- return vModelText;
1769
- default:
1770
- switch (type) {
1771
- case "checkbox":
1772
- return vModelCheckbox;
1773
- case "radio":
1774
- return vModelRadio;
1775
- default:
1776
- return vModelText;
1777
- }
1778
- }
1427
+ switch (tagName) {
1428
+ case "SELECT": return vModelSelect;
1429
+ case "TEXTAREA": return vModelText;
1430
+ default: switch (type) {
1431
+ case "checkbox": return vModelCheckbox;
1432
+ case "radio": return vModelRadio;
1433
+ default: return vModelText;
1434
+ }
1435
+ }
1779
1436
  }
1780
1437
  function callModelHook(el, binding, vnode, prevVNode, hook) {
1781
- const modelToUse = resolveDynamicModel(
1782
- el.tagName,
1783
- vnode.props && vnode.props.type
1784
- );
1785
- const fn = modelToUse[hook];
1786
- fn && fn(el, binding, vnode, prevVNode);
1438
+ const fn = resolveDynamicModel(el.tagName, vnode.props && vnode.props.type)[hook];
1439
+ fn && fn(el, binding, vnode, prevVNode);
1787
1440
  }
1788
1441
  function initVModelForSSR() {
1789
- vModelText.getSSRProps = ({ value }) => ({ value });
1790
- vModelRadio.getSSRProps = ({ value }, vnode) => {
1791
- if (vnode.props && looseEqual(vnode.props.value, value)) {
1792
- return { checked: true };
1793
- }
1794
- };
1795
- vModelCheckbox.getSSRProps = ({ value }, vnode) => {
1796
- if (isArray(value)) {
1797
- if (vnode.props && looseIndexOf(value, vnode.props.value) > -1) {
1798
- return { checked: true };
1799
- }
1800
- } else if (isSet(value)) {
1801
- if (vnode.props && value.has(vnode.props.value)) {
1802
- return { checked: true };
1803
- }
1804
- } else if (value) {
1805
- return { checked: true };
1806
- }
1807
- };
1808
- vModelDynamic.getSSRProps = (binding, vnode) => {
1809
- if (typeof vnode.type !== "string") {
1810
- return;
1811
- }
1812
- const modelToUse = resolveDynamicModel(
1813
- // resolveDynamicModel expects an uppercase tag name, but vnode.type is lowercase
1814
- vnode.type.toUpperCase(),
1815
- vnode.props && vnode.props.type
1816
- );
1817
- if (modelToUse.getSSRProps) {
1818
- return modelToUse.getSSRProps(binding, vnode);
1819
- }
1820
- };
1442
+ vModelText.getSSRProps = ({ value }) => ({ value });
1443
+ vModelRadio.getSSRProps = ({ value }, vnode) => {
1444
+ if (vnode.props && looseEqual(vnode.props.value, value)) return { checked: true };
1445
+ };
1446
+ vModelCheckbox.getSSRProps = ({ value }, vnode) => {
1447
+ if (isArray(value)) {
1448
+ if (vnode.props && looseIndexOf(value, vnode.props.value) > -1) return { checked: true };
1449
+ } else if (isSet(value)) {
1450
+ if (vnode.props && value.has(vnode.props.value)) return { checked: true };
1451
+ } else if (value) return { checked: true };
1452
+ };
1453
+ vModelDynamic.getSSRProps = (binding, vnode) => {
1454
+ if (typeof vnode.type !== "string") return;
1455
+ const modelToUse = resolveDynamicModel(vnode.type.toUpperCase(), vnode.props && vnode.props.type);
1456
+ if (modelToUse.getSSRProps) return modelToUse.getSSRProps(binding, vnode);
1457
+ };
1821
1458
  }
1822
-
1823
- const systemModifiers = ["ctrl", "shift", "alt", "meta"];
1459
+ //#endregion
1460
+ //#region packages/runtime-dom/src/directives/vOn.ts
1461
+ const systemModifiers = [
1462
+ "ctrl",
1463
+ "shift",
1464
+ "alt",
1465
+ "meta"
1466
+ ];
1824
1467
  const modifierGuards = {
1825
- stop: (e) => e.stopPropagation(),
1826
- prevent: (e) => e.preventDefault(),
1827
- self: (e) => e.target !== e.currentTarget,
1828
- ctrl: (e) => !e.ctrlKey,
1829
- shift: (e) => !e.shiftKey,
1830
- alt: (e) => !e.altKey,
1831
- meta: (e) => !e.metaKey,
1832
- left: (e) => "button" in e && e.button !== 0,
1833
- middle: (e) => "button" in e && e.button !== 1,
1834
- right: (e) => "button" in e && e.button !== 2,
1835
- exact: (e, modifiers) => systemModifiers.some((m) => e[`${m}Key`] && !modifiers.includes(m))
1468
+ stop: (e) => e.stopPropagation(),
1469
+ prevent: (e) => e.preventDefault(),
1470
+ self: (e) => e.target !== e.currentTarget,
1471
+ ctrl: (e) => !e.ctrlKey,
1472
+ shift: (e) => !e.shiftKey,
1473
+ alt: (e) => !e.altKey,
1474
+ meta: (e) => !e.metaKey,
1475
+ left: (e) => "button" in e && e.button !== 0,
1476
+ middle: (e) => "button" in e && e.button !== 1,
1477
+ right: (e) => "button" in e && e.button !== 2,
1478
+ exact: (e, modifiers) => systemModifiers.some((m) => e[`${m}Key`] && !modifiers.includes(m))
1836
1479
  };
1480
+ /**
1481
+ * @private
1482
+ */
1837
1483
  const withModifiers = (fn, modifiers) => {
1838
- const cache = fn._withMods || (fn._withMods = {});
1839
- const cacheKey = modifiers.join(".");
1840
- return cache[cacheKey] || (cache[cacheKey] = ((event, ...args) => {
1841
- for (let i = 0; i < modifiers.length; i++) {
1842
- const guard = modifierGuards[modifiers[i]];
1843
- if (guard && guard(event, modifiers)) return;
1844
- }
1845
- return fn(event, ...args);
1846
- }));
1484
+ if (!fn) return fn;
1485
+ const cache = fn._withMods || (fn._withMods = {});
1486
+ const cacheKey = modifiers.join(".");
1487
+ return cache[cacheKey] || (cache[cacheKey] = ((event, ...args) => {
1488
+ for (let i = 0; i < modifiers.length; i++) {
1489
+ const guard = modifierGuards[modifiers[i]];
1490
+ if (guard && guard(event, modifiers)) return;
1491
+ }
1492
+ return fn(event, ...args);
1493
+ }));
1847
1494
  };
1848
1495
  const keyNames = {
1849
- esc: "escape",
1850
- space: " ",
1851
- up: "arrow-up",
1852
- left: "arrow-left",
1853
- right: "arrow-right",
1854
- down: "arrow-down",
1855
- delete: "backspace"
1496
+ esc: "escape",
1497
+ space: " ",
1498
+ up: "arrow-up",
1499
+ left: "arrow-left",
1500
+ right: "arrow-right",
1501
+ down: "arrow-down",
1502
+ delete: "backspace"
1856
1503
  };
1504
+ /**
1505
+ * @private
1506
+ */
1857
1507
  const withKeys = (fn, modifiers) => {
1858
- const cache = fn._withKeys || (fn._withKeys = {});
1859
- const cacheKey = modifiers.join(".");
1860
- return cache[cacheKey] || (cache[cacheKey] = ((event) => {
1861
- if (!("key" in event)) {
1862
- return;
1863
- }
1864
- const eventKey = hyphenate(event.key);
1865
- if (modifiers.some(
1866
- (k) => k === eventKey || keyNames[k] === eventKey
1867
- )) {
1868
- return fn(event);
1869
- }
1870
- }));
1508
+ const cache = fn._withKeys || (fn._withKeys = {});
1509
+ const cacheKey = modifiers.join(".");
1510
+ return cache[cacheKey] || (cache[cacheKey] = ((event) => {
1511
+ if (!("key" in event)) return;
1512
+ const eventKey = hyphenate(event.key);
1513
+ if (modifiers.some((k) => k === eventKey || keyNames[k] === eventKey)) return fn(event);
1514
+ }));
1871
1515
  };
1872
-
1516
+ //#endregion
1517
+ //#region packages/runtime-dom/src/index.ts
1873
1518
  const rendererOptions = /* @__PURE__ */ extend({ patchProp }, nodeOps);
1874
1519
  let renderer;
1875
1520
  let enabledHydration = false;
1876
1521
  function ensureRenderer() {
1877
- return renderer || (renderer = createRenderer(rendererOptions));
1522
+ return renderer || (renderer = createRenderer(rendererOptions));
1878
1523
  }
1879
1524
  function ensureHydrationRenderer() {
1880
- renderer = enabledHydration ? renderer : createHydrationRenderer(rendererOptions);
1881
- enabledHydration = true;
1882
- return renderer;
1525
+ renderer = enabledHydration ? renderer : createHydrationRenderer(rendererOptions);
1526
+ enabledHydration = true;
1527
+ return renderer;
1883
1528
  }
1884
1529
  const render = ((...args) => {
1885
- ensureRenderer().render(...args);
1530
+ ensureRenderer().render(...args);
1886
1531
  });
1887
1532
  const hydrate = ((...args) => {
1888
- ensureHydrationRenderer().hydrate(...args);
1533
+ ensureHydrationRenderer().hydrate(...args);
1889
1534
  });
1890
1535
  const createApp = ((...args) => {
1891
- const app = ensureRenderer().createApp(...args);
1892
- if (!!(process.env.NODE_ENV !== "production")) {
1893
- injectNativeTagCheck(app);
1894
- injectCompilerOptionsCheck(app);
1895
- }
1896
- const { mount } = app;
1897
- app.mount = (containerOrSelector) => {
1898
- const container = normalizeContainer(containerOrSelector);
1899
- if (!container) return;
1900
- const component = app._component;
1901
- if (!isFunction(component) && !component.render && !component.template) {
1902
- component.template = container.innerHTML;
1903
- }
1904
- if (container.nodeType === 1) {
1905
- container.textContent = "";
1906
- }
1907
- const proxy = mount(container, false, resolveRootNamespace(container));
1908
- if (container instanceof Element) {
1909
- container.removeAttribute("v-cloak");
1910
- container.setAttribute("data-v-app", "");
1911
- }
1912
- return proxy;
1913
- };
1914
- return app;
1536
+ const app = ensureRenderer().createApp(...args);
1537
+ if (!!(process.env.NODE_ENV !== "production")) {
1538
+ injectNativeTagCheck(app);
1539
+ injectCompilerOptionsCheck(app);
1540
+ }
1541
+ const { mount } = app;
1542
+ app.mount = (containerOrSelector) => {
1543
+ const container = normalizeContainer(containerOrSelector);
1544
+ if (!container) return;
1545
+ const component = app._component;
1546
+ if (!isFunction(component) && !component.render && !component.template) component.template = container.innerHTML;
1547
+ if (container.nodeType === 1) container.textContent = "";
1548
+ const proxy = mount(container, false, resolveRootNamespace(container));
1549
+ if (container instanceof Element) {
1550
+ container.removeAttribute("v-cloak");
1551
+ container.setAttribute("data-v-app", "");
1552
+ }
1553
+ return proxy;
1554
+ };
1555
+ return app;
1915
1556
  });
1916
1557
  const createSSRApp = ((...args) => {
1917
- const app = ensureHydrationRenderer().createApp(...args);
1918
- if (!!(process.env.NODE_ENV !== "production")) {
1919
- injectNativeTagCheck(app);
1920
- injectCompilerOptionsCheck(app);
1921
- }
1922
- const { mount } = app;
1923
- app.mount = (containerOrSelector) => {
1924
- const container = normalizeContainer(containerOrSelector);
1925
- if (container) {
1926
- return mount(container, true, resolveRootNamespace(container));
1927
- }
1928
- };
1929
- return app;
1558
+ setIsHydratingEnabled(true);
1559
+ const app = ensureHydrationRenderer().createApp(...args);
1560
+ if (!!(process.env.NODE_ENV !== "production")) {
1561
+ injectNativeTagCheck(app);
1562
+ injectCompilerOptionsCheck(app);
1563
+ }
1564
+ const { mount } = app;
1565
+ app.mount = (containerOrSelector) => {
1566
+ const container = normalizeContainer(containerOrSelector);
1567
+ if (container) return mount(container, true, resolveRootNamespace(container));
1568
+ };
1569
+ return app;
1930
1570
  });
1931
1571
  function resolveRootNamespace(container) {
1932
- if (container instanceof SVGElement) {
1933
- return "svg";
1934
- }
1935
- if (typeof MathMLElement === "function" && container instanceof MathMLElement) {
1936
- return "mathml";
1937
- }
1572
+ if (container instanceof SVGElement) return "svg";
1573
+ if (typeof MathMLElement === "function" && container instanceof MathMLElement) return "mathml";
1938
1574
  }
1939
1575
  function injectNativeTagCheck(app) {
1940
- Object.defineProperty(app.config, "isNativeTag", {
1941
- value: (tag) => isHTMLTag(tag) || isSVGTag(tag) || isMathMLTag(tag),
1942
- writable: false
1943
- });
1576
+ Object.defineProperty(app.config, "isNativeTag", {
1577
+ value: (tag) => isHTMLTag(tag) || isSVGTag(tag) || isMathMLTag(tag),
1578
+ writable: false
1579
+ });
1944
1580
  }
1945
1581
  function injectCompilerOptionsCheck(app) {
1946
- if (isRuntimeOnly()) {
1947
- const isCustomElement = app.config.isCustomElement;
1948
- Object.defineProperty(app.config, "isCustomElement", {
1949
- get() {
1950
- return isCustomElement;
1951
- },
1952
- set() {
1953
- warn(
1954
- `The \`isCustomElement\` config option is deprecated. Use \`compilerOptions.isCustomElement\` instead.`
1955
- );
1956
- }
1957
- });
1958
- const compilerOptions = app.config.compilerOptions;
1959
- const msg = `The \`compilerOptions\` config option is only respected when using a build of Vue.js that includes the runtime compiler (aka "full build"). Since you are using the runtime-only build, \`compilerOptions\` must be passed to \`@vue/compiler-dom\` in the build setup instead.
1960
- - For vue-loader: pass it via vue-loader's \`compilerOptions\` loader option.
1961
- - For vue-cli: see https://cli.vuejs.org/guide/webpack.html#modifying-options-of-a-loader
1962
- - For vite: pass it via @vitejs/plugin-vue options. See https://github.com/vitejs/vite-plugin-vue/tree/main/packages/plugin-vue#example-for-passing-options-to-vuecompiler-sfc`;
1963
- Object.defineProperty(app.config, "compilerOptions", {
1964
- get() {
1965
- warn(msg);
1966
- return compilerOptions;
1967
- },
1968
- set() {
1969
- warn(msg);
1970
- }
1971
- });
1972
- }
1582
+ if (isRuntimeOnly()) {
1583
+ const isCustomElement = app.config.isCustomElement;
1584
+ Object.defineProperty(app.config, "isCustomElement", {
1585
+ get() {
1586
+ return isCustomElement;
1587
+ },
1588
+ set() {
1589
+ warn("The `isCustomElement` config option is deprecated. Use `compilerOptions.isCustomElement` instead.");
1590
+ }
1591
+ });
1592
+ const compilerOptions = app.config.compilerOptions;
1593
+ const msg = "The `compilerOptions` config option is only respected when using a build of Vue.js that includes the runtime compiler (aka \"full build\"). Since you are using the runtime-only build, `compilerOptions` must be passed to `@vue/compiler-dom` in the build setup instead.\n- For vue-loader: pass it via vue-loader's `compilerOptions` loader option.\n- For vue-cli: see https://cli.vuejs.org/guide/webpack.html#modifying-options-of-a-loader\n- For vite: pass it via @vitejs/plugin-vue options. See https://github.com/vitejs/vite-plugin-vue/tree/main/packages/plugin-vue#example-for-passing-options-to-vuecompiler-sfc";
1594
+ Object.defineProperty(app.config, "compilerOptions", {
1595
+ get() {
1596
+ warn(msg);
1597
+ return compilerOptions;
1598
+ },
1599
+ set() {
1600
+ warn(msg);
1601
+ }
1602
+ });
1603
+ }
1973
1604
  }
1605
+ /**
1606
+ * @internal
1607
+ */
1974
1608
  function normalizeContainer(container) {
1975
- if (isString(container)) {
1976
- const res = document.querySelector(container);
1977
- if (!!(process.env.NODE_ENV !== "production") && !res) {
1978
- warn(
1979
- `Failed to mount app: mount target selector "${container}" returned null.`
1980
- );
1981
- }
1982
- return res;
1983
- }
1984
- if (!!(process.env.NODE_ENV !== "production") && window.ShadowRoot && container instanceof window.ShadowRoot && container.mode === "closed") {
1985
- warn(
1986
- `mounting on a ShadowRoot with \`{mode: "closed"}\` may lead to unpredictable bugs`
1987
- );
1988
- }
1989
- return container;
1609
+ if (isString(container)) {
1610
+ const res = document.querySelector(container);
1611
+ if (!!(process.env.NODE_ENV !== "production") && !res) warn(`Failed to mount app: mount target selector "${container}" returned null.`);
1612
+ return res;
1613
+ }
1614
+ if (!!(process.env.NODE_ENV !== "production") && window.ShadowRoot && container instanceof window.ShadowRoot && container.mode === "closed") warn(`mounting on a ShadowRoot with \`{mode: "closed"}\` may lead to unpredictable bugs`);
1615
+ return container;
1990
1616
  }
1991
1617
  let ssrDirectiveInitialized = false;
1618
+ /**
1619
+ * @internal
1620
+ */
1992
1621
  const initDirectivesForSSR = () => {
1993
- if (!ssrDirectiveInitialized) {
1994
- ssrDirectiveInitialized = true;
1995
- initVModelForSSR();
1996
- initVShowForSSR();
1997
- }
1998
- } ;
1999
-
2000
- export { Transition, TransitionGroup, TransitionPropsValidators, VueElement, VueElementBase, baseApplyTranslation, baseUseCssVars, callPendingCbs, createApp, createSSRApp, defineCustomElement, defineSSRCustomElement, ensureHydrationRenderer, ensureRenderer, forceReflow, handleMovedChildren, hasCSSTransform, hydrate, initDirectivesForSSR, nodeOps, normalizeContainer, patchProp, patchStyle, render, resolveTransitionProps, setVarsOnNode, shouldSetAsProp, svgNS, unsafeToTrustedHTML, useCssModule, useCssVars, useHost, useShadowRoot, vModelCheckbox, vModelCheckboxInit, vModelCheckboxUpdate, vModelDynamic, getValue as vModelGetValue, vModelRadio, vModelSelect, vModelSelectInit, vModelSetSelected, vModelText, vModelTextInit, vModelTextUpdate, vShow, vShowHidden, vShowOriginalDisplay, withKeys, withModifiers, xlinkNS };
1622
+ if (!ssrDirectiveInitialized) {
1623
+ ssrDirectiveInitialized = true;
1624
+ initVModelForSSR();
1625
+ initVShowForSSR();
1626
+ }
1627
+ };
1628
+ //#endregion
1629
+ export { Transition, TransitionGroup, TransitionPropsValidators, VueElement, VueElementBase, baseApplyTranslation, baseUseCssVars, callPendingCbs, createApp, createSSRApp, defineCustomElement, defineSSRCustomElement, ensureHydrationRenderer, ensureRenderer, forceReflow, handleMovedChildren, hasCSSTransform, hydrate, initDirectivesForSSR, nodeOps, normalizeContainer, patchProp, patchStyle, render, resolveTransitionProps, setVarsOnNode, shouldSetAsProp, shouldSetAsPropForVueCE, svgNS, unsafeToTrustedHTML, useCssModule, useCssVars, useHost, useShadowRoot, vModelCheckbox, vModelCheckboxInit, vModelCheckboxUpdate, vModelDynamic, getValue as vModelGetValue, vModelRadio, vModelSelect, vModelSelectInit, vModelSetSelected, vModelText, vModelTextInit, vModelTextUpdate, vShow, vShowHidden, vShowOriginalDisplay, withKeys, withModifiers, xlinkNS };