@vue/runtime-dom 3.6.0-beta.1 → 3.6.0-beta.11

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