runtime-dom.cjs.js 43 KB

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