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