runtime-dom.cjs.prod.js 48 KB

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