runtime-dom.esm-bundler.js 45 KB

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