@vuact/runtime-dom 3.5.46-vuact.0 → 3.6.0-rc.17-vuact.0

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