runtime-dom.cjs.js 47 KB

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